Skip to content

Commit 66ae69c

Browse files
feat: add the authentication_key for BGP MD5 authentication in directlink service
1. Add the option to add the authentication_key while approving provider created gateways 2. Add the authentication_key in the response while fetching gateways
1 parent 1cac1bb commit 66ae69c

File tree

5 files changed

+347
-39
lines changed

5 files changed

+347
-39
lines changed

.travis.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@ matrix:
1010
before_script:
1111
- >-
1212
[ -z "${TRAVIS_TAG}" ] && [ "${TRAVIS_PULL_REQUEST}" == "false" ]
13-
&& openssl aes-256-cbc -K $encrypted_fc092b9428d6_key -iv $encrypted_fc092b9428d6_iv -in cis.env.enc -out cis.env -d
14-
&& openssl aes-256-cbc -K $encrypted_d4a185972ecc_key -iv $encrypted_d4a185972ecc_iv -in pdns.env.enc -out pdns.env -d
15-
&& openssl aes-256-cbc -K $encrypted_16de86179301_key -iv $encrypted_16de86179301_iv -in .transit_env.enc -out .transit_env -d
16-
&& openssl aes-256-cbc -K $encrypted_27cb64608ff6_key -iv $encrypted_27cb64608ff6_iv -in dl.env.enc -out dl.env -d
17-
|| true
18-
[ -z "${TRAVIS_TAG}" ] && [ "${TRAVIS_PULL_REQUEST}" == "false" ]
13+
&& openssl aes-256-cbc -K $encrypted_fc092b9428d6_key -iv $encrypted_fc092b9428d6_iv -in cis.env.enc -out cis.env -d || true
14+
&& openssl aes-256-cbc -K $encrypted_d4a185972ecc_key -iv $encrypted_d4a185972ecc_iv -in pdns.env.enc -out pdns.env -d || true
15+
&& openssl aes-256-cbc -K $encrypted_16de86179301_key -iv $encrypted_16de86179301_iv -in .transit_env.enc -out .transit_env -d || true
16+
&& openssl aes-256-cbc -K $encrypted_27cb64608ff6_key -iv $encrypted_27cb64608ff6_iv -in dl.env.enc -out dl.env -d || true
1917
&& openssl aes-256-cbc -K $encrypted_89a9eb4f9417_key -iv $encrypted_89a9eb4f9417_iv -in dns.env.enc -out dns.env -d || true
2018
- python: 3.7
2119
- python: 3.8

dl.env.enc

304 Bytes
Binary file not shown.

ibm_cloud_networking_services/direct_link_v1.py

