Skip to content

Commit

Permalink
Revert "feat(baremetal): add support for private network (#211)" (#216)
Browse files Browse the repository at this point in the history
  • Loading branch information
scaleway-bot authored Nov 7, 2022
1 parent 7acdc5a commit 2cfd537
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 35 deletions.
50 changes: 33 additions & 17 deletions packages/clients/src/api/baremetal/v1/api.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import type { WaitForOptions, Zone } from '../../../bridge'
import { SERVER_TRANSIENT_STATUSES } from './content.gen'
import {
marshalAddOptionServerRequest,
marshalAddServerPrivateNetworkRequest,
marshalCreateServerRequest,
marshalInstallServerRequest,
marshalPrivateNetworkApiAddServerPrivateNetworkRequest,
marshalPrivateNetworkApiSetServerPrivateNetworksRequest,
marshalRebootServerRequest,
marshalSetServerPrivateNetworksRequest,
marshalStartBMCAccessRequest,
marshalStartServerRequest,
marshalUpdateIPRequest,
Expand All @@ -41,11 +41,9 @@ import {
} from './marshalling.gen'
import type {
AddOptionServerRequest,
AddServerPrivateNetworkRequest,
BMCAccess,
CreateServerRequest,
DeleteOptionServerRequest,
DeleteServerPrivateNetworkRequest,
DeleteServerRequest,
GetBMCAccessRequest,
GetOSRequest,
Expand All @@ -64,7 +62,6 @@ import type {
ListOptionsResponse,
ListServerEventsRequest,
ListServerEventsResponse,
ListServerPrivateNetworksRequest,
ListServerPrivateNetworksResponse,
ListServersRequest,
ListServersResponse,
Expand All @@ -73,10 +70,13 @@ import type {
OS,
Offer,
Option,
PrivateNetworkApiAddServerPrivateNetworkRequest,
PrivateNetworkApiDeleteServerPrivateNetworkRequest,
PrivateNetworkApiListServerPrivateNetworksRequest,
PrivateNetworkApiSetServerPrivateNetworksRequest,
RebootServerRequest,
Server,
ServerPrivateNetwork,
SetServerPrivateNetworksRequest,
SetServerPrivateNetworksResponse,
Setting,
StartBMCAccessRequest,
Expand Down Expand Up @@ -729,20 +729,30 @@ export class BaremetalV1GenAPI extends API {
},
unmarshalOS,
)
}

/** Elastic Metal Private Network API. */
export class BaremetalPrivateNetworkV1GenAPI extends API {
/** Lists the available zones of the API. */
public static readonly LOCALITIES: Zone[] = ['fr-par-2']

/**
* Add a server to a private network
*
* @param request - The request {@link AddServerPrivateNetworkRequest}
* @param request - The request
* {@link PrivateNetworkApiAddServerPrivateNetworkRequest}
* @returns A Promise of ServerPrivateNetwork
*/
addServerPrivateNetwork = (
request: Readonly<AddServerPrivateNetworkRequest>,
request: Readonly<PrivateNetworkApiAddServerPrivateNetworkRequest>,
) =>
this.client.fetch<ServerPrivateNetwork>(
{
body: JSON.stringify(
marshalAddServerPrivateNetworkRequest(request, this.client.settings),
marshalPrivateNetworkApiAddServerPrivateNetworkRequest(
request,
this.client.settings,
),
),
headers: jsonContentHeaders,
method: 'POST',
Expand All @@ -760,16 +770,20 @@ export class BaremetalV1GenAPI extends API {
/**
* Set multiple private networks on a server
*
* @param request - The request {@link SetServerPrivateNetworksRequest}
* @param request - The request
* {@link PrivateNetworkApiSetServerPrivateNetworksRequest}
* @returns A Promise of SetServerPrivateNetworksResponse
*/
setServerPrivateNetworks = (
request: Readonly<SetServerPrivateNetworksRequest>,
request: Readonly<PrivateNetworkApiSetServerPrivateNetworksRequest>,
) =>
this.client.fetch<SetServerPrivateNetworksResponse>(
{
body: JSON.stringify(
marshalSetServerPrivateNetworksRequest(request, this.client.settings),
marshalPrivateNetworkApiSetServerPrivateNetworksRequest(
request,
this.client.settings,
),
),
headers: jsonContentHeaders,
method: 'PUT',
Expand All @@ -785,7 +799,7 @@ export class BaremetalV1GenAPI extends API {
)

protected pageOfListServerPrivateNetworks = (
request: Readonly<ListServerPrivateNetworksRequest> = {},
request: Readonly<PrivateNetworkApiListServerPrivateNetworksRequest> = {},
) =>
this.client.fetch<ListServerPrivateNetworksResponse>(
{
Expand Down Expand Up @@ -820,11 +834,12 @@ export class BaremetalV1GenAPI extends API {
/**
* List the private networks of a server
*
* @param request - The request {@link ListServerPrivateNetworksRequest}
* @param request - The request
* {@link PrivateNetworkApiListServerPrivateNetworksRequest}
* @returns A Promise of ListServerPrivateNetworksResponse
*/
listServerPrivateNetworks = (
request: Readonly<ListServerPrivateNetworksRequest> = {},
request: Readonly<PrivateNetworkApiListServerPrivateNetworksRequest> = {},
) =>
enrichForPagination(
'serverPrivateNetworks',
Expand All @@ -835,10 +850,11 @@ export class BaremetalV1GenAPI extends API {
/**
* Delete a private network
*
* @param request - The request {@link DeleteServerPrivateNetworkRequest}
* @param request - The request
* {@link PrivateNetworkApiDeleteServerPrivateNetworkRequest}
*/
deleteServerPrivateNetwork = (
request: Readonly<DeleteServerPrivateNetworkRequest>,
request: Readonly<PrivateNetworkApiDeleteServerPrivateNetworkRequest>,
) =>
this.client.fetch<void>({
method: 'DELETE',
Expand Down
28 changes: 14 additions & 14 deletions packages/clients/src/api/baremetal/v1/marshalling.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
import type { DefaultValues } from '../../../bridge'
import type {
AddOptionServerRequest,
AddServerPrivateNetworkRequest,
BMCAccess,
CPU,
CreateServerRequest,
Expand All @@ -34,6 +33,8 @@ import type {
OfferOptionOffer,
Option,
PersistentMemory,
PrivateNetworkApiAddServerPrivateNetworkRequest,
PrivateNetworkApiSetServerPrivateNetworksRequest,
RaidController,
RebootServerRequest,
Server,
Expand All @@ -42,7 +43,6 @@ import type {
ServerOption,
ServerPrivateNetwork,
ServerRescueServer,
SetServerPrivateNetworksRequest,
SetServerPrivateNetworksResponse,
Setting,
StartBMCAccessRequest,
Expand Down Expand Up @@ -521,13 +521,6 @@ export const marshalAddOptionServerRequest = (
expires_at: request.expiresAt,
})

export const marshalAddServerPrivateNetworkRequest = (
request: AddServerPrivateNetworkRequest,
defaults: DefaultValues,
): Record<string, unknown> => ({
private_network_id: request.privateNetworkId,
})

export const marshalCreateServerRequest = (
request: CreateServerRequest,
defaults: DefaultValues,
Expand Down Expand Up @@ -567,20 +560,27 @@ export const marshalInstallServerRequest = (
user: request.user,
})

export const marshalRebootServerRequest = (
request: RebootServerRequest,
export const marshalPrivateNetworkApiAddServerPrivateNetworkRequest = (
request: PrivateNetworkApiAddServerPrivateNetworkRequest,
defaults: DefaultValues,
): Record<string, unknown> => ({
boot_type: request.bootType,
private_network_id: request.privateNetworkId,
})

export const marshalSetServerPrivateNetworksRequest = (
request: SetServerPrivateNetworksRequest,
export const marshalPrivateNetworkApiSetServerPrivateNetworksRequest = (
request: PrivateNetworkApiSetServerPrivateNetworksRequest,
defaults: DefaultValues,
): Record<string, unknown> => ({
private_network_ids: request.privateNetworkIds,
})

export const marshalRebootServerRequest = (
request: RebootServerRequest,
defaults: DefaultValues,
): Record<string, unknown> => ({
boot_type: request.bootType,
})

export const marshalStartBMCAccessRequest = (
request: StartBMCAccessRequest,
defaults: DefaultValues,
Expand Down
8 changes: 4 additions & 4 deletions packages/clients/src/api/baremetal/v1/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ export type GetOSRequest = {
osId: string
}

export type AddServerPrivateNetworkRequest = {
export type PrivateNetworkApiAddServerPrivateNetworkRequest = {
/** Zone to target. If none is passed will use default zone from the config */
zone?: Zone
/** The ID of the server */
Expand All @@ -766,7 +766,7 @@ export type AddServerPrivateNetworkRequest = {
privateNetworkId: string
}

export type SetServerPrivateNetworksRequest = {
export type PrivateNetworkApiSetServerPrivateNetworksRequest = {
/** Zone to target. If none is passed will use default zone from the config */
zone?: Zone
/** The ID of the server */
Expand All @@ -775,7 +775,7 @@ export type SetServerPrivateNetworksRequest = {
privateNetworkIds: Array<string>
}

export type ListServerPrivateNetworksRequest = {
export type PrivateNetworkApiListServerPrivateNetworksRequest = {
/** Zone to target. If none is passed will use default zone from the config */
zone?: Zone
/** The sort order for the returned private networks */
Expand All @@ -794,7 +794,7 @@ export type ListServerPrivateNetworksRequest = {
projectId?: string
}

export type DeleteServerPrivateNetworkRequest = {
export type PrivateNetworkApiDeleteServerPrivateNetworkRequest = {
/** Zone to target. If none is passed will use default zone from the config */
zone?: Zone
/** The ID of the server */
Expand Down

0 comments on commit 2cfd537

Please sign in to comment.