Skip to content

Commit

Permalink
Merge branch 'main' into v1.5930.0
Browse files Browse the repository at this point in the history
  • Loading branch information
philibea authored Dec 27, 2024
2 parents 9e91a4f + 506a671 commit 571707f
Show file tree
Hide file tree
Showing 6 changed files with 454 additions and 66 deletions.
167 changes: 166 additions & 1 deletion packages/clients/src/api/applesilicon/v1alpha1/api.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,27 @@ import {
waitForResource,
} from '../../../bridge'
import type { WaitForOptions, Zone } from '../../../bridge'
import { SERVER_TRANSIENT_STATUSES } from './content.gen'
import {
SERVER_PRIVATE_NETWORK_SERVER_TRANSIENT_STATUSES,
SERVER_TRANSIENT_STATUSES,
} from './content.gen'
import {
marshalCreateServerRequest,
marshalPrivateNetworkApiAddServerPrivateNetworkRequest,
marshalPrivateNetworkApiSetServerPrivateNetworksRequest,
marshalReinstallServerRequest,
marshalStartConnectivityDiagnosticRequest,
marshalUpdateServerRequest,
unmarshalConnectivityDiagnostic,
unmarshalListOSResponse,
unmarshalListServerPrivateNetworksResponse,
unmarshalListServerTypesResponse,
unmarshalListServersResponse,
unmarshalOS,
unmarshalServer,
unmarshalServerPrivateNetwork,
unmarshalServerType,
unmarshalSetServerPrivateNetworksResponse,
unmarshalStartConnectivityDiagnosticResponse,
} from './marshalling.gen'
import type {
Expand All @@ -33,15 +41,23 @@ import type {
GetServerTypeRequest,
ListOSRequest,
ListOSResponse,
ListServerPrivateNetworksResponse,
ListServerTypesRequest,
ListServerTypesResponse,
ListServersRequest,
ListServersResponse,
OS,
PrivateNetworkApiAddServerPrivateNetworkRequest,
PrivateNetworkApiDeleteServerPrivateNetworkRequest,
PrivateNetworkApiGetServerPrivateNetworkRequest,
PrivateNetworkApiListServerPrivateNetworksRequest,
PrivateNetworkApiSetServerPrivateNetworksRequest,
RebootServerRequest,
ReinstallServerRequest,
Server,
ServerPrivateNetwork,
ServerType,
SetServerPrivateNetworksResponse,
StartConnectivityDiagnosticRequest,
StartConnectivityDiagnosticResponse,
UpdateServerRequest,
Expand Down Expand Up @@ -328,3 +344,152 @@ export class API extends ParentAPI {
unmarshalConnectivityDiagnostic,
)
}

/** Apple silicon - Private Networks API. */
export class PrivateNetworkAPI extends ParentAPI {
/** Lists the available zones of the API. */
public static readonly LOCALITIES: Zone[] = ['fr-par-1', 'fr-par-3']

getServerPrivateNetwork = (
request: Readonly<PrivateNetworkApiGetServerPrivateNetworkRequest>,
) =>
this.client.fetch<ServerPrivateNetwork>(
{
method: 'GET',
path: `/apple-silicon/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}/private-networks/${validatePathParam('privateNetworkId', request.privateNetworkId)}`,
},
unmarshalServerPrivateNetwork,
)

/**
* Waits for {@link ServerPrivateNetwork} to be in a final state.
*
* @param request - The request
* {@link PrivateNetworkApiGetServerPrivateNetworkRequest}
* @param options - The waiting options
* @returns A Promise of ServerPrivateNetwork
*/
waitForServerPrivateNetwork = (
request: Readonly<PrivateNetworkApiGetServerPrivateNetworkRequest>,
options?: Readonly<WaitForOptions<ServerPrivateNetwork>>,
) =>
waitForResource(
options?.stop ??
(res =>
Promise.resolve(
!SERVER_PRIVATE_NETWORK_SERVER_TRANSIENT_STATUSES.includes(
res.status,
),
)),
this.getServerPrivateNetwork,
request,
options,
)

/**
* Add a server to a Private Network. Add an Apple silicon server to a Private
* Network.
*
* @param request - The request
* {@link PrivateNetworkApiAddServerPrivateNetworkRequest}
* @returns A Promise of ServerPrivateNetwork
*/
addServerPrivateNetwork = (
request: Readonly<PrivateNetworkApiAddServerPrivateNetworkRequest>,
) =>
this.client.fetch<ServerPrivateNetwork>(
{
body: JSON.stringify(
marshalPrivateNetworkApiAddServerPrivateNetworkRequest(
request,
this.client.settings,
),
),
headers: jsonContentHeaders,
method: 'POST',
path: `/apple-silicon/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}/private-networks`,
},
unmarshalServerPrivateNetwork,
)

/**
* Set multiple Private Networks on a server. Configure multiple Private
* Networks on an Apple silicon server.
*
* @param request - The request
* {@link PrivateNetworkApiSetServerPrivateNetworksRequest}
* @returns A Promise of SetServerPrivateNetworksResponse
*/
setServerPrivateNetworks = (
request: Readonly<PrivateNetworkApiSetServerPrivateNetworksRequest>,
) =>
this.client.fetch<SetServerPrivateNetworksResponse>(
{
body: JSON.stringify(
marshalPrivateNetworkApiSetServerPrivateNetworksRequest(
request,
this.client.settings,
),
),
headers: jsonContentHeaders,
method: 'PUT',
path: `/apple-silicon/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}/private-networks`,
},
unmarshalSetServerPrivateNetworksResponse,
)

protected pageOfListServerPrivateNetworks = (
request: Readonly<PrivateNetworkApiListServerPrivateNetworksRequest> = {},
) =>
this.client.fetch<ListServerPrivateNetworksResponse>(
{
method: 'GET',
path: `/apple-silicon/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/server-private-networks`,
urlParams: urlParams(
['ipam_ip_ids', request.ipamIpIds],
['order_by', request.orderBy],
['organization_id', request.organizationId],
['page', request.page],
[
'page_size',
request.pageSize ?? this.client.settings.defaultPageSize,
],
['private_network_id', request.privateNetworkId],
['project_id', request.projectId],
['server_id', request.serverId],
),
},
unmarshalListServerPrivateNetworksResponse,
)

/**
* List the Private Networks of a server. List the Private Networks of an
* Apple silicon server.
*
* @param request - The request
* {@link PrivateNetworkApiListServerPrivateNetworksRequest}
* @returns A Promise of ListServerPrivateNetworksResponse
*/
listServerPrivateNetworks = (
request: Readonly<PrivateNetworkApiListServerPrivateNetworksRequest> = {},
) =>
enrichForPagination(
'serverPrivateNetworks',
this.pageOfListServerPrivateNetworks,
request,
)

/**
* Delete a Private Network.
*
* @param request - The request
* {@link PrivateNetworkApiDeleteServerPrivateNetworkRequest}
*/
deleteServerPrivateNetwork = (
request: Readonly<PrivateNetworkApiDeleteServerPrivateNetworkRequest>,
) =>
this.client.fetch<void>({
method: 'DELETE',
path: `/apple-silicon/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}/private-networks/${validatePathParam('privateNetworkId', request.privateNetworkId)}`,
})
}
10 changes: 9 additions & 1 deletion packages/clients/src/api/applesilicon/v1alpha1/content.gen.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
// This file was automatically generated. DO NOT EDIT.
// If you have any remark or suggestion do not hesitate to open an issue.
import type { ServerPrivateNetworkStatus, ServerStatus } from './types.gen'
import type {
ServerPrivateNetworkServerStatus,
ServerPrivateNetworkStatus,
ServerStatus,
} from './types.gen'

/** Lists transient statutes of the enum {@link ServerPrivateNetworkServerStatus}. */
export const SERVER_PRIVATE_NETWORK_SERVER_TRANSIENT_STATUSES: ServerPrivateNetworkServerStatus[] =
['attaching', 'detaching']

/** Lists transient statutes of the enum {@link ServerPrivateNetworkStatus}. */
export const SERVER_PRIVATE_NETWORK_TRANSIENT_STATUSES: ServerPrivateNetworkStatus[] =
Expand Down
77 changes: 77 additions & 0 deletions packages/clients/src/api/applesilicon/v1alpha1/marshalling.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,22 @@ import type {
ConnectivityDiagnosticServerHealth,
CreateServerRequest,
ListOSResponse,
ListServerPrivateNetworksResponse,
ListServerTypesResponse,
ListServersResponse,
OS,
PrivateNetworkApiAddServerPrivateNetworkRequest,
PrivateNetworkApiSetServerPrivateNetworksRequest,
ReinstallServerRequest,
Server,
ServerPrivateNetwork,
ServerType,
ServerTypeCPU,
ServerTypeDisk,
ServerTypeGPU,
ServerTypeMemory,
ServerTypeNetwork,
SetServerPrivateNetworksResponse,
StartConnectivityDiagnosticRequest,
StartConnectivityDiagnosticResponse,
UpdateServerRequest,
Expand All @@ -48,6 +53,28 @@ export const unmarshalOS = (data: unknown): OS => {
} as OS
}

export const unmarshalServerPrivateNetwork = (
data: unknown,
): ServerPrivateNetwork => {
if (!isJSONObject(data)) {
throw new TypeError(
`Unmarshalling the type 'ServerPrivateNetwork' failed as data isn't a dictionary.`,
)
}

return {
createdAt: unmarshalDate(data.created_at),
id: data.id,
ipamIpIds: data.ipam_ip_ids,
privateNetworkId: data.private_network_id,
projectId: data.project_id,
serverId: data.server_id,
status: data.status,
updatedAt: unmarshalDate(data.updated_at),
vlan: data.vlan,
} as ServerPrivateNetwork
}

const unmarshalServerTypeCPU = (data: unknown): ServerTypeCPU => {
if (!isJSONObject(data)) {
throw new TypeError(
Expand Down Expand Up @@ -217,6 +244,24 @@ export const unmarshalListOSResponse = (data: unknown): ListOSResponse => {
} as ListOSResponse
}

export const unmarshalListServerPrivateNetworksResponse = (
data: unknown,
): ListServerPrivateNetworksResponse => {
if (!isJSONObject(data)) {
throw new TypeError(
`Unmarshalling the type 'ListServerPrivateNetworksResponse' failed as data isn't a dictionary.`,
)
}

return {
serverPrivateNetworks: unmarshalArrayOfObject(
data.server_private_networks,
unmarshalServerPrivateNetwork,
),
totalCount: data.total_count,
} as ListServerPrivateNetworksResponse
}

export const unmarshalListServerTypesResponse = (
data: unknown,
): ListServerTypesResponse => {
Expand Down Expand Up @@ -246,6 +291,23 @@ export const unmarshalListServersResponse = (
} as ListServersResponse
}

export const unmarshalSetServerPrivateNetworksResponse = (
data: unknown,
): SetServerPrivateNetworksResponse => {
if (!isJSONObject(data)) {
throw new TypeError(
`Unmarshalling the type 'SetServerPrivateNetworksResponse' failed as data isn't a dictionary.`,
)
}

return {
serverPrivateNetworks: unmarshalArrayOfObject(
data.server_private_networks,
unmarshalServerPrivateNetwork,
),
} as SetServerPrivateNetworksResponse
}

export const unmarshalStartConnectivityDiagnosticResponse = (
data: unknown,
): StartConnectivityDiagnosticResponse => {
Expand All @@ -271,6 +333,21 @@ export const marshalCreateServerRequest = (
type: request.type,
})

export const marshalPrivateNetworkApiAddServerPrivateNetworkRequest = (
request: PrivateNetworkApiAddServerPrivateNetworkRequest,
defaults: DefaultValues,
): Record<string, unknown> => ({
ipam_ip_ids: request.ipamIpIds,
private_network_id: request.privateNetworkId,
})

export const marshalPrivateNetworkApiSetServerPrivateNetworksRequest = (
request: PrivateNetworkApiSetServerPrivateNetworksRequest,
defaults: DefaultValues,
): Record<string, unknown> => ({
per_private_network_ipam_ip_ids: request.perPrivateNetworkIpamIpIds,
})

export const marshalReinstallServerRequest = (
request: ReinstallServerRequest,
defaults: DefaultValues,
Expand Down
Loading

0 comments on commit 571707f

Please sign in to comment.