/* 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 {DtoCreateCredentialRequest, DtoCredentialOut, DtoUpdateCredentialRequest,} from "../models/index"; import { DtoCreateCredentialRequestToJSON, DtoCredentialOutFromJSON, DtoUpdateCredentialRequestToJSON, } from "../models/index"; export interface CreateCredentialRequest { dtoCreateCredentialRequest: DtoCreateCredentialRequest; xOrgID?: string; } export interface DeleteCredentialRequest { id: string; xOrgID?: string; } export interface GetCredentialRequest { id: string; xOrgID?: string; } export interface ListCredentialsRequest { xOrgID?: string; credentialProvider?: string; kind?: string; scopeKind?: string; } export interface RevealCredentialRequest { id: string; xOrgID?: string; body?: object; } export interface UpdateCredentialRequest { id: string; dtoUpdateCredentialRequest: DtoUpdateCredentialRequest; xOrgID?: string; } /** * */ export class CredentialsApi extends runtime.BaseAPI { /** * Create a credential (encrypts secret) */ async createCredentialRaw( requestParameters: CreateCredentialRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction, ): Promise> { if (requestParameters["dtoCreateCredentialRequest"] == null) { throw new runtime.RequiredError( "dtoCreateCredentialRequest", 'Required parameter "dtoCreateCredentialRequest" was null or undefined when calling createCredential().', ); } 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 = `/credentials`; const response = await this.request( { path: urlPath, method: "POST", headers: headerParameters, query: queryParameters, body: DtoCreateCredentialRequestToJSON( requestParameters["dtoCreateCredentialRequest"], ), }, initOverrides, ); return new runtime.JSONApiResponse(response, (jsonValue) => DtoCredentialOutFromJSON(jsonValue), ); } /** * Create a credential (encrypts secret) */ async createCredential( requestParameters: CreateCredentialRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction, ): Promise { const response = await this.createCredentialRaw( requestParameters, initOverrides, ); return await response.value(); } /** * Delete credential */ async deleteCredentialRaw( requestParameters: DeleteCredentialRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction, ): Promise> { if (requestParameters["id"] == null) { throw new runtime.RequiredError( "id", 'Required parameter "id" was null or undefined when calling deleteCredential().', ); } 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 = `/credentials/{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); } /** * Delete credential */ async deleteCredential( requestParameters: DeleteCredentialRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction, ): Promise { await this.deleteCredentialRaw(requestParameters, initOverrides); } /** * Get credential by ID (metadata only) */ async getCredentialRaw( requestParameters: GetCredentialRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction, ): Promise> { if (requestParameters["id"] == null) { throw new runtime.RequiredError( "id", 'Required parameter "id" was null or undefined when calling getCredential().', ); } 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 = `/credentials/{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) => DtoCredentialOutFromJSON(jsonValue), ); } /** * Get credential by ID (metadata only) */ async getCredential( requestParameters: GetCredentialRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction, ): Promise { const response = await this.getCredentialRaw( requestParameters, initOverrides, ); return await response.value(); } /** * Returns credential metadata for the current org. Secrets are never returned. * List credentials (metadata only) */ async listCredentialsRaw( requestParameters: ListCredentialsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction, ): Promise>> { const queryParameters: any = {}; if (requestParameters["credentialProvider"] != null) { queryParameters["credential_provider"] = requestParameters["credentialProvider"]; } if (requestParameters["kind"] != null) { queryParameters["kind"] = requestParameters["kind"]; } if (requestParameters["scopeKind"] != null) { queryParameters["scope_kind"] = requestParameters["scopeKind"]; } 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 = `/credentials`; const response = await this.request( { path: urlPath, method: "GET", headers: headerParameters, query: queryParameters, }, initOverrides, ); return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(DtoCredentialOutFromJSON), ); } /** * Returns credential metadata for the current org. Secrets are never returned. * List credentials (metadata only) */ async listCredentials( requestParameters: ListCredentialsRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction, ): Promise> { const response = await this.listCredentialsRaw( requestParameters, initOverrides, ); return await response.value(); } /** * Reveal decrypted secret (one-time read) */ async revealCredentialRaw( requestParameters: RevealCredentialRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction, ): Promise> { if (requestParameters["id"] == null) { throw new runtime.RequiredError( "id", 'Required parameter "id" was null or undefined when calling revealCredential().', ); } 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 = `/credentials/{id}/reveal`; 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); } /** * Reveal decrypted secret (one-time read) */ async revealCredential( requestParameters: RevealCredentialRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction, ): Promise<{ [key: string]: any }> { const response = await this.revealCredentialRaw( requestParameters, initOverrides, ); return await response.value(); } /** * Update credential metadata and/or rotate secret */ async updateCredentialRaw( requestParameters: UpdateCredentialRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction, ): Promise> { if (requestParameters["id"] == null) { throw new runtime.RequiredError( "id", 'Required parameter "id" was null or undefined when calling updateCredential().', ); } if (requestParameters["dtoUpdateCredentialRequest"] == null) { throw new runtime.RequiredError( "dtoUpdateCredentialRequest", 'Required parameter "dtoUpdateCredentialRequest" was null or undefined when calling updateCredential().', ); } 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 = `/credentials/{id}`; urlPath = urlPath.replace( `{${"id"}}`, encodeURIComponent(String(requestParameters["id"])), ); const response = await this.request( { path: urlPath, method: "PATCH", headers: headerParameters, query: queryParameters, body: DtoUpdateCredentialRequestToJSON( requestParameters["dtoUpdateCredentialRequest"], ), }, initOverrides, ); return new runtime.JSONApiResponse(response, (jsonValue) => DtoCredentialOutFromJSON(jsonValue), ); } /** * Update credential metadata and/or rotate secret */ async updateCredential( requestParameters: UpdateCredentialRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction, ): Promise { const response = await this.updateCredentialRaw( requestParameters, initOverrides, ); return await response.value(); } }