Skip to content

Commit 6dc1996

Browse files
feat: added the following changes to DL SDK
1. Add capabilities field for Offering Speeds 2. Add Capabilities field for Cross Connect Routers
1 parent e82ec1d commit 6dc1996

File tree

3 files changed

+70
-33
lines changed

3 files changed

+70
-33
lines changed

ibm_cloud_networking_services/direct_link_v1.py

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# coding: utf-8
22

3-
# (C) Copyright IBM Corp. 2020.
3+
# (C) Copyright IBM Corp. 2021.
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.
@@ -1168,29 +1168,36 @@ class CrossConnectRouter():
11681168
"""
11691169
Cross Connect Router details.
11701170
1171+
:attr List[str] capabilities: (optional) Array of capabilities for this router.
11711172
:attr str router_name: (optional) The name of the Router.
11721173
:attr int total_connections: (optional) Count of existing Direct Link Dedicated
11731174
gateways on this router for this account.
11741175
"""
11751176

11761177
def __init__(self,
11771178
*,
1179+
capabilities: List[str] = None,
11781180
router_name: str = None,
11791181
total_connections: int = None) -> None:
11801182
"""
11811183
Initialize a CrossConnectRouter object.
11821184
1185+
:param List[str] capabilities: (optional) Array of capabilities for this
1186+
router.
11831187
:param str router_name: (optional) The name of the Router.
11841188
:param int total_connections: (optional) Count of existing Direct Link
11851189
Dedicated gateways on this router for this account.
11861190
"""
1191+
self.capabilities = capabilities
11871192
self.router_name = router_name
11881193
self.total_connections = total_connections
11891194

