Skip to content
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
138 changes: 130 additions & 8 deletions packages/clients/src/api/interlink/v1beta1/api.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,23 @@ import {
enrichForPagination,
urlParams,
validatePathParam,
waitForResource,
} from '@scaleway/sdk-client'
import type { Region as ScwRegion } from '@scaleway/sdk-client'
import type { Region as ScwRegion, WaitForOptions } from '@scaleway/sdk-client'
import {
DEDICATED_CONNECTION_TRANSIENT_STATUSES as DEDICATED_CONNECTION_TRANSIENT_STATUSES_INTERLINK,
LINK_TRANSIENT_STATUSES as LINK_TRANSIENT_STATUSES_INTERLINK,
} from './content.gen'
import {
marshalAttachRoutingPolicyRequest,
marshalAttachVpcRequest,
marshalCreateLinkRequest,
marshalCreateRoutingPolicyRequest,
marshalUpdateLinkRequest,
marshalUpdateRoutingPolicyRequest,
unmarshalDedicatedConnection,
unmarshalLink,
unmarshalListDedicatedConnectionsResponse,
unmarshalListLinksResponse,
unmarshalListPartnersResponse,
unmarshalListPopsResponse,
Expand All @@ -28,17 +35,21 @@ import type {
AttachVpcRequest,
CreateLinkRequest,
CreateRoutingPolicyRequest,
DedicatedConnection,
DeleteLinkRequest,
DeleteRoutingPolicyRequest,
DetachRoutingPolicyRequest,
DetachVpcRequest,
DisableRoutePropagationRequest,
EnableRoutePropagationRequest,
GetDedicatedConnectionRequest,
GetLinkRequest,
GetPartnerRequest,
GetPopRequest,
GetRoutingPolicyRequest,
Link,
ListDedicatedConnectionsRequest,
ListDedicatedConnectionsResponse,
ListLinksRequest,
ListLinksResponse,
ListPartnersRequest,
Expand Down Expand Up @@ -72,6 +83,91 @@ export class API extends ParentAPI {
'pl-waw',
]

protected pageOfListDedicatedConnections = (
request: Readonly<ListDedicatedConnectionsRequest> = {},
) =>
this.client.fetch<ListDedicatedConnectionsResponse>(
{
method: 'GET',
path: `/interlink/v1beta1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/dedicated-connections`,
urlParams: urlParams(
['bandwidth_mbps', request.bandwidthMbps],
['name', request.name],
['order_by', request.orderBy],
['organization_id', request.organizationId],
['page', request.page],
[
'page_size',
request.pageSize ?? this.client.settings.defaultPageSize,
],
['pop_id', request.popId],
['project_id', request.projectId],
['status', request.status],
['tags', request.tags],
),
},
unmarshalListDedicatedConnectionsResponse,
)

/**
* List dedicated connections. For self-hosted users, list their dedicated
* physical connections in a given region. By default, the connections
* 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 ListDedicatedConnectionsRequest}
* @returns A Promise of ListDedicatedConnectionsResponse
*/
listDedicatedConnections = (
request: Readonly<ListDedicatedConnectionsRequest> = {},
) =>
enrichForPagination(
'connections',
this.pageOfListDedicatedConnections,
request,
)

/**
* Get a dedicated connection. For self-hosted users, get a dedicated physical
* connection corresponding to the given ID. The response object includes
* information such as the connection's name, status and total bandwidth.
*
* @param request - The request {@link GetDedicatedConnectionRequest}
* @returns A Promise of DedicatedConnection
*/
getDedicatedConnection = (request: Readonly<GetDedicatedConnectionRequest>) =>
this.client.fetch<DedicatedConnection>(
{
method: 'GET',
path: `/interlink/v1beta1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/dedicated-connections/${validatePathParam('connectionId', request.connectionId)}`,
},
unmarshalDedicatedConnection,
)

/**
* Waits for {@link DedicatedConnection} to be in a final state.
*
* @param request - The request {@link GetDedicatedConnectionRequest}
* @param options - The waiting options
* @returns A Promise of DedicatedConnection
*/
waitForDedicatedConnection = (
request: Readonly<GetDedicatedConnectionRequest>,
options?: Readonly<WaitForOptions<DedicatedConnection>>,
) =>
waitForResource(
options?.stop ??
(res =>
Promise.resolve(
!DEDICATED_CONNECTION_TRANSIENT_STATUSES_INTERLINK.includes(
res.status,
),
)),
this.getDedicatedConnection,
request,
options,
)

protected pageOfListPartners = (
request: Readonly<ListPartnersRequest> = {},
) =>
Expand Down Expand Up @@ -126,6 +222,7 @@ export class API extends ParentAPI {
method: 'GET',
path: `/interlink/v1beta1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/pops`,
urlParams: urlParams(
['dedicated_available', request.dedicatedAvailable],
['hosting_provider_name', request.hostingProviderName],
['link_bandwidth_mbps', request.linkBandwidthMbps],
['name', request.name],
Expand Down Expand Up @@ -176,6 +273,8 @@ export class API extends ParentAPI {
['bandwidth_mbps', request.bandwidthMbps],
['bgp_v4_status', request.bgpV4Status],
['bgp_v6_status', request.bgpV6Status],
['connection_id', request.connectionId],
['kind', request.kind],
['name', request.name],
['order_by', request.orderBy],
['organization_id', request.organizationId],
Expand Down Expand Up @@ -208,9 +307,9 @@ export class API extends ParentAPI {
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.
* Get a link. Get a link (InterLink session / logical InterLink resource) 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
Expand All @@ -225,10 +324,33 @@ export class API extends ParentAPI {
)

/**
* 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.
* Waits for {@link Link} to be in a final state.
*
* @param request - The request {@link GetLinkRequest}
* @param options - The waiting options
* @returns A Promise of Link
*/
waitForLink = (
request: Readonly<GetLinkRequest>,
options?: Readonly<WaitForOptions<Link>>,
) =>
waitForResource(
options?.stop ??
(res =>
Promise.resolve(
!LINK_TRANSIENT_STATUSES_INTERLINK.includes(res.status),
)),
this.getLink,
request,
options,
)

/**
* Create a link. Create a link (InterLink session / logical InterLink
* resource) in a given PoP, specifying its various configuration details.
* Links can either be hosted (faciliated by partners' shared physical
* connections) or self-hosted (for users who have purchased a dedicated
* physical connection).
*
* @param request - The request {@link CreateLinkRequest}
* @returns A Promise of Link
Expand Down
10 changes: 10 additions & 0 deletions packages/clients/src/api/interlink/v1beta1/content.gen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// This file was automatically generated. DO NOT EDIT.
// If you have any remark or suggestion do not hesitate to open an issue.
import type { DedicatedConnectionStatus, LinkStatus } from './types.gen'

/** Lists transient statutes of the enum {@link DedicatedConnectionStatus}. */
export const DEDICATED_CONNECTION_TRANSIENT_STATUSES: DedicatedConnectionStatus[] =
['configuring']

/** Lists transient statutes of the enum {@link LinkStatus}. */
export const LINK_TRANSIENT_STATUSES: LinkStatus[] = ['configuring']
11 changes: 11 additions & 0 deletions packages/clients/src/api/interlink/v1beta1/index.gen.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
// 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 * from './content.gen'
export type {
AttachRoutingPolicyRequest,
AttachVpcRequest,
BgpConfig,
BgpStatus,
CreateLinkRequest,
CreateRoutingPolicyRequest,
DedicatedConnection,
DedicatedConnectionStatus,
DeleteLinkRequest,
DeleteRoutingPolicyRequest,
DetachRoutingPolicyRequest,
DetachVpcRequest,
DisableRoutePropagationRequest,
EnableRoutePropagationRequest,
GetDedicatedConnectionRequest,
GetLinkRequest,
GetPartnerRequest,
GetPopRequest,
GetRoutingPolicyRequest,
Link,
LinkKind,
LinkStatus,
ListDedicatedConnectionsRequest,
ListDedicatedConnectionsRequestOrderBy,
ListDedicatedConnectionsResponse,
ListLinksRequest,
ListLinksRequestOrderBy,
ListLinksResponse,
Expand All @@ -32,8 +41,10 @@ export type {
ListRoutingPoliciesRequestOrderBy,
ListRoutingPoliciesResponse,
Partner,
PartnerHost,
Pop,
RoutingPolicy,
SelfHost,
UpdateLinkRequest,
UpdateRoutingPolicyRequest,
} from './types.gen'
Expand Down
Loading
Loading