/* tslint:disable */ /* eslint-disable */ /** * AutoGlue API * API for managing K3s clusters across cloud providers * * The version of the OpenAPI document: dev * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ import * as runtime from "../runtime"; import type { DtoCreateServerRequest, DtoServerResponse, DtoUpdateServerRequest, } from "../models/index"; import { DtoCreateServerRequestFromJSON, DtoCreateServerRequestToJSON, DtoServerResponseFromJSON, DtoServerResponseToJSON, DtoUpdateServerRequestFromJSON, DtoUpdateServerRequestToJSON, } from "../models/index"; export interface CreateServerRequest { dtoCreateServerRequest: DtoCreateServerRequest; xOrgID?: string; } export interface DeleteServerRequest { id: string; xOrgID?: string; } export interface GetServerRequest { id: string; xOrgID?: string; } export interface ListServersRequest { xOrgID?: string; status?: string; role?: string; } export interface ResetServerHostKeyRequest { id: string; xOrgID?: string; body?: object; } export interface UpdateServerRequest { id: string; dtoUpdateServerRequest: DtoUpdateServerRequest; xOrgID?: string; } /** * */ export class ServersApi extends runtime.BaseAPI { /** * Creates a server bound to the org in X-Org-ID. Validates that ssh_key_id belongs to the org. * Create server (org scoped) */ async createServerRaw( requestParameters: CreateServerRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction, ): Promise> { if (requestParameters["dtoCreateServerRequest"] == null) { throw new runtime.RequiredError( "dtoCreateServerRequest", 'Required parameter "dtoCreateServerRequest" was null or undefined when calling createServer().', ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; headerParameters["Content-Type"] = "application/json"; if (requestParameters["xOrgID"] != null) { headerParameters["X-Org-ID"] = String(requestParameters["xOrgID"]); } if (this.configuration && this.configuration.apiKey) { headerParameters["X-ORG-KEY"] = await this.configuration.apiKey("X-ORG-KEY"); // OrgKeyAuth authentication } if (this.configuration && this.configuration.apiKey) { headerParameters["X-ORG-SECRET"] = await this.configuration.apiKey("X-ORG-SECRET"); // OrgSecretAuth authentication } if (this.configuration && this.configuration.apiKey) { headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // BearerAuth authentication } let urlPath = `/servers`; const response = await this.request( { path: urlPath, method: "POST", headers: headerParameters, query: queryParameters, body: DtoCreateServerRequestToJSON( requestParameters["dtoCreateServerRequest"], ), }, initOverrides, ); return new runtime.JSONApiResponse(response, (jsonValue) => DtoServerResponseFromJSON(jsonValue), ); } /** * Creates a server bound to the org in X-Org-ID. Validates that ssh_key_id belongs to the org. * Create server (org scoped) */ async createServer( requestParameters: CreateServerRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction, ): Promise { const response = await this.createServerRaw( requestParameters, initOverrides, ); return await response.value(); } /** * Permanently deletes the server. * Delete server (org scoped) */ async deleteServerRaw( requestParameters: DeleteServerRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction, ): Promise> { if (requestParameters["id"] == null) { throw new runtime.RequiredError( "id", 'Required parameter "id" was null or undefined when calling deleteServer().', ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (requestParameters["xOrgID"] != null) { headerParameters["X-Org-ID"] = String(requestParameters["xOrgID"]); } if (this.configuration && this.configuration.apiKey) { headerParameters["X-ORG-KEY"] = await this.configuration.apiKey("X-ORG-KEY"); // OrgKeyAuth authentication } if (this.configuration && this.configuration.apiKey) { headerParameters["X-ORG-SECRET"] = await this.configuration.apiKey("X-ORG-SECRET"); // OrgSecretAuth authentication } if (this.configuration && this.configuration.apiKey) { headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // BearerAuth authentication } let urlPath = `/servers/{id}`; urlPath = urlPath.replace( `{${"id"}}`, encodeURIComponent(String(requestParameters["id"])), ); const response = await this.request( { path: urlPath, method: "DELETE", headers: headerParameters, query: queryParameters, }, initOverrides, ); return new runtime.VoidApiResponse(response); } /** * Permanently deletes the server. * Delete server (org scoped) */ async deleteServer( requestParameters: DeleteServerRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction, ): Promise { await this.deleteServerRaw(requestParameters, initOverrides); } /** * Returns one server in the given organization. * Get server by ID (org scoped) */ async getServerRaw( requestParameters: GetServerRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction, ): Promise> { if (requestParameters["id"] == null) { throw new runtime.RequiredError( "id", 'Required parameter "id" was null or undefined when calling getServer().', ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (requestParameters["xOrgID"] != null) { headerParameters["X-Org-ID"] = String(requestParameters["xOrgID"]); } if (this.configuration && this.configuration.apiKey) { headerParameters["X-ORG-KEY"] = await this.configuration.apiKey("X-ORG-KEY"); // OrgKeyAuth authentication } if (this.configuration && this.configuration.apiKey) { headerParameters["X-ORG-SECRET"] = await this.configuration.apiKey("X-ORG-SECRET"); // OrgSecretAuth authentication } if (this.configuration && this.configuration.apiKey) { headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // BearerAuth authentication } let urlPath = `/servers/{id}`; urlPath = urlPath.replace( `{${"id"}}`, encodeURIComponent(String(requestParameters["id"])), ); const response = await this.request( { path: urlPath, method: "GET", headers: headerParameters, query: queryParameters, }, initOverrides, ); return new runtime.JSONApiResponse(response, (jsonValue) => DtoServerResponseFromJSON(jsonValue), ); } /** * Returns one server in the given organization. * Get server by ID (org scoped) */ async getServer( requestParameters: GetServerRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction, ): Promise { const response = await this.getServerRaw(requestParameters, initOverrides); return await response.value(); } /** * Returns servers for the organization in X-Org-ID. Optional filters: status, role. * List servers (org scoped) */ async listServersRaw( requestParameters: ListServersRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction, ): Promise>> { const queryParameters: any = {}; if (requestParameters["status"] != null) { queryParameters["status"] = requestParameters["status"]; } if (requestParameters["role"] != null) { queryParameters["role"] = requestParameters["role"]; } const headerParameters: runtime.HTTPHeaders = {}; if (requestParameters["xOrgID"] != null) { headerParameters["X-Org-ID"] = String(requestParameters["xOrgID"]); } if (this.configuration && this.configuration.apiKey) { headerParameters["X-ORG-KEY"] = await this.configuration.apiKey("X-ORG-KEY"); // OrgKeyAuth authentication } if (this.configuration && this.configuration.apiKey) { headerParameters["X-ORG-SECRET"] = await this.configuration.apiKey("X-ORG-SECRET"); // OrgSecretAuth authentication } if (this.configuration && this.configuration.apiKey) { headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // BearerAuth authentication } let urlPath = `/servers`; const response = await this.request( { path: urlPath, method: "GET", headers: headerParameters, query: queryParameters, }, initOverrides, ); return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(DtoServerResponseFromJSON), ); } /** * Returns servers for the organization in X-Org-ID. Optional filters: status, role. * List servers (org scoped) */ async listServers( requestParameters: ListServersRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction, ): Promise> { const response = await this.listServersRaw( requestParameters, initOverrides, ); return await response.value(); } /** * Clears the stored SSH host key for this server. The next SSH connection will re-learn the host key (trust-on-first-use). * Reset SSH host key (org scoped) */ async resetServerHostKeyRaw( requestParameters: ResetServerHostKeyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction, ): Promise> { if (requestParameters["id"] == null) { throw new runtime.RequiredError( "id", 'Required parameter "id" was null or undefined when calling resetServerHostKey().', ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; headerParameters["Content-Type"] = "application/json"; if (requestParameters["xOrgID"] != null) { headerParameters["X-Org-ID"] = String(requestParameters["xOrgID"]); } if (this.configuration && this.configuration.apiKey) { headerParameters["X-ORG-KEY"] = await this.configuration.apiKey("X-ORG-KEY"); // OrgKeyAuth authentication } if (this.configuration && this.configuration.apiKey) { headerParameters["X-ORG-SECRET"] = await this.configuration.apiKey("X-ORG-SECRET"); // OrgSecretAuth authentication } if (this.configuration && this.configuration.apiKey) { headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // BearerAuth authentication } let urlPath = `/servers/{id}/reset-hostkey`; urlPath = urlPath.replace( `{${"id"}}`, encodeURIComponent(String(requestParameters["id"])), ); const response = await this.request( { path: urlPath, method: "POST", headers: headerParameters, query: queryParameters, body: requestParameters["body"] as any, }, initOverrides, ); return new runtime.JSONApiResponse(response, (jsonValue) => DtoServerResponseFromJSON(jsonValue), ); } /** * Clears the stored SSH host key for this server. The next SSH connection will re-learn the host key (trust-on-first-use). * Reset SSH host key (org scoped) */ async resetServerHostKey( requestParameters: ResetServerHostKeyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction, ): Promise { const response = await this.resetServerHostKeyRaw( requestParameters, initOverrides, ); return await response.value(); } /** * Partially update fields; changing ssh_key_id validates ownership. * Update server (org scoped) */ async updateServerRaw( requestParameters: UpdateServerRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction, ): Promise> { if (requestParameters["id"] == null) { throw new runtime.RequiredError( "id", 'Required parameter "id" was null or undefined when calling updateServer().', ); } if (requestParameters["dtoUpdateServerRequest"] == null) { throw new runtime.RequiredError( "dtoUpdateServerRequest", 'Required parameter "dtoUpdateServerRequest" was null or undefined when calling updateServer().', ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; headerParameters["Content-Type"] = "application/json"; if (requestParameters["xOrgID"] != null) { headerParameters["X-Org-ID"] = String(requestParameters["xOrgID"]); } if (this.configuration && this.configuration.apiKey) { headerParameters["X-ORG-KEY"] = await this.configuration.apiKey("X-ORG-KEY"); // OrgKeyAuth authentication } if (this.configuration && this.configuration.apiKey) { headerParameters["X-ORG-SECRET"] = await this.configuration.apiKey("X-ORG-SECRET"); // OrgSecretAuth authentication } if (this.configuration && this.configuration.apiKey) { headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // BearerAuth authentication } let urlPath = `/servers/{id}`; urlPath = urlPath.replace( `{${"id"}}`, encodeURIComponent(String(requestParameters["id"])), ); const response = await this.request( { path: urlPath, method: "PATCH", headers: headerParameters, query: queryParameters, body: DtoUpdateServerRequestToJSON( requestParameters["dtoUpdateServerRequest"], ), }, initOverrides, ); return new runtime.JSONApiResponse(response, (jsonValue) => DtoServerResponseFromJSON(jsonValue), ); } /** * Partially update fields; changing ssh_key_id validates ownership. * Update server (org scoped) */ async updateServer( requestParameters: UpdateServerRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction, ): Promise { const response = await this.updateServerRaw( requestParameters, initOverrides, ); return await response.value(); } }