Skip to content

Commit 47878a4

Browse files
feat(DirectLink): implement the DLaaS changes for Direct link gateway
Add connection_mode to Create/Update/Actions api for direct link gateways to specify the type of service this gateway attaches to. Mode transit means this Gateway will be attached to Transit Gateway Service and direct means this Gateway will be attached to vpc or classic connection
1 parent c283954 commit 47878a4

File tree

4 files changed

+399
-1
lines changed

4 files changed

+399
-1
lines changed

direct-link/v1.ts

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,10 @@ class DirectLinkV1 extends BaseService {
288288
* The key material that you provide must be base64 encoded and original string must be maximum 126 ASCII characters
289289
* in length.
290290
* To clear the optional `authentication_key` field patch its crn to `""`.
291+
* @param {string} [params.connectionMode] - Type of services this Gateway is attached to. Mode transit means this
292+
* Gateway will be attached to Transit Gateway Service and direct means this Gateway will be attached to vpc or
293+
* classic connection. The list of enumerated values for this property may expand in the future. Code and processes
294+
* using this field must tolerate unexpected values.
291295
* @param {boolean} [params.global] - Gateways with global routing (`true`) can connect to networks outside of their
292296
* associated region.
293297
* @param {string} [params.loaRejectReason] - Use this field during LOA rejection to provide the reason for the
@@ -324,6 +328,7 @@ class DirectLinkV1 extends BaseService {
324328

325329
const body = {
326330
'authentication_key': _params.authenticationKey,
331+
'connection_mode': _params.connectionMode,
327332
'global': _params.global,
328333
'loa_reject_reason': _params.loaRejectReason,
329334
'macsec_config': _params.macsecConfig,
@@ -379,6 +384,10 @@ class DirectLinkV1 extends BaseService {
379384
* The key material that you provide must be base64 encoded and original string must be maximum 126 ASCII characters
380385
* in length.
381386
* To clear the optional `authentication_key` field patch its crn to `""`.
387+
* @param {string} [params.connectionMode] - Type of services this Gateway is attached to. Mode transit means this
388+
* Gateway will be attached to Transit Gateway Service and direct means this Gateway will be attached to vpc or
389+
* classic connection. The list of enumerated values for this property may expand in the future. Code and processes
390+
* using this field must tolerate unexpected values.
382391
* @param {boolean} [params.global] - Required for create_gateway_approve requests to select the gateway's routing
383392
* option. Gateways with global routing (`true`) can connect to networks outside of their associated region.
384393
* @param {boolean} [params.metered] - Required for create_gateway_approve requests to select the gateway's metered
@@ -406,6 +415,7 @@ class DirectLinkV1 extends BaseService {
406415
const body = {
407416
'action': _params.action,
408417
'authentication_key': _params.authenticationKey,
418+
'connection_mode': _params.connectionMode,
409419
'global': _params.global,
410420
'metered': _params.metered,
411421
'resource_group': _params.resourceGroup,
@@ -1250,6 +1260,12 @@ namespace DirectLinkV1 {
12501260
* To clear the optional `authentication_key` field patch its crn to `""`.
12511261
*/
12521262
authenticationKey?: GatewayPatchTemplateAuthenticationKey;
1263+
/** Type of services this Gateway is attached to. Mode transit means this Gateway will be attached to Transit
1264+
* Gateway Service and direct means this Gateway will be attached to vpc or classic connection. The list of
1265+
* enumerated values for this property may expand in the future. Code and processes using this field must tolerate
1266+
* unexpected values.
1267+
*/
1268+
connectionMode?: UpdateGatewayConstants.ConnectionMode | string;
12531269
/** Gateways with global routing (`true`) can connect to networks outside of their associated region. */
12541270
global?: boolean;
12551271
/** Use this field during LOA rejection to provide the reason for the rejection.
@@ -1284,6 +1300,11 @@ namespace DirectLinkV1 {
12841300

12851301
/** Constants for the `updateGateway` operation. */
12861302
export namespace UpdateGatewayConstants {
1303+
/** Type of services this Gateway is attached to. Mode transit means this Gateway will be attached to Transit Gateway Service and direct means this Gateway will be attached to vpc or classic connection. The list of enumerated values for this property may expand in the future. Code and processes using this field must tolerate unexpected values. */
1304+
export enum ConnectionMode {
1305+
DIRECT = 'direct',
1306+
TRANSIT = 'transit',
1307+
}
12871308
/** Gateway operational status. For gateways pending LOA approval, patch operational_status to the appropriate value to approve or reject its LOA. When rejecting an LOA, provide reject reasoning in `loa_reject_reason`. Only allowed for type=dedicated gateways. */
12881309
export enum OperationalStatus {
12891310
LOA_ACCEPTED = 'loa_accepted',
@@ -1303,6 +1324,12 @@ namespace DirectLinkV1 {
13031324
* To clear the optional `authentication_key` field patch its crn to `""`.
13041325
*/
13051326
authenticationKey?: GatewayActionTemplateAuthenticationKey;
1327+
/** Type of services this Gateway is attached to. Mode transit means this Gateway will be attached to Transit
1328+
* Gateway Service and direct means this Gateway will be attached to vpc or classic connection. The list of
1329+
* enumerated values for this property may expand in the future. Code and processes using this field must tolerate
1330+
* unexpected values.
1331+
*/
1332+
connectionMode?: CreateGatewayActionConstants.ConnectionMode | string;
13061333
/** Required for create_gateway_approve requests to select the gateway's routing option. Gateways with global
13071334
* routing (`true`) can connect to networks outside of their associated region.
13081335
*/
@@ -1335,6 +1362,11 @@ namespace DirectLinkV1 {
13351362
UPDATE_ATTRIBUTES_APPROVE = 'update_attributes_approve',
13361363
UPDATE_ATTRIBUTES_REJECT = 'update_attributes_reject',
13371364
}
1365+
/** Type of services this Gateway is attached to. Mode transit means this Gateway will be attached to Transit Gateway Service and direct means this Gateway will be attached to vpc or classic connection. The list of enumerated values for this property may expand in the future. Code and processes using this field must tolerate unexpected values. */
1366+
export enum ConnectionMode {
1367+
DIRECT = 'direct',
1368+
TRANSIT = 'transit',
1369+
}
13381370
}
13391371

13401372
/** Parameters for the `listGatewayCompletionNotice` operation. */
@@ -1552,7 +1584,7 @@ namespace DirectLinkV1 {
15521584
/** (DEPRECATED) BGP base CIDR is deprecated and no longer recognized by the Direct Link APIs.
15531585
*
15541586
* See bgp_cer_cidr and bgp_ibm_cidr fields instead for IP related information.
1555-
*
1587+
*
15561588
* Deprecated field bgp_base_cidr will be removed from the API specificiation after 15-MAR-2021.
15571589
*/
15581590
bgp_base_cidr?: string;
@@ -1574,6 +1606,12 @@ namespace DirectLinkV1 {
15741606
* notice.
15751607
*/
15761608
completion_notice_reject_reason?: string;
1609+
/** Type of services this Gateway is attached to. Mode transit means this Gateway will be attached to Transit
1610+
* Gateway Service and direct means this Gateway will be attached to vpc or classic connection. The list of
1611+
* enumerated values for this property may expand in the future. Code and processes using this field must tolerate
1612+
* unexpected values.
1613+
*/
1614+
connection_mode?: string;
15771615
/** The date and time resource was created. */
15781616
created_at: string;
15791617
/** The CRN (Cloud Resource Name) of this gateway. */
@@ -1867,6 +1905,12 @@ namespace DirectLinkV1 {
18671905
* bgp_ibm_cidr must have matching network and subnet mask values.
18681906
*/
18691907
bgp_ibm_cidr?: string;
1908+
/** Type of services this Gateway is attached to. Mode transit means this Gateway will be attached to Transit
1909+
* Gateway Service and direct means this Gateway will be attached to vpc or classic connection. The list of
1910+
* enumerated values for this property may expand in the future. Code and processes using this field must tolerate
1911+
* unexpected values.
1912+
*/
1913+
connection_mode?: string;
18701914
/** Gateways with global routing (`true`) can connect to networks outside their associated region. */
18711915
global: boolean;
18721916
/** Metered billing option. When `true` gateway usage is billed per gigabyte. When `false` there is no per

test/integration/direct-link-provider.v2.test.js

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,4 +727,122 @@ describe('DirectLinkProviderV2', () => {
727727
}
728728
});
729729
});
730+
731+
describe('Direct Link Provider Gateways with DLAAS', () => {
732+
jest.setTimeout(timeout);
733+
734+
const time = currentDate.getTime().toString();
735+
const gwName = 'NODE-INT-SDK-PROVIDER-DLAAS-' + time;
736+
const speedMbps = 1000;
737+
738+
let portId = '';
739+
let gatewayId = '';
740+
741+
const params = {
742+
name: gwName,
743+
speedMbps,
744+
bgpAsn: 64999,
745+
metered: false,
746+
customerAccountId: config.CUSTOMER_ACCT_ID,
747+
};
748+
749+
it('should successfully get the provider port', async done => {
750+
try {
751+
const response = await dlProviderService.listProviderPorts({});
752+
expect(response).toBeDefined();
753+
expect(response.status).toEqual(200);
754+
755+
const { result } = response || {};
756+
expect(result.ports.length).toBeGreaterThan(0);
757+
portId = result.ports[0].id;
758+
done();
759+
} catch (err) {
760+
done(err);
761+
}
762+
});
763+
764+
it('should create a provider gateway', async done => {
765+
try {
766+
const response = await dlProviderService.createProviderGateway({
767+
...params,
768+
port: { id: portId },
769+
});
770+
expect(response).toBeDefined();
771+
expect(response.status).toEqual(201);
772+
gatewayId = response.result.id;
773+
done();
774+
} catch (err) {
775+
done(err);
776+
}
777+
});
778+
779+
it('should successfully approve the provider created gateway with connection mode set as transit', async done => {
780+
try {
781+
const response = await dlService.createGatewayAction({
782+
id: gatewayId,
783+
action: 'create_gateway_approve',
784+
global: false,
785+
metered: false,
786+
connectionMode: 'transit',
787+
});
788+
789+
expect(response).toBeDefined();
790+
expect(response.status).toEqual(200);
791+
const { result } = response || {};
792+
expect(result.id).toBe(gatewayId);
793+
expect(result.name).toEqual(gwName);
794+
expect(result.connection_mode).toEqual('transit');
795+
expect(result.type).toEqual('connect');
796+
expect(result.speed_mbps).toEqual(speedMbps);
797+
expect(result.bgp_asn).toEqual(params.bgpAsn);
798+
expect(result.port.id).toBe(portId);
799+
expect(result.global).toBeFalsy();
800+
expect(result.metered).toBeFalsy();
801+
done();
802+
} catch (err) {
803+
done(err);
804+
}
805+
});
806+
807+
it('should successfully wait for the gateway to move to provisioned state', async done => {
808+
try {
809+
const result = await poll(
810+
() => dlProviderService.getProviderGateway({ id: gatewayId }),
811+
result => result.operational_status === 'provisioned',
812+
100
813+
);
814+
815+
expect(result).toBeDefined();
816+
expect(result.operational_status).toEqual('provisioned');
817+
done();
818+
} catch (err) {
819+
done(err);
820+
}
821+
});
822+
823+
it('should successfully request delete gateway using provider account', async done => {
824+
try {
825+
const response = await dlProviderService.deleteProviderGateway({ id: gatewayId });
826+
expect(response).toBeDefined();
827+
expect(response.status).toEqual(202);
828+
done();
829+
} catch (err) {
830+
done(err);
831+
}
832+
});
833+
834+
it('should successfully approve delete gayeway using client account', async done => {
835+
try {
836+
const response = await dlService.createGatewayAction({
837+
id: gatewayId,
838+
action: 'delete_gateway_approve',
839+
});
840+
expect(response).toBeDefined();
841+
expect(response.status).toEqual(204);
842+
done();
843+
} catch (err) {
844+
done(err);
845+
}
846+
});
847+
});
730848
});

0 commit comments

Comments
 (0)