From c02137a72479e14f62c79cbce70f6bdf230a3836 Mon Sep 17 00:00:00 2001 From: Dwitikrushna Dash Date: Tue, 22 Jun 2021 10:02:39 +0530 Subject: [PATCH] feat(filters_v1, Python SDK): added sdk code for filters --- .secrets.baseline | 15 +- .travis.yml | 2 +- cis.env.enc | Bin 8400 -> 720 bytes dns.env.enc | Bin 544 -> 704 bytes ibm_cloud_networking_services/__init__.py | 3 +- ibm_cloud_networking_services/filters_v1.py | 1396 +++++++++++++++++++ test/integration/test_filters_v1.py | 250 ++++ test/unit/test_filters_v1.py | 1152 +++++++++++++++ 8 files changed, 2809 insertions(+), 9 deletions(-) create mode 100644 ibm_cloud_networking_services/filters_v1.py create mode 100644 test/integration/test_filters_v1.py create mode 100644 test/unit/test_filters_v1.py diff --git a/.secrets.baseline b/.secrets.baseline index 592fd7f..ec77adb 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -3,7 +3,7 @@ "files": "package-lock.json|^.secrets.baseline$", "lines": null }, - "generated_at": "2021-03-09T20:23:57Z", + "generated_at": "2021-06-22T04:29:24Z", "plugins_used": [ { "name": "AWSKeyDetector" @@ -25,6 +25,7 @@ "name": "CloudantDetector" }, { + "ghe_instance": "github.ibm.com", "name": "GheDetector" }, { @@ -163,7 +164,7 @@ "hashed_secret": "94851979e1cb78bbd9e48a9e2a01f7485e2dbf37", "is_secret": false, "is_verified": false, - "line_number": 2286, + "line_number": 2365, "type": "Hex High Entropy String", "verified_result": null }, @@ -171,7 +172,7 @@ "hashed_secret": "4c154143659305d3cea695447bc2947935d294d0", "is_secret": false, "is_verified": false, - "line_number": 2623, + "line_number": 2705, "type": "Hex High Entropy String", "verified_result": null }, @@ -179,7 +180,7 @@ "hashed_secret": "d67a00cdeec75b04602db35a89c15bb6ee53c877", "is_secret": false, "is_verified": false, - "line_number": 2858, + "line_number": 2940, "type": "Hex High Entropy String", "verified_result": null } @@ -353,7 +354,7 @@ "hashed_secret": "d67a00cdeec75b04602db35a89c15bb6ee53c877", "is_secret": false, "is_verified": false, - "line_number": 1253, + "line_number": 1632, "type": "Hex High Entropy String", "verified_result": null }, @@ -361,7 +362,7 @@ "hashed_secret": "eb74ff42e2e8dfbaf3e4f64a02cdadc8bedda8c3", "is_secret": false, "is_verified": false, - "line_number": 1343, + "line_number": 1815, "type": "Hex High Entropy String", "verified_result": null } @@ -521,7 +522,7 @@ } ] }, - "version": "0.13.1+ibm.31.dss", + "version": "0.13.1+ibm.38.dss", "word_list": { "file": null, "hash": null diff --git a/.travis.yml b/.travis.yml index 2440ba4..6984b76 100644 --- a/.travis.yml +++ b/.travis.yml @@ -53,4 +53,4 @@ deploy: skip_cleanup: true on: python: '3.6' - tags: true \ No newline at end of file + tags: true diff --git a/cis.env.enc b/cis.env.enc index 0942b1b2334a863b5ec06f6f3cb614f41877aed1..86f87d0405cfbdd616ca82665c7a4932d176f708 100644 GIT binary patch literal 720 zcmV;>0x$h`ys!Ie=YN=k4{5g#Vo7FPCfSmt26CUX;>RAwCZI(CSwlCgAy34p9u@l%oa5GLkr-(NXe@IU{Q-R0yTypy1| zCh>s0rX`euYSqQ27DlHYECt5O`g#k164FMq(1+OgMZKgn>MdLOO1@NmdF}?>X?f0Z z+>oGjzsUk5KE{2fqcVYh0AT!=*)YG@aN;_wde76Sh?`e(-l@k#$oV3wo$c&EMl!<) zw27H$%{EFv0Q%3O%vZAqwueLYLyaiT=A!ey^5vF&E=YZFrGWqQ$ti*K%L_03j4=bF zU+zcDpR9G?MJrLTS}T(R{?*5+U7)cdfYw7Wa#>&l{}@Fb+Yj6!5lIwpB@j^OwBZy$ zWo4%f`%9y~w#N_0g|fxJ%8Icnj}}b~svwAQ;Sia)r}zIW;e@1Dn!RQ+hqE26@RWHH zl8WmWCS&|sO5d%C2uM9HYu8IM*$-K*83Xht4}Wrk& zN0Q>`XTR#MVSp~^M*c(l;Bu<)aEC|-D0_+31;;kY&xwZEl@rfqJ@y(wn=)7 zw;zZtGz;4F{n1M?1(n~@>8XTEuMxRn;0rYX&r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%h`KXm z^D#h>HJ3=M2}`-Xdi0n)n)HtRZ#Hj}dQ={Eo2K&Aa~^d!1KrxW#K8Qyt{o3s)XR5T zcnuLrIFsPgpR*-@=9_|;uJj7a14@ok3aSCUThLqMg0u=f8k*N|Z>)E#>1po3fFm|c zDsVP99(&lAj>%3v>U7wVXK<6ndz=Y+&_>s_O7HRD6u4VjhV9hfnV<)g|K$Pj@ z39VO5xZ^Z(dQ8}p{RR6NcJZDzQUboH?D--JvYFH9ooJf+w~76$A-=CM6j7P!Zs2Be6lUo&|MRy96vxGz zAxifC7^Wa^NDZ#YD^qY`8fbWnR(hHAJ{ZSNf4s5?H!Q!`kF{M=dsiFG_M`MnzTssH zM|jxMr(;=5zKFtES}*kZS0Uo`I0zk>%(1~%x>N+qjD|jNCSe+~tO9gmzq^EfZ)44a zI7<&plC3DeI=a+4$ox3C<#-)F(b@*bKC7GAerJCx3io=^@j9tUT8L#?+$I|g3~ zEdA>Aqnm&>+c0Tf7VZm__VvQ-R^Su-Z_}0Vo+^=dBb^P@!{=4bD2vM0xuD1WQIrEH;wc)O5LqO74Yf2b1U ia20-8Wng+(+j60hmIRu)Jb^+^;p3AP-Ks6Uh8rAswF$ET diff --git a/ibm_cloud_networking_services/__init__.py b/ibm_cloud_networking_services/__init__.py index 7d54f99..c2d3e00 100644 --- a/ibm_cloud_networking_services/__init__.py +++ b/ibm_cloud_networking_services/__init__.py @@ -1,5 +1,5 @@ # coding: utf-8 -# Copyright 2020 IBM All Rights Reserved. +# Copyright 2021 IBM All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ from .custom_pages_v1 import CustomPagesV1 from .dns_record_bulk_v1 import DnsRecordBulkV1 from .dns_records_v1 import DnsRecordsV1 +from .filters_v1 import FiltersV1 from .firewall_access_rules_v1 import FirewallAccessRulesV1 from .firewall_api_v1 import FirewallApiV1 from .global_load_balancer_events_v1 import GlobalLoadBalancerEventsV1 diff --git a/ibm_cloud_networking_services/filters_v1.py b/ibm_cloud_networking_services/filters_v1.py new file mode 100644 index 0000000..f16dd14 --- /dev/null +++ b/ibm_cloud_networking_services/filters_v1.py @@ -0,0 +1,1396 @@ +# coding: utf-8 + +# (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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# IBM OpenAPI SDK Code Generator Version: 3.32.0-4c6a3129-20210514-210323 + +""" +Filters +""" + +from typing import Dict, List +import json + +from ibm_cloud_sdk_core import BaseService, DetailedResponse +from ibm_cloud_sdk_core.authenticators.authenticator import Authenticator +from ibm_cloud_sdk_core.get_authenticator import get_authenticator_from_environment +from ibm_cloud_sdk_core.utils import convert_model + +from .common import get_sdk_headers + +############################################################################## +# Service +############################################################################## + +class FiltersV1(BaseService): + """The Filters V1 service.""" + + DEFAULT_SERVICE_URL = 'https://api.cis.cloud.ibm.com' + DEFAULT_SERVICE_NAME = 'filters' + + @classmethod + def new_instance(cls, + service_name: str = DEFAULT_SERVICE_NAME, + ) -> 'FiltersV1': + """ + Return a new client for the Filters service using the specified parameters + and external configuration. + """ + authenticator = get_authenticator_from_environment(service_name) + service = cls( + authenticator + ) + service.configure_service(service_name) + return service + + def __init__(self, + authenticator: Authenticator = None, + ) -> None: + """ + Construct a new client for the Filters service. + + :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 + about initializing the authenticator of your choice. + """ + BaseService.__init__(self, + service_url=self.DEFAULT_SERVICE_URL, + authenticator=authenticator) + + + ######################### + # Filters + ######################### + + + def list_all_filters(self, + x_auth_user_token: str, + crn: str, + zone_identifier: str, + **kwargs + ) -> DetailedResponse: + """ + List all filters for a zone. + + List all filters for a zone. + + :param str x_auth_user_token: IBM Cloud user IAM token. + :param str crn: Full url-encoded cloud resource name (CRN) of resource + instance. + :param str zone_identifier: Zone identifier of the zone for which filters + are listed. + :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 `ListFiltersResp` object + """ + + if x_auth_user_token is None: + raise ValueError('x_auth_user_token must be provided') + if crn is None: + raise ValueError('crn must be provided') + if zone_identifier is None: + raise ValueError('zone_identifier must be provided') + headers = { + 'X-Auth-User-Token': x_auth_user_token + } + sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='list_all_filters') + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'zone_identifier'] + path_param_values = self.encode_path_vars(crn, zone_identifier) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/zones/{zone_identifier}/filters'.format(**path_param_dict) + request = self.prepare_request(method='GET', + url=url, + headers=headers) + + response = self.send(request) + return response + + + def create_filter(self, + x_auth_user_token: str, + crn: str, + zone_identifier: str, + *, + filter_input: List['FilterInput'] = None, + **kwargs + ) -> DetailedResponse: + """ + Create filters for a zone. + + Create new filters for a given zone under a service instance. + + :param str x_auth_user_token: IBM Cloud user IAM token. + :param str crn: Full url-encoded cloud resource name (CRN) of resource + instance. + :param str zone_identifier: Zone identifier of the zone for which filters + are created. + :param List[FilterInput] filter_input: (optional) Json objects which are + used to create filters. + :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 `FiltersResp` object + """ + + if x_auth_user_token is None: + raise ValueError('x_auth_user_token must be provided') + if crn is None: + raise ValueError('crn must be provided') + if zone_identifier is None: + raise ValueError('zone_identifier must be provided') + if filter_input is not None: + filter_input = [convert_model(x) for x in filter_input] + headers = { + 'X-Auth-User-Token': x_auth_user_token + } + sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='create_filter') + headers.update(sdk_headers) + + data = json.dumps(filter_input) + headers['content-type'] = 'application/json' + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'zone_identifier'] + path_param_values = self.encode_path_vars(crn, zone_identifier) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/zones/{zone_identifier}/filters'.format(**path_param_dict) + request = self.prepare_request(method='POST', + url=url, + headers=headers, + data=data) + + response = self.send(request) + return response + + + def update_filters(self, + x_auth_user_token: str, + crn: str, + zone_identifier: str, + *, + filter_update_input: List['FilterUpdateInput'] = None, + **kwargs + ) -> DetailedResponse: + """ + Update filters. + + Update existing filters for a given zone under a given service instance. + + :param str x_auth_user_token: IBM Cloud user IAM token. + :param str crn: Full crn of the service instance. + :param str zone_identifier: Zone identifier (zone id). + :param List[FilterUpdateInput] filter_update_input: (optional) + :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 `FiltersResp` object + """ + + if x_auth_user_token is None: + raise ValueError('x_auth_user_token must be provided') + if crn is None: + raise ValueError('crn must be provided') + if zone_identifier is None: + raise ValueError('zone_identifier must be provided') + if filter_update_input is not None: + filter_update_input = [convert_model(x) for x in filter_update_input] + headers = { + 'X-Auth-User-Token': x_auth_user_token + } + sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='update_filters') + headers.update(sdk_headers) + + data = json.dumps(filter_update_input) + headers['content-type'] = 'application/json' + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'zone_identifier'] + path_param_values = self.encode_path_vars(crn, zone_identifier) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/zones/{zone_identifier}/filters'.format(**path_param_dict) + request = self.prepare_request(method='PUT', + url=url, + headers=headers, + data=data) + + response = self.send(request) + return response + + + def delete_filters(self, + x_auth_user_token: str, + crn: str, + zone_identifier: str, + id: str, + **kwargs + ) -> DetailedResponse: + """ + Delete filters. + + Delete filters by filter ids. + + :param str x_auth_user_token: IBM Cloud user IAM token. + :param str crn: Full crn of the service instance. + :param str zone_identifier: Identifier of zone whose filters are to be + deleted. + :param str id: ids of filters which will be deleted. + :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 `DeleteFiltersResp` object + """ + + if x_auth_user_token is None: + raise ValueError('x_auth_user_token must be provided') + if crn is None: + raise ValueError('crn must be provided') + if zone_identifier is None: + raise ValueError('zone_identifier must be provided') + if id is None: + raise ValueError('id must be provided') + headers = { + 'X-Auth-User-Token': x_auth_user_token + } + sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='delete_filters') + headers.update(sdk_headers) + + params = { + 'id': id + } + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'zone_identifier'] + path_param_values = self.encode_path_vars(crn, zone_identifier) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/zones/{zone_identifier}/filters'.format(**path_param_dict) + request = self.prepare_request(method='DELETE', + url=url, + headers=headers, + params=params) + + response = self.send(request) + return response + + + def delete_filter(self, + x_auth_user_token: str, + crn: str, + zone_identifier: str, + filter_identifier: str, + **kwargs + ) -> DetailedResponse: + """ + Delete a filter. + + Delete a filter given its id. + + :param str x_auth_user_token: IBM Cloud user IAM token. + :param str crn: Full crn of the service instance. + :param str zone_identifier: Identifier of zone whose filter is to be + deleted. + :param str filter_identifier: Identifier of the filter to be deleted. + :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 `DeleteFilterResp` object + """ + + if x_auth_user_token is None: + raise ValueError('x_auth_user_token must be provided') + if crn is None: + raise ValueError('crn must be provided') + if zone_identifier is None: + raise ValueError('zone_identifier must be provided') + if filter_identifier is None: + raise ValueError('filter_identifier must be provided') + headers = { + 'X-Auth-User-Token': x_auth_user_token + } + sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='delete_filter') + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'zone_identifier', 'filter_identifier'] + path_param_values = self.encode_path_vars(crn, zone_identifier, filter_identifier) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/zones/{zone_identifier}/filters/{filter_identifier}'.format(**path_param_dict) + request = self.prepare_request(method='DELETE', + url=url, + headers=headers) + + response = self.send(request) + return response + + + def get_filter(self, + x_auth_user_token: str, + crn: str, + zone_identifier: str, + filter_identifier: str, + **kwargs + ) -> DetailedResponse: + """ + Get filter details by id. + + Get the details of a filter for a given zone under a given service instance. + + :param str x_auth_user_token: IBM Cloud user IAM token. + :param str crn: Full crn of the service instance. + :param str zone_identifier: Zone identifier (zone id). + :param str filter_identifier: Identifier of filter for the given 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 `FilterResp` object + """ + + if x_auth_user_token is None: + raise ValueError('x_auth_user_token must be provided') + if crn is None: + raise ValueError('crn must be provided') + if zone_identifier is None: + raise ValueError('zone_identifier must be provided') + if filter_identifier is None: + raise ValueError('filter_identifier must be provided') + headers = { + 'X-Auth-User-Token': x_auth_user_token + } + sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='get_filter') + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'zone_identifier', 'filter_identifier'] + path_param_values = self.encode_path_vars(crn, zone_identifier, filter_identifier) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/zones/{zone_identifier}/filters/{filter_identifier}'.format(**path_param_dict) + request = self.prepare_request(method='GET', + url=url, + headers=headers) + + response = self.send(request) + return response + + + def update_filter(self, + x_auth_user_token: str, + crn: str, + zone_identifier: str, + filter_identifier: str, + *, + id: str = None, + expression: str = None, + description: str = None, + paused: bool = None, + **kwargs + ) -> DetailedResponse: + """ + Update a filter. + + Update an existing filter for a given zone under a given service instance. + + :param str x_auth_user_token: IBM Cloud user IAM token. + :param str crn: Full crn of the service instance. + :param str zone_identifier: Zone identifier (zone id). + :param str filter_identifier: Identifier of filter. + :param str id: (optional) Identifier of the filter. + :param str expression: (optional) A filter expression. + :param str description: (optional) To briefly describe the filter. + :param bool paused: (optional) Indicates if the filter is active. + :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 `FilterResp` object + """ + + if x_auth_user_token is None: + raise ValueError('x_auth_user_token must be provided') + if crn is None: + raise ValueError('crn must be provided') + if zone_identifier is None: + raise ValueError('zone_identifier must be provided') + if filter_identifier is None: + raise ValueError('filter_identifier must be provided') + headers = { + 'X-Auth-User-Token': x_auth_user_token + } + sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='update_filter') + headers.update(sdk_headers) + + data = { + 'id': id, + 'expression': expression, + 'description': description, + 'paused': paused + } + data = {k: v for (k, v) in data.items() if v is not None} + data = json.dumps(data) + headers['content-type'] = 'application/json' + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'zone_identifier', 'filter_identifier'] + path_param_values = self.encode_path_vars(crn, zone_identifier, filter_identifier) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/zones/{zone_identifier}/filters/{filter_identifier}'.format(**path_param_dict) + request = self.prepare_request(method='PUT', + url=url, + headers=headers, + data=data) + + response = self.send(request) + return response + + +############################################################################## +# Models +############################################################################## + + +class DeleteFilterRespResult(): + """ + Container for response information. + + :attr str id: Identifier of the filter. + """ + + def __init__(self, + id: str) -> None: + """ + Initialize a DeleteFilterRespResult object. + + :param str id: Identifier of the filter. + """ + self.id = id + + @classmethod + def from_dict(cls, _dict: Dict) -> 'DeleteFilterRespResult': + """Initialize a DeleteFilterRespResult object from a json dictionary.""" + args = {} + if 'id' in _dict: + args['id'] = _dict.get('id') + else: + raise ValueError('Required property \'id\' not present in DeleteFilterRespResult JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a DeleteFilterRespResult 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 + 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 DeleteFilterRespResult object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'DeleteFilterRespResult') -> 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: 'DeleteFilterRespResult') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + +class DeleteFiltersRespResultItem(): + """ + DeleteFiltersRespResultItem. + + :attr str id: Identifier of the filter. + """ + + def __init__(self, + id: str) -> None: + """ + Initialize a DeleteFiltersRespResultItem object. + + :param str id: Identifier of the filter. + """ + self.id = id + + @classmethod + def from_dict(cls, _dict: Dict) -> 'DeleteFiltersRespResultItem': + """Initialize a DeleteFiltersRespResultItem object from a json dictionary.""" + args = {} + if 'id' in _dict: + args['id'] = _dict.get('id') + else: + raise ValueError('Required property \'id\' not present in DeleteFiltersRespResultItem JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a DeleteFiltersRespResultItem 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 + 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 DeleteFiltersRespResultItem object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'DeleteFiltersRespResultItem') -> 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: 'DeleteFiltersRespResultItem') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + +class ListFiltersRespResultInfo(): + """ + Statistics of results. + + :attr int page: Page number. + :attr int per_page: Number of results per page. + :attr int count: Number of results. + :attr int total_count: Total number of results. + """ + + def __init__(self, + page: int, + per_page: int, + count: int, + total_count: int) -> None: + """ + Initialize a ListFiltersRespResultInfo object. + + :param int page: Page number. + :param int per_page: Number of results per page. + :param int count: Number of results. + :param int total_count: Total number of results. + """ + self.page = page + self.per_page = per_page + self.count = count + self.total_count = total_count + + @classmethod + def from_dict(cls, _dict: Dict) -> 'ListFiltersRespResultInfo': + """Initialize a ListFiltersRespResultInfo object from a json dictionary.""" + args = {} + if 'page' in _dict: + args['page'] = _dict.get('page') + else: + raise ValueError('Required property \'page\' not present in ListFiltersRespResultInfo JSON') + if 'per_page' in _dict: + args['per_page'] = _dict.get('per_page') + else: + raise ValueError('Required property \'per_page\' not present in ListFiltersRespResultInfo JSON') + if 'count' in _dict: + args['count'] = _dict.get('count') + else: + raise ValueError('Required property \'count\' not present in ListFiltersRespResultInfo JSON') + if 'total_count' in _dict: + args['total_count'] = _dict.get('total_count') + else: + raise ValueError('Required property \'total_count\' not present in ListFiltersRespResultInfo JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a ListFiltersRespResultInfo 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, 'page') and self.page is not None: + _dict['page'] = self.page + if hasattr(self, 'per_page') and self.per_page is not None: + _dict['per_page'] = self.per_page + if hasattr(self, 'count') and self.count is not None: + _dict['count'] = self.count + if hasattr(self, 'total_count') and self.total_count is not None: + _dict['total_count'] = self.total_count + 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 ListFiltersRespResultInfo object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'ListFiltersRespResultInfo') -> 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: 'ListFiltersRespResultInfo') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + +class DeleteFilterResp(): + """ + DeleteFilterResp. + + :attr bool success: Operation success flag. + :attr List[List[str]] errors: Array of errors encountered. + :attr List[List[str]] messages: Array of messages returned. + :attr DeleteFilterRespResult result: Container for response information. + """ + + def __init__(self, + success: bool, + errors: List[List[str]], + messages: List[List[str]], + result: 'DeleteFilterRespResult') -> None: + """ + Initialize a DeleteFilterResp object. + + :param bool success: Operation success flag. + :param List[List[str]] errors: Array of errors encountered. + :param List[List[str]] messages: Array of messages returned. + :param DeleteFilterRespResult result: Container for response information. + """ + self.success = success + self.errors = errors + self.messages = messages + self.result = result + + @classmethod + def from_dict(cls, _dict: Dict) -> 'DeleteFilterResp': + """Initialize a DeleteFilterResp object from a json dictionary.""" + args = {} + if 'success' in _dict: + args['success'] = _dict.get('success') + else: + raise ValueError('Required property \'success\' not present in DeleteFilterResp JSON') + if 'errors' in _dict: + args['errors'] = _dict.get('errors') + else: + raise ValueError('Required property \'errors\' not present in DeleteFilterResp JSON') + if 'messages' in _dict: + args['messages'] = _dict.get('messages') + else: + raise ValueError('Required property \'messages\' not present in DeleteFilterResp JSON') + if 'result' in _dict: + args['result'] = DeleteFilterRespResult.from_dict(_dict.get('result')) + else: + raise ValueError('Required property \'result\' not present in DeleteFilterResp JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a DeleteFilterResp 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, '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 + if hasattr(self, 'result') and self.result is not None: + _dict['result'] = self.result.to_dict() + 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 DeleteFilterResp object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'DeleteFilterResp') -> 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: 'DeleteFilterResp') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + +class DeleteFiltersResp(): + """ + DeleteFiltersResp. + + :attr bool success: Operation success flag. + :attr List[List[str]] errors: Array of errors encountered. + :attr List[List[str]] messages: Array of messages returned. + :attr List[DeleteFiltersRespResultItem] result: Container for response + information. + """ + + def __init__(self, + success: bool, + errors: List[List[str]], + messages: List[List[str]], + result: List['DeleteFiltersRespResultItem']) -> None: + """ + Initialize a DeleteFiltersResp object. + + :param bool success: Operation success flag. + :param List[List[str]] errors: Array of errors encountered. + :param List[List[str]] messages: Array of messages returned. + :param List[DeleteFiltersRespResultItem] result: Container for response + information. + """ + self.success = success + self.errors = errors + self.messages = messages + self.result = result + + @classmethod + def from_dict(cls, _dict: Dict) -> 'DeleteFiltersResp': + """Initialize a DeleteFiltersResp object from a json dictionary.""" + args = {} + if 'success' in _dict: + args['success'] = _dict.get('success') + else: + raise ValueError('Required property \'success\' not present in DeleteFiltersResp JSON') + if 'errors' in _dict: + args['errors'] = _dict.get('errors') + else: + raise ValueError('Required property \'errors\' not present in DeleteFiltersResp JSON') + if 'messages' in _dict: + args['messages'] = _dict.get('messages') + else: + raise ValueError('Required property \'messages\' not present in DeleteFiltersResp JSON') + if 'result' in _dict: + args['result'] = [DeleteFiltersRespResultItem.from_dict(x) for x in _dict.get('result')] + else: + raise ValueError('Required property \'result\' not present in DeleteFiltersResp JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a DeleteFiltersResp 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, '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 + if hasattr(self, 'result') and self.result is not None: + _dict['result'] = [x.to_dict() for x in self.result] + 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 DeleteFiltersResp object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'DeleteFiltersResp') -> 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: 'DeleteFiltersResp') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + +class FilterInput(): + """ + Json objects which are used to create filters. + + :attr str expression: A filter expression. + :attr bool paused: (optional) Indicates if the filter is active. + :attr str description: (optional) To briefly describe the filter, omitted from + object if empty. + """ + + def __init__(self, + expression: str, + *, + paused: bool = None, + description: str = None) -> None: + """ + Initialize a FilterInput object. + + :param str expression: A filter expression. + :param bool paused: (optional) Indicates if the filter is active. + :param str description: (optional) To briefly describe the filter, omitted + from object if empty. + """ + self.expression = expression + self.paused = paused + self.description = description + + @classmethod + def from_dict(cls, _dict: Dict) -> 'FilterInput': + """Initialize a FilterInput object from a json dictionary.""" + args = {} + if 'expression' in _dict: + args['expression'] = _dict.get('expression') + else: + raise ValueError('Required property \'expression\' not present in FilterInput JSON') + if 'paused' in _dict: + args['paused'] = _dict.get('paused') + if 'description' in _dict: + args['description'] = _dict.get('description') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a FilterInput 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, 'expression') and self.expression is not None: + _dict['expression'] = self.expression + if hasattr(self, 'paused') and self.paused is not None: + _dict['paused'] = self.paused + if hasattr(self, 'description') and self.description is not None: + _dict['description'] = self.description + 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 FilterInput object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'FilterInput') -> 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: 'FilterInput') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + +class FilterObject(): + """ + FilterObject. + + :attr str id: Identifier of the filter. + :attr bool paused: Indicates if the filter is active. + :attr str description: To briefly describe the filter, omitted from object if + empty. + :attr str expression: A filter expression. + :attr str created_on: The creation date-time of the filter. + :attr str modified_on: The modification date-time of the filter. + """ + + def __init__(self, + id: str, + paused: bool, + description: str, + expression: str, + created_on: str, + modified_on: str) -> None: + """ + Initialize a FilterObject object. + + :param str id: Identifier of the filter. + :param bool paused: Indicates if the filter is active. + :param str description: To briefly describe the filter, omitted from object + if empty. + :param str expression: A filter expression. + :param str created_on: The creation date-time of the filter. + :param str modified_on: The modification date-time of the filter. + """ + self.id = id + self.paused = paused + self.description = description + self.expression = expression + self.created_on = created_on + self.modified_on = modified_on + + @classmethod + def from_dict(cls, _dict: Dict) -> 'FilterObject': + """Initialize a FilterObject object from a json dictionary.""" + args = {} + if 'id' in _dict: + args['id'] = _dict.get('id') + else: + raise ValueError('Required property \'id\' not present in FilterObject JSON') + if 'paused' in _dict: + args['paused'] = _dict.get('paused') + else: + raise ValueError('Required property \'paused\' not present in FilterObject JSON') + if 'description' in _dict: + args['description'] = _dict.get('description') + else: + raise ValueError('Required property \'description\' not present in FilterObject JSON') + if 'expression' in _dict: + args['expression'] = _dict.get('expression') + else: + raise ValueError('Required property \'expression\' not present in FilterObject JSON') + if 'created_on' in _dict: + args['created_on'] = _dict.get('created_on') + else: + raise ValueError('Required property \'created_on\' not present in FilterObject JSON') + if 'modified_on' in _dict: + args['modified_on'] = _dict.get('modified_on') + else: + raise ValueError('Required property \'modified_on\' not present in FilterObject JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a FilterObject 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, 'paused') and self.paused is not None: + _dict['paused'] = self.paused + if hasattr(self, 'description') and self.description is not None: + _dict['description'] = self.description + if hasattr(self, 'expression') and self.expression is not None: + _dict['expression'] = self.expression + if hasattr(self, 'created_on') and self.created_on is not None: + _dict['created_on'] = self.created_on + if hasattr(self, 'modified_on') and self.modified_on is not None: + _dict['modified_on'] = 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 FilterObject object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'FilterObject') -> 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: 'FilterObject') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + +class FilterResp(): + """ + FilterResp. + + :attr bool success: Operation success flag. + :attr List[List[str]] errors: Array of errors encountered. + :attr List[List[str]] messages: Array of messages returned. + :attr FilterObject result: + """ + + def __init__(self, + success: bool, + errors: List[List[str]], + messages: List[List[str]], + result: 'FilterObject') -> None: + """ + Initialize a FilterResp object. + + :param bool success: Operation success flag. + :param List[List[str]] errors: Array of errors encountered. + :param List[List[str]] messages: Array of messages returned. + :param FilterObject result: + """ + self.success = success + self.errors = errors + self.messages = messages + self.result = result + + @classmethod + def from_dict(cls, _dict: Dict) -> 'FilterResp': + """Initialize a FilterResp object from a json dictionary.""" + args = {} + if 'success' in _dict: + args['success'] = _dict.get('success') + else: + raise ValueError('Required property \'success\' not present in FilterResp JSON') + if 'errors' in _dict: + args['errors'] = _dict.get('errors') + else: + raise ValueError('Required property \'errors\' not present in FilterResp JSON') + if 'messages' in _dict: + args['messages'] = _dict.get('messages') + else: + raise ValueError('Required property \'messages\' not present in FilterResp JSON') + if 'result' in _dict: + args['result'] = FilterObject.from_dict(_dict.get('result')) + else: + raise ValueError('Required property \'result\' not present in FilterResp JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a FilterResp 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, '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 + if hasattr(self, 'result') and self.result is not None: + _dict['result'] = self.result.to_dict() + 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 FilterResp object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'FilterResp') -> 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: 'FilterResp') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + +class FilterUpdateInput(): + """ + FilterUpdateInput. + + :attr str id: Identifier of the filter. + :attr str expression: A filter expression. + :attr str description: (optional) To briefly describe the filter. + :attr bool paused: (optional) Indicates if the filter is active. + """ + + def __init__(self, + id: str, + expression: str, + *, + description: str = None, + paused: bool = None) -> None: + """ + Initialize a FilterUpdateInput object. + + :param str id: Identifier of the filter. + :param str expression: A filter expression. + :param str description: (optional) To briefly describe the filter. + :param bool paused: (optional) Indicates if the filter is active. + """ + self.id = id + self.expression = expression + self.description = description + self.paused = paused + + @classmethod + def from_dict(cls, _dict: Dict) -> 'FilterUpdateInput': + """Initialize a FilterUpdateInput object from a json dictionary.""" + args = {} + if 'id' in _dict: + args['id'] = _dict.get('id') + else: + raise ValueError('Required property \'id\' not present in FilterUpdateInput JSON') + if 'expression' in _dict: + args['expression'] = _dict.get('expression') + else: + raise ValueError('Required property \'expression\' not present in FilterUpdateInput JSON') + if 'description' in _dict: + args['description'] = _dict.get('description') + if 'paused' in _dict: + args['paused'] = _dict.get('paused') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a FilterUpdateInput 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, 'expression') and self.expression is not None: + _dict['expression'] = self.expression + if hasattr(self, 'description') and self.description is not None: + _dict['description'] = self.description + if hasattr(self, 'paused') and self.paused is not None: + _dict['paused'] = self.paused + 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 FilterUpdateInput object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'FilterUpdateInput') -> 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: 'FilterUpdateInput') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + +class FiltersResp(): + """ + FiltersResp. + + :attr bool success: Operation success flag. + :attr List[List[str]] errors: Array of errors encountered. + :attr List[List[str]] messages: Array of messages returned. + :attr List[FilterObject] result: Container for response information. + """ + + def __init__(self, + success: bool, + errors: List[List[str]], + messages: List[List[str]], + result: List['FilterObject']) -> None: + """ + Initialize a FiltersResp object. + + :param bool success: Operation success flag. + :param List[List[str]] errors: Array of errors encountered. + :param List[List[str]] messages: Array of messages returned. + :param List[FilterObject] result: Container for response information. + """ + self.success = success + self.errors = errors + self.messages = messages + self.result = result + + @classmethod + def from_dict(cls, _dict: Dict) -> 'FiltersResp': + """Initialize a FiltersResp object from a json dictionary.""" + args = {} + if 'success' in _dict: + args['success'] = _dict.get('success') + else: + raise ValueError('Required property \'success\' not present in FiltersResp JSON') + if 'errors' in _dict: + args['errors'] = _dict.get('errors') + else: + raise ValueError('Required property \'errors\' not present in FiltersResp JSON') + if 'messages' in _dict: + args['messages'] = _dict.get('messages') + else: + raise ValueError('Required property \'messages\' not present in FiltersResp JSON') + if 'result' in _dict: + args['result'] = [FilterObject.from_dict(x) for x in _dict.get('result')] + else: + raise ValueError('Required property \'result\' not present in FiltersResp JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a FiltersResp 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, '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 + if hasattr(self, 'result') and self.result is not None: + _dict['result'] = [x.to_dict() for x in self.result] + 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 FiltersResp object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'FiltersResp') -> 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: 'FiltersResp') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + +class ListFiltersResp(): + """ + ListFiltersResp. + + :attr bool success: Operation success flag. + :attr List[List[str]] errors: Array of errors encountered. + :attr List[List[str]] messages: Array of messages returned. + :attr List[FilterObject] result: Container for response information. + :attr ListFiltersRespResultInfo result_info: Statistics of results. + """ + + def __init__(self, + success: bool, + errors: List[List[str]], + messages: List[List[str]], + result: List['FilterObject'], + result_info: 'ListFiltersRespResultInfo') -> None: + """ + Initialize a ListFiltersResp object. + + :param bool success: Operation success flag. + :param List[List[str]] errors: Array of errors encountered. + :param List[List[str]] messages: Array of messages returned. + :param List[FilterObject] result: Container for response information. + :param ListFiltersRespResultInfo result_info: Statistics of results. + """ + self.success = success + self.errors = errors + self.messages = messages + self.result = result + self.result_info = result_info + + @classmethod + def from_dict(cls, _dict: Dict) -> 'ListFiltersResp': + """Initialize a ListFiltersResp object from a json dictionary.""" + args = {} + if 'success' in _dict: + args['success'] = _dict.get('success') + else: + raise ValueError('Required property \'success\' not present in ListFiltersResp JSON') + if 'errors' in _dict: + args['errors'] = _dict.get('errors') + else: + raise ValueError('Required property \'errors\' not present in ListFiltersResp JSON') + if 'messages' in _dict: + args['messages'] = _dict.get('messages') + else: + raise ValueError('Required property \'messages\' not present in ListFiltersResp JSON') + if 'result' in _dict: + args['result'] = [FilterObject.from_dict(x) for x in _dict.get('result')] + else: + raise ValueError('Required property \'result\' not present in ListFiltersResp JSON') + if 'result_info' in _dict: + args['result_info'] = ListFiltersRespResultInfo.from_dict(_dict.get('result_info')) + else: + raise ValueError('Required property \'result_info\' not present in ListFiltersResp JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a ListFiltersResp 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, '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 + if hasattr(self, 'result') and self.result is not None: + _dict['result'] = [x.to_dict() for x in self.result] + if hasattr(self, 'result_info') and self.result_info is not None: + _dict['result_info'] = self.result_info.to_dict() + 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 ListFiltersResp object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'ListFiltersResp') -> 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: 'ListFiltersResp') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other diff --git a/test/integration/test_filters_v1.py b/test/integration/test_filters_v1.py new file mode 100644 index 0000000..157304f --- /dev/null +++ b/test/integration/test_filters_v1.py @@ -0,0 +1,250 @@ +# -*- coding: utf-8 -*- +# (C) Copyright IBM Corp. 2021. + +""" +Integration test code to execute Filters of a Zone +""" + +import os +import unittest +from dotenv import load_dotenv, find_dotenv +from ibm_cloud_networking_services.filters_v1 import FiltersV1 + +configFile = "cis.env" + +# load the .env file containing your environment variables +try: + load_dotenv(find_dotenv(filename="cis.env")) +except: + print('warning: no cis.env file loaded') + +class TestFiltersV1(unittest.TestCase): + """ Test class to call dns record sdk functions """ + def setUp(self): + """ test case setup """ + if not os.path.exists(configFile): + raise unittest.SkipTest( + 'External configuration not available, skipping...') + self.crn = os.getenv("CRN") + self.zone_id = os.getenv("ZONE_ID") + self.endpoint = os.getenv("API_ENDPOINT") + self.x_auth_user_token = os.getenv("CIS_SERVICES_APIKEY") + # create dns record class object + self.service = FiltersV1.new_instance( + service_name="cis_services") + self.service.set_service_url(self.endpoint) + self._clean_filters() + + def tearDown(self): + """ tear down """ + # Delete the resources + self._clean_filters() + print("Clean up complete") + + def _clean_filters(self): + response = self.service.list_all_filters( + x_auth_user_token = self.x_auth_user_token, + crn = self.crn, + zone_identifier = self.zone_id + ) + assert response is not None + assert response.status_code == 200 + resp = response.get_result().get("result") + for record in resp: + self.service.delete_filter( + x_auth_user_token = self.x_auth_user_token, + crn = self.crn, + zone_identifier = self.zone_id, + filter_identifier = record.get("id") + ) + + def _create_filter(self, expression, description, paused=False): + filter_input_model = {} + filter_input_model['expression'] = expression + filter_input_model['paused'] = False + filter_input_model['description'] = description + filter_input = [filter_input_model] + + response = self.service.create_filter( + x_auth_user_token = self.x_auth_user_token, + crn = self.crn, + zone_identifier = self.zone_id, + filter_input = filter_input + ) + assert response is not None and response.get_status_code() == 200 + filter_id = response.get_result()['result'][0]['id'] + return filter_id + + ################## create Filter ###################### + def test_1_create_filter(self): + """ test for success """ + # Construct a dict representation of a FilterInput model + filter_input_model = {} + filter_input_model['expression'] = 'not http.request.uri.path matches "^/test/.*$"' + filter_input_model['paused'] = False + filter_input_model['description'] = 'not /test' + filter_input = [filter_input_model] + + response = self.service.create_filter( + x_auth_user_token = self.x_auth_user_token, + crn = self.crn, + zone_identifier = self.zone_id, + filter_input = filter_input + ) + assert response is not None and response.get_status_code() == 200 + self.filter_id = response.get_result()['result'][0]['id'] + + ################## list_all_filters ################### + + def test_2_list_all_filters(self): + """ test for success """ + filter_input_model = {} + filter_input_model['expression'] = 'http.request.uri.path matches "^/list-all/.*$"' + filter_input_model['paused'] = False + filter_input_model['description'] = 'list test' + filter_input = [filter_input_model] + + response = self.service.create_filter( + x_auth_user_token = self.x_auth_user_token, + crn = self.crn, + zone_identifier = self.zone_id, + filter_input = filter_input + ) + assert response is not None and response.get_status_code() == 200 + + response = self.service.list_all_filters( + x_auth_user_token = self.x_auth_user_token, + crn = self.crn, + zone_identifier = self.zone_id + ) + assert response is not None and response.get_status_code() == 200 + assert len(response.get_result()['result']) >= 1 + + ################## update filters ################### + def test_3_update_filters(self): + filter_input_model = {} + filter_input_model['expression'] = 'http.request.uri.path matches "^/update-one/.*$"' + filter_input_model['paused'] = False + filter_input_model['description'] = 'Update test' + filter_input = [filter_input_model] + + response = self.service.create_filter( + x_auth_user_token = self.x_auth_user_token, + crn = self.crn, + zone_identifier = self.zone_id, + filter_input = filter_input + ) + assert response is not None and response.get_status_code() == 200 + filter_id = response.get_result()['result'][0]['id'] + # Construct a dict representation of a FilterUpdateInput model + filter_update_input_model = {} + filter_update_input_model['id'] = filter_id + filter_update_input_model['expression'] = '(ip.src eq 13.15.12.24)' + filter_update_input_model['description'] = 'sdk python update lists' + filter_update_input_model['paused'] = False + filter_update_input = [filter_update_input_model] + + response = self.service.update_filters( + x_auth_user_token = self.x_auth_user_token, + crn = self.crn, + zone_identifier = self.zone_id, + filter_update_input = filter_update_input + ) + assert response is not None and response.get_status_code() == 200 + update_filter_id = response.get_result()['result'][0]['id'] + assert update_filter_id == filter_id + assert response.get_result()['result'][0]['expression'] == filter_update_input_model['expression'] + + + ################## get filter by id ################### + def test_4_get_filter_by_id(self): + expression = 'http.request.uri.path matches "^/get-filter/.*$"' + filter_id = self._create_filter( + expression = expression, + description = 'Update Filter' + ) + response = self.service.get_filter( + x_auth_user_token = self.x_auth_user_token, + crn = self.crn, + zone_identifier = self.zone_id, + filter_identifier = filter_id + ) + assert response is not None and response.get_status_code() == 200 + get_filter_id = response.get_result()['result']['id'] + assert get_filter_id == filter_id + assert response.get_result()['result']['expression'] == expression + + ################## update filter by id ################### + def test_5_update_filter_by_id(self): + filter_id = self._create_filter( + expression = 'http.request.uri.path matches "^/get-filter/.*$"', + description = 'Update Filter' + ) + + response = self.service.update_filter( + x_auth_user_token = self.x_auth_user_token, + crn = self.crn, + zone_identifier = self.zone_id, + filter_identifier = filter_id, + id = filter_id, + expression = '(ip.src eq 213.115.12.24)', + description = 'update a single filter test' + ) + assert response is not None and response.get_status_code() == 200 + get_filter_id = response.get_result()['result']['id'] + assert get_filter_id == filter_id + + ################## delete a filter by id ################### + def test_6_delete_filter_by_id(self): + filter_id = self._create_filter( + expression = 'http.request.uri.path matches "^/delete-filter/.*$"', + description = 'Delete Filter' + ) + response = self.service.delete_filter( + x_auth_user_token = self.x_auth_user_token, + crn = self.crn, + zone_identifier = self.zone_id, + filter_identifier = filter_id + ) + assert response is not None and response.get_status_code() == 200 + get_filter_id = response.get_result()['result']['id'] + assert get_filter_id == filter_id + + ################## delete filters ################### + def test_7_delete_filters(self): + # Create a filter + # Construct a dict representation of a FilterInput model + filter_input_model = {} + filter_input_model['expression'] = 'ip.src eq 193.184.216.0' + filter_input_model['paused'] = False + filter_input_model['description'] = 'not from ip' + filter_input = [filter_input_model] + + response = self.service.create_filter( + x_auth_user_token = self.x_auth_user_token, + crn = self.crn, + zone_identifier = self.zone_id, + filter_input = filter_input + ) + assert response is not None and response.get_status_code() == 200 + filter_id_to_del = response.get_result()['result'][0]['id'] + + response = self.service.delete_filters( + x_auth_user_token = self.x_auth_user_token, + crn = self.crn, + zone_identifier = self.zone_id, + id = filter_id_to_del + ) + assert response is not None and response.get_status_code() == 200 + print(response.get_result()) + get_filter_id = response.get_result()['result'][0]['id'] + assert get_filter_id == filter_id_to_del + +if __name__ == '__main__': + unittest.main() + + + + + + diff --git a/test/unit/test_filters_v1.py b/test/unit/test_filters_v1.py new file mode 100644 index 0000000..a23af7b --- /dev/null +++ b/test/unit/test_filters_v1.py @@ -0,0 +1,1152 @@ +# -*- coding: utf-8 -*- +# (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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +""" +Unit Tests for FiltersV1 +""" + +from ibm_cloud_sdk_core.authenticators.no_auth_authenticator import NoAuthAuthenticator +import inspect +import json +import pytest +import re +import requests +import responses +import urllib +from ibm_cloud_networking_services.filters_v1 import * + + +_service = FiltersV1( + authenticator=NoAuthAuthenticator() + ) + +_base_url = 'https://api.cis.cloud.ibm.com' +_service.set_service_url(_base_url) + +############################################################################## +# Start of Service: Filters +############################################################################## +# region + +class TestListAllFilters(): + """ + Test Class for list_all_filters + """ + + def preprocess_url(self, request_url: str): + """ + Preprocess the request URL to ensure the mock response will be found. + """ + if re.fullmatch('.*/+', request_url) is None: + return request_url + else: + return re.compile(request_url.rstrip('/') + '/+') + + @responses.activate + def test_list_all_filters_all_params(self): + """ + list_all_filters() + """ + # Set up mock + url = self.preprocess_url(_base_url + '/v1/testString/zones/testString/filters') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": [{"id": "6f58318e7fa2477a23112e8118c66f61", "paused": true, "description": "Login from office", "expression": "ip.src eq 93.184.216.0 and (http.request.uri.path ~ \"^.*/wp-login.php$\" or http.request.uri.path ~ \"^.*/xmlrpc.php$\")", "created_on": "2018-01-01T05:20:00.123Z", "modified_on": "2018-01-01T05:20:00.123Z"}], "result_info": {"page": 1, "per_page": 2, "count": 1, "total_count": 200}}' + responses.add(responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Set up parameter values + x_auth_user_token = 'testString' + crn = 'testString' + zone_identifier = 'testString' + + # Invoke method + response = _service.list_all_filters( + x_auth_user_token, + crn, + zone_identifier, + headers={} + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + + @responses.activate + def test_list_all_filters_value_error(self): + """ + test_list_all_filters_value_error() + """ + # Set up mock + url = self.preprocess_url(_base_url + '/v1/testString/zones/testString/filters') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": [{"id": "6f58318e7fa2477a23112e8118c66f61", "paused": true, "description": "Login from office", "expression": "ip.src eq 93.184.216.0 and (http.request.uri.path ~ \"^.*/wp-login.php$\" or http.request.uri.path ~ \"^.*/xmlrpc.php$\")", "created_on": "2018-01-01T05:20:00.123Z", "modified_on": "2018-01-01T05:20:00.123Z"}], "result_info": {"page": 1, "per_page": 2, "count": 1, "total_count": 200}}' + responses.add(responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Set up parameter values + x_auth_user_token = 'testString' + crn = 'testString' + zone_identifier = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "x_auth_user_token": x_auth_user_token, + "crn": crn, + "zone_identifier": zone_identifier, + } + 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_all_filters(**req_copy) + + + +class TestCreateFilter(): + """ + Test Class for create_filter + """ + + def preprocess_url(self, request_url: str): + """ + Preprocess the request URL to ensure the mock response will be found. + """ + if re.fullmatch('.*/+', request_url) is None: + return request_url + else: + return re.compile(request_url.rstrip('/') + '/+') + + @responses.activate + def test_create_filter_all_params(self): + """ + create_filter() + """ + # Set up mock + url = self.preprocess_url(_base_url + '/v1/testString/zones/testString/filters') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": [{"id": "6f58318e7fa2477a23112e8118c66f61", "paused": true, "description": "Login from office", "expression": "ip.src eq 93.184.216.0 and (http.request.uri.path ~ \"^.*/wp-login.php$\" or http.request.uri.path ~ \"^.*/xmlrpc.php$\")", "created_on": "2018-01-01T05:20:00.123Z", "modified_on": "2018-01-01T05:20:00.123Z"}]}' + responses.add(responses.POST, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Construct a dict representation of a FilterInput model + filter_input_model = {} + filter_input_model['expression'] = 'not http.request.uri.path matches "^/api/.*$"' + filter_input_model['paused'] = False + filter_input_model['description'] = 'not /api' + + # Set up parameter values + x_auth_user_token = 'testString' + crn = 'testString' + zone_identifier = 'testString' + filter_input = [filter_input_model] + + # Invoke method + response = _service.create_filter( + x_auth_user_token, + crn, + zone_identifier, + filter_input=filter_input, + 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 == filter_input + + + @responses.activate + def test_create_filter_required_params(self): + """ + test_create_filter_required_params() + """ + # Set up mock + url = self.preprocess_url(_base_url + '/v1/testString/zones/testString/filters') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": [{"id": "6f58318e7fa2477a23112e8118c66f61", "paused": true, "description": "Login from office", "expression": "ip.src eq 93.184.216.0 and (http.request.uri.path ~ \"^.*/wp-login.php$\" or http.request.uri.path ~ \"^.*/xmlrpc.php$\")", "created_on": "2018-01-01T05:20:00.123Z", "modified_on": "2018-01-01T05:20:00.123Z"}]}' + responses.add(responses.POST, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Set up parameter values + x_auth_user_token = 'testString' + crn = 'testString' + zone_identifier = 'testString' + + # Invoke method + response = _service.create_filter( + x_auth_user_token, + crn, + zone_identifier, + headers={} + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + + @responses.activate + def test_create_filter_value_error(self): + """ + test_create_filter_value_error() + """ + # Set up mock + url = self.preprocess_url(_base_url + '/v1/testString/zones/testString/filters') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": [{"id": "6f58318e7fa2477a23112e8118c66f61", "paused": true, "description": "Login from office", "expression": "ip.src eq 93.184.216.0 and (http.request.uri.path ~ \"^.*/wp-login.php$\" or http.request.uri.path ~ \"^.*/xmlrpc.php$\")", "created_on": "2018-01-01T05:20:00.123Z", "modified_on": "2018-01-01T05:20:00.123Z"}]}' + responses.add(responses.POST, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Set up parameter values + x_auth_user_token = 'testString' + crn = 'testString' + zone_identifier = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "x_auth_user_token": x_auth_user_token, + "crn": crn, + "zone_identifier": zone_identifier, + } + 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_filter(**req_copy) + + + +class TestUpdateFilters(): + """ + Test Class for update_filters + """ + + def preprocess_url(self, request_url: str): + """ + Preprocess the request URL to ensure the mock response will be found. + """ + if re.fullmatch('.*/+', request_url) is None: + return request_url + else: + return re.compile(request_url.rstrip('/') + '/+') + + @responses.activate + def test_update_filters_all_params(self): + """ + update_filters() + """ + # Set up mock + url = self.preprocess_url(_base_url + '/v1/testString/zones/testString/filters') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": [{"id": "6f58318e7fa2477a23112e8118c66f61", "paused": true, "description": "Login from office", "expression": "ip.src eq 93.184.216.0 and (http.request.uri.path ~ \"^.*/wp-login.php$\" or http.request.uri.path ~ \"^.*/xmlrpc.php$\")", "created_on": "2018-01-01T05:20:00.123Z", "modified_on": "2018-01-01T05:20:00.123Z"}]}' + responses.add(responses.PUT, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Construct a dict representation of a FilterUpdateInput model + filter_update_input_model = {} + filter_update_input_model['id'] = 'f2a64520581a4209aab12187a0081364' + filter_update_input_model['expression'] = 'not http.request.uri.path matches "^/api/.*$"' + filter_update_input_model['description'] = 'not /api' + filter_update_input_model['paused'] = False + + # Set up parameter values + x_auth_user_token = 'testString' + crn = 'testString' + zone_identifier = 'testString' + filter_update_input = [filter_update_input_model] + + # Invoke method + response = _service.update_filters( + x_auth_user_token, + crn, + zone_identifier, + filter_update_input=filter_update_input, + 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 == filter_update_input + + + @responses.activate + def test_update_filters_required_params(self): + """ + test_update_filters_required_params() + """ + # Set up mock + url = self.preprocess_url(_base_url + '/v1/testString/zones/testString/filters') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": [{"id": "6f58318e7fa2477a23112e8118c66f61", "paused": true, "description": "Login from office", "expression": "ip.src eq 93.184.216.0 and (http.request.uri.path ~ \"^.*/wp-login.php$\" or http.request.uri.path ~ \"^.*/xmlrpc.php$\")", "created_on": "2018-01-01T05:20:00.123Z", "modified_on": "2018-01-01T05:20:00.123Z"}]}' + responses.add(responses.PUT, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Set up parameter values + x_auth_user_token = 'testString' + crn = 'testString' + zone_identifier = 'testString' + + # Invoke method + response = _service.update_filters( + x_auth_user_token, + crn, + zone_identifier, + headers={} + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + + @responses.activate + def test_update_filters_value_error(self): + """ + test_update_filters_value_error() + """ + # Set up mock + url = self.preprocess_url(_base_url + '/v1/testString/zones/testString/filters') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": [{"id": "6f58318e7fa2477a23112e8118c66f61", "paused": true, "description": "Login from office", "expression": "ip.src eq 93.184.216.0 and (http.request.uri.path ~ \"^.*/wp-login.php$\" or http.request.uri.path ~ \"^.*/xmlrpc.php$\")", "created_on": "2018-01-01T05:20:00.123Z", "modified_on": "2018-01-01T05:20:00.123Z"}]}' + responses.add(responses.PUT, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Set up parameter values + x_auth_user_token = 'testString' + crn = 'testString' + zone_identifier = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "x_auth_user_token": x_auth_user_token, + "crn": crn, + "zone_identifier": zone_identifier, + } + 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_filters(**req_copy) + + + +class TestDeleteFilters(): + """ + Test Class for delete_filters + """ + + def preprocess_url(self, request_url: str): + """ + Preprocess the request URL to ensure the mock response will be found. + """ + if re.fullmatch('.*/+', request_url) is None: + return request_url + else: + return re.compile(request_url.rstrip('/') + '/+') + + @responses.activate + def test_delete_filters_all_params(self): + """ + delete_filters() + """ + # Set up mock + url = self.preprocess_url(_base_url + '/v1/testString/zones/testString/filters') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": [{"id": "b7ff25282d394be7b945e23c7106ce8a"}]}' + responses.add(responses.DELETE, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Set up parameter values + x_auth_user_token = 'testString' + crn = 'testString' + zone_identifier = 'testString' + id = 'b7ff25282d394be7b945e23c7106ce8a' + + # Invoke method + response = _service.delete_filters( + x_auth_user_token, + crn, + zone_identifier, + id, + headers={} + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + # Validate query params + query_string = responses.calls[0].request.url.split('?',1)[1] + query_string = urllib.parse.unquote_plus(query_string) + assert 'id={}'.format(id) in query_string + + + @responses.activate + def test_delete_filters_value_error(self): + """ + test_delete_filters_value_error() + """ + # Set up mock + url = self.preprocess_url(_base_url + '/v1/testString/zones/testString/filters') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": [{"id": "b7ff25282d394be7b945e23c7106ce8a"}]}' + responses.add(responses.DELETE, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Set up parameter values + x_auth_user_token = 'testString' + crn = 'testString' + zone_identifier = 'testString' + id = 'b7ff25282d394be7b945e23c7106ce8a' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "x_auth_user_token": x_auth_user_token, + "crn": crn, + "zone_identifier": zone_identifier, + "id": id, + } + for param in req_param_dict.keys(): + req_copy = {key:val if key is not param else None for (key,val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.delete_filters(**req_copy) + + + +class TestDeleteFilter(): + """ + Test Class for delete_filter + """ + + def preprocess_url(self, request_url: str): + """ + Preprocess the request URL to ensure the mock response will be found. + """ + if re.fullmatch('.*/+', request_url) is None: + return request_url + else: + return re.compile(request_url.rstrip('/') + '/+') + + @responses.activate + def test_delete_filter_all_params(self): + """ + delete_filter() + """ + # Set up mock + url = self.preprocess_url(_base_url + '/v1/testString/zones/testString/filters/testString') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"id": "b7ff25282d394be7b945e23c7106ce8a"}}' + responses.add(responses.DELETE, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Set up parameter values + x_auth_user_token = 'testString' + crn = 'testString' + zone_identifier = 'testString' + filter_identifier = 'testString' + + # Invoke method + response = _service.delete_filter( + x_auth_user_token, + crn, + zone_identifier, + filter_identifier, + headers={} + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + + @responses.activate + def test_delete_filter_value_error(self): + """ + test_delete_filter_value_error() + """ + # Set up mock + url = self.preprocess_url(_base_url + '/v1/testString/zones/testString/filters/testString') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"id": "b7ff25282d394be7b945e23c7106ce8a"}}' + responses.add(responses.DELETE, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Set up parameter values + x_auth_user_token = 'testString' + crn = 'testString' + zone_identifier = 'testString' + filter_identifier = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "x_auth_user_token": x_auth_user_token, + "crn": crn, + "zone_identifier": zone_identifier, + "filter_identifier": filter_identifier, + } + 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_filter(**req_copy) + + + +class TestGetFilter(): + """ + Test Class for get_filter + """ + + def preprocess_url(self, request_url: str): + """ + Preprocess the request URL to ensure the mock response will be found. + """ + if re.fullmatch('.*/+', request_url) is None: + return request_url + else: + return re.compile(request_url.rstrip('/') + '/+') + + @responses.activate + def test_get_filter_all_params(self): + """ + get_filter() + """ + # Set up mock + url = self.preprocess_url(_base_url + '/v1/testString/zones/testString/filters/testString') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"id": "6f58318e7fa2477a23112e8118c66f61", "paused": true, "description": "Login from office", "expression": "ip.src eq 93.184.216.0 and (http.request.uri.path ~ \"^.*/wp-login.php$\" or http.request.uri.path ~ \"^.*/xmlrpc.php$\")", "created_on": "2018-01-01T05:20:00.123Z", "modified_on": "2018-01-01T05:20:00.123Z"}}' + responses.add(responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Set up parameter values + x_auth_user_token = 'testString' + crn = 'testString' + zone_identifier = 'testString' + filter_identifier = 'testString' + + # Invoke method + response = _service.get_filter( + x_auth_user_token, + crn, + zone_identifier, + filter_identifier, + headers={} + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + + @responses.activate + def test_get_filter_value_error(self): + """ + test_get_filter_value_error() + """ + # Set up mock + url = self.preprocess_url(_base_url + '/v1/testString/zones/testString/filters/testString') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"id": "6f58318e7fa2477a23112e8118c66f61", "paused": true, "description": "Login from office", "expression": "ip.src eq 93.184.216.0 and (http.request.uri.path ~ \"^.*/wp-login.php$\" or http.request.uri.path ~ \"^.*/xmlrpc.php$\")", "created_on": "2018-01-01T05:20:00.123Z", "modified_on": "2018-01-01T05:20:00.123Z"}}' + responses.add(responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Set up parameter values + x_auth_user_token = 'testString' + crn = 'testString' + zone_identifier = 'testString' + filter_identifier = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "x_auth_user_token": x_auth_user_token, + "crn": crn, + "zone_identifier": zone_identifier, + "filter_identifier": filter_identifier, + } + 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_filter(**req_copy) + + + +class TestUpdateFilter(): + """ + Test Class for update_filter + """ + + def preprocess_url(self, request_url: str): + """ + Preprocess the request URL to ensure the mock response will be found. + """ + if re.fullmatch('.*/+', request_url) is None: + return request_url + else: + return re.compile(request_url.rstrip('/') + '/+') + + @responses.activate + def test_update_filter_all_params(self): + """ + update_filter() + """ + # Set up mock + url = self.preprocess_url(_base_url + '/v1/testString/zones/testString/filters/testString') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"id": "6f58318e7fa2477a23112e8118c66f61", "paused": true, "description": "Login from office", "expression": "ip.src eq 93.184.216.0 and (http.request.uri.path ~ \"^.*/wp-login.php$\" or http.request.uri.path ~ \"^.*/xmlrpc.php$\")", "created_on": "2018-01-01T05:20:00.123Z", "modified_on": "2018-01-01T05:20:00.123Z"}}' + responses.add(responses.PUT, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Set up parameter values + x_auth_user_token = 'testString' + crn = 'testString' + zone_identifier = 'testString' + filter_identifier = 'testString' + id = 'f2a64520581a4209aab12187a0081364' + expression = 'not http.request.uri.path matches "^/api/.*$"' + description = 'not /api' + paused = False + + # Invoke method + response = _service.update_filter( + x_auth_user_token, + crn, + zone_identifier, + filter_identifier, + id=id, + expression=expression, + description=description, + paused=paused, + 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['id'] == 'f2a64520581a4209aab12187a0081364' + assert req_body['expression'] == 'not http.request.uri.path matches "^/api/.*$"' + assert req_body['description'] == 'not /api' + assert req_body['paused'] == False + + + @responses.activate + def test_update_filter_required_params(self): + """ + test_update_filter_required_params() + """ + # Set up mock + url = self.preprocess_url(_base_url + '/v1/testString/zones/testString/filters/testString') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"id": "6f58318e7fa2477a23112e8118c66f61", "paused": true, "description": "Login from office", "expression": "ip.src eq 93.184.216.0 and (http.request.uri.path ~ \"^.*/wp-login.php$\" or http.request.uri.path ~ \"^.*/xmlrpc.php$\")", "created_on": "2018-01-01T05:20:00.123Z", "modified_on": "2018-01-01T05:20:00.123Z"}}' + responses.add(responses.PUT, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Set up parameter values + x_auth_user_token = 'testString' + crn = 'testString' + zone_identifier = 'testString' + filter_identifier = 'testString' + + # Invoke method + response = _service.update_filter( + x_auth_user_token, + crn, + zone_identifier, + filter_identifier, + headers={} + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + + @responses.activate + def test_update_filter_value_error(self): + """ + test_update_filter_value_error() + """ + # Set up mock + url = self.preprocess_url(_base_url + '/v1/testString/zones/testString/filters/testString') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"id": "6f58318e7fa2477a23112e8118c66f61", "paused": true, "description": "Login from office", "expression": "ip.src eq 93.184.216.0 and (http.request.uri.path ~ \"^.*/wp-login.php$\" or http.request.uri.path ~ \"^.*/xmlrpc.php$\")", "created_on": "2018-01-01T05:20:00.123Z", "modified_on": "2018-01-01T05:20:00.123Z"}}' + responses.add(responses.PUT, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Set up parameter values + x_auth_user_token = 'testString' + crn = 'testString' + zone_identifier = 'testString' + filter_identifier = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "x_auth_user_token": x_auth_user_token, + "crn": crn, + "zone_identifier": zone_identifier, + "filter_identifier": filter_identifier, + } + 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_filter(**req_copy) + + + +# endregion +############################################################################## +# End of Service: Filters +############################################################################## + + +############################################################################## +# Start of Model Tests +############################################################################## +# region +class TestDeleteFilterRespResult(): + """ + Test Class for DeleteFilterRespResult + """ + + def test_delete_filter_resp_result_serialization(self): + """ + Test serialization/deserialization for DeleteFilterRespResult + """ + + # Construct a json representation of a DeleteFilterRespResult model + delete_filter_resp_result_model_json = {} + delete_filter_resp_result_model_json['id'] = 'b7ff25282d394be7b945e23c7106ce8a' + + # Construct a model instance of DeleteFilterRespResult by calling from_dict on the json representation + delete_filter_resp_result_model = DeleteFilterRespResult.from_dict(delete_filter_resp_result_model_json) + assert delete_filter_resp_result_model != False + + # Construct a model instance of DeleteFilterRespResult by calling from_dict on the json representation + delete_filter_resp_result_model_dict = DeleteFilterRespResult.from_dict(delete_filter_resp_result_model_json).__dict__ + delete_filter_resp_result_model2 = DeleteFilterRespResult(**delete_filter_resp_result_model_dict) + + # Verify the model instances are equivalent + assert delete_filter_resp_result_model == delete_filter_resp_result_model2 + + # Convert model instance back to dict and verify no loss of data + delete_filter_resp_result_model_json2 = delete_filter_resp_result_model.to_dict() + assert delete_filter_resp_result_model_json2 == delete_filter_resp_result_model_json + +class TestDeleteFiltersRespResultItem(): + """ + Test Class for DeleteFiltersRespResultItem + """ + + def test_delete_filters_resp_result_item_serialization(self): + """ + Test serialization/deserialization for DeleteFiltersRespResultItem + """ + + # Construct a json representation of a DeleteFiltersRespResultItem model + delete_filters_resp_result_item_model_json = {} + delete_filters_resp_result_item_model_json['id'] = 'b7ff25282d394be7b945e23c7106ce8a' + + # Construct a model instance of DeleteFiltersRespResultItem by calling from_dict on the json representation + delete_filters_resp_result_item_model = DeleteFiltersRespResultItem.from_dict(delete_filters_resp_result_item_model_json) + assert delete_filters_resp_result_item_model != False + + # Construct a model instance of DeleteFiltersRespResultItem by calling from_dict on the json representation + delete_filters_resp_result_item_model_dict = DeleteFiltersRespResultItem.from_dict(delete_filters_resp_result_item_model_json).__dict__ + delete_filters_resp_result_item_model2 = DeleteFiltersRespResultItem(**delete_filters_resp_result_item_model_dict) + + # Verify the model instances are equivalent + assert delete_filters_resp_result_item_model == delete_filters_resp_result_item_model2 + + # Convert model instance back to dict and verify no loss of data + delete_filters_resp_result_item_model_json2 = delete_filters_resp_result_item_model.to_dict() + assert delete_filters_resp_result_item_model_json2 == delete_filters_resp_result_item_model_json + +class TestListFiltersRespResultInfo(): + """ + Test Class for ListFiltersRespResultInfo + """ + + def test_list_filters_resp_result_info_serialization(self): + """ + Test serialization/deserialization for ListFiltersRespResultInfo + """ + + # Construct a json representation of a ListFiltersRespResultInfo model + list_filters_resp_result_info_model_json = {} + list_filters_resp_result_info_model_json['page'] = 1 + list_filters_resp_result_info_model_json['per_page'] = 2 + list_filters_resp_result_info_model_json['count'] = 1 + list_filters_resp_result_info_model_json['total_count'] = 200 + + # Construct a model instance of ListFiltersRespResultInfo by calling from_dict on the json representation + list_filters_resp_result_info_model = ListFiltersRespResultInfo.from_dict(list_filters_resp_result_info_model_json) + assert list_filters_resp_result_info_model != False + + # Construct a model instance of ListFiltersRespResultInfo by calling from_dict on the json representation + list_filters_resp_result_info_model_dict = ListFiltersRespResultInfo.from_dict(list_filters_resp_result_info_model_json).__dict__ + list_filters_resp_result_info_model2 = ListFiltersRespResultInfo(**list_filters_resp_result_info_model_dict) + + # Verify the model instances are equivalent + assert list_filters_resp_result_info_model == list_filters_resp_result_info_model2 + + # Convert model instance back to dict and verify no loss of data + list_filters_resp_result_info_model_json2 = list_filters_resp_result_info_model.to_dict() + assert list_filters_resp_result_info_model_json2 == list_filters_resp_result_info_model_json + +class TestDeleteFilterResp(): + """ + Test Class for DeleteFilterResp + """ + + def test_delete_filter_resp_serialization(self): + """ + Test serialization/deserialization for DeleteFilterResp + """ + + # Construct dict forms of any model objects needed in order to build this model. + + delete_filter_resp_result_model = {} # DeleteFilterRespResult + delete_filter_resp_result_model['id'] = 'b7ff25282d394be7b945e23c7106ce8a' + + # Construct a json representation of a DeleteFilterResp model + delete_filter_resp_model_json = {} + delete_filter_resp_model_json['success'] = True + delete_filter_resp_model_json['errors'] = [['testString']] + delete_filter_resp_model_json['messages'] = [['testString']] + delete_filter_resp_model_json['result'] = delete_filter_resp_result_model + + # Construct a model instance of DeleteFilterResp by calling from_dict on the json representation + delete_filter_resp_model = DeleteFilterResp.from_dict(delete_filter_resp_model_json) + assert delete_filter_resp_model != False + + # Construct a model instance of DeleteFilterResp by calling from_dict on the json representation + delete_filter_resp_model_dict = DeleteFilterResp.from_dict(delete_filter_resp_model_json).__dict__ + delete_filter_resp_model2 = DeleteFilterResp(**delete_filter_resp_model_dict) + + # Verify the model instances are equivalent + assert delete_filter_resp_model == delete_filter_resp_model2 + + # Convert model instance back to dict and verify no loss of data + delete_filter_resp_model_json2 = delete_filter_resp_model.to_dict() + assert delete_filter_resp_model_json2 == delete_filter_resp_model_json + +class TestDeleteFiltersResp(): + """ + Test Class for DeleteFiltersResp + """ + + def test_delete_filters_resp_serialization(self): + """ + Test serialization/deserialization for DeleteFiltersResp + """ + + # Construct dict forms of any model objects needed in order to build this model. + + delete_filters_resp_result_item_model = {} # DeleteFiltersRespResultItem + delete_filters_resp_result_item_model['id'] = 'b7ff25282d394be7b945e23c7106ce8a' + + # Construct a json representation of a DeleteFiltersResp model + delete_filters_resp_model_json = {} + delete_filters_resp_model_json['success'] = True + delete_filters_resp_model_json['errors'] = [['testString']] + delete_filters_resp_model_json['messages'] = [['testString']] + delete_filters_resp_model_json['result'] = [delete_filters_resp_result_item_model] + + # Construct a model instance of DeleteFiltersResp by calling from_dict on the json representation + delete_filters_resp_model = DeleteFiltersResp.from_dict(delete_filters_resp_model_json) + assert delete_filters_resp_model != False + + # Construct a model instance of DeleteFiltersResp by calling from_dict on the json representation + delete_filters_resp_model_dict = DeleteFiltersResp.from_dict(delete_filters_resp_model_json).__dict__ + delete_filters_resp_model2 = DeleteFiltersResp(**delete_filters_resp_model_dict) + + # Verify the model instances are equivalent + assert delete_filters_resp_model == delete_filters_resp_model2 + + # Convert model instance back to dict and verify no loss of data + delete_filters_resp_model_json2 = delete_filters_resp_model.to_dict() + assert delete_filters_resp_model_json2 == delete_filters_resp_model_json + +class TestFilterInput(): + """ + Test Class for FilterInput + """ + + def test_filter_input_serialization(self): + """ + Test serialization/deserialization for FilterInput + """ + + # Construct a json representation of a FilterInput model + filter_input_model_json = {} + filter_input_model_json['expression'] = 'not http.request.uri.path matches "^/api/.*$"' + filter_input_model_json['paused'] = False + filter_input_model_json['description'] = 'not /api' + + # Construct a model instance of FilterInput by calling from_dict on the json representation + filter_input_model = FilterInput.from_dict(filter_input_model_json) + assert filter_input_model != False + + # Construct a model instance of FilterInput by calling from_dict on the json representation + filter_input_model_dict = FilterInput.from_dict(filter_input_model_json).__dict__ + filter_input_model2 = FilterInput(**filter_input_model_dict) + + # Verify the model instances are equivalent + assert filter_input_model == filter_input_model2 + + # Convert model instance back to dict and verify no loss of data + filter_input_model_json2 = filter_input_model.to_dict() + assert filter_input_model_json2 == filter_input_model_json + +class TestFilterObject(): + """ + Test Class for FilterObject + """ + + def test_filter_object_serialization(self): + """ + Test serialization/deserialization for FilterObject + """ + + # Construct a json representation of a FilterObject model + filter_object_model_json = {} + filter_object_model_json['id'] = '6f58318e7fa2477a23112e8118c66f61' + filter_object_model_json['paused'] = True + filter_object_model_json['description'] = 'Login from office' + filter_object_model_json['expression'] = 'ip.src eq 93.184.216.0 and (http.request.uri.path ~ \"^.*/wp-login.php$\" or http.request.uri.path ~ \"^.*/xmlrpc.php$\")' + filter_object_model_json['created_on'] = '2018-01-01T05:20:00.123Z' + filter_object_model_json['modified_on'] = '2018-01-01T05:20:00.123Z' + + # Construct a model instance of FilterObject by calling from_dict on the json representation + filter_object_model = FilterObject.from_dict(filter_object_model_json) + assert filter_object_model != False + + # Construct a model instance of FilterObject by calling from_dict on the json representation + filter_object_model_dict = FilterObject.from_dict(filter_object_model_json).__dict__ + filter_object_model2 = FilterObject(**filter_object_model_dict) + + # Verify the model instances are equivalent + assert filter_object_model == filter_object_model2 + + # Convert model instance back to dict and verify no loss of data + filter_object_model_json2 = filter_object_model.to_dict() + assert filter_object_model_json2 == filter_object_model_json + +class TestFilterResp(): + """ + Test Class for FilterResp + """ + + def test_filter_resp_serialization(self): + """ + Test serialization/deserialization for FilterResp + """ + + # Construct dict forms of any model objects needed in order to build this model. + + filter_object_model = {} # FilterObject + filter_object_model['id'] = '6f58318e7fa2477a23112e8118c66f61' + filter_object_model['paused'] = True + filter_object_model['description'] = 'Login from office' + filter_object_model['expression'] = 'ip.src eq 93.184.216.0 and (http.request.uri.path ~ \"^.*/wp-login.php$\" or http.request.uri.path ~ \"^.*/xmlrpc.php$\")' + filter_object_model['created_on'] = '2018-01-01T05:20:00.123Z' + filter_object_model['modified_on'] = '2018-01-01T05:20:00.123Z' + + # Construct a json representation of a FilterResp model + filter_resp_model_json = {} + filter_resp_model_json['success'] = True + filter_resp_model_json['errors'] = [['testString']] + filter_resp_model_json['messages'] = [['testString']] + filter_resp_model_json['result'] = filter_object_model + + # Construct a model instance of FilterResp by calling from_dict on the json representation + filter_resp_model = FilterResp.from_dict(filter_resp_model_json) + assert filter_resp_model != False + + # Construct a model instance of FilterResp by calling from_dict on the json representation + filter_resp_model_dict = FilterResp.from_dict(filter_resp_model_json).__dict__ + filter_resp_model2 = FilterResp(**filter_resp_model_dict) + + # Verify the model instances are equivalent + assert filter_resp_model == filter_resp_model2 + + # Convert model instance back to dict and verify no loss of data + filter_resp_model_json2 = filter_resp_model.to_dict() + assert filter_resp_model_json2 == filter_resp_model_json + +class TestFilterUpdateInput(): + """ + Test Class for FilterUpdateInput + """ + + def test_filter_update_input_serialization(self): + """ + Test serialization/deserialization for FilterUpdateInput + """ + + # Construct a json representation of a FilterUpdateInput model + filter_update_input_model_json = {} + filter_update_input_model_json['id'] = 'f2a64520581a4209aab12187a0081364' + filter_update_input_model_json['expression'] = 'not http.request.uri.path matches "^/api/.*$"' + filter_update_input_model_json['description'] = 'not /api' + filter_update_input_model_json['paused'] = False + + # Construct a model instance of FilterUpdateInput by calling from_dict on the json representation + filter_update_input_model = FilterUpdateInput.from_dict(filter_update_input_model_json) + assert filter_update_input_model != False + + # Construct a model instance of FilterUpdateInput by calling from_dict on the json representation + filter_update_input_model_dict = FilterUpdateInput.from_dict(filter_update_input_model_json).__dict__ + filter_update_input_model2 = FilterUpdateInput(**filter_update_input_model_dict) + + # Verify the model instances are equivalent + assert filter_update_input_model == filter_update_input_model2 + + # Convert model instance back to dict and verify no loss of data + filter_update_input_model_json2 = filter_update_input_model.to_dict() + assert filter_update_input_model_json2 == filter_update_input_model_json + +class TestFiltersResp(): + """ + Test Class for FiltersResp + """ + + def test_filters_resp_serialization(self): + """ + Test serialization/deserialization for FiltersResp + """ + + # Construct dict forms of any model objects needed in order to build this model. + + filter_object_model = {} # FilterObject + filter_object_model['id'] = '6f58318e7fa2477a23112e8118c66f61' + filter_object_model['paused'] = True + filter_object_model['description'] = 'Login from office' + filter_object_model['expression'] = 'ip.src eq 93.184.216.0 and (http.request.uri.path ~ \"^.*/wp-login.php$\" or http.request.uri.path ~ \"^.*/xmlrpc.php$\")' + filter_object_model['created_on'] = '2018-01-01T05:20:00.123Z' + filter_object_model['modified_on'] = '2018-01-01T05:20:00.123Z' + + # Construct a json representation of a FiltersResp model + filters_resp_model_json = {} + filters_resp_model_json['success'] = True + filters_resp_model_json['errors'] = [['testString']] + filters_resp_model_json['messages'] = [['testString']] + filters_resp_model_json['result'] = [filter_object_model] + + # Construct a model instance of FiltersResp by calling from_dict on the json representation + filters_resp_model = FiltersResp.from_dict(filters_resp_model_json) + assert filters_resp_model != False + + # Construct a model instance of FiltersResp by calling from_dict on the json representation + filters_resp_model_dict = FiltersResp.from_dict(filters_resp_model_json).__dict__ + filters_resp_model2 = FiltersResp(**filters_resp_model_dict) + + # Verify the model instances are equivalent + assert filters_resp_model == filters_resp_model2 + + # Convert model instance back to dict and verify no loss of data + filters_resp_model_json2 = filters_resp_model.to_dict() + assert filters_resp_model_json2 == filters_resp_model_json + +class TestListFiltersResp(): + """ + Test Class for ListFiltersResp + """ + + def test_list_filters_resp_serialization(self): + """ + Test serialization/deserialization for ListFiltersResp + """ + + # Construct dict forms of any model objects needed in order to build this model. + + filter_object_model = {} # FilterObject + filter_object_model['id'] = '6f58318e7fa2477a23112e8118c66f61' + filter_object_model['paused'] = True + filter_object_model['description'] = 'Login from office' + filter_object_model['expression'] = 'ip.src eq 93.184.216.0 and (http.request.uri.path ~ \"^.*/wp-login.php$\" or http.request.uri.path ~ \"^.*/xmlrpc.php$\")' + filter_object_model['created_on'] = '2018-01-01T05:20:00.123Z' + filter_object_model['modified_on'] = '2018-01-01T05:20:00.123Z' + + list_filters_resp_result_info_model = {} # ListFiltersRespResultInfo + list_filters_resp_result_info_model['page'] = 1 + list_filters_resp_result_info_model['per_page'] = 2 + list_filters_resp_result_info_model['count'] = 1 + list_filters_resp_result_info_model['total_count'] = 200 + + # Construct a json representation of a ListFiltersResp model + list_filters_resp_model_json = {} + list_filters_resp_model_json['success'] = True + list_filters_resp_model_json['errors'] = [['testString']] + list_filters_resp_model_json['messages'] = [['testString']] + list_filters_resp_model_json['result'] = [filter_object_model] + list_filters_resp_model_json['result_info'] = list_filters_resp_result_info_model + + # Construct a model instance of ListFiltersResp by calling from_dict on the json representation + list_filters_resp_model = ListFiltersResp.from_dict(list_filters_resp_model_json) + assert list_filters_resp_model != False + + # Construct a model instance of ListFiltersResp by calling from_dict on the json representation + list_filters_resp_model_dict = ListFiltersResp.from_dict(list_filters_resp_model_json).__dict__ + list_filters_resp_model2 = ListFiltersResp(**list_filters_resp_model_dict) + + # Verify the model instances are equivalent + assert list_filters_resp_model == list_filters_resp_model2 + + # Convert model instance back to dict and verify no loss of data + list_filters_resp_model_json2 = list_filters_resp_model.to_dict() + assert list_filters_resp_model_json2 == list_filters_resp_model_json + + +# endregion +############################################################################## +# End of Model Tests +##############################################################################