diff --git a/packages/clients/src/api/index.gen.ts b/packages/clients/src/api/index.gen.ts index f1ea4aea0..b4c0be94c 100644 --- a/packages/clients/src/api/index.gen.ts +++ b/packages/clients/src/api/index.gen.ts @@ -20,6 +20,7 @@ import * as Function from './function/index.gen' import * as Iam from './iam/index.gen' import * as Inference from './inference/index.gen' import * as Instance from './instance/index.gen' +import * as Interlink from './interlink/index.gen' import * as Iot from './iot/index.gen' import * as Ipam from './ipam/index.gen' import * as Ipfs from './ipfs/index.gen' @@ -62,6 +63,7 @@ export { Iam, Inference, Instance, + Interlink, Iot, Ipam, Ipfs, diff --git a/packages/clients/src/api/interlink/index.gen.ts b/packages/clients/src/api/interlink/index.gen.ts new file mode 100644 index 000000000..886270369 --- /dev/null +++ b/packages/clients/src/api/interlink/index.gen.ts @@ -0,0 +1,6 @@ +/** + * This file is automatically generated from /scripts/generate.js PLEASE DO NOT + * EDIT HERE + */ + +export * as v1beta1 from './v1beta1/index.gen' diff --git a/packages/clients/src/api/interlink/v1beta1/api.gen.ts b/packages/clients/src/api/interlink/v1beta1/api.gen.ts new file mode 100644 index 000000000..6a1d693dd --- /dev/null +++ b/packages/clients/src/api/interlink/v1beta1/api.gen.ts @@ -0,0 +1,514 @@ +// 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 { Region } from '../../../bridge' +import { + marshalAttachRoutingPolicyRequest, + marshalAttachVpcRequest, + marshalCreateLinkRequest, + marshalCreateRoutingPolicyRequest, + marshalUpdateLinkRequest, + marshalUpdateRoutingPolicyRequest, + unmarshalLink, + unmarshalListLinksResponse, + unmarshalListPartnersResponse, + unmarshalListPopsResponse, + unmarshalListRoutingPoliciesResponse, + unmarshalPartner, + unmarshalPop, + unmarshalRoutingPolicy, +} from './marshalling.gen' +import type { + AttachRoutingPolicyRequest, + AttachVpcRequest, + CreateLinkRequest, + CreateRoutingPolicyRequest, + DeleteLinkRequest, + DeleteRoutingPolicyRequest, + DetachRoutingPolicyRequest, + DetachVpcRequest, + DisableRoutePropagationRequest, + EnableRoutePropagationRequest, + GetLinkRequest, + GetPartnerRequest, + GetPopRequest, + GetRoutingPolicyRequest, + Link, + ListLinksRequest, + ListLinksResponse, + ListPartnersRequest, + ListPartnersResponse, + ListPopsRequest, + ListPopsResponse, + ListRoutingPoliciesRequest, + ListRoutingPoliciesResponse, + Partner, + Pop, + RoutingPolicy, + UpdateLinkRequest, + UpdateRoutingPolicyRequest, +} from './types.gen' + +const jsonContentHeaders = { + 'Content-Type': 'application/json; charset=utf-8', +} + +/** + * InterLink API. + * + * This API allows you to manage your Scaleway InterLink, to connect your + * on-premises infrastructure with your Scaleway VPC. + */ +export class API extends ParentAPI { + /** Lists the available regions of the API. */ + public static readonly LOCALITIES: Region[] = ['fr-par', 'nl-ams', 'pl-waw'] + + protected pageOfListPartners = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + method: 'GET', + path: `/interlink/v1beta1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/partners`, + urlParams: urlParams( + ['order_by', request.orderBy], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ['pop_ids', request.popIds], + ), + }, + unmarshalListPartnersResponse, + ) + + /** + * List available partners. List all available partners. By default, the + * partners returned in the list are ordered by name in ascending order, + * though this can be modified via the `order_by` field. + * + * @param request - The request {@link ListPartnersRequest} + * @returns A Promise of ListPartnersResponse + */ + listPartners = (request: Readonly = {}) => + enrichForPagination('partners', this.pageOfListPartners, request) + + /** + * Get a partner. Get a partner for the given partner IP. The response object + * includes information such as the partner's name, email address and portal + * URL. + * + * @param request - The request {@link GetPartnerRequest} + * @returns A Promise of Partner + */ + getPartner = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/interlink/v1beta1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/partners/${validatePathParam('partnerId', request.partnerId)}`, + }, + unmarshalPartner, + ) + + protected pageOfListPops = (request: Readonly = {}) => + this.client.fetch( + { + method: 'GET', + path: `/interlink/v1beta1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/pops`, + urlParams: urlParams( + ['hosting_provider_name', request.hostingProviderName], + ['link_bandwidth_mbps', request.linkBandwidthMbps], + ['name', request.name], + ['order_by', request.orderBy], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ['partner_id', request.partnerId], + ), + }, + unmarshalListPopsResponse, + ) + + /** + * List PoPs. List all available PoPs (locations) for a given region. By + * default, the results are returned in ascending alphabetical order by name. + * + * @param request - The request {@link ListPopsRequest} + * @returns A Promise of ListPopsResponse + */ + listPops = (request: Readonly = {}) => + enrichForPagination('pops', this.pageOfListPops, request) + + /** + * Get a PoP. Get a PoP for the given PoP ID. The response object includes the + * PoP's name and information about its physical location. + * + * @param request - The request {@link GetPopRequest} + * @returns A Promise of Pop + */ + getPop = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/interlink/v1beta1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/pops/${validatePathParam('popId', request.popId)}`, + }, + unmarshalPop, + ) + + protected pageOfListLinks = (request: Readonly = {}) => + this.client.fetch( + { + method: 'GET', + path: `/interlink/v1beta1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/links`, + urlParams: urlParams( + ['bandwidth_mbps', request.bandwidthMbps], + ['bgp_v4_status', request.bgpV4Status], + ['bgp_v6_status', request.bgpV6Status], + ['name', request.name], + ['order_by', request.orderBy], + ['organization_id', request.organizationId], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ['pairing_key', request.pairingKey], + ['partner_id', request.partnerId], + ['pop_id', request.popId], + ['project_id', request.projectId], + ['routing_policy_id', request.routingPolicyId], + ['status', request.status], + ['tags', request.tags], + ['vpc_id', request.vpcId], + ), + }, + unmarshalListLinksResponse, + ) + + /** + * List links. List all your links (InterLink connections). A number of + * filters are available, including Project ID, name, tags and status. + * + * @param request - The request {@link ListLinksRequest} + * @returns A Promise of ListLinksResponse + */ + listLinks = (request: Readonly = {}) => + enrichForPagination('links', this.pageOfListLinks, request) + + /** + * Get a link. Get a link (InterLink connection) for the given link ID. The + * response object includes information about the link's various configuration + * details. + * + * @param request - The request {@link GetLinkRequest} + * @returns A Promise of Link + */ + getLink = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/interlink/v1beta1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/links/${validatePathParam('linkId', request.linkId)}`, + }, + unmarshalLink, + ) + + /** + * Create a link. Create a link (InterLink connection) in a given PoP, + * specifying its various configuration details. For the moment only hosted + * links (faciliated by partners) are available, though in the future + * dedicated and shared links will also be possible. + * + * @param request - The request {@link CreateLinkRequest} + * @returns A Promise of Link + */ + createLink = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalCreateLinkRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/interlink/v1beta1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/links`, + }, + unmarshalLink, + ) + + /** + * Update a link. Update an existing link, specified by its link ID. Only its + * name and tags can be updated. + * + * @param request - The request {@link UpdateLinkRequest} + * @returns A Promise of Link + */ + updateLink = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalUpdateLinkRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'PATCH', + path: `/interlink/v1beta1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/links/${validatePathParam('linkId', request.linkId)}`, + }, + unmarshalLink, + ) + + /** + * Delete a link. Delete an existing link, specified by its link ID. Note that + * as well as deleting the link here on the Scaleway side, it is also + * necessary to request deletion from the partner on their side. Only when + * this action has been carried out on both sides will the resource be + * completely deleted. + * + * @param request - The request {@link DeleteLinkRequest} + * @returns A Promise of Link + */ + deleteLink = (request: Readonly) => + this.client.fetch( + { + method: 'DELETE', + path: `/interlink/v1beta1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/links/${validatePathParam('linkId', request.linkId)}`, + }, + unmarshalLink, + ) + + /** + * Attach a VPC. Attach a VPC to an existing link. This facilitates + * communication between the resources in your Scaleway VPC, and your + * on-premises infrastructure. + * + * @param request - The request {@link AttachVpcRequest} + * @returns A Promise of Link + */ + attachVpc = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalAttachVpcRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/interlink/v1beta1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/links/${validatePathParam('linkId', request.linkId)}/attach-vpc`, + }, + unmarshalLink, + ) + + /** + * Detach a VPC. Detach a VPC from an existing link. + * + * @param request - The request {@link DetachVpcRequest} + * @returns A Promise of Link + */ + detachVpc = (request: Readonly) => + this.client.fetch( + { + body: '{}', + headers: jsonContentHeaders, + method: 'POST', + path: `/interlink/v1beta1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/links/${validatePathParam('linkId', request.linkId)}/detach-vpc`, + }, + unmarshalLink, + ) + + /** + * Attach a routing policy. Attach a routing policy to an existing link. As + * all routes across the link are blocked by default, you must attach a + * routing policy to set IP prefix filters for allowed routes, facilitating + * traffic flow. + * + * @param request - The request {@link AttachRoutingPolicyRequest} + * @returns A Promise of Link + */ + attachRoutingPolicy = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalAttachRoutingPolicyRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/interlink/v1beta1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/links/${validatePathParam('linkId', request.linkId)}/attach-routing-policy`, + }, + unmarshalLink, + ) + + /** + * Detach a routing policy. Detach a routing policy from an existing link. + * Without a routing policy, all routes across the link are blocked by + * default. + * + * @param request - The request {@link DetachRoutingPolicyRequest} + * @returns A Promise of Link + */ + detachRoutingPolicy = (request: Readonly) => + this.client.fetch( + { + body: '{}', + headers: jsonContentHeaders, + method: 'POST', + path: `/interlink/v1beta1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/links/${validatePathParam('linkId', request.linkId)}/detach-routing-policy`, + }, + unmarshalLink, + ) + + /** + * Enable route propagation. Enable all allowed prefixes (defined in a routing + * policy) to be announced in the BGP session. This allows traffic to flow + * between the attached VPC and the on-premises infrastructure along the + * announced routes. Note that by default, even when route propagation is + * enabled, all routes are blocked. It is essential to attach a routing policy + * to define the ranges of routes to announce. + * + * @param request - The request {@link EnableRoutePropagationRequest} + * @returns A Promise of Link + */ + enableRoutePropagation = (request: Readonly) => + this.client.fetch( + { + body: '{}', + headers: jsonContentHeaders, + method: 'POST', + path: `/interlink/v1beta1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/links/${validatePathParam('linkId', request.linkId)}/enable-route-propagation`, + }, + unmarshalLink, + ) + + /** + * Disable route propagation. Prevent any prefixes from being announced in the + * BGP session. Traffic will not be able to flow over the InterLink until + * route propagation is re-enabled. + * + * @param request - The request {@link DisableRoutePropagationRequest} + * @returns A Promise of Link + */ + disableRoutePropagation = ( + request: Readonly, + ) => + this.client.fetch( + { + body: '{}', + headers: jsonContentHeaders, + method: 'POST', + path: `/interlink/v1beta1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/links/${validatePathParam('linkId', request.linkId)}/disable-route-propagation`, + }, + unmarshalLink, + ) + + protected pageOfListRoutingPolicies = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + method: 'GET', + path: `/interlink/v1beta1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/routing-policies`, + urlParams: urlParams( + ['name', request.name], + ['order_by', request.orderBy], + ['organization_id', request.organizationId], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ['project_id', request.projectId], + ['tags', request.tags], + ), + }, + unmarshalListRoutingPoliciesResponse, + ) + + /** + * List routing policies. List all routing policies in a given region. A + * routing policy can be attached to one or multiple links (InterLink + * connections). + * + * @param request - The request {@link ListRoutingPoliciesRequest} + * @returns A Promise of ListRoutingPoliciesResponse + */ + listRoutingPolicies = (request: Readonly = {}) => + enrichForPagination( + 'routingPolicies', + this.pageOfListRoutingPolicies, + request, + ) + + /** + * Get routing policy. Get a routing policy for the given routing policy ID. + * The response object gives information including the policy's name, tags and + * prefix filters. + * + * @param request - The request {@link GetRoutingPolicyRequest} + * @returns A Promise of RoutingPolicy + */ + getRoutingPolicy = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/interlink/v1beta1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/routing-policies/${validatePathParam('routingPolicyId', request.routingPolicyId)}`, + }, + unmarshalRoutingPolicy, + ) + + /** + * Create a routing policy. Create a routing policy. Routing policies allow + * you to set IP prefix filters to define the incoming route announcements to + * accept from the peer, and the outgoing routes to announce to the peer. + * + * @param request - The request {@link CreateRoutingPolicyRequest} + * @returns A Promise of RoutingPolicy + */ + createRoutingPolicy = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalCreateRoutingPolicyRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/interlink/v1beta1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/routing-policies`, + }, + unmarshalRoutingPolicy, + ) + + /** + * Update a routing policy. Update an existing routing policy, specified by + * its routing policy ID. Its name, tags and incoming/outgoing prefix filters + * can be updated. + * + * @param request - The request {@link UpdateRoutingPolicyRequest} + * @returns A Promise of RoutingPolicy + */ + updateRoutingPolicy = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalUpdateRoutingPolicyRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'PATCH', + path: `/interlink/v1beta1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/routing-policies/${validatePathParam('routingPolicyId', request.routingPolicyId)}`, + }, + unmarshalRoutingPolicy, + ) + + /** + * Delete a routing policy. Delete an existing routing policy, specified by + * its routing policy ID. + * + * @param request - The request {@link DeleteRoutingPolicyRequest} + */ + deleteRoutingPolicy = (request: Readonly) => + this.client.fetch({ + method: 'DELETE', + path: `/interlink/v1beta1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/routing-policies/${validatePathParam('routingPolicyId', request.routingPolicyId)}`, + }) +} diff --git a/packages/clients/src/api/interlink/v1beta1/index.gen.ts b/packages/clients/src/api/interlink/v1beta1/index.gen.ts new file mode 100644 index 000000000..710cd67c6 --- /dev/null +++ b/packages/clients/src/api/interlink/v1beta1/index.gen.ts @@ -0,0 +1,40 @@ +// 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 type { + AttachRoutingPolicyRequest, + AttachVpcRequest, + BgpStatus, + CreateLinkRequest, + CreateRoutingPolicyRequest, + DeleteLinkRequest, + DeleteRoutingPolicyRequest, + DetachRoutingPolicyRequest, + DetachVpcRequest, + DisableRoutePropagationRequest, + EnableRoutePropagationRequest, + GetLinkRequest, + GetPartnerRequest, + GetPopRequest, + GetRoutingPolicyRequest, + Link, + LinkStatus, + ListLinksRequest, + ListLinksRequestOrderBy, + ListLinksResponse, + ListPartnersRequest, + ListPartnersRequestOrderBy, + ListPartnersResponse, + ListPopsRequest, + ListPopsRequestOrderBy, + ListPopsResponse, + ListRoutingPoliciesRequest, + ListRoutingPoliciesRequestOrderBy, + ListRoutingPoliciesResponse, + Partner, + Pop, + RoutingPolicy, + UpdateLinkRequest, + UpdateRoutingPolicyRequest, +} from './types.gen' +export * as ValidationRules from './validation-rules.gen' diff --git a/packages/clients/src/api/interlink/v1beta1/marshalling.gen.ts b/packages/clients/src/api/interlink/v1beta1/marshalling.gen.ts new file mode 100644 index 000000000..6dfdd5848 --- /dev/null +++ b/packages/clients/src/api/interlink/v1beta1/marshalling.gen.ts @@ -0,0 +1,231 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. +import { + isJSONObject, + resolveOneOf, + unmarshalArrayOfObject, + unmarshalDate, +} from '../../../bridge' +import type { DefaultValues } from '../../../bridge' +import type { + AttachRoutingPolicyRequest, + AttachVpcRequest, + CreateLinkRequest, + CreateRoutingPolicyRequest, + Link, + ListLinksResponse, + ListPartnersResponse, + ListPopsResponse, + ListRoutingPoliciesResponse, + Partner, + Pop, + RoutingPolicy, + UpdateLinkRequest, + UpdateRoutingPolicyRequest, +} from './types.gen' + +export const unmarshalLink = (data: unknown): Link => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Link' failed as data isn't a dictionary.`, + ) + } + + return { + bandwidthMbps: data.bandwidth_mbps, + bgpV4Status: data.bgp_v4_status, + bgpV6Status: data.bgp_v6_status, + createdAt: unmarshalDate(data.created_at), + enableRoutePropagation: data.enable_route_propagation, + id: data.id, + name: data.name, + organizationId: data.organization_id, + pairingKey: data.pairing_key, + partnerId: data.partner_id, + popId: data.pop_id, + projectId: data.project_id, + region: data.region, + routingPolicyId: data.routing_policy_id, + status: data.status, + tags: data.tags, + updatedAt: unmarshalDate(data.updated_at), + vpcId: data.vpc_id, + } as Link +} + +export const unmarshalPartner = (data: unknown): Partner => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Partner' failed as data isn't a dictionary.`, + ) + } + + return { + contactEmail: data.contact_email, + createdAt: unmarshalDate(data.created_at), + id: data.id, + logoUrl: data.logo_url, + name: data.name, + portalUrl: data.portal_url, + updatedAt: unmarshalDate(data.updated_at), + } as Partner +} + +export const unmarshalPop = (data: unknown): Pop => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Pop' failed as data isn't a dictionary.`, + ) + } + + return { + address: data.address, + city: data.city, + hostingProviderName: data.hosting_provider_name, + id: data.id, + logoUrl: data.logo_url, + name: data.name, + region: data.region, + } as Pop +} + +export const unmarshalRoutingPolicy = (data: unknown): RoutingPolicy => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'RoutingPolicy' failed as data isn't a dictionary.`, + ) + } + + return { + createdAt: unmarshalDate(data.created_at), + id: data.id, + name: data.name, + organizationId: data.organization_id, + prefixFilterIn: data.prefix_filter_in, + prefixFilterOut: data.prefix_filter_out, + projectId: data.project_id, + region: data.region, + tags: data.tags, + updatedAt: unmarshalDate(data.updated_at), + } as RoutingPolicy +} + +export const unmarshalListLinksResponse = ( + data: unknown, +): ListLinksResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListLinksResponse' failed as data isn't a dictionary.`, + ) + } + + return { + links: unmarshalArrayOfObject(data.links, unmarshalLink), + totalCount: data.total_count, + } as ListLinksResponse +} + +export const unmarshalListPartnersResponse = ( + data: unknown, +): ListPartnersResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListPartnersResponse' failed as data isn't a dictionary.`, + ) + } + + return { + partners: unmarshalArrayOfObject(data.partners, unmarshalPartner), + totalCount: data.total_count, + } as ListPartnersResponse +} + +export const unmarshalListPopsResponse = (data: unknown): ListPopsResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListPopsResponse' failed as data isn't a dictionary.`, + ) + } + + return { + pops: unmarshalArrayOfObject(data.pops, unmarshalPop), + totalCount: data.total_count, + } as ListPopsResponse +} + +export const unmarshalListRoutingPoliciesResponse = ( + data: unknown, +): ListRoutingPoliciesResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListRoutingPoliciesResponse' failed as data isn't a dictionary.`, + ) + } + + return { + routingPolicies: unmarshalArrayOfObject( + data.routing_policies, + unmarshalRoutingPolicy, + ), + totalCount: data.total_count, + } as ListRoutingPoliciesResponse +} + +export const marshalAttachRoutingPolicyRequest = ( + request: AttachRoutingPolicyRequest, + defaults: DefaultValues, +): Record => ({ + routing_policy_id: request.routingPolicyId, +}) + +export const marshalAttachVpcRequest = ( + request: AttachVpcRequest, + defaults: DefaultValues, +): Record => ({ + vpc_id: request.vpcId, +}) + +export const marshalCreateLinkRequest = ( + request: CreateLinkRequest, + defaults: DefaultValues, +): Record => ({ + bandwidth_mbps: request.bandwidthMbps, + name: request.name, + pop_id: request.popId, + project_id: request.projectId ?? defaults.defaultProjectId, + tags: request.tags, + ...resolveOneOf([ + { param: 'dedicated', value: request.dedicated }, + { param: 'port_id', value: request.portId }, + { param: 'partner_id', value: request.partnerId }, + ]), +}) + +export const marshalCreateRoutingPolicyRequest = ( + request: CreateRoutingPolicyRequest, + defaults: DefaultValues, +): Record => ({ + name: request.name, + prefix_filter_in: request.prefixFilterIn, + prefix_filter_out: request.prefixFilterOut, + project_id: request.projectId ?? defaults.defaultProjectId, + tags: request.tags, +}) + +export const marshalUpdateLinkRequest = ( + request: UpdateLinkRequest, + defaults: DefaultValues, +): Record => ({ + name: request.name, + tags: request.tags, +}) + +export const marshalUpdateRoutingPolicyRequest = ( + request: UpdateRoutingPolicyRequest, + defaults: DefaultValues, +): Record => ({ + name: request.name, + prefix_filter_in: request.prefixFilterIn, + prefix_filter_out: request.prefixFilterOut, + tags: request.tags, +}) diff --git a/packages/clients/src/api/interlink/v1beta1/types.gen.ts b/packages/clients/src/api/interlink/v1beta1/types.gen.ts new file mode 100644 index 000000000..e7c545139 --- /dev/null +++ b/packages/clients/src/api/interlink/v1beta1/types.gen.ts @@ -0,0 +1,509 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. +import type { Region } from '../../../bridge' + +export type BgpStatus = 'unknown_bgp_status' | 'up' | 'down' + +export type LinkStatus = + | 'unknown_link_status' + | 'configuring' + | 'failed' + | 'requested' + | 'refused' + | 'expired' + | 'provisioning' + | 'active' + | 'limited_connectivity' + | 'all_down' + | 'deprovisioning' + | 'deleted' + | 'locked' + +export type ListLinksRequestOrderBy = + | 'created_at_asc' + | 'created_at_desc' + | 'name_asc' + | 'name_desc' + | 'status_asc' + | 'status_desc' + +export type ListPartnersRequestOrderBy = 'name_asc' | 'name_desc' + +export type ListPopsRequestOrderBy = 'name_asc' | 'name_desc' + +export type ListRoutingPoliciesRequestOrderBy = + | 'created_at_asc' + | 'created_at_desc' + | 'name_asc' + | 'name_desc' + +export interface Link { + /** Unique identifier of the link. */ + id: string + /** Project ID. */ + projectId: string + /** Organization ID. */ + organizationId: string + /** Name of the link. */ + name: string + /** List of tags associated with the link. */ + tags: string[] + /** ID of the PoP where the link's corresponding port is located. */ + popId: string + /** ID of the partner facilitating this link. */ + partnerId?: string + /** Rate limited bandwidth of the link. */ + bandwidthMbps: number + /** Status of the link. */ + status: LinkStatus + /** Status of the link's BGP IPv4 session. */ + bgpV4Status: BgpStatus + /** Status of the link's BGP IPv6 session. */ + bgpV6Status: BgpStatus + /** ID of the Scaleway VPC attached to the link. */ + vpcId?: string + /** ID of the routing policy attached to the link. */ + routingPolicyId?: string + /** + * Defines whether route propagation is enabled or not. To enable or disable + * route propagation, use the dedicated endpoint. + */ + enableRoutePropagation: boolean + /** Creation date of the link. */ + createdAt?: Date + /** Last modification date of the link. */ + updatedAt?: Date + /** Used to identify a link from a user or partner's point of view. */ + pairingKey: string + /** Region of the link. */ + region: Region +} + +export interface Partner { + /** Unique identifier of the partner. */ + id: string + /** Name of the partner. */ + name: string + /** Contact email address of partner. */ + contactEmail: string + /** Image URL of the partner's logo. */ + logoUrl: string + /** URL of the partner's portal. */ + portalUrl: string + /** Creation date of the partner. */ + createdAt?: Date + /** Last modification date of the partner. */ + updatedAt?: Date +} + +export interface Pop { + /** Unique identifier of the PoP. */ + id: string + /** Name of the PoP. It is the common reference of Hosting DC (ex: TH2). */ + name: string + /** + * Name of the PoP's hosting provider, e.g. Telehouse for TH2 or OpCore for + * DC3. + */ + hostingProviderName: string + /** Physical address of the PoP. */ + address: string + /** City where PoP is located. */ + city: string + /** Image URL of the PoP's logo. */ + logoUrl: string + /** Region of the PoP. */ + region: Region +} + +export interface RoutingPolicy { + /** Unique identifier of the routing policy. */ + id: string + /** Project ID. */ + projectId: string + /** Organization ID. */ + organizationId: string + /** Name of the routing policy. */ + name: string + /** List of tags associated with the routing policy. */ + tags: string[] + /** + * IP prefixes to accept from the peer (ranges of route announcements to + * accept). + */ + prefixFilterIn: string[] + /** IP prefix filters to advertise to the peer (ranges of routes to advertise). */ + prefixFilterOut: string[] + /** Creation date of the routing policy. */ + createdAt?: Date + /** Last modification date of the routing policy. */ + updatedAt?: Date + /** Region of the routing policy. */ + region: Region +} + +export type AttachRoutingPolicyRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** ID of the link to attach a routing policy to. */ + linkId: string + /** ID of the routing policy to be attached. */ + routingPolicyId: string +} + +export type AttachVpcRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** ID of the link to attach VPC to. */ + linkId: string + /** ID of the VPC to attach. */ + vpcId: string +} + +export type CreateLinkRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** ID of the Project to create the link in. */ + projectId?: string + /** Name of the link. */ + name: string + /** List of tags to apply to the link. */ + tags?: string[] + /** PoP (location) where the link will be created. */ + popId: string + /** + * Desired bandwidth for the link. Must be compatible with available link + * bandwidths and remaining bandwidth capacity of the port. + */ + bandwidthMbps: number + /** + * If true, a dedicated link (1 link per port, dedicated to one customer) will + * be crated. It is not necessary to specify a `port_id` or `partner_id`. A + * new port will created and assigned to the link. Note that Scaleway has not + * yet enabled the creation of dedicated links, this field is reserved for + * future use. + * + * One-of ('linkKind'): at most one of 'dedicated', 'portId', 'partnerId' + * could be set. + */ + dedicated?: boolean + /** + * If set, a shared link (N links per port, one of which is this customer's + * port) will be created. As the customer, specify the ID of the port you + * already have for this link. Note that shared links are not currently + * available. Note that Scaleway has not yet enabled the creation of shared + * links, this field is reserved for future use. + * + * One-of ('linkKind'): at most one of 'dedicated', 'portId', 'partnerId' + * could be set. + */ + portId?: string + /** + * If set, a hosted link (N links per port on a partner port) will be created. + * Specify the ID of the chosen partner, who already has a shareable port with + * available bandwidth. Note that this is currently the only type of link + * offered by Scaleway, and therefore this field must be set when creating a + * link. + * + * One-of ('linkKind'): at most one of 'dedicated', 'portId', 'partnerId' + * could be set. + */ + partnerId?: string +} + +export type CreateRoutingPolicyRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** ID of the Project to create the routing policy in. */ + projectId?: string + /** Name of the routing policy. */ + name: string + /** List of tags to apply to the routing policy. */ + tags?: string[] + /** + * IP prefixes to accept from the peer (ranges of route announcements to + * accept). + */ + prefixFilterIn?: string[] + /** IP prefix filters to advertise to the peer (ranges of routes to advertise). */ + prefixFilterOut?: string[] +} + +export type DeleteLinkRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** ID of the link to delete. */ + linkId: string +} + +export type DeleteRoutingPolicyRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** ID of the routing policy to delete. */ + routingPolicyId: string +} + +export type DetachRoutingPolicyRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** ID of the link to detach a routing policy from. */ + linkId: string +} + +export type DetachVpcRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** ID of the link to detach the VPC from. */ + linkId: string +} + +export type DisableRoutePropagationRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** ID of the link on which to disable route propagation. */ + linkId: string +} + +export type EnableRoutePropagationRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** ID of the link on which to enable route propagation. */ + linkId: string +} + +export type GetLinkRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** ID of the link to get. */ + linkId: string +} + +export type GetPartnerRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** ID of partner to get. */ + partnerId: string +} + +export type GetPopRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** ID of PoP to get. */ + popId: string +} + +export type GetRoutingPolicyRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** ID of the routing policy to get. */ + routingPolicyId: string +} + +export type ListLinksRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** Order in which to return results. */ + orderBy?: ListLinksRequestOrderBy + /** Page number to return. */ + page?: number + /** Maximum number of links to return per page. */ + pageSize?: number + /** Project ID to filter for. */ + projectId?: string + /** Organization ID to filter for. */ + organizationId?: string + /** Link name to filter for. */ + name?: string + /** Tags to filter for. */ + tags?: string[] + /** Link status to filter for. */ + status?: LinkStatus + /** BGP IPv4 status to filter for. */ + bgpV4Status?: BgpStatus + /** BGP IPv6 status to filter for. */ + bgpV6Status?: BgpStatus + /** Filter for links attached to this PoP (via ports). */ + popId?: string + /** Filter for link bandwidth (in Mbps). */ + bandwidthMbps?: number + /** Filter for links hosted by this partner. */ + partnerId?: string + /** Filter for links attached to this VPC. */ + vpcId?: string + /** Filter for links using this routing policy. */ + routingPolicyId?: string + /** Filter for the link with this pairing_key. */ + pairingKey?: string +} + +export interface ListLinksResponse { + /** List of links on the current page. */ + links: Link[] + /** Total number of links. */ + totalCount: number +} + +export type ListPartnersRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** Order in which to return results. */ + orderBy?: ListPartnersRequestOrderBy + /** Page number to return. */ + page?: number + /** Maximum number of partners to return per page. */ + pageSize?: number + /** Filter for partners present (offering a port) in one of these PoPs. */ + popIds?: string[] +} + +export interface ListPartnersResponse { + /** List of partners on current page. */ + partners: Partner[] + /** Total number of partners returned. */ + totalCount: number +} + +export type ListPopsRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** Order in which to return results. */ + orderBy?: ListPopsRequestOrderBy + /** Page number to return. */ + page?: number + /** Maximum number of PoPs to return per page. */ + pageSize?: number + /** PoP name to filter for. */ + name?: string + /** Hosting provider name to filter for. */ + hostingProviderName?: string + /** Filter for PoPs hosting an available shared port from this partner. */ + partnerId?: string + /** + * Filter for PoPs with a shared port allowing this bandwidth size. Note that + * we cannot guarantee that PoPs returned will have available capacity. + */ + linkBandwidthMbps?: number +} + +export interface ListPopsResponse { + /** List of PoPs on the current page. */ + pops: Pop[] + /** Total number of PoPs. */ + totalCount: number +} + +export type ListRoutingPoliciesRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** Order in which to return results. */ + orderBy?: ListRoutingPoliciesRequestOrderBy + /** Page number to return. */ + page?: number + /** Maximum number of routing policies to return per page. */ + pageSize?: number + /** Project ID to filter for. */ + projectId?: string + /** Organization ID to filter for. */ + organizationId?: string + /** Routing policy name to filter for. */ + name?: string + /** Tags to filter for. */ + tags?: string[] +} + +export interface ListRoutingPoliciesResponse { + routingPolicies: RoutingPolicy[] + totalCount: number +} + +export type UpdateLinkRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** ID of the link to update. */ + linkId: string + /** Name of the link. */ + name?: string + /** List of tags to apply to the link. */ + tags?: string[] +} + +export type UpdateRoutingPolicyRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** ID of the routing policy to update. */ + routingPolicyId: string + /** Name of the routing policy. */ + name?: string + /** List of tags to apply to the routing policy. */ + tags?: string[] + /** + * IP prefixes to accept from the peer (ranges of route announcements to + * accept). + */ + prefixFilterIn?: string[] + /** + * IP prefix filters for routes to advertise to the peer (ranges of routes to + * advertise). + */ + prefixFilterOut?: string[] +} diff --git a/packages/clients/src/api/interlink/v1beta1/validation-rules.gen.ts b/packages/clients/src/api/interlink/v1beta1/validation-rules.gen.ts new file mode 100644 index 000000000..40202ea39 --- /dev/null +++ b/packages/clients/src/api/interlink/v1beta1/validation-rules.gen.ts @@ -0,0 +1,107 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. + +export const CreateLinkRequest = { + bandwidthMbps: { + greaterThanOrEqual: 1, + lessThanOrEqual: 100000000, + }, + name: { + maxLength: 255, + minLength: 1, + }, +} + +export const CreateRoutingPolicyRequest = { + name: { + maxLength: 255, + minLength: 1, + }, +} + +export const Link = { + name: { + minLength: 1, + }, +} + +export const ListLinksRequest = { + page: { + greaterThanOrEqual: 1, + }, + pageSize: { + greaterThanOrEqual: 1, + lessThanOrEqual: 1000, + }, +} + +export const ListPartnersRequest = { + page: { + greaterThanOrEqual: 1, + }, + pageSize: { + greaterThanOrEqual: 1, + lessThanOrEqual: 1000, + }, +} + +export const ListPopsRequest = { + page: { + greaterThanOrEqual: 1, + }, + pageSize: { + greaterThanOrEqual: 1, + lessThanOrEqual: 1000, + }, +} + +export const ListRoutingPoliciesRequest = { + page: { + greaterThanOrEqual: 1, + }, + pageSize: { + greaterThanOrEqual: 1, + lessThanOrEqual: 1000, + }, +} + +export const Partner = { + name: { + minLength: 1, + }, +} + +export const Pop = { + address: { + minLength: 1, + }, + city: { + minLength: 1, + }, + hostingProviderName: { + minLength: 1, + }, + name: { + minLength: 1, + }, +} + +export const RoutingPolicy = { + name: { + minLength: 1, + }, +} + +export const UpdateLinkRequest = { + name: { + maxLength: 255, + minLength: 1, + }, +} + +export const UpdateRoutingPolicyRequest = { + name: { + maxLength: 255, + minLength: 1, + }, +}