11901195
@classmethod
11911196
def from_dict(cls, _dict: Dict) -> 'CrossConnectRouter':
11921197
"""Initialize a CrossConnectRouter object from a json dictionary."""
11931198
args = {}
1199+
if 'capabilities' in _dict:
1200+
args['capabilities'] = _dict.get('capabilities')
11941201
if 'router_name' in _dict:
11951202
args['router_name'] = _dict.get('router_name')
11961203
if 'total_connections' in _dict:
@@ -1205,6 +1212,8 @@ def _from_dict(cls, _dict):
12051212
def to_dict(self) -> Dict:
12061213
"""Return a json dictionary representing this model."""
12071214
_dict = {}
1215+
if hasattr(self, 'capabilities') and self.capabilities is not None:
1216+
_dict['capabilities'] = self.capabilities
12081217
if hasattr(self, 'router_name') and self.router_name is not None:
12091218
_dict['router_name'] = self.router_name
12101219
if hasattr(self, 'total_connections') and self.total_connections is not None:
@@ -1235,7 +1244,7 @@ class Gateway():
12351244
12361245
:attr int bgp_asn: Customer BGP ASN.
12371246
:attr str bgp_base_cidr: (optional) (DEPRECATED) BGP base CIDR is deprecated and
1238-
no longer recognized the Direct Link APIs.
1247+
no longer recognized by the Direct Link APIs.
12391248
See bgp_cer_cidr and bgp_ibm_cidr fields instead for IP related information.
12401249
Deprecated field bgp_base_cidr will be removed from the API specificiation after
12411250
15-MAR-2021.
@@ -1343,7 +1352,7 @@ def __init__(self,
13431352
property may expand in the future. Code and processes using this field
13441353
must tolerate unexpected values.
13451354
:param str bgp_base_cidr: (optional) (DEPRECATED) BGP base CIDR is
1346-
deprecated and no longer recognized the Direct Link APIs.
1355+
deprecated and no longer recognized by the Direct Link APIs.
13471356
See bgp_cer_cidr and bgp_ibm_cidr fields instead for IP related
13481357
information.
13491358
Deprecated field bgp_base_cidr will be removed from the API specificiation
@@ -1724,10 +1733,10 @@ class GatewayMacsecConfig():
17241733
association key.
17251734
:attr int sak_expiry_time: (optional) Secure Association Key (SAK) expiry time
17261735
in seconds.
1727-
:attr str security_policy: (optional) Packets without MACsec headers are not
1728-
dropped when security_policy is `should_secure`.
1736+
:attr str security_policy: (optional) Packets without MACsec headers are dropped
1737+
when security_policy is `must_secure`.
17291738
:attr str status: Current status of MACsec on this gateway.
1730-
Status 'unknown' is returned during gateway creation and deletion.
1739+
Status 'offline' is returned during gateway creation and deletion.
17311740
:attr int window_size: (optional) replay protection window size.
17321741
"""
17331742

@@ -1754,7 +1763,7 @@ def __init__(self,
17541763
:param GatewayMacsecConfigPrimaryCak primary_cak: desired primary
17551764
connectivity association key.
17561765
:param str status: Current status of MACsec on this gateway.
1757-
Status 'unknown' is returned during gateway creation and deletion.
1766+
Status 'offline' is returned during gateway creation and deletion.
17581767
:param GatewayMacsecConfigActiveCak active_cak: (optional) Active
17591768
connectivity association key.
17601769
During normal operation `active_cak` will match the desired `primary_cak`.
@@ -1769,7 +1778,7 @@ def __init__(self,
17691778
:param int sak_expiry_time: (optional) Secure Association Key (SAK) expiry
17701779
time in seconds.
17711780
:param str security_policy: (optional) Packets without MACsec headers are
1772-
not dropped when security_policy is `should_secure`.
1781+
dropped when security_policy is `must_secure`.
17731782
:param int window_size: (optional) replay protection window size.
17741783
"""
17751784
self.active = active
@@ -1889,21 +1898,20 @@ class CryptographicAlgorithmEnum(Enum):
18891898

18901899
class SecurityPolicyEnum(Enum):
18911900
"""
1892-
Packets without MACsec headers are not dropped when security_policy is
1893-
`should_secure`.
1901+
Packets without MACsec headers are dropped when security_policy is `must_secure`.
18941902
"""
1895-
SHOULD_SECURE = "should_secure"
1903+
MUST_SECURE = "must_secure"
18961904

18971905

18981906
class StatusEnum(Enum):
18991907
"""
19001908
Current status of MACsec on this gateway.
1901-
Status 'unknown' is returned during gateway creation and deletion.
1909+
Status 'offline' is returned during gateway creation and deletion.
19021910
"""
19031911
INIT = "init"
19041912
PENDING = "pending"
1913+
OFFLINE = "offline"
19051914
SECURED = "secured"
1906-
UNKNOWN = "unknown"
19071915

19081916

19091917
class GatewayMacsecConfigActiveCak():
@@ -3424,31 +3432,39 @@ class OfferingSpeed():
34243432
"""
34253433
Speed.
34263434
3435+
:attr List[str] capabilities: Array of capabilities for billing option.
34273436
:attr int link_speed: Link speed in megabits per second.
34283437
:attr bool macsec_enabled: (optional) Indicate whether speed supports MACsec.
34293438
Only returned for gateway type=dedicated speeds. Contact IBM support for access
34303439
to MACsec.
34313440
"""
34323441

34333442
def __init__(self,
3443+
capabilities: List[str],
34343444
link_speed: int,
34353445
*,
34363446
macsec_enabled: bool = None) -> None:
34373447
"""
34383448
Initialize a OfferingSpeed object.
34393449
3450+
:param List[str] capabilities: Array of capabilities for billing option.
34403451
:param int link_speed: Link speed in megabits per second.
34413452
:param bool macsec_enabled: (optional) Indicate whether speed supports
34423453
MACsec. Only returned for gateway type=dedicated speeds. Contact IBM
34433454
support for access to MACsec.
34443455
"""
3456+
self.capabilities = capabilities
34453457
self.link_speed = link_speed
34463458
self.macsec_enabled = macsec_enabled
34473459

34483460
@classmethod
34493461
def from_dict(cls, _dict: Dict) -> 'OfferingSpeed':
34503462
"""Initialize a OfferingSpeed object from a json dictionary."""
34513463
args = {}
3464+
if 'capabilities' in _dict:
3465+
args['capabilities'] = _dict.get('capabilities')
3466+
else:
3467+
raise ValueError('Required property \'capabilities\' not present in OfferingSpeed JSON')
34523468
if 'link_speed' in _dict:
34533469
args['link_speed'] = _dict.get('link_speed')
34543470
else:
@@ -3465,6 +3481,8 @@ def _from_dict(cls, _dict):
34653481
def to_dict(self) -> Dict:
34663482
"""Return a json dictionary representing this model."""
34673483
_dict = {}
3484+
if hasattr(self, 'capabilities') and self.capabilities is not None:
3485+
_dict['capabilities'] = self.capabilities
34683486
if hasattr(self, 'link_speed') and self.link_speed is not None:
34693487
_dict['link_speed'] = self.link_speed
34703488
if hasattr(self, 'macsec_enabled') and self.macsec_enabled is not None:

test/integration/test_direct_link_v1.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
1-
# -*- coding: utf-8 -*-
2-
# (C) Copyright IBM Corp. 2020.
1+
# coding: utf-8
2+
3+
# (C) Copyright IBM Corp. 2021.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
316

417
"""
518
Integration test code to execute DirectLink client functions
@@ -264,6 +277,8 @@ def test1_offering_type_speeds(self):
264277
assert response is not None
265278
assert response.get_status_code() == 200
266279
assert response.get_result() is not None
280+
#Check if we are recieving capabilities as part of 100G changes
281+
assert response.get_result().get("speeds")[0].get("capabilities") is not None
267282

268283

269284

0 commit comments

Comments
 (0)