Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update generated apis #1696

Merged
merged 1 commit into from
Dec 27, 2024
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
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)}`,
})
}
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
12 changes: 11 additions & 1 deletion packages/clients/src/api/applesilicon/v1alpha1/index.gen.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file was automatically generated. DO NOT EDIT.
// If you have any remark or suggestion do not hesitate to open an issue.
export { API } from './api.gen'
export { API, PrivateNetworkAPI } from './api.gen'
export * from './content.gen'
export type {
ConnectivityDiagnostic,
Expand All @@ -15,15 +15,24 @@ export type {
GetServerTypeRequest,
ListOSRequest,
ListOSResponse,
ListServerPrivateNetworksRequestOrderBy,
ListServerPrivateNetworksResponse,
ListServerTypesRequest,
ListServerTypesResponse,
ListServersRequest,
ListServersRequestOrderBy,
ListServersResponse,
OS,
PrivateNetworkApiAddServerPrivateNetworkRequest,
PrivateNetworkApiDeleteServerPrivateNetworkRequest,
PrivateNetworkApiGetServerPrivateNetworkRequest,
PrivateNetworkApiListServerPrivateNetworksRequest,
PrivateNetworkApiSetServerPrivateNetworksRequest,
RebootServerRequest,
ReinstallServerRequest,
Server,
ServerPrivateNetwork,
ServerPrivateNetworkServerStatus,
ServerPrivateNetworkStatus,
ServerStatus,
ServerType,
Expand All @@ -33,6 +42,7 @@ export type {
ServerTypeMemory,
ServerTypeNetwork,
ServerTypeStock,
SetServerPrivateNetworksResponse,
StartConnectivityDiagnosticRequest,
StartConnectivityDiagnosticResponse,
UpdateServerRequest,
Expand Down
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
Loading