/* tslint:disable */ /* eslint-disable */ /** * AutoGlue API * API for managing K3s clusters across cloud providers * * The version of the OpenAPI document: 1.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 * as runtime from '../runtime'; import type { DtoCreateSSHRequest, DtoSshResponse, DtoSshRevealResponse, } from '../models/index'; import { DtoCreateSSHRequestFromJSON, DtoCreateSSHRequestToJSON, DtoSshResponseFromJSON, DtoSshResponseToJSON, DtoSshRevealResponseFromJSON, DtoSshRevealResponseToJSON, } from '../models/index'; export interface CreateSSHKeyRequest { body: DtoCreateSSHRequest; xOrgID?: string; } export interface DeleteSSHKeyRequest { id: string; xOrgID?: string; } export interface DownloadSSHKeyRequest { xOrgID: string; id: string; part: DownloadSSHKeyPartEnum; } export interface GetSSHKeyRequest { id: string; xOrgID?: string; reveal?: boolean; } export interface ListPublicSshKeysRequest { xOrgID?: string; } /** * */ export class SshApi extends runtime.BaseAPI { /** * Generates an RSA or ED25519 keypair, saves it, and returns metadata. For RSA you may set bits (2048/3072/4096). Default is 4096. ED25519 ignores bits. * Create ssh keypair (org scoped) */ async createSSHKeyRaw(requestParameters: CreateSSHKeyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (requestParameters['body'] == null) { throw new runtime.RequiredError( 'body', 'Required parameter "body" was null or undefined when calling createSSHKey().' ); } 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 = `/ssh`; const response = await this.request({ path: urlPath, method: 'POST', headers: headerParameters, query: queryParameters, body: DtoCreateSSHRequestToJSON(requestParameters['body']), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => DtoSshResponseFromJSON(jsonValue)); } /** * Generates an RSA or ED25519 keypair, saves it, and returns metadata. For RSA you may set bits (2048/3072/4096). Default is 4096. ED25519 ignores bits. * Create ssh keypair (org scoped) */ async createSSHKey(requestParameters: CreateSSHKeyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.createSSHKeyRaw(requestParameters, initOverrides); return await response.value(); } /** * Permanently deletes a keypair. * Delete ssh keypair (org scoped) */ async deleteSSHKeyRaw(requestParameters: DeleteSSHKeyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (requestParameters['id'] == null) { throw new runtime.RequiredError( 'id', 'Required parameter "id" was null or undefined when calling deleteSSHKey().' ); } 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 = `/ssh/{id}`; urlPath = urlPath.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))); const response = await this.request({ path: urlPath, method: 'DELETE', headers: headerParameters, query: queryParameters, }, initOverrides); if (this.isJsonMime(response.headers.get('content-type'))) { return new runtime.JSONApiResponse(response); } else { return new runtime.TextApiResponse(response) as any; } } /** * Permanently deletes a keypair. * Delete ssh keypair (org scoped) */ async deleteSSHKey(requestParameters: DeleteSSHKeyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.deleteSSHKeyRaw(requestParameters, initOverrides); return await response.value(); } /** * Download `part=public|private|both` of the keypair. `both` returns a zip file. * Download ssh key files by ID (org scoped) */ async downloadSSHKeyRaw(requestParameters: DownloadSSHKeyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (requestParameters['xOrgID'] == null) { throw new runtime.RequiredError( 'xOrgID', 'Required parameter "xOrgID" was null or undefined when calling downloadSSHKey().' ); } if (requestParameters['id'] == null) { throw new runtime.RequiredError( 'id', 'Required parameter "id" was null or undefined when calling downloadSSHKey().' ); } if (requestParameters['part'] == null) { throw new runtime.RequiredError( 'part', 'Required parameter "part" was null or undefined when calling downloadSSHKey().' ); } const queryParameters: any = {}; if (requestParameters['part'] != null) { queryParameters['part'] = requestParameters['part']; } 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 = `/ssh/{id}/download`; urlPath = urlPath.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))); const response = await this.request({ path: urlPath, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); if (this.isJsonMime(response.headers.get('content-type'))) { return new runtime.JSONApiResponse(response); } else { return new runtime.TextApiResponse(response) as any; } } /** * Download `part=public|private|both` of the keypair. `both` returns a zip file. * Download ssh key files by ID (org scoped) */ async downloadSSHKey(requestParameters: DownloadSSHKeyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.downloadSSHKeyRaw(requestParameters, initOverrides); return await response.value(); } /** * Returns public key fields. Append `?reveal=true` to include the private key PEM. * Get ssh key by ID (org scoped) */ async getSSHKeyRaw(requestParameters: GetSSHKeyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (requestParameters['id'] == null) { throw new runtime.RequiredError( 'id', 'Required parameter "id" was null or undefined when calling getSSHKey().' ); } const queryParameters: any = {}; if (requestParameters['reveal'] != null) { queryParameters['reveal'] = requestParameters['reveal']; } 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 = `/ssh/{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) => DtoSshRevealResponseFromJSON(jsonValue)); } /** * Returns public key fields. Append `?reveal=true` to include the private key PEM. * Get ssh key by ID (org scoped) */ async getSSHKey(requestParameters: GetSSHKeyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.getSSHKeyRaw(requestParameters, initOverrides); return await response.value(); } /** * Returns ssh keys for the organization in X-Org-ID. * List ssh keys (org scoped) */ async listPublicSshKeysRaw(requestParameters: ListPublicSshKeysRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { 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 = `/ssh`; const response = await this.request({ path: urlPath, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(DtoSshResponseFromJSON)); } /** * Returns ssh keys for the organization in X-Org-ID. * List ssh keys (org scoped) */ async listPublicSshKeys(requestParameters: ListPublicSshKeysRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const response = await this.listPublicSshKeysRaw(requestParameters, initOverrides); return await response.value(); } } /** * @export */ export const DownloadSSHKeyPartEnum = { public: 'public', private: 'private', both: 'both' } as const; export type DownloadSSHKeyPartEnum = typeof DownloadSSHKeyPartEnum[keyof typeof DownloadSSHKeyPartEnum];