diff --git a/ibm_cloud_networking_services/lists_api_v1.py b/ibm_cloud_networking_services/lists_api_v1.py new file mode 100644 index 0000000..71d3453 --- /dev/null +++ b/ibm_cloud_networking_services/lists_api_v1.py @@ -0,0 +1,2233 @@ +# coding: utf-8 + +# (C) Copyright IBM Corp. 2026. +# +# 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.114.0-a902401e-20260427-192904 + +""" +CIS Lists + +API Version: 1.0.0 +""" + +from enum import Enum +from typing import Dict, List, Optional +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 ListsApiV1(BaseService): + """The Lists API V1 service.""" + + DEFAULT_SERVICE_URL = 'https://api.cis.cloud.ibm.com' + DEFAULT_SERVICE_NAME = 'lists_api' + + @classmethod + def new_instance( + cls, + crn: str, + item_id: str, + list_id: str, + operation_id: str, + service_name: str = DEFAULT_SERVICE_NAME, + ) -> 'ListsApiV1': + """ + Return a new client for the Lists API service using the specified + parameters and external configuration. + + :param str crn: Full URL-encoded CRN of the service instance. + + :param str item_id: List item identifier. + + :param str list_id: List identifier. + + :param str operation_id: List operation identifier. + """ + if crn is None: + raise ValueError('crn must be provided') + if item_id is None: + raise ValueError('item_id must be provided') + if list_id is None: + raise ValueError('list_id must be provided') + if operation_id is None: + raise ValueError('operation_id must be provided') + + authenticator = get_authenticator_from_environment(service_name) + service = cls( + crn, + item_id, + list_id, + operation_id, + authenticator + ) + service.configure_service(service_name) + return service + + def __init__( + self, + crn: str, + item_id: str, + list_id: str, + operation_id: str, + authenticator: Authenticator = None, + ) -> None: + """ + Construct a new client for the Lists API service. + + :param str crn: Full URL-encoded CRN of the service instance. + + :param str item_id: List item identifier. + + :param str list_id: List identifier. + + :param str operation_id: List operation identifier. + + :param Authenticator authenticator: The authenticator specifies the authentication mechanism. + Get up to date information from https://github.com/IBM/python-sdk-core/blob/main/README.md + about initializing the authenticator of your choice. + """ + if crn is None: + raise ValueError('crn must be provided') + if item_id is None: + raise ValueError('item_id must be provided') + if list_id is None: + raise ValueError('list_id must be provided') + if operation_id is None: + raise ValueError('operation_id must be provided') + + BaseService.__init__(self, service_url=self.DEFAULT_SERVICE_URL, authenticator=authenticator) + self.crn = crn + self.item_id = item_id + self.list_id = list_id + self.operation_id = operation_id + + ######################### + # Lists + ######################### + + def get_managed_lists( + self, + **kwargs, + ) -> DetailedResponse: + """ + List Managed Lists. + + List available managed lists for your instance. + + :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 `ManagedListsResp` object + """ + + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='get_managed_lists', + ) + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['crn'] + path_param_values = self.encode_path_vars(self.crn) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/rules/managed_lists'.format(**path_param_dict) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + ) + + response = self.send(request, **kwargs) + return response + + def get_custom_lists( + self, + **kwargs, + ) -> DetailedResponse: + """ + List Custom Lists. + + List the custom lists for your instance. + + :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 `CustomListsResp` object + """ + + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='get_custom_lists', + ) + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['crn'] + path_param_values = self.encode_path_vars(self.crn) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/rules/lists'.format(**path_param_dict) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + ) + + response = self.send(request, **kwargs) + return response + + def create_custom_lists( + self, + *, + kind: Optional[str] = None, + name: Optional[str] = None, + description: Optional[str] = None, + **kwargs, + ) -> DetailedResponse: + """ + Create Custom List. + + Create a custom list for your instance. + + :param str kind: (optional) The type of list. Each type supports specific + list items (IP addresses, ASNs, hostnames or redirects). + :param str name: (optional) An informative name for the list. Use this name + in rule expressions. + :param str description: (optional) An informative summary of the list. + :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 `CustomListResp` object + """ + + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='create_custom_lists', + ) + headers.update(sdk_headers) + + data = { + 'kind': kind, + 'name': name, + 'description': description, + } + data = {k: v for (k, v) in data.items() if v is not None} + data = json.dumps(data) + headers['content-type'] = 'application/json' + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['crn'] + path_param_values = self.encode_path_vars(self.crn) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/rules/lists'.format(**path_param_dict) + request = self.prepare_request( + method='POST', + url=url, + headers=headers, + data=data, + ) + + response = self.send(request, **kwargs) + return response + + def get_custom_list( + self, + **kwargs, + ) -> DetailedResponse: + """ + Get Custom List. + + Get a custom list for your instance. + + :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 `CustomListResp` object + """ + + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='get_custom_list', + ) + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'list_id'] + path_param_values = self.encode_path_vars(self.crn, self.list_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/rules/lists/{list_id}'.format(**path_param_dict) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + ) + + response = self.send(request, **kwargs) + return response + + def update_custom_list( + self, + *, + description: Optional[str] = None, + **kwargs, + ) -> DetailedResponse: + """ + Update Custom List. + + Update the description of a custom list. + + :param str description: (optional) An informative summary of the list. + :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 `CustomListResp` object + """ + + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='update_custom_list', + ) + headers.update(sdk_headers) + + data = { + 'description': description, + } + data = {k: v for (k, v) in data.items() if v is not None} + data = json.dumps(data) + headers['content-type'] = 'application/json' + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'list_id'] + path_param_values = self.encode_path_vars(self.crn, self.list_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/rules/lists/{list_id}'.format(**path_param_dict) + request = self.prepare_request( + method='PUT', + url=url, + headers=headers, + data=data, + ) + + response = self.send(request, **kwargs) + return response + + def delete_custom_list( + self, + **kwargs, + ) -> DetailedResponse: + """ + Delete Custom List. + + Delete a custom list for your instance. + + :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 `DeleteResourceResp` object + """ + + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='delete_custom_list', + ) + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'list_id'] + path_param_values = self.encode_path_vars(self.crn, self.list_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/rules/lists/{list_id}'.format(**path_param_dict) + request = self.prepare_request( + method='DELETE', + url=url, + headers=headers, + ) + + response = self.send(request, **kwargs) + return response + + def get_list_items( + self, + *, + cursor: Optional[str] = None, + per_page: Optional[int] = None, + search: Optional[str] = None, + **kwargs, + ) -> DetailedResponse: + """ + Get List Items. + + Get the list items for a custom list. + + :param str cursor: (optional) The pagination cursor. An opaque string token + indicating the position from which to continue when requesting the + next/previous set of records. Cursor values are provided under + result_info.cursors in the response. + :param int per_page: (optional) Amount of results to include in each + paginated response. A non-negative 32 bit integer. Minimum 1, maximum 500. + :param str search: (optional) A search query to filter returned items. Its + meaning depends on the list type: IP addresses must start with the provided + string, hostnames and bulk redirects must contain the string, and ASNs must + match the string exactly. + :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 `ListItemsResp` object + """ + + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='get_list_items', + ) + headers.update(sdk_headers) + + params = { + 'cursor': cursor, + 'per_page': per_page, + 'search': search, + } + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'list_id'] + path_param_values = self.encode_path_vars(self.crn, self.list_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/rules/lists/{list_id}/items'.format(**path_param_dict) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + params=params, + ) + + response = self.send(request, **kwargs) + return response + + def create_list_items( + self, + *, + create_list_items_req_item: Optional[List['CreateListItemsReqItem']] = None, + **kwargs, + ) -> DetailedResponse: + """ + Create List Items. + + Create list items for your custom list. This operation is asynchronous. To get + current the operation status, use the get operation status API. + + :param List[CreateListItemsReqItem] create_list_items_req_item: (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 `ListOperationResp` object + """ + + if create_list_items_req_item is not None: + create_list_items_req_item = [convert_model(x) for x in create_list_items_req_item] + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='create_list_items', + ) + headers.update(sdk_headers) + + data = json.dumps(create_list_items_req_item) + headers['content-type'] = 'application/json' + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'list_id'] + path_param_values = self.encode_path_vars(self.crn, self.list_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/rules/lists/{list_id}/items'.format(**path_param_dict) + request = self.prepare_request( + method='POST', + url=url, + headers=headers, + data=data, + ) + + response = self.send(request, **kwargs) + return response + + def delete_list_items( + self, + *, + items: Optional[List['DeleteListItemsReqItemsItem']] = None, + **kwargs, + ) -> DetailedResponse: + """ + Delete List Items. + + Remove one or more list items from your custom list. This operation is + asynchronous. To get current the operation status, use the get operation status + API. + + :param List[DeleteListItemsReqItemsItem] items: (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 `ListOperationResp` object + """ + + if items is not None: + items = [convert_model(x) for x in items] + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='delete_list_items', + ) + headers.update(sdk_headers) + + data = { + 'items': items, + } + data = {k: v for (k, v) in data.items() if v is not None} + data = json.dumps(data) + headers['content-type'] = 'application/json' + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'list_id'] + path_param_values = self.encode_path_vars(self.crn, self.list_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/rules/lists/{list_id}/items'.format(**path_param_dict) + request = self.prepare_request( + method='DELETE', + url=url, + headers=headers, + data=data, + ) + + response = self.send(request, **kwargs) + return response + + def update_list_items( + self, + *, + create_list_items_req_item: Optional[List['CreateListItemsReqItem']] = None, + **kwargs, + ) -> DetailedResponse: + """ + Update All List Items. + + Update all list items for your custom list. This removes existing items from the + list. This operation is asynchronous. To get current the operation status, use the + get operation status API. + + :param List[CreateListItemsReqItem] create_list_items_req_item: (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 `ListOperationResp` object + """ + + if create_list_items_req_item is not None: + create_list_items_req_item = [convert_model(x) for x in create_list_items_req_item] + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='update_list_items', + ) + headers.update(sdk_headers) + + data = json.dumps(create_list_items_req_item) + headers['content-type'] = 'application/json' + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'list_id'] + path_param_values = self.encode_path_vars(self.crn, self.list_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/rules/lists/{list_id}/items'.format(**path_param_dict) + request = self.prepare_request( + method='PUT', + url=url, + headers=headers, + data=data, + ) + + response = self.send(request, **kwargs) + return response + + def get_list_item( + self, + **kwargs, + ) -> DetailedResponse: + """ + Get List Item. + + Get a specific list item. + + :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 `ListItemResp` object + """ + + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='get_list_item', + ) + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'list_id', 'item_id'] + path_param_values = self.encode_path_vars(self.crn, self.list_id, self.item_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/rules/lists/{list_id}/items/{item_id}'.format(**path_param_dict) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + ) + + response = self.send(request, **kwargs) + return response + + def get_operation_status( + self, + **kwargs, + ) -> DetailedResponse: + """ + Get List Operation Status. + + Get the operation status for a custom list operation. + + :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 `OperationStatusResp` object + """ + + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='get_operation_status', + ) + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'operation_id'] + path_param_values = self.encode_path_vars(self.crn, self.operation_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/rules/lists/bulk_operations/{operation_id}'.format(**path_param_dict) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + ) + + response = self.send(request, **kwargs) + return response + + +############################################################################## +# Models +############################################################################## + + +class CreateListItemsReqItem: + """ + CreateListItemsReqItem. + + :param float asn: (optional) An autonomous system number. + :param str comment: (optional) An informative summary of the list item. + :param str hostname: (optional) Valid characters for hostnames are ASCII(7) + letters from a to z, the digits from 0 to 9, wildcards (*), and the hyphen (-). + :param str ip: (optional) An IPv4 address, an IPv4 CIDR, or an IPv6 CIDR. IPv6 + CIDRs are limited to a maximum of /64. + """ + + def __init__( + self, + *, + asn: Optional[float] = None, + comment: Optional[str] = None, + hostname: Optional[str] = None, + ip: Optional[str] = None, + ) -> None: + """ + Initialize a CreateListItemsReqItem object. + + :param float asn: (optional) An autonomous system number. + :param str comment: (optional) An informative summary of the list item. + :param str hostname: (optional) Valid characters for hostnames are ASCII(7) + letters from a to z, the digits from 0 to 9, wildcards (*), and the hyphen + (-). + :param str ip: (optional) An IPv4 address, an IPv4 CIDR, or an IPv6 CIDR. + IPv6 CIDRs are limited to a maximum of /64. + """ + self.asn = asn + self.comment = comment + self.hostname = hostname + self.ip = ip + + @classmethod + def from_dict(cls, _dict: Dict) -> 'CreateListItemsReqItem': + """Initialize a CreateListItemsReqItem object from a json dictionary.""" + args = {} + if (asn := _dict.get('asn')) is not None: + args['asn'] = asn + if (comment := _dict.get('comment')) is not None: + args['comment'] = comment + if (hostname := _dict.get('hostname')) is not None: + args['hostname'] = hostname + if (ip := _dict.get('ip')) is not None: + args['ip'] = ip + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a CreateListItemsReqItem 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, 'asn') and self.asn is not None: + _dict['asn'] = self.asn + if hasattr(self, 'comment') and self.comment is not None: + _dict['comment'] = self.comment + if hasattr(self, 'hostname') and self.hostname is not None: + _dict['hostname'] = self.hostname + if hasattr(self, 'ip') and self.ip is not None: + _dict['ip'] = self.ip + 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 CreateListItemsReqItem object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'CreateListItemsReqItem') -> 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: 'CreateListItemsReqItem') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class DeleteListItemsReqItemsItem: + """ + DeleteListItemsReqItemsItem. + + :param str id: (optional) + """ + + def __init__( + self, + *, + id: Optional[str] = None, + ) -> None: + """ + Initialize a DeleteListItemsReqItemsItem object. + + :param str id: (optional) + """ + self.id = id + + @classmethod + def from_dict(cls, _dict: Dict) -> 'DeleteListItemsReqItemsItem': + """Initialize a DeleteListItemsReqItemsItem object from a json dictionary.""" + args = {} + if (id := _dict.get('id')) is not None: + args['id'] = id + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a DeleteListItemsReqItemsItem 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 DeleteListItemsReqItemsItem object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'DeleteListItemsReqItemsItem') -> 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: 'DeleteListItemsReqItemsItem') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class DeleteResourceRespResult: + """ + DeleteResourceRespResult. + + :param str id: (optional) + """ + + def __init__( + self, + *, + id: Optional[str] = None, + ) -> None: + """ + Initialize a DeleteResourceRespResult object. + + :param str id: (optional) + """ + self.id = id + + @classmethod + def from_dict(cls, _dict: Dict) -> 'DeleteResourceRespResult': + """Initialize a DeleteResourceRespResult object from a json dictionary.""" + args = {} + if (id := _dict.get('id')) is not None: + args['id'] = id + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a DeleteResourceRespResult 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 DeleteResourceRespResult object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'DeleteResourceRespResult') -> 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: 'DeleteResourceRespResult') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class ListOperationRespResult: + """ + ListOperationRespResult. + + :param str operation_id: (optional) + """ + + def __init__( + self, + *, + operation_id: Optional[str] = None, + ) -> None: + """ + Initialize a ListOperationRespResult object. + + :param str operation_id: (optional) + """ + self.operation_id = operation_id + + @classmethod + def from_dict(cls, _dict: Dict) -> 'ListOperationRespResult': + """Initialize a ListOperationRespResult object from a json dictionary.""" + args = {} + if (operation_id := _dict.get('operation_id')) is not None: + args['operation_id'] = operation_id + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a ListOperationRespResult 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, 'operation_id') and self.operation_id is not None: + _dict['operation_id'] = self.operation_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 ListOperationRespResult object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'ListOperationRespResult') -> 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: 'ListOperationRespResult') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class ManagedListsResultItem: + """ + ManagedListsResultItem. + + :param str name: (optional) The name of the list to be referenced by rule + expressions. + :param str description: (optional) Describes the contents of the managed list. + :param str kind: (optional) The type of resource this list contains. + """ + + def __init__( + self, + *, + name: Optional[str] = None, + description: Optional[str] = None, + kind: Optional[str] = None, + ) -> None: + """ + Initialize a ManagedListsResultItem object. + + :param str name: (optional) The name of the list to be referenced by rule + expressions. + :param str description: (optional) Describes the contents of the managed + list. + :param str kind: (optional) The type of resource this list contains. + """ + self.name = name + self.description = description + self.kind = kind + + @classmethod + def from_dict(cls, _dict: Dict) -> 'ManagedListsResultItem': + """Initialize a ManagedListsResultItem object from a json dictionary.""" + args = {} + if (name := _dict.get('name')) is not None: + args['name'] = name + if (description := _dict.get('description')) is not None: + args['description'] = description + if (kind := _dict.get('kind')) is not None: + args['kind'] = kind + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a ManagedListsResultItem object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'name') and self.name is not None: + _dict['name'] = self.name + if hasattr(self, 'description') and self.description is not None: + _dict['description'] = self.description + if hasattr(self, 'kind') and self.kind is not None: + _dict['kind'] = self.kind + 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 ManagedListsResultItem object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'ManagedListsResultItem') -> 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: 'ManagedListsResultItem') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class OperationStatusRespResult: + """ + OperationStatusRespResult. + + :param str id: (optional) + :param str status: (optional) + :param str completed: (optional) + :param str error: (optional) A message describing the error when the status is + failed. + """ + + def __init__( + self, + *, + id: Optional[str] = None, + status: Optional[str] = None, + completed: Optional[str] = None, + error: Optional[str] = None, + ) -> None: + """ + Initialize a OperationStatusRespResult object. + + :param str id: (optional) + :param str status: (optional) + :param str completed: (optional) + :param str error: (optional) A message describing the error when the status + is failed. + """ + self.id = id + self.status = status + self.completed = completed + self.error = error + + @classmethod + def from_dict(cls, _dict: Dict) -> 'OperationStatusRespResult': + """Initialize a OperationStatusRespResult object from a json dictionary.""" + args = {} + if (id := _dict.get('id')) is not None: + args['id'] = id + if (status := _dict.get('status')) is not None: + args['status'] = status + if (completed := _dict.get('completed')) is not None: + args['completed'] = completed + if (error := _dict.get('error')) is not None: + args['error'] = error + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a OperationStatusRespResult 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, 'status') and self.status is not None: + _dict['status'] = self.status + if hasattr(self, 'completed') and self.completed is not None: + _dict['completed'] = self.completed + if hasattr(self, 'error') and self.error is not None: + _dict['error'] = self.error + 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 OperationStatusRespResult object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'OperationStatusRespResult') -> 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: 'OperationStatusRespResult') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + class StatusEnum(str, Enum): + """ + status. + """ + + PENDING = 'pending' + RUNNING = 'running' + COMPLETED = 'completed' + FAILED = 'failed' + + + +class CustomListResp: + """ + Create Custom List Response. + + :param bool success: Was operation successful. + :param List[List[str]] errors: Errors. + :param List[List[str]] messages: Messages. + :param CustomListResult result: + """ + + def __init__( + self, + success: bool, + errors: List[List[str]], + messages: List[List[str]], + result: 'CustomListResult', + ) -> None: + """ + Initialize a CustomListResp object. + + :param bool success: Was operation successful. + :param List[List[str]] errors: Errors. + :param List[List[str]] messages: Messages. + :param CustomListResult result: + """ + self.success = success + self.errors = errors + self.messages = messages + self.result = result + + @classmethod + def from_dict(cls, _dict: Dict) -> 'CustomListResp': + """Initialize a CustomListResp object from a json dictionary.""" + args = {} + if (success := _dict.get('success')) is not None: + args['success'] = success + else: + raise ValueError('Required property \'success\' not present in CustomListResp JSON') + if (errors := _dict.get('errors')) is not None: + args['errors'] = errors + else: + raise ValueError('Required property \'errors\' not present in CustomListResp JSON') + if (messages := _dict.get('messages')) is not None: + args['messages'] = messages + else: + raise ValueError('Required property \'messages\' not present in CustomListResp JSON') + if (result := _dict.get('result')) is not None: + args['result'] = CustomListResult.from_dict(result) + else: + raise ValueError('Required property \'result\' not present in CustomListResp JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a CustomListResp 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: + if isinstance(self.result, dict): + _dict['result'] = self.result + else: + _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 CustomListResp object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'CustomListResp') -> 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: 'CustomListResp') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class CustomListResult: + """ + CustomListResult. + + :param str name: (optional) The name of the list to be referenced by rule + expressions. + :param str id: (optional) The unique ID of the list. + :param str description: (optional) Describes the contents of the list. + :param str kind: (optional) The type of resource this list contains. + :param float num_items: (optional) How many items the list contains. + :param float num_referencing_filters: (optional) How many times the list is used + by rule expressions. + """ + + def __init__( + self, + *, + name: Optional[str] = None, + id: Optional[str] = None, + description: Optional[str] = None, + kind: Optional[str] = None, + num_items: Optional[float] = None, + num_referencing_filters: Optional[float] = None, + ) -> None: + """ + Initialize a CustomListResult object. + + :param str name: (optional) The name of the list to be referenced by rule + expressions. + :param str id: (optional) The unique ID of the list. + :param str description: (optional) Describes the contents of the list. + :param str kind: (optional) The type of resource this list contains. + :param float num_items: (optional) How many items the list contains. + :param float num_referencing_filters: (optional) How many times the list is + used by rule expressions. + """ + self.name = name + self.id = id + self.description = description + self.kind = kind + self.num_items = num_items + self.num_referencing_filters = num_referencing_filters + + @classmethod + def from_dict(cls, _dict: Dict) -> 'CustomListResult': + """Initialize a CustomListResult object from a json dictionary.""" + args = {} + if (name := _dict.get('name')) is not None: + args['name'] = name + if (id := _dict.get('id')) is not None: + args['id'] = id + if (description := _dict.get('description')) is not None: + args['description'] = description + if (kind := _dict.get('kind')) is not None: + args['kind'] = kind + if (num_items := _dict.get('num_items')) is not None: + args['num_items'] = num_items + if (num_referencing_filters := _dict.get('num_referencing_filters')) is not None: + args['num_referencing_filters'] = num_referencing_filters + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a CustomListResult object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'name') and self.name is not None: + _dict['name'] = self.name + if hasattr(self, 'id') and self.id is not None: + _dict['id'] = self.id + if hasattr(self, 'description') and self.description is not None: + _dict['description'] = self.description + if hasattr(self, 'kind') and self.kind is not None: + _dict['kind'] = self.kind + if hasattr(self, 'num_items') and self.num_items is not None: + _dict['num_items'] = self.num_items + if hasattr(self, 'num_referencing_filters') and self.num_referencing_filters is not None: + _dict['num_referencing_filters'] = self.num_referencing_filters + 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 CustomListResult object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'CustomListResult') -> 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: 'CustomListResult') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class CustomListsResp: + """ + List Custom Lists Response. + + :param bool success: Was operation successful. + :param List[List[str]] errors: Errors. + :param List[List[str]] messages: Messages. + :param List[CustomListResult] result: + """ + + def __init__( + self, + success: bool, + errors: List[List[str]], + messages: List[List[str]], + result: List['CustomListResult'], + ) -> None: + """ + Initialize a CustomListsResp object. + + :param bool success: Was operation successful. + :param List[List[str]] errors: Errors. + :param List[List[str]] messages: Messages. + :param List[CustomListResult] result: + """ + self.success = success + self.errors = errors + self.messages = messages + self.result = result + + @classmethod + def from_dict(cls, _dict: Dict) -> 'CustomListsResp': + """Initialize a CustomListsResp object from a json dictionary.""" + args = {} + if (success := _dict.get('success')) is not None: + args['success'] = success + else: + raise ValueError('Required property \'success\' not present in CustomListsResp JSON') + if (errors := _dict.get('errors')) is not None: + args['errors'] = errors + else: + raise ValueError('Required property \'errors\' not present in CustomListsResp JSON') + if (messages := _dict.get('messages')) is not None: + args['messages'] = messages + else: + raise ValueError('Required property \'messages\' not present in CustomListsResp JSON') + if (result := _dict.get('result')) is not None: + args['result'] = [CustomListResult.from_dict(v) for v in result] + else: + raise ValueError('Required property \'result\' not present in CustomListsResp JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a CustomListsResp 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: + result_list = [] + for v in self.result: + if isinstance(v, dict): + result_list.append(v) + else: + result_list.append(v.to_dict()) + _dict['result'] = result_list + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this CustomListsResp object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'CustomListsResp') -> 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: 'CustomListsResp') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class DeleteResourceResp: + """ + DeleteResourceResp. + + :param bool success: Was operation successful. + :param List[List[str]] errors: Errors. + :param List[List[str]] messages: Messages. + :param DeleteResourceRespResult result: + """ + + def __init__( + self, + success: bool, + errors: List[List[str]], + messages: List[List[str]], + result: 'DeleteResourceRespResult', + ) -> None: + """ + Initialize a DeleteResourceResp object. + + :param bool success: Was operation successful. + :param List[List[str]] errors: Errors. + :param List[List[str]] messages: Messages. + :param DeleteResourceRespResult result: + """ + self.success = success + self.errors = errors + self.messages = messages + self.result = result + + @classmethod + def from_dict(cls, _dict: Dict) -> 'DeleteResourceResp': + """Initialize a DeleteResourceResp object from a json dictionary.""" + args = {} + if (success := _dict.get('success')) is not None: + args['success'] = success + else: + raise ValueError('Required property \'success\' not present in DeleteResourceResp JSON') + if (errors := _dict.get('errors')) is not None: + args['errors'] = errors + else: + raise ValueError('Required property \'errors\' not present in DeleteResourceResp JSON') + if (messages := _dict.get('messages')) is not None: + args['messages'] = messages + else: + raise ValueError('Required property \'messages\' not present in DeleteResourceResp JSON') + if (result := _dict.get('result')) is not None: + args['result'] = DeleteResourceRespResult.from_dict(result) + else: + raise ValueError('Required property \'result\' not present in DeleteResourceResp JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a DeleteResourceResp 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: + if isinstance(self.result, dict): + _dict['result'] = self.result + else: + _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 DeleteResourceResp object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'DeleteResourceResp') -> 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: 'DeleteResourceResp') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class ListCursor: + """ + ListCursor. + + :param str after: (optional) The cursor token to fetch the next page of results. + :param str before: (optional) The cursor token to fetch the previous page of + results. + """ + + def __init__( + self, + *, + after: Optional[str] = None, + before: Optional[str] = None, + ) -> None: + """ + Initialize a ListCursor object. + + :param str after: (optional) The cursor token to fetch the next page of + results. + :param str before: (optional) The cursor token to fetch the previous page + of results. + """ + self.after = after + self.before = before + + @classmethod + def from_dict(cls, _dict: Dict) -> 'ListCursor': + """Initialize a ListCursor object from a json dictionary.""" + args = {} + if (after := _dict.get('after')) is not None: + args['after'] = after + if (before := _dict.get('before')) is not None: + args['before'] = before + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a ListCursor 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, 'after') and self.after is not None: + _dict['after'] = self.after + if hasattr(self, 'before') and self.before is not None: + _dict['before'] = self.before + 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 ListCursor object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'ListCursor') -> 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: 'ListCursor') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class ListItem: + """ + ListItem. + + :param str id: (optional) + :param float asn: (optional) An autonomous system number. + :param str comment: (optional) An informative summary of the list item. + :param str hostname: (optional) Valid characters for hostnames are ASCII(7) + letters from a to z, the digits from 0 to 9, wildcards (*), and the hyphen (-). + :param str ip: (optional) An IPv4 address, an IPv4 CIDR, or an IPv6 CIDR. IPv6 + CIDRs are limited to a maximum of /64. + :param str created_on: (optional) + :param str modified_on: (optional) + """ + + def __init__( + self, + *, + id: Optional[str] = None, + asn: Optional[float] = None, + comment: Optional[str] = None, + hostname: Optional[str] = None, + ip: Optional[str] = None, + created_on: Optional[str] = None, + modified_on: Optional[str] = None, + ) -> None: + """ + Initialize a ListItem object. + + :param str id: (optional) + :param float asn: (optional) An autonomous system number. + :param str comment: (optional) An informative summary of the list item. + :param str hostname: (optional) Valid characters for hostnames are ASCII(7) + letters from a to z, the digits from 0 to 9, wildcards (*), and the hyphen + (-). + :param str ip: (optional) An IPv4 address, an IPv4 CIDR, or an IPv6 CIDR. + IPv6 CIDRs are limited to a maximum of /64. + :param str created_on: (optional) + :param str modified_on: (optional) + """ + self.id = id + self.asn = asn + self.comment = comment + self.hostname = hostname + self.ip = ip + self.created_on = created_on + self.modified_on = modified_on + + @classmethod + def from_dict(cls, _dict: Dict) -> 'ListItem': + """Initialize a ListItem object from a json dictionary.""" + args = {} + if (id := _dict.get('id')) is not None: + args['id'] = id + if (asn := _dict.get('asn')) is not None: + args['asn'] = asn + if (comment := _dict.get('comment')) is not None: + args['comment'] = comment + if (hostname := _dict.get('hostname')) is not None: + args['hostname'] = hostname + if (ip := _dict.get('ip')) is not None: + args['ip'] = ip + if (created_on := _dict.get('created_on')) is not None: + args['created_on'] = created_on + if (modified_on := _dict.get('modified_on')) is not None: + args['modified_on'] = modified_on + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a ListItem 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, 'asn') and self.asn is not None: + _dict['asn'] = self.asn + if hasattr(self, 'comment') and self.comment is not None: + _dict['comment'] = self.comment + if hasattr(self, 'hostname') and self.hostname is not None: + _dict['hostname'] = self.hostname + if hasattr(self, 'ip') and self.ip is not None: + _dict['ip'] = self.ip + 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 ListItem object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'ListItem') -> 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: 'ListItem') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class ListItemResp: + """ + ListItemResp. + + :param bool success: Was operation successful. + :param List[List[str]] errors: Errors. + :param List[List[str]] messages: Messages. + :param ListItem result: + """ + + def __init__( + self, + success: bool, + errors: List[List[str]], + messages: List[List[str]], + result: 'ListItem', + ) -> None: + """ + Initialize a ListItemResp object. + + :param bool success: Was operation successful. + :param List[List[str]] errors: Errors. + :param List[List[str]] messages: Messages. + :param ListItem result: + """ + self.success = success + self.errors = errors + self.messages = messages + self.result = result + + @classmethod + def from_dict(cls, _dict: Dict) -> 'ListItemResp': + """Initialize a ListItemResp object from a json dictionary.""" + args = {} + if (success := _dict.get('success')) is not None: + args['success'] = success + else: + raise ValueError('Required property \'success\' not present in ListItemResp JSON') + if (errors := _dict.get('errors')) is not None: + args['errors'] = errors + else: + raise ValueError('Required property \'errors\' not present in ListItemResp JSON') + if (messages := _dict.get('messages')) is not None: + args['messages'] = messages + else: + raise ValueError('Required property \'messages\' not present in ListItemResp JSON') + if (result := _dict.get('result')) is not None: + args['result'] = ListItem.from_dict(result) + else: + raise ValueError('Required property \'result\' not present in ListItemResp JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a ListItemResp 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: + if isinstance(self.result, dict): + _dict['result'] = self.result + else: + _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 ListItemResp object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'ListItemResp') -> 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: 'ListItemResp') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class ListItemsResp: + """ + ListItemsResp. + + :param bool success: Was operation successful. + :param List[List[str]] errors: Errors. + :param List[List[str]] messages: Messages. + :param List[ListItem] result: + :param ListItemsResultInfo result_info: (optional) + """ + + def __init__( + self, + success: bool, + errors: List[List[str]], + messages: List[List[str]], + result: List['ListItem'], + *, + result_info: Optional['ListItemsResultInfo'] = None, + ) -> None: + """ + Initialize a ListItemsResp object. + + :param bool success: Was operation successful. + :param List[List[str]] errors: Errors. + :param List[List[str]] messages: Messages. + :param List[ListItem] result: + :param ListItemsResultInfo result_info: (optional) + """ + self.success = success + self.errors = errors + self.messages = messages + self.result = result + self.result_info = result_info + + @classmethod + def from_dict(cls, _dict: Dict) -> 'ListItemsResp': + """Initialize a ListItemsResp object from a json dictionary.""" + args = {} + if (success := _dict.get('success')) is not None: + args['success'] = success + else: + raise ValueError('Required property \'success\' not present in ListItemsResp JSON') + if (errors := _dict.get('errors')) is not None: + args['errors'] = errors + else: + raise ValueError('Required property \'errors\' not present in ListItemsResp JSON') + if (messages := _dict.get('messages')) is not None: + args['messages'] = messages + else: + raise ValueError('Required property \'messages\' not present in ListItemsResp JSON') + if (result := _dict.get('result')) is not None: + args['result'] = [ListItem.from_dict(v) for v in result] + else: + raise ValueError('Required property \'result\' not present in ListItemsResp JSON') + if (result_info := _dict.get('result_info')) is not None: + args['result_info'] = ListItemsResultInfo.from_dict(result_info) + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a ListItemsResp 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: + result_list = [] + for v in self.result: + if isinstance(v, dict): + result_list.append(v) + else: + result_list.append(v.to_dict()) + _dict['result'] = result_list + if hasattr(self, 'result_info') and self.result_info is not None: + if isinstance(self.result_info, dict): + _dict['result_info'] = self.result_info + else: + _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 ListItemsResp object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'ListItemsResp') -> 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: 'ListItemsResp') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class ListItemsResultInfo: + """ + ListItemsResultInfo. + + :param ListCursor cursors: (optional) + """ + + def __init__( + self, + *, + cursors: Optional['ListCursor'] = None, + ) -> None: + """ + Initialize a ListItemsResultInfo object. + + :param ListCursor cursors: (optional) + """ + self.cursors = cursors + + @classmethod + def from_dict(cls, _dict: Dict) -> 'ListItemsResultInfo': + """Initialize a ListItemsResultInfo object from a json dictionary.""" + args = {} + if (cursors := _dict.get('cursors')) is not None: + args['cursors'] = ListCursor.from_dict(cursors) + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a ListItemsResultInfo 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, 'cursors') and self.cursors is not None: + if isinstance(self.cursors, dict): + _dict['cursors'] = self.cursors + else: + _dict['cursors'] = self.cursors.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 ListItemsResultInfo object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'ListItemsResultInfo') -> 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: 'ListItemsResultInfo') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class ListOperationResp: + """ + ListOperationResp. + + :param bool success: Was operation successful. + :param List[List[str]] errors: Errors. + :param List[List[str]] messages: Messages. + :param ListOperationRespResult result: + """ + + def __init__( + self, + success: bool, + errors: List[List[str]], + messages: List[List[str]], + result: 'ListOperationRespResult', + ) -> None: + """ + Initialize a ListOperationResp object. + + :param bool success: Was operation successful. + :param List[List[str]] errors: Errors. + :param List[List[str]] messages: Messages. + :param ListOperationRespResult result: + """ + self.success = success + self.errors = errors + self.messages = messages + self.result = result + + @classmethod + def from_dict(cls, _dict: Dict) -> 'ListOperationResp': + """Initialize a ListOperationResp object from a json dictionary.""" + args = {} + if (success := _dict.get('success')) is not None: + args['success'] = success + else: + raise ValueError('Required property \'success\' not present in ListOperationResp JSON') + if (errors := _dict.get('errors')) is not None: + args['errors'] = errors + else: + raise ValueError('Required property \'errors\' not present in ListOperationResp JSON') + if (messages := _dict.get('messages')) is not None: + args['messages'] = messages + else: + raise ValueError('Required property \'messages\' not present in ListOperationResp JSON') + if (result := _dict.get('result')) is not None: + args['result'] = ListOperationRespResult.from_dict(result) + else: + raise ValueError('Required property \'result\' not present in ListOperationResp JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a ListOperationResp 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: + if isinstance(self.result, dict): + _dict['result'] = self.result + else: + _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 ListOperationResp object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'ListOperationResp') -> 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: 'ListOperationResp') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class ManagedListsResp: + """ + List Managed Lists Response. + + :param bool success: Was operation successful. + :param List[List[str]] errors: Errors. + :param List[List[str]] messages: Messages. + :param List[ManagedListsResultItem] result: + """ + + def __init__( + self, + success: bool, + errors: List[List[str]], + messages: List[List[str]], + result: List['ManagedListsResultItem'], + ) -> None: + """ + Initialize a ManagedListsResp object. + + :param bool success: Was operation successful. + :param List[List[str]] errors: Errors. + :param List[List[str]] messages: Messages. + :param List[ManagedListsResultItem] result: + """ + self.success = success + self.errors = errors + self.messages = messages + self.result = result + + @classmethod + def from_dict(cls, _dict: Dict) -> 'ManagedListsResp': + """Initialize a ManagedListsResp object from a json dictionary.""" + args = {} + if (success := _dict.get('success')) is not None: + args['success'] = success + else: + raise ValueError('Required property \'success\' not present in ManagedListsResp JSON') + if (errors := _dict.get('errors')) is not None: + args['errors'] = errors + else: + raise ValueError('Required property \'errors\' not present in ManagedListsResp JSON') + if (messages := _dict.get('messages')) is not None: + args['messages'] = messages + else: + raise ValueError('Required property \'messages\' not present in ManagedListsResp JSON') + if (result := _dict.get('result')) is not None: + args['result'] = [ManagedListsResultItem.from_dict(v) for v in result] + else: + raise ValueError('Required property \'result\' not present in ManagedListsResp JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a ManagedListsResp 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: + result_list = [] + for v in self.result: + if isinstance(v, dict): + result_list.append(v) + else: + result_list.append(v.to_dict()) + _dict['result'] = result_list + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this ManagedListsResp object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'ManagedListsResp') -> 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: 'ManagedListsResp') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class OperationStatusResp: + """ + OperationStatusResp. + + :param bool success: Was operation successful. + :param List[List[str]] errors: Errors. + :param List[List[str]] messages: Messages. + :param OperationStatusRespResult result: + """ + + def __init__( + self, + success: bool, + errors: List[List[str]], + messages: List[List[str]], + result: 'OperationStatusRespResult', + ) -> None: + """ + Initialize a OperationStatusResp object. + + :param bool success: Was operation successful. + :param List[List[str]] errors: Errors. + :param List[List[str]] messages: Messages. + :param OperationStatusRespResult result: + """ + self.success = success + self.errors = errors + self.messages = messages + self.result = result + + @classmethod + def from_dict(cls, _dict: Dict) -> 'OperationStatusResp': + """Initialize a OperationStatusResp object from a json dictionary.""" + args = {} + if (success := _dict.get('success')) is not None: + args['success'] = success + else: + raise ValueError('Required property \'success\' not present in OperationStatusResp JSON') + if (errors := _dict.get('errors')) is not None: + args['errors'] = errors + else: + raise ValueError('Required property \'errors\' not present in OperationStatusResp JSON') + if (messages := _dict.get('messages')) is not None: + args['messages'] = messages + else: + raise ValueError('Required property \'messages\' not present in OperationStatusResp JSON') + if (result := _dict.get('result')) is not None: + args['result'] = OperationStatusRespResult.from_dict(result) + else: + raise ValueError('Required property \'result\' not present in OperationStatusResp JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a OperationStatusResp 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: + if isinstance(self.result, dict): + _dict['result'] = self.result + else: + _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 OperationStatusResp object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'OperationStatusResp') -> 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: 'OperationStatusResp') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other diff --git a/test/integration/test_lists_api_v1.py b/test/integration/test_lists_api_v1.py new file mode 100644 index 0000000..67f8490 --- /dev/null +++ b/test/integration/test_lists_api_v1.py @@ -0,0 +1,203 @@ +# -*- coding: utf-8 -*- +# (C) Copyright IBM Corp. 2026. + +""" +Integration test code to execute Lists API +""" + +import os +import unittest +from dotenv import load_dotenv, find_dotenv +from ibm_cloud_networking_services.lists_api_v1 import ListsApiV1, CreateListItemsReqItem, DeleteListItemsReqItemsItem + +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 TestListsApiV1(unittest.TestCase): + """ Test class to call Lists API 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.endpoint = os.getenv("API_ENDPOINT") + self.service = ListsApiV1.new_instance( + service_name="cis_services", + crn=self.crn, + item_id="00000000000000000000000000000001", + list_id="00000000000000000000000000000001", + operation_id="00000000000000000000000000000001", + ) + self.service.set_service_url(self.endpoint) + self._clean_custom_lists() + + def tearDown(self): + """ tear down """ + self._clean_custom_lists() + print("Clean up complete") + + def _clean_custom_lists(self): + response = self.service.get_custom_lists() + assert response is not None + assert response.status_code == 200 + resp = response.get_result().get('result') or [] + for record in resp: + if record.get('name', '').startswith('sdk_integration_test'): + self.service.list_id = record['id'] + self.service.delete_custom_list() + + def _create_custom_list(self): + response = self.service.create_custom_lists( + name='sdk_integration_test_list', + kind='ip', + description='Integration test custom list', + ) + assert response is not None + assert response.get_status_code() in (200, 201) + list_id = response.get_result()['result']['id'] + self.service.list_id = list_id + return list_id + + ################## get managed lists ###################### + def test_1_get_managed_lists(self): + """ test for success """ + response = self.service.get_managed_lists() + assert response is not None + assert response.get_status_code() == 200 + + ################## list custom lists ################### + def test_2_get_custom_lists(self): + """ test for success """ + response = self.service.get_custom_lists() + assert response is not None + assert response.get_status_code() == 200 + + ################## create custom list ###################### + def test_3_create_custom_lists(self): + """ test for success """ + list_id = self._create_custom_list() + assert list_id is not None + + ################## get custom list by id ################### + def test_4_get_custom_list(self): + """ test for success """ + self._create_custom_list() + response = self.service.get_custom_list() + assert response is not None + assert response.get_status_code() == 200 + + ################## update custom list by id ################### + def test_5_update_custom_list(self): + """ test for success """ + self._create_custom_list() + response = self.service.update_custom_list( + description='Updated integration test custom list', + ) + assert response is not None + assert response.get_status_code() == 200 + + ################## create list items ################### + def test_6_create_list_items(self): + """ test for success """ + self._create_custom_list() + item = CreateListItemsReqItem(ip='192.0.2.10', comment='integration test item') + response = self.service.create_list_items( + create_list_items_req_item=[item], + ) + assert response is not None + assert response.get_status_code() in (200, 202) + operation_id = response.get_result()['result']['operation_id'] + assert operation_id is not None + self.service.operation_id = operation_id + + ################## get operation status ################### + def test_7_get_operation_status(self): + """ test for success """ + self._create_custom_list() + item = CreateListItemsReqItem(ip='192.0.2.10', comment='integration test item') + op_response = self.service.create_list_items( + create_list_items_req_item=[item], + ) + assert op_response is not None + assert op_response.get_status_code() in (200, 202) + self.service.operation_id = op_response.get_result()['result']['operation_id'] + + response = self.service.get_operation_status() + assert response is not None + assert response.get_status_code() == 200 + + ################## get list items ################### + def test_8_get_list_items(self): + """ test for success """ + self._create_custom_list() + item = CreateListItemsReqItem(ip='192.0.2.10', comment='integration test item') + self.service.create_list_items(create_list_items_req_item=[item]) + + response = self.service.get_list_items(per_page=1, search='192.0.2') + assert response is not None + assert response.get_status_code() == 200 + items = response.get_result().get('result') or [] + if items: + self.service.item_id = items[0]['id'] + + ################## get list item by id ################### + def test_9_get_list_item(self): + """ test for success """ + self._create_custom_list() + item = CreateListItemsReqItem(ip='192.0.2.10', comment='integration test item') + self.service.create_list_items(create_list_items_req_item=[item]) + + items_response = self.service.get_list_items() + assert items_response is not None + items = items_response.get_result().get('result') or [] + if items: + self.service.item_id = items[0]['id'] + response = self.service.get_list_item() + assert response is not None + assert response.get_status_code() == 200 + + ################## update list items ################### + def test_10_update_list_items(self): + """ test for success """ + self._create_custom_list() + item = CreateListItemsReqItem(ip='192.0.2.11', comment='updated integration test item') + response = self.service.update_list_items( + create_list_items_req_item=[item], + ) + assert response is not None + assert response.get_status_code() in (200, 202) + + ################## delete list items ################### + def test_11_delete_list_items(self): + """ test for success """ + self._create_custom_list() + item = CreateListItemsReqItem(ip='192.0.2.10', comment='integration test item') + self.service.create_list_items(create_list_items_req_item=[item]) + + items_response = self.service.get_list_items() + assert items_response is not None + items = items_response.get_result().get('result') or [] + if items: + items_to_delete = [DeleteListItemsReqItemsItem(id=i['id']) for i in items] + response = self.service.delete_list_items(items=items_to_delete) + assert response is not None + assert response.get_status_code() in (200, 202) + + ################## delete custom list by id ################### + def test_12_delete_custom_list(self): + """ test for success """ + self._create_custom_list() + response = self.service.delete_custom_list() + assert response is not None + assert response.get_status_code() == 200 + + +if __name__ == '__main__': + unittest.main() diff --git a/test/unit/test_lists_api_v1.py b/test/unit/test_lists_api_v1.py new file mode 100644 index 0000000..9a6779b --- /dev/null +++ b/test/unit/test_lists_api_v1.py @@ -0,0 +1,1936 @@ +# -*- coding: utf-8 -*- +# (C) Copyright IBM Corp. 2026. +# +# 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 ListsApiV1 +""" + +from ibm_cloud_sdk_core.authenticators.no_auth_authenticator import NoAuthAuthenticator +import inspect +import json +import os +import pytest +import re +import requests +import responses +import urllib +from ibm_cloud_networking_services.lists_api_v1 import * + +crn = 'testString' +item_id = 'testString' +list_id = 'testString' +operation_id = 'testString' + +_service = ListsApiV1( + authenticator=NoAuthAuthenticator(), + crn=crn, + item_id=item_id, + list_id=list_id, + operation_id=operation_id, +) + +_base_url = 'https://api.cis.cloud.ibm.com' +_service.set_service_url(_base_url) + + +def preprocess_url(operation_path: str): + """ + Returns the request url associated with the specified operation path. + This will be base_url concatenated with a quoted version of operation_path. + The returned request URL is used to register the mock response so it needs + to match the request URL that is formed by the requests library. + """ + + # Form the request URL from the base URL and operation path. + request_url = _base_url + operation_path + + # If the request url does NOT end with a /, then just return it as-is. + # Otherwise, return a regular expression that matches one or more trailing /. + if not request_url.endswith('/'): + return request_url + return re.compile(request_url.rstrip('/') + '/+') + + +############################################################################## +# Start of Service: Lists +############################################################################## +# region + + +class TestNewInstance: + """ + Test Class for new_instance + """ + + def test_new_instance(self): + """ + new_instance() + """ + os.environ['TEST_SERVICE_AUTH_TYPE'] = 'noAuth' + + service = ListsApiV1.new_instance( + crn=crn, + item_id=item_id, + list_id=list_id, + operation_id=operation_id, + service_name='TEST_SERVICE', + ) + + assert service is not None + assert isinstance(service, ListsApiV1) + + def test_new_instance_without_authenticator(self): + """ + new_instance_without_authenticator() + """ + with pytest.raises(ValueError, match='authenticator must be provided'): + service = ListsApiV1.new_instance( + crn=crn, + item_id=item_id, + list_id=list_id, + operation_id=operation_id, + service_name='TEST_SERVICE_NOT_FOUND', + ) + + def test_new_instance_without_required_params(self): + """ + new_instance_without_required_params() + """ + with pytest.raises(TypeError, match='new_instance\\(\\) missing \\d required positional arguments?: \'.*\''): + service = ListsApiV1.new_instance() + + def test_new_instance_required_param_none(self): + """ + new_instance_required_param_none() + """ + with pytest.raises(ValueError, match='crn must be provided'): + service = ListsApiV1.new_instance( + crn=None, + item_id=None, + list_id=None, + operation_id=None, + ) + + +class TestGetManagedLists: + """ + Test Class for get_managed_lists + """ + + @responses.activate + def test_get_managed_lists_all_params(self): + """ + get_managed_lists() + """ + # Set up mock + url = preprocess_url('/v1/testString/rules/managed_lists') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": [{"name": "cf.malware", "description": "description", "kind": "ip"}]}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Invoke method + response = _service.get_managed_lists() + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_get_managed_lists_all_params_with_retries(self): + # Enable retries and run test_get_managed_lists_all_params. + _service.enable_retries() + self.test_get_managed_lists_all_params() + + # Disable retries and run test_get_managed_lists_all_params. + _service.disable_retries() + self.test_get_managed_lists_all_params() + + @responses.activate + def test_get_managed_lists_value_error(self): + """ + test_get_managed_lists_value_error() + """ + # Set up mock + url = preprocess_url('/v1/testString/rules/managed_lists') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": [{"name": "cf.malware", "description": "description", "kind": "ip"}]}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.get_managed_lists(**req_copy) + + def test_get_managed_lists_value_error_with_retries(self): + # Enable retries and run test_get_managed_lists_value_error. + _service.enable_retries() + self.test_get_managed_lists_value_error() + + # Disable retries and run test_get_managed_lists_value_error. + _service.disable_retries() + self.test_get_managed_lists_value_error() + + +class TestGetCustomLists: + """ + Test Class for get_custom_lists + """ + + @responses.activate + def test_get_custom_lists_all_params(self): + """ + get_custom_lists() + """ + # Set up mock + url = preprocess_url('/v1/testString/rules/lists') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": [{"name": "good_ips", "id": "id", "description": "description", "kind": "ip", "num_items": 10, "num_referencing_filters": 5}]}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Invoke method + response = _service.get_custom_lists() + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_get_custom_lists_all_params_with_retries(self): + # Enable retries and run test_get_custom_lists_all_params. + _service.enable_retries() + self.test_get_custom_lists_all_params() + + # Disable retries and run test_get_custom_lists_all_params. + _service.disable_retries() + self.test_get_custom_lists_all_params() + + @responses.activate + def test_get_custom_lists_value_error(self): + """ + test_get_custom_lists_value_error() + """ + # Set up mock + url = preprocess_url('/v1/testString/rules/lists') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": [{"name": "good_ips", "id": "id", "description": "description", "kind": "ip", "num_items": 10, "num_referencing_filters": 5}]}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.get_custom_lists(**req_copy) + + def test_get_custom_lists_value_error_with_retries(self): + # Enable retries and run test_get_custom_lists_value_error. + _service.enable_retries() + self.test_get_custom_lists_value_error() + + # Disable retries and run test_get_custom_lists_value_error. + _service.disable_retries() + self.test_get_custom_lists_value_error() + + +class TestCreateCustomLists: + """ + Test Class for create_custom_lists + """ + + @responses.activate + def test_create_custom_lists_all_params(self): + """ + create_custom_lists() + """ + # Set up mock + url = preprocess_url('/v1/testString/rules/lists') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"name": "good_ips", "id": "id", "description": "description", "kind": "ip", "num_items": 10, "num_referencing_filters": 5}}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + kind = 'ip' + name = 'testString' + description = 'testString' + + # Invoke method + response = _service.create_custom_lists( + kind=kind, + name=name, + description=description, + 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['kind'] == 'ip' + assert req_body['name'] == 'testString' + assert req_body['description'] == 'testString' + + def test_create_custom_lists_all_params_with_retries(self): + # Enable retries and run test_create_custom_lists_all_params. + _service.enable_retries() + self.test_create_custom_lists_all_params() + + # Disable retries and run test_create_custom_lists_all_params. + _service.disable_retries() + self.test_create_custom_lists_all_params() + + @responses.activate + def test_create_custom_lists_required_params(self): + """ + test_create_custom_lists_required_params() + """ + # Set up mock + url = preprocess_url('/v1/testString/rules/lists') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"name": "good_ips", "id": "id", "description": "description", "kind": "ip", "num_items": 10, "num_referencing_filters": 5}}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Invoke method + response = _service.create_custom_lists() + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_create_custom_lists_required_params_with_retries(self): + # Enable retries and run test_create_custom_lists_required_params. + _service.enable_retries() + self.test_create_custom_lists_required_params() + + # Disable retries and run test_create_custom_lists_required_params. + _service.disable_retries() + self.test_create_custom_lists_required_params() + + @responses.activate + def test_create_custom_lists_value_error(self): + """ + test_create_custom_lists_value_error() + """ + # Set up mock + url = preprocess_url('/v1/testString/rules/lists') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"name": "good_ips", "id": "id", "description": "description", "kind": "ip", "num_items": 10, "num_referencing_filters": 5}}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.create_custom_lists(**req_copy) + + def test_create_custom_lists_value_error_with_retries(self): + # Enable retries and run test_create_custom_lists_value_error. + _service.enable_retries() + self.test_create_custom_lists_value_error() + + # Disable retries and run test_create_custom_lists_value_error. + _service.disable_retries() + self.test_create_custom_lists_value_error() + + +class TestGetCustomList: + """ + Test Class for get_custom_list + """ + + @responses.activate + def test_get_custom_list_all_params(self): + """ + get_custom_list() + """ + # Set up mock + url = preprocess_url('/v1/testString/rules/lists/testString') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"name": "good_ips", "id": "id", "description": "description", "kind": "ip", "num_items": 10, "num_referencing_filters": 5}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Invoke method + response = _service.get_custom_list() + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_get_custom_list_all_params_with_retries(self): + # Enable retries and run test_get_custom_list_all_params. + _service.enable_retries() + self.test_get_custom_list_all_params() + + # Disable retries and run test_get_custom_list_all_params. + _service.disable_retries() + self.test_get_custom_list_all_params() + + @responses.activate + def test_get_custom_list_value_error(self): + """ + test_get_custom_list_value_error() + """ + # Set up mock + url = preprocess_url('/v1/testString/rules/lists/testString') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"name": "good_ips", "id": "id", "description": "description", "kind": "ip", "num_items": 10, "num_referencing_filters": 5}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.get_custom_list(**req_copy) + + def test_get_custom_list_value_error_with_retries(self): + # Enable retries and run test_get_custom_list_value_error. + _service.enable_retries() + self.test_get_custom_list_value_error() + + # Disable retries and run test_get_custom_list_value_error. + _service.disable_retries() + self.test_get_custom_list_value_error() + + +class TestUpdateCustomList: + """ + Test Class for update_custom_list + """ + + @responses.activate + def test_update_custom_list_all_params(self): + """ + update_custom_list() + """ + # Set up mock + url = preprocess_url('/v1/testString/rules/lists/testString') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"name": "good_ips", "id": "id", "description": "description", "kind": "ip", "num_items": 10, "num_referencing_filters": 5}}' + responses.add( + responses.PUT, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + description = 'testString' + + # Invoke method + response = _service.update_custom_list( + description=description, + 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['description'] == 'testString' + + def test_update_custom_list_all_params_with_retries(self): + # Enable retries and run test_update_custom_list_all_params. + _service.enable_retries() + self.test_update_custom_list_all_params() + + # Disable retries and run test_update_custom_list_all_params. + _service.disable_retries() + self.test_update_custom_list_all_params() + + @responses.activate + def test_update_custom_list_required_params(self): + """ + test_update_custom_list_required_params() + """ + # Set up mock + url = preprocess_url('/v1/testString/rules/lists/testString') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"name": "good_ips", "id": "id", "description": "description", "kind": "ip", "num_items": 10, "num_referencing_filters": 5}}' + responses.add( + responses.PUT, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Invoke method + response = _service.update_custom_list() + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_update_custom_list_required_params_with_retries(self): + # Enable retries and run test_update_custom_list_required_params. + _service.enable_retries() + self.test_update_custom_list_required_params() + + # Disable retries and run test_update_custom_list_required_params. + _service.disable_retries() + self.test_update_custom_list_required_params() + + @responses.activate + def test_update_custom_list_value_error(self): + """ + test_update_custom_list_value_error() + """ + # Set up mock + url = preprocess_url('/v1/testString/rules/lists/testString') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"name": "good_ips", "id": "id", "description": "description", "kind": "ip", "num_items": 10, "num_referencing_filters": 5}}' + responses.add( + responses.PUT, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.update_custom_list(**req_copy) + + def test_update_custom_list_value_error_with_retries(self): + # Enable retries and run test_update_custom_list_value_error. + _service.enable_retries() + self.test_update_custom_list_value_error() + + # Disable retries and run test_update_custom_list_value_error. + _service.disable_retries() + self.test_update_custom_list_value_error() + + +class TestDeleteCustomList: + """ + Test Class for delete_custom_list + """ + + @responses.activate + def test_delete_custom_list_all_params(self): + """ + delete_custom_list() + """ + # Set up mock + url = preprocess_url('/v1/testString/rules/lists/testString') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"id": "34b12448945f11eaa1b71c4d701ab86e"}}' + responses.add( + responses.DELETE, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Invoke method + response = _service.delete_custom_list() + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_delete_custom_list_all_params_with_retries(self): + # Enable retries and run test_delete_custom_list_all_params. + _service.enable_retries() + self.test_delete_custom_list_all_params() + + # Disable retries and run test_delete_custom_list_all_params. + _service.disable_retries() + self.test_delete_custom_list_all_params() + + @responses.activate + def test_delete_custom_list_value_error(self): + """ + test_delete_custom_list_value_error() + """ + # Set up mock + url = preprocess_url('/v1/testString/rules/lists/testString') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"id": "34b12448945f11eaa1b71c4d701ab86e"}}' + responses.add( + responses.DELETE, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.delete_custom_list(**req_copy) + + def test_delete_custom_list_value_error_with_retries(self): + # Enable retries and run test_delete_custom_list_value_error. + _service.enable_retries() + self.test_delete_custom_list_value_error() + + # Disable retries and run test_delete_custom_list_value_error. + _service.disable_retries() + self.test_delete_custom_list_value_error() + + +class TestGetListItems: + """ + Test Class for get_list_items + """ + + @responses.activate + def test_get_list_items_all_params(self): + """ + get_list_items() + """ + # Set up mock + url = preprocess_url('/v1/testString/rules/lists/testString/items') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": [{"id": "70c2009751b24ffc9ed1ab462ba957b4", "asn": 19604, "comment": "My list of developer IPs.", "hostname": "cloud.ibm.com", "ip": "172.64.0.0/13", "created_on": "2025-03-21T16:19:21Z", "modified_on": "2025-03-21T16:19:37Z"}], "result_info": {"cursors": {"after": "yyy", "before": "xxx"}}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + cursor = 'testString' + per_page = 1 + search = 'testString' + + # Invoke method + response = _service.get_list_items( + cursor=cursor, + per_page=per_page, + search=search, + 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 'cursor={}'.format(cursor) in query_string + assert 'per_page={}'.format(per_page) in query_string + assert 'search={}'.format(search) in query_string + + def test_get_list_items_all_params_with_retries(self): + # Enable retries and run test_get_list_items_all_params. + _service.enable_retries() + self.test_get_list_items_all_params() + + # Disable retries and run test_get_list_items_all_params. + _service.disable_retries() + self.test_get_list_items_all_params() + + @responses.activate + def test_get_list_items_required_params(self): + """ + test_get_list_items_required_params() + """ + # Set up mock + url = preprocess_url('/v1/testString/rules/lists/testString/items') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": [{"id": "70c2009751b24ffc9ed1ab462ba957b4", "asn": 19604, "comment": "My list of developer IPs.", "hostname": "cloud.ibm.com", "ip": "172.64.0.0/13", "created_on": "2025-03-21T16:19:21Z", "modified_on": "2025-03-21T16:19:37Z"}], "result_info": {"cursors": {"after": "yyy", "before": "xxx"}}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Invoke method + response = _service.get_list_items() + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_get_list_items_required_params_with_retries(self): + # Enable retries and run test_get_list_items_required_params. + _service.enable_retries() + self.test_get_list_items_required_params() + + # Disable retries and run test_get_list_items_required_params. + _service.disable_retries() + self.test_get_list_items_required_params() + + @responses.activate + def test_get_list_items_value_error(self): + """ + test_get_list_items_value_error() + """ + # Set up mock + url = preprocess_url('/v1/testString/rules/lists/testString/items') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": [{"id": "70c2009751b24ffc9ed1ab462ba957b4", "asn": 19604, "comment": "My list of developer IPs.", "hostname": "cloud.ibm.com", "ip": "172.64.0.0/13", "created_on": "2025-03-21T16:19:21Z", "modified_on": "2025-03-21T16:19:37Z"}], "result_info": {"cursors": {"after": "yyy", "before": "xxx"}}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.get_list_items(**req_copy) + + def test_get_list_items_value_error_with_retries(self): + # Enable retries and run test_get_list_items_value_error. + _service.enable_retries() + self.test_get_list_items_value_error() + + # Disable retries and run test_get_list_items_value_error. + _service.disable_retries() + self.test_get_list_items_value_error() + + +class TestCreateListItems: + """ + Test Class for create_list_items + """ + + @responses.activate + def test_create_list_items_all_params(self): + """ + create_list_items() + """ + # Set up mock + url = preprocess_url('/v1/testString/rules/lists/testString/items') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"operation_id": "53d73a83d33d4e3b8791764a9b9f2412"}}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Construct a dict representation of a CreateListItemsReqItem model + create_list_items_req_item_model = {} + create_list_items_req_item_model['asn'] = 19604 + create_list_items_req_item_model['comment'] = 'My list of developer IPs.' + create_list_items_req_item_model['hostname'] = 'cloud.ibm.com' + create_list_items_req_item_model['ip'] = '172.64.0.0/13' + + # Set up parameter values + create_list_items_req_item = [create_list_items_req_item_model] + + # Invoke method + response = _service.create_list_items( + create_list_items_req_item=create_list_items_req_item, + 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 == create_list_items_req_item + + def test_create_list_items_all_params_with_retries(self): + # Enable retries and run test_create_list_items_all_params. + _service.enable_retries() + self.test_create_list_items_all_params() + + # Disable retries and run test_create_list_items_all_params. + _service.disable_retries() + self.test_create_list_items_all_params() + + @responses.activate + def test_create_list_items_required_params(self): + """ + test_create_list_items_required_params() + """ + # Set up mock + url = preprocess_url('/v1/testString/rules/lists/testString/items') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"operation_id": "53d73a83d33d4e3b8791764a9b9f2412"}}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Invoke method + response = _service.create_list_items() + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_create_list_items_required_params_with_retries(self): + # Enable retries and run test_create_list_items_required_params. + _service.enable_retries() + self.test_create_list_items_required_params() + + # Disable retries and run test_create_list_items_required_params. + _service.disable_retries() + self.test_create_list_items_required_params() + + @responses.activate + def test_create_list_items_value_error(self): + """ + test_create_list_items_value_error() + """ + # Set up mock + url = preprocess_url('/v1/testString/rules/lists/testString/items') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"operation_id": "53d73a83d33d4e3b8791764a9b9f2412"}}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.create_list_items(**req_copy) + + def test_create_list_items_value_error_with_retries(self): + # Enable retries and run test_create_list_items_value_error. + _service.enable_retries() + self.test_create_list_items_value_error() + + # Disable retries and run test_create_list_items_value_error. + _service.disable_retries() + self.test_create_list_items_value_error() + + +class TestDeleteListItems: + """ + Test Class for delete_list_items + """ + + @responses.activate + def test_delete_list_items_all_params(self): + """ + delete_list_items() + """ + # Set up mock + url = preprocess_url('/v1/testString/rules/lists/testString/items') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"operation_id": "53d73a83d33d4e3b8791764a9b9f2412"}}' + responses.add( + responses.DELETE, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Construct a dict representation of a DeleteListItemsReqItemsItem model + delete_list_items_req_items_item_model = {} + delete_list_items_req_items_item_model['id'] = '70c2009751b24ffc9ed1ab462ba957b4' + + # Set up parameter values + items = [delete_list_items_req_items_item_model] + + # Invoke method + response = _service.delete_list_items( + items=items, + 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['items'] == [delete_list_items_req_items_item_model] + + def test_delete_list_items_all_params_with_retries(self): + # Enable retries and run test_delete_list_items_all_params. + _service.enable_retries() + self.test_delete_list_items_all_params() + + # Disable retries and run test_delete_list_items_all_params. + _service.disable_retries() + self.test_delete_list_items_all_params() + + @responses.activate + def test_delete_list_items_required_params(self): + """ + test_delete_list_items_required_params() + """ + # Set up mock + url = preprocess_url('/v1/testString/rules/lists/testString/items') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"operation_id": "53d73a83d33d4e3b8791764a9b9f2412"}}' + responses.add( + responses.DELETE, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Invoke method + response = _service.delete_list_items() + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_delete_list_items_required_params_with_retries(self): + # Enable retries and run test_delete_list_items_required_params. + _service.enable_retries() + self.test_delete_list_items_required_params() + + # Disable retries and run test_delete_list_items_required_params. + _service.disable_retries() + self.test_delete_list_items_required_params() + + @responses.activate + def test_delete_list_items_value_error(self): + """ + test_delete_list_items_value_error() + """ + # Set up mock + url = preprocess_url('/v1/testString/rules/lists/testString/items') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"operation_id": "53d73a83d33d4e3b8791764a9b9f2412"}}' + responses.add( + responses.DELETE, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.delete_list_items(**req_copy) + + def test_delete_list_items_value_error_with_retries(self): + # Enable retries and run test_delete_list_items_value_error. + _service.enable_retries() + self.test_delete_list_items_value_error() + + # Disable retries and run test_delete_list_items_value_error. + _service.disable_retries() + self.test_delete_list_items_value_error() + + +class TestUpdateListItems: + """ + Test Class for update_list_items + """ + + @responses.activate + def test_update_list_items_all_params(self): + """ + update_list_items() + """ + # Set up mock + url = preprocess_url('/v1/testString/rules/lists/testString/items') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"operation_id": "53d73a83d33d4e3b8791764a9b9f2412"}}' + responses.add( + responses.PUT, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Construct a dict representation of a CreateListItemsReqItem model + create_list_items_req_item_model = {} + create_list_items_req_item_model['asn'] = 19604 + create_list_items_req_item_model['comment'] = 'My list of developer IPs.' + create_list_items_req_item_model['hostname'] = 'cloud.ibm.com' + create_list_items_req_item_model['ip'] = '172.64.0.0/13' + + # Set up parameter values + create_list_items_req_item = [create_list_items_req_item_model] + + # Invoke method + response = _service.update_list_items( + create_list_items_req_item=create_list_items_req_item, + 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 == create_list_items_req_item + + def test_update_list_items_all_params_with_retries(self): + # Enable retries and run test_update_list_items_all_params. + _service.enable_retries() + self.test_update_list_items_all_params() + + # Disable retries and run test_update_list_items_all_params. + _service.disable_retries() + self.test_update_list_items_all_params() + + @responses.activate + def test_update_list_items_required_params(self): + """ + test_update_list_items_required_params() + """ + # Set up mock + url = preprocess_url('/v1/testString/rules/lists/testString/items') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"operation_id": "53d73a83d33d4e3b8791764a9b9f2412"}}' + responses.add( + responses.PUT, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Invoke method + response = _service.update_list_items() + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_update_list_items_required_params_with_retries(self): + # Enable retries and run test_update_list_items_required_params. + _service.enable_retries() + self.test_update_list_items_required_params() + + # Disable retries and run test_update_list_items_required_params. + _service.disable_retries() + self.test_update_list_items_required_params() + + @responses.activate + def test_update_list_items_value_error(self): + """ + test_update_list_items_value_error() + """ + # Set up mock + url = preprocess_url('/v1/testString/rules/lists/testString/items') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"operation_id": "53d73a83d33d4e3b8791764a9b9f2412"}}' + responses.add( + responses.PUT, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.update_list_items(**req_copy) + + def test_update_list_items_value_error_with_retries(self): + # Enable retries and run test_update_list_items_value_error. + _service.enable_retries() + self.test_update_list_items_value_error() + + # Disable retries and run test_update_list_items_value_error. + _service.disable_retries() + self.test_update_list_items_value_error() + + +class TestGetListItem: + """ + Test Class for get_list_item + """ + + @responses.activate + def test_get_list_item_all_params(self): + """ + get_list_item() + """ + # Set up mock + url = preprocess_url('/v1/testString/rules/lists/testString/items/testString') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"id": "70c2009751b24ffc9ed1ab462ba957b4", "asn": 19604, "comment": "My list of developer IPs.", "hostname": "cloud.ibm.com", "ip": "172.64.0.0/13", "created_on": "2025-03-21T16:19:21Z", "modified_on": "2025-03-21T16:19:37Z"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Invoke method + response = _service.get_list_item() + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_get_list_item_all_params_with_retries(self): + # Enable retries and run test_get_list_item_all_params. + _service.enable_retries() + self.test_get_list_item_all_params() + + # Disable retries and run test_get_list_item_all_params. + _service.disable_retries() + self.test_get_list_item_all_params() + + @responses.activate + def test_get_list_item_value_error(self): + """ + test_get_list_item_value_error() + """ + # Set up mock + url = preprocess_url('/v1/testString/rules/lists/testString/items/testString') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"id": "70c2009751b24ffc9ed1ab462ba957b4", "asn": 19604, "comment": "My list of developer IPs.", "hostname": "cloud.ibm.com", "ip": "172.64.0.0/13", "created_on": "2025-03-21T16:19:21Z", "modified_on": "2025-03-21T16:19:37Z"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.get_list_item(**req_copy) + + def test_get_list_item_value_error_with_retries(self): + # Enable retries and run test_get_list_item_value_error. + _service.enable_retries() + self.test_get_list_item_value_error() + + # Disable retries and run test_get_list_item_value_error. + _service.disable_retries() + self.test_get_list_item_value_error() + + +class TestGetOperationStatus: + """ + Test Class for get_operation_status + """ + + @responses.activate + def test_get_operation_status_all_params(self): + """ + get_operation_status() + """ + # Set up mock + url = preprocess_url('/v1/testString/rules/lists/bulk_operations/testString') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"id": "0147be950d5c42b8b47c07792c5015e3", "status": "completed", "completed": "2025-03-21T16:07:41.782564Z", "error": "error"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Invoke method + response = _service.get_operation_status() + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_get_operation_status_all_params_with_retries(self): + # Enable retries and run test_get_operation_status_all_params. + _service.enable_retries() + self.test_get_operation_status_all_params() + + # Disable retries and run test_get_operation_status_all_params. + _service.disable_retries() + self.test_get_operation_status_all_params() + + @responses.activate + def test_get_operation_status_value_error(self): + """ + test_get_operation_status_value_error() + """ + # Set up mock + url = preprocess_url('/v1/testString/rules/lists/bulk_operations/testString') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"id": "0147be950d5c42b8b47c07792c5015e3", "status": "completed", "completed": "2025-03-21T16:07:41.782564Z", "error": "error"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.get_operation_status(**req_copy) + + def test_get_operation_status_value_error_with_retries(self): + # Enable retries and run test_get_operation_status_value_error. + _service.enable_retries() + self.test_get_operation_status_value_error() + + # Disable retries and run test_get_operation_status_value_error. + _service.disable_retries() + self.test_get_operation_status_value_error() + + +# endregion +############################################################################## +# End of Service: Lists +############################################################################## + + +############################################################################## +# Start of Model Tests +############################################################################## +# region + + +class TestModel_CreateListItemsReqItem: + """ + Test Class for CreateListItemsReqItem + """ + + def test_create_list_items_req_item_serialization(self): + """ + Test serialization/deserialization for CreateListItemsReqItem + """ + + # Construct a json representation of a CreateListItemsReqItem model + create_list_items_req_item_model_json = {} + create_list_items_req_item_model_json['asn'] = 19604 + create_list_items_req_item_model_json['comment'] = 'My list of developer IPs.' + create_list_items_req_item_model_json['hostname'] = 'cloud.ibm.com' + create_list_items_req_item_model_json['ip'] = '172.64.0.0/13' + + # Construct a model instance of CreateListItemsReqItem by calling from_dict on the json representation + create_list_items_req_item_model = CreateListItemsReqItem.from_dict(create_list_items_req_item_model_json) + assert create_list_items_req_item_model != False + + # Construct a model instance of CreateListItemsReqItem by calling from_dict on the json representation + create_list_items_req_item_model_dict = CreateListItemsReqItem.from_dict(create_list_items_req_item_model_json).__dict__ + create_list_items_req_item_model2 = CreateListItemsReqItem(**create_list_items_req_item_model_dict) + + # Verify the model instances are equivalent + assert create_list_items_req_item_model == create_list_items_req_item_model2 + + # Convert model instance back to dict and verify no loss of data + create_list_items_req_item_model_json2 = create_list_items_req_item_model.to_dict() + assert create_list_items_req_item_model_json2 == create_list_items_req_item_model_json + + +class TestModel_DeleteListItemsReqItemsItem: + """ + Test Class for DeleteListItemsReqItemsItem + """ + + def test_delete_list_items_req_items_item_serialization(self): + """ + Test serialization/deserialization for DeleteListItemsReqItemsItem + """ + + # Construct a json representation of a DeleteListItemsReqItemsItem model + delete_list_items_req_items_item_model_json = {} + delete_list_items_req_items_item_model_json['id'] = '70c2009751b24ffc9ed1ab462ba957b4' + + # Construct a model instance of DeleteListItemsReqItemsItem by calling from_dict on the json representation + delete_list_items_req_items_item_model = DeleteListItemsReqItemsItem.from_dict(delete_list_items_req_items_item_model_json) + assert delete_list_items_req_items_item_model != False + + # Construct a model instance of DeleteListItemsReqItemsItem by calling from_dict on the json representation + delete_list_items_req_items_item_model_dict = DeleteListItemsReqItemsItem.from_dict(delete_list_items_req_items_item_model_json).__dict__ + delete_list_items_req_items_item_model2 = DeleteListItemsReqItemsItem(**delete_list_items_req_items_item_model_dict) + + # Verify the model instances are equivalent + assert delete_list_items_req_items_item_model == delete_list_items_req_items_item_model2 + + # Convert model instance back to dict and verify no loss of data + delete_list_items_req_items_item_model_json2 = delete_list_items_req_items_item_model.to_dict() + assert delete_list_items_req_items_item_model_json2 == delete_list_items_req_items_item_model_json + + +class TestModel_DeleteResourceRespResult: + """ + Test Class for DeleteResourceRespResult + """ + + def test_delete_resource_resp_result_serialization(self): + """ + Test serialization/deserialization for DeleteResourceRespResult + """ + + # Construct a json representation of a DeleteResourceRespResult model + delete_resource_resp_result_model_json = {} + delete_resource_resp_result_model_json['id'] = '34b12448945f11eaa1b71c4d701ab86e' + + # Construct a model instance of DeleteResourceRespResult by calling from_dict on the json representation + delete_resource_resp_result_model = DeleteResourceRespResult.from_dict(delete_resource_resp_result_model_json) + assert delete_resource_resp_result_model != False + + # Construct a model instance of DeleteResourceRespResult by calling from_dict on the json representation + delete_resource_resp_result_model_dict = DeleteResourceRespResult.from_dict(delete_resource_resp_result_model_json).__dict__ + delete_resource_resp_result_model2 = DeleteResourceRespResult(**delete_resource_resp_result_model_dict) + + # Verify the model instances are equivalent + assert delete_resource_resp_result_model == delete_resource_resp_result_model2 + + # Convert model instance back to dict and verify no loss of data + delete_resource_resp_result_model_json2 = delete_resource_resp_result_model.to_dict() + assert delete_resource_resp_result_model_json2 == delete_resource_resp_result_model_json + + +class TestModel_ListOperationRespResult: + """ + Test Class for ListOperationRespResult + """ + + def test_list_operation_resp_result_serialization(self): + """ + Test serialization/deserialization for ListOperationRespResult + """ + + # Construct a json representation of a ListOperationRespResult model + list_operation_resp_result_model_json = {} + list_operation_resp_result_model_json['operation_id'] = '53d73a83d33d4e3b8791764a9b9f2412' + + # Construct a model instance of ListOperationRespResult by calling from_dict on the json representation + list_operation_resp_result_model = ListOperationRespResult.from_dict(list_operation_resp_result_model_json) + assert list_operation_resp_result_model != False + + # Construct a model instance of ListOperationRespResult by calling from_dict on the json representation + list_operation_resp_result_model_dict = ListOperationRespResult.from_dict(list_operation_resp_result_model_json).__dict__ + list_operation_resp_result_model2 = ListOperationRespResult(**list_operation_resp_result_model_dict) + + # Verify the model instances are equivalent + assert list_operation_resp_result_model == list_operation_resp_result_model2 + + # Convert model instance back to dict and verify no loss of data + list_operation_resp_result_model_json2 = list_operation_resp_result_model.to_dict() + assert list_operation_resp_result_model_json2 == list_operation_resp_result_model_json + + +class TestModel_ManagedListsResultItem: + """ + Test Class for ManagedListsResultItem + """ + + def test_managed_lists_result_item_serialization(self): + """ + Test serialization/deserialization for ManagedListsResultItem + """ + + # Construct a json representation of a ManagedListsResultItem model + managed_lists_result_item_model_json = {} + managed_lists_result_item_model_json['name'] = 'cf.malware' + managed_lists_result_item_model_json['description'] = 'testString' + managed_lists_result_item_model_json['kind'] = 'ip' + + # Construct a model instance of ManagedListsResultItem by calling from_dict on the json representation + managed_lists_result_item_model = ManagedListsResultItem.from_dict(managed_lists_result_item_model_json) + assert managed_lists_result_item_model != False + + # Construct a model instance of ManagedListsResultItem by calling from_dict on the json representation + managed_lists_result_item_model_dict = ManagedListsResultItem.from_dict(managed_lists_result_item_model_json).__dict__ + managed_lists_result_item_model2 = ManagedListsResultItem(**managed_lists_result_item_model_dict) + + # Verify the model instances are equivalent + assert managed_lists_result_item_model == managed_lists_result_item_model2 + + # Convert model instance back to dict and verify no loss of data + managed_lists_result_item_model_json2 = managed_lists_result_item_model.to_dict() + assert managed_lists_result_item_model_json2 == managed_lists_result_item_model_json + + +class TestModel_OperationStatusRespResult: + """ + Test Class for OperationStatusRespResult + """ + + def test_operation_status_resp_result_serialization(self): + """ + Test serialization/deserialization for OperationStatusRespResult + """ + + # Construct a json representation of a OperationStatusRespResult model + operation_status_resp_result_model_json = {} + operation_status_resp_result_model_json['id'] = '0147be950d5c42b8b47c07792c5015e3' + operation_status_resp_result_model_json['status'] = 'completed' + operation_status_resp_result_model_json['completed'] = '2025-03-21T16:07:41.782564Z' + operation_status_resp_result_model_json['error'] = 'testString' + + # Construct a model instance of OperationStatusRespResult by calling from_dict on the json representation + operation_status_resp_result_model = OperationStatusRespResult.from_dict(operation_status_resp_result_model_json) + assert operation_status_resp_result_model != False + + # Construct a model instance of OperationStatusRespResult by calling from_dict on the json representation + operation_status_resp_result_model_dict = OperationStatusRespResult.from_dict(operation_status_resp_result_model_json).__dict__ + operation_status_resp_result_model2 = OperationStatusRespResult(**operation_status_resp_result_model_dict) + + # Verify the model instances are equivalent + assert operation_status_resp_result_model == operation_status_resp_result_model2 + + # Convert model instance back to dict and verify no loss of data + operation_status_resp_result_model_json2 = operation_status_resp_result_model.to_dict() + assert operation_status_resp_result_model_json2 == operation_status_resp_result_model_json + + +class TestModel_CustomListResp: + """ + Test Class for CustomListResp + """ + + def test_custom_list_resp_serialization(self): + """ + Test serialization/deserialization for CustomListResp + """ + + # Construct dict forms of any model objects needed in order to build this model. + + custom_list_result_model = {} # CustomListResult + custom_list_result_model['name'] = 'good_ips' + custom_list_result_model['id'] = 'testString' + custom_list_result_model['description'] = 'testString' + custom_list_result_model['kind'] = 'ip' + custom_list_result_model['num_items'] = 10 + custom_list_result_model['num_referencing_filters'] = 5 + + # Construct a json representation of a CustomListResp model + custom_list_resp_model_json = {} + custom_list_resp_model_json['success'] = True + custom_list_resp_model_json['errors'] = [['testString']] + custom_list_resp_model_json['messages'] = [['testString']] + custom_list_resp_model_json['result'] = custom_list_result_model + + # Construct a model instance of CustomListResp by calling from_dict on the json representation + custom_list_resp_model = CustomListResp.from_dict(custom_list_resp_model_json) + assert custom_list_resp_model != False + + # Construct a model instance of CustomListResp by calling from_dict on the json representation + custom_list_resp_model_dict = CustomListResp.from_dict(custom_list_resp_model_json).__dict__ + custom_list_resp_model2 = CustomListResp(**custom_list_resp_model_dict) + + # Verify the model instances are equivalent + assert custom_list_resp_model == custom_list_resp_model2 + + # Convert model instance back to dict and verify no loss of data + custom_list_resp_model_json2 = custom_list_resp_model.to_dict() + assert custom_list_resp_model_json2 == custom_list_resp_model_json + + +class TestModel_CustomListResult: + """ + Test Class for CustomListResult + """ + + def test_custom_list_result_serialization(self): + """ + Test serialization/deserialization for CustomListResult + """ + + # Construct a json representation of a CustomListResult model + custom_list_result_model_json = {} + custom_list_result_model_json['name'] = 'good_ips' + custom_list_result_model_json['id'] = 'testString' + custom_list_result_model_json['description'] = 'testString' + custom_list_result_model_json['kind'] = 'ip' + custom_list_result_model_json['num_items'] = 10 + custom_list_result_model_json['num_referencing_filters'] = 5 + + # Construct a model instance of CustomListResult by calling from_dict on the json representation + custom_list_result_model = CustomListResult.from_dict(custom_list_result_model_json) + assert custom_list_result_model != False + + # Construct a model instance of CustomListResult by calling from_dict on the json representation + custom_list_result_model_dict = CustomListResult.from_dict(custom_list_result_model_json).__dict__ + custom_list_result_model2 = CustomListResult(**custom_list_result_model_dict) + + # Verify the model instances are equivalent + assert custom_list_result_model == custom_list_result_model2 + + # Convert model instance back to dict and verify no loss of data + custom_list_result_model_json2 = custom_list_result_model.to_dict() + assert custom_list_result_model_json2 == custom_list_result_model_json + + +class TestModel_CustomListsResp: + """ + Test Class for CustomListsResp + """ + + def test_custom_lists_resp_serialization(self): + """ + Test serialization/deserialization for CustomListsResp + """ + + # Construct dict forms of any model objects needed in order to build this model. + + custom_list_result_model = {} # CustomListResult + custom_list_result_model['name'] = 'good_ips' + custom_list_result_model['id'] = 'testString' + custom_list_result_model['description'] = 'testString' + custom_list_result_model['kind'] = 'ip' + custom_list_result_model['num_items'] = 10 + custom_list_result_model['num_referencing_filters'] = 5 + + # Construct a json representation of a CustomListsResp model + custom_lists_resp_model_json = {} + custom_lists_resp_model_json['success'] = True + custom_lists_resp_model_json['errors'] = [['testString']] + custom_lists_resp_model_json['messages'] = [['testString']] + custom_lists_resp_model_json['result'] = [custom_list_result_model] + + # Construct a model instance of CustomListsResp by calling from_dict on the json representation + custom_lists_resp_model = CustomListsResp.from_dict(custom_lists_resp_model_json) + assert custom_lists_resp_model != False + + # Construct a model instance of CustomListsResp by calling from_dict on the json representation + custom_lists_resp_model_dict = CustomListsResp.from_dict(custom_lists_resp_model_json).__dict__ + custom_lists_resp_model2 = CustomListsResp(**custom_lists_resp_model_dict) + + # Verify the model instances are equivalent + assert custom_lists_resp_model == custom_lists_resp_model2 + + # Convert model instance back to dict and verify no loss of data + custom_lists_resp_model_json2 = custom_lists_resp_model.to_dict() + assert custom_lists_resp_model_json2 == custom_lists_resp_model_json + + +class TestModel_DeleteResourceResp: + """ + Test Class for DeleteResourceResp + """ + + def test_delete_resource_resp_serialization(self): + """ + Test serialization/deserialization for DeleteResourceResp + """ + + # Construct dict forms of any model objects needed in order to build this model. + + delete_resource_resp_result_model = {} # DeleteResourceRespResult + delete_resource_resp_result_model['id'] = '34b12448945f11eaa1b71c4d701ab86e' + + # Construct a json representation of a DeleteResourceResp model + delete_resource_resp_model_json = {} + delete_resource_resp_model_json['success'] = True + delete_resource_resp_model_json['errors'] = [['testString']] + delete_resource_resp_model_json['messages'] = [['testString']] + delete_resource_resp_model_json['result'] = delete_resource_resp_result_model + + # Construct a model instance of DeleteResourceResp by calling from_dict on the json representation + delete_resource_resp_model = DeleteResourceResp.from_dict(delete_resource_resp_model_json) + assert delete_resource_resp_model != False + + # Construct a model instance of DeleteResourceResp by calling from_dict on the json representation + delete_resource_resp_model_dict = DeleteResourceResp.from_dict(delete_resource_resp_model_json).__dict__ + delete_resource_resp_model2 = DeleteResourceResp(**delete_resource_resp_model_dict) + + # Verify the model instances are equivalent + assert delete_resource_resp_model == delete_resource_resp_model2 + + # Convert model instance back to dict and verify no loss of data + delete_resource_resp_model_json2 = delete_resource_resp_model.to_dict() + assert delete_resource_resp_model_json2 == delete_resource_resp_model_json + + +class TestModel_ListCursor: + """ + Test Class for ListCursor + """ + + def test_list_cursor_serialization(self): + """ + Test serialization/deserialization for ListCursor + """ + + # Construct a json representation of a ListCursor model + list_cursor_model_json = {} + list_cursor_model_json['after'] = 'yyy' + list_cursor_model_json['before'] = 'xxx' + + # Construct a model instance of ListCursor by calling from_dict on the json representation + list_cursor_model = ListCursor.from_dict(list_cursor_model_json) + assert list_cursor_model != False + + # Construct a model instance of ListCursor by calling from_dict on the json representation + list_cursor_model_dict = ListCursor.from_dict(list_cursor_model_json).__dict__ + list_cursor_model2 = ListCursor(**list_cursor_model_dict) + + # Verify the model instances are equivalent + assert list_cursor_model == list_cursor_model2 + + # Convert model instance back to dict and verify no loss of data + list_cursor_model_json2 = list_cursor_model.to_dict() + assert list_cursor_model_json2 == list_cursor_model_json + + +class TestModel_ListItem: + """ + Test Class for ListItem + """ + + def test_list_item_serialization(self): + """ + Test serialization/deserialization for ListItem + """ + + # Construct a json representation of a ListItem model + list_item_model_json = {} + list_item_model_json['id'] = '70c2009751b24ffc9ed1ab462ba957b4' + list_item_model_json['asn'] = 19604 + list_item_model_json['comment'] = 'My list of developer IPs.' + list_item_model_json['hostname'] = 'cloud.ibm.com' + list_item_model_json['ip'] = '172.64.0.0/13' + list_item_model_json['created_on'] = '2025-03-21T16:19:21Z' + list_item_model_json['modified_on'] = '2025-03-21T16:19:37Z' + + # Construct a model instance of ListItem by calling from_dict on the json representation + list_item_model = ListItem.from_dict(list_item_model_json) + assert list_item_model != False + + # Construct a model instance of ListItem by calling from_dict on the json representation + list_item_model_dict = ListItem.from_dict(list_item_model_json).__dict__ + list_item_model2 = ListItem(**list_item_model_dict) + + # Verify the model instances are equivalent + assert list_item_model == list_item_model2 + + # Convert model instance back to dict and verify no loss of data + list_item_model_json2 = list_item_model.to_dict() + assert list_item_model_json2 == list_item_model_json + + +class TestModel_ListItemResp: + """ + Test Class for ListItemResp + """ + + def test_list_item_resp_serialization(self): + """ + Test serialization/deserialization for ListItemResp + """ + + # Construct dict forms of any model objects needed in order to build this model. + + list_item_model = {} # ListItem + list_item_model['id'] = '70c2009751b24ffc9ed1ab462ba957b4' + list_item_model['asn'] = 19604 + list_item_model['comment'] = 'My list of developer IPs.' + list_item_model['hostname'] = 'cloud.ibm.com' + list_item_model['ip'] = '172.64.0.0/13' + list_item_model['created_on'] = '2025-03-21T16:19:21Z' + list_item_model['modified_on'] = '2025-03-21T16:19:37Z' + + # Construct a json representation of a ListItemResp model + list_item_resp_model_json = {} + list_item_resp_model_json['success'] = True + list_item_resp_model_json['errors'] = [['testString']] + list_item_resp_model_json['messages'] = [['testString']] + list_item_resp_model_json['result'] = list_item_model + + # Construct a model instance of ListItemResp by calling from_dict on the json representation + list_item_resp_model = ListItemResp.from_dict(list_item_resp_model_json) + assert list_item_resp_model != False + + # Construct a model instance of ListItemResp by calling from_dict on the json representation + list_item_resp_model_dict = ListItemResp.from_dict(list_item_resp_model_json).__dict__ + list_item_resp_model2 = ListItemResp(**list_item_resp_model_dict) + + # Verify the model instances are equivalent + assert list_item_resp_model == list_item_resp_model2 + + # Convert model instance back to dict and verify no loss of data + list_item_resp_model_json2 = list_item_resp_model.to_dict() + assert list_item_resp_model_json2 == list_item_resp_model_json + + +class TestModel_ListItemsResp: + """ + Test Class for ListItemsResp + """ + + def test_list_items_resp_serialization(self): + """ + Test serialization/deserialization for ListItemsResp + """ + + # Construct dict forms of any model objects needed in order to build this model. + + list_item_model = {} # ListItem + list_item_model['id'] = '70c2009751b24ffc9ed1ab462ba957b4' + list_item_model['asn'] = 19604 + list_item_model['comment'] = 'My list of developer IPs.' + list_item_model['hostname'] = 'cloud.ibm.com' + list_item_model['ip'] = '172.64.0.0/13' + list_item_model['created_on'] = '2025-03-21T16:19:21Z' + list_item_model['modified_on'] = '2025-03-21T16:19:37Z' + + list_cursor_model = {} # ListCursor + list_cursor_model['after'] = 'yyy' + list_cursor_model['before'] = 'xxx' + + list_items_result_info_model = {} # ListItemsResultInfo + list_items_result_info_model['cursors'] = list_cursor_model + + # Construct a json representation of a ListItemsResp model + list_items_resp_model_json = {} + list_items_resp_model_json['success'] = True + list_items_resp_model_json['errors'] = [['testString']] + list_items_resp_model_json['messages'] = [['testString']] + list_items_resp_model_json['result'] = [list_item_model] + list_items_resp_model_json['result_info'] = list_items_result_info_model + + # Construct a model instance of ListItemsResp by calling from_dict on the json representation + list_items_resp_model = ListItemsResp.from_dict(list_items_resp_model_json) + assert list_items_resp_model != False + + # Construct a model instance of ListItemsResp by calling from_dict on the json representation + list_items_resp_model_dict = ListItemsResp.from_dict(list_items_resp_model_json).__dict__ + list_items_resp_model2 = ListItemsResp(**list_items_resp_model_dict) + + # Verify the model instances are equivalent + assert list_items_resp_model == list_items_resp_model2 + + # Convert model instance back to dict and verify no loss of data + list_items_resp_model_json2 = list_items_resp_model.to_dict() + assert list_items_resp_model_json2 == list_items_resp_model_json + + +class TestModel_ListItemsResultInfo: + """ + Test Class for ListItemsResultInfo + """ + + def test_list_items_result_info_serialization(self): + """ + Test serialization/deserialization for ListItemsResultInfo + """ + + # Construct dict forms of any model objects needed in order to build this model. + + list_cursor_model = {} # ListCursor + list_cursor_model['after'] = 'yyy' + list_cursor_model['before'] = 'xxx' + + # Construct a json representation of a ListItemsResultInfo model + list_items_result_info_model_json = {} + list_items_result_info_model_json['cursors'] = list_cursor_model + + # Construct a model instance of ListItemsResultInfo by calling from_dict on the json representation + list_items_result_info_model = ListItemsResultInfo.from_dict(list_items_result_info_model_json) + assert list_items_result_info_model != False + + # Construct a model instance of ListItemsResultInfo by calling from_dict on the json representation + list_items_result_info_model_dict = ListItemsResultInfo.from_dict(list_items_result_info_model_json).__dict__ + list_items_result_info_model2 = ListItemsResultInfo(**list_items_result_info_model_dict) + + # Verify the model instances are equivalent + assert list_items_result_info_model == list_items_result_info_model2 + + # Convert model instance back to dict and verify no loss of data + list_items_result_info_model_json2 = list_items_result_info_model.to_dict() + assert list_items_result_info_model_json2 == list_items_result_info_model_json + + +class TestModel_ListOperationResp: + """ + Test Class for ListOperationResp + """ + + def test_list_operation_resp_serialization(self): + """ + Test serialization/deserialization for ListOperationResp + """ + + # Construct dict forms of any model objects needed in order to build this model. + + list_operation_resp_result_model = {} # ListOperationRespResult + list_operation_resp_result_model['operation_id'] = '53d73a83d33d4e3b8791764a9b9f2412' + + # Construct a json representation of a ListOperationResp model + list_operation_resp_model_json = {} + list_operation_resp_model_json['success'] = True + list_operation_resp_model_json['errors'] = [['testString']] + list_operation_resp_model_json['messages'] = [['testString']] + list_operation_resp_model_json['result'] = list_operation_resp_result_model + + # Construct a model instance of ListOperationResp by calling from_dict on the json representation + list_operation_resp_model = ListOperationResp.from_dict(list_operation_resp_model_json) + assert list_operation_resp_model != False + + # Construct a model instance of ListOperationResp by calling from_dict on the json representation + list_operation_resp_model_dict = ListOperationResp.from_dict(list_operation_resp_model_json).__dict__ + list_operation_resp_model2 = ListOperationResp(**list_operation_resp_model_dict) + + # Verify the model instances are equivalent + assert list_operation_resp_model == list_operation_resp_model2 + + # Convert model instance back to dict and verify no loss of data + list_operation_resp_model_json2 = list_operation_resp_model.to_dict() + assert list_operation_resp_model_json2 == list_operation_resp_model_json + + +class TestModel_ManagedListsResp: + """ + Test Class for ManagedListsResp + """ + + def test_managed_lists_resp_serialization(self): + """ + Test serialization/deserialization for ManagedListsResp + """ + + # Construct dict forms of any model objects needed in order to build this model. + + managed_lists_result_item_model = {} # ManagedListsResultItem + managed_lists_result_item_model['name'] = 'cf.malware' + managed_lists_result_item_model['description'] = 'testString' + managed_lists_result_item_model['kind'] = 'ip' + + # Construct a json representation of a ManagedListsResp model + managed_lists_resp_model_json = {} + managed_lists_resp_model_json['success'] = True + managed_lists_resp_model_json['errors'] = [['testString']] + managed_lists_resp_model_json['messages'] = [['testString']] + managed_lists_resp_model_json['result'] = [managed_lists_result_item_model] + + # Construct a model instance of ManagedListsResp by calling from_dict on the json representation + managed_lists_resp_model = ManagedListsResp.from_dict(managed_lists_resp_model_json) + assert managed_lists_resp_model != False + + # Construct a model instance of ManagedListsResp by calling from_dict on the json representation + managed_lists_resp_model_dict = ManagedListsResp.from_dict(managed_lists_resp_model_json).__dict__ + managed_lists_resp_model2 = ManagedListsResp(**managed_lists_resp_model_dict) + + # Verify the model instances are equivalent + assert managed_lists_resp_model == managed_lists_resp_model2 + + # Convert model instance back to dict and verify no loss of data + managed_lists_resp_model_json2 = managed_lists_resp_model.to_dict() + assert managed_lists_resp_model_json2 == managed_lists_resp_model_json + + +class TestModel_OperationStatusResp: + """ + Test Class for OperationStatusResp + """ + + def test_operation_status_resp_serialization(self): + """ + Test serialization/deserialization for OperationStatusResp + """ + + # Construct dict forms of any model objects needed in order to build this model. + + operation_status_resp_result_model = {} # OperationStatusRespResult + operation_status_resp_result_model['id'] = '0147be950d5c42b8b47c07792c5015e3' + operation_status_resp_result_model['status'] = 'completed' + operation_status_resp_result_model['completed'] = '2025-03-21T16:07:41.782564Z' + operation_status_resp_result_model['error'] = 'testString' + + # Construct a json representation of a OperationStatusResp model + operation_status_resp_model_json = {} + operation_status_resp_model_json['success'] = True + operation_status_resp_model_json['errors'] = [['testString']] + operation_status_resp_model_json['messages'] = [['testString']] + operation_status_resp_model_json['result'] = operation_status_resp_result_model + + # Construct a model instance of OperationStatusResp by calling from_dict on the json representation + operation_status_resp_model = OperationStatusResp.from_dict(operation_status_resp_model_json) + assert operation_status_resp_model != False + + # Construct a model instance of OperationStatusResp by calling from_dict on the json representation + operation_status_resp_model_dict = OperationStatusResp.from_dict(operation_status_resp_model_json).__dict__ + operation_status_resp_model2 = OperationStatusResp(**operation_status_resp_model_dict) + + # Verify the model instances are equivalent + assert operation_status_resp_model == operation_status_resp_model2 + + # Convert model instance back to dict and verify no loss of data + operation_status_resp_model_json2 = operation_status_resp_model.to_dict() + assert operation_status_resp_model_json2 == operation_status_resp_model_json + + +# endregion +############################################################################## +# End of Model Tests +##############################################################################