Skip to content

Commit

Permalink
chore(baremetal): generate SDK v3 (#1464)
Browse files Browse the repository at this point in the history
  • Loading branch information
scaleway-bot authored Oct 4, 2024
1 parent 0ab8ab3 commit 050ca6f
Show file tree
Hide file tree
Showing 6 changed files with 362 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/clients/src/api/baremetal/index.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
*/

export * as v1 from './v1/index'
export * as v3 from './v3/index.gen'
149 changes: 149 additions & 0 deletions packages/clients/src/api/baremetal/v3/api.gen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
// This file was automatically generated. DO NOT EDIT.
// If you have any remark or suggestion do not hesitate to open an issue.
import {
API as ParentAPI,
enrichForPagination,
urlParams,
validatePathParam,
} from '../../../bridge'
import type { Zone } from '../../../bridge'
import {
marshalPrivateNetworkApiAddServerPrivateNetworkRequest,
marshalPrivateNetworkApiSetServerPrivateNetworksRequest,
unmarshalListServerPrivateNetworksResponse,
unmarshalServerPrivateNetwork,
unmarshalSetServerPrivateNetworksResponse,
} from './marshalling.gen'
import type {
ListServerPrivateNetworksResponse,
PrivateNetworkApiAddServerPrivateNetworkRequest,
PrivateNetworkApiDeleteServerPrivateNetworkRequest,
PrivateNetworkApiListServerPrivateNetworksRequest,
PrivateNetworkApiSetServerPrivateNetworksRequest,
ServerPrivateNetwork,
SetServerPrivateNetworksResponse,
} from './types.gen'

const jsonContentHeaders = {
'Content-Type': 'application/json; charset=utf-8',
}

/** Elastic Metal - 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-2',
'nl-ams-1',
'nl-ams-2',
'pl-waw-2',
'pl-waw-3',
]

/**
* Add a server to a Private Network. Add an Elastic Metal 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: `/baremetal/v3/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 Elastic Metal 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: `/baremetal/v3/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: `/baremetal/v3/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
* Elastic Metal 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: `/baremetal/v3/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}/private-networks/${validatePathParam('privateNetworkId', request.privateNetworkId)}`,
})
}
7 changes: 7 additions & 0 deletions packages/clients/src/api/baremetal/v3/content.gen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// 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 } from './types.gen'

/** Lists transient statutes of the enum {@link ServerPrivateNetworkStatus}. */
export const SERVER_PRIVATE_NETWORK_TRANSIENT_STATUSES: ServerPrivateNetworkStatus[] =
['attaching', 'detaching']
15 changes: 15 additions & 0 deletions packages/clients/src/api/baremetal/v3/index.gen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// This file was automatically generated. DO NOT EDIT.
// If you have any remark or suggestion do not hesitate to open an issue.
export { PrivateNetworkAPI } from './api.gen'
export * from './content.gen'
export type {
ListServerPrivateNetworksRequestOrderBy,
ListServerPrivateNetworksResponse,
PrivateNetworkApiAddServerPrivateNetworkRequest,
PrivateNetworkApiDeleteServerPrivateNetworkRequest,
PrivateNetworkApiListServerPrivateNetworksRequest,
PrivateNetworkApiSetServerPrivateNetworksRequest,
ServerPrivateNetwork,
ServerPrivateNetworkStatus,
SetServerPrivateNetworksResponse,
} from './types.gen'
87 changes: 87 additions & 0 deletions packages/clients/src/api/baremetal/v3/marshalling.gen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// This file was automatically generated. DO NOT EDIT.
// If you have any remark or suggestion do not hesitate to open an issue.
import {
isJSONObject,
unmarshalArrayOfObject,
unmarshalDate,
} from '../../../bridge'
import type { DefaultValues } from '../../../bridge'
import type {
ListServerPrivateNetworksResponse,
PrivateNetworkApiAddServerPrivateNetworkRequest,
PrivateNetworkApiSetServerPrivateNetworksRequest,
ServerPrivateNetwork,
SetServerPrivateNetworksResponse,
} from './types.gen'

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
}

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 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 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,
})
103 changes: 103 additions & 0 deletions packages/clients/src/api/baremetal/v3/types.gen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
// This file was automatically generated. DO NOT EDIT.
// If you have any remark or suggestion do not hesitate to open an issue.
import type { Zone } from '../../../bridge'

export type ListServerPrivateNetworksRequestOrderBy =
| 'created_at_asc'
| 'created_at_desc'
| 'updated_at_asc'
| 'updated_at_desc'

export type ServerPrivateNetworkStatus =
| 'unknown_status'
| 'attaching'
| 'attached'
| 'error'
| 'detaching'
| 'locked'

export interface ServerPrivateNetwork {
/** UUID of the Server-to-Private Network mapping. */
id: string
/** Private Network Project UUID. */
projectId: string
/** Server UUID. */
serverId: string
/** Private Network UUID. */
privateNetworkId: string
/** VLAN UUID associated with the Private Network. */
vlan?: number
/** Configuration status of the Private Network. */
status: ServerPrivateNetworkStatus
/** Private Network creation date. */
createdAt?: Date
/** Date the Private Network was last modified. */
updatedAt?: Date
/** IPAM IP IDs of the server, if it has any. */
ipamIpIds: string[]
}

export interface ListServerPrivateNetworksResponse {
serverPrivateNetworks: ServerPrivateNetwork[]
totalCount: number
}

export type PrivateNetworkApiAddServerPrivateNetworkRequest = {
/** Zone to target. If none is passed will use default zone from the config. */
zone?: Zone
/** UUID of the server. */
serverId: string
/** UUID of the Private Network. */
privateNetworkId: string
/** IPAM IDs of an IPs to attach to the server. */
ipamIpIds?: string[]
}

export type PrivateNetworkApiDeleteServerPrivateNetworkRequest = {
/** Zone to target. If none is passed will use default zone from the config. */
zone?: Zone
/** UUID of the server. */
serverId: string
/** UUID of the Private Network. */
privateNetworkId: string
}

export type PrivateNetworkApiListServerPrivateNetworksRequest = {
/** Zone to target. If none is passed will use default zone from the config. */
zone?: Zone
/** Sort order for the returned Private Networks. */
orderBy?: ListServerPrivateNetworksRequestOrderBy
/** Page number for the returned Private Networks. */
page?: number
/** Maximum number of Private Networks per page. */
pageSize?: number
/** Filter Private Networks by server UUID. */
serverId?: string
/** Filter Private Networks by Private Network UUID. */
privateNetworkId?: string
/** Filter Private Networks by organization UUID. */
organizationId?: string
/** Filter Private Networks by project UUID. */
projectId?: string
/** Filter Private Networks by IPAM IP UUIDs. */
ipamIpIds?: string[]
}

export type PrivateNetworkApiSetServerPrivateNetworksRequest = {
/** Zone to target. If none is passed will use default zone from the config. */
zone?: Zone
/** UUID of the server. */
serverId: string
/**
* Object where the keys are the UUIDs of Private Networks and the values are
* arrays of IPAM IDs representing the IPs to assign to this Elastic Metal
* server on the Private Network. If the array supplied for a Private Network
* is empty, the next available IP from the Private Network's CIDR block will
* automatically be used for attachment.
*/
perPrivateNetworkIpamIpIds: Record<string, string[]>
}

export interface SetServerPrivateNetworksResponse {
serverPrivateNetworks: ServerPrivateNetwork[]
}

0 comments on commit 050ca6f

Please sign in to comment.