Compare commits

...

6 Commits

Author SHA1 Message Date
philkunz 18cbf8693f 1.0.15 2024-02-18 23:41:51 +01:00
philkunz 7d64a2bc4d fix(core): update 2024-02-18 23:41:50 +01:00
philkunz 4c327e5e32 1.0.14 2024-02-18 23:25:57 +01:00
philkunz a898928bd3 fix(core): update 2024-02-18 23:25:57 +01:00
philkunz aba8182422 1.0.13 2024-02-18 23:23:21 +01:00
philkunz 5412ab524b fix(core): update 2024-02-18 23:23:20 +01:00
4 changed files with 26 additions and 3 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@apiclient.xyz/hetznercloud",
"version": "1.0.12",
"version": "1.0.15",
"private": false,
"description": "an unofficial api client for the hetzner cloud api",
"main": "dist_ts/index.js",
+1 -1
View File
@@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@apiclient.xyz/hetznercloud',
version: '1.0.12',
version: '1.0.15',
description: 'an unofficial api client for the hetzner cloud api'
}
+4
View File
@@ -11,6 +11,10 @@ export class HetznerAccount {
return HetznerServer.getServers(this);
}
public async getServerByLabel(labelArg: string, labelObject: plugins.tsclass.typeFestOwn.SecondArgument<typeof HetznerServer.getServersByLabel>) {
return HetznerServer.getServersByLabel(this, labelObject);
}
public async createServer(optionsArg: plugins.tsclass.typeFestOwn.SecondArgument<typeof HetznerServer.create>) {
return HetznerServer.create(this, optionsArg);
}
+20 -1
View File
@@ -10,7 +10,8 @@ export class HetznerServer {
name: string;
type: types.THetznerCloudServerName;
location: types.THetznerCloudLocationName;
labels: {[key: string]: string},
labels?: {[key: string]: string},
userData?: string,
}
) {
const server = new HetznerServer(hetznerAccountRefArg);
@@ -23,6 +24,7 @@ export class HetznerServer {
start_after_create: true,
labels: optionsArg.labels || {} as any,
location: optionsArg.location,
user_data: optionsArg.userData || '',
public_net: {
enable_ipv4: true,
enable_ipv6: true,
@@ -50,6 +52,23 @@ export class HetznerServer {
return servers;
}
public static async getServersByLabel(hetznerAccountRefArg: HetznerAccount, labelObject: {[key: string]: string}) {
const servers = await HetznerServer.getServers(hetznerAccountRefArg);
const results: HetznerServer[] = [];
for (const server of servers) {
let isMatch = true;
for (const key in labelObject) {
if (server.data.labels[key] !== labelObject[key]) {
isMatch = false;
}
}
if (isMatch) {
results.push(server);
}
}
return results;
}
// INSTANCE
public hetznerAccountRef: HetznerAccount;
public data: types.IServer;