@@ -5,16 +5,23 @@ import {
55 enrichForPagination ,
66 urlParams ,
77 validatePathParam ,
8+ waitForResource ,
89} from '@scaleway/sdk-client'
9- import type { Region as ScwRegion } from '@scaleway/sdk-client'
10+ import type { Region as ScwRegion , WaitForOptions } from '@scaleway/sdk-client'
11+ import {
12+ DEDICATED_CONNECTION_TRANSIENT_STATUSES as DEDICATED_CONNECTION_TRANSIENT_STATUSES_INTERLINK ,
13+ LINK_TRANSIENT_STATUSES as LINK_TRANSIENT_STATUSES_INTERLINK ,
14+ } from './content.gen'
1015import {
1116 marshalAttachRoutingPolicyRequest ,
1217 marshalAttachVpcRequest ,
1318 marshalCreateLinkRequest ,
1419 marshalCreateRoutingPolicyRequest ,
1520 marshalUpdateLinkRequest ,
1621 marshalUpdateRoutingPolicyRequest ,
22+ unmarshalDedicatedConnection ,
1723 unmarshalLink ,
24+ unmarshalListDedicatedConnectionsResponse ,
1825 unmarshalListLinksResponse ,
1926 unmarshalListPartnersResponse ,
2027 unmarshalListPopsResponse ,
@@ -28,17 +35,21 @@ import type {
2835 AttachVpcRequest ,
2936 CreateLinkRequest ,
3037 CreateRoutingPolicyRequest ,
38+ DedicatedConnection ,
3139 DeleteLinkRequest ,
3240 DeleteRoutingPolicyRequest ,
3341 DetachRoutingPolicyRequest ,
3442 DetachVpcRequest ,
3543 DisableRoutePropagationRequest ,
3644 EnableRoutePropagationRequest ,
45+ GetDedicatedConnectionRequest ,
3746 GetLinkRequest ,
3847 GetPartnerRequest ,
3948 GetPopRequest ,
4049 GetRoutingPolicyRequest ,
4150 Link ,
51+ ListDedicatedConnectionsRequest ,
52+ ListDedicatedConnectionsResponse ,
4253 ListLinksRequest ,
4354 ListLinksResponse ,
4455 ListPartnersRequest ,
@@ -72,6 +83,91 @@ export class API extends ParentAPI {
7283 'pl-waw' ,
7384 ]
7485
86+ protected pageOfListDedicatedConnections = (
87+ request : Readonly < ListDedicatedConnectionsRequest > = { } ,
88+ ) =>
89+ this . client . fetch < ListDedicatedConnectionsResponse > (
90+ {
91+ method : 'GET' ,
92+ path : `/interlink/v1beta1/regions/${ validatePathParam ( 'region' , request . region ?? this . client . settings . defaultRegion ) } /dedicated-connections` ,
93+ urlParams : urlParams (
94+ [ 'bandwidth_mbps' , request . bandwidthMbps ] ,
95+ [ 'name' , request . name ] ,
96+ [ 'order_by' , request . orderBy ] ,
97+ [ 'organization_id' , request . organizationId ] ,
98+ [ 'page' , request . page ] ,
99+ [
100+ 'page_size' ,
101+ request . pageSize ?? this . client . settings . defaultPageSize ,
102+ ] ,
103+ [ 'pop_id' , request . popId ] ,
104+ [ 'project_id' , request . projectId ] ,
105+ [ 'status' , request . status ] ,
106+ [ 'tags' , request . tags ] ,
107+ ) ,
108+ } ,
109+ unmarshalListDedicatedConnectionsResponse ,
110+ )
111+
112+ /**
113+ * List dedicated connections. For self-hosted users, list their dedicated
114+ * physical connections in a given region. By default, the connections
115+ * returned in the list are ordered by name in ascending order, though this
116+ * can be modified via the `order_by` field.
117+ *
118+ * @param request - The request {@link ListDedicatedConnectionsRequest}
119+ * @returns A Promise of ListDedicatedConnectionsResponse
120+ */
121+ listDedicatedConnections = (
122+ request : Readonly < ListDedicatedConnectionsRequest > = { } ,
123+ ) =>
124+ enrichForPagination (
125+ 'connections' ,
126+ this . pageOfListDedicatedConnections ,
127+ request ,
128+ )
129+
130+ /**
131+ * Get a dedicated connection. For self-hosted users, get a dedicated physical
132+ * connection corresponding to the given ID. The response object includes
133+ * information such as the connection's name, status and total bandwidth.
134+ *
135+ * @param request - The request {@link GetDedicatedConnectionRequest}
136+ * @returns A Promise of DedicatedConnection
137+ */
138+ getDedicatedConnection = ( request : Readonly < GetDedicatedConnectionRequest > ) =>
139+ this . client . fetch < DedicatedConnection > (
140+ {
141+ method : 'GET' ,
142+ path : `/interlink/v1beta1/regions/${ validatePathParam ( 'region' , request . region ?? this . client . settings . defaultRegion ) } /dedicated-connections/${ validatePathParam ( 'connectionId' , request . connectionId ) } ` ,
143+ } ,
144+ unmarshalDedicatedConnection ,
145+ )
146+
147+ /**
148+ * Waits for {@link DedicatedConnection} to be in a final state.
149+ *
150+ * @param request - The request {@link GetDedicatedConnectionRequest}
151+ * @param options - The waiting options
152+ * @returns A Promise of DedicatedConnection
153+ */
154+ waitForDedicatedConnection = (
155+ request : Readonly < GetDedicatedConnectionRequest > ,
156+ options ?: Readonly < WaitForOptions < DedicatedConnection > > ,
157+ ) =>
158+ waitForResource (
159+ options ?. stop ??
160+ ( res =>
161+ Promise . resolve (
162+ ! DEDICATED_CONNECTION_TRANSIENT_STATUSES_INTERLINK . includes (
163+ res . status ,
164+ ) ,
165+ ) ) ,
166+ this . getDedicatedConnection ,
167+ request ,
168+ options ,
169+ )
170+
75171 protected pageOfListPartners = (
76172 request : Readonly < ListPartnersRequest > = { } ,
77173 ) =>
@@ -126,6 +222,7 @@ export class API extends ParentAPI {
126222 method : 'GET' ,
127223 path : `/interlink/v1beta1/regions/${ validatePathParam ( 'region' , request . region ?? this . client . settings . defaultRegion ) } /pops` ,
128224 urlParams : urlParams (
225+ [ 'dedicated_available' , request . dedicatedAvailable ] ,
129226 [ 'hosting_provider_name' , request . hostingProviderName ] ,
130227 [ 'link_bandwidth_mbps' , request . linkBandwidthMbps ] ,
131228 [ 'name' , request . name ] ,
@@ -176,6 +273,8 @@ export class API extends ParentAPI {
176273 [ 'bandwidth_mbps' , request . bandwidthMbps ] ,
177274 [ 'bgp_v4_status' , request . bgpV4Status ] ,
178275 [ 'bgp_v6_status' , request . bgpV6Status ] ,
276+ [ 'connection_id' , request . connectionId ] ,
277+ [ 'kind' , request . kind ] ,
179278 [ 'name' , request . name ] ,
180279 [ 'order_by' , request . orderBy ] ,
181280 [ 'organization_id' , request . organizationId ] ,
@@ -208,9 +307,9 @@ export class API extends ParentAPI {
208307 enrichForPagination ( 'links' , this . pageOfListLinks , request )
209308
210309 /**
211- * Get a link. Get a link (InterLink connection) for the given link ID. The
212- * response object includes information about the link's various configuration
213- * details.
310+ * Get a link. Get a link (InterLink session / logical InterLink resource) for
311+ * the given link ID. The response object includes information about the
312+ * link's various configuration details.
214313 *
215314 * @param request - The request {@link GetLinkRequest}
216315 * @returns A Promise of Link
@@ -225,10 +324,33 @@ export class API extends ParentAPI {
225324 )
226325
227326 /**
228- * Create a link. Create a link (InterLink connection) in a given PoP,
229- * specifying its various configuration details. For the moment only hosted
230- * links (faciliated by partners) are available, though in the future
231- * dedicated and shared links will also be possible.
327+ * Waits for {@link Link} to be in a final state.
328+ *
329+ * @param request - The request {@link GetLinkRequest}
330+ * @param options - The waiting options
331+ * @returns A Promise of Link
332+ */
333+ waitForLink = (
334+ request : Readonly < GetLinkRequest > ,
335+ options ?: Readonly < WaitForOptions < Link > > ,
336+ ) =>
337+ waitForResource (
338+ options ?. stop ??
339+ ( res =>
340+ Promise . resolve (
341+ ! LINK_TRANSIENT_STATUSES_INTERLINK . includes ( res . status ) ,
342+ ) ) ,
343+ this . getLink ,
344+ request ,
345+ options ,
346+ )
347+
348+ /**
349+ * Create a link. Create a link (InterLink session / logical InterLink
350+ * resource) in a given PoP, specifying its various configuration details.
351+ * Links can either be hosted (faciliated by partners' shared physical
352+ * connections) or self-hosted (for users who have purchased a dedicated
353+ * physical connection).
232354 *
233355 * @param request - The request {@link CreateLinkRequest}
234356 * @returns A Promise of Link
0 commit comments