diff --git a/ibm_cloud_networking_services/direct_link_provider_v2.py b/ibm_cloud_networking_services/direct_link_provider_v2.py index 180a293..54a3693 100644 --- a/ibm_cloud_networking_services/direct_link_provider_v2.py +++ b/ibm_cloud_networking_services/direct_link_provider_v2.py @@ -1,6 +1,6 @@ # coding: utf-8 -# (C) Copyright IBM Corp. 2020. +# (C) Copyright IBM Corp. 2021. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -324,6 +324,9 @@ def get_provider_gateway(self, def update_provider_gateway(self, id: str, *, + bgp_asn: int = None, + bgp_cer_cidr: str = None, + bgp_ibm_cidr: str = None, name: str = None, speed_mbps: int = None, **kwargs @@ -336,6 +339,26 @@ def update_provider_gateway(self, change_request and require approval from the client. :param str id: Direct Link Connect gateway identifier. + :param int bgp_asn: (optional) The autonomous system number (ASN) of Border + Gateway Protocol (BGP) configuration for the IBM side of the DL 2.0 + gateway. + :param str bgp_cer_cidr: (optional) BGP customer edge router CIDR is the + new CIDR (Classless Inter-Domain Routing) value to be updated on customer + edge router for the DL 2.0 gateway. Customer edge IP and IBM IP should be + in the same network. Updating customer edge router CIDR should be + accompanied with IBM CIDR in the request. Update customer edge router IP to + a valid bgp_cer_cidr and bgp_ibm_cidr CIDR, the value must reside in one of + "10.254.0.0/16", "172.16.0.0/12", "192.168.0.0/16", "169.254.0.0/16" or an + owned public CIDR. bgp_cer_cidr and bgp_ibm_cidr must have matching + network and subnet mask values. + :param str bgp_ibm_cidr: (optional) BGP IBM CIDR is the new CIDR (Classless + Inter-Domain Routing) value to be updated on IBM edge router for the DL 2.0 + gateway. IBM IP and customer edge IP should be in the same network. + Updating IBM CIDR should be accompanied with customer edge router CIDR in + the request. Update IBM CIDR to a valid bgp_cer_cidr and bgp_ibm_cidr CIDR, + the value must reside in one of "10.254.0.0/16", "172.16.0.0/12", + "192.168.0.0/16", "169.254.0.0/16" or an owned public CIDR. bgp_cer_cidr + and bgp_ibm_cidr must have matching network and subnet mask values. :param str name: (optional) The unique user-defined name for this gateway. :param int speed_mbps: (optional) Gateway speed in megabits per second. :param dict headers: A `dict` containing the request headers @@ -356,6 +379,9 @@ def update_provider_gateway(self, } data = { + 'bgp_asn': bgp_asn, + 'bgp_cer_cidr': bgp_cer_cidr, + 'bgp_ibm_cidr': bgp_ibm_cidr, 'name': name, 'speed_mbps': speed_mbps } @@ -481,7 +507,7 @@ class ProviderGateway(): :attr str bgp_ibm_cidr: (optional) BGP IBM CIDR. :attr str bgp_status: (optional) Gateway BGP status. The list of enumerated values for this property may expand in the future. Code - and processes using this field must tolerate unexpected values. + and processes using this field must tolerate unexpected values. :attr ProviderGatewayChangeRequest change_request: (optional) :attr datetime created_at: The date and time resource was created. :attr str crn: (optional) The CRN (Cloud Resource Name) of this gateway. @@ -490,7 +516,7 @@ class ProviderGateway(): :attr str name: The unique user-defined name for this gateway. :attr str operational_status: Gateway operational status. The list of enumerated values for this property may expand in the future. Code - and processes using this field must tolerate unexpected values. + and processes using this field must tolerate unexpected values. :attr ProviderGatewayPortReference port: Port identifier for the gateway. :attr bool provider_api_managed: Set to `true` for gateways created through the Direct Link Provider APIs. @@ -534,7 +560,7 @@ def __init__(self, :param str name: The unique user-defined name for this gateway. :param str operational_status: Gateway operational status. The list of enumerated values for this property may expand in the future. - Code and processes using this field must tolerate unexpected values. + Code and processes using this field must tolerate unexpected values. :param ProviderGatewayPortReference port: Port identifier for the gateway. :param bool provider_api_managed: Set to `true` for gateways created through the Direct Link Provider APIs. @@ -546,7 +572,7 @@ def __init__(self, :param str bgp_ibm_cidr: (optional) BGP IBM CIDR. :param str bgp_status: (optional) Gateway BGP status. The list of enumerated values for this property may expand in the future. - Code and processes using this field must tolerate unexpected values. + Code and processes using this field must tolerate unexpected values. :param ProviderGatewayChangeRequest change_request: (optional) :param str crn: (optional) The CRN (Cloud Resource Name) of this gateway. :param int vlan: (optional) VLAN allocated for this gateway. @@ -697,7 +723,7 @@ class BgpStatusEnum(Enum): """ Gateway BGP status. The list of enumerated values for this property may expand in the future. Code and - processes using this field must tolerate unexpected values. + processes using this field must tolerate unexpected values. """ ACTIVE = "active" CONNECT = "connect" @@ -709,8 +735,9 @@ class OperationalStatusEnum(Enum): """ Gateway operational status. The list of enumerated values for this property may expand in the future. Code and - processes using this field must tolerate unexpected values. + processes using this field must tolerate unexpected values. """ + CONFIGURING = "configuring" CREATE_PENDING = "create_pending" CREATE_REJECTED = "create_rejected" DELETE_PENDING = "delete_pending" diff --git a/ibm_cloud_networking_services/direct_link_v1.py b/ibm_cloud_networking_services/direct_link_v1.py index 0fff042..528cf20 100644 --- a/ibm_cloud_networking_services/direct_link_v1.py +++ b/ibm_cloud_networking_services/direct_link_v1.py @@ -14,9 +14,13 @@ # See the License for the specific language governing permissions and # limitations under the License. +# IBM OpenAPI SDK Code Generator Version: 3.39.0-748eb4ca-20210917-165907 + """ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +API Version: __VERSION__ """ from datetime import datetime @@ -77,7 +81,7 @@ def __init__(self, provided. Specify the current date to request the latest version. :param Authenticator authenticator: The authenticator specifies the authentication mechanism. - Get up to date information from https://github.com/IBM/python-sdk-core/blob/master/README.md + Get up to date information from https://github.com/IBM/python-sdk-core/blob/main/README.md about initializing the authenticator of your choice. """ if version is None: @@ -120,6 +124,7 @@ def list_gateways(self, if 'headers' in kwargs: headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' url = '/gateways' request = self.prepare_request(method='GET', @@ -127,7 +132,7 @@ def list_gateways(self, headers=headers, params=params) - response = self.send(request) + response = self.send(request, **kwargs) return response @@ -165,6 +170,7 @@ def create_gateway(self, if 'headers' in kwargs: headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' url = '/gateways' request = self.prepare_request(method='POST', @@ -173,7 +179,7 @@ def create_gateway(self, params=params, data=data) - response = self.send(request) + response = self.send(request, **kwargs) return response @@ -207,14 +213,16 @@ def delete_gateway(self, if 'headers' in kwargs: headers.update(kwargs.get('headers')) - url = '/gateways/{0}'.format( - *self.encode_path_vars(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 = '/gateways/{id}'.format(**path_param_dict) request = self.prepare_request(method='DELETE', url=url, headers=headers, params=params) - response = self.send(request) + response = self.send(request, **kwargs) return response @@ -247,15 +255,18 @@ def get_gateway(self, if 'headers' in kwargs: headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' - url = '/gateways/{0}'.format( - *self.encode_path_vars(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 = '/gateways/{id}'.format(**path_param_dict) request = self.prepare_request(method='GET', url=url, headers=headers, params=params) - response = self.send(request) + response = self.send(request, **kwargs) return response @@ -263,6 +274,10 @@ def update_gateway(self, id: str, *, authentication_key: 'GatewayPatchTemplateAuthenticationKey' = None, + bfd_config: 'GatewayBfdPatchTemplate' = None, + bgp_asn: int = None, + bgp_cer_cidr: str = None, + bgp_ibm_cidr: str = None, connection_mode: str = None, global_: bool = None, loa_reject_reason: str = None, @@ -270,6 +285,7 @@ def update_gateway(self, metered: bool = None, name: str = None, operational_status: str = None, + patch_panel_completion_notice: str = None, speed_mbps: int = None, **kwargs ) -> DetailedResponse: @@ -284,6 +300,30 @@ def update_gateway(self, The key material that you provide must be base64 encoded and original string must be maximum 126 ASCII characters in length. To clear the optional `authentication_key` field patch its crn to `""`. + :param GatewayBfdPatchTemplate bfd_config: (optional) BFD configuration + information. + :param int bgp_asn: (optional) The autonomous system number (ASN) of Border + Gateway Protocol (BGP) configuration for the IBM side of the DL 2.0 + gateway. + :param str bgp_cer_cidr: (optional) BGP customer edge router CIDR is the + new CIDR (Classless Inter-Domain Routing) value to be updated on customer + edge router for the DL 2.0 gateway. + Customer edge IP and IBM IP should be in the same network. Updating + customer edge router CIDR should be accompanied with IBM CIDR in the + request. Update customer edge router IP to a valid bgp_cer_cidr and + bgp_ibm_cidr CIDR, the value must reside in one of "10.254.0.0/16", + "172.16.0.0/12", "192.168.0.0/16", "169.254.0.0/16" or an owned public + CIDR. bgp_cer_cidr and bgp_ibm_cidr must have matching network and subnet + mask values. + :param str bgp_ibm_cidr: (optional) BGP IBM CIDR is the new CIDR (Classless + Inter-Domain Routing) value to be updated on IBM edge router for the DL 2.0 + gateway. + IBM IP and customer edge IP should be in the same network. Updating IBM + CIDR should be accompanied with customer edge router CIDR in the request. + Update IBM CIDR to a valid bgp_cer_cidr and bgp_ibm_cidr CIDR, the value + must reside in one of "10.254.0.0/16", "172.16.0.0/12", "192.168.0.0/16", + "169.254.0.0/16" or an owned public CIDR. bgp_cer_cidr and bgp_ibm_cidr + must have matching network and subnet mask values. :param str connection_mode: (optional) Type of services this Gateway is attached to. Mode transit means this Gateway will be attached to Transit Gateway Service and direct means this Gateway will be attached to vpc or @@ -309,6 +349,8 @@ def update_gateway(self, appropriate value to approve or reject its LOA. When rejecting an LOA, provide reject reasoning in `loa_reject_reason`. Only allowed for type=dedicated gateways. + :param str patch_panel_completion_notice: (optional) Gateway patch panel + complete notification from implementation team. :param int speed_mbps: (optional) Gateway speed in megabits per second. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. @@ -319,6 +361,8 @@ def update_gateway(self, raise ValueError('id must be provided') if authentication_key is not None: authentication_key = convert_model(authentication_key) + if bfd_config is not None: + bfd_config = convert_model(bfd_config) if macsec_config is not None: macsec_config = convert_model(macsec_config) headers = {} @@ -333,6 +377,10 @@ def update_gateway(self, data = { 'authentication_key': authentication_key, + 'bfd_config': bfd_config, + 'bgp_asn': bgp_asn, + 'bgp_cer_cidr': bgp_cer_cidr, + 'bgp_ibm_cidr': bgp_ibm_cidr, 'connection_mode': connection_mode, 'global': global_, 'loa_reject_reason': loa_reject_reason, @@ -340,6 +388,7 @@ def update_gateway(self, 'metered': metered, 'name': name, 'operational_status': operational_status, + 'patch_panel_completion_notice': patch_panel_completion_notice, 'speed_mbps': speed_mbps } data = {k: v for (k, v) in data.items() if v is not None} @@ -348,16 +397,19 @@ def update_gateway(self, if 'headers' in kwargs: headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' - url = '/gateways/{0}'.format( - *self.encode_path_vars(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 = '/gateways/{id}'.format(**path_param_dict) request = self.prepare_request(method='PATCH', url=url, headers=headers, params=params, data=data) - response = self.send(request) + response = self.send(request, **kwargs) return response @@ -366,11 +418,12 @@ def create_gateway_action(self, action: str, *, authentication_key: 'GatewayActionTemplateAuthenticationKey' = None, + bfd_config: 'GatewayBfdConfigActionTemplate' = None, connection_mode: str = None, global_: bool = None, metered: bool = None, resource_group: 'ResourceGroupIdentity' = None, - updates: List[object] = None, + updates: List['GatewayActionTemplateUpdatesItem'] = None, **kwargs ) -> DetailedResponse: """ @@ -383,22 +436,27 @@ def create_gateway_action(self, :param str id: Direct Link Connect gateway identifier. :param str action: Action request. :param GatewayActionTemplateAuthenticationKey authentication_key: - (optional) The identity of the standard key to use for BGP MD5 - authentication key. + (optional) Applicable for create_gateway_approve requests to select the + gateway's BGP MD5 authentication key. The key material that you provide must be base64 encoded and original string must be maximum 126 ASCII characters in length. To clear the optional `authentication_key` field patch its crn to `""`. - :param str connection_mode: (optional) Type of services this Gateway is - attached to. Mode transit means this Gateway will be attached to Transit - Gateway Service and direct means this Gateway will be attached to vpc or - classic connection. The list of enumerated values for this property may - expand in the future. Code and processes using this field must tolerate - unexpected values. - :param bool global_: (optional) Required for create_gateway_approve - requests to select the gateway's routing option. Gateways with global + :param GatewayBfdConfigActionTemplate bfd_config: (optional) Applicable for + create_gateway_approve requests to select the gateway's BFD configuration + information. + :param str connection_mode: (optional) Applicable for + create_gateway_approve requests to select the type of services this gateway + is attached to. Mode transit indicates this gateway will be attached to + Transit Gateway Service and direct means this gateway will be attached to + vpc or classic connection. If unspecified on create_gateway_approve, + default value direct is used. The list of enumerated values for this + property may expand in the future. Code and processes using this field must + tolerate unexpected values. + :param bool global_: (optional) Applicable for create_gateway_approve + requests to select the gateway's routing option. Gateways with global routing (`true`) can connect to networks outside of their associated region. - :param bool metered: (optional) Required for create_gateway_approve + :param bool metered: (optional) Applicable for create_gateway_approve requests to select the gateway's metered billing option. When `true` gateway usage is billed per gigabyte. When `false` there is no per gigabyte usage charge, instead a flat rate is charged for the gateway. @@ -407,8 +465,8 @@ def create_gateway_action(self, unspecified on create_gateway_approve, the account's [default resource group](https://cloud.ibm.com/apidocs/resource-manager#introduction) is used. - :param List[object] updates: (optional) Specify attribute updates being - approved or rejected, update_attributes_approve and + :param List[GatewayActionTemplateUpdatesItem] updates: (optional) Specify + attribute updates being approved or rejected, update_attributes_approve and update_attributes_reject actions must provide an updates field that matches the gateway's current pending changes. :param dict headers: A `dict` containing the request headers @@ -422,8 +480,12 @@ def create_gateway_action(self, raise ValueError('action must be provided') if authentication_key is not None: authentication_key = convert_model(authentication_key) + if bfd_config is not None: + bfd_config = convert_model(bfd_config) if resource_group is not None: resource_group = convert_model(resource_group) + if updates is not None: + updates = [convert_model(x) for x in updates] headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', @@ -437,6 +499,7 @@ def create_gateway_action(self, data = { 'action': action, 'authentication_key': authentication_key, + 'bfd_config': bfd_config, 'connection_mode': connection_mode, 'global': global_, 'metered': metered, @@ -449,16 +512,19 @@ def create_gateway_action(self, if 'headers' in kwargs: headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' - url = '/gateways/{0}/actions'.format( - *self.encode_path_vars(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 = '/gateways/{id}/actions'.format(**path_param_dict) request = self.prepare_request(method='POST', url=url, headers=headers, params=params, data=data) - response = self.send(request) + response = self.send(request, **kwargs) return response @@ -491,15 +557,18 @@ def list_gateway_completion_notice(self, if 'headers' in kwargs: headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/pdf' - url = '/gateways/{0}/completion_notice'.format( - *self.encode_path_vars(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 = '/gateways/{id}/completion_notice'.format(**path_param_dict) request = self.prepare_request(method='GET', url=url, headers=headers, params=params) - response = self.send(request) + response = self.send(request, **kwargs) return response @@ -542,15 +611,17 @@ def create_gateway_completion_notice(self, if 'headers' in kwargs: headers.update(kwargs.get('headers')) - url = '/gateways/{0}/completion_notice'.format( - *self.encode_path_vars(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 = '/gateways/{id}/completion_notice'.format(**path_param_dict) request = self.prepare_request(method='PUT', url=url, headers=headers, params=params, files=form_data) - response = self.send(request) + response = self.send(request, **kwargs) return response @@ -583,15 +654,18 @@ def list_gateway_letter_of_authorization(self, if 'headers' in kwargs: headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/pdf' - url = '/gateways/{0}/letter_of_authorization'.format( - *self.encode_path_vars(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 = '/gateways/{id}/letter_of_authorization'.format(**path_param_dict) request = self.prepare_request(method='GET', url=url, headers=headers, params=params) - response = self.send(request) + response = self.send(request, **kwargs) return response @@ -601,14 +675,13 @@ def get_gateway_statistics(self, **kwargs ) -> DetailedResponse: """ - Gateway statistics. + Gateway statistics/debug information. - Retrieve gateway statistics. Specify statistic to retrieve using required `type` - query parameter. Currently data retrieval is only supported for MACsec - configurations. + Retrieve gateway statistics or debug information. Specify statistic to retrieve + using required `type` query parameter. - :param str id: Direct Link Dedicated gateway identifier. - :param str type: specify statistic to retrieve. + :param str id: Direct Link gateway identifier. + :param str type: Specify statistic to retrieve. :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 `GatewayStatisticCollection` object @@ -631,15 +704,67 @@ def get_gateway_statistics(self, 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_dict = dict(zip(path_param_keys, path_param_values)) + url = '/gateways/{id}/statistics'.format(**path_param_dict) + request = self.prepare_request(method='GET', + url=url, + headers=headers, + params=params) + + response = self.send(request, **kwargs) + return response + + + def get_gateway_status(self, + id: str, + *, + type: str = None, + **kwargs + ) -> DetailedResponse: + """ + Gateway status information. + + Retrieve gateway status. Specify status to retrieve using required `type` query + parameter. + + :param str id: Direct Link gateway identifier. + :param str type: (optional) Specify status to retrieve. + :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 `GatewayStatusCollection` 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_gateway_status') + headers.update(sdk_headers) + + params = { + 'version': self.version, + 'type': type + } + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' - url = '/gateways/{0}/statistics'.format( - *self.encode_path_vars(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 = '/gateways/{id}/status'.format(**path_param_dict) request = self.prepare_request(method='GET', url=url, headers=headers, params=params) - response = self.send(request) + response = self.send(request, **kwargs) return response ######################### @@ -677,15 +802,18 @@ def list_offering_type_locations(self, if 'headers' in kwargs: headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' - url = '/offering_types/{0}/locations'.format( - *self.encode_path_vars(offering_type)) + path_param_keys = ['offering_type'] + path_param_values = self.encode_path_vars(offering_type) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/offering_types/{offering_type}/locations'.format(**path_param_dict) request = self.prepare_request(method='GET', url=url, headers=headers, params=params) - response = self.send(request) + response = self.send(request, **kwargs) return response @@ -724,15 +852,18 @@ def list_offering_type_location_cross_connect_routers(self, if 'headers' in kwargs: headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' - url = '/offering_types/{0}/locations/{1}/cross_connect_routers'.format( - *self.encode_path_vars(offering_type, location_name)) + path_param_keys = ['offering_type', 'location_name'] + path_param_values = self.encode_path_vars(offering_type, location_name) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/offering_types/{offering_type}/locations/{location_name}/cross_connect_routers'.format(**path_param_dict) request = self.prepare_request(method='GET', url=url, headers=headers, params=params) - response = self.send(request) + response = self.send(request, **kwargs) return response @@ -766,15 +897,18 @@ def list_offering_type_speeds(self, if 'headers' in kwargs: headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' - url = '/offering_types/{0}/speeds'.format( - *self.encode_path_vars(offering_type)) + path_param_keys = ['offering_type'] + path_param_values = self.encode_path_vars(offering_type) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/offering_types/{offering_type}/speeds'.format(**path_param_dict) request = self.prepare_request(method='GET', url=url, headers=headers, params=params) - response = self.send(request) + response = self.send(request, **kwargs) return response ######################### @@ -819,6 +953,7 @@ def list_ports(self, if 'headers' in kwargs: headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' url = '/ports' request = self.prepare_request(method='GET', @@ -826,7 +961,7 @@ def list_ports(self, headers=headers, params=params) - response = self.send(request) + response = self.send(request, **kwargs) return response @@ -859,15 +994,18 @@ def get_port(self, if 'headers' in kwargs: headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' - url = '/ports/{0}'.format( - *self.encode_path_vars(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 = '/ports/{id}'.format(**path_param_dict) request = self.prepare_request(method='GET', url=url, headers=headers, params=params) - response = self.send(request) + response = self.send(request, **kwargs) return response ######################### @@ -906,15 +1044,18 @@ def list_gateway_virtual_connections(self, if 'headers' in kwargs: headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' - url = '/gateways/{0}/virtual_connections'.format( - *self.encode_path_vars(gateway_id)) + path_param_keys = ['gateway_id'] + path_param_values = self.encode_path_vars(gateway_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/gateways/{gateway_id}/virtual_connections'.format(**path_param_dict) request = self.prepare_request(method='GET', url=url, headers=headers, params=params) - response = self.send(request) + response = self.send(request, **kwargs) return response @@ -972,16 +1113,19 @@ def create_gateway_virtual_connection(self, if 'headers' in kwargs: headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' - url = '/gateways/{0}/virtual_connections'.format( - *self.encode_path_vars(gateway_id)) + path_param_keys = ['gateway_id'] + path_param_values = self.encode_path_vars(gateway_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/gateways/{gateway_id}/virtual_connections'.format(**path_param_dict) request = self.prepare_request(method='POST', url=url, headers=headers, params=params, data=data) - response = self.send(request) + response = self.send(request, **kwargs) return response @@ -1019,14 +1163,16 @@ def delete_gateway_virtual_connection(self, if 'headers' in kwargs: headers.update(kwargs.get('headers')) - url = '/gateways/{0}/virtual_connections/{1}'.format( - *self.encode_path_vars(gateway_id, id)) + path_param_keys = ['gateway_id', 'id'] + path_param_values = self.encode_path_vars(gateway_id, id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/gateways/{gateway_id}/virtual_connections/{id}'.format(**path_param_dict) request = self.prepare_request(method='DELETE', url=url, headers=headers, params=params) - response = self.send(request) + response = self.send(request, **kwargs) return response @@ -1063,15 +1209,18 @@ def get_gateway_virtual_connection(self, if 'headers' in kwargs: headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' - url = '/gateways/{0}/virtual_connections/{1}'.format( - *self.encode_path_vars(gateway_id, id)) + path_param_keys = ['gateway_id', 'id'] + path_param_values = self.encode_path_vars(gateway_id, id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/gateways/{gateway_id}/virtual_connections/{id}'.format(**path_param_dict) request = self.prepare_request(method='GET', url=url, headers=headers, params=params) - response = self.send(request) + response = self.send(request, **kwargs) return response @@ -1127,16 +1276,19 @@ def update_gateway_virtual_connection(self, if 'headers' in kwargs: headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' - url = '/gateways/{0}/virtual_connections/{1}'.format( - *self.encode_path_vars(gateway_id, id)) + path_param_keys = ['gateway_id', 'id'] + path_param_values = self.encode_path_vars(gateway_id, id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/gateways/{gateway_id}/virtual_connections/{id}'.format(**path_param_dict) request = self.prepare_request(method='PATCH', url=url, headers=headers, params=params, data=data) - response = self.send(request) + response = self.send(request, **kwargs) return response @@ -1145,12 +1297,28 @@ class GetGatewayStatisticsEnums: Enums for get_gateway_statistics parameters. """ - class Type(Enum): + class Type(str, Enum): """ - specify statistic to retrieve. + Specify statistic to retrieve. """ - MACSEC_MKA = 'macsec_mka' - MACSEC_SECURITY = 'macsec_security' + MACSEC_MKA_SESSION = 'macsec_mka_session' + MACSEC_POLICY = 'macsec_policy' + MACSEC_MKA_STATISTICS = 'macsec_mka_statistics' + BFD_SESSION = 'bfd_session' + + +class GetGatewayStatusEnums: + """ + Enums for get_gateway_status parameters. + """ + + class Type(str, Enum): + """ + Specify status to retrieve. + """ + BGP = 'bgp' + BFD = 'bfd' + LINK = 'link' class ListOfferingTypeLocationsEnums: @@ -1158,7 +1326,7 @@ class ListOfferingTypeLocationsEnums: Enums for list_offering_type_locations parameters. """ - class OfferingType(Enum): + class OfferingType(str, Enum): """ The Direct Link offering type. Current supported values are `"dedicated"` and `"connect"`. @@ -1172,7 +1340,7 @@ class ListOfferingTypeLocationCrossConnectRoutersEnums: Enums for list_offering_type_location_cross_connect_routers parameters. """ - class OfferingType(Enum): + class OfferingType(str, Enum): """ The Direct Link offering type. Only value `"dedicated"` is supported for this API. @@ -1185,7 +1353,7 @@ class ListOfferingTypeSpeedsEnums: Enums for list_offering_type_speeds parameters. """ - class OfferingType(Enum): + class OfferingType(str, Enum): """ The Direct Link offering type. Current supported values are `"dedicated"` and `"connect"`. @@ -1282,6 +1450,7 @@ class Gateway(): The key material that you provide must be base64 encoded and original string must be maximum 126 ASCII characters in length. To clear the optional `authentication_key` field patch its crn to `""`. + :attr GatewayBfdConfig bfd_config: (optional) BFD configuration information. :attr int bgp_asn: Customer BGP ASN. :attr str bgp_base_cidr: (optional) (DEPRECATED) BGP base CIDR is deprecated and no longer recognized by the Direct Link APIs. @@ -1294,6 +1463,8 @@ class Gateway(): :attr str bgp_status: (optional) Gateway BGP status. The list of enumerated values for this property may expand in the future. Code and processes using this field must tolerate unexpected values. + :attr datetime bgp_status_updated_at: (optional) Date and time bgp status was + updated. :attr str carrier_name: (optional) Carrier name. Only set for type=dedicated gateways. :attr GatewayChangeRequest change_request: (optional) Changes pending approval @@ -1319,6 +1490,8 @@ class Gateway(): type=dedicated gateways. The list of enumerated values for this property may expand in the future. Code and processes using this field must tolerate unexpected values. + :attr datetime link_status_updated_at: (optional) Date and time link status was + updated. :attr str location_display_name: Gateway location long name. :attr str location_name: Gateway location. :attr GatewayMacsecConfig macsec_config: (optional) MACsec configuration @@ -1331,6 +1504,8 @@ class Gateway(): :attr str operational_status: Gateway operational status. The list of enumerated values for this property may expand in the future. Code and processes using this field must tolerate unexpected values. + :attr str patch_panel_completion_notice: (optional) Gateway patch panel complete + notification from implementation team. :attr GatewayPort port: (optional) gateway port for type=connect gateways. :attr bool provider_api_managed: (optional) Indicates whether gateway changes must be made via a provider portal. @@ -1359,11 +1534,13 @@ def __init__(self, type: str, *, authentication_key: 'GatewayAuthenticationKey' = None, + bfd_config: 'GatewayBfdConfig' = None, bgp_base_cidr: str = None, bgp_cer_cidr: str = None, bgp_ibm_asn: int = None, bgp_ibm_cidr: str = None, bgp_status: str = None, + bgp_status_updated_at: datetime = None, carrier_name: str = None, change_request: 'GatewayChangeRequest' = None, completion_notice_reject_reason: str = None, @@ -1371,7 +1548,9 @@ def __init__(self, cross_connect_router: str = None, customer_name: str = None, link_status: str = None, + link_status_updated_at: datetime = None, macsec_config: 'GatewayMacsecConfig' = None, + patch_panel_completion_notice: str = None, port: 'GatewayPort' = None, provider_api_managed: bool = None, resource_group: 'ResourceGroupReference' = None, @@ -1403,6 +1582,8 @@ def __init__(self, The key material that you provide must be base64 encoded and original string must be maximum 126 ASCII characters in length. To clear the optional `authentication_key` field patch its crn to `""`. + :param GatewayBfdConfig bfd_config: (optional) BFD configuration + information. :param str bgp_base_cidr: (optional) (DEPRECATED) BGP base CIDR is deprecated and no longer recognized by the Direct Link APIs. See bgp_cer_cidr and bgp_ibm_cidr fields instead for IP related @@ -1415,6 +1596,8 @@ def __init__(self, :param str bgp_status: (optional) Gateway BGP status. The list of enumerated values for this property may expand in the future. Code and processes using this field must tolerate unexpected values. + :param datetime bgp_status_updated_at: (optional) Date and time bgp status + was updated. :param str carrier_name: (optional) Carrier name. Only set for type=dedicated gateways. :param GatewayChangeRequest change_request: (optional) Changes pending @@ -1436,9 +1619,13 @@ def __init__(self, type=dedicated gateways. The list of enumerated values for this property may expand in the future. Code and processes using this field must tolerate unexpected values. + :param datetime link_status_updated_at: (optional) Date and time link + status was updated. :param GatewayMacsecConfig macsec_config: (optional) MACsec configuration information. For Dedicated Gateways with MACsec configured, return configuration information. Contact IBM support for access to MACsec. + :param str patch_panel_completion_notice: (optional) Gateway patch panel + complete notification from implementation team. :param GatewayPort port: (optional) gateway port for type=connect gateways. :param bool provider_api_managed: (optional) Indicates whether gateway changes must be made via a provider portal. @@ -1448,12 +1635,14 @@ def __init__(self, type=connect gateways. """ self.authentication_key = authentication_key + self.bfd_config = bfd_config self.bgp_asn = bgp_asn self.bgp_base_cidr = bgp_base_cidr self.bgp_cer_cidr = bgp_cer_cidr self.bgp_ibm_asn = bgp_ibm_asn self.bgp_ibm_cidr = bgp_ibm_cidr self.bgp_status = bgp_status + self.bgp_status_updated_at = bgp_status_updated_at self.carrier_name = carrier_name self.change_request = change_request self.completion_notice_reject_reason = completion_notice_reject_reason @@ -1465,12 +1654,14 @@ def __init__(self, self.global_ = global_ self.id = id self.link_status = link_status + self.link_status_updated_at = link_status_updated_at self.location_display_name = location_display_name self.location_name = location_name self.macsec_config = macsec_config self.metered = metered self.name = name self.operational_status = operational_status + self.patch_panel_completion_notice = patch_panel_completion_notice self.port = port self.provider_api_managed = provider_api_managed self.resource_group = resource_group @@ -1484,6 +1675,8 @@ def from_dict(cls, _dict: Dict) -> 'Gateway': args = {} if 'authentication_key' in _dict: args['authentication_key'] = GatewayAuthenticationKey.from_dict(_dict.get('authentication_key')) + if 'bfd_config' in _dict: + args['bfd_config'] = GatewayBfdConfig.from_dict(_dict.get('bfd_config')) if 'bgp_asn' in _dict: args['bgp_asn'] = _dict.get('bgp_asn') else: @@ -1498,6 +1691,8 @@ def from_dict(cls, _dict: Dict) -> 'Gateway': args['bgp_ibm_cidr'] = _dict.get('bgp_ibm_cidr') if 'bgp_status' in _dict: args['bgp_status'] = _dict.get('bgp_status') + if 'bgp_status_updated_at' in _dict: + args['bgp_status_updated_at'] = string_to_datetime(_dict.get('bgp_status_updated_at')) if 'carrier_name' in _dict: args['carrier_name'] = _dict.get('carrier_name') if 'change_request' in _dict: @@ -1528,6 +1723,8 @@ def from_dict(cls, _dict: Dict) -> 'Gateway': raise ValueError('Required property \'id\' not present in Gateway JSON') if 'link_status' in _dict: args['link_status'] = _dict.get('link_status') + if 'link_status_updated_at' in _dict: + args['link_status_updated_at'] = string_to_datetime(_dict.get('link_status_updated_at')) if 'location_display_name' in _dict: args['location_display_name'] = _dict.get('location_display_name') else: @@ -1550,6 +1747,8 @@ def from_dict(cls, _dict: Dict) -> 'Gateway': args['operational_status'] = _dict.get('operational_status') else: raise ValueError('Required property \'operational_status\' not present in Gateway JSON') + if 'patch_panel_completion_notice' in _dict: + args['patch_panel_completion_notice'] = _dict.get('patch_panel_completion_notice') if 'port' in _dict: args['port'] = GatewayPort.from_dict(_dict.get('port')) if 'provider_api_managed' in _dict: @@ -1578,6 +1777,8 @@ def to_dict(self) -> Dict: _dict = {} if hasattr(self, 'authentication_key') and self.authentication_key is not None: _dict['authentication_key'] = self.authentication_key.to_dict() + if hasattr(self, 'bfd_config') and self.bfd_config is not None: + _dict['bfd_config'] = self.bfd_config.to_dict() if hasattr(self, 'bgp_asn') and self.bgp_asn is not None: _dict['bgp_asn'] = self.bgp_asn if hasattr(self, 'bgp_base_cidr') and self.bgp_base_cidr is not None: @@ -1590,10 +1791,15 @@ def to_dict(self) -> Dict: _dict['bgp_ibm_cidr'] = self.bgp_ibm_cidr if hasattr(self, 'bgp_status') and self.bgp_status is not None: _dict['bgp_status'] = self.bgp_status + if hasattr(self, 'bgp_status_updated_at') and self.bgp_status_updated_at is not None: + _dict['bgp_status_updated_at'] = datetime_to_string(self.bgp_status_updated_at) if hasattr(self, 'carrier_name') and self.carrier_name is not None: _dict['carrier_name'] = self.carrier_name if hasattr(self, 'change_request') and self.change_request is not None: - _dict['change_request'] = self.change_request + if isinstance(self.change_request, dict): + _dict['change_request'] = self.change_request + else: + _dict['change_request'] = self.change_request.to_dict() if hasattr(self, 'completion_notice_reject_reason') and self.completion_notice_reject_reason is not None: _dict['completion_notice_reject_reason'] = self.completion_notice_reject_reason if hasattr(self, 'connection_mode') and self.connection_mode is not None: @@ -1612,6 +1818,8 @@ def to_dict(self) -> Dict: _dict['id'] = self.id if hasattr(self, 'link_status') and self.link_status is not None: _dict['link_status'] = self.link_status + if hasattr(self, 'link_status_updated_at') and self.link_status_updated_at is not None: + _dict['link_status_updated_at'] = datetime_to_string(self.link_status_updated_at) if hasattr(self, 'location_display_name') and self.location_display_name is not None: _dict['location_display_name'] = self.location_display_name if hasattr(self, 'location_name') and self.location_name is not None: @@ -1624,6 +1832,8 @@ def to_dict(self) -> Dict: _dict['name'] = self.name if hasattr(self, 'operational_status') and self.operational_status is not None: _dict['operational_status'] = self.operational_status + if hasattr(self, 'patch_panel_completion_notice') and self.patch_panel_completion_notice is not None: + _dict['patch_panel_completion_notice'] = self.patch_panel_completion_notice if hasattr(self, 'port') and self.port is not None: _dict['port'] = self.port.to_dict() if hasattr(self, 'provider_api_managed') and self.provider_api_managed is not None: @@ -1656,18 +1866,18 @@ def __ne__(self, other: 'Gateway') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class BgpStatusEnum(Enum): + class BgpStatusEnum(str, Enum): """ Gateway BGP status. The list of enumerated values for this property may expand in the future. Code and processes using this field must tolerate unexpected values. """ - ACTIVE = "active" - CONNECT = "connect" - ESTABLISHED = "established" - IDLE = "idle" + ACTIVE = 'active' + CONNECT = 'connect' + ESTABLISHED = 'established' + IDLE = 'idle' - class ConnectionModeEnum(Enum): + class ConnectionModeEnum(str, Enum): """ Type of services this Gateway is attached to. Mode transit means this Gateway will be attached to Transit Gateway Service and direct means this Gateway will be @@ -1675,56 +1885,56 @@ class ConnectionModeEnum(Enum): property may expand in the future. Code and processes using this field must tolerate unexpected values. """ - DIRECT = "direct" - TRANSIT = "transit" + DIRECT = 'direct' + TRANSIT = 'transit' - class LinkStatusEnum(Enum): + class LinkStatusEnum(str, Enum): """ Gateway link status. Only included on type=dedicated gateways. The list of enumerated values for this property may expand in the future. Code and processes using this field must tolerate unexpected values. """ - DOWN = "down" - UP = "up" + DOWN = 'down' + UP = 'up' - class OperationalStatusEnum(Enum): + class OperationalStatusEnum(str, Enum): """ Gateway operational status. The list of enumerated values for this property may expand in the future. Code and processes using this field must tolerate unexpected values. """ - AWAITING_COMPLETION_NOTICE = "awaiting_completion_notice" - AWAITING_LOA = "awaiting_loa" - CONFIGURING = "configuring" - CREATE_PENDING = "create_pending" - CREATE_REJECTED = "create_rejected" - COMPLETION_NOTICE_APPROVED = "completion_notice_approved" - COMPLETION_NOTICE_RECEIVED = "completion_notice_received" - COMPLETION_NOTICE_REJECTED = "completion_notice_rejected" - DELETE_PENDING = "delete_pending" - LOA_ACCEPTED = "loa_accepted" - LOA_CREATED = "loa_created" - LOA_REJECTED = "loa_rejected" - PROVISIONED = "provisioned" + AWAITING_COMPLETION_NOTICE = 'awaiting_completion_notice' + AWAITING_LOA = 'awaiting_loa' + CONFIGURING = 'configuring' + CREATE_PENDING = 'create_pending' + CREATE_REJECTED = 'create_rejected' + COMPLETION_NOTICE_APPROVED = 'completion_notice_approved' + COMPLETION_NOTICE_RECEIVED = 'completion_notice_received' + COMPLETION_NOTICE_REJECTED = 'completion_notice_rejected' + DELETE_PENDING = 'delete_pending' + LOA_ACCEPTED = 'loa_accepted' + LOA_CREATED = 'loa_created' + LOA_REJECTED = 'loa_rejected' + PROVISIONED = 'provisioned' - class TypeEnum(Enum): + class TypeEnum(str, Enum): """ Offering type. The list of enumerated values for this property may expand in the future. Code and processes using this field must tolerate unexpected values. """ - CONNECT = "connect" - DEDICATED = "dedicated" + CONNECT = 'connect' + DEDICATED = 'dedicated' class GatewayActionTemplateAuthenticationKey(): """ - The identity of the standard key to use for BGP MD5 authentication key. The key - material that you provide must be base64 encoded and original string must be maximum - 126 ASCII characters in length. To clear the optional `authentication_key` field patch - its crn to `""`. + Applicable for create_gateway_approve requests to select the gateway's BGP MD5 + authentication key. The key material that you provide must be base64 encoded and + original string must be maximum 126 ASCII characters in length. To clear the optional + `authentication_key` field patch its crn to `""`. :attr str crn: The CRN of the [Key Protect Standard Key](https://cloud.ibm.com/docs/key-protect?topic=key-protect-getting-started-tutorial) @@ -1786,6 +1996,21 @@ def __ne__(self, other: 'GatewayActionTemplateAuthenticationKey') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other +class GatewayActionTemplateUpdatesItem(): + """ + GatewayActionTemplateUpdatesItem. + + """ + + def __init__(self) -> None: + """ + Initialize a GatewayActionTemplateUpdatesItem object. + + """ + msg = "Cannot instantiate base class. Instead, instantiate one of the defined subclasses: {0}".format( + ", ".join(['GatewayActionTemplateUpdatesItemGatewayClientSpeedUpdate', 'GatewayActionTemplateUpdatesItemGatewayClientBGPIPUpdate', 'GatewayActionTemplateUpdatesItemGatewayClientBGPASNUpdate'])) + raise Exception(msg) + class GatewayAuthenticationKey(): """ The identity of the standard key to use for BGP MD5 authentication key. The key @@ -1853,6 +2078,326 @@ def __ne__(self, other: 'GatewayAuthenticationKey') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other +class GatewayBfdConfig(): + """ + BFD configuration information. + + :attr str bfd_status: (optional) Gateway BFD status. The list of enumerated + values for this property may expand in the future. Code and processes using this + field must tolerate unexpected values. + :attr datetime bfd_status_updated_at: (optional) Date and time bfd status was + updated. + :attr int interval: Minimum interval in milliseconds at which the local routing + device transmits hello packets and then expects to receive a reply from a + neighbor with which it has established a BFD session. + :attr int multiplier: The number of hello packets not received by a neighbor + that causes the originating interface to be declared down. + """ + + def __init__(self, + interval: int, + multiplier: int, + *, + bfd_status: str = None, + bfd_status_updated_at: datetime = None) -> None: + """ + Initialize a GatewayBfdConfig object. + + :param int interval: Minimum interval in milliseconds at which the local + routing device transmits hello packets and then expects to receive a reply + from a neighbor with which it has established a BFD session. + :param int multiplier: The number of hello packets not received by a + neighbor that causes the originating interface to be declared down. + :param str bfd_status: (optional) Gateway BFD status. The list of + enumerated values for this property may expand in the future. Code and + processes using this field must tolerate unexpected values. + :param datetime bfd_status_updated_at: (optional) Date and time bfd status + was updated. + """ + self.bfd_status = bfd_status + self.bfd_status_updated_at = bfd_status_updated_at + self.interval = interval + self.multiplier = multiplier + + @classmethod + def from_dict(cls, _dict: Dict) -> 'GatewayBfdConfig': + """Initialize a GatewayBfdConfig object from a json dictionary.""" + args = {} + if 'bfd_status' in _dict: + args['bfd_status'] = _dict.get('bfd_status') + if 'bfd_status_updated_at' in _dict: + args['bfd_status_updated_at'] = string_to_datetime(_dict.get('bfd_status_updated_at')) + if 'interval' in _dict: + args['interval'] = _dict.get('interval') + else: + raise ValueError('Required property \'interval\' not present in GatewayBfdConfig JSON') + if 'multiplier' in _dict: + args['multiplier'] = _dict.get('multiplier') + else: + raise ValueError('Required property \'multiplier\' not present in GatewayBfdConfig JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a GatewayBfdConfig 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, 'bfd_status') and self.bfd_status is not None: + _dict['bfd_status'] = self.bfd_status + if hasattr(self, 'bfd_status_updated_at') and self.bfd_status_updated_at is not None: + _dict['bfd_status_updated_at'] = datetime_to_string(self.bfd_status_updated_at) + if hasattr(self, 'interval') and self.interval is not None: + _dict['interval'] = self.interval + if hasattr(self, 'multiplier') and self.multiplier is not None: + _dict['multiplier'] = self.multiplier + 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 GatewayBfdConfig object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'GatewayBfdConfig') -> 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: 'GatewayBfdConfig') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + class BfdStatusEnum(str, Enum): + """ + Gateway BFD status. The list of enumerated values for this property may expand in + the future. Code and processes using this field must tolerate unexpected values. + """ + INIT = 'init' + UP = 'up' + DOWN = 'down' + + +class GatewayBfdConfigActionTemplate(): + """ + Applicable for create_gateway_approve requests to select the gateway's BFD + configuration information. + + :attr int interval: Minimum interval in milliseconds at which the local routing + device transmits hello packets and then expects to receive a reply from a + neighbor with which it has established a BFD session. + :attr int multiplier: (optional) The number of hello packets not received by a + neighbor that causes the originating interface to be declared down. + """ + + def __init__(self, + interval: int, + *, + multiplier: int = None) -> None: + """ + Initialize a GatewayBfdConfigActionTemplate object. + + :param int interval: Minimum interval in milliseconds at which the local + routing device transmits hello packets and then expects to receive a reply + from a neighbor with which it has established a BFD session. + :param int multiplier: (optional) The number of hello packets not received + by a neighbor that causes the originating interface to be declared down. + """ + self.interval = interval + self.multiplier = multiplier + + @classmethod + def from_dict(cls, _dict: Dict) -> 'GatewayBfdConfigActionTemplate': + """Initialize a GatewayBfdConfigActionTemplate object from a json dictionary.""" + args = {} + if 'interval' in _dict: + args['interval'] = _dict.get('interval') + else: + raise ValueError('Required property \'interval\' not present in GatewayBfdConfigActionTemplate JSON') + if 'multiplier' in _dict: + args['multiplier'] = _dict.get('multiplier') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a GatewayBfdConfigActionTemplate 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, 'interval') and self.interval is not None: + _dict['interval'] = self.interval + if hasattr(self, 'multiplier') and self.multiplier is not None: + _dict['multiplier'] = self.multiplier + 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 GatewayBfdConfigActionTemplate object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'GatewayBfdConfigActionTemplate') -> 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: 'GatewayBfdConfigActionTemplate') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + +class GatewayBfdConfigTemplate(): + """ + BFD configuration information. + + :attr int interval: Minimum interval in milliseconds at which the local routing + device transmits hello packets and then expects to receive a reply from a + neighbor with which it has established a BFD session. + :attr int multiplier: (optional) The number of hello packets not received by a + neighbor that causes the originating interface to be declared down. + """ + + def __init__(self, + interval: int, + *, + multiplier: int = None) -> None: + """ + Initialize a GatewayBfdConfigTemplate object. + + :param int interval: Minimum interval in milliseconds at which the local + routing device transmits hello packets and then expects to receive a reply + from a neighbor with which it has established a BFD session. + :param int multiplier: (optional) The number of hello packets not received + by a neighbor that causes the originating interface to be declared down. + """ + self.interval = interval + self.multiplier = multiplier + + @classmethod + def from_dict(cls, _dict: Dict) -> 'GatewayBfdConfigTemplate': + """Initialize a GatewayBfdConfigTemplate object from a json dictionary.""" + args = {} + if 'interval' in _dict: + args['interval'] = _dict.get('interval') + else: + raise ValueError('Required property \'interval\' not present in GatewayBfdConfigTemplate JSON') + if 'multiplier' in _dict: + args['multiplier'] = _dict.get('multiplier') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a GatewayBfdConfigTemplate 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, 'interval') and self.interval is not None: + _dict['interval'] = self.interval + if hasattr(self, 'multiplier') and self.multiplier is not None: + _dict['multiplier'] = self.multiplier + 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 GatewayBfdConfigTemplate object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'GatewayBfdConfigTemplate') -> 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: 'GatewayBfdConfigTemplate') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + +class GatewayBfdPatchTemplate(): + """ + BFD configuration information. + + :attr int interval: (optional) Minimum interval in milliseconds at which the + local routing device transmits hello packets and then expects to receive a reply + from a neighbor with which it has established a BFD session. + To clear the BFD configuration patch its interval to 0. + :attr int multiplier: (optional) The number of hello packets not received by a + neighbor that causes the originating interface to be declared down. + """ + + def __init__(self, + *, + interval: int = None, + multiplier: int = None) -> None: + """ + Initialize a GatewayBfdPatchTemplate object. + + :param int interval: (optional) Minimum interval in milliseconds at which + the local routing device transmits hello packets and then expects to + receive a reply from a neighbor with which it has established a BFD + session. + To clear the BFD configuration patch its interval to 0. + :param int multiplier: (optional) The number of hello packets not received + by a neighbor that causes the originating interface to be declared down. + """ + self.interval = interval + self.multiplier = multiplier + + @classmethod + def from_dict(cls, _dict: Dict) -> 'GatewayBfdPatchTemplate': + """Initialize a GatewayBfdPatchTemplate object from a json dictionary.""" + args = {} + if 'interval' in _dict: + args['interval'] = _dict.get('interval') + if 'multiplier' in _dict: + args['multiplier'] = _dict.get('multiplier') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a GatewayBfdPatchTemplate 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, 'interval') and self.interval is not None: + _dict['interval'] = self.interval + if hasattr(self, 'multiplier') and self.multiplier is not None: + _dict['multiplier'] = self.multiplier + 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 GatewayBfdPatchTemplate object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'GatewayBfdPatchTemplate') -> 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: 'GatewayBfdPatchTemplate') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + class GatewayChangeRequest(): """ GatewayChangeRequest. @@ -1868,6 +2413,21 @@ def __init__(self) -> None: ", ".join(['GatewayChangeRequestGatewayClientGatewayCreate', 'GatewayChangeRequestGatewayClientGatewayDelete', 'GatewayChangeRequestGatewayClientGatewayUpdateAttributes'])) raise Exception(msg) +class GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItem(): + """ + GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItem. + + """ + + def __init__(self) -> None: + """ + Initialize a GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItem object. + + """ + msg = "Cannot instantiate base class. Instead, instantiate one of the defined subclasses: {0}".format( + ", ".join(['GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientSpeedUpdate', 'GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPIPUpdate', 'GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPASNUpdate'])) + raise Exception(msg) + class GatewayCollection(): """ GatewayCollection. @@ -2096,36 +2656,36 @@ def __ne__(self, other: 'GatewayMacsecConfig') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class CipherSuiteEnum(Enum): + class CipherSuiteEnum(str, Enum): """ SAK cipher suite. """ - GCM_AES_XPN_256 = "gcm_aes_xpn_256" + GCM_AES_XPN_256 = 'gcm_aes_xpn_256' - class CryptographicAlgorithmEnum(Enum): + class CryptographicAlgorithmEnum(str, Enum): """ cryptographic algorithm. """ - AES_256_CMAC = "aes_256_cmac" + AES_256_CMAC = 'aes_256_cmac' - class SecurityPolicyEnum(Enum): + class SecurityPolicyEnum(str, Enum): """ Packets without MACsec headers are dropped when security_policy is `must_secure`. """ - MUST_SECURE = "must_secure" + MUST_SECURE = 'must_secure' - class StatusEnum(Enum): + class StatusEnum(str, Enum): """ Current status of MACsec on this gateway. Status 'offline' is returned during gateway creation and deletion. """ - INIT = "init" - PENDING = "pending" - OFFLINE = "offline" - SECURED = "secured" + INIT = 'init' + PENDING = 'pending' + OFFLINE = 'offline' + SECURED = 'secured' class GatewayMacsecConfigActiveCak(): @@ -2967,8 +3527,7 @@ def __ne__(self, other: 'GatewayPortIdentity') -> bool: class GatewayStatistic(): """ - Gateway statistics. Currently data retrieval is only supported for MACsec - configurations. + Gateway statistics and debug commands. :attr datetime created_at: Date and time data was collected. :attr str data: statistics output. @@ -3042,13 +3601,14 @@ def __ne__(self, other: 'GatewayStatistic') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class TypeEnum(Enum): + class TypeEnum(str, Enum): """ statistic type. """ - MACSEC_MKA_SESSION = "macsec_mka_session" - MACSEC_POLICY = "macsec_policy" - MACSEC_MKA_STATISTICS = "macsec_mka_statistics" + MACSEC_MKA_SESSION = 'macsec_mka_session' + MACSEC_POLICY = 'macsec_policy' + MACSEC_MKA_STATISTICS = 'macsec_mka_statistics' + BFD_SESSION = 'bfd_session' class GatewayStatisticCollection(): @@ -3107,19 +3667,97 @@ def __ne__(self, other: 'GatewayStatisticCollection') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class GatewayTemplate(): +class GatewayStatus(): """ - Create gateway template. + GatewayStatus. - :attr GatewayTemplateAuthenticationKey authentication_key: (optional) The - identity of the standard key to use for BGP MD5 authentication key. - The key material that you provide must be base64 encoded and original string - must be maximum 126 ASCII characters in length. - To clear the optional `authentication_key` field patch its crn to `""`. - :attr int bgp_asn: BGP ASN. - :attr str bgp_base_cidr: (optional) (DEPRECATED) BGP base CIDR. - Field is deprecated. See bgp_ibm_cidr and bgp_cer_cidr for details on how to - create a gateway using either automatic or explicit IP assignment. Any + """ + + def __init__(self) -> None: + """ + Initialize a GatewayStatus object. + + """ + msg = "Cannot instantiate base class. Instead, instantiate one of the defined subclasses: {0}".format( + ", ".join(['GatewayStatusGatewayBGPStatus', 'GatewayStatusGatewayBFDStatus', 'GatewayStatusGatewayLinkStatus'])) + raise Exception(msg) + +class GatewayStatusCollection(): + """ + gateway status. + + :attr List[GatewayStatus] status: (optional) + """ + + def __init__(self, + *, + status: List['GatewayStatus'] = None) -> None: + """ + Initialize a GatewayStatusCollection object. + + :param List[GatewayStatus] status: (optional) + """ + self.status = status + + @classmethod + def from_dict(cls, _dict: Dict) -> 'GatewayStatusCollection': + """Initialize a GatewayStatusCollection object from a json dictionary.""" + args = {} + if 'status' in _dict: + args['status'] = _dict.get('status') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a GatewayStatusCollection 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, 'status') and self.status is not None: + status_list = [] + for x in self.status: + if isinstance(x, dict): + status_list.append(x) + else: + status_list.append(x.to_dict()) + _dict['status'] = status_list + 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 GatewayStatusCollection object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'GatewayStatusCollection') -> 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: 'GatewayStatusCollection') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + +class GatewayTemplate(): + """ + Create gateway template. + + :attr GatewayTemplateAuthenticationKey authentication_key: (optional) The + identity of the standard key to use for BGP MD5 authentication key. + The key material that you provide must be base64 encoded and original string + must be maximum 126 ASCII characters in length. + To clear the optional `authentication_key` field patch its crn to `""`. + :attr GatewayBfdConfigTemplate bfd_config: (optional) BFD configuration + information. + :attr int bgp_asn: BGP ASN. + :attr str bgp_base_cidr: (optional) (DEPRECATED) BGP base CIDR. + Field is deprecated. See bgp_ibm_cidr and bgp_cer_cidr for details on how to + create a gateway using either automatic or explicit IP assignment. Any bgp_base_cidr value set will be ignored. Deprecated field bgp_base_cidr will be removed from the API specificiation after 15-MAR-2021. @@ -3148,6 +3786,8 @@ class GatewayTemplate(): per gigabyte. When `false` there is no per gigabyte usage charge, instead a flat rate is charged for the gateway. :attr str name: The unique user-defined name for this gateway. + :attr str patch_panel_completion_notice: (optional) Gateway patch panel complete + notification from implementation team. :attr ResourceGroupIdentity resource_group: (optional) Resource group for this resource. If unspecified, the account's [default resource group](https://cloud.ibm.com/apidocs/resource-manager#introduction) is used. @@ -3164,10 +3804,12 @@ def __init__(self, type: str, *, authentication_key: 'GatewayTemplateAuthenticationKey' = None, + bfd_config: 'GatewayBfdConfigTemplate' = None, bgp_base_cidr: str = None, bgp_cer_cidr: str = None, bgp_ibm_cidr: str = None, connection_mode: str = None, + patch_panel_completion_notice: str = None, resource_group: 'ResourceGroupIdentity' = None) -> None: """ Initialize a GatewayTemplate object. @@ -3186,6 +3828,8 @@ def __init__(self, The key material that you provide must be base64 encoded and original string must be maximum 126 ASCII characters in length. To clear the optional `authentication_key` field patch its crn to `""`. + :param GatewayBfdConfigTemplate bfd_config: (optional) BFD configuration + information. :param str bgp_base_cidr: (optional) (DEPRECATED) BGP base CIDR. Field is deprecated. See bgp_ibm_cidr and bgp_cer_cidr for details on how to create a gateway using either automatic or explicit IP assignment. Any @@ -3212,6 +3856,8 @@ def __init__(self, classic connection. The list of enumerated values for this property may expand in the future. Code and processes using this field must tolerate unexpected values. + :param str patch_panel_completion_notice: (optional) Gateway patch panel + complete notification from implementation team. :param ResourceGroupIdentity resource_group: (optional) Resource group for this resource. If unspecified, the account's [default resource group](https://cloud.ibm.com/apidocs/resource-manager#introduction) is @@ -3221,7 +3867,7 @@ def __init__(self, ", ".join(['GatewayTemplateGatewayTypeDedicatedTemplate', 'GatewayTemplateGatewayTypeConnectTemplate'])) raise Exception(msg) - class ConnectionModeEnum(Enum): + class ConnectionModeEnum(str, Enum): """ Type of services this Gateway is attached to. Mode transit means this Gateway will be attached to Transit Gateway Service and direct means this Gateway will be @@ -3229,16 +3875,16 @@ class ConnectionModeEnum(Enum): property may expand in the future. Code and processes using this field must tolerate unexpected values. """ - DIRECT = "direct" - TRANSIT = "transit" + DIRECT = 'direct' + TRANSIT = 'transit' - class TypeEnum(Enum): + class TypeEnum(str, Enum): """ Offering type. """ - CONNECT = "connect" - DEDICATED = "dedicated" + CONNECT = 'connect' + DEDICATED = 'dedicated' class GatewayTemplateAuthenticationKey(): @@ -3308,140 +3954,6 @@ def __ne__(self, other: 'GatewayTemplateAuthenticationKey') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class GatewayTemplateGatewayTypeConnectTemplateAuthenticationKey(): - """ - The identity of the standard key to use for BGP MD5 authentication key. The key - material that you provide must be base64 encoded and original string must be maximum - 126 ASCII characters in length. To clear the optional `authentication_key` field patch - its crn to `""`. - - :attr str crn: The CRN of the [Key Protect Standard - Key](https://cloud.ibm.com/docs/key-protect?topic=key-protect-getting-started-tutorial) - or [Hyper Protect Crypto Service Standard - Key](https://cloud.ibm.com/docs/hs-crypto?topic=hs-crypto-get-started) for this - resource. - """ - - def __init__(self, - crn: str) -> None: - """ - Initialize a GatewayTemplateGatewayTypeConnectTemplateAuthenticationKey object. - - :param str crn: The CRN of the [Key Protect Standard - Key](https://cloud.ibm.com/docs/key-protect?topic=key-protect-getting-started-tutorial) - or [Hyper Protect Crypto Service Standard - Key](https://cloud.ibm.com/docs/hs-crypto?topic=hs-crypto-get-started) for - this resource. - """ - self.crn = crn - - @classmethod - def from_dict(cls, _dict: Dict) -> 'GatewayTemplateGatewayTypeConnectTemplateAuthenticationKey': - """Initialize a GatewayTemplateGatewayTypeConnectTemplateAuthenticationKey object from a json dictionary.""" - args = {} - if 'crn' in _dict: - args['crn'] = _dict.get('crn') - else: - raise ValueError('Required property \'crn\' not present in GatewayTemplateGatewayTypeConnectTemplateAuthenticationKey JSON') - return cls(**args) - - @classmethod - def _from_dict(cls, _dict): - """Initialize a GatewayTemplateGatewayTypeConnectTemplateAuthenticationKey object from a json dictionary.""" - return cls.from_dict(_dict) - - def to_dict(self) -> Dict: - """Return a json dictionary representing this model.""" - _dict = {} - if hasattr(self, 'crn') and self.crn is not None: - _dict['crn'] = self.crn - return _dict - - def _to_dict(self): - """Return a json dictionary representing this model.""" - return self.to_dict() - - def __str__(self) -> str: - """Return a `str` version of this GatewayTemplateGatewayTypeConnectTemplateAuthenticationKey object.""" - return json.dumps(self.to_dict(), indent=2) - - def __eq__(self, other: 'GatewayTemplateGatewayTypeConnectTemplateAuthenticationKey') -> 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: 'GatewayTemplateGatewayTypeConnectTemplateAuthenticationKey') -> bool: - """Return `true` when self and other are not equal, false otherwise.""" - return not self == other - -class GatewayTemplateGatewayTypeDedicatedTemplateAuthenticationKey(): - """ - The identity of the standard key to use for BGP MD5 authentication key. The key - material that you provide must be base64 encoded and original string must be maximum - 126 ASCII characters in length. To clear the optional `authentication_key` field patch - its crn to `""`. - - :attr str crn: The CRN of the [Key Protect Standard - Key](https://cloud.ibm.com/docs/key-protect?topic=key-protect-getting-started-tutorial) - or [Hyper Protect Crypto Service Standard - Key](https://cloud.ibm.com/docs/hs-crypto?topic=hs-crypto-get-started) for this - resource. - """ - - def __init__(self, - crn: str) -> None: - """ - Initialize a GatewayTemplateGatewayTypeDedicatedTemplateAuthenticationKey object. - - :param str crn: The CRN of the [Key Protect Standard - Key](https://cloud.ibm.com/docs/key-protect?topic=key-protect-getting-started-tutorial) - or [Hyper Protect Crypto Service Standard - Key](https://cloud.ibm.com/docs/hs-crypto?topic=hs-crypto-get-started) for - this resource. - """ - self.crn = crn - - @classmethod - def from_dict(cls, _dict: Dict) -> 'GatewayTemplateGatewayTypeDedicatedTemplateAuthenticationKey': - """Initialize a GatewayTemplateGatewayTypeDedicatedTemplateAuthenticationKey object from a json dictionary.""" - args = {} - if 'crn' in _dict: - args['crn'] = _dict.get('crn') - else: - raise ValueError('Required property \'crn\' not present in GatewayTemplateGatewayTypeDedicatedTemplateAuthenticationKey JSON') - return cls(**args) - - @classmethod - def _from_dict(cls, _dict): - """Initialize a GatewayTemplateGatewayTypeDedicatedTemplateAuthenticationKey object from a json dictionary.""" - return cls.from_dict(_dict) - - def to_dict(self) -> Dict: - """Return a json dictionary representing this model.""" - _dict = {} - if hasattr(self, 'crn') and self.crn is not None: - _dict['crn'] = self.crn - return _dict - - def _to_dict(self): - """Return a json dictionary representing this model.""" - return self.to_dict() - - def __str__(self) -> str: - """Return a `str` version of this GatewayTemplateGatewayTypeDedicatedTemplateAuthenticationKey object.""" - return json.dumps(self.to_dict(), indent=2) - - def __eq__(self, other: 'GatewayTemplateGatewayTypeDedicatedTemplateAuthenticationKey') -> 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: 'GatewayTemplateGatewayTypeDedicatedTemplateAuthenticationKey') -> bool: - """Return `true` when self and other are not equal, false otherwise.""" - return not self == other - class GatewayVirtualConnection(): """ Virtual connection. @@ -3576,30 +4088,31 @@ def __ne__(self, other: 'GatewayVirtualConnection') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class StatusEnum(Enum): + class StatusEnum(str, Enum): """ Status of the virtual connection. The list of enumerated values for this property may expand in the future. Code and processes using this field must tolerate unexpected values. """ - PENDING = "pending" - ATTACHED = "attached" - APPROVAL_PENDING = "approval_pending" - REJECTED = "rejected" - EXPIRED = "expired" - DELETING = "deleting" - DETACHED_BY_NETWORK_PENDING = "detached_by_network_pending" - DETACHED_BY_NETWORK = "detached_by_network" + PENDING = 'pending' + ATTACHED = 'attached' + APPROVAL_PENDING = 'approval_pending' + REJECTED = 'rejected' + EXPIRED = 'expired' + DELETING = 'deleting' + DETACHED_BY_NETWORK_PENDING = 'detached_by_network_pending' + DETACHED_BY_NETWORK = 'detached_by_network' - class TypeEnum(Enum): + class TypeEnum(str, Enum): """ Virtual connection type. The list of enumerated values for this property may expand in the future. Code and processes using this field must tolerate unexpected values. """ - CLASSIC = "classic" - VPC = "vpc" + CLASSIC = 'classic' + VPC = 'vpc' + TRANSIT = 'transit' class GatewayVirtualConnectionCollection(): @@ -4534,43 +5047,43 @@ def __ne__(self, other: 'ResourceGroupReference') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class GatewayChangeRequestGatewayClientGatewayCreate(GatewayChangeRequest): +class GatewayActionTemplateUpdatesItemGatewayClientBGPASNUpdate(GatewayActionTemplateUpdatesItem): """ - gateway create. + The autonomous system number (ASN) of Border Gateway Protocol + (BGP) configuration for the IBM side of the DL 2.0 gateway. - :attr str type: type of gateway change request. + :attr int bgp_asn: (optional) New gateway BGP ASN. """ def __init__(self, - type: str) -> None: + *, + bgp_asn: int = None) -> None: """ - Initialize a GatewayChangeRequestGatewayClientGatewayCreate object. + Initialize a GatewayActionTemplateUpdatesItemGatewayClientBGPASNUpdate object. - :param str type: type of gateway change request. + :param int bgp_asn: (optional) New gateway BGP ASN. """ # pylint: disable=super-init-not-called - self.type = type + self.bgp_asn = bgp_asn @classmethod - def from_dict(cls, _dict: Dict) -> 'GatewayChangeRequestGatewayClientGatewayCreate': - """Initialize a GatewayChangeRequestGatewayClientGatewayCreate object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'GatewayActionTemplateUpdatesItemGatewayClientBGPASNUpdate': + """Initialize a GatewayActionTemplateUpdatesItemGatewayClientBGPASNUpdate object from a json dictionary.""" args = {} - if 'type' in _dict: - args['type'] = _dict.get('type') - else: - raise ValueError('Required property \'type\' not present in GatewayChangeRequestGatewayClientGatewayCreate JSON') + if 'bgp_asn' in _dict: + args['bgp_asn'] = _dict.get('bgp_asn') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a GatewayChangeRequestGatewayClientGatewayCreate object from a json dictionary.""" + """Initialize a GatewayActionTemplateUpdatesItemGatewayClientBGPASNUpdate 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, 'type') and self.type is not None: - _dict['type'] = self.type + if hasattr(self, 'bgp_asn') and self.bgp_asn is not None: + _dict['bgp_asn'] = self.bgp_asn return _dict def _to_dict(self): @@ -4578,63 +5091,96 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this GatewayChangeRequestGatewayClientGatewayCreate object.""" + """Return a `str` version of this GatewayActionTemplateUpdatesItemGatewayClientBGPASNUpdate object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'GatewayChangeRequestGatewayClientGatewayCreate') -> bool: + def __eq__(self, other: 'GatewayActionTemplateUpdatesItemGatewayClientBGPASNUpdate') -> 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: 'GatewayChangeRequestGatewayClientGatewayCreate') -> bool: + def __ne__(self, other: 'GatewayActionTemplateUpdatesItemGatewayClientBGPASNUpdate') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class TypeEnum(Enum): - """ - type of gateway change request. - """ - CREATE_GATEWAY = "create_gateway" - - -class GatewayChangeRequestGatewayClientGatewayDelete(GatewayChangeRequest): +class GatewayActionTemplateUpdatesItemGatewayClientBGPIPUpdate(GatewayActionTemplateUpdatesItem): """ - gateway delete. - - :attr str type: type of gateway change request. + Update BGP customer and IBM CIDR. + + :attr str bgp_cer_cidr: (optional) BGP customer edge router CIDR is the new CIDR + (Classless Inter-Domain Routing) value to be updated on customer edge router for + the DL 2.0 gateway. + Customer edge IP and IBM IP should be in the same network. Updating customer + edge router CIDR should be accompanied with IBM CIDR in the request. Update + customer edge router IP to a valid bgp_cer_cidr and bgp_ibm_cidr CIDR, the value + must reside in one of "10.254.0.0/16", "172.16.0.0/12", "192.168.0.0/16", + "169.254.0.0/16" or an owned public CIDR. bgp_cer_cidr and bgp_ibm_cidr must + have matching network and subnet mask values. + :attr str bgp_ibm_cidr: (optional) BGP IBM CIDR is the new CIDR (Classless + Inter-Domain Routing) value to be updated on IBM edge router for the DL 2.0 + gateway. + IBM IP and customer edge IP should be in the same network. Updating IBM CIDR + should be accompanied with customer edge router CIDR in the request. Update IBM + CIDR to a valid bgp_cer_cidr and bgp_ibm_cidr CIDR, the value must reside in one + of "10.254.0.0/16", "172.16.0.0/12", "192.168.0.0/16", "169.254.0.0/16" or an + owned public CIDR. bgp_cer_cidr and bgp_ibm_cidr must have matching network and + subnet mask values. """ def __init__(self, - type: str) -> None: - """ - Initialize a GatewayChangeRequestGatewayClientGatewayDelete object. - - :param str type: type of gateway change request. + *, + bgp_cer_cidr: str = None, + bgp_ibm_cidr: str = None) -> None: + """ + Initialize a GatewayActionTemplateUpdatesItemGatewayClientBGPIPUpdate object. + + :param str bgp_cer_cidr: (optional) BGP customer edge router CIDR is the + new CIDR (Classless Inter-Domain Routing) value to be updated on customer + edge router for the DL 2.0 gateway. + Customer edge IP and IBM IP should be in the same network. Updating + customer edge router CIDR should be accompanied with IBM CIDR in the + request. Update customer edge router IP to a valid bgp_cer_cidr and + bgp_ibm_cidr CIDR, the value must reside in one of "10.254.0.0/16", + "172.16.0.0/12", "192.168.0.0/16", + "169.254.0.0/16" or an owned public CIDR. bgp_cer_cidr and bgp_ibm_cidr + must have matching network and subnet mask values. + :param str bgp_ibm_cidr: (optional) BGP IBM CIDR is the new CIDR (Classless + Inter-Domain Routing) value to be updated on IBM edge router for the DL 2.0 + gateway. + IBM IP and customer edge IP should be in the same network. Updating IBM + CIDR should be accompanied with customer edge router CIDR in the request. + Update IBM CIDR to a valid bgp_cer_cidr and bgp_ibm_cidr CIDR, the value + must reside in one of "10.254.0.0/16", "172.16.0.0/12", "192.168.0.0/16", + "169.254.0.0/16" or an owned public CIDR. bgp_cer_cidr and bgp_ibm_cidr + must have matching network and subnet mask values. """ # pylint: disable=super-init-not-called - self.type = type + self.bgp_cer_cidr = bgp_cer_cidr + self.bgp_ibm_cidr = bgp_ibm_cidr @classmethod - def from_dict(cls, _dict: Dict) -> 'GatewayChangeRequestGatewayClientGatewayDelete': - """Initialize a GatewayChangeRequestGatewayClientGatewayDelete object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'GatewayActionTemplateUpdatesItemGatewayClientBGPIPUpdate': + """Initialize a GatewayActionTemplateUpdatesItemGatewayClientBGPIPUpdate object from a json dictionary.""" args = {} - if 'type' in _dict: - args['type'] = _dict.get('type') - else: - raise ValueError('Required property \'type\' not present in GatewayChangeRequestGatewayClientGatewayDelete JSON') + if 'bgp_cer_cidr' in _dict: + args['bgp_cer_cidr'] = _dict.get('bgp_cer_cidr') + if 'bgp_ibm_cidr' in _dict: + args['bgp_ibm_cidr'] = _dict.get('bgp_ibm_cidr') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a GatewayChangeRequestGatewayClientGatewayDelete object from a json dictionary.""" + """Initialize a GatewayActionTemplateUpdatesItemGatewayClientBGPIPUpdate 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, 'type') and self.type is not None: - _dict['type'] = self.type + if hasattr(self, 'bgp_cer_cidr') and self.bgp_cer_cidr is not None: + _dict['bgp_cer_cidr'] = self.bgp_cer_cidr + if hasattr(self, 'bgp_ibm_cidr') and self.bgp_ibm_cidr is not None: + _dict['bgp_ibm_cidr'] = self.bgp_ibm_cidr return _dict def _to_dict(self): @@ -4642,42 +5188,432 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this GatewayChangeRequestGatewayClientGatewayDelete object.""" + """Return a `str` version of this GatewayActionTemplateUpdatesItemGatewayClientBGPIPUpdate object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'GatewayChangeRequestGatewayClientGatewayDelete') -> bool: + def __eq__(self, other: 'GatewayActionTemplateUpdatesItemGatewayClientBGPIPUpdate') -> 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: 'GatewayChangeRequestGatewayClientGatewayDelete') -> bool: + def __ne__(self, other: 'GatewayActionTemplateUpdatesItemGatewayClientBGPIPUpdate') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class TypeEnum(Enum): - """ - type of gateway change request. - """ - DELETE_GATEWAY = "delete_gateway" - +class GatewayActionTemplateUpdatesItemGatewayClientSpeedUpdate(GatewayActionTemplateUpdatesItem): + """ + gateway speed change. -class GatewayChangeRequestGatewayClientGatewayUpdateAttributes(GatewayChangeRequest): + :attr int speed_mbps: (optional) New gateway speed in megabits per second. + """ + + def __init__(self, + *, + speed_mbps: int = None) -> None: + """ + Initialize a GatewayActionTemplateUpdatesItemGatewayClientSpeedUpdate object. + + :param int speed_mbps: (optional) New gateway speed in megabits per second. + """ + # pylint: disable=super-init-not-called + self.speed_mbps = speed_mbps + + @classmethod + def from_dict(cls, _dict: Dict) -> 'GatewayActionTemplateUpdatesItemGatewayClientSpeedUpdate': + """Initialize a GatewayActionTemplateUpdatesItemGatewayClientSpeedUpdate object from a json dictionary.""" + args = {} + if 'speed_mbps' in _dict: + args['speed_mbps'] = _dict.get('speed_mbps') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a GatewayActionTemplateUpdatesItemGatewayClientSpeedUpdate 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, 'speed_mbps') and self.speed_mbps is not None: + _dict['speed_mbps'] = self.speed_mbps + 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 GatewayActionTemplateUpdatesItemGatewayClientSpeedUpdate object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'GatewayActionTemplateUpdatesItemGatewayClientSpeedUpdate') -> 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: 'GatewayActionTemplateUpdatesItemGatewayClientSpeedUpdate') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + +class GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPASNUpdate(GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItem): + """ + The autonomous system number (ASN) of Border Gateway Protocol + (BGP) configuration for the IBM side of the DL 2.0 gateway. + + :attr int bgp_asn: (optional) New gateway BGP ASN. + """ + + def __init__(self, + *, + bgp_asn: int = None) -> None: + """ + Initialize a GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPASNUpdate object. + + :param int bgp_asn: (optional) New gateway BGP ASN. + """ + # pylint: disable=super-init-not-called + self.bgp_asn = bgp_asn + + @classmethod + def from_dict(cls, _dict: Dict) -> 'GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPASNUpdate': + """Initialize a GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPASNUpdate object from a json dictionary.""" + args = {} + if 'bgp_asn' in _dict: + args['bgp_asn'] = _dict.get('bgp_asn') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPASNUpdate 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, 'bgp_asn') and self.bgp_asn is not None: + _dict['bgp_asn'] = self.bgp_asn + 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 GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPASNUpdate object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPASNUpdate') -> 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: 'GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPASNUpdate') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + +class GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPIPUpdate(GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItem): + """ + Update BGP customer and IBM CIDR. + + :attr str bgp_cer_cidr: (optional) BGP customer edge router CIDR is the new CIDR + (Classless Inter-Domain Routing) value to be updated on customer edge router for + the DL 2.0 gateway. + Customer edge IP and IBM IP should be in the same network. Updating customer + edge router CIDR should be accompanied with IBM CIDR in the request. Update + customer edge router IP to a valid bgp_cer_cidr and bgp_ibm_cidr CIDR, the value + must reside in one of "10.254.0.0/16", "172.16.0.0/12", "192.168.0.0/16", + "169.254.0.0/16" or an owned public CIDR. bgp_cer_cidr and bgp_ibm_cidr must + have matching network and subnet mask values. + :attr str bgp_ibm_cidr: (optional) BGP IBM CIDR is the new CIDR (Classless + Inter-Domain Routing) value to be updated on IBM edge router for the DL 2.0 + gateway. + IBM IP and customer edge IP should be in the same network. Updating IBM CIDR + should be accompanied with customer edge router CIDR in the request. Update IBM + CIDR to a valid bgp_cer_cidr and bgp_ibm_cidr CIDR, the value must reside in one + of "10.254.0.0/16", "172.16.0.0/12", "192.168.0.0/16", "169.254.0.0/16" or an + owned public CIDR. bgp_cer_cidr and bgp_ibm_cidr must have matching network and + subnet mask values. + """ + + def __init__(self, + *, + bgp_cer_cidr: str = None, + bgp_ibm_cidr: str = None) -> None: + """ + Initialize a GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPIPUpdate object. + + :param str bgp_cer_cidr: (optional) BGP customer edge router CIDR is the + new CIDR (Classless Inter-Domain Routing) value to be updated on customer + edge router for the DL 2.0 gateway. + Customer edge IP and IBM IP should be in the same network. Updating + customer edge router CIDR should be accompanied with IBM CIDR in the + request. Update customer edge router IP to a valid bgp_cer_cidr and + bgp_ibm_cidr CIDR, the value must reside in one of "10.254.0.0/16", + "172.16.0.0/12", "192.168.0.0/16", + "169.254.0.0/16" or an owned public CIDR. bgp_cer_cidr and bgp_ibm_cidr + must have matching network and subnet mask values. + :param str bgp_ibm_cidr: (optional) BGP IBM CIDR is the new CIDR (Classless + Inter-Domain Routing) value to be updated on IBM edge router for the DL 2.0 + gateway. + IBM IP and customer edge IP should be in the same network. Updating IBM + CIDR should be accompanied with customer edge router CIDR in the request. + Update IBM CIDR to a valid bgp_cer_cidr and bgp_ibm_cidr CIDR, the value + must reside in one of "10.254.0.0/16", "172.16.0.0/12", "192.168.0.0/16", + "169.254.0.0/16" or an owned public CIDR. bgp_cer_cidr and bgp_ibm_cidr + must have matching network and subnet mask values. + """ + # pylint: disable=super-init-not-called + self.bgp_cer_cidr = bgp_cer_cidr + self.bgp_ibm_cidr = bgp_ibm_cidr + + @classmethod + def from_dict(cls, _dict: Dict) -> 'GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPIPUpdate': + """Initialize a GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPIPUpdate object from a json dictionary.""" + args = {} + if 'bgp_cer_cidr' in _dict: + args['bgp_cer_cidr'] = _dict.get('bgp_cer_cidr') + if 'bgp_ibm_cidr' in _dict: + args['bgp_ibm_cidr'] = _dict.get('bgp_ibm_cidr') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPIPUpdate 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, 'bgp_cer_cidr') and self.bgp_cer_cidr is not None: + _dict['bgp_cer_cidr'] = self.bgp_cer_cidr + if hasattr(self, 'bgp_ibm_cidr') and self.bgp_ibm_cidr is not None: + _dict['bgp_ibm_cidr'] = self.bgp_ibm_cidr + 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 GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPIPUpdate object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPIPUpdate') -> 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: 'GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPIPUpdate') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + +class GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientSpeedUpdate(GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItem): + """ + gateway speed change. + + :attr int speed_mbps: (optional) New gateway speed in megabits per second. + """ + + def __init__(self, + *, + speed_mbps: int = None) -> None: + """ + Initialize a GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientSpeedUpdate object. + + :param int speed_mbps: (optional) New gateway speed in megabits per second. + """ + # pylint: disable=super-init-not-called + self.speed_mbps = speed_mbps + + @classmethod + def from_dict(cls, _dict: Dict) -> 'GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientSpeedUpdate': + """Initialize a GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientSpeedUpdate object from a json dictionary.""" + args = {} + if 'speed_mbps' in _dict: + args['speed_mbps'] = _dict.get('speed_mbps') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientSpeedUpdate 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, 'speed_mbps') and self.speed_mbps is not None: + _dict['speed_mbps'] = self.speed_mbps + 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 GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientSpeedUpdate object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientSpeedUpdate') -> 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: 'GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientSpeedUpdate') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + +class GatewayChangeRequestGatewayClientGatewayCreate(GatewayChangeRequest): + """ + gateway create. + + :attr str type: type of gateway change request. + """ + + def __init__(self, + type: str) -> None: + """ + Initialize a GatewayChangeRequestGatewayClientGatewayCreate object. + + :param str type: type of gateway change request. + """ + # pylint: disable=super-init-not-called + self.type = type + + @classmethod + def from_dict(cls, _dict: Dict) -> 'GatewayChangeRequestGatewayClientGatewayCreate': + """Initialize a GatewayChangeRequestGatewayClientGatewayCreate object from a json dictionary.""" + args = {} + if 'type' in _dict: + args['type'] = _dict.get('type') + else: + raise ValueError('Required property \'type\' not present in GatewayChangeRequestGatewayClientGatewayCreate JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a GatewayChangeRequestGatewayClientGatewayCreate 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, 'type') and self.type is not None: + _dict['type'] = self.type + 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 GatewayChangeRequestGatewayClientGatewayCreate object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'GatewayChangeRequestGatewayClientGatewayCreate') -> 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: 'GatewayChangeRequestGatewayClientGatewayCreate') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + class TypeEnum(str, Enum): + """ + type of gateway change request. + """ + CREATE_GATEWAY = 'create_gateway' + + +class GatewayChangeRequestGatewayClientGatewayDelete(GatewayChangeRequest): + """ + gateway delete. + + :attr str type: type of gateway change request. + """ + + def __init__(self, + type: str) -> None: + """ + Initialize a GatewayChangeRequestGatewayClientGatewayDelete object. + + :param str type: type of gateway change request. + """ + # pylint: disable=super-init-not-called + self.type = type + + @classmethod + def from_dict(cls, _dict: Dict) -> 'GatewayChangeRequestGatewayClientGatewayDelete': + """Initialize a GatewayChangeRequestGatewayClientGatewayDelete object from a json dictionary.""" + args = {} + if 'type' in _dict: + args['type'] = _dict.get('type') + else: + raise ValueError('Required property \'type\' not present in GatewayChangeRequestGatewayClientGatewayDelete JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a GatewayChangeRequestGatewayClientGatewayDelete 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, 'type') and self.type is not None: + _dict['type'] = self.type + 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 GatewayChangeRequestGatewayClientGatewayDelete object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'GatewayChangeRequestGatewayClientGatewayDelete') -> 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: 'GatewayChangeRequestGatewayClientGatewayDelete') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + class TypeEnum(str, Enum): + """ + type of gateway change request. + """ + DELETE_GATEWAY = 'delete_gateway' + + +class GatewayChangeRequestGatewayClientGatewayUpdateAttributes(GatewayChangeRequest): """ gateway attributes update. :attr str type: type of gateway change request. - :attr List[object] updates: array of pending updates. + :attr List[GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItem] + updates: array of pending updates. """ def __init__(self, type: str, - updates: List[object]) -> None: + updates: List['GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItem']) -> None: """ Initialize a GatewayChangeRequestGatewayClientGatewayUpdateAttributes object. :param str type: type of gateway change request. - :param List[object] updates: array of pending updates. + :param + List[GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItem] + updates: array of pending updates. """ # pylint: disable=super-init-not-called self.type = type @@ -4708,7 +5644,13 @@ def to_dict(self) -> Dict: if hasattr(self, 'type') and self.type is not None: _dict['type'] = self.type if hasattr(self, 'updates') and self.updates is not None: - _dict['updates'] = self.updates + updates_list = [] + for x in self.updates: + if isinstance(x, dict): + updates_list.append(x) + else: + updates_list.append(x.to_dict()) + _dict['updates'] = updates_list return _dict def _to_dict(self): @@ -4729,23 +5671,299 @@ def __ne__(self, other: 'GatewayChangeRequestGatewayClientGatewayUpdateAttribute """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class TypeEnum(Enum): + class TypeEnum(str, Enum): """ type of gateway change request. """ - UPDATE_ATTRIBUTES = "update_attributes" + UPDATE_ATTRIBUTES = 'update_attributes' + + +class GatewayStatusGatewayBFDStatus(GatewayStatus): + """ + Gateway bfd status. + + :attr str type: Status type. + :attr datetime updated_at: Date and time status was collected. + :attr str value: Status. + """ + + def __init__(self, + type: str, + updated_at: datetime, + value: str) -> None: + """ + Initialize a GatewayStatusGatewayBFDStatus object. + + :param str type: Status type. + :param datetime updated_at: Date and time status was collected. + :param str value: Status. + """ + # pylint: disable=super-init-not-called + self.type = type + self.updated_at = updated_at + self.value = value + + @classmethod + def from_dict(cls, _dict: Dict) -> 'GatewayStatusGatewayBFDStatus': + """Initialize a GatewayStatusGatewayBFDStatus object from a json dictionary.""" + args = {} + if 'type' in _dict: + args['type'] = _dict.get('type') + else: + raise ValueError('Required property \'type\' not present in GatewayStatusGatewayBFDStatus JSON') + if 'updated_at' in _dict: + args['updated_at'] = string_to_datetime(_dict.get('updated_at')) + else: + raise ValueError('Required property \'updated_at\' not present in GatewayStatusGatewayBFDStatus JSON') + if 'value' in _dict: + args['value'] = _dict.get('value') + else: + raise ValueError('Required property \'value\' not present in GatewayStatusGatewayBFDStatus JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a GatewayStatusGatewayBFDStatus 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, 'type') and self.type is not None: + _dict['type'] = self.type + if hasattr(self, 'updated_at') and self.updated_at is not None: + _dict['updated_at'] = datetime_to_string(self.updated_at) + if hasattr(self, 'value') and self.value is not None: + _dict['value'] = self.value + 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 GatewayStatusGatewayBFDStatus object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'GatewayStatusGatewayBFDStatus') -> 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: 'GatewayStatusGatewayBFDStatus') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + class TypeEnum(str, Enum): + """ + Status type. + """ + BFD = 'bfd' + + + class ValueEnum(str, Enum): + """ + Status. + """ + NOT_AVAILABLE = 'not_available' + INIT = 'init' + UP = 'up' + DOWN = 'down' + + +class GatewayStatusGatewayBGPStatus(GatewayStatus): + """ + Gateway bgp status. + + :attr str type: Status type. + :attr datetime updated_at: Date and time status was collected. + :attr str value: Status. + """ + + def __init__(self, + type: str, + updated_at: datetime, + value: str) -> None: + """ + Initialize a GatewayStatusGatewayBGPStatus object. + + :param str type: Status type. + :param datetime updated_at: Date and time status was collected. + :param str value: Status. + """ + # pylint: disable=super-init-not-called + self.type = type + self.updated_at = updated_at + self.value = value + + @classmethod + def from_dict(cls, _dict: Dict) -> 'GatewayStatusGatewayBGPStatus': + """Initialize a GatewayStatusGatewayBGPStatus object from a json dictionary.""" + args = {} + if 'type' in _dict: + args['type'] = _dict.get('type') + else: + raise ValueError('Required property \'type\' not present in GatewayStatusGatewayBGPStatus JSON') + if 'updated_at' in _dict: + args['updated_at'] = string_to_datetime(_dict.get('updated_at')) + else: + raise ValueError('Required property \'updated_at\' not present in GatewayStatusGatewayBGPStatus JSON') + if 'value' in _dict: + args['value'] = _dict.get('value') + else: + raise ValueError('Required property \'value\' not present in GatewayStatusGatewayBGPStatus JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a GatewayStatusGatewayBGPStatus 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, 'type') and self.type is not None: + _dict['type'] = self.type + if hasattr(self, 'updated_at') and self.updated_at is not None: + _dict['updated_at'] = datetime_to_string(self.updated_at) + if hasattr(self, 'value') and self.value is not None: + _dict['value'] = self.value + 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 GatewayStatusGatewayBGPStatus object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'GatewayStatusGatewayBGPStatus') -> 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: 'GatewayStatusGatewayBGPStatus') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + class TypeEnum(str, Enum): + """ + Status type. + """ + BGP = 'bgp' + + + class ValueEnum(str, Enum): + """ + Status. + """ + ACTIVE = 'active' + CONNECT = 'connect' + ESTABLISHED = 'established' + IDLE = 'idle' + + +class GatewayStatusGatewayLinkStatus(GatewayStatus): + """ + Gateway link status. Only available for dedicated gateways. + + :attr str type: Status type. + :attr datetime updated_at: Date and time status was collected. + :attr str value: Status. + """ + + def __init__(self, + type: str, + updated_at: datetime, + value: str) -> None: + """ + Initialize a GatewayStatusGatewayLinkStatus object. + + :param str type: Status type. + :param datetime updated_at: Date and time status was collected. + :param str value: Status. + """ + # pylint: disable=super-init-not-called + self.type = type + self.updated_at = updated_at + self.value = value + + @classmethod + def from_dict(cls, _dict: Dict) -> 'GatewayStatusGatewayLinkStatus': + """Initialize a GatewayStatusGatewayLinkStatus object from a json dictionary.""" + args = {} + if 'type' in _dict: + args['type'] = _dict.get('type') + else: + raise ValueError('Required property \'type\' not present in GatewayStatusGatewayLinkStatus JSON') + if 'updated_at' in _dict: + args['updated_at'] = string_to_datetime(_dict.get('updated_at')) + else: + raise ValueError('Required property \'updated_at\' not present in GatewayStatusGatewayLinkStatus JSON') + if 'value' in _dict: + args['value'] = _dict.get('value') + else: + raise ValueError('Required property \'value\' not present in GatewayStatusGatewayLinkStatus JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a GatewayStatusGatewayLinkStatus 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, 'type') and self.type is not None: + _dict['type'] = self.type + if hasattr(self, 'updated_at') and self.updated_at is not None: + _dict['updated_at'] = datetime_to_string(self.updated_at) + if hasattr(self, 'value') and self.value is not None: + _dict['value'] = self.value + 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 GatewayStatusGatewayLinkStatus object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'GatewayStatusGatewayLinkStatus') -> 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: 'GatewayStatusGatewayLinkStatus') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + class TypeEnum(str, Enum): + """ + Status type. + """ + LINK = 'link' + + + class ValueEnum(str, Enum): + """ + Status. + """ + UP = 'up' + DOWN = 'down' class GatewayTemplateGatewayTypeConnectTemplate(GatewayTemplate): """ Gateway fields specific to type=connect gateway create. - :attr GatewayTemplateGatewayTypeConnectTemplateAuthenticationKey - authentication_key: (optional) The identity of the standard key to use for BGP - MD5 authentication key. - The key material that you provide must be base64 encoded and original string - must be maximum 126 ASCII characters in length. - To clear the optional `authentication_key` field patch its crn to `""`. + :attr GatewayTemplateAuthenticationKey authentication_key: (optional) + :attr GatewayBfdConfigTemplate bfd_config: (optional) :attr int bgp_asn: BGP ASN. :attr str bgp_base_cidr: (optional) (DEPRECATED) BGP base CIDR. Field is deprecated. See bgp_ibm_cidr and bgp_cer_cidr for details on how to @@ -4778,9 +5996,9 @@ class GatewayTemplateGatewayTypeConnectTemplate(GatewayTemplate): per gigabyte. When `false` there is no per gigabyte usage charge, instead a flat rate is charged for the gateway. :attr str name: The unique user-defined name for this gateway. - :attr ResourceGroupIdentity resource_group: (optional) Resource group for this - resource. If unspecified, the account's [default resource - group](https://cloud.ibm.com/apidocs/resource-manager#introduction) is used. + :attr str patch_panel_completion_notice: (optional) Gateway patch panel complete + notification from implementation team. + :attr ResourceGroupIdentity resource_group: (optional) :attr int speed_mbps: Gateway speed in megabits per second. :attr str type: Offering type. :attr GatewayPortIdentity port: Select Port Label for new type=connect gateway. @@ -4795,11 +6013,13 @@ def __init__(self, type: str, port: 'GatewayPortIdentity', *, - authentication_key: 'GatewayTemplateGatewayTypeConnectTemplateAuthenticationKey' = None, + authentication_key: 'GatewayTemplateAuthenticationKey' = None, + bfd_config: 'GatewayBfdConfigTemplate' = None, bgp_base_cidr: str = None, bgp_cer_cidr: str = None, bgp_ibm_cidr: str = None, connection_mode: str = None, + patch_panel_completion_notice: str = None, resource_group: 'ResourceGroupIdentity' = None) -> None: """ Initialize a GatewayTemplateGatewayTypeConnectTemplate object. @@ -4815,12 +6035,8 @@ def __init__(self, :param str type: Offering type. :param GatewayPortIdentity port: Select Port Label for new type=connect gateway. - :param GatewayTemplateGatewayTypeConnectTemplateAuthenticationKey - authentication_key: (optional) The identity of the standard key to use for - BGP MD5 authentication key. - The key material that you provide must be base64 encoded and original - string must be maximum 126 ASCII characters in length. - To clear the optional `authentication_key` field patch its crn to `""`. + :param GatewayTemplateAuthenticationKey authentication_key: (optional) + :param GatewayBfdConfigTemplate bfd_config: (optional) :param str bgp_base_cidr: (optional) (DEPRECATED) BGP base CIDR. Field is deprecated. See bgp_ibm_cidr and bgp_cer_cidr for details on how to create a gateway using either automatic or explicit IP assignment. Any @@ -4847,13 +6063,13 @@ def __init__(self, classic connection. The list of enumerated values for this property may expand in the future. Code and processes using this field must tolerate unexpected values. - :param ResourceGroupIdentity resource_group: (optional) Resource group for - this resource. If unspecified, the account's [default resource - group](https://cloud.ibm.com/apidocs/resource-manager#introduction) is - used. + :param str patch_panel_completion_notice: (optional) Gateway patch panel + complete notification from implementation team. + :param ResourceGroupIdentity resource_group: (optional) """ # pylint: disable=super-init-not-called self.authentication_key = authentication_key + self.bfd_config = bfd_config self.bgp_asn = bgp_asn self.bgp_base_cidr = bgp_base_cidr self.bgp_cer_cidr = bgp_cer_cidr @@ -4862,6 +6078,7 @@ def __init__(self, self.global_ = global_ self.metered = metered self.name = name + self.patch_panel_completion_notice = patch_panel_completion_notice self.resource_group = resource_group self.speed_mbps = speed_mbps self.type = type @@ -4872,7 +6089,9 @@ def from_dict(cls, _dict: Dict) -> 'GatewayTemplateGatewayTypeConnectTemplate': """Initialize a GatewayTemplateGatewayTypeConnectTemplate object from a json dictionary.""" args = {} if 'authentication_key' in _dict: - args['authentication_key'] = GatewayTemplateGatewayTypeConnectTemplateAuthenticationKey.from_dict(_dict.get('authentication_key')) + args['authentication_key'] = GatewayTemplateAuthenticationKey.from_dict(_dict.get('authentication_key')) + if 'bfd_config' in _dict: + args['bfd_config'] = GatewayBfdConfigTemplate.from_dict(_dict.get('bfd_config')) if 'bgp_asn' in _dict: args['bgp_asn'] = _dict.get('bgp_asn') else: @@ -4897,6 +6116,8 @@ def from_dict(cls, _dict: Dict) -> 'GatewayTemplateGatewayTypeConnectTemplate': args['name'] = _dict.get('name') else: raise ValueError('Required property \'name\' not present in GatewayTemplateGatewayTypeConnectTemplate JSON') + if 'patch_panel_completion_notice' in _dict: + args['patch_panel_completion_notice'] = _dict.get('patch_panel_completion_notice') if 'resource_group' in _dict: args['resource_group'] = ResourceGroupIdentity.from_dict(_dict.get('resource_group')) if 'speed_mbps' in _dict: @@ -4923,6 +6144,8 @@ def to_dict(self) -> Dict: _dict = {} if hasattr(self, 'authentication_key') and self.authentication_key is not None: _dict['authentication_key'] = self.authentication_key.to_dict() + if hasattr(self, 'bfd_config') and self.bfd_config is not None: + _dict['bfd_config'] = self.bfd_config.to_dict() if hasattr(self, 'bgp_asn') and self.bgp_asn is not None: _dict['bgp_asn'] = self.bgp_asn if hasattr(self, 'bgp_base_cidr') and self.bgp_base_cidr is not None: @@ -4939,6 +6162,8 @@ def to_dict(self) -> Dict: _dict['metered'] = self.metered if hasattr(self, 'name') and self.name is not None: _dict['name'] = self.name + if hasattr(self, 'patch_panel_completion_notice') and self.patch_panel_completion_notice is not None: + _dict['patch_panel_completion_notice'] = self.patch_panel_completion_notice if hasattr(self, 'resource_group') and self.resource_group is not None: _dict['resource_group'] = self.resource_group.to_dict() if hasattr(self, 'speed_mbps') and self.speed_mbps is not None: @@ -4967,7 +6192,7 @@ def __ne__(self, other: 'GatewayTemplateGatewayTypeConnectTemplate') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class ConnectionModeEnum(Enum): + class ConnectionModeEnum(str, Enum): """ Type of services this Gateway is attached to. Mode transit means this Gateway will be attached to Transit Gateway Service and direct means this Gateway will be @@ -4975,28 +6200,24 @@ class ConnectionModeEnum(Enum): property may expand in the future. Code and processes using this field must tolerate unexpected values. """ - DIRECT = "direct" - TRANSIT = "transit" + DIRECT = 'direct' + TRANSIT = 'transit' - class TypeEnum(Enum): + class TypeEnum(str, Enum): """ Offering type. """ - CONNECT = "connect" - DEDICATED = "dedicated" + CONNECT = 'connect' + DEDICATED = 'dedicated' class GatewayTemplateGatewayTypeDedicatedTemplate(GatewayTemplate): """ Gateway fields specific to type=dedicated gateway create. - :attr GatewayTemplateGatewayTypeDedicatedTemplateAuthenticationKey - authentication_key: (optional) The identity of the standard key to use for BGP - MD5 authentication key. - The key material that you provide must be base64 encoded and original string - must be maximum 126 ASCII characters in length. - To clear the optional `authentication_key` field patch its crn to `""`. + :attr GatewayTemplateAuthenticationKey authentication_key: (optional) + :attr GatewayBfdConfigTemplate bfd_config: (optional) :attr int bgp_asn: BGP ASN. :attr str bgp_base_cidr: (optional) (DEPRECATED) BGP base CIDR. Field is deprecated. See bgp_ibm_cidr and bgp_cer_cidr for details on how to @@ -5029,9 +6250,9 @@ class GatewayTemplateGatewayTypeDedicatedTemplate(GatewayTemplate): per gigabyte. When `false` there is no per gigabyte usage charge, instead a flat rate is charged for the gateway. :attr str name: The unique user-defined name for this gateway. - :attr ResourceGroupIdentity resource_group: (optional) Resource group for this - resource. If unspecified, the account's [default resource - group](https://cloud.ibm.com/apidocs/resource-manager#introduction) is used. + :attr str patch_panel_completion_notice: (optional) Gateway patch panel complete + notification from implementation team. + :attr ResourceGroupIdentity resource_group: (optional) :attr int speed_mbps: Gateway speed in megabits per second. :attr str type: Offering type. :attr str carrier_name: Carrier name. @@ -5054,11 +6275,13 @@ def __init__(self, customer_name: str, location_name: str, *, - authentication_key: 'GatewayTemplateGatewayTypeDedicatedTemplateAuthenticationKey' = None, + authentication_key: 'GatewayTemplateAuthenticationKey' = None, + bfd_config: 'GatewayBfdConfigTemplate' = None, bgp_base_cidr: str = None, bgp_cer_cidr: str = None, bgp_ibm_cidr: str = None, connection_mode: str = None, + patch_panel_completion_notice: str = None, resource_group: 'ResourceGroupIdentity' = None, macsec_config: 'GatewayMacsecConfigTemplate' = None) -> None: """ @@ -5077,12 +6300,8 @@ def __init__(self, :param str cross_connect_router: Cross connect router. :param str customer_name: Customer name. :param str location_name: Gateway location. - :param GatewayTemplateGatewayTypeDedicatedTemplateAuthenticationKey - authentication_key: (optional) The identity of the standard key to use for - BGP MD5 authentication key. - The key material that you provide must be base64 encoded and original - string must be maximum 126 ASCII characters in length. - To clear the optional `authentication_key` field patch its crn to `""`. + :param GatewayTemplateAuthenticationKey authentication_key: (optional) + :param GatewayBfdConfigTemplate bfd_config: (optional) :param str bgp_base_cidr: (optional) (DEPRECATED) BGP base CIDR. Field is deprecated. See bgp_ibm_cidr and bgp_cer_cidr for details on how to create a gateway using either automatic or explicit IP assignment. Any @@ -5109,15 +6328,15 @@ def __init__(self, classic connection. The list of enumerated values for this property may expand in the future. Code and processes using this field must tolerate unexpected values. - :param ResourceGroupIdentity resource_group: (optional) Resource group for - this resource. If unspecified, the account's [default resource - group](https://cloud.ibm.com/apidocs/resource-manager#introduction) is - used. + :param str patch_panel_completion_notice: (optional) Gateway patch panel + complete notification from implementation team. + :param ResourceGroupIdentity resource_group: (optional) :param GatewayMacsecConfigTemplate macsec_config: (optional) MACsec configuration information. Contact IBM support for access to MACsec. """ # pylint: disable=super-init-not-called self.authentication_key = authentication_key + self.bfd_config = bfd_config self.bgp_asn = bgp_asn self.bgp_base_cidr = bgp_base_cidr self.bgp_cer_cidr = bgp_cer_cidr @@ -5126,6 +6345,7 @@ def __init__(self, self.global_ = global_ self.metered = metered self.name = name + self.patch_panel_completion_notice = patch_panel_completion_notice self.resource_group = resource_group self.speed_mbps = speed_mbps self.type = type @@ -5140,7 +6360,9 @@ def from_dict(cls, _dict: Dict) -> 'GatewayTemplateGatewayTypeDedicatedTemplate' """Initialize a GatewayTemplateGatewayTypeDedicatedTemplate object from a json dictionary.""" args = {} if 'authentication_key' in _dict: - args['authentication_key'] = GatewayTemplateGatewayTypeDedicatedTemplateAuthenticationKey.from_dict(_dict.get('authentication_key')) + args['authentication_key'] = GatewayTemplateAuthenticationKey.from_dict(_dict.get('authentication_key')) + if 'bfd_config' in _dict: + args['bfd_config'] = GatewayBfdConfigTemplate.from_dict(_dict.get('bfd_config')) if 'bgp_asn' in _dict: args['bgp_asn'] = _dict.get('bgp_asn') else: @@ -5165,6 +6387,8 @@ def from_dict(cls, _dict: Dict) -> 'GatewayTemplateGatewayTypeDedicatedTemplate' args['name'] = _dict.get('name') else: raise ValueError('Required property \'name\' not present in GatewayTemplateGatewayTypeDedicatedTemplate JSON') + if 'patch_panel_completion_notice' in _dict: + args['patch_panel_completion_notice'] = _dict.get('patch_panel_completion_notice') if 'resource_group' in _dict: args['resource_group'] = ResourceGroupIdentity.from_dict(_dict.get('resource_group')) if 'speed_mbps' in _dict: @@ -5205,6 +6429,8 @@ def to_dict(self) -> Dict: _dict = {} if hasattr(self, 'authentication_key') and self.authentication_key is not None: _dict['authentication_key'] = self.authentication_key.to_dict() + if hasattr(self, 'bfd_config') and self.bfd_config is not None: + _dict['bfd_config'] = self.bfd_config.to_dict() if hasattr(self, 'bgp_asn') and self.bgp_asn is not None: _dict['bgp_asn'] = self.bgp_asn if hasattr(self, 'bgp_base_cidr') and self.bgp_base_cidr is not None: @@ -5221,6 +6447,8 @@ def to_dict(self) -> Dict: _dict['metered'] = self.metered if hasattr(self, 'name') and self.name is not None: _dict['name'] = self.name + if hasattr(self, 'patch_panel_completion_notice') and self.patch_panel_completion_notice is not None: + _dict['patch_panel_completion_notice'] = self.patch_panel_completion_notice if hasattr(self, 'resource_group') and self.resource_group is not None: _dict['resource_group'] = self.resource_group.to_dict() if hasattr(self, 'speed_mbps') and self.speed_mbps is not None: @@ -5257,7 +6485,7 @@ def __ne__(self, other: 'GatewayTemplateGatewayTypeDedicatedTemplate') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class ConnectionModeEnum(Enum): + class ConnectionModeEnum(str, Enum): """ Type of services this Gateway is attached to. Mode transit means this Gateway will be attached to Transit Gateway Service and direct means this Gateway will be @@ -5265,14 +6493,14 @@ class ConnectionModeEnum(Enum): property may expand in the future. Code and processes using this field must tolerate unexpected values. """ - DIRECT = "direct" - TRANSIT = "transit" + DIRECT = 'direct' + TRANSIT = 'transit' - class TypeEnum(Enum): + class TypeEnum(str, Enum): """ Offering type. """ - CONNECT = "connect" - DEDICATED = "dedicated" + CONNECT = 'connect' + DEDICATED = 'dedicated' diff --git a/test/integration/test_direct_link_provider_v2.py b/test/integration/test_direct_link_provider_v2.py index dfa5647..d1caa1d 100644 --- a/test/integration/test_direct_link_provider_v2.py +++ b/test/integration/test_direct_link_provider_v2.py @@ -13,7 +13,7 @@ from ibm_cloud_networking_services import DirectLinkV1 from ibm_cloud_networking_services import DirectLinkProviderV2 from ibm_cloud_networking_services.direct_link_provider_v2 import ProviderGatewayPortIdentity -from ibm_cloud_networking_services.direct_link_v1 import GatewayActionTemplateAuthenticationKey +from ibm_cloud_networking_services.direct_link_v1 import (GatewayActionTemplateAuthenticationKey, GatewayBfdConfigActionTemplate) from dotenv import load_dotenv, find_dotenv @@ -382,7 +382,7 @@ def test_provider_gateway_actions_with_client_api(self): assert response is not None assert response.get_status_code() == 204 - ################## Direct Link Provider Gateways with Client API MD5 Auth ############################ + ################## Direct Link Provider Gateways with Client API MD5 Auth ############################ def test_provider_gateway_actions_with_client_api_md5(self): timestamp = time.time() @@ -479,5 +479,225 @@ def test_provider_gateway_actions_with_client_api_md5(self): assert response is not None assert response.get_status_code() == 204 + ################## Direct Link Provider Gateways with BGP IP Update ############################ + + def test_provider_gateway_actions_with_client_api_bgp_ip_update(self): + timestamp = time.time() + name = os.getenv("DL_PROVIDER_SERVICES_GW_NAME") + "-BGP-IP-UPD-" + str(int(timestamp)) + bgpAsn = 64999 + customerAccount = os.getenv("DL_PROVIDER_SERVICES_CUSTOMER_ACCT_ID") + speedMbps = 1000 + + """ successfully get a provider port id """ + response = self.dl_provider.list_provider_ports() + assert response is not None + + port_id = response.get_result().get("ports")[0].get("id") + port = ProviderGatewayPortIdentity(id=port_id) + + #created provider gateway + response = self.dl_provider.create_provider_gateway(bgp_asn=bgpAsn, + customer_account_id=customerAccount, + name=name, + port=port, + speed_mbps=speedMbps) + assert response is not None + assert response.get_status_code() == 201 + gateway_id = response.get_result().get("id") + + #verfiy client account can see the provider created gateway + response = self.dl.get_gateway(id=gateway_id) + assert response is not None + assert response.get_status_code() == 200 + assert response.get_result().get("id") == gateway_id + assert response.get_result().get("name") == name + assert response.get_result().get("speed_mbps") == speedMbps + assert response.get_result().get("provider_api_managed") == True + assert response.get_result().get("operational_status") == "create_pending" + assert response.get_result().get("type") == "connect" + assert "change_request" in response.get_result() + + #successfully approve the gateway create using client account + response = self.dl.create_gateway_action(id=gateway_id, + action="create_gateway_approve", + metered=False, + global_=False) + assert response is not None + assert response.get_status_code() == 200 + result = response.get_result() + assert result['id'] == gateway_id + assert result['name'] == name + + # wait until gateway moves to provisioned state + count = 0 + while True: + response = None + response = self.dl.get_gateway(id=gateway_id) + operationalStatus = response.get_result().get("operational_status") + + if (response is not None) and (response.get_result().get("operational_status") == "provisioned"): + assert response is not None + assert response.get_status_code() == 200 + assert response.get_result().get("id") == gateway_id + assert response.get_result().get("name") == name + assert response.get_result().get("speed_mbps") == speedMbps + assert response.get_result().get("provider_api_managed") == True + assert response.get_result().get("operational_status") == "provisioned" + assert response.get_result().get("type") == "connect" + break + + if count > 24: + assert response.get_result().get("operational_status") == "provisioned" + else: + time.sleep(10) + count += 1 + + #update the bgp asn and bgp ip + updatedBgpAsn = 63999 + updatedBgpCerCidr = "172.17.252.2/29" + updatedBgpIbmCidr = "172.17.252.1/29" + try: + response = self.dl_provider.update_provider_gateway(id=gateway_id, + bgp_cer_cidr=updatedBgpCerCidr, bgp_ibm_cidr=updatedBgpIbmCidr, bgp_asn=updatedBgpAsn) + assert response.get_status_code() == 200 + assert response.get_result()["name"] == name + assert response.get_result()["id"] == gateway_id + assert response.get_result()["change_request"] is not None + except ApiException as e: + assert e.code == 400 + assert e.detail == "Please make sure localIP and remoteIP are not in use" + + #approve BGP changes request using client account + bgpAsnObject = {"bgp_asn": updatedBgpAsn} + bgpIpObject = {"bgp_cer_cidr": updatedBgpCerCidr, "bgp_ibm_cidr": updatedBgpIbmCidr} + updateAttributes = [bgpAsnObject, bgpIpObject] + response = self.dl.create_gateway_action(id=gateway_id, + action="update_attributes_approve", + updates=updateAttributes) + assert response is not None + assert response.get_status_code() == 200 + + # wait until gateway moves to provisioned state + count = 0 + while True: + response = None + response = self.dl.get_gateway(id=gateway_id) + operationalStatus = response.get_result().get("operational_status") + + if (response is not None) and (response.get_result().get("operational_status") == "provisioned"): + assert response is not None + assert response.get_status_code() == 200 + assert response.get_result().get("id") == gateway_id + assert response.get_result().get("name") == name + assert response.get_result().get("bgp_asn") == updatedBgpAsn + assert response.get_result().get("bgp_cer_cidr") == updatedBgpCerCidr + assert response.get_result().get("bgp_ibm_cidr") == updatedBgpIbmCidr + assert response.get_result().get("provider_api_managed") == True + assert response.get_result().get("operational_status") == "provisioned" + assert response.get_result().get("type") == "connect" + break + + if count > 24: + assert response.get_result().get("operational_status") == "provisioned" + else: + time.sleep(10) + count += 1 + + #successfully request delete using provider account + response = self.dl_provider.delete_provider_gateway(id=gateway_id) + assert response is not None + assert response.get_status_code() == 202 + + #successfully approve delete gateway using client account + response = self.dl.create_gateway_action(id=gateway_id, action="delete_gateway_approve") + assert response is not None + assert response.get_status_code() == 204 + +################## Direct Link Provider Gateways with BFD Config ############################ + + def test_provider_gateway_actions_with_client_api_bfd_config(self): + timestamp = time.time() + name = os.getenv("DL_PROVIDER_SERVICES_GW_NAME") + "-BFD-CONFIG-" + str(int(timestamp)) + bgpAsn = 64999 + customerAccount = os.getenv("DL_PROVIDER_SERVICES_CUSTOMER_ACCT_ID") + speedMbps = 1000 + + """ successfully get a provider port id """ + response = self.dl_provider.list_provider_ports() + assert response is not None + + port_id = response.get_result().get("ports")[0].get("id") + port = ProviderGatewayPortIdentity(id=port_id) + + #created provider gateway + response = self.dl_provider.create_provider_gateway(bgp_asn=bgpAsn, + customer_account_id=customerAccount, + name=name, + port=port, + speed_mbps=speedMbps) + assert response is not None + assert response.get_status_code() == 201 + gateway_id = response.get_result().get("id") + + #verfiy client account can see the provider created gateway + response = self.dl.get_gateway(id=gateway_id) + assert response is not None + assert response.get_status_code() == 200 + assert response.get_result().get("id") == gateway_id + assert response.get_result().get("name") == name + assert response.get_result().get("speed_mbps") == speedMbps + assert response.get_result().get("provider_api_managed") == True + assert response.get_result().get("operational_status") == "create_pending" + assert response.get_result().get("type") == "connect" + assert "change_request" in response.get_result() + + #successfully approve the gateway create using client account + bfdConfig = GatewayBfdConfigActionTemplate(interval=1000, multiplier=2) + response = self.dl.create_gateway_action(id=gateway_id, + action="create_gateway_approve", + metered=False, + global_=False, + bfd_config=bfdConfig) + assert response is not None + assert response.get_status_code() == 200 + result = response.get_result() + assert result['id'] == gateway_id + assert result['name'] == name + assert result['bfd_config'] is not None + + # wait until gateway moves to provisioned state + count = 0 + while True: + response = None + response = self.dl.get_gateway(id=gateway_id) + operationalStatus = response.get_result().get("operational_status") + + if (response is not None) and (response.get_result().get("operational_status") == "provisioned"): + assert response is not None + assert response.get_status_code() == 200 + assert response.get_result().get("id") == gateway_id + assert response.get_result().get("name") == name + assert response.get_result().get("speed_mbps") == speedMbps + assert response.get_result().get("provider_api_managed") == True + assert response.get_result().get("operational_status") == "provisioned" + assert response.get_result().get("type") == "connect" + assert response.get_result().get('bfd_config') is not None + break + + if count > 24: + assert response.get_result().get("operational_status") == "provisioned" + else: + time.sleep(10) + count += 1 + + #successfully request delete using provider account + response = self.dl_provider.delete_provider_gateway(id=gateway_id) + assert response is not None + assert response.get_status_code() == 202 + + #successfully approve delete gateway using client account + response = self.dl.create_gateway_action(id=gateway_id, action="delete_gateway_approve") + assert response is not None + assert response.get_status_code() == 204 if __name__ == '__main__': unittest.main() \ No newline at end of file diff --git a/test/integration/test_direct_link_v1.py b/test/integration/test_direct_link_v1.py index 8c4bd9b..c8af8b4 100644 --- a/test/integration/test_direct_link_v1.py +++ b/test/integration/test_direct_link_v1.py @@ -29,7 +29,10 @@ GatewayTemplateAuthenticationKey, GatewayPatchTemplateAuthenticationKey, GatewayTemplateGatewayTypeConnectTemplate, - GatewayPortIdentity + GatewayPortIdentity, + Gateway, + GatewayBfdConfigTemplate, + GatewayBfdPatchTemplate ) # from ibm_cloud_networking_services.direct_link_v1 import ( # GatewayMacsecConfigTemplate) @@ -498,7 +501,65 @@ def test_dedicated_gateway_with_connection_mode(self): assert response.get_result()["id"] == gateway_id assert response.get_result()["connection_mode"] == "direct" - # check gateway status until provisioned + # delete gateway + self.delete_gateway(gateway_id) + + ################## Direct Link Connect Gateways with Connection Mode ############################ + + def test_connect_gateway_with_connection_mode(self): + bgpAsn = 64999 + global_bool = True + speedMbps = 1000 + metered = False + gatewayType = "connect" + connectionMode = "direct" + + """ test create/update/delete gateway with connection_mode success """ + # FEtch the list of ports and use a port to create a connect gateway + response = self.dl.list_ports() + assert response is not None + + port_id = response.get_result().get("ports")[0].get("id") + + # create gateway with connection_mode as transit + gwPort = GatewayPortIdentity(id= port_id) + name = os.getenv("DL_SERVICES_GW_NAME") + str("-CONNECT-DLAAS-") +str(int(time.time())) + gtw_template = GatewayTemplateGatewayTypeConnectTemplate(name=name, + type=gatewayType, speed_mbps=speedMbps, global_=global_bool, + bgp_asn=bgpAsn, metered=metered, connection_mode=connectionMode, port=gwPort) + response = self.dl.create_gateway(gateway_template=gtw_template) + assert response is not None + assert response.get_status_code() == 201 + gateway_id = response.get_result().get("id") + + res = response.get_result() + assert res["name"] == name + assert res["connection_mode"] == connectionMode + + # check gateway status until provisioned + count = 0 + while count < 24: + response = self.dl.get_gateway(id=gateway_id) + status = response.get_result()["operational_status"] + ret_id = response.get_result()["id"] + assert ret_id == gateway_id + assert response.get_status_code() == 200 + if status == "provisioned": + break + else: + time.sleep(5) + count += 1 + + # update the connection_mode to direct + response = self.dl.update_gateway(id=gateway_id, + connection_mode="transit") + assert response is not None + assert response.get_status_code() == 200 + assert response.get_result()["name"] == name + assert response.get_result()["id"] == gateway_id + assert response.get_result()["connection_mode"] == "transit" + + # check gateway status until provisioned count = 0 while count < 24: response = self.dl.get_gateway(id=gateway_id) @@ -515,29 +576,81 @@ def test_dedicated_gateway_with_connection_mode(self): # delete gateway self.delete_gateway(gateway_id) - ################## Direct Link Connect Gateways with Connection Mode ############################ + ################## Direct Link Dedicated Gateways with BGP IP Update ############################ - def test_connect_gateway_with_connection_mode(self): + def test_dedicated_gateway_with_bgp_ip_update(self): + bgpAsn = 64999 + crossConnectRouter = "LAB-xcr01.dal09" + global_bool = True + locationName = os.getenv("DL_SERVICES_LOCATION_NAME") + speedMbps = 1000 + metered = False + carrierName = "carrier1" + customerName = "customer1" + gatewayType = "dedicated" + + """ test create/update/delete gateway with bgp_asn bgp_cer_cidr bgp_ibm_cidr success """ + # create a dedicated gateway + name = os.getenv("DL_SERVICES_GW_NAME") + str("-DEDICATED-BGP-IP-UPDATE-") +str(int(time.time())) + gtw_template = GatewayTemplateGatewayTypeDedicatedTemplate(name=name, + type=gatewayType, speed_mbps=speedMbps, global_=global_bool, + bgp_asn=bgpAsn, metered=metered, + carrier_name=carrierName, cross_connect_router=crossConnectRouter, + customer_name=customerName, location_name=locationName) + response = self.dl.create_gateway(gateway_template=gtw_template) + assert response is not None + assert response.get_status_code() == 201 + gateway_id = response.get_result().get("id") + + res = response.get_result() + assert res["name"] == name + + # update the bgp_asn + response = self.dl.update_gateway(id=gateway_id, + bgp_asn=63999) + assert response is not None + assert response.get_status_code() == 200 + assert response.get_result()["name"] == name + assert response.get_result()["id"] == gateway_id + assert response.get_result()["bgp_asn"] == 63999 + + #update the bgp ip cer and ibm cidr + try: + response = self.dl.update_gateway(id=gateway_id, + bgp_cer_cidr="172.17.252.2/29", bgp_ibm_cidr="172.17.252.1/29") + assert response.get_status_code() == 200 + assert response.get_result()["name"] == name + assert response.get_result()["id"] == gateway_id + assert response.get_result()["bgp_asn"] == 63999 + except ApiException as e: + assert e.code == 400 + assert e.detail == "Please make sure localIP and remoteIP are not in use" + + # delete gateway + self.delete_gateway(gateway_id) + +################## Direct Link Connect Gateways with Connection Mode ############################ + + def test_connect_gateway_with_bgp_ip_update(self): bgpAsn = 64999 global_bool = True speedMbps = 1000 metered = False gatewayType = "connect" - connectionMode = "direct" - """ test create/update/delete gateway with connection_mode success """ - # FEtch the list of ports and use a port to create a connect gateway + """ test create/update/delete gateway with bgp_asn bgp_cer_cidr bgp_ibm_cidr success """ + # Fetch the list of ports and use a port to create a connect gateway response = self.dl.list_ports() assert response is not None port_id = response.get_result().get("ports")[0].get("id") - # create gateway with connection_mode as transit + # create a connect gateway gwPort = GatewayPortIdentity(id= port_id) - name = os.getenv("DL_SERVICES_GW_NAME") + str("-CONNECT-DLAAS-") +str(int(time.time())) + name = os.getenv("DL_SERVICES_GW_NAME") + str("-DEDICATED-BGP-IP-UPDATE-") +str(int(time.time())) gtw_template = GatewayTemplateGatewayTypeConnectTemplate(name=name, type=gatewayType, speed_mbps=speedMbps, global_=global_bool, - bgp_asn=bgpAsn, metered=metered, connection_mode=connectionMode, port=gwPort) + bgp_asn=bgpAsn, metered=metered, port=gwPort) response = self.dl.create_gateway(gateway_template=gtw_template) assert response is not None assert response.get_status_code() == 201 @@ -545,7 +658,6 @@ def test_connect_gateway_with_connection_mode(self): res = response.get_result() assert res["name"] == name - assert res["connection_mode"] == connectionMode # check gateway status until provisioned count = 0 @@ -561,14 +673,41 @@ def test_connect_gateway_with_connection_mode(self): time.sleep(5) count += 1 - # update the connection_mode to direct + # update the bgp_asn response = self.dl.update_gateway(id=gateway_id, - connection_mode="transit") + bgp_asn=63999) assert response is not None assert response.get_status_code() == 200 assert response.get_result()["name"] == name assert response.get_result()["id"] == gateway_id - assert response.get_result()["connection_mode"] == "transit" + assert response.get_result()["bgp_asn"] == 63999 + + # check gateway status until provisioned + count = 0 + while count < 24: + response = self.dl.get_gateway(id=gateway_id) + status = response.get_result()["operational_status"] + ret_id = response.get_result()["id"] + assert ret_id == gateway_id + assert response.get_status_code() == 200 + if status == "provisioned": + break + else: + time.sleep(5) + count += 1 + + #update the bgp ip cer and ibm cidr + try: + response = self.dl.update_gateway(id=gateway_id, + bgp_cer_cidr="172.17.252.2/29", bgp_ibm_cidr="172.17.252.1/29") + assert response.get_status_code() == 200 + assert response.get_result()["name"] == name + assert response.get_result()["id"] == gateway_id + assert response.get_result()["bgp_cer_cidr"] == "172.17.252.2/29" + assert response.get_result()["bgp_ibm_cidr"] == "172.17.252.1/29" + except ApiException as e: + assert e.code == 400 + assert e.detail == "Please make sure localIP and remoteIP are not in use" # check gateway status until provisioned count = 0 @@ -587,5 +726,178 @@ def test_connect_gateway_with_connection_mode(self): # delete gateway self.delete_gateway(gateway_id) +################## Direct Link Dedicated Gateways with BFD Config ############################ + + def test_dedicated_gateway_with_bfd_config(self): + bgpAsn = 64999 + crossConnectRouter = "LAB-xcr01.dal09" + global_bool = True + locationName = os.getenv("DL_SERVICES_LOCATION_NAME") + speedMbps = 1000 + metered = False + carrierName = "carrier1" + customerName = "customer1" + gatewayType = "dedicated" + + bfdInterval = 1000 + bfdMultiplier = 2 + bfdConfig = GatewayBfdConfigTemplate(interval=bfdInterval, multiplier=bfdMultiplier) + + """ test create/update/delete gateway with bfd_config """ + # create a dedicated gateway + name = os.getenv("DL_SERVICES_GW_NAME") + str("-DEDICATED-BFD-") +str(int(time.time())) + gtw_template = GatewayTemplateGatewayTypeDedicatedTemplate(name=name, + type=gatewayType, speed_mbps=speedMbps, global_=global_bool, + bgp_asn=bgpAsn, metered=metered, + carrier_name=carrierName, cross_connect_router=crossConnectRouter, + customer_name=customerName, location_name=locationName, bfd_config=bfdConfig) + response = self.dl.create_gateway(gateway_template=gtw_template) + assert response is not None + assert response.get_status_code() == 201 + assert response.get_result()["bfd_config"]["interval"] == bfdInterval + assert response.get_result()["bfd_config"]["multiplier"] == bfdMultiplier + gateway_id = response.get_result().get("id") + + res = response.get_result() + assert res["name"] == name + + # update the bfd_config + updatedBfdInterval = 700 + updatedBfdMultiplier = 10 + updatedBfdConfig = GatewayBfdPatchTemplate(interval=updatedBfdInterval, multiplier=updatedBfdMultiplier) + response = self.dl.update_gateway(id=gateway_id, + bfd_config=updatedBfdConfig) + assert response is not None + assert response.get_status_code() == 200 + assert response.get_result()["name"] == name + assert response.get_result()["id"] == gateway_id + assert response.get_result()["bfd_config"]["interval"] == updatedBfdInterval + assert response.get_result()["bfd_config"]["multiplier"] == updatedBfdMultiplier + + # delete gateway + self.delete_gateway(gateway_id) + +################## Direct Link Connect Gateways BFD Config ############################ + + def test_connect_gateway_with_bfd_config(self): + bgpAsn = 64999 + global_bool = True + speedMbps = 1000 + metered = False + gatewayType = "connect" + + """ test create/update/delete gateway with bfd_config """ + # Fetch the list of ports and use a port to create a connect gateway + response = self.dl.list_ports() + assert response is not None + + port_id = response.get_result().get("ports")[0].get("id") + + # create a connect gateway + gwPort = GatewayPortIdentity(id= port_id) + name = os.getenv("DL_SERVICES_GW_NAME") + str("-DEDICATED-BFD-CONFIG-") +str(int(time.time())) + + bfdInterval = 1000 + bfdMultiplier = 2 + bfdConfig = GatewayBfdConfigTemplate(interval=bfdInterval, multiplier=bfdMultiplier) + + gtw_template = GatewayTemplateGatewayTypeConnectTemplate(name=name, + type=gatewayType, speed_mbps=speedMbps, global_=global_bool, + bgp_asn=bgpAsn, metered=metered, port=gwPort, bfd_config=bfdConfig) + response = self.dl.create_gateway(gateway_template=gtw_template) + assert response is not None + assert response.get_status_code() == 201 + gateway_id = response.get_result().get("id") + + res = response.get_result() + assert res["name"] == name + + # check gateway status until provisioned + count = 0 + while count < 24: + response = self.dl.get_gateway(id=gateway_id) + status = response.get_result()["operational_status"] + ret_id = response.get_result()["id"] + assert ret_id == gateway_id + assert response.get_status_code() == 200 + if status == "provisioned": + break + else: + time.sleep(5) + count += 1 + + # update the bfd_config + updatedBfdInterval = 700 + updatedBfdMultiplier = 10 + updatedBfdConfig = GatewayBfdPatchTemplate(interval=updatedBfdInterval, multiplier=updatedBfdMultiplier) + response = self.dl.update_gateway(id=gateway_id, + bfd_config=updatedBfdConfig) + assert response is not None + assert response.get_status_code() == 200 + assert response.get_result()["name"] == name + assert response.get_result()["id"] == gateway_id + assert response.get_result()["bfd_config"]["interval"] == updatedBfdInterval + assert response.get_result()["bfd_config"]["multiplier"] == updatedBfdMultiplier + + # check gateway status until provisioned + count = 0 + while count < 24: + response = self.dl.get_gateway(id=gateway_id) + status = response.get_result()["operational_status"] + ret_id = response.get_result()["id"] + assert ret_id == gateway_id + assert response.get_status_code() == 200 + if status == "provisioned": + break + else: + time.sleep(5) + count += 1 + + # delete gateway + self.delete_gateway(gateway_id) + +################## Direct Link Dedicated Gateways Status ############################ + + def test_dedicated_gateway_with_status(self): + bgpAsn = 64999 + crossConnectRouter = "LAB-xcr01.dal09" + global_bool = True + locationName = os.getenv("DL_SERVICES_LOCATION_NAME") + speedMbps = 1000 + metered = False + carrierName = "carrier1" + customerName = "customer1" + gatewayType = "dedicated" + + bfdInterval = 1000 + bfdMultiplier = 2 + bfdConfig = GatewayBfdConfigTemplate(interval=bfdInterval, multiplier=bfdMultiplier) + + """ test create/update/delete gateway with get gateway status """ + # create a dedicated gateway + name = os.getenv("DL_SERVICES_GW_NAME") + str("-DEDICATED-GW-STATUS") +str(int(time.time())) + gtw_template = GatewayTemplateGatewayTypeDedicatedTemplate(name=name, + type=gatewayType, speed_mbps=speedMbps, global_=global_bool, + bgp_asn=bgpAsn, metered=metered, + carrier_name=carrierName, cross_connect_router=crossConnectRouter, + customer_name=customerName, location_name=locationName, bfd_config=bfdConfig) + response = self.dl.create_gateway(gateway_template=gtw_template) + assert response is not None + assert response.get_status_code() == 201 + assert response.get_result()["bfd_config"]["interval"] == bfdInterval + assert response.get_result()["bfd_config"]["multiplier"] == bfdMultiplier + gateway_id = response.get_result().get("id") + + res = response.get_result() + assert res["name"] == name + + # get the gateway status + response = self.dl.get_gateway_status(id=gateway_id, type="link") + assert response is not None + assert response.get_status_code() == 200 + assert response.get_result()["status"] is not None + + # delete gateway + self.delete_gateway(gateway_id) if __name__ == '__main__': unittest.main() diff --git a/test/unit/test_direct_link_provider_v2.py b/test/unit/test_direct_link_provider_v2.py index 8451caa..879b11e 100644 --- a/test/unit/test_direct_link_provider_v2.py +++ b/test/unit/test_direct_link_provider_v2.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# (C) Copyright IBM Corp. 2020. +# (C) Copyright IBM Corp. 2021. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -49,7 +49,7 @@ class TestListProviderGateways(): def test_list_provider_gateways_all_params(self): # Set up mock url = base_url + '/gateways' - mock_response = '{"first": {"href": "https://directlink.cloud.ibm.com/provider/v2/gateways?limit=100"}, "limit": 100, "next": {"href": "https://directlink.cloud.ibm.com/provider/v2/gateways?start=8c4a91a3e2cbd233b5a5b33436855fc2&limit=100", "start": "8c4a91a3e2cbd233b5a5b33436855fc2"}, "total_count": 132, "gateways": [{"bgp_asn": 64999, "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "change_request": {"type": "create_gateway"}, "created_at": "2019-01-01T12:00:00", "crn": "crn:v1:bluemix:public:directlink:dal03:a/57a7d05f36894e3cb9b46a43556d903e::connect:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "customer_account_id": "57a7d05f36894e3cb9b46a43556d903e", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "myGateway", "operational_status": "create_pending", "port": {"id": "fffdcb1a-fee4-41c7-9e11-9cd99e65c777"}, "provider_api_managed": true, "speed_mbps": 1000, "type": "connect", "vlan": 10}]}' + mock_response = '{"first": {"href": "https://directlink.cloud.ibm.com/provider/v2/gateways?limit=100"}, "limit": 100, "next": {"href": "https://directlink.cloud.ibm.com/provider/v2/gateways?start=8c4a91a3e2cbd233b5a5b33436855fc2&limit=100", "start": "8c4a91a3e2cbd233b5a5b33436855fc2"}, "total_count": 132, "gateways": [{"bgp_asn": 64999, "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "change_request": {"type": "create_gateway"}, "created_at": "2019-01-01T12:00:00", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::connect:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "customer_account_id": "4111d05f36894e3cb9b46a43556d9000", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "myGateway", "operational_status": "configuring", "port": {"id": "fffdcb1a-fee4-41c7-9e11-9cd99e65c777"}, "provider_api_managed": true, "speed_mbps": 1000, "type": "connect", "vlan": 10}]}' responses.add(responses.GET, url, body=mock_response, @@ -84,7 +84,7 @@ def test_list_provider_gateways_all_params(self): def test_list_provider_gateways_required_params(self): # Set up mock url = base_url + '/gateways' - mock_response = '{"first": {"href": "https://directlink.cloud.ibm.com/provider/v2/gateways?limit=100"}, "limit": 100, "next": {"href": "https://directlink.cloud.ibm.com/provider/v2/gateways?start=8c4a91a3e2cbd233b5a5b33436855fc2&limit=100", "start": "8c4a91a3e2cbd233b5a5b33436855fc2"}, "total_count": 132, "gateways": [{"bgp_asn": 64999, "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "change_request": {"type": "create_gateway"}, "created_at": "2019-01-01T12:00:00", "crn": "crn:v1:bluemix:public:directlink:dal03:a/57a7d05f36894e3cb9b46a43556d903e::connect:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "customer_account_id": "57a7d05f36894e3cb9b46a43556d903e", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "myGateway", "operational_status": "create_pending", "port": {"id": "fffdcb1a-fee4-41c7-9e11-9cd99e65c777"}, "provider_api_managed": true, "speed_mbps": 1000, "type": "connect", "vlan": 10}]}' + mock_response = '{"first": {"href": "https://directlink.cloud.ibm.com/provider/v2/gateways?limit=100"}, "limit": 100, "next": {"href": "https://directlink.cloud.ibm.com/provider/v2/gateways?start=8c4a91a3e2cbd233b5a5b33436855fc2&limit=100", "start": "8c4a91a3e2cbd233b5a5b33436855fc2"}, "total_count": 132, "gateways": [{"bgp_asn": 64999, "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "change_request": {"type": "create_gateway"}, "created_at": "2019-01-01T12:00:00", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::connect:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "customer_account_id": "4111d05f36894e3cb9b46a43556d9000", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "myGateway", "operational_status": "configuring", "port": {"id": "fffdcb1a-fee4-41c7-9e11-9cd99e65c777"}, "provider_api_managed": true, "speed_mbps": 1000, "type": "connect", "vlan": 10}]}' responses.add(responses.GET, url, body=mock_response, @@ -107,7 +107,7 @@ def test_list_provider_gateways_required_params(self): def test_list_provider_gateways_value_error(self): # Set up mock url = base_url + '/gateways' - mock_response = '{"first": {"href": "https://directlink.cloud.ibm.com/provider/v2/gateways?limit=100"}, "limit": 100, "next": {"href": "https://directlink.cloud.ibm.com/provider/v2/gateways?start=8c4a91a3e2cbd233b5a5b33436855fc2&limit=100", "start": "8c4a91a3e2cbd233b5a5b33436855fc2"}, "total_count": 132, "gateways": [{"bgp_asn": 64999, "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "change_request": {"type": "create_gateway"}, "created_at": "2019-01-01T12:00:00", "crn": "crn:v1:bluemix:public:directlink:dal03:a/57a7d05f36894e3cb9b46a43556d903e::connect:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "customer_account_id": "57a7d05f36894e3cb9b46a43556d903e", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "myGateway", "operational_status": "create_pending", "port": {"id": "fffdcb1a-fee4-41c7-9e11-9cd99e65c777"}, "provider_api_managed": true, "speed_mbps": 1000, "type": "connect", "vlan": 10}]}' + mock_response = '{"first": {"href": "https://directlink.cloud.ibm.com/provider/v2/gateways?limit=100"}, "limit": 100, "next": {"href": "https://directlink.cloud.ibm.com/provider/v2/gateways?start=8c4a91a3e2cbd233b5a5b33436855fc2&limit=100", "start": "8c4a91a3e2cbd233b5a5b33436855fc2"}, "total_count": 132, "gateways": [{"bgp_asn": 64999, "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "change_request": {"type": "create_gateway"}, "created_at": "2019-01-01T12:00:00", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::connect:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "customer_account_id": "4111d05f36894e3cb9b46a43556d9000", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "myGateway", "operational_status": "configuring", "port": {"id": "fffdcb1a-fee4-41c7-9e11-9cd99e65c777"}, "provider_api_managed": true, "speed_mbps": 1000, "type": "connect", "vlan": 10}]}' responses.add(responses.GET, url, body=mock_response, @@ -136,7 +136,7 @@ class TestCreateProviderGateway(): def test_create_provider_gateway_all_params(self): # Set up mock url = base_url + '/gateways' - mock_response = '{"bgp_asn": 64999, "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "change_request": {"type": "create_gateway"}, "created_at": "2019-01-01T12:00:00", "crn": "crn:v1:bluemix:public:directlink:dal03:a/57a7d05f36894e3cb9b46a43556d903e::connect:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "customer_account_id": "57a7d05f36894e3cb9b46a43556d903e", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "myGateway", "operational_status": "create_pending", "port": {"id": "fffdcb1a-fee4-41c7-9e11-9cd99e65c777"}, "provider_api_managed": true, "speed_mbps": 1000, "type": "connect", "vlan": 10}' + mock_response = '{"bgp_asn": 64999, "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "change_request": {"type": "create_gateway"}, "created_at": "2019-01-01T12:00:00", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::connect:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "customer_account_id": "4111d05f36894e3cb9b46a43556d9000", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "myGateway", "operational_status": "configuring", "port": {"id": "fffdcb1a-fee4-41c7-9e11-9cd99e65c777"}, "provider_api_managed": true, "speed_mbps": 1000, "type": "connect", "vlan": 10}' responses.add(responses.POST, url, body=mock_response, @@ -149,7 +149,7 @@ def test_create_provider_gateway_all_params(self): # Set up parameter values bgp_asn = 64999 - customer_account_id = '57a7d05f36894e3cb9b46a43556d903e' + customer_account_id = '4111d05f36894e3cb9b46a43556d9000' name = 'myGateway' port = provider_gateway_port_identity_model speed_mbps = 1000 @@ -180,7 +180,7 @@ def test_create_provider_gateway_all_params(self): # Validate body params req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) assert req_body['bgp_asn'] == 64999 - assert req_body['customer_account_id'] == '57a7d05f36894e3cb9b46a43556d903e' + assert req_body['customer_account_id'] == '4111d05f36894e3cb9b46a43556d9000' assert req_body['name'] == 'myGateway' assert req_body['port'] == provider_gateway_port_identity_model assert req_body['speed_mbps'] == 1000 @@ -195,7 +195,7 @@ def test_create_provider_gateway_all_params(self): def test_create_provider_gateway_required_params(self): # Set up mock url = base_url + '/gateways' - mock_response = '{"bgp_asn": 64999, "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "change_request": {"type": "create_gateway"}, "created_at": "2019-01-01T12:00:00", "crn": "crn:v1:bluemix:public:directlink:dal03:a/57a7d05f36894e3cb9b46a43556d903e::connect:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "customer_account_id": "57a7d05f36894e3cb9b46a43556d903e", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "myGateway", "operational_status": "create_pending", "port": {"id": "fffdcb1a-fee4-41c7-9e11-9cd99e65c777"}, "provider_api_managed": true, "speed_mbps": 1000, "type": "connect", "vlan": 10}' + mock_response = '{"bgp_asn": 64999, "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "change_request": {"type": "create_gateway"}, "created_at": "2019-01-01T12:00:00", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::connect:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "customer_account_id": "4111d05f36894e3cb9b46a43556d9000", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "myGateway", "operational_status": "configuring", "port": {"id": "fffdcb1a-fee4-41c7-9e11-9cd99e65c777"}, "provider_api_managed": true, "speed_mbps": 1000, "type": "connect", "vlan": 10}' responses.add(responses.POST, url, body=mock_response, @@ -208,7 +208,7 @@ def test_create_provider_gateway_required_params(self): # Set up parameter values bgp_asn = 64999 - customer_account_id = '57a7d05f36894e3cb9b46a43556d903e' + customer_account_id = '4111d05f36894e3cb9b46a43556d9000' name = 'myGateway' port = provider_gateway_port_identity_model speed_mbps = 1000 @@ -233,7 +233,7 @@ def test_create_provider_gateway_required_params(self): # Validate body params req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) assert req_body['bgp_asn'] == 64999 - assert req_body['customer_account_id'] == '57a7d05f36894e3cb9b46a43556d903e' + assert req_body['customer_account_id'] == '4111d05f36894e3cb9b46a43556d9000' assert req_body['name'] == 'myGateway' assert req_body['port'] == provider_gateway_port_identity_model assert req_body['speed_mbps'] == 1000 @@ -248,7 +248,7 @@ def test_create_provider_gateway_required_params(self): def test_create_provider_gateway_value_error(self): # Set up mock url = base_url + '/gateways' - mock_response = '{"bgp_asn": 64999, "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "change_request": {"type": "create_gateway"}, "created_at": "2019-01-01T12:00:00", "crn": "crn:v1:bluemix:public:directlink:dal03:a/57a7d05f36894e3cb9b46a43556d903e::connect:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "customer_account_id": "57a7d05f36894e3cb9b46a43556d903e", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "myGateway", "operational_status": "create_pending", "port": {"id": "fffdcb1a-fee4-41c7-9e11-9cd99e65c777"}, "provider_api_managed": true, "speed_mbps": 1000, "type": "connect", "vlan": 10}' + mock_response = '{"bgp_asn": 64999, "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "change_request": {"type": "create_gateway"}, "created_at": "2019-01-01T12:00:00", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::connect:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "customer_account_id": "4111d05f36894e3cb9b46a43556d9000", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "myGateway", "operational_status": "configuring", "port": {"id": "fffdcb1a-fee4-41c7-9e11-9cd99e65c777"}, "provider_api_managed": true, "speed_mbps": 1000, "type": "connect", "vlan": 10}' responses.add(responses.POST, url, body=mock_response, @@ -261,7 +261,7 @@ def test_create_provider_gateway_value_error(self): # Set up parameter values bgp_asn = 64999 - customer_account_id = '57a7d05f36894e3cb9b46a43556d903e' + customer_account_id = '4111d05f36894e3cb9b46a43556d9000' name = 'myGateway' port = provider_gateway_port_identity_model speed_mbps = 1000 @@ -295,7 +295,7 @@ class TestDeleteProviderGateway(): def test_delete_provider_gateway_all_params(self): # Set up mock url = base_url + '/gateways/testString' - mock_response = '{"bgp_asn": 64999, "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "change_request": {"type": "create_gateway"}, "created_at": "2019-01-01T12:00:00", "crn": "crn:v1:bluemix:public:directlink:dal03:a/57a7d05f36894e3cb9b46a43556d903e::connect:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "customer_account_id": "57a7d05f36894e3cb9b46a43556d903e", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "myGateway", "operational_status": "create_pending", "port": {"id": "fffdcb1a-fee4-41c7-9e11-9cd99e65c777"}, "provider_api_managed": true, "speed_mbps": 1000, "type": "connect", "vlan": 10}' + mock_response = '{"bgp_asn": 64999, "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "change_request": {"type": "create_gateway"}, "created_at": "2019-01-01T12:00:00", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::connect:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "customer_account_id": "4111d05f36894e3cb9b46a43556d9000", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "myGateway", "operational_status": "configuring", "port": {"id": "fffdcb1a-fee4-41c7-9e11-9cd99e65c777"}, "provider_api_managed": true, "speed_mbps": 1000, "type": "connect", "vlan": 10}' responses.add(responses.DELETE, url, body=mock_response, @@ -323,7 +323,7 @@ def test_delete_provider_gateway_all_params(self): def test_delete_provider_gateway_value_error(self): # Set up mock url = base_url + '/gateways/testString' - mock_response = '{"bgp_asn": 64999, "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "change_request": {"type": "create_gateway"}, "created_at": "2019-01-01T12:00:00", "crn": "crn:v1:bluemix:public:directlink:dal03:a/57a7d05f36894e3cb9b46a43556d903e::connect:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "customer_account_id": "57a7d05f36894e3cb9b46a43556d903e", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "myGateway", "operational_status": "create_pending", "port": {"id": "fffdcb1a-fee4-41c7-9e11-9cd99e65c777"}, "provider_api_managed": true, "speed_mbps": 1000, "type": "connect", "vlan": 10}' + mock_response = '{"bgp_asn": 64999, "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "change_request": {"type": "create_gateway"}, "created_at": "2019-01-01T12:00:00", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::connect:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "customer_account_id": "4111d05f36894e3cb9b46a43556d9000", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "myGateway", "operational_status": "configuring", "port": {"id": "fffdcb1a-fee4-41c7-9e11-9cd99e65c777"}, "provider_api_managed": true, "speed_mbps": 1000, "type": "connect", "vlan": 10}' responses.add(responses.DELETE, url, body=mock_response, @@ -356,7 +356,7 @@ class TestGetProviderGateway(): def test_get_provider_gateway_all_params(self): # Set up mock url = base_url + '/gateways/testString' - mock_response = '{"bgp_asn": 64999, "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "change_request": {"type": "create_gateway"}, "created_at": "2019-01-01T12:00:00", "crn": "crn:v1:bluemix:public:directlink:dal03:a/57a7d05f36894e3cb9b46a43556d903e::connect:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "customer_account_id": "57a7d05f36894e3cb9b46a43556d903e", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "myGateway", "operational_status": "create_pending", "port": {"id": "fffdcb1a-fee4-41c7-9e11-9cd99e65c777"}, "provider_api_managed": true, "speed_mbps": 1000, "type": "connect", "vlan": 10}' + mock_response = '{"bgp_asn": 64999, "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "change_request": {"type": "create_gateway"}, "created_at": "2019-01-01T12:00:00", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::connect:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "customer_account_id": "4111d05f36894e3cb9b46a43556d9000", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "myGateway", "operational_status": "configuring", "port": {"id": "fffdcb1a-fee4-41c7-9e11-9cd99e65c777"}, "provider_api_managed": true, "speed_mbps": 1000, "type": "connect", "vlan": 10}' responses.add(responses.GET, url, body=mock_response, @@ -384,7 +384,7 @@ def test_get_provider_gateway_all_params(self): def test_get_provider_gateway_value_error(self): # Set up mock url = base_url + '/gateways/testString' - mock_response = '{"bgp_asn": 64999, "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "change_request": {"type": "create_gateway"}, "created_at": "2019-01-01T12:00:00", "crn": "crn:v1:bluemix:public:directlink:dal03:a/57a7d05f36894e3cb9b46a43556d903e::connect:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "customer_account_id": "57a7d05f36894e3cb9b46a43556d903e", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "myGateway", "operational_status": "create_pending", "port": {"id": "fffdcb1a-fee4-41c7-9e11-9cd99e65c777"}, "provider_api_managed": true, "speed_mbps": 1000, "type": "connect", "vlan": 10}' + mock_response = '{"bgp_asn": 64999, "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "change_request": {"type": "create_gateway"}, "created_at": "2019-01-01T12:00:00", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::connect:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "customer_account_id": "4111d05f36894e3cb9b46a43556d9000", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "myGateway", "operational_status": "configuring", "port": {"id": "fffdcb1a-fee4-41c7-9e11-9cd99e65c777"}, "provider_api_managed": true, "speed_mbps": 1000, "type": "connect", "vlan": 10}' responses.add(responses.GET, url, body=mock_response, @@ -417,7 +417,7 @@ class TestUpdateProviderGateway(): def test_update_provider_gateway_all_params(self): # Set up mock url = base_url + '/gateways/testString' - mock_response = '{"bgp_asn": 64999, "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "change_request": {"type": "create_gateway"}, "created_at": "2019-01-01T12:00:00", "crn": "crn:v1:bluemix:public:directlink:dal03:a/57a7d05f36894e3cb9b46a43556d903e::connect:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "customer_account_id": "57a7d05f36894e3cb9b46a43556d903e", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "myGateway", "operational_status": "create_pending", "port": {"id": "fffdcb1a-fee4-41c7-9e11-9cd99e65c777"}, "provider_api_managed": true, "speed_mbps": 1000, "type": "connect", "vlan": 10}' + mock_response = '{"bgp_asn": 64999, "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "change_request": {"type": "create_gateway"}, "created_at": "2019-01-01T12:00:00", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::connect:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "customer_account_id": "4111d05f36894e3cb9b46a43556d9000", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "myGateway", "operational_status": "configuring", "port": {"id": "fffdcb1a-fee4-41c7-9e11-9cd99e65c777"}, "provider_api_managed": true, "speed_mbps": 1000, "type": "connect", "vlan": 10}' responses.add(responses.PATCH, url, body=mock_response, @@ -426,12 +426,18 @@ def test_update_provider_gateway_all_params(self): # Set up parameter values id = 'testString' + bgp_asn = 64999 + bgp_cer_cidr = '169.254.0.10/30' + bgp_ibm_cidr = '169.254.0.9/30' name = 'myNewGateway' speed_mbps = 1000 # Invoke method response = service.update_provider_gateway( id, + bgp_asn=bgp_asn, + bgp_cer_cidr=bgp_cer_cidr, + bgp_ibm_cidr=bgp_ibm_cidr, name=name, speed_mbps=speed_mbps, headers={} @@ -442,6 +448,9 @@ def test_update_provider_gateway_all_params(self): assert response.status_code == 200 # Validate body params req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['bgp_asn'] == 64999 + assert req_body['bgp_cer_cidr'] == '169.254.0.10/30' + assert req_body['bgp_ibm_cidr'] == '169.254.0.9/30' assert req_body['name'] == 'myNewGateway' assert req_body['speed_mbps'] == 1000 @@ -453,7 +462,7 @@ def test_update_provider_gateway_all_params(self): def test_update_provider_gateway_value_error(self): # Set up mock url = base_url + '/gateways/testString' - mock_response = '{"bgp_asn": 64999, "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "change_request": {"type": "create_gateway"}, "created_at": "2019-01-01T12:00:00", "crn": "crn:v1:bluemix:public:directlink:dal03:a/57a7d05f36894e3cb9b46a43556d903e::connect:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "customer_account_id": "57a7d05f36894e3cb9b46a43556d903e", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "myGateway", "operational_status": "create_pending", "port": {"id": "fffdcb1a-fee4-41c7-9e11-9cd99e65c777"}, "provider_api_managed": true, "speed_mbps": 1000, "type": "connect", "vlan": 10}' + mock_response = '{"bgp_asn": 64999, "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "change_request": {"type": "create_gateway"}, "created_at": "2019-01-01T12:00:00", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::connect:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "customer_account_id": "4111d05f36894e3cb9b46a43556d9000", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "myGateway", "operational_status": "configuring", "port": {"id": "fffdcb1a-fee4-41c7-9e11-9cd99e65c777"}, "provider_api_managed": true, "speed_mbps": 1000, "type": "connect", "vlan": 10}' responses.add(responses.PATCH, url, body=mock_response, @@ -462,6 +471,9 @@ def test_update_provider_gateway_value_error(self): # Set up parameter values id = 'testString' + bgp_asn = 64999 + bgp_cer_cidr = '169.254.0.10/30' + bgp_ibm_cidr = '169.254.0.9/30' name = 'myNewGateway' speed_mbps = 1000 @@ -661,11 +673,11 @@ def test_provider_gateway_serialization(self): provider_gateway_model_json['bgp_status'] = 'active' provider_gateway_model_json['change_request'] = provider_gateway_change_request_model provider_gateway_model_json['created_at'] = '2020-01-28T18:40:40.123456Z' - provider_gateway_model_json['crn'] = 'crn:v1:bluemix:public:directlink:dal03:a/57a7d05f36894e3cb9b46a43556d903e::connect:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4' - provider_gateway_model_json['customer_account_id'] = '57a7d05f36894e3cb9b46a43556d903e' + provider_gateway_model_json['crn'] = 'crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::connect:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4' + provider_gateway_model_json['customer_account_id'] = '4111d05f36894e3cb9b46a43556d9000' provider_gateway_model_json['id'] = 'ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4' provider_gateway_model_json['name'] = 'myGateway' - provider_gateway_model_json['operational_status'] = 'create_pending' + provider_gateway_model_json['operational_status'] = 'configuring' provider_gateway_model_json['port'] = provider_gateway_port_reference_model provider_gateway_model_json['provider_api_managed'] = True provider_gateway_model_json['speed_mbps'] = 1000 @@ -713,11 +725,11 @@ def test_provider_gateway_collection_serialization(self): provider_gateway_model['bgp_status'] = 'active' provider_gateway_model['change_request'] = provider_gateway_change_request_model provider_gateway_model['created_at'] = '2020-01-28T18:40:40.123456Z' - provider_gateway_model['crn'] = 'crn:v1:bluemix:public:directlink:dal03:a/57a7d05f36894e3cb9b46a43556d903e::connect:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4' - provider_gateway_model['customer_account_id'] = '57a7d05f36894e3cb9b46a43556d903e' + provider_gateway_model['crn'] = 'crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::connect:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4' + provider_gateway_model['customer_account_id'] = '4111d05f36894e3cb9b46a43556d9000' provider_gateway_model['id'] = 'ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4' provider_gateway_model['name'] = 'myGateway' - provider_gateway_model['operational_status'] = 'create_pending' + provider_gateway_model['operational_status'] = 'configuring' provider_gateway_model['port'] = provider_gateway_port_reference_model provider_gateway_model['provider_api_managed'] = True provider_gateway_model['speed_mbps'] = 1000 diff --git a/test/unit/test_direct_link_v1.py b/test/unit/test_direct_link_v1.py index af0cf44..d80b006 100644 --- a/test/unit/test_direct_link_v1.py +++ b/test/unit/test_direct_link_v1.py @@ -13,45 +13,107 @@ # See the License for the specific language governing permissions and # limitations under the License. +""" +Unit Tests for DirectLinkV1 +""" + from datetime import datetime, timezone from ibm_cloud_sdk_core.authenticators.no_auth_authenticator import NoAuthAuthenticator +from ibm_cloud_sdk_core.utils import datetime_to_string, string_to_datetime import inspect import io import json +import os import pytest +import re import requests import responses import tempfile +import urllib from ibm_cloud_networking_services.direct_link_v1 import * version = 'testString' -service = DirectLinkV1( +_service = DirectLinkV1( authenticator=NoAuthAuthenticator(), version=version - ) +) -base_url = 'https://directlink.cloud.ibm.com/v1' -service.set_service_url(base_url) +_base_url = 'https://directlink.cloud.ibm.com/v1' +_service.set_service_url(_base_url) ############################################################################## # Start of Service: Gateways ############################################################################## # region -#----------------------------------------------------------------------------- -# Test Class for list_gateways -#----------------------------------------------------------------------------- +class TestNewInstance(): + """ + Test Class for new_instance + """ + + def test_new_instance(self): + """ + new_instance() + """ + os.environ['TEST_SERVICE_AUTH_TYPE'] = 'noAuth' + + service = DirectLinkV1.new_instance( + version=version, + service_name='TEST_SERVICE', + ) + + assert service is not None + assert isinstance(service, DirectLinkV1) + + def test_new_instance_without_authenticator(self): + """ + new_instance_without_authenticator() + """ + with pytest.raises(ValueError, match='authenticator must be provided'): + service = DirectLinkV1.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 = DirectLinkV1.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 = DirectLinkV1.new_instance( + version=None, + ) class TestListGateways(): + """ + Test Class for list_gateways + """ + + def preprocess_url(self, request_url: str): + """ + Preprocess the request URL to ensure the mock response will be found. + """ + 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('/') + '/+') - #-------------------------------------------------------- - # list_gateways() - #-------------------------------------------------------- @responses.activate def test_list_gateways_all_params(self): + """ + list_gateways() + """ # Set up mock - url = base_url + '/gateways' - mock_response = '{"gateways": [{"authentication_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c"}, "bgp_asn": 64999, "bgp_base_cidr": "bgp_base_cidr", "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "carrier_name": "myCarrierName", "change_request": {"type": "create_gateway"}, "completion_notice_reject_reason": "The completion notice file was blank", "connection_mode": "transit", "created_at": "2019-01-01T12:00:00", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::dedicated:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "cross_connect_router": "xcr01.dal03", "customer_name": "newCustomerName", "global": true, "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "link_status": "up", "location_display_name": "Dallas 03", "location_name": "dal03", "macsec_config": {"active": true, "active_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "cipher_suite": "gcm_aes_xpn_256", "confidentiality_offset": 0, "cryptographic_algorithm": "aes_256_cmac", "fallback_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "key_server_priority": 255, "primary_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "sak_expiry_time": 3600, "security_policy": "must_secure", "status": "secured", "window_size": 64}, "metered": false, "name": "myGateway", "operational_status": "awaiting_completion_notice", "port": {"id": "54321b1a-fee4-41c7-9e11-9cd99e000aaa"}, "provider_api_managed": false, "resource_group": {"id": "56969d6043e9465c883cb9f7363e78e8"}, "speed_mbps": 1000, "type": "dedicated", "vlan": 10}]}' + url = self.preprocess_url(_base_url + '/gateways') + mock_response = '{"gateways": [{"authentication_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c"}, "bfd_config": {"bfd_status": "active", "bfd_status_updated_at": "2020-08-20T06:58:41.909Z", "interval": 2000, "multiplier": 10}, "bgp_asn": 64999, "bgp_base_cidr": "bgp_base_cidr", "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "bgp_status_updated_at": "2020-08-20T06:58:41.909Z", "carrier_name": "myCarrierName", "change_request": {"type": "create_gateway"}, "completion_notice_reject_reason": "The completion notice file was blank", "connection_mode": "transit", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::dedicated:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "cross_connect_router": "xcr01.dal03", "customer_name": "newCustomerName", "global": true, "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "link_status": "up", "link_status_updated_at": "2020-08-20T06:58:41.909Z", "location_display_name": "Dallas 03", "location_name": "dal03", "macsec_config": {"active": true, "active_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "cipher_suite": "gcm_aes_xpn_256", "confidentiality_offset": 0, "cryptographic_algorithm": "aes_256_cmac", "fallback_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "key_server_priority": 255, "primary_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "sak_expiry_time": 3600, "security_policy": "must_secure", "status": "secured", "window_size": 64}, "metered": false, "name": "myGateway", "operational_status": "awaiting_completion_notice", "patch_panel_completion_notice": "patch panel configuration details", "port": {"id": "54321b1a-fee4-41c7-9e11-9cd99e000aaa"}, "provider_api_managed": false, "resource_group": {"id": "56969d6043e9465c883cb9f7363e78e8"}, "speed_mbps": 1000, "type": "dedicated", "vlan": 10}]}' responses.add(responses.GET, url, body=mock_response, @@ -59,22 +121,30 @@ def test_list_gateways_all_params(self): status=200) # Invoke method - response = service.list_gateways() + response = _service.list_gateways() # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 + def test_list_gateways_all_params_with_retries(self): + # Enable retries and run test_list_gateways_all_params. + _service.enable_retries() + self.test_list_gateways_all_params() + + # Disable retries and run test_list_gateways_all_params. + _service.disable_retries() + self.test_list_gateways_all_params() - #-------------------------------------------------------- - # test_list_gateways_value_error() - #-------------------------------------------------------- @responses.activate def test_list_gateways_value_error(self): + """ + test_list_gateways_value_error() + """ # Set up mock - url = base_url + '/gateways' - mock_response = '{"gateways": [{"authentication_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c"}, "bgp_asn": 64999, "bgp_base_cidr": "bgp_base_cidr", "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "carrier_name": "myCarrierName", "change_request": {"type": "create_gateway"}, "completion_notice_reject_reason": "The completion notice file was blank", "connection_mode": "transit", "created_at": "2019-01-01T12:00:00", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::dedicated:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "cross_connect_router": "xcr01.dal03", "customer_name": "newCustomerName", "global": true, "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "link_status": "up", "location_display_name": "Dallas 03", "location_name": "dal03", "macsec_config": {"active": true, "active_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "cipher_suite": "gcm_aes_xpn_256", "confidentiality_offset": 0, "cryptographic_algorithm": "aes_256_cmac", "fallback_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "key_server_priority": 255, "primary_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "sak_expiry_time": 3600, "security_policy": "must_secure", "status": "secured", "window_size": 64}, "metered": false, "name": "myGateway", "operational_status": "awaiting_completion_notice", "port": {"id": "54321b1a-fee4-41c7-9e11-9cd99e000aaa"}, "provider_api_managed": false, "resource_group": {"id": "56969d6043e9465c883cb9f7363e78e8"}, "speed_mbps": 1000, "type": "dedicated", "vlan": 10}]}' + url = self.preprocess_url(_base_url + '/gateways') + mock_response = '{"gateways": [{"authentication_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c"}, "bfd_config": {"bfd_status": "active", "bfd_status_updated_at": "2020-08-20T06:58:41.909Z", "interval": 2000, "multiplier": 10}, "bgp_asn": 64999, "bgp_base_cidr": "bgp_base_cidr", "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "bgp_status_updated_at": "2020-08-20T06:58:41.909Z", "carrier_name": "myCarrierName", "change_request": {"type": "create_gateway"}, "completion_notice_reject_reason": "The completion notice file was blank", "connection_mode": "transit", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::dedicated:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "cross_connect_router": "xcr01.dal03", "customer_name": "newCustomerName", "global": true, "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "link_status": "up", "link_status_updated_at": "2020-08-20T06:58:41.909Z", "location_display_name": "Dallas 03", "location_name": "dal03", "macsec_config": {"active": true, "active_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "cipher_suite": "gcm_aes_xpn_256", "confidentiality_offset": 0, "cryptographic_algorithm": "aes_256_cmac", "fallback_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "key_server_priority": 255, "primary_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "sak_expiry_time": 3600, "security_policy": "must_secure", "status": "secured", "window_size": 64}, "metered": false, "name": "myGateway", "operational_status": "awaiting_completion_notice", "patch_panel_completion_notice": "patch panel configuration details", "port": {"id": "54321b1a-fee4-41c7-9e11-9cd99e000aaa"}, "provider_api_managed": false, "resource_group": {"id": "56969d6043e9465c883cb9f7363e78e8"}, "speed_mbps": 1000, "type": "dedicated", "vlan": 10}]}' responses.add(responses.GET, url, body=mock_response, @@ -87,29 +157,61 @@ def test_list_gateways_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_gateways(**req_copy) + _service.list_gateways(**req_copy) + def test_list_gateways_value_error_with_retries(self): + # Enable retries and run test_list_gateways_value_error. + _service.enable_retries() + self.test_list_gateways_value_error() + + # Disable retries and run test_list_gateways_value_error. + _service.disable_retries() + self.test_list_gateways_value_error() -#----------------------------------------------------------------------------- -# Test Class for create_gateway -#----------------------------------------------------------------------------- class TestCreateGateway(): + """ + Test Class for create_gateway + """ + + def preprocess_url(self, request_url: str): + """ + Preprocess the request URL to ensure the mock response will be found. + """ + 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('/') + '/+') - #-------------------------------------------------------- - # create_gateway() - #-------------------------------------------------------- @responses.activate def test_create_gateway_all_params(self): + """ + create_gateway() + """ # Set up mock - url = base_url + '/gateways' - mock_response = '{"authentication_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c"}, "bgp_asn": 64999, "bgp_base_cidr": "bgp_base_cidr", "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "carrier_name": "myCarrierName", "change_request": {"type": "create_gateway"}, "completion_notice_reject_reason": "The completion notice file was blank", "connection_mode": "transit", "created_at": "2019-01-01T12:00:00", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::dedicated:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "cross_connect_router": "xcr01.dal03", "customer_name": "newCustomerName", "global": true, "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "link_status": "up", "location_display_name": "Dallas 03", "location_name": "dal03", "macsec_config": {"active": true, "active_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "cipher_suite": "gcm_aes_xpn_256", "confidentiality_offset": 0, "cryptographic_algorithm": "aes_256_cmac", "fallback_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "key_server_priority": 255, "primary_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "sak_expiry_time": 3600, "security_policy": "must_secure", "status": "secured", "window_size": 64}, "metered": false, "name": "myGateway", "operational_status": "awaiting_completion_notice", "port": {"id": "54321b1a-fee4-41c7-9e11-9cd99e000aaa"}, "provider_api_managed": false, "resource_group": {"id": "56969d6043e9465c883cb9f7363e78e8"}, "speed_mbps": 1000, "type": "dedicated", "vlan": 10}' + url = self.preprocess_url(_base_url + '/gateways') + mock_response = '{"authentication_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c"}, "bfd_config": {"bfd_status": "active", "bfd_status_updated_at": "2020-08-20T06:58:41.909Z", "interval": 2000, "multiplier": 10}, "bgp_asn": 64999, "bgp_base_cidr": "bgp_base_cidr", "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "bgp_status_updated_at": "2020-08-20T06:58:41.909Z", "carrier_name": "myCarrierName", "change_request": {"type": "create_gateway"}, "completion_notice_reject_reason": "The completion notice file was blank", "connection_mode": "transit", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::dedicated:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "cross_connect_router": "xcr01.dal03", "customer_name": "newCustomerName", "global": true, "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "link_status": "up", "link_status_updated_at": "2020-08-20T06:58:41.909Z", "location_display_name": "Dallas 03", "location_name": "dal03", "macsec_config": {"active": true, "active_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "cipher_suite": "gcm_aes_xpn_256", "confidentiality_offset": 0, "cryptographic_algorithm": "aes_256_cmac", "fallback_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "key_server_priority": 255, "primary_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "sak_expiry_time": 3600, "security_policy": "must_secure", "status": "secured", "window_size": 64}, "metered": false, "name": "myGateway", "operational_status": "awaiting_completion_notice", "patch_panel_completion_notice": "patch panel configuration details", "port": {"id": "54321b1a-fee4-41c7-9e11-9cd99e000aaa"}, "provider_api_managed": false, "resource_group": {"id": "56969d6043e9465c883cb9f7363e78e8"}, "speed_mbps": 1000, "type": "dedicated", "vlan": 10}' responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) + # Construct a dict representation of a GatewayTemplateAuthenticationKey model + gateway_template_authentication_key_model = {} + gateway_template_authentication_key_model['crn'] = 'crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c' + + # Construct a dict representation of a GatewayBfdConfigTemplate model + gateway_bfd_config_template_model = {} + gateway_bfd_config_template_model['interval'] = 2000 + gateway_bfd_config_template_model['multiplier'] = 10 + + # Construct a dict representation of a ResourceGroupIdentity model + resource_group_identity_model = {} + resource_group_identity_model['id'] = '56969d6043e9465c883cb9f7363e78e8' + # Construct a dict representation of a GatewayMacsecConfigTemplateFallbackCak model gateway_macsec_config_template_fallback_cak_model = {} gateway_macsec_config_template_fallback_cak_model['crn'] = 'crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222' @@ -125,17 +227,10 @@ def test_create_gateway_all_params(self): gateway_macsec_config_template_model['primary_cak'] = gateway_macsec_config_template_primary_cak_model gateway_macsec_config_template_model['window_size'] = 148809600 - # Construct a dict representation of a GatewayTemplateGatewayTypeDedicatedTemplateAuthenticationKey model - gateway_template_gateway_type_dedicated_template_authentication_key_model = {} - gateway_template_gateway_type_dedicated_template_authentication_key_model['crn'] = 'crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c' - - # Construct a dict representation of a ResourceGroupIdentity model - resource_group_identity_model = {} - resource_group_identity_model['id'] = '56969d6043e9465c883cb9f7363e78e8' - # Construct a dict representation of a GatewayTemplateGatewayTypeDedicatedTemplate model gateway_template_model = {} - gateway_template_model['authentication_key'] = gateway_template_gateway_type_dedicated_template_authentication_key_model + gateway_template_model['authentication_key'] = gateway_template_authentication_key_model + gateway_template_model['bfd_config'] = gateway_bfd_config_template_model gateway_template_model['bgp_asn'] = 64999 gateway_template_model['bgp_base_cidr'] = 'testString' gateway_template_model['bgp_cer_cidr'] = '169.254.0.10/30' @@ -144,6 +239,7 @@ def test_create_gateway_all_params(self): gateway_template_model['global'] = True gateway_template_model['metered'] = False gateway_template_model['name'] = 'myGateway' + gateway_template_model['patch_panel_completion_notice'] = 'patch panel configuration details' gateway_template_model['resource_group'] = resource_group_identity_model gateway_template_model['speed_mbps'] = 1000 gateway_template_model['type'] = 'dedicated' @@ -157,7 +253,7 @@ def test_create_gateway_all_params(self): gateway_template = gateway_template_model # Invoke method - response = service.create_gateway( + response = _service.create_gateway( gateway_template, headers={} ) @@ -169,21 +265,42 @@ def test_create_gateway_all_params(self): req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) assert req_body == gateway_template + def test_create_gateway_all_params_with_retries(self): + # Enable retries and run test_create_gateway_all_params. + _service.enable_retries() + self.test_create_gateway_all_params() + + # Disable retries and run test_create_gateway_all_params. + _service.disable_retries() + self.test_create_gateway_all_params() - #-------------------------------------------------------- - # test_create_gateway_value_error() - #-------------------------------------------------------- @responses.activate def test_create_gateway_value_error(self): + """ + test_create_gateway_value_error() + """ # Set up mock - url = base_url + '/gateways' - mock_response = '{"authentication_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c"}, "bgp_asn": 64999, "bgp_base_cidr": "bgp_base_cidr", "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "carrier_name": "myCarrierName", "change_request": {"type": "create_gateway"}, "completion_notice_reject_reason": "The completion notice file was blank", "connection_mode": "transit", "created_at": "2019-01-01T12:00:00", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::dedicated:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "cross_connect_router": "xcr01.dal03", "customer_name": "newCustomerName", "global": true, "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "link_status": "up", "location_display_name": "Dallas 03", "location_name": "dal03", "macsec_config": {"active": true, "active_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "cipher_suite": "gcm_aes_xpn_256", "confidentiality_offset": 0, "cryptographic_algorithm": "aes_256_cmac", "fallback_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "key_server_priority": 255, "primary_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "sak_expiry_time": 3600, "security_policy": "must_secure", "status": "secured", "window_size": 64}, "metered": false, "name": "myGateway", "operational_status": "awaiting_completion_notice", "port": {"id": "54321b1a-fee4-41c7-9e11-9cd99e000aaa"}, "provider_api_managed": false, "resource_group": {"id": "56969d6043e9465c883cb9f7363e78e8"}, "speed_mbps": 1000, "type": "dedicated", "vlan": 10}' + url = self.preprocess_url(_base_url + '/gateways') + mock_response = '{"authentication_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c"}, "bfd_config": {"bfd_status": "active", "bfd_status_updated_at": "2020-08-20T06:58:41.909Z", "interval": 2000, "multiplier": 10}, "bgp_asn": 64999, "bgp_base_cidr": "bgp_base_cidr", "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "bgp_status_updated_at": "2020-08-20T06:58:41.909Z", "carrier_name": "myCarrierName", "change_request": {"type": "create_gateway"}, "completion_notice_reject_reason": "The completion notice file was blank", "connection_mode": "transit", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::dedicated:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "cross_connect_router": "xcr01.dal03", "customer_name": "newCustomerName", "global": true, "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "link_status": "up", "link_status_updated_at": "2020-08-20T06:58:41.909Z", "location_display_name": "Dallas 03", "location_name": "dal03", "macsec_config": {"active": true, "active_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "cipher_suite": "gcm_aes_xpn_256", "confidentiality_offset": 0, "cryptographic_algorithm": "aes_256_cmac", "fallback_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "key_server_priority": 255, "primary_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "sak_expiry_time": 3600, "security_policy": "must_secure", "status": "secured", "window_size": 64}, "metered": false, "name": "myGateway", "operational_status": "awaiting_completion_notice", "patch_panel_completion_notice": "patch panel configuration details", "port": {"id": "54321b1a-fee4-41c7-9e11-9cd99e000aaa"}, "provider_api_managed": false, "resource_group": {"id": "56969d6043e9465c883cb9f7363e78e8"}, "speed_mbps": 1000, "type": "dedicated", "vlan": 10}' responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) + # Construct a dict representation of a GatewayTemplateAuthenticationKey model + gateway_template_authentication_key_model = {} + gateway_template_authentication_key_model['crn'] = 'crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c' + + # Construct a dict representation of a GatewayBfdConfigTemplate model + gateway_bfd_config_template_model = {} + gateway_bfd_config_template_model['interval'] = 2000 + gateway_bfd_config_template_model['multiplier'] = 10 + + # Construct a dict representation of a ResourceGroupIdentity model + resource_group_identity_model = {} + resource_group_identity_model['id'] = '56969d6043e9465c883cb9f7363e78e8' + # Construct a dict representation of a GatewayMacsecConfigTemplateFallbackCak model gateway_macsec_config_template_fallback_cak_model = {} gateway_macsec_config_template_fallback_cak_model['crn'] = 'crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222' @@ -199,17 +316,10 @@ def test_create_gateway_value_error(self): gateway_macsec_config_template_model['primary_cak'] = gateway_macsec_config_template_primary_cak_model gateway_macsec_config_template_model['window_size'] = 148809600 - # Construct a dict representation of a GatewayTemplateGatewayTypeDedicatedTemplateAuthenticationKey model - gateway_template_gateway_type_dedicated_template_authentication_key_model = {} - gateway_template_gateway_type_dedicated_template_authentication_key_model['crn'] = 'crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c' - - # Construct a dict representation of a ResourceGroupIdentity model - resource_group_identity_model = {} - resource_group_identity_model['id'] = '56969d6043e9465c883cb9f7363e78e8' - # Construct a dict representation of a GatewayTemplateGatewayTypeDedicatedTemplate model gateway_template_model = {} - gateway_template_model['authentication_key'] = gateway_template_gateway_type_dedicated_template_authentication_key_model + gateway_template_model['authentication_key'] = gateway_template_authentication_key_model + gateway_template_model['bfd_config'] = gateway_bfd_config_template_model gateway_template_model['bgp_asn'] = 64999 gateway_template_model['bgp_base_cidr'] = 'testString' gateway_template_model['bgp_cer_cidr'] = '169.254.0.10/30' @@ -218,6 +328,7 @@ def test_create_gateway_value_error(self): gateway_template_model['global'] = True gateway_template_model['metered'] = False gateway_template_model['name'] = 'myGateway' + gateway_template_model['patch_panel_completion_notice'] = 'patch panel configuration details' gateway_template_model['resource_group'] = resource_group_identity_model gateway_template_model['speed_mbps'] = 1000 gateway_template_model['type'] = 'dedicated' @@ -237,22 +348,41 @@ def test_create_gateway_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.create_gateway(**req_copy) + _service.create_gateway(**req_copy) + + def test_create_gateway_value_error_with_retries(self): + # Enable retries and run test_create_gateway_value_error. + _service.enable_retries() + self.test_create_gateway_value_error() + # Disable retries and run test_create_gateway_value_error. + _service.disable_retries() + self.test_create_gateway_value_error() -#----------------------------------------------------------------------------- -# Test Class for delete_gateway -#----------------------------------------------------------------------------- class TestDeleteGateway(): + """ + Test Class for delete_gateway + """ + + def preprocess_url(self, request_url: str): + """ + Preprocess the request URL to ensure the mock response will be found. + """ + 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('/') + '/+') - #-------------------------------------------------------- - # delete_gateway() - #-------------------------------------------------------- @responses.activate def test_delete_gateway_all_params(self): + """ + delete_gateway() + """ # Set up mock - url = base_url + '/gateways/testString' + url = self.preprocess_url(_base_url + '/gateways/testString') responses.add(responses.DELETE, url, status=204) @@ -261,7 +391,7 @@ def test_delete_gateway_all_params(self): id = 'testString' # Invoke method - response = service.delete_gateway( + response = _service.delete_gateway( id, headers={} ) @@ -270,14 +400,22 @@ def test_delete_gateway_all_params(self): assert len(responses.calls) == 1 assert response.status_code == 204 + def test_delete_gateway_all_params_with_retries(self): + # Enable retries and run test_delete_gateway_all_params. + _service.enable_retries() + self.test_delete_gateway_all_params() + + # Disable retries and run test_delete_gateway_all_params. + _service.disable_retries() + self.test_delete_gateway_all_params() - #-------------------------------------------------------- - # test_delete_gateway_value_error() - #-------------------------------------------------------- @responses.activate def test_delete_gateway_value_error(self): + """ + test_delete_gateway_value_error() + """ # Set up mock - url = base_url + '/gateways/testString' + url = self.preprocess_url(_base_url + '/gateways/testString') responses.add(responses.DELETE, url, status=204) @@ -292,23 +430,42 @@ def test_delete_gateway_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_gateway(**req_copy) + _service.delete_gateway(**req_copy) + def test_delete_gateway_value_error_with_retries(self): + # Enable retries and run test_delete_gateway_value_error. + _service.enable_retries() + self.test_delete_gateway_value_error() + + # Disable retries and run test_delete_gateway_value_error. + _service.disable_retries() + self.test_delete_gateway_value_error() -#----------------------------------------------------------------------------- -# Test Class for get_gateway -#----------------------------------------------------------------------------- class TestGetGateway(): + """ + Test Class for get_gateway + """ + + def preprocess_url(self, request_url: str): + """ + Preprocess the request URL to ensure the mock response will be found. + """ + 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('/') + '/+') - #-------------------------------------------------------- - # get_gateway() - #-------------------------------------------------------- @responses.activate def test_get_gateway_all_params(self): + """ + get_gateway() + """ # Set up mock - url = base_url + '/gateways/testString' - mock_response = '{"authentication_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c"}, "bgp_asn": 64999, "bgp_base_cidr": "bgp_base_cidr", "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "carrier_name": "myCarrierName", "change_request": {"type": "create_gateway"}, "completion_notice_reject_reason": "The completion notice file was blank", "connection_mode": "transit", "created_at": "2019-01-01T12:00:00", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::dedicated:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "cross_connect_router": "xcr01.dal03", "customer_name": "newCustomerName", "global": true, "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "link_status": "up", "location_display_name": "Dallas 03", "location_name": "dal03", "macsec_config": {"active": true, "active_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "cipher_suite": "gcm_aes_xpn_256", "confidentiality_offset": 0, "cryptographic_algorithm": "aes_256_cmac", "fallback_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "key_server_priority": 255, "primary_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "sak_expiry_time": 3600, "security_policy": "must_secure", "status": "secured", "window_size": 64}, "metered": false, "name": "myGateway", "operational_status": "awaiting_completion_notice", "port": {"id": "54321b1a-fee4-41c7-9e11-9cd99e000aaa"}, "provider_api_managed": false, "resource_group": {"id": "56969d6043e9465c883cb9f7363e78e8"}, "speed_mbps": 1000, "type": "dedicated", "vlan": 10}' + url = self.preprocess_url(_base_url + '/gateways/testString') + mock_response = '{"authentication_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c"}, "bfd_config": {"bfd_status": "active", "bfd_status_updated_at": "2020-08-20T06:58:41.909Z", "interval": 2000, "multiplier": 10}, "bgp_asn": 64999, "bgp_base_cidr": "bgp_base_cidr", "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "bgp_status_updated_at": "2020-08-20T06:58:41.909Z", "carrier_name": "myCarrierName", "change_request": {"type": "create_gateway"}, "completion_notice_reject_reason": "The completion notice file was blank", "connection_mode": "transit", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::dedicated:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "cross_connect_router": "xcr01.dal03", "customer_name": "newCustomerName", "global": true, "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "link_status": "up", "link_status_updated_at": "2020-08-20T06:58:41.909Z", "location_display_name": "Dallas 03", "location_name": "dal03", "macsec_config": {"active": true, "active_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "cipher_suite": "gcm_aes_xpn_256", "confidentiality_offset": 0, "cryptographic_algorithm": "aes_256_cmac", "fallback_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "key_server_priority": 255, "primary_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "sak_expiry_time": 3600, "security_policy": "must_secure", "status": "secured", "window_size": 64}, "metered": false, "name": "myGateway", "operational_status": "awaiting_completion_notice", "patch_panel_completion_notice": "patch panel configuration details", "port": {"id": "54321b1a-fee4-41c7-9e11-9cd99e000aaa"}, "provider_api_managed": false, "resource_group": {"id": "56969d6043e9465c883cb9f7363e78e8"}, "speed_mbps": 1000, "type": "dedicated", "vlan": 10}' responses.add(responses.GET, url, body=mock_response, @@ -319,7 +476,7 @@ def test_get_gateway_all_params(self): id = 'testString' # Invoke method - response = service.get_gateway( + response = _service.get_gateway( id, headers={} ) @@ -328,15 +485,23 @@ def test_get_gateway_all_params(self): assert len(responses.calls) == 1 assert response.status_code == 200 + def test_get_gateway_all_params_with_retries(self): + # Enable retries and run test_get_gateway_all_params. + _service.enable_retries() + self.test_get_gateway_all_params() + + # Disable retries and run test_get_gateway_all_params. + _service.disable_retries() + self.test_get_gateway_all_params() - #-------------------------------------------------------- - # test_get_gateway_value_error() - #-------------------------------------------------------- @responses.activate def test_get_gateway_value_error(self): + """ + test_get_gateway_value_error() + """ # Set up mock - url = base_url + '/gateways/testString' - mock_response = '{"authentication_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c"}, "bgp_asn": 64999, "bgp_base_cidr": "bgp_base_cidr", "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "carrier_name": "myCarrierName", "change_request": {"type": "create_gateway"}, "completion_notice_reject_reason": "The completion notice file was blank", "connection_mode": "transit", "created_at": "2019-01-01T12:00:00", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::dedicated:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "cross_connect_router": "xcr01.dal03", "customer_name": "newCustomerName", "global": true, "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "link_status": "up", "location_display_name": "Dallas 03", "location_name": "dal03", "macsec_config": {"active": true, "active_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "cipher_suite": "gcm_aes_xpn_256", "confidentiality_offset": 0, "cryptographic_algorithm": "aes_256_cmac", "fallback_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "key_server_priority": 255, "primary_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "sak_expiry_time": 3600, "security_policy": "must_secure", "status": "secured", "window_size": 64}, "metered": false, "name": "myGateway", "operational_status": "awaiting_completion_notice", "port": {"id": "54321b1a-fee4-41c7-9e11-9cd99e000aaa"}, "provider_api_managed": false, "resource_group": {"id": "56969d6043e9465c883cb9f7363e78e8"}, "speed_mbps": 1000, "type": "dedicated", "vlan": 10}' + url = self.preprocess_url(_base_url + '/gateways/testString') + mock_response = '{"authentication_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c"}, "bfd_config": {"bfd_status": "active", "bfd_status_updated_at": "2020-08-20T06:58:41.909Z", "interval": 2000, "multiplier": 10}, "bgp_asn": 64999, "bgp_base_cidr": "bgp_base_cidr", "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "bgp_status_updated_at": "2020-08-20T06:58:41.909Z", "carrier_name": "myCarrierName", "change_request": {"type": "create_gateway"}, "completion_notice_reject_reason": "The completion notice file was blank", "connection_mode": "transit", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::dedicated:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "cross_connect_router": "xcr01.dal03", "customer_name": "newCustomerName", "global": true, "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "link_status": "up", "link_status_updated_at": "2020-08-20T06:58:41.909Z", "location_display_name": "Dallas 03", "location_name": "dal03", "macsec_config": {"active": true, "active_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "cipher_suite": "gcm_aes_xpn_256", "confidentiality_offset": 0, "cryptographic_algorithm": "aes_256_cmac", "fallback_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "key_server_priority": 255, "primary_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "sak_expiry_time": 3600, "security_policy": "must_secure", "status": "secured", "window_size": 64}, "metered": false, "name": "myGateway", "operational_status": "awaiting_completion_notice", "patch_panel_completion_notice": "patch panel configuration details", "port": {"id": "54321b1a-fee4-41c7-9e11-9cd99e000aaa"}, "provider_api_managed": false, "resource_group": {"id": "56969d6043e9465c883cb9f7363e78e8"}, "speed_mbps": 1000, "type": "dedicated", "vlan": 10}' responses.add(responses.GET, url, body=mock_response, @@ -353,23 +518,42 @@ def test_get_gateway_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_gateway(**req_copy) + _service.get_gateway(**req_copy) + def test_get_gateway_value_error_with_retries(self): + # Enable retries and run test_get_gateway_value_error. + _service.enable_retries() + self.test_get_gateway_value_error() + + # Disable retries and run test_get_gateway_value_error. + _service.disable_retries() + self.test_get_gateway_value_error() -#----------------------------------------------------------------------------- -# Test Class for update_gateway -#----------------------------------------------------------------------------- class TestUpdateGateway(): + """ + Test Class for update_gateway + """ + + def preprocess_url(self, request_url: str): + """ + Preprocess the request URL to ensure the mock response will be found. + """ + 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('/') + '/+') - #-------------------------------------------------------- - # update_gateway() - #-------------------------------------------------------- @responses.activate def test_update_gateway_all_params(self): + """ + update_gateway() + """ # Set up mock - url = base_url + '/gateways/testString' - mock_response = '{"authentication_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c"}, "bgp_asn": 64999, "bgp_base_cidr": "bgp_base_cidr", "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "carrier_name": "myCarrierName", "change_request": {"type": "create_gateway"}, "completion_notice_reject_reason": "The completion notice file was blank", "connection_mode": "transit", "created_at": "2019-01-01T12:00:00", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::dedicated:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "cross_connect_router": "xcr01.dal03", "customer_name": "newCustomerName", "global": true, "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "link_status": "up", "location_display_name": "Dallas 03", "location_name": "dal03", "macsec_config": {"active": true, "active_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "cipher_suite": "gcm_aes_xpn_256", "confidentiality_offset": 0, "cryptographic_algorithm": "aes_256_cmac", "fallback_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "key_server_priority": 255, "primary_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "sak_expiry_time": 3600, "security_policy": "must_secure", "status": "secured", "window_size": 64}, "metered": false, "name": "myGateway", "operational_status": "awaiting_completion_notice", "port": {"id": "54321b1a-fee4-41c7-9e11-9cd99e000aaa"}, "provider_api_managed": false, "resource_group": {"id": "56969d6043e9465c883cb9f7363e78e8"}, "speed_mbps": 1000, "type": "dedicated", "vlan": 10}' + url = self.preprocess_url(_base_url + '/gateways/testString') + mock_response = '{"authentication_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c"}, "bfd_config": {"bfd_status": "active", "bfd_status_updated_at": "2020-08-20T06:58:41.909Z", "interval": 2000, "multiplier": 10}, "bgp_asn": 64999, "bgp_base_cidr": "bgp_base_cidr", "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "bgp_status_updated_at": "2020-08-20T06:58:41.909Z", "carrier_name": "myCarrierName", "change_request": {"type": "create_gateway"}, "completion_notice_reject_reason": "The completion notice file was blank", "connection_mode": "transit", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::dedicated:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "cross_connect_router": "xcr01.dal03", "customer_name": "newCustomerName", "global": true, "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "link_status": "up", "link_status_updated_at": "2020-08-20T06:58:41.909Z", "location_display_name": "Dallas 03", "location_name": "dal03", "macsec_config": {"active": true, "active_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "cipher_suite": "gcm_aes_xpn_256", "confidentiality_offset": 0, "cryptographic_algorithm": "aes_256_cmac", "fallback_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "key_server_priority": 255, "primary_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "sak_expiry_time": 3600, "security_policy": "must_secure", "status": "secured", "window_size": 64}, "metered": false, "name": "myGateway", "operational_status": "awaiting_completion_notice", "patch_panel_completion_notice": "patch panel configuration details", "port": {"id": "54321b1a-fee4-41c7-9e11-9cd99e000aaa"}, "provider_api_managed": false, "resource_group": {"id": "56969d6043e9465c883cb9f7363e78e8"}, "speed_mbps": 1000, "type": "dedicated", "vlan": 10}' responses.add(responses.PATCH, url, body=mock_response, @@ -380,6 +564,11 @@ def test_update_gateway_all_params(self): gateway_patch_template_authentication_key_model = {} gateway_patch_template_authentication_key_model['crn'] = 'crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c' + # Construct a dict representation of a GatewayBfdPatchTemplate model + gateway_bfd_patch_template_model = {} + gateway_bfd_patch_template_model['interval'] = 2000 + gateway_bfd_patch_template_model['multiplier'] = 10 + # Construct a dict representation of a GatewayMacsecConfigPatchTemplateFallbackCak model gateway_macsec_config_patch_template_fallback_cak_model = {} gateway_macsec_config_patch_template_fallback_cak_model['crn'] = 'crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222' @@ -398,6 +587,10 @@ def test_update_gateway_all_params(self): # Set up parameter values id = 'testString' authentication_key = gateway_patch_template_authentication_key_model + bfd_config = gateway_bfd_patch_template_model + bgp_asn = 64999 + bgp_cer_cidr = '169.254.0.10/30' + bgp_ibm_cidr = '169.254.0.9/30' connection_mode = 'transit' global_ = True loa_reject_reason = 'The port mentioned was incorrect' @@ -405,12 +598,17 @@ def test_update_gateway_all_params(self): metered = False name = 'testGateway' operational_status = 'loa_accepted' + patch_panel_completion_notice = 'patch panel configuration details' speed_mbps = 1000 # Invoke method - response = service.update_gateway( + response = _service.update_gateway( id, authentication_key=authentication_key, + bfd_config=bfd_config, + bgp_asn=bgp_asn, + bgp_cer_cidr=bgp_cer_cidr, + bgp_ibm_cidr=bgp_ibm_cidr, connection_mode=connection_mode, global_=global_, loa_reject_reason=loa_reject_reason, @@ -418,6 +616,7 @@ def test_update_gateway_all_params(self): metered=metered, name=name, operational_status=operational_status, + patch_panel_completion_notice=patch_panel_completion_notice, speed_mbps=speed_mbps, headers={} ) @@ -428,6 +627,10 @@ def test_update_gateway_all_params(self): # Validate body params req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) assert req_body['authentication_key'] == gateway_patch_template_authentication_key_model + assert req_body['bfd_config'] == gateway_bfd_patch_template_model + assert req_body['bgp_asn'] == 64999 + assert req_body['bgp_cer_cidr'] == '169.254.0.10/30' + assert req_body['bgp_ibm_cidr'] == '169.254.0.9/30' assert req_body['connection_mode'] == 'transit' assert req_body['global'] == True assert req_body['loa_reject_reason'] == 'The port mentioned was incorrect' @@ -435,17 +638,26 @@ def test_update_gateway_all_params(self): assert req_body['metered'] == False assert req_body['name'] == 'testGateway' assert req_body['operational_status'] == 'loa_accepted' + assert req_body['patch_panel_completion_notice'] == 'patch panel configuration details' assert req_body['speed_mbps'] == 1000 + def test_update_gateway_all_params_with_retries(self): + # Enable retries and run test_update_gateway_all_params. + _service.enable_retries() + self.test_update_gateway_all_params() + + # Disable retries and run test_update_gateway_all_params. + _service.disable_retries() + self.test_update_gateway_all_params() - #-------------------------------------------------------- - # test_update_gateway_value_error() - #-------------------------------------------------------- @responses.activate def test_update_gateway_value_error(self): + """ + test_update_gateway_value_error() + """ # Set up mock - url = base_url + '/gateways/testString' - mock_response = '{"authentication_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c"}, "bgp_asn": 64999, "bgp_base_cidr": "bgp_base_cidr", "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "carrier_name": "myCarrierName", "change_request": {"type": "create_gateway"}, "completion_notice_reject_reason": "The completion notice file was blank", "connection_mode": "transit", "created_at": "2019-01-01T12:00:00", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::dedicated:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "cross_connect_router": "xcr01.dal03", "customer_name": "newCustomerName", "global": true, "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "link_status": "up", "location_display_name": "Dallas 03", "location_name": "dal03", "macsec_config": {"active": true, "active_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "cipher_suite": "gcm_aes_xpn_256", "confidentiality_offset": 0, "cryptographic_algorithm": "aes_256_cmac", "fallback_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "key_server_priority": 255, "primary_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "sak_expiry_time": 3600, "security_policy": "must_secure", "status": "secured", "window_size": 64}, "metered": false, "name": "myGateway", "operational_status": "awaiting_completion_notice", "port": {"id": "54321b1a-fee4-41c7-9e11-9cd99e000aaa"}, "provider_api_managed": false, "resource_group": {"id": "56969d6043e9465c883cb9f7363e78e8"}, "speed_mbps": 1000, "type": "dedicated", "vlan": 10}' + url = self.preprocess_url(_base_url + '/gateways/testString') + mock_response = '{"authentication_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c"}, "bfd_config": {"bfd_status": "active", "bfd_status_updated_at": "2020-08-20T06:58:41.909Z", "interval": 2000, "multiplier": 10}, "bgp_asn": 64999, "bgp_base_cidr": "bgp_base_cidr", "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "bgp_status_updated_at": "2020-08-20T06:58:41.909Z", "carrier_name": "myCarrierName", "change_request": {"type": "create_gateway"}, "completion_notice_reject_reason": "The completion notice file was blank", "connection_mode": "transit", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::dedicated:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "cross_connect_router": "xcr01.dal03", "customer_name": "newCustomerName", "global": true, "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "link_status": "up", "link_status_updated_at": "2020-08-20T06:58:41.909Z", "location_display_name": "Dallas 03", "location_name": "dal03", "macsec_config": {"active": true, "active_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "cipher_suite": "gcm_aes_xpn_256", "confidentiality_offset": 0, "cryptographic_algorithm": "aes_256_cmac", "fallback_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "key_server_priority": 255, "primary_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "sak_expiry_time": 3600, "security_policy": "must_secure", "status": "secured", "window_size": 64}, "metered": false, "name": "myGateway", "operational_status": "awaiting_completion_notice", "patch_panel_completion_notice": "patch panel configuration details", "port": {"id": "54321b1a-fee4-41c7-9e11-9cd99e000aaa"}, "provider_api_managed": false, "resource_group": {"id": "56969d6043e9465c883cb9f7363e78e8"}, "speed_mbps": 1000, "type": "dedicated", "vlan": 10}' responses.add(responses.PATCH, url, body=mock_response, @@ -456,6 +668,11 @@ def test_update_gateway_value_error(self): gateway_patch_template_authentication_key_model = {} gateway_patch_template_authentication_key_model['crn'] = 'crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c' + # Construct a dict representation of a GatewayBfdPatchTemplate model + gateway_bfd_patch_template_model = {} + gateway_bfd_patch_template_model['interval'] = 2000 + gateway_bfd_patch_template_model['multiplier'] = 10 + # Construct a dict representation of a GatewayMacsecConfigPatchTemplateFallbackCak model gateway_macsec_config_patch_template_fallback_cak_model = {} gateway_macsec_config_patch_template_fallback_cak_model['crn'] = 'crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222' @@ -474,6 +691,10 @@ def test_update_gateway_value_error(self): # Set up parameter values id = 'testString' authentication_key = gateway_patch_template_authentication_key_model + bfd_config = gateway_bfd_patch_template_model + bgp_asn = 64999 + bgp_cer_cidr = '169.254.0.10/30' + bgp_ibm_cidr = '169.254.0.9/30' connection_mode = 'transit' global_ = True loa_reject_reason = 'The port mentioned was incorrect' @@ -481,6 +702,7 @@ def test_update_gateway_value_error(self): metered = False name = 'testGateway' operational_status = 'loa_accepted' + patch_panel_completion_notice = 'patch panel configuration details' speed_mbps = 1000 # Pass in all but one required param and check for a ValueError @@ -490,23 +712,42 @@ def test_update_gateway_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.update_gateway(**req_copy) + _service.update_gateway(**req_copy) + + def test_update_gateway_value_error_with_retries(self): + # Enable retries and run test_update_gateway_value_error. + _service.enable_retries() + self.test_update_gateway_value_error() + # Disable retries and run test_update_gateway_value_error. + _service.disable_retries() + self.test_update_gateway_value_error() -#----------------------------------------------------------------------------- -# Test Class for create_gateway_action -#----------------------------------------------------------------------------- class TestCreateGatewayAction(): + """ + Test Class for create_gateway_action + """ + + def preprocess_url(self, request_url: str): + """ + Preprocess the request URL to ensure the mock response will be found. + """ + 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('/') + '/+') - #-------------------------------------------------------- - # create_gateway_action() - #-------------------------------------------------------- @responses.activate def test_create_gateway_action_all_params(self): + """ + create_gateway_action() + """ # Set up mock - url = base_url + '/gateways/testString/actions' - mock_response = '{"authentication_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c"}, "bgp_asn": 64999, "bgp_base_cidr": "bgp_base_cidr", "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "carrier_name": "myCarrierName", "change_request": {"type": "create_gateway"}, "completion_notice_reject_reason": "The completion notice file was blank", "connection_mode": "transit", "created_at": "2019-01-01T12:00:00", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::dedicated:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "cross_connect_router": "xcr01.dal03", "customer_name": "newCustomerName", "global": true, "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "link_status": "up", "location_display_name": "Dallas 03", "location_name": "dal03", "macsec_config": {"active": true, "active_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "cipher_suite": "gcm_aes_xpn_256", "confidentiality_offset": 0, "cryptographic_algorithm": "aes_256_cmac", "fallback_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "key_server_priority": 255, "primary_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "sak_expiry_time": 3600, "security_policy": "must_secure", "status": "secured", "window_size": 64}, "metered": false, "name": "myGateway", "operational_status": "awaiting_completion_notice", "port": {"id": "54321b1a-fee4-41c7-9e11-9cd99e000aaa"}, "provider_api_managed": false, "resource_group": {"id": "56969d6043e9465c883cb9f7363e78e8"}, "speed_mbps": 1000, "type": "dedicated", "vlan": 10}' + url = self.preprocess_url(_base_url + '/gateways/testString/actions') + mock_response = '{"authentication_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c"}, "bfd_config": {"bfd_status": "active", "bfd_status_updated_at": "2020-08-20T06:58:41.909Z", "interval": 2000, "multiplier": 10}, "bgp_asn": 64999, "bgp_base_cidr": "bgp_base_cidr", "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "bgp_status_updated_at": "2020-08-20T06:58:41.909Z", "carrier_name": "myCarrierName", "change_request": {"type": "create_gateway"}, "completion_notice_reject_reason": "The completion notice file was blank", "connection_mode": "transit", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::dedicated:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "cross_connect_router": "xcr01.dal03", "customer_name": "newCustomerName", "global": true, "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "link_status": "up", "link_status_updated_at": "2020-08-20T06:58:41.909Z", "location_display_name": "Dallas 03", "location_name": "dal03", "macsec_config": {"active": true, "active_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "cipher_suite": "gcm_aes_xpn_256", "confidentiality_offset": 0, "cryptographic_algorithm": "aes_256_cmac", "fallback_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "key_server_priority": 255, "primary_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "sak_expiry_time": 3600, "security_policy": "must_secure", "status": "secured", "window_size": 64}, "metered": false, "name": "myGateway", "operational_status": "awaiting_completion_notice", "patch_panel_completion_notice": "patch panel configuration details", "port": {"id": "54321b1a-fee4-41c7-9e11-9cd99e000aaa"}, "provider_api_managed": false, "resource_group": {"id": "56969d6043e9465c883cb9f7363e78e8"}, "speed_mbps": 1000, "type": "dedicated", "vlan": 10}' responses.add(responses.POST, url, body=mock_response, @@ -517,25 +758,36 @@ def test_create_gateway_action_all_params(self): gateway_action_template_authentication_key_model = {} gateway_action_template_authentication_key_model['crn'] = 'crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c' + # Construct a dict representation of a GatewayBfdConfigActionTemplate model + gateway_bfd_config_action_template_model = {} + gateway_bfd_config_action_template_model['interval'] = 2000 + gateway_bfd_config_action_template_model['multiplier'] = 10 + # Construct a dict representation of a ResourceGroupIdentity model resource_group_identity_model = {} resource_group_identity_model['id'] = '56969d6043e9465c883cb9f7363e78e8' + # Construct a dict representation of a GatewayActionTemplateUpdatesItemGatewayClientSpeedUpdate model + gateway_action_template_updates_item_model = {} + gateway_action_template_updates_item_model['speed_mbps'] = 500 + # Set up parameter values id = 'testString' action = 'create_gateway_approve' authentication_key = gateway_action_template_authentication_key_model + bfd_config = gateway_bfd_config_action_template_model connection_mode = 'transit' global_ = True metered = False resource_group = resource_group_identity_model - updates = [{ 'foo': 'bar' }] + updates = [gateway_action_template_updates_item_model] # Invoke method - response = service.create_gateway_action( + response = _service.create_gateway_action( id, action, authentication_key=authentication_key, + bfd_config=bfd_config, connection_mode=connection_mode, global_=global_, metered=metered, @@ -551,21 +803,30 @@ def test_create_gateway_action_all_params(self): req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) assert req_body['action'] == 'create_gateway_approve' assert req_body['authentication_key'] == gateway_action_template_authentication_key_model + assert req_body['bfd_config'] == gateway_bfd_config_action_template_model assert req_body['connection_mode'] == 'transit' assert req_body['global'] == True assert req_body['metered'] == False assert req_body['resource_group'] == resource_group_identity_model - assert req_body['updates'] == [{ 'foo': 'bar' }] + assert req_body['updates'] == [gateway_action_template_updates_item_model] + + def test_create_gateway_action_all_params_with_retries(self): + # Enable retries and run test_create_gateway_action_all_params. + _service.enable_retries() + self.test_create_gateway_action_all_params() + # Disable retries and run test_create_gateway_action_all_params. + _service.disable_retries() + self.test_create_gateway_action_all_params() - #-------------------------------------------------------- - # test_create_gateway_action_value_error() - #-------------------------------------------------------- @responses.activate def test_create_gateway_action_value_error(self): + """ + test_create_gateway_action_value_error() + """ # Set up mock - url = base_url + '/gateways/testString/actions' - mock_response = '{"authentication_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c"}, "bgp_asn": 64999, "bgp_base_cidr": "bgp_base_cidr", "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "carrier_name": "myCarrierName", "change_request": {"type": "create_gateway"}, "completion_notice_reject_reason": "The completion notice file was blank", "connection_mode": "transit", "created_at": "2019-01-01T12:00:00", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::dedicated:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "cross_connect_router": "xcr01.dal03", "customer_name": "newCustomerName", "global": true, "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "link_status": "up", "location_display_name": "Dallas 03", "location_name": "dal03", "macsec_config": {"active": true, "active_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "cipher_suite": "gcm_aes_xpn_256", "confidentiality_offset": 0, "cryptographic_algorithm": "aes_256_cmac", "fallback_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "key_server_priority": 255, "primary_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "sak_expiry_time": 3600, "security_policy": "must_secure", "status": "secured", "window_size": 64}, "metered": false, "name": "myGateway", "operational_status": "awaiting_completion_notice", "port": {"id": "54321b1a-fee4-41c7-9e11-9cd99e000aaa"}, "provider_api_managed": false, "resource_group": {"id": "56969d6043e9465c883cb9f7363e78e8"}, "speed_mbps": 1000, "type": "dedicated", "vlan": 10}' + url = self.preprocess_url(_base_url + '/gateways/testString/actions') + mock_response = '{"authentication_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c"}, "bfd_config": {"bfd_status": "active", "bfd_status_updated_at": "2020-08-20T06:58:41.909Z", "interval": 2000, "multiplier": 10}, "bgp_asn": 64999, "bgp_base_cidr": "bgp_base_cidr", "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "bgp_status_updated_at": "2020-08-20T06:58:41.909Z", "carrier_name": "myCarrierName", "change_request": {"type": "create_gateway"}, "completion_notice_reject_reason": "The completion notice file was blank", "connection_mode": "transit", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::dedicated:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "cross_connect_router": "xcr01.dal03", "customer_name": "newCustomerName", "global": true, "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "link_status": "up", "link_status_updated_at": "2020-08-20T06:58:41.909Z", "location_display_name": "Dallas 03", "location_name": "dal03", "macsec_config": {"active": true, "active_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "cipher_suite": "gcm_aes_xpn_256", "confidentiality_offset": 0, "cryptographic_algorithm": "aes_256_cmac", "fallback_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "key_server_priority": 255, "primary_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "status"}, "sak_expiry_time": 3600, "security_policy": "must_secure", "status": "secured", "window_size": 64}, "metered": false, "name": "myGateway", "operational_status": "awaiting_completion_notice", "patch_panel_completion_notice": "patch panel configuration details", "port": {"id": "54321b1a-fee4-41c7-9e11-9cd99e000aaa"}, "provider_api_managed": false, "resource_group": {"id": "56969d6043e9465c883cb9f7363e78e8"}, "speed_mbps": 1000, "type": "dedicated", "vlan": 10}' responses.add(responses.POST, url, body=mock_response, @@ -576,19 +837,29 @@ def test_create_gateway_action_value_error(self): gateway_action_template_authentication_key_model = {} gateway_action_template_authentication_key_model['crn'] = 'crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c' + # Construct a dict representation of a GatewayBfdConfigActionTemplate model + gateway_bfd_config_action_template_model = {} + gateway_bfd_config_action_template_model['interval'] = 2000 + gateway_bfd_config_action_template_model['multiplier'] = 10 + # Construct a dict representation of a ResourceGroupIdentity model resource_group_identity_model = {} resource_group_identity_model['id'] = '56969d6043e9465c883cb9f7363e78e8' + # Construct a dict representation of a GatewayActionTemplateUpdatesItemGatewayClientSpeedUpdate model + gateway_action_template_updates_item_model = {} + gateway_action_template_updates_item_model['speed_mbps'] = 500 + # Set up parameter values id = 'testString' action = 'create_gateway_approve' authentication_key = gateway_action_template_authentication_key_model + bfd_config = gateway_bfd_config_action_template_model connection_mode = 'transit' global_ = True metered = False resource_group = resource_group_identity_model - updates = [{ 'foo': 'bar' }] + updates = [gateway_action_template_updates_item_model] # Pass in all but one required param and check for a ValueError req_param_dict = { @@ -598,23 +869,42 @@ def test_create_gateway_action_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.create_gateway_action(**req_copy) + _service.create_gateway_action(**req_copy) + + def test_create_gateway_action_value_error_with_retries(self): + # Enable retries and run test_create_gateway_action_value_error. + _service.enable_retries() + self.test_create_gateway_action_value_error() + # Disable retries and run test_create_gateway_action_value_error. + _service.disable_retries() + self.test_create_gateway_action_value_error() -#----------------------------------------------------------------------------- -# Test Class for list_gateway_completion_notice -#----------------------------------------------------------------------------- class TestListGatewayCompletionNotice(): + """ + Test Class for list_gateway_completion_notice + """ + + def preprocess_url(self, request_url: str): + """ + Preprocess the request URL to ensure the mock response will be found. + """ + 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('/') + '/+') - #-------------------------------------------------------- - # list_gateway_completion_notice() - #-------------------------------------------------------- @responses.activate def test_list_gateway_completion_notice_all_params(self): + """ + list_gateway_completion_notice() + """ # Set up mock - url = base_url + '/gateways/testString/completion_notice' - mock_response = 'Contents of response byte-stream...' + url = self.preprocess_url(_base_url + '/gateways/testString/completion_notice') + mock_response = 'This is a mock binary response.' responses.add(responses.GET, url, body=mock_response, @@ -625,7 +915,7 @@ def test_list_gateway_completion_notice_all_params(self): id = 'testString' # Invoke method - response = service.list_gateway_completion_notice( + response = _service.list_gateway_completion_notice( id, headers={} ) @@ -634,15 +924,23 @@ def test_list_gateway_completion_notice_all_params(self): assert len(responses.calls) == 1 assert response.status_code == 200 + def test_list_gateway_completion_notice_all_params_with_retries(self): + # Enable retries and run test_list_gateway_completion_notice_all_params. + _service.enable_retries() + self.test_list_gateway_completion_notice_all_params() + + # Disable retries and run test_list_gateway_completion_notice_all_params. + _service.disable_retries() + self.test_list_gateway_completion_notice_all_params() - #-------------------------------------------------------- - # test_list_gateway_completion_notice_value_error() - #-------------------------------------------------------- @responses.activate def test_list_gateway_completion_notice_value_error(self): + """ + test_list_gateway_completion_notice_value_error() + """ # Set up mock - url = base_url + '/gateways/testString/completion_notice' - mock_response = 'Contents of response byte-stream...' + url = self.preprocess_url(_base_url + '/gateways/testString/completion_notice') + mock_response = 'This is a mock binary response.' responses.add(responses.GET, url, body=mock_response, @@ -659,22 +957,41 @@ def test_list_gateway_completion_notice_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_gateway_completion_notice(**req_copy) + _service.list_gateway_completion_notice(**req_copy) + + def test_list_gateway_completion_notice_value_error_with_retries(self): + # Enable retries and run test_list_gateway_completion_notice_value_error. + _service.enable_retries() + self.test_list_gateway_completion_notice_value_error() + # Disable retries and run test_list_gateway_completion_notice_value_error. + _service.disable_retries() + self.test_list_gateway_completion_notice_value_error() -#----------------------------------------------------------------------------- -# Test Class for create_gateway_completion_notice -#----------------------------------------------------------------------------- class TestCreateGatewayCompletionNotice(): + """ + Test Class for create_gateway_completion_notice + """ + + def preprocess_url(self, request_url: str): + """ + Preprocess the request URL to ensure the mock response will be found. + """ + 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('/') + '/+') - #-------------------------------------------------------- - # create_gateway_completion_notice() - #-------------------------------------------------------- @responses.activate def test_create_gateway_completion_notice_all_params(self): + """ + create_gateway_completion_notice() + """ # Set up mock - url = base_url + '/gateways/testString/completion_notice' + url = self.preprocess_url(_base_url + '/gateways/testString/completion_notice') responses.add(responses.PUT, url, status=204) @@ -685,7 +1002,7 @@ def test_create_gateway_completion_notice_all_params(self): upload_content_type = 'testString' # Invoke method - response = service.create_gateway_completion_notice( + response = _service.create_gateway_completion_notice( id, upload=upload, upload_content_type=upload_content_type, @@ -696,14 +1013,22 @@ def test_create_gateway_completion_notice_all_params(self): assert len(responses.calls) == 1 assert response.status_code == 204 + def test_create_gateway_completion_notice_all_params_with_retries(self): + # Enable retries and run test_create_gateway_completion_notice_all_params. + _service.enable_retries() + self.test_create_gateway_completion_notice_all_params() + + # Disable retries and run test_create_gateway_completion_notice_all_params. + _service.disable_retries() + self.test_create_gateway_completion_notice_all_params() - #-------------------------------------------------------- - # test_create_gateway_completion_notice_required_params() - #-------------------------------------------------------- @responses.activate def test_create_gateway_completion_notice_required_params(self): + """ + test_create_gateway_completion_notice_required_params() + """ # Set up mock - url = base_url + '/gateways/testString/completion_notice' + url = self.preprocess_url(_base_url + '/gateways/testString/completion_notice') responses.add(responses.PUT, url, status=204) @@ -712,7 +1037,7 @@ def test_create_gateway_completion_notice_required_params(self): id = 'testString' # Invoke method - response = service.create_gateway_completion_notice( + response = _service.create_gateway_completion_notice( id, headers={} ) @@ -721,14 +1046,22 @@ def test_create_gateway_completion_notice_required_params(self): assert len(responses.calls) == 1 assert response.status_code == 204 + def test_create_gateway_completion_notice_required_params_with_retries(self): + # Enable retries and run test_create_gateway_completion_notice_required_params. + _service.enable_retries() + self.test_create_gateway_completion_notice_required_params() + + # Disable retries and run test_create_gateway_completion_notice_required_params. + _service.disable_retries() + self.test_create_gateway_completion_notice_required_params() - #-------------------------------------------------------- - # test_create_gateway_completion_notice_value_error() - #-------------------------------------------------------- @responses.activate def test_create_gateway_completion_notice_value_error(self): + """ + test_create_gateway_completion_notice_value_error() + """ # Set up mock - url = base_url + '/gateways/testString/completion_notice' + url = self.preprocess_url(_base_url + '/gateways/testString/completion_notice') responses.add(responses.PUT, url, status=204) @@ -743,23 +1076,42 @@ def test_create_gateway_completion_notice_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.create_gateway_completion_notice(**req_copy) + _service.create_gateway_completion_notice(**req_copy) + + def test_create_gateway_completion_notice_value_error_with_retries(self): + # Enable retries and run test_create_gateway_completion_notice_value_error. + _service.enable_retries() + self.test_create_gateway_completion_notice_value_error() + # Disable retries and run test_create_gateway_completion_notice_value_error. + _service.disable_retries() + self.test_create_gateway_completion_notice_value_error() -#----------------------------------------------------------------------------- -# Test Class for list_gateway_letter_of_authorization -#----------------------------------------------------------------------------- class TestListGatewayLetterOfAuthorization(): + """ + Test Class for list_gateway_letter_of_authorization + """ + + def preprocess_url(self, request_url: str): + """ + Preprocess the request URL to ensure the mock response will be found. + """ + 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('/') + '/+') - #-------------------------------------------------------- - # list_gateway_letter_of_authorization() - #-------------------------------------------------------- @responses.activate def test_list_gateway_letter_of_authorization_all_params(self): + """ + list_gateway_letter_of_authorization() + """ # Set up mock - url = base_url + '/gateways/testString/letter_of_authorization' - mock_response = 'Contents of response byte-stream...' + url = self.preprocess_url(_base_url + '/gateways/testString/letter_of_authorization') + mock_response = 'This is a mock binary response.' responses.add(responses.GET, url, body=mock_response, @@ -770,7 +1122,7 @@ def test_list_gateway_letter_of_authorization_all_params(self): id = 'testString' # Invoke method - response = service.list_gateway_letter_of_authorization( + response = _service.list_gateway_letter_of_authorization( id, headers={} ) @@ -779,15 +1131,23 @@ def test_list_gateway_letter_of_authorization_all_params(self): assert len(responses.calls) == 1 assert response.status_code == 200 + def test_list_gateway_letter_of_authorization_all_params_with_retries(self): + # Enable retries and run test_list_gateway_letter_of_authorization_all_params. + _service.enable_retries() + self.test_list_gateway_letter_of_authorization_all_params() + + # Disable retries and run test_list_gateway_letter_of_authorization_all_params. + _service.disable_retries() + self.test_list_gateway_letter_of_authorization_all_params() - #-------------------------------------------------------- - # test_list_gateway_letter_of_authorization_value_error() - #-------------------------------------------------------- @responses.activate def test_list_gateway_letter_of_authorization_value_error(self): + """ + test_list_gateway_letter_of_authorization_value_error() + """ # Set up mock - url = base_url + '/gateways/testString/letter_of_authorization' - mock_response = 'Contents of response byte-stream...' + url = self.preprocess_url(_base_url + '/gateways/testString/letter_of_authorization') + mock_response = 'This is a mock binary response.' responses.add(responses.GET, url, body=mock_response, @@ -804,23 +1164,42 @@ def test_list_gateway_letter_of_authorization_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_gateway_letter_of_authorization(**req_copy) + _service.list_gateway_letter_of_authorization(**req_copy) + def test_list_gateway_letter_of_authorization_value_error_with_retries(self): + # Enable retries and run test_list_gateway_letter_of_authorization_value_error. + _service.enable_retries() + self.test_list_gateway_letter_of_authorization_value_error() + + # Disable retries and run test_list_gateway_letter_of_authorization_value_error. + _service.disable_retries() + self.test_list_gateway_letter_of_authorization_value_error() -#----------------------------------------------------------------------------- -# Test Class for get_gateway_statistics -#----------------------------------------------------------------------------- class TestGetGatewayStatistics(): + """ + Test Class for get_gateway_statistics + """ + + def preprocess_url(self, request_url: str): + """ + Preprocess the request URL to ensure the mock response will be found. + """ + 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('/') + '/+') - #-------------------------------------------------------- - # get_gateway_statistics() - #-------------------------------------------------------- @responses.activate def test_get_gateway_statistics_all_params(self): + """ + get_gateway_statistics() + """ # Set up mock - url = base_url + '/gateways/testString/statistics' - mock_response = '{"statistics": [{"created_at": "2019-01-01T12:00:00", "data": "MKA statistics text...", "type": "macsec_policy"}]}' + url = self.preprocess_url(_base_url + '/gateways/testString/statistics') + mock_response = '{"statistics": [{"created_at": "2020-08-20T06:58:41.909Z", "data": "MKA statistics text...", "type": "macsec_policy"}]}' responses.add(responses.GET, url, body=mock_response, @@ -829,10 +1208,10 @@ def test_get_gateway_statistics_all_params(self): # Set up parameter values id = 'testString' - type = 'macsec_mka' + type = 'macsec_mka_session' # Invoke method - response = service.get_gateway_statistics( + response = _service.get_gateway_statistics( id, type, headers={} @@ -843,18 +1222,26 @@ def test_get_gateway_statistics_all_params(self): assert response.status_code == 200 # Validate query params query_string = responses.calls[0].request.url.split('?',1)[1] - query_string = requests.utils.unquote(query_string) + query_string = urllib.parse.unquote_plus(query_string) assert 'type={}'.format(type) in query_string + def test_get_gateway_statistics_all_params_with_retries(self): + # Enable retries and run test_get_gateway_statistics_all_params. + _service.enable_retries() + self.test_get_gateway_statistics_all_params() + + # Disable retries and run test_get_gateway_statistics_all_params. + _service.disable_retries() + self.test_get_gateway_statistics_all_params() - #-------------------------------------------------------- - # test_get_gateway_statistics_value_error() - #-------------------------------------------------------- @responses.activate def test_get_gateway_statistics_value_error(self): + """ + test_get_gateway_statistics_value_error() + """ # Set up mock - url = base_url + '/gateways/testString/statistics' - mock_response = '{"statistics": [{"created_at": "2019-01-01T12:00:00", "data": "MKA statistics text...", "type": "macsec_policy"}]}' + url = self.preprocess_url(_base_url + '/gateways/testString/statistics') + mock_response = '{"statistics": [{"created_at": "2020-08-20T06:58:41.909Z", "data": "MKA statistics text...", "type": "macsec_policy"}]}' responses.add(responses.GET, url, body=mock_response, @@ -863,7 +1250,7 @@ def test_get_gateway_statistics_value_error(self): # Set up parameter values id = 'testString' - type = 'macsec_mka' + type = 'macsec_mka_session' # Pass in all but one required param and check for a ValueError req_param_dict = { @@ -873,9 +1260,147 @@ def test_get_gateway_statistics_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_gateway_statistics(**req_copy) + _service.get_gateway_statistics(**req_copy) + + + def test_get_gateway_statistics_value_error_with_retries(self): + # Enable retries and run test_get_gateway_statistics_value_error. + _service.enable_retries() + self.test_get_gateway_statistics_value_error() + + # Disable retries and run test_get_gateway_statistics_value_error. + _service.disable_retries() + self.test_get_gateway_statistics_value_error() + +class TestGetGatewayStatus(): + """ + Test Class for get_gateway_status + """ + + def preprocess_url(self, request_url: str): + """ + Preprocess the request URL to ensure the mock response will be found. + """ + 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('/') + '/+') + + @responses.activate + def test_get_gateway_status_all_params(self): + """ + get_gateway_status() + """ + # Set up mock + url = self.preprocess_url(_base_url + '/gateways/testString/status') + mock_response = '{"status": [{"type": "bgp", "updated_at": "2020-08-20T06:58:41.909Z", "value": "active"}]}' + responses.add(responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Set up parameter values + id = 'testString' + type = 'bgp' + + # Invoke method + response = _service.get_gateway_status( + id, + type=type, + 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 'type={}'.format(type) in query_string + + def test_get_gateway_status_all_params_with_retries(self): + # Enable retries and run test_get_gateway_status_all_params. + _service.enable_retries() + self.test_get_gateway_status_all_params() + + # Disable retries and run test_get_gateway_status_all_params. + _service.disable_retries() + self.test_get_gateway_status_all_params() + @responses.activate + def test_get_gateway_status_required_params(self): + """ + test_get_gateway_status_required_params() + """ + # Set up mock + url = self.preprocess_url(_base_url + '/gateways/testString/status') + mock_response = '{"status": [{"type": "bgp", "updated_at": "2020-08-20T06:58:41.909Z", "value": "active"}]}' + responses.add(responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200) + # Set up parameter values + id = 'testString' + + # Invoke method + response = _service.get_gateway_status( + id, + headers={} + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_get_gateway_status_required_params_with_retries(self): + # Enable retries and run test_get_gateway_status_required_params. + _service.enable_retries() + self.test_get_gateway_status_required_params() + + # Disable retries and run test_get_gateway_status_required_params. + _service.disable_retries() + self.test_get_gateway_status_required_params() + + @responses.activate + def test_get_gateway_status_value_error(self): + """ + test_get_gateway_status_value_error() + """ + # Set up mock + url = self.preprocess_url(_base_url + '/gateways/testString/status') + mock_response = '{"status": [{"type": "bgp", "updated_at": "2020-08-20T06:58:41.909Z", "value": "active"}]}' + responses.add(responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Set up parameter values + id = 'testString' + + # 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.get_gateway_status(**req_copy) + + + def test_get_gateway_status_value_error_with_retries(self): + # Enable retries and run test_get_gateway_status_value_error. + _service.enable_retries() + self.test_get_gateway_status_value_error() + + # Disable retries and run test_get_gateway_status_value_error. + _service.disable_retries() + self.test_get_gateway_status_value_error() # endregion ############################################################################## @@ -887,18 +1412,72 @@ def test_get_gateway_statistics_value_error(self): ############################################################################## # region -#----------------------------------------------------------------------------- -# Test Class for list_offering_type_locations -#----------------------------------------------------------------------------- +class TestNewInstance(): + """ + Test Class for new_instance + """ + + def test_new_instance(self): + """ + new_instance() + """ + os.environ['TEST_SERVICE_AUTH_TYPE'] = 'noAuth' + + service = DirectLinkV1.new_instance( + version=version, + service_name='TEST_SERVICE', + ) + + assert service is not None + assert isinstance(service, DirectLinkV1) + + def test_new_instance_without_authenticator(self): + """ + new_instance_without_authenticator() + """ + with pytest.raises(ValueError, match='authenticator must be provided'): + service = DirectLinkV1.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 = DirectLinkV1.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 = DirectLinkV1.new_instance( + version=None, + ) class TestListOfferingTypeLocations(): + """ + Test Class for list_offering_type_locations + """ + + def preprocess_url(self, request_url: str): + """ + Preprocess the request URL to ensure the mock response will be found. + """ + 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('/') + '/+') - #-------------------------------------------------------- - # list_offering_type_locations() - #-------------------------------------------------------- @responses.activate def test_list_offering_type_locations_all_params(self): + """ + list_offering_type_locations() + """ # Set up mock - url = base_url + '/offering_types/dedicated/locations' + url = self.preprocess_url(_base_url + '/offering_types/dedicated/locations') mock_response = '{"locations": [{"billing_location": "us", "building_colocation_owner": "MyProvider", "display_name": "Dallas 9", "location_type": "PoP", "macsec_enabled": false, "market": "Dallas", "market_geography": "N/S America", "mzr": true, "name": "dal03", "offering_type": "dedicated", "provision_enabled": true, "vpc_region": "us-south"}]}' responses.add(responses.GET, url, @@ -910,7 +1489,7 @@ def test_list_offering_type_locations_all_params(self): offering_type = 'dedicated' # Invoke method - response = service.list_offering_type_locations( + response = _service.list_offering_type_locations( offering_type, headers={} ) @@ -919,14 +1498,22 @@ def test_list_offering_type_locations_all_params(self): assert len(responses.calls) == 1 assert response.status_code == 200 + def test_list_offering_type_locations_all_params_with_retries(self): + # Enable retries and run test_list_offering_type_locations_all_params. + _service.enable_retries() + self.test_list_offering_type_locations_all_params() + + # Disable retries and run test_list_offering_type_locations_all_params. + _service.disable_retries() + self.test_list_offering_type_locations_all_params() - #-------------------------------------------------------- - # test_list_offering_type_locations_value_error() - #-------------------------------------------------------- @responses.activate def test_list_offering_type_locations_value_error(self): + """ + test_list_offering_type_locations_value_error() + """ # Set up mock - url = base_url + '/offering_types/dedicated/locations' + url = self.preprocess_url(_base_url + '/offering_types/dedicated/locations') mock_response = '{"locations": [{"billing_location": "us", "building_colocation_owner": "MyProvider", "display_name": "Dallas 9", "location_type": "PoP", "macsec_enabled": false, "market": "Dallas", "market_geography": "N/S America", "mzr": true, "name": "dal03", "offering_type": "dedicated", "provision_enabled": true, "vpc_region": "us-south"}]}' responses.add(responses.GET, url, @@ -944,22 +1531,41 @@ def test_list_offering_type_locations_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_offering_type_locations(**req_copy) + _service.list_offering_type_locations(**req_copy) + def test_list_offering_type_locations_value_error_with_retries(self): + # Enable retries and run test_list_offering_type_locations_value_error. + _service.enable_retries() + self.test_list_offering_type_locations_value_error() + + # Disable retries and run test_list_offering_type_locations_value_error. + _service.disable_retries() + self.test_list_offering_type_locations_value_error() -#----------------------------------------------------------------------------- -# Test Class for list_offering_type_location_cross_connect_routers -#----------------------------------------------------------------------------- class TestListOfferingTypeLocationCrossConnectRouters(): + """ + Test Class for list_offering_type_location_cross_connect_routers + """ + + def preprocess_url(self, request_url: str): + """ + Preprocess the request URL to ensure the mock response will be found. + """ + 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('/') + '/+') - #-------------------------------------------------------- - # list_offering_type_location_cross_connect_routers() - #-------------------------------------------------------- @responses.activate def test_list_offering_type_location_cross_connect_routers_all_params(self): + """ + list_offering_type_location_cross_connect_routers() + """ # Set up mock - url = base_url + '/offering_types/dedicated/locations/testString/cross_connect_routers' + url = self.preprocess_url(_base_url + '/offering_types/dedicated/locations/testString/cross_connect_routers') mock_response = '{"cross_connect_routers": [{"capabilities": ["capabilities"], "router_name": "xcr01.dal03", "total_connections": 1}]}' responses.add(responses.GET, url, @@ -972,7 +1578,7 @@ def test_list_offering_type_location_cross_connect_routers_all_params(self): location_name = 'testString' # Invoke method - response = service.list_offering_type_location_cross_connect_routers( + response = _service.list_offering_type_location_cross_connect_routers( offering_type, location_name, headers={} @@ -982,14 +1588,22 @@ def test_list_offering_type_location_cross_connect_routers_all_params(self): assert len(responses.calls) == 1 assert response.status_code == 200 + def test_list_offering_type_location_cross_connect_routers_all_params_with_retries(self): + # Enable retries and run test_list_offering_type_location_cross_connect_routers_all_params. + _service.enable_retries() + self.test_list_offering_type_location_cross_connect_routers_all_params() + + # Disable retries and run test_list_offering_type_location_cross_connect_routers_all_params. + _service.disable_retries() + self.test_list_offering_type_location_cross_connect_routers_all_params() - #-------------------------------------------------------- - # test_list_offering_type_location_cross_connect_routers_value_error() - #-------------------------------------------------------- @responses.activate def test_list_offering_type_location_cross_connect_routers_value_error(self): + """ + test_list_offering_type_location_cross_connect_routers_value_error() + """ # Set up mock - url = base_url + '/offering_types/dedicated/locations/testString/cross_connect_routers' + url = self.preprocess_url(_base_url + '/offering_types/dedicated/locations/testString/cross_connect_routers') mock_response = '{"cross_connect_routers": [{"capabilities": ["capabilities"], "router_name": "xcr01.dal03", "total_connections": 1}]}' responses.add(responses.GET, url, @@ -1009,22 +1623,41 @@ def test_list_offering_type_location_cross_connect_routers_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_offering_type_location_cross_connect_routers(**req_copy) + _service.list_offering_type_location_cross_connect_routers(**req_copy) + + def test_list_offering_type_location_cross_connect_routers_value_error_with_retries(self): + # Enable retries and run test_list_offering_type_location_cross_connect_routers_value_error. + _service.enable_retries() + self.test_list_offering_type_location_cross_connect_routers_value_error() + # Disable retries and run test_list_offering_type_location_cross_connect_routers_value_error. + _service.disable_retries() + self.test_list_offering_type_location_cross_connect_routers_value_error() -#----------------------------------------------------------------------------- -# Test Class for list_offering_type_speeds -#----------------------------------------------------------------------------- class TestListOfferingTypeSpeeds(): + """ + Test Class for list_offering_type_speeds + """ + + def preprocess_url(self, request_url: str): + """ + Preprocess the request URL to ensure the mock response will be found. + """ + 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('/') + '/+') - #-------------------------------------------------------- - # list_offering_type_speeds() - #-------------------------------------------------------- @responses.activate def test_list_offering_type_speeds_all_params(self): + """ + list_offering_type_speeds() + """ # Set up mock - url = base_url + '/offering_types/dedicated/speeds' + url = self.preprocess_url(_base_url + '/offering_types/dedicated/speeds') mock_response = '{"speeds": [{"capabilities": ["capabilities"], "link_speed": 2000, "macsec_enabled": false}]}' responses.add(responses.GET, url, @@ -1036,7 +1669,7 @@ def test_list_offering_type_speeds_all_params(self): offering_type = 'dedicated' # Invoke method - response = service.list_offering_type_speeds( + response = _service.list_offering_type_speeds( offering_type, headers={} ) @@ -1045,14 +1678,22 @@ def test_list_offering_type_speeds_all_params(self): assert len(responses.calls) == 1 assert response.status_code == 200 + def test_list_offering_type_speeds_all_params_with_retries(self): + # Enable retries and run test_list_offering_type_speeds_all_params. + _service.enable_retries() + self.test_list_offering_type_speeds_all_params() + + # Disable retries and run test_list_offering_type_speeds_all_params. + _service.disable_retries() + self.test_list_offering_type_speeds_all_params() - #-------------------------------------------------------- - # test_list_offering_type_speeds_value_error() - #-------------------------------------------------------- @responses.activate def test_list_offering_type_speeds_value_error(self): + """ + test_list_offering_type_speeds_value_error() + """ # Set up mock - url = base_url + '/offering_types/dedicated/speeds' + url = self.preprocess_url(_base_url + '/offering_types/dedicated/speeds') mock_response = '{"speeds": [{"capabilities": ["capabilities"], "link_speed": 2000, "macsec_enabled": false}]}' responses.add(responses.GET, url, @@ -1070,9 +1711,17 @@ def test_list_offering_type_speeds_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_offering_type_speeds(**req_copy) + _service.list_offering_type_speeds(**req_copy) + + def test_list_offering_type_speeds_value_error_with_retries(self): + # Enable retries and run test_list_offering_type_speeds_value_error. + _service.enable_retries() + self.test_list_offering_type_speeds_value_error() + # Disable retries and run test_list_offering_type_speeds_value_error. + _service.disable_retries() + self.test_list_offering_type_speeds_value_error() # endregion ############################################################################## @@ -1084,18 +1733,72 @@ def test_list_offering_type_speeds_value_error(self): ############################################################################## # region -#----------------------------------------------------------------------------- -# Test Class for list_ports -#----------------------------------------------------------------------------- +class TestNewInstance(): + """ + Test Class for new_instance + """ + + def test_new_instance(self): + """ + new_instance() + """ + os.environ['TEST_SERVICE_AUTH_TYPE'] = 'noAuth' + + service = DirectLinkV1.new_instance( + version=version, + service_name='TEST_SERVICE', + ) + + assert service is not None + assert isinstance(service, DirectLinkV1) + + def test_new_instance_without_authenticator(self): + """ + new_instance_without_authenticator() + """ + with pytest.raises(ValueError, match='authenticator must be provided'): + service = DirectLinkV1.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 = DirectLinkV1.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 = DirectLinkV1.new_instance( + version=None, + ) class TestListPorts(): + """ + Test Class for list_ports + """ + + def preprocess_url(self, request_url: str): + """ + Preprocess the request URL to ensure the mock response will be found. + """ + 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('/') + '/+') - #-------------------------------------------------------- - # list_ports() - #-------------------------------------------------------- @responses.activate def test_list_ports_all_params(self): + """ + list_ports() + """ # Set up mock - url = base_url + '/ports' + url = self.preprocess_url(_base_url + '/ports') mock_response = '{"first": {"href": "https://directlink.cloud.ibm.com/v1/ports?limit=100"}, "limit": 100, "next": {"href": "https://directlink.cloud.ibm.com/v1/ports?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=100", "start": "9d5a91a3e2cbd233b5a5b33436855ed1"}, "total_count": 132, "ports": [{"direct_link_count": 1, "id": "01122b9b-820f-4c44-8a31-77f1f0806765", "label": "XCR-FRK-CS-SEC-01", "location_display_name": "Dallas 03", "location_name": "dal03", "provider_name": "provider_1", "supported_link_speeds": [21]}]}' responses.add(responses.GET, url, @@ -1105,11 +1808,11 @@ def test_list_ports_all_params(self): # Set up parameter values start = 'testString' - limit = 38 + limit = 1 location_name = 'testString' # Invoke method - response = service.list_ports( + response = _service.list_ports( start=start, limit=limit, location_name=location_name, @@ -1121,19 +1824,27 @@ def test_list_ports_all_params(self): assert response.status_code == 200 # Validate query params query_string = responses.calls[0].request.url.split('?',1)[1] - query_string = requests.utils.unquote(query_string) + query_string = urllib.parse.unquote_plus(query_string) assert 'start={}'.format(start) in query_string assert 'limit={}'.format(limit) in query_string assert 'location_name={}'.format(location_name) in query_string + def test_list_ports_all_params_with_retries(self): + # Enable retries and run test_list_ports_all_params. + _service.enable_retries() + self.test_list_ports_all_params() + + # Disable retries and run test_list_ports_all_params. + _service.disable_retries() + self.test_list_ports_all_params() - #-------------------------------------------------------- - # test_list_ports_required_params() - #-------------------------------------------------------- @responses.activate def test_list_ports_required_params(self): + """ + test_list_ports_required_params() + """ # Set up mock - url = base_url + '/ports' + url = self.preprocess_url(_base_url + '/ports') mock_response = '{"first": {"href": "https://directlink.cloud.ibm.com/v1/ports?limit=100"}, "limit": 100, "next": {"href": "https://directlink.cloud.ibm.com/v1/ports?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=100", "start": "9d5a91a3e2cbd233b5a5b33436855ed1"}, "total_count": 132, "ports": [{"direct_link_count": 1, "id": "01122b9b-820f-4c44-8a31-77f1f0806765", "label": "XCR-FRK-CS-SEC-01", "location_display_name": "Dallas 03", "location_name": "dal03", "provider_name": "provider_1", "supported_link_speeds": [21]}]}' responses.add(responses.GET, url, @@ -1142,21 +1853,29 @@ def test_list_ports_required_params(self): status=200) # Invoke method - response = service.list_ports() + response = _service.list_ports() # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 + def test_list_ports_required_params_with_retries(self): + # Enable retries and run test_list_ports_required_params. + _service.enable_retries() + self.test_list_ports_required_params() + + # Disable retries and run test_list_ports_required_params. + _service.disable_retries() + self.test_list_ports_required_params() - #-------------------------------------------------------- - # test_list_ports_value_error() - #-------------------------------------------------------- @responses.activate def test_list_ports_value_error(self): + """ + test_list_ports_value_error() + """ # Set up mock - url = base_url + '/ports' + url = self.preprocess_url(_base_url + '/ports') mock_response = '{"first": {"href": "https://directlink.cloud.ibm.com/v1/ports?limit=100"}, "limit": 100, "next": {"href": "https://directlink.cloud.ibm.com/v1/ports?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=100", "start": "9d5a91a3e2cbd233b5a5b33436855ed1"}, "total_count": 132, "ports": [{"direct_link_count": 1, "id": "01122b9b-820f-4c44-8a31-77f1f0806765", "label": "XCR-FRK-CS-SEC-01", "location_display_name": "Dallas 03", "location_name": "dal03", "provider_name": "provider_1", "supported_link_speeds": [21]}]}' responses.add(responses.GET, url, @@ -1170,22 +1889,41 @@ def test_list_ports_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_ports(**req_copy) + _service.list_ports(**req_copy) + def test_list_ports_value_error_with_retries(self): + # Enable retries and run test_list_ports_value_error. + _service.enable_retries() + self.test_list_ports_value_error() + + # Disable retries and run test_list_ports_value_error. + _service.disable_retries() + self.test_list_ports_value_error() -#----------------------------------------------------------------------------- -# Test Class for get_port -#----------------------------------------------------------------------------- class TestGetPort(): + """ + Test Class for get_port + """ + + def preprocess_url(self, request_url: str): + """ + Preprocess the request URL to ensure the mock response will be found. + """ + 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('/') + '/+') - #-------------------------------------------------------- - # get_port() - #-------------------------------------------------------- @responses.activate def test_get_port_all_params(self): + """ + get_port() + """ # Set up mock - url = base_url + '/ports/testString' + url = self.preprocess_url(_base_url + '/ports/testString') mock_response = '{"direct_link_count": 1, "id": "01122b9b-820f-4c44-8a31-77f1f0806765", "label": "XCR-FRK-CS-SEC-01", "location_display_name": "Dallas 03", "location_name": "dal03", "provider_name": "provider_1", "supported_link_speeds": [21]}' responses.add(responses.GET, url, @@ -1197,7 +1935,7 @@ def test_get_port_all_params(self): id = 'testString' # Invoke method - response = service.get_port( + response = _service.get_port( id, headers={} ) @@ -1206,14 +1944,22 @@ def test_get_port_all_params(self): assert len(responses.calls) == 1 assert response.status_code == 200 + def test_get_port_all_params_with_retries(self): + # Enable retries and run test_get_port_all_params. + _service.enable_retries() + self.test_get_port_all_params() + + # Disable retries and run test_get_port_all_params. + _service.disable_retries() + self.test_get_port_all_params() - #-------------------------------------------------------- - # test_get_port_value_error() - #-------------------------------------------------------- @responses.activate def test_get_port_value_error(self): + """ + test_get_port_value_error() + """ # Set up mock - url = base_url + '/ports/testString' + url = self.preprocess_url(_base_url + '/ports/testString') mock_response = '{"direct_link_count": 1, "id": "01122b9b-820f-4c44-8a31-77f1f0806765", "label": "XCR-FRK-CS-SEC-01", "location_display_name": "Dallas 03", "location_name": "dal03", "provider_name": "provider_1", "supported_link_speeds": [21]}' responses.add(responses.GET, url, @@ -1231,9 +1977,17 @@ def test_get_port_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_port(**req_copy) + _service.get_port(**req_copy) + + def test_get_port_value_error_with_retries(self): + # Enable retries and run test_get_port_value_error. + _service.enable_retries() + self.test_get_port_value_error() + # Disable retries and run test_get_port_value_error. + _service.disable_retries() + self.test_get_port_value_error() # endregion ############################################################################## @@ -1245,19 +1999,73 @@ def test_get_port_value_error(self): ############################################################################## # region -#----------------------------------------------------------------------------- -# Test Class for list_gateway_virtual_connections -#----------------------------------------------------------------------------- +class TestNewInstance(): + """ + Test Class for new_instance + """ + + def test_new_instance(self): + """ + new_instance() + """ + os.environ['TEST_SERVICE_AUTH_TYPE'] = 'noAuth' + + service = DirectLinkV1.new_instance( + version=version, + service_name='TEST_SERVICE', + ) + + assert service is not None + assert isinstance(service, DirectLinkV1) + + def test_new_instance_without_authenticator(self): + """ + new_instance_without_authenticator() + """ + with pytest.raises(ValueError, match='authenticator must be provided'): + service = DirectLinkV1.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 = DirectLinkV1.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 = DirectLinkV1.new_instance( + version=None, + ) class TestListGatewayVirtualConnections(): + """ + Test Class for list_gateway_virtual_connections + """ + + def preprocess_url(self, request_url: str): + """ + Preprocess the request URL to ensure the mock response will be found. + """ + 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('/') + '/+') - #-------------------------------------------------------- - # list_gateway_virtual_connections() - #-------------------------------------------------------- @responses.activate def test_list_gateway_virtual_connections_all_params(self): + """ + list_gateway_virtual_connections() + """ # Set up mock - url = base_url + '/gateways/testString/virtual_connections' - mock_response = '{"virtual_connections": [{"created_at": "2019-01-01T12:00:00", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "newVC", "network_account": "00aa14a2e0fb102c8995ebefff865555", "network_id": "crn:v1:bluemix:public:is:us-east:a/28e4d90ac7504be69447111122223333::vpc:aaa81ac8-5e96-42a0-a4b7-6c2e2d1bbbbb", "status": "attached", "type": "vpc"}]}' + url = self.preprocess_url(_base_url + '/gateways/testString/virtual_connections') + mock_response = '{"virtual_connections": [{"created_at": "2019-01-01T12:00:00.000Z", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "newVC", "network_account": "00aa14a2e0fb102c8995ebefff865555", "network_id": "crn:v1:bluemix:public:is:us-east:a/28e4d90ac7504be69447111122223333::vpc:aaa81ac8-5e96-42a0-a4b7-6c2e2d1bbbbb", "status": "attached", "type": "vpc"}]}' responses.add(responses.GET, url, body=mock_response, @@ -1268,7 +2076,7 @@ def test_list_gateway_virtual_connections_all_params(self): gateway_id = 'testString' # Invoke method - response = service.list_gateway_virtual_connections( + response = _service.list_gateway_virtual_connections( gateway_id, headers={} ) @@ -1277,15 +2085,23 @@ def test_list_gateway_virtual_connections_all_params(self): assert len(responses.calls) == 1 assert response.status_code == 200 + def test_list_gateway_virtual_connections_all_params_with_retries(self): + # Enable retries and run test_list_gateway_virtual_connections_all_params. + _service.enable_retries() + self.test_list_gateway_virtual_connections_all_params() + + # Disable retries and run test_list_gateway_virtual_connections_all_params. + _service.disable_retries() + self.test_list_gateway_virtual_connections_all_params() - #-------------------------------------------------------- - # test_list_gateway_virtual_connections_value_error() - #-------------------------------------------------------- @responses.activate def test_list_gateway_virtual_connections_value_error(self): + """ + test_list_gateway_virtual_connections_value_error() + """ # Set up mock - url = base_url + '/gateways/testString/virtual_connections' - mock_response = '{"virtual_connections": [{"created_at": "2019-01-01T12:00:00", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "newVC", "network_account": "00aa14a2e0fb102c8995ebefff865555", "network_id": "crn:v1:bluemix:public:is:us-east:a/28e4d90ac7504be69447111122223333::vpc:aaa81ac8-5e96-42a0-a4b7-6c2e2d1bbbbb", "status": "attached", "type": "vpc"}]}' + url = self.preprocess_url(_base_url + '/gateways/testString/virtual_connections') + mock_response = '{"virtual_connections": [{"created_at": "2019-01-01T12:00:00.000Z", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "newVC", "network_account": "00aa14a2e0fb102c8995ebefff865555", "network_id": "crn:v1:bluemix:public:is:us-east:a/28e4d90ac7504be69447111122223333::vpc:aaa81ac8-5e96-42a0-a4b7-6c2e2d1bbbbb", "status": "attached", "type": "vpc"}]}' responses.add(responses.GET, url, body=mock_response, @@ -1302,23 +2118,42 @@ def test_list_gateway_virtual_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_gateway_virtual_connections(**req_copy) + _service.list_gateway_virtual_connections(**req_copy) + def test_list_gateway_virtual_connections_value_error_with_retries(self): + # Enable retries and run test_list_gateway_virtual_connections_value_error. + _service.enable_retries() + self.test_list_gateway_virtual_connections_value_error() + + # Disable retries and run test_list_gateway_virtual_connections_value_error. + _service.disable_retries() + self.test_list_gateway_virtual_connections_value_error() -#----------------------------------------------------------------------------- -# Test Class for create_gateway_virtual_connection -#----------------------------------------------------------------------------- class TestCreateGatewayVirtualConnection(): + """ + Test Class for create_gateway_virtual_connection + """ + + def preprocess_url(self, request_url: str): + """ + Preprocess the request URL to ensure the mock response will be found. + """ + 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('/') + '/+') - #-------------------------------------------------------- - # create_gateway_virtual_connection() - #-------------------------------------------------------- @responses.activate def test_create_gateway_virtual_connection_all_params(self): + """ + create_gateway_virtual_connection() + """ # Set up mock - url = base_url + '/gateways/testString/virtual_connections' - mock_response = '{"created_at": "2019-01-01T12:00:00", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "newVC", "network_account": "00aa14a2e0fb102c8995ebefff865555", "network_id": "crn:v1:bluemix:public:is:us-east:a/28e4d90ac7504be69447111122223333::vpc:aaa81ac8-5e96-42a0-a4b7-6c2e2d1bbbbb", "status": "attached", "type": "vpc"}' + url = self.preprocess_url(_base_url + '/gateways/testString/virtual_connections') + mock_response = '{"created_at": "2019-01-01T12:00:00.000Z", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "newVC", "network_account": "00aa14a2e0fb102c8995ebefff865555", "network_id": "crn:v1:bluemix:public:is:us-east:a/28e4d90ac7504be69447111122223333::vpc:aaa81ac8-5e96-42a0-a4b7-6c2e2d1bbbbb", "status": "attached", "type": "vpc"}' responses.add(responses.POST, url, body=mock_response, @@ -1332,7 +2167,7 @@ def test_create_gateway_virtual_connection_all_params(self): network_id = 'crn:v1:bluemix:public:is:us-east:a/28e4d90ac7504be69447111122223333::vpc:aaa81ac8-5e96-42a0-a4b7-6c2e2d1bbbbb' # Invoke method - response = service.create_gateway_virtual_connection( + response = _service.create_gateway_virtual_connection( gateway_id, name, type, @@ -1349,15 +2184,23 @@ def test_create_gateway_virtual_connection_all_params(self): assert req_body['type'] == 'vpc' assert req_body['network_id'] == 'crn:v1:bluemix:public:is:us-east:a/28e4d90ac7504be69447111122223333::vpc:aaa81ac8-5e96-42a0-a4b7-6c2e2d1bbbbb' + def test_create_gateway_virtual_connection_all_params_with_retries(self): + # Enable retries and run test_create_gateway_virtual_connection_all_params. + _service.enable_retries() + self.test_create_gateway_virtual_connection_all_params() + + # Disable retries and run test_create_gateway_virtual_connection_all_params. + _service.disable_retries() + self.test_create_gateway_virtual_connection_all_params() - #-------------------------------------------------------- - # test_create_gateway_virtual_connection_value_error() - #-------------------------------------------------------- @responses.activate def test_create_gateway_virtual_connection_value_error(self): + """ + test_create_gateway_virtual_connection_value_error() + """ # Set up mock - url = base_url + '/gateways/testString/virtual_connections' - mock_response = '{"created_at": "2019-01-01T12:00:00", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "newVC", "network_account": "00aa14a2e0fb102c8995ebefff865555", "network_id": "crn:v1:bluemix:public:is:us-east:a/28e4d90ac7504be69447111122223333::vpc:aaa81ac8-5e96-42a0-a4b7-6c2e2d1bbbbb", "status": "attached", "type": "vpc"}' + url = self.preprocess_url(_base_url + '/gateways/testString/virtual_connections') + mock_response = '{"created_at": "2019-01-01T12:00:00.000Z", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "newVC", "network_account": "00aa14a2e0fb102c8995ebefff865555", "network_id": "crn:v1:bluemix:public:is:us-east:a/28e4d90ac7504be69447111122223333::vpc:aaa81ac8-5e96-42a0-a4b7-6c2e2d1bbbbb", "status": "attached", "type": "vpc"}' responses.add(responses.POST, url, body=mock_response, @@ -1379,22 +2222,41 @@ def test_create_gateway_virtual_connection_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.create_gateway_virtual_connection(**req_copy) + _service.create_gateway_virtual_connection(**req_copy) + + def test_create_gateway_virtual_connection_value_error_with_retries(self): + # Enable retries and run test_create_gateway_virtual_connection_value_error. + _service.enable_retries() + self.test_create_gateway_virtual_connection_value_error() + # Disable retries and run test_create_gateway_virtual_connection_value_error. + _service.disable_retries() + self.test_create_gateway_virtual_connection_value_error() -#----------------------------------------------------------------------------- -# Test Class for delete_gateway_virtual_connection -#----------------------------------------------------------------------------- class TestDeleteGatewayVirtualConnection(): + """ + Test Class for delete_gateway_virtual_connection + """ + + def preprocess_url(self, request_url: str): + """ + Preprocess the request URL to ensure the mock response will be found. + """ + 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('/') + '/+') - #-------------------------------------------------------- - # delete_gateway_virtual_connection() - #-------------------------------------------------------- @responses.activate def test_delete_gateway_virtual_connection_all_params(self): + """ + delete_gateway_virtual_connection() + """ # Set up mock - url = base_url + '/gateways/testString/virtual_connections/testString' + url = self.preprocess_url(_base_url + '/gateways/testString/virtual_connections/testString') responses.add(responses.DELETE, url, status=204) @@ -1404,7 +2266,7 @@ def test_delete_gateway_virtual_connection_all_params(self): id = 'testString' # Invoke method - response = service.delete_gateway_virtual_connection( + response = _service.delete_gateway_virtual_connection( gateway_id, id, headers={} @@ -1414,14 +2276,22 @@ def test_delete_gateway_virtual_connection_all_params(self): assert len(responses.calls) == 1 assert response.status_code == 204 + def test_delete_gateway_virtual_connection_all_params_with_retries(self): + # Enable retries and run test_delete_gateway_virtual_connection_all_params. + _service.enable_retries() + self.test_delete_gateway_virtual_connection_all_params() + + # Disable retries and run test_delete_gateway_virtual_connection_all_params. + _service.disable_retries() + self.test_delete_gateway_virtual_connection_all_params() - #-------------------------------------------------------- - # test_delete_gateway_virtual_connection_value_error() - #-------------------------------------------------------- @responses.activate def test_delete_gateway_virtual_connection_value_error(self): + """ + test_delete_gateway_virtual_connection_value_error() + """ # Set up mock - url = base_url + '/gateways/testString/virtual_connections/testString' + url = self.preprocess_url(_base_url + '/gateways/testString/virtual_connections/testString') responses.add(responses.DELETE, url, status=204) @@ -1438,23 +2308,42 @@ def test_delete_gateway_virtual_connection_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_gateway_virtual_connection(**req_copy) + _service.delete_gateway_virtual_connection(**req_copy) + + def test_delete_gateway_virtual_connection_value_error_with_retries(self): + # Enable retries and run test_delete_gateway_virtual_connection_value_error. + _service.enable_retries() + self.test_delete_gateway_virtual_connection_value_error() + # Disable retries and run test_delete_gateway_virtual_connection_value_error. + _service.disable_retries() + self.test_delete_gateway_virtual_connection_value_error() -#----------------------------------------------------------------------------- -# Test Class for get_gateway_virtual_connection -#----------------------------------------------------------------------------- class TestGetGatewayVirtualConnection(): + """ + Test Class for get_gateway_virtual_connection + """ + + def preprocess_url(self, request_url: str): + """ + Preprocess the request URL to ensure the mock response will be found. + """ + 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('/') + '/+') - #-------------------------------------------------------- - # get_gateway_virtual_connection() - #-------------------------------------------------------- @responses.activate def test_get_gateway_virtual_connection_all_params(self): + """ + get_gateway_virtual_connection() + """ # Set up mock - url = base_url + '/gateways/testString/virtual_connections/testString' - mock_response = '{"created_at": "2019-01-01T12:00:00", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "newVC", "network_account": "00aa14a2e0fb102c8995ebefff865555", "network_id": "crn:v1:bluemix:public:is:us-east:a/28e4d90ac7504be69447111122223333::vpc:aaa81ac8-5e96-42a0-a4b7-6c2e2d1bbbbb", "status": "attached", "type": "vpc"}' + url = self.preprocess_url(_base_url + '/gateways/testString/virtual_connections/testString') + mock_response = '{"created_at": "2019-01-01T12:00:00.000Z", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "newVC", "network_account": "00aa14a2e0fb102c8995ebefff865555", "network_id": "crn:v1:bluemix:public:is:us-east:a/28e4d90ac7504be69447111122223333::vpc:aaa81ac8-5e96-42a0-a4b7-6c2e2d1bbbbb", "status": "attached", "type": "vpc"}' responses.add(responses.GET, url, body=mock_response, @@ -1466,7 +2355,7 @@ def test_get_gateway_virtual_connection_all_params(self): id = 'testString' # Invoke method - response = service.get_gateway_virtual_connection( + response = _service.get_gateway_virtual_connection( gateway_id, id, headers={} @@ -1476,15 +2365,23 @@ def test_get_gateway_virtual_connection_all_params(self): assert len(responses.calls) == 1 assert response.status_code == 200 + def test_get_gateway_virtual_connection_all_params_with_retries(self): + # Enable retries and run test_get_gateway_virtual_connection_all_params. + _service.enable_retries() + self.test_get_gateway_virtual_connection_all_params() + + # Disable retries and run test_get_gateway_virtual_connection_all_params. + _service.disable_retries() + self.test_get_gateway_virtual_connection_all_params() - #-------------------------------------------------------- - # test_get_gateway_virtual_connection_value_error() - #-------------------------------------------------------- @responses.activate def test_get_gateway_virtual_connection_value_error(self): + """ + test_get_gateway_virtual_connection_value_error() + """ # Set up mock - url = base_url + '/gateways/testString/virtual_connections/testString' - mock_response = '{"created_at": "2019-01-01T12:00:00", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "newVC", "network_account": "00aa14a2e0fb102c8995ebefff865555", "network_id": "crn:v1:bluemix:public:is:us-east:a/28e4d90ac7504be69447111122223333::vpc:aaa81ac8-5e96-42a0-a4b7-6c2e2d1bbbbb", "status": "attached", "type": "vpc"}' + url = self.preprocess_url(_base_url + '/gateways/testString/virtual_connections/testString') + mock_response = '{"created_at": "2019-01-01T12:00:00.000Z", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "newVC", "network_account": "00aa14a2e0fb102c8995ebefff865555", "network_id": "crn:v1:bluemix:public:is:us-east:a/28e4d90ac7504be69447111122223333::vpc:aaa81ac8-5e96-42a0-a4b7-6c2e2d1bbbbb", "status": "attached", "type": "vpc"}' responses.add(responses.GET, url, body=mock_response, @@ -1503,23 +2400,42 @@ def test_get_gateway_virtual_connection_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_gateway_virtual_connection(**req_copy) + _service.get_gateway_virtual_connection(**req_copy) + def test_get_gateway_virtual_connection_value_error_with_retries(self): + # Enable retries and run test_get_gateway_virtual_connection_value_error. + _service.enable_retries() + self.test_get_gateway_virtual_connection_value_error() + + # Disable retries and run test_get_gateway_virtual_connection_value_error. + _service.disable_retries() + self.test_get_gateway_virtual_connection_value_error() -#----------------------------------------------------------------------------- -# Test Class for update_gateway_virtual_connection -#----------------------------------------------------------------------------- class TestUpdateGatewayVirtualConnection(): + """ + Test Class for update_gateway_virtual_connection + """ + + def preprocess_url(self, request_url: str): + """ + Preprocess the request URL to ensure the mock response will be found. + """ + 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('/') + '/+') - #-------------------------------------------------------- - # update_gateway_virtual_connection() - #-------------------------------------------------------- @responses.activate def test_update_gateway_virtual_connection_all_params(self): + """ + update_gateway_virtual_connection() + """ # Set up mock - url = base_url + '/gateways/testString/virtual_connections/testString' - mock_response = '{"created_at": "2019-01-01T12:00:00", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "newVC", "network_account": "00aa14a2e0fb102c8995ebefff865555", "network_id": "crn:v1:bluemix:public:is:us-east:a/28e4d90ac7504be69447111122223333::vpc:aaa81ac8-5e96-42a0-a4b7-6c2e2d1bbbbb", "status": "attached", "type": "vpc"}' + url = self.preprocess_url(_base_url + '/gateways/testString/virtual_connections/testString') + mock_response = '{"created_at": "2019-01-01T12:00:00.000Z", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "newVC", "network_account": "00aa14a2e0fb102c8995ebefff865555", "network_id": "crn:v1:bluemix:public:is:us-east:a/28e4d90ac7504be69447111122223333::vpc:aaa81ac8-5e96-42a0-a4b7-6c2e2d1bbbbb", "status": "attached", "type": "vpc"}' responses.add(responses.PATCH, url, body=mock_response, @@ -1533,7 +2449,7 @@ def test_update_gateway_virtual_connection_all_params(self): status = 'attached' # Invoke method - response = service.update_gateway_virtual_connection( + response = _service.update_gateway_virtual_connection( gateway_id, id, name=name, @@ -1549,15 +2465,23 @@ def test_update_gateway_virtual_connection_all_params(self): assert req_body['name'] == 'newConnectionName' assert req_body['status'] == 'attached' + def test_update_gateway_virtual_connection_all_params_with_retries(self): + # Enable retries and run test_update_gateway_virtual_connection_all_params. + _service.enable_retries() + self.test_update_gateway_virtual_connection_all_params() + + # Disable retries and run test_update_gateway_virtual_connection_all_params. + _service.disable_retries() + self.test_update_gateway_virtual_connection_all_params() - #-------------------------------------------------------- - # test_update_gateway_virtual_connection_value_error() - #-------------------------------------------------------- @responses.activate def test_update_gateway_virtual_connection_value_error(self): + """ + test_update_gateway_virtual_connection_value_error() + """ # Set up mock - url = base_url + '/gateways/testString/virtual_connections/testString' - mock_response = '{"created_at": "2019-01-01T12:00:00", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "newVC", "network_account": "00aa14a2e0fb102c8995ebefff865555", "network_id": "crn:v1:bluemix:public:is:us-east:a/28e4d90ac7504be69447111122223333::vpc:aaa81ac8-5e96-42a0-a4b7-6c2e2d1bbbbb", "status": "attached", "type": "vpc"}' + url = self.preprocess_url(_base_url + '/gateways/testString/virtual_connections/testString') + mock_response = '{"created_at": "2019-01-01T12:00:00.000Z", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "newVC", "network_account": "00aa14a2e0fb102c8995ebefff865555", "network_id": "crn:v1:bluemix:public:is:us-east:a/28e4d90ac7504be69447111122223333::vpc:aaa81ac8-5e96-42a0-a4b7-6c2e2d1bbbbb", "status": "attached", "type": "vpc"}' responses.add(responses.PATCH, url, body=mock_response, @@ -1578,9 +2502,17 @@ def test_update_gateway_virtual_connection_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.update_gateway_virtual_connection(**req_copy) + _service.update_gateway_virtual_connection(**req_copy) + + def test_update_gateway_virtual_connection_value_error_with_retries(self): + # Enable retries and run test_update_gateway_virtual_connection_value_error. + _service.enable_retries() + self.test_update_gateway_virtual_connection_value_error() + # Disable retries and run test_update_gateway_virtual_connection_value_error. + _service.disable_retries() + self.test_update_gateway_virtual_connection_value_error() # endregion ############################################################################## @@ -1592,19 +2524,19 @@ def test_update_gateway_virtual_connection_value_error(self): # Start of Model Tests ############################################################################## # region -#----------------------------------------------------------------------------- -# Test Class for CrossConnectRouter -#----------------------------------------------------------------------------- -class TestCrossConnectRouter(): - - #-------------------------------------------------------- - # Test serialization/deserialization for CrossConnectRouter - #-------------------------------------------------------- +class TestModel_CrossConnectRouter(): + """ + Test Class for CrossConnectRouter + """ + def test_cross_connect_router_serialization(self): + """ + Test serialization/deserialization for CrossConnectRouter + """ # Construct a json representation of a CrossConnectRouter model cross_connect_router_model_json = {} - cross_connect_router_model_json['capabilities'] = ['testString'] + cross_connect_router_model_json['capabilities'] = ['non_macsec', 'macsec'] cross_connect_router_model_json['router_name'] = 'xcr01.dal03' cross_connect_router_model_json['total_connections'] = 1 @@ -1623,18 +2555,30 @@ def test_cross_connect_router_serialization(self): cross_connect_router_model_json2 = cross_connect_router_model.to_dict() assert cross_connect_router_model_json2 == cross_connect_router_model_json -#----------------------------------------------------------------------------- -# Test Class for Gateway -#----------------------------------------------------------------------------- -class TestGateway(): +class TestModel_Gateway(): + """ + Test Class for Gateway + """ - #-------------------------------------------------------- - # Test serialization/deserialization for Gateway - #-------------------------------------------------------- def test_gateway_serialization(self): + """ + Test serialization/deserialization for Gateway + """ # Construct dict forms of any model objects needed in order to build this model. + gateway_authentication_key_model = {} # GatewayAuthenticationKey + gateway_authentication_key_model['crn'] = 'crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c' + + gateway_bfd_config_model = {} # GatewayBfdConfig + gateway_bfd_config_model['bfd_status'] = 'active' + gateway_bfd_config_model['bfd_status_updated_at'] = "2020-08-20T06:58:41.909000Z" + gateway_bfd_config_model['interval'] = 2000 + gateway_bfd_config_model['multiplier'] = 10 + + gateway_change_request_model = {} # GatewayChangeRequestGatewayClientGatewayCreate + gateway_change_request_model['type'] = 'create_gateway' + gateway_macsec_config_active_cak_model = {} # GatewayMacsecConfigActiveCak gateway_macsec_config_active_cak_model['crn'] = 'crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222' gateway_macsec_config_active_cak_model['status'] = 'testString' @@ -1647,12 +2591,6 @@ def test_gateway_serialization(self): gateway_macsec_config_primary_cak_model['crn'] = 'crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222' gateway_macsec_config_primary_cak_model['status'] = 'testString' - gateway_authentication_key_model = {} # GatewayAuthenticationKey - gateway_authentication_key_model['crn'] = 'crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c' - - gateway_change_request_model = {} # GatewayChangeRequest - gateway_change_request_model['type'] = 'create_gateway' - gateway_macsec_config_model = {} # GatewayMacsecConfig gateway_macsec_config_model['active'] = True gateway_macsec_config_model['active_cak'] = gateway_macsec_config_active_cak_model @@ -1676,29 +2614,33 @@ def test_gateway_serialization(self): # Construct a json representation of a Gateway model gateway_model_json = {} gateway_model_json['authentication_key'] = gateway_authentication_key_model + gateway_model_json['bfd_config'] = gateway_bfd_config_model gateway_model_json['bgp_asn'] = 64999 gateway_model_json['bgp_base_cidr'] = 'testString' gateway_model_json['bgp_cer_cidr'] = '10.254.30.78/30' gateway_model_json['bgp_ibm_asn'] = 13884 gateway_model_json['bgp_ibm_cidr'] = '10.254.30.77/30' gateway_model_json['bgp_status'] = 'active' + gateway_model_json['bgp_status_updated_at'] = "2020-08-20T06:58:41.909000Z" gateway_model_json['carrier_name'] = 'myCarrierName' gateway_model_json['change_request'] = gateway_change_request_model gateway_model_json['completion_notice_reject_reason'] = 'The completion notice file was blank' gateway_model_json['connection_mode'] = 'transit' - gateway_model_json['created_at'] = '2020-01-28T18:40:40.123456Z' + gateway_model_json['created_at'] = "2019-01-01T12:00:00Z" gateway_model_json['crn'] = 'crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::dedicated:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4' gateway_model_json['cross_connect_router'] = 'xcr01.dal03' gateway_model_json['customer_name'] = 'newCustomerName' gateway_model_json['global'] = True gateway_model_json['id'] = 'ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4' gateway_model_json['link_status'] = 'up' + gateway_model_json['link_status_updated_at'] = "2020-08-20T06:58:41.909000Z" gateway_model_json['location_display_name'] = 'Dallas 03' gateway_model_json['location_name'] = 'dal03' gateway_model_json['macsec_config'] = gateway_macsec_config_model gateway_model_json['metered'] = False gateway_model_json['name'] = 'myGateway' gateway_model_json['operational_status'] = 'awaiting_completion_notice' + gateway_model_json['patch_panel_completion_notice'] = 'patch panel configuration details' gateway_model_json['port'] = gateway_port_model gateway_model_json['provider_api_managed'] = False gateway_model_json['resource_group'] = resource_group_reference_model @@ -1721,15 +2663,15 @@ def test_gateway_serialization(self): gateway_model_json2 = gateway_model.to_dict() assert gateway_model_json2 == gateway_model_json -#----------------------------------------------------------------------------- -# Test Class for GatewayActionTemplateAuthenticationKey -#----------------------------------------------------------------------------- -class TestGatewayActionTemplateAuthenticationKey(): +class TestModel_GatewayActionTemplateAuthenticationKey(): + """ + Test Class for GatewayActionTemplateAuthenticationKey + """ - #-------------------------------------------------------- - # Test serialization/deserialization for GatewayActionTemplateAuthenticationKey - #-------------------------------------------------------- def test_gateway_action_template_authentication_key_serialization(self): + """ + Test serialization/deserialization for GatewayActionTemplateAuthenticationKey + """ # Construct a json representation of a GatewayActionTemplateAuthenticationKey model gateway_action_template_authentication_key_model_json = {} @@ -1750,15 +2692,15 @@ def test_gateway_action_template_authentication_key_serialization(self): gateway_action_template_authentication_key_model_json2 = gateway_action_template_authentication_key_model.to_dict() assert gateway_action_template_authentication_key_model_json2 == gateway_action_template_authentication_key_model_json -#----------------------------------------------------------------------------- -# Test Class for GatewayAuthenticationKey -#----------------------------------------------------------------------------- -class TestGatewayAuthenticationKey(): +class TestModel_GatewayAuthenticationKey(): + """ + Test Class for GatewayAuthenticationKey + """ - #-------------------------------------------------------- - # Test serialization/deserialization for GatewayAuthenticationKey - #-------------------------------------------------------- def test_gateway_authentication_key_serialization(self): + """ + Test serialization/deserialization for GatewayAuthenticationKey + """ # Construct a json representation of a GatewayAuthenticationKey model gateway_authentication_key_model_json = {} @@ -1779,18 +2721,152 @@ def test_gateway_authentication_key_serialization(self): gateway_authentication_key_model_json2 = gateway_authentication_key_model.to_dict() assert gateway_authentication_key_model_json2 == gateway_authentication_key_model_json -#----------------------------------------------------------------------------- -# Test Class for GatewayCollection -#----------------------------------------------------------------------------- -class TestGatewayCollection(): +class TestModel_GatewayBfdConfig(): + """ + Test Class for GatewayBfdConfig + """ + + def test_gateway_bfd_config_serialization(self): + """ + Test serialization/deserialization for GatewayBfdConfig + """ + + # Construct a json representation of a GatewayBfdConfig model + gateway_bfd_config_model_json = {} + gateway_bfd_config_model_json['bfd_status'] = 'active' + gateway_bfd_config_model_json['bfd_status_updated_at'] = "2020-08-20T06:58:41.909000Z" + gateway_bfd_config_model_json['interval'] = 2000 + gateway_bfd_config_model_json['multiplier'] = 10 + + # Construct a model instance of GatewayBfdConfig by calling from_dict on the json representation + gateway_bfd_config_model = GatewayBfdConfig.from_dict(gateway_bfd_config_model_json) + assert gateway_bfd_config_model != False + + # Construct a model instance of GatewayBfdConfig by calling from_dict on the json representation + gateway_bfd_config_model_dict = GatewayBfdConfig.from_dict(gateway_bfd_config_model_json).__dict__ + gateway_bfd_config_model2 = GatewayBfdConfig(**gateway_bfd_config_model_dict) + + # Verify the model instances are equivalent + assert gateway_bfd_config_model == gateway_bfd_config_model2 + + # Convert model instance back to dict and verify no loss of data + gateway_bfd_config_model_json2 = gateway_bfd_config_model.to_dict() + assert gateway_bfd_config_model_json2 == gateway_bfd_config_model_json + +class TestModel_GatewayBfdConfigActionTemplate(): + """ + Test Class for GatewayBfdConfigActionTemplate + """ + + def test_gateway_bfd_config_action_template_serialization(self): + """ + Test serialization/deserialization for GatewayBfdConfigActionTemplate + """ + + # Construct a json representation of a GatewayBfdConfigActionTemplate model + gateway_bfd_config_action_template_model_json = {} + gateway_bfd_config_action_template_model_json['interval'] = 2000 + gateway_bfd_config_action_template_model_json['multiplier'] = 10 + + # Construct a model instance of GatewayBfdConfigActionTemplate by calling from_dict on the json representation + gateway_bfd_config_action_template_model = GatewayBfdConfigActionTemplate.from_dict(gateway_bfd_config_action_template_model_json) + assert gateway_bfd_config_action_template_model != False + + # Construct a model instance of GatewayBfdConfigActionTemplate by calling from_dict on the json representation + gateway_bfd_config_action_template_model_dict = GatewayBfdConfigActionTemplate.from_dict(gateway_bfd_config_action_template_model_json).__dict__ + gateway_bfd_config_action_template_model2 = GatewayBfdConfigActionTemplate(**gateway_bfd_config_action_template_model_dict) + + # Verify the model instances are equivalent + assert gateway_bfd_config_action_template_model == gateway_bfd_config_action_template_model2 + + # Convert model instance back to dict and verify no loss of data + gateway_bfd_config_action_template_model_json2 = gateway_bfd_config_action_template_model.to_dict() + assert gateway_bfd_config_action_template_model_json2 == gateway_bfd_config_action_template_model_json + +class TestModel_GatewayBfdConfigTemplate(): + """ + Test Class for GatewayBfdConfigTemplate + """ + + def test_gateway_bfd_config_template_serialization(self): + """ + Test serialization/deserialization for GatewayBfdConfigTemplate + """ + + # Construct a json representation of a GatewayBfdConfigTemplate model + gateway_bfd_config_template_model_json = {} + gateway_bfd_config_template_model_json['interval'] = 2000 + gateway_bfd_config_template_model_json['multiplier'] = 10 + + # Construct a model instance of GatewayBfdConfigTemplate by calling from_dict on the json representation + gateway_bfd_config_template_model = GatewayBfdConfigTemplate.from_dict(gateway_bfd_config_template_model_json) + assert gateway_bfd_config_template_model != False + + # Construct a model instance of GatewayBfdConfigTemplate by calling from_dict on the json representation + gateway_bfd_config_template_model_dict = GatewayBfdConfigTemplate.from_dict(gateway_bfd_config_template_model_json).__dict__ + gateway_bfd_config_template_model2 = GatewayBfdConfigTemplate(**gateway_bfd_config_template_model_dict) + + # Verify the model instances are equivalent + assert gateway_bfd_config_template_model == gateway_bfd_config_template_model2 + + # Convert model instance back to dict and verify no loss of data + gateway_bfd_config_template_model_json2 = gateway_bfd_config_template_model.to_dict() + assert gateway_bfd_config_template_model_json2 == gateway_bfd_config_template_model_json + +class TestModel_GatewayBfdPatchTemplate(): + """ + Test Class for GatewayBfdPatchTemplate + """ + + def test_gateway_bfd_patch_template_serialization(self): + """ + Test serialization/deserialization for GatewayBfdPatchTemplate + """ + + # Construct a json representation of a GatewayBfdPatchTemplate model + gateway_bfd_patch_template_model_json = {} + gateway_bfd_patch_template_model_json['interval'] = 2000 + gateway_bfd_patch_template_model_json['multiplier'] = 10 + + # Construct a model instance of GatewayBfdPatchTemplate by calling from_dict on the json representation + gateway_bfd_patch_template_model = GatewayBfdPatchTemplate.from_dict(gateway_bfd_patch_template_model_json) + assert gateway_bfd_patch_template_model != False + + # Construct a model instance of GatewayBfdPatchTemplate by calling from_dict on the json representation + gateway_bfd_patch_template_model_dict = GatewayBfdPatchTemplate.from_dict(gateway_bfd_patch_template_model_json).__dict__ + gateway_bfd_patch_template_model2 = GatewayBfdPatchTemplate(**gateway_bfd_patch_template_model_dict) + + # Verify the model instances are equivalent + assert gateway_bfd_patch_template_model == gateway_bfd_patch_template_model2 + + # Convert model instance back to dict and verify no loss of data + gateway_bfd_patch_template_model_json2 = gateway_bfd_patch_template_model.to_dict() + assert gateway_bfd_patch_template_model_json2 == gateway_bfd_patch_template_model_json + +class TestModel_GatewayCollection(): + """ + Test Class for GatewayCollection + """ - #-------------------------------------------------------- - # Test serialization/deserialization for GatewayCollection - #-------------------------------------------------------- def test_gateway_collection_serialization(self): + """ + Test serialization/deserialization for GatewayCollection + """ # Construct dict forms of any model objects needed in order to build this model. + gateway_authentication_key_model = {} # GatewayAuthenticationKey + gateway_authentication_key_model['crn'] = 'crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c' + + gateway_bfd_config_model = {} # GatewayBfdConfig + gateway_bfd_config_model['bfd_status'] = 'active' + gateway_bfd_config_model['bfd_status_updated_at'] = "2020-08-20T06:58:41.909000Z" + gateway_bfd_config_model['interval'] = 2000 + gateway_bfd_config_model['multiplier'] = 10 + + gateway_change_request_model = {} # GatewayChangeRequestGatewayClientGatewayCreate + gateway_change_request_model['type'] = 'create_gateway' + gateway_macsec_config_active_cak_model = {} # GatewayMacsecConfigActiveCak gateway_macsec_config_active_cak_model['crn'] = 'crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222' gateway_macsec_config_active_cak_model['status'] = 'testString' @@ -1803,12 +2879,6 @@ def test_gateway_collection_serialization(self): gateway_macsec_config_primary_cak_model['crn'] = 'crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222' gateway_macsec_config_primary_cak_model['status'] = 'testString' - gateway_authentication_key_model = {} # GatewayAuthenticationKey - gateway_authentication_key_model['crn'] = 'crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c' - - gateway_change_request_model = {} # GatewayChangeRequest - gateway_change_request_model['type'] = 'create_gateway' - gateway_macsec_config_model = {} # GatewayMacsecConfig gateway_macsec_config_model['active'] = True gateway_macsec_config_model['active_cak'] = gateway_macsec_config_active_cak_model @@ -1831,29 +2901,33 @@ def test_gateway_collection_serialization(self): gateway_model = {} # Gateway gateway_model['authentication_key'] = gateway_authentication_key_model + gateway_model['bfd_config'] = gateway_bfd_config_model gateway_model['bgp_asn'] = 64999 gateway_model['bgp_base_cidr'] = 'testString' gateway_model['bgp_cer_cidr'] = '10.254.30.78/30' gateway_model['bgp_ibm_asn'] = 13884 gateway_model['bgp_ibm_cidr'] = '10.254.30.77/30' gateway_model['bgp_status'] = 'active' + gateway_model['bgp_status_updated_at'] = "2020-08-20T06:58:41.909000Z" gateway_model['carrier_name'] = 'myCarrierName' gateway_model['change_request'] = gateway_change_request_model gateway_model['completion_notice_reject_reason'] = 'The completion notice file was blank' gateway_model['connection_mode'] = 'transit' - gateway_model['created_at'] = '2020-01-28T18:40:40.123456Z' + gateway_model['created_at'] = "2019-01-01T12:00:00Z" gateway_model['crn'] = 'crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::dedicated:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4' gateway_model['cross_connect_router'] = 'xcr01.dal03' gateway_model['customer_name'] = 'newCustomerName' gateway_model['global'] = True gateway_model['id'] = 'ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4' gateway_model['link_status'] = 'up' + gateway_model['link_status_updated_at'] = "2020-08-20T06:58:41.909000Z" gateway_model['location_display_name'] = 'Dallas 03' gateway_model['location_name'] = 'dal03' gateway_model['macsec_config'] = gateway_macsec_config_model gateway_model['metered'] = False gateway_model['name'] = 'myGateway' gateway_model['operational_status'] = 'awaiting_completion_notice' + gateway_model['patch_panel_completion_notice'] = 'patch panel configuration details' gateway_model['port'] = gateway_port_model gateway_model['provider_api_managed'] = False gateway_model['resource_group'] = resource_group_reference_model @@ -1880,15 +2954,15 @@ def test_gateway_collection_serialization(self): gateway_collection_model_json2 = gateway_collection_model.to_dict() assert gateway_collection_model_json2 == gateway_collection_model_json -#----------------------------------------------------------------------------- -# Test Class for GatewayMacsecConfig -#----------------------------------------------------------------------------- -class TestGatewayMacsecConfig(): +class TestModel_GatewayMacsecConfig(): + """ + Test Class for GatewayMacsecConfig + """ - #-------------------------------------------------------- - # Test serialization/deserialization for GatewayMacsecConfig - #-------------------------------------------------------- def test_gateway_macsec_config_serialization(self): + """ + Test serialization/deserialization for GatewayMacsecConfig + """ # Construct dict forms of any model objects needed in order to build this model. @@ -1934,15 +3008,15 @@ def test_gateway_macsec_config_serialization(self): gateway_macsec_config_model_json2 = gateway_macsec_config_model.to_dict() assert gateway_macsec_config_model_json2 == gateway_macsec_config_model_json -#----------------------------------------------------------------------------- -# Test Class for GatewayMacsecConfigActiveCak -#----------------------------------------------------------------------------- -class TestGatewayMacsecConfigActiveCak(): +class TestModel_GatewayMacsecConfigActiveCak(): + """ + Test Class for GatewayMacsecConfigActiveCak + """ - #-------------------------------------------------------- - # Test serialization/deserialization for GatewayMacsecConfigActiveCak - #-------------------------------------------------------- def test_gateway_macsec_config_active_cak_serialization(self): + """ + Test serialization/deserialization for GatewayMacsecConfigActiveCak + """ # Construct a json representation of a GatewayMacsecConfigActiveCak model gateway_macsec_config_active_cak_model_json = {} @@ -1964,15 +3038,15 @@ def test_gateway_macsec_config_active_cak_serialization(self): gateway_macsec_config_active_cak_model_json2 = gateway_macsec_config_active_cak_model.to_dict() assert gateway_macsec_config_active_cak_model_json2 == gateway_macsec_config_active_cak_model_json -#----------------------------------------------------------------------------- -# Test Class for GatewayMacsecConfigFallbackCak -#----------------------------------------------------------------------------- -class TestGatewayMacsecConfigFallbackCak(): +class TestModel_GatewayMacsecConfigFallbackCak(): + """ + Test Class for GatewayMacsecConfigFallbackCak + """ - #-------------------------------------------------------- - # Test serialization/deserialization for GatewayMacsecConfigFallbackCak - #-------------------------------------------------------- def test_gateway_macsec_config_fallback_cak_serialization(self): + """ + Test serialization/deserialization for GatewayMacsecConfigFallbackCak + """ # Construct a json representation of a GatewayMacsecConfigFallbackCak model gateway_macsec_config_fallback_cak_model_json = {} @@ -1994,15 +3068,15 @@ def test_gateway_macsec_config_fallback_cak_serialization(self): gateway_macsec_config_fallback_cak_model_json2 = gateway_macsec_config_fallback_cak_model.to_dict() assert gateway_macsec_config_fallback_cak_model_json2 == gateway_macsec_config_fallback_cak_model_json -#----------------------------------------------------------------------------- -# Test Class for GatewayMacsecConfigPatchTemplate -#----------------------------------------------------------------------------- -class TestGatewayMacsecConfigPatchTemplate(): +class TestModel_GatewayMacsecConfigPatchTemplate(): + """ + Test Class for GatewayMacsecConfigPatchTemplate + """ - #-------------------------------------------------------- - # Test serialization/deserialization for GatewayMacsecConfigPatchTemplate - #-------------------------------------------------------- def test_gateway_macsec_config_patch_template_serialization(self): + """ + Test serialization/deserialization for GatewayMacsecConfigPatchTemplate + """ # Construct dict forms of any model objects needed in order to build this model. @@ -2034,15 +3108,15 @@ def test_gateway_macsec_config_patch_template_serialization(self): gateway_macsec_config_patch_template_model_json2 = gateway_macsec_config_patch_template_model.to_dict() assert gateway_macsec_config_patch_template_model_json2 == gateway_macsec_config_patch_template_model_json -#----------------------------------------------------------------------------- -# Test Class for GatewayMacsecConfigPatchTemplateFallbackCak -#----------------------------------------------------------------------------- -class TestGatewayMacsecConfigPatchTemplateFallbackCak(): +class TestModel_GatewayMacsecConfigPatchTemplateFallbackCak(): + """ + Test Class for GatewayMacsecConfigPatchTemplateFallbackCak + """ - #-------------------------------------------------------- - # Test serialization/deserialization for GatewayMacsecConfigPatchTemplateFallbackCak - #-------------------------------------------------------- def test_gateway_macsec_config_patch_template_fallback_cak_serialization(self): + """ + Test serialization/deserialization for GatewayMacsecConfigPatchTemplateFallbackCak + """ # Construct a json representation of a GatewayMacsecConfigPatchTemplateFallbackCak model gateway_macsec_config_patch_template_fallback_cak_model_json = {} @@ -2063,15 +3137,15 @@ def test_gateway_macsec_config_patch_template_fallback_cak_serialization(self): gateway_macsec_config_patch_template_fallback_cak_model_json2 = gateway_macsec_config_patch_template_fallback_cak_model.to_dict() assert gateway_macsec_config_patch_template_fallback_cak_model_json2 == gateway_macsec_config_patch_template_fallback_cak_model_json -#----------------------------------------------------------------------------- -# Test Class for GatewayMacsecConfigPatchTemplatePrimaryCak -#----------------------------------------------------------------------------- -class TestGatewayMacsecConfigPatchTemplatePrimaryCak(): +class TestModel_GatewayMacsecConfigPatchTemplatePrimaryCak(): + """ + Test Class for GatewayMacsecConfigPatchTemplatePrimaryCak + """ - #-------------------------------------------------------- - # Test serialization/deserialization for GatewayMacsecConfigPatchTemplatePrimaryCak - #-------------------------------------------------------- def test_gateway_macsec_config_patch_template_primary_cak_serialization(self): + """ + Test serialization/deserialization for GatewayMacsecConfigPatchTemplatePrimaryCak + """ # Construct a json representation of a GatewayMacsecConfigPatchTemplatePrimaryCak model gateway_macsec_config_patch_template_primary_cak_model_json = {} @@ -2092,15 +3166,15 @@ def test_gateway_macsec_config_patch_template_primary_cak_serialization(self): gateway_macsec_config_patch_template_primary_cak_model_json2 = gateway_macsec_config_patch_template_primary_cak_model.to_dict() assert gateway_macsec_config_patch_template_primary_cak_model_json2 == gateway_macsec_config_patch_template_primary_cak_model_json -#----------------------------------------------------------------------------- -# Test Class for GatewayMacsecConfigPrimaryCak -#----------------------------------------------------------------------------- -class TestGatewayMacsecConfigPrimaryCak(): +class TestModel_GatewayMacsecConfigPrimaryCak(): + """ + Test Class for GatewayMacsecConfigPrimaryCak + """ - #-------------------------------------------------------- - # Test serialization/deserialization for GatewayMacsecConfigPrimaryCak - #-------------------------------------------------------- def test_gateway_macsec_config_primary_cak_serialization(self): + """ + Test serialization/deserialization for GatewayMacsecConfigPrimaryCak + """ # Construct a json representation of a GatewayMacsecConfigPrimaryCak model gateway_macsec_config_primary_cak_model_json = {} @@ -2122,15 +3196,15 @@ def test_gateway_macsec_config_primary_cak_serialization(self): gateway_macsec_config_primary_cak_model_json2 = gateway_macsec_config_primary_cak_model.to_dict() assert gateway_macsec_config_primary_cak_model_json2 == gateway_macsec_config_primary_cak_model_json -#----------------------------------------------------------------------------- -# Test Class for GatewayMacsecConfigTemplate -#----------------------------------------------------------------------------- -class TestGatewayMacsecConfigTemplate(): +class TestModel_GatewayMacsecConfigTemplate(): + """ + Test Class for GatewayMacsecConfigTemplate + """ - #-------------------------------------------------------- - # Test serialization/deserialization for GatewayMacsecConfigTemplate - #-------------------------------------------------------- def test_gateway_macsec_config_template_serialization(self): + """ + Test serialization/deserialization for GatewayMacsecConfigTemplate + """ # Construct dict forms of any model objects needed in order to build this model. @@ -2162,15 +3236,15 @@ def test_gateway_macsec_config_template_serialization(self): gateway_macsec_config_template_model_json2 = gateway_macsec_config_template_model.to_dict() assert gateway_macsec_config_template_model_json2 == gateway_macsec_config_template_model_json -#----------------------------------------------------------------------------- -# Test Class for GatewayMacsecConfigTemplateFallbackCak -#----------------------------------------------------------------------------- -class TestGatewayMacsecConfigTemplateFallbackCak(): +class TestModel_GatewayMacsecConfigTemplateFallbackCak(): + """ + Test Class for GatewayMacsecConfigTemplateFallbackCak + """ - #-------------------------------------------------------- - # Test serialization/deserialization for GatewayMacsecConfigTemplateFallbackCak - #-------------------------------------------------------- def test_gateway_macsec_config_template_fallback_cak_serialization(self): + """ + Test serialization/deserialization for GatewayMacsecConfigTemplateFallbackCak + """ # Construct a json representation of a GatewayMacsecConfigTemplateFallbackCak model gateway_macsec_config_template_fallback_cak_model_json = {} @@ -2191,15 +3265,15 @@ def test_gateway_macsec_config_template_fallback_cak_serialization(self): gateway_macsec_config_template_fallback_cak_model_json2 = gateway_macsec_config_template_fallback_cak_model.to_dict() assert gateway_macsec_config_template_fallback_cak_model_json2 == gateway_macsec_config_template_fallback_cak_model_json -#----------------------------------------------------------------------------- -# Test Class for GatewayMacsecConfigTemplatePrimaryCak -#----------------------------------------------------------------------------- -class TestGatewayMacsecConfigTemplatePrimaryCak(): +class TestModel_GatewayMacsecConfigTemplatePrimaryCak(): + """ + Test Class for GatewayMacsecConfigTemplatePrimaryCak + """ - #-------------------------------------------------------- - # Test serialization/deserialization for GatewayMacsecConfigTemplatePrimaryCak - #-------------------------------------------------------- def test_gateway_macsec_config_template_primary_cak_serialization(self): + """ + Test serialization/deserialization for GatewayMacsecConfigTemplatePrimaryCak + """ # Construct a json representation of a GatewayMacsecConfigTemplatePrimaryCak model gateway_macsec_config_template_primary_cak_model_json = {} @@ -2220,15 +3294,15 @@ def test_gateway_macsec_config_template_primary_cak_serialization(self): gateway_macsec_config_template_primary_cak_model_json2 = gateway_macsec_config_template_primary_cak_model.to_dict() assert gateway_macsec_config_template_primary_cak_model_json2 == gateway_macsec_config_template_primary_cak_model_json -#----------------------------------------------------------------------------- -# Test Class for GatewayPatchTemplateAuthenticationKey -#----------------------------------------------------------------------------- -class TestGatewayPatchTemplateAuthenticationKey(): +class TestModel_GatewayPatchTemplateAuthenticationKey(): + """ + Test Class for GatewayPatchTemplateAuthenticationKey + """ - #-------------------------------------------------------- - # Test serialization/deserialization for GatewayPatchTemplateAuthenticationKey - #-------------------------------------------------------- def test_gateway_patch_template_authentication_key_serialization(self): + """ + Test serialization/deserialization for GatewayPatchTemplateAuthenticationKey + """ # Construct a json representation of a GatewayPatchTemplateAuthenticationKey model gateway_patch_template_authentication_key_model_json = {} @@ -2249,15 +3323,15 @@ def test_gateway_patch_template_authentication_key_serialization(self): gateway_patch_template_authentication_key_model_json2 = gateway_patch_template_authentication_key_model.to_dict() assert gateway_patch_template_authentication_key_model_json2 == gateway_patch_template_authentication_key_model_json -#----------------------------------------------------------------------------- -# Test Class for GatewayPort -#----------------------------------------------------------------------------- -class TestGatewayPort(): +class TestModel_GatewayPort(): + """ + Test Class for GatewayPort + """ - #-------------------------------------------------------- - # Test serialization/deserialization for GatewayPort - #-------------------------------------------------------- def test_gateway_port_serialization(self): + """ + Test serialization/deserialization for GatewayPort + """ # Construct a json representation of a GatewayPort model gateway_port_model_json = {} @@ -2278,15 +3352,15 @@ def test_gateway_port_serialization(self): gateway_port_model_json2 = gateway_port_model.to_dict() assert gateway_port_model_json2 == gateway_port_model_json -#----------------------------------------------------------------------------- -# Test Class for GatewayPortIdentity -#----------------------------------------------------------------------------- -class TestGatewayPortIdentity(): +class TestModel_GatewayPortIdentity(): + """ + Test Class for GatewayPortIdentity + """ - #-------------------------------------------------------- - # Test serialization/deserialization for GatewayPortIdentity - #-------------------------------------------------------- def test_gateway_port_identity_serialization(self): + """ + Test serialization/deserialization for GatewayPortIdentity + """ # Construct a json representation of a GatewayPortIdentity model gateway_port_identity_model_json = {} @@ -2307,19 +3381,19 @@ def test_gateway_port_identity_serialization(self): gateway_port_identity_model_json2 = gateway_port_identity_model.to_dict() assert gateway_port_identity_model_json2 == gateway_port_identity_model_json -#----------------------------------------------------------------------------- -# Test Class for GatewayStatistic -#----------------------------------------------------------------------------- -class TestGatewayStatistic(): +class TestModel_GatewayStatistic(): + """ + Test Class for GatewayStatistic + """ - #-------------------------------------------------------- - # Test serialization/deserialization for GatewayStatistic - #-------------------------------------------------------- def test_gateway_statistic_serialization(self): + """ + Test serialization/deserialization for GatewayStatistic + """ # Construct a json representation of a GatewayStatistic model gateway_statistic_model_json = {} - gateway_statistic_model_json['created_at'] = '2020-01-28T18:40:40.123456Z' + gateway_statistic_model_json['created_at'] = "2020-08-20T06:58:41.909000Z" gateway_statistic_model_json['data'] = 'MKA statistics text...' gateway_statistic_model_json['type'] = 'macsec_policy' @@ -2338,20 +3412,20 @@ def test_gateway_statistic_serialization(self): gateway_statistic_model_json2 = gateway_statistic_model.to_dict() assert gateway_statistic_model_json2 == gateway_statistic_model_json -#----------------------------------------------------------------------------- -# Test Class for GatewayStatisticCollection -#----------------------------------------------------------------------------- -class TestGatewayStatisticCollection(): +class TestModel_GatewayStatisticCollection(): + """ + Test Class for GatewayStatisticCollection + """ - #-------------------------------------------------------- - # Test serialization/deserialization for GatewayStatisticCollection - #-------------------------------------------------------- def test_gateway_statistic_collection_serialization(self): + """ + Test serialization/deserialization for GatewayStatisticCollection + """ # Construct dict forms of any model objects needed in order to build this model. gateway_statistic_model = {} # GatewayStatistic - gateway_statistic_model['created_at'] = '2020-01-28T18:40:40.123456Z' + gateway_statistic_model['created_at'] = "2020-08-20T06:58:41.909000Z" gateway_statistic_model['data'] = 'MKA statistics text...' gateway_statistic_model['type'] = 'macsec_policy' @@ -2374,15 +3448,51 @@ def test_gateway_statistic_collection_serialization(self): gateway_statistic_collection_model_json2 = gateway_statistic_collection_model.to_dict() assert gateway_statistic_collection_model_json2 == gateway_statistic_collection_model_json -#----------------------------------------------------------------------------- -# Test Class for GatewayTemplateAuthenticationKey -#----------------------------------------------------------------------------- -class TestGatewayTemplateAuthenticationKey(): +class TestModel_GatewayStatusCollection(): + """ + Test Class for GatewayStatusCollection + """ + + def test_gateway_status_collection_serialization(self): + """ + Test serialization/deserialization for GatewayStatusCollection + """ + + # Construct dict forms of any model objects needed in order to build this model. + + gateway_status_model = {} # GatewayStatusGatewayBGPStatus + gateway_status_model['type'] = 'bgp' + gateway_status_model['updated_at'] = "2020-08-20T06:58:41.909000Z" + gateway_status_model['value'] = 'active' + + # Construct a json representation of a GatewayStatusCollection model + gateway_status_collection_model_json = {} + gateway_status_collection_model_json['status'] = [gateway_status_model] + + # Construct a model instance of GatewayStatusCollection by calling from_dict on the json representation + gateway_status_collection_model = GatewayStatusCollection.from_dict(gateway_status_collection_model_json) + assert gateway_status_collection_model != False + + # Construct a model instance of GatewayStatusCollection by calling from_dict on the json representation + gateway_status_collection_model_dict = GatewayStatusCollection.from_dict(gateway_status_collection_model_json).__dict__ + gateway_status_collection_model2 = GatewayStatusCollection(**gateway_status_collection_model_dict) + + # Verify the model instances are equivalent + assert gateway_status_collection_model == gateway_status_collection_model2 + + # Convert model instance back to dict and verify no loss of data + gateway_status_collection_model_json2 = gateway_status_collection_model.to_dict() + assert gateway_status_collection_model_json2 == gateway_status_collection_model_json + +class TestModel_GatewayTemplateAuthenticationKey(): + """ + Test Class for GatewayTemplateAuthenticationKey + """ - #-------------------------------------------------------- - # Test serialization/deserialization for GatewayTemplateAuthenticationKey - #-------------------------------------------------------- def test_gateway_template_authentication_key_serialization(self): + """ + Test serialization/deserialization for GatewayTemplateAuthenticationKey + """ # Construct a json representation of a GatewayTemplateAuthenticationKey model gateway_template_authentication_key_model_json = {} @@ -2403,77 +3513,19 @@ def test_gateway_template_authentication_key_serialization(self): gateway_template_authentication_key_model_json2 = gateway_template_authentication_key_model.to_dict() assert gateway_template_authentication_key_model_json2 == gateway_template_authentication_key_model_json -#----------------------------------------------------------------------------- -# Test Class for GatewayTemplateGatewayTypeConnectTemplateAuthenticationKey -#----------------------------------------------------------------------------- -class TestGatewayTemplateGatewayTypeConnectTemplateAuthenticationKey(): - - #-------------------------------------------------------- - # Test serialization/deserialization for GatewayTemplateGatewayTypeConnectTemplateAuthenticationKey - #-------------------------------------------------------- - def test_gateway_template_gateway_type_connect_template_authentication_key_serialization(self): - - # Construct a json representation of a GatewayTemplateGatewayTypeConnectTemplateAuthenticationKey model - gateway_template_gateway_type_connect_template_authentication_key_model_json = {} - gateway_template_gateway_type_connect_template_authentication_key_model_json['crn'] = 'crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c' - - # Construct a model instance of GatewayTemplateGatewayTypeConnectTemplateAuthenticationKey by calling from_dict on the json representation - gateway_template_gateway_type_connect_template_authentication_key_model = GatewayTemplateGatewayTypeConnectTemplateAuthenticationKey.from_dict(gateway_template_gateway_type_connect_template_authentication_key_model_json) - assert gateway_template_gateway_type_connect_template_authentication_key_model != False - - # Construct a model instance of GatewayTemplateGatewayTypeConnectTemplateAuthenticationKey by calling from_dict on the json representation - gateway_template_gateway_type_connect_template_authentication_key_model_dict = GatewayTemplateGatewayTypeConnectTemplateAuthenticationKey.from_dict(gateway_template_gateway_type_connect_template_authentication_key_model_json).__dict__ - gateway_template_gateway_type_connect_template_authentication_key_model2 = GatewayTemplateGatewayTypeConnectTemplateAuthenticationKey(**gateway_template_gateway_type_connect_template_authentication_key_model_dict) - - # Verify the model instances are equivalent - assert gateway_template_gateway_type_connect_template_authentication_key_model == gateway_template_gateway_type_connect_template_authentication_key_model2 - - # Convert model instance back to dict and verify no loss of data - gateway_template_gateway_type_connect_template_authentication_key_model_json2 = gateway_template_gateway_type_connect_template_authentication_key_model.to_dict() - assert gateway_template_gateway_type_connect_template_authentication_key_model_json2 == gateway_template_gateway_type_connect_template_authentication_key_model_json - -#----------------------------------------------------------------------------- -# Test Class for GatewayTemplateGatewayTypeDedicatedTemplateAuthenticationKey -#----------------------------------------------------------------------------- -class TestGatewayTemplateGatewayTypeDedicatedTemplateAuthenticationKey(): +class TestModel_GatewayVirtualConnection(): + """ + Test Class for GatewayVirtualConnection + """ - #-------------------------------------------------------- - # Test serialization/deserialization for GatewayTemplateGatewayTypeDedicatedTemplateAuthenticationKey - #-------------------------------------------------------- - def test_gateway_template_gateway_type_dedicated_template_authentication_key_serialization(self): - - # Construct a json representation of a GatewayTemplateGatewayTypeDedicatedTemplateAuthenticationKey model - gateway_template_gateway_type_dedicated_template_authentication_key_model_json = {} - gateway_template_gateway_type_dedicated_template_authentication_key_model_json['crn'] = 'crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c' - - # Construct a model instance of GatewayTemplateGatewayTypeDedicatedTemplateAuthenticationKey by calling from_dict on the json representation - gateway_template_gateway_type_dedicated_template_authentication_key_model = GatewayTemplateGatewayTypeDedicatedTemplateAuthenticationKey.from_dict(gateway_template_gateway_type_dedicated_template_authentication_key_model_json) - assert gateway_template_gateway_type_dedicated_template_authentication_key_model != False - - # Construct a model instance of GatewayTemplateGatewayTypeDedicatedTemplateAuthenticationKey by calling from_dict on the json representation - gateway_template_gateway_type_dedicated_template_authentication_key_model_dict = GatewayTemplateGatewayTypeDedicatedTemplateAuthenticationKey.from_dict(gateway_template_gateway_type_dedicated_template_authentication_key_model_json).__dict__ - gateway_template_gateway_type_dedicated_template_authentication_key_model2 = GatewayTemplateGatewayTypeDedicatedTemplateAuthenticationKey(**gateway_template_gateway_type_dedicated_template_authentication_key_model_dict) - - # Verify the model instances are equivalent - assert gateway_template_gateway_type_dedicated_template_authentication_key_model == gateway_template_gateway_type_dedicated_template_authentication_key_model2 - - # Convert model instance back to dict and verify no loss of data - gateway_template_gateway_type_dedicated_template_authentication_key_model_json2 = gateway_template_gateway_type_dedicated_template_authentication_key_model.to_dict() - assert gateway_template_gateway_type_dedicated_template_authentication_key_model_json2 == gateway_template_gateway_type_dedicated_template_authentication_key_model_json - -#----------------------------------------------------------------------------- -# Test Class for GatewayVirtualConnection -#----------------------------------------------------------------------------- -class TestGatewayVirtualConnection(): - - #-------------------------------------------------------- - # Test serialization/deserialization for GatewayVirtualConnection - #-------------------------------------------------------- def test_gateway_virtual_connection_serialization(self): + """ + Test serialization/deserialization for GatewayVirtualConnection + """ # Construct a json representation of a GatewayVirtualConnection model gateway_virtual_connection_model_json = {} - gateway_virtual_connection_model_json['created_at'] = '2020-01-28T18:40:40.123456Z' + gateway_virtual_connection_model_json['created_at'] = "2019-01-01T12:00:00Z" gateway_virtual_connection_model_json['id'] = 'ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4' gateway_virtual_connection_model_json['name'] = 'newVC' gateway_virtual_connection_model_json['network_account'] = '00aa14a2e0fb102c8995ebefff865555' @@ -2496,20 +3548,20 @@ def test_gateway_virtual_connection_serialization(self): gateway_virtual_connection_model_json2 = gateway_virtual_connection_model.to_dict() assert gateway_virtual_connection_model_json2 == gateway_virtual_connection_model_json -#----------------------------------------------------------------------------- -# Test Class for GatewayVirtualConnectionCollection -#----------------------------------------------------------------------------- -class TestGatewayVirtualConnectionCollection(): +class TestModel_GatewayVirtualConnectionCollection(): + """ + Test Class for GatewayVirtualConnectionCollection + """ - #-------------------------------------------------------- - # Test serialization/deserialization for GatewayVirtualConnectionCollection - #-------------------------------------------------------- def test_gateway_virtual_connection_collection_serialization(self): + """ + Test serialization/deserialization for GatewayVirtualConnectionCollection + """ # Construct dict forms of any model objects needed in order to build this model. gateway_virtual_connection_model = {} # GatewayVirtualConnection - gateway_virtual_connection_model['created_at'] = '2020-01-28T18:40:40.123456Z' + gateway_virtual_connection_model['created_at'] = "2019-01-01T12:00:00Z" gateway_virtual_connection_model['id'] = 'ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4' gateway_virtual_connection_model['name'] = 'newVC' gateway_virtual_connection_model['network_account'] = '00aa14a2e0fb102c8995ebefff865555' @@ -2536,15 +3588,15 @@ def test_gateway_virtual_connection_collection_serialization(self): gateway_virtual_connection_collection_model_json2 = gateway_virtual_connection_collection_model.to_dict() assert gateway_virtual_connection_collection_model_json2 == gateway_virtual_connection_collection_model_json -#----------------------------------------------------------------------------- -# Test Class for LocationCollection -#----------------------------------------------------------------------------- -class TestLocationCollection(): +class TestModel_LocationCollection(): + """ + Test Class for LocationCollection + """ - #-------------------------------------------------------- - # Test serialization/deserialization for LocationCollection - #-------------------------------------------------------- def test_location_collection_serialization(self): + """ + Test serialization/deserialization for LocationCollection + """ # Construct dict forms of any model objects needed in order to build this model. @@ -2581,20 +3633,20 @@ def test_location_collection_serialization(self): location_collection_model_json2 = location_collection_model.to_dict() assert location_collection_model_json2 == location_collection_model_json -#----------------------------------------------------------------------------- -# Test Class for LocationCrossConnectRouterCollection -#----------------------------------------------------------------------------- -class TestLocationCrossConnectRouterCollection(): +class TestModel_LocationCrossConnectRouterCollection(): + """ + Test Class for LocationCrossConnectRouterCollection + """ - #-------------------------------------------------------- - # Test serialization/deserialization for LocationCrossConnectRouterCollection - #-------------------------------------------------------- def test_location_cross_connect_router_collection_serialization(self): + """ + Test serialization/deserialization for LocationCrossConnectRouterCollection + """ # Construct dict forms of any model objects needed in order to build this model. cross_connect_router_model = {} # CrossConnectRouter - cross_connect_router_model['capabilities'] = ['testString'] + cross_connect_router_model['capabilities'] = ['non_macsec', 'macsec'] cross_connect_router_model['router_name'] = 'xcr01.dal03' cross_connect_router_model['total_connections'] = 1 @@ -2617,15 +3669,15 @@ def test_location_cross_connect_router_collection_serialization(self): location_cross_connect_router_collection_model_json2 = location_cross_connect_router_collection_model.to_dict() assert location_cross_connect_router_collection_model_json2 == location_cross_connect_router_collection_model_json -#----------------------------------------------------------------------------- -# Test Class for LocationOutput -#----------------------------------------------------------------------------- -class TestLocationOutput(): +class TestModel_LocationOutput(): + """ + Test Class for LocationOutput + """ - #-------------------------------------------------------- - # Test serialization/deserialization for LocationOutput - #-------------------------------------------------------- def test_location_output_serialization(self): + """ + Test serialization/deserialization for LocationOutput + """ # Construct a json representation of a LocationOutput model location_output_model_json = {} @@ -2657,19 +3709,19 @@ def test_location_output_serialization(self): location_output_model_json2 = location_output_model.to_dict() assert location_output_model_json2 == location_output_model_json -#----------------------------------------------------------------------------- -# Test Class for OfferingSpeed -#----------------------------------------------------------------------------- -class TestOfferingSpeed(): +class TestModel_OfferingSpeed(): + """ + Test Class for OfferingSpeed + """ - #-------------------------------------------------------- - # Test serialization/deserialization for OfferingSpeed - #-------------------------------------------------------- def test_offering_speed_serialization(self): + """ + Test serialization/deserialization for OfferingSpeed + """ # Construct a json representation of a OfferingSpeed model offering_speed_model_json = {} - offering_speed_model_json['capabilities'] = ['testString'] + offering_speed_model_json['capabilities'] = ['metered', 'unmetered'] offering_speed_model_json['link_speed'] = 2000 offering_speed_model_json['macsec_enabled'] = False @@ -2688,20 +3740,20 @@ def test_offering_speed_serialization(self): offering_speed_model_json2 = offering_speed_model.to_dict() assert offering_speed_model_json2 == offering_speed_model_json -#----------------------------------------------------------------------------- -# Test Class for OfferingSpeedCollection -#----------------------------------------------------------------------------- -class TestOfferingSpeedCollection(): +class TestModel_OfferingSpeedCollection(): + """ + Test Class for OfferingSpeedCollection + """ - #-------------------------------------------------------- - # Test serialization/deserialization for OfferingSpeedCollection - #-------------------------------------------------------- def test_offering_speed_collection_serialization(self): + """ + Test serialization/deserialization for OfferingSpeedCollection + """ # Construct dict forms of any model objects needed in order to build this model. offering_speed_model = {} # OfferingSpeed - offering_speed_model['capabilities'] = ['testString'] + offering_speed_model['capabilities'] = ['metered', 'unmetered'] offering_speed_model['link_speed'] = 2000 offering_speed_model['macsec_enabled'] = False @@ -2724,15 +3776,15 @@ def test_offering_speed_collection_serialization(self): offering_speed_collection_model_json2 = offering_speed_collection_model.to_dict() assert offering_speed_collection_model_json2 == offering_speed_collection_model_json -#----------------------------------------------------------------------------- -# Test Class for Port -#----------------------------------------------------------------------------- -class TestPort(): +class TestModel_Port(): + """ + Test Class for Port + """ - #-------------------------------------------------------- - # Test serialization/deserialization for Port - #-------------------------------------------------------- def test_port_serialization(self): + """ + Test serialization/deserialization for Port + """ # Construct a json representation of a Port model port_model_json = {} @@ -2742,7 +3794,7 @@ def test_port_serialization(self): port_model_json['location_display_name'] = 'Dallas 03' port_model_json['location_name'] = 'dal03' port_model_json['provider_name'] = 'provider_1' - port_model_json['supported_link_speeds'] = [38] + port_model_json['supported_link_speeds'] = [1000, 2000, 5000, 10000] # Construct a model instance of Port by calling from_dict on the json representation port_model = Port.from_dict(port_model_json) @@ -2759,18 +3811,25 @@ def test_port_serialization(self): port_model_json2 = port_model.to_dict() assert port_model_json2 == port_model_json -#----------------------------------------------------------------------------- -# Test Class for PortCollection -#----------------------------------------------------------------------------- -class TestPortCollection(): +class TestModel_PortCollection(): + """ + Test Class for PortCollection + """ - #-------------------------------------------------------- - # Test serialization/deserialization for PortCollection - #-------------------------------------------------------- def test_port_collection_serialization(self): + """ + Test serialization/deserialization for PortCollection + """ # Construct dict forms of any model objects needed in order to build this model. + ports_paginated_collection_first_model = {} # PortsPaginatedCollectionFirst + ports_paginated_collection_first_model['href'] = 'https://directlink.cloud.ibm.com/v1/ports?limit=100' + + ports_paginated_collection_next_model = {} # PortsPaginatedCollectionNext + ports_paginated_collection_next_model['href'] = 'https://directlink.cloud.ibm.com/v1/ports?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=100' + ports_paginated_collection_next_model['start'] = '9d5a91a3e2cbd233b5a5b33436855ed1' + port_model = {} # Port port_model['direct_link_count'] = 1 port_model['id'] = '01122b9b-820f-4c44-8a31-77f1f0806765' @@ -2778,14 +3837,7 @@ def test_port_collection_serialization(self): port_model['location_display_name'] = 'Dallas 03' port_model['location_name'] = 'dal03' port_model['provider_name'] = 'provider_1' - port_model['supported_link_speeds'] = [38] - - ports_paginated_collection_first_model = {} # PortsPaginatedCollectionFirst - ports_paginated_collection_first_model['href'] = 'https://directlink.cloud.ibm.com/v1/ports?limit=100' - - ports_paginated_collection_next_model = {} # PortsPaginatedCollectionNext - ports_paginated_collection_next_model['href'] = 'https://directlink.cloud.ibm.com/v1/ports?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=100' - ports_paginated_collection_next_model['start'] = '9d5a91a3e2cbd233b5a5b33436855ed1' + port_model['supported_link_speeds'] = [1000, 2000, 5000, 10000] # Construct a json representation of a PortCollection model port_collection_model_json = {} @@ -2810,15 +3862,15 @@ def test_port_collection_serialization(self): port_collection_model_json2 = port_collection_model.to_dict() assert port_collection_model_json2 == port_collection_model_json -#----------------------------------------------------------------------------- -# Test Class for PortsPaginatedCollectionFirst -#----------------------------------------------------------------------------- -class TestPortsPaginatedCollectionFirst(): +class TestModel_PortsPaginatedCollectionFirst(): + """ + Test Class for PortsPaginatedCollectionFirst + """ - #-------------------------------------------------------- - # Test serialization/deserialization for PortsPaginatedCollectionFirst - #-------------------------------------------------------- def test_ports_paginated_collection_first_serialization(self): + """ + Test serialization/deserialization for PortsPaginatedCollectionFirst + """ # Construct a json representation of a PortsPaginatedCollectionFirst model ports_paginated_collection_first_model_json = {} @@ -2839,15 +3891,15 @@ def test_ports_paginated_collection_first_serialization(self): ports_paginated_collection_first_model_json2 = ports_paginated_collection_first_model.to_dict() assert ports_paginated_collection_first_model_json2 == ports_paginated_collection_first_model_json -#----------------------------------------------------------------------------- -# Test Class for PortsPaginatedCollectionNext -#----------------------------------------------------------------------------- -class TestPortsPaginatedCollectionNext(): +class TestModel_PortsPaginatedCollectionNext(): + """ + Test Class for PortsPaginatedCollectionNext + """ - #-------------------------------------------------------- - # Test serialization/deserialization for PortsPaginatedCollectionNext - #-------------------------------------------------------- def test_ports_paginated_collection_next_serialization(self): + """ + Test serialization/deserialization for PortsPaginatedCollectionNext + """ # Construct a json representation of a PortsPaginatedCollectionNext model ports_paginated_collection_next_model_json = {} @@ -2869,15 +3921,15 @@ def test_ports_paginated_collection_next_serialization(self): ports_paginated_collection_next_model_json2 = ports_paginated_collection_next_model.to_dict() assert ports_paginated_collection_next_model_json2 == ports_paginated_collection_next_model_json -#----------------------------------------------------------------------------- -# Test Class for ResourceGroupIdentity -#----------------------------------------------------------------------------- -class TestResourceGroupIdentity(): +class TestModel_ResourceGroupIdentity(): + """ + Test Class for ResourceGroupIdentity + """ - #-------------------------------------------------------- - # Test serialization/deserialization for ResourceGroupIdentity - #-------------------------------------------------------- def test_resource_group_identity_serialization(self): + """ + Test serialization/deserialization for ResourceGroupIdentity + """ # Construct a json representation of a ResourceGroupIdentity model resource_group_identity_model_json = {} @@ -2898,15 +3950,15 @@ def test_resource_group_identity_serialization(self): resource_group_identity_model_json2 = resource_group_identity_model.to_dict() assert resource_group_identity_model_json2 == resource_group_identity_model_json -#----------------------------------------------------------------------------- -# Test Class for ResourceGroupReference -#----------------------------------------------------------------------------- -class TestResourceGroupReference(): +class TestModel_ResourceGroupReference(): + """ + Test Class for ResourceGroupReference + """ - #-------------------------------------------------------- - # Test serialization/deserialization for ResourceGroupReference - #-------------------------------------------------------- def test_resource_group_reference_serialization(self): + """ + Test serialization/deserialization for ResourceGroupReference + """ # Construct a json representation of a ResourceGroupReference model resource_group_reference_model_json = {} @@ -2927,15 +3979,191 @@ def test_resource_group_reference_serialization(self): resource_group_reference_model_json2 = resource_group_reference_model.to_dict() assert resource_group_reference_model_json2 == resource_group_reference_model_json -#----------------------------------------------------------------------------- -# Test Class for GatewayChangeRequestGatewayClientGatewayCreate -#----------------------------------------------------------------------------- -class TestGatewayChangeRequestGatewayClientGatewayCreate(): +class TestModel_GatewayActionTemplateUpdatesItemGatewayClientBGPASNUpdate(): + """ + Test Class for GatewayActionTemplateUpdatesItemGatewayClientBGPASNUpdate + """ + + def test_gateway_action_template_updates_item_gateway_client_bgpasn_update_serialization(self): + """ + Test serialization/deserialization for GatewayActionTemplateUpdatesItemGatewayClientBGPASNUpdate + """ + + # Construct a json representation of a GatewayActionTemplateUpdatesItemGatewayClientBGPASNUpdate model + gateway_action_template_updates_item_gateway_client_bgpasn_update_model_json = {} + gateway_action_template_updates_item_gateway_client_bgpasn_update_model_json['bgp_asn'] = 64999 + + # Construct a model instance of GatewayActionTemplateUpdatesItemGatewayClientBGPASNUpdate by calling from_dict on the json representation + gateway_action_template_updates_item_gateway_client_bgpasn_update_model = GatewayActionTemplateUpdatesItemGatewayClientBGPASNUpdate.from_dict(gateway_action_template_updates_item_gateway_client_bgpasn_update_model_json) + assert gateway_action_template_updates_item_gateway_client_bgpasn_update_model != False + + # Construct a model instance of GatewayActionTemplateUpdatesItemGatewayClientBGPASNUpdate by calling from_dict on the json representation + gateway_action_template_updates_item_gateway_client_bgpasn_update_model_dict = GatewayActionTemplateUpdatesItemGatewayClientBGPASNUpdate.from_dict(gateway_action_template_updates_item_gateway_client_bgpasn_update_model_json).__dict__ + gateway_action_template_updates_item_gateway_client_bgpasn_update_model2 = GatewayActionTemplateUpdatesItemGatewayClientBGPASNUpdate(**gateway_action_template_updates_item_gateway_client_bgpasn_update_model_dict) + + # Verify the model instances are equivalent + assert gateway_action_template_updates_item_gateway_client_bgpasn_update_model == gateway_action_template_updates_item_gateway_client_bgpasn_update_model2 + + # Convert model instance back to dict and verify no loss of data + gateway_action_template_updates_item_gateway_client_bgpasn_update_model_json2 = gateway_action_template_updates_item_gateway_client_bgpasn_update_model.to_dict() + assert gateway_action_template_updates_item_gateway_client_bgpasn_update_model_json2 == gateway_action_template_updates_item_gateway_client_bgpasn_update_model_json + +class TestModel_GatewayActionTemplateUpdatesItemGatewayClientBGPIPUpdate(): + """ + Test Class for GatewayActionTemplateUpdatesItemGatewayClientBGPIPUpdate + """ + + def test_gateway_action_template_updates_item_gateway_client_bgpip_update_serialization(self): + """ + Test serialization/deserialization for GatewayActionTemplateUpdatesItemGatewayClientBGPIPUpdate + """ + + # Construct a json representation of a GatewayActionTemplateUpdatesItemGatewayClientBGPIPUpdate model + gateway_action_template_updates_item_gateway_client_bgpip_update_model_json = {} + gateway_action_template_updates_item_gateway_client_bgpip_update_model_json['bgp_cer_cidr'] = '169.254.0.10/30' + gateway_action_template_updates_item_gateway_client_bgpip_update_model_json['bgp_ibm_cidr'] = '169.254.0.9/30' + + # Construct a model instance of GatewayActionTemplateUpdatesItemGatewayClientBGPIPUpdate by calling from_dict on the json representation + gateway_action_template_updates_item_gateway_client_bgpip_update_model = GatewayActionTemplateUpdatesItemGatewayClientBGPIPUpdate.from_dict(gateway_action_template_updates_item_gateway_client_bgpip_update_model_json) + assert gateway_action_template_updates_item_gateway_client_bgpip_update_model != False + + # Construct a model instance of GatewayActionTemplateUpdatesItemGatewayClientBGPIPUpdate by calling from_dict on the json representation + gateway_action_template_updates_item_gateway_client_bgpip_update_model_dict = GatewayActionTemplateUpdatesItemGatewayClientBGPIPUpdate.from_dict(gateway_action_template_updates_item_gateway_client_bgpip_update_model_json).__dict__ + gateway_action_template_updates_item_gateway_client_bgpip_update_model2 = GatewayActionTemplateUpdatesItemGatewayClientBGPIPUpdate(**gateway_action_template_updates_item_gateway_client_bgpip_update_model_dict) + + # Verify the model instances are equivalent + assert gateway_action_template_updates_item_gateway_client_bgpip_update_model == gateway_action_template_updates_item_gateway_client_bgpip_update_model2 + + # Convert model instance back to dict and verify no loss of data + gateway_action_template_updates_item_gateway_client_bgpip_update_model_json2 = gateway_action_template_updates_item_gateway_client_bgpip_update_model.to_dict() + assert gateway_action_template_updates_item_gateway_client_bgpip_update_model_json2 == gateway_action_template_updates_item_gateway_client_bgpip_update_model_json + +class TestModel_GatewayActionTemplateUpdatesItemGatewayClientSpeedUpdate(): + """ + Test Class for GatewayActionTemplateUpdatesItemGatewayClientSpeedUpdate + """ + + def test_gateway_action_template_updates_item_gateway_client_speed_update_serialization(self): + """ + Test serialization/deserialization for GatewayActionTemplateUpdatesItemGatewayClientSpeedUpdate + """ + + # Construct a json representation of a GatewayActionTemplateUpdatesItemGatewayClientSpeedUpdate model + gateway_action_template_updates_item_gateway_client_speed_update_model_json = {} + gateway_action_template_updates_item_gateway_client_speed_update_model_json['speed_mbps'] = 500 + + # Construct a model instance of GatewayActionTemplateUpdatesItemGatewayClientSpeedUpdate by calling from_dict on the json representation + gateway_action_template_updates_item_gateway_client_speed_update_model = GatewayActionTemplateUpdatesItemGatewayClientSpeedUpdate.from_dict(gateway_action_template_updates_item_gateway_client_speed_update_model_json) + assert gateway_action_template_updates_item_gateway_client_speed_update_model != False + + # Construct a model instance of GatewayActionTemplateUpdatesItemGatewayClientSpeedUpdate by calling from_dict on the json representation + gateway_action_template_updates_item_gateway_client_speed_update_model_dict = GatewayActionTemplateUpdatesItemGatewayClientSpeedUpdate.from_dict(gateway_action_template_updates_item_gateway_client_speed_update_model_json).__dict__ + gateway_action_template_updates_item_gateway_client_speed_update_model2 = GatewayActionTemplateUpdatesItemGatewayClientSpeedUpdate(**gateway_action_template_updates_item_gateway_client_speed_update_model_dict) + + # Verify the model instances are equivalent + assert gateway_action_template_updates_item_gateway_client_speed_update_model == gateway_action_template_updates_item_gateway_client_speed_update_model2 + + # Convert model instance back to dict and verify no loss of data + gateway_action_template_updates_item_gateway_client_speed_update_model_json2 = gateway_action_template_updates_item_gateway_client_speed_update_model.to_dict() + assert gateway_action_template_updates_item_gateway_client_speed_update_model_json2 == gateway_action_template_updates_item_gateway_client_speed_update_model_json + +class TestModel_GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPASNUpdate(): + """ + Test Class for GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPASNUpdate + """ + + def test_gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_bgpasn_update_serialization(self): + """ + Test serialization/deserialization for GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPASNUpdate + """ + + # Construct a json representation of a GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPASNUpdate model + gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_bgpasn_update_model_json = {} + gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_bgpasn_update_model_json['bgp_asn'] = 64999 + + # Construct a model instance of GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPASNUpdate by calling from_dict on the json representation + gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_bgpasn_update_model = GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPASNUpdate.from_dict(gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_bgpasn_update_model_json) + assert gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_bgpasn_update_model != False + + # Construct a model instance of GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPASNUpdate by calling from_dict on the json representation + gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_bgpasn_update_model_dict = GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPASNUpdate.from_dict(gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_bgpasn_update_model_json).__dict__ + gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_bgpasn_update_model2 = GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPASNUpdate(**gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_bgpasn_update_model_dict) + + # Verify the model instances are equivalent + assert gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_bgpasn_update_model == gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_bgpasn_update_model2 + + # Convert model instance back to dict and verify no loss of data + gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_bgpasn_update_model_json2 = gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_bgpasn_update_model.to_dict() + assert gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_bgpasn_update_model_json2 == gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_bgpasn_update_model_json + +class TestModel_GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPIPUpdate(): + """ + Test Class for GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPIPUpdate + """ + + def test_gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_bgpip_update_serialization(self): + """ + Test serialization/deserialization for GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPIPUpdate + """ + + # Construct a json representation of a GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPIPUpdate model + gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_bgpip_update_model_json = {} + gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_bgpip_update_model_json['bgp_cer_cidr'] = '169.254.0.10/30' + gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_bgpip_update_model_json['bgp_ibm_cidr'] = '169.254.0.9/30' + + # Construct a model instance of GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPIPUpdate by calling from_dict on the json representation + gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_bgpip_update_model = GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPIPUpdate.from_dict(gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_bgpip_update_model_json) + assert gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_bgpip_update_model != False + + # Construct a model instance of GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPIPUpdate by calling from_dict on the json representation + gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_bgpip_update_model_dict = GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPIPUpdate.from_dict(gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_bgpip_update_model_json).__dict__ + gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_bgpip_update_model2 = GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPIPUpdate(**gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_bgpip_update_model_dict) + + # Verify the model instances are equivalent + assert gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_bgpip_update_model == gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_bgpip_update_model2 + + # Convert model instance back to dict and verify no loss of data + gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_bgpip_update_model_json2 = gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_bgpip_update_model.to_dict() + assert gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_bgpip_update_model_json2 == gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_bgpip_update_model_json + +class TestModel_GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientSpeedUpdate(): + """ + Test Class for GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientSpeedUpdate + """ + + def test_gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_speed_update_serialization(self): + """ + Test serialization/deserialization for GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientSpeedUpdate + """ + + # Construct a json representation of a GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientSpeedUpdate model + gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_speed_update_model_json = {} + gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_speed_update_model_json['speed_mbps'] = 500 + + # Construct a model instance of GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientSpeedUpdate by calling from_dict on the json representation + gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_speed_update_model = GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientSpeedUpdate.from_dict(gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_speed_update_model_json) + assert gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_speed_update_model != False + + # Construct a model instance of GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientSpeedUpdate by calling from_dict on the json representation + gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_speed_update_model_dict = GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientSpeedUpdate.from_dict(gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_speed_update_model_json).__dict__ + gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_speed_update_model2 = GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientSpeedUpdate(**gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_speed_update_model_dict) + + # Verify the model instances are equivalent + assert gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_speed_update_model == gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_speed_update_model2 + + # Convert model instance back to dict and verify no loss of data + gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_speed_update_model_json2 = gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_speed_update_model.to_dict() + assert gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_speed_update_model_json2 == gateway_change_request_gateway_client_gateway_update_attributes_updates_item_gateway_client_speed_update_model_json + +class TestModel_GatewayChangeRequestGatewayClientGatewayCreate(): + """ + Test Class for GatewayChangeRequestGatewayClientGatewayCreate + """ - #-------------------------------------------------------- - # Test serialization/deserialization for GatewayChangeRequestGatewayClientGatewayCreate - #-------------------------------------------------------- def test_gateway_change_request_gateway_client_gateway_create_serialization(self): + """ + Test serialization/deserialization for GatewayChangeRequestGatewayClientGatewayCreate + """ # Construct a json representation of a GatewayChangeRequestGatewayClientGatewayCreate model gateway_change_request_gateway_client_gateway_create_model_json = {} @@ -2956,15 +4184,15 @@ def test_gateway_change_request_gateway_client_gateway_create_serialization(self gateway_change_request_gateway_client_gateway_create_model_json2 = gateway_change_request_gateway_client_gateway_create_model.to_dict() assert gateway_change_request_gateway_client_gateway_create_model_json2 == gateway_change_request_gateway_client_gateway_create_model_json -#----------------------------------------------------------------------------- -# Test Class for GatewayChangeRequestGatewayClientGatewayDelete -#----------------------------------------------------------------------------- -class TestGatewayChangeRequestGatewayClientGatewayDelete(): +class TestModel_GatewayChangeRequestGatewayClientGatewayDelete(): + """ + Test Class for GatewayChangeRequestGatewayClientGatewayDelete + """ - #-------------------------------------------------------- - # Test serialization/deserialization for GatewayChangeRequestGatewayClientGatewayDelete - #-------------------------------------------------------- def test_gateway_change_request_gateway_client_gateway_delete_serialization(self): + """ + Test serialization/deserialization for GatewayChangeRequestGatewayClientGatewayDelete + """ # Construct a json representation of a GatewayChangeRequestGatewayClientGatewayDelete model gateway_change_request_gateway_client_gateway_delete_model_json = {} @@ -2985,20 +4213,25 @@ def test_gateway_change_request_gateway_client_gateway_delete_serialization(self gateway_change_request_gateway_client_gateway_delete_model_json2 = gateway_change_request_gateway_client_gateway_delete_model.to_dict() assert gateway_change_request_gateway_client_gateway_delete_model_json2 == gateway_change_request_gateway_client_gateway_delete_model_json -#----------------------------------------------------------------------------- -# Test Class for GatewayChangeRequestGatewayClientGatewayUpdateAttributes -#----------------------------------------------------------------------------- -class TestGatewayChangeRequestGatewayClientGatewayUpdateAttributes(): +class TestModel_GatewayChangeRequestGatewayClientGatewayUpdateAttributes(): + """ + Test Class for GatewayChangeRequestGatewayClientGatewayUpdateAttributes + """ - #-------------------------------------------------------- - # Test serialization/deserialization for GatewayChangeRequestGatewayClientGatewayUpdateAttributes - #-------------------------------------------------------- def test_gateway_change_request_gateway_client_gateway_update_attributes_serialization(self): + """ + Test serialization/deserialization for GatewayChangeRequestGatewayClientGatewayUpdateAttributes + """ + + # Construct dict forms of any model objects needed in order to build this model. + + gateway_change_request_gateway_client_gateway_update_attributes_updates_item_model = {} # GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientSpeedUpdate + gateway_change_request_gateway_client_gateway_update_attributes_updates_item_model['speed_mbps'] = 500 # Construct a json representation of a GatewayChangeRequestGatewayClientGatewayUpdateAttributes model gateway_change_request_gateway_client_gateway_update_attributes_model_json = {} gateway_change_request_gateway_client_gateway_update_attributes_model_json['type'] = 'update_attributes' - gateway_change_request_gateway_client_gateway_update_attributes_model_json['updates'] = [{ 'foo': 'bar' }] + gateway_change_request_gateway_client_gateway_update_attributes_model_json['updates'] = [gateway_change_request_gateway_client_gateway_update_attributes_updates_item_model] # Construct a model instance of GatewayChangeRequestGatewayClientGatewayUpdateAttributes by calling from_dict on the json representation gateway_change_request_gateway_client_gateway_update_attributes_model = GatewayChangeRequestGatewayClientGatewayUpdateAttributes.from_dict(gateway_change_request_gateway_client_gateway_update_attributes_model_json) @@ -3015,30 +4248,128 @@ def test_gateway_change_request_gateway_client_gateway_update_attributes_seriali gateway_change_request_gateway_client_gateway_update_attributes_model_json2 = gateway_change_request_gateway_client_gateway_update_attributes_model.to_dict() assert gateway_change_request_gateway_client_gateway_update_attributes_model_json2 == gateway_change_request_gateway_client_gateway_update_attributes_model_json -#----------------------------------------------------------------------------- -# Test Class for GatewayTemplateGatewayTypeConnectTemplate -#----------------------------------------------------------------------------- -class TestGatewayTemplateGatewayTypeConnectTemplate(): +class TestModel_GatewayStatusGatewayBFDStatus(): + """ + Test Class for GatewayStatusGatewayBFDStatus + """ + + def test_gateway_status_gateway_bfd_status_serialization(self): + """ + Test serialization/deserialization for GatewayStatusGatewayBFDStatus + """ + + # Construct a json representation of a GatewayStatusGatewayBFDStatus model + gateway_status_gateway_bfd_status_model_json = {} + gateway_status_gateway_bfd_status_model_json['type'] = 'bfd' + gateway_status_gateway_bfd_status_model_json['updated_at'] = "2020-08-20T06:58:41.909000Z" + gateway_status_gateway_bfd_status_model_json['value'] = 'up' + + # Construct a model instance of GatewayStatusGatewayBFDStatus by calling from_dict on the json representation + gateway_status_gateway_bfd_status_model = GatewayStatusGatewayBFDStatus.from_dict(gateway_status_gateway_bfd_status_model_json) + assert gateway_status_gateway_bfd_status_model != False + + # Construct a model instance of GatewayStatusGatewayBFDStatus by calling from_dict on the json representation + gateway_status_gateway_bfd_status_model_dict = GatewayStatusGatewayBFDStatus.from_dict(gateway_status_gateway_bfd_status_model_json).__dict__ + gateway_status_gateway_bfd_status_model2 = GatewayStatusGatewayBFDStatus(**gateway_status_gateway_bfd_status_model_dict) + + # Verify the model instances are equivalent + assert gateway_status_gateway_bfd_status_model == gateway_status_gateway_bfd_status_model2 + + # Convert model instance back to dict and verify no loss of data + gateway_status_gateway_bfd_status_model_json2 = gateway_status_gateway_bfd_status_model.to_dict() + assert gateway_status_gateway_bfd_status_model_json2 == gateway_status_gateway_bfd_status_model_json + +class TestModel_GatewayStatusGatewayBGPStatus(): + """ + Test Class for GatewayStatusGatewayBGPStatus + """ + + def test_gateway_status_gateway_bgp_status_serialization(self): + """ + Test serialization/deserialization for GatewayStatusGatewayBGPStatus + """ + + # Construct a json representation of a GatewayStatusGatewayBGPStatus model + gateway_status_gateway_bgp_status_model_json = {} + gateway_status_gateway_bgp_status_model_json['type'] = 'bgp' + gateway_status_gateway_bgp_status_model_json['updated_at'] = "2020-08-20T06:58:41.909000Z" + gateway_status_gateway_bgp_status_model_json['value'] = 'active' + + # Construct a model instance of GatewayStatusGatewayBGPStatus by calling from_dict on the json representation + gateway_status_gateway_bgp_status_model = GatewayStatusGatewayBGPStatus.from_dict(gateway_status_gateway_bgp_status_model_json) + assert gateway_status_gateway_bgp_status_model != False + + # Construct a model instance of GatewayStatusGatewayBGPStatus by calling from_dict on the json representation + gateway_status_gateway_bgp_status_model_dict = GatewayStatusGatewayBGPStatus.from_dict(gateway_status_gateway_bgp_status_model_json).__dict__ + gateway_status_gateway_bgp_status_model2 = GatewayStatusGatewayBGPStatus(**gateway_status_gateway_bgp_status_model_dict) + + # Verify the model instances are equivalent + assert gateway_status_gateway_bgp_status_model == gateway_status_gateway_bgp_status_model2 + + # Convert model instance back to dict and verify no loss of data + gateway_status_gateway_bgp_status_model_json2 = gateway_status_gateway_bgp_status_model.to_dict() + assert gateway_status_gateway_bgp_status_model_json2 == gateway_status_gateway_bgp_status_model_json + +class TestModel_GatewayStatusGatewayLinkStatus(): + """ + Test Class for GatewayStatusGatewayLinkStatus + """ + + def test_gateway_status_gateway_link_status_serialization(self): + """ + Test serialization/deserialization for GatewayStatusGatewayLinkStatus + """ + + # Construct a json representation of a GatewayStatusGatewayLinkStatus model + gateway_status_gateway_link_status_model_json = {} + gateway_status_gateway_link_status_model_json['type'] = 'link' + gateway_status_gateway_link_status_model_json['updated_at'] = "2020-08-20T06:58:41.909000Z" + gateway_status_gateway_link_status_model_json['value'] = 'up' + + # Construct a model instance of GatewayStatusGatewayLinkStatus by calling from_dict on the json representation + gateway_status_gateway_link_status_model = GatewayStatusGatewayLinkStatus.from_dict(gateway_status_gateway_link_status_model_json) + assert gateway_status_gateway_link_status_model != False + + # Construct a model instance of GatewayStatusGatewayLinkStatus by calling from_dict on the json representation + gateway_status_gateway_link_status_model_dict = GatewayStatusGatewayLinkStatus.from_dict(gateway_status_gateway_link_status_model_json).__dict__ + gateway_status_gateway_link_status_model2 = GatewayStatusGatewayLinkStatus(**gateway_status_gateway_link_status_model_dict) + + # Verify the model instances are equivalent + assert gateway_status_gateway_link_status_model == gateway_status_gateway_link_status_model2 + + # Convert model instance back to dict and verify no loss of data + gateway_status_gateway_link_status_model_json2 = gateway_status_gateway_link_status_model.to_dict() + assert gateway_status_gateway_link_status_model_json2 == gateway_status_gateway_link_status_model_json + +class TestModel_GatewayTemplateGatewayTypeConnectTemplate(): + """ + Test Class for GatewayTemplateGatewayTypeConnectTemplate + """ - #-------------------------------------------------------- - # Test serialization/deserialization for GatewayTemplateGatewayTypeConnectTemplate - #-------------------------------------------------------- def test_gateway_template_gateway_type_connect_template_serialization(self): + """ + Test serialization/deserialization for GatewayTemplateGatewayTypeConnectTemplate + """ # Construct dict forms of any model objects needed in order to build this model. - gateway_port_identity_model = {} # GatewayPortIdentity - gateway_port_identity_model['id'] = 'fffdcb1a-fee4-41c7-9e11-9cd99e65c777' + gateway_template_authentication_key_model = {} # GatewayTemplateAuthenticationKey + gateway_template_authentication_key_model['crn'] = 'crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c' - gateway_template_gateway_type_connect_template_authentication_key_model = {} # GatewayTemplateGatewayTypeConnectTemplateAuthenticationKey - gateway_template_gateway_type_connect_template_authentication_key_model['crn'] = 'crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c' + gateway_bfd_config_template_model = {} # GatewayBfdConfigTemplate + gateway_bfd_config_template_model['interval'] = 2000 + gateway_bfd_config_template_model['multiplier'] = 10 resource_group_identity_model = {} # ResourceGroupIdentity resource_group_identity_model['id'] = '56969d6043e9465c883cb9f7363e78e8' + gateway_port_identity_model = {} # GatewayPortIdentity + gateway_port_identity_model['id'] = 'fffdcb1a-fee4-41c7-9e11-9cd99e65c777' + # Construct a json representation of a GatewayTemplateGatewayTypeConnectTemplate model gateway_template_gateway_type_connect_template_model_json = {} - gateway_template_gateway_type_connect_template_model_json['authentication_key'] = gateway_template_gateway_type_connect_template_authentication_key_model + gateway_template_gateway_type_connect_template_model_json['authentication_key'] = gateway_template_authentication_key_model + gateway_template_gateway_type_connect_template_model_json['bfd_config'] = gateway_bfd_config_template_model gateway_template_gateway_type_connect_template_model_json['bgp_asn'] = 64999 gateway_template_gateway_type_connect_template_model_json['bgp_base_cidr'] = 'testString' gateway_template_gateway_type_connect_template_model_json['bgp_cer_cidr'] = '169.254.0.10/30' @@ -3047,6 +4378,7 @@ def test_gateway_template_gateway_type_connect_template_serialization(self): gateway_template_gateway_type_connect_template_model_json['global'] = True gateway_template_gateway_type_connect_template_model_json['metered'] = False gateway_template_gateway_type_connect_template_model_json['name'] = 'myGateway' + gateway_template_gateway_type_connect_template_model_json['patch_panel_completion_notice'] = 'patch panel configuration details' gateway_template_gateway_type_connect_template_model_json['resource_group'] = resource_group_identity_model gateway_template_gateway_type_connect_template_model_json['speed_mbps'] = 1000 gateway_template_gateway_type_connect_template_model_json['type'] = 'dedicated' @@ -3067,18 +4399,28 @@ def test_gateway_template_gateway_type_connect_template_serialization(self): gateway_template_gateway_type_connect_template_model_json2 = gateway_template_gateway_type_connect_template_model.to_dict() assert gateway_template_gateway_type_connect_template_model_json2 == gateway_template_gateway_type_connect_template_model_json -#----------------------------------------------------------------------------- -# Test Class for GatewayTemplateGatewayTypeDedicatedTemplate -#----------------------------------------------------------------------------- -class TestGatewayTemplateGatewayTypeDedicatedTemplate(): +class TestModel_GatewayTemplateGatewayTypeDedicatedTemplate(): + """ + Test Class for GatewayTemplateGatewayTypeDedicatedTemplate + """ - #-------------------------------------------------------- - # Test serialization/deserialization for GatewayTemplateGatewayTypeDedicatedTemplate - #-------------------------------------------------------- def test_gateway_template_gateway_type_dedicated_template_serialization(self): + """ + Test serialization/deserialization for GatewayTemplateGatewayTypeDedicatedTemplate + """ # Construct dict forms of any model objects needed in order to build this model. + gateway_template_authentication_key_model = {} # GatewayTemplateAuthenticationKey + gateway_template_authentication_key_model['crn'] = 'crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c' + + gateway_bfd_config_template_model = {} # GatewayBfdConfigTemplate + gateway_bfd_config_template_model['interval'] = 2000 + gateway_bfd_config_template_model['multiplier'] = 10 + + resource_group_identity_model = {} # ResourceGroupIdentity + resource_group_identity_model['id'] = '56969d6043e9465c883cb9f7363e78e8' + gateway_macsec_config_template_fallback_cak_model = {} # GatewayMacsecConfigTemplateFallbackCak gateway_macsec_config_template_fallback_cak_model['crn'] = 'crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222' @@ -3091,15 +4433,10 @@ def test_gateway_template_gateway_type_dedicated_template_serialization(self): gateway_macsec_config_template_model['primary_cak'] = gateway_macsec_config_template_primary_cak_model gateway_macsec_config_template_model['window_size'] = 148809600 - gateway_template_gateway_type_dedicated_template_authentication_key_model = {} # GatewayTemplateGatewayTypeDedicatedTemplateAuthenticationKey - gateway_template_gateway_type_dedicated_template_authentication_key_model['crn'] = 'crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c' - - resource_group_identity_model = {} # ResourceGroupIdentity - resource_group_identity_model['id'] = '56969d6043e9465c883cb9f7363e78e8' - # Construct a json representation of a GatewayTemplateGatewayTypeDedicatedTemplate model gateway_template_gateway_type_dedicated_template_model_json = {} - gateway_template_gateway_type_dedicated_template_model_json['authentication_key'] = gateway_template_gateway_type_dedicated_template_authentication_key_model + gateway_template_gateway_type_dedicated_template_model_json['authentication_key'] = gateway_template_authentication_key_model + gateway_template_gateway_type_dedicated_template_model_json['bfd_config'] = gateway_bfd_config_template_model gateway_template_gateway_type_dedicated_template_model_json['bgp_asn'] = 64999 gateway_template_gateway_type_dedicated_template_model_json['bgp_base_cidr'] = 'testString' gateway_template_gateway_type_dedicated_template_model_json['bgp_cer_cidr'] = '169.254.0.10/30' @@ -3108,6 +4445,7 @@ def test_gateway_template_gateway_type_dedicated_template_serialization(self): gateway_template_gateway_type_dedicated_template_model_json['global'] = True gateway_template_gateway_type_dedicated_template_model_json['metered'] = False gateway_template_gateway_type_dedicated_template_model_json['name'] = 'myGateway' + gateway_template_gateway_type_dedicated_template_model_json['patch_panel_completion_notice'] = 'patch panel configuration details' gateway_template_gateway_type_dedicated_template_model_json['resource_group'] = resource_group_identity_model gateway_template_gateway_type_dedicated_template_model_json['speed_mbps'] = 1000 gateway_template_gateway_type_dedicated_template_model_json['type'] = 'dedicated'