diff --git a/ibm_cloud_networking_services/transit_gateway_apis_v1.py b/ibm_cloud_networking_services/transit_gateway_apis_v1.py index aa69d3b..de4a815 100644 --- a/ibm_cloud_networking_services/transit_gateway_apis_v1.py +++ b/ibm_cloud_networking_services/transit_gateway_apis_v1.py @@ -14,8 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -# IBM OpenAPI SDK Code Generator Version: 3.43.0-49eab5c7-20211117-152138 - +# IBM OpenAPI SDK Code Generator Version: 3.43.5-e0ec19e2-20220124-172004 + """ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) @@ -39,6 +39,7 @@ # Service ############################################################################## + class TransitGatewayApisV1(BaseService): """The Transit Gateway Apis V1 service.""" @@ -49,7 +50,7 @@ class TransitGatewayApisV1(BaseService): def new_instance(cls, version: str, service_name: str = DEFAULT_SERVICE_NAME, - ) -> 'TransitGatewayApisV1': + ) -> 'TransitGatewayApisV1': """ Return a new client for the Transit Gateway Apis service using the specified parameters and external configuration. @@ -65,14 +66,14 @@ def new_instance(cls, service = cls( version, authenticator - ) + ) service.configure_service(service_name) return service def __init__(self, version: str, authenticator: Authenticator = None, - ) -> None: + ) -> None: """ Construct a new client for the Transit Gateway Apis service. @@ -92,105 +93,47 @@ def __init__(self, authenticator=authenticator) self.version = version - ######################### - # transitConnections + # Transit Gateways ######################### - - def list_connections(self, - *, - limit: int = None, - start: str = None, - network_id: str = None, - **kwargs - ) -> DetailedResponse: + def list_transit_gateways(self, + *, + limit: int = None, + start: str = None, + **kwargs + ) -> DetailedResponse: """ - Retrieves all connections. + Retrieves all Transit Gateways. - List all transit gateway connections associated with this account. + 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 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 + :rtype: DetailedResponse with `dict` result representing a `TransitGatewayCollection` object """ headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', - operation_id='list_connections') + operation_id='list_transit_gateways') 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, **kwargs) - return response - - ######################### - # transitGatewayConnectionPrefixFilters - ######################### - - - def list_transit_gateway_connection_prefix_filters(self, - transit_gateway_id: str, - id: str, - **kwargs - ) -> DetailedResponse: - """ - Retrieves all prefix filters in a Transit Gateway connection. - - This request retrieves all prefix filters in a Transit Gateway connection. - - :param str transit_gateway_id: The Transit Gateway identifier. - :param str id: The connection identifier. - :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 `PrefixFilterCollection` object - """ - - if transit_gateway_id is None: - raise ValueError('transit_gateway_id must be provided') - if id is None: - raise ValueError('id must be provided') - headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='list_transit_gateway_connection_prefix_filters') - headers.update(sdk_headers) - - params = { - 'version': self.version + 'start': start } if 'headers' in kwargs: headers.update(kwargs.get('headers')) headers['Accept'] = 'application/json' - path_param_keys = ['transit_gateway_id', 'id'] - path_param_values = self.encode_path_vars(transit_gateway_id, id) - path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/transit_gateways/{transit_gateway_id}/connections/{id}/prefix_filters'.format(**path_param_dict) + url = '/transit_gateways' request = self.prepare_request(method='GET', url=url, headers=headers, @@ -199,64 +142,42 @@ def list_transit_gateway_connection_prefix_filters(self, response = self.send(request, **kwargs) return response - - def create_transit_gateway_connection_prefix_filter(self, - transit_gateway_id: str, - id: str, - action: str, - prefix: str, - *, - before: str = None, - ge: int = None, - le: int = None, - **kwargs - ) -> DetailedResponse: + def create_transit_gateway(self, + location: str, + name: str, + *, + global_: bool = None, + resource_group: 'ResourceGroupIdentity' = None, + **kwargs + ) -> DetailedResponse: """ - Add a prefix filter to a Transit Gateway Connection. + Creates a Transit Gateway. - Add a prefix filter to a Transit Gateway Connection. + Create a Transit Gateway based on the supplied input template. - :param str transit_gateway_id: The Transit Gateway identifier. - :param str id: The connection identifier. - :param str action: Whether to permit or deny prefix filter. - :param str prefix: IP Prefix. - :param str before: (optional) Identifier of prefix filter to handle the - ordering and follow semantics: - - When a filter reference another filter in it's before field, then the - filter making the reference is applied before - the referenced filter. For example: if filter A references filter B in - its before field, A is applied before B. - - When a new filter is added that has the same before as an existing - filter, then the older filter will have its before - field updated to point to the new filter. Starting with the above - example: if filter C is added and it references B in its - before field, then A's before field should be modified to point to C, so - the order of application would be A, C and finally B. - - A filter that has an empty before reference will be applied last (though - the date order mentioned above will still apply). - So continuing the above examples, if filter B has an empty before field, - then it will be applied last, but if filter D - is created with an empty before field, then B's before field will be - modified to point to D, so B will be applied before D. - :param int ge: (optional) IP Prefix GE. - :param int le: (optional) IP Prefix LE. + :param str location: Location of Transit Gateway Services. + :param str name: Name Transit Gateway Services. + :param bool global_: (optional) Allow global routing for a Transit Gateway. + If unspecified, the default value is false. + :param ResourceGroupIdentity 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 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 `PrefixFilterCust` object + :rtype: DetailedResponse with `dict` result representing a `TransitGateway` object """ - if transit_gateway_id is None: - raise ValueError('transit_gateway_id must be provided') - if id is None: - raise ValueError('id must be provided') - if action is None: - raise ValueError('action must be provided') - if prefix is None: - raise ValueError('prefix must be provided') + if location is None: + raise ValueError('location must be provided') + if name is None: + raise ValueError('name must be provided') + if resource_group is not None: + resource_group = convert_model(resource_group) headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', - operation_id='create_transit_gateway_connection_prefix_filter') + operation_id='create_transit_gateway') headers.update(sdk_headers) params = { @@ -264,11 +185,10 @@ def create_transit_gateway_connection_prefix_filter(self, } data = { - 'action': action, - 'prefix': prefix, - 'before': before, - 'ge': ge, - 'le': le + 'location': location, + 'name': name, + 'global': global_, + 'resource_group': resource_group } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) @@ -278,10 +198,7 @@ def create_transit_gateway_connection_prefix_filter(self, headers.update(kwargs.get('headers')) headers['Accept'] = 'application/json' - path_param_keys = ['transit_gateway_id', 'id'] - path_param_values = self.encode_path_vars(transit_gateway_id, id) - path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/transit_gateways/{transit_gateway_id}/connections/{id}/prefix_filters'.format(**path_param_dict) + url = '/transit_gateways' request = self.prepare_request(method='POST', url=url, headers=headers, @@ -291,36 +208,28 @@ def create_transit_gateway_connection_prefix_filter(self, response = self.send(request, **kwargs) return response - - def delete_transit_gateway_connection_prefix_filter(self, - transit_gateway_id: str, - id: str, - filter_id: str, - **kwargs - ) -> DetailedResponse: + def delete_transit_gateway(self, + id: str, + **kwargs + ) -> DetailedResponse: """ - Remove prefix filter from Transit Gateway Connection. + Deletes specified Transit Gateway. - Delete a prefix filter. + This request deletes a Transit Gateway. This operation cannot be reversed. For + this request to succeed, the Transit Gateway must not contain connections. - :param str transit_gateway_id: The Transit Gateway identifier. - :param str id: The connection identifier. - :param str filter_id: Prefix filter identifier. + :param str id: The Transit Gateway identifier. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse """ - if transit_gateway_id is None: - raise ValueError('transit_gateway_id must be provided') if id is None: raise ValueError('id must be provided') - if filter_id is None: - raise ValueError('filter_id must be provided') headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', - operation_id='delete_transit_gateway_connection_prefix_filter') + operation_id='delete_transit_gateway') headers.update(sdk_headers) params = { @@ -330,10 +239,10 @@ def delete_transit_gateway_connection_prefix_filter(self, if 'headers' in kwargs: headers.update(kwargs.get('headers')) - path_param_keys = ['transit_gateway_id', 'id', 'filter_id'] - path_param_values = self.encode_path_vars(transit_gateway_id, id, filter_id) + path_param_keys = ['id'] + path_param_values = self.encode_path_vars(id) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/transit_gateways/{transit_gateway_id}/connections/{id}/prefix_filters/{filter_id}'.format(**path_param_dict) + url = '/transit_gateways/{id}'.format(**path_param_dict) request = self.prepare_request(method='DELETE', url=url, headers=headers, @@ -342,36 +251,28 @@ def delete_transit_gateway_connection_prefix_filter(self, response = self.send(request, **kwargs) return response - - def get_transit_gateway_connection_prefix_filter(self, - transit_gateway_id: str, - id: str, - filter_id: str, - **kwargs - ) -> DetailedResponse: + def get_transit_gateway(self, + id: str, + **kwargs + ) -> DetailedResponse: """ - Retrieves specified Transit Gateway connection prefix filter. + Retrieves specified Transit Gateway. - This request retrieves a prefix filter from the Transit Gateway Connection. + This request retrieves a single Transit Gateway specified by the identifier in the + URL. - :param str transit_gateway_id: The Transit Gateway identifier. - :param str id: The connection identifier. - :param str filter_id: Prefix filter identifier. + :param str id: The Transit Gateway identifier. :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 `PrefixFilterCust` object + :rtype: DetailedResponse with `dict` result representing a `TransitGateway` object """ - if transit_gateway_id is None: - raise ValueError('transit_gateway_id must be provided') if id is None: raise ValueError('id must be provided') - if filter_id is None: - raise ValueError('filter_id must be provided') headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', - operation_id='get_transit_gateway_connection_prefix_filter') + operation_id='get_transit_gateway') headers.update(sdk_headers) params = { @@ -382,10 +283,10 @@ def get_transit_gateway_connection_prefix_filter(self, headers.update(kwargs.get('headers')) headers['Accept'] = 'application/json' - path_param_keys = ['transit_gateway_id', 'id', 'filter_id'] - path_param_values = self.encode_path_vars(transit_gateway_id, id, filter_id) + path_param_keys = ['id'] + path_param_values = self.encode_path_vars(id) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/transit_gateways/{transit_gateway_id}/connections/{id}/prefix_filters/{filter_id}'.format(**path_param_dict) + url = '/transit_gateways/{id}'.format(**path_param_dict) request = self.prepare_request(method='GET', url=url, headers=headers, @@ -394,64 +295,32 @@ def get_transit_gateway_connection_prefix_filter(self, response = self.send(request, **kwargs) return response - - def update_transit_gateway_connection_prefix_filter(self, - transit_gateway_id: str, - id: str, - filter_id: str, - *, - action: str = None, - before: str = None, - ge: int = None, - le: int = None, - prefix: str = None, - **kwargs - ) -> DetailedResponse: + def update_transit_gateway(self, + id: str, + *, + global_: bool = None, + name: str = None, + **kwargs + ) -> DetailedResponse: """ - Updates specified Transit Gateway connection prefix filter. + Updates specified Transit Gateway. - Update prefix filter for a Transit Gateway Connection. + This request updates a Transit Gateway's name and/or global flag. - :param str transit_gateway_id: The Transit Gateway identifier. - :param str id: The connection identifier. - :param str filter_id: Prefix filter identifier. - :param str action: (optional) Whether to permit or deny prefix filter. - :param str before: (optional) Identifier of prefix filter to handle the - ordering and follow semantics: - - When a filter reference another filter in it's before field, then the - filter making the reference is applied before - the referenced filter. For example: if filter A references filter B in - its before field, A is applied before B. - - When a new filter is added that has the same before as an existing - filter, then the older filter will have its before - field updated to point to the new filter. Starting with the above - example: if filter C is added and it references B in its - before field, then A's before field should be modified to point to C, so - the order of application would be A, C and finally B. - - A filter that has an empty before reference will be applied last (though - the date order mentioned above will still apply). - So continuing the above examples, if filter B has an empty before field, - then it will be applied last, but if filter D - is created with an empty before field, then B's before field will be - modified to point to D, so B will be applied before D. - :param int ge: (optional) IP Prefix GE. - :param int le: (optional) IP Prefix LE. - :param str prefix: (optional) IP Prefix. + :param str id: The Transit Gateway identifier. + :param bool global_: (optional) Allow global routing for a Transit Gateway. + :param str name: (optional) The user-defined name for this transit gateway. :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 `PrefixFilterCust` object + :rtype: DetailedResponse with `dict` result representing a `TransitGateway` object """ - if transit_gateway_id is None: - raise ValueError('transit_gateway_id must be provided') if id is None: raise ValueError('id must be provided') - if filter_id is None: - raise ValueError('filter_id must be provided') headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', - operation_id='update_transit_gateway_connection_prefix_filter') + operation_id='update_transit_gateway') headers.update(sdk_headers) params = { @@ -459,11 +328,8 @@ def update_transit_gateway_connection_prefix_filter(self, } data = { - 'action': action, - 'before': before, - 'ge': ge, - 'le': le, - 'prefix': prefix + 'global': global_, + 'name': name } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) @@ -473,10 +339,10 @@ def update_transit_gateway_connection_prefix_filter(self, headers.update(kwargs.get('headers')) headers['Accept'] = 'application/json' - path_param_keys = ['transit_gateway_id', 'id', 'filter_id'] - path_param_values = self.encode_path_vars(transit_gateway_id, id, filter_id) + path_param_keys = ['id'] + path_param_values = self.encode_path_vars(id) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/transit_gateways/{transit_gateway_id}/connections/{id}/prefix_filters/{filter_id}'.format(**path_param_dict) + url = '/transit_gateways/{id}'.format(**path_param_dict) request = self.prepare_request(method='PATCH', url=url, headers=headers, @@ -487,47 +353,50 @@ def update_transit_gateway_connection_prefix_filter(self, return response ######################### - # transitGatewayRouteReports + # Transit Connections ######################### - - def list_transit_gateway_route_reports(self, - transit_gateway_id: str, - **kwargs - ) -> DetailedResponse: + def list_connections(self, + *, + limit: int = None, + start: str = None, + network_id: str = None, + **kwargs + ) -> DetailedResponse: """ - List route reports. + Retrieves all connections. - Retrieve all route reports for the specified Transit Gateway. There will normally - be at most one completed report and one pending report. Additionally, completed - route reports are written to IBM Cloud Activity Tracker. + List all transit gateway connections associated with this account. - :param str transit_gateway_id: The Transit Gateway identifier. + :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 `RouteReportCollection` object + :rtype: DetailedResponse with `dict` result representing a `TransitConnectionCollection` object """ - if transit_gateway_id is None: - raise ValueError('transit_gateway_id must be provided') headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', - operation_id='list_transit_gateway_route_reports') + operation_id='list_connections') headers.update(sdk_headers) params = { - 'version': self.version + 'version': self.version, + 'limit': limit, + 'start': start, + 'network_id': network_id } if 'headers' in kwargs: headers.update(kwargs.get('headers')) headers['Accept'] = 'application/json' - path_param_keys = ['transit_gateway_id'] - path_param_values = self.encode_path_vars(transit_gateway_id) - path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/transit_gateways/{transit_gateway_id}/route_reports'.format(**path_param_dict) + url = '/connections' request = self.prepare_request(method='GET', url=url, headers=headers, @@ -536,22 +405,23 @@ def list_transit_gateway_route_reports(self, response = self.send(request, **kwargs) return response + ######################### + # Transit Gateways Network Connections + ######################### - def create_transit_gateway_route_report(self, - transit_gateway_id: str, - **kwargs - ) -> DetailedResponse: + def list_transit_gateway_connections(self, + transit_gateway_id: str, + **kwargs + ) -> DetailedResponse: """ - Request a route report. + Retrieves all connections in a Transit Gateway. - Request route report generation. While report generation is in progress, - additional requests to generate a report are ignored and return the current - pending report. + This request retrieves all connections in a Transit Gateway. :param str transit_gateway_id: The Transit Gateway identifier. :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 `RouteReport` object + :rtype: DetailedResponse with `dict` result representing a `TransitGatewayConnectionCollection` object """ if transit_gateway_id is None: @@ -559,7 +429,7 @@ def create_transit_gateway_route_report(self, headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', - operation_id='create_transit_gateway_route_report') + operation_id='list_transit_gateway_connections') headers.update(sdk_headers) params = { @@ -573,8 +443,9 @@ def create_transit_gateway_route_report(self, path_param_keys = ['transit_gateway_id'] path_param_values = self.encode_path_vars(transit_gateway_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/transit_gateways/{transit_gateway_id}/route_reports'.format(**path_param_dict) - request = self.prepare_request(method='POST', + url = '/transit_gateways/{transit_gateway_id}/connections'.format( + **path_param_dict) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) @@ -582,69 +453,198 @@ def create_transit_gateway_route_report(self, response = self.send(request, **kwargs) return response - - def delete_transit_gateway_route_report(self, - transit_gateway_id: str, - id: str, - **kwargs - ) -> DetailedResponse: + def create_transit_gateway_connection(self, + transit_gateway_id: str, + network_type: str, + *, + base_connection_id: str = None, + base_network_type: str = None, + local_gateway_ip: str = None, + local_tunnel_ip: str = None, + name: str = None, + network_account_id: str = None, + network_id: str = None, + prefix_filters: List['TransitGatewayConnectionPrefixFilter'] = None, + prefix_filters_default: str = None, + remote_bgp_asn: int = None, + remote_gateway_ip: str = None, + remote_tunnel_ip: str = None, + zone: 'ZoneIdentity' = None, + **kwargs + ) -> DetailedResponse: """ - Delete route report. + Add connection to a Transit Gateway. - Delete a route report. + Add a connection to Transit Gateway. :param str transit_gateway_id: The Transit Gateway identifier. - :param str id: Route report identifier. + :param str network_type: Defines what type of network is connected via this + connection. For access to gre_tunnel or unbound_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 must specify the ID of an active transit gateway + network_type 'classic' connection in the same transit gateway. + This field is required for network type 'gre_tunnel' connections. + This field is required to be unspecified for network type 'classic', + 'directlink', 'vpc', 'power_virtual_server' and 'unbound_gre_tunnel' + connections. + :param str base_network_type: (optional) The type of network the Unbound + GRE tunnel is targeting. This field is required for network type + 'unbound_gre_tunnel' connections. This field is required to be unspecified + for network type 'classic', 'directlink', 'vpc', 'power_virtual_server' and + 'gre_tunnel' connections. + :param str local_gateway_ip: (optional) Local gateway IP address. This + field is required for network type 'gre_tunnel' and 'unbound_gre_tunnel' + connections. This field is required to be unspecified for network type + 'classic', 'directlink', 'vpc' and 'power_virtual_server' connections. + :param str local_tunnel_ip: (optional) Local tunnel IP address. The + local_tunnel_ip and remote_tunnel_ip addresses must be in the same /30 + network. Neither can be the network nor broadcast addresses. + This field is required for network type 'gre_tunnel' and + 'unbound_gre_tunnel' connections. + This field is required to be unspecified for network type 'classic', + 'directlink', 'vpc' and 'power_virtual_server' connections. + :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'. + This field is required for network type 'gre_tunnel' and + 'unbound_gre_tunnel' connections. + This field is optional for network type 'classic', 'directlink', 'vpc' and + 'power_virtual_server' 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 for type + 'unbound_gre_tunnel' when the associated_network_type is 'classic' and the + GRE tunnel is in a different account than the gateway. + :param str network_id: (optional) The ID of the network being connected via + this connection. For network types 'vpc','power_virtual_server' and + 'directlink' this is the CRN of the VPC / PowerVS / Direct Link gateway + respectively. This field is required for network type 'vpc', + 'power_virtual_server' and 'directlink' connections. This field is required + to be unspecified for network type 'classic', 'gre_tunnel' and + 'unbound_gre_tunnel' connections. + :param List[TransitGatewayConnectionPrefixFilter] prefix_filters: + (optional) Array of prefix route filters for a transit gateway connection. + Prefix filters can be specified for netowrk type 'vpc', 'classic', + 'power_virtual_server' and 'directlink' connections. They are not allowed + for type 'gre_tunnel' connections. This is order dependent with those first + in the array being applied first, and those at the end of the array being + applied last, or just before applying the default. This field is optional + for network type 'classic', 'vpc', 'directlink', and 'power_virtual_server' + connections. This field is required to be unspecified for network type + 'gre_tunnel' and 'unbound_gre_tunnel' connections. + :param str prefix_filters_default: (optional) Default setting of permit or + deny which applies to any routes that don't match a specified filter. This + field is optional for network type 'classic', 'vpc', 'directlink', and + 'power_virtual_server' connections. This field is required to be + unspecified for network type 'gre_tunnel' and 'unbound_gre_tunnel' + connections. + :param int remote_bgp_asn: (optional) Remote network BGP ASN. 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 or unbound_gre_tunnel connection create requests IBM + will assign an ASN. + This field is optional for network type 'gre_tunnel' and + 'unbound_gre_tunnel' connections. + This field is required to be unspecified for network type 'classic', + 'directlink', 'vpc' and 'power_virtual_server' connections. + :param str remote_gateway_ip: (optional) Remote gateway IP address. This + field is required for network type 'gre_tunnel' and 'unbound_gre_tunnel' + connections. This field is required to be unspecified for network type + 'classic', 'directlink', 'vpc' and 'power_virtual_server' connections. + :param str remote_tunnel_ip: (optional) Remote tunnel IP address. The + local_tunnel_ip and remote_tunnel_ip addresses must be in the same /30 + network. Neither can be the network nor broadcast addresses. + This field is required for network type 'gre_tunnel' and + 'unbound_gre_tunnel' connections. + This field is required to be unspecified for network type 'classic', + 'directlink', 'vpc' and 'power_virtual_server' connections. + :param ZoneIdentity zone: (optional) 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 network type 'gre_tunnel' and + 'unbound_gre_tunnel' connections. + This field is required to be unspecified for network type 'classic', + 'directlink', 'vpc' and 'power_virtual_server' connections. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. - :rtype: DetailedResponse + :rtype: DetailedResponse with `dict` result representing a `TransitGatewayConnectionCust` object """ if transit_gateway_id is None: raise ValueError('transit_gateway_id must be provided') - if id is None: - raise ValueError('id must be provided') + if network_type is None: + raise ValueError('network_type must be provided') + if prefix_filters is not None: + prefix_filters = [convert_model(x) for x in prefix_filters] + if zone is not None: + zone = convert_model(zone) headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', - operation_id='delete_transit_gateway_route_report') + operation_id='create_transit_gateway_connection') headers.update(sdk_headers) params = { 'version': self.version } + data = { + 'network_type': network_type, + 'base_connection_id': base_connection_id, + 'base_network_type': base_network_type, + 'local_gateway_ip': local_gateway_ip, + 'local_tunnel_ip': local_tunnel_ip, + 'name': name, + 'network_account_id': network_account_id, + 'network_id': network_id, + 'prefix_filters': prefix_filters, + 'prefix_filters_default': prefix_filters_default, + '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) + headers['content-type'] = 'application/json' + if 'headers' in kwargs: headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' - path_param_keys = ['transit_gateway_id', 'id'] - path_param_values = self.encode_path_vars(transit_gateway_id, id) + path_param_keys = ['transit_gateway_id'] + path_param_values = self.encode_path_vars(transit_gateway_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/transit_gateways/{transit_gateway_id}/route_reports/{id}'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', + url = '/transit_gateways/{transit_gateway_id}/connections'.format( + **path_param_dict) + request = self.prepare_request(method='POST', url=url, headers=headers, - params=params) + params=params, + data=data) response = self.send(request, **kwargs) return response - - def get_transit_gateway_route_report(self, - transit_gateway_id: str, - id: str, - **kwargs - ) -> DetailedResponse: + def delete_transit_gateway_connection(self, + transit_gateway_id: str, + id: str, + **kwargs + ) -> DetailedResponse: """ - Retrieve route report. + Remove connection from Transit Gateway. - Retrieve a route report. + After the specified connection is detached, entities still within the Transit + Gateway will no longer be able to communicate directly to it through the IBM Cloud + private backbone. :param str transit_gateway_id: The Transit Gateway identifier. - :param str id: Route report identifier. + :param str id: The connection identifier. :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 `RouteReport` object + :rtype: DetailedResponse """ if transit_gateway_id is None: @@ -654,7 +654,7 @@ def get_transit_gateway_route_report(self, headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', - operation_id='get_transit_gateway_route_report') + operation_id='delete_transit_gateway_connection') headers.update(sdk_headers) params = { @@ -663,13 +663,13 @@ def get_transit_gateway_route_report(self, if 'headers' in kwargs: headers.update(kwargs.get('headers')) - headers['Accept'] = 'application/json' path_param_keys = ['transit_gateway_id', 'id'] path_param_values = self.encode_path_vars(transit_gateway_id, id) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/transit_gateways/{transit_gateway_id}/route_reports/{id}'.format(**path_param_dict) - request = self.prepare_request(method='GET', + url = '/transit_gateways/{transit_gateway_id}/connections/{id}'.format( + **path_param_dict) + request = self.prepare_request(method='DELETE', url=url, headers=headers, params=params) @@ -677,48 +677,46 @@ def get_transit_gateway_route_report(self, response = self.send(request, **kwargs) return response - ######################### - # transitGateways - ######################### - - - def list_transit_gateways(self, - *, - limit: int = None, - start: str = None, - **kwargs - ) -> DetailedResponse: + def get_transit_gateway_connection(self, + transit_gateway_id: str, + id: str, + **kwargs + ) -> DetailedResponse: """ - Retrieves all Transit Gateways. + Retrieves specified Transit Gateway connection. - List all Transit Gateways in account the caller is authorized to view. + This request retrieves a connection from the Transit Gateway. - :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 transit_gateway_id: The Transit Gateway identifier. + :param str id: The connection identifier. :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 + :rtype: DetailedResponse with `dict` result representing a `TransitGatewayConnectionCust` object """ + if transit_gateway_id is None: + raise ValueError('transit_gateway_id must be provided') + if id is None: + raise ValueError('id must be provided') headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', - operation_id='list_transit_gateways') + operation_id='get_transit_gateway_connection') headers.update(sdk_headers) params = { - 'version': self.version, - 'limit': limit, - 'start': start + 'version': self.version } if 'headers' in kwargs: headers.update(kwargs.get('headers')) headers['Accept'] = 'application/json' - url = '/transit_gateways' + path_param_keys = ['transit_gateway_id', 'id'] + path_param_values = self.encode_path_vars(transit_gateway_id, id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/transit_gateways/{transit_gateway_id}/connections/{id}'.format( + **path_param_dict) request = self.prepare_request(method='GET', url=url, headers=headers, @@ -727,43 +725,40 @@ def list_transit_gateways(self, response = self.send(request, **kwargs) return response - - def create_transit_gateway(self, - location: str, - name: str, - *, - global_: bool = None, - resource_group: 'ResourceGroupIdentity' = None, - **kwargs - ) -> DetailedResponse: + def update_transit_gateway_connection(self, + transit_gateway_id: str, + id: str, + *, + name: str = None, + prefix_filters_default: str = None, + **kwargs + ) -> DetailedResponse: """ - Creates a Transit Gateway. + Updates specified Transit Gateway connection. - Create a Transit Gateway based on the supplied input template. + Update the name of a connection to a Transit Gateway. - :param str location: Location of Transit Gateway Services. - :param str name: Name Transit Gateway Services. - :param bool global_: (optional) Allow global routing for a Transit Gateway. - If unspecified, the default value is false. - :param ResourceGroupIdentity 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 str transit_gateway_id: The Transit Gateway identifier. + :param str id: The connection identifier. + :param str name: (optional) The user-defined name for this transit gateway. + If specified as empty string or nil, 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 prefix_filters_default: (optional) Default setting of permit or + deny which applies to any routes that don't match a specified filter. :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 `TransitGateway` object + :rtype: DetailedResponse with `dict` result representing a `TransitGatewayConnectionCust` object """ - if location is None: - raise ValueError('location must be provided') - if name is None: - raise ValueError('name must be provided') - if resource_group is not None: - resource_group = convert_model(resource_group) + if transit_gateway_id is None: + raise ValueError('transit_gateway_id must be provided') + if id is None: + raise ValueError('id must be provided') headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', - operation_id='create_transit_gateway') + operation_id='update_transit_gateway_connection') headers.update(sdk_headers) params = { @@ -771,10 +766,8 @@ def create_transit_gateway(self, } data = { - 'location': location, 'name': name, - 'global': global_, - 'resource_group': resource_group + 'prefix_filters_default': prefix_filters_default } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) @@ -784,8 +777,12 @@ def create_transit_gateway(self, headers.update(kwargs.get('headers')) headers['Accept'] = 'application/json' - url = '/transit_gateways' - request = self.prepare_request(method='POST', + path_param_keys = ['transit_gateway_id', 'id'] + path_param_values = self.encode_path_vars(transit_gateway_id, id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/transit_gateways/{transit_gateway_id}/connections/{id}'.format( + **path_param_dict) + request = self.prepare_request(method='PATCH', url=url, headers=headers, params=params, @@ -794,73 +791,87 @@ def create_transit_gateway(self, response = self.send(request, **kwargs) return response - - def delete_transit_gateway(self, - id: str, - **kwargs - ) -> DetailedResponse: + def create_transit_gateway_connection_actions(self, + transit_gateway_id: str, + id: str, + action: str, + **kwargs + ) -> DetailedResponse: """ - Deletes specified Transit Gateway. + Perform actions on a connection for a Transit Gateway. - This request deletes a Transit Gateway. This operation cannot be reversed. For - this request to succeed, the Transit Gateway must not contain connections. + Allow a network owner to approve or reject a cross-account connection request. - :param str id: The Transit Gateway identifier. + :param str transit_gateway_id: The Transit Gateway identifier. + :param str id: The connection identifier. + :param str action: The action that is to be performed against the + connection request. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse """ + if transit_gateway_id is None: + raise ValueError('transit_gateway_id must be provided') if id is None: raise ValueError('id must be provided') + if action is None: + raise ValueError('action must be provided') headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', - operation_id='delete_transit_gateway') + operation_id='create_transit_gateway_connection_actions') headers.update(sdk_headers) params = { 'version': self.version } + data = { + 'action': action + } + data = {k: v for (k, v) in data.items() if v is not None} + data = json.dumps(data) + headers['content-type'] = 'application/json' + if 'headers' in kwargs: headers.update(kwargs.get('headers')) - path_param_keys = ['id'] - path_param_values = self.encode_path_vars(id) + path_param_keys = ['transit_gateway_id', 'id'] + path_param_values = self.encode_path_vars(transit_gateway_id, id) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/transit_gateways/{id}'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', + url = '/transit_gateways/{transit_gateway_id}/connections/{id}/actions'.format( + **path_param_dict) + request = self.prepare_request(method='POST', url=url, headers=headers, - params=params) + params=params, + data=data) response = self.send(request, **kwargs) return response + ######################### + # Transit Location + ######################### - def get_transit_gateway(self, - id: str, - **kwargs - ) -> DetailedResponse: + def list_gateway_locations(self, + **kwargs + ) -> DetailedResponse: """ - Retrieves specified Transit Gateway. + List all locations that support Transit Gateways. - This request retrieves a single Transit Gateway specified by the identifier in the - URL. + List all locations that support Transit Gateways. - :param str id: The Transit Gateway identifier. :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 `TransitGateway` object + :rtype: DetailedResponse with `dict` result representing a `TSCollection` object """ - if id is None: - raise ValueError('id must be provided') headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', - operation_id='get_transit_gateway') + operation_id='list_gateway_locations') headers.update(sdk_headers) params = { @@ -871,10 +882,7 @@ def get_transit_gateway(self, headers.update(kwargs.get('headers')) headers['Accept'] = 'application/json' - path_param_keys = ['id'] - path_param_values = self.encode_path_vars(id) - path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/transit_gateways/{id}'.format(**path_param_dict) + url = '/locations' request = self.prepare_request(method='GET', url=url, headers=headers, @@ -883,90 +891,78 @@ def get_transit_gateway(self, response = self.send(request, **kwargs) return response - - def update_transit_gateway(self, - id: str, - *, - global_: bool = None, - name: str = None, - **kwargs - ) -> DetailedResponse: + def get_gateway_location(self, + name: str, + **kwargs + ) -> DetailedResponse: """ - Updates specified Transit Gateway. + Show the details of a given Transit Gateway location. - This request updates a Transit Gateway's name and/or global flag. + Get the details of a Transit Gateway Location. - :param str id: The Transit Gateway identifier. - :param bool global_: (optional) Allow global routing for a Transit Gateway. - :param str name: (optional) The user-defined name for this transit gateway. + :param str name: The Transit Gateway location Name. :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 `TransitGateway` object + :rtype: DetailedResponse with `dict` result representing a `TSLocation` object """ - if id is None: - raise ValueError('id must be provided') + if name is None: + raise ValueError('name must be provided') headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', - operation_id='update_transit_gateway') + operation_id='get_gateway_location') headers.update(sdk_headers) params = { 'version': self.version } - data = { - 'global': global_, - 'name': name - } - data = {k: v for (k, v) in data.items() if v is not None} - data = json.dumps(data) - headers['content-type'] = 'application/json' - if 'headers' in kwargs: headers.update(kwargs.get('headers')) headers['Accept'] = 'application/json' - path_param_keys = ['id'] - path_param_values = self.encode_path_vars(id) + path_param_keys = ['name'] + path_param_values = self.encode_path_vars(name) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/transit_gateways/{id}'.format(**path_param_dict) - request = self.prepare_request(method='PATCH', + url = '/locations/{name}'.format(**path_param_dict) + request = self.prepare_request(method='GET', url=url, headers=headers, - params=params, - data=data) + params=params) response = self.send(request, **kwargs) return response ######################### - # transitGatewaysNetworkConnections + # Transit Gateway Connection Prefix Filters ######################### - - def list_transit_gateway_connections(self, - transit_gateway_id: str, - **kwargs - ) -> DetailedResponse: + def list_transit_gateway_connection_prefix_filters(self, + transit_gateway_id: str, + id: str, + **kwargs + ) -> DetailedResponse: """ - Retrieves all connections in a Transit Gateway. + Retrieves all prefix filters in a Transit Gateway connection. - This request retrieves all connections in a Transit Gateway. + This request retrieves all prefix filters in a Transit Gateway connection. :param str transit_gateway_id: The Transit Gateway identifier. + :param str id: The connection identifier. :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 `TransitGatewayConnectionCollection` object + :rtype: DetailedResponse with `dict` result representing a `PrefixFilterCollection` object """ if transit_gateway_id is None: raise ValueError('transit_gateway_id must be provided') + if id is None: + raise ValueError('id must be provided') headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', - operation_id='list_transit_gateway_connections') + operation_id='list_transit_gateway_connection_prefix_filters') headers.update(sdk_headers) params = { @@ -977,10 +973,11 @@ def list_transit_gateway_connections(self, headers.update(kwargs.get('headers')) headers['Accept'] = 'application/json' - path_param_keys = ['transit_gateway_id'] - path_param_values = self.encode_path_vars(transit_gateway_id) + path_param_keys = ['transit_gateway_id', 'id'] + path_param_values = self.encode_path_vars(transit_gateway_id, id) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/transit_gateways/{transit_gateway_id}/connections'.format(**path_param_dict) + url = '/transit_gateways/{transit_gateway_id}/connections/{id}/prefix_filters'.format( + **path_param_dict) request = self.prepare_request(method='GET', url=url, headers=headers, @@ -989,101 +986,63 @@ def list_transit_gateway_connections(self, response = self.send(request, **kwargs) return response - - 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_account_id: str = None, - network_id: str = None, - prefix_filters: List['TransitGatewayConnectionPrefixFilter'] = None, - prefix_filters_default: str = None, - remote_bgp_asn: str = None, - remote_gateway_ip: str = None, - remote_tunnel_ip: str = None, - zone: 'ZoneIdentity' = None, - **kwargs - ) -> DetailedResponse: + def create_transit_gateway_connection_prefix_filter(self, + transit_gateway_id: str, + id: str, + action: str, + prefix: str, + *, + before: str = None, + ge: int = None, + le: int = None, + **kwargs + ) -> DetailedResponse: """ - Add connection to a Transit Gateway. + Add a prefix filter to a Transit Gateway Connection. - Add a connection to Transit Gateway. + Add a prefix filter to a Transit Gateway Connection. :param str transit_gateway_id: The Transit Gateway identifier. - :param str network_type: Defines what type of network is connected via this - 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' and - 'directlink'. For network types 'vpc' and 'directlink' this is the CRN of - the VPC / Direct Link gateway respectively. This field is required to be - unspecified for network type 'classic' and 'gre_tunnel' connections. - :param List[TransitGatewayConnectionPrefixFilter] prefix_filters: - (optional) Array of prefix route filters for a transit gateway connection. - Prefix filters can be specified for netowrk type 'vpc', 'classic' and - 'directlink' connections. They are not allowed for type 'gre_tunnel' - connections. This is order dependent with those first in the array being - applied first, and those at the end of the array being applied last, or - just before applying the default. - :param str prefix_filters_default: (optional) Default setting of permit or - deny which applies to any routes that don't match a specified filter. - :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 str id: The connection identifier. + :param str action: Whether to permit or deny prefix filter. + :param str prefix: IP Prefix. + :param str before: (optional) Identifier of prefix filter to handle the + ordering and follow semantics: + - When a filter reference another filter in it's before field, then the + filter making the reference is applied before + the referenced filter. For example: if filter A references filter B in + its before field, A is applied before B. + - When a new filter is added that has the same before as an existing + filter, then the older filter will have its before + field updated to point to the new filter. Starting with the above + example: if filter C is added and it references B in its + before field, then A's before field should be modified to point to C, so + the order of application would be A, C and finally B. + - A filter that has an empty before reference will be applied last (though + the date order mentioned above will still apply). + So continuing the above examples, if filter B has an empty before field, + then it will be applied last, but if filter D + is created with an empty before field, then B's before field will be + modified to point to D, so B will be applied before D. + :param int ge: (optional) IP Prefix GE. + :param int le: (optional) IP Prefix LE. :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 + :rtype: DetailedResponse with `dict` result representing a `PrefixFilterCust` object """ if transit_gateway_id is None: raise ValueError('transit_gateway_id must be provided') - if network_type is None: - raise ValueError('network_type must be provided') - if prefix_filters is not None: - prefix_filters = [convert_model(x) for x in prefix_filters] - if zone is not None: - zone = convert_model(zone) + if id is None: + raise ValueError('id must be provided') + if action is None: + raise ValueError('action must be provided') + if prefix is None: + raise ValueError('prefix must be provided') headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', - operation_id='create_transit_gateway_connection') + operation_id='create_transit_gateway_connection_prefix_filter') headers.update(sdk_headers) params = { @@ -1091,19 +1050,11 @@ 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, - 'prefix_filters': prefix_filters, - 'prefix_filters_default': prefix_filters_default, - 'remote_bgp_asn': remote_bgp_asn, - 'remote_gateway_ip': remote_gateway_ip, - 'remote_tunnel_ip': remote_tunnel_ip, - 'zone': zone + 'action': action, + 'prefix': prefix, + 'before': before, + 'ge': ge, + 'le': le } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) @@ -1113,10 +1064,11 @@ def create_transit_gateway_connection(self, headers.update(kwargs.get('headers')) headers['Accept'] = 'application/json' - path_param_keys = ['transit_gateway_id'] - path_param_values = self.encode_path_vars(transit_gateway_id) + path_param_keys = ['transit_gateway_id', 'id'] + path_param_values = self.encode_path_vars(transit_gateway_id, id) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/transit_gateways/{transit_gateway_id}/connections'.format(**path_param_dict) + url = '/transit_gateways/{transit_gateway_id}/connections/{id}/prefix_filters'.format( + **path_param_dict) request = self.prepare_request(method='POST', url=url, headers=headers, @@ -1126,47 +1078,111 @@ def create_transit_gateway_connection(self, response = self.send(request, **kwargs) return response - - def delete_transit_gateway_connection(self, - transit_gateway_id: str, - id: str, - **kwargs - ) -> DetailedResponse: + def replace_transit_gateway_connection_prefix_filter(self, + transit_gateway_id: str, + id: str, + prefix_filters: List['PrefixFilterPut'], + **kwargs + ) -> DetailedResponse: """ - Remove connection from Transit Gateway. + Replaces the prefix filters of the Transit Gateway Connection. - After the specified connection is detached, entities still within the Transit - Gateway will no longer be able to communicate directly to it through the IBM Cloud - private backbone. + Replaces the prefix filters of the Transit Gateway Connection. :param str transit_gateway_id: The Transit Gateway identifier. :param str id: The connection identifier. + :param List[PrefixFilterPut] prefix_filters: Array of prefix filters. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. - :rtype: DetailedResponse + :rtype: DetailedResponse with `dict` result representing a `PrefixFilterCollection` object """ if transit_gateway_id is None: raise ValueError('transit_gateway_id must be provided') if id is None: raise ValueError('id must be provided') + if prefix_filters is None: + raise ValueError('prefix_filters must be provided') + prefix_filters = [convert_model(x) for x in prefix_filters] headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', - operation_id='delete_transit_gateway_connection') + operation_id='replace_transit_gateway_connection_prefix_filter') headers.update(sdk_headers) params = { 'version': self.version } + data = { + 'prefix_filters': prefix_filters + } + data = {k: v for (k, v) in data.items() if v is not None} + data = json.dumps(data) + headers['content-type'] = 'application/json' + if 'headers' in kwargs: headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' path_param_keys = ['transit_gateway_id', 'id'] path_param_values = self.encode_path_vars(transit_gateway_id, id) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/transit_gateways/{transit_gateway_id}/connections/{id}'.format(**path_param_dict) + url = '/transit_gateways/{transit_gateway_id}/connections/{id}/prefix_filters'.format( + **path_param_dict) + request = self.prepare_request(method='PUT', + url=url, + headers=headers, + params=params, + data=data) + + response = self.send(request, **kwargs) + return response + + def delete_transit_gateway_connection_prefix_filter(self, + transit_gateway_id: str, + id: str, + filter_id: str, + **kwargs + ) -> DetailedResponse: + """ + Remove prefix filter from Transit Gateway Connection. + + Delete a prefix filter. + + :param str transit_gateway_id: The Transit Gateway identifier. + :param str id: The connection identifier. + :param str filter_id: Prefix filter identifier. + :param dict headers: A `dict` containing the request headers + :return: A `DetailedResponse` containing the result, headers and HTTP status code. + :rtype: DetailedResponse + """ + + if transit_gateway_id is None: + raise ValueError('transit_gateway_id must be provided') + if id is None: + raise ValueError('id must be provided') + if filter_id is None: + raise ValueError('filter_id must be provided') + headers = {} + sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='delete_transit_gateway_connection_prefix_filter') + headers.update(sdk_headers) + + params = { + 'version': self.version + } + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + + path_param_keys = ['transit_gateway_id', 'id', 'filter_id'] + path_param_values = self.encode_path_vars( + transit_gateway_id, id, filter_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/transit_gateways/{transit_gateway_id}/connections/{id}/prefix_filters/{filter_id}'.format( + **path_param_dict) request = self.prepare_request(method='DELETE', url=url, headers=headers, @@ -1175,32 +1191,35 @@ def delete_transit_gateway_connection(self, response = self.send(request, **kwargs) return response - - def get_transit_gateway_connection(self, - transit_gateway_id: str, - id: str, - **kwargs - ) -> DetailedResponse: + def get_transit_gateway_connection_prefix_filter(self, + transit_gateway_id: str, + id: str, + filter_id: str, + **kwargs + ) -> DetailedResponse: """ - Retrieves specified Transit Gateway connection. + Retrieves specified Transit Gateway connection prefix filter. - This request retrieves a connection from the Transit Gateway. + This request retrieves a prefix filter from the Transit Gateway Connection. :param str transit_gateway_id: The Transit Gateway identifier. :param str id: The connection identifier. + :param str filter_id: Prefix filter identifier. :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 + :rtype: DetailedResponse with `dict` result representing a `PrefixFilterCust` object """ if transit_gateway_id is None: raise ValueError('transit_gateway_id must be provided') if id is None: raise ValueError('id must be provided') + if filter_id is None: + raise ValueError('filter_id must be provided') headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', - operation_id='get_transit_gateway_connection') + operation_id='get_transit_gateway_connection_prefix_filter') headers.update(sdk_headers) params = { @@ -1211,10 +1230,12 @@ def get_transit_gateway_connection(self, headers.update(kwargs.get('headers')) headers['Accept'] = 'application/json' - path_param_keys = ['transit_gateway_id', 'id'] - path_param_values = self.encode_path_vars(transit_gateway_id, id) + path_param_keys = ['transit_gateway_id', 'id', 'filter_id'] + path_param_values = self.encode_path_vars( + transit_gateway_id, id, filter_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/transit_gateways/{transit_gateway_id}/connections/{id}'.format(**path_param_dict) + url = '/transit_gateways/{transit_gateway_id}/connections/{id}/prefix_filters/{filter_id}'.format( + **path_param_dict) request = self.prepare_request(method='GET', url=url, headers=headers, @@ -1223,154 +1244,220 @@ def get_transit_gateway_connection(self, response = self.send(request, **kwargs) return response + def update_transit_gateway_connection_prefix_filter(self, + transit_gateway_id: str, + id: str, + filter_id: str, + *, + action: str = None, + before: str = None, + ge: int = None, + le: int = None, + prefix: str = None, + **kwargs + ) -> DetailedResponse: + """ + Updates specified Transit Gateway connection prefix filter. - def update_transit_gateway_connection(self, - transit_gateway_id: str, - id: str, - *, - name: str = None, - prefix_filters_default: str = None, - **kwargs - ) -> DetailedResponse: + Update prefix filter for a Transit Gateway Connection. + + :param str transit_gateway_id: The Transit Gateway identifier. + :param str id: The connection identifier. + :param str filter_id: Prefix filter identifier. + :param str action: (optional) Whether to permit or deny prefix filter. + :param str before: (optional) Identifier of prefix filter to handle the + ordering and follow semantics: + - When a filter reference another filter in it's before field, then the + filter making the reference is applied before + the referenced filter. For example: if filter A references filter B in + its before field, A is applied before B. + - When a new filter is added that has the same before as an existing + filter, then the older filter will have its before + field updated to point to the new filter. Starting with the above + example: if filter C is added and it references B in its + before field, then A's before field should be modified to point to C, so + the order of application would be A, C and finally B. + - A filter that has an empty before reference will be applied last (though + the date order mentioned above will still apply). + So continuing the above examples, if filter B has an empty before field, + then it will be applied last, but if filter D + is created with an empty before field, then B's before field will be + modified to point to D, so B will be applied before D. + :param int ge: (optional) IP Prefix GE. + :param int le: (optional) IP Prefix LE. + :param str prefix: (optional) IP Prefix. + :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 `PrefixFilterCust` object + """ + + if transit_gateway_id is None: + raise ValueError('transit_gateway_id must be provided') + if id is None: + raise ValueError('id must be provided') + if filter_id is None: + raise ValueError('filter_id must be provided') + headers = {} + sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='update_transit_gateway_connection_prefix_filter') + headers.update(sdk_headers) + + params = { + 'version': self.version + } + + data = { + 'action': action, + 'before': before, + 'ge': ge, + 'le': le, + 'prefix': prefix + } + data = {k: v for (k, v) in data.items() if v is not None} + data = json.dumps(data) + headers['content-type'] = 'application/json' + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' + + path_param_keys = ['transit_gateway_id', 'id', 'filter_id'] + path_param_values = self.encode_path_vars( + transit_gateway_id, id, filter_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/transit_gateways/{transit_gateway_id}/connections/{id}/prefix_filters/{filter_id}'.format( + **path_param_dict) + request = self.prepare_request(method='PATCH', + url=url, + headers=headers, + params=params, + data=data) + + response = self.send(request, **kwargs) + return response + + ######################### + # Transit Gateway Route Reports + ######################### + + def list_transit_gateway_route_reports(self, + transit_gateway_id: str, + **kwargs + ) -> DetailedResponse: """ - Updates specified Transit Gateway connection. + List route reports. - Update the name of a connection to a Transit Gateway. + Retrieve all route reports for the specified Transit Gateway. There will normally + be at most one completed report and one pending report. Additionally, completed + route reports are written to IBM Cloud Activity Tracker. :param str transit_gateway_id: The Transit Gateway identifier. - :param str id: The connection identifier. - :param str name: (optional) The user-defined name for this transit gateway. - If specified as empty string or nil, 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 prefix_filters_default: (optional) Default setting of permit or - deny which applies to any routes that don't match a specified filter. :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 + :rtype: DetailedResponse with `dict` result representing a `RouteReportCollection` object """ if transit_gateway_id is None: raise ValueError('transit_gateway_id must be provided') - if id is None: - raise ValueError('id must be provided') headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', - operation_id='update_transit_gateway_connection') + operation_id='list_transit_gateway_route_reports') headers.update(sdk_headers) params = { 'version': self.version } - data = { - 'name': name, - 'prefix_filters_default': prefix_filters_default - } - data = {k: v for (k, v) in data.items() if v is not None} - data = json.dumps(data) - headers['content-type'] = 'application/json' - if 'headers' in kwargs: headers.update(kwargs.get('headers')) headers['Accept'] = 'application/json' - path_param_keys = ['transit_gateway_id', 'id'] - path_param_values = self.encode_path_vars(transit_gateway_id, id) + path_param_keys = ['transit_gateway_id'] + path_param_values = self.encode_path_vars(transit_gateway_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/transit_gateways/{transit_gateway_id}/connections/{id}'.format(**path_param_dict) - request = self.prepare_request(method='PATCH', + url = '/transit_gateways/{transit_gateway_id}/route_reports'.format( + **path_param_dict) + request = self.prepare_request(method='GET', url=url, headers=headers, - params=params, - data=data) + params=params) response = self.send(request, **kwargs) return response - - def create_transit_gateway_connection_actions(self, - transit_gateway_id: str, - id: str, - action: str, - **kwargs - ) -> DetailedResponse: + def create_transit_gateway_route_report(self, + transit_gateway_id: str, + **kwargs + ) -> DetailedResponse: """ - Perform actions on a connection for a Transit Gateway. + Request a route report. - Allow a network owner to approve or reject a cross-account connection request. + Request route report generation. While report generation is in progress, + additional requests to generate a report are ignored and return the current + pending report. :param str transit_gateway_id: The Transit Gateway identifier. - :param str id: The connection identifier. - :param str action: The action that is to be performed against the - connection request. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. - :rtype: DetailedResponse + :rtype: DetailedResponse with `dict` result representing a `RouteReport` object """ if transit_gateway_id is None: raise ValueError('transit_gateway_id must be provided') - if id is None: - raise ValueError('id must be provided') - if action is None: - raise ValueError('action must be provided') headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', - operation_id='create_transit_gateway_connection_actions') + operation_id='create_transit_gateway_route_report') headers.update(sdk_headers) params = { 'version': self.version } - data = { - 'action': action - } - data = {k: v for (k, v) in data.items() if v is not None} - data = json.dumps(data) - headers['content-type'] = 'application/json' - if 'headers' in kwargs: headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' - path_param_keys = ['transit_gateway_id', 'id'] - path_param_values = self.encode_path_vars(transit_gateway_id, id) + path_param_keys = ['transit_gateway_id'] + path_param_values = self.encode_path_vars(transit_gateway_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/transit_gateways/{transit_gateway_id}/connections/{id}/actions'.format(**path_param_dict) + url = '/transit_gateways/{transit_gateway_id}/route_reports'.format( + **path_param_dict) request = self.prepare_request(method='POST', url=url, headers=headers, - params=params, - data=data) + params=params) response = self.send(request, **kwargs) return response - ######################### - # transitLocation - ######################### - - - def list_gateway_locations(self, - **kwargs - ) -> DetailedResponse: + def delete_transit_gateway_route_report(self, + transit_gateway_id: str, + id: str, + **kwargs + ) -> DetailedResponse: """ - List all locations that support Transit Gateways. + Delete route report. - List all locations that support Transit Gateways. + Delete a route report. + :param str transit_gateway_id: The Transit Gateway identifier. + :param str id: Route report identifier. :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 `TSCollection` object + :rtype: DetailedResponse """ + if transit_gateway_id is None: + raise ValueError('transit_gateway_id must be provided') + if id is None: + raise ValueError('id must be provided') headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', - operation_id='list_gateway_locations') + operation_id='delete_transit_gateway_route_report') headers.update(sdk_headers) params = { @@ -1379,10 +1466,13 @@ 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', + path_param_keys = ['transit_gateway_id', 'id'] + path_param_values = self.encode_path_vars(transit_gateway_id, id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/transit_gateways/{transit_gateway_id}/route_reports/{id}'.format( + **path_param_dict) + request = self.prepare_request(method='DELETE', url=url, headers=headers, params=params) @@ -1390,28 +1480,31 @@ def list_gateway_locations(self, response = self.send(request, **kwargs) return response - - def get_gateway_location(self, - name: str, - **kwargs - ) -> DetailedResponse: + def get_transit_gateway_route_report(self, + transit_gateway_id: str, + id: str, + **kwargs + ) -> DetailedResponse: """ - Show the details of a given Transit Gateway location. + Retrieve route report. - Get the details of a Transit Gateway Location. + Retrieve a route report. - :param str name: The Transit Gateway location Name. + :param str transit_gateway_id: The Transit Gateway identifier. + :param str id: Route report identifier. :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 `TSLocation` object + :rtype: DetailedResponse with `dict` result representing a `RouteReport` object """ - if name is None: - raise ValueError('name must be provided') + if transit_gateway_id is None: + raise ValueError('transit_gateway_id must be provided') + if id is None: + raise ValueError('id must be provided') headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', - operation_id='get_gateway_location') + operation_id='get_transit_gateway_route_report') headers.update(sdk_headers) params = { @@ -1422,10 +1515,11 @@ def get_gateway_location(self, headers.update(kwargs.get('headers')) headers['Accept'] = 'application/json' - path_param_keys = ['name'] - path_param_values = self.encode_path_vars(name) + path_param_keys = ['transit_gateway_id', 'id'] + path_param_values = self.encode_path_vars(transit_gateway_id, id) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/locations/{name}'.format(**path_param_dict) + url = '/transit_gateways/{transit_gateway_id}/route_reports/{id}'.format( + **path_param_dict) request = self.prepare_request(method='GET', url=url, headers=headers, @@ -1461,9 +1555,11 @@ def from_dict(cls, _dict: Dict) -> 'PrefixFilterCollection': """Initialize a PrefixFilterCollection object from a json dictionary.""" args = {} if 'prefix_filters' in _dict: - args['prefix_filters'] = [PrefixFilterCust.from_dict(x) for x in _dict.get('prefix_filters')] + args['prefix_filters'] = [PrefixFilterCust.from_dict( + x) for x in _dict.get('prefix_filters')] else: - raise ValueError('Required property \'prefix_filters\' not present in PrefixFilterCollection JSON') + raise ValueError( + 'Required property \'prefix_filters\' not present in PrefixFilterCollection JSON') return cls(**args) @classmethod @@ -1475,7 +1571,8 @@ def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} if hasattr(self, 'prefix_filters') and self.prefix_filters is not None: - _dict['prefix_filters'] = [x.to_dict() for x in self.prefix_filters] + _dict['prefix_filters'] = [x.to_dict() + for x in self.prefix_filters] return _dict def _to_dict(self): @@ -1496,6 +1593,7 @@ def __ne__(self, other: 'PrefixFilterCollection') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other + class PrefixFilterCust(): """ prefix filter. @@ -1586,25 +1684,29 @@ def from_dict(cls, _dict: Dict) -> 'PrefixFilterCust': if 'action' in _dict: args['action'] = _dict.get('action') else: - raise ValueError('Required property \'action\' not present in PrefixFilterCust JSON') + raise ValueError( + 'Required property \'action\' not present in PrefixFilterCust JSON') if 'before' in _dict: args['before'] = _dict.get('before') 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 PrefixFilterCust JSON') + raise ValueError( + 'Required property \'created_at\' not present in PrefixFilterCust JSON') if 'ge' in _dict: args['ge'] = _dict.get('ge') if 'id' in _dict: args['id'] = _dict.get('id') else: - raise ValueError('Required property \'id\' not present in PrefixFilterCust JSON') + raise ValueError( + 'Required property \'id\' not present in PrefixFilterCust JSON') if 'le' in _dict: args['le'] = _dict.get('le') if 'prefix' in _dict: args['prefix'] = _dict.get('prefix') else: - raise ValueError('Required property \'prefix\' not present in PrefixFilterCust JSON') + raise ValueError( + 'Required property \'prefix\' not present in PrefixFilterCust JSON') if 'updated_at' in _dict: args['updated_at'] = string_to_datetime(_dict.get('updated_at')) return cls(**args) @@ -1661,6 +1763,99 @@ class ActionEnum(str, Enum): DENY = 'deny' +class PrefixFilterPut(): + """ + A prefix filter create template. + + :attr str action: Whether to permit or deny prefix filter. + :attr int ge: (optional) IP Prefix GE. + :attr int le: (optional) IP Prefix LE. + :attr str prefix: IP Prefix. + """ + + def __init__(self, + action: str, + prefix: str, + *, + ge: int = None, + le: int = None) -> None: + """ + Initialize a PrefixFilterPut object. + + :param str action: Whether to permit or deny prefix filter. + :param str prefix: IP Prefix. + :param int ge: (optional) IP Prefix GE. + :param int le: (optional) IP Prefix LE. + """ + self.action = action + self.ge = ge + self.le = le + self.prefix = prefix + + @classmethod + def from_dict(cls, _dict: Dict) -> 'PrefixFilterPut': + """Initialize a PrefixFilterPut object from a json dictionary.""" + args = {} + if 'action' in _dict: + args['action'] = _dict.get('action') + else: + raise ValueError( + 'Required property \'action\' not present in PrefixFilterPut JSON') + if 'ge' in _dict: + args['ge'] = _dict.get('ge') + if 'le' in _dict: + args['le'] = _dict.get('le') + if 'prefix' in _dict: + args['prefix'] = _dict.get('prefix') + else: + raise ValueError( + 'Required property \'prefix\' not present in PrefixFilterPut JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a PrefixFilterPut 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, 'action') and self.action is not None: + _dict['action'] = self.action + if hasattr(self, 'ge') and self.ge is not None: + _dict['ge'] = self.ge + if hasattr(self, 'le') and self.le is not None: + _dict['le'] = self.le + if hasattr(self, 'prefix') and self.prefix is not None: + _dict['prefix'] = self.prefix + 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 PrefixFilterPut object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'PrefixFilterPut') -> 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: 'PrefixFilterPut') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + class ActionEnum(str, Enum): + """ + Whether to permit or deny prefix filter. + """ + PERMIT = 'permit' + DENY = 'deny' + + class ResourceGroupIdentity(): """ The resource group to use. If unspecified, the account's [default resource @@ -1685,7 +1880,8 @@ def from_dict(cls, _dict: Dict) -> 'ResourceGroupIdentity': if 'id' in _dict: args['id'] = _dict.get('id') else: - raise ValueError('Required property \'id\' not present in ResourceGroupIdentity JSON') + raise ValueError( + 'Required property \'id\' not present in ResourceGroupIdentity JSON') return cls(**args) @classmethod @@ -1718,6 +1914,7 @@ def __ne__(self, other: 'ResourceGroupIdentity') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other + class ResourceGroupReference(): """ The resource group to use. If unspecified, the account's [default resource @@ -1746,11 +1943,13 @@ def from_dict(cls, _dict: Dict) -> 'ResourceGroupReference': if 'id' in _dict: args['id'] = _dict.get('id') else: - raise ValueError('Required property \'id\' not present in ResourceGroupReference JSON') + raise ValueError( + 'Required property \'id\' not present in ResourceGroupReference JSON') if 'href' in _dict: args['href'] = _dict.get('href') else: - raise ValueError('Required property \'href\' not present in ResourceGroupReference JSON') + raise ValueError( + 'Required property \'href\' not present in ResourceGroupReference JSON') return cls(**args) @classmethod @@ -1785,6 +1984,7 @@ def __ne__(self, other: 'ResourceGroupReference') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other + class RouteReport(): """ route report. @@ -1837,25 +2037,32 @@ def from_dict(cls, _dict: Dict) -> 'RouteReport': """Initialize a RouteReport object from a json dictionary.""" args = {} if 'connections' in _dict: - args['connections'] = [RouteReportConnection.from_dict(x) for x in _dict.get('connections')] + args['connections'] = [RouteReportConnection.from_dict( + x) for x in _dict.get('connections')] else: - raise ValueError('Required property \'connections\' not present in RouteReport JSON') + raise ValueError( + 'Required property \'connections\' not present in RouteReport 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 RouteReport JSON') + raise ValueError( + 'Required property \'created_at\' not present in RouteReport JSON') if 'id' in _dict: args['id'] = _dict.get('id') else: - raise ValueError('Required property \'id\' not present in RouteReport JSON') + raise ValueError( + 'Required property \'id\' not present in RouteReport JSON') if 'overlapping_routes' in _dict: - args['overlapping_routes'] = [RouteReportOverlappingRouteGroup.from_dict(x) for x in _dict.get('overlapping_routes')] + args['overlapping_routes'] = [RouteReportOverlappingRouteGroup.from_dict( + x) for x in _dict.get('overlapping_routes')] else: - raise ValueError('Required property \'overlapping_routes\' not present in RouteReport JSON') + raise ValueError( + 'Required property \'overlapping_routes\' not present in RouteReport JSON') if 'status' in _dict: args['status'] = _dict.get('status') else: - raise ValueError('Required property \'status\' not present in RouteReport JSON') + raise ValueError( + 'Required property \'status\' not present in RouteReport JSON') if 'updated_at' in _dict: args['updated_at'] = string_to_datetime(_dict.get('updated_at')) return cls(**args) @@ -1875,7 +2082,8 @@ def to_dict(self) -> Dict: if hasattr(self, 'id') and self.id is not None: _dict['id'] = self.id if hasattr(self, 'overlapping_routes') and self.overlapping_routes is not None: - _dict['overlapping_routes'] = [x.to_dict() for x in self.overlapping_routes] + _dict['overlapping_routes'] = [x.to_dict() + for x in self.overlapping_routes] 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: @@ -1930,9 +2138,11 @@ def from_dict(cls, _dict: Dict) -> 'RouteReportCollection': """Initialize a RouteReportCollection object from a json dictionary.""" args = {} if 'route_reports' in _dict: - args['route_reports'] = [RouteReport.from_dict(x) for x in _dict.get('route_reports')] + args['route_reports'] = [RouteReport.from_dict( + x) for x in _dict.get('route_reports')] else: - raise ValueError('Required property \'route_reports\' not present in RouteReportCollection JSON') + raise ValueError( + 'Required property \'route_reports\' not present in RouteReportCollection JSON') return cls(**args) @classmethod @@ -1965,6 +2175,7 @@ def __ne__(self, other: 'RouteReportCollection') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other + class RouteReportConnection(): """ route report connection. @@ -2007,13 +2218,15 @@ def from_dict(cls, _dict: Dict) -> 'RouteReportConnection': """Initialize a RouteReportConnection object from a json dictionary.""" args = {} if 'bgps' in _dict: - args['bgps'] = [RouteReportConnectionBgp.from_dict(x) for x in _dict.get('bgps')] + args['bgps'] = [RouteReportConnectionBgp.from_dict( + x) for x in _dict.get('bgps')] if 'id' in _dict: args['id'] = _dict.get('id') if 'name' in _dict: args['name'] = _dict.get('name') if 'routes' in _dict: - args['routes'] = [RouteReportConnectionRoute.from_dict(x) for x in _dict.get('routes')] + args['routes'] = [RouteReportConnectionRoute.from_dict( + x) for x in _dict.get('routes')] if 'type' in _dict: args['type'] = _dict.get('type') return cls(**args) @@ -2056,6 +2269,7 @@ def __ne__(self, other: 'RouteReportConnection') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other + class RouteReportConnectionBgp(): """ connection bgp details. @@ -2136,6 +2350,7 @@ def __ne__(self, other: 'RouteReportConnectionBgp') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other + class RouteReportConnectionRoute(): """ connection used route. @@ -2191,6 +2406,7 @@ def __ne__(self, other: 'RouteReportConnectionRoute') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other + class RouteReportOverlappingRoute(): """ overlapping route details. @@ -2254,6 +2470,7 @@ def __ne__(self, other: 'RouteReportOverlappingRoute') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other + class RouteReportOverlappingRouteGroup(): """ Collection of overlapping route. @@ -2278,7 +2495,8 @@ def from_dict(cls, _dict: Dict) -> 'RouteReportOverlappingRouteGroup': """Initialize a RouteReportOverlappingRouteGroup object from a json dictionary.""" args = {} if 'routes' in _dict: - args['routes'] = [RouteReportOverlappingRoute.from_dict(x) for x in _dict.get('routes')] + args['routes'] = [RouteReportOverlappingRoute.from_dict( + x) for x in _dict.get('routes')] return cls(**args) @classmethod @@ -2311,6 +2529,7 @@ def __ne__(self, other: 'RouteReportOverlappingRouteGroup') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other + class TSCollection(): """ A list of Transit Gateway locations. @@ -2333,9 +2552,11 @@ def from_dict(cls, _dict: Dict) -> 'TSCollection': """Initialize a TSCollection object from a json dictionary.""" args = {} if 'locations' in _dict: - args['locations'] = [TSLocationBasic.from_dict(x) for x in _dict.get('locations')] + args['locations'] = [TSLocationBasic.from_dict( + x) for x in _dict.get('locations')] else: - raise ValueError('Required property \'locations\' not present in TSCollection JSON') + raise ValueError( + 'Required property \'locations\' not present in TSCollection JSON') return cls(**args) @classmethod @@ -2368,12 +2589,15 @@ def __ne__(self, other: 'TSCollection') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other + class TSLocalLocation(): """ Details of a local connection location. :attr str display_name: (optional) A descriptive display name for the location. :attr str name: (optional) The name of the location. + :attr List[str] supported_connection_types: (optional) Array of supported + connection types. :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 @@ -2384,6 +2608,7 @@ def __init__(self, *, display_name: str = None, name: str = None, + supported_connection_types: List[str] = None, type: str = None) -> None: """ Initialize a TSLocalLocation object. @@ -2391,6 +2616,8 @@ def __init__(self, :param str display_name: (optional) A descriptive display name for the location. :param str name: (optional) The name of the location. + :param List[str] supported_connection_types: (optional) Array of supported + connection types. :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 @@ -2398,6 +2625,7 @@ def __init__(self, """ self.display_name = display_name self.name = name + self.supported_connection_types = supported_connection_types self.type = type @classmethod @@ -2408,6 +2636,9 @@ def from_dict(cls, _dict: Dict) -> 'TSLocalLocation': args['display_name'] = _dict.get('display_name') if 'name' in _dict: args['name'] = _dict.get('name') + if 'supported_connection_types' in _dict: + args['supported_connection_types'] = _dict.get( + 'supported_connection_types') if 'type' in _dict: args['type'] = _dict.get('type') return cls(**args) @@ -2424,6 +2655,8 @@ def to_dict(self) -> Dict: _dict['display_name'] = self.display_name if hasattr(self, 'name') and self.name is not None: _dict['name'] = self.name + if hasattr(self, 'supported_connection_types') and self.supported_connection_types is not None: + _dict['supported_connection_types'] = self.supported_connection_types if hasattr(self, 'type') and self.type is not None: _dict['type'] = self.type return _dict @@ -2454,6 +2687,7 @@ class TypeEnum(str, Enum): unexpected values. """ REGION = 'region' + DC = 'dc' class TSLocation(): @@ -2497,19 +2731,24 @@ def from_dict(cls, _dict: Dict) -> 'TSLocation': if 'billing_location' in _dict: args['billing_location'] = _dict.get('billing_location') else: - raise ValueError('Required property \'billing_location\' not present in TSLocation JSON') + raise ValueError( + 'Required property \'billing_location\' not present in TSLocation JSON') if 'name' in _dict: args['name'] = _dict.get('name') else: - raise ValueError('Required property \'name\' not present in TSLocation JSON') + raise ValueError( + 'Required property \'name\' not present in TSLocation JSON') if 'type' in _dict: args['type'] = _dict.get('type') else: - raise ValueError('Required property \'type\' not present in TSLocation JSON') + raise ValueError( + 'Required property \'type\' not present in TSLocation JSON') if 'local_connection_locations' in _dict: - args['local_connection_locations'] = [TSLocalLocation.from_dict(x) for x in _dict.get('local_connection_locations')] + args['local_connection_locations'] = [TSLocalLocation.from_dict( + x) for x in _dict.get('local_connection_locations')] else: - raise ValueError('Required property \'local_connection_locations\' not present in TSLocation JSON') + raise ValueError( + 'Required property \'local_connection_locations\' not present in TSLocation JSON') return cls(**args) @classmethod @@ -2527,7 +2766,8 @@ def to_dict(self) -> Dict: if hasattr(self, 'type') and self.type is not None: _dict['type'] = self.type if hasattr(self, 'local_connection_locations') and self.local_connection_locations is not None: - _dict['local_connection_locations'] = [x.to_dict() for x in self.local_connection_locations] + _dict['local_connection_locations'] = [x.to_dict() + for x in self.local_connection_locations] return _dict def _to_dict(self): @@ -2548,6 +2788,7 @@ def __ne__(self, other: 'TSLocation') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other + class TSLocationBasic(): """ Details of a Transit Gateway location. @@ -2583,15 +2824,18 @@ def from_dict(cls, _dict: Dict) -> 'TSLocationBasic': if 'billing_location' in _dict: args['billing_location'] = _dict.get('billing_location') else: - raise ValueError('Required property \'billing_location\' not present in TSLocationBasic JSON') + raise ValueError( + 'Required property \'billing_location\' not present in TSLocationBasic JSON') if 'name' in _dict: args['name'] = _dict.get('name') else: - raise ValueError('Required property \'name\' not present in TSLocationBasic JSON') + raise ValueError( + 'Required property \'name\' not present in TSLocationBasic JSON') if 'type' in _dict: args['type'] = _dict.get('type') else: - raise ValueError('Required property \'type\' not present in TSLocationBasic JSON') + raise ValueError( + 'Required property \'type\' not present in TSLocationBasic JSON') return cls(**args) @classmethod @@ -2628,6 +2872,7 @@ def __ne__(self, other: 'TSLocationBasic') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other + class TransitConnection(): """ Transit gateway connection. @@ -2653,9 +2898,10 @@ class TransitConnection(): 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' and - 'directlink'. For network types 'vpc' and 'directlink' it should be the CRN of - the target vpc / gateway respectively. + connection. This field is required for some types, such as 'vpc', + 'power_virtual_server' and 'directlink'. For network types + 'vpc','power_virtual_server' and 'directlink' this is the CRN of the VPC / + PowerVS / Direct Link gateway respectively. :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. @@ -2746,9 +2992,10 @@ def __init__(self, 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' and - 'directlink'. For network types 'vpc' and 'directlink' it should be the CRN - of the target vpc / gateway respectively. + this connection. This field is required for some types, such as 'vpc', + 'power_virtual_server' and 'directlink'. For network types + 'vpc','power_virtual_server' and 'directlink' this is the CRN of the VPC / + PowerVS / Direct Link gateway respectively. :param List[TransitGatewayConnectionPrefixFilterReference] prefix_filters: (optional) Array of prefix route filters for a transit gateway connection. This is order dependent with those first in the array being applied first, @@ -2801,11 +3048,13 @@ def from_dict(cls, _dict: Dict) -> 'TransitConnection': 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') + 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 TransitConnection 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: @@ -2817,7 +3066,8 @@ def from_dict(cls, _dict: Dict) -> 'TransitConnection': if 'name' in _dict: args['name'] = _dict.get('name') else: - raise ValueError('Required property \'name\' not present in TransitConnection JSON') + 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: @@ -2825,13 +3075,17 @@ def from_dict(cls, _dict: Dict) -> 'TransitConnection': if 'network_type' in _dict: args['network_type'] = _dict.get('network_type') else: - raise ValueError('Required property \'network_type\' not present in TransitConnection JSON') + raise ValueError( + 'Required property \'network_type\' not present in TransitConnection JSON') if 'prefix_filters' in _dict: - args['prefix_filters'] = [TransitGatewayConnectionPrefixFilterReference.from_dict(x) for x in _dict.get('prefix_filters')] + args['prefix_filters'] = [TransitGatewayConnectionPrefixFilterReference.from_dict( + x) for x in _dict.get('prefix_filters')] if 'prefix_filters_default' in _dict: - args['prefix_filters_default'] = _dict.get('prefix_filters_default') + args['prefix_filters_default'] = _dict.get( + 'prefix_filters_default') else: - raise ValueError('Required property \'prefix_filters_default\' not present in TransitConnection JSON') + raise ValueError( + 'Required property \'prefix_filters_default\' 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: @@ -2843,11 +3097,14 @@ def from_dict(cls, _dict: Dict) -> 'TransitConnection': if 'status' in _dict: args['status'] = _dict.get('status') else: - raise ValueError('Required property \'status\' not present in TransitConnection 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')) + args['transit_gateway'] = TransitGatewayReference.from_dict( + _dict.get('transit_gateway')) else: - raise ValueError('Required property \'transit_gateway\' not present in TransitConnection JSON') + 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: @@ -2885,7 +3142,8 @@ def to_dict(self) -> Dict: if hasattr(self, 'network_type') and self.network_type is not None: _dict['network_type'] = self.network_type if hasattr(self, 'prefix_filters') and self.prefix_filters is not None: - _dict['prefix_filters'] = [x.to_dict() for x in self.prefix_filters] + _dict['prefix_filters'] = [x.to_dict() + for x in self.prefix_filters] if hasattr(self, 'prefix_filters_default') and self.prefix_filters_default is not None: _dict['prefix_filters_default'] = self.prefix_filters_default if hasattr(self, 'remote_bgp_asn') and self.remote_bgp_asn is not None: @@ -2933,8 +3191,9 @@ class NetworkTypeEnum(str, Enum): CLASSIC = 'classic' DIRECTLINK = 'directlink' GRE_TUNNEL = 'gre_tunnel' + UNBOUND_GRE_TUNNEL = 'unbound_gre_tunnel' VPC = 'vpc' - + POWER_VIRTUAL_SERVER = 'power_virtual_server' class PrefixFiltersDefaultEnum(str, Enum): """ @@ -2944,7 +3203,6 @@ class PrefixFiltersDefaultEnum(str, Enum): PERMIT = 'permit' DENY = 'deny' - class RequestStatusEnum(str, Enum): """ Only visible for cross account connections, this field represents the status of a @@ -2958,7 +3216,6 @@ class RequestStatusEnum(str, Enum): EXPIRED = 'expired' DETACHED = 'detached' - class StatusEnum(str, Enum): """ Connection state. The list of enumerated values for this property may expand in @@ -2970,6 +3227,8 @@ class StatusEnum(str, Enum): DELETING = 'deleting' DETACHING = 'detaching' DETACHED = 'detached' + SUSPENDING = 'suspending' + SUSPENDED = 'suspended' class TransitConnectionCollection(): @@ -3014,19 +3273,25 @@ def from_dict(cls, _dict: Dict) -> 'TransitConnectionCollection': """Initialize a TransitConnectionCollection object from a json dictionary.""" args = {} if 'connections' in _dict: - args['connections'] = [TransitConnection.from_dict(x) for x in _dict.get('connections')] + args['connections'] = [TransitConnection.from_dict( + x) for x in _dict.get('connections')] else: - raise ValueError('Required property \'connections\' not present in TransitConnectionCollection JSON') + raise ValueError( + 'Required property \'connections\' not present in TransitConnectionCollection JSON') if 'first' in _dict: - args['first'] = TransitConnectionCollectionFirst.from_dict(_dict.get('first')) + args['first'] = TransitConnectionCollectionFirst.from_dict( + _dict.get('first')) else: - raise ValueError('Required property \'first\' not present in TransitConnectionCollection JSON') + 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') + raise ValueError( + 'Required property \'limit\' not present in TransitConnectionCollection JSON') if 'next' in _dict: - args['next'] = TransitConnectionCollectionNext.from_dict(_dict.get('next')) + args['next'] = TransitConnectionCollectionNext.from_dict( + _dict.get('next')) return cls(**args) @classmethod @@ -3065,6 +3330,7 @@ def __ne__(self, other: 'TransitConnectionCollection') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other + class TransitConnectionCollectionFirst(): """ A reference to the first page of resources. @@ -3088,7 +3354,8 @@ def from_dict(cls, _dict: Dict) -> 'TransitConnectionCollectionFirst': if 'href' in _dict: args['href'] = _dict.get('href') else: - raise ValueError('Required property \'href\' not present in TransitConnectionCollectionFirst JSON') + raise ValueError( + 'Required property \'href\' not present in TransitConnectionCollectionFirst JSON') return cls(**args) @classmethod @@ -3121,6 +3388,7 @@ def __ne__(self, other: 'TransitConnectionCollectionFirst') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other + class TransitConnectionCollectionNext(): """ A reference to the next page of resources; this reference is included for all pages @@ -3187,6 +3455,7 @@ 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. @@ -3256,33 +3525,41 @@ def from_dict(cls, _dict: Dict) -> 'TransitGateway': if 'id' in _dict: args['id'] = _dict.get('id') else: - raise ValueError('Required property \'id\' not present in TransitGateway JSON') + 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 \'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') + 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') + 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') + 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') + 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')) + 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') + 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) @@ -3343,6 +3620,8 @@ class StatusEnum(str, Enum): FAILED = 'failed' PENDING = 'pending' DELETING = 'deleting' + SUSPENDING = 'suspending' + SUSPENDED = 'suspended' class TransitGatewayCollection(): @@ -3386,19 +3665,25 @@ 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')) + args['first'] = TransitGatewayCollectionFirst.from_dict( + _dict.get('first')) else: - raise ValueError('Required property \'first\' not present in TransitGatewayCollection JSON') + 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') + raise ValueError( + 'Required property \'limit\' not present in TransitGatewayCollection JSON') if 'next' in _dict: - args['next'] = TransitGatewayCollectionNext.from_dict(_dict.get('next')) + 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')] + 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') + raise ValueError( + 'Required property \'transit_gateways\' not present in TransitGatewayCollection JSON') return cls(**args) @classmethod @@ -3416,7 +3701,8 @@ def to_dict(self) -> Dict: 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] + _dict['transit_gateways'] = [x.to_dict() + for x in self.transit_gateways] return _dict def _to_dict(self): @@ -3437,6 +3723,7 @@ 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. @@ -3460,7 +3747,8 @@ def from_dict(cls, _dict: Dict) -> 'TransitGatewayCollectionFirst': if 'href' in _dict: args['href'] = _dict.get('href') else: - raise ValueError('Required property \'href\' not present in TransitGatewayCollectionFirst JSON') + raise ValueError( + 'Required property \'href\' not present in TransitGatewayCollectionFirst JSON') return cls(**args) @classmethod @@ -3493,6 +3781,7 @@ 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 @@ -3521,11 +3810,13 @@ def from_dict(cls, _dict: Dict) -> 'TransitGatewayCollectionNext': if 'href' in _dict: args['href'] = _dict.get('href') else: - raise ValueError('Required property \'href\' not present in TransitGatewayCollectionNext JSON') + 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') + raise ValueError( + 'Required property \'start\' not present in TransitGatewayCollectionNext JSON') return cls(**args) @classmethod @@ -3560,6 +3851,7 @@ 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. @@ -3583,9 +3875,11 @@ 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')] + args['connections'] = [TransitGatewayConnectionCust.from_dict( + x) for x in _dict.get('connections')] else: - raise ValueError('Required property \'connections\' not present in TransitGatewayConnectionCollection JSON') + raise ValueError( + 'Required property \'connections\' not present in TransitGatewayConnectionCollection JSON') return cls(**args) @classmethod @@ -3618,15 +3912,19 @@ 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 base_network_type: (optional) The type of network the GRE tunnel is + targeting. :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' and - 'directlink'. For network types 'vpc' and 'directlink' it should be the CRN of - the target vpc / gateway respectively. + connection. This field is required for some types, such as 'vpc', + 'power_virtual_server' and 'directlink'. For network types + 'vpc','power_virtual_server' and 'directlink' this is the CRN of the VPC / + PowerVS / Direct Link gateway respectively. :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. @@ -3639,13 +3937,13 @@ class TransitGatewayConnectionCust(): 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. + applies to network type 'gre_tunnel' and 'unbound_gre_tunnel' connections. :attr str local_gateway_ip: (optional) Local gateway IP address. This field - only applies to network type 'gre_tunnel' connections. + only applies to network type 'gre_tunnel' and 'unbound_gre_tunnel' connections. :attr str local_tunnel_ip: (optional) Local tunnel IP address. This field only - applies to network type 'gre_tunnel' connections. + applies to network type 'gre_tunnel' and 'unbound_gre_tunnel' connections. :attr int mtu: (optional) GRE tunnel MTU. This field only applies to network - type 'gre_tunnel' connections. + type 'gre_tunnel' and 'unbound_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. @@ -3656,11 +3954,11 @@ class TransitGatewayConnectionCust(): :attr str prefix_filters_default: Default setting of permit or deny which applies to any routes that don't match a specified filter. :attr int remote_bgp_asn: (optional) Remote network BGP ASN. This field only - applies to network type 'gre_tunnel' connections. + applies to network type 'gre_tunnel' and 'unbound_gre_tunnel' connections. :attr str remote_gateway_ip: (optional) Remote gateway IP address. This field - only applies to network type 'gre_tunnel' connections. + only applies to network type 'gre_tunnel' and 'unbound_gre_tunnel' connections. :attr str remote_tunnel_ip: (optional) Remote tunnel IP address. This field - only applies to network type 'gre_tunnel' connections. + only applies to network type 'gre_tunnel' and 'unbound_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 @@ -3671,7 +3969,8 @@ class TransitGatewayConnectionCust(): :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. + This field only applies to network type 'gre_tunnel' and 'unbound_gre_tunnel' + connections. """ def __init__(self, @@ -3681,6 +3980,7 @@ def __init__(self, created_at: datetime, prefix_filters_default: str, *, + base_network_type: str = None, network_id: str = None, base_connection_id: str = None, local_bgp_asn: int = None, @@ -3709,10 +4009,13 @@ def __init__(self, created. :param str prefix_filters_default: Default setting of permit or deny which applies to any routes that don't match a specified filter. + :param str base_network_type: (optional) The type of network the GRE tunnel + is targeting. :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' and - 'directlink'. For network types 'vpc' and 'directlink' it should be the CRN - of the target vpc / gateway respectively. + this connection. This field is required for some types, such as 'vpc', + 'power_virtual_server' and 'directlink'. For network types + 'vpc','power_virtual_server' and 'directlink' this is the CRN of the VPC / + PowerVS / Direct Link gateway respectively. :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 @@ -3721,13 +4024,16 @@ def __init__(self, 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. + only applies to network type 'gre_tunnel' and 'unbound_gre_tunnel' + connections. :param str local_gateway_ip: (optional) Local gateway IP address. This - field only applies to network type 'gre_tunnel' connections. + field only applies to network type 'gre_tunnel' and 'unbound_gre_tunnel' + connections. :param str local_tunnel_ip: (optional) Local tunnel IP address. This field - only applies to network type 'gre_tunnel' connections. + only applies to network type 'gre_tunnel' and 'unbound_gre_tunnel' + connections. :param int mtu: (optional) GRE tunnel MTU. This field only applies to - network type 'gre_tunnel' connections. + network type 'gre_tunnel' and 'unbound_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. @@ -3737,11 +4043,14 @@ def __init__(self, and those at the end of the array is applied last, or just before the default. :param int remote_bgp_asn: (optional) Remote network BGP ASN. This field - only applies to network type 'gre_tunnel' connections. + only applies to network type 'gre_tunnel' and 'unbound_gre_tunnel' + connections. :param str remote_gateway_ip: (optional) Remote gateway IP address. This - field only applies to network type 'gre_tunnel' connections. + field only applies to network type 'gre_tunnel' and 'unbound_gre_tunnel' + connections. :param str remote_tunnel_ip: (optional) Remote tunnel IP address. This - field only applies to network type 'gre_tunnel' connections. + field only applies to network type 'gre_tunnel' and 'unbound_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 @@ -3753,8 +4062,10 @@ def __init__(self, :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. + tunnel. This field only applies to network type 'gre_tunnel' and + 'unbound_gre_tunnel' connections. """ + self.base_network_type = base_network_type self.name = name self.network_id = network_id self.network_type = network_type @@ -3780,26 +4091,32 @@ def __init__(self, def from_dict(cls, _dict: Dict) -> 'TransitGatewayConnectionCust': """Initialize a TransitGatewayConnectionCust object from a json dictionary.""" args = {} + if 'base_network_type' in _dict: + args['base_network_type'] = _dict.get('base_network_type') if 'name' in _dict: args['name'] = _dict.get('name') else: - raise ValueError('Required property \'name\' not present in TransitGatewayConnectionCust JSON') + 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') + raise ValueError( + 'Required property \'network_type\' not present in TransitGatewayConnectionCust JSON') if 'id' in _dict: args['id'] = _dict.get('id') else: - raise ValueError('Required property \'id\' not present in TransitGatewayConnectionCust JSON') + 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') + 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: @@ -3811,11 +4128,14 @@ def from_dict(cls, _dict: Dict) -> 'TransitGatewayConnectionCust': if 'network_account_id' in _dict: args['network_account_id'] = _dict.get('network_account_id') if 'prefix_filters' in _dict: - args['prefix_filters'] = [TransitGatewayConnectionPrefixFilterReference.from_dict(x) for x in _dict.get('prefix_filters')] + args['prefix_filters'] = [TransitGatewayConnectionPrefixFilterReference.from_dict( + x) for x in _dict.get('prefix_filters')] if 'prefix_filters_default' in _dict: - args['prefix_filters_default'] = _dict.get('prefix_filters_default') + args['prefix_filters_default'] = _dict.get( + 'prefix_filters_default') else: - raise ValueError('Required property \'prefix_filters_default\' not present in TransitGatewayConnectionCust JSON') + raise ValueError( + 'Required property \'prefix_filters_default\' not present in TransitGatewayConnectionCust JSON') if 'remote_bgp_asn' in _dict: args['remote_bgp_asn'] = _dict.get('remote_bgp_asn') if 'remote_gateway_ip' in _dict: @@ -3829,7 +4149,8 @@ def from_dict(cls, _dict: Dict) -> 'TransitGatewayConnectionCust': 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')) + args['zone'] = TransitGatewayConnectionCustZone.from_dict( + _dict.get('zone')) return cls(**args) @classmethod @@ -3840,6 +4161,8 @@ def _from_dict(cls, _dict): def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} + if hasattr(self, 'base_network_type') and self.base_network_type is not None: + _dict['base_network_type'] = self.base_network_type if hasattr(self, 'name') and self.name is not None: _dict['name'] = self.name if hasattr(self, 'network_id') and self.network_id is not None: @@ -3863,7 +4186,8 @@ def to_dict(self) -> 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, 'prefix_filters') and self.prefix_filters is not None: - _dict['prefix_filters'] = [x.to_dict() for x in self.prefix_filters] + _dict['prefix_filters'] = [x.to_dict() + for x in self.prefix_filters] if hasattr(self, 'prefix_filters_default') and self.prefix_filters_default is not None: _dict['prefix_filters_default'] = self.prefix_filters_default if hasattr(self, 'remote_bgp_asn') and self.remote_bgp_asn is not None: @@ -3900,6 +4224,12 @@ def __ne__(self, other: 'TransitGatewayConnectionCust') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other + class BaseNetworkTypeEnum(str, Enum): + """ + The type of network the GRE tunnel is targeting. + """ + CLASSIC = 'classic' + class NetworkTypeEnum(str, Enum): """ Defines what type of network is connected via this connection. The list of @@ -3909,8 +4239,9 @@ class NetworkTypeEnum(str, Enum): CLASSIC = 'classic' DIRECTLINK = 'directlink' GRE_TUNNEL = 'gre_tunnel' + UNBOUND_GRE_TUNNEL = 'unbound_gre_tunnel' VPC = 'vpc' - + POWER_VIRTUAL_SERVER = 'power_virtual_server' class PrefixFiltersDefaultEnum(str, Enum): """ @@ -3920,7 +4251,6 @@ class PrefixFiltersDefaultEnum(str, Enum): PERMIT = 'permit' DENY = 'deny' - class RequestStatusEnum(str, Enum): """ Only visible for cross account connections, this field represents the status of a @@ -3934,7 +4264,6 @@ class RequestStatusEnum(str, Enum): EXPIRED = 'expired' DETACHED = 'detached' - class StatusEnum(str, Enum): """ Connection's current configuration state. The list of enumerated values for this @@ -3947,12 +4276,14 @@ class StatusEnum(str, Enum): DELETING = 'deleting' DETACHING = 'detaching' DETACHED = 'detached' + SUSPENDING = 'suspending' + SUSPENDED = 'suspended' class TransitGatewayConnectionCustZone(): """ - Location of GRE tunnel. This field only applies to network type 'gre_tunnel' - connections. + Location of GRE tunnel. This field only applies to network type 'gre_tunnel' and + 'unbound_gre_tunnel' connections. :attr str name: Availability zone name. """ @@ -3973,7 +4304,8 @@ def from_dict(cls, _dict: Dict) -> 'TransitGatewayConnectionCustZone': if 'name' in _dict: args['name'] = _dict.get('name') else: - raise ValueError('Required property \'name\' not present in TransitGatewayConnectionCustZone JSON') + raise ValueError( + 'Required property \'name\' not present in TransitGatewayConnectionCustZone JSON') return cls(**args) @classmethod @@ -4006,6 +4338,7 @@ def __ne__(self, other: 'TransitGatewayConnectionCustZone') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other + class TransitGatewayConnectionPrefixFilter(): """ A prefix filter for a Transit Gateway connection. @@ -4042,7 +4375,8 @@ def from_dict(cls, _dict: Dict) -> 'TransitGatewayConnectionPrefixFilter': if 'action' in _dict: args['action'] = _dict.get('action') else: - raise ValueError('Required property \'action\' not present in TransitGatewayConnectionPrefixFilter JSON') + raise ValueError( + 'Required property \'action\' not present in TransitGatewayConnectionPrefixFilter JSON') if 'ge' in _dict: args['ge'] = _dict.get('ge') if 'le' in _dict: @@ -4050,7 +4384,8 @@ def from_dict(cls, _dict: Dict) -> 'TransitGatewayConnectionPrefixFilter': if 'prefix' in _dict: args['prefix'] = _dict.get('prefix') else: - raise ValueError('Required property \'prefix\' not present in TransitGatewayConnectionPrefixFilter JSON') + raise ValueError( + 'Required property \'prefix\' not present in TransitGatewayConnectionPrefixFilter JSON') return cls(**args) @classmethod @@ -4187,25 +4522,29 @@ def from_dict(cls, _dict: Dict) -> 'TransitGatewayConnectionPrefixFilterReferenc if 'action' in _dict: args['action'] = _dict.get('action') else: - raise ValueError('Required property \'action\' not present in TransitGatewayConnectionPrefixFilterReference JSON') + raise ValueError( + 'Required property \'action\' not present in TransitGatewayConnectionPrefixFilterReference JSON') if 'before' in _dict: args['before'] = _dict.get('before') 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 TransitGatewayConnectionPrefixFilterReference JSON') + raise ValueError( + 'Required property \'created_at\' not present in TransitGatewayConnectionPrefixFilterReference JSON') if 'ge' in _dict: args['ge'] = _dict.get('ge') if 'id' in _dict: args['id'] = _dict.get('id') else: - raise ValueError('Required property \'id\' not present in TransitGatewayConnectionPrefixFilterReference JSON') + raise ValueError( + 'Required property \'id\' not present in TransitGatewayConnectionPrefixFilterReference JSON') if 'le' in _dict: args['le'] = _dict.get('le') if 'prefix' in _dict: args['prefix'] = _dict.get('prefix') else: - raise ValueError('Required property \'prefix\' not present in TransitGatewayConnectionPrefixFilterReference JSON') + raise ValueError( + 'Required property \'prefix\' not present in TransitGatewayConnectionPrefixFilterReference JSON') if 'updated_at' in _dict: args['updated_at'] = string_to_datetime(_dict.get('updated_at')) return cls(**args) @@ -4293,15 +4632,18 @@ def from_dict(cls, _dict: Dict) -> 'TransitGatewayReference': if 'crn' in _dict: args['crn'] = _dict.get('crn') else: - raise ValueError('Required property \'crn\' not present in TransitGatewayReference JSON') + 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') + 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') + raise ValueError( + 'Required property \'name\' not present in TransitGatewayReference JSON') return cls(**args) @classmethod @@ -4338,6 +4680,7 @@ def __ne__(self, other: 'TransitGatewayReference') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other + class ZoneIdentity(): """ ZoneIdentity. @@ -4350,9 +4693,10 @@ def __init__(self) -> None: """ msg = "Cannot instantiate base class. Instead, instantiate one of the defined subclasses: {0}".format( - ", ".join(['ZoneIdentityByName'])) + ", ".join(['ZoneIdentityByName'])) raise Exception(msg) + class ZoneReference(): """ Availability zone reference. @@ -4376,7 +4720,8 @@ def from_dict(cls, _dict: Dict) -> 'ZoneReference': if 'name' in _dict: args['name'] = _dict.get('name') else: - raise ValueError('Required property \'name\' not present in ZoneReference JSON') + raise ValueError( + 'Required property \'name\' not present in ZoneReference JSON') return cls(**args) @classmethod @@ -4409,6 +4754,7 @@ 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. diff --git a/test/integration/test_transit_gateway_apis_v1.py b/test/integration/test_transit_gateway_apis_v1.py index b362e69..142405a 100644 --- a/test/integration/test_transit_gateway_apis_v1.py +++ b/test/integration/test_transit_gateway_apis_v1.py @@ -74,7 +74,7 @@ def _clean_tg_records(self): for connection in connections: if ("SDK-PY" in connection["name"]) and ( "delet" not in connection["status"]): - if connection["network_type"] == "gre_tunnel": + if connection["network_type"] == "gre_tunnel" or connection["network_type"] == "unbound_gre_tunnel": self.delete_resource_test(gateway_id=gateway_id, conn_id=connection["id"], rr_id="", pf_id="") else: @@ -380,6 +380,38 @@ def test_03_transit_gateway_connection_actions(self): assert self.is_resource_available(gateway_id=gateway_id, conn_id=gre_conn_id, rr_id="") + ############################################# + # Success: POST Transit Unbound GRE Connection: + ############################################# + zone = {}; zone['name'] = 'us-south-1' + unbound_gre_name = "unbound-GRE_" + time.strftime("%H%M%S") + unbound_gre_name = os.getenv("TG_SERVICES_CONN_NAME") + unbound_gre_name + + response = self.tg.create_transit_gateway_connection( + zone=zone, + name=unbound_gre_name, + network_type="unbound_gre_tunnel", + transit_gateway_id=gateway_id, + local_gateway_ip="192.168.100.1", + local_tunnel_ip="192.168.101.1", + remote_gateway_ip="10.242.63.12", + remote_tunnel_ip="192.168.101.2", + base_connection_id=classic_conn_id) + + assert response is not None + assert response.get_status_code() == 201 + assert response.get_result().get("id") != "" + assert response.get_result().get("zone") == zone + assert response.get_result().get("name") == unbound_gre_name + assert response.get_result().get("network_type") == "unbound_gre_tunnel" + assert response.get_result().get("base_connection_id") == classic_conn_id + assert response.get_result().get("base_network_type") == "classic" + + # wait until the Connection status = attached + unbound_gre_conn_id = response.get_result().get("id") + assert self.is_resource_available(gateway_id=gateway_id, + conn_id=unbound_gre_conn_id, rr_id="") + ############################################# # Success: GET Transit CLASSIC Connection: ############################################# @@ -430,6 +462,20 @@ def test_03_transit_gateway_connection_actions(self): assert response.get_result().get("name") == gre_name assert response.get_result().get("id") == gre_conn_id assert response.get_result().get("network_type") == "gre_tunnel" + assert response.get_result().get("base_connection_id") == classic_conn_id + + ############################################# + # Success: GET Transit Unbound GRE Connection: + ############################################# + response = self.tg.get_transit_gateway_connection( + transit_gateway_id=gateway_id, id=unbound_gre_conn_id) + + assert response is not None + assert response.get_status_code() == 200 + assert response.get_result().get("zone") == zone + assert response.get_result().get("name") == unbound_gre_name + assert response.get_result().get("id") == unbound_gre_conn_id + assert response.get_result().get("network_type") == "unbound_gre_tunnel" assert response.get_result().get("base_connection_id") == classic_conn_id ############################################# @@ -488,6 +534,20 @@ def test_03_transit_gateway_connection_actions(self): assert response.get_result().get("id") == gre_conn_id assert response.get_result().get("name") == gre_name + ################################################# + # Success: UPDATE Transit Unbound GRE Connection: + ################################################# + gre_name = "UPDATED_" + unbound_gre_name + response = self.tg.update_transit_gateway_connection( + transit_gateway_id=gateway_id, + name=unbound_gre_name, + id=unbound_gre_conn_id) + + assert response is not None + assert response.get_status_code() == 200 + assert response.get_result().get("id") == unbound_gre_conn_id + assert response.get_result().get("name") == unbound_gre_name + ############################################# # Success: LIST Transit Connections: ############################################# @@ -498,7 +558,7 @@ def test_03_transit_gateway_connection_actions(self): assert response.get_status_code() == 200 assert len(response.get_result().get("connections")) > 0 - gre_found = dl_found = vpc_found = classic_found = False + gre_found = dl_found = vpc_found = classic_found = unbound_gre_found = False conns = response.get_result().get("connections") for conn in conns: if conn["network_type"] == "directlink": @@ -519,10 +579,16 @@ def test_03_transit_gateway_connection_actions(self): elif conn["network_type"] == "classic": assert conn["name"] == classic_name assert conn["id"] == classic_conn_id - classic_found = True + classic_found = True + + elif conn["network_type"] == "unbound_gre_tunnel": + assert conn["name"] == unbound_gre_name + assert conn["id"] == unbound_gre_conn_id + unbound_gre_found = True assert dl_found assert gre_found + assert unbound_gre_found assert vpc_found assert classic_found @@ -633,6 +699,11 @@ def test_03_transit_gateway_connection_actions(self): assert conn["name"] == gre_name gre_found = True + elif conn["type"] == "unbound_gre_tunnel": + assert conn["id"] == gre_conn_id + assert conn["name"] == gre_name + unbound_gre_found = True + elif conn["type"] == "classic": assert conn["id"] == classic_conn_id assert conn["name"] == classic_name @@ -640,6 +711,7 @@ def test_03_transit_gateway_connection_actions(self): assert dl_found assert gre_found + assert unbound_gre_found assert vpc_found assert classic_found diff --git a/test/unit/test_transit_gateway_apis_v1.py b/test/unit/test_transit_gateway_apis_v1.py index 4c7c8a2..90d1c90 100644 --- a/test/unit/test_transit_gateway_apis_v1.py +++ b/test/unit/test_transit_gateway_apis_v1.py @@ -41,7 +41,7 @@ _service.set_service_url(_base_url) ############################################################################## -# Start of Service: TransitConnections +# Start of Service: TransitGateways ############################################################################## # region @@ -71,6 +71,7 @@ def test_new_instance_without_authenticator(self): with pytest.raises(ValueError, match='authenticator must be provided'): service = TransitGatewayApisV1.new_instance( version=version, + service_name='TEST_SERVICE_NOT_FOUND', ) def test_new_instance_without_required_params(self): @@ -88,9 +89,9 @@ def test_new_instance_required_param_none(self): service = TransitGatewayApisV1.new_instance( version=None, ) -class TestListConnections(): +class TestListTransitGateways(): """ - Test Class for list_connections + Test Class for list_transit_gateways """ def preprocess_url(self, request_url: str): @@ -105,13 +106,13 @@ def preprocess_url(self, request_url: str): return re.compile(request_url.rstrip('/') + '/+') @responses.activate - def test_list_connections_all_params(self): + def test_list_transit_gateways_all_params(self): """ - list_connections() + list_transit_gateways() """ # 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.000Z", "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", "prefix_filters": [{"action": "permit", "before": "1a15dcab-7e40-45e1-b7c5-bc690eaa9782", "created_at": "2019-01-01T12:00:00.000Z", "ge": 0, "id": "1a15dcab-7e30-45e1-b7c5-bc690eaa9865", "le": 32, "prefix": "192.168.100.0/24", "updated_at": "2019-01-01T12:00:00.000Z"}], "prefix_filters_default": "permit", "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.000Z", "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"}}' + 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.000Z", "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.000Z"}]}' responses.add(responses.GET, url, body=mock_response, @@ -121,13 +122,11 @@ def test_list_connections_all_params(self): # Set up parameter values limit = 1 start = 'testString' - network_id = 'testString' # Invoke method - response = _service.list_connections( + response = _service.list_transit_gateways( limit=limit, start=start, - network_id=network_id, headers={} ) @@ -139,25 +138,24 @@ def test_list_connections_all_params(self): query_string = urllib.parse.unquote_plus(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 - def test_list_connections_all_params_with_retries(self): - # Enable retries and run test_list_connections_all_params. + def test_list_transit_gateways_all_params_with_retries(self): + # Enable retries and run test_list_transit_gateways_all_params. _service.enable_retries() - self.test_list_connections_all_params() + self.test_list_transit_gateways_all_params() - # Disable retries and run test_list_connections_all_params. + # Disable retries and run test_list_transit_gateways_all_params. _service.disable_retries() - self.test_list_connections_all_params() + self.test_list_transit_gateways_all_params() @responses.activate - def test_list_connections_required_params(self): + def test_list_transit_gateways_required_params(self): """ - test_list_connections_required_params() + test_list_transit_gateways_required_params() """ # 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.000Z", "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", "prefix_filters": [{"action": "permit", "before": "1a15dcab-7e40-45e1-b7c5-bc690eaa9782", "created_at": "2019-01-01T12:00:00.000Z", "ge": 0, "id": "1a15dcab-7e30-45e1-b7c5-bc690eaa9865", "le": 32, "prefix": "192.168.100.0/24", "updated_at": "2019-01-01T12:00:00.000Z"}], "prefix_filters_default": "permit", "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.000Z", "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"}}' + 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.000Z", "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.000Z"}]}' responses.add(responses.GET, url, body=mock_response, @@ -165,30 +163,30 @@ def test_list_connections_required_params(self): status=200) # Invoke method - response = _service.list_connections() + response = _service.list_transit_gateways() # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 - def test_list_connections_required_params_with_retries(self): - # Enable retries and run test_list_connections_required_params. + def test_list_transit_gateways_required_params_with_retries(self): + # Enable retries and run test_list_transit_gateways_required_params. _service.enable_retries() - self.test_list_connections_required_params() + self.test_list_transit_gateways_required_params() - # Disable retries and run test_list_connections_required_params. + # Disable retries and run test_list_transit_gateways_required_params. _service.disable_retries() - self.test_list_connections_required_params() + self.test_list_transit_gateways_required_params() @responses.activate - def test_list_connections_value_error(self): + def test_list_transit_gateways_value_error(self): """ - test_list_connections_value_error() + test_list_transit_gateways_value_error() """ # 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.000Z", "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", "prefix_filters": [{"action": "permit", "before": "1a15dcab-7e40-45e1-b7c5-bc690eaa9782", "created_at": "2019-01-01T12:00:00.000Z", "ge": 0, "id": "1a15dcab-7e30-45e1-b7c5-bc690eaa9865", "le": 32, "prefix": "192.168.100.0/24", "updated_at": "2019-01-01T12:00:00.000Z"}], "prefix_filters_default": "permit", "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.000Z", "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"}}' + 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.000Z", "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.000Z"}]}' responses.add(responses.GET, url, body=mock_response, @@ -201,74 +199,21 @@ def test_list_connections_value_error(self): 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) + _service.list_transit_gateways(**req_copy) - def test_list_connections_value_error_with_retries(self): - # Enable retries and run test_list_connections_value_error. + def test_list_transit_gateways_value_error_with_retries(self): + # Enable retries and run test_list_transit_gateways_value_error. _service.enable_retries() - self.test_list_connections_value_error() + self.test_list_transit_gateways_value_error() - # Disable retries and run test_list_connections_value_error. + # Disable retries and run test_list_transit_gateways_value_error. _service.disable_retries() - self.test_list_connections_value_error() - -# endregion -############################################################################## -# End of Service: TransitConnections -############################################################################## - -############################################################################## -# Start of Service: TransitGatewayConnectionPrefixFilters -############################################################################## -# region - -class TestNewInstance(): - """ - Test Class for new_instance - """ - - def test_new_instance(self): - """ - new_instance() - """ - os.environ['TEST_SERVICE_AUTH_TYPE'] = 'noAuth' - - service = TransitGatewayApisV1.new_instance( - version=version, - service_name='TEST_SERVICE', - ) - - assert service is not None - assert isinstance(service, TransitGatewayApisV1) - - def test_new_instance_without_authenticator(self): - """ - new_instance_without_authenticator() - """ - with pytest.raises(ValueError, match='authenticator must be provided'): - service = TransitGatewayApisV1.new_instance( - version=version, - ) - - def test_new_instance_without_required_params(self): - """ - new_instance_without_required_params() - """ - with pytest.raises(TypeError, match='new_instance\\(\\) missing \\d required positional arguments?: \'.*\''): - service = TransitGatewayApisV1.new_instance() + self.test_list_transit_gateways_value_error() - def test_new_instance_required_param_none(self): - """ - new_instance_required_param_none() - """ - with pytest.raises(ValueError, match='version must be provided'): - service = TransitGatewayApisV1.new_instance( - version=None, - ) -class TestListTransitGatewayConnectionPrefixFilters(): +class TestCreateTransitGateway(): """ - Test Class for list_transit_gateway_connection_prefix_filters + Test Class for create_transit_gateway """ def preprocess_url(self, request_url: str): @@ -283,84 +228,104 @@ def preprocess_url(self, request_url: str): return re.compile(request_url.rstrip('/') + '/+') @responses.activate - def test_list_transit_gateway_connection_prefix_filters_all_params(self): + def test_create_transit_gateway_all_params(self): """ - list_transit_gateway_connection_prefix_filters() + create_transit_gateway() """ # Set up mock - url = self.preprocess_url(_base_url + '/transit_gateways/testString/connections/testString/prefix_filters') - mock_response = '{"prefix_filters": [{"action": "permit", "before": "1a15dcab-7e40-45e1-b7c5-bc690eaa9782", "created_at": "2019-01-01T12:00:00.000Z", "ge": 0, "id": "1a15dcab-7e30-45e1-b7c5-bc690eaa9865", "le": 32, "prefix": "192.168.100.0/24", "updated_at": "2019-01-01T12:00:00.000Z"}]}' - responses.add(responses.GET, + url = self.preprocess_url(_base_url + '/transit_gateways') + mock_response = '{"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.000Z", "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.000Z"}' + responses.add(responses.POST, url, body=mock_response, content_type='application/json', - status=200) + status=201) + + # Construct a dict representation of a ResourceGroupIdentity model + resource_group_identity_model = {} + resource_group_identity_model['id'] = '56969d6043e9465c883cb9f7363e78e8' # Set up parameter values - transit_gateway_id = 'testString' - id = 'testString' + location = 'us-south' + name = 'Transit_Service_BWTN_SJ_DL' + global_ = True + resource_group = resource_group_identity_model # Invoke method - response = _service.list_transit_gateway_connection_prefix_filters( - transit_gateway_id, - id, + response = _service.create_transit_gateway( + location, + name, + global_=global_, + resource_group=resource_group, headers={} ) # Check for correct operation assert len(responses.calls) == 1 - assert response.status_code == 200 + assert response.status_code == 201 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['location'] == 'us-south' + assert req_body['name'] == 'Transit_Service_BWTN_SJ_DL' + assert req_body['global'] == True + assert req_body['resource_group'] == resource_group_identity_model - def test_list_transit_gateway_connection_prefix_filters_all_params_with_retries(self): - # Enable retries and run test_list_transit_gateway_connection_prefix_filters_all_params. + def test_create_transit_gateway_all_params_with_retries(self): + # Enable retries and run test_create_transit_gateway_all_params. _service.enable_retries() - self.test_list_transit_gateway_connection_prefix_filters_all_params() + self.test_create_transit_gateway_all_params() - # Disable retries and run test_list_transit_gateway_connection_prefix_filters_all_params. + # Disable retries and run test_create_transit_gateway_all_params. _service.disable_retries() - self.test_list_transit_gateway_connection_prefix_filters_all_params() + self.test_create_transit_gateway_all_params() @responses.activate - def test_list_transit_gateway_connection_prefix_filters_value_error(self): + def test_create_transit_gateway_value_error(self): """ - test_list_transit_gateway_connection_prefix_filters_value_error() + test_create_transit_gateway_value_error() """ # Set up mock - url = self.preprocess_url(_base_url + '/transit_gateways/testString/connections/testString/prefix_filters') - mock_response = '{"prefix_filters": [{"action": "permit", "before": "1a15dcab-7e40-45e1-b7c5-bc690eaa9782", "created_at": "2019-01-01T12:00:00.000Z", "ge": 0, "id": "1a15dcab-7e30-45e1-b7c5-bc690eaa9865", "le": 32, "prefix": "192.168.100.0/24", "updated_at": "2019-01-01T12:00:00.000Z"}]}' - responses.add(responses.GET, + url = self.preprocess_url(_base_url + '/transit_gateways') + mock_response = '{"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.000Z", "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.000Z"}' + responses.add(responses.POST, url, body=mock_response, content_type='application/json', - status=200) + status=201) + + # Construct a dict representation of a ResourceGroupIdentity model + resource_group_identity_model = {} + resource_group_identity_model['id'] = '56969d6043e9465c883cb9f7363e78e8' # Set up parameter values - transit_gateway_id = 'testString' - id = 'testString' + location = 'us-south' + name = 'Transit_Service_BWTN_SJ_DL' + global_ = True + resource_group = resource_group_identity_model # Pass in all but one required param and check for a ValueError req_param_dict = { - "transit_gateway_id": transit_gateway_id, - "id": id, + "location": location, + "name": name, } 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_transit_gateway_connection_prefix_filters(**req_copy) + _service.create_transit_gateway(**req_copy) - def test_list_transit_gateway_connection_prefix_filters_value_error_with_retries(self): - # Enable retries and run test_list_transit_gateway_connection_prefix_filters_value_error. + def test_create_transit_gateway_value_error_with_retries(self): + # Enable retries and run test_create_transit_gateway_value_error. _service.enable_retries() - self.test_list_transit_gateway_connection_prefix_filters_value_error() + self.test_create_transit_gateway_value_error() - # Disable retries and run test_list_transit_gateway_connection_prefix_filters_value_error. + # Disable retries and run test_create_transit_gateway_value_error. _service.disable_retries() - self.test_list_transit_gateway_connection_prefix_filters_value_error() + self.test_create_transit_gateway_value_error() -class TestCreateTransitGatewayConnectionPrefixFilter(): +class TestDeleteTransitGateway(): """ - Test Class for create_transit_gateway_connection_prefix_filter + Test Class for delete_transit_gateway """ def preprocess_url(self, request_url: str): @@ -375,108 +340,74 @@ def preprocess_url(self, request_url: str): return re.compile(request_url.rstrip('/') + '/+') @responses.activate - def test_create_transit_gateway_connection_prefix_filter_all_params(self): + def test_delete_transit_gateway_all_params(self): """ - create_transit_gateway_connection_prefix_filter() + delete_transit_gateway() """ # Set up mock - url = self.preprocess_url(_base_url + '/transit_gateways/testString/connections/testString/prefix_filters') - mock_response = '{"action": "permit", "before": "1a15dcab-7e40-45e1-b7c5-bc690eaa9782", "created_at": "2019-01-01T12:00:00.000Z", "ge": 0, "id": "1a15dcab-7e30-45e1-b7c5-bc690eaa9865", "le": 32, "prefix": "192.168.100.0/24", "updated_at": "2019-01-01T12:00:00.000Z"}' - responses.add(responses.POST, + url = self.preprocess_url(_base_url + '/transit_gateways/testString') + responses.add(responses.DELETE, url, - body=mock_response, - content_type='application/json', - status=201) + status=204) # Set up parameter values - transit_gateway_id = 'testString' id = 'testString' - action = 'permit' - prefix = '192.168.100.0/24' - before = '1a15dcab-7e40-45e1-b7c5-bc690eaa9782' - ge = 0 - le = 32 # Invoke method - response = _service.create_transit_gateway_connection_prefix_filter( - transit_gateway_id, + response = _service.delete_transit_gateway( id, - action, - prefix, - before=before, - ge=ge, - le=le, headers={} ) # Check for correct operation assert len(responses.calls) == 1 - assert response.status_code == 201 - # Validate body params - req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) - assert req_body['action'] == 'permit' - assert req_body['prefix'] == '192.168.100.0/24' - assert req_body['before'] == '1a15dcab-7e40-45e1-b7c5-bc690eaa9782' - assert req_body['ge'] == 0 - assert req_body['le'] == 32 + assert response.status_code == 204 - def test_create_transit_gateway_connection_prefix_filter_all_params_with_retries(self): - # Enable retries and run test_create_transit_gateway_connection_prefix_filter_all_params. + def test_delete_transit_gateway_all_params_with_retries(self): + # Enable retries and run test_delete_transit_gateway_all_params. _service.enable_retries() - self.test_create_transit_gateway_connection_prefix_filter_all_params() + self.test_delete_transit_gateway_all_params() - # Disable retries and run test_create_transit_gateway_connection_prefix_filter_all_params. + # Disable retries and run test_delete_transit_gateway_all_params. _service.disable_retries() - self.test_create_transit_gateway_connection_prefix_filter_all_params() + self.test_delete_transit_gateway_all_params() @responses.activate - def test_create_transit_gateway_connection_prefix_filter_value_error(self): + def test_delete_transit_gateway_value_error(self): """ - test_create_transit_gateway_connection_prefix_filter_value_error() + test_delete_transit_gateway_value_error() """ # Set up mock - url = self.preprocess_url(_base_url + '/transit_gateways/testString/connections/testString/prefix_filters') - mock_response = '{"action": "permit", "before": "1a15dcab-7e40-45e1-b7c5-bc690eaa9782", "created_at": "2019-01-01T12:00:00.000Z", "ge": 0, "id": "1a15dcab-7e30-45e1-b7c5-bc690eaa9865", "le": 32, "prefix": "192.168.100.0/24", "updated_at": "2019-01-01T12:00:00.000Z"}' - responses.add(responses.POST, + url = self.preprocess_url(_base_url + '/transit_gateways/testString') + responses.add(responses.DELETE, url, - body=mock_response, - content_type='application/json', - status=201) + status=204) # Set up parameter values - transit_gateway_id = 'testString' id = 'testString' - action = 'permit' - prefix = '192.168.100.0/24' - before = '1a15dcab-7e40-45e1-b7c5-bc690eaa9782' - ge = 0 - le = 32 # Pass in all but one required param and check for a ValueError req_param_dict = { - "transit_gateway_id": transit_gateway_id, "id": id, - "action": action, - "prefix": prefix, } 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.create_transit_gateway_connection_prefix_filter(**req_copy) + _service.delete_transit_gateway(**req_copy) - def test_create_transit_gateway_connection_prefix_filter_value_error_with_retries(self): - # Enable retries and run test_create_transit_gateway_connection_prefix_filter_value_error. + def test_delete_transit_gateway_value_error_with_retries(self): + # Enable retries and run test_delete_transit_gateway_value_error. _service.enable_retries() - self.test_create_transit_gateway_connection_prefix_filter_value_error() + self.test_delete_transit_gateway_value_error() - # Disable retries and run test_create_transit_gateway_connection_prefix_filter_value_error. + # Disable retries and run test_delete_transit_gateway_value_error. _service.disable_retries() - self.test_create_transit_gateway_connection_prefix_filter_value_error() + self.test_delete_transit_gateway_value_error() -class TestDeleteTransitGatewayConnectionPrefixFilter(): +class TestGetTransitGateway(): """ - Test Class for delete_transit_gateway_connection_prefix_filter + Test Class for get_transit_gateway """ def preprocess_url(self, request_url: str): @@ -491,82 +422,80 @@ def preprocess_url(self, request_url: str): return re.compile(request_url.rstrip('/') + '/+') @responses.activate - def test_delete_transit_gateway_connection_prefix_filter_all_params(self): + def test_get_transit_gateway_all_params(self): """ - delete_transit_gateway_connection_prefix_filter() + get_transit_gateway() """ # Set up mock - url = self.preprocess_url(_base_url + '/transit_gateways/testString/connections/testString/prefix_filters/testString') - responses.add(responses.DELETE, + url = self.preprocess_url(_base_url + '/transit_gateways/testString') + mock_response = '{"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.000Z", "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.000Z"}' + responses.add(responses.GET, url, - status=204) + body=mock_response, + content_type='application/json', + status=200) # Set up parameter values - transit_gateway_id = 'testString' id = 'testString' - filter_id = 'testString' # Invoke method - response = _service.delete_transit_gateway_connection_prefix_filter( - transit_gateway_id, + response = _service.get_transit_gateway( id, - filter_id, headers={} ) # Check for correct operation assert len(responses.calls) == 1 - assert response.status_code == 204 + assert response.status_code == 200 - def test_delete_transit_gateway_connection_prefix_filter_all_params_with_retries(self): - # Enable retries and run test_delete_transit_gateway_connection_prefix_filter_all_params. + def test_get_transit_gateway_all_params_with_retries(self): + # Enable retries and run test_get_transit_gateway_all_params. _service.enable_retries() - self.test_delete_transit_gateway_connection_prefix_filter_all_params() + self.test_get_transit_gateway_all_params() - # Disable retries and run test_delete_transit_gateway_connection_prefix_filter_all_params. + # Disable retries and run test_get_transit_gateway_all_params. _service.disable_retries() - self.test_delete_transit_gateway_connection_prefix_filter_all_params() + self.test_get_transit_gateway_all_params() @responses.activate - def test_delete_transit_gateway_connection_prefix_filter_value_error(self): + def test_get_transit_gateway_value_error(self): """ - test_delete_transit_gateway_connection_prefix_filter_value_error() + test_get_transit_gateway_value_error() """ # Set up mock - url = self.preprocess_url(_base_url + '/transit_gateways/testString/connections/testString/prefix_filters/testString') - responses.add(responses.DELETE, + url = self.preprocess_url(_base_url + '/transit_gateways/testString') + mock_response = '{"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.000Z", "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.000Z"}' + responses.add(responses.GET, url, - status=204) + body=mock_response, + content_type='application/json', + status=200) # Set up parameter values - transit_gateway_id = 'testString' id = 'testString' - filter_id = 'testString' # Pass in all but one required param and check for a ValueError req_param_dict = { - "transit_gateway_id": transit_gateway_id, "id": id, - "filter_id": filter_id, } 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.delete_transit_gateway_connection_prefix_filter(**req_copy) + _service.get_transit_gateway(**req_copy) - def test_delete_transit_gateway_connection_prefix_filter_value_error_with_retries(self): - # Enable retries and run test_delete_transit_gateway_connection_prefix_filter_value_error. + def test_get_transit_gateway_value_error_with_retries(self): + # Enable retries and run test_get_transit_gateway_value_error. _service.enable_retries() - self.test_delete_transit_gateway_connection_prefix_filter_value_error() + self.test_get_transit_gateway_value_error() - # Disable retries and run test_delete_transit_gateway_connection_prefix_filter_value_error. + # Disable retries and run test_get_transit_gateway_value_error. _service.disable_retries() - self.test_delete_transit_gateway_connection_prefix_filter_value_error() + self.test_get_transit_gateway_value_error() -class TestGetTransitGatewayConnectionPrefixFilter(): +class TestUpdateTransitGateway(): """ - Test Class for get_transit_gateway_connection_prefix_filter + Test Class for update_transit_gateway """ def preprocess_url(self, request_url: str): @@ -581,88 +510,144 @@ def preprocess_url(self, request_url: str): return re.compile(request_url.rstrip('/') + '/+') @responses.activate - def test_get_transit_gateway_connection_prefix_filter_all_params(self): + def test_update_transit_gateway_all_params(self): """ - get_transit_gateway_connection_prefix_filter() + update_transit_gateway() """ # Set up mock - url = self.preprocess_url(_base_url + '/transit_gateways/testString/connections/testString/prefix_filters/testString') - mock_response = '{"action": "permit", "before": "1a15dcab-7e40-45e1-b7c5-bc690eaa9782", "created_at": "2019-01-01T12:00:00.000Z", "ge": 0, "id": "1a15dcab-7e30-45e1-b7c5-bc690eaa9865", "le": 32, "prefix": "192.168.100.0/24", "updated_at": "2019-01-01T12:00:00.000Z"}' - responses.add(responses.GET, + url = self.preprocess_url(_base_url + '/transit_gateways/testString') + mock_response = '{"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.000Z", "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.000Z"}' + responses.add(responses.PATCH, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values - transit_gateway_id = 'testString' id = 'testString' - filter_id = 'testString' + global_ = True + name = 'my-transit-gateway' # Invoke method - response = _service.get_transit_gateway_connection_prefix_filter( - transit_gateway_id, + response = _service.update_transit_gateway( id, - filter_id, + global_=global_, + name=name, headers={} ) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['global'] == True + assert req_body['name'] == 'my-transit-gateway' - def test_get_transit_gateway_connection_prefix_filter_all_params_with_retries(self): - # Enable retries and run test_get_transit_gateway_connection_prefix_filter_all_params. + def test_update_transit_gateway_all_params_with_retries(self): + # Enable retries and run test_update_transit_gateway_all_params. _service.enable_retries() - self.test_get_transit_gateway_connection_prefix_filter_all_params() + self.test_update_transit_gateway_all_params() - # Disable retries and run test_get_transit_gateway_connection_prefix_filter_all_params. + # Disable retries and run test_update_transit_gateway_all_params. _service.disable_retries() - self.test_get_transit_gateway_connection_prefix_filter_all_params() + self.test_update_transit_gateway_all_params() @responses.activate - def test_get_transit_gateway_connection_prefix_filter_value_error(self): + def test_update_transit_gateway_value_error(self): """ - test_get_transit_gateway_connection_prefix_filter_value_error() + test_update_transit_gateway_value_error() """ # Set up mock - url = self.preprocess_url(_base_url + '/transit_gateways/testString/connections/testString/prefix_filters/testString') - mock_response = '{"action": "permit", "before": "1a15dcab-7e40-45e1-b7c5-bc690eaa9782", "created_at": "2019-01-01T12:00:00.000Z", "ge": 0, "id": "1a15dcab-7e30-45e1-b7c5-bc690eaa9865", "le": 32, "prefix": "192.168.100.0/24", "updated_at": "2019-01-01T12:00:00.000Z"}' - responses.add(responses.GET, + url = self.preprocess_url(_base_url + '/transit_gateways/testString') + mock_response = '{"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.000Z", "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.000Z"}' + responses.add(responses.PATCH, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values - transit_gateway_id = 'testString' id = 'testString' - filter_id = 'testString' + global_ = True + name = 'my-transit-gateway' # Pass in all but one required param and check for a ValueError req_param_dict = { - "transit_gateway_id": transit_gateway_id, "id": id, - "filter_id": filter_id, } 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.get_transit_gateway_connection_prefix_filter(**req_copy) + _service.update_transit_gateway(**req_copy) - def test_get_transit_gateway_connection_prefix_filter_value_error_with_retries(self): - # Enable retries and run test_get_transit_gateway_connection_prefix_filter_value_error. + def test_update_transit_gateway_value_error_with_retries(self): + # Enable retries and run test_update_transit_gateway_value_error. _service.enable_retries() - self.test_get_transit_gateway_connection_prefix_filter_value_error() + self.test_update_transit_gateway_value_error() - # Disable retries and run test_get_transit_gateway_connection_prefix_filter_value_error. + # Disable retries and run test_update_transit_gateway_value_error. _service.disable_retries() - self.test_get_transit_gateway_connection_prefix_filter_value_error() + self.test_update_transit_gateway_value_error() -class TestUpdateTransitGatewayConnectionPrefixFilter(): +# endregion +############################################################################## +# End of Service: TransitGateways +############################################################################## + +############################################################################## +# Start of Service: TransitConnections +############################################################################## +# region + +class TestNewInstance(): """ - Test Class for update_transit_gateway_connection_prefix_filter + Test Class for new_instance + """ + + def test_new_instance(self): + """ + new_instance() + """ + os.environ['TEST_SERVICE_AUTH_TYPE'] = 'noAuth' + + service = TransitGatewayApisV1.new_instance( + version=version, + service_name='TEST_SERVICE', + ) + + assert service is not None + assert isinstance(service, TransitGatewayApisV1) + + def test_new_instance_without_authenticator(self): + """ + new_instance_without_authenticator() + """ + with pytest.raises(ValueError, match='authenticator must be provided'): + service = TransitGatewayApisV1.new_instance( + version=version, + service_name='TEST_SERVICE_NOT_FOUND', + ) + + def test_new_instance_without_required_params(self): + """ + new_instance_without_required_params() + """ + with pytest.raises(TypeError, match='new_instance\\(\\) missing \\d required positional arguments?: \'.*\''): + service = TransitGatewayApisV1.new_instance() + + def test_new_instance_required_param_none(self): + """ + new_instance_required_param_none() + """ + with pytest.raises(ValueError, match='version must be provided'): + service = TransitGatewayApisV1.new_instance( + version=None, + ) +class TestListConnections(): + """ + Test Class for list_connections """ def preprocess_url(self, request_url: str): @@ -677,114 +662,121 @@ def preprocess_url(self, request_url: str): return re.compile(request_url.rstrip('/') + '/+') @responses.activate - def test_update_transit_gateway_connection_prefix_filter_all_params(self): + def test_list_connections_all_params(self): """ - update_transit_gateway_connection_prefix_filter() + list_connections() """ # Set up mock - url = self.preprocess_url(_base_url + '/transit_gateways/testString/connections/testString/prefix_filters/testString') - mock_response = '{"action": "permit", "before": "1a15dcab-7e40-45e1-b7c5-bc690eaa9782", "created_at": "2019-01-01T12:00:00.000Z", "ge": 0, "id": "1a15dcab-7e30-45e1-b7c5-bc690eaa9865", "le": 32, "prefix": "192.168.100.0/24", "updated_at": "2019-01-01T12:00:00.000Z"}' - responses.add(responses.PATCH, + 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.000Z", "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", "prefix_filters": [{"action": "permit", "before": "1a15dcab-7e40-45e1-b7c5-bc690eaa9782", "created_at": "2019-01-01T12:00:00.000Z", "ge": 0, "id": "1a15dcab-7e30-45e1-b7c5-bc690eaa9865", "le": 32, "prefix": "192.168.100.0/24", "updated_at": "2019-01-01T12:00:00.000Z"}], "prefix_filters_default": "permit", "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.000Z", "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 - transit_gateway_id = 'testString' - id = 'testString' - filter_id = 'testString' - action = 'permit' - before = '1a15dcab-7e40-45e1-b7c5-bc690eaa9782' - ge = 0 - le = 32 - prefix = '192.168.100.0/24' + limit = 1 + start = 'testString' + network_id = 'testString' # Invoke method - response = _service.update_transit_gateway_connection_prefix_filter( - transit_gateway_id, - id, - filter_id, - action=action, - before=before, - ge=ge, - le=le, - prefix=prefix, + 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 body params - req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) - assert req_body['action'] == 'permit' - assert req_body['before'] == '1a15dcab-7e40-45e1-b7c5-bc690eaa9782' - assert req_body['ge'] == 0 - assert req_body['le'] == 32 - assert req_body['prefix'] == '192.168.100.0/24' + # Validate query params + query_string = responses.calls[0].request.url.split('?',1)[1] + query_string = urllib.parse.unquote_plus(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 - def test_update_transit_gateway_connection_prefix_filter_all_params_with_retries(self): - # Enable retries and run test_update_transit_gateway_connection_prefix_filter_all_params. + def test_list_connections_all_params_with_retries(self): + # Enable retries and run test_list_connections_all_params. _service.enable_retries() - self.test_update_transit_gateway_connection_prefix_filter_all_params() + self.test_list_connections_all_params() - # Disable retries and run test_update_transit_gateway_connection_prefix_filter_all_params. + # Disable retries and run test_list_connections_all_params. _service.disable_retries() - self.test_update_transit_gateway_connection_prefix_filter_all_params() + self.test_list_connections_all_params() @responses.activate - def test_update_transit_gateway_connection_prefix_filter_value_error(self): + def test_list_connections_required_params(self): """ - test_update_transit_gateway_connection_prefix_filter_value_error() + test_list_connections_required_params() """ # Set up mock - url = self.preprocess_url(_base_url + '/transit_gateways/testString/connections/testString/prefix_filters/testString') - mock_response = '{"action": "permit", "before": "1a15dcab-7e40-45e1-b7c5-bc690eaa9782", "created_at": "2019-01-01T12:00:00.000Z", "ge": 0, "id": "1a15dcab-7e30-45e1-b7c5-bc690eaa9865", "le": 32, "prefix": "192.168.100.0/24", "updated_at": "2019-01-01T12:00:00.000Z"}' - responses.add(responses.PATCH, + 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.000Z", "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", "prefix_filters": [{"action": "permit", "before": "1a15dcab-7e40-45e1-b7c5-bc690eaa9782", "created_at": "2019-01-01T12:00:00.000Z", "ge": 0, "id": "1a15dcab-7e30-45e1-b7c5-bc690eaa9865", "le": 32, "prefix": "192.168.100.0/24", "updated_at": "2019-01-01T12:00:00.000Z"}], "prefix_filters_default": "permit", "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.000Z", "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 - transit_gateway_id = 'testString' - id = 'testString' - filter_id = 'testString' - action = 'permit' - before = '1a15dcab-7e40-45e1-b7c5-bc690eaa9782' - ge = 0 - le = 32 - prefix = '192.168.100.0/24' + # Invoke method + response = _service.list_connections() + + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_list_connections_required_params_with_retries(self): + # Enable retries and run test_list_connections_required_params. + _service.enable_retries() + self.test_list_connections_required_params() + + # Disable retries and run test_list_connections_required_params. + _service.disable_retries() + self.test_list_connections_required_params() + + @responses.activate + def test_list_connections_value_error(self): + """ + test_list_connections_value_error() + """ + # 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.000Z", "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", "prefix_filters": [{"action": "permit", "before": "1a15dcab-7e40-45e1-b7c5-bc690eaa9782", "created_at": "2019-01-01T12:00:00.000Z", "ge": 0, "id": "1a15dcab-7e30-45e1-b7c5-bc690eaa9865", "le": 32, "prefix": "192.168.100.0/24", "updated_at": "2019-01-01T12:00:00.000Z"}], "prefix_filters_default": "permit", "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.000Z", "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 = { - "transit_gateway_id": transit_gateway_id, - "id": id, - "filter_id": filter_id, } 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.update_transit_gateway_connection_prefix_filter(**req_copy) + _service.list_connections(**req_copy) - def test_update_transit_gateway_connection_prefix_filter_value_error_with_retries(self): - # Enable retries and run test_update_transit_gateway_connection_prefix_filter_value_error. + def test_list_connections_value_error_with_retries(self): + # Enable retries and run test_list_connections_value_error. _service.enable_retries() - self.test_update_transit_gateway_connection_prefix_filter_value_error() + self.test_list_connections_value_error() - # Disable retries and run test_update_transit_gateway_connection_prefix_filter_value_error. + # Disable retries and run test_list_connections_value_error. _service.disable_retries() - self.test_update_transit_gateway_connection_prefix_filter_value_error() + self.test_list_connections_value_error() # endregion ############################################################################## -# End of Service: TransitGatewayConnectionPrefixFilters +# End of Service: TransitConnections ############################################################################## ############################################################################## -# Start of Service: TransitGatewayRouteReports +# Start of Service: TransitGatewaysNetworkConnections ############################################################################## # region @@ -814,6 +806,7 @@ def test_new_instance_without_authenticator(self): with pytest.raises(ValueError, match='authenticator must be provided'): service = TransitGatewayApisV1.new_instance( version=version, + service_name='TEST_SERVICE_NOT_FOUND', ) def test_new_instance_without_required_params(self): @@ -831,9 +824,9 @@ def test_new_instance_required_param_none(self): service = TransitGatewayApisV1.new_instance( version=None, ) -class TestListTransitGatewayRouteReports(): +class TestListTransitGatewayConnections(): """ - Test Class for list_transit_gateway_route_reports + Test Class for list_transit_gateway_connections """ def preprocess_url(self, request_url: str): @@ -848,13 +841,13 @@ def preprocess_url(self, request_url: str): return re.compile(request_url.rstrip('/') + '/+') @responses.activate - def test_list_transit_gateway_route_reports_all_params(self): + def test_list_transit_gateway_connections_all_params(self): """ - list_transit_gateway_route_reports() + list_transit_gateway_connections() """ # Set up mock - url = self.preprocess_url(_base_url + '/transit_gateways/testString/route_reports') - mock_response = '{"route_reports": [{"connections": [{"bgps": [{"as_path": "(65201 4201065544) 4203065544", "is_used": true, "local_preference": "190", "prefix": "172.17.0.0/16"}], "id": "3c265a62-91da-4261-a950-950b6af0eb58", "name": "transit-connection-vpc1", "routes": [{"prefix": "192.168.0.0/16"}], "type": "vpc"}], "created_at": "2019-01-01T12:00:00.000Z", "id": "1a15dcab-7e26-45e1-b7c5-bc690eaa9724", "overlapping_routes": [{"routes": [{"connection_id": "d2d985d8-1d8e-4e8b-96cd-cee2290ecaff", "prefix": "prefix"}]}], "status": "complete", "updated_at": "2019-01-01T12:00:00.000Z"}]}' + url = self.preprocess_url(_base_url + '/transit_gateways/testString/connections') + mock_response = '{"connections": [{"base_network_type": "classic", "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.000Z", "local_bgp_asn": 64490, "local_gateway_ip": "192.168.100.1", "local_tunnel_ip": "192.168.129.2", "mtu": 9000, "network_account_id": "28e4d90ac7504be694471ee66e70d0d5", "prefix_filters": [{"action": "permit", "before": "1a15dcab-7e40-45e1-b7c5-bc690eaa9782", "created_at": "2019-01-01T12:00:00.000Z", "ge": 0, "id": "1a15dcab-7e30-45e1-b7c5-bc690eaa9865", "le": 32, "prefix": "192.168.100.0/24", "updated_at": "2019-01-01T12:00:00.000Z"}], "prefix_filters_default": "permit", "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.000Z", "zone": {"name": "us-south-1"}}]}' responses.add(responses.GET, url, body=mock_response, @@ -865,7 +858,7 @@ def test_list_transit_gateway_route_reports_all_params(self): transit_gateway_id = 'testString' # Invoke method - response = _service.list_transit_gateway_route_reports( + response = _service.list_transit_gateway_connections( transit_gateway_id, headers={} ) @@ -874,23 +867,23 @@ def test_list_transit_gateway_route_reports_all_params(self): assert len(responses.calls) == 1 assert response.status_code == 200 - def test_list_transit_gateway_route_reports_all_params_with_retries(self): - # Enable retries and run test_list_transit_gateway_route_reports_all_params. + def test_list_transit_gateway_connections_all_params_with_retries(self): + # Enable retries and run test_list_transit_gateway_connections_all_params. _service.enable_retries() - self.test_list_transit_gateway_route_reports_all_params() + self.test_list_transit_gateway_connections_all_params() - # Disable retries and run test_list_transit_gateway_route_reports_all_params. + # Disable retries and run test_list_transit_gateway_connections_all_params. _service.disable_retries() - self.test_list_transit_gateway_route_reports_all_params() + self.test_list_transit_gateway_connections_all_params() @responses.activate - def test_list_transit_gateway_route_reports_value_error(self): + def test_list_transit_gateway_connections_value_error(self): """ - test_list_transit_gateway_route_reports_value_error() + test_list_transit_gateway_connections_value_error() """ # Set up mock - url = self.preprocess_url(_base_url + '/transit_gateways/testString/route_reports') - mock_response = '{"route_reports": [{"connections": [{"bgps": [{"as_path": "(65201 4201065544) 4203065544", "is_used": true, "local_preference": "190", "prefix": "172.17.0.0/16"}], "id": "3c265a62-91da-4261-a950-950b6af0eb58", "name": "transit-connection-vpc1", "routes": [{"prefix": "192.168.0.0/16"}], "type": "vpc"}], "created_at": "2019-01-01T12:00:00.000Z", "id": "1a15dcab-7e26-45e1-b7c5-bc690eaa9724", "overlapping_routes": [{"routes": [{"connection_id": "d2d985d8-1d8e-4e8b-96cd-cee2290ecaff", "prefix": "prefix"}]}], "status": "complete", "updated_at": "2019-01-01T12:00:00.000Z"}]}' + url = self.preprocess_url(_base_url + '/transit_gateways/testString/connections') + mock_response = '{"connections": [{"base_network_type": "classic", "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.000Z", "local_bgp_asn": 64490, "local_gateway_ip": "192.168.100.1", "local_tunnel_ip": "192.168.129.2", "mtu": 9000, "network_account_id": "28e4d90ac7504be694471ee66e70d0d5", "prefix_filters": [{"action": "permit", "before": "1a15dcab-7e40-45e1-b7c5-bc690eaa9782", "created_at": "2019-01-01T12:00:00.000Z", "ge": 0, "id": "1a15dcab-7e30-45e1-b7c5-bc690eaa9865", "le": 32, "prefix": "192.168.100.0/24", "updated_at": "2019-01-01T12:00:00.000Z"}], "prefix_filters_default": "permit", "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.000Z", "zone": {"name": "us-south-1"}}]}' responses.add(responses.GET, url, body=mock_response, @@ -907,21 +900,21 @@ def test_list_transit_gateway_route_reports_value_error(self): 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_transit_gateway_route_reports(**req_copy) + _service.list_transit_gateway_connections(**req_copy) - def test_list_transit_gateway_route_reports_value_error_with_retries(self): - # Enable retries and run test_list_transit_gateway_route_reports_value_error. + def test_list_transit_gateway_connections_value_error_with_retries(self): + # Enable retries and run test_list_transit_gateway_connections_value_error. _service.enable_retries() - self.test_list_transit_gateway_route_reports_value_error() + self.test_list_transit_gateway_connections_value_error() - # Disable retries and run test_list_transit_gateway_route_reports_value_error. + # Disable retries and run test_list_transit_gateway_connections_value_error. _service.disable_retries() - self.test_list_transit_gateway_route_reports_value_error() + self.test_list_transit_gateway_connections_value_error() -class TestCreateTransitGatewayRouteReport(): +class TestCreateTransitGatewayConnection(): """ - Test Class for create_transit_gateway_route_report + Test Class for create_transit_gateway_connection """ def preprocess_url(self, request_url: str): @@ -936,80 +929,161 @@ def preprocess_url(self, request_url: str): return re.compile(request_url.rstrip('/') + '/+') @responses.activate - def test_create_transit_gateway_route_report_all_params(self): + def test_create_transit_gateway_connection_all_params(self): """ - create_transit_gateway_route_report() + create_transit_gateway_connection() """ # Set up mock - url = self.preprocess_url(_base_url + '/transit_gateways/testString/route_reports') - mock_response = '{"connections": [{"bgps": [{"as_path": "(65201 4201065544) 4203065544", "is_used": true, "local_preference": "190", "prefix": "172.17.0.0/16"}], "id": "3c265a62-91da-4261-a950-950b6af0eb58", "name": "transit-connection-vpc1", "routes": [{"prefix": "192.168.0.0/16"}], "type": "vpc"}], "created_at": "2019-01-01T12:00:00.000Z", "id": "1a15dcab-7e26-45e1-b7c5-bc690eaa9724", "overlapping_routes": [{"routes": [{"connection_id": "d2d985d8-1d8e-4e8b-96cd-cee2290ecaff", "prefix": "prefix"}]}], "status": "complete", "updated_at": "2019-01-01T12:00:00.000Z"}' + url = self.preprocess_url(_base_url + '/transit_gateways/testString/connections') + mock_response = '{"base_network_type": "classic", "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.000Z", "local_bgp_asn": 64490, "local_gateway_ip": "192.168.100.1", "local_tunnel_ip": "192.168.129.2", "mtu": 9000, "network_account_id": "28e4d90ac7504be694471ee66e70d0d5", "prefix_filters": [{"action": "permit", "before": "1a15dcab-7e40-45e1-b7c5-bc690eaa9782", "created_at": "2019-01-01T12:00:00.000Z", "ge": 0, "id": "1a15dcab-7e30-45e1-b7c5-bc690eaa9865", "le": 32, "prefix": "192.168.100.0/24", "updated_at": "2019-01-01T12:00:00.000Z"}], "prefix_filters_default": "permit", "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.000Z", "zone": {"name": "us-south-1"}}' responses.add(responses.POST, url, body=mock_response, content_type='application/json', - status=202) + status=201) + + # Construct a dict representation of a TransitGatewayConnectionPrefixFilter model + transit_gateway_connection_prefix_filter_model = {} + transit_gateway_connection_prefix_filter_model['action'] = 'permit' + transit_gateway_connection_prefix_filter_model['ge'] = 0 + transit_gateway_connection_prefix_filter_model['le'] = 32 + transit_gateway_connection_prefix_filter_model['prefix'] = '192.168.100.0/24' + + # 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' + base_network_type = 'classic' + local_gateway_ip = '192.168.100.1' + local_tunnel_ip = '192.168.129.2' + name = 'Transit_Service_BWTN_SJ_DL' + network_account_id = '28e4d90ac7504be694471ee66e70d0d5' + network_id = 'crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b' + prefix_filters = [transit_gateway_connection_prefix_filter_model] + prefix_filters_default = 'permit' + 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_route_report( + response = _service.create_transit_gateway_connection( transit_gateway_id, + network_type, + base_connection_id=base_connection_id, + base_network_type=base_network_type, + local_gateway_ip=local_gateway_ip, + local_tunnel_ip=local_tunnel_ip, + name=name, + network_account_id=network_account_id, + network_id=network_id, + prefix_filters=prefix_filters, + prefix_filters_default=prefix_filters_default, + remote_bgp_asn=remote_bgp_asn, + remote_gateway_ip=remote_gateway_ip, + remote_tunnel_ip=remote_tunnel_ip, + zone=zone, headers={} ) # Check for correct operation assert len(responses.calls) == 1 - assert response.status_code == 202 + assert response.status_code == 201 + # 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['base_network_type'] == 'classic' + 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_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['prefix_filters'] == [transit_gateway_connection_prefix_filter_model] + assert req_body['prefix_filters_default'] == 'permit' + 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 - def test_create_transit_gateway_route_report_all_params_with_retries(self): - # Enable retries and run test_create_transit_gateway_route_report_all_params. + def test_create_transit_gateway_connection_all_params_with_retries(self): + # Enable retries and run test_create_transit_gateway_connection_all_params. _service.enable_retries() - self.test_create_transit_gateway_route_report_all_params() + self.test_create_transit_gateway_connection_all_params() - # Disable retries and run test_create_transit_gateway_route_report_all_params. + # Disable retries and run test_create_transit_gateway_connection_all_params. _service.disable_retries() - self.test_create_transit_gateway_route_report_all_params() + self.test_create_transit_gateway_connection_all_params() @responses.activate - def test_create_transit_gateway_route_report_value_error(self): + def test_create_transit_gateway_connection_value_error(self): """ - test_create_transit_gateway_route_report_value_error() + test_create_transit_gateway_connection_value_error() """ # Set up mock - url = self.preprocess_url(_base_url + '/transit_gateways/testString/route_reports') - mock_response = '{"connections": [{"bgps": [{"as_path": "(65201 4201065544) 4203065544", "is_used": true, "local_preference": "190", "prefix": "172.17.0.0/16"}], "id": "3c265a62-91da-4261-a950-950b6af0eb58", "name": "transit-connection-vpc1", "routes": [{"prefix": "192.168.0.0/16"}], "type": "vpc"}], "created_at": "2019-01-01T12:00:00.000Z", "id": "1a15dcab-7e26-45e1-b7c5-bc690eaa9724", "overlapping_routes": [{"routes": [{"connection_id": "d2d985d8-1d8e-4e8b-96cd-cee2290ecaff", "prefix": "prefix"}]}], "status": "complete", "updated_at": "2019-01-01T12:00:00.000Z"}' + url = self.preprocess_url(_base_url + '/transit_gateways/testString/connections') + mock_response = '{"base_network_type": "classic", "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.000Z", "local_bgp_asn": 64490, "local_gateway_ip": "192.168.100.1", "local_tunnel_ip": "192.168.129.2", "mtu": 9000, "network_account_id": "28e4d90ac7504be694471ee66e70d0d5", "prefix_filters": [{"action": "permit", "before": "1a15dcab-7e40-45e1-b7c5-bc690eaa9782", "created_at": "2019-01-01T12:00:00.000Z", "ge": 0, "id": "1a15dcab-7e30-45e1-b7c5-bc690eaa9865", "le": 32, "prefix": "192.168.100.0/24", "updated_at": "2019-01-01T12:00:00.000Z"}], "prefix_filters_default": "permit", "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.000Z", "zone": {"name": "us-south-1"}}' responses.add(responses.POST, url, body=mock_response, content_type='application/json', - status=202) + status=201) + + # Construct a dict representation of a TransitGatewayConnectionPrefixFilter model + transit_gateway_connection_prefix_filter_model = {} + transit_gateway_connection_prefix_filter_model['action'] = 'permit' + transit_gateway_connection_prefix_filter_model['ge'] = 0 + transit_gateway_connection_prefix_filter_model['le'] = 32 + transit_gateway_connection_prefix_filter_model['prefix'] = '192.168.100.0/24' + + # 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' + base_network_type = 'classic' + local_gateway_ip = '192.168.100.1' + local_tunnel_ip = '192.168.129.2' + name = 'Transit_Service_BWTN_SJ_DL' + network_account_id = '28e4d90ac7504be694471ee66e70d0d5' + network_id = 'crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b' + prefix_filters = [transit_gateway_connection_prefix_filter_model] + prefix_filters_default = 'permit' + 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 = { "transit_gateway_id": transit_gateway_id, + "network_type": network_type, } 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.create_transit_gateway_route_report(**req_copy) + _service.create_transit_gateway_connection(**req_copy) - def test_create_transit_gateway_route_report_value_error_with_retries(self): - # Enable retries and run test_create_transit_gateway_route_report_value_error. + def test_create_transit_gateway_connection_value_error_with_retries(self): + # Enable retries and run test_create_transit_gateway_connection_value_error. _service.enable_retries() - self.test_create_transit_gateway_route_report_value_error() + self.test_create_transit_gateway_connection_value_error() - # Disable retries and run test_create_transit_gateway_route_report_value_error. + # Disable retries and run test_create_transit_gateway_connection_value_error. _service.disable_retries() - self.test_create_transit_gateway_route_report_value_error() + self.test_create_transit_gateway_connection_value_error() -class TestDeleteTransitGatewayRouteReport(): +class TestDeleteTransitGatewayConnection(): """ - Test Class for delete_transit_gateway_route_report + Test Class for delete_transit_gateway_connection """ def preprocess_url(self, request_url: str): @@ -1024,12 +1098,12 @@ def preprocess_url(self, request_url: str): return re.compile(request_url.rstrip('/') + '/+') @responses.activate - def test_delete_transit_gateway_route_report_all_params(self): + def test_delete_transit_gateway_connection_all_params(self): """ - delete_transit_gateway_route_report() + delete_transit_gateway_connection() """ # Set up mock - url = self.preprocess_url(_base_url + '/transit_gateways/testString/route_reports/testString') + url = self.preprocess_url(_base_url + '/transit_gateways/testString/connections/testString') responses.add(responses.DELETE, url, status=204) @@ -1039,7 +1113,7 @@ def test_delete_transit_gateway_route_report_all_params(self): id = 'testString' # Invoke method - response = _service.delete_transit_gateway_route_report( + response = _service.delete_transit_gateway_connection( transit_gateway_id, id, headers={} @@ -1049,22 +1123,22 @@ def test_delete_transit_gateway_route_report_all_params(self): assert len(responses.calls) == 1 assert response.status_code == 204 - def test_delete_transit_gateway_route_report_all_params_with_retries(self): - # Enable retries and run test_delete_transit_gateway_route_report_all_params. + def test_delete_transit_gateway_connection_all_params_with_retries(self): + # Enable retries and run test_delete_transit_gateway_connection_all_params. _service.enable_retries() - self.test_delete_transit_gateway_route_report_all_params() + self.test_delete_transit_gateway_connection_all_params() - # Disable retries and run test_delete_transit_gateway_route_report_all_params. + # Disable retries and run test_delete_transit_gateway_connection_all_params. _service.disable_retries() - self.test_delete_transit_gateway_route_report_all_params() + self.test_delete_transit_gateway_connection_all_params() @responses.activate - def test_delete_transit_gateway_route_report_value_error(self): + def test_delete_transit_gateway_connection_value_error(self): """ - test_delete_transit_gateway_route_report_value_error() + test_delete_transit_gateway_connection_value_error() """ # Set up mock - url = self.preprocess_url(_base_url + '/transit_gateways/testString/route_reports/testString') + url = self.preprocess_url(_base_url + '/transit_gateways/testString/connections/testString') responses.add(responses.DELETE, url, status=204) @@ -1081,21 +1155,21 @@ def test_delete_transit_gateway_route_report_value_error(self): 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.delete_transit_gateway_route_report(**req_copy) + _service.delete_transit_gateway_connection(**req_copy) - def test_delete_transit_gateway_route_report_value_error_with_retries(self): - # Enable retries and run test_delete_transit_gateway_route_report_value_error. + def test_delete_transit_gateway_connection_value_error_with_retries(self): + # Enable retries and run test_delete_transit_gateway_connection_value_error. _service.enable_retries() - self.test_delete_transit_gateway_route_report_value_error() + self.test_delete_transit_gateway_connection_value_error() - # Disable retries and run test_delete_transit_gateway_route_report_value_error. + # Disable retries and run test_delete_transit_gateway_connection_value_error. _service.disable_retries() - self.test_delete_transit_gateway_route_report_value_error() + self.test_delete_transit_gateway_connection_value_error() -class TestGetTransitGatewayRouteReport(): +class TestGetTransitGatewayConnection(): """ - Test Class for get_transit_gateway_route_report + Test Class for get_transit_gateway_connection """ def preprocess_url(self, request_url: str): @@ -1110,13 +1184,13 @@ def preprocess_url(self, request_url: str): return re.compile(request_url.rstrip('/') + '/+') @responses.activate - def test_get_transit_gateway_route_report_all_params(self): + def test_get_transit_gateway_connection_all_params(self): """ - get_transit_gateway_route_report() + get_transit_gateway_connection() """ # Set up mock - url = self.preprocess_url(_base_url + '/transit_gateways/testString/route_reports/testString') - mock_response = '{"connections": [{"bgps": [{"as_path": "(65201 4201065544) 4203065544", "is_used": true, "local_preference": "190", "prefix": "172.17.0.0/16"}], "id": "3c265a62-91da-4261-a950-950b6af0eb58", "name": "transit-connection-vpc1", "routes": [{"prefix": "192.168.0.0/16"}], "type": "vpc"}], "created_at": "2019-01-01T12:00:00.000Z", "id": "1a15dcab-7e26-45e1-b7c5-bc690eaa9724", "overlapping_routes": [{"routes": [{"connection_id": "d2d985d8-1d8e-4e8b-96cd-cee2290ecaff", "prefix": "prefix"}]}], "status": "complete", "updated_at": "2019-01-01T12:00:00.000Z"}' + url = self.preprocess_url(_base_url + '/transit_gateways/testString/connections/testString') + mock_response = '{"base_network_type": "classic", "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.000Z", "local_bgp_asn": 64490, "local_gateway_ip": "192.168.100.1", "local_tunnel_ip": "192.168.129.2", "mtu": 9000, "network_account_id": "28e4d90ac7504be694471ee66e70d0d5", "prefix_filters": [{"action": "permit", "before": "1a15dcab-7e40-45e1-b7c5-bc690eaa9782", "created_at": "2019-01-01T12:00:00.000Z", "ge": 0, "id": "1a15dcab-7e30-45e1-b7c5-bc690eaa9865", "le": 32, "prefix": "192.168.100.0/24", "updated_at": "2019-01-01T12:00:00.000Z"}], "prefix_filters_default": "permit", "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.000Z", "zone": {"name": "us-south-1"}}' responses.add(responses.GET, url, body=mock_response, @@ -1128,7 +1202,7 @@ def test_get_transit_gateway_route_report_all_params(self): id = 'testString' # Invoke method - response = _service.get_transit_gateway_route_report( + response = _service.get_transit_gateway_connection( transit_gateway_id, id, headers={} @@ -1138,23 +1212,23 @@ def test_get_transit_gateway_route_report_all_params(self): assert len(responses.calls) == 1 assert response.status_code == 200 - def test_get_transit_gateway_route_report_all_params_with_retries(self): - # Enable retries and run test_get_transit_gateway_route_report_all_params. + def test_get_transit_gateway_connection_all_params_with_retries(self): + # Enable retries and run test_get_transit_gateway_connection_all_params. _service.enable_retries() - self.test_get_transit_gateway_route_report_all_params() + self.test_get_transit_gateway_connection_all_params() - # Disable retries and run test_get_transit_gateway_route_report_all_params. + # Disable retries and run test_get_transit_gateway_connection_all_params. _service.disable_retries() - self.test_get_transit_gateway_route_report_all_params() + self.test_get_transit_gateway_connection_all_params() @responses.activate - def test_get_transit_gateway_route_report_value_error(self): + def test_get_transit_gateway_connection_value_error(self): """ - test_get_transit_gateway_route_report_value_error() + test_get_transit_gateway_connection_value_error() """ # Set up mock - url = self.preprocess_url(_base_url + '/transit_gateways/testString/route_reports/testString') - mock_response = '{"connections": [{"bgps": [{"as_path": "(65201 4201065544) 4203065544", "is_used": true, "local_preference": "190", "prefix": "172.17.0.0/16"}], "id": "3c265a62-91da-4261-a950-950b6af0eb58", "name": "transit-connection-vpc1", "routes": [{"prefix": "192.168.0.0/16"}], "type": "vpc"}], "created_at": "2019-01-01T12:00:00.000Z", "id": "1a15dcab-7e26-45e1-b7c5-bc690eaa9724", "overlapping_routes": [{"routes": [{"connection_id": "d2d985d8-1d8e-4e8b-96cd-cee2290ecaff", "prefix": "prefix"}]}], "status": "complete", "updated_at": "2019-01-01T12:00:00.000Z"}' + url = self.preprocess_url(_base_url + '/transit_gateways/testString/connections/testString') + mock_response = '{"base_network_type": "classic", "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.000Z", "local_bgp_asn": 64490, "local_gateway_ip": "192.168.100.1", "local_tunnel_ip": "192.168.129.2", "mtu": 9000, "network_account_id": "28e4d90ac7504be694471ee66e70d0d5", "prefix_filters": [{"action": "permit", "before": "1a15dcab-7e40-45e1-b7c5-bc690eaa9782", "created_at": "2019-01-01T12:00:00.000Z", "ge": 0, "id": "1a15dcab-7e30-45e1-b7c5-bc690eaa9865", "le": 32, "prefix": "192.168.100.0/24", "updated_at": "2019-01-01T12:00:00.000Z"}], "prefix_filters_default": "permit", "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.000Z", "zone": {"name": "us-south-1"}}' responses.add(responses.GET, url, body=mock_response, @@ -1173,74 +1247,21 @@ def test_get_transit_gateway_route_report_value_error(self): 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.get_transit_gateway_route_report(**req_copy) + _service.get_transit_gateway_connection(**req_copy) - def test_get_transit_gateway_route_report_value_error_with_retries(self): - # Enable retries and run test_get_transit_gateway_route_report_value_error. + def test_get_transit_gateway_connection_value_error_with_retries(self): + # Enable retries and run test_get_transit_gateway_connection_value_error. _service.enable_retries() - self.test_get_transit_gateway_route_report_value_error() + self.test_get_transit_gateway_connection_value_error() - # Disable retries and run test_get_transit_gateway_route_report_value_error. + # Disable retries and run test_get_transit_gateway_connection_value_error. _service.disable_retries() - self.test_get_transit_gateway_route_report_value_error() - -# endregion -############################################################################## -# End of Service: TransitGatewayRouteReports -############################################################################## - -############################################################################## -# Start of Service: TransitGateways -############################################################################## -# region - -class TestNewInstance(): - """ - Test Class for new_instance - """ - - def test_new_instance(self): - """ - new_instance() - """ - os.environ['TEST_SERVICE_AUTH_TYPE'] = 'noAuth' - - service = TransitGatewayApisV1.new_instance( - version=version, - service_name='TEST_SERVICE', - ) - - assert service is not None - assert isinstance(service, TransitGatewayApisV1) - - def test_new_instance_without_authenticator(self): - """ - new_instance_without_authenticator() - """ - with pytest.raises(ValueError, match='authenticator must be provided'): - service = TransitGatewayApisV1.new_instance( - version=version, - ) - - def test_new_instance_without_required_params(self): - """ - new_instance_without_required_params() - """ - with pytest.raises(TypeError, match='new_instance\\(\\) missing \\d required positional arguments?: \'.*\''): - service = TransitGatewayApisV1.new_instance() + self.test_get_transit_gateway_connection_value_error() - def test_new_instance_required_param_none(self): - """ - new_instance_required_param_none() - """ - with pytest.raises(ValueError, match='version must be provided'): - service = TransitGatewayApisV1.new_instance( - version=None, - ) -class TestListTransitGateways(): +class TestUpdateTransitGatewayConnection(): """ - Test Class for list_transit_gateways + Test Class for update_transit_gateway_connection """ def preprocess_url(self, request_url: str): @@ -1255,114 +1276,94 @@ def preprocess_url(self, request_url: str): return re.compile(request_url.rstrip('/') + '/+') @responses.activate - def test_list_transit_gateways_all_params(self): + def test_update_transit_gateway_connection_all_params(self): """ - list_transit_gateways() + update_transit_gateway_connection() """ # 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.000Z", "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.000Z"}]}' - responses.add(responses.GET, + url = self.preprocess_url(_base_url + '/transit_gateways/testString/connections/testString') + mock_response = '{"base_network_type": "classic", "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.000Z", "local_bgp_asn": 64490, "local_gateway_ip": "192.168.100.1", "local_tunnel_ip": "192.168.129.2", "mtu": 9000, "network_account_id": "28e4d90ac7504be694471ee66e70d0d5", "prefix_filters": [{"action": "permit", "before": "1a15dcab-7e40-45e1-b7c5-bc690eaa9782", "created_at": "2019-01-01T12:00:00.000Z", "ge": 0, "id": "1a15dcab-7e30-45e1-b7c5-bc690eaa9865", "le": 32, "prefix": "192.168.100.0/24", "updated_at": "2019-01-01T12:00:00.000Z"}], "prefix_filters_default": "permit", "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.000Z", "zone": {"name": "us-south-1"}}' + responses.add(responses.PATCH, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values - limit = 1 - start = 'testString' + transit_gateway_id = 'testString' + id = 'testString' + name = 'Transit_Service_BWTN_SJ_DL' + prefix_filters_default = 'permit' # Invoke method - response = _service.list_transit_gateways( - limit=limit, - start=start, + response = _service.update_transit_gateway_connection( + transit_gateway_id, + id, + name=name, + prefix_filters_default=prefix_filters_default, 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 = urllib.parse.unquote_plus(query_string) - assert 'limit={}'.format(limit) in query_string - assert 'start={}'.format(start) in query_string + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['name'] == 'Transit_Service_BWTN_SJ_DL' + assert req_body['prefix_filters_default'] == 'permit' - def test_list_transit_gateways_all_params_with_retries(self): - # Enable retries and run test_list_transit_gateways_all_params. + def test_update_transit_gateway_connection_all_params_with_retries(self): + # Enable retries and run test_update_transit_gateway_connection_all_params. _service.enable_retries() - self.test_list_transit_gateways_all_params() + self.test_update_transit_gateway_connection_all_params() - # Disable retries and run test_list_transit_gateways_all_params. + # Disable retries and run test_update_transit_gateway_connection_all_params. _service.disable_retries() - self.test_list_transit_gateways_all_params() + self.test_update_transit_gateway_connection_all_params() @responses.activate - def test_list_transit_gateways_required_params(self): + def test_update_transit_gateway_connection_value_error(self): """ - test_list_transit_gateways_required_params() + test_update_transit_gateway_connection_value_error() """ # 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.000Z", "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.000Z"}]}' - responses.add(responses.GET, + url = self.preprocess_url(_base_url + '/transit_gateways/testString/connections/testString') + mock_response = '{"base_network_type": "classic", "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.000Z", "local_bgp_asn": 64490, "local_gateway_ip": "192.168.100.1", "local_tunnel_ip": "192.168.129.2", "mtu": 9000, "network_account_id": "28e4d90ac7504be694471ee66e70d0d5", "prefix_filters": [{"action": "permit", "before": "1a15dcab-7e40-45e1-b7c5-bc690eaa9782", "created_at": "2019-01-01T12:00:00.000Z", "ge": 0, "id": "1a15dcab-7e30-45e1-b7c5-bc690eaa9865", "le": 32, "prefix": "192.168.100.0/24", "updated_at": "2019-01-01T12:00:00.000Z"}], "prefix_filters_default": "permit", "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.000Z", "zone": {"name": "us-south-1"}}' + responses.add(responses.PATCH, url, body=mock_response, content_type='application/json', status=200) - # Invoke method - response = _service.list_transit_gateways() - - - # Check for correct operation - assert len(responses.calls) == 1 - assert response.status_code == 200 - - def test_list_transit_gateways_required_params_with_retries(self): - # Enable retries and run test_list_transit_gateways_required_params. - _service.enable_retries() - self.test_list_transit_gateways_required_params() - - # Disable retries and run test_list_transit_gateways_required_params. - _service.disable_retries() - self.test_list_transit_gateways_required_params() - - @responses.activate - def test_list_transit_gateways_value_error(self): - """ - test_list_transit_gateways_value_error() - """ - # 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.000Z", "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.000Z"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + # Set up parameter values + transit_gateway_id = 'testString' + id = 'testString' + name = 'Transit_Service_BWTN_SJ_DL' + prefix_filters_default = 'permit' # Pass in all but one required param and check for a ValueError req_param_dict = { + "transit_gateway_id": transit_gateway_id, + "id": id, } 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_transit_gateways(**req_copy) + _service.update_transit_gateway_connection(**req_copy) - def test_list_transit_gateways_value_error_with_retries(self): - # Enable retries and run test_list_transit_gateways_value_error. + def test_update_transit_gateway_connection_value_error_with_retries(self): + # Enable retries and run test_update_transit_gateway_connection_value_error. _service.enable_retries() - self.test_list_transit_gateways_value_error() + self.test_update_transit_gateway_connection_value_error() - # Disable retries and run test_list_transit_gateways_value_error. + # Disable retries and run test_update_transit_gateway_connection_value_error. _service.disable_retries() - self.test_list_transit_gateways_value_error() + self.test_update_transit_gateway_connection_value_error() -class TestCreateTransitGateway(): +class TestCreateTransitGatewayConnectionActions(): """ - Test Class for create_transit_gateway + Test Class for create_transit_gateway_connection_actions """ def preprocess_url(self, request_url: str): @@ -1377,104 +1378,139 @@ def preprocess_url(self, request_url: str): return re.compile(request_url.rstrip('/') + '/+') @responses.activate - def test_create_transit_gateway_all_params(self): + def test_create_transit_gateway_connection_actions_all_params(self): """ - create_transit_gateway() + create_transit_gateway_connection_actions() """ # Set up mock - url = self.preprocess_url(_base_url + '/transit_gateways') - mock_response = '{"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.000Z", "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.000Z"}' + url = self.preprocess_url(_base_url + '/transit_gateways/testString/connections/testString/actions') responses.add(responses.POST, url, - body=mock_response, - content_type='application/json', - status=201) - - # Construct a dict representation of a ResourceGroupIdentity model - resource_group_identity_model = {} - resource_group_identity_model['id'] = '56969d6043e9465c883cb9f7363e78e8' + status=204) # Set up parameter values - location = 'us-south' - name = 'Transit_Service_BWTN_SJ_DL' - global_ = True - resource_group = resource_group_identity_model + transit_gateway_id = 'testString' + id = 'testString' + action = 'approve' # Invoke method - response = _service.create_transit_gateway( - location, - name, - global_=global_, - resource_group=resource_group, + response = _service.create_transit_gateway_connection_actions( + transit_gateway_id, + id, + action, headers={} ) # Check for correct operation assert len(responses.calls) == 1 - assert response.status_code == 201 + assert response.status_code == 204 # Validate body params req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) - assert req_body['location'] == 'us-south' - assert req_body['name'] == 'Transit_Service_BWTN_SJ_DL' - assert req_body['global'] == True - assert req_body['resource_group'] == resource_group_identity_model + assert req_body['action'] == 'approve' - def test_create_transit_gateway_all_params_with_retries(self): - # Enable retries and run test_create_transit_gateway_all_params. + def test_create_transit_gateway_connection_actions_all_params_with_retries(self): + # Enable retries and run test_create_transit_gateway_connection_actions_all_params. _service.enable_retries() - self.test_create_transit_gateway_all_params() + self.test_create_transit_gateway_connection_actions_all_params() - # Disable retries and run test_create_transit_gateway_all_params. + # Disable retries and run test_create_transit_gateway_connection_actions_all_params. _service.disable_retries() - self.test_create_transit_gateway_all_params() + self.test_create_transit_gateway_connection_actions_all_params() @responses.activate - def test_create_transit_gateway_value_error(self): + def test_create_transit_gateway_connection_actions_value_error(self): """ - test_create_transit_gateway_value_error() + test_create_transit_gateway_connection_actions_value_error() """ # Set up mock - url = self.preprocess_url(_base_url + '/transit_gateways') - mock_response = '{"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.000Z", "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.000Z"}' + url = self.preprocess_url(_base_url + '/transit_gateways/testString/connections/testString/actions') responses.add(responses.POST, url, - body=mock_response, - content_type='application/json', - status=201) - - # Construct a dict representation of a ResourceGroupIdentity model - resource_group_identity_model = {} - resource_group_identity_model['id'] = '56969d6043e9465c883cb9f7363e78e8' + status=204) # Set up parameter values - location = 'us-south' - name = 'Transit_Service_BWTN_SJ_DL' - global_ = True - resource_group = resource_group_identity_model + transit_gateway_id = 'testString' + id = 'testString' + action = 'approve' # Pass in all but one required param and check for a ValueError req_param_dict = { - "location": location, - "name": name, + "transit_gateway_id": transit_gateway_id, + "id": id, + "action": action, } 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.create_transit_gateway(**req_copy) + _service.create_transit_gateway_connection_actions(**req_copy) - def test_create_transit_gateway_value_error_with_retries(self): - # Enable retries and run test_create_transit_gateway_value_error. + def test_create_transit_gateway_connection_actions_value_error_with_retries(self): + # Enable retries and run test_create_transit_gateway_connection_actions_value_error. _service.enable_retries() - self.test_create_transit_gateway_value_error() + self.test_create_transit_gateway_connection_actions_value_error() - # Disable retries and run test_create_transit_gateway_value_error. + # Disable retries and run test_create_transit_gateway_connection_actions_value_error. _service.disable_retries() - self.test_create_transit_gateway_value_error() + self.test_create_transit_gateway_connection_actions_value_error() -class TestDeleteTransitGateway(): +# endregion +############################################################################## +# End of Service: TransitGatewaysNetworkConnections +############################################################################## + +############################################################################## +# Start of Service: TransitLocation +############################################################################## +# region + +class TestNewInstance(): """ - Test Class for delete_transit_gateway + Test Class for new_instance + """ + + def test_new_instance(self): + """ + new_instance() + """ + os.environ['TEST_SERVICE_AUTH_TYPE'] = 'noAuth' + + service = TransitGatewayApisV1.new_instance( + version=version, + service_name='TEST_SERVICE', + ) + + assert service is not None + assert isinstance(service, TransitGatewayApisV1) + + def test_new_instance_without_authenticator(self): + """ + new_instance_without_authenticator() + """ + with pytest.raises(ValueError, match='authenticator must be provided'): + service = TransitGatewayApisV1.new_instance( + version=version, + service_name='TEST_SERVICE_NOT_FOUND', + ) + + def test_new_instance_without_required_params(self): + """ + new_instance_without_required_params() + """ + with pytest.raises(TypeError, match='new_instance\\(\\) missing \\d required positional arguments?: \'.*\''): + service = TransitGatewayApisV1.new_instance() + + def test_new_instance_required_param_none(self): + """ + new_instance_required_param_none() + """ + with pytest.raises(ValueError, match='version must be provided'): + service = TransitGatewayApisV1.new_instance( + version=None, + ) +class TestListGatewayLocations(): + """ + Test Class for list_gateway_locations """ def preprocess_url(self, request_url: str): @@ -1489,74 +1525,71 @@ def preprocess_url(self, request_url: str): return re.compile(request_url.rstrip('/') + '/+') @responses.activate - def test_delete_transit_gateway_all_params(self): + def test_list_gateway_locations_all_params(self): """ - delete_transit_gateway() + list_gateway_locations() """ # Set up mock - url = self.preprocess_url(_base_url + '/transit_gateways/testString') - responses.add(responses.DELETE, + url = self.preprocess_url(_base_url + '/locations') + mock_response = '{"locations": [{"billing_location": "us", "name": "us-south", "type": "region"}]}' + responses.add(responses.GET, url, - status=204) - - # Set up parameter values - id = 'testString' + body=mock_response, + content_type='application/json', + status=200) # Invoke method - response = _service.delete_transit_gateway( - id, - headers={} - ) + response = _service.list_gateway_locations() + # Check for correct operation assert len(responses.calls) == 1 - assert response.status_code == 204 + assert response.status_code == 200 - def test_delete_transit_gateway_all_params_with_retries(self): - # Enable retries and run test_delete_transit_gateway_all_params. + def test_list_gateway_locations_all_params_with_retries(self): + # Enable retries and run test_list_gateway_locations_all_params. _service.enable_retries() - self.test_delete_transit_gateway_all_params() + self.test_list_gateway_locations_all_params() - # Disable retries and run test_delete_transit_gateway_all_params. + # Disable retries and run test_list_gateway_locations_all_params. _service.disable_retries() - self.test_delete_transit_gateway_all_params() + self.test_list_gateway_locations_all_params() @responses.activate - def test_delete_transit_gateway_value_error(self): + def test_list_gateway_locations_value_error(self): """ - test_delete_transit_gateway_value_error() + test_list_gateway_locations_value_error() """ # Set up mock - url = self.preprocess_url(_base_url + '/transit_gateways/testString') - responses.add(responses.DELETE, + url = self.preprocess_url(_base_url + '/locations') + mock_response = '{"locations": [{"billing_location": "us", "name": "us-south", "type": "region"}]}' + responses.add(responses.GET, url, - status=204) - - # Set up parameter values - id = 'testString' + body=mock_response, + content_type='application/json', + status=200) # Pass in all but one required param and check for a ValueError req_param_dict = { - "id": id, } 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.delete_transit_gateway(**req_copy) + _service.list_gateway_locations(**req_copy) - def test_delete_transit_gateway_value_error_with_retries(self): - # Enable retries and run test_delete_transit_gateway_value_error. + def test_list_gateway_locations_value_error_with_retries(self): + # Enable retries and run test_list_gateway_locations_value_error. _service.enable_retries() - self.test_delete_transit_gateway_value_error() + self.test_list_gateway_locations_value_error() - # Disable retries and run test_delete_transit_gateway_value_error. + # Disable retries and run test_list_gateway_locations_value_error. _service.disable_retries() - self.test_delete_transit_gateway_value_error() + self.test_list_gateway_locations_value_error() -class TestGetTransitGateway(): +class TestGetGatewayLocation(): """ - Test Class for get_transit_gateway + Test Class for get_gateway_location """ def preprocess_url(self, request_url: str): @@ -1571,13 +1604,13 @@ def preprocess_url(self, request_url: str): return re.compile(request_url.rstrip('/') + '/+') @responses.activate - def test_get_transit_gateway_all_params(self): + def test_get_gateway_location_all_params(self): """ - get_transit_gateway() + get_gateway_location() """ # Set up mock - url = self.preprocess_url(_base_url + '/transit_gateways/testString') - mock_response = '{"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.000Z", "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.000Z"}' + url = self.preprocess_url(_base_url + '/locations/testString') + mock_response = '{"billing_location": "us", "name": "us-south", "type": "region", "local_connection_locations": [{"display_name": "Dallas", "name": "us-south", "supported_connection_types": ["supported_connection_types"], "type": "region"}]}' responses.add(responses.GET, url, body=mock_response, @@ -1585,11 +1618,11 @@ def test_get_transit_gateway_all_params(self): status=200) # Set up parameter values - id = 'testString' + name = 'testString' # Invoke method - response = _service.get_transit_gateway( - id, + response = _service.get_gateway_location( + name, headers={} ) @@ -1597,23 +1630,23 @@ def test_get_transit_gateway_all_params(self): assert len(responses.calls) == 1 assert response.status_code == 200 - def test_get_transit_gateway_all_params_with_retries(self): - # Enable retries and run test_get_transit_gateway_all_params. + def test_get_gateway_location_all_params_with_retries(self): + # Enable retries and run test_get_gateway_location_all_params. _service.enable_retries() - self.test_get_transit_gateway_all_params() + self.test_get_gateway_location_all_params() - # Disable retries and run test_get_transit_gateway_all_params. + # Disable retries and run test_get_gateway_location_all_params. _service.disable_retries() - self.test_get_transit_gateway_all_params() + self.test_get_gateway_location_all_params() @responses.activate - def test_get_transit_gateway_value_error(self): + def test_get_gateway_location_value_error(self): """ - test_get_transit_gateway_value_error() + test_get_gateway_location_value_error() """ # Set up mock - url = self.preprocess_url(_base_url + '/transit_gateways/testString') - mock_response = '{"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.000Z", "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.000Z"}' + url = self.preprocess_url(_base_url + '/locations/testString') + mock_response = '{"billing_location": "us", "name": "us-south", "type": "region", "local_connection_locations": [{"display_name": "Dallas", "name": "us-south", "supported_connection_types": ["supported_connection_types"], "type": "region"}]}' responses.add(responses.GET, url, body=mock_response, @@ -1621,31 +1654,85 @@ def test_get_transit_gateway_value_error(self): status=200) # Set up parameter values - id = 'testString' + name = 'testString' # Pass in all but one required param and check for a ValueError req_param_dict = { - "id": id, + "name": name, } 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.get_transit_gateway(**req_copy) + _service.get_gateway_location(**req_copy) - def test_get_transit_gateway_value_error_with_retries(self): - # Enable retries and run test_get_transit_gateway_value_error. + def test_get_gateway_location_value_error_with_retries(self): + # Enable retries and run test_get_gateway_location_value_error. _service.enable_retries() - self.test_get_transit_gateway_value_error() + self.test_get_gateway_location_value_error() - # Disable retries and run test_get_transit_gateway_value_error. + # Disable retries and run test_get_gateway_location_value_error. _service.disable_retries() - self.test_get_transit_gateway_value_error() + self.test_get_gateway_location_value_error() -class TestUpdateTransitGateway(): - """ - Test Class for update_transit_gateway - """ +# endregion +############################################################################## +# End of Service: TransitLocation +############################################################################## + +############################################################################## +# Start of Service: TransitGatewayConnectionPrefixFilters +############################################################################## +# region + +class TestNewInstance(): + """ + Test Class for new_instance + """ + + def test_new_instance(self): + """ + new_instance() + """ + os.environ['TEST_SERVICE_AUTH_TYPE'] = 'noAuth' + + service = TransitGatewayApisV1.new_instance( + version=version, + service_name='TEST_SERVICE', + ) + + assert service is not None + assert isinstance(service, TransitGatewayApisV1) + + def test_new_instance_without_authenticator(self): + """ + new_instance_without_authenticator() + """ + with pytest.raises(ValueError, match='authenticator must be provided'): + service = TransitGatewayApisV1.new_instance( + version=version, + service_name='TEST_SERVICE_NOT_FOUND', + ) + + def test_new_instance_without_required_params(self): + """ + new_instance_without_required_params() + """ + with pytest.raises(TypeError, match='new_instance\\(\\) missing \\d required positional arguments?: \'.*\''): + service = TransitGatewayApisV1.new_instance() + + def test_new_instance_required_param_none(self): + """ + new_instance_required_param_none() + """ + with pytest.raises(ValueError, match='version must be provided'): + service = TransitGatewayApisV1.new_instance( + version=None, + ) +class TestListTransitGatewayConnectionPrefixFilters(): + """ + Test Class for list_transit_gateway_connection_prefix_filters + """ def preprocess_url(self, request_url: str): """ @@ -1659,143 +1746,200 @@ def preprocess_url(self, request_url: str): return re.compile(request_url.rstrip('/') + '/+') @responses.activate - def test_update_transit_gateway_all_params(self): + def test_list_transit_gateway_connection_prefix_filters_all_params(self): """ - update_transit_gateway() + list_transit_gateway_connection_prefix_filters() """ # Set up mock - url = self.preprocess_url(_base_url + '/transit_gateways/testString') - mock_response = '{"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.000Z", "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.000Z"}' - responses.add(responses.PATCH, + url = self.preprocess_url(_base_url + '/transit_gateways/testString/connections/testString/prefix_filters') + mock_response = '{"prefix_filters": [{"action": "permit", "before": "1a15dcab-7e40-45e1-b7c5-bc690eaa9782", "created_at": "2019-01-01T12:00:00.000Z", "ge": 0, "id": "1a15dcab-7e30-45e1-b7c5-bc690eaa9865", "le": 32, "prefix": "192.168.100.0/24", "updated_at": "2019-01-01T12:00:00.000Z"}]}' + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values + transit_gateway_id = 'testString' id = 'testString' - global_ = True - name = 'my-transit-gateway' # Invoke method - response = _service.update_transit_gateway( + response = _service.list_transit_gateway_connection_prefix_filters( + transit_gateway_id, id, - global_=global_, - name=name, headers={} ) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 - # Validate body params - req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) - assert req_body['global'] == True - assert req_body['name'] == 'my-transit-gateway' - def test_update_transit_gateway_all_params_with_retries(self): - # Enable retries and run test_update_transit_gateway_all_params. + def test_list_transit_gateway_connection_prefix_filters_all_params_with_retries(self): + # Enable retries and run test_list_transit_gateway_connection_prefix_filters_all_params. _service.enable_retries() - self.test_update_transit_gateway_all_params() + self.test_list_transit_gateway_connection_prefix_filters_all_params() - # Disable retries and run test_update_transit_gateway_all_params. + # Disable retries and run test_list_transit_gateway_connection_prefix_filters_all_params. _service.disable_retries() - self.test_update_transit_gateway_all_params() + self.test_list_transit_gateway_connection_prefix_filters_all_params() @responses.activate - def test_update_transit_gateway_value_error(self): + def test_list_transit_gateway_connection_prefix_filters_value_error(self): """ - test_update_transit_gateway_value_error() + test_list_transit_gateway_connection_prefix_filters_value_error() """ # Set up mock - url = self.preprocess_url(_base_url + '/transit_gateways/testString') - mock_response = '{"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.000Z", "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.000Z"}' - responses.add(responses.PATCH, + url = self.preprocess_url(_base_url + '/transit_gateways/testString/connections/testString/prefix_filters') + mock_response = '{"prefix_filters": [{"action": "permit", "before": "1a15dcab-7e40-45e1-b7c5-bc690eaa9782", "created_at": "2019-01-01T12:00:00.000Z", "ge": 0, "id": "1a15dcab-7e30-45e1-b7c5-bc690eaa9865", "le": 32, "prefix": "192.168.100.0/24", "updated_at": "2019-01-01T12:00:00.000Z"}]}' + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values + transit_gateway_id = 'testString' id = 'testString' - global_ = True - name = 'my-transit-gateway' # Pass in all but one required param and check for a ValueError req_param_dict = { + "transit_gateway_id": transit_gateway_id, "id": id, } 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.update_transit_gateway(**req_copy) + _service.list_transit_gateway_connection_prefix_filters(**req_copy) - def test_update_transit_gateway_value_error_with_retries(self): - # Enable retries and run test_update_transit_gateway_value_error. + def test_list_transit_gateway_connection_prefix_filters_value_error_with_retries(self): + # Enable retries and run test_list_transit_gateway_connection_prefix_filters_value_error. _service.enable_retries() - self.test_update_transit_gateway_value_error() + self.test_list_transit_gateway_connection_prefix_filters_value_error() - # Disable retries and run test_update_transit_gateway_value_error. + # Disable retries and run test_list_transit_gateway_connection_prefix_filters_value_error. _service.disable_retries() - self.test_update_transit_gateway_value_error() - -# endregion -############################################################################## -# End of Service: TransitGateways -############################################################################## - -############################################################################## -# Start of Service: TransitGatewaysNetworkConnections -############################################################################## -# region + self.test_list_transit_gateway_connection_prefix_filters_value_error() -class TestNewInstance(): +class TestCreateTransitGatewayConnectionPrefixFilter(): """ - Test Class for new_instance + Test Class for create_transit_gateway_connection_prefix_filter """ - def test_new_instance(self): + def preprocess_url(self, request_url: str): """ - new_instance() + Preprocess the request URL to ensure the mock response will be found. """ - os.environ['TEST_SERVICE_AUTH_TYPE'] = 'noAuth' + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + 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('/') + '/+') - service = TransitGatewayApisV1.new_instance( - version=version, - service_name='TEST_SERVICE', + @responses.activate + def test_create_transit_gateway_connection_prefix_filter_all_params(self): + """ + create_transit_gateway_connection_prefix_filter() + """ + # Set up mock + url = self.preprocess_url(_base_url + '/transit_gateways/testString/connections/testString/prefix_filters') + mock_response = '{"action": "permit", "before": "1a15dcab-7e40-45e1-b7c5-bc690eaa9782", "created_at": "2019-01-01T12:00:00.000Z", "ge": 0, "id": "1a15dcab-7e30-45e1-b7c5-bc690eaa9865", "le": 32, "prefix": "192.168.100.0/24", "updated_at": "2019-01-01T12:00:00.000Z"}' + responses.add(responses.POST, + url, + body=mock_response, + content_type='application/json', + status=201) + + # Set up parameter values + transit_gateway_id = 'testString' + id = 'testString' + action = 'permit' + prefix = '192.168.100.0/24' + before = '1a15dcab-7e40-45e1-b7c5-bc690eaa9782' + ge = 0 + le = 32 + + # Invoke method + response = _service.create_transit_gateway_connection_prefix_filter( + transit_gateway_id, + id, + action, + prefix, + before=before, + ge=ge, + le=le, + headers={} ) - assert service is not None - assert isinstance(service, TransitGatewayApisV1) + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 201 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['action'] == 'permit' + assert req_body['prefix'] == '192.168.100.0/24' + assert req_body['before'] == '1a15dcab-7e40-45e1-b7c5-bc690eaa9782' + assert req_body['ge'] == 0 + assert req_body['le'] == 32 - def test_new_instance_without_authenticator(self): - """ - new_instance_without_authenticator() - """ - with pytest.raises(ValueError, match='authenticator must be provided'): - service = TransitGatewayApisV1.new_instance( - version=version, - ) + def test_create_transit_gateway_connection_prefix_filter_all_params_with_retries(self): + # Enable retries and run test_create_transit_gateway_connection_prefix_filter_all_params. + _service.enable_retries() + self.test_create_transit_gateway_connection_prefix_filter_all_params() - def test_new_instance_without_required_params(self): - """ - new_instance_without_required_params() - """ - with pytest.raises(TypeError, match='new_instance\\(\\) missing \\d required positional arguments?: \'.*\''): - service = TransitGatewayApisV1.new_instance() + # Disable retries and run test_create_transit_gateway_connection_prefix_filter_all_params. + _service.disable_retries() + self.test_create_transit_gateway_connection_prefix_filter_all_params() - def test_new_instance_required_param_none(self): + @responses.activate + def test_create_transit_gateway_connection_prefix_filter_value_error(self): """ - new_instance_required_param_none() + test_create_transit_gateway_connection_prefix_filter_value_error() """ - with pytest.raises(ValueError, match='version must be provided'): - service = TransitGatewayApisV1.new_instance( - version=None, - ) -class TestListTransitGatewayConnections(): + # Set up mock + url = self.preprocess_url(_base_url + '/transit_gateways/testString/connections/testString/prefix_filters') + mock_response = '{"action": "permit", "before": "1a15dcab-7e40-45e1-b7c5-bc690eaa9782", "created_at": "2019-01-01T12:00:00.000Z", "ge": 0, "id": "1a15dcab-7e30-45e1-b7c5-bc690eaa9865", "le": 32, "prefix": "192.168.100.0/24", "updated_at": "2019-01-01T12:00:00.000Z"}' + responses.add(responses.POST, + url, + body=mock_response, + content_type='application/json', + status=201) + + # Set up parameter values + transit_gateway_id = 'testString' + id = 'testString' + action = 'permit' + prefix = '192.168.100.0/24' + before = '1a15dcab-7e40-45e1-b7c5-bc690eaa9782' + ge = 0 + le = 32 + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "transit_gateway_id": transit_gateway_id, + "id": id, + "action": action, + "prefix": prefix, + } + 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.create_transit_gateway_connection_prefix_filter(**req_copy) + + + def test_create_transit_gateway_connection_prefix_filter_value_error_with_retries(self): + # Enable retries and run test_create_transit_gateway_connection_prefix_filter_value_error. + _service.enable_retries() + self.test_create_transit_gateway_connection_prefix_filter_value_error() + + # Disable retries and run test_create_transit_gateway_connection_prefix_filter_value_error. + _service.disable_retries() + self.test_create_transit_gateway_connection_prefix_filter_value_error() + +class TestReplaceTransitGatewayConnectionPrefixFilter(): """ - Test Class for list_transit_gateway_connections + Test Class for replace_transit_gateway_connection_prefix_filter """ def preprocess_url(self, request_url: str): @@ -1810,80 +1954,105 @@ def preprocess_url(self, request_url: str): return re.compile(request_url.rstrip('/') + '/+') @responses.activate - def test_list_transit_gateway_connections_all_params(self): + def test_replace_transit_gateway_connection_prefix_filter_all_params(self): """ - list_transit_gateway_connections() + replace_transit_gateway_connection_prefix_filter() """ # 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", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "base_connection_id": "975f58c1-afe7-469a-9727-7f3d720f2d32", "created_at": "2019-01-01T12:00:00.000Z", "local_bgp_asn": 64490, "local_gateway_ip": "192.168.100.1", "local_tunnel_ip": "192.168.129.2", "mtu": 9000, "network_account_id": "28e4d90ac7504be694471ee66e70d0d5", "prefix_filters": [{"action": "permit", "before": "1a15dcab-7e40-45e1-b7c5-bc690eaa9782", "created_at": "2019-01-01T12:00:00.000Z", "ge": 0, "id": "1a15dcab-7e30-45e1-b7c5-bc690eaa9865", "le": 32, "prefix": "192.168.100.0/24", "updated_at": "2019-01-01T12:00:00.000Z"}], "prefix_filters_default": "permit", "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.000Z", "zone": {"name": "us-south-1"}}]}' - responses.add(responses.GET, + url = self.preprocess_url(_base_url + '/transit_gateways/testString/connections/testString/prefix_filters') + mock_response = '{"prefix_filters": [{"action": "permit", "before": "1a15dcab-7e40-45e1-b7c5-bc690eaa9782", "created_at": "2019-01-01T12:00:00.000Z", "ge": 0, "id": "1a15dcab-7e30-45e1-b7c5-bc690eaa9865", "le": 32, "prefix": "192.168.100.0/24", "updated_at": "2019-01-01T12:00:00.000Z"}]}' + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', - status=200) + status=201) + + # Construct a dict representation of a PrefixFilterPut model + prefix_filter_put_model = {} + prefix_filter_put_model['action'] = 'permit' + prefix_filter_put_model['ge'] = 0 + prefix_filter_put_model['le'] = 32 + prefix_filter_put_model['prefix'] = '192.168.100.0/24' # Set up parameter values transit_gateway_id = 'testString' + id = 'testString' + prefix_filters = [prefix_filter_put_model] # Invoke method - response = _service.list_transit_gateway_connections( + response = _service.replace_transit_gateway_connection_prefix_filter( transit_gateway_id, + id, + prefix_filters, headers={} ) # Check for correct operation assert len(responses.calls) == 1 - assert response.status_code == 200 + assert response.status_code == 201 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['prefix_filters'] == [prefix_filter_put_model] - def test_list_transit_gateway_connections_all_params_with_retries(self): - # Enable retries and run test_list_transit_gateway_connections_all_params. + def test_replace_transit_gateway_connection_prefix_filter_all_params_with_retries(self): + # Enable retries and run test_replace_transit_gateway_connection_prefix_filter_all_params. _service.enable_retries() - self.test_list_transit_gateway_connections_all_params() + self.test_replace_transit_gateway_connection_prefix_filter_all_params() - # Disable retries and run test_list_transit_gateway_connections_all_params. + # Disable retries and run test_replace_transit_gateway_connection_prefix_filter_all_params. _service.disable_retries() - self.test_list_transit_gateway_connections_all_params() + self.test_replace_transit_gateway_connection_prefix_filter_all_params() @responses.activate - def test_list_transit_gateway_connections_value_error(self): + def test_replace_transit_gateway_connection_prefix_filter_value_error(self): """ - test_list_transit_gateway_connections_value_error() + test_replace_transit_gateway_connection_prefix_filter_value_error() """ # 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", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "base_connection_id": "975f58c1-afe7-469a-9727-7f3d720f2d32", "created_at": "2019-01-01T12:00:00.000Z", "local_bgp_asn": 64490, "local_gateway_ip": "192.168.100.1", "local_tunnel_ip": "192.168.129.2", "mtu": 9000, "network_account_id": "28e4d90ac7504be694471ee66e70d0d5", "prefix_filters": [{"action": "permit", "before": "1a15dcab-7e40-45e1-b7c5-bc690eaa9782", "created_at": "2019-01-01T12:00:00.000Z", "ge": 0, "id": "1a15dcab-7e30-45e1-b7c5-bc690eaa9865", "le": 32, "prefix": "192.168.100.0/24", "updated_at": "2019-01-01T12:00:00.000Z"}], "prefix_filters_default": "permit", "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.000Z", "zone": {"name": "us-south-1"}}]}' - responses.add(responses.GET, + url = self.preprocess_url(_base_url + '/transit_gateways/testString/connections/testString/prefix_filters') + mock_response = '{"prefix_filters": [{"action": "permit", "before": "1a15dcab-7e40-45e1-b7c5-bc690eaa9782", "created_at": "2019-01-01T12:00:00.000Z", "ge": 0, "id": "1a15dcab-7e30-45e1-b7c5-bc690eaa9865", "le": 32, "prefix": "192.168.100.0/24", "updated_at": "2019-01-01T12:00:00.000Z"}]}' + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', - status=200) + status=201) + + # Construct a dict representation of a PrefixFilterPut model + prefix_filter_put_model = {} + prefix_filter_put_model['action'] = 'permit' + prefix_filter_put_model['ge'] = 0 + prefix_filter_put_model['le'] = 32 + prefix_filter_put_model['prefix'] = '192.168.100.0/24' # Set up parameter values transit_gateway_id = 'testString' + id = 'testString' + prefix_filters = [prefix_filter_put_model] # Pass in all but one required param and check for a ValueError req_param_dict = { "transit_gateway_id": transit_gateway_id, + "id": id, + "prefix_filters": prefix_filters, } 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_transit_gateway_connections(**req_copy) + _service.replace_transit_gateway_connection_prefix_filter(**req_copy) - def test_list_transit_gateway_connections_value_error_with_retries(self): - # Enable retries and run test_list_transit_gateway_connections_value_error. + def test_replace_transit_gateway_connection_prefix_filter_value_error_with_retries(self): + # Enable retries and run test_replace_transit_gateway_connection_prefix_filter_value_error. _service.enable_retries() - self.test_list_transit_gateway_connections_value_error() + self.test_replace_transit_gateway_connection_prefix_filter_value_error() - # Disable retries and run test_list_transit_gateway_connections_value_error. + # Disable retries and run test_replace_transit_gateway_connection_prefix_filter_value_error. _service.disable_retries() - self.test_list_transit_gateway_connections_value_error() + self.test_replace_transit_gateway_connection_prefix_filter_value_error() -class TestCreateTransitGatewayConnection(): +class TestDeleteTransitGatewayConnectionPrefixFilter(): """ - Test Class for create_transit_gateway_connection + Test Class for delete_transit_gateway_connection_prefix_filter """ def preprocess_url(self, request_url: str): @@ -1898,157 +2067,82 @@ def preprocess_url(self, request_url: str): return re.compile(request_url.rstrip('/') + '/+') @responses.activate - def test_create_transit_gateway_connection_all_params(self): + def test_delete_transit_gateway_connection_prefix_filter_all_params(self): """ - create_transit_gateway_connection() + delete_transit_gateway_connection_prefix_filter() """ # 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", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "base_connection_id": "975f58c1-afe7-469a-9727-7f3d720f2d32", "created_at": "2019-01-01T12:00:00.000Z", "local_bgp_asn": 64490, "local_gateway_ip": "192.168.100.1", "local_tunnel_ip": "192.168.129.2", "mtu": 9000, "network_account_id": "28e4d90ac7504be694471ee66e70d0d5", "prefix_filters": [{"action": "permit", "before": "1a15dcab-7e40-45e1-b7c5-bc690eaa9782", "created_at": "2019-01-01T12:00:00.000Z", "ge": 0, "id": "1a15dcab-7e30-45e1-b7c5-bc690eaa9865", "le": 32, "prefix": "192.168.100.0/24", "updated_at": "2019-01-01T12:00:00.000Z"}], "prefix_filters_default": "permit", "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.000Z", "zone": {"name": "us-south-1"}}' - responses.add(responses.POST, + url = self.preprocess_url(_base_url + '/transit_gateways/testString/connections/testString/prefix_filters/testString') + responses.add(responses.DELETE, url, - body=mock_response, - content_type='application/json', - status=201) - - # Construct a dict representation of a TransitGatewayConnectionPrefixFilter model - transit_gateway_connection_prefix_filter_model = {} - transit_gateway_connection_prefix_filter_model['action'] = 'permit' - transit_gateway_connection_prefix_filter_model['ge'] = 0 - transit_gateway_connection_prefix_filter_model['le'] = 32 - transit_gateway_connection_prefix_filter_model['prefix'] = '192.168.100.0/24' - - # Construct a dict representation of a ZoneIdentityByName model - zone_identity_model = {} - zone_identity_model['name'] = 'us-south-1' + status=204) # 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_account_id = '28e4d90ac7504be694471ee66e70d0d5' - network_id = 'crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b' - prefix_filters = [transit_gateway_connection_prefix_filter_model] - prefix_filters_default = 'permit' - remote_bgp_asn = '65010' - remote_gateway_ip = '10.242.63.12' - remote_tunnel_ip = '192.168.129.1' - zone = zone_identity_model + id = 'testString' + filter_id = 'testString' # Invoke method - response = _service.create_transit_gateway_connection( + response = _service.delete_transit_gateway_connection_prefix_filter( 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_account_id=network_account_id, - network_id=network_id, - prefix_filters=prefix_filters, - prefix_filters_default=prefix_filters_default, - remote_bgp_asn=remote_bgp_asn, - remote_gateway_ip=remote_gateway_ip, - remote_tunnel_ip=remote_tunnel_ip, - zone=zone, + id, + filter_id, headers={} ) # Check for correct operation assert len(responses.calls) == 1 - assert response.status_code == 201 - # 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_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['prefix_filters'] == [transit_gateway_connection_prefix_filter_model] - assert req_body['prefix_filters_default'] == 'permit' - 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 + assert response.status_code == 204 - def test_create_transit_gateway_connection_all_params_with_retries(self): - # Enable retries and run test_create_transit_gateway_connection_all_params. + def test_delete_transit_gateway_connection_prefix_filter_all_params_with_retries(self): + # Enable retries and run test_delete_transit_gateway_connection_prefix_filter_all_params. _service.enable_retries() - self.test_create_transit_gateway_connection_all_params() + self.test_delete_transit_gateway_connection_prefix_filter_all_params() - # Disable retries and run test_create_transit_gateway_connection_all_params. + # Disable retries and run test_delete_transit_gateway_connection_prefix_filter_all_params. _service.disable_retries() - self.test_create_transit_gateway_connection_all_params() + self.test_delete_transit_gateway_connection_prefix_filter_all_params() @responses.activate - def test_create_transit_gateway_connection_value_error(self): + def test_delete_transit_gateway_connection_prefix_filter_value_error(self): """ - test_create_transit_gateway_connection_value_error() + test_delete_transit_gateway_connection_prefix_filter_value_error() """ # 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", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "base_connection_id": "975f58c1-afe7-469a-9727-7f3d720f2d32", "created_at": "2019-01-01T12:00:00.000Z", "local_bgp_asn": 64490, "local_gateway_ip": "192.168.100.1", "local_tunnel_ip": "192.168.129.2", "mtu": 9000, "network_account_id": "28e4d90ac7504be694471ee66e70d0d5", "prefix_filters": [{"action": "permit", "before": "1a15dcab-7e40-45e1-b7c5-bc690eaa9782", "created_at": "2019-01-01T12:00:00.000Z", "ge": 0, "id": "1a15dcab-7e30-45e1-b7c5-bc690eaa9865", "le": 32, "prefix": "192.168.100.0/24", "updated_at": "2019-01-01T12:00:00.000Z"}], "prefix_filters_default": "permit", "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.000Z", "zone": {"name": "us-south-1"}}' - responses.add(responses.POST, + url = self.preprocess_url(_base_url + '/transit_gateways/testString/connections/testString/prefix_filters/testString') + responses.add(responses.DELETE, url, - body=mock_response, - content_type='application/json', - status=201) - - # Construct a dict representation of a TransitGatewayConnectionPrefixFilter model - transit_gateway_connection_prefix_filter_model = {} - transit_gateway_connection_prefix_filter_model['action'] = 'permit' - transit_gateway_connection_prefix_filter_model['ge'] = 0 - transit_gateway_connection_prefix_filter_model['le'] = 32 - transit_gateway_connection_prefix_filter_model['prefix'] = '192.168.100.0/24' - - # Construct a dict representation of a ZoneIdentityByName model - zone_identity_model = {} - zone_identity_model['name'] = 'us-south-1' + status=204) # 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_account_id = '28e4d90ac7504be694471ee66e70d0d5' - network_id = 'crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b' - prefix_filters = [transit_gateway_connection_prefix_filter_model] - prefix_filters_default = 'permit' - remote_bgp_asn = '65010' - remote_gateway_ip = '10.242.63.12' - remote_tunnel_ip = '192.168.129.1' - zone = zone_identity_model + id = 'testString' + filter_id = 'testString' # Pass in all but one required param and check for a ValueError req_param_dict = { "transit_gateway_id": transit_gateway_id, - "network_type": network_type, + "id": id, + "filter_id": filter_id, } 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.create_transit_gateway_connection(**req_copy) + _service.delete_transit_gateway_connection_prefix_filter(**req_copy) - def test_create_transit_gateway_connection_value_error_with_retries(self): - # Enable retries and run test_create_transit_gateway_connection_value_error. + def test_delete_transit_gateway_connection_prefix_filter_value_error_with_retries(self): + # Enable retries and run test_delete_transit_gateway_connection_prefix_filter_value_error. _service.enable_retries() - self.test_create_transit_gateway_connection_value_error() + self.test_delete_transit_gateway_connection_prefix_filter_value_error() - # Disable retries and run test_create_transit_gateway_connection_value_error. + # Disable retries and run test_delete_transit_gateway_connection_prefix_filter_value_error. _service.disable_retries() - self.test_create_transit_gateway_connection_value_error() + self.test_delete_transit_gateway_connection_prefix_filter_value_error() -class TestDeleteTransitGatewayConnection(): +class TestGetTransitGatewayConnectionPrefixFilter(): """ - Test Class for delete_transit_gateway_connection + Test Class for get_transit_gateway_connection_prefix_filter """ def preprocess_url(self, request_url: str): @@ -2063,78 +2157,88 @@ def preprocess_url(self, request_url: str): return re.compile(request_url.rstrip('/') + '/+') @responses.activate - def test_delete_transit_gateway_connection_all_params(self): + def test_get_transit_gateway_connection_prefix_filter_all_params(self): """ - delete_transit_gateway_connection() + get_transit_gateway_connection_prefix_filter() """ # Set up mock - url = self.preprocess_url(_base_url + '/transit_gateways/testString/connections/testString') - responses.add(responses.DELETE, + url = self.preprocess_url(_base_url + '/transit_gateways/testString/connections/testString/prefix_filters/testString') + mock_response = '{"action": "permit", "before": "1a15dcab-7e40-45e1-b7c5-bc690eaa9782", "created_at": "2019-01-01T12:00:00.000Z", "ge": 0, "id": "1a15dcab-7e30-45e1-b7c5-bc690eaa9865", "le": 32, "prefix": "192.168.100.0/24", "updated_at": "2019-01-01T12:00:00.000Z"}' + responses.add(responses.GET, url, - status=204) + body=mock_response, + content_type='application/json', + status=200) # Set up parameter values transit_gateway_id = 'testString' id = 'testString' + filter_id = 'testString' # Invoke method - response = _service.delete_transit_gateway_connection( + response = _service.get_transit_gateway_connection_prefix_filter( transit_gateway_id, id, + filter_id, headers={} ) # Check for correct operation assert len(responses.calls) == 1 - assert response.status_code == 204 + assert response.status_code == 200 - def test_delete_transit_gateway_connection_all_params_with_retries(self): - # Enable retries and run test_delete_transit_gateway_connection_all_params. + def test_get_transit_gateway_connection_prefix_filter_all_params_with_retries(self): + # Enable retries and run test_get_transit_gateway_connection_prefix_filter_all_params. _service.enable_retries() - self.test_delete_transit_gateway_connection_all_params() + self.test_get_transit_gateway_connection_prefix_filter_all_params() - # Disable retries and run test_delete_transit_gateway_connection_all_params. + # Disable retries and run test_get_transit_gateway_connection_prefix_filter_all_params. _service.disable_retries() - self.test_delete_transit_gateway_connection_all_params() + self.test_get_transit_gateway_connection_prefix_filter_all_params() @responses.activate - def test_delete_transit_gateway_connection_value_error(self): + def test_get_transit_gateway_connection_prefix_filter_value_error(self): """ - test_delete_transit_gateway_connection_value_error() + test_get_transit_gateway_connection_prefix_filter_value_error() """ # Set up mock - url = self.preprocess_url(_base_url + '/transit_gateways/testString/connections/testString') - responses.add(responses.DELETE, + url = self.preprocess_url(_base_url + '/transit_gateways/testString/connections/testString/prefix_filters/testString') + mock_response = '{"action": "permit", "before": "1a15dcab-7e40-45e1-b7c5-bc690eaa9782", "created_at": "2019-01-01T12:00:00.000Z", "ge": 0, "id": "1a15dcab-7e30-45e1-b7c5-bc690eaa9865", "le": 32, "prefix": "192.168.100.0/24", "updated_at": "2019-01-01T12:00:00.000Z"}' + responses.add(responses.GET, url, - status=204) + body=mock_response, + content_type='application/json', + status=200) # Set up parameter values transit_gateway_id = 'testString' id = 'testString' + filter_id = 'testString' # Pass in all but one required param and check for a ValueError req_param_dict = { "transit_gateway_id": transit_gateway_id, "id": id, + "filter_id": filter_id, } 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.delete_transit_gateway_connection(**req_copy) + _service.get_transit_gateway_connection_prefix_filter(**req_copy) - def test_delete_transit_gateway_connection_value_error_with_retries(self): - # Enable retries and run test_delete_transit_gateway_connection_value_error. + def test_get_transit_gateway_connection_prefix_filter_value_error_with_retries(self): + # Enable retries and run test_get_transit_gateway_connection_prefix_filter_value_error. _service.enable_retries() - self.test_delete_transit_gateway_connection_value_error() + self.test_get_transit_gateway_connection_prefix_filter_value_error() - # Disable retries and run test_delete_transit_gateway_connection_value_error. + # Disable retries and run test_get_transit_gateway_connection_prefix_filter_value_error. _service.disable_retries() - self.test_delete_transit_gateway_connection_value_error() + self.test_get_transit_gateway_connection_prefix_filter_value_error() -class TestGetTransitGatewayConnection(): +class TestUpdateTransitGatewayConnectionPrefixFilter(): """ - Test Class for get_transit_gateway_connection + Test Class for update_transit_gateway_connection_prefix_filter """ def preprocess_url(self, request_url: str): @@ -2149,14 +2253,14 @@ def preprocess_url(self, request_url: str): return re.compile(request_url.rstrip('/') + '/+') @responses.activate - def test_get_transit_gateway_connection_all_params(self): + def test_update_transit_gateway_connection_prefix_filter_all_params(self): """ - get_transit_gateway_connection() + update_transit_gateway_connection_prefix_filter() """ # 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", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "base_connection_id": "975f58c1-afe7-469a-9727-7f3d720f2d32", "created_at": "2019-01-01T12:00:00.000Z", "local_bgp_asn": 64490, "local_gateway_ip": "192.168.100.1", "local_tunnel_ip": "192.168.129.2", "mtu": 9000, "network_account_id": "28e4d90ac7504be694471ee66e70d0d5", "prefix_filters": [{"action": "permit", "before": "1a15dcab-7e40-45e1-b7c5-bc690eaa9782", "created_at": "2019-01-01T12:00:00.000Z", "ge": 0, "id": "1a15dcab-7e30-45e1-b7c5-bc690eaa9865", "le": 32, "prefix": "192.168.100.0/24", "updated_at": "2019-01-01T12:00:00.000Z"}], "prefix_filters_default": "permit", "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.000Z", "zone": {"name": "us-south-1"}}' - responses.add(responses.GET, + url = self.preprocess_url(_base_url + '/transit_gateways/testString/connections/testString/prefix_filters/testString') + mock_response = '{"action": "permit", "before": "1a15dcab-7e40-45e1-b7c5-bc690eaa9782", "created_at": "2019-01-01T12:00:00.000Z", "ge": 0, "id": "1a15dcab-7e30-45e1-b7c5-bc690eaa9865", "le": 32, "prefix": "192.168.100.0/24", "updated_at": "2019-01-01T12:00:00.000Z"}' + responses.add(responses.PATCH, url, body=mock_response, content_type='application/json', @@ -2165,36 +2269,55 @@ def test_get_transit_gateway_connection_all_params(self): # Set up parameter values transit_gateway_id = 'testString' id = 'testString' + filter_id = 'testString' + action = 'permit' + before = '1a15dcab-7e40-45e1-b7c5-bc690eaa9782' + ge = 0 + le = 32 + prefix = '192.168.100.0/24' # Invoke method - response = _service.get_transit_gateway_connection( + response = _service.update_transit_gateway_connection_prefix_filter( transit_gateway_id, id, + filter_id, + action=action, + before=before, + ge=ge, + le=le, + prefix=prefix, headers={} ) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['action'] == 'permit' + assert req_body['before'] == '1a15dcab-7e40-45e1-b7c5-bc690eaa9782' + assert req_body['ge'] == 0 + assert req_body['le'] == 32 + assert req_body['prefix'] == '192.168.100.0/24' - def test_get_transit_gateway_connection_all_params_with_retries(self): - # Enable retries and run test_get_transit_gateway_connection_all_params. + def test_update_transit_gateway_connection_prefix_filter_all_params_with_retries(self): + # Enable retries and run test_update_transit_gateway_connection_prefix_filter_all_params. _service.enable_retries() - self.test_get_transit_gateway_connection_all_params() + self.test_update_transit_gateway_connection_prefix_filter_all_params() - # Disable retries and run test_get_transit_gateway_connection_all_params. + # Disable retries and run test_update_transit_gateway_connection_prefix_filter_all_params. _service.disable_retries() - self.test_get_transit_gateway_connection_all_params() + self.test_update_transit_gateway_connection_prefix_filter_all_params() @responses.activate - def test_get_transit_gateway_connection_value_error(self): + def test_update_transit_gateway_connection_prefix_filter_value_error(self): """ - test_get_transit_gateway_connection_value_error() + test_update_transit_gateway_connection_prefix_filter_value_error() """ # 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", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "base_connection_id": "975f58c1-afe7-469a-9727-7f3d720f2d32", "created_at": "2019-01-01T12:00:00.000Z", "local_bgp_asn": 64490, "local_gateway_ip": "192.168.100.1", "local_tunnel_ip": "192.168.129.2", "mtu": 9000, "network_account_id": "28e4d90ac7504be694471ee66e70d0d5", "prefix_filters": [{"action": "permit", "before": "1a15dcab-7e40-45e1-b7c5-bc690eaa9782", "created_at": "2019-01-01T12:00:00.000Z", "ge": 0, "id": "1a15dcab-7e30-45e1-b7c5-bc690eaa9865", "le": 32, "prefix": "192.168.100.0/24", "updated_at": "2019-01-01T12:00:00.000Z"}], "prefix_filters_default": "permit", "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.000Z", "zone": {"name": "us-south-1"}}' - responses.add(responses.GET, + url = self.preprocess_url(_base_url + '/transit_gateways/testString/connections/testString/prefix_filters/testString') + mock_response = '{"action": "permit", "before": "1a15dcab-7e40-45e1-b7c5-bc690eaa9782", "created_at": "2019-01-01T12:00:00.000Z", "ge": 0, "id": "1a15dcab-7e30-45e1-b7c5-bc690eaa9865", "le": 32, "prefix": "192.168.100.0/24", "updated_at": "2019-01-01T12:00:00.000Z"}' + responses.add(responses.PATCH, url, body=mock_response, content_type='application/json', @@ -2203,30 +2326,91 @@ def test_get_transit_gateway_connection_value_error(self): # Set up parameter values transit_gateway_id = 'testString' id = 'testString' + filter_id = 'testString' + action = 'permit' + before = '1a15dcab-7e40-45e1-b7c5-bc690eaa9782' + ge = 0 + le = 32 + prefix = '192.168.100.0/24' # Pass in all but one required param and check for a ValueError req_param_dict = { "transit_gateway_id": transit_gateway_id, "id": id, + "filter_id": filter_id, } 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.get_transit_gateway_connection(**req_copy) + _service.update_transit_gateway_connection_prefix_filter(**req_copy) - def test_get_transit_gateway_connection_value_error_with_retries(self): - # Enable retries and run test_get_transit_gateway_connection_value_error. + def test_update_transit_gateway_connection_prefix_filter_value_error_with_retries(self): + # Enable retries and run test_update_transit_gateway_connection_prefix_filter_value_error. _service.enable_retries() - self.test_get_transit_gateway_connection_value_error() + self.test_update_transit_gateway_connection_prefix_filter_value_error() - # Disable retries and run test_get_transit_gateway_connection_value_error. + # Disable retries and run test_update_transit_gateway_connection_prefix_filter_value_error. _service.disable_retries() - self.test_get_transit_gateway_connection_value_error() + self.test_update_transit_gateway_connection_prefix_filter_value_error() -class TestUpdateTransitGatewayConnection(): +# endregion +############################################################################## +# End of Service: TransitGatewayConnectionPrefixFilters +############################################################################## + +############################################################################## +# Start of Service: TransitGatewayRouteReports +############################################################################## +# region + +class TestNewInstance(): """ - Test Class for update_transit_gateway_connection + Test Class for new_instance + """ + + def test_new_instance(self): + """ + new_instance() + """ + os.environ['TEST_SERVICE_AUTH_TYPE'] = 'noAuth' + + service = TransitGatewayApisV1.new_instance( + version=version, + service_name='TEST_SERVICE', + ) + + assert service is not None + assert isinstance(service, TransitGatewayApisV1) + + def test_new_instance_without_authenticator(self): + """ + new_instance_without_authenticator() + """ + with pytest.raises(ValueError, match='authenticator must be provided'): + service = TransitGatewayApisV1.new_instance( + version=version, + service_name='TEST_SERVICE_NOT_FOUND', + ) + + def test_new_instance_without_required_params(self): + """ + new_instance_without_required_params() + """ + with pytest.raises(TypeError, match='new_instance\\(\\) missing \\d required positional arguments?: \'.*\''): + service = TransitGatewayApisV1.new_instance() + + def test_new_instance_required_param_none(self): + """ + new_instance_required_param_none() + """ + with pytest.raises(ValueError, match='version must be provided'): + service = TransitGatewayApisV1.new_instance( + version=None, + ) +class TestListTransitGatewayRouteReports(): + """ + Test Class for list_transit_gateway_route_reports """ def preprocess_url(self, request_url: str): @@ -2241,14 +2425,14 @@ def preprocess_url(self, request_url: str): return re.compile(request_url.rstrip('/') + '/+') @responses.activate - def test_update_transit_gateway_connection_all_params(self): + def test_list_transit_gateway_route_reports_all_params(self): """ - update_transit_gateway_connection() + list_transit_gateway_route_reports() """ # 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", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "base_connection_id": "975f58c1-afe7-469a-9727-7f3d720f2d32", "created_at": "2019-01-01T12:00:00.000Z", "local_bgp_asn": 64490, "local_gateway_ip": "192.168.100.1", "local_tunnel_ip": "192.168.129.2", "mtu": 9000, "network_account_id": "28e4d90ac7504be694471ee66e70d0d5", "prefix_filters": [{"action": "permit", "before": "1a15dcab-7e40-45e1-b7c5-bc690eaa9782", "created_at": "2019-01-01T12:00:00.000Z", "ge": 0, "id": "1a15dcab-7e30-45e1-b7c5-bc690eaa9865", "le": 32, "prefix": "192.168.100.0/24", "updated_at": "2019-01-01T12:00:00.000Z"}], "prefix_filters_default": "permit", "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.000Z", "zone": {"name": "us-south-1"}}' - responses.add(responses.PATCH, + url = self.preprocess_url(_base_url + '/transit_gateways/testString/route_reports') + mock_response = '{"route_reports": [{"connections": [{"bgps": [{"as_path": "(65201 4201065544) 4203065544", "is_used": true, "local_preference": "190", "prefix": "172.17.0.0/16"}], "id": "3c265a62-91da-4261-a950-950b6af0eb58", "name": "transit-connection-vpc1", "routes": [{"prefix": "192.168.0.0/16"}], "type": "vpc"}], "created_at": "2019-01-01T12:00:00.000Z", "id": "1a15dcab-7e26-45e1-b7c5-bc690eaa9724", "overlapping_routes": [{"routes": [{"connection_id": "d2d985d8-1d8e-4e8b-96cd-cee2290ecaff", "prefix": "prefix"}]}], "status": "complete", "updated_at": "2019-01-01T12:00:00.000Z"}]}' + responses.add(responses.GET, url, body=mock_response, content_type='application/json', @@ -2256,45 +2440,35 @@ def test_update_transit_gateway_connection_all_params(self): # Set up parameter values transit_gateway_id = 'testString' - id = 'testString' - name = 'Transit_Service_BWTN_SJ_DL' - prefix_filters_default = 'permit' # Invoke method - response = _service.update_transit_gateway_connection( + response = _service.list_transit_gateway_route_reports( transit_gateway_id, - id, - name=name, - prefix_filters_default=prefix_filters_default, headers={} ) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 - # Validate body params - req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) - assert req_body['name'] == 'Transit_Service_BWTN_SJ_DL' - assert req_body['prefix_filters_default'] == 'permit' - def test_update_transit_gateway_connection_all_params_with_retries(self): - # Enable retries and run test_update_transit_gateway_connection_all_params. + def test_list_transit_gateway_route_reports_all_params_with_retries(self): + # Enable retries and run test_list_transit_gateway_route_reports_all_params. _service.enable_retries() - self.test_update_transit_gateway_connection_all_params() + self.test_list_transit_gateway_route_reports_all_params() - # Disable retries and run test_update_transit_gateway_connection_all_params. + # Disable retries and run test_list_transit_gateway_route_reports_all_params. _service.disable_retries() - self.test_update_transit_gateway_connection_all_params() + self.test_list_transit_gateway_route_reports_all_params() @responses.activate - def test_update_transit_gateway_connection_value_error(self): + def test_list_transit_gateway_route_reports_value_error(self): """ - test_update_transit_gateway_connection_value_error() + test_list_transit_gateway_route_reports_value_error() """ # 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", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "base_connection_id": "975f58c1-afe7-469a-9727-7f3d720f2d32", "created_at": "2019-01-01T12:00:00.000Z", "local_bgp_asn": 64490, "local_gateway_ip": "192.168.100.1", "local_tunnel_ip": "192.168.129.2", "mtu": 9000, "network_account_id": "28e4d90ac7504be694471ee66e70d0d5", "prefix_filters": [{"action": "permit", "before": "1a15dcab-7e40-45e1-b7c5-bc690eaa9782", "created_at": "2019-01-01T12:00:00.000Z", "ge": 0, "id": "1a15dcab-7e30-45e1-b7c5-bc690eaa9865", "le": 32, "prefix": "192.168.100.0/24", "updated_at": "2019-01-01T12:00:00.000Z"}], "prefix_filters_default": "permit", "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.000Z", "zone": {"name": "us-south-1"}}' - responses.add(responses.PATCH, + url = self.preprocess_url(_base_url + '/transit_gateways/testString/route_reports') + mock_response = '{"route_reports": [{"connections": [{"bgps": [{"as_path": "(65201 4201065544) 4203065544", "is_used": true, "local_preference": "190", "prefix": "172.17.0.0/16"}], "id": "3c265a62-91da-4261-a950-950b6af0eb58", "name": "transit-connection-vpc1", "routes": [{"prefix": "192.168.0.0/16"}], "type": "vpc"}], "created_at": "2019-01-01T12:00:00.000Z", "id": "1a15dcab-7e26-45e1-b7c5-bc690eaa9724", "overlapping_routes": [{"routes": [{"connection_id": "d2d985d8-1d8e-4e8b-96cd-cee2290ecaff", "prefix": "prefix"}]}], "status": "complete", "updated_at": "2019-01-01T12:00:00.000Z"}]}' + responses.add(responses.GET, url, body=mock_response, content_type='application/json', @@ -2302,33 +2476,29 @@ def test_update_transit_gateway_connection_value_error(self): # Set up parameter values transit_gateway_id = 'testString' - id = 'testString' - name = 'Transit_Service_BWTN_SJ_DL' - prefix_filters_default = 'permit' # Pass in all but one required param and check for a ValueError req_param_dict = { "transit_gateway_id": transit_gateway_id, - "id": id, } 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.update_transit_gateway_connection(**req_copy) + _service.list_transit_gateway_route_reports(**req_copy) - def test_update_transit_gateway_connection_value_error_with_retries(self): - # Enable retries and run test_update_transit_gateway_connection_value_error. + def test_list_transit_gateway_route_reports_value_error_with_retries(self): + # Enable retries and run test_list_transit_gateway_route_reports_value_error. _service.enable_retries() - self.test_update_transit_gateway_connection_value_error() + self.test_list_transit_gateway_route_reports_value_error() - # Disable retries and run test_update_transit_gateway_connection_value_error. + # Disable retries and run test_list_transit_gateway_route_reports_value_error. _service.disable_retries() - self.test_update_transit_gateway_connection_value_error() + self.test_list_transit_gateway_route_reports_value_error() -class TestCreateTransitGatewayConnectionActions(): +class TestCreateTransitGatewayRouteReport(): """ - Test Class for create_transit_gateway_connection_actions + Test Class for create_transit_gateway_route_report """ def preprocess_url(self, request_url: str): @@ -2343,138 +2513,80 @@ def preprocess_url(self, request_url: str): return re.compile(request_url.rstrip('/') + '/+') @responses.activate - def test_create_transit_gateway_connection_actions_all_params(self): + def test_create_transit_gateway_route_report_all_params(self): """ - create_transit_gateway_connection_actions() + create_transit_gateway_route_report() """ # Set up mock - url = self.preprocess_url(_base_url + '/transit_gateways/testString/connections/testString/actions') + url = self.preprocess_url(_base_url + '/transit_gateways/testString/route_reports') + mock_response = '{"connections": [{"bgps": [{"as_path": "(65201 4201065544) 4203065544", "is_used": true, "local_preference": "190", "prefix": "172.17.0.0/16"}], "id": "3c265a62-91da-4261-a950-950b6af0eb58", "name": "transit-connection-vpc1", "routes": [{"prefix": "192.168.0.0/16"}], "type": "vpc"}], "created_at": "2019-01-01T12:00:00.000Z", "id": "1a15dcab-7e26-45e1-b7c5-bc690eaa9724", "overlapping_routes": [{"routes": [{"connection_id": "d2d985d8-1d8e-4e8b-96cd-cee2290ecaff", "prefix": "prefix"}]}], "status": "complete", "updated_at": "2019-01-01T12:00:00.000Z"}' responses.add(responses.POST, url, - status=204) + body=mock_response, + content_type='application/json', + status=202) # Set up parameter values transit_gateway_id = 'testString' - id = 'testString' - action = 'approve' # Invoke method - response = _service.create_transit_gateway_connection_actions( + response = _service.create_transit_gateway_route_report( transit_gateway_id, - id, - action, headers={} ) # Check for correct operation assert len(responses.calls) == 1 - assert response.status_code == 204 - # Validate body params - req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) - assert req_body['action'] == 'approve' + assert response.status_code == 202 - def test_create_transit_gateway_connection_actions_all_params_with_retries(self): - # Enable retries and run test_create_transit_gateway_connection_actions_all_params. + def test_create_transit_gateway_route_report_all_params_with_retries(self): + # Enable retries and run test_create_transit_gateway_route_report_all_params. _service.enable_retries() - self.test_create_transit_gateway_connection_actions_all_params() + self.test_create_transit_gateway_route_report_all_params() - # Disable retries and run test_create_transit_gateway_connection_actions_all_params. + # Disable retries and run test_create_transit_gateway_route_report_all_params. _service.disable_retries() - self.test_create_transit_gateway_connection_actions_all_params() + self.test_create_transit_gateway_route_report_all_params() @responses.activate - def test_create_transit_gateway_connection_actions_value_error(self): + def test_create_transit_gateway_route_report_value_error(self): """ - test_create_transit_gateway_connection_actions_value_error() + test_create_transit_gateway_route_report_value_error() """ # Set up mock - url = self.preprocess_url(_base_url + '/transit_gateways/testString/connections/testString/actions') + url = self.preprocess_url(_base_url + '/transit_gateways/testString/route_reports') + mock_response = '{"connections": [{"bgps": [{"as_path": "(65201 4201065544) 4203065544", "is_used": true, "local_preference": "190", "prefix": "172.17.0.0/16"}], "id": "3c265a62-91da-4261-a950-950b6af0eb58", "name": "transit-connection-vpc1", "routes": [{"prefix": "192.168.0.0/16"}], "type": "vpc"}], "created_at": "2019-01-01T12:00:00.000Z", "id": "1a15dcab-7e26-45e1-b7c5-bc690eaa9724", "overlapping_routes": [{"routes": [{"connection_id": "d2d985d8-1d8e-4e8b-96cd-cee2290ecaff", "prefix": "prefix"}]}], "status": "complete", "updated_at": "2019-01-01T12:00:00.000Z"}' responses.add(responses.POST, url, - status=204) + body=mock_response, + content_type='application/json', + status=202) # Set up parameter values transit_gateway_id = 'testString' - id = 'testString' - action = 'approve' # Pass in all but one required param and check for a ValueError req_param_dict = { "transit_gateway_id": transit_gateway_id, - "id": id, - "action": action, } 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.create_transit_gateway_connection_actions(**req_copy) + _service.create_transit_gateway_route_report(**req_copy) - def test_create_transit_gateway_connection_actions_value_error_with_retries(self): - # Enable retries and run test_create_transit_gateway_connection_actions_value_error. + def test_create_transit_gateway_route_report_value_error_with_retries(self): + # Enable retries and run test_create_transit_gateway_route_report_value_error. _service.enable_retries() - self.test_create_transit_gateway_connection_actions_value_error() + self.test_create_transit_gateway_route_report_value_error() - # Disable retries and run test_create_transit_gateway_connection_actions_value_error. + # Disable retries and run test_create_transit_gateway_route_report_value_error. _service.disable_retries() - self.test_create_transit_gateway_connection_actions_value_error() - -# endregion -############################################################################## -# End of Service: TransitGatewaysNetworkConnections -############################################################################## - -############################################################################## -# Start of Service: TransitLocation -############################################################################## -# region - -class TestNewInstance(): - """ - Test Class for new_instance - """ - - def test_new_instance(self): - """ - new_instance() - """ - os.environ['TEST_SERVICE_AUTH_TYPE'] = 'noAuth' - - service = TransitGatewayApisV1.new_instance( - version=version, - service_name='TEST_SERVICE', - ) - - assert service is not None - assert isinstance(service, TransitGatewayApisV1) - - def test_new_instance_without_authenticator(self): - """ - new_instance_without_authenticator() - """ - with pytest.raises(ValueError, match='authenticator must be provided'): - service = TransitGatewayApisV1.new_instance( - version=version, - ) - - def test_new_instance_without_required_params(self): - """ - new_instance_without_required_params() - """ - with pytest.raises(TypeError, match='new_instance\\(\\) missing \\d required positional arguments?: \'.*\''): - service = TransitGatewayApisV1.new_instance() + self.test_create_transit_gateway_route_report_value_error() - def test_new_instance_required_param_none(self): - """ - new_instance_required_param_none() - """ - with pytest.raises(ValueError, match='version must be provided'): - service = TransitGatewayApisV1.new_instance( - version=None, - ) -class TestListGatewayLocations(): +class TestDeleteTransitGatewayRouteReport(): """ - Test Class for list_gateway_locations + Test Class for delete_transit_gateway_route_report """ def preprocess_url(self, request_url: str): @@ -2489,71 +2601,78 @@ def preprocess_url(self, request_url: str): return re.compile(request_url.rstrip('/') + '/+') @responses.activate - def test_list_gateway_locations_all_params(self): + def test_delete_transit_gateway_route_report_all_params(self): """ - list_gateway_locations() + delete_transit_gateway_route_report() """ # Set up mock - url = self.preprocess_url(_base_url + '/locations') - mock_response = '{"locations": [{"billing_location": "us", "name": "us-south", "type": "region"}]}' - responses.add(responses.GET, + url = self.preprocess_url(_base_url + '/transit_gateways/testString/route_reports/testString') + responses.add(responses.DELETE, url, - body=mock_response, - content_type='application/json', - status=200) + status=204) - # Invoke method - response = _service.list_gateway_locations() + # Set up parameter values + transit_gateway_id = 'testString' + id = 'testString' + # Invoke method + response = _service.delete_transit_gateway_route_report( + transit_gateway_id, + id, + headers={} + ) # Check for correct operation assert len(responses.calls) == 1 - assert response.status_code == 200 + assert response.status_code == 204 - def test_list_gateway_locations_all_params_with_retries(self): - # Enable retries and run test_list_gateway_locations_all_params. + def test_delete_transit_gateway_route_report_all_params_with_retries(self): + # Enable retries and run test_delete_transit_gateway_route_report_all_params. _service.enable_retries() - self.test_list_gateway_locations_all_params() + self.test_delete_transit_gateway_route_report_all_params() - # Disable retries and run test_list_gateway_locations_all_params. + # Disable retries and run test_delete_transit_gateway_route_report_all_params. _service.disable_retries() - self.test_list_gateway_locations_all_params() + self.test_delete_transit_gateway_route_report_all_params() @responses.activate - def test_list_gateway_locations_value_error(self): + def test_delete_transit_gateway_route_report_value_error(self): """ - test_list_gateway_locations_value_error() + test_delete_transit_gateway_route_report_value_error() """ # Set up mock - url = self.preprocess_url(_base_url + '/locations') - mock_response = '{"locations": [{"billing_location": "us", "name": "us-south", "type": "region"}]}' - responses.add(responses.GET, + url = self.preprocess_url(_base_url + '/transit_gateways/testString/route_reports/testString') + responses.add(responses.DELETE, url, - body=mock_response, - content_type='application/json', - status=200) + status=204) + + # Set up parameter values + transit_gateway_id = 'testString' + id = 'testString' # Pass in all but one required param and check for a ValueError req_param_dict = { + "transit_gateway_id": transit_gateway_id, + "id": id, } 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_gateway_locations(**req_copy) + _service.delete_transit_gateway_route_report(**req_copy) - def test_list_gateway_locations_value_error_with_retries(self): - # Enable retries and run test_list_gateway_locations_value_error. + def test_delete_transit_gateway_route_report_value_error_with_retries(self): + # Enable retries and run test_delete_transit_gateway_route_report_value_error. _service.enable_retries() - self.test_list_gateway_locations_value_error() + self.test_delete_transit_gateway_route_report_value_error() - # Disable retries and run test_list_gateway_locations_value_error. + # Disable retries and run test_delete_transit_gateway_route_report_value_error. _service.disable_retries() - self.test_list_gateway_locations_value_error() + self.test_delete_transit_gateway_route_report_value_error() -class TestGetGatewayLocation(): +class TestGetTransitGatewayRouteReport(): """ - Test Class for get_gateway_location + Test Class for get_transit_gateway_route_report """ def preprocess_url(self, request_url: str): @@ -2568,13 +2687,13 @@ def preprocess_url(self, request_url: str): return re.compile(request_url.rstrip('/') + '/+') @responses.activate - def test_get_gateway_location_all_params(self): + def test_get_transit_gateway_route_report_all_params(self): """ - get_gateway_location() + get_transit_gateway_route_report() """ # Set up mock - url = self.preprocess_url(_base_url + '/locations/testString') - mock_response = '{"billing_location": "us", "name": "us-south", "type": "region", "local_connection_locations": [{"display_name": "Dallas", "name": "us-south", "type": "region"}]}' + url = self.preprocess_url(_base_url + '/transit_gateways/testString/route_reports/testString') + mock_response = '{"connections": [{"bgps": [{"as_path": "(65201 4201065544) 4203065544", "is_used": true, "local_preference": "190", "prefix": "172.17.0.0/16"}], "id": "3c265a62-91da-4261-a950-950b6af0eb58", "name": "transit-connection-vpc1", "routes": [{"prefix": "192.168.0.0/16"}], "type": "vpc"}], "created_at": "2019-01-01T12:00:00.000Z", "id": "1a15dcab-7e26-45e1-b7c5-bc690eaa9724", "overlapping_routes": [{"routes": [{"connection_id": "d2d985d8-1d8e-4e8b-96cd-cee2290ecaff", "prefix": "prefix"}]}], "status": "complete", "updated_at": "2019-01-01T12:00:00.000Z"}' responses.add(responses.GET, url, body=mock_response, @@ -2582,11 +2701,13 @@ def test_get_gateway_location_all_params(self): status=200) # Set up parameter values - name = 'testString' + transit_gateway_id = 'testString' + id = 'testString' # Invoke method - response = _service.get_gateway_location( - name, + response = _service.get_transit_gateway_route_report( + transit_gateway_id, + id, headers={} ) @@ -2594,23 +2715,23 @@ def test_get_gateway_location_all_params(self): assert len(responses.calls) == 1 assert response.status_code == 200 - def test_get_gateway_location_all_params_with_retries(self): - # Enable retries and run test_get_gateway_location_all_params. + def test_get_transit_gateway_route_report_all_params_with_retries(self): + # Enable retries and run test_get_transit_gateway_route_report_all_params. _service.enable_retries() - self.test_get_gateway_location_all_params() + self.test_get_transit_gateway_route_report_all_params() - # Disable retries and run test_get_gateway_location_all_params. + # Disable retries and run test_get_transit_gateway_route_report_all_params. _service.disable_retries() - self.test_get_gateway_location_all_params() + self.test_get_transit_gateway_route_report_all_params() @responses.activate - def test_get_gateway_location_value_error(self): + def test_get_transit_gateway_route_report_value_error(self): """ - test_get_gateway_location_value_error() + test_get_transit_gateway_route_report_value_error() """ # Set up mock - url = self.preprocess_url(_base_url + '/locations/testString') - mock_response = '{"billing_location": "us", "name": "us-south", "type": "region", "local_connection_locations": [{"display_name": "Dallas", "name": "us-south", "type": "region"}]}' + url = self.preprocess_url(_base_url + '/transit_gateways/testString/route_reports/testString') + mock_response = '{"connections": [{"bgps": [{"as_path": "(65201 4201065544) 4203065544", "is_used": true, "local_preference": "190", "prefix": "172.17.0.0/16"}], "id": "3c265a62-91da-4261-a950-950b6af0eb58", "name": "transit-connection-vpc1", "routes": [{"prefix": "192.168.0.0/16"}], "type": "vpc"}], "created_at": "2019-01-01T12:00:00.000Z", "id": "1a15dcab-7e26-45e1-b7c5-bc690eaa9724", "overlapping_routes": [{"routes": [{"connection_id": "d2d985d8-1d8e-4e8b-96cd-cee2290ecaff", "prefix": "prefix"}]}], "status": "complete", "updated_at": "2019-01-01T12:00:00.000Z"}' responses.add(responses.GET, url, body=mock_response, @@ -2618,30 +2739,32 @@ def test_get_gateway_location_value_error(self): status=200) # Set up parameter values - name = 'testString' + transit_gateway_id = 'testString' + id = 'testString' # Pass in all but one required param and check for a ValueError req_param_dict = { - "name": name, + "transit_gateway_id": transit_gateway_id, + "id": id, } 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.get_gateway_location(**req_copy) + _service.get_transit_gateway_route_report(**req_copy) - def test_get_gateway_location_value_error_with_retries(self): - # Enable retries and run test_get_gateway_location_value_error. + def test_get_transit_gateway_route_report_value_error_with_retries(self): + # Enable retries and run test_get_transit_gateway_route_report_value_error. _service.enable_retries() - self.test_get_gateway_location_value_error() + self.test_get_transit_gateway_route_report_value_error() - # Disable retries and run test_get_gateway_location_value_error. + # Disable retries and run test_get_transit_gateway_route_report_value_error. _service.disable_retries() - self.test_get_gateway_location_value_error() + self.test_get_transit_gateway_route_report_value_error() # endregion ############################################################################## -# End of Service: TransitLocation +# End of Service: TransitGatewayRouteReports ############################################################################## @@ -2726,6 +2849,38 @@ def test_prefix_filter_cust_serialization(self): prefix_filter_cust_model_json2 = prefix_filter_cust_model.to_dict() assert prefix_filter_cust_model_json2 == prefix_filter_cust_model_json +class TestModel_PrefixFilterPut(): + """ + Test Class for PrefixFilterPut + """ + + def test_prefix_filter_put_serialization(self): + """ + Test serialization/deserialization for PrefixFilterPut + """ + + # Construct a json representation of a PrefixFilterPut model + prefix_filter_put_model_json = {} + prefix_filter_put_model_json['action'] = 'permit' + prefix_filter_put_model_json['ge'] = 0 + prefix_filter_put_model_json['le'] = 32 + prefix_filter_put_model_json['prefix'] = '192.168.100.0/24' + + # Construct a model instance of PrefixFilterPut by calling from_dict on the json representation + prefix_filter_put_model = PrefixFilterPut.from_dict(prefix_filter_put_model_json) + assert prefix_filter_put_model != False + + # Construct a model instance of PrefixFilterPut by calling from_dict on the json representation + prefix_filter_put_model_dict = PrefixFilterPut.from_dict(prefix_filter_put_model_json).__dict__ + prefix_filter_put_model2 = PrefixFilterPut(**prefix_filter_put_model_dict) + + # Verify the model instances are equivalent + assert prefix_filter_put_model == prefix_filter_put_model2 + + # Convert model instance back to dict and verify no loss of data + prefix_filter_put_model_json2 = prefix_filter_put_model.to_dict() + assert prefix_filter_put_model_json2 == prefix_filter_put_model_json + class TestModel_ResourceGroupIdentity(): """ Test Class for ResourceGroupIdentity @@ -3126,6 +3281,7 @@ def test_ts_local_location_serialization(self): ts_local_location_model_json = {} ts_local_location_model_json['display_name'] = 'Dallas' ts_local_location_model_json['name'] = 'us-south' + ts_local_location_model_json['supported_connection_types'] = ['classic', 'vpc', 'directlink', 'gre_tunnel', 'power_virtual_server'] ts_local_location_model_json['type'] = 'region' # Construct a model instance of TSLocalLocation by calling from_dict on the json representation @@ -3158,6 +3314,7 @@ def test_ts_location_serialization(self): ts_local_location_model = {} # TSLocalLocation ts_local_location_model['display_name'] = 'Dallas' ts_local_location_model['name'] = 'us-south' + ts_local_location_model['supported_connection_types'] = ['classic', 'vpc', 'directlink', 'gre_tunnel', 'power_virtual_server'] ts_local_location_model['type'] = 'region' # Construct a json representation of a TSLocation model @@ -3607,6 +3764,7 @@ def test_transit_gateway_connection_collection_serialization(self): transit_gateway_connection_cust_zone_model['name'] = 'us-south-1' transit_gateway_connection_cust_model = {} # TransitGatewayConnectionCust + transit_gateway_connection_cust_model['base_network_type'] = 'classic' 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' @@ -3674,6 +3832,7 @@ def test_transit_gateway_connection_cust_serialization(self): # Construct a json representation of a TransitGatewayConnectionCust model transit_gateway_connection_cust_model_json = {} + transit_gateway_connection_cust_model_json['base_network_type'] = 'classic' 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'