fix(core): update
This commit is contained in:
parent
4c327e5e32
commit
7d64a2bc4d
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@apiclient.xyz/hetznercloud',
|
||||
version: '1.0.14',
|
||||
version: '1.0.15',
|
||||
description: 'an unofficial api client for the hetzner cloud api'
|
||||
}
|
||||
|
@ -11,8 +11,8 @@ export class HetznerAccount {
|
||||
return HetznerServer.getServers(this);
|
||||
}
|
||||
|
||||
public async getServerByLabel(labelArg: string, valueArg?: string) {
|
||||
return HetznerServer.getServerByLabel(this, labelArg, valueArg);
|
||||
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>) {
|
||||
|
@ -52,13 +52,21 @@ export class HetznerServer {
|
||||
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 results: HetznerServer[] = [];
|
||||
for (const server of servers) {
|
||||
if (valueArg ? server.data.labels[labelArg] === valueArg : server.data.labels[labelArg]) {
|
||||
return server;
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user