575 lines
42 KiB
TypeScript
575 lines
42 KiB
TypeScript
|
/**
|
|||
|
* Hetzner Cloud API
|
|||
|
* This is the official documentation for the Hetzner Cloud API. ## Introduction The Hetzner Cloud API operates over HTTPS and uses JSON as its data format. The API is a RESTful API and utilizes HTTP methods and HTTP status codes to specify requests and responses. As an alternative to working directly with our API you may also consider to use: - Our CLI program [hcloud](https://github.com/hetznercloud/cli) - Our [library for Go](https://github.com/hetznercloud/hcloud-go) - Our [library for Python](https://github.com/hetznercloud/hcloud-python) Also you can find a [list of libraries, tools, and integrations on GitHub](https://github.com/hetznercloud/awesome-hcloud). If you are developing integrations based on our API and your product is Open Source you may be eligible for a free one time €50 (excl. VAT) credit on your account. Please contact us via the the support page on your Cloud Console and let us know the following: - The type of integration you would like to develop - Link to the GitHub repo you will use for the Project - Link to some other Open Source work you have already done (if you have done so) ## Getting Started To get started using the API you first need an API token. Sign in into the [Hetzner Cloud Console](https://console.hetzner.cloud/) choose a Project, go to `Security` → `API Tokens`, and generate a new token. Make sure to copy the token because it won’t be shown to you again. A token is bound to a Project, to interact with the API of another Project you have to create a new token inside the Project. Let’s say your new token is `LRK9DAWQ1ZAEFSrCNEEzLCUwhYX1U3g7wMg4dTlkkDC96fyDuyJ39nVbVjCKSDfj`. You’re now ready to do your first request against the API. To get a list of all Servers in your Project, issue the example request on the right side using [curl](https://curl.se/). Make sure to replace the token in the example command with the token you have just created. Since your Project probably does not contain any Servers yet, the example response will look like the response on the right side. We will almost always provide a resource root like `servers` inside the example response. A response can also contain a `meta` object with information like [Pagination](#pagination). **Example Request** ```bash curl -H \"Authorization: Bearer LRK9DAWQ1ZAEFSrCNEEzLCUwhYX1U3g7wMg4dTlkkDC96fyDuyJ39nVbVjCKSDfj\" \\ https://api.hetzner.cloud/v1/servers ``` **Example Response** ```json { \"servers\": [], \"meta\": { \"pagination\": { \"page\": 1, \"per_page\": 25, \"previous_page\": null, \"next_page\": null, \"last_page\": 1, \"total_entries\": 0 } } } ``` ## Authentication All requests to the Hetzner Cloud API must be authenticated via a API token. Include your secret API token in every request you send to the API with the `Authorization` HTTP header. To create a new API token for your Project, switch into the [Hetzner Cloud Console](https://console.hetzner.cloud/) choose a Project, go to `Security` → `API Tokens`, and generate a new token. **Example Authorization header** ```http Authorization: Bearer LRK9DAWQ1ZAEFSrCNEEzLCUwhYX1U3g7wMg4dTlkkDC96fyDuyJ39nVbVjCKSDfj ``` ## Errors Errors are indicated by HTTP status codes. Further, the response of the request which generated the error contains an error code, an error message, and, optionally, error details. The schema of the error details object depends on the error code. The error response contains the following keys: | Keys | Meaning | | --------- | --------------------------------------------------------------------- | | `code` | Short string indicating the type of error (machine-parsable) | | `message` | Textual description on what has gone wrong | | `details` | An object providing for details on the error (schema depends on code) | **Example response** ```json { \"error\": { \"code\": \"invalid_input\", \"message\": \"invalid input in field \'broken_field\': is too
|
|||
|
*
|
|||
|
* The version of the OpenAPI document: 1.0.0
|
|||
|
*
|
|||
|
*
|
|||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|||
|
* https://openapi-generator.tech
|
|||
|
* Do not edit the class manually.
|
|||
|
*/
|
|||
|
|
|||
|
|
|||
|
import localVarRequest from 'request';
|
|||
|
import http from 'http';
|
|||
|
|
|||
|
/* tslint:disable:no-unused-locals */
|
|||
|
import { CreateLoadBalancerRequest } from '../model/createLoadBalancerRequest';
|
|||
|
import { LoadBalancersGet200Response } from '../model/loadBalancersGet200Response';
|
|||
|
import { LoadBalancersIdGet200Response } from '../model/loadBalancersIdGet200Response';
|
|||
|
import { LoadBalancersIdMetricsGet200Response } from '../model/loadBalancersIdMetricsGet200Response';
|
|||
|
import { LoadBalancersIdPutRequest } from '../model/loadBalancersIdPutRequest';
|
|||
|
import { LoadBalancersPost201Response } from '../model/loadBalancersPost201Response';
|
|||
|
|
|||
|
import { ObjectSerializer, Authentication, VoidAuth, Interceptor } from '../model/models';
|
|||
|
import { HttpBasicAuth, HttpBearerAuth, ApiKeyAuth, OAuth } from '../model/models';
|
|||
|
|
|||
|
import { HttpError, RequestFile } from './apis';
|
|||
|
|
|||
|
let defaultBasePath = 'https://api.hetzner.cloud/v1';
|
|||
|
|
|||
|
// ===============================================
|
|||
|
// This file is autogenerated - Please do not edit
|
|||
|
// ===============================================
|
|||
|
|
|||
|
export enum LoadBalancersApiApiKeys {
|
|||
|
}
|
|||
|
|
|||
|
export class LoadBalancersApi {
|
|||
|
protected _basePath = defaultBasePath;
|
|||
|
protected _defaultHeaders : any = {};
|
|||
|
protected _useQuerystring : boolean = false;
|
|||
|
|
|||
|
protected authentications = {
|
|||
|
'default': <Authentication>new VoidAuth(),
|
|||
|
'APIToken': new HttpBearerAuth(),
|
|||
|
}
|
|||
|
|
|||
|
protected interceptors: Interceptor[] = [];
|
|||
|
|
|||
|
constructor(basePath?: string);
|
|||
|
constructor(basePathOrUsername: string, password?: string, basePath?: string) {
|
|||
|
if (password) {
|
|||
|
if (basePath) {
|
|||
|
this.basePath = basePath;
|
|||
|
}
|
|||
|
} else {
|
|||
|
if (basePathOrUsername) {
|
|||
|
this.basePath = basePathOrUsername
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
set useQuerystring(value: boolean) {
|
|||
|
this._useQuerystring = value;
|
|||
|
}
|
|||
|
|
|||
|
set basePath(basePath: string) {
|
|||
|
this._basePath = basePath;
|
|||
|
}
|
|||
|
|
|||
|
set defaultHeaders(defaultHeaders: any) {
|
|||
|
this._defaultHeaders = defaultHeaders;
|
|||
|
}
|
|||
|
|
|||
|
get defaultHeaders() {
|
|||
|
return this._defaultHeaders;
|
|||
|
}
|
|||
|
|
|||
|
get basePath() {
|
|||
|
return this._basePath;
|
|||
|
}
|
|||
|
|
|||
|
public setDefaultAuthentication(auth: Authentication) {
|
|||
|
this.authentications.default = auth;
|
|||
|
}
|
|||
|
|
|||
|
public setApiKey(key: LoadBalancersApiApiKeys, value: string) {
|
|||
|
(this.authentications as any)[LoadBalancersApiApiKeys[key]].apiKey = value;
|
|||
|
}
|
|||
|
|
|||
|
set accessToken(accessToken: string | (() => string)) {
|
|||
|
this.authentications.APIToken.accessToken = accessToken;
|
|||
|
}
|
|||
|
|
|||
|
public addInterceptor(interceptor: Interceptor) {
|
|||
|
this.interceptors.push(interceptor);
|
|||
|
}
|
|||
|
|
|||
|
/**
|
|||
|
* Gets all existing Load Balancers that you have available.
|
|||
|
* @summary Get all Load Balancers
|
|||
|
* @param sort Can be used multiple times.
|
|||
|
* @param name Can be used to filter resources by their name. The response will only contain the resources matching the specified name
|
|||
|
* @param labelSelector Can be used to filter resources by labels. The response will only contain resources matching the label selector.
|
|||
|
* @param page Page to load.
|
|||
|
* @param perPage Items to load per page.
|
|||
|
*/
|
|||
|
public async loadBalancersGet (sort?: 'id' | 'id:asc' | 'id:desc' | 'name' | 'name:asc' | 'name:desc' | 'created' | 'created:asc' | 'created:desc', name?: string, labelSelector?: string, page?: number, perPage?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: LoadBalancersGet200Response; }> {
|
|||
|
const localVarPath = this.basePath + '/load_balancers';
|
|||
|
let localVarQueryParameters: any = {};
|
|||
|
let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders);
|
|||
|
const produces = ['application/json'];
|
|||
|
// give precedence to 'application/json'
|
|||
|
if (produces.indexOf('application/json') >= 0) {
|
|||
|
localVarHeaderParams.Accept = 'application/json';
|
|||
|
} else {
|
|||
|
localVarHeaderParams.Accept = produces.join(',');
|
|||
|
}
|
|||
|
let localVarFormParams: any = {};
|
|||
|
|
|||
|
if (sort !== undefined) {
|
|||
|
localVarQueryParameters['sort'] = ObjectSerializer.serialize(sort, "'id' | 'id:asc' | 'id:desc' | 'name' | 'name:asc' | 'name:desc' | 'created' | 'created:asc' | 'created:desc'");
|
|||
|
}
|
|||
|
|
|||
|
if (name !== undefined) {
|
|||
|
localVarQueryParameters['name'] = ObjectSerializer.serialize(name, "string");
|
|||
|
}
|
|||
|
|
|||
|
if (labelSelector !== undefined) {
|
|||
|
localVarQueryParameters['label_selector'] = ObjectSerializer.serialize(labelSelector, "string");
|
|||
|
}
|
|||
|
|
|||
|
if (page !== undefined) {
|
|||
|
localVarQueryParameters['page'] = ObjectSerializer.serialize(page, "number");
|
|||
|
}
|
|||
|
|
|||
|
if (perPage !== undefined) {
|
|||
|
localVarQueryParameters['per_page'] = ObjectSerializer.serialize(perPage, "number");
|
|||
|
}
|
|||
|
|
|||
|
(<any>Object).assign(localVarHeaderParams, options.headers);
|
|||
|
|
|||
|
let localVarUseFormData = false;
|
|||
|
|
|||
|
let localVarRequestOptions: localVarRequest.Options = {
|
|||
|
method: 'GET',
|
|||
|
qs: localVarQueryParameters,
|
|||
|
headers: localVarHeaderParams,
|
|||
|
uri: localVarPath,
|
|||
|
useQuerystring: this._useQuerystring,
|
|||
|
json: true,
|
|||
|
};
|
|||
|
|
|||
|
let authenticationPromise = Promise.resolve();
|
|||
|
if (this.authentications.APIToken.accessToken) {
|
|||
|
authenticationPromise = authenticationPromise.then(() => this.authentications.APIToken.applyToRequest(localVarRequestOptions));
|
|||
|
}
|
|||
|
authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
|
|||
|
|
|||
|
let interceptorPromise = authenticationPromise;
|
|||
|
for (const interceptor of this.interceptors) {
|
|||
|
interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions));
|
|||
|
}
|
|||
|
|
|||
|
return interceptorPromise.then(() => {
|
|||
|
if (Object.keys(localVarFormParams).length) {
|
|||
|
if (localVarUseFormData) {
|
|||
|
(<any>localVarRequestOptions).formData = localVarFormParams;
|
|||
|
} else {
|
|||
|
localVarRequestOptions.form = localVarFormParams;
|
|||
|
}
|
|||
|
}
|
|||
|
return new Promise<{ response: http.IncomingMessage; body: LoadBalancersGet200Response; }>((resolve, reject) => {
|
|||
|
localVarRequest(localVarRequestOptions, (error, response, body) => {
|
|||
|
if (error) {
|
|||
|
reject(error);
|
|||
|
} else {
|
|||
|
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
|
|||
|
body = ObjectSerializer.deserialize(body, "LoadBalancersGet200Response");
|
|||
|
resolve({ response: response, body: body });
|
|||
|
} else {
|
|||
|
reject(new HttpError(response, body, response.statusCode));
|
|||
|
}
|
|||
|
}
|
|||
|
});
|
|||
|
});
|
|||
|
});
|
|||
|
}
|
|||
|
/**
|
|||
|
* Deletes a Load Balancer.
|
|||
|
* @summary Delete a Load Balancer
|
|||
|
* @param id ID of the Load Balancer
|
|||
|
*/
|
|||
|
public async loadBalancersIdDelete (id: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> {
|
|||
|
const localVarPath = this.basePath + '/load_balancers/{id}'
|
|||
|
.replace('{' + 'id' + '}', encodeURIComponent(String(id)));
|
|||
|
let localVarQueryParameters: any = {};
|
|||
|
let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders);
|
|||
|
let localVarFormParams: any = {};
|
|||
|
|
|||
|
// verify required parameter 'id' is not null or undefined
|
|||
|
if (id === null || id === undefined) {
|
|||
|
throw new Error('Required parameter id was null or undefined when calling loadBalancersIdDelete.');
|
|||
|
}
|
|||
|
|
|||
|
(<any>Object).assign(localVarHeaderParams, options.headers);
|
|||
|
|
|||
|
let localVarUseFormData = false;
|
|||
|
|
|||
|
let localVarRequestOptions: localVarRequest.Options = {
|
|||
|
method: 'DELETE',
|
|||
|
qs: localVarQueryParameters,
|
|||
|
headers: localVarHeaderParams,
|
|||
|
uri: localVarPath,
|
|||
|
useQuerystring: this._useQuerystring,
|
|||
|
json: true,
|
|||
|
};
|
|||
|
|
|||
|
let authenticationPromise = Promise.resolve();
|
|||
|
if (this.authentications.APIToken.accessToken) {
|
|||
|
authenticationPromise = authenticationPromise.then(() => this.authentications.APIToken.applyToRequest(localVarRequestOptions));
|
|||
|
}
|
|||
|
authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
|
|||
|
|
|||
|
let interceptorPromise = authenticationPromise;
|
|||
|
for (const interceptor of this.interceptors) {
|
|||
|
interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions));
|
|||
|
}
|
|||
|
|
|||
|
return interceptorPromise.then(() => {
|
|||
|
if (Object.keys(localVarFormParams).length) {
|
|||
|
if (localVarUseFormData) {
|
|||
|
(<any>localVarRequestOptions).formData = localVarFormParams;
|
|||
|
} else {
|
|||
|
localVarRequestOptions.form = localVarFormParams;
|
|||
|
}
|
|||
|
}
|
|||
|
return new Promise<{ response: http.IncomingMessage; body?: any; }>((resolve, reject) => {
|
|||
|
localVarRequest(localVarRequestOptions, (error, response, body) => {
|
|||
|
if (error) {
|
|||
|
reject(error);
|
|||
|
} else {
|
|||
|
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
|
|||
|
resolve({ response: response, body: body });
|
|||
|
} else {
|
|||
|
reject(new HttpError(response, body, response.statusCode));
|
|||
|
}
|
|||
|
}
|
|||
|
});
|
|||
|
});
|
|||
|
});
|
|||
|
}
|
|||
|
/**
|
|||
|
* Gets a specific Load Balancer object.
|
|||
|
* @summary Get a Load Balancer
|
|||
|
* @param id ID of the Load Balancer
|
|||
|
*/
|
|||
|
public async loadBalancersIdGet (id: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: LoadBalancersIdGet200Response; }> {
|
|||
|
const localVarPath = this.basePath + '/load_balancers/{id}'
|
|||
|
.replace('{' + 'id' + '}', encodeURIComponent(String(id)));
|
|||
|
let localVarQueryParameters: any = {};
|
|||
|
let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders);
|
|||
|
const produces = ['application/json'];
|
|||
|
// give precedence to 'application/json'
|
|||
|
if (produces.indexOf('application/json') >= 0) {
|
|||
|
localVarHeaderParams.Accept = 'application/json';
|
|||
|
} else {
|
|||
|
localVarHeaderParams.Accept = produces.join(',');
|
|||
|
}
|
|||
|
let localVarFormParams: any = {};
|
|||
|
|
|||
|
// verify required parameter 'id' is not null or undefined
|
|||
|
if (id === null || id === undefined) {
|
|||
|
throw new Error('Required parameter id was null or undefined when calling loadBalancersIdGet.');
|
|||
|
}
|
|||
|
|
|||
|
(<any>Object).assign(localVarHeaderParams, options.headers);
|
|||
|
|
|||
|
let localVarUseFormData = false;
|
|||
|
|
|||
|
let localVarRequestOptions: localVarRequest.Options = {
|
|||
|
method: 'GET',
|
|||
|
qs: localVarQueryParameters,
|
|||
|
headers: localVarHeaderParams,
|
|||
|
uri: localVarPath,
|
|||
|
useQuerystring: this._useQuerystring,
|
|||
|
json: true,
|
|||
|
};
|
|||
|
|
|||
|
let authenticationPromise = Promise.resolve();
|
|||
|
if (this.authentications.APIToken.accessToken) {
|
|||
|
authenticationPromise = authenticationPromise.then(() => this.authentications.APIToken.applyToRequest(localVarRequestOptions));
|
|||
|
}
|
|||
|
authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
|
|||
|
|
|||
|
let interceptorPromise = authenticationPromise;
|
|||
|
for (const interceptor of this.interceptors) {
|
|||
|
interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions));
|
|||
|
}
|
|||
|
|
|||
|
return interceptorPromise.then(() => {
|
|||
|
if (Object.keys(localVarFormParams).length) {
|
|||
|
if (localVarUseFormData) {
|
|||
|
(<any>localVarRequestOptions).formData = localVarFormParams;
|
|||
|
} else {
|
|||
|
localVarRequestOptions.form = localVarFormParams;
|
|||
|
}
|
|||
|
}
|
|||
|
return new Promise<{ response: http.IncomingMessage; body: LoadBalancersIdGet200Response; }>((resolve, reject) => {
|
|||
|
localVarRequest(localVarRequestOptions, (error, response, body) => {
|
|||
|
if (error) {
|
|||
|
reject(error);
|
|||
|
} else {
|
|||
|
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
|
|||
|
body = ObjectSerializer.deserialize(body, "LoadBalancersIdGet200Response");
|
|||
|
resolve({ response: response, body: body });
|
|||
|
} else {
|
|||
|
reject(new HttpError(response, body, response.statusCode));
|
|||
|
}
|
|||
|
}
|
|||
|
});
|
|||
|
});
|
|||
|
});
|
|||
|
}
|
|||
|
/**
|
|||
|
* You must specify the type of metric to get: `open_connections`, `connections_per_second`, `requests_per_second` or `bandwidth`. You can also specify more than one type by comma separation, e.g. `requests_per_second,bandwidth`. Depending on the type you will get different time series data: |Type | Timeseries | Unit | Description | |---- |------------|------|-------------| | open_connections | open_connections | number | Open connections | | connections_per_second | connections_per_second | connections/s | Connections per second | | requests_per_second | requests_per_second | requests/s | Requests per second | | bandwidth | bandwidth.in | bytes/s | Ingress bandwidth | || bandwidth.out | bytes/s | Egress bandwidth | Metrics are available for the last 30 days only. If you do not provide the step argument we will automatically adjust it so that 200 samples are returned. We limit the number of samples to a maximum of 500 and will adjust the step parameter accordingly.
|
|||
|
* @summary Get Metrics for a LoadBalancer
|
|||
|
* @param id ID of the Load Balancer
|
|||
|
* @param type Type of metrics to get
|
|||
|
* @param start Start of period to get Metrics for (in ISO-8601 format)
|
|||
|
* @param end End of period to get Metrics for (in ISO-8601 format)
|
|||
|
* @param step Resolution of results in seconds
|
|||
|
*/
|
|||
|
public async loadBalancersIdMetricsGet (id: number, type: 'open_connections' | 'connections_per_second' | 'requests_per_second' | 'bandwidth', start: string, end: string, step?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: LoadBalancersIdMetricsGet200Response; }> {
|
|||
|
const localVarPath = this.basePath + '/load_balancers/{id}/metrics'
|
|||
|
.replace('{' + 'id' + '}', encodeURIComponent(String(id)));
|
|||
|
let localVarQueryParameters: any = {};
|
|||
|
let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders);
|
|||
|
const produces = ['application/json'];
|
|||
|
// give precedence to 'application/json'
|
|||
|
if (produces.indexOf('application/json') >= 0) {
|
|||
|
localVarHeaderParams.Accept = 'application/json';
|
|||
|
} else {
|
|||
|
localVarHeaderParams.Accept = produces.join(',');
|
|||
|
}
|
|||
|
let localVarFormParams: any = {};
|
|||
|
|
|||
|
// verify required parameter 'id' is not null or undefined
|
|||
|
if (id === null || id === undefined) {
|
|||
|
throw new Error('Required parameter id was null or undefined when calling loadBalancersIdMetricsGet.');
|
|||
|
}
|
|||
|
|
|||
|
// verify required parameter 'type' is not null or undefined
|
|||
|
if (type === null || type === undefined) {
|
|||
|
throw new Error('Required parameter type was null or undefined when calling loadBalancersIdMetricsGet.');
|
|||
|
}
|
|||
|
|
|||
|
// verify required parameter 'start' is not null or undefined
|
|||
|
if (start === null || start === undefined) {
|
|||
|
throw new Error('Required parameter start was null or undefined when calling loadBalancersIdMetricsGet.');
|
|||
|
}
|
|||
|
|
|||
|
// verify required parameter 'end' is not null or undefined
|
|||
|
if (end === null || end === undefined) {
|
|||
|
throw new Error('Required parameter end was null or undefined when calling loadBalancersIdMetricsGet.');
|
|||
|
}
|
|||
|
|
|||
|
if (type !== undefined) {
|
|||
|
localVarQueryParameters['type'] = ObjectSerializer.serialize(type, "'open_connections' | 'connections_per_second' | 'requests_per_second' | 'bandwidth'");
|
|||
|
}
|
|||
|
|
|||
|
if (start !== undefined) {
|
|||
|
localVarQueryParameters['start'] = ObjectSerializer.serialize(start, "string");
|
|||
|
}
|
|||
|
|
|||
|
if (end !== undefined) {
|
|||
|
localVarQueryParameters['end'] = ObjectSerializer.serialize(end, "string");
|
|||
|
}
|
|||
|
|
|||
|
if (step !== undefined) {
|
|||
|
localVarQueryParameters['step'] = ObjectSerializer.serialize(step, "string");
|
|||
|
}
|
|||
|
|
|||
|
(<any>Object).assign(localVarHeaderParams, options.headers);
|
|||
|
|
|||
|
let localVarUseFormData = false;
|
|||
|
|
|||
|
let localVarRequestOptions: localVarRequest.Options = {
|
|||
|
method: 'GET',
|
|||
|
qs: localVarQueryParameters,
|
|||
|
headers: localVarHeaderParams,
|
|||
|
uri: localVarPath,
|
|||
|
useQuerystring: this._useQuerystring,
|
|||
|
json: true,
|
|||
|
};
|
|||
|
|
|||
|
let authenticationPromise = Promise.resolve();
|
|||
|
if (this.authentications.APIToken.accessToken) {
|
|||
|
authenticationPromise = authenticationPromise.then(() => this.authentications.APIToken.applyToRequest(localVarRequestOptions));
|
|||
|
}
|
|||
|
authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
|
|||
|
|
|||
|
let interceptorPromise = authenticationPromise;
|
|||
|
for (const interceptor of this.interceptors) {
|
|||
|
interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions));
|
|||
|
}
|
|||
|
|
|||
|
return interceptorPromise.then(() => {
|
|||
|
if (Object.keys(localVarFormParams).length) {
|
|||
|
if (localVarUseFormData) {
|
|||
|
(<any>localVarRequestOptions).formData = localVarFormParams;
|
|||
|
} else {
|
|||
|
localVarRequestOptions.form = localVarFormParams;
|
|||
|
}
|
|||
|
}
|
|||
|
return new Promise<{ response: http.IncomingMessage; body: LoadBalancersIdMetricsGet200Response; }>((resolve, reject) => {
|
|||
|
localVarRequest(localVarRequestOptions, (error, response, body) => {
|
|||
|
if (error) {
|
|||
|
reject(error);
|
|||
|
} else {
|
|||
|
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
|
|||
|
body = ObjectSerializer.deserialize(body, "LoadBalancersIdMetricsGet200Response");
|
|||
|
resolve({ response: response, body: body });
|
|||
|
} else {
|
|||
|
reject(new HttpError(response, body, response.statusCode));
|
|||
|
}
|
|||
|
}
|
|||
|
});
|
|||
|
});
|
|||
|
});
|
|||
|
}
|
|||
|
/**
|
|||
|
* Updates a Load Balancer. You can update a Load Balancer’s name and a Load Balancer’s labels. Note that when updating labels, the Load Balancer’s current set of labels will be replaced with the labels provided in the request body. So, for example, if you want to add a new label, you have to provide all existing labels plus the new label in the request body. Note: if the Load Balancer object changes during the request, the response will be a “conflict” error.
|
|||
|
* @summary Update a Load Balancer
|
|||
|
* @param id ID of the Load Balancer
|
|||
|
* @param loadBalancersIdPutRequest
|
|||
|
*/
|
|||
|
public async loadBalancersIdPut (id: number, loadBalancersIdPutRequest?: LoadBalancersIdPutRequest, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: LoadBalancersIdGet200Response; }> {
|
|||
|
const localVarPath = this.basePath + '/load_balancers/{id}'
|
|||
|
.replace('{' + 'id' + '}', encodeURIComponent(String(id)));
|
|||
|
let localVarQueryParameters: any = {};
|
|||
|
let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders);
|
|||
|
const produces = ['application/json'];
|
|||
|
// give precedence to 'application/json'
|
|||
|
if (produces.indexOf('application/json') >= 0) {
|
|||
|
localVarHeaderParams.Accept = 'application/json';
|
|||
|
} else {
|
|||
|
localVarHeaderParams.Accept = produces.join(',');
|
|||
|
}
|
|||
|
let localVarFormParams: any = {};
|
|||
|
|
|||
|
// verify required parameter 'id' is not null or undefined
|
|||
|
if (id === null || id === undefined) {
|
|||
|
throw new Error('Required parameter id was null or undefined when calling loadBalancersIdPut.');
|
|||
|
}
|
|||
|
|
|||
|
(<any>Object).assign(localVarHeaderParams, options.headers);
|
|||
|
|
|||
|
let localVarUseFormData = false;
|
|||
|
|
|||
|
let localVarRequestOptions: localVarRequest.Options = {
|
|||
|
method: 'PUT',
|
|||
|
qs: localVarQueryParameters,
|
|||
|
headers: localVarHeaderParams,
|
|||
|
uri: localVarPath,
|
|||
|
useQuerystring: this._useQuerystring,
|
|||
|
json: true,
|
|||
|
body: ObjectSerializer.serialize(loadBalancersIdPutRequest, "LoadBalancersIdPutRequest")
|
|||
|
};
|
|||
|
|
|||
|
let authenticationPromise = Promise.resolve();
|
|||
|
if (this.authentications.APIToken.accessToken) {
|
|||
|
authenticationPromise = authenticationPromise.then(() => this.authentications.APIToken.applyToRequest(localVarRequestOptions));
|
|||
|
}
|
|||
|
authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
|
|||
|
|
|||
|
let interceptorPromise = authenticationPromise;
|
|||
|
for (const interceptor of this.interceptors) {
|
|||
|
interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions));
|
|||
|
}
|
|||
|
|
|||
|
return interceptorPromise.then(() => {
|
|||
|
if (Object.keys(localVarFormParams).length) {
|
|||
|
if (localVarUseFormData) {
|
|||
|
(<any>localVarRequestOptions).formData = localVarFormParams;
|
|||
|
} else {
|
|||
|
localVarRequestOptions.form = localVarFormParams;
|
|||
|
}
|
|||
|
}
|
|||
|
return new Promise<{ response: http.IncomingMessage; body: LoadBalancersIdGet200Response; }>((resolve, reject) => {
|
|||
|
localVarRequest(localVarRequestOptions, (error, response, body) => {
|
|||
|
if (error) {
|
|||
|
reject(error);
|
|||
|
} else {
|
|||
|
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
|
|||
|
body = ObjectSerializer.deserialize(body, "LoadBalancersIdGet200Response");
|
|||
|
resolve({ response: response, body: body });
|
|||
|
} else {
|
|||
|
reject(new HttpError(response, body, response.statusCode));
|
|||
|
}
|
|||
|
}
|
|||
|
});
|
|||
|
});
|
|||
|
});
|
|||
|
}
|
|||
|
/**
|
|||
|
* Creates a Load Balancer. #### Call specific error codes | Code | Description | |-----------------------------------------|-------------------------------------------------------------------------------------------------------| | `cloud_resource_ip_not_allowed` | The IP you are trying to add as a target belongs to a Hetzner Cloud resource | | `ip_not_owned` | The IP is not owned by the owner of the project of the Load Balancer | | `load_balancer_not_attached_to_network` | The Load Balancer is not attached to a network | | `robot_unavailable` | Robot was not available. The caller may retry the operation after a short delay. | | `server_not_attached_to_network` | The server you are trying to add as a target is not attached to the same network as the Load Balancer | | `source_port_already_used` | The source port you are trying to add is already in use | | `target_already_defined` | The Load Balancer target you are trying to define is already defined |
|
|||
|
* @summary Create a Load Balancer
|
|||
|
* @param createLoadBalancerRequest
|
|||
|
*/
|
|||
|
public async loadBalancersPost (createLoadBalancerRequest?: CreateLoadBalancerRequest, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: LoadBalancersPost201Response; }> {
|
|||
|
const localVarPath = this.basePath + '/load_balancers';
|
|||
|
let localVarQueryParameters: any = {};
|
|||
|
let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders);
|
|||
|
const produces = ['application/json'];
|
|||
|
// give precedence to 'application/json'
|
|||
|
if (produces.indexOf('application/json') >= 0) {
|
|||
|
localVarHeaderParams.Accept = 'application/json';
|
|||
|
} else {
|
|||
|
localVarHeaderParams.Accept = produces.join(',');
|
|||
|
}
|
|||
|
let localVarFormParams: any = {};
|
|||
|
|
|||
|
(<any>Object).assign(localVarHeaderParams, options.headers);
|
|||
|
|
|||
|
let localVarUseFormData = false;
|
|||
|
|
|||
|
let localVarRequestOptions: localVarRequest.Options = {
|
|||
|
method: 'POST',
|
|||
|
qs: localVarQueryParameters,
|
|||
|
headers: localVarHeaderParams,
|
|||
|
uri: localVarPath,
|
|||
|
useQuerystring: this._useQuerystring,
|
|||
|
json: true,
|
|||
|
body: ObjectSerializer.serialize(createLoadBalancerRequest, "CreateLoadBalancerRequest")
|
|||
|
};
|
|||
|
|
|||
|
let authenticationPromise = Promise.resolve();
|
|||
|
if (this.authentications.APIToken.accessToken) {
|
|||
|
authenticationPromise = authenticationPromise.then(() => this.authentications.APIToken.applyToRequest(localVarRequestOptions));
|
|||
|
}
|
|||
|
authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
|
|||
|
|
|||
|
let interceptorPromise = authenticationPromise;
|
|||
|
for (const interceptor of this.interceptors) {
|
|||
|
interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions));
|
|||
|
}
|
|||
|
|
|||
|
return interceptorPromise.then(() => {
|
|||
|
if (Object.keys(localVarFormParams).length) {
|
|||
|
if (localVarUseFormData) {
|
|||
|
(<any>localVarRequestOptions).formData = localVarFormParams;
|
|||
|
} else {
|
|||
|
localVarRequestOptions.form = localVarFormParams;
|
|||
|
}
|
|||
|
}
|
|||
|
return new Promise<{ response: http.IncomingMessage; body: LoadBalancersPost201Response; }>((resolve, reject) => {
|
|||
|
localVarRequest(localVarRequestOptions, (error, response, body) => {
|
|||
|
if (error) {
|
|||
|
reject(error);
|
|||
|
} else {
|
|||
|
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
|
|||
|
body = ObjectSerializer.deserialize(body, "LoadBalancersPost201Response");
|
|||
|
resolve({ response: response, body: body });
|
|||
|
} else {
|
|||
|
reject(new HttpError(response, body, response.statusCode));
|
|||
|
}
|
|||
|
}
|
|||
|
});
|
|||
|
});
|
|||
|
});
|
|||
|
}
|
|||
|
}
|