Lines changed: 160 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ def create_gateway_action(self,
348348
id: str,
349349
action: str,
350350
*,
351+
authentication_key: 'GatewayActionTemplateAuthenticationKey' = None,
351352
global_: bool = None,
352353
metered: bool = None,
353354
resource_group: 'ResourceGroupIdentity' = None,
@@ -363,6 +364,12 @@ def create_gateway_action(self,
363364
364365
:param str id: Direct Link Connect gateway identifier.
365366
:param str action: Action request.
367+
:param GatewayActionTemplateAuthenticationKey authentication_key:
368+
(optional) BGP MD5 authentication key.
369+
BGP MD5 keys must be type=standard.
370+
The key material that you provide must be base64 encoded and original
371+
string must be maximum 126 ASCII characters in length.
372+
To clear the optional `authentication_key` field patch its crn to `""`.
366373
:param bool global_: (optional) Required for create_gateway_approve
367374
requests to select the gateway's routing option. Gateways with global
368375
routing (`true`) can connect to networks outside of their associated
@@ -389,6 +396,8 @@ def create_gateway_action(self,
389396
raise ValueError('id must be provided')
390397
if action is None:
391398
raise ValueError('action must be provided')
399+
if authentication_key is not None:
400+
authentication_key = convert_model(authentication_key)
392401
if resource_group is not None:
393402
resource_group = convert_model(resource_group)
394403
headers = {}
@@ -403,6 +412,7 @@ def create_gateway_action(self,
403412

404413
data = {
405414
'action': action,
415+
'authentication_key': authentication_key,
406416
'global': global_,
407417
'metered': metered,
408418
'resource_group': resource_group,
@@ -1242,6 +1252,12 @@ class Gateway():
12421252
"""
12431253
gateway.
12441254
1255+
:attr GatewayAuthenticationKey authentication_key: (optional) BGP MD5
1256+
authentication key.
1257+
BGP MD5 keys must be type=standard.
1258+
The key material that you provide must be base64 encoded and original string
1259+
must be maximum 126 ASCII characters in length.
1260+
To clear the optional `authentication_key` field patch its crn to `""`.
12451261
:attr int bgp_asn: Customer BGP ASN.
12461262
:attr str bgp_base_cidr: (optional) (DEPRECATED) BGP base CIDR is deprecated and
12471263
no longer recognized by the Direct Link APIs.
@@ -1292,7 +1308,7 @@ class Gateway():
12921308
:attr ResourceGroupReference resource_group: (optional) Resource group
12931309
reference.
12941310
:attr int speed_mbps: Gateway speed in megabits per second.
1295-
:attr str type: Gateway type. The list of enumerated values for this property
1311+
:attr str type: Offering type. The list of enumerated values for this property
12961312
may expand in the future. Code and processes using this field must tolerate
12971313
unexpected values.
12981314
:attr int vlan: (optional) VLAN allocated for this gateway. Only set for
@@ -1313,6 +1329,7 @@ def __init__(self,
13131329
speed_mbps: int,
13141330
type: str,
13151331
*,
1332+
authentication_key: 'GatewayAuthenticationKey' = None,
13161333
bgp_base_cidr: str = None,
13171334
bgp_cer_cidr: str = None,
13181335
bgp_ibm_asn: int = None,
@@ -1348,9 +1365,15 @@ def __init__(self,
13481365
enumerated values for this property may expand in the future. Code and
13491366
processes using this field must tolerate unexpected values.
13501367
:param int speed_mbps: Gateway speed in megabits per second.
1351-
:param str type: Gateway type. The list of enumerated values for this
1368+
:param str type: Offering type. The list of enumerated values for this
13521369
property may expand in the future. Code and processes using this field
13531370
must tolerate unexpected values.
1371+
:param GatewayAuthenticationKey authentication_key: (optional) BGP MD5
1372+
authentication key.
1373+
BGP MD5 keys must be type=standard.
1374+
The key material that you provide must be base64 encoded and original
1375+
string must be maximum 126 ASCII characters in length.
1376+
To clear the optional `authentication_key` field patch its crn to `""`.
13541377
:param str bgp_base_cidr: (optional) (DEPRECATED) BGP base CIDR is
13551378
deprecated and no longer recognized by the Direct Link APIs.
13561379
See bgp_cer_cidr and bgp_ibm_cidr fields instead for IP related
@@ -1389,6 +1412,7 @@ def __init__(self,
13891412
:param int vlan: (optional) VLAN allocated for this gateway. Only set for
13901413
type=connect gateways.
13911414
"""
1415+
self.authentication_key = authentication_key
13921416
self.bgp_asn = bgp_asn
13931417
self.bgp_base_cidr = bgp_base_cidr
13941418
self.bgp_cer_cidr = bgp_cer_cidr
@@ -1422,6 +1446,8 @@ def __init__(self,
14221446
def from_dict(cls, _dict: Dict) -> 'Gateway':
14231447
"""Initialize a Gateway object from a json dictionary."""
14241448
args = {}
1449+
if 'authentication_key' in _dict:
1450+
args['authentication_key'] = GatewayAuthenticationKey.from_dict(_dict.get('authentication_key'))
14251451
if 'bgp_asn' in _dict:
14261452
args['bgp_asn'] = _dict.get('bgp_asn')
14271453
else:
@@ -1512,6 +1538,8 @@ def _from_dict(cls, _dict):
15121538
def to_dict(self) -> Dict:
15131539
"""Return a json dictionary representing this model."""
15141540
_dict = {}
1541+
if hasattr(self, 'authentication_key') and self.authentication_key is not None:
1542+
_dict['authentication_key'] = self.authentication_key.to_dict()
15151543
if hasattr(self, 'bgp_asn') and self.bgp_asn is not None:
15161544
_dict['bgp_asn'] = self.bgp_asn
15171545
if hasattr(self, 'bgp_base_cidr') and self.bgp_base_cidr is not None:
@@ -1632,13 +1660,133 @@ class OperationalStatusEnum(Enum):
16321660

16331661
class TypeEnum(Enum):
16341662
"""
1635-
Gateway type. The list of enumerated values for this property may expand in the
1663+
Offering type. The list of enumerated values for this property may expand in the
16361664
future. Code and processes using this field must tolerate unexpected values.
16371665
"""
16381666
CONNECT = "connect"
16391667
DEDICATED = "dedicated"
16401668

16411669

1670+
class GatewayActionTemplateAuthenticationKey():
1671+
"""
1672+
BGP MD5 authentication key.
1673+
BGP MD5 keys must be type=standard.
1674+
The key material that you provide must be base64 encoded and original string must be
1675+
maximum 126 ASCII characters in length.
1676+
To clear the optional `authentication_key` field patch its crn to `""`.
1677+
1678+
:attr str crn: connectivity association key crn.
1679+
"""
1680+
1681+
def __init__(self,
1682+
crn: str) -> None:
1683+
"""
1684+
Initialize a GatewayActionTemplateAuthenticationKey object.
1685+
1686+
:param str crn: connectivity association key crn.
1687+
"""
1688+
self.crn = crn
1689+
1690+
@classmethod
1691+
def from_dict(cls, _dict: Dict) -> 'GatewayActionTemplateAuthenticationKey':
1692+
"""Initialize a GatewayActionTemplateAuthenticationKey object from a json dictionary."""
1693+
args = {}
1694+
if 'crn' in _dict:
1695+
args['crn'] = _dict.get('crn')
1696+
else:
1697+
raise ValueError('Required property \'crn\' not present in GatewayActionTemplateAuthenticationKey JSON')
1698+
return cls(**args)
1699+
1700+
@classmethod
1701+
def _from_dict(cls, _dict):
1702+
"""Initialize a GatewayActionTemplateAuthenticationKey object from a json dictionary."""
1703+
return cls.from_dict(_dict)
1704+
1705+
def to_dict(self) -> Dict:
1706+
"""Return a json dictionary representing this model."""
1707+
_dict = {}
1708+
if hasattr(self, 'crn') and self.crn is not None:
1709+
_dict['crn'] = self.crn
1710+
return _dict
1711+
1712+
def _to_dict(self):
1713+
"""Return a json dictionary representing this model."""
1714+
return self.to_dict()
1715+
1716+
def __str__(self) -> str:
1717+
"""Return a `str` version of this GatewayActionTemplateAuthenticationKey object."""
1718+
return json.dumps(self.to_dict(), indent=2)
1719+
1720+
def __eq__(self, other: 'GatewayActionTemplateAuthenticationKey') -> bool:
1721+
"""Return `true` when self and other are equal, false otherwise."""
1722+
if not isinstance(other, self.__class__):
1723+
return False
1724+
return self.__dict__ == other.__dict__
1725+
1726+
def __ne__(self, other: 'GatewayActionTemplateAuthenticationKey') -> bool:
1727+
"""Return `true` when self and other are not equal, false otherwise."""
1728+
return not self == other
1729+
1730+
class GatewayAuthenticationKey():
1731+
"""
1732+
BGP MD5 authentication key.
1733+
BGP MD5 keys must be type=standard.
1734+
The key material that you provide must be base64 encoded and original string must be
1735+
maximum 126 ASCII characters in length.
1736+
To clear the optional `authentication_key` field patch its crn to `""`.
1737+
1738+
:attr str crn: connectivity association key crn.
1739+
"""
1740+
1741+
def __init__(self,
1742+
crn: str) -> None:
1743+
"""
1744+
Initialize a GatewayAuthenticationKey object.
1745+
1746+
:param str crn: connectivity association key crn.
1747+
"""
1748+
self.crn = crn
1749+
1750+
@classmethod
1751+
def from_dict(cls, _dict: Dict) -> 'GatewayAuthenticationKey':
1752+
"""Initialize a GatewayAuthenticationKey object from a json dictionary."""
1753+
args = {}
1754+
if 'crn' in _dict:
1755+
args['crn'] = _dict.get('crn')
1756+
else:
1757+
raise ValueError('Required property \'crn\' not present in GatewayAuthenticationKey JSON')
1758+
return cls(**args)
1759+
1760+
@classmethod
1761+
def _from_dict(cls, _dict):
1762+
"""Initialize a GatewayAuthenticationKey object from a json dictionary."""
1763+
return cls.from_dict(_dict)
1764+
1765+
def to_dict(self) -> Dict:
1766+
"""Return a json dictionary representing this model."""
1767+
_dict = {}
1768+
if hasattr(self, 'crn') and self.crn is not None:
1769+
_dict['crn'] = self.crn
1770+
return _dict
1771+
1772+
def _to_dict(self):
1773+
"""Return a json dictionary representing this model."""
1774+
return self.to_dict()
1775+
1776+
def __str__(self) -> str:
1777+
"""Return a `str` version of this GatewayAuthenticationKey object."""
1778+
return json.dumps(self.to_dict(), indent=2)
1779+
1780+
def __eq__(self, other: 'GatewayAuthenticationKey') -> bool:
1781+
"""Return `true` when self and other are equal, false otherwise."""
1782+
if not isinstance(other, self.__class__):
1783+
return False
1784+
return self.__dict__ == other.__dict__
1785+
1786+
def __ne__(self, other: 'GatewayAuthenticationKey') -> bool:
1787+
"""Return `true` when self and other are not equal, false otherwise."""
1788+
return not self == other
1789+
16421790
class GatewayChangeRequest():
16431791
"""
16441792
GatewayChangeRequest.
@@ -2861,7 +3009,7 @@ class GatewayTemplate():
28613009
resource. If unspecified, the account's [default resource
28623010
group](https://cloud.ibm.com/apidocs/resource-manager#introduction) is used.
28633011
:attr int speed_mbps: Gateway speed in megabits per second.
2864-
:attr str type: Gateway type.
3012+
:attr str type: Offering type.
28653013
"""
28663014

28673015
def __init__(self,
@@ -2887,7 +3035,7 @@ def __init__(self,
28873035
instead a flat rate is charged for the gateway.
28883036
:param str name: The unique user-defined name for this gateway.
28893037
:param int speed_mbps: Gateway speed in megabits per second.
2890-
:param str type: Gateway type.
3038+
:param str type: Offering type.
28913039
:param str bgp_base_cidr: (optional) (DEPRECATED) BGP base CIDR.
28923040
Field is deprecated. See bgp_ibm_cidr and bgp_cer_cidr for details on how
28933041
to create a gateway using either automatic or explicit IP assignment. Any
@@ -2919,7 +3067,7 @@ def __init__(self,
29193067

29203068
class TypeEnum(Enum):
29213069
"""
2922-
Gateway type.
3070+
Offering type.
29233071
"""
29243072
CONNECT = "connect"
29253073
DEDICATED = "dedicated"
@@ -4254,7 +4402,7 @@ class GatewayTemplateGatewayTypeConnectTemplate(GatewayTemplate):
42544402
resource. If unspecified, the account's [default resource
42554403
group](https://cloud.ibm.com/apidocs/resource-manager#introduction) is used.
42564404
:attr int speed_mbps: Gateway speed in megabits per second.
4257-
:attr str type: Gateway type.
4405+
:attr str type: Offering type.
42584406
:attr GatewayPortIdentity port: Select Port Label for new type=connect gateway.
42594407
"""
42604408

@@ -4282,7 +4430,7 @@ def __init__(self,
42824430
instead a flat rate is charged for the gateway.
42834431
:param str name: The unique user-defined name for this gateway.
42844432
:param int speed_mbps: Gateway speed in megabits per second.
4285-
:param str type: Gateway type.
4433+
:param str type: Offering type.
42864434
:param GatewayPortIdentity port: Select Port Label for new type=connect
42874435
gateway.
42884436
:param str bgp_base_cidr: (optional) (DEPRECATED) BGP base CIDR.
@@ -4417,7 +4565,7 @@ def __ne__(self, other: 'GatewayTemplateGatewayTypeConnectTemplate') -> bool:
44174565

44184566
class TypeEnum(Enum):
44194567
"""
4420-
Gateway type.
4568+
Offering type.
44214569
"""
44224570
CONNECT = "connect"
44234571
DEDICATED = "dedicated"
@@ -4458,7 +4606,7 @@ class GatewayTemplateGatewayTypeDedicatedTemplate(GatewayTemplate):
44584606
resource. If unspecified, the account's [default resource
44594607
group](https://cloud.ibm.com/apidocs/resource-manager#introduction) is used.
44604608
:attr int speed_mbps: Gateway speed in megabits per second.
4461-
:attr str type: Gateway type.
4609+
:attr str type: Offering type.
44624610
:attr str carrier_name: Carrier name.
44634611
:attr str cross_connect_router: Cross connect router.
44644612
:attr str customer_name: Customer name.
@@ -4495,7 +4643,7 @@ def __init__(self,
44954643
instead a flat rate is charged for the gateway.
44964644
:param str name: The unique user-defined name for this gateway.
44974645
:param int speed_mbps: Gateway speed in megabits per second.
4498-
:param str type: Gateway type.
4646+
:param str type: Offering type.
44994647
:param str carrier_name: Carrier name.
45004648
:param str cross_connect_router: Cross connect router.
45014649
:param str customer_name: Customer name.
@@ -4660,7 +4808,7 @@ def __ne__(self, other: 'GatewayTemplateGatewayTypeDedicatedTemplate') -> bool:
46604808

46614809
class TypeEnum(Enum):
46624810
"""
4663-
Gateway type.
4811+
Offering type.
46644812
"""
46654813
CONNECT = "connect"
46664814
DEDICATED = "dedicated"

0 commit comments

Comments
 (0)