Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions packages/clients/src/api/instance/v1/api.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ import {
unmarshalMigrationPlan,
unmarshalPrivateNIC,
unmarshalServerActionResponse,
unmarshalServerCompatibleTypes,
unmarshalSetImageResponse,
unmarshalSetPlacementGroupResponse,
unmarshalSetPlacementGroupServersResponse,
Expand Down Expand Up @@ -153,6 +154,7 @@ import type {
GetSecurityGroupResponse,
GetSecurityGroupRuleRequest,
GetSecurityGroupRuleResponse,
GetServerCompatibleTypesRequest,
GetServerRequest,
GetServerResponse,
GetServerTypesAvailabilityRequest,
Expand Down Expand Up @@ -193,6 +195,7 @@ import type {
PrivateNIC,
ServerActionRequest,
ServerActionResponse,
ServerCompatibleTypes,
SetImageRequest,
SetPlacementGroupRequest,
SetPlacementGroupResponse,
Expand Down Expand Up @@ -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<GetServerCompatibleTypesRequest>,
) =>
this.client.fetch<ServerCompatibleTypes>(
{
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<AttachServerVolumeRequest>) =>
this.client.fetch<AttachServerVolumeResponse>(
{
Expand Down
2 changes: 2 additions & 0 deletions packages/clients/src/api/instance/v1/index.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export type {
GetSecurityGroupResponse,
GetSecurityGroupRuleRequest,
GetSecurityGroupRuleResponse,
GetServerCompatibleTypesRequest,
GetServerRequest,
GetServerResponse,
GetServerTypesAvailabilityRequest,
Expand Down Expand Up @@ -124,6 +125,7 @@ export type {
ServerActionRequest,
ServerActionRequestVolumeBackupTemplate,
ServerActionResponse,
ServerCompatibleTypes,
ServerIp,
ServerIpIpFamily,
ServerIpProvisioningMode,
Expand Down
16 changes: 16 additions & 0 deletions packages/clients/src/api/instance/v1/marshalling.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ import type {
ServerActionRequest,
ServerActionRequestVolumeBackupTemplate,
ServerActionResponse,
ServerCompatibleTypes,
ServerIp,
ServerIpv6,
ServerLocation,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down
14 changes: 14 additions & 0 deletions packages/clients/src/api/instance/v1/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading