Skip to content

Commit

Permalink
Merge pull request #26 from IBM/md5
Browse files Browse the repository at this point in the history
feat: add the authentication_key for BGP MD5 authentication in directlink service
  • Loading branch information
ajay-malhotra1 authored Jun 2, 2021
2 parents 1cac1bb + 66ae69c commit c5b84e1
Show file tree
Hide file tree
Showing 5 changed files with 347 additions and 39 deletions.
10 changes: 4 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ matrix:
before_script:
- >-
[ -z "${TRAVIS_TAG}" ] && [ "${TRAVIS_PULL_REQUEST}" == "false" ]
&& openssl aes-256-cbc -K $encrypted_fc092b9428d6_key -iv $encrypted_fc092b9428d6_iv -in cis.env.enc -out cis.env -d
&& openssl aes-256-cbc -K $encrypted_d4a185972ecc_key -iv $encrypted_d4a185972ecc_iv -in pdns.env.enc -out pdns.env -d
&& openssl aes-256-cbc -K $encrypted_16de86179301_key -iv $encrypted_16de86179301_iv -in .transit_env.enc -out .transit_env -d
&& openssl aes-256-cbc -K $encrypted_27cb64608ff6_key -iv $encrypted_27cb64608ff6_iv -in dl.env.enc -out dl.env -d
|| true
[ -z "${TRAVIS_TAG}" ] && [ "${TRAVIS_PULL_REQUEST}" == "false" ]
&& openssl aes-256-cbc -K $encrypted_fc092b9428d6_key -iv $encrypted_fc092b9428d6_iv -in cis.env.enc -out cis.env -d || true
&& openssl aes-256-cbc -K $encrypted_d4a185972ecc_key -iv $encrypted_d4a185972ecc_iv -in pdns.env.enc -out pdns.env -d || true
&& openssl aes-256-cbc -K $encrypted_16de86179301_key -iv $encrypted_16de86179301_iv -in .transit_env.enc -out .transit_env -d || true
&& openssl aes-256-cbc -K $encrypted_27cb64608ff6_key -iv $encrypted_27cb64608ff6_iv -in dl.env.enc -out dl.env -d || true
&& openssl aes-256-cbc -K $encrypted_89a9eb4f9417_key -iv $encrypted_89a9eb4f9417_iv -in dns.env.enc -out dns.env -d || true
- python: 3.7
- python: 3.8
Expand Down
Binary file modified dl.env.enc
Binary file not shown.
172 changes: 160 additions & 12 deletions ibm_cloud_networking_services/direct_link_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ def create_gateway_action(self,
id: str,
action: str,
*,
authentication_key: 'GatewayActionTemplateAuthenticationKey' = None,
global_: bool = None,
metered: bool = None,
resource_group: 'ResourceGroupIdentity' = None,
Expand All @@ -363,6 +364,12 @@ def create_gateway_action(self,
:param str id: Direct Link Connect gateway identifier.
:param str action: Action request.
:param GatewayActionTemplateAuthenticationKey authentication_key:
(optional) BGP MD5 authentication key.
BGP MD5 keys must be type=standard.
The key material that you provide must be base64 encoded and original
string must be maximum 126 ASCII characters in length.
To clear the optional `authentication_key` field patch its crn to `""`.
:param bool global_: (optional) Required for create_gateway_approve
requests to select the gateway's routing option. Gateways with global
routing (`true`) can connect to networks outside of their associated
Expand All @@ -389,6 +396,8 @@ def create_gateway_action(self,
raise ValueError('id must be provided')
if action is None:
raise ValueError('action must be provided')
if authentication_key is not None:
authentication_key = convert_model(authentication_key)
if resource_group is not None:
resource_group = convert_model(resource_group)
headers = {}
Expand All @@ -403,6 +412,7 @@ def create_gateway_action(self,

data = {
'action': action,
'authentication_key': authentication_key,
'global': global_,
'metered': metered,
'resource_group': resource_group,
Expand Down Expand Up @@ -1242,6 +1252,12 @@ class Gateway():
"""
gateway.
:attr GatewayAuthenticationKey authentication_key: (optional) BGP MD5
authentication key.
BGP MD5 keys must be type=standard.
The key material that you provide must be base64 encoded and original string
must be maximum 126 ASCII characters in length.
To clear the optional `authentication_key` field patch its crn to `""`.
:attr int bgp_asn: Customer BGP ASN.
:attr str bgp_base_cidr: (optional) (DEPRECATED) BGP base CIDR is deprecated and
no longer recognized by the Direct Link APIs.
Expand Down Expand Up @@ -1292,7 +1308,7 @@ class Gateway():
:attr ResourceGroupReference resource_group: (optional) Resource group
reference.
:attr int speed_mbps: Gateway speed in megabits per second.
:attr str type: Gateway type. The list of enumerated values for this property
:attr str type: Offering type. The list of enumerated values for this property
may expand in the future. Code and processes using this field must tolerate
unexpected values.
:attr int vlan: (optional) VLAN allocated for this gateway. Only set for
Expand All @@ -1313,6 +1329,7 @@ def __init__(self,
speed_mbps: int,
type: str,
*,
authentication_key: 'GatewayAuthenticationKey' = None,
bgp_base_cidr: str = None,
bgp_cer_cidr: str = None,
bgp_ibm_asn: int = None,
Expand Down Expand Up @@ -1348,9 +1365,15 @@ def __init__(self,
enumerated values for this property may expand in the future. Code and
processes using this field must tolerate unexpected values.
:param int speed_mbps: Gateway speed in megabits per second.
:param str type: Gateway type. The list of enumerated values for this
:param str type: Offering type. The list of enumerated values for this
property may expand in the future. Code and processes using this field
must tolerate unexpected values.
:param GatewayAuthenticationKey authentication_key: (optional) BGP MD5
authentication key.
BGP MD5 keys must be type=standard.
The key material that you provide must be base64 encoded and original
string must be maximum 126 ASCII characters in length.
To clear the optional `authentication_key` field patch its crn to `""`.
:param str bgp_base_cidr: (optional) (DEPRECATED) BGP base CIDR is
deprecated and no longer recognized by the Direct Link APIs.
See bgp_cer_cidr and bgp_ibm_cidr fields instead for IP related
Expand Down Expand Up @@ -1389,6 +1412,7 @@ def __init__(self,
:param int vlan: (optional) VLAN allocated for this gateway. Only set for
type=connect gateways.
"""
self.authentication_key = authentication_key
self.bgp_asn = bgp_asn
self.bgp_base_cidr = bgp_base_cidr
self.bgp_cer_cidr = bgp_cer_cidr
Expand Down Expand Up @@ -1422,6 +1446,8 @@ def __init__(self,
def from_dict(cls, _dict: Dict) -> 'Gateway':
"""Initialize a Gateway object from a json dictionary."""
args = {}
if 'authentication_key' in _dict:
args['authentication_key'] = GatewayAuthenticationKey.from_dict(_dict.get('authentication_key'))
if 'bgp_asn' in _dict:
args['bgp_asn'] = _dict.get('bgp_asn')
else:
Expand Down Expand Up @@ -1512,6 +1538,8 @@ def _from_dict(cls, _dict):
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'authentication_key') and self.authentication_key is not None:
_dict['authentication_key'] = self.authentication_key.to_dict()
if hasattr(self, 'bgp_asn') and self.bgp_asn is not None:
_dict['bgp_asn'] = self.bgp_asn
if hasattr(self, 'bgp_base_cidr') and self.bgp_base_cidr is not None:
Expand Down Expand Up @@ -1632,13 +1660,133 @@ class OperationalStatusEnum(Enum):

class TypeEnum(Enum):
"""
Gateway type. The list of enumerated values for this property may expand in the
Offering type. The list of enumerated values for this property may expand in the
future. Code and processes using this field must tolerate unexpected values.
"""
CONNECT = "connect"
DEDICATED = "dedicated"


class GatewayActionTemplateAuthenticationKey():
"""
BGP MD5 authentication key.
BGP MD5 keys must be type=standard.
The key material that you provide must be base64 encoded and original string must be
maximum 126 ASCII characters in length.
To clear the optional `authentication_key` field patch its crn to `""`.
:attr str crn: connectivity association key crn.
"""

def __init__(self,
crn: str) -> None:
"""
Initialize a GatewayActionTemplateAuthenticationKey object.
:param str crn: connectivity association key crn.
"""
self.crn = crn

@classmethod
def from_dict(cls, _dict: Dict) -> 'GatewayActionTemplateAuthenticationKey':
"""Initialize a GatewayActionTemplateAuthenticationKey object from a json dictionary."""
args = {}
if 'crn' in _dict:
args['crn'] = _dict.get('crn')
else:
raise ValueError('Required property \'crn\' not present in GatewayActionTemplateAuthenticationKey JSON')
return cls(**args)

@classmethod
def _from_dict(cls, _dict):
"""Initialize a GatewayActionTemplateAuthenticationKey object from a json dictionary."""
return cls.from_dict(_dict)

def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'crn') and self.crn is not None:
_dict['crn'] = self.crn
return _dict

def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()

def __str__(self) -> str:
"""Return a `str` version of this GatewayActionTemplateAuthenticationKey object."""
return json.dumps(self.to_dict(), indent=2)

def __eq__(self, other: 'GatewayActionTemplateAuthenticationKey') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__

def __ne__(self, other: 'GatewayActionTemplateAuthenticationKey') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other

class GatewayAuthenticationKey():
"""
BGP MD5 authentication key.
BGP MD5 keys must be type=standard.
The key material that you provide must be base64 encoded and original string must be
maximum 126 ASCII characters in length.
To clear the optional `authentication_key` field patch its crn to `""`.
:attr str crn: connectivity association key crn.
"""

def __init__(self,
crn: str) -> None:
"""
Initialize a GatewayAuthenticationKey object.
:param str crn: connectivity association key crn.
"""
self.crn = crn

@classmethod
def from_dict(cls, _dict: Dict) -> 'GatewayAuthenticationKey':
"""Initialize a GatewayAuthenticationKey object from a json dictionary."""
args = {}
if 'crn' in _dict:
args['crn'] = _dict.get('crn')
else:
raise ValueError('Required property \'crn\' not present in GatewayAuthenticationKey JSON')
return cls(**args)

@classmethod
def _from_dict(cls, _dict):
"""Initialize a GatewayAuthenticationKey object from a json dictionary."""
return cls.from_dict(_dict)

def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'crn') and self.crn is not None:
_dict['crn'] = self.crn
return _dict

def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()

def __str__(self) -> str:
"""Return a `str` version of this GatewayAuthenticationKey object."""
return json.dumps(self.to_dict(), indent=2)

def __eq__(self, other: 'GatewayAuthenticationKey') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__

def __ne__(self, other: 'GatewayAuthenticationKey') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other

class GatewayChangeRequest():
"""
GatewayChangeRequest.
Expand Down Expand Up @@ -2861,7 +3009,7 @@ class GatewayTemplate():
resource. If unspecified, the account's [default resource
group](https://cloud.ibm.com/apidocs/resource-manager#introduction) is used.
:attr int speed_mbps: Gateway speed in megabits per second.
:attr str type: Gateway type.
:attr str type: Offering type.
"""

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

class TypeEnum(Enum):
"""
Gateway type.
Offering type.
"""
CONNECT = "connect"
DEDICATED = "dedicated"
Expand Down Expand Up @@ -4254,7 +4402,7 @@ class GatewayTemplateGatewayTypeConnectTemplate(GatewayTemplate):
resource. If unspecified, the account's [default resource
group](https://cloud.ibm.com/apidocs/resource-manager#introduction) is used.
:attr int speed_mbps: Gateway speed in megabits per second.
:attr str type: Gateway type.
:attr str type: Offering type.
:attr GatewayPortIdentity port: Select Port Label for new type=connect gateway.
"""

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

class TypeEnum(Enum):
"""
Gateway type.
Offering type.
"""
CONNECT = "connect"
DEDICATED = "dedicated"
Expand Down Expand Up @@ -4458,7 +4606,7 @@ class GatewayTemplateGatewayTypeDedicatedTemplate(GatewayTemplate):
resource. If unspecified, the account's [default resource
group](https://cloud.ibm.com/apidocs/resource-manager#introduction) is used.
:attr int speed_mbps: Gateway speed in megabits per second.
:attr str type: Gateway type.
:attr str type: Offering type.
:attr str carrier_name: Carrier name.
:attr str cross_connect_router: Cross connect router.
:attr str customer_name: Customer name.
Expand Down Expand Up @@ -4495,7 +4643,7 @@ def __init__(self,
instead a flat rate is charged for the gateway.
:param str name: The unique user-defined name for this gateway.
:param int speed_mbps: Gateway speed in megabits per second.
:param str type: Gateway type.
:param str type: Offering type.
:param str carrier_name: Carrier name.
:param str cross_connect_router: Cross connect router.
:param str customer_name: Customer name.
Expand Down Expand Up @@ -4660,7 +4808,7 @@ def __ne__(self, other: 'GatewayTemplateGatewayTypeDedicatedTemplate') -> bool:

class TypeEnum(Enum):
"""
Gateway type.
Offering type.
"""
CONNECT = "connect"
DEDICATED = "dedicated"
Expand Down
Loading

0 comments on commit c5b84e1

Please sign in to comment.