diff --git a/packages/clients/src/api/instance/v1/api.gen.ts b/packages/clients/src/api/instance/v1/api.gen.ts index 82e3f695f..92c68df04 100644 --- a/packages/clients/src/api/instance/v1/api.gen.ts +++ b/packages/clients/src/api/instance/v1/api.gen.ts @@ -82,6 +82,7 @@ import { unmarshalMigrationPlan, unmarshalPrivateNIC, unmarshalServerActionResponse, + unmarshalServerCompatibleTypes, unmarshalSetImageResponse, unmarshalSetPlacementGroupResponse, unmarshalSetPlacementGroupServersResponse, @@ -153,6 +154,7 @@ import type { GetSecurityGroupResponse, GetSecurityGroupRuleRequest, GetSecurityGroupRuleResponse, + GetServerCompatibleTypesRequest, GetServerRequest, GetServerResponse, GetServerTypesAvailabilityRequest, @@ -193,6 +195,7 @@ import type { PrivateNIC, ServerActionRequest, ServerActionResponse, + ServerCompatibleTypes, SetImageRequest, SetPlacementGroupRequest, SetPlacementGroupResponse, @@ -512,6 +515,28 @@ export class API extends ParentAPI { path: `/instance/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}/user_data/${validatePathParam('key', request.key)}`, }) + /** + * Get Instance compatible types. Get compatible commercial types that can be + * used to update the Instance. The compatibility of an Instance offer is + * based on: the CPU architecture the OS type the required l_ssd storage size + * the required scratch storage size If the specified Instance offer is + * flagged as end of service, the best compatible offer is the first + * returned. + * + * @param request - The request {@link GetServerCompatibleTypesRequest} + * @returns A Promise of ServerCompatibleTypes + */ + getServerCompatibleTypes = ( + request: Readonly, + ) => + this.client.fetch( + { + method: 'GET', + path: `/instance/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}/compatible-types`, + }, + unmarshalServerCompatibleTypes, + ) + attachServerVolume = (request: Readonly) => this.client.fetch( { diff --git a/packages/clients/src/api/instance/v1/index.gen.ts b/packages/clients/src/api/instance/v1/index.gen.ts index 36921af14..8d6c9153e 100644 --- a/packages/clients/src/api/instance/v1/index.gen.ts +++ b/packages/clients/src/api/instance/v1/index.gen.ts @@ -60,6 +60,7 @@ export type { GetSecurityGroupResponse, GetSecurityGroupRuleRequest, GetSecurityGroupRuleResponse, + GetServerCompatibleTypesRequest, GetServerRequest, GetServerResponse, GetServerTypesAvailabilityRequest, @@ -124,6 +125,7 @@ export type { ServerActionRequest, ServerActionRequestVolumeBackupTemplate, ServerActionResponse, + ServerCompatibleTypes, ServerIp, ServerIpIpFamily, ServerIpProvisioningMode, diff --git a/packages/clients/src/api/instance/v1/marshalling.gen.ts b/packages/clients/src/api/instance/v1/marshalling.gen.ts index a896202d8..c462f2d09 100644 --- a/packages/clients/src/api/instance/v1/marshalling.gen.ts +++ b/packages/clients/src/api/instance/v1/marshalling.gen.ts @@ -79,6 +79,7 @@ import type { ServerActionRequest, ServerActionRequestVolumeBackupTemplate, ServerActionResponse, + ServerCompatibleTypes, ServerIp, ServerIpv6, ServerLocation, @@ -1204,6 +1205,7 @@ const unmarshalServerType = (data: unknown): ServerType => { capabilities: data.capabilities ? unmarshalServerTypeCapabilities(data.capabilities) : undefined, + endOfService: data.end_of_service, gpu: data.gpu, hourlyPrice: data.hourly_price, monthlyPrice: data.monthly_price, @@ -1357,6 +1359,20 @@ export const unmarshalServerActionResponse = ( } as ServerActionResponse } +export const unmarshalServerCompatibleTypes = ( + data: unknown, +): ServerCompatibleTypes => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ServerCompatibleTypes' failed as data isn't a dictionary.`, + ) + } + + return { + compatibleTypes: data.compatible_types, + } as ServerCompatibleTypes +} + export const unmarshalSetImageResponse = (data: unknown): SetImageResponse => { if (!isJSONObject(data)) { throw new TypeError( diff --git a/packages/clients/src/api/instance/v1/types.gen.ts b/packages/clients/src/api/instance/v1/types.gen.ts index bcdabf05a..a357ddee2 100644 --- a/packages/clients/src/api/instance/v1/types.gen.ts +++ b/packages/clients/src/api/instance/v1/types.gen.ts @@ -696,6 +696,8 @@ export interface ServerType { * second). */ blockBandwidth?: number + /** True if this Instance type has reached end of service. */ + endOfService: boolean } export interface VolumeType { @@ -1335,6 +1337,13 @@ export interface GetSecurityGroupRuleResponse { rule?: SecurityGroupRule } +export type GetServerCompatibleTypesRequest = { + /** Zone to target. If none is passed will use default zone from the config. */ + zone?: ScwZone + /** UUID of the Instance you want to get. */ + serverId: string +} + export type GetServerRequest = { /** Zone to target. If none is passed will use default zone from the config. */ zone?: ScwZone @@ -1787,6 +1796,11 @@ export interface ServerActionResponse { task?: Task } +export interface ServerCompatibleTypes { + /** Instance compatible types. */ + compatibleTypes: string[] +} + export type SetImageRequest = { /** Zone to target. If none is passed will use default zone from the config. */ zone?: ScwZone