Skip to content

Commit 9f18271

Browse files
feat(baremetal): add support for MigrateServerToMonthlyOfferRequest (#1836)
Co-authored-by: Rémy Léone <[email protected]>
1 parent f849b3e commit 9f18271

File tree

5 files changed

+31
-0
lines changed

5 files changed

+31
-0
lines changed

packages/clients/src/api/baremetal/v1/api.gen.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ import type {
7070
ListServersResponse,
7171
ListSettingsRequest,
7272
ListSettingsResponse,
73+
MigrateServerToMonthlyOfferRequest,
7374
OS,
7475
Offer,
7576
Option,
@@ -517,6 +518,23 @@ export class API extends ParentAPI {
517518
unmarshalServer,
518519
)
519520

521+
/**
522+
* Migrate server offer. Migrate server with hourly offer to monthly offer.
523+
*
524+
* @param request - The request {@link MigrateServerToMonthlyOfferRequest}
525+
* @returns A Promise of Server
526+
*/
527+
migrateServerToMonthlyOffer = (
528+
request: Readonly<MigrateServerToMonthlyOfferRequest>,
529+
) =>
530+
this.client.fetch<Server>(
531+
{
532+
method: 'POST',
533+
path: `/baremetal/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}/migrate-offer-monthly`,
534+
},
535+
unmarshalServer,
536+
)
537+
520538
protected pageOfListOffers = (request: Readonly<ListOffersRequest> = {}) =>
521539
this.client.fetch<ListOffersResponse>(
522540
{

packages/clients/src/api/baremetal/v1/content.gen.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ export const SERVER_TRANSIENT_STATUSES: ServerStatus[] = [
2424
'deleting',
2525
'ordered',
2626
'resetting',
27+
'migrating',
2728
]

packages/clients/src/api/baremetal/v1/index.gen.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export type {
4444
ListSettingsRequestOrderBy,
4545
ListSettingsResponse,
4646
Memory,
47+
MigrateServerToMonthlyOfferRequest,
4748
OS,
4849
OSOSField,
4950
Offer,

packages/clients/src/api/baremetal/v1/marshalling.gen.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,7 @@ export const unmarshalOffer = (data: unknown): Offer => {
421421
incompatibleOsIds: data.incompatible_os_ids,
422422
maxBandwidth: data.max_bandwidth,
423423
memories: unmarshalArrayOfObject(data.memories, unmarshalMemory),
424+
monthlyOfferId: data.monthly_offer_id,
424425
name: data.name,
425426
operationPath: data.operation_path,
426427
options: unmarshalArrayOfObject(data.options, unmarshalOfferOptionOffer),

packages/clients/src/api/baremetal/v1/types.gen.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ export type ServerStatus =
104104
| 'out_of_stock'
105105
| 'ordered'
106106
| 'resetting'
107+
| 'migrating'
107108

108109
export type SettingType = 'unknown' | 'smtp'
109110

@@ -479,6 +480,8 @@ export interface Offer {
479480
tags: string[]
480481
/** GPU specifications of the offer. */
481482
gpus: GPU[]
483+
/** Exist only for hourly offers, to migrate to the monthly offer. */
484+
monthlyOfferId?: string
482485
}
483486

484487
export interface Option {
@@ -900,6 +903,13 @@ export interface ListSettingsResponse {
900903
settings: Setting[]
901904
}
902905

906+
export type MigrateServerToMonthlyOfferRequest = {
907+
/** Zone to target. If none is passed will use default zone from the config. */
908+
zone?: ScwZone
909+
/** ID of the server. */
910+
serverId: string
911+
}
912+
903913
export type PrivateNetworkApiAddServerPrivateNetworkRequest = {
904914
/** Zone to target. If none is passed will use default zone from the config. */
905915
zone?: ScwZone

0 commit comments

Comments
 (0)