From 0e721b38aaf991127afb05eeb1987bc7ac43d92d Mon Sep 17 00:00:00 2001 From: scaleway-bot Date: Mon, 2 Sep 2024 14:09:30 +0000 Subject: [PATCH] feat: update generated APIs --- packages/clients/src/api/ipam/v1/api.gen.ts | 77 +++++++++++++++++++ packages/clients/src/api/ipam/v1/index.gen.ts | 4 + .../src/api/ipam/v1/marshalling.gen.ts | 41 ++++++++++ packages/clients/src/api/ipam/v1/types.gen.ts | 56 ++++++++++++++ 4 files changed, 178 insertions(+) diff --git a/packages/clients/src/api/ipam/v1/api.gen.ts b/packages/clients/src/api/ipam/v1/api.gen.ts index 580f5841d..c6861455f 100644 --- a/packages/clients/src/api/ipam/v1/api.gen.ts +++ b/packages/clients/src/api/ipam/v1/api.gen.ts @@ -9,18 +9,24 @@ import { } from '../../../bridge' import type { Region } from '../../../bridge' import { + marshalAttachIPRequest, marshalBookIPRequest, + marshalDetachIPRequest, + marshalMoveIPRequest, marshalReleaseIPSetRequest, marshalUpdateIPRequest, unmarshalIP, unmarshalListIPsResponse, } from './marshalling.gen' import type { + AttachIPRequest, BookIPRequest, + DetachIPRequest, GetIPRequest, IP, ListIPsRequest, ListIPsResponse, + MoveIPRequest, ReleaseIPRequest, ReleaseIPSetRequest, UpdateIPRequest, @@ -165,4 +171,75 @@ export class API extends ParentAPI { */ listIPs = (request: Readonly = {}) => enrichForPagination('ips', this.pageOfListIPs, request) + + /** + * Attach existing IP to custom resource. Attach an existing IP from a Private + * Network subnet to a custom, named resource via its MAC address. An example + * of a custom resource is a virtual machine hosted on an Elastic Metal + * server. Do not use this method for attaching IP addresses to standard + * Scaleway resources as it will fail - see the relevant product API for an + * equivalent method. + * + * @param request - The request {@link AttachIPRequest} + * @returns A Promise of IP + */ + attachIP = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalAttachIPRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/ipam/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/ips/${validatePathParam('ipId', request.ipId)}/attach`, + }, + unmarshalIP, + ) + + /** + * Detach existing IP from a custom resource. Detach a private IP from a + * custom resource. An example of a custom resource is a virtual machine + * hosted on an Elastic Metal server. Do not use this method for attaching IP + * addresses to standard Scaleway resources (e.g. Instances, Load Balancers) + * as it will fail - see the relevant product API for an equivalent method. + * + * @param request - The request {@link DetachIPRequest} + * @returns A Promise of IP + */ + detachIP = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalDetachIPRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/ipam/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/ips/${validatePathParam('ipId', request.ipId)}/detach`, + }, + unmarshalIP, + ) + + /** + * Move existing IP to a custom resource. Move an existing private IP from one + * custom resource (e.g. a virtual machine hosted on an Elastic Metal server) + * to another custom resource. This will detach it from the first resource, + * and attach it to the second. Do not use this method for moving IP addresses + * between standard Scaleway resources (e.g. Instances, Load Balancers) as it + * will fail - see the relevant product API for an equivalent method. + * + * @param request - The request {@link MoveIPRequest} + * @returns A Promise of IP + */ + moveIP = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalMoveIPRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/ipam/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/ips/${validatePathParam('ipId', request.ipId)}/move`, + }, + unmarshalIP, + ) } diff --git a/packages/clients/src/api/ipam/v1/index.gen.ts b/packages/clients/src/api/ipam/v1/index.gen.ts index 9213a8b72..dd119cc13 100644 --- a/packages/clients/src/api/ipam/v1/index.gen.ts +++ b/packages/clients/src/api/ipam/v1/index.gen.ts @@ -2,12 +2,16 @@ // If you have any remark or suggestion do not hesitate to open an issue. export { API } from './api.gen' export type { + AttachIPRequest, BookIPRequest, + CustomResource, + DetachIPRequest, GetIPRequest, IP, ListIPsRequest, ListIPsRequestOrderBy, ListIPsResponse, + MoveIPRequest, ReleaseIPRequest, ReleaseIPSetRequest, Resource, diff --git a/packages/clients/src/api/ipam/v1/marshalling.gen.ts b/packages/clients/src/api/ipam/v1/marshalling.gen.ts index b28d0f8eb..62443b5c8 100644 --- a/packages/clients/src/api/ipam/v1/marshalling.gen.ts +++ b/packages/clients/src/api/ipam/v1/marshalling.gen.ts @@ -8,9 +8,13 @@ import { } from '../../../bridge' import type { DefaultValues } from '../../../bridge' import type { + AttachIPRequest, BookIPRequest, + CustomResource, + DetachIPRequest, IP, ListIPsResponse, + MoveIPRequest, ReleaseIPSetRequest, Resource, Reverse, @@ -96,6 +100,21 @@ export const unmarshalListIPsResponse = (data: unknown): ListIPsResponse => { } as ListIPsResponse } +const marshalCustomResource = ( + request: CustomResource, + defaults: DefaultValues, +): Record => ({ + mac_address: request.macAddress, + name: request.name, +}) + +export const marshalAttachIPRequest = ( + request: AttachIPRequest, + defaults: DefaultValues, +): Record => ({ + resource: marshalCustomResource(request.resource, defaults), +}) + const marshalSource = ( request: Source, defaults: DefaultValues, @@ -114,10 +133,32 @@ export const marshalBookIPRequest = ( address: request.address, is_ipv6: request.isIpv6, project_id: request.projectId ?? defaults.defaultProjectId, + resource: + request.resource !== undefined + ? marshalCustomResource(request.resource, defaults) + : undefined, source: marshalSource(request.source, defaults), tags: request.tags, }) +export const marshalDetachIPRequest = ( + request: DetachIPRequest, + defaults: DefaultValues, +): Record => ({ + resource: marshalCustomResource(request.resource, defaults), +}) + +export const marshalMoveIPRequest = ( + request: MoveIPRequest, + defaults: DefaultValues, +): Record => ({ + from_resource: marshalCustomResource(request.fromResource, defaults), + to_resource: + request.toResource !== undefined + ? marshalCustomResource(request.toResource, defaults) + : undefined, +}) + export const marshalReleaseIPSetRequest = ( request: ReleaseIPSetRequest, defaults: DefaultValues, diff --git a/packages/clients/src/api/ipam/v1/types.gen.ts b/packages/clients/src/api/ipam/v1/types.gen.ts index 36abacc00..4b225bf27 100644 --- a/packages/clients/src/api/ipam/v1/types.gen.ts +++ b/packages/clients/src/api/ipam/v1/types.gen.ts @@ -12,6 +12,7 @@ export type ListIPsRequestOrderBy = export type ResourceType = | 'unknown_type' + | 'custom' | 'instance_server' | 'instance_ip' | 'instance_private_nic' @@ -72,6 +73,16 @@ export interface Source { subnetId?: string } +export interface CustomResource { + /** MAC address of the custom resource. */ + macAddress: string + /** + * When the resource is in a Private Network, a DNS record is available to + * resolve the resource name. + */ + name?: string +} + export interface IP { /** IP ID. */ id: string @@ -99,6 +110,18 @@ export interface IP { zone?: Zone } +export type AttachIPRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** IP ID. */ + ipId: string + /** Custom resource to be attached to the IP. */ + resource: CustomResource +} + export type BookIPRequest = { /** * Region to target. If none is passed will use default region from the @@ -122,6 +145,25 @@ export type BookIPRequest = { address?: string /** Tags for the IP. */ tags?: string[] + /** + * Custom resource to attach to the IP being booked. An example of a custom + * resource is a virtual machine hosted on an Elastic Metal server. Do not use + * this for attaching IP addresses to standard Scaleway resources, as it will + * fail - instead, see the relevant product API for an equivalent method. + */ + resource?: CustomResource +} + +export type DetachIPRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** IP ID. */ + ipId: string + /** Custom resource currently attached to the IP. */ + resource: CustomResource } export type GetIPRequest = { @@ -221,6 +263,20 @@ export interface ListIPsResponse { ips: IP[] } +export type MoveIPRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** IP ID. */ + ipId: string + /** Custom resource currently attached to the IP. */ + fromResource: CustomResource + /** Custom resource to be attached to the IP. */ + toResource?: CustomResource +} + export type ReleaseIPRequest = { /** * Region to target. If none is passed will use default region from the