From c38b0a1434ce845fe5e9133c2e7212f5f7126feb Mon Sep 17 00:00:00 2001 From: Yacine Fodil <105779815+yfodil@users.noreply.github.com> Date: Fri, 29 Nov 2024 14:29:55 +0100 Subject: [PATCH] feat(instance): create CheckQuotasOrganizationBlockMigration endpoint (#1617) --- packages/clients/src/api/instance/v1/api.gen.ts | 17 +++++++++++++++++ .../clients/src/api/instance/v1/api.utils.ts | 6 ++++-- .../clients/src/api/instance/v1/index.gen.ts | 1 + .../src/api/instance/v1/marshalling.gen.ts | 8 ++++++++ .../clients/src/api/instance/v1/types.gen.ts | 6 ++++++ 5 files changed, 36 insertions(+), 2 deletions(-) diff --git a/packages/clients/src/api/instance/v1/api.gen.ts b/packages/clients/src/api/instance/v1/api.gen.ts index cda8139f1..ce5d8cebf 100644 --- a/packages/clients/src/api/instance/v1/api.gen.ts +++ b/packages/clients/src/api/instance/v1/api.gen.ts @@ -10,6 +10,7 @@ import type { Zone } from '../../../bridge' import { marshalApplyBlockMigrationRequest, marshalAttachServerVolumeRequest, + marshalCheckBlockMigrationOrganizationQuotasRequest, marshalCreateImageRequest, marshalCreateIpRequest, marshalCreatePlacementGroupRequest, @@ -103,6 +104,7 @@ import type { ApplyBlockMigrationRequest, AttachServerVolumeRequest, AttachServerVolumeResponse, + CheckBlockMigrationOrganizationQuotasRequest, CreateImageRequest, CreateImageResponse, CreateIpRequest, @@ -1588,4 +1590,19 @@ export class API extends ParentAPI { method: 'POST', path: `/instance/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/block-migration/apply`, }) + + checkBlockMigrationOrganizationQuotas = ( + request: Readonly = {}, + ) => + this.client.fetch({ + body: JSON.stringify( + marshalCheckBlockMigrationOrganizationQuotasRequest( + request, + this.client.settings, + ), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/instance/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/block-migration/check-organization-quotas`, + }) } diff --git a/packages/clients/src/api/instance/v1/api.utils.ts b/packages/clients/src/api/instance/v1/api.utils.ts index d52f0beb4..a7a9d8e50 100644 --- a/packages/clients/src/api/instance/v1/api.utils.ts +++ b/packages/clients/src/api/instance/v1/api.utils.ts @@ -266,7 +266,8 @@ export class InstanceV1UtilsAPI extends API { zone: request.zone, }).then(res => validateNotUndefined(res.server?.volumes)) - const newVolumes: Record = {} + const newVolumes: Record = + {} for (const [key, server] of Object.entries(volumes)) { newVolumes[key] = { id: server.id, name: server.name } } @@ -322,7 +323,8 @@ export class InstanceV1UtilsAPI extends API { .then(res => validateNotUndefined(res.server)) // Remove volume. - const newVolumes: Record = {} + const newVolumes: Record = + {} for (const [key, volume] of Object.entries(server.volumes)) { if (volume.id !== request.volumeId) { newVolumes[key] = { id: volume.id, name: volume.name } diff --git a/packages/clients/src/api/instance/v1/index.gen.ts b/packages/clients/src/api/instance/v1/index.gen.ts index 42c657172..36921af14 100644 --- a/packages/clients/src/api/instance/v1/index.gen.ts +++ b/packages/clients/src/api/instance/v1/index.gen.ts @@ -10,6 +10,7 @@ export type { AttachServerVolumeResponse, BootType, Bootscript, + CheckBlockMigrationOrganizationQuotasRequest, CreateImageRequest, CreateImageResponse, CreateIpRequest, diff --git a/packages/clients/src/api/instance/v1/marshalling.gen.ts b/packages/clients/src/api/instance/v1/marshalling.gen.ts index aa963ef4d..a896202d8 100644 --- a/packages/clients/src/api/instance/v1/marshalling.gen.ts +++ b/packages/clients/src/api/instance/v1/marshalling.gen.ts @@ -14,6 +14,7 @@ import type { AttachServerVolumeRequest, AttachServerVolumeResponse, Bootscript, + CheckBlockMigrationOrganizationQuotasRequest, CreateImageRequest, CreateImageResponse, CreateIpRequest, @@ -1624,6 +1625,13 @@ export const marshalAttachServerVolumeRequest = ( volume_type: request.volumeType, }) +export const marshalCheckBlockMigrationOrganizationQuotasRequest = ( + request: CheckBlockMigrationOrganizationQuotasRequest, + defaults: DefaultValues, +): Record => ({ + organization: request.organization ?? defaults.defaultOrganizationId, +}) + const marshalVolumeTemplate = ( request: VolumeTemplate, defaults: DefaultValues, diff --git a/packages/clients/src/api/instance/v1/types.gen.ts b/packages/clients/src/api/instance/v1/types.gen.ts index 53b9e23de..651f728dd 100644 --- a/packages/clients/src/api/instance/v1/types.gen.ts +++ b/packages/clients/src/api/instance/v1/types.gen.ts @@ -801,6 +801,12 @@ export interface AttachServerVolumeResponse { server?: Server } +export type CheckBlockMigrationOrganizationQuotasRequest = { + /** Zone to target. If none is passed will use default zone from the config. */ + zone?: Zone + organization?: string +} + export type CreateImageRequest = { /** Zone to target. If none is passed will use default zone from the config. */ zone?: Zone