diff --git a/ibm_cloud_networking_services/zones_settings_v1.py b/ibm_cloud_networking_services/zones_settings_v1.py index 9df78b0..8616d5f 100644 --- a/ibm_cloud_networking_services/zones_settings_v1.py +++ b/ibm_cloud_networking_services/zones_settings_v1.py @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -# IBM OpenAPI SDK Code Generator Version: 3.112.0-f88e9264-20260220-115155 +# IBM OpenAPI SDK Code Generator Version: 3.114.0-a902401e-20260427-192904 """ CIS Zones Settings @@ -3712,6 +3712,97 @@ def update_email_obfuscation( response = self.send(request, **kwargs) return response + def get_security_level( + self, + **kwargs, + ) -> DetailedResponse: + """ + Get security level setting. + + Get security level for a zone. + + :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 `SecurityLevelResp` object + """ + + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='get_security_level', + ) + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'zone_identifier'] + path_param_values = self.encode_path_vars(self.crn, self.zone_identifier) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/zones/{zone_identifier}/settings/security_level'.format(**path_param_dict) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + ) + + response = self.send(request, **kwargs) + return response + + def update_security_level( + self, + *, + value: Optional[str] = None, + **kwargs, + ) -> DetailedResponse: + """ + Update security level setting. + + Update security level setting for a zone. + + :param str value: (optional) Value. + :param dict headers: A `dict` containing the request headers + :return: A `DetailedResponse` containing the result, headers and HTTP status code. + :rtype: DetailedResponse with `dict` result representing a `SecurityLevelResp` object + """ + + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='update_security_level', + ) + headers.update(sdk_headers) + + data = { + 'value': value, + } + data = {k: v for (k, v) in data.items() if v is not None} + data = json.dumps(data) + headers['content-type'] = 'application/json' + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'zone_identifier'] + path_param_values = self.encode_path_vars(self.crn, self.zone_identifier) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/zones/{zone_identifier}/settings/security_level'.format(**path_param_dict) + request = self.prepare_request( + method='PATCH', + url=url, + headers=headers, + data=data, + ) + + response = self.send(request, **kwargs) + return response + ############################################################################## # Models @@ -4259,7 +4350,7 @@ class EmailObfuscationRespResult: :param str id: ID. :param str value: Value. :param bool editable: Editable. - :param datetime modified_on: Modified date. + :param datetime modified_on: (optional) Modified date. """ def __init__( @@ -4267,7 +4358,8 @@ def __init__( id: str, value: str, editable: bool, - modified_on: datetime, + *, + modified_on: Optional[datetime] = None, ) -> None: """ Initialize a EmailObfuscationRespResult object. @@ -4275,7 +4367,7 @@ def __init__( :param str id: ID. :param str value: Value. :param bool editable: Editable. - :param datetime modified_on: Modified date. + :param datetime modified_on: (optional) Modified date. """ self.id = id self.value = value @@ -4300,8 +4392,6 @@ def from_dict(cls, _dict: Dict) -> 'EmailObfuscationRespResult': raise ValueError('Required property \'editable\' not present in EmailObfuscationRespResult JSON') if (modified_on := _dict.get('modified_on')) is not None: args['modified_on'] = string_to_datetime(modified_on) - else: - raise ValueError('Required property \'modified_on\' not present in EmailObfuscationRespResult JSON') return cls(**args) @classmethod @@ -6480,7 +6570,7 @@ class ReplaceInsecureJsRespResult: :param str id: ID. :param str value: Value. :param bool editable: Editable. - :param datetime modified_on: Modified date. + :param datetime modified_on: (optional) Modified date. """ def __init__( @@ -6488,7 +6578,8 @@ def __init__( id: str, value: str, editable: bool, - modified_on: datetime, + *, + modified_on: Optional[datetime] = None, ) -> None: """ Initialize a ReplaceInsecureJsRespResult object. @@ -6496,7 +6587,7 @@ def __init__( :param str id: ID. :param str value: Value. :param bool editable: Editable. - :param datetime modified_on: Modified date. + :param datetime modified_on: (optional) Modified date. """ self.id = id self.value = value @@ -6521,8 +6612,6 @@ def from_dict(cls, _dict: Dict) -> 'ReplaceInsecureJsRespResult': raise ValueError('Required property \'editable\' not present in ReplaceInsecureJsRespResult JSON') if (modified_on := _dict.get('modified_on')) is not None: args['modified_on'] = string_to_datetime(modified_on) - else: - raise ValueError('Required property \'modified_on\' not present in ReplaceInsecureJsRespResult JSON') return cls(**args) @classmethod @@ -7166,6 +7255,94 @@ def __ne__(self, other: 'SecurityHeaderSettingValueStrictTransportSecurity') -> return not self == other +class SecurityLevelRespResult: + """ + Container for response information. + + :param str id: ID. + :param str value: Value. + :param bool editable: Editable. + :param datetime modified_on: (optional) Modified date. + """ + + def __init__( + self, + id: str, + value: str, + editable: bool, + *, + modified_on: Optional[datetime] = None, + ) -> None: + """ + Initialize a SecurityLevelRespResult object. + + :param str id: ID. + :param str value: Value. + :param bool editable: Editable. + :param datetime modified_on: (optional) Modified date. + """ + self.id = id + self.value = value + self.editable = editable + self.modified_on = modified_on + + @classmethod + def from_dict(cls, _dict: Dict) -> 'SecurityLevelRespResult': + """Initialize a SecurityLevelRespResult object from a json dictionary.""" + args = {} + if (id := _dict.get('id')) is not None: + args['id'] = id + else: + raise ValueError('Required property \'id\' not present in SecurityLevelRespResult JSON') + if (value := _dict.get('value')) is not None: + args['value'] = value + else: + raise ValueError('Required property \'value\' not present in SecurityLevelRespResult JSON') + if (editable := _dict.get('editable')) is not None: + args['editable'] = editable + else: + raise ValueError('Required property \'editable\' not present in SecurityLevelRespResult JSON') + if (modified_on := _dict.get('modified_on')) is not None: + args['modified_on'] = string_to_datetime(modified_on) + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a SecurityLevelRespResult object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'id') and self.id is not None: + _dict['id'] = self.id + if hasattr(self, 'value') and self.value is not None: + _dict['value'] = self.value + if hasattr(self, 'editable') and self.editable is not None: + _dict['editable'] = self.editable + if hasattr(self, 'modified_on') and self.modified_on is not None: + _dict['modified_on'] = datetime_to_string(self.modified_on) + 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 SecurityLevelRespResult object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'SecurityLevelRespResult') -> 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: 'SecurityLevelRespResult') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + class ServerSideExcludeRespResult: """ Container for response information. @@ -8594,6 +8771,7 @@ class EmailObfuscationResp: email address obfuscation response. :param EmailObfuscationRespResult result: Container for response information. + :param dict result_info: (optional) Result information. :param bool success: Was the get successful. :param List[List[str]] errors: Array of errors encountered. :param List[List[str]] messages: Array of messages returned. @@ -8605,6 +8783,8 @@ def __init__( success: bool, errors: List[List[str]], messages: List[List[str]], + *, + result_info: Optional[dict] = None, ) -> None: """ Initialize a EmailObfuscationResp object. @@ -8614,8 +8794,10 @@ def __init__( :param bool success: Was the get successful. :param List[List[str]] errors: Array of errors encountered. :param List[List[str]] messages: Array of messages returned. + :param dict result_info: (optional) Result information. """ self.result = result + self.result_info = result_info self.success = success self.errors = errors self.messages = messages @@ -8628,6 +8810,8 @@ def from_dict(cls, _dict: Dict) -> 'EmailObfuscationResp': args['result'] = EmailObfuscationRespResult.from_dict(result) else: raise ValueError('Required property \'result\' not present in EmailObfuscationResp JSON') + if (result_info := _dict.get('result_info')) is not None: + args['result_info'] = result_info if (success := _dict.get('success')) is not None: args['success'] = success else: @@ -8655,6 +8839,8 @@ def to_dict(self) -> Dict: _dict['result'] = self.result else: _dict['result'] = self.result.to_dict() + if hasattr(self, 'result_info') and self.result_info is not None: + _dict['result_info'] = self.result_info if hasattr(self, 'success') and self.success is not None: _dict['success'] = self.success if hasattr(self, 'errors') and self.errors is not None: @@ -10545,6 +10731,7 @@ class ReplaceInsecureJsResp: Replace insecure Javascript response. :param ReplaceInsecureJsRespResult result: Container for response information. + :param dict result_info: (optional) Result information. :param bool success: Was the get successful. :param List[List[str]] errors: Array of errors encountered. :param List[List[str]] messages: Array of messages returned. @@ -10556,6 +10743,8 @@ def __init__( success: bool, errors: List[List[str]], messages: List[List[str]], + *, + result_info: Optional[dict] = None, ) -> None: """ Initialize a ReplaceInsecureJsResp object. @@ -10565,8 +10754,10 @@ def __init__( :param bool success: Was the get successful. :param List[List[str]] errors: Array of errors encountered. :param List[List[str]] messages: Array of messages returned. + :param dict result_info: (optional) Result information. """ self.result = result + self.result_info = result_info self.success = success self.errors = errors self.messages = messages @@ -10579,6 +10770,8 @@ def from_dict(cls, _dict: Dict) -> 'ReplaceInsecureJsResp': args['result'] = ReplaceInsecureJsRespResult.from_dict(result) else: raise ValueError('Required property \'result\' not present in ReplaceInsecureJsResp JSON') + if (result_info := _dict.get('result_info')) is not None: + args['result_info'] = result_info if (success := _dict.get('success')) is not None: args['success'] = success else: @@ -10606,6 +10799,8 @@ def to_dict(self) -> Dict: _dict['result'] = self.result else: _dict['result'] = self.result.to_dict() + if hasattr(self, 'result_info') and self.result_info is not None: + _dict['result_info'] = self.result_info if hasattr(self, 'success') and self.success is not None: _dict['success'] = self.success if hasattr(self, 'errors') and self.errors is not None: @@ -10912,6 +11107,98 @@ def __ne__(self, other: 'SecurityHeaderResp') -> bool: return not self == other +class SecurityLevelResp: + """ + Security level response. + + :param SecurityLevelRespResult result: Container for response information. + :param bool success: Was the get successful. + :param List[List[str]] errors: Array of errors encountered. + :param List[List[str]] messages: Array of messages returned. + """ + + def __init__( + self, + result: 'SecurityLevelRespResult', + success: bool, + errors: List[List[str]], + messages: List[List[str]], + ) -> None: + """ + Initialize a SecurityLevelResp object. + + :param SecurityLevelRespResult result: Container for response information. + :param bool success: Was the get successful. + :param List[List[str]] errors: Array of errors encountered. + :param List[List[str]] messages: Array of messages returned. + """ + self.result = result + self.success = success + self.errors = errors + self.messages = messages + + @classmethod + def from_dict(cls, _dict: Dict) -> 'SecurityLevelResp': + """Initialize a SecurityLevelResp object from a json dictionary.""" + args = {} + if (result := _dict.get('result')) is not None: + args['result'] = SecurityLevelRespResult.from_dict(result) + else: + raise ValueError('Required property \'result\' not present in SecurityLevelResp JSON') + if (success := _dict.get('success')) is not None: + args['success'] = success + else: + raise ValueError('Required property \'success\' not present in SecurityLevelResp JSON') + if (errors := _dict.get('errors')) is not None: + args['errors'] = errors + else: + raise ValueError('Required property \'errors\' not present in SecurityLevelResp JSON') + if (messages := _dict.get('messages')) is not None: + args['messages'] = messages + else: + raise ValueError('Required property \'messages\' not present in SecurityLevelResp JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a SecurityLevelResp 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, 'result') and self.result is not None: + if isinstance(self.result, dict): + _dict['result'] = self.result + else: + _dict['result'] = self.result.to_dict() + if hasattr(self, 'success') and self.success is not None: + _dict['success'] = self.success + if hasattr(self, 'errors') and self.errors is not None: + _dict['errors'] = self.errors + if hasattr(self, 'messages') and self.messages is not None: + _dict['messages'] = self.messages + 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 SecurityLevelResp object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'SecurityLevelResp') -> 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: 'SecurityLevelResp') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + class ServerSideExcludeResp: """ Response of server side exclude. diff --git a/test/integration/test_zones_settings_v1.py b/test/integration/test_zones_settings_v1.py index 682bdc3..43dd500 100644 --- a/test/integration/test_zones_settings_v1.py +++ b/test/integration/test_zones_settings_v1.py @@ -646,6 +646,26 @@ def test_1_email_obfuscation_setting(self): value=self.value).get_result() assert response is not None and response.get('success') is True + def test_1_get_security_level(self): + """ test for success """ + + #Get security level + response = self.zonesSettings.get_security_level() + assert response is not None and response.get_status_code() == 200 + assert response.get_result()['result'] is not None + + def test_2_update_security_level(self): + """ test for success """ + + # Set up parameter values + value = 'medium' + + # invoke method + response = self.zonesSettings.update_security_level( + value=value + ) + assert response is not None and response.get_status_code() == 200 + assert response.get_result()['result']['value'] == value if __name__ == '__main__': unittest.main() \ No newline at end of file diff --git a/test/unit/test_zones_settings_v1.py b/test/unit/test_zones_settings_v1.py index b4c0cd5..a72c84c 100644 --- a/test/unit/test_zones_settings_v1.py +++ b/test/unit/test_zones_settings_v1.py @@ -6963,7 +6963,7 @@ def test_get_replace_insecure_js_all_params(self): """ # Set up mock url = preprocess_url('/v1/testString/zones/testString/settings/replace_insecure_js') - mock_response = '{"result": {"id": "replace_insecure_js", "value": "off", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' + mock_response = '{"result": {"id": "replace_insecure_js", "value": "off", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "result_info": {"anyKey": "anyValue"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' responses.add( responses.GET, url, @@ -6995,7 +6995,7 @@ def test_get_replace_insecure_js_value_error(self): """ # Set up mock url = preprocess_url('/v1/testString/zones/testString/settings/replace_insecure_js') - mock_response = '{"result": {"id": "replace_insecure_js", "value": "off", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' + mock_response = '{"result": {"id": "replace_insecure_js", "value": "off", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "result_info": {"anyKey": "anyValue"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' responses.add( responses.GET, url, @@ -7034,7 +7034,7 @@ def test_update_replace_insecure_js_all_params(self): """ # Set up mock url = preprocess_url('/v1/testString/zones/testString/settings/replace_insecure_js') - mock_response = '{"result": {"id": "replace_insecure_js", "value": "off", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' + mock_response = '{"result": {"id": "replace_insecure_js", "value": "off", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "result_info": {"anyKey": "anyValue"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' responses.add( responses.PATCH, url, @@ -7075,7 +7075,7 @@ def test_update_replace_insecure_js_required_params(self): """ # Set up mock url = preprocess_url('/v1/testString/zones/testString/settings/replace_insecure_js') - mock_response = '{"result": {"id": "replace_insecure_js", "value": "off", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' + mock_response = '{"result": {"id": "replace_insecure_js", "value": "off", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "result_info": {"anyKey": "anyValue"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' responses.add( responses.PATCH, url, @@ -7107,7 +7107,7 @@ def test_update_replace_insecure_js_value_error(self): """ # Set up mock url = preprocess_url('/v1/testString/zones/testString/settings/replace_insecure_js') - mock_response = '{"result": {"id": "replace_insecure_js", "value": "off", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' + mock_response = '{"result": {"id": "replace_insecure_js", "value": "off", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "result_info": {"anyKey": "anyValue"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' responses.add( responses.PATCH, url, @@ -7146,7 +7146,7 @@ def test_get_email_obfuscation_all_params(self): """ # Set up mock url = preprocess_url('/v1/testString/zones/testString/settings/email_obfuscation') - mock_response = '{"result": {"id": "email_obfuscation", "value": "off", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' + mock_response = '{"result": {"id": "email_obfuscation", "value": "off", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "result_info": {"anyKey": "anyValue"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' responses.add( responses.GET, url, @@ -7178,7 +7178,7 @@ def test_get_email_obfuscation_value_error(self): """ # Set up mock url = preprocess_url('/v1/testString/zones/testString/settings/email_obfuscation') - mock_response = '{"result": {"id": "email_obfuscation", "value": "off", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' + mock_response = '{"result": {"id": "email_obfuscation", "value": "off", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "result_info": {"anyKey": "anyValue"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' responses.add( responses.GET, url, @@ -7217,7 +7217,7 @@ def test_update_email_obfuscation_all_params(self): """ # Set up mock url = preprocess_url('/v1/testString/zones/testString/settings/email_obfuscation') - mock_response = '{"result": {"id": "email_obfuscation", "value": "off", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' + mock_response = '{"result": {"id": "email_obfuscation", "value": "off", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "result_info": {"anyKey": "anyValue"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' responses.add( responses.PATCH, url, @@ -7258,7 +7258,7 @@ def test_update_email_obfuscation_required_params(self): """ # Set up mock url = preprocess_url('/v1/testString/zones/testString/settings/email_obfuscation') - mock_response = '{"result": {"id": "email_obfuscation", "value": "off", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' + mock_response = '{"result": {"id": "email_obfuscation", "value": "off", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "result_info": {"anyKey": "anyValue"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' responses.add( responses.PATCH, url, @@ -7290,7 +7290,7 @@ def test_update_email_obfuscation_value_error(self): """ # Set up mock url = preprocess_url('/v1/testString/zones/testString/settings/email_obfuscation') - mock_response = '{"result": {"id": "email_obfuscation", "value": "off", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' + mock_response = '{"result": {"id": "email_obfuscation", "value": "off", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "result_info": {"anyKey": "anyValue"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' responses.add( responses.PATCH, url, @@ -7317,6 +7317,189 @@ def test_update_email_obfuscation_value_error_with_retries(self): self.test_update_email_obfuscation_value_error() +class TestGetSecurityLevel: + """ + Test Class for get_security_level + """ + + @responses.activate + def test_get_security_level_all_params(self): + """ + get_security_level() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/settings/security_level') + mock_response = '{"result": {"id": "security_level", "value": "medium", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Invoke method + response = _service.get_security_level() + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_get_security_level_all_params_with_retries(self): + # Enable retries and run test_get_security_level_all_params. + _service.enable_retries() + self.test_get_security_level_all_params() + + # Disable retries and run test_get_security_level_all_params. + _service.disable_retries() + self.test_get_security_level_all_params() + + @responses.activate + def test_get_security_level_value_error(self): + """ + test_get_security_level_value_error() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/settings/security_level') + mock_response = '{"result": {"id": "security_level", "value": "medium", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.get_security_level(**req_copy) + + def test_get_security_level_value_error_with_retries(self): + # Enable retries and run test_get_security_level_value_error. + _service.enable_retries() + self.test_get_security_level_value_error() + + # Disable retries and run test_get_security_level_value_error. + _service.disable_retries() + self.test_get_security_level_value_error() + + +class TestUpdateSecurityLevel: + """ + Test Class for update_security_level + """ + + @responses.activate + def test_update_security_level_all_params(self): + """ + update_security_level() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/settings/security_level') + mock_response = '{"result": {"id": "security_level", "value": "medium", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' + responses.add( + responses.PATCH, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + value = 'medium' + + # Invoke method + response = _service.update_security_level( + value=value, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['value'] == 'medium' + + def test_update_security_level_all_params_with_retries(self): + # Enable retries and run test_update_security_level_all_params. + _service.enable_retries() + self.test_update_security_level_all_params() + + # Disable retries and run test_update_security_level_all_params. + _service.disable_retries() + self.test_update_security_level_all_params() + + @responses.activate + def test_update_security_level_required_params(self): + """ + test_update_security_level_required_params() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/settings/security_level') + mock_response = '{"result": {"id": "security_level", "value": "medium", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' + responses.add( + responses.PATCH, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Invoke method + response = _service.update_security_level() + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_update_security_level_required_params_with_retries(self): + # Enable retries and run test_update_security_level_required_params. + _service.enable_retries() + self.test_update_security_level_required_params() + + # Disable retries and run test_update_security_level_required_params. + _service.disable_retries() + self.test_update_security_level_required_params() + + @responses.activate + def test_update_security_level_value_error(self): + """ + test_update_security_level_value_error() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/settings/security_level') + mock_response = '{"result": {"id": "security_level", "value": "medium", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' + responses.add( + responses.PATCH, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.update_security_level(**req_copy) + + def test_update_security_level_value_error_with_retries(self): + # Enable retries and run test_update_security_level_value_error. + _service.enable_retries() + self.test_update_security_level_value_error() + + # Disable retries and run test_update_security_level_value_error. + _service.disable_retries() + self.test_update_security_level_value_error() + + # endregion ############################################################################## # End of Service: ZonesSettings @@ -8649,6 +8832,39 @@ def test_security_header_setting_value_strict_transport_security_serialization(s assert security_header_setting_value_strict_transport_security_model_json2 == security_header_setting_value_strict_transport_security_model_json +class TestModel_SecurityLevelRespResult: + """ + Test Class for SecurityLevelRespResult + """ + + def test_security_level_resp_result_serialization(self): + """ + Test serialization/deserialization for SecurityLevelRespResult + """ + + # Construct a json representation of a SecurityLevelRespResult model + security_level_resp_result_model_json = {} + security_level_resp_result_model_json['id'] = 'security_level' + security_level_resp_result_model_json['value'] = 'medium' + security_level_resp_result_model_json['editable'] = True + security_level_resp_result_model_json['modified_on'] = '2017-01-01T05:20:00.123000Z' + + # Construct a model instance of SecurityLevelRespResult by calling from_dict on the json representation + security_level_resp_result_model = SecurityLevelRespResult.from_dict(security_level_resp_result_model_json) + assert security_level_resp_result_model != False + + # Construct a model instance of SecurityLevelRespResult by calling from_dict on the json representation + security_level_resp_result_model_dict = SecurityLevelRespResult.from_dict(security_level_resp_result_model_json).__dict__ + security_level_resp_result_model2 = SecurityLevelRespResult(**security_level_resp_result_model_dict) + + # Verify the model instances are equivalent + assert security_level_resp_result_model == security_level_resp_result_model2 + + # Convert model instance back to dict and verify no loss of data + security_level_resp_result_model_json2 = security_level_resp_result_model.to_dict() + assert security_level_resp_result_model_json2 == security_level_resp_result_model_json + + class TestModel_ServerSideExcludeRespResult: """ Test Class for ServerSideExcludeRespResult @@ -9227,6 +9443,7 @@ def test_email_obfuscation_resp_serialization(self): # Construct a json representation of a EmailObfuscationResp model email_obfuscation_resp_model_json = {} email_obfuscation_resp_model_json['result'] = email_obfuscation_resp_result_model + email_obfuscation_resp_model_json['result_info'] = {'anyKey': 'anyValue'} email_obfuscation_resp_model_json['success'] = True email_obfuscation_resp_model_json['errors'] = [['testString']] email_obfuscation_resp_model_json['messages'] = [['testString']] @@ -10095,6 +10312,7 @@ def test_replace_insecure_js_resp_serialization(self): # Construct a json representation of a ReplaceInsecureJsResp model replace_insecure_js_resp_model_json = {} replace_insecure_js_resp_model_json['result'] = replace_insecure_js_resp_result_model + replace_insecure_js_resp_model_json['result_info'] = {'anyKey': 'anyValue'} replace_insecure_js_resp_model_json['success'] = True replace_insecure_js_resp_model_json['errors'] = [['testString']] replace_insecure_js_resp_model_json['messages'] = [['testString']] @@ -10248,6 +10466,47 @@ def test_security_header_resp_serialization(self): assert security_header_resp_model_json2 == security_header_resp_model_json +class TestModel_SecurityLevelResp: + """ + Test Class for SecurityLevelResp + """ + + def test_security_level_resp_serialization(self): + """ + Test serialization/deserialization for SecurityLevelResp + """ + + # Construct dict forms of any model objects needed in order to build this model. + + security_level_resp_result_model = {} # SecurityLevelRespResult + security_level_resp_result_model['id'] = 'security_level' + security_level_resp_result_model['value'] = 'medium' + security_level_resp_result_model['editable'] = True + security_level_resp_result_model['modified_on'] = '2017-01-01T05:20:00.123000Z' + + # Construct a json representation of a SecurityLevelResp model + security_level_resp_model_json = {} + security_level_resp_model_json['result'] = security_level_resp_result_model + security_level_resp_model_json['success'] = True + security_level_resp_model_json['errors'] = [['testString']] + security_level_resp_model_json['messages'] = [['testString']] + + # Construct a model instance of SecurityLevelResp by calling from_dict on the json representation + security_level_resp_model = SecurityLevelResp.from_dict(security_level_resp_model_json) + assert security_level_resp_model != False + + # Construct a model instance of SecurityLevelResp by calling from_dict on the json representation + security_level_resp_model_dict = SecurityLevelResp.from_dict(security_level_resp_model_json).__dict__ + security_level_resp_model2 = SecurityLevelResp(**security_level_resp_model_dict) + + # Verify the model instances are equivalent + assert security_level_resp_model == security_level_resp_model2 + + # Convert model instance back to dict and verify no loss of data + security_level_resp_model_json2 = security_level_resp_model.to_dict() + assert security_level_resp_model_json2 == security_level_resp_model_json + + class TestModel_ServerSideExcludeResp: """ Test Class for ServerSideExcludeResp