fix(core): update
This commit is contained in:
parent
4c327e5e32
commit
7d64a2bc4d
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@apiclient.xyz/hetznercloud',
|
name: '@apiclient.xyz/hetznercloud',
|
||||||
version: '1.0.14',
|
version: '1.0.15',
|
||||||
description: 'an unofficial api client for the hetzner cloud api'
|
description: 'an unofficial api client for the hetzner cloud api'
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,8 @@ export class HetznerAccount {
|
|||||||
return HetznerServer.getServers(this);
|
return HetznerServer.getServers(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getServerByLabel(labelArg: string, valueArg?: string) {
|
public async getServerByLabel(labelArg: string, labelObject: plugins.tsclass.typeFestOwn.SecondArgument<typeof HetznerServer.getServersByLabel>) {
|
||||||
return HetznerServer.getServerByLabel(this, labelArg, valueArg);
|
return HetznerServer.getServersByLabel(this, labelObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async createServer(optionsArg: plugins.tsclass.typeFestOwn.SecondArgument<typeof HetznerServer.create>) {
|
public async createServer(optionsArg: plugins.tsclass.typeFestOwn.SecondArgument<typeof HetznerServer.create>) {
|
||||||
|
@ -52,13 +52,21 @@ export class HetznerServer {
|
|||||||
return servers;
|
return servers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async getServerByLabel(hetznerAccountRefArg: HetznerAccount, labelArg: string, valueArg?: string) {
|
public static async getServersByLabel(hetznerAccountRefArg: HetznerAccount, labelObject: {[key: string]: string}) {
|
||||||
const servers = await HetznerServer.getServers(hetznerAccountRefArg);
|
const servers = await HetznerServer.getServers(hetznerAccountRefArg);
|
||||||
|
const results: HetznerServer[] = [];
|
||||||
for (const server of servers) {
|
for (const server of servers) {
|
||||||
if (valueArg ? server.data.labels[labelArg] === valueArg : server.data.labels[labelArg]) {
|
let isMatch = true;
|
||||||
return server;
|
for (const key in labelObject) {
|
||||||
|
if (server.data.labels[key] !== labelObject[key]) {
|
||||||
|
isMatch = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isMatch) {
|
||||||
|
results.push(server);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
// INSTANCE
|
// INSTANCE
|
||||||
|
Loading…
Reference in New Issue
Block a user