Compare commits
No commits in common. "master" and "v1.0.2" have entirely different histories.
@ -5,23 +5,10 @@
|
||||
"githost": "gitlab.com",
|
||||
"gitscope": "apiclient.xyz",
|
||||
"gitrepo": "hetznercloud",
|
||||
"description": "An unofficial TypeScript API client for the Hetzner Cloud API providing easy methods to manage servers, volumes, and firewalls.",
|
||||
"description": "an unofficial api client for the hetzner cloud api",
|
||||
"npmPackagename": "@apiclient.xyz/hetznercloud",
|
||||
"license": "MIT",
|
||||
"projectDomain": "apiclient.xyz",
|
||||
"keywords": [
|
||||
"Hetzner",
|
||||
"Cloud",
|
||||
"API",
|
||||
"TypeScript",
|
||||
"Client",
|
||||
"Servers",
|
||||
"Volumes",
|
||||
"Firewalls",
|
||||
"Automation",
|
||||
"DevOps",
|
||||
"Cloud Infrastructure"
|
||||
]
|
||||
"projectDomain": "apiclient.xyz"
|
||||
}
|
||||
},
|
||||
"npmci": {
|
||||
|
7
openapitools.json
Normal file
7
openapitools.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"$schema": "./node_modules/@openapitools/openapi-generator-cli/config.schema.json",
|
||||
"spaces": 2,
|
||||
"generator-cli": {
|
||||
"version": "7.2.0"
|
||||
}
|
||||
}
|
28
package.json
28
package.json
@ -1,8 +1,8 @@
|
||||
{
|
||||
"name": "@apiclient.xyz/hetznercloud",
|
||||
"version": "1.2.0",
|
||||
"version": "1.0.2",
|
||||
"private": false,
|
||||
"description": "An unofficial TypeScript API client for the Hetzner Cloud API providing easy methods to manage servers, volumes, and firewalls.",
|
||||
"description": "an unofficial api client for the hetzner cloud api",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
"type": "module",
|
||||
@ -12,22 +12,17 @@
|
||||
"test": "(tstest test/ --web)",
|
||||
"build": "(tsbuild --web --allowimplicitany)",
|
||||
"buildDocs": "(tsdoc)",
|
||||
"updateAPI": "openapi-typescript https://docs.hetzner.cloud/spec.json --output ts/openapi.spec.ts"
|
||||
"create": "openapi-generator-cli generate -i https://docs.hetzner.cloud/spec.json -g typescript-node -o ts_openapi"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@git.zone/tsbuild": "^2.1.25",
|
||||
"@git.zone/tsbundle": "^2.0.5",
|
||||
"@git.zone/tsrun": "^1.2.46",
|
||||
"@git.zone/tstest": "^1.0.44",
|
||||
"@push.rocks/qenv": "^6.0.5",
|
||||
"@push.rocks/tapbundle": "^5.0.15",
|
||||
"@types/node": "^20.11.22",
|
||||
"openapi-typescript": "^6.7.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"@push.rocks/smartrequest": "^2.0.21",
|
||||
"@tsclass/tsclass": "^4.0.52"
|
||||
"@types/node": "^20.8.7"
|
||||
},
|
||||
"dependencies": {},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://gitlab.com/apiclient.xyz/hetznercloud.git"
|
||||
@ -50,18 +45,5 @@
|
||||
"cli.js",
|
||||
"npmextra.json",
|
||||
"readme.md"
|
||||
],
|
||||
"keywords": [
|
||||
"Hetzner",
|
||||
"Cloud",
|
||||
"API",
|
||||
"TypeScript",
|
||||
"Client",
|
||||
"Servers",
|
||||
"Volumes",
|
||||
"Firewalls",
|
||||
"Automation",
|
||||
"DevOps",
|
||||
"Cloud Infrastructure"
|
||||
]
|
||||
}
|
||||
|
6788
pnpm-lock.yaml
generated
6788
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
284
readme.md
284
readme.md
@ -1,267 +1,31 @@
|
||||
# @apiclient.xyz/hetznercloud
|
||||
An unofficial API client for the Hetzner Cloud API
|
||||
an unofficial api client for the hetzner cloud api
|
||||
|
||||
## Install
|
||||
## Availabililty and Links
|
||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@apiclient.xyz/hetznercloud)
|
||||
* [gitlab.com (source)](https://gitlab.com/apiclient.xyz/hetznercloud)
|
||||
* [github.com (source mirror)](https://github.com/apiclient.xyz/hetznercloud)
|
||||
* [docs (typedoc)](https://apiclient.xyz.gitlab.io/hetznercloud/)
|
||||
|
||||
You can install the `@apiclient.xyz/hetznercloud` package via npm:
|
||||
## Status for master
|
||||
|
||||
```bash
|
||||
npm install @apiclient.xyz/hetznercloud
|
||||
```
|
||||
|
||||
Or using yarn:
|
||||
|
||||
```bash
|
||||
yarn add @apiclient.xyz/hetznercloud
|
||||
```
|
||||
Status Category | Status Badge
|
||||
-- | --
|
||||
GitLab Pipelines | [](https://lossless.cloud)
|
||||
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||
npm | [](https://lossless.cloud)
|
||||
Snyk | [](https://lossless.cloud)
|
||||
TypeScript Support | [](https://lossless.cloud)
|
||||
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
Code Style | [](https://lossless.cloud)
|
||||
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||
|
||||
## Usage
|
||||
Use TypeScript for best in class intellisense
|
||||
For further information read the linked docs at the top of this readme.
|
||||
|
||||
The `@apiclient.xyz/hetznercloud` package provides a modern approach to interact with the Hetzner Cloud API. Below are some detailed examples demonstrating the usage of this package for different scenarios like managing accounts, servers, volumes, and firewalls.
|
||||
|
||||
### Initial Setup
|
||||
|
||||
To begin using the package, you need to import it and initialize your Hetzner account with an API token:
|
||||
|
||||
```typescript
|
||||
import { HetznerAccount, HetznerServer, Volume, HetznerFirewall } from '@apiclient.xyz/hetznercloud';
|
||||
|
||||
// Initialize Hetzner account
|
||||
const myHetznerAccount = new HetznerAccount('yourHetznerApiToken');
|
||||
```
|
||||
|
||||
### Managing Servers
|
||||
|
||||
#### Creating a Server
|
||||
|
||||
You can create a new server using the `createServer` method in the `HetznerAccount` class. Provide the necessary options such as name, type, location, labels, and optional user data:
|
||||
|
||||
```typescript
|
||||
const newServer = await myHetznerAccount.createServer({
|
||||
name: 'my-server',
|
||||
type: 'cpx31',
|
||||
location: 'nbg1',
|
||||
labels: {
|
||||
purpose: 'test'
|
||||
},
|
||||
userData: '#!/bin/bash\necho Hello from your new server!'
|
||||
});
|
||||
|
||||
console.log('New server details:', newServer.data);
|
||||
```
|
||||
|
||||
#### Listing Servers
|
||||
|
||||
To list all servers in your account, you can use the `getServers` method:
|
||||
|
||||
```typescript
|
||||
const servers = await myHetznerAccount.getServers();
|
||||
console.log('Current servers:', servers);
|
||||
```
|
||||
|
||||
#### Filtering Servers by Labels
|
||||
|
||||
You can filter servers based on specific labels:
|
||||
|
||||
```typescript
|
||||
const filteredServers = await myHetznerAccount.getServersByLabel({ purpose: 'test' });
|
||||
console.log('Filtered servers:', filteredServers);
|
||||
```
|
||||
|
||||
#### Deleting a Server
|
||||
|
||||
To delete a server, call the `delete` method on the server instance:
|
||||
|
||||
```typescript
|
||||
const serverToDelete = filteredServers[0]; // Example, choose the first filtered server
|
||||
await serverToDelete.delete();
|
||||
console.log('Server deleted successfully');
|
||||
```
|
||||
|
||||
### Managing Volumes
|
||||
|
||||
#### Creating a Volume
|
||||
|
||||
To create a new volume, use the `Volume.create` method, passing in the necessary options:
|
||||
|
||||
```typescript
|
||||
const newVolume = await Volume.create(myHetznerAccount, {
|
||||
name: 'my-volume',
|
||||
size: 10, // Size in GB
|
||||
location: 'nbg1',
|
||||
labels: {
|
||||
purpose: 'test-volume'
|
||||
},
|
||||
server: newServer // Attach the volume to a specific server (newServer in this case)
|
||||
});
|
||||
|
||||
console.log('New volume details:', newVolume.data);
|
||||
```
|
||||
|
||||
#### Listing Volumes
|
||||
|
||||
You can list all volumes in your account with the `getVolumes` method:
|
||||
|
||||
```typescript
|
||||
const volumes = await Volume.getVolumes(myHetznerAccount);
|
||||
console.log('Current volumes:', volumes);
|
||||
```
|
||||
|
||||
#### Filtering Volumes by Labels
|
||||
|
||||
To filter volumes based on specific labels:
|
||||
|
||||
```typescript
|
||||
const filteredVolumes = await Volume.getVolumesByLabel(myHetznerAccount, { purpose: 'test-volume' });
|
||||
console.log('Filtered volumes:', filteredVolumes);
|
||||
```
|
||||
|
||||
#### Deleting a Volume
|
||||
|
||||
To delete a volume, call the `delete` method on the volume instance:
|
||||
|
||||
```typescript
|
||||
const volumeToDelete = filteredVolumes[0]; // Example, choose the first filtered volume
|
||||
await volumeToDelete.delete();
|
||||
console.log('Volume deleted successfully');
|
||||
```
|
||||
|
||||
### Managing Firewalls
|
||||
|
||||
#### Creating a Firewall
|
||||
|
||||
To create a new firewall, use the `create` method in the `HetznerFirewall` class:
|
||||
|
||||
```typescript
|
||||
const newFirewall = await HetznerFirewall.create(myHetznerAccount, {
|
||||
name: 'my-firewall',
|
||||
labels: {
|
||||
purpose: 'test-firewall'
|
||||
},
|
||||
rules: [
|
||||
{
|
||||
direction: 'in',
|
||||
protocol: 'tcp',
|
||||
port: '80',
|
||||
source_ips: ['0.0.0.0/0', '::/0']
|
||||
},
|
||||
{
|
||||
direction: 'in',
|
||||
protocol: 'tcp',
|
||||
port: '443',
|
||||
source_ips: ['0.0.0.0/0', '::/0']
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
console.log('New firewall details:', newFirewall.data);
|
||||
```
|
||||
|
||||
#### Listing Firewalls
|
||||
|
||||
To list all firewalls in your account:
|
||||
|
||||
```typescript
|
||||
const firewalls = await HetznerFirewall.getFirewalls(myHetznerAccount);
|
||||
console.log('Current firewalls:', firewalls);
|
||||
```
|
||||
|
||||
#### Filtering Firewalls by Labels
|
||||
|
||||
To filter firewalls based on specific labels:
|
||||
|
||||
```typescript
|
||||
const filteredFirewalls = await HetznerFirewall.getFirewallsByLabel(myHetznerAccount, { purpose: 'test-firewall' });
|
||||
console.log('Filtered firewalls:', filteredFirewalls);
|
||||
```
|
||||
|
||||
#### Deleting a Firewall
|
||||
|
||||
To delete a firewall, call the `delete` method on the firewall instance:
|
||||
|
||||
```typescript
|
||||
const firewallToDelete = filteredFirewalls[0]; // Example, choose the first filtered firewall
|
||||
await firewallToDelete.delete();
|
||||
console.log('Firewall deleted successfully');
|
||||
```
|
||||
|
||||
### Example: Full Lifecycle Management
|
||||
|
||||
Here is a complete example that demonstrates the full lifecycle of creating, listing, filtering, and deleting servers, volumes, and firewalls:
|
||||
|
||||
```typescript
|
||||
import { HetznerAccount, HetznerServer, Volume, HetznerFirewall } from '@apiclient.xyz/hetznercloud';
|
||||
|
||||
// Initialize Hetzner account
|
||||
const myHetznerAccount = new HetznerAccount('yourHetznerApiToken');
|
||||
|
||||
// Step 1: Create a new server
|
||||
const newServer = await myHetznerAccount.createServer({
|
||||
name: 'my-server',
|
||||
type: 'cpx31',
|
||||
location: 'nbg1',
|
||||
labels: { purpose: 'test' },
|
||||
userData: '#!/bin/bash\necho Hello from your new server!'
|
||||
});
|
||||
console.log('New server created:', newServer.data);
|
||||
|
||||
// Step 2: Create a new volume and attach it to the server
|
||||
const newVolume = await Volume.create(myHetznerAccount, {
|
||||
name: 'my-volume',
|
||||
size: 10, // GB
|
||||
location: 'nbg1',
|
||||
labels: { purpose: 'test-volume' },
|
||||
server: newServer
|
||||
});
|
||||
console.log('New volume created:', newVolume.data);
|
||||
|
||||
// Step 3: Create a new firewall and attach rules to it
|
||||
const newFirewall = await HetznerFirewall.create(myHetznerAccount, {
|
||||
name: 'my-firewall',
|
||||
labels: { purpose: 'test-firewall' },
|
||||
rules: [
|
||||
{ direction: 'in', protocol: 'tcp', port: '80', source_ips: ['0.0.0.0/0', '::/0'] },
|
||||
{ direction: 'in', protocol: 'tcp', port: '443', source_ips: ['0.0.0.0/0', '::/0'] }
|
||||
]
|
||||
});
|
||||
console.log('New firewall created:', newFirewall.data);
|
||||
|
||||
// Step 4: List all servers, volumes, and firewalls
|
||||
const servers = await myHetznerAccount.getServers();
|
||||
console.log('All servers:', servers);
|
||||
|
||||
const volumes = await Volume.getVolumes(myHetznerAccount);
|
||||
console.log('All volumes:', volumes);
|
||||
|
||||
const firewalls = await HetznerFirewall.getFirewalls(myHetznerAccount);
|
||||
console.log('All firewalls:', firewalls);
|
||||
|
||||
// Step 5: Filter servers, volumes, and firewalls by labels
|
||||
const filteredServers = await myHetznerAccount.getServersByLabel({ purpose: 'test' });
|
||||
console.log('Filtered servers:', filteredServers);
|
||||
|
||||
const filteredVolumes = await Volume.getVolumesByLabel(myHetznerAccount, { purpose: 'test-volume' });
|
||||
console.log('Filtered volumes:', filteredVolumes);
|
||||
|
||||
const filteredFirewalls = await HetznerFirewall.getFirewallsByLabel(myHetznerAccount, { purpose: 'test-firewall' });
|
||||
console.log('Filtered firewalls:', filteredFirewalls);
|
||||
|
||||
// Step 6: Cleanup - Delete created resources
|
||||
for (const server of filteredServers) {
|
||||
await server.delete();
|
||||
console.log('Server deleted:', server.data);
|
||||
}
|
||||
|
||||
for (const volume of filteredVolumes) {
|
||||
await volume.delete();
|
||||
console.log('Volume deleted:', volume.data);
|
||||
}
|
||||
|
||||
for (const firewall of filteredFirewalls) {
|
||||
await firewall.delete();
|
||||
console.log('Firewall deleted:', firewall.data);
|
||||
}
|
||||
```
|
||||
|
||||
This comprehensive example demonstrates how you can manage your Hetzner resources using the `@apiclient.xyz/hetznercloud` package efficiently and effectively.
|
||||
undefined
|
||||
## Legal
|
||||
> MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc)
|
||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||
|
44
test/test.ts
44
test/test.ts
@ -1,42 +1,8 @@
|
||||
import { expect, expectAsync, tap } from '@push.rocks/tapbundle';
|
||||
import * as hetznercloud from '../ts/index.js';
|
||||
import * as qenv from '@push.rocks/qenv';
|
||||
const testQenv = new qenv.Qenv('./', './.nogit/');
|
||||
import * as hetznercloud from '../ts/index.js'
|
||||
|
||||
let testAccount: hetznercloud.HetznerAccount;
|
||||
tap.test('first test', async () => {
|
||||
console.log(hetznercloud)
|
||||
})
|
||||
|
||||
tap.test('should create a valid hetzer account', async () => {
|
||||
testAccount = new hetznercloud.HetznerAccount(
|
||||
await testQenv.getEnvVarOnDemand('HETZNER_API_TOKEN')
|
||||
);
|
||||
expect(testAccount).toBeInstanceOf(hetznercloud.HetznerAccount);
|
||||
});
|
||||
|
||||
tap.test('should be able to list all servers', async () => {
|
||||
const servers = await testAccount.getServers();
|
||||
expect(servers).toBeArray();
|
||||
console.log(JSON.stringify(servers, null, 2));
|
||||
});
|
||||
|
||||
const testserver = tap.test('should be able to create a server', async (toolsArg) => {
|
||||
const newServer = await testAccount.createServer({
|
||||
name: 'testserver',
|
||||
location: 'nbg1',
|
||||
type: 'cpx41',
|
||||
labels: {
|
||||
servezoneId: 'testzone',
|
||||
},
|
||||
});
|
||||
expect(newServer).toBeInstanceOf(hetznercloud.HetznerServer);
|
||||
console.log(newServer);
|
||||
await toolsArg.delayFor(10000);
|
||||
return newServer;
|
||||
});
|
||||
|
||||
tap.test('should be able to delete a server', async () => {
|
||||
const testServer: hetznercloud.HetznerServer =
|
||||
await (testserver.testResultPromise as Promise<hetznercloud.HetznerServer>);
|
||||
await testServer.delete();
|
||||
});
|
||||
|
||||
tap.start();
|
||||
tap.start()
|
||||
|
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@apiclient.xyz/hetznercloud',
|
||||
version: '1.2.0',
|
||||
description: 'An unofficial TypeScript API client for the Hetzner Cloud API providing easy methods to manage servers, volumes, and firewalls.'
|
||||
version: '1.0.2',
|
||||
description: 'an unofficial api client for the hetzner cloud api'
|
||||
}
|
||||
|
@ -1,45 +0,0 @@
|
||||
import { HetznerServer } from './classes.server.js';
|
||||
import * as plugins from './hetznercloud.plugins.js';
|
||||
|
||||
export class HetznerAccount {
|
||||
public token: string;
|
||||
constructor(tokenArg: string) {
|
||||
this.token = tokenArg;
|
||||
}
|
||||
|
||||
public async getServers() {
|
||||
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>) {
|
||||
return HetznerServer.create(this, optionsArg);
|
||||
}
|
||||
|
||||
/**
|
||||
* request things from the hetzner API
|
||||
* @param methodArg
|
||||
* @param pathArg
|
||||
* @param payloadArg
|
||||
*/
|
||||
public request = async (methodArg: string, pathArg: string, payloadArg: any) => {
|
||||
const url = `https://api.hetzner.cloud/v1${pathArg}`;
|
||||
console.log(`Url: ${url}`);
|
||||
console.log(`Method: ${methodArg}`);
|
||||
console.log(`Payload: ${JSON.stringify(payloadArg, null, 2)}`);
|
||||
const response = await plugins.smartrequest.request(url, {
|
||||
method: methodArg,
|
||||
headers: {
|
||||
Authorization: `Bearer ${this.token}`,
|
||||
},
|
||||
requestBody: payloadArg,
|
||||
keepAlive: false,
|
||||
});
|
||||
console.log(response.statusCode);
|
||||
console.log(response.body);
|
||||
return response;
|
||||
}
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
// Hetzner Cloud Firewall Class
|
||||
import type { HetznerAccount } from './classes.account.js';
|
||||
import * as plugins from './hetznercloud.plugins.js';
|
||||
import * as types from './types.js';
|
||||
|
||||
export class HetznerFirewall {
|
||||
// STATIC
|
||||
public static create = async (
|
||||
hetznerAccountRefArg: HetznerAccount,
|
||||
optionsArg: {
|
||||
name: string;
|
||||
labels?: {[key: string]: string},
|
||||
rules: types.IFirewall['rules'],
|
||||
}
|
||||
) => {
|
||||
const firewall = new HetznerFirewall(hetznerAccountRefArg);
|
||||
|
||||
const createFirewallUrl = '/firewalls';
|
||||
const createFirewallPayload: types.TFirewallCreateRequestBody = {
|
||||
name: optionsArg.name,
|
||||
labels: optionsArg.labels || {} as any,
|
||||
rules: optionsArg.rules
|
||||
};
|
||||
const response = await firewall.hetznerAccountRef.request(
|
||||
'POST',
|
||||
createFirewallUrl,
|
||||
createFirewallPayload
|
||||
);
|
||||
firewall.data = (response.body as types.TFirewallCreateResponseBody).firewall;
|
||||
return firewall;
|
||||
}
|
||||
|
||||
public static getFirewalls = async (hetznerAccountRefArg: HetznerAccount) => {
|
||||
const firewallsGetUrl = '/firewalls';
|
||||
const response = await hetznerAccountRefArg.request('GET', firewallsGetUrl, {});
|
||||
const firewallsDataArray = (response.body as types.TFirewallsGetResponseBody).firewalls;
|
||||
const firewalls: HetznerFirewall[] = [];
|
||||
for (const firewallData of firewallsDataArray) {
|
||||
const firewall = new HetznerFirewall(hetznerAccountRefArg);
|
||||
firewall.data = firewallData;
|
||||
firewalls.push(firewall);
|
||||
}
|
||||
return firewalls;
|
||||
}
|
||||
|
||||
public static getFirewallsByLabel = async (hetznerAccountRefArg: HetznerAccount, labelObject: {[key: string]: string}) => {
|
||||
const firewalls = await HetznerFirewall.getFirewalls(hetznerAccountRefArg);
|
||||
const results: HetznerFirewall[] = [];
|
||||
for (const firewall of firewalls) {
|
||||
let isMatch = true;
|
||||
for (const key in labelObject) {
|
||||
if (firewall.data.labels[key] !== labelObject[key]) {
|
||||
isMatch = false;
|
||||
}
|
||||
}
|
||||
if (isMatch) {
|
||||
results.push(firewall);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
// INSTANCE
|
||||
public data: types.IFirewall;
|
||||
public hetznerAccountRef: HetznerAccount;
|
||||
|
||||
constructor(hetznerAccountRefArg: HetznerAccount) {
|
||||
this.hetznerAccountRef = hetznerAccountRefArg;
|
||||
}
|
||||
|
||||
public async delete() {
|
||||
await this.hetznerAccountRef.request('DELETE', `/firewalls/${this.data.id}`, {});
|
||||
}
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
import type { HetznerAccount } from './classes.account.js';
|
||||
import * as plugins from './hetznercloud.plugins.js';
|
||||
import * as types from './types.js';
|
||||
|
||||
export class HetznerServer {
|
||||
// STATIC
|
||||
public static async create(
|
||||
hetznerAccountRefArg: HetznerAccount,
|
||||
optionsArg: {
|
||||
name: string;
|
||||
type: types.THetznerCloudServerName;
|
||||
location: types.THetznerCloudLocationName;
|
||||
labels?: {[key: string]: string},
|
||||
userData?: string,
|
||||
}
|
||||
) {
|
||||
const server = new HetznerServer(hetznerAccountRefArg);
|
||||
|
||||
const createServerUrl = '/servers';
|
||||
const createServerPayload: types.TServerCreateRequestBody = {
|
||||
name: optionsArg.name,
|
||||
image: 'ubuntu-22.04',
|
||||
server_type: optionsArg.type,
|
||||
start_after_create: true,
|
||||
labels: optionsArg.labels || {} as any,
|
||||
location: optionsArg.location,
|
||||
user_data: optionsArg.userData || '',
|
||||
public_net: {
|
||||
enable_ipv4: true,
|
||||
enable_ipv6: true,
|
||||
},
|
||||
};
|
||||
const response = await server.hetznerAccountRef.request(
|
||||
'POST',
|
||||
createServerUrl,
|
||||
createServerPayload
|
||||
);
|
||||
server.data = (response.body as types.TServerCreateResponseBody).server;
|
||||
return server;
|
||||
}
|
||||
|
||||
public static async getServers(hetznerAccountRefArg: HetznerAccount) {
|
||||
const serversGetUrl = '/servers';
|
||||
const response = await hetznerAccountRefArg.request('GET', serversGetUrl, {});
|
||||
const serversDataArray = (response.body as types.TServersGetResponseBody).servers;
|
||||
const servers: HetznerServer[] = [];
|
||||
for (const serverData of serversDataArray) {
|
||||
const server = new HetznerServer(hetznerAccountRefArg);
|
||||
server.data = serverData;
|
||||
servers.push(server);
|
||||
}
|
||||
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;
|
||||
|
||||
constructor(hetznerAccountRefArg: HetznerAccount) {
|
||||
this.hetznerAccountRef = hetznerAccountRefArg;
|
||||
}
|
||||
|
||||
public async delete() {
|
||||
await this.hetznerAccountRef.request('DELETE', `/servers/${this.data.id}`, {});
|
||||
}
|
||||
}
|
@ -1,77 +0,0 @@
|
||||
import type { HetznerAccount } from './classes.account.js';
|
||||
import type { HetznerServer } from './classes.server.js';
|
||||
import * as plugins from './hetznercloud.plugins.js';
|
||||
import * as types from './types.js';
|
||||
|
||||
export class HetznerVolume {
|
||||
public static create = async (
|
||||
hetznerAccountRefArg: HetznerAccount,
|
||||
optionsArg: {
|
||||
name: string;
|
||||
size: number;
|
||||
location: types.THetznerCloudLocationName;
|
||||
labels?: {[key: string]: string},
|
||||
server: HetznerServer,
|
||||
}
|
||||
) => {
|
||||
const volume = new HetznerVolume(hetznerAccountRefArg);
|
||||
|
||||
const createVolumeUrl = '/volumes';
|
||||
const createVolumePayload: types.TVolumeCreateRequestBody = {
|
||||
name: optionsArg.name,
|
||||
size: optionsArg.size,
|
||||
location: optionsArg.location,
|
||||
labels: optionsArg.labels || {} as any,
|
||||
server: optionsArg.server.data.id,
|
||||
format: 'xfs'
|
||||
};
|
||||
const response = await volume.hetznerAccountRef.request(
|
||||
'POST',
|
||||
createVolumeUrl,
|
||||
createVolumePayload
|
||||
);
|
||||
volume.data = (response.body as types.TVolumeCreateResponseBody).volume;
|
||||
return volume;
|
||||
}
|
||||
|
||||
public static getVolumes = async (hetznerAccountRefArg: HetznerAccount) => {
|
||||
const volumesGetUrl = '/volumes';
|
||||
const response = await hetznerAccountRefArg.request('GET', volumesGetUrl, {});
|
||||
const volumesDataArray = (response.body as types.TVolumeGetResponseBody).volumes;
|
||||
const volumes: HetznerVolume[] = [];
|
||||
for (const volumeData of volumesDataArray) {
|
||||
const volume = new HetznerVolume(hetznerAccountRefArg);
|
||||
volume.data = volumeData;
|
||||
volumes.push(volume);
|
||||
}
|
||||
return volumes;
|
||||
}
|
||||
|
||||
public static getVolumesByLabel = async (hetznerAccountRefArg: HetznerAccount, labelObject: {[key: string]: string}) => {
|
||||
const volumes = await HetznerVolume.getVolumes(hetznerAccountRefArg);
|
||||
const results: HetznerVolume[] = [];
|
||||
for (const volume of volumes) {
|
||||
let isMatch = true;
|
||||
for (const key in labelObject) {
|
||||
if (volume.data.labels[key] !== labelObject[key]) {
|
||||
isMatch = false;
|
||||
}
|
||||
}
|
||||
if (isMatch) {
|
||||
results.push(volume);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
public data: types.IVolume;
|
||||
public hetznerAccountRef: HetznerAccount;
|
||||
|
||||
constructor(hetznerAccountRefArg: HetznerAccount) {
|
||||
this.hetznerAccountRef = hetznerAccountRefArg;
|
||||
}
|
||||
|
||||
public delete = async () => {
|
||||
await this.hetznerAccountRef.request('DELETE', `/volumes/${this.data.id}`, {});
|
||||
}
|
||||
}
|
@ -1,13 +1,4 @@
|
||||
// @push.rocks
|
||||
import * as smartrequest from '@push.rocks/smartrequest';
|
||||
|
||||
const removeme = {};
|
||||
export {
|
||||
smartrequest,
|
||||
}
|
||||
|
||||
// @tsclass scope
|
||||
import * as tsclass from '@tsclass/tsclass';
|
||||
|
||||
export {
|
||||
tsclass,
|
||||
removeme
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
export * from './classes.account.js';
|
||||
export * from './classes.server.js';
|
||||
export * from './classes.volume.js';
|
||||
export * from './classes.firewall.js';
|
||||
import * as plugins from './hetznercloud.plugins.js';
|
||||
|
||||
export let demoExport = 'Hi there! :) This is an exported string';
|
||||
|
25285
ts/openapi.spec.ts
25285
ts/openapi.spec.ts
File diff suppressed because it is too large
Load Diff
60
ts/types.ts
60
ts/types.ts
@ -1,60 +0,0 @@
|
||||
import * as plugins from './hetznercloud.plugins.js';
|
||||
import * as hetznerOpenapiSpec from './openapi.spec.js';
|
||||
|
||||
// datacenters
|
||||
export type TDatacenters = hetznerOpenapiSpec.paths['/datacenters']['get']['responses']['200']['content']['application/json'];
|
||||
|
||||
// servers
|
||||
export type IServer = hetznerOpenapiSpec.paths['/servers/{id}']['get']['responses']['200']['content']['application/json']['server'];
|
||||
export type TServersGetRequestBody = {};
|
||||
export type TServersGetResponseBody = hetznerOpenapiSpec.paths['/servers']['get']['responses']['200']['content']['application/json'];
|
||||
export type TServerCreateRequestBody = hetznerOpenapiSpec.paths['/servers']['post']['requestBody']['content']['application/json'];
|
||||
export type TServerCreateResponseBody = hetznerOpenapiSpec.paths['/servers']['post']['responses']['201']['content']['application/json'];
|
||||
export type TServerDeleteRequestBody = hetznerOpenapiSpec.paths['/servers/{id}']['delete'];
|
||||
|
||||
// server types
|
||||
export type THetznerCloudServerName =
|
||||
| 'cx11'
|
||||
| 'cx21'
|
||||
| 'cx31'
|
||||
| 'cx41'
|
||||
| 'cx51'
|
||||
| 'ccx11'
|
||||
| 'ccx21'
|
||||
| 'ccx31'
|
||||
| 'ccx41'
|
||||
| 'ccx51'
|
||||
| 'ccx13'
|
||||
| 'ccx23'
|
||||
| 'ccx33'
|
||||
| 'ccx43'
|
||||
| 'ccx53'
|
||||
| 'ccx63'
|
||||
| 'cpx11'
|
||||
| 'cpx21'
|
||||
| 'cpx31'
|
||||
| 'cpx41'
|
||||
| 'cpx51'
|
||||
| 'cpx61'
|
||||
| 'cpx70'
|
||||
| 'cpx71'
|
||||
| 'cpx90';
|
||||
|
||||
// location types
|
||||
export type THetznerCloudLocationName = 'fsn1' | 'nbg1' | 'hel1' | 'ash' | 'hil';
|
||||
|
||||
// volumes
|
||||
export type IVolume = hetznerOpenapiSpec.paths['/volumes/{id}']['get']['responses']['200']['content']['application/json']['volume'];
|
||||
export type TVolumeGetRequestBody = {};
|
||||
export type TVolumeGetResponseBody = hetznerOpenapiSpec.paths['/volumes']['get']['responses']['200']['content']['application/json'];
|
||||
export type TVolumeCreateRequestBody = hetznerOpenapiSpec.paths['/volumes']['post']['requestBody']['content']['application/json'];
|
||||
export type TVolumeCreateResponseBody = hetznerOpenapiSpec.paths['/volumes']['post']['responses']['201']['content']['application/json'];
|
||||
export type TVolumeDeleteRequestBody = hetznerOpenapiSpec.paths['/volumes/{id}']['delete'];
|
||||
|
||||
// firewalls
|
||||
export type IFirewall = hetznerOpenapiSpec.paths['/firewalls/{id}']['get']['responses']['200']['content']['application/json']['firewall'];
|
||||
export type TFirewallsGetRequestBody = {};
|
||||
export type TFirewallsGetResponseBody = hetznerOpenapiSpec.paths['/firewalls']['get']['responses']['200']['content']['application/json'];
|
||||
export type TFirewallCreateRequestBody = hetznerOpenapiSpec.paths['/firewalls']['post']['requestBody']['content']['application/json'];
|
||||
export type TFirewallCreateResponseBody = hetznerOpenapiSpec.paths['/firewalls']['post']['responses']['201']['content']['application/json'];
|
||||
export type TFirewallDeleteRequestBody = hetznerOpenapiSpec.paths['/firewalls/{id}']['delete'];
|
4
ts_openapi/.gitignore
vendored
Normal file
4
ts_openapi/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
wwwroot/*.js
|
||||
node_modules
|
||||
typings
|
||||
dist
|
23
ts_openapi/.openapi-generator-ignore
Normal file
23
ts_openapi/.openapi-generator-ignore
Normal file
@ -0,0 +1,23 @@
|
||||
# OpenAPI Generator Ignore
|
||||
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
|
||||
|
||||
# Use this file to prevent files from being overwritten by the generator.
|
||||
# The patterns follow closely to .gitignore or .dockerignore.
|
||||
|
||||
# As an example, the C# client generator defines ApiClient.cs.
|
||||
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
|
||||
#ApiClient.cs
|
||||
|
||||
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||
#foo/*/qux
|
||||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||
|
||||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||
#foo/**/qux
|
||||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||
|
||||
# You can also negate patterns with an exclamation (!).
|
||||
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||
#docs/*.md
|
||||
# Then explicitly reverse the ignore rule for a single file:
|
||||
#!docs/README.md
|
258
ts_openapi/.openapi-generator/FILES
Normal file
258
ts_openapi/.openapi-generator/FILES
Normal file
@ -0,0 +1,258 @@
|
||||
.gitignore
|
||||
.openapi-generator-ignore
|
||||
api.ts
|
||||
api/actionsApi.ts
|
||||
api/apis.ts
|
||||
api/certificateActionsApi.ts
|
||||
api/certificatesApi.ts
|
||||
api/datacentersApi.ts
|
||||
api/firewallActionsApi.ts
|
||||
api/firewallsApi.ts
|
||||
api/floatingIPActionsApi.ts
|
||||
api/floatingIPsApi.ts
|
||||
api/iSOsApi.ts
|
||||
api/imageActionsApi.ts
|
||||
api/imagesApi.ts
|
||||
api/loadBalancerActionsApi.ts
|
||||
api/loadBalancerTypesApi.ts
|
||||
api/loadBalancersApi.ts
|
||||
api/locationsApi.ts
|
||||
api/networkActionsApi.ts
|
||||
api/networksApi.ts
|
||||
api/placementGroupsApi.ts
|
||||
api/pricingApi.ts
|
||||
api/primaryIPActionsApi.ts
|
||||
api/primaryIPsApi.ts
|
||||
api/sSHKeysApi.ts
|
||||
api/serverActionsApi.ts
|
||||
api/serverTypesApi.ts
|
||||
api/serversApi.ts
|
||||
api/volumeActionsApi.ts
|
||||
api/volumesApi.ts
|
||||
git_push.sh
|
||||
model/action.ts
|
||||
model/actionError.ts
|
||||
model/actionResourcesInner.ts
|
||||
model/actionResponse.ts
|
||||
model/actionsResponse.ts
|
||||
model/actionsResponseMeta.ts
|
||||
model/actionsResponseMetaPagination.ts
|
||||
model/addDeleteRouteRequest.ts
|
||||
model/addSubnetRequest.ts
|
||||
model/addTargetRequest.ts
|
||||
model/addTargetRequestLabelSelector.ts
|
||||
model/addTargetRequestServer.ts
|
||||
model/addToPlacementGroupRequest.ts
|
||||
model/applyToResourcesRequest.ts
|
||||
model/assignFloatingIPRequest.ts
|
||||
model/assignPrimaryIPRequest.ts
|
||||
model/attachToNetworkRequest.ts
|
||||
model/attachVolumeRequest.ts
|
||||
model/certificate.ts
|
||||
model/certificateResponse.ts
|
||||
model/certificateStatus.ts
|
||||
model/certificateStatusError.ts
|
||||
model/certificateUsedByInner.ts
|
||||
model/certificatesResponse.ts
|
||||
model/changeDNSPTRRequest.ts
|
||||
model/changeIPRangeRequest.ts
|
||||
model/changeLoadbalancerDnsPtrRequest.ts
|
||||
model/changeProtectionRequest.ts
|
||||
model/changeProtectionRequest1.ts
|
||||
model/changeProtectionRequest2.ts
|
||||
model/changeTypeRequest.ts
|
||||
model/createCertificateRequest.ts
|
||||
model/createCertificateResponse.ts
|
||||
model/createFirewallRequest.ts
|
||||
model/createFirewallRequestApplyToInner.ts
|
||||
model/createFirewallRequestApplyToInnerLabelSelector.ts
|
||||
model/createFirewallRequestApplyToInnerServer.ts
|
||||
model/createFirewallResponse.ts
|
||||
model/createFloatingIPRequest.ts
|
||||
model/createImageRequest.ts
|
||||
model/createLoadBalancerRequest.ts
|
||||
model/createLoadBalancerRequestLabels.ts
|
||||
model/createNetworkRequest.ts
|
||||
model/createNetworkRequestSubnetsInner.ts
|
||||
model/createPlacementGroupRequest.ts
|
||||
model/createPlacementGroupResponse.ts
|
||||
model/createPrimaryIPRequest.ts
|
||||
model/createPrimaryIPResponse.ts
|
||||
model/createServerRequest.ts
|
||||
model/createServerRequestFirewallsInner.ts
|
||||
model/createServerRequestPublicNet.ts
|
||||
model/createServerResponse.ts
|
||||
model/createVolumeRequest.ts
|
||||
model/datacentersGet200Response.ts
|
||||
model/datacentersGet200ResponseDatacentersInner.ts
|
||||
model/datacentersGet200ResponseDatacentersInnerLocation.ts
|
||||
model/datacentersGet200ResponseDatacentersInnerServerTypes.ts
|
||||
model/datacentersIdGet200Response.ts
|
||||
model/deleteSubnetRequest.ts
|
||||
model/deprecationInfo.ts
|
||||
model/detachFromNetworkRequest.ts
|
||||
model/firewall.ts
|
||||
model/firewallAppliedToInner.ts
|
||||
model/firewallAppliedToInnerAppliedToResourcesInner.ts
|
||||
model/firewallAppliedToInnerAppliedToResourcesInnerServer.ts
|
||||
model/firewallAppliedToInnerLabelSelector.ts
|
||||
model/firewallApplyToResources.ts
|
||||
model/firewallApplyToResourcesLabelSelector.ts
|
||||
model/firewallApplyToResourcesServer.ts
|
||||
model/firewallRemoveFromResources.ts
|
||||
model/firewallResponse.ts
|
||||
model/firewallsResponse.ts
|
||||
model/floatingIpsGet200Response.ts
|
||||
model/floatingIpsGet200ResponseFloatingIpsInner.ts
|
||||
model/floatingIpsGet200ResponseFloatingIpsInnerDnsPtrInner.ts
|
||||
model/floatingIpsGet200ResponseFloatingIpsInnerHomeLocation.ts
|
||||
model/floatingIpsGet200ResponseFloatingIpsInnerProtection.ts
|
||||
model/floatingIpsIdActionsGet200Response.ts
|
||||
model/floatingIpsIdGet200Response.ts
|
||||
model/floatingIpsPost201Response.ts
|
||||
model/imagesGet200Response.ts
|
||||
model/imagesGet200ResponseImagesInner.ts
|
||||
model/imagesGet200ResponseImagesInnerCreatedFrom.ts
|
||||
model/imagesIdActionsChangeProtectionPostRequest.ts
|
||||
model/imagesIdGet200Response.ts
|
||||
model/isosGet200Response.ts
|
||||
model/isosGet200ResponseIsosInner.ts
|
||||
model/isosIdGet200Response.ts
|
||||
model/loadBalancerAlgorithm.ts
|
||||
model/loadBalancerService.ts
|
||||
model/loadBalancerServiceHTTP.ts
|
||||
model/loadBalancerServiceHTTP1.ts
|
||||
model/loadBalancerServiceHealthCheck.ts
|
||||
model/loadBalancerServiceHealthCheckHttp.ts
|
||||
model/loadBalancerTarget.ts
|
||||
model/loadBalancerTargetHealthStatusInner.ts
|
||||
model/loadBalancerTargetIP.ts
|
||||
model/loadBalancerTargetLabelSelector.ts
|
||||
model/loadBalancerTargetServer.ts
|
||||
model/loadBalancerTargetTarget.ts
|
||||
model/loadBalancerTypesGet200Response.ts
|
||||
model/loadBalancerTypesGet200ResponseLoadBalancerTypesInner.ts
|
||||
model/loadBalancerTypesGet200ResponseLoadBalancerTypesInnerPricesInner.ts
|
||||
model/loadBalancerTypesGet200ResponseLoadBalancerTypesInnerPricesInnerPriceHourly.ts
|
||||
model/loadBalancerTypesGet200ResponseLoadBalancerTypesInnerPricesInnerPriceMonthly.ts
|
||||
model/loadBalancerTypesIdGet200Response.ts
|
||||
model/loadBalancersGet200Response.ts
|
||||
model/loadBalancersGet200ResponseLoadBalancersInner.ts
|
||||
model/loadBalancersGet200ResponseLoadBalancersInnerAlgorithm.ts
|
||||
model/loadBalancersGet200ResponseLoadBalancersInnerLocation.ts
|
||||
model/loadBalancersGet200ResponseLoadBalancersInnerPrivateNetInner.ts
|
||||
model/loadBalancersGet200ResponseLoadBalancersInnerPublicNet.ts
|
||||
model/loadBalancersGet200ResponseLoadBalancersInnerPublicNetIpv4.ts
|
||||
model/loadBalancersGet200ResponseLoadBalancersInnerPublicNetIpv6.ts
|
||||
model/loadBalancersIdActionsAttachToNetworkPostRequest.ts
|
||||
model/loadBalancersIdActionsChangeAlgorithmPostRequest.ts
|
||||
model/loadBalancersIdActionsChangeProtectionPostRequest.ts
|
||||
model/loadBalancersIdActionsDeleteServicePostRequest.ts
|
||||
model/loadBalancersIdActionsDetachFromNetworkPostRequest.ts
|
||||
model/loadBalancersIdGet200Response.ts
|
||||
model/loadBalancersIdMetricsGet200Response.ts
|
||||
model/loadBalancersIdMetricsGet200ResponseMetrics.ts
|
||||
model/loadBalancersIdMetricsGet200ResponseMetricsTimeSeriesValue.ts
|
||||
model/loadBalancersIdMetricsGet200ResponseMetricsTimeSeriesValueValuesInnerInner.ts
|
||||
model/loadBalancersIdPutRequest.ts
|
||||
model/loadBalancersPost201Response.ts
|
||||
model/locationsGet200Response.ts
|
||||
model/locationsIdGet200Response.ts
|
||||
model/models.ts
|
||||
model/networksGet200Response.ts
|
||||
model/networksGet200ResponseNetworksInner.ts
|
||||
model/networksGet200ResponseNetworksInnerProtection.ts
|
||||
model/networksGet200ResponseNetworksInnerRoutesInner.ts
|
||||
model/networksGet200ResponseNetworksInnerSubnetsInner.ts
|
||||
model/networksPost201Response.ts
|
||||
model/nullableAction.ts
|
||||
model/placementGroup.ts
|
||||
model/placementGroupNullable.ts
|
||||
model/placementGroupResponse.ts
|
||||
model/placementGroupsResponse.ts
|
||||
model/pricingGet200Response.ts
|
||||
model/pricingGet200ResponsePricing.ts
|
||||
model/pricingGet200ResponsePricingFloatingIp.ts
|
||||
model/pricingGet200ResponsePricingFloatingIpPriceMonthly.ts
|
||||
model/pricingGet200ResponsePricingFloatingIpsInner.ts
|
||||
model/pricingGet200ResponsePricingFloatingIpsInnerPricesInner.ts
|
||||
model/pricingGet200ResponsePricingFloatingIpsInnerPricesInnerPriceMonthly.ts
|
||||
model/pricingGet200ResponsePricingImage.ts
|
||||
model/pricingGet200ResponsePricingLoadBalancerTypesInner.ts
|
||||
model/pricingGet200ResponsePricingLoadBalancerTypesInnerPricesInner.ts
|
||||
model/pricingGet200ResponsePricingLoadBalancerTypesInnerPricesInnerPriceHourly.ts
|
||||
model/pricingGet200ResponsePricingLoadBalancerTypesInnerPricesInnerPriceMonthly.ts
|
||||
model/pricingGet200ResponsePricingPrimaryIpsInner.ts
|
||||
model/pricingGet200ResponsePricingPrimaryIpsInnerPricesInner.ts
|
||||
model/pricingGet200ResponsePricingPrimaryIpsInnerPricesInnerPriceHourly.ts
|
||||
model/pricingGet200ResponsePricingPrimaryIpsInnerPricesInnerPriceMonthly.ts
|
||||
model/pricingGet200ResponsePricingServerBackup.ts
|
||||
model/pricingGet200ResponsePricingServerTypesInner.ts
|
||||
model/pricingGet200ResponsePricingServerTypesInnerPricesInner.ts
|
||||
model/pricingGet200ResponsePricingServerTypesInnerPricesInnerPriceHourly.ts
|
||||
model/pricingGet200ResponsePricingServerTypesInnerPricesInnerPriceMonthly.ts
|
||||
model/pricingGet200ResponsePricingTraffic.ts
|
||||
model/pricingGet200ResponsePricingVolume.ts
|
||||
model/primaryIP.ts
|
||||
model/primaryIPDatacenter.ts
|
||||
model/primaryIPDnsPtrInner.ts
|
||||
model/primaryIPResponse.ts
|
||||
model/primaryIPsResponse.ts
|
||||
model/rebuildServerRequest.ts
|
||||
model/removeFromResourcesRequest.ts
|
||||
model/removeTargetRequest.ts
|
||||
model/rule.ts
|
||||
model/serverPublicNetFirewall.ts
|
||||
model/serverTypesGet200Response.ts
|
||||
model/serverTypesGet200ResponseServerTypesInner.ts
|
||||
model/serverTypesIdGet200Response.ts
|
||||
model/serversGet200Response.ts
|
||||
model/serversGet200ResponseServersInner.ts
|
||||
model/serversGet200ResponseServersInnerDatacenter.ts
|
||||
model/serversGet200ResponseServersInnerImage.ts
|
||||
model/serversGet200ResponseServersInnerIso.ts
|
||||
model/serversGet200ResponseServersInnerPrivateNetInner.ts
|
||||
model/serversGet200ResponseServersInnerProtection.ts
|
||||
model/serversGet200ResponseServersInnerPublicNet.ts
|
||||
model/serversGet200ResponseServersInnerPublicNetIpv4.ts
|
||||
model/serversGet200ResponseServersInnerPublicNetIpv6.ts
|
||||
model/serversGet200ResponseServersInnerPublicNetIpv6DnsPtrInner.ts
|
||||
model/serversGet200ResponseServersInnerServerType.ts
|
||||
model/serversIdActionsAttachIsoPostRequest.ts
|
||||
model/serversIdActionsChangeAliasIpsPostRequest.ts
|
||||
model/serversIdActionsChangeDnsPtrPostRequest.ts
|
||||
model/serversIdActionsChangeProtectionPostRequest.ts
|
||||
model/serversIdActionsChangeTypePostRequest.ts
|
||||
model/serversIdActionsCreateImagePost201Response.ts
|
||||
model/serversIdActionsEnableRescuePost201Response.ts
|
||||
model/serversIdActionsEnableRescuePostRequest.ts
|
||||
model/serversIdActionsRebuildPost201Response.ts
|
||||
model/serversIdActionsRequestConsolePost201Response.ts
|
||||
model/serversIdDelete200Response.ts
|
||||
model/serversIdGet200Response.ts
|
||||
model/setRulesRequest.ts
|
||||
model/sshKeysGet200Response.ts
|
||||
model/sshKeysGet200ResponseSshKeysInner.ts
|
||||
model/sshKeysIdPutRequest.ts
|
||||
model/sshKeysPost201Response.ts
|
||||
model/sshKeysPostRequest.ts
|
||||
model/updateCertificateRequest.ts
|
||||
model/updateFirewallRequest.ts
|
||||
model/updateFloatingIPRequest.ts
|
||||
model/updateImageRequest.ts
|
||||
model/updateLoadBalancerService.ts
|
||||
model/updateLoadBalancerServiceHealthCheck.ts
|
||||
model/updateLoadBalancerServiceHealthCheckHttp.ts
|
||||
model/updateNetworkRequest.ts
|
||||
model/updateNetworkRequestLabels.ts
|
||||
model/updatePlacementGroupRequest.ts
|
||||
model/updatePrimaryIPRequest.ts
|
||||
model/updateServerRequest.ts
|
||||
model/updateVolumeRequest.ts
|
||||
model/volumesGet200Response.ts
|
||||
model/volumesGet200ResponseVolumesInner.ts
|
||||
model/volumesGet200ResponseVolumesInnerLocation.ts
|
||||
model/volumesIdActionsChangeProtectionPostRequest.ts
|
||||
model/volumesIdActionsResizePostRequest.ts
|
||||
model/volumesIdGet200Response.ts
|
||||
model/volumesPost201Response.ts
|
1
ts_openapi/.openapi-generator/VERSION
Normal file
1
ts_openapi/.openapi-generator/VERSION
Normal file
@ -0,0 +1 @@
|
||||
7.2.0
|
3
ts_openapi/api.ts
Normal file
3
ts_openapi/api.ts
Normal file
@ -0,0 +1,3 @@
|
||||
// This is the entrypoint for the package
|
||||
export * from './api/apis';
|
||||
export * from './model/models';
|
258
ts_openapi/api/actionsApi.ts
Normal file
258
ts_openapi/api/actionsApi.ts
Normal file
File diff suppressed because one or more lines are too long
66
ts_openapi/api/apis.ts
Normal file
66
ts_openapi/api/apis.ts
Normal file
@ -0,0 +1,66 @@
|
||||
export * from './actionsApi';
|
||||
import { ActionsApi } from './actionsApi';
|
||||
export * from './certificateActionsApi';
|
||||
import { CertificateActionsApi } from './certificateActionsApi';
|
||||
export * from './certificatesApi';
|
||||
import { CertificatesApi } from './certificatesApi';
|
||||
export * from './datacentersApi';
|
||||
import { DatacentersApi } from './datacentersApi';
|
||||
export * from './firewallActionsApi';
|
||||
import { FirewallActionsApi } from './firewallActionsApi';
|
||||
export * from './firewallsApi';
|
||||
import { FirewallsApi } from './firewallsApi';
|
||||
export * from './floatingIPActionsApi';
|
||||
import { FloatingIPActionsApi } from './floatingIPActionsApi';
|
||||
export * from './floatingIPsApi';
|
||||
import { FloatingIPsApi } from './floatingIPsApi';
|
||||
export * from './iSOsApi';
|
||||
import { ISOsApi } from './iSOsApi';
|
||||
export * from './imageActionsApi';
|
||||
import { ImageActionsApi } from './imageActionsApi';
|
||||
export * from './imagesApi';
|
||||
import { ImagesApi } from './imagesApi';
|
||||
export * from './loadBalancerActionsApi';
|
||||
import { LoadBalancerActionsApi } from './loadBalancerActionsApi';
|
||||
export * from './loadBalancerTypesApi';
|
||||
import { LoadBalancerTypesApi } from './loadBalancerTypesApi';
|
||||
export * from './loadBalancersApi';
|
||||
import { LoadBalancersApi } from './loadBalancersApi';
|
||||
export * from './locationsApi';
|
||||
import { LocationsApi } from './locationsApi';
|
||||
export * from './networkActionsApi';
|
||||
import { NetworkActionsApi } from './networkActionsApi';
|
||||
export * from './networksApi';
|
||||
import { NetworksApi } from './networksApi';
|
||||
export * from './placementGroupsApi';
|
||||
import { PlacementGroupsApi } from './placementGroupsApi';
|
||||
export * from './pricingApi';
|
||||
import { PricingApi } from './pricingApi';
|
||||
export * from './primaryIPActionsApi';
|
||||
import { PrimaryIPActionsApi } from './primaryIPActionsApi';
|
||||
export * from './primaryIPsApi';
|
||||
import { PrimaryIPsApi } from './primaryIPsApi';
|
||||
export * from './sSHKeysApi';
|
||||
import { SSHKeysApi } from './sSHKeysApi';
|
||||
export * from './serverActionsApi';
|
||||
import { ServerActionsApi } from './serverActionsApi';
|
||||
export * from './serverTypesApi';
|
||||
import { ServerTypesApi } from './serverTypesApi';
|
||||
export * from './serversApi';
|
||||
import { ServersApi } from './serversApi';
|
||||
export * from './volumeActionsApi';
|
||||
import { VolumeActionsApi } from './volumeActionsApi';
|
||||
export * from './volumesApi';
|
||||
import { VolumesApi } from './volumesApi';
|
||||
import * as http from 'http';
|
||||
|
||||
export class HttpError extends Error {
|
||||
constructor (public response: http.IncomingMessage, public body: any, public statusCode?: number) {
|
||||
super('HTTP request failed');
|
||||
this.name = 'HttpError';
|
||||
}
|
||||
}
|
||||
|
||||
export { RequestFile } from '../model/models';
|
||||
|
||||
export const APIS = [ActionsApi, CertificateActionsApi, CertificatesApi, DatacentersApi, FirewallActionsApi, FirewallsApi, FloatingIPActionsApi, FloatingIPsApi, ISOsApi, ImageActionsApi, ImagesApi, LoadBalancerActionsApi, LoadBalancerTypesApi, LoadBalancersApi, LocationsApi, NetworkActionsApi, NetworksApi, PlacementGroupsApi, PricingApi, PrimaryIPActionsApi, PrimaryIPsApi, SSHKeysApi, ServerActionsApi, ServerTypesApi, ServersApi, VolumeActionsApi, VolumesApi];
|
501
ts_openapi/api/certificateActionsApi.ts
Normal file
501
ts_openapi/api/certificateActionsApi.ts
Normal file
File diff suppressed because one or more lines are too long
471
ts_openapi/api/certificatesApi.ts
Normal file
471
ts_openapi/api/certificatesApi.ts
Normal file
File diff suppressed because one or more lines are too long
253
ts_openapi/api/datacentersApi.ts
Normal file
253
ts_openapi/api/datacentersApi.ts
Normal file
File diff suppressed because one or more lines are too long
654
ts_openapi/api/firewallActionsApi.ts
Normal file
654
ts_openapi/api/firewallActionsApi.ts
Normal file
File diff suppressed because one or more lines are too long
466
ts_openapi/api/firewallsApi.ts
Normal file
466
ts_openapi/api/firewallsApi.ts
Normal file
File diff suppressed because one or more lines are too long
727
ts_openapi/api/floatingIPActionsApi.ts
Normal file
727
ts_openapi/api/floatingIPActionsApi.ts
Normal file
File diff suppressed because one or more lines are too long
466
ts_openapi/api/floatingIPsApi.ts
Normal file
466
ts_openapi/api/floatingIPsApi.ts
Normal file
File diff suppressed because one or more lines are too long
258
ts_openapi/api/iSOsApi.ts
Normal file
258
ts_openapi/api/iSOsApi.ts
Normal file
File diff suppressed because one or more lines are too long
504
ts_openapi/api/imageActionsApi.ts
Normal file
504
ts_openapi/api/imageActionsApi.ts
Normal file
File diff suppressed because one or more lines are too long
422
ts_openapi/api/imagesApi.ts
Normal file
422
ts_openapi/api/imagesApi.ts
Normal file
File diff suppressed because one or more lines are too long
1398
ts_openapi/api/loadBalancerActionsApi.ts
Normal file
1398
ts_openapi/api/loadBalancerActionsApi.ts
Normal file
File diff suppressed because one or more lines are too long
248
ts_openapi/api/loadBalancerTypesApi.ts
Normal file
248
ts_openapi/api/loadBalancerTypesApi.ts
Normal file
File diff suppressed because one or more lines are too long
574
ts_openapi/api/loadBalancersApi.ts
Normal file
574
ts_openapi/api/loadBalancersApi.ts
Normal file
File diff suppressed because one or more lines are too long
253
ts_openapi/api/locationsApi.ts
Normal file
253
ts_openapi/api/locationsApi.ts
Normal file
File diff suppressed because one or more lines are too long
878
ts_openapi/api/networkActionsApi.ts
Normal file
878
ts_openapi/api/networkActionsApi.ts
Normal file
File diff suppressed because one or more lines are too long
460
ts_openapi/api/networksApi.ts
Normal file
460
ts_openapi/api/networksApi.ts
Normal file
File diff suppressed because one or more lines are too long
471
ts_openapi/api/placementGroupsApi.ts
Normal file
471
ts_openapi/api/placementGroupsApi.ts
Normal file
File diff suppressed because one or more lines are too long
160
ts_openapi/api/pricingApi.ts
Normal file
160
ts_openapi/api/pricingApi.ts
Normal file
File diff suppressed because one or more lines are too long
555
ts_openapi/api/primaryIPActionsApi.ts
Normal file
555
ts_openapi/api/primaryIPActionsApi.ts
Normal file
File diff suppressed because one or more lines are too long
471
ts_openapi/api/primaryIPsApi.ts
Normal file
471
ts_openapi/api/primaryIPsApi.ts
Normal file
File diff suppressed because one or more lines are too long
470
ts_openapi/api/sSHKeysApi.ts
Normal file
470
ts_openapi/api/sSHKeysApi.ts
Normal file
File diff suppressed because one or more lines are too long
2122
ts_openapi/api/serverActionsApi.ts
Normal file
2122
ts_openapi/api/serverActionsApi.ts
Normal file
File diff suppressed because one or more lines are too long
248
ts_openapi/api/serverTypesApi.ts
Normal file
248
ts_openapi/api/serverTypesApi.ts
Normal file
File diff suppressed because one or more lines are too long
588
ts_openapi/api/serversApi.ts
Normal file
588
ts_openapi/api/serversApi.ts
Normal file
File diff suppressed because one or more lines are too long
726
ts_openapi/api/volumeActionsApi.ts
Normal file
726
ts_openapi/api/volumeActionsApi.ts
Normal file
File diff suppressed because one or more lines are too long
471
ts_openapi/api/volumesApi.ts
Normal file
471
ts_openapi/api/volumesApi.ts
Normal file
File diff suppressed because one or more lines are too long
57
ts_openapi/git_push.sh
Normal file
57
ts_openapi/git_push.sh
Normal file
@ -0,0 +1,57 @@
|
||||
#!/bin/sh
|
||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||
#
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com"
|
||||
|
||||
git_user_id=$1
|
||||
git_repo_id=$2
|
||||
release_note=$3
|
||||
git_host=$4
|
||||
|
||||
if [ "$git_host" = "" ]; then
|
||||
git_host="github.com"
|
||||
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
|
||||
fi
|
||||
|
||||
if [ "$git_user_id" = "" ]; then
|
||||
git_user_id="GIT_USER_ID"
|
||||
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
|
||||
fi
|
||||
|
||||
if [ "$git_repo_id" = "" ]; then
|
||||
git_repo_id="GIT_REPO_ID"
|
||||
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
|
||||
fi
|
||||
|
||||
if [ "$release_note" = "" ]; then
|
||||
release_note="Minor update"
|
||||
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
|
||||
fi
|
||||
|
||||
# Initialize the local directory as a Git repository
|
||||
git init
|
||||
|
||||
# Adds the files in the local repository and stages them for commit.
|
||||
git add .
|
||||
|
||||
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
||||
git commit -m "$release_note"
|
||||
|
||||
# Sets the new remote
|
||||
git_remote=$(git remote)
|
||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||
|
||||
if [ "$GIT_TOKEN" = "" ]; then
|
||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
else
|
||||
git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
git pull origin master
|
||||
|
||||
# Pushes (Forces) the changes in the local repository up to the remote repository
|
||||
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
|
||||
git push origin master 2>&1 | grep -v 'To https'
|
103
ts_openapi/model/action.ts
Normal file
103
ts_openapi/model/action.ts
Normal file
File diff suppressed because one or more lines are too long
46
ts_openapi/model/actionError.ts
Normal file
46
ts_openapi/model/actionError.ts
Normal file
File diff suppressed because one or more lines are too long
43
ts_openapi/model/actionResourcesInner.ts
Normal file
43
ts_openapi/model/actionResourcesInner.ts
Normal file
File diff suppressed because one or more lines are too long
32
ts_openapi/model/actionResponse.ts
Normal file
32
ts_openapi/model/actionResponse.ts
Normal file
File diff suppressed because one or more lines are too long
39
ts_openapi/model/actionsResponse.ts
Normal file
39
ts_openapi/model/actionsResponse.ts
Normal file
File diff suppressed because one or more lines are too long
32
ts_openapi/model/actionsResponseMeta.ts
Normal file
32
ts_openapi/model/actionsResponseMeta.ts
Normal file
File diff suppressed because one or more lines are too long
79
ts_openapi/model/actionsResponseMetaPagination.ts
Normal file
79
ts_openapi/model/actionsResponseMetaPagination.ts
Normal file
File diff suppressed because one or more lines are too long
43
ts_openapi/model/addDeleteRouteRequest.ts
Normal file
43
ts_openapi/model/addDeleteRouteRequest.ts
Normal file
File diff suppressed because one or more lines are too long
68
ts_openapi/model/addSubnetRequest.ts
Normal file
68
ts_openapi/model/addSubnetRequest.ts
Normal file
File diff suppressed because one or more lines are too long
71
ts_openapi/model/addTargetRequest.ts
Normal file
71
ts_openapi/model/addTargetRequest.ts
Normal file
File diff suppressed because one or more lines are too long
37
ts_openapi/model/addTargetRequestLabelSelector.ts
Normal file
37
ts_openapi/model/addTargetRequestLabelSelector.ts
Normal file
File diff suppressed because one or more lines are too long
37
ts_openapi/model/addTargetRequestServer.ts
Normal file
37
ts_openapi/model/addTargetRequestServer.ts
Normal file
File diff suppressed because one or more lines are too long
34
ts_openapi/model/addToPlacementGroupRequest.ts
Normal file
34
ts_openapi/model/addToPlacementGroupRequest.ts
Normal file
File diff suppressed because one or more lines are too long
35
ts_openapi/model/applyToResourcesRequest.ts
Normal file
35
ts_openapi/model/applyToResourcesRequest.ts
Normal file
File diff suppressed because one or more lines are too long
37
ts_openapi/model/assignFloatingIPRequest.ts
Normal file
37
ts_openapi/model/assignFloatingIPRequest.ts
Normal file
File diff suppressed because one or more lines are too long
48
ts_openapi/model/assignPrimaryIPRequest.ts
Normal file
48
ts_openapi/model/assignPrimaryIPRequest.ts
Normal file
File diff suppressed because one or more lines are too long
52
ts_openapi/model/attachToNetworkRequest.ts
Normal file
52
ts_openapi/model/attachToNetworkRequest.ts
Normal file
File diff suppressed because one or more lines are too long
43
ts_openapi/model/attachVolumeRequest.ts
Normal file
43
ts_openapi/model/attachVolumeRequest.ts
Normal file
File diff suppressed because one or more lines are too long
138
ts_openapi/model/certificate.ts
Normal file
138
ts_openapi/model/certificate.ts
Normal file
File diff suppressed because one or more lines are too long
32
ts_openapi/model/certificateResponse.ts
Normal file
32
ts_openapi/model/certificateResponse.ts
Normal file
File diff suppressed because one or more lines are too long
66
ts_openapi/model/certificateStatus.ts
Normal file
66
ts_openapi/model/certificateStatus.ts
Normal file
File diff suppressed because one or more lines are too long
40
ts_openapi/model/certificateStatusError.ts
Normal file
40
ts_openapi/model/certificateStatusError.ts
Normal file
File diff suppressed because one or more lines are too long
43
ts_openapi/model/certificateUsedByInner.ts
Normal file
43
ts_openapi/model/certificateUsedByInner.ts
Normal file
File diff suppressed because one or more lines are too long
39
ts_openapi/model/certificatesResponse.ts
Normal file
39
ts_openapi/model/certificatesResponse.ts
Normal file
File diff suppressed because one or more lines are too long
43
ts_openapi/model/changeDNSPTRRequest.ts
Normal file
43
ts_openapi/model/changeDNSPTRRequest.ts
Normal file
File diff suppressed because one or more lines are too long
34
ts_openapi/model/changeIPRangeRequest.ts
Normal file
34
ts_openapi/model/changeIPRangeRequest.ts
Normal file
File diff suppressed because one or more lines are too long
43
ts_openapi/model/changeLoadbalancerDnsPtrRequest.ts
Normal file
43
ts_openapi/model/changeLoadbalancerDnsPtrRequest.ts
Normal file
File diff suppressed because one or more lines are too long
34
ts_openapi/model/changeProtectionRequest.ts
Normal file
34
ts_openapi/model/changeProtectionRequest.ts
Normal file
File diff suppressed because one or more lines are too long
34
ts_openapi/model/changeProtectionRequest1.ts
Normal file
34
ts_openapi/model/changeProtectionRequest1.ts
Normal file
File diff suppressed because one or more lines are too long
34
ts_openapi/model/changeProtectionRequest2.ts
Normal file
34
ts_openapi/model/changeProtectionRequest2.ts
Normal file
File diff suppressed because one or more lines are too long
34
ts_openapi/model/changeTypeRequest.ts
Normal file
34
ts_openapi/model/changeTypeRequest.ts
Normal file
File diff suppressed because one or more lines are too long
85
ts_openapi/model/createCertificateRequest.ts
Normal file
85
ts_openapi/model/createCertificateRequest.ts
Normal file
File diff suppressed because one or more lines are too long
39
ts_openapi/model/createCertificateResponse.ts
Normal file
39
ts_openapi/model/createCertificateResponse.ts
Normal file
File diff suppressed because one or more lines are too long
63
ts_openapi/model/createFirewallRequest.ts
Normal file
63
ts_openapi/model/createFirewallRequest.ts
Normal file
File diff suppressed because one or more lines are too long
54
ts_openapi/model/createFirewallRequestApplyToInner.ts
Normal file
54
ts_openapi/model/createFirewallRequestApplyToInner.ts
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
37
ts_openapi/model/createFirewallRequestApplyToInnerServer.ts
Normal file
37
ts_openapi/model/createFirewallRequestApplyToInnerServer.ts
Normal file
File diff suppressed because one or more lines are too long
39
ts_openapi/model/createFirewallResponse.ts
Normal file
39
ts_openapi/model/createFirewallResponse.ts
Normal file
File diff suppressed because one or more lines are too long
79
ts_openapi/model/createFloatingIPRequest.ts
Normal file
79
ts_openapi/model/createFloatingIPRequest.ts
Normal file
File diff suppressed because one or more lines are too long
56
ts_openapi/model/createImageRequest.ts
Normal file
56
ts_openapi/model/createImageRequest.ts
Normal file
File diff suppressed because one or more lines are too long
113
ts_openapi/model/createLoadBalancerRequest.ts
Normal file
113
ts_openapi/model/createLoadBalancerRequest.ts
Normal file
File diff suppressed because one or more lines are too long
37
ts_openapi/model/createLoadBalancerRequestLabels.ts
Normal file
37
ts_openapi/model/createLoadBalancerRequestLabels.ts
Normal file
File diff suppressed because one or more lines are too long
79
ts_openapi/model/createNetworkRequest.ts
Normal file
79
ts_openapi/model/createNetworkRequest.ts
Normal file
File diff suppressed because one or more lines are too long
68
ts_openapi/model/createNetworkRequestSubnetsInner.ts
Normal file
68
ts_openapi/model/createNetworkRequestSubnetsInner.ts
Normal file
File diff suppressed because one or more lines are too long
57
ts_openapi/model/createPlacementGroupRequest.ts
Normal file
57
ts_openapi/model/createPlacementGroupRequest.ts
Normal file
File diff suppressed because one or more lines are too long
39
ts_openapi/model/createPlacementGroupResponse.ts
Normal file
39
ts_openapi/model/createPlacementGroupResponse.ts
Normal file
File diff suppressed because one or more lines are too long
94
ts_openapi/model/createPrimaryIPRequest.ts
Normal file
94
ts_openapi/model/createPrimaryIPRequest.ts
Normal file
File diff suppressed because one or more lines are too long
39
ts_openapi/model/createPrimaryIPResponse.ts
Normal file
39
ts_openapi/model/createPrimaryIPResponse.ts
Normal file
File diff suppressed because one or more lines are too long
159
ts_openapi/model/createServerRequest.ts
Normal file
159
ts_openapi/model/createServerRequest.ts
Normal file
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user