Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4e0dfb0356 | |||
| 84780647da | |||
| 1645d7881a | |||
| 88351db20f | |||
| 18cbf8693f | |||
| 7d64a2bc4d | |||
| 4c327e5e32 | |||
| a898928bd3 | |||
| aba8182422 | |||
| 5412ab524b |
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@apiclient.xyz/hetznercloud",
|
"name": "@apiclient.xyz/hetznercloud",
|
||||||
"version": "1.0.12",
|
"version": "1.0.17",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "an unofficial api client for the hetzner cloud api",
|
"description": "an unofficial api client for the hetzner cloud api",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@apiclient.xyz/hetznercloud',
|
name: '@apiclient.xyz/hetznercloud',
|
||||||
version: '1.0.12',
|
version: '1.0.17',
|
||||||
description: 'an unofficial api client for the hetzner cloud api'
|
description: 'an unofficial api client for the hetzner cloud api'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,10 @@ export class HetznerAccount {
|
|||||||
return HetznerServer.getServers(this);
|
return HetznerServer.getServers(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async getServersByLabel(labelObject: plugins.tsclass.typeFestOwn.SecondArgument<typeof HetznerServer.getServersByLabel>) {
|
||||||
|
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>) {
|
||||||
return HetznerServer.create(this, optionsArg);
|
return HetznerServer.create(this, optionsArg);
|
||||||
}
|
}
|
||||||
|
|||||||
+20
-1
@@ -10,7 +10,8 @@ export class HetznerServer {
|
|||||||
name: string;
|
name: string;
|
||||||
type: types.THetznerCloudServerName;
|
type: types.THetznerCloudServerName;
|
||||||
location: types.THetznerCloudLocationName;
|
location: types.THetznerCloudLocationName;
|
||||||
labels: {[key: string]: string},
|
labels?: {[key: string]: string},
|
||||||
|
userData?: string,
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
const server = new HetznerServer(hetznerAccountRefArg);
|
const server = new HetznerServer(hetznerAccountRefArg);
|
||||||
@@ -23,6 +24,7 @@ export class HetznerServer {
|
|||||||
start_after_create: true,
|
start_after_create: true,
|
||||||
labels: optionsArg.labels || {} as any,
|
labels: optionsArg.labels || {} as any,
|
||||||
location: optionsArg.location,
|
location: optionsArg.location,
|
||||||
|
user_data: optionsArg.userData || '',
|
||||||
public_net: {
|
public_net: {
|
||||||
enable_ipv4: true,
|
enable_ipv4: true,
|
||||||
enable_ipv6: true,
|
enable_ipv6: true,
|
||||||
@@ -50,6 +52,23 @@ export class HetznerServer {
|
|||||||
return servers;
|
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
|
// INSTANCE
|
||||||
public hetznerAccountRef: HetznerAccount;
|
public hetznerAccountRef: HetznerAccount;
|
||||||
public data: types.IServer;
|
public data: types.IServer;
|
||||||
|
|||||||
Reference in New Issue
Block a user