diff --git a/.gitignore b/.gitignore index 9570712..d0f1264 100644 --- a/.gitignore +++ b/.gitignore @@ -53,7 +53,6 @@ venv/ python3/ *.env -.*env # resources resources/output.wav diff --git a/.transit_env.enc b/.transit_env.enc deleted file mode 100644 index a0de6a4..0000000 Binary files a/.transit_env.enc and /dev/null differ diff --git a/.travis.yml b/.travis.yml index cb84d83..2440ba4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ matrix: [ -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_3d8a3eb98382_key -iv $encrypted_3d8a3eb98382_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 diff --git a/ibm_cloud_networking_services/transit_gateway_apis_v1.py b/ibm_cloud_networking_services/transit_gateway_apis_v1.py index 4dddb53..1bd1ee3 100644 --- a/ibm_cloud_networking_services/transit_gateway_apis_v1.py +++ b/ibm_cloud_networking_services/transit_gateway_apis_v1.py @@ -1,6 +1,6 @@ # coding: utf-8 -# (C) Copyright IBM Corp. 2020. +# (C) Copyright IBM Corp. 2021. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,6 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +# IBM OpenAPI SDK Code Generator Version: 3.10.3-18e3fe12-20200803-172650 + """ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) @@ -89,20 +91,80 @@ def __init__(self, self.version = version + ######################### + # transitConnections + ######################### + + + def list_connections(self, + *, + limit: int = None, + start: str = None, + network_id: str = None, + **kwargs + ) -> DetailedResponse: + """ + Retrieves all connections. + + List all transit gateway connections associated with this account. + + :param int limit: (optional) The maximum number of resources to return per + page. + :param str start: (optional) A server supplied token determining which + resource to start the page on. + :param str network_id: (optional) Search for connections with the given + network_id value. + :param dict headers: A `dict` containing the request headers + :return: A `DetailedResponse` containing the result, headers and HTTP status code. + :rtype: DetailedResponse with `dict` result representing a `TransitConnectionCollection` object + """ + + headers = {} + sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='list_connections') + headers.update(sdk_headers) + + params = { + 'version': self.version, + 'limit': limit, + 'start': start, + 'network_id': network_id + } + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' + + url = '/connections' + request = self.prepare_request(method='GET', + url=url, + headers=headers, + params=params) + + response = self.send(request) + return response + ######################### # transitGateways ######################### def list_transit_gateways(self, + *, + limit: int = None, + start: str = None, **kwargs ) -> DetailedResponse: """ Retrieves all Transit Gateways. - List all the Transit Gateways in the account. User will get a list of Transit - Gateways they have access to 'view'. + List all Transit Gateways in account the caller is authorized to view. + :param int limit: (optional) The maximum number of resources to return per + page. + :param str start: (optional) A server supplied token determining which + resource to start the page on. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `TransitGatewayCollection` object @@ -115,11 +177,14 @@ def list_transit_gateways(self, headers.update(sdk_headers) params = { - 'version': self.version + 'version': self.version, + 'limit': limit, + 'start': start } if 'headers' in kwargs: headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' url = '/transit_gateways' request = self.prepare_request(method='GET', @@ -185,6 +250,7 @@ def create_transit_gateway(self, if 'headers' in kwargs: headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' url = '/transit_gateways' request = self.prepare_request(method='POST', @@ -269,6 +335,7 @@ def get_transit_gateway(self, if 'headers' in kwargs: headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' url = '/transit_gateways/{0}'.format( *self.encode_path_vars(id)) @@ -323,6 +390,7 @@ def update_transit_gateway(self, if 'headers' in kwargs: headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' url = '/transit_gateways/{0}'.format( *self.encode_path_vars(id)) @@ -369,6 +437,7 @@ def list_transit_gateway_connections(self, if 'headers' in kwargs: headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' url = '/transit_gateways/{0}/connections'.format( *self.encode_path_vars(transit_gateway_id)) @@ -385,9 +454,16 @@ def create_transit_gateway_connection(self, transit_gateway_id: str, network_type: str, *, + base_connection_id: str = None, + local_gateway_ip: str = None, + local_tunnel_ip: str = None, name: str = None, - network_id: str = None, network_account_id: str = None, + network_id: str = None, + remote_bgp_asn: str = None, + remote_gateway_ip: str = None, + remote_tunnel_ip: str = None, + zone: 'ZoneIdentity' = None, **kwargs ) -> DetailedResponse: """ @@ -397,18 +473,49 @@ def create_transit_gateway_connection(self, :param str transit_gateway_id: The Transit Gateway identifier. :param str network_type: Defines what type of network is connected via this - connection. - :param str name: (optional) The user-defined name for this transit gateway. - If unspecified, the name will be the network name (the name of the VPC in - the case of network type 'vpc', and the word Classic, in the case of - network type 'classic'). + connection. For access to gre_tunnel connections contact IBM support. + :param str base_connection_id: (optional) network_type 'gre_tunnel' + connections must be created over an existing network_type 'classic' + connection. This field is required for 'gre_tunnel' connections and must + specify the ID of an active transit gateway network_type 'classic' + connection in the same transit gateway. Omit 'base_connection_id' for any + connection type other than 'gre_tunnel'. + :param str local_gateway_ip: (optional) Local gateway IP address. This + field is required for and only applicable to type gre_tunnel connections. + :param str local_tunnel_ip: (optional) Local tunnel IP address. This field + is required for and only applicable to type gre_tunnel connections. The + local_tunnel_ip and remote_tunnel_ip addresses must be in the same /30 + network. Neither can be the network nor broadcast addresses. + :param str name: (optional) The user-defined name for this transit gateway + connection. Network type 'vpc' connections are defaulted to the name of + the VPC. Network type 'classic' connections are named 'Classic'. Name + specification is required for network type 'gre_tunnel' connections. + :param str network_account_id: (optional) The ID of the account which owns + the network that is being connected. Generally only used if the network is + in a different account than the gateway. This field is required to be + unspecified for network type 'gre_tunnel'. :param str network_id: (optional) The ID of the network being connected via this connection. This field is required for some types, such as 'vpc'. For network type 'vpc' this is the CRN of the VPC to be connected. This field - is required to be unspecified for network type 'classic'. - :param str network_account_id: (optional) The ID of the account which owns - the network that is being connected. Generally only used if the network is - in a different account than the gateway. + is required to be unspecified for network type 'classic' and 'gre_tunnel' + connections. + :param str remote_bgp_asn: (optional) Remote network BGP ASN. This field + is only applicable to 'gre_tunnel' type connections. The following ASN + values are reserved and unavailable 64512-64513, 65100, 65201-65234, + 65402-65433, 65500 and 4201065000-4201065999. If 'remote_bgp_asn' is + omitted on gre_tunnel connection create requests IBM will assign an ASN. + :param str remote_gateway_ip: (optional) Remote gateway IP address. This + field is required for and only applicable to type gre_tunnel connections. + :param str remote_tunnel_ip: (optional) Remote tunnel IP address. This + field is required for and only applicable to type gre_tunnel connections. + The local_tunnel_ip and remote_tunnel_ip addresses must be in the same /30 + network. Neither can be the network nor broadcast addresses. + :param ZoneIdentity zone: (optional) For network_type 'gre_tunnel' + connections specify the connection's location. The specified availability + zone must reside in the gateway's region. + Use the IBM Cloud global catalog to list zones within the desired region. + This field is required for and only applicable to network type 'gre_tunnel' + connections. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `TransitGatewayConnectionCust` object @@ -418,6 +525,8 @@ def create_transit_gateway_connection(self, raise ValueError('transit_gateway_id must be provided') if network_type is None: raise ValueError('network_type must be provided') + if zone is not None: + zone = convert_model(zone) headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', @@ -430,9 +539,16 @@ def create_transit_gateway_connection(self, data = { 'network_type': network_type, + 'base_connection_id': base_connection_id, + 'local_gateway_ip': local_gateway_ip, + 'local_tunnel_ip': local_tunnel_ip, 'name': name, + 'network_account_id': network_account_id, 'network_id': network_id, - 'network_account_id': network_account_id + 'remote_bgp_asn': remote_bgp_asn, + 'remote_gateway_ip': remote_gateway_ip, + 'remote_tunnel_ip': remote_tunnel_ip, + 'zone': zone } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) @@ -440,6 +556,7 @@ def create_transit_gateway_connection(self, if 'headers' in kwargs: headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' url = '/transit_gateways/{0}/connections'.format( *self.encode_path_vars(transit_gateway_id)) @@ -533,6 +650,7 @@ def get_transit_gateway_connection(self, if 'headers' in kwargs: headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' url = '/transit_gateways/{0}/connections/{1}'.format( *self.encode_path_vars(transit_gateway_id, id)) @@ -591,6 +709,7 @@ def update_transit_gateway_connection(self, if 'headers' in kwargs: headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' url = '/transit_gateways/{0}/connections/{1}'.format( *self.encode_path_vars(transit_gateway_id, id)) @@ -691,6 +810,7 @@ def list_gateway_locations(self, if 'headers' in kwargs: headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' url = '/locations' request = self.prepare_request(method='GET', @@ -731,6 +851,7 @@ def get_gateway_location(self, if 'headers' in kwargs: headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' url = '/locations/{0}'.format( *self.encode_path_vars(name)) @@ -933,23 +1054,29 @@ class TSLocalLocation(): """ Details of a local connection location. - :attr str display_name: A descriptive display name for the location. - :attr str name: The name of the location. - :attr str type: The type of the location, determining is this a multi-zone - region, a single data center, or a point of presence. + :attr str display_name: (optional) A descriptive display name for the location. + :attr str name: (optional) The name of the location. + :attr str type: (optional) The type of the location, determining is this a + multi-zone region, a single data center, or a point of presence. The list of + enumerated values for this property may expand in the future. Code and processes + using this field must tolerate unexpected values. """ def __init__(self, - display_name: str, - name: str, - type: str) -> None: + *, + display_name: str = None, + name: str = None, + type: str = None) -> None: """ Initialize a TSLocalLocation object. - :param str display_name: A descriptive display name for the location. - :param str name: The name of the location. - :param str type: The type of the location, determining is this a multi-zone - region, a single data center, or a point of presence. + :param str display_name: (optional) A descriptive display name for the + location. + :param str name: (optional) The name of the location. + :param str type: (optional) The type of the location, determining is this a + multi-zone region, a single data center, or a point of presence. The list + of enumerated values for this property may expand in the future. Code and + processes using this field must tolerate unexpected values. """ self.display_name = display_name self.name = name @@ -961,16 +1088,10 @@ def from_dict(cls, _dict: Dict) -> 'TSLocalLocation': args = {} if 'display_name' in _dict: args['display_name'] = _dict.get('display_name') - else: - raise ValueError('Required property \'display_name\' not present in TSLocalLocation JSON') if 'name' in _dict: args['name'] = _dict.get('name') - else: - raise ValueError('Required property \'name\' not present in TSLocalLocation JSON') if 'type' in _dict: args['type'] = _dict.get('type') - else: - raise ValueError('Required property \'type\' not present in TSLocalLocation JSON') return cls(**args) @classmethod @@ -1010,7 +1131,9 @@ def __ne__(self, other: 'TSLocalLocation') -> bool: class TypeEnum(str, Enum): """ The type of the location, determining is this a multi-zone region, a single data - center, or a point of presence. + center, or a point of presence. The list of enumerated values for this property + may expand in the future. Code and processes using this field must tolerate + unexpected values. """ REGION = 'region' @@ -1187,128 +1310,253 @@ def __ne__(self, other: 'TSLocationBasic') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class TransitGateway(): +class TransitConnection(): """ - Details of a Transit Gateway. - - :attr str id: The unique identifier for this Transit Gateway. - :attr str crn: The CRN for this Transit Gateway. - :attr str name: A human readable name for the transit gateway. - :attr str location: Location of Transit Gateway Services. - :attr datetime created_at: The date and time that this gateway was created. - :attr bool global_: Allow global routing for a Transit Gateway. - :attr ResourceGroupReference resource_group: (optional) The resource group to - use. If unspecified, the account's [default resource - group](https://console.bluemix.net/apidocs/resource-manager#introduction) is - used. - :attr str status: The status of the Transit Gateway. - :attr datetime updated_at: (optional) The date and time that this gateway was + Transit gateway connection. + + :attr str base_connection_id: (optional) network_type 'gre_tunnel' connections + use 'base_connection_id' to specify the id of a network_type 'classic' + connection the tunnel is configured over. The specified connection must reside + in the same transit gateway and be in an active state. The 'classic' connection + cannot be deleted until any 'gre_tunnel' connections using it are deleted. This + field only applies to and is required for network type 'gre_tunnel' connections. + :attr datetime created_at: The date and time that this connection was created. + :attr str id: The unique identifier for this connection. + :attr int local_bgp_asn: (optional) Local network BGP ASN. This field only + applies to network type 'gre_tunnel' connections. + :attr str local_gateway_ip: (optional) Local gateway IP address. This field + only applies to network type 'gre_tunnel' connections. + :attr str local_tunnel_ip: (optional) Local tunnel IP address. This field only + applies to network type 'gre_tunnel' connections. + :attr int mtu: (optional) GRE tunnel MTU. This field only applies to network + type 'gre_tunnel' connections. + :attr str name: The user-defined name for this transit gateway connection. + :attr str network_account_id: (optional) The ID of the account which owns the + connected network. Generally only used if the network is in a different IBM + Cloud account than the gateway. + :attr str network_id: (optional) The ID of the network being connected via this + connection. This field is required for some types, such as 'vpc'. For network + type 'vpc' this is the CRN of the VPC to be connected. + :attr str network_type: Defines what type of network is connected via this + connection. 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 remote_bgp_asn: (optional) Remote network BGP ASN. This field only + applies to network type 'gre_tunnel' connections. + :attr str remote_gateway_ip: (optional) Remote gateway IP address. This field + only applies to network type 'gre_tunnel' connections. + :attr str remote_tunnel_ip: (optional) Remote tunnel IP address. This field + only applies to network type 'gre_tunnel' connections. + :attr str request_status: (optional) Only visible for cross account connections, + this field represents the status of a connection request between IBM Cloud + accounts. The list of enumerated values for this property may expand in the + future. Code and processes using this field must tolerate unexpected values. + :attr str status: Connection state. The list of enumerated values for this + property may expand in the future. Code and processes using this field must + tolerate unexpected values. + :attr TransitGatewayReference transit_gateway: Reference to the transit gateway + that contains this connection. + :attr datetime updated_at: (optional) The date and time that this connection was last updated. + :attr ZoneReference zone: (optional) Location of GRE tunnel. This field only + applies to network type 'gre_tunnel' connections. """ def __init__(self, + created_at: datetime, id: str, - crn: str, name: str, - location: str, - created_at: datetime, - global_: bool, + network_type: str, status: str, + transit_gateway: 'TransitGatewayReference', *, - resource_group: 'ResourceGroupReference' = None, - updated_at: datetime = None) -> None: + base_connection_id: str = None, + local_bgp_asn: int = None, + local_gateway_ip: str = None, + local_tunnel_ip: str = None, + mtu: int = None, + network_account_id: str = None, + network_id: str = None, + remote_bgp_asn: int = None, + remote_gateway_ip: str = None, + remote_tunnel_ip: str = None, + request_status: str = None, + updated_at: datetime = None, + zone: 'ZoneReference' = None) -> None: """ - Initialize a TransitGateway object. + Initialize a TransitConnection object. - :param str id: The unique identifier for this Transit Gateway. - :param str crn: The CRN for this Transit Gateway. - :param str name: A human readable name for the transit gateway. - :param str location: Location of Transit Gateway Services. - :param datetime created_at: The date and time that this gateway was + :param datetime created_at: The date and time that this connection was created. - :param bool global_: Allow global routing for a Transit Gateway. - :param str status: The status of the Transit Gateway. - :param ResourceGroupReference resource_group: (optional) The resource group - to use. If unspecified, the account's [default resource - group](https://console.bluemix.net/apidocs/resource-manager#introduction) - is used. - :param datetime updated_at: (optional) The date and time that this gateway - was last updated. + :param str id: The unique identifier for this connection. + :param str name: The user-defined name for this transit gateway connection. + :param str network_type: Defines what type of network is connected via this + connection. The list of enumerated values for this property may expand in + the future. Code and processes using this field must tolerate unexpected + values. + :param str status: Connection state. The list of enumerated values for this + property may expand in the future. Code and processes using this field must + tolerate unexpected values. + :param TransitGatewayReference transit_gateway: Reference to the transit + gateway that contains this connection. + :param str base_connection_id: (optional) network_type 'gre_tunnel' + connections use 'base_connection_id' to specify the id of a network_type + 'classic' connection the tunnel is configured over. The specified + connection must reside in the same transit gateway and be in an active + state. The 'classic' connection cannot be deleted until any 'gre_tunnel' + connections using it are deleted. This field only applies to and is + required for network type 'gre_tunnel' connections. + :param int local_bgp_asn: (optional) Local network BGP ASN. This field + only applies to network type 'gre_tunnel' connections. + :param str local_gateway_ip: (optional) Local gateway IP address. This + field only applies to network type 'gre_tunnel' connections. + :param str local_tunnel_ip: (optional) Local tunnel IP address. This field + only applies to network type 'gre_tunnel' connections. + :param int mtu: (optional) GRE tunnel MTU. This field only applies to + network type 'gre_tunnel' connections. + :param str network_account_id: (optional) The ID of the account which owns + the connected network. Generally only used if the network is in a different + IBM Cloud account than the gateway. + :param str network_id: (optional) The ID of the network being connected via + this connection. This field is required for some types, such as 'vpc'. For + network type 'vpc' this is the CRN of the VPC to be connected. + :param int remote_bgp_asn: (optional) Remote network BGP ASN. This field + only applies to network type 'gre_tunnel' connections. + :param str remote_gateway_ip: (optional) Remote gateway IP address. This + field only applies to network type 'gre_tunnel' connections. + :param str remote_tunnel_ip: (optional) Remote tunnel IP address. This + field only applies to network type 'gre_tunnel' connections. + :param str request_status: (optional) Only visible for cross account + connections, this field represents the status of a connection request + between IBM Cloud accounts. The list of enumerated values for this property + may expand in the future. Code and processes using this field must tolerate + unexpected values. + :param datetime updated_at: (optional) The date and time that this + connection was last updated. + :param ZoneReference zone: (optional) Location of GRE tunnel. This field + only applies to network type 'gre_tunnel' connections. """ + self.base_connection_id = base_connection_id + self.created_at = created_at self.id = id - self.crn = crn + self.local_bgp_asn = local_bgp_asn + self.local_gateway_ip = local_gateway_ip + self.local_tunnel_ip = local_tunnel_ip + self.mtu = mtu self.name = name - self.location = location - self.created_at = created_at - self.global_ = global_ - self.resource_group = resource_group + self.network_account_id = network_account_id + self.network_id = network_id + self.network_type = network_type + self.remote_bgp_asn = remote_bgp_asn + self.remote_gateway_ip = remote_gateway_ip + self.remote_tunnel_ip = remote_tunnel_ip + self.request_status = request_status self.status = status + self.transit_gateway = transit_gateway self.updated_at = updated_at + self.zone = zone @classmethod - def from_dict(cls, _dict: Dict) -> 'TransitGateway': - """Initialize a TransitGateway object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'TransitConnection': + """Initialize a TransitConnection object from a json dictionary.""" args = {} + if 'base_connection_id' in _dict: + args['base_connection_id'] = _dict.get('base_connection_id') + if 'created_at' in _dict: + args['created_at'] = string_to_datetime(_dict.get('created_at')) + else: + raise ValueError('Required property \'created_at\' not present in TransitConnection JSON') if 'id' in _dict: args['id'] = _dict.get('id') else: - raise ValueError('Required property \'id\' not present in TransitGateway JSON') - if 'crn' in _dict: - args['crn'] = _dict.get('crn') - else: - raise ValueError('Required property \'crn\' not present in TransitGateway JSON') + raise ValueError('Required property \'id\' not present in TransitConnection JSON') + if 'local_bgp_asn' in _dict: + args['local_bgp_asn'] = _dict.get('local_bgp_asn') + if 'local_gateway_ip' in _dict: + args['local_gateway_ip'] = _dict.get('local_gateway_ip') + if 'local_tunnel_ip' in _dict: + args['local_tunnel_ip'] = _dict.get('local_tunnel_ip') + if 'mtu' in _dict: + args['mtu'] = _dict.get('mtu') if 'name' in _dict: args['name'] = _dict.get('name') else: - raise ValueError('Required property \'name\' not present in TransitGateway JSON') - if 'location' in _dict: - args['location'] = _dict.get('location') - else: - raise ValueError('Required property \'location\' not present in TransitGateway JSON') - if 'created_at' in _dict: - args['created_at'] = string_to_datetime(_dict.get('created_at')) - else: - raise ValueError('Required property \'created_at\' not present in TransitGateway JSON') - if 'global' in _dict: - args['global_'] = _dict.get('global') + raise ValueError('Required property \'name\' not present in TransitConnection JSON') + if 'network_account_id' in _dict: + args['network_account_id'] = _dict.get('network_account_id') + if 'network_id' in _dict: + args['network_id'] = _dict.get('network_id') + if 'network_type' in _dict: + args['network_type'] = _dict.get('network_type') else: - raise ValueError('Required property \'global\' not present in TransitGateway JSON') - if 'resource_group' in _dict: - args['resource_group'] = ResourceGroupReference.from_dict(_dict.get('resource_group')) + raise ValueError('Required property \'network_type\' not present in TransitConnection JSON') + if 'remote_bgp_asn' in _dict: + args['remote_bgp_asn'] = _dict.get('remote_bgp_asn') + if 'remote_gateway_ip' in _dict: + args['remote_gateway_ip'] = _dict.get('remote_gateway_ip') + if 'remote_tunnel_ip' in _dict: + args['remote_tunnel_ip'] = _dict.get('remote_tunnel_ip') + if 'request_status' in _dict: + args['request_status'] = _dict.get('request_status') if 'status' in _dict: args['status'] = _dict.get('status') else: - raise ValueError('Required property \'status\' not present in TransitGateway JSON') + raise ValueError('Required property \'status\' not present in TransitConnection JSON') + if 'transit_gateway' in _dict: + args['transit_gateway'] = TransitGatewayReference.from_dict(_dict.get('transit_gateway')) + else: + raise ValueError('Required property \'transit_gateway\' not present in TransitConnection JSON') if 'updated_at' in _dict: args['updated_at'] = string_to_datetime(_dict.get('updated_at')) + if 'zone' in _dict: + args['zone'] = ZoneReference.from_dict(_dict.get('zone')) return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a TransitGateway object from a json dictionary.""" + """Initialize a TransitConnection 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, 'base_connection_id') and self.base_connection_id is not None: + _dict['base_connection_id'] = self.base_connection_id + if hasattr(self, 'created_at') and self.created_at is not None: + _dict['created_at'] = datetime_to_string(self.created_at) if hasattr(self, 'id') and self.id is not None: _dict['id'] = self.id - if hasattr(self, 'crn') and self.crn is not None: - _dict['crn'] = self.crn + if hasattr(self, 'local_bgp_asn') and self.local_bgp_asn is not None: + _dict['local_bgp_asn'] = self.local_bgp_asn + if hasattr(self, 'local_gateway_ip') and self.local_gateway_ip is not None: + _dict['local_gateway_ip'] = self.local_gateway_ip + if hasattr(self, 'local_tunnel_ip') and self.local_tunnel_ip is not None: + _dict['local_tunnel_ip'] = self.local_tunnel_ip + if hasattr(self, 'mtu') and self.mtu is not None: + _dict['mtu'] = self.mtu if hasattr(self, 'name') and self.name is not None: _dict['name'] = self.name - if hasattr(self, 'location') and self.location is not None: - _dict['location'] = self.location - if hasattr(self, 'created_at') and self.created_at is not None: - _dict['created_at'] = datetime_to_string(self.created_at) - if hasattr(self, 'global_') and self.global_ is not None: - _dict['global'] = self.global_ - if hasattr(self, 'resource_group') and self.resource_group is not None: - _dict['resource_group'] = self.resource_group.to_dict() + if hasattr(self, 'network_account_id') and self.network_account_id is not None: + _dict['network_account_id'] = self.network_account_id + if hasattr(self, 'network_id') and self.network_id is not None: + _dict['network_id'] = self.network_id + if hasattr(self, 'network_type') and self.network_type is not None: + _dict['network_type'] = self.network_type + if hasattr(self, 'remote_bgp_asn') and self.remote_bgp_asn is not None: + _dict['remote_bgp_asn'] = self.remote_bgp_asn + if hasattr(self, 'remote_gateway_ip') and self.remote_gateway_ip is not None: + _dict['remote_gateway_ip'] = self.remote_gateway_ip + if hasattr(self, 'remote_tunnel_ip') and self.remote_tunnel_ip is not None: + _dict['remote_tunnel_ip'] = self.remote_tunnel_ip + if hasattr(self, 'request_status') and self.request_status is not None: + _dict['request_status'] = self.request_status if hasattr(self, 'status') and self.status is not None: _dict['status'] = self.status + if hasattr(self, 'transit_gateway') and self.transit_gateway is not None: + _dict['transit_gateway'] = self.transit_gateway.to_dict() if hasattr(self, 'updated_at') and self.updated_at is not None: _dict['updated_at'] = datetime_to_string(self.updated_at) + if hasattr(self, 'zone') and self.zone is not None: + _dict['zone'] = self.zone.to_dict() return _dict def _to_dict(self): @@ -1316,67 +1564,130 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this TransitGateway object.""" + """Return a `str` version of this TransitConnection object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'TransitGateway') -> bool: + def __eq__(self, other: 'TransitConnection') -> 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: 'TransitGateway') -> bool: + def __ne__(self, other: 'TransitConnection') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other + class NetworkTypeEnum(str, Enum): + """ + Defines what type of network is connected via this connection. The list of + enumerated values for this property may expand in the future. Code and processes + using this field must tolerate unexpected values. + """ + VPC = 'vpc' + CLASSIC = 'classic' + GRE_TUNNEL = 'gre_tunnel' + + + class RequestStatusEnum(str, Enum): + """ + Only visible for cross account connections, this field represents the status of a + connection request between IBM Cloud accounts. The list of enumerated values for + this property may expand in the future. Code and processes using this field must + tolerate unexpected values. + """ + PENDING = 'pending' + APPROVED = 'approved' + REJECTED = 'rejected' + EXPIRED = 'expired' + DETACHED = 'detached' + + class StatusEnum(str, Enum): """ - The status of the Transit Gateway. + Connection state. The list of enumerated values for this property may expand in + the future. Code and processes using this field must tolerate unexpected values. """ - AVAILABLE = 'available' + ATTACHED = 'attached' FAILED = 'failed' PENDING = 'pending' DELETING = 'deleting' + DETACHING = 'detaching' + DETACHED = 'detached' -class TransitGatewayCollection(): +class TransitConnectionCollection(): """ - A list of Transit Gateways. - - :attr List[TransitGateway] transit_gateways: Collection of Transit Services - gateways. + Transit gateway connections. + + :attr List[TransitConnection] connections: Array of transit gateway connections. + :attr TransitConnectionCollectionFirst first: A reference to the first page of + resources. + :attr int limit: The maximum number of connections returned on one request. + :attr TransitConnectionCollectionNext next: (optional) A reference to the next + page of resources; this reference is included for all pages except the last + page. """ def __init__(self, - transit_gateways: List['TransitGateway']) -> None: + connections: List['TransitConnection'], + first: 'TransitConnectionCollectionFirst', + limit: int, + *, + next: 'TransitConnectionCollectionNext' = None) -> None: """ - Initialize a TransitGatewayCollection object. - - :param List[TransitGateway] transit_gateways: Collection of Transit - Services gateways. + Initialize a TransitConnectionCollection object. + + :param List[TransitConnection] connections: Array of transit gateway + connections. + :param TransitConnectionCollectionFirst first: A reference to the first + page of resources. + :param int limit: The maximum number of connections returned on one + request. + :param TransitConnectionCollectionNext next: (optional) A reference to the + next page of resources; this reference is included for all pages except the + last page. """ - self.transit_gateways = transit_gateways + self.connections = connections + self.first = first + self.limit = limit + self.next = next @classmethod - def from_dict(cls, _dict: Dict) -> 'TransitGatewayCollection': - """Initialize a TransitGatewayCollection object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'TransitConnectionCollection': + """Initialize a TransitConnectionCollection object from a json dictionary.""" args = {} - if 'transit_gateways' in _dict: - args['transit_gateways'] = [TransitGateway.from_dict(x) for x in _dict.get('transit_gateways')] + if 'connections' in _dict: + args['connections'] = [TransitConnection.from_dict(x) for x in _dict.get('connections')] else: - raise ValueError('Required property \'transit_gateways\' not present in TransitGatewayCollection JSON') + raise ValueError('Required property \'connections\' not present in TransitConnectionCollection JSON') + if 'first' in _dict: + args['first'] = TransitConnectionCollectionFirst.from_dict(_dict.get('first')) + else: + raise ValueError('Required property \'first\' not present in TransitConnectionCollection JSON') + if 'limit' in _dict: + args['limit'] = _dict.get('limit') + else: + raise ValueError('Required property \'limit\' not present in TransitConnectionCollection JSON') + if 'next' in _dict: + args['next'] = TransitConnectionCollectionNext.from_dict(_dict.get('next')) return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a TransitGatewayCollection object from a json dictionary.""" + """Initialize a TransitConnectionCollection 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, 'transit_gateways') and self.transit_gateways is not None: - _dict['transit_gateways'] = [x.to_dict() for x in self.transit_gateways] + if hasattr(self, 'connections') and self.connections is not None: + _dict['connections'] = [x.to_dict() for x in self.connections] + if hasattr(self, 'first') and self.first is not None: + _dict['first'] = self.first.to_dict() + if hasattr(self, 'limit') and self.limit is not None: + _dict['limit'] = self.limit + if hasattr(self, 'next') and self.next is not None: + _dict['next'] = self.next.to_dict() return _dict def _to_dict(self): @@ -1384,57 +1695,55 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this TransitGatewayCollection object.""" + """Return a `str` version of this TransitConnectionCollection object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'TransitGatewayCollection') -> bool: + def __eq__(self, other: 'TransitConnectionCollection') -> 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: 'TransitGatewayCollection') -> bool: + def __ne__(self, other: 'TransitConnectionCollection') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class TransitGatewayConnectionCollection(): +class TransitConnectionCollectionFirst(): """ - A set of Transit Gateway network connections. + A reference to the first page of resources. - :attr List[TransitGatewayConnectionCust] connections: Array of transit gateways - network Connections. + :attr str href: url. """ def __init__(self, - connections: List['TransitGatewayConnectionCust']) -> None: + href: str) -> None: """ - Initialize a TransitGatewayConnectionCollection object. + Initialize a TransitConnectionCollectionFirst object. - :param List[TransitGatewayConnectionCust] connections: Array of transit - gateways network Connections. + :param str href: url. """ - self.connections = connections + self.href = href @classmethod - def from_dict(cls, _dict: Dict) -> 'TransitGatewayConnectionCollection': - """Initialize a TransitGatewayConnectionCollection object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'TransitConnectionCollectionFirst': + """Initialize a TransitConnectionCollectionFirst object from a json dictionary.""" args = {} - if 'connections' in _dict: - args['connections'] = [TransitGatewayConnectionCust.from_dict(x) for x in _dict.get('connections')] + if 'href' in _dict: + args['href'] = _dict.get('href') else: - raise ValueError('Required property \'connections\' not present in TransitGatewayConnectionCollection JSON') + raise ValueError('Required property \'href\' not present in TransitConnectionCollectionFirst JSON') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a TransitGatewayConnectionCollection object from a json dictionary.""" + """Initialize a TransitConnectionCollectionFirst 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, 'connections') and self.connections is not None: - _dict['connections'] = [x.to_dict() for x in self.connections] + if hasattr(self, 'href') and self.href is not None: + _dict['href'] = self.href return _dict def _to_dict(self): @@ -1442,96 +1751,654 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this TransitGatewayConnectionCollection object.""" + """Return a `str` version of this TransitConnectionCollectionFirst object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'TransitGatewayConnectionCollection') -> bool: + def __eq__(self, other: 'TransitConnectionCollectionFirst') -> 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: 'TransitGatewayConnectionCollection') -> bool: + def __ne__(self, other: 'TransitConnectionCollectionFirst') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class TransitGatewayConnectionCust(): +class TransitConnectionCollectionNext(): """ - Connection included in transit gateway. + A reference to the next page of resources; this reference is included for all pages + except the last page. - :attr str name: (optional) The user-defined name for this transit gateway. If - unspecified, the name will be the network name (the name of the VPC in the case - of network type 'vpc', and the word Classic, in the case of network type - 'classic'). - :attr str network_id: (optional) The ID of the network being connected via this - connection. This field is required for some types, such as 'vpc'. For network - type 'vpc' this is the CRN of the VPC to be connected. This field is required to - be unspecified for network type 'classic'. - :attr str network_type: Defines what type of network is connected via this - connection. - :attr str network_account_id: (optional) The ID of the account which owns the - network that is being connected. Generally only used if the network is in a - different account than the gateway. - :attr str id: The unique identifier for this Transit Gateway Connection to - Network (vpc/classic). + :attr str href: (optional) url. + :attr str start: (optional) server generated start token for next page of + resources. + """ + + def __init__(self, + *, + href: str = None, + start: str = None) -> None: + """ + Initialize a TransitConnectionCollectionNext object. + + :param str href: (optional) url. + :param str start: (optional) server generated start token for next page of + resources. + """ + self.href = href + self.start = start + + @classmethod + def from_dict(cls, _dict: Dict) -> 'TransitConnectionCollectionNext': + """Initialize a TransitConnectionCollectionNext object from a json dictionary.""" + args = {} + if 'href' in _dict: + args['href'] = _dict.get('href') + if 'start' in _dict: + args['start'] = _dict.get('start') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a TransitConnectionCollectionNext 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, 'href') and self.href is not None: + _dict['href'] = self.href + if hasattr(self, 'start') and self.start is not None: + _dict['start'] = self.start + 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 TransitConnectionCollectionNext object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'TransitConnectionCollectionNext') -> 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: 'TransitConnectionCollectionNext') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + +class TransitGateway(): + """ + Details of a Transit Gateway. + + :attr str id: The unique identifier for this Transit Gateway. + :attr str crn: The CRN for this Transit Gateway. + :attr str name: A human readable name for the transit gateway. + :attr str location: Location of Transit Gateway Services. + :attr datetime created_at: The date and time that this gateway was created. + :attr bool global_: Allow global routing for a Transit Gateway. + :attr ResourceGroupReference resource_group: (optional) The resource group to + use. If unspecified, the account's [default resource + group](https://console.bluemix.net/apidocs/resource-manager#introduction) is + used. + :attr str status: The status of the Transit Gateway. The list of enumerated + values for this property may expand in the future. Code and processes using this + field must tolerate unexpected values. + :attr datetime updated_at: (optional) The date and time that this gateway was + last updated. + """ + + def __init__(self, + id: str, + crn: str, + name: str, + location: str, + created_at: datetime, + global_: bool, + status: str, + *, + resource_group: 'ResourceGroupReference' = None, + updated_at: datetime = None) -> None: + """ + Initialize a TransitGateway object. + + :param str id: The unique identifier for this Transit Gateway. + :param str crn: The CRN for this Transit Gateway. + :param str name: A human readable name for the transit gateway. + :param str location: Location of Transit Gateway Services. + :param datetime created_at: The date and time that this gateway was + created. + :param bool global_: Allow global routing for a Transit Gateway. + :param str status: The status of the Transit Gateway. The list of + enumerated values for this property may expand in the future. Code and + processes using this field must tolerate unexpected values. + :param ResourceGroupReference resource_group: (optional) The resource group + to use. If unspecified, the account's [default resource + group](https://console.bluemix.net/apidocs/resource-manager#introduction) + is used. + :param datetime updated_at: (optional) The date and time that this gateway + was last updated. + """ + self.id = id + self.crn = crn + self.name = name + self.location = location + self.created_at = created_at + self.global_ = global_ + self.resource_group = resource_group + self.status = status + self.updated_at = updated_at + + @classmethod + def from_dict(cls, _dict: Dict) -> 'TransitGateway': + """Initialize a TransitGateway object from a json dictionary.""" + args = {} + if 'id' in _dict: + args['id'] = _dict.get('id') + else: + raise ValueError('Required property \'id\' not present in TransitGateway JSON') + if 'crn' in _dict: + args['crn'] = _dict.get('crn') + else: + raise ValueError('Required property \'crn\' not present in TransitGateway JSON') + if 'name' in _dict: + args['name'] = _dict.get('name') + else: + raise ValueError('Required property \'name\' not present in TransitGateway JSON') + if 'location' in _dict: + args['location'] = _dict.get('location') + else: + raise ValueError('Required property \'location\' not present in TransitGateway JSON') + if 'created_at' in _dict: + args['created_at'] = string_to_datetime(_dict.get('created_at')) + else: + raise ValueError('Required property \'created_at\' not present in TransitGateway JSON') + if 'global' in _dict: + args['global_'] = _dict.get('global') + else: + raise ValueError('Required property \'global\' not present in TransitGateway JSON') + if 'resource_group' in _dict: + args['resource_group'] = ResourceGroupReference.from_dict(_dict.get('resource_group')) + if 'status' in _dict: + args['status'] = _dict.get('status') + else: + raise ValueError('Required property \'status\' not present in TransitGateway JSON') + if 'updated_at' in _dict: + args['updated_at'] = string_to_datetime(_dict.get('updated_at')) + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a TransitGateway 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, 'id') and self.id is not None: + _dict['id'] = self.id + if hasattr(self, 'crn') and self.crn is not None: + _dict['crn'] = self.crn + if hasattr(self, 'name') and self.name is not None: + _dict['name'] = self.name + if hasattr(self, 'location') and self.location is not None: + _dict['location'] = self.location + if hasattr(self, 'created_at') and self.created_at is not None: + _dict['created_at'] = datetime_to_string(self.created_at) + if hasattr(self, 'global_') and self.global_ is not None: + _dict['global'] = self.global_ + if hasattr(self, 'resource_group') and self.resource_group is not None: + _dict['resource_group'] = self.resource_group.to_dict() + if hasattr(self, 'status') and self.status is not None: + _dict['status'] = self.status + if hasattr(self, 'updated_at') and self.updated_at is not None: + _dict['updated_at'] = datetime_to_string(self.updated_at) + 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 TransitGateway object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'TransitGateway') -> 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: 'TransitGateway') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + class StatusEnum(str, Enum): + """ + The status of the Transit Gateway. The list of enumerated values for this property + may expand in the future. Code and processes using this field must tolerate + unexpected values. + """ + AVAILABLE = 'available' + FAILED = 'failed' + PENDING = 'pending' + DELETING = 'deleting' + + +class TransitGatewayCollection(): + """ + A list of Transit Gateways. + + :attr TransitGatewayCollectionFirst first: A reference to the first page of + resources. + :attr int limit: The maximum number of gateways returned on one request. + :attr TransitGatewayCollectionNext next: (optional) A reference to the next page + of resources; this reference is included for all pages except the last page. + :attr List[TransitGateway] transit_gateways: Collection of Transit Services + gateways. + """ + + def __init__(self, + first: 'TransitGatewayCollectionFirst', + limit: int, + transit_gateways: List['TransitGateway'], + *, + next: 'TransitGatewayCollectionNext' = None) -> None: + """ + Initialize a TransitGatewayCollection object. + + :param TransitGatewayCollectionFirst first: A reference to the first page + of resources. + :param int limit: The maximum number of gateways returned on one request. + :param List[TransitGateway] transit_gateways: Collection of Transit + Services gateways. + :param TransitGatewayCollectionNext next: (optional) A reference to the + next page of resources; this reference is included for all pages except the + last page. + """ + self.first = first + self.limit = limit + self.next = next + self.transit_gateways = transit_gateways + + @classmethod + def from_dict(cls, _dict: Dict) -> 'TransitGatewayCollection': + """Initialize a TransitGatewayCollection object from a json dictionary.""" + args = {} + if 'first' in _dict: + args['first'] = TransitGatewayCollectionFirst.from_dict(_dict.get('first')) + else: + raise ValueError('Required property \'first\' not present in TransitGatewayCollection JSON') + if 'limit' in _dict: + args['limit'] = _dict.get('limit') + else: + raise ValueError('Required property \'limit\' not present in TransitGatewayCollection JSON') + if 'next' in _dict: + args['next'] = TransitGatewayCollectionNext.from_dict(_dict.get('next')) + if 'transit_gateways' in _dict: + args['transit_gateways'] = [TransitGateway.from_dict(x) for x in _dict.get('transit_gateways')] + else: + raise ValueError('Required property \'transit_gateways\' not present in TransitGatewayCollection JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a TransitGatewayCollection 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, 'first') and self.first is not None: + _dict['first'] = self.first.to_dict() + if hasattr(self, 'limit') and self.limit is not None: + _dict['limit'] = self.limit + if hasattr(self, 'next') and self.next is not None: + _dict['next'] = self.next.to_dict() + if hasattr(self, 'transit_gateways') and self.transit_gateways is not None: + _dict['transit_gateways'] = [x.to_dict() for x in self.transit_gateways] + 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 TransitGatewayCollection object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'TransitGatewayCollection') -> 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: 'TransitGatewayCollection') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + +class TransitGatewayCollectionFirst(): + """ + A reference to the first page of resources. + + :attr str href: url. + """ + + def __init__(self, + href: str) -> None: + """ + Initialize a TransitGatewayCollectionFirst object. + + :param str href: url. + """ + self.href = href + + @classmethod + def from_dict(cls, _dict: Dict) -> 'TransitGatewayCollectionFirst': + """Initialize a TransitGatewayCollectionFirst object from a json dictionary.""" + args = {} + if 'href' in _dict: + args['href'] = _dict.get('href') + else: + raise ValueError('Required property \'href\' not present in TransitGatewayCollectionFirst JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a TransitGatewayCollectionFirst 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, 'href') and self.href is not None: + _dict['href'] = self.href + 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 TransitGatewayCollectionFirst object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'TransitGatewayCollectionFirst') -> 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: 'TransitGatewayCollectionFirst') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + +class TransitGatewayCollectionNext(): + """ + A reference to the next page of resources; this reference is included for all pages + except the last page. + + :attr str href: url. + :attr str start: server generated start token for next page of resources. + """ + + def __init__(self, + href: str, + start: str) -> None: + """ + Initialize a TransitGatewayCollectionNext object. + + :param str href: url. + :param str start: server generated start token for next page of resources. + """ + self.href = href + self.start = start + + @classmethod + def from_dict(cls, _dict: Dict) -> 'TransitGatewayCollectionNext': + """Initialize a TransitGatewayCollectionNext object from a json dictionary.""" + args = {} + if 'href' in _dict: + args['href'] = _dict.get('href') + else: + raise ValueError('Required property \'href\' not present in TransitGatewayCollectionNext JSON') + if 'start' in _dict: + args['start'] = _dict.get('start') + else: + raise ValueError('Required property \'start\' not present in TransitGatewayCollectionNext JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a TransitGatewayCollectionNext 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, 'href') and self.href is not None: + _dict['href'] = self.href + if hasattr(self, 'start') and self.start is not None: + _dict['start'] = self.start + 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 TransitGatewayCollectionNext object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'TransitGatewayCollectionNext') -> 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: 'TransitGatewayCollectionNext') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + +class TransitGatewayConnectionCollection(): + """ + A set of Transit Gateway network connections. + + :attr List[TransitGatewayConnectionCust] connections: Array of transit gateways + network Connections. + """ + + def __init__(self, + connections: List['TransitGatewayConnectionCust']) -> None: + """ + Initialize a TransitGatewayConnectionCollection object. + + :param List[TransitGatewayConnectionCust] connections: Array of transit + gateways network Connections. + """ + self.connections = connections + + @classmethod + def from_dict(cls, _dict: Dict) -> 'TransitGatewayConnectionCollection': + """Initialize a TransitGatewayConnectionCollection object from a json dictionary.""" + args = {} + if 'connections' in _dict: + args['connections'] = [TransitGatewayConnectionCust.from_dict(x) for x in _dict.get('connections')] + else: + raise ValueError('Required property \'connections\' not present in TransitGatewayConnectionCollection JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a TransitGatewayConnectionCollection 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, 'connections') and self.connections is not None: + _dict['connections'] = [x.to_dict() for x in self.connections] + 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 TransitGatewayConnectionCollection object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'TransitGatewayConnectionCollection') -> 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: 'TransitGatewayConnectionCollection') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + +class TransitGatewayConnectionCust(): + """ + Connection included in transit gateway. + + :attr str name: The user-defined name for this transit gateway connection. + :attr str network_id: (optional) The ID of the network being connected via this + connection. This field is required for some types, such as 'vpc'. For network + type 'vpc' this is the CRN of the VPC to be connected. + :attr str network_type: Defines what type of network is connected via this + connection. The list of enumerated values for this property may expand in the + future. Code and processes using this field must tolerate unexpected values. + :attr str id: The unique identifier for this Transit Gateway Connection. + :attr str base_connection_id: (optional) network_type 'gre_tunnel' connections + use 'base_connection_id' to specify the ID of a network_type 'classic' + connection the tunnel is configured over. The specified connection must reside + in the same transit gateway and be in an active state. The 'classic' connection + cannot be deleted until any 'gre_tunnel' connections using it are deleted. This + field only applies to and is required for network type 'gre_tunnel' connections. :attr datetime created_at: The date and time that this connection was created. + :attr int local_bgp_asn: (optional) Local network BGP ASN. This field only + applies to network type 'gre_tunnel' connections. + :attr str local_gateway_ip: (optional) Local gateway IP address. This field + only applies to network type 'gre_tunnel' connections. + :attr str local_tunnel_ip: (optional) Local tunnel IP address. This field only + applies to network type 'gre_tunnel' connections. + :attr int mtu: (optional) GRE tunnel MTU. This field only applies to network + type 'gre_tunnel' connections. + :attr str network_account_id: (optional) The ID of the account which owns the + connected network. Generally only used if the network is in a different IBM + Cloud account than the gateway. + :attr int remote_bgp_asn: (optional) Remote network BGP ASN. This field only + applies to network type 'gre_tunnel' connections. + :attr str remote_gateway_ip: (optional) Remote gateway IP address. This field + only applies to network type 'gre_tunnel' connections. + :attr str remote_tunnel_ip: (optional) Remote tunnel IP address. This field + only applies to network type 'gre_tunnel' connections. :attr str request_status: (optional) Only visible for cross account connections, - this field represents the status of the request to connect the given network - between accounts. - :attr str status: (optional) What is the current configuration state of this - connection. + this field represents the status of a connection request between IBM Cloud + accounts. The list of enumerated values for this property may expand in the + future. Code and processes using this field must tolerate unexpected values. + :attr str status: (optional) Connection's current configuration state. The list + of enumerated values for this property may expand in the future. Code and + processes using this field must tolerate unexpected values. :attr datetime updated_at: (optional) The date and time that this connection was last updated. + :attr TransitGatewayConnectionCustZone zone: (optional) Location of GRE tunnel. + This field only applies to network type 'gre_tunnel' connections. """ def __init__(self, + name: str, network_type: str, id: str, created_at: datetime, *, - name: str = None, network_id: str = None, + base_connection_id: str = None, + local_bgp_asn: int = None, + local_gateway_ip: str = None, + local_tunnel_ip: str = None, + mtu: int = None, network_account_id: str = None, + remote_bgp_asn: int = None, + remote_gateway_ip: str = None, + remote_tunnel_ip: str = None, request_status: str = None, status: str = None, - updated_at: datetime = None) -> None: + updated_at: datetime = None, + zone: 'TransitGatewayConnectionCustZone' = None) -> None: """ Initialize a TransitGatewayConnectionCust object. + :param str name: The user-defined name for this transit gateway connection. :param str network_type: Defines what type of network is connected via this - connection. - :param str id: The unique identifier for this Transit Gateway Connection to - Network (vpc/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. + :param str id: The unique identifier for this Transit Gateway Connection. :param datetime created_at: The date and time that this connection was created. - :param str name: (optional) The user-defined name for this transit gateway. - If unspecified, the name will be the network name (the name of the VPC in - the case of network type 'vpc', and the word Classic, in the case of - network type 'classic'). :param str network_id: (optional) The ID of the network being connected via this connection. This field is required for some types, such as 'vpc'. For - network type 'vpc' this is the CRN of the VPC to be connected. This field - is required to be unspecified for network type 'classic'. + network type 'vpc' this is the CRN of the VPC to be connected. + :param str base_connection_id: (optional) network_type 'gre_tunnel' + connections use 'base_connection_id' to specify the ID of a network_type + 'classic' connection the tunnel is configured over. The specified + connection must reside in the same transit gateway and be in an active + state. The 'classic' connection cannot be deleted until any 'gre_tunnel' + connections using it are deleted. This field only applies to and is + required for network type 'gre_tunnel' connections. + :param int local_bgp_asn: (optional) Local network BGP ASN. This field + only applies to network type 'gre_tunnel' connections. + :param str local_gateway_ip: (optional) Local gateway IP address. This + field only applies to network type 'gre_tunnel' connections. + :param str local_tunnel_ip: (optional) Local tunnel IP address. This field + only applies to network type 'gre_tunnel' connections. + :param int mtu: (optional) GRE tunnel MTU. This field only applies to + network type 'gre_tunnel' connections. :param str network_account_id: (optional) The ID of the account which owns - the network that is being connected. Generally only used if the network is - in a different account than the gateway. + the connected network. Generally only used if the network is in a different + IBM Cloud account than the gateway. + :param int remote_bgp_asn: (optional) Remote network BGP ASN. This field + only applies to network type 'gre_tunnel' connections. + :param str remote_gateway_ip: (optional) Remote gateway IP address. This + field only applies to network type 'gre_tunnel' connections. + :param str remote_tunnel_ip: (optional) Remote tunnel IP address. This + field only applies to network type 'gre_tunnel' connections. :param str request_status: (optional) Only visible for cross account - connections, this field represents the status of the request to connect the - given network between accounts. - :param str status: (optional) What is the current configuration state of - this connection. + connections, this field represents the status of a connection request + between IBM Cloud accounts. The list of enumerated values for this property + may expand in the future. Code and processes using this field must tolerate + unexpected values. + :param str status: (optional) Connection's current configuration state. The + list of enumerated values for this property may expand in the future. Code + and processes using this field must tolerate unexpected values. :param datetime updated_at: (optional) The date and time that this connection was last updated. + :param TransitGatewayConnectionCustZone zone: (optional) Location of GRE + tunnel. This field only applies to network type 'gre_tunnel' connections. """ self.name = name self.network_id = network_id self.network_type = network_type - self.network_account_id = network_account_id self.id = id + self.base_connection_id = base_connection_id self.created_at = created_at + self.local_bgp_asn = local_bgp_asn + self.local_gateway_ip = local_gateway_ip + self.local_tunnel_ip = local_tunnel_ip + self.mtu = mtu + self.network_account_id = network_account_id + self.remote_bgp_asn = remote_bgp_asn + self.remote_gateway_ip = remote_gateway_ip + self.remote_tunnel_ip = remote_tunnel_ip self.request_status = request_status self.status = status self.updated_at = updated_at + self.zone = zone @classmethod def from_dict(cls, _dict: Dict) -> 'TransitGatewayConnectionCust': @@ -1539,28 +2406,48 @@ def from_dict(cls, _dict: Dict) -> 'TransitGatewayConnectionCust': args = {} if 'name' in _dict: args['name'] = _dict.get('name') + else: + raise ValueError('Required property \'name\' not present in TransitGatewayConnectionCust JSON') if 'network_id' in _dict: args['network_id'] = _dict.get('network_id') if 'network_type' in _dict: args['network_type'] = _dict.get('network_type') else: raise ValueError('Required property \'network_type\' not present in TransitGatewayConnectionCust JSON') - if 'network_account_id' in _dict: - args['network_account_id'] = _dict.get('network_account_id') if 'id' in _dict: args['id'] = _dict.get('id') else: raise ValueError('Required property \'id\' not present in TransitGatewayConnectionCust JSON') + if 'base_connection_id' in _dict: + args['base_connection_id'] = _dict.get('base_connection_id') if 'created_at' in _dict: args['created_at'] = string_to_datetime(_dict.get('created_at')) else: raise ValueError('Required property \'created_at\' not present in TransitGatewayConnectionCust JSON') + if 'local_bgp_asn' in _dict: + args['local_bgp_asn'] = _dict.get('local_bgp_asn') + if 'local_gateway_ip' in _dict: + args['local_gateway_ip'] = _dict.get('local_gateway_ip') + if 'local_tunnel_ip' in _dict: + args['local_tunnel_ip'] = _dict.get('local_tunnel_ip') + if 'mtu' in _dict: + args['mtu'] = _dict.get('mtu') + if 'network_account_id' in _dict: + args['network_account_id'] = _dict.get('network_account_id') + if 'remote_bgp_asn' in _dict: + args['remote_bgp_asn'] = _dict.get('remote_bgp_asn') + if 'remote_gateway_ip' in _dict: + args['remote_gateway_ip'] = _dict.get('remote_gateway_ip') + if 'remote_tunnel_ip' in _dict: + args['remote_tunnel_ip'] = _dict.get('remote_tunnel_ip') if 'request_status' in _dict: args['request_status'] = _dict.get('request_status') if 'status' in _dict: args['status'] = _dict.get('status') if 'updated_at' in _dict: args['updated_at'] = string_to_datetime(_dict.get('updated_at')) + if 'zone' in _dict: + args['zone'] = TransitGatewayConnectionCustZone.from_dict(_dict.get('zone')) return cls(**args) @classmethod @@ -1577,18 +2464,36 @@ def to_dict(self) -> Dict: _dict['network_id'] = self.network_id if hasattr(self, 'network_type') and self.network_type is not None: _dict['network_type'] = self.network_type - if hasattr(self, 'network_account_id') and self.network_account_id is not None: - _dict['network_account_id'] = self.network_account_id if hasattr(self, 'id') and self.id is not None: _dict['id'] = self.id + if hasattr(self, 'base_connection_id') and self.base_connection_id is not None: + _dict['base_connection_id'] = self.base_connection_id if hasattr(self, 'created_at') and self.created_at is not None: _dict['created_at'] = datetime_to_string(self.created_at) + if hasattr(self, 'local_bgp_asn') and self.local_bgp_asn is not None: + _dict['local_bgp_asn'] = self.local_bgp_asn + if hasattr(self, 'local_gateway_ip') and self.local_gateway_ip is not None: + _dict['local_gateway_ip'] = self.local_gateway_ip + if hasattr(self, 'local_tunnel_ip') and self.local_tunnel_ip is not None: + _dict['local_tunnel_ip'] = self.local_tunnel_ip + if hasattr(self, 'mtu') and self.mtu is not None: + _dict['mtu'] = self.mtu + if hasattr(self, 'network_account_id') and self.network_account_id is not None: + _dict['network_account_id'] = self.network_account_id + if hasattr(self, 'remote_bgp_asn') and self.remote_bgp_asn is not None: + _dict['remote_bgp_asn'] = self.remote_bgp_asn + if hasattr(self, 'remote_gateway_ip') and self.remote_gateway_ip is not None: + _dict['remote_gateway_ip'] = self.remote_gateway_ip + if hasattr(self, 'remote_tunnel_ip') and self.remote_tunnel_ip is not None: + _dict['remote_tunnel_ip'] = self.remote_tunnel_ip if hasattr(self, 'request_status') and self.request_status is not None: _dict['request_status'] = self.request_status if hasattr(self, 'status') and self.status is not None: _dict['status'] = self.status if hasattr(self, 'updated_at') and self.updated_at is not None: _dict['updated_at'] = datetime_to_string(self.updated_at) + if hasattr(self, 'zone') and self.zone is not None: + _dict['zone'] = self.zone.to_dict() return _dict def _to_dict(self): @@ -1611,16 +2516,21 @@ def __ne__(self, other: 'TransitGatewayConnectionCust') -> bool: class NetworkTypeEnum(str, Enum): """ - Defines what type of network is connected via this connection. + Defines what type of network is connected via this connection. The list of + enumerated values for this property may expand in the future. Code and processes + using this field must tolerate unexpected values. """ VPC = 'vpc' CLASSIC = 'classic' + GRE_TUNNEL = 'gre_tunnel' class RequestStatusEnum(str, Enum): """ - Only visible for cross account connections, this field represents the status of - the request to connect the given network between accounts. + Only visible for cross account connections, this field represents the status of a + connection request between IBM Cloud accounts. The list of enumerated values for + this property may expand in the future. Code and processes using this field must + tolerate unexpected values. """ PENDING = 'pending' APPROVED = 'approved' @@ -1631,7 +2541,9 @@ class RequestStatusEnum(str, Enum): class StatusEnum(str, Enum): """ - What is the current configuration state of this connection. + Connection's current configuration state. The list of enumerated values for this + property may expand in the future. Code and processes using this field must + tolerate unexpected values. """ ATTACHED = 'attached' FAILED = 'failed' @@ -1640,3 +2552,263 @@ class StatusEnum(str, Enum): DETACHING = 'detaching' DETACHED = 'detached' + +class TransitGatewayConnectionCustZone(): + """ + Location of GRE tunnel. This field only applies to network type 'gre_tunnel' + connections. + + :attr str name: Availability zone name. + """ + + def __init__(self, + name: str) -> None: + """ + Initialize a TransitGatewayConnectionCustZone object. + + :param str name: Availability zone name. + """ + self.name = name + + @classmethod + def from_dict(cls, _dict: Dict) -> 'TransitGatewayConnectionCustZone': + """Initialize a TransitGatewayConnectionCustZone object from a json dictionary.""" + args = {} + if 'name' in _dict: + args['name'] = _dict.get('name') + else: + raise ValueError('Required property \'name\' not present in TransitGatewayConnectionCustZone JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a TransitGatewayConnectionCustZone 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, 'name') and self.name is not None: + _dict['name'] = self.name + 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 TransitGatewayConnectionCustZone object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'TransitGatewayConnectionCustZone') -> 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: 'TransitGatewayConnectionCustZone') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + +class TransitGatewayReference(): + """ + Transit gateway reference. + + :attr str crn: gateway CRN. + :attr str id: gateway ID. + :attr str name: transit gateway name. + """ + + def __init__(self, + crn: str, + id: str, + name: str) -> None: + """ + Initialize a TransitGatewayReference object. + + :param str crn: gateway CRN. + :param str id: gateway ID. + :param str name: transit gateway name. + """ + self.crn = crn + self.id = id + self.name = name + + @classmethod + def from_dict(cls, _dict: Dict) -> 'TransitGatewayReference': + """Initialize a TransitGatewayReference object from a json dictionary.""" + args = {} + if 'crn' in _dict: + args['crn'] = _dict.get('crn') + else: + raise ValueError('Required property \'crn\' not present in TransitGatewayReference JSON') + if 'id' in _dict: + args['id'] = _dict.get('id') + else: + raise ValueError('Required property \'id\' not present in TransitGatewayReference JSON') + if 'name' in _dict: + args['name'] = _dict.get('name') + else: + raise ValueError('Required property \'name\' not present in TransitGatewayReference JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a TransitGatewayReference 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 + if hasattr(self, 'id') and self.id is not None: + _dict['id'] = self.id + if hasattr(self, 'name') and self.name is not None: + _dict['name'] = self.name + 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 TransitGatewayReference object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'TransitGatewayReference') -> 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: 'TransitGatewayReference') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + +class ZoneIdentity(): + """ + ZoneIdentity. + + """ + + def __init__(self) -> None: + """ + Initialize a ZoneIdentity object. + + """ + msg = "Cannot instantiate base class. Instead, instantiate one of the defined subclasses: {0}".format( + ", ".join(['ZoneIdentityByName'])) + raise Exception(msg) + +class ZoneReference(): + """ + Availability zone reference. + + :attr str name: Availability zone name. + """ + + def __init__(self, + name: str) -> None: + """ + Initialize a ZoneReference object. + + :param str name: Availability zone name. + """ + self.name = name + + @classmethod + def from_dict(cls, _dict: Dict) -> 'ZoneReference': + """Initialize a ZoneReference object from a json dictionary.""" + args = {} + if 'name' in _dict: + args['name'] = _dict.get('name') + else: + raise ValueError('Required property \'name\' not present in ZoneReference JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a ZoneReference 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, 'name') and self.name is not None: + _dict['name'] = self.name + 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 ZoneReference object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'ZoneReference') -> 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: 'ZoneReference') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + +class ZoneIdentityByName(ZoneIdentity): + """ + Availability zone. + + :attr str name: (optional) Availability zone name. + """ + + def __init__(self, + *, + name: str = None) -> None: + """ + Initialize a ZoneIdentityByName object. + + :param str name: (optional) Availability zone name. + """ + # pylint: disable=super-init-not-called + self.name = name + + @classmethod + def from_dict(cls, _dict: Dict) -> 'ZoneIdentityByName': + """Initialize a ZoneIdentityByName object from a json dictionary.""" + args = {} + if 'name' in _dict: + args['name'] = _dict.get('name') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a ZoneIdentityByName 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, 'name') and self.name is not None: + _dict['name'] = self.name + 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 ZoneIdentityByName object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'ZoneIdentityByName') -> 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: 'ZoneIdentityByName') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other diff --git a/test/integration/test_transit_gateway_apis_v1.py b/test/integration/test_transit_gateway_apis_v1.py index 545e97a..b11548c 100644 --- a/test/integration/test_transit_gateway_apis_v1.py +++ b/test/integration/test_transit_gateway_apis_v1.py @@ -17,9 +17,9 @@ # load the .env file containing your environment variables for the required try: - load_dotenv(find_dotenv(filename=".transit_env")) + load_dotenv(find_dotenv(filename="transit.env")) except: - raise unittest.SkipTest('no .transit_env file loaded, skipping...') + raise unittest.SkipTest('no transit.env file loaded, skipping...') class TestTransitGatewayApisV1(unittest.TestCase): """ Test class for Transit Gateway sdk functions """ diff --git a/test/unit/test_transit_gateway_apis_v1.py b/test/unit/test_transit_gateway_apis_v1.py index 3306407..c691a8d 100644 --- a/test/unit/test_transit_gateway_apis_v1.py +++ b/test/unit/test_transit_gateway_apis_v1.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# (C) Copyright IBM Corp. 2020. +# (C) Copyright IBM Corp. 2021. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ import re import requests import responses +import urllib from ibm_cloud_networking_services.transit_gateway_apis_v1 import * version = 'testString' @@ -33,6 +34,114 @@ base_url = 'https://transit.cloud.ibm.com/v1' service.set_service_url(base_url) +############################################################################## +# Start of Service: TransitConnections +############################################################################## +# region + +#----------------------------------------------------------------------------- +# Test Class for list_connections +#----------------------------------------------------------------------------- +class TestListConnections(): + + # Preprocess the request URL to ensure the mock response will be found. + def preprocess_url(self, request_url: str): + request_url = urllib.parse.quote(request_url, safe=':/') + if re.fullmatch('.*/+', request_url) is None: + return request_url + else: + return re.compile(request_url.rstrip('/') + '/+') + + #-------------------------------------------------------- + # list_connections() + #-------------------------------------------------------- + @responses.activate + def test_list_connections_all_params(self): + # Set up mock + url = self.preprocess_url(base_url + '/connections') + mock_response = '{"connections": [{"base_connection_id": "975f58c1-afe7-469a-9727-7f3d720f2d32", "created_at": "2019-01-01T12:00:00", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "local_bgp_asn": 64490, "local_gateway_ip": "192.168.100.1", "local_tunnel_ip": "192.168.129.2", "mtu": 9000, "name": "Transit_Service_SJ_DL", "network_account_id": "28e4d90ac7504be694471ee66e70d0d5", "network_id": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "network_type": "vpc", "remote_bgp_asn": 65010, "remote_gateway_ip": "10.242.63.12", "remote_tunnel_ip": "192.168.129.1", "request_status": "pending", "status": "attached", "transit_gateway": {"crn": "crn:v1:bluemix:public:transit:us-south:a/123456::gateway:456f58c1-afe7-123a-0a0a-7f3d720f1a44", "id": "456f58c1-afe7-123a-0a0a-7f3d720f1a44", "name": "my-transit-gw100"}, "updated_at": "2019-01-01T12:00:00", "zone": {"name": "us-south-1"}}], "first": {"href": "https://transit.cloud.ibm.com/v1/connections?limit=50"}, "limit": 50, "next": {"href": "https://transit.cloud.ibm.com/v1/connections?start=MjAyMC0wNS0wOVQxNjoyMDoyMC4yMjQ5NzNa&limit=50", "start": "MjAyMC0wNS0wOVQxNjoyMDoyMC4yMjQ5NzNa"}}' + responses.add(responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Set up parameter values + limit = 1 + start = 'testString' + network_id = 'testString' + + # Invoke method + response = service.list_connections( + limit=limit, + start=start, + network_id=network_id, + headers={} + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + # Validate query params + query_string = responses.calls[0].request.url.split('?',1)[1] + query_string = requests.utils.unquote(query_string) + assert 'limit={}'.format(limit) in query_string + assert 'start={}'.format(start) in query_string + assert 'network_id={}'.format(network_id) in query_string + + + #-------------------------------------------------------- + # test_list_connections_required_params() + #-------------------------------------------------------- + @responses.activate + def test_list_connections_required_params(self): + # Set up mock + url = self.preprocess_url(base_url + '/connections') + mock_response = '{"connections": [{"base_connection_id": "975f58c1-afe7-469a-9727-7f3d720f2d32", "created_at": "2019-01-01T12:00:00", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "local_bgp_asn": 64490, "local_gateway_ip": "192.168.100.1", "local_tunnel_ip": "192.168.129.2", "mtu": 9000, "name": "Transit_Service_SJ_DL", "network_account_id": "28e4d90ac7504be694471ee66e70d0d5", "network_id": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "network_type": "vpc", "remote_bgp_asn": 65010, "remote_gateway_ip": "10.242.63.12", "remote_tunnel_ip": "192.168.129.1", "request_status": "pending", "status": "attached", "transit_gateway": {"crn": "crn:v1:bluemix:public:transit:us-south:a/123456::gateway:456f58c1-afe7-123a-0a0a-7f3d720f1a44", "id": "456f58c1-afe7-123a-0a0a-7f3d720f1a44", "name": "my-transit-gw100"}, "updated_at": "2019-01-01T12:00:00", "zone": {"name": "us-south-1"}}], "first": {"href": "https://transit.cloud.ibm.com/v1/connections?limit=50"}, "limit": 50, "next": {"href": "https://transit.cloud.ibm.com/v1/connections?start=MjAyMC0wNS0wOVQxNjoyMDoyMC4yMjQ5NzNa&limit=50", "start": "MjAyMC0wNS0wOVQxNjoyMDoyMC4yMjQ5NzNa"}}' + responses.add(responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Invoke method + response = service.list_connections() + + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + + #-------------------------------------------------------- + # test_list_connections_value_error() + #-------------------------------------------------------- + @responses.activate + def test_list_connections_value_error(self): + # Set up mock + url = self.preprocess_url(base_url + '/connections') + mock_response = '{"connections": [{"base_connection_id": "975f58c1-afe7-469a-9727-7f3d720f2d32", "created_at": "2019-01-01T12:00:00", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "local_bgp_asn": 64490, "local_gateway_ip": "192.168.100.1", "local_tunnel_ip": "192.168.129.2", "mtu": 9000, "name": "Transit_Service_SJ_DL", "network_account_id": "28e4d90ac7504be694471ee66e70d0d5", "network_id": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "network_type": "vpc", "remote_bgp_asn": 65010, "remote_gateway_ip": "10.242.63.12", "remote_tunnel_ip": "192.168.129.1", "request_status": "pending", "status": "attached", "transit_gateway": {"crn": "crn:v1:bluemix:public:transit:us-south:a/123456::gateway:456f58c1-afe7-123a-0a0a-7f3d720f1a44", "id": "456f58c1-afe7-123a-0a0a-7f3d720f1a44", "name": "my-transit-gw100"}, "updated_at": "2019-01-01T12:00:00", "zone": {"name": "us-south-1"}}], "first": {"href": "https://transit.cloud.ibm.com/v1/connections?limit=50"}, "limit": 50, "next": {"href": "https://transit.cloud.ibm.com/v1/connections?start=MjAyMC0wNS0wOVQxNjoyMDoyMC4yMjQ5NzNa&limit=50", "start": "MjAyMC0wNS0wOVQxNjoyMDoyMC4yMjQ5NzNa"}}' + responses.add(responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + } + for param in req_param_dict.keys(): + req_copy = {key:val if key is not param else None for (key,val) in req_param_dict.items()} + with pytest.raises(ValueError): + service.list_connections(**req_copy) + + + +# endregion +############################################################################## +# End of Service: TransitConnections +############################################################################## + ############################################################################## # Start of Service: TransitGateways ############################################################################## @@ -45,6 +154,7 @@ class TestListTransitGateways(): # Preprocess the request URL to ensure the mock response will be found. def preprocess_url(self, request_url: str): + request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url else: @@ -57,7 +167,42 @@ def preprocess_url(self, request_url: str): def test_list_transit_gateways_all_params(self): # Set up mock url = self.preprocess_url(base_url + '/transit_gateways') - mock_response = '{"transit_gateways": [{"id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "crn": "crn:v1:bluemix:public:transit:dal03:a/57a7d05f36894e3cb9b46a43556d903e::gateway:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "my-transit-gateway-in-TransitGateway", "location": "us-south", "created_at": "2019-01-01T12:00:00", "global": true, "resource_group": {"id": "56969d6043e9465c883cb9f7363e78e8", "href": "https://resource-manager.bluemix.net/v1/resource_groups/56969d6043e9465c883cb9f7363e78e8"}, "status": "available", "updated_at": "2019-01-01T12:00:00"}]}' + mock_response = '{"first": {"href": "https://transit.cloud.ibm.com/v1/transit_gateways?limit=50"}, "limit": 50, "next": {"href": "https://transit.cloud.ibm.com/v1/transit_gateways?start=MjAyMC0wNS0wOFQxNDoxNzowMy45NzQ5NzNa&limit=50", "start": "MjAyMC0wNS0wOFQxNDoxNzowMy45NzQ5NzNa"}, "transit_gateways": [{"id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "crn": "crn:v1:bluemix:public:transit:dal03:a/57a7d05f36894e3cb9b46a43556d903e::gateway:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "my-transit-gateway-in-TransitGateway", "location": "us-south", "created_at": "2019-01-01T12:00:00", "global": true, "resource_group": {"id": "56969d6043e9465c883cb9f7363e78e8", "href": "https://resource-manager.bluemix.net/v1/resource_groups/56969d6043e9465c883cb9f7363e78e8"}, "status": "available", "updated_at": "2019-01-01T12:00:00"}]}' + responses.add(responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Set up parameter values + limit = 1 + start = 'testString' + + # Invoke method + response = service.list_transit_gateways( + limit=limit, + start=start, + headers={} + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + # Validate query params + query_string = responses.calls[0].request.url.split('?',1)[1] + query_string = requests.utils.unquote(query_string) + assert 'limit={}'.format(limit) in query_string + assert 'start={}'.format(start) in query_string + + + #-------------------------------------------------------- + # test_list_transit_gateways_required_params() + #-------------------------------------------------------- + @responses.activate + def test_list_transit_gateways_required_params(self): + # Set up mock + url = self.preprocess_url(base_url + '/transit_gateways') + mock_response = '{"first": {"href": "https://transit.cloud.ibm.com/v1/transit_gateways?limit=50"}, "limit": 50, "next": {"href": "https://transit.cloud.ibm.com/v1/transit_gateways?start=MjAyMC0wNS0wOFQxNDoxNzowMy45NzQ5NzNa&limit=50", "start": "MjAyMC0wNS0wOFQxNDoxNzowMy45NzQ5NzNa"}, "transit_gateways": [{"id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "crn": "crn:v1:bluemix:public:transit:dal03:a/57a7d05f36894e3cb9b46a43556d903e::gateway:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "my-transit-gateway-in-TransitGateway", "location": "us-south", "created_at": "2019-01-01T12:00:00", "global": true, "resource_group": {"id": "56969d6043e9465c883cb9f7363e78e8", "href": "https://resource-manager.bluemix.net/v1/resource_groups/56969d6043e9465c883cb9f7363e78e8"}, "status": "available", "updated_at": "2019-01-01T12:00:00"}]}' responses.add(responses.GET, url, body=mock_response, @@ -80,7 +225,7 @@ def test_list_transit_gateways_all_params(self): def test_list_transit_gateways_value_error(self): # Set up mock url = self.preprocess_url(base_url + '/transit_gateways') - mock_response = '{"transit_gateways": [{"id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "crn": "crn:v1:bluemix:public:transit:dal03:a/57a7d05f36894e3cb9b46a43556d903e::gateway:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "my-transit-gateway-in-TransitGateway", "location": "us-south", "created_at": "2019-01-01T12:00:00", "global": true, "resource_group": {"id": "56969d6043e9465c883cb9f7363e78e8", "href": "https://resource-manager.bluemix.net/v1/resource_groups/56969d6043e9465c883cb9f7363e78e8"}, "status": "available", "updated_at": "2019-01-01T12:00:00"}]}' + mock_response = '{"first": {"href": "https://transit.cloud.ibm.com/v1/transit_gateways?limit=50"}, "limit": 50, "next": {"href": "https://transit.cloud.ibm.com/v1/transit_gateways?start=MjAyMC0wNS0wOFQxNDoxNzowMy45NzQ5NzNa&limit=50", "start": "MjAyMC0wNS0wOFQxNDoxNzowMy45NzQ5NzNa"}, "transit_gateways": [{"id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "crn": "crn:v1:bluemix:public:transit:dal03:a/57a7d05f36894e3cb9b46a43556d903e::gateway:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "my-transit-gateway-in-TransitGateway", "location": "us-south", "created_at": "2019-01-01T12:00:00", "global": true, "resource_group": {"id": "56969d6043e9465c883cb9f7363e78e8", "href": "https://resource-manager.bluemix.net/v1/resource_groups/56969d6043e9465c883cb9f7363e78e8"}, "status": "available", "updated_at": "2019-01-01T12:00:00"}]}' responses.add(responses.GET, url, body=mock_response, @@ -104,6 +249,7 @@ class TestCreateTransitGateway(): # Preprocess the request URL to ensure the mock response will be found. def preprocess_url(self, request_url: str): + request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url else: @@ -196,6 +342,7 @@ class TestDeleteTransitGateway(): # Preprocess the request URL to ensure the mock response will be found. def preprocess_url(self, request_url: str): + request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url else: @@ -258,6 +405,7 @@ class TestGetTransitGateway(): # Preprocess the request URL to ensure the mock response will be found. def preprocess_url(self, request_url: str): + request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url else: @@ -326,6 +474,7 @@ class TestUpdateTransitGateway(): # Preprocess the request URL to ensure the mock response will be found. def preprocess_url(self, request_url: str): + request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url else: @@ -414,6 +563,7 @@ class TestListTransitGatewayConnections(): # Preprocess the request URL to ensure the mock response will be found. def preprocess_url(self, request_url: str): + request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url else: @@ -426,7 +576,7 @@ def preprocess_url(self, request_url: str): def test_list_transit_gateway_connections_all_params(self): # Set up mock url = self.preprocess_url(base_url + '/transit_gateways/testString/connections') - mock_response = '{"connections": [{"name": "Transit_Service_BWTN_SJ_DL", "network_id": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "network_type": "vpc", "network_account_id": "28e4d90ac7504be694471ee66e70d0d5", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "created_at": "2019-01-01T12:00:00", "request_status": "pending", "status": "attached", "updated_at": "2019-01-01T12:00:00"}]}' + mock_response = '{"connections": [{"name": "Transit_Service_BWTN_SJ_DL", "network_id": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "network_type": "vpc", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "base_connection_id": "975f58c1-afe7-469a-9727-7f3d720f2d32", "created_at": "2019-01-01T12:00:00", "local_bgp_asn": 64490, "local_gateway_ip": "192.168.100.1", "local_tunnel_ip": "192.168.129.2", "mtu": 9000, "network_account_id": "28e4d90ac7504be694471ee66e70d0d5", "remote_bgp_asn": 65010, "remote_gateway_ip": "10.242.63.12", "remote_tunnel_ip": "192.168.129.1", "request_status": "pending", "status": "attached", "updated_at": "2019-01-01T12:00:00", "zone": {"name": "us-south-1"}}]}' responses.add(responses.GET, url, body=mock_response, @@ -454,7 +604,7 @@ def test_list_transit_gateway_connections_all_params(self): def test_list_transit_gateway_connections_value_error(self): # Set up mock url = self.preprocess_url(base_url + '/transit_gateways/testString/connections') - mock_response = '{"connections": [{"name": "Transit_Service_BWTN_SJ_DL", "network_id": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "network_type": "vpc", "network_account_id": "28e4d90ac7504be694471ee66e70d0d5", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "created_at": "2019-01-01T12:00:00", "request_status": "pending", "status": "attached", "updated_at": "2019-01-01T12:00:00"}]}' + mock_response = '{"connections": [{"name": "Transit_Service_BWTN_SJ_DL", "network_id": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "network_type": "vpc", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "base_connection_id": "975f58c1-afe7-469a-9727-7f3d720f2d32", "created_at": "2019-01-01T12:00:00", "local_bgp_asn": 64490, "local_gateway_ip": "192.168.100.1", "local_tunnel_ip": "192.168.129.2", "mtu": 9000, "network_account_id": "28e4d90ac7504be694471ee66e70d0d5", "remote_bgp_asn": 65010, "remote_gateway_ip": "10.242.63.12", "remote_tunnel_ip": "192.168.129.1", "request_status": "pending", "status": "attached", "updated_at": "2019-01-01T12:00:00", "zone": {"name": "us-south-1"}}]}' responses.add(responses.GET, url, body=mock_response, @@ -482,6 +632,7 @@ class TestCreateTransitGatewayConnection(): # Preprocess the request URL to ensure the mock response will be found. def preprocess_url(self, request_url: str): + request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url else: @@ -494,27 +645,45 @@ def preprocess_url(self, request_url: str): def test_create_transit_gateway_connection_all_params(self): # Set up mock url = self.preprocess_url(base_url + '/transit_gateways/testString/connections') - mock_response = '{"name": "Transit_Service_BWTN_SJ_DL", "network_id": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "network_type": "vpc", "network_account_id": "28e4d90ac7504be694471ee66e70d0d5", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "created_at": "2019-01-01T12:00:00", "request_status": "pending", "status": "attached", "updated_at": "2019-01-01T12:00:00"}' + mock_response = '{"name": "Transit_Service_BWTN_SJ_DL", "network_id": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "network_type": "vpc", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "base_connection_id": "975f58c1-afe7-469a-9727-7f3d720f2d32", "created_at": "2019-01-01T12:00:00", "local_bgp_asn": 64490, "local_gateway_ip": "192.168.100.1", "local_tunnel_ip": "192.168.129.2", "mtu": 9000, "network_account_id": "28e4d90ac7504be694471ee66e70d0d5", "remote_bgp_asn": 65010, "remote_gateway_ip": "10.242.63.12", "remote_tunnel_ip": "192.168.129.1", "request_status": "pending", "status": "attached", "updated_at": "2019-01-01T12:00:00", "zone": {"name": "us-south-1"}}' responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) + # Construct a dict representation of a ZoneIdentityByName model + zone_identity_model = {} + zone_identity_model['name'] = 'us-south-1' + # Set up parameter values transit_gateway_id = 'testString' network_type = 'vpc' + base_connection_id = '975f58c1-afe7-469a-9727-7f3d720f2d32' + local_gateway_ip = '192.168.100.1' + local_tunnel_ip = '192.168.129.2' name = 'Transit_Service_BWTN_SJ_DL' - network_id = 'crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b' network_account_id = '28e4d90ac7504be694471ee66e70d0d5' + network_id = 'crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b' + remote_bgp_asn = '65010' + remote_gateway_ip = '10.242.63.12' + remote_tunnel_ip = '192.168.129.1' + zone = zone_identity_model # Invoke method response = service.create_transit_gateway_connection( transit_gateway_id, network_type, + base_connection_id=base_connection_id, + local_gateway_ip=local_gateway_ip, + local_tunnel_ip=local_tunnel_ip, name=name, - network_id=network_id, network_account_id=network_account_id, + network_id=network_id, + remote_bgp_asn=remote_bgp_asn, + remote_gateway_ip=remote_gateway_ip, + remote_tunnel_ip=remote_tunnel_ip, + zone=zone, headers={} ) @@ -524,9 +693,16 @@ def test_create_transit_gateway_connection_all_params(self): # Validate body params req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) assert req_body['network_type'] == 'vpc' + assert req_body['base_connection_id'] == '975f58c1-afe7-469a-9727-7f3d720f2d32' + assert req_body['local_gateway_ip'] == '192.168.100.1' + assert req_body['local_tunnel_ip'] == '192.168.129.2' assert req_body['name'] == 'Transit_Service_BWTN_SJ_DL' - assert req_body['network_id'] == 'crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b' assert req_body['network_account_id'] == '28e4d90ac7504be694471ee66e70d0d5' + assert req_body['network_id'] == 'crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b' + assert req_body['remote_bgp_asn'] == '65010' + assert req_body['remote_gateway_ip'] == '10.242.63.12' + assert req_body['remote_tunnel_ip'] == '192.168.129.1' + assert req_body['zone'] == zone_identity_model #-------------------------------------------------------- @@ -536,19 +712,30 @@ def test_create_transit_gateway_connection_all_params(self): def test_create_transit_gateway_connection_value_error(self): # Set up mock url = self.preprocess_url(base_url + '/transit_gateways/testString/connections') - mock_response = '{"name": "Transit_Service_BWTN_SJ_DL", "network_id": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "network_type": "vpc", "network_account_id": "28e4d90ac7504be694471ee66e70d0d5", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "created_at": "2019-01-01T12:00:00", "request_status": "pending", "status": "attached", "updated_at": "2019-01-01T12:00:00"}' + mock_response = '{"name": "Transit_Service_BWTN_SJ_DL", "network_id": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "network_type": "vpc", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "base_connection_id": "975f58c1-afe7-469a-9727-7f3d720f2d32", "created_at": "2019-01-01T12:00:00", "local_bgp_asn": 64490, "local_gateway_ip": "192.168.100.1", "local_tunnel_ip": "192.168.129.2", "mtu": 9000, "network_account_id": "28e4d90ac7504be694471ee66e70d0d5", "remote_bgp_asn": 65010, "remote_gateway_ip": "10.242.63.12", "remote_tunnel_ip": "192.168.129.1", "request_status": "pending", "status": "attached", "updated_at": "2019-01-01T12:00:00", "zone": {"name": "us-south-1"}}' responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) + # Construct a dict representation of a ZoneIdentityByName model + zone_identity_model = {} + zone_identity_model['name'] = 'us-south-1' + # Set up parameter values transit_gateway_id = 'testString' network_type = 'vpc' + base_connection_id = '975f58c1-afe7-469a-9727-7f3d720f2d32' + local_gateway_ip = '192.168.100.1' + local_tunnel_ip = '192.168.129.2' name = 'Transit_Service_BWTN_SJ_DL' - network_id = 'crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b' network_account_id = '28e4d90ac7504be694471ee66e70d0d5' + network_id = 'crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b' + remote_bgp_asn = '65010' + remote_gateway_ip = '10.242.63.12' + remote_tunnel_ip = '192.168.129.1' + zone = zone_identity_model # Pass in all but one required param and check for a ValueError req_param_dict = { @@ -569,6 +756,7 @@ class TestDeleteTransitGatewayConnection(): # Preprocess the request URL to ensure the mock response will be found. def preprocess_url(self, request_url: str): + request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url else: @@ -635,6 +823,7 @@ class TestGetTransitGatewayConnection(): # Preprocess the request URL to ensure the mock response will be found. def preprocess_url(self, request_url: str): + request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url else: @@ -647,7 +836,7 @@ def preprocess_url(self, request_url: str): def test_get_transit_gateway_connection_all_params(self): # Set up mock url = self.preprocess_url(base_url + '/transit_gateways/testString/connections/testString') - mock_response = '{"name": "Transit_Service_BWTN_SJ_DL", "network_id": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "network_type": "vpc", "network_account_id": "28e4d90ac7504be694471ee66e70d0d5", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "created_at": "2019-01-01T12:00:00", "request_status": "pending", "status": "attached", "updated_at": "2019-01-01T12:00:00"}' + mock_response = '{"name": "Transit_Service_BWTN_SJ_DL", "network_id": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "network_type": "vpc", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "base_connection_id": "975f58c1-afe7-469a-9727-7f3d720f2d32", "created_at": "2019-01-01T12:00:00", "local_bgp_asn": 64490, "local_gateway_ip": "192.168.100.1", "local_tunnel_ip": "192.168.129.2", "mtu": 9000, "network_account_id": "28e4d90ac7504be694471ee66e70d0d5", "remote_bgp_asn": 65010, "remote_gateway_ip": "10.242.63.12", "remote_tunnel_ip": "192.168.129.1", "request_status": "pending", "status": "attached", "updated_at": "2019-01-01T12:00:00", "zone": {"name": "us-south-1"}}' responses.add(responses.GET, url, body=mock_response, @@ -677,7 +866,7 @@ def test_get_transit_gateway_connection_all_params(self): def test_get_transit_gateway_connection_value_error(self): # Set up mock url = self.preprocess_url(base_url + '/transit_gateways/testString/connections/testString') - mock_response = '{"name": "Transit_Service_BWTN_SJ_DL", "network_id": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "network_type": "vpc", "network_account_id": "28e4d90ac7504be694471ee66e70d0d5", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "created_at": "2019-01-01T12:00:00", "request_status": "pending", "status": "attached", "updated_at": "2019-01-01T12:00:00"}' + mock_response = '{"name": "Transit_Service_BWTN_SJ_DL", "network_id": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "network_type": "vpc", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "base_connection_id": "975f58c1-afe7-469a-9727-7f3d720f2d32", "created_at": "2019-01-01T12:00:00", "local_bgp_asn": 64490, "local_gateway_ip": "192.168.100.1", "local_tunnel_ip": "192.168.129.2", "mtu": 9000, "network_account_id": "28e4d90ac7504be694471ee66e70d0d5", "remote_bgp_asn": 65010, "remote_gateway_ip": "10.242.63.12", "remote_tunnel_ip": "192.168.129.1", "request_status": "pending", "status": "attached", "updated_at": "2019-01-01T12:00:00", "zone": {"name": "us-south-1"}}' responses.add(responses.GET, url, body=mock_response, @@ -707,6 +896,7 @@ class TestUpdateTransitGatewayConnection(): # Preprocess the request URL to ensure the mock response will be found. def preprocess_url(self, request_url: str): + request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url else: @@ -719,7 +909,7 @@ def preprocess_url(self, request_url: str): def test_update_transit_gateway_connection_all_params(self): # Set up mock url = self.preprocess_url(base_url + '/transit_gateways/testString/connections/testString') - mock_response = '{"name": "Transit_Service_BWTN_SJ_DL", "network_id": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "network_type": "vpc", "network_account_id": "28e4d90ac7504be694471ee66e70d0d5", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "created_at": "2019-01-01T12:00:00", "request_status": "pending", "status": "attached", "updated_at": "2019-01-01T12:00:00"}' + mock_response = '{"name": "Transit_Service_BWTN_SJ_DL", "network_id": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "network_type": "vpc", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "base_connection_id": "975f58c1-afe7-469a-9727-7f3d720f2d32", "created_at": "2019-01-01T12:00:00", "local_bgp_asn": 64490, "local_gateway_ip": "192.168.100.1", "local_tunnel_ip": "192.168.129.2", "mtu": 9000, "network_account_id": "28e4d90ac7504be694471ee66e70d0d5", "remote_bgp_asn": 65010, "remote_gateway_ip": "10.242.63.12", "remote_tunnel_ip": "192.168.129.1", "request_status": "pending", "status": "attached", "updated_at": "2019-01-01T12:00:00", "zone": {"name": "us-south-1"}}' responses.add(responses.PATCH, url, body=mock_response, @@ -754,7 +944,7 @@ def test_update_transit_gateway_connection_all_params(self): def test_update_transit_gateway_connection_value_error(self): # Set up mock url = self.preprocess_url(base_url + '/transit_gateways/testString/connections/testString') - mock_response = '{"name": "Transit_Service_BWTN_SJ_DL", "network_id": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "network_type": "vpc", "network_account_id": "28e4d90ac7504be694471ee66e70d0d5", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "created_at": "2019-01-01T12:00:00", "request_status": "pending", "status": "attached", "updated_at": "2019-01-01T12:00:00"}' + mock_response = '{"name": "Transit_Service_BWTN_SJ_DL", "network_id": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "network_type": "vpc", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "base_connection_id": "975f58c1-afe7-469a-9727-7f3d720f2d32", "created_at": "2019-01-01T12:00:00", "local_bgp_asn": 64490, "local_gateway_ip": "192.168.100.1", "local_tunnel_ip": "192.168.129.2", "mtu": 9000, "network_account_id": "28e4d90ac7504be694471ee66e70d0d5", "remote_bgp_asn": 65010, "remote_gateway_ip": "10.242.63.12", "remote_tunnel_ip": "192.168.129.1", "request_status": "pending", "status": "attached", "updated_at": "2019-01-01T12:00:00", "zone": {"name": "us-south-1"}}' responses.add(responses.PATCH, url, body=mock_response, @@ -785,6 +975,7 @@ class TestCreateTransitGatewayConnectionActions(): # Preprocess the request URL to ensure the mock response will be found. def preprocess_url(self, request_url: str): + request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url else: @@ -868,6 +1059,7 @@ class TestListGatewayLocations(): # Preprocess the request URL to ensure the mock response will be found. def preprocess_url(self, request_url: str): + request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url else: @@ -927,6 +1119,7 @@ class TestGetGatewayLocation(): # Preprocess the request URL to ensure the mock response will be found. def preprocess_url(self, request_url: str): + request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url else: @@ -1194,6 +1387,192 @@ def test_ts_location_basic_serialization(self): ts_location_basic_model_json2 = ts_location_basic_model.to_dict() assert ts_location_basic_model_json2 == ts_location_basic_model_json +#----------------------------------------------------------------------------- +# Test Class for TransitConnection +#----------------------------------------------------------------------------- +class TestTransitConnection(): + + #-------------------------------------------------------- + # Test serialization/deserialization for TransitConnection + #-------------------------------------------------------- + def test_transit_connection_serialization(self): + + # Construct dict forms of any model objects needed in order to build this model. + + transit_gateway_reference_model = {} # TransitGatewayReference + transit_gateway_reference_model['crn'] = 'crn:v1:bluemix:public:transit:us-south:a/123456::gateway:456f58c1-afe7-123a-0a0a-7f3d720f1a44' + transit_gateway_reference_model['id'] = '456f58c1-afe7-123a-0a0a-7f3d720f1a44' + transit_gateway_reference_model['name'] = 'my-transit-gw100' + + zone_reference_model = {} # ZoneReference + zone_reference_model['name'] = 'us-south-1' + + # Construct a json representation of a TransitConnection model + transit_connection_model_json = {} + transit_connection_model_json['base_connection_id'] = '975f58c1-afe7-469a-9727-7f3d720f2d32' + transit_connection_model_json['created_at'] = '2020-01-28T18:40:40.123456Z' + transit_connection_model_json['id'] = '1a15dca5-7e33-45e1-b7c5-bc690e569531' + transit_connection_model_json['local_bgp_asn'] = 64490 + transit_connection_model_json['local_gateway_ip'] = '192.168.100.1' + transit_connection_model_json['local_tunnel_ip'] = '192.168.129.2' + transit_connection_model_json['mtu'] = 9000 + transit_connection_model_json['name'] = 'Transit_Service_SJ_DL' + transit_connection_model_json['network_account_id'] = '28e4d90ac7504be694471ee66e70d0d5' + transit_connection_model_json['network_id'] = 'crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b' + transit_connection_model_json['network_type'] = 'vpc' + transit_connection_model_json['remote_bgp_asn'] = 65010 + transit_connection_model_json['remote_gateway_ip'] = '10.242.63.12' + transit_connection_model_json['remote_tunnel_ip'] = '192.168.129.1' + transit_connection_model_json['request_status'] = 'pending' + transit_connection_model_json['status'] = 'attached' + transit_connection_model_json['transit_gateway'] = transit_gateway_reference_model + transit_connection_model_json['updated_at'] = '2020-01-28T18:40:40.123456Z' + transit_connection_model_json['zone'] = zone_reference_model + + # Construct a model instance of TransitConnection by calling from_dict on the json representation + transit_connection_model = TransitConnection.from_dict(transit_connection_model_json) + assert transit_connection_model != False + + # Construct a model instance of TransitConnection by calling from_dict on the json representation + transit_connection_model_dict = TransitConnection.from_dict(transit_connection_model_json).__dict__ + transit_connection_model2 = TransitConnection(**transit_connection_model_dict) + + # Verify the model instances are equivalent + assert transit_connection_model == transit_connection_model2 + + # Convert model instance back to dict and verify no loss of data + transit_connection_model_json2 = transit_connection_model.to_dict() + assert transit_connection_model_json2 == transit_connection_model_json + +#----------------------------------------------------------------------------- +# Test Class for TransitConnectionCollection +#----------------------------------------------------------------------------- +class TestTransitConnectionCollection(): + + #-------------------------------------------------------- + # Test serialization/deserialization for TransitConnectionCollection + #-------------------------------------------------------- + def test_transit_connection_collection_serialization(self): + + # Construct dict forms of any model objects needed in order to build this model. + + transit_gateway_reference_model = {} # TransitGatewayReference + transit_gateway_reference_model['crn'] = 'crn:v1:bluemix:public:transit:us-south:a/123456::gateway:456f58c1-afe7-123a-0a0a-7f3d720f1a44' + transit_gateway_reference_model['id'] = '456f58c1-afe7-123a-0a0a-7f3d720f1a44' + transit_gateway_reference_model['name'] = 'my-transit-gw100' + + zone_reference_model = {} # ZoneReference + zone_reference_model['name'] = 'us-south-1' + + transit_connection_model = {} # TransitConnection + transit_connection_model['base_connection_id'] = '975f58c1-afe7-469a-9727-7f3d720f2d32' + transit_connection_model['created_at'] = '2020-01-28T18:40:40.123456Z' + transit_connection_model['id'] = '1a15dca5-7e33-45e1-b7c5-bc690e569531' + transit_connection_model['local_bgp_asn'] = 64490 + transit_connection_model['local_gateway_ip'] = '192.168.100.1' + transit_connection_model['local_tunnel_ip'] = '192.168.129.2' + transit_connection_model['mtu'] = 9000 + transit_connection_model['name'] = 'Transit_Service_SJ_DL' + transit_connection_model['network_account_id'] = '28e4d90ac7504be694471ee66e70d0d5' + transit_connection_model['network_id'] = 'crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b' + transit_connection_model['network_type'] = 'vpc' + transit_connection_model['remote_bgp_asn'] = 65010 + transit_connection_model['remote_gateway_ip'] = '10.242.63.12' + transit_connection_model['remote_tunnel_ip'] = '192.168.129.1' + transit_connection_model['request_status'] = 'pending' + transit_connection_model['status'] = 'attached' + transit_connection_model['transit_gateway'] = transit_gateway_reference_model + transit_connection_model['updated_at'] = '2020-01-28T18:40:40.123456Z' + transit_connection_model['zone'] = zone_reference_model + + transit_connection_collection_first_model = {} # TransitConnectionCollectionFirst + transit_connection_collection_first_model['href'] = 'https://transit.cloud.ibm.com/v1/connections?limit=50' + + transit_connection_collection_next_model = {} # TransitConnectionCollectionNext + transit_connection_collection_next_model['href'] = 'https://transit.cloud.ibm.com/v1/connections?start=MjAyMC0wNS0wOVQxNjoyMDoyMC4yMjQ5NzNa&limit=50' + transit_connection_collection_next_model['start'] = 'MjAyMC0wNS0wOVQxNjoyMDoyMC4yMjQ5NzNa' + + # Construct a json representation of a TransitConnectionCollection model + transit_connection_collection_model_json = {} + transit_connection_collection_model_json['connections'] = [transit_connection_model] + transit_connection_collection_model_json['first'] = transit_connection_collection_first_model + transit_connection_collection_model_json['limit'] = 50 + transit_connection_collection_model_json['next'] = transit_connection_collection_next_model + + # Construct a model instance of TransitConnectionCollection by calling from_dict on the json representation + transit_connection_collection_model = TransitConnectionCollection.from_dict(transit_connection_collection_model_json) + assert transit_connection_collection_model != False + + # Construct a model instance of TransitConnectionCollection by calling from_dict on the json representation + transit_connection_collection_model_dict = TransitConnectionCollection.from_dict(transit_connection_collection_model_json).__dict__ + transit_connection_collection_model2 = TransitConnectionCollection(**transit_connection_collection_model_dict) + + # Verify the model instances are equivalent + assert transit_connection_collection_model == transit_connection_collection_model2 + + # Convert model instance back to dict and verify no loss of data + transit_connection_collection_model_json2 = transit_connection_collection_model.to_dict() + assert transit_connection_collection_model_json2 == transit_connection_collection_model_json + +#----------------------------------------------------------------------------- +# Test Class for TransitConnectionCollectionFirst +#----------------------------------------------------------------------------- +class TestTransitConnectionCollectionFirst(): + + #-------------------------------------------------------- + # Test serialization/deserialization for TransitConnectionCollectionFirst + #-------------------------------------------------------- + def test_transit_connection_collection_first_serialization(self): + + # Construct a json representation of a TransitConnectionCollectionFirst model + transit_connection_collection_first_model_json = {} + transit_connection_collection_first_model_json['href'] = 'https://transit.cloud.ibm.com/v1/connections?limit=50' + + # Construct a model instance of TransitConnectionCollectionFirst by calling from_dict on the json representation + transit_connection_collection_first_model = TransitConnectionCollectionFirst.from_dict(transit_connection_collection_first_model_json) + assert transit_connection_collection_first_model != False + + # Construct a model instance of TransitConnectionCollectionFirst by calling from_dict on the json representation + transit_connection_collection_first_model_dict = TransitConnectionCollectionFirst.from_dict(transit_connection_collection_first_model_json).__dict__ + transit_connection_collection_first_model2 = TransitConnectionCollectionFirst(**transit_connection_collection_first_model_dict) + + # Verify the model instances are equivalent + assert transit_connection_collection_first_model == transit_connection_collection_first_model2 + + # Convert model instance back to dict and verify no loss of data + transit_connection_collection_first_model_json2 = transit_connection_collection_first_model.to_dict() + assert transit_connection_collection_first_model_json2 == transit_connection_collection_first_model_json + +#----------------------------------------------------------------------------- +# Test Class for TransitConnectionCollectionNext +#----------------------------------------------------------------------------- +class TestTransitConnectionCollectionNext(): + + #-------------------------------------------------------- + # Test serialization/deserialization for TransitConnectionCollectionNext + #-------------------------------------------------------- + def test_transit_connection_collection_next_serialization(self): + + # Construct a json representation of a TransitConnectionCollectionNext model + transit_connection_collection_next_model_json = {} + transit_connection_collection_next_model_json['href'] = 'https://transit.cloud.ibm.com/v1/connections?start=MjAyMC0wNS0wOVQxNjoyMDoyMC4yMjQ5NzNa&limit=50' + transit_connection_collection_next_model_json['start'] = 'MjAyMC0wNS0wOVQxNjoyMDoyMC4yMjQ5NzNa' + + # Construct a model instance of TransitConnectionCollectionNext by calling from_dict on the json representation + transit_connection_collection_next_model = TransitConnectionCollectionNext.from_dict(transit_connection_collection_next_model_json) + assert transit_connection_collection_next_model != False + + # Construct a model instance of TransitConnectionCollectionNext by calling from_dict on the json representation + transit_connection_collection_next_model_dict = TransitConnectionCollectionNext.from_dict(transit_connection_collection_next_model_json).__dict__ + transit_connection_collection_next_model2 = TransitConnectionCollectionNext(**transit_connection_collection_next_model_dict) + + # Verify the model instances are equivalent + assert transit_connection_collection_next_model == transit_connection_collection_next_model2 + + # Convert model instance back to dict and verify no loss of data + transit_connection_collection_next_model_json2 = transit_connection_collection_next_model.to_dict() + assert transit_connection_collection_next_model_json2 == transit_connection_collection_next_model_json + #----------------------------------------------------------------------------- # Test Class for TransitGateway #----------------------------------------------------------------------------- @@ -1264,8 +1643,18 @@ def test_transit_gateway_collection_serialization(self): transit_gateway_model['status'] = 'available' transit_gateway_model['updated_at'] = '2020-01-28T18:40:40.123456Z' + transit_gateway_collection_first_model = {} # TransitGatewayCollectionFirst + transit_gateway_collection_first_model['href'] = 'https://transit.cloud.ibm.com/v1/transit_gateways?limit=50' + + transit_gateway_collection_next_model = {} # TransitGatewayCollectionNext + transit_gateway_collection_next_model['href'] = 'https://transit.cloud.ibm.com/v1/transit_gateways?start=MjAyMC0wNS0wOFQxNDoxNzowMy45NzQ5NzNa&limit=50' + transit_gateway_collection_next_model['start'] = 'MjAyMC0wNS0wOFQxNDoxNzowMy45NzQ5NzNa' + # Construct a json representation of a TransitGatewayCollection model transit_gateway_collection_model_json = {} + transit_gateway_collection_model_json['first'] = transit_gateway_collection_first_model + transit_gateway_collection_model_json['limit'] = 50 + transit_gateway_collection_model_json['next'] = transit_gateway_collection_next_model transit_gateway_collection_model_json['transit_gateways'] = [transit_gateway_model] # Construct a model instance of TransitGatewayCollection by calling from_dict on the json representation @@ -1283,6 +1672,65 @@ def test_transit_gateway_collection_serialization(self): transit_gateway_collection_model_json2 = transit_gateway_collection_model.to_dict() assert transit_gateway_collection_model_json2 == transit_gateway_collection_model_json +#----------------------------------------------------------------------------- +# Test Class for TransitGatewayCollectionFirst +#----------------------------------------------------------------------------- +class TestTransitGatewayCollectionFirst(): + + #-------------------------------------------------------- + # Test serialization/deserialization for TransitGatewayCollectionFirst + #-------------------------------------------------------- + def test_transit_gateway_collection_first_serialization(self): + + # Construct a json representation of a TransitGatewayCollectionFirst model + transit_gateway_collection_first_model_json = {} + transit_gateway_collection_first_model_json['href'] = 'https://transit.cloud.ibm.com/v1/transit_gateways?limit=50' + + # Construct a model instance of TransitGatewayCollectionFirst by calling from_dict on the json representation + transit_gateway_collection_first_model = TransitGatewayCollectionFirst.from_dict(transit_gateway_collection_first_model_json) + assert transit_gateway_collection_first_model != False + + # Construct a model instance of TransitGatewayCollectionFirst by calling from_dict on the json representation + transit_gateway_collection_first_model_dict = TransitGatewayCollectionFirst.from_dict(transit_gateway_collection_first_model_json).__dict__ + transit_gateway_collection_first_model2 = TransitGatewayCollectionFirst(**transit_gateway_collection_first_model_dict) + + # Verify the model instances are equivalent + assert transit_gateway_collection_first_model == transit_gateway_collection_first_model2 + + # Convert model instance back to dict and verify no loss of data + transit_gateway_collection_first_model_json2 = transit_gateway_collection_first_model.to_dict() + assert transit_gateway_collection_first_model_json2 == transit_gateway_collection_first_model_json + +#----------------------------------------------------------------------------- +# Test Class for TransitGatewayCollectionNext +#----------------------------------------------------------------------------- +class TestTransitGatewayCollectionNext(): + + #-------------------------------------------------------- + # Test serialization/deserialization for TransitGatewayCollectionNext + #-------------------------------------------------------- + def test_transit_gateway_collection_next_serialization(self): + + # Construct a json representation of a TransitGatewayCollectionNext model + transit_gateway_collection_next_model_json = {} + transit_gateway_collection_next_model_json['href'] = 'https://transit.cloud.ibm.com/v1/transit_gateways?start=MjAyMC0wNS0wOFQxNDoxNzowMy45NzQ5NzNa&limit=50' + transit_gateway_collection_next_model_json['start'] = 'MjAyMC0wNS0wOFQxNDoxNzowMy45NzQ5NzNa' + + # Construct a model instance of TransitGatewayCollectionNext by calling from_dict on the json representation + transit_gateway_collection_next_model = TransitGatewayCollectionNext.from_dict(transit_gateway_collection_next_model_json) + assert transit_gateway_collection_next_model != False + + # Construct a model instance of TransitGatewayCollectionNext by calling from_dict on the json representation + transit_gateway_collection_next_model_dict = TransitGatewayCollectionNext.from_dict(transit_gateway_collection_next_model_json).__dict__ + transit_gateway_collection_next_model2 = TransitGatewayCollectionNext(**transit_gateway_collection_next_model_dict) + + # Verify the model instances are equivalent + assert transit_gateway_collection_next_model == transit_gateway_collection_next_model2 + + # Convert model instance back to dict and verify no loss of data + transit_gateway_collection_next_model_json2 = transit_gateway_collection_next_model.to_dict() + assert transit_gateway_collection_next_model_json2 == transit_gateway_collection_next_model_json + #----------------------------------------------------------------------------- # Test Class for TransitGatewayConnectionCollection #----------------------------------------------------------------------------- @@ -1295,16 +1743,28 @@ def test_transit_gateway_connection_collection_serialization(self): # Construct dict forms of any model objects needed in order to build this model. + transit_gateway_connection_cust_zone_model = {} # TransitGatewayConnectionCustZone + transit_gateway_connection_cust_zone_model['name'] = 'us-south-1' + transit_gateway_connection_cust_model = {} # TransitGatewayConnectionCust transit_gateway_connection_cust_model['name'] = 'Transit_Service_BWTN_SJ_DL' transit_gateway_connection_cust_model['network_id'] = 'crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b' transit_gateway_connection_cust_model['network_type'] = 'vpc' - transit_gateway_connection_cust_model['network_account_id'] = '28e4d90ac7504be694471ee66e70d0d5' transit_gateway_connection_cust_model['id'] = '1a15dca5-7e33-45e1-b7c5-bc690e569531' + transit_gateway_connection_cust_model['base_connection_id'] = '975f58c1-afe7-469a-9727-7f3d720f2d32' transit_gateway_connection_cust_model['created_at'] = '2020-01-28T18:40:40.123456Z' + transit_gateway_connection_cust_model['local_bgp_asn'] = 64490 + transit_gateway_connection_cust_model['local_gateway_ip'] = '192.168.100.1' + transit_gateway_connection_cust_model['local_tunnel_ip'] = '192.168.129.2' + transit_gateway_connection_cust_model['mtu'] = 9000 + transit_gateway_connection_cust_model['network_account_id'] = '28e4d90ac7504be694471ee66e70d0d5' + transit_gateway_connection_cust_model['remote_bgp_asn'] = 65010 + transit_gateway_connection_cust_model['remote_gateway_ip'] = '10.242.63.12' + transit_gateway_connection_cust_model['remote_tunnel_ip'] = '192.168.129.1' transit_gateway_connection_cust_model['request_status'] = 'pending' transit_gateway_connection_cust_model['status'] = 'attached' transit_gateway_connection_cust_model['updated_at'] = '2020-01-28T18:40:40.123456Z' + transit_gateway_connection_cust_model['zone'] = transit_gateway_connection_cust_zone_model # Construct a json representation of a TransitGatewayConnectionCollection model transit_gateway_connection_collection_model_json = {} @@ -1335,17 +1795,31 @@ class TestTransitGatewayConnectionCust(): #-------------------------------------------------------- def test_transit_gateway_connection_cust_serialization(self): + # Construct dict forms of any model objects needed in order to build this model. + + transit_gateway_connection_cust_zone_model = {} # TransitGatewayConnectionCustZone + transit_gateway_connection_cust_zone_model['name'] = 'us-south-1' + # Construct a json representation of a TransitGatewayConnectionCust model transit_gateway_connection_cust_model_json = {} transit_gateway_connection_cust_model_json['name'] = 'Transit_Service_BWTN_SJ_DL' transit_gateway_connection_cust_model_json['network_id'] = 'crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b' transit_gateway_connection_cust_model_json['network_type'] = 'vpc' - transit_gateway_connection_cust_model_json['network_account_id'] = '28e4d90ac7504be694471ee66e70d0d5' transit_gateway_connection_cust_model_json['id'] = '1a15dca5-7e33-45e1-b7c5-bc690e569531' + transit_gateway_connection_cust_model_json['base_connection_id'] = '975f58c1-afe7-469a-9727-7f3d720f2d32' transit_gateway_connection_cust_model_json['created_at'] = '2020-01-28T18:40:40.123456Z' + transit_gateway_connection_cust_model_json['local_bgp_asn'] = 64490 + transit_gateway_connection_cust_model_json['local_gateway_ip'] = '192.168.100.1' + transit_gateway_connection_cust_model_json['local_tunnel_ip'] = '192.168.129.2' + transit_gateway_connection_cust_model_json['mtu'] = 9000 + transit_gateway_connection_cust_model_json['network_account_id'] = '28e4d90ac7504be694471ee66e70d0d5' + transit_gateway_connection_cust_model_json['remote_bgp_asn'] = 65010 + transit_gateway_connection_cust_model_json['remote_gateway_ip'] = '10.242.63.12' + transit_gateway_connection_cust_model_json['remote_tunnel_ip'] = '192.168.129.1' transit_gateway_connection_cust_model_json['request_status'] = 'pending' transit_gateway_connection_cust_model_json['status'] = 'attached' transit_gateway_connection_cust_model_json['updated_at'] = '2020-01-28T18:40:40.123456Z' + transit_gateway_connection_cust_model_json['zone'] = transit_gateway_connection_cust_zone_model # Construct a model instance of TransitGatewayConnectionCust by calling from_dict on the json representation transit_gateway_connection_cust_model = TransitGatewayConnectionCust.from_dict(transit_gateway_connection_cust_model_json) @@ -1362,6 +1836,124 @@ def test_transit_gateway_connection_cust_serialization(self): transit_gateway_connection_cust_model_json2 = transit_gateway_connection_cust_model.to_dict() assert transit_gateway_connection_cust_model_json2 == transit_gateway_connection_cust_model_json +#----------------------------------------------------------------------------- +# Test Class for TransitGatewayConnectionCustZone +#----------------------------------------------------------------------------- +class TestTransitGatewayConnectionCustZone(): + + #-------------------------------------------------------- + # Test serialization/deserialization for TransitGatewayConnectionCustZone + #-------------------------------------------------------- + def test_transit_gateway_connection_cust_zone_serialization(self): + + # Construct a json representation of a TransitGatewayConnectionCustZone model + transit_gateway_connection_cust_zone_model_json = {} + transit_gateway_connection_cust_zone_model_json['name'] = 'us-south-1' + + # Construct a model instance of TransitGatewayConnectionCustZone by calling from_dict on the json representation + transit_gateway_connection_cust_zone_model = TransitGatewayConnectionCustZone.from_dict(transit_gateway_connection_cust_zone_model_json) + assert transit_gateway_connection_cust_zone_model != False + + # Construct a model instance of TransitGatewayConnectionCustZone by calling from_dict on the json representation + transit_gateway_connection_cust_zone_model_dict = TransitGatewayConnectionCustZone.from_dict(transit_gateway_connection_cust_zone_model_json).__dict__ + transit_gateway_connection_cust_zone_model2 = TransitGatewayConnectionCustZone(**transit_gateway_connection_cust_zone_model_dict) + + # Verify the model instances are equivalent + assert transit_gateway_connection_cust_zone_model == transit_gateway_connection_cust_zone_model2 + + # Convert model instance back to dict and verify no loss of data + transit_gateway_connection_cust_zone_model_json2 = transit_gateway_connection_cust_zone_model.to_dict() + assert transit_gateway_connection_cust_zone_model_json2 == transit_gateway_connection_cust_zone_model_json + +#----------------------------------------------------------------------------- +# Test Class for TransitGatewayReference +#----------------------------------------------------------------------------- +class TestTransitGatewayReference(): + + #-------------------------------------------------------- + # Test serialization/deserialization for TransitGatewayReference + #-------------------------------------------------------- + def test_transit_gateway_reference_serialization(self): + + # Construct a json representation of a TransitGatewayReference model + transit_gateway_reference_model_json = {} + transit_gateway_reference_model_json['crn'] = 'crn:v1:bluemix:public:transit:us-south:a/123456::gateway:456f58c1-afe7-123a-0a0a-7f3d720f1a44' + transit_gateway_reference_model_json['id'] = '456f58c1-afe7-123a-0a0a-7f3d720f1a44' + transit_gateway_reference_model_json['name'] = 'my-transit-gw100' + + # Construct a model instance of TransitGatewayReference by calling from_dict on the json representation + transit_gateway_reference_model = TransitGatewayReference.from_dict(transit_gateway_reference_model_json) + assert transit_gateway_reference_model != False + + # Construct a model instance of TransitGatewayReference by calling from_dict on the json representation + transit_gateway_reference_model_dict = TransitGatewayReference.from_dict(transit_gateway_reference_model_json).__dict__ + transit_gateway_reference_model2 = TransitGatewayReference(**transit_gateway_reference_model_dict) + + # Verify the model instances are equivalent + assert transit_gateway_reference_model == transit_gateway_reference_model2 + + # Convert model instance back to dict and verify no loss of data + transit_gateway_reference_model_json2 = transit_gateway_reference_model.to_dict() + assert transit_gateway_reference_model_json2 == transit_gateway_reference_model_json + +#----------------------------------------------------------------------------- +# Test Class for ZoneReference +#----------------------------------------------------------------------------- +class TestZoneReference(): + + #-------------------------------------------------------- + # Test serialization/deserialization for ZoneReference + #-------------------------------------------------------- + def test_zone_reference_serialization(self): + + # Construct a json representation of a ZoneReference model + zone_reference_model_json = {} + zone_reference_model_json['name'] = 'us-south-1' + + # Construct a model instance of ZoneReference by calling from_dict on the json representation + zone_reference_model = ZoneReference.from_dict(zone_reference_model_json) + assert zone_reference_model != False + + # Construct a model instance of ZoneReference by calling from_dict on the json representation + zone_reference_model_dict = ZoneReference.from_dict(zone_reference_model_json).__dict__ + zone_reference_model2 = ZoneReference(**zone_reference_model_dict) + + # Verify the model instances are equivalent + assert zone_reference_model == zone_reference_model2 + + # Convert model instance back to dict and verify no loss of data + zone_reference_model_json2 = zone_reference_model.to_dict() + assert zone_reference_model_json2 == zone_reference_model_json + +#----------------------------------------------------------------------------- +# Test Class for ZoneIdentityByName +#----------------------------------------------------------------------------- +class TestZoneIdentityByName(): + + #-------------------------------------------------------- + # Test serialization/deserialization for ZoneIdentityByName + #-------------------------------------------------------- + def test_zone_identity_by_name_serialization(self): + + # Construct a json representation of a ZoneIdentityByName model + zone_identity_by_name_model_json = {} + zone_identity_by_name_model_json['name'] = 'us-south-1' + + # Construct a model instance of ZoneIdentityByName by calling from_dict on the json representation + zone_identity_by_name_model = ZoneIdentityByName.from_dict(zone_identity_by_name_model_json) + assert zone_identity_by_name_model != False + + # Construct a model instance of ZoneIdentityByName by calling from_dict on the json representation + zone_identity_by_name_model_dict = ZoneIdentityByName.from_dict(zone_identity_by_name_model_json).__dict__ + zone_identity_by_name_model2 = ZoneIdentityByName(**zone_identity_by_name_model_dict) + + # Verify the model instances are equivalent + assert zone_identity_by_name_model == zone_identity_by_name_model2 + + # Convert model instance back to dict and verify no loss of data + zone_identity_by_name_model_json2 = zone_identity_by_name_model.to_dict() + assert zone_identity_by_name_model_json2 == zone_identity_by_name_model_json + # endregion ############################################################################## diff --git a/transit.env.enc b/transit.env.enc new file mode 100644 index 0000000..2114671 Binary files /dev/null and b/transit.env.enc differ