diff --git a/packages/clients/src/api/account/index.ts b/packages/clients/src/api/account/index.ts index 54205ccfb..c399bf084 100644 --- a/packages/clients/src/api/account/index.ts +++ b/packages/clients/src/api/account/index.ts @@ -1,2 +1 @@ -export * as v2alpha1 from './v2alpha1' export * as v2 from './v2/index.gen' diff --git a/packages/clients/src/api/account/v2alpha1/api.gen.ts b/packages/clients/src/api/account/v2alpha1/api.gen.ts deleted file mode 100644 index 89d9d5acb..000000000 --- a/packages/clients/src/api/account/v2alpha1/api.gen.ts +++ /dev/null @@ -1,139 +0,0 @@ -// This file was automatically generated. DO NOT EDIT. -// If you have any remark or suggestion do not hesitate to open an issue. -import { - API, - enrichForPagination, - urlParams, - validatePathParam, -} from '../../../bridge' -import { - marshalCreateSSHKeyRequest, - marshalUpdateSSHKeyRequest, - unmarshalListSSHKeysResponse, - unmarshalSSHKey, -} from './marshalling.gen' -import type { - CreateSSHKeyRequest, - DeleteSSHKeyRequest, - GetSSHKeyRequest, - ListSSHKeysRequest, - ListSSHKeysResponse, - SSHKey, - UpdateSSHKeyRequest, -} from './types.gen' - -const jsonContentHeaders = { - 'Content-Type': 'application/json; charset=utf-8', -} - -/** Account API. */ -export class AccountV2Alpha1GenAPI extends API { - protected pageOfListSSHKeys = (request: Readonly = {}) => - this.client.fetch( - { - method: 'GET', - path: `/account/v2alpha1/ssh-keys`, - urlParams: urlParams( - ['name', request.name], - ['order_by', request.orderBy ?? 'created_at_asc'], - [ - 'organization_id', - request.organizationId ?? - this.client.settings.defaultOrganizationId, - ], - ['page', request.page], - [ - 'page_size', - request.pageSize ?? this.client.settings.defaultPageSize, - ], - [ - 'project_id', - request.projectId ?? this.client.settings.defaultProjectId, - ], - ), - }, - unmarshalListSSHKeysResponse, - ) - - /** - * List all SSH keys of your project - * - * @param request - The request {@link ListSSHKeysRequest} - * @returns A Promise of ListSSHKeysResponse - */ - listSSHKeys = (request: Readonly = {}) => - enrichForPagination('sshKeys', this.pageOfListSSHKeys, request) - - /** - * Add an SSH key to your project - * - * @param request - The request {@link CreateSSHKeyRequest} - * @returns A Promise of SSHKey - */ - createSSHKey = (request: Readonly) => - this.client.fetch( - { - body: JSON.stringify( - marshalCreateSSHKeyRequest(request, this.client.settings), - ), - headers: jsonContentHeaders, - method: 'POST', - path: `/account/v2alpha1/ssh-keys`, - }, - unmarshalSSHKey, - ) - - /** - * Get an SSH key from your project - * - * @param request - The request {@link GetSSHKeyRequest} - * @returns A Promise of SSHKey - */ - getSSHKey = (request: Readonly) => - this.client.fetch( - { - method: 'GET', - path: `/account/v2alpha1/ssh-key/${validatePathParam( - 'sshKeyId', - request.sshKeyId, - )}`, - }, - unmarshalSSHKey, - ) - - /** - * Update an SSH key on your project - * - * @param request - The request {@link UpdateSSHKeyRequest} - * @returns A Promise of SSHKey - */ - updateSSHKey = (request: Readonly) => - this.client.fetch( - { - body: JSON.stringify( - marshalUpdateSSHKeyRequest(request, this.client.settings), - ), - headers: jsonContentHeaders, - method: 'PATCH', - path: `/account/v2alpha1/ssh-key/${validatePathParam( - 'sshKeyId', - request.sshKeyId, - )}`, - }, - unmarshalSSHKey, - ) - - /** - * Remove an SSH key from your project - * - * @param request - The request {@link DeleteSSHKeyRequest} - */ - deleteSSHKey = (request: Readonly) => - this.client.fetch({ - method: 'DELETE', - path: `/account/v2alpha1/ssh-key/${validatePathParam( - 'sshKeyId', - request.sshKeyId, - )}`, - }) -} diff --git a/packages/clients/src/api/account/v2alpha1/index.ts b/packages/clients/src/api/account/v2alpha1/index.ts deleted file mode 100644 index 0a1192e20..000000000 --- a/packages/clients/src/api/account/v2alpha1/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { AccountV2Alpha1GenAPI as API } from './api.gen' -export * from './types.gen' diff --git a/packages/clients/src/api/account/v2alpha1/marshalling.gen.ts b/packages/clients/src/api/account/v2alpha1/marshalling.gen.ts deleted file mode 100644 index 0f2ddda87..000000000 --- a/packages/clients/src/api/account/v2alpha1/marshalling.gen.ts +++ /dev/null @@ -1,92 +0,0 @@ -// This file was automatically generated. DO NOT EDIT. -// If you have any remark or suggestion do not hesitate to open an issue. -import { - isJSONObject, - resolveOneOf, - unmarshalArrayOfObject, - unmarshalDate, -} from '../../../bridge' -import type { DefaultValues } from '../../../bridge' -import type { - CreateSSHKeyRequest, - ListSSHKeysResponse, - SSHKey, - SSHKeyCreationInfo, - UpdateSSHKeyRequest, -} from './types.gen' - -const unmarshalSSHKeyCreationInfo = (data: unknown) => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'SSHKeyCreationInfo' failed as data isn't a dictionary.`, - ) - } - - return { - address: data.address, - countryCode: data.country_code, - userAgent: data.user_agent, - } as SSHKeyCreationInfo -} - -export const unmarshalSSHKey = (data: unknown) => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'SSHKey' failed as data isn't a dictionary.`, - ) - } - - return { - createdAt: unmarshalDate(data.created_at), - creationInfo: data.creation_info - ? unmarshalSSHKeyCreationInfo(data.creation_info) - : undefined, - fingerprint: data.fingerprint, - id: data.id, - name: data.name, - organizationId: data.organization_id, - projectId: data.project_id, - publicKey: data.public_key, - updatedAt: unmarshalDate(data.updated_at), - } as SSHKey -} - -export const unmarshalListSSHKeysResponse = (data: unknown) => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'ListSSHKeysResponse' failed as data isn't a dictionary.`, - ) - } - - return { - sshKeys: unmarshalArrayOfObject(data.ssh_keys, unmarshalSSHKey), - totalCount: data.total_count, - } as ListSSHKeysResponse -} - -export const marshalCreateSSHKeyRequest = ( - request: CreateSSHKeyRequest, - defaults: DefaultValues, -): Record => ({ - name: request.name, - public_key: request.publicKey, - ...resolveOneOf([ - { - default: defaults.defaultProjectId, - param: 'project_id', - value: request.projectId, - }, - { - default: defaults.defaultOrganizationId, - param: 'organization_id', - value: request.organizationId, - }, - ]), -}) - -export const marshalUpdateSSHKeyRequest = ( - request: UpdateSSHKeyRequest, - defaults: DefaultValues, -): Record => ({ - name: request.name, -}) diff --git a/packages/clients/src/api/account/v2alpha1/types.gen.ts b/packages/clients/src/api/account/v2alpha1/types.gen.ts deleted file mode 100644 index def7336ec..000000000 --- a/packages/clients/src/api/account/v2alpha1/types.gen.ts +++ /dev/null @@ -1,83 +0,0 @@ -// This file was automatically generated. DO NOT EDIT. -// If you have any remark or suggestion do not hesitate to open an issue. - -export type ListSSHKeysRequestOrderBy = - | 'created_at_asc' - | 'created_at_desc' - | 'updated_at_asc' - | 'updated_at_desc' - | 'name_asc' - | 'name_desc' - -/** List ssh keys response */ -export interface ListSSHKeysResponse { - sshKeys: SSHKey[] - totalCount: number -} - -/** Ssh key */ -export interface SSHKey { - id: string - name: string - publicKey: string - fingerprint: string - createdAt?: Date - updatedAt?: Date - creationInfo?: SSHKeyCreationInfo - organizationId: string - projectId: string -} - -export interface SSHKeyCreationInfo { - address: string - userAgent: string - countryCode: string -} - -export type ListSSHKeysRequest = { - orderBy?: ListSSHKeysRequestOrderBy - page?: number - pageSize?: number - name?: string - organizationId?: string - projectId?: string -} - -export type CreateSSHKeyRequest = { - /** The name of the SSH key */ - name: string - /** - * SSH public key. Currently ssh-rsa, ssh-dss (DSA), ssh-ed25519 and ecdsa - * keys with NIST curves are supported - */ - publicKey: string - /** - * @deprecated Use project_id field instead. - * - * One-of ('projectIdentifier'): at most one of 'organizationId', 'projectId' - * could be set. - */ - organizationId?: string - /** - * Project owning the resource. - * - * One-of ('projectIdentifier'): at most one of 'organizationId', 'projectId' - * could be set. - */ - projectId?: string -} - -export type GetSSHKeyRequest = { - /** The ID of the SSH key */ - sshKeyId: string -} - -export type UpdateSSHKeyRequest = { - sshKeyId: string - /** Name of the SSH key */ - name?: string -} - -export type DeleteSSHKeyRequest = { - sshKeyId: string -}