Skip to content

Commit

Permalink
feat(instance): create CheckQuotasOrganizationBlockMigration endpoint (
Browse files Browse the repository at this point in the history
  • Loading branch information
yfodil authored Nov 29, 2024
1 parent f04a200 commit c38b0a1
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 2 deletions.
17 changes: 17 additions & 0 deletions packages/clients/src/api/instance/v1/api.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type { Zone } from '../../../bridge'
import {
marshalApplyBlockMigrationRequest,
marshalAttachServerVolumeRequest,
marshalCheckBlockMigrationOrganizationQuotasRequest,
marshalCreateImageRequest,
marshalCreateIpRequest,
marshalCreatePlacementGroupRequest,
Expand Down Expand Up @@ -103,6 +104,7 @@ import type {
ApplyBlockMigrationRequest,
AttachServerVolumeRequest,
AttachServerVolumeResponse,
CheckBlockMigrationOrganizationQuotasRequest,
CreateImageRequest,
CreateImageResponse,
CreateIpRequest,
Expand Down Expand Up @@ -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<CheckBlockMigrationOrganizationQuotasRequest> = {},
) =>
this.client.fetch<void>({
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`,
})
}
6 changes: 4 additions & 2 deletions packages/clients/src/api/instance/v1/api.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,8 @@ export class InstanceV1UtilsAPI extends API {
zone: request.zone,
}).then(res => validateNotUndefined(res.server?.volumes))

const newVolumes: Record<string, { id: string; name: string | undefined }> = {}
const newVolumes: Record<string, { id: string; name: string | undefined }> =
{}
for (const [key, server] of Object.entries(volumes)) {
newVolumes[key] = { id: server.id, name: server.name }
}
Expand Down Expand Up @@ -322,7 +323,8 @@ export class InstanceV1UtilsAPI extends API {
.then(res => validateNotUndefined(res.server))

// Remove volume.
const newVolumes: Record<string, { id: string; name: string | undefined }> = {}
const newVolumes: Record<string, { id: string; name: string | undefined }> =
{}
for (const [key, volume] of Object.entries(server.volumes)) {
if (volume.id !== request.volumeId) {
newVolumes[key] = { id: volume.id, name: volume.name }
Expand Down
1 change: 1 addition & 0 deletions packages/clients/src/api/instance/v1/index.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export type {
AttachServerVolumeResponse,
BootType,
Bootscript,
CheckBlockMigrationOrganizationQuotasRequest,
CreateImageRequest,
CreateImageResponse,
CreateIpRequest,
Expand Down
8 changes: 8 additions & 0 deletions packages/clients/src/api/instance/v1/marshalling.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import type {
AttachServerVolumeRequest,
AttachServerVolumeResponse,
Bootscript,
CheckBlockMigrationOrganizationQuotasRequest,
CreateImageRequest,
CreateImageResponse,
CreateIpRequest,
Expand Down Expand Up @@ -1624,6 +1625,13 @@ export const marshalAttachServerVolumeRequest = (
volume_type: request.volumeType,
})

export const marshalCheckBlockMigrationOrganizationQuotasRequest = (
request: CheckBlockMigrationOrganizationQuotasRequest,
defaults: DefaultValues,
): Record<string, unknown> => ({
organization: request.organization ?? defaults.defaultOrganizationId,
})

const marshalVolumeTemplate = (
request: VolumeTemplate,
defaults: DefaultValues,
Expand Down
6 changes: 6 additions & 0 deletions packages/clients/src/api/instance/v1/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c38b0a1

Please sign in to comment.