diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 153e8ea..074c935 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.31.1 +current_version = 0.33.0 commit = True message = Update version {current_version} -> {new_version} [skip ci] diff --git a/CHANGELOG.md b/CHANGELOG.md index bbcfc0e..40b34f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,17 @@ +# [0.33.0](https://github.com/IBM/networking-python-sdk/compare/v0.32.0...v0.33.0) (2026-05-05) + + +### Features + +* Update CIS SDK — CIS_Frontend_API_Spec-Lists ([#205](https://github.com/IBM/networking-python-sdk/issues/205)) ([4690267](https://github.com/IBM/networking-python-sdk/commit/469026744a45621b95b618ef0fdc9dee72f23a0b)) + +# [0.32.0](https://github.com/IBM/networking-python-sdk/compare/v0.31.1...v0.32.0) (2026-05-05) + + +### Features + +* Add security level setting operations ([#204](https://github.com/IBM/networking-python-sdk/issues/204)) ([88ee858](https://github.com/IBM/networking-python-sdk/commit/88ee8582a2f4e8b3861944859b970181803825ff)) + ## [0.31.1](https://github.com/IBM/networking-python-sdk/compare/v0.31.0...v0.31.1) (2026-04-29) diff --git a/README.md b/README.md index 95ce62f..4a006b7 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) -# IBM Cloud Networking Services Python SDK Version 0.31.1 +# IBM Cloud Networking Services Python SDK Version 0.33.0 Python client library to interact with various [IBM Cloud Networking Service APIs](https://cloud.ibm.com/apidocs?category=network). @@ -99,13 +99,13 @@ IBM Cloud services: To install, use `pip` or `easy_install`: ```bash -pip install --upgrade "ibm-cloud-networking-services==0.31.1" +pip install --upgrade "ibm-cloud-networking-services==0.33.0" ``` or ```bash -easy_install --upgrade "ibm-cloud-networking-servies==0.31.1" +easy_install --upgrade "ibm-cloud-networking-servies==0.33.0" ``` ## Using the SDK 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/ibm_cloud_networking_services/mtls_v1.py b/ibm_cloud_networking_services/mtls_v1.py new file mode 100644 index 0000000..414259b --- /dev/null +++ b/ibm_cloud_networking_services/mtls_v1.py @@ -0,0 +1,3291 @@ +# 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 + +""" +MTLS + +API Version: 1.0.0 +""" + +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 MtlsV1(BaseService): + """The MTLS V1 service.""" + + DEFAULT_SERVICE_URL = 'https://api.cis.cloud.ibm.com' + DEFAULT_SERVICE_NAME = 'mtls' + + @classmethod + def new_instance( + cls, + crn: str, + service_name: str = DEFAULT_SERVICE_NAME, + ) -> 'MtlsV1': + """ + Return a new client for the MTLS service using the specified parameters and + external configuration. + + :param str crn: Cloud resource name. + """ + if crn is None: + raise ValueError('crn must be provided') + + authenticator = get_authenticator_from_environment(service_name) + service = cls( + crn, + authenticator + ) + service.configure_service(service_name) + return service + + def __init__( + self, + crn: str, + authenticator: Authenticator = None, + ) -> None: + """ + Construct a new client for the MTLS service. + + :param str crn: Cloud resource name. + + :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') + + BaseService.__init__(self, service_url=self.DEFAULT_SERVICE_URL, authenticator=authenticator) + self.crn = crn + + ######################### + # Mutual TLS + ######################### + + def list_access_certificates( + self, + zone_id: str, + **kwargs, + ) -> DetailedResponse: + """ + List access certificates. + + List access certificates. + + :param str zone_id: Zone ID. + :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 `ListAccessCertsResp` object + """ + + if not zone_id: + raise ValueError('zone_id must be provided') + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='list_access_certificates', + ) + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'zone_id'] + path_param_values = self.encode_path_vars(self.crn, zone_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/zones/{zone_id}/access/certificates'.format(**path_param_dict) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + ) + + response = self.send(request, **kwargs) + return response + + def create_access_certificate( + self, + zone_id: str, + *, + name: Optional[str] = None, + certificate: Optional[str] = None, + associated_hostnames: Optional[List[str]] = None, + **kwargs, + ) -> DetailedResponse: + """ + Create access certificate. + + Create access certificate. + + :param str zone_id: Zone ID. + :param str name: (optional) Access certificate name. + :param str certificate: (optional) Access certificate. + :param List[str] associated_hostnames: (optional) The hostnames that are + prompted for this certificate. + :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 `AccessCertResp` object + """ + + if not zone_id: + raise ValueError('zone_id must be provided') + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='create_access_certificate', + ) + headers.update(sdk_headers) + + data = { + 'name': name, + 'certificate': certificate, + 'associated_hostnames': associated_hostnames, + } + data = {k: v for (k, v) in data.items() if v is not None} + data = json.dumps(data) + headers['content-type'] = 'application/json' + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'zone_id'] + path_param_values = self.encode_path_vars(self.crn, zone_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/zones/{zone_id}/access/certificates'.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_access_certificate( + self, + zone_id: str, + cert_id: str, + **kwargs, + ) -> DetailedResponse: + """ + Get access certificate. + + Get access certificate. + + :param str zone_id: Zone ID. + :param str cert_id: Access certificate ID. + :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 `AccessCertResp` object + """ + + if not zone_id: + raise ValueError('zone_id must be provided') + if not cert_id: + raise ValueError('cert_id must be provided') + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='get_access_certificate', + ) + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'zone_id', 'cert_id'] + path_param_values = self.encode_path_vars(self.crn, zone_id, cert_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/zones/{zone_id}/access/certificates/{cert_id}'.format(**path_param_dict) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + ) + + response = self.send(request, **kwargs) + return response + + def update_access_certificate( + self, + zone_id: str, + cert_id: str, + *, + name: Optional[str] = None, + associated_hostnames: Optional[List[str]] = None, + **kwargs, + ) -> DetailedResponse: + """ + Update access certificate. + + Update access certificate. + + :param str zone_id: Zone ID. + :param str cert_id: Access certificate ID. + :param str name: (optional) Access certificate name. + :param List[str] associated_hostnames: (optional) The hostnames that are + prompted for this certificate. + :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 `AccessCertResp` object + """ + + if not zone_id: + raise ValueError('zone_id must be provided') + if not cert_id: + raise ValueError('cert_id must be provided') + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='update_access_certificate', + ) + headers.update(sdk_headers) + + data = { + 'name': name, + 'associated_hostnames': associated_hostnames, + } + data = {k: v for (k, v) in data.items() if v is not None} + data = json.dumps(data) + headers['content-type'] = 'application/json' + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'zone_id', 'cert_id'] + path_param_values = self.encode_path_vars(self.crn, zone_id, cert_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/zones/{zone_id}/access/certificates/{cert_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_access_certificate( + self, + zone_id: str, + cert_id: str, + **kwargs, + ) -> DetailedResponse: + """ + Delete access certificate. + + Delete access certificate. + + :param str zone_id: Zone ID. + :param str cert_id: Access certificate ID. + :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 `DeleteAccessCertResp` object + """ + + if not zone_id: + raise ValueError('zone_id must be provided') + if not cert_id: + raise ValueError('cert_id must be provided') + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='delete_access_certificate', + ) + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'zone_id', 'cert_id'] + path_param_values = self.encode_path_vars(self.crn, zone_id, cert_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/zones/{zone_id}/access/certificates/{cert_id}'.format(**path_param_dict) + request = self.prepare_request( + method='DELETE', + url=url, + headers=headers, + ) + + response = self.send(request, **kwargs) + return response + + def list_access_applications( + self, + zone_id: str, + **kwargs, + ) -> DetailedResponse: + """ + List access applications. + + List access applications. + + :param str zone_id: Zone ID. + :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 `ListAccessAppsResp` object + """ + + if not zone_id: + raise ValueError('zone_id must be provided') + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='list_access_applications', + ) + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'zone_id'] + path_param_values = self.encode_path_vars(self.crn, zone_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/zones/{zone_id}/access/apps'.format(**path_param_dict) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + ) + + response = self.send(request, **kwargs) + return response + + def create_access_application( + self, + zone_id: str, + *, + name: Optional[str] = None, + domain: Optional[str] = None, + session_duration: Optional[str] = None, + **kwargs, + ) -> DetailedResponse: + """ + Create access application. + + Create access application. + + :param str zone_id: Zone ID. + :param str name: (optional) Application name. + :param str domain: (optional) The domain and path that Access blocks. + :param str session_duration: (optional) The amount of time that the tokens + issued for this application are valid. + :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 `CreateAccessAppResp` object + """ + + if not zone_id: + raise ValueError('zone_id must be provided') + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='create_access_application', + ) + headers.update(sdk_headers) + + data = { + 'name': name, + 'domain': domain, + 'session_duration': session_duration, + } + data = {k: v for (k, v) in data.items() if v is not None} + data = json.dumps(data) + headers['content-type'] = 'application/json' + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'zone_id'] + path_param_values = self.encode_path_vars(self.crn, zone_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/zones/{zone_id}/access/apps'.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_access_application( + self, + zone_id: str, + app_id: str, + **kwargs, + ) -> DetailedResponse: + """ + Get access application. + + Get access application. + + :param str zone_id: Zone ID. + :param str app_id: Access application ID. + :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 `AccessAppResp` object + """ + + if not zone_id: + raise ValueError('zone_id must be provided') + if not app_id: + raise ValueError('app_id must be provided') + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='get_access_application', + ) + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'zone_id', 'app_id'] + path_param_values = self.encode_path_vars(self.crn, zone_id, app_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/zones/{zone_id}/access/apps/{app_id}'.format(**path_param_dict) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + ) + + response = self.send(request, **kwargs) + return response + + def update_access_application( + self, + zone_id: str, + app_id: str, + *, + name: Optional[str] = None, + domain: Optional[str] = None, + session_duration: Optional[str] = None, + **kwargs, + ) -> DetailedResponse: + """ + Update access application. + + Update access application. + + :param str zone_id: Zone ID. + :param str app_id: Access application ID. + :param str name: (optional) Application name. + :param str domain: (optional) The domain and path that Access blocks. + :param str session_duration: (optional) The amount of time that the tokens + issued for this application are valid. + :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 `AccessAppResp` object + """ + + if not zone_id: + raise ValueError('zone_id must be provided') + if not app_id: + raise ValueError('app_id must be provided') + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='update_access_application', + ) + headers.update(sdk_headers) + + data = { + 'name': name, + 'domain': domain, + 'session_duration': session_duration, + } + data = {k: v for (k, v) in data.items() if v is not None} + data = json.dumps(data) + headers['content-type'] = 'application/json' + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'zone_id', 'app_id'] + path_param_values = self.encode_path_vars(self.crn, zone_id, app_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/zones/{zone_id}/access/apps/{app_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_access_application( + self, + zone_id: str, + app_id: str, + **kwargs, + ) -> DetailedResponse: + """ + Delete access application. + + Delete access application. + + :param str zone_id: Zone ID. + :param str app_id: Access application ID. + :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 `DeleteAccessAppResp` object + """ + + if not zone_id: + raise ValueError('zone_id must be provided') + if not app_id: + raise ValueError('app_id must be provided') + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='delete_access_application', + ) + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'zone_id', 'app_id'] + path_param_values = self.encode_path_vars(self.crn, zone_id, app_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/zones/{zone_id}/access/apps/{app_id}'.format(**path_param_dict) + request = self.prepare_request( + method='DELETE', + url=url, + headers=headers, + ) + + response = self.send(request, **kwargs) + return response + + def list_access_policies( + self, + zone_id: str, + app_id: str, + **kwargs, + ) -> DetailedResponse: + """ + List access policies. + + List access policies. + + :param str zone_id: Zone ID. + :param str app_id: Access application ID. + :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 `ListAccessPoliciesResp` object + """ + + if not zone_id: + raise ValueError('zone_id must be provided') + if not app_id: + raise ValueError('app_id must be provided') + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='list_access_policies', + ) + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'zone_id', 'app_id'] + path_param_values = self.encode_path_vars(self.crn, zone_id, app_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/zones/{zone_id}/access/apps/{app_id}/policies'.format(**path_param_dict) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + ) + + response = self.send(request, **kwargs) + return response + + def create_access_policy( + self, + zone_id: str, + app_id: str, + *, + name: Optional[str] = None, + decision: Optional[str] = None, + include: Optional[List['PolicyRule']] = None, + **kwargs, + ) -> DetailedResponse: + """ + Create access policy. + + Create access policy. + + :param str zone_id: Zone ID. + :param str app_id: Access application ID. + :param str name: (optional) Policy name. + :param str decision: (optional) Defines the action Access takes if the + policy matches the user. + :param List[PolicyRule] include: (optional) The include policy works like + an OR logical operator. The user must satisfy one of the rules in includes. + :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 `AccessPolicyResp` object + """ + + if not zone_id: + raise ValueError('zone_id must be provided') + if not app_id: + raise ValueError('app_id must be provided') + if include is not None: + include = [convert_model(x) for x in include] + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='create_access_policy', + ) + headers.update(sdk_headers) + + data = { + 'name': name, + 'decision': decision, + 'include': include, + } + data = {k: v for (k, v) in data.items() if v is not None} + data = json.dumps(data) + headers['content-type'] = 'application/json' + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'zone_id', 'app_id'] + path_param_values = self.encode_path_vars(self.crn, zone_id, app_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/zones/{zone_id}/access/apps/{app_id}/policies'.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_access_policy( + self, + zone_id: str, + app_id: str, + policy_id: str, + **kwargs, + ) -> DetailedResponse: + """ + Get access policy. + + Get access policy. + + :param str zone_id: Zone ID. + :param str app_id: Access application ID. + :param str policy_id: Access policy ID. + :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 `AccessPolicyResp` object + """ + + if not zone_id: + raise ValueError('zone_id must be provided') + if not app_id: + raise ValueError('app_id must be provided') + if not policy_id: + raise ValueError('policy_id must be provided') + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='get_access_policy', + ) + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'zone_id', 'app_id', 'policy_id'] + path_param_values = self.encode_path_vars(self.crn, zone_id, app_id, policy_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/zones/{zone_id}/access/apps/{app_id}/policies/{policy_id}'.format(**path_param_dict) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + ) + + response = self.send(request, **kwargs) + return response + + def update_access_policy( + self, + zone_id: str, + app_id: str, + policy_id: str, + *, + name: Optional[str] = None, + decision: Optional[str] = None, + include: Optional[List['PolicyRule']] = None, + **kwargs, + ) -> DetailedResponse: + """ + Update access policy. + + Update access policy. + + :param str zone_id: Zone ID. + :param str app_id: Access application ID. + :param str policy_id: Access policy ID. + :param str name: (optional) Policy name. + :param str decision: (optional) Defines the action Access takes if the + policy matches the user. + :param List[PolicyRule] include: (optional) The include policy works like + an OR logical operator. The user must satisfy one of the rules in includes. + :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 `AccessPolicyResp` object + """ + + if not zone_id: + raise ValueError('zone_id must be provided') + if not app_id: + raise ValueError('app_id must be provided') + if not policy_id: + raise ValueError('policy_id must be provided') + if include is not None: + include = [convert_model(x) for x in include] + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='update_access_policy', + ) + headers.update(sdk_headers) + + data = { + 'name': name, + 'decision': decision, + 'include': include, + } + data = {k: v for (k, v) in data.items() if v is not None} + data = json.dumps(data) + headers['content-type'] = 'application/json' + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'zone_id', 'app_id', 'policy_id'] + path_param_values = self.encode_path_vars(self.crn, zone_id, app_id, policy_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/zones/{zone_id}/access/apps/{app_id}/policies/{policy_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_access_policy( + self, + zone_id: str, + app_id: str, + policy_id: str, + **kwargs, + ) -> DetailedResponse: + """ + Delete access policy. + + Delete access policy. + + :param str zone_id: Zone ID. + :param str app_id: Access application ID. + :param str policy_id: Access policy ID. + :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 `DeleteAccessPolicyResp` object + """ + + if not zone_id: + raise ValueError('zone_id must be provided') + if not app_id: + raise ValueError('app_id must be provided') + if not policy_id: + raise ValueError('policy_id must be provided') + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='delete_access_policy', + ) + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'zone_id', 'app_id', 'policy_id'] + path_param_values = self.encode_path_vars(self.crn, zone_id, app_id, policy_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/zones/{zone_id}/access/apps/{app_id}/policies/{policy_id}'.format(**path_param_dict) + request = self.prepare_request( + method='DELETE', + url=url, + headers=headers, + ) + + response = self.send(request, **kwargs) + return response + + def get_access_cert_settings( + self, + zone_id: str, + **kwargs, + ) -> DetailedResponse: + """ + Get access certificates settings. + + Get access certificates settings. + + :param str zone_id: Zone ID. + :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 `AccessCertSettingsResp` object + """ + + if not zone_id: + raise ValueError('zone_id must be provided') + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='get_access_cert_settings', + ) + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'zone_id'] + path_param_values = self.encode_path_vars(self.crn, zone_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/zones/{zone_id}/access/certificates/settings'.format(**path_param_dict) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + ) + + response = self.send(request, **kwargs) + return response + + def update_access_cert_settings( + self, + zone_id: str, + *, + settings: Optional[List['AccessCertSettingsInputArray']] = None, + **kwargs, + ) -> DetailedResponse: + """ + Update access certificates settings. + + Update access certificates settings. + + :param str zone_id: Zone ID. + :param List[AccessCertSettingsInputArray] settings: (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 `AccessCertSettingsResp` object + """ + + if not zone_id: + raise ValueError('zone_id must be provided') + if settings is not None: + settings = [convert_model(x) for x in settings] + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='update_access_cert_settings', + ) + headers.update(sdk_headers) + + data = { + 'settings': settings, + } + data = {k: v for (k, v) in data.items() if v is not None} + data = json.dumps(data) + headers['content-type'] = 'application/json' + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'zone_id'] + path_param_values = self.encode_path_vars(self.crn, zone_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/zones/{zone_id}/access/certificates/settings'.format(**path_param_dict) + request = self.prepare_request( + method='PUT', + url=url, + headers=headers, + data=data, + ) + + response = self.send(request, **kwargs) + return response + + def create_access_organization( + self, + *, + name: Optional[str] = None, + auth_domain: Optional[str] = None, + **kwargs, + ) -> DetailedResponse: + """ + Create access organization. + + Create access organization. + + :param str name: (optional) Name of the access organization. + :param str auth_domain: (optional) The domain that you are redirected to on + Access login attempts. + :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 `AccessOrgResp` object + """ + + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='create_access_organization', + ) + headers.update(sdk_headers) + + data = { + 'name': name, + 'auth_domain': auth_domain, + } + 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}/access/organizations'.format(**path_param_dict) + request = self.prepare_request( + method='POST', + url=url, + headers=headers, + data=data, + ) + + response = self.send(request, **kwargs) + return response + + +############################################################################## +# Models +############################################################################## + + +class AccessOrgRespResult: + """ + AccessOrgRespResult. + + :param str auth_domain: (optional) + :param str name: (optional) + :param dict login_design: (optional) + :param str created_at: (optional) + :param str updated_at: (optional) + """ + + def __init__( + self, + *, + auth_domain: Optional[str] = None, + name: Optional[str] = None, + login_design: Optional[dict] = None, + created_at: Optional[str] = None, + updated_at: Optional[str] = None, + ) -> None: + """ + Initialize a AccessOrgRespResult object. + + :param str auth_domain: (optional) + :param str name: (optional) + :param dict login_design: (optional) + :param str created_at: (optional) + :param str updated_at: (optional) + """ + self.auth_domain = auth_domain + self.name = name + self.login_design = login_design + self.created_at = created_at + self.updated_at = updated_at + + @classmethod + def from_dict(cls, _dict: Dict) -> 'AccessOrgRespResult': + """Initialize a AccessOrgRespResult object from a json dictionary.""" + args = {} + if (auth_domain := _dict.get('auth_domain')) is not None: + args['auth_domain'] = auth_domain + if (name := _dict.get('name')) is not None: + args['name'] = name + if (login_design := _dict.get('login_design')) is not None: + args['login_design'] = login_design + if (created_at := _dict.get('created_at')) is not None: + args['created_at'] = created_at + if (updated_at := _dict.get('updated_at')) is not None: + args['updated_at'] = updated_at + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a AccessOrgRespResult 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, 'auth_domain') and self.auth_domain is not None: + _dict['auth_domain'] = self.auth_domain + if hasattr(self, 'name') and self.name is not None: + _dict['name'] = self.name + if hasattr(self, 'login_design') and self.login_design is not None: + _dict['login_design'] = self.login_design + if hasattr(self, 'created_at') and self.created_at is not None: + _dict['created_at'] = self.created_at + if hasattr(self, 'updated_at') and self.updated_at is not None: + _dict['updated_at'] = self.updated_at + 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 AccessOrgRespResult object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'AccessOrgRespResult') -> 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: 'AccessOrgRespResult') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class CreateAccessAppRespResult: + """ + Access application details. + + :param str id: (optional) + :param str name: (optional) + :param str domain: (optional) + :param str aud: (optional) + :param List[dict] policies: (optional) + :param List[str] allowed_idps: (optional) + :param bool auto_redirect_to_identity: (optional) + :param str session_duration: (optional) + :param str type: (optional) + :param str uid: (optional) + :param str created_at: (optional) + :param str updated_at: (optional) + """ + + def __init__( + self, + *, + id: Optional[str] = None, + name: Optional[str] = None, + domain: Optional[str] = None, + aud: Optional[str] = None, + policies: Optional[List[dict]] = None, + allowed_idps: Optional[List[str]] = None, + auto_redirect_to_identity: Optional[bool] = None, + session_duration: Optional[str] = None, + type: Optional[str] = None, + uid: Optional[str] = None, + created_at: Optional[str] = None, + updated_at: Optional[str] = None, + ) -> None: + """ + Initialize a CreateAccessAppRespResult object. + + :param str id: (optional) + :param str name: (optional) + :param str domain: (optional) + :param str aud: (optional) + :param List[dict] policies: (optional) + :param List[str] allowed_idps: (optional) + :param bool auto_redirect_to_identity: (optional) + :param str session_duration: (optional) + :param str type: (optional) + :param str uid: (optional) + :param str created_at: (optional) + :param str updated_at: (optional) + """ + self.id = id + self.name = name + self.domain = domain + self.aud = aud + self.policies = policies + self.allowed_idps = allowed_idps + self.auto_redirect_to_identity = auto_redirect_to_identity + self.session_duration = session_duration + self.type = type + self.uid = uid + self.created_at = created_at + self.updated_at = updated_at + + @classmethod + def from_dict(cls, _dict: Dict) -> 'CreateAccessAppRespResult': + """Initialize a CreateAccessAppRespResult object from a json dictionary.""" + args = {} + if (id := _dict.get('id')) is not None: + args['id'] = id + if (name := _dict.get('name')) is not None: + args['name'] = name + if (domain := _dict.get('domain')) is not None: + args['domain'] = domain + if (aud := _dict.get('aud')) is not None: + args['aud'] = aud + if (policies := _dict.get('policies')) is not None: + args['policies'] = policies + if (allowed_idps := _dict.get('allowed_idps')) is not None: + args['allowed_idps'] = allowed_idps + if (auto_redirect_to_identity := _dict.get('auto_redirect_to_identity')) is not None: + args['auto_redirect_to_identity'] = auto_redirect_to_identity + if (session_duration := _dict.get('session_duration')) is not None: + args['session_duration'] = session_duration + if (type := _dict.get('type')) is not None: + args['type'] = type + if (uid := _dict.get('uid')) is not None: + args['uid'] = uid + if (created_at := _dict.get('created_at')) is not None: + args['created_at'] = created_at + if (updated_at := _dict.get('updated_at')) is not None: + args['updated_at'] = updated_at + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a CreateAccessAppRespResult 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, 'name') and self.name is not None: + _dict['name'] = self.name + if hasattr(self, 'domain') and self.domain is not None: + _dict['domain'] = self.domain + if hasattr(self, 'aud') and self.aud is not None: + _dict['aud'] = self.aud + if hasattr(self, 'policies') and self.policies is not None: + _dict['policies'] = self.policies + if hasattr(self, 'allowed_idps') and self.allowed_idps is not None: + _dict['allowed_idps'] = self.allowed_idps + if hasattr(self, 'auto_redirect_to_identity') and self.auto_redirect_to_identity is not None: + _dict['auto_redirect_to_identity'] = self.auto_redirect_to_identity + if hasattr(self, 'session_duration') and self.session_duration is not None: + _dict['session_duration'] = self.session_duration + if hasattr(self, 'type') and self.type is not None: + _dict['type'] = self.type + if hasattr(self, 'uid') and self.uid is not None: + _dict['uid'] = self.uid + if hasattr(self, 'created_at') and self.created_at is not None: + _dict['created_at'] = self.created_at + if hasattr(self, 'updated_at') and self.updated_at is not None: + _dict['updated_at'] = self.updated_at + 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 CreateAccessAppRespResult object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'CreateAccessAppRespResult') -> 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: 'CreateAccessAppRespResult') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class DeleteAccessAppRespResult: + """ + DeleteAccessAppRespResult. + + :param str id: (optional) Application ID. + """ + + def __init__( + self, + *, + id: Optional[str] = None, + ) -> None: + """ + Initialize a DeleteAccessAppRespResult object. + + :param str id: (optional) Application ID. + """ + self.id = id + + @classmethod + def from_dict(cls, _dict: Dict) -> 'DeleteAccessAppRespResult': + """Initialize a DeleteAccessAppRespResult 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 DeleteAccessAppRespResult 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 DeleteAccessAppRespResult object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'DeleteAccessAppRespResult') -> 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: 'DeleteAccessAppRespResult') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class DeleteAccessCertRespResult: + """ + DeleteAccessCertRespResult. + + :param str id: (optional) Certificate ID. + """ + + def __init__( + self, + *, + id: Optional[str] = None, + ) -> None: + """ + Initialize a DeleteAccessCertRespResult object. + + :param str id: (optional) Certificate ID. + """ + self.id = id + + @classmethod + def from_dict(cls, _dict: Dict) -> 'DeleteAccessCertRespResult': + """Initialize a DeleteAccessCertRespResult 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 DeleteAccessCertRespResult 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 DeleteAccessCertRespResult object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'DeleteAccessCertRespResult') -> 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: 'DeleteAccessCertRespResult') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class DeleteAccessPolicyRespResult: + """ + DeleteAccessPolicyRespResult. + + :param str id: (optional) Policy ID. + """ + + def __init__( + self, + *, + id: Optional[str] = None, + ) -> None: + """ + Initialize a DeleteAccessPolicyRespResult object. + + :param str id: (optional) Policy ID. + """ + self.id = id + + @classmethod + def from_dict(cls, _dict: Dict) -> 'DeleteAccessPolicyRespResult': + """Initialize a DeleteAccessPolicyRespResult 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 DeleteAccessPolicyRespResult 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 DeleteAccessPolicyRespResult object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'DeleteAccessPolicyRespResult') -> 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: 'DeleteAccessPolicyRespResult') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class PolicyCnRuleCommonName: + """ + PolicyCnRuleCommonName. + + :param str common_name: Common name of client certificate. + """ + + def __init__( + self, + common_name: str, + ) -> None: + """ + Initialize a PolicyCnRuleCommonName object. + + :param str common_name: Common name of client certificate. + """ + self.common_name = common_name + + @classmethod + def from_dict(cls, _dict: Dict) -> 'PolicyCnRuleCommonName': + """Initialize a PolicyCnRuleCommonName object from a json dictionary.""" + args = {} + if (common_name := _dict.get('common_name')) is not None: + args['common_name'] = common_name + else: + raise ValueError('Required property \'common_name\' not present in PolicyCnRuleCommonName JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a PolicyCnRuleCommonName 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, 'common_name') and self.common_name is not None: + _dict['common_name'] = self.common_name + 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 PolicyCnRuleCommonName object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'PolicyCnRuleCommonName') -> 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: 'PolicyCnRuleCommonName') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class AccessAppResp: + """ + Access application response. + + :param bool success: (optional) Was operation successful. + :param List[List[str]] errors: (optional) Array of errors encountered. + :param List[List[str]] messages: (optional) Array of messages returned. + :param AppResult result: (optional) Access application details. + """ + + def __init__( + self, + *, + success: Optional[bool] = None, + errors: Optional[List[List[str]]] = None, + messages: Optional[List[List[str]]] = None, + result: Optional['AppResult'] = None, + ) -> None: + """ + Initialize a AccessAppResp object. + + :param bool success: (optional) Was operation successful. + :param List[List[str]] errors: (optional) Array of errors encountered. + :param List[List[str]] messages: (optional) Array of messages returned. + :param AppResult result: (optional) Access application details. + """ + self.success = success + self.errors = errors + self.messages = messages + self.result = result + + @classmethod + def from_dict(cls, _dict: Dict) -> 'AccessAppResp': + """Initialize a AccessAppResp object from a json dictionary.""" + args = {} + if (success := _dict.get('success')) is not None: + args['success'] = success + if (errors := _dict.get('errors')) is not None: + args['errors'] = errors + if (messages := _dict.get('messages')) is not None: + args['messages'] = messages + if (result := _dict.get('result')) is not None: + args['result'] = AppResult.from_dict(result) + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a AccessAppResp 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 AccessAppResp object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'AccessAppResp') -> 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: 'AccessAppResp') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class AccessCertResp: + """ + Access certificate response. + + :param bool success: (optional) Was operation successful. + :param List[List[str]] errors: (optional) Array of errors encountered. + :param List[List[str]] messages: (optional) Array of messages returned. + :param CertResult result: (optional) Access certificate details. + """ + + def __init__( + self, + *, + success: Optional[bool] = None, + errors: Optional[List[List[str]]] = None, + messages: Optional[List[List[str]]] = None, + result: Optional['CertResult'] = None, + ) -> None: + """ + Initialize a AccessCertResp object. + + :param bool success: (optional) Was operation successful. + :param List[List[str]] errors: (optional) Array of errors encountered. + :param List[List[str]] messages: (optional) Array of messages returned. + :param CertResult result: (optional) Access certificate details. + """ + self.success = success + self.errors = errors + self.messages = messages + self.result = result + + @classmethod + def from_dict(cls, _dict: Dict) -> 'AccessCertResp': + """Initialize a AccessCertResp object from a json dictionary.""" + args = {} + if (success := _dict.get('success')) is not None: + args['success'] = success + if (errors := _dict.get('errors')) is not None: + args['errors'] = errors + if (messages := _dict.get('messages')) is not None: + args['messages'] = messages + if (result := _dict.get('result')) is not None: + args['result'] = CertResult.from_dict(result) + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a AccessCertResp 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 AccessCertResp object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'AccessCertResp') -> 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: 'AccessCertResp') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class AccessCertSettingsInputArray: + """ + AccessCertSettingsInputArray. + + :param str hostname: + :param bool client_certificate_forwarding: Whether to forward the client + certificate. + """ + + def __init__( + self, + hostname: str, + client_certificate_forwarding: bool, + ) -> None: + """ + Initialize a AccessCertSettingsInputArray object. + + :param str hostname: + :param bool client_certificate_forwarding: Whether to forward the client + certificate. + """ + self.hostname = hostname + self.client_certificate_forwarding = client_certificate_forwarding + + @classmethod + def from_dict(cls, _dict: Dict) -> 'AccessCertSettingsInputArray': + """Initialize a AccessCertSettingsInputArray object from a json dictionary.""" + args = {} + if (hostname := _dict.get('hostname')) is not None: + args['hostname'] = hostname + else: + raise ValueError('Required property \'hostname\' not present in AccessCertSettingsInputArray JSON') + if (client_certificate_forwarding := _dict.get('client_certificate_forwarding')) is not None: + args['client_certificate_forwarding'] = client_certificate_forwarding + else: + raise ValueError('Required property \'client_certificate_forwarding\' not present in AccessCertSettingsInputArray JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a AccessCertSettingsInputArray 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, 'hostname') and self.hostname is not None: + _dict['hostname'] = self.hostname + if hasattr(self, 'client_certificate_forwarding') and self.client_certificate_forwarding is not None: + _dict['client_certificate_forwarding'] = self.client_certificate_forwarding + 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 AccessCertSettingsInputArray object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'AccessCertSettingsInputArray') -> 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: 'AccessCertSettingsInputArray') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class AccessCertSettingsResp: + """ + Access certificates settings response. + + :param bool success: (optional) Was operation successful. + :param List[List[str]] errors: (optional) Array of errors encountered. + :param List[List[str]] messages: (optional) Array of messages returned. + :param List[CertSettingsResult] result: (optional) + """ + + def __init__( + self, + *, + success: Optional[bool] = None, + errors: Optional[List[List[str]]] = None, + messages: Optional[List[List[str]]] = None, + result: Optional[List['CertSettingsResult']] = None, + ) -> None: + """ + Initialize a AccessCertSettingsResp object. + + :param bool success: (optional) Was operation successful. + :param List[List[str]] errors: (optional) Array of errors encountered. + :param List[List[str]] messages: (optional) Array of messages returned. + :param List[CertSettingsResult] result: (optional) + """ + self.success = success + self.errors = errors + self.messages = messages + self.result = result + + @classmethod + def from_dict(cls, _dict: Dict) -> 'AccessCertSettingsResp': + """Initialize a AccessCertSettingsResp object from a json dictionary.""" + args = {} + if (success := _dict.get('success')) is not None: + args['success'] = success + if (errors := _dict.get('errors')) is not None: + args['errors'] = errors + if (messages := _dict.get('messages')) is not None: + args['messages'] = messages + if (result := _dict.get('result')) is not None: + args['result'] = [CertSettingsResult.from_dict(v) for v in result] + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a AccessCertSettingsResp 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 AccessCertSettingsResp object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'AccessCertSettingsResp') -> 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: 'AccessCertSettingsResp') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class AccessOrgResp: + """ + Access organization response. + + :param bool success: (optional) Was operation successful. + :param List[List[str]] errors: (optional) Array of errors encountered. + :param List[List[str]] messages: (optional) Array of messages returned. + :param AccessOrgRespResult result: (optional) + """ + + def __init__( + self, + *, + success: Optional[bool] = None, + errors: Optional[List[List[str]]] = None, + messages: Optional[List[List[str]]] = None, + result: Optional['AccessOrgRespResult'] = None, + ) -> None: + """ + Initialize a AccessOrgResp object. + + :param bool success: (optional) Was operation successful. + :param List[List[str]] errors: (optional) Array of errors encountered. + :param List[List[str]] messages: (optional) Array of messages returned. + :param AccessOrgRespResult result: (optional) + """ + self.success = success + self.errors = errors + self.messages = messages + self.result = result + + @classmethod + def from_dict(cls, _dict: Dict) -> 'AccessOrgResp': + """Initialize a AccessOrgResp object from a json dictionary.""" + args = {} + if (success := _dict.get('success')) is not None: + args['success'] = success + if (errors := _dict.get('errors')) is not None: + args['errors'] = errors + if (messages := _dict.get('messages')) is not None: + args['messages'] = messages + if (result := _dict.get('result')) is not None: + args['result'] = AccessOrgRespResult.from_dict(result) + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a AccessOrgResp 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 AccessOrgResp object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'AccessOrgResp') -> 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: 'AccessOrgResp') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class AccessPolicyResp: + """ + Access policy response. + + :param bool success: (optional) Was operation successful. + :param List[List[str]] errors: (optional) Array of errors encountered. + :param List[List[str]] messages: (optional) Array of messages returned. + :param PolicyResult result: (optional) Access policies information. + """ + + def __init__( + self, + *, + success: Optional[bool] = None, + errors: Optional[List[List[str]]] = None, + messages: Optional[List[List[str]]] = None, + result: Optional['PolicyResult'] = None, + ) -> None: + """ + Initialize a AccessPolicyResp object. + + :param bool success: (optional) Was operation successful. + :param List[List[str]] errors: (optional) Array of errors encountered. + :param List[List[str]] messages: (optional) Array of messages returned. + :param PolicyResult result: (optional) Access policies information. + """ + self.success = success + self.errors = errors + self.messages = messages + self.result = result + + @classmethod + def from_dict(cls, _dict: Dict) -> 'AccessPolicyResp': + """Initialize a AccessPolicyResp object from a json dictionary.""" + args = {} + if (success := _dict.get('success')) is not None: + args['success'] = success + if (errors := _dict.get('errors')) is not None: + args['errors'] = errors + if (messages := _dict.get('messages')) is not None: + args['messages'] = messages + if (result := _dict.get('result')) is not None: + args['result'] = PolicyResult.from_dict(result) + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a AccessPolicyResp 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 AccessPolicyResp object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'AccessPolicyResp') -> 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: 'AccessPolicyResp') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class AppResult: + """ + Access application details. + + :param str id: (optional) Application ID. + :param str name: (optional) Application name. + :param str domain: (optional) The domain and path that Access blocks. + :param str aud: (optional) + :param List[PolicyResult] policies: (optional) Policies of the application. + :param List[str] allowed_idps: (optional) The identity providers selected for + application. + :param bool auto_redirect_to_identity: (optional) Option to skip identity + provider selection if only one is configured in allowed_idps. + :param str session_duration: (optional) The amount of time that the tokens + issued for this application are valid. + :param str type: (optional) Application type. + :param str uid: (optional) UUID, same as ID. + :param str created_at: (optional) Created time of the application. + :param str updated_at: (optional) Updated time of the application. + """ + + def __init__( + self, + *, + id: Optional[str] = None, + name: Optional[str] = None, + domain: Optional[str] = None, + aud: Optional[str] = None, + policies: Optional[List['PolicyResult']] = None, + allowed_idps: Optional[List[str]] = None, + auto_redirect_to_identity: Optional[bool] = None, + session_duration: Optional[str] = None, + type: Optional[str] = None, + uid: Optional[str] = None, + created_at: Optional[str] = None, + updated_at: Optional[str] = None, + ) -> None: + """ + Initialize a AppResult object. + + :param str id: (optional) Application ID. + :param str name: (optional) Application name. + :param str domain: (optional) The domain and path that Access blocks. + :param str aud: (optional) + :param List[PolicyResult] policies: (optional) Policies of the application. + :param List[str] allowed_idps: (optional) The identity providers selected + for application. + :param bool auto_redirect_to_identity: (optional) Option to skip identity + provider selection if only one is configured in allowed_idps. + :param str session_duration: (optional) The amount of time that the tokens + issued for this application are valid. + :param str type: (optional) Application type. + :param str uid: (optional) UUID, same as ID. + :param str created_at: (optional) Created time of the application. + :param str updated_at: (optional) Updated time of the application. + """ + self.id = id + self.name = name + self.domain = domain + self.aud = aud + self.policies = policies + self.allowed_idps = allowed_idps + self.auto_redirect_to_identity = auto_redirect_to_identity + self.session_duration = session_duration + self.type = type + self.uid = uid + self.created_at = created_at + self.updated_at = updated_at + + @classmethod + def from_dict(cls, _dict: Dict) -> 'AppResult': + """Initialize a AppResult object from a json dictionary.""" + args = {} + if (id := _dict.get('id')) is not None: + args['id'] = id + if (name := _dict.get('name')) is not None: + args['name'] = name + if (domain := _dict.get('domain')) is not None: + args['domain'] = domain + if (aud := _dict.get('aud')) is not None: + args['aud'] = aud + if (policies := _dict.get('policies')) is not None: + args['policies'] = [PolicyResult.from_dict(v) for v in policies] + if (allowed_idps := _dict.get('allowed_idps')) is not None: + args['allowed_idps'] = allowed_idps + if (auto_redirect_to_identity := _dict.get('auto_redirect_to_identity')) is not None: + args['auto_redirect_to_identity'] = auto_redirect_to_identity + if (session_duration := _dict.get('session_duration')) is not None: + args['session_duration'] = session_duration + if (type := _dict.get('type')) is not None: + args['type'] = type + if (uid := _dict.get('uid')) is not None: + args['uid'] = uid + if (created_at := _dict.get('created_at')) is not None: + args['created_at'] = created_at + if (updated_at := _dict.get('updated_at')) is not None: + args['updated_at'] = updated_at + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a AppResult 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, 'name') and self.name is not None: + _dict['name'] = self.name + if hasattr(self, 'domain') and self.domain is not None: + _dict['domain'] = self.domain + if hasattr(self, 'aud') and self.aud is not None: + _dict['aud'] = self.aud + if hasattr(self, 'policies') and self.policies is not None: + policies_list = [] + for v in self.policies: + if isinstance(v, dict): + policies_list.append(v) + else: + policies_list.append(v.to_dict()) + _dict['policies'] = policies_list + if hasattr(self, 'allowed_idps') and self.allowed_idps is not None: + _dict['allowed_idps'] = self.allowed_idps + if hasattr(self, 'auto_redirect_to_identity') and self.auto_redirect_to_identity is not None: + _dict['auto_redirect_to_identity'] = self.auto_redirect_to_identity + if hasattr(self, 'session_duration') and self.session_duration is not None: + _dict['session_duration'] = self.session_duration + if hasattr(self, 'type') and self.type is not None: + _dict['type'] = self.type + if hasattr(self, 'uid') and self.uid is not None: + _dict['uid'] = self.uid + if hasattr(self, 'created_at') and self.created_at is not None: + _dict['created_at'] = self.created_at + if hasattr(self, 'updated_at') and self.updated_at is not None: + _dict['updated_at'] = self.updated_at + 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 AppResult object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'AppResult') -> 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: 'AppResult') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class CertResult: + """ + Access certificate details. + + :param str id: (optional) Access certificate ID. + :param str name: (optional) access certificate name. + :param str fingerprint: (optional) Fingerprint of the certificate. + :param List[str] associated_hostnames: (optional) The hostnames that are + prompted for this certificate. + :param str created_at: (optional) Created time of the access certificate. + :param str updated_at: (optional) Updated time of the access certificate. + :param str expires_on: (optional) Expire time of the access certificate. + """ + + def __init__( + self, + *, + id: Optional[str] = None, + name: Optional[str] = None, + fingerprint: Optional[str] = None, + associated_hostnames: Optional[List[str]] = None, + created_at: Optional[str] = None, + updated_at: Optional[str] = None, + expires_on: Optional[str] = None, + ) -> None: + """ + Initialize a CertResult object. + + :param str id: (optional) Access certificate ID. + :param str name: (optional) access certificate name. + :param str fingerprint: (optional) Fingerprint of the certificate. + :param List[str] associated_hostnames: (optional) The hostnames that are + prompted for this certificate. + :param str created_at: (optional) Created time of the access certificate. + :param str updated_at: (optional) Updated time of the access certificate. + :param str expires_on: (optional) Expire time of the access certificate. + """ + self.id = id + self.name = name + self.fingerprint = fingerprint + self.associated_hostnames = associated_hostnames + self.created_at = created_at + self.updated_at = updated_at + self.expires_on = expires_on + + @classmethod + def from_dict(cls, _dict: Dict) -> 'CertResult': + """Initialize a CertResult object from a json dictionary.""" + args = {} + if (id := _dict.get('id')) is not None: + args['id'] = id + if (name := _dict.get('name')) is not None: + args['name'] = name + if (fingerprint := _dict.get('fingerprint')) is not None: + args['fingerprint'] = fingerprint + if (associated_hostnames := _dict.get('associated_hostnames')) is not None: + args['associated_hostnames'] = associated_hostnames + if (created_at := _dict.get('created_at')) is not None: + args['created_at'] = created_at + if (updated_at := _dict.get('updated_at')) is not None: + args['updated_at'] = updated_at + if (expires_on := _dict.get('expires_on')) is not None: + args['expires_on'] = expires_on + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a CertResult 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, 'name') and self.name is not None: + _dict['name'] = self.name + if hasattr(self, 'fingerprint') and self.fingerprint is not None: + _dict['fingerprint'] = self.fingerprint + if hasattr(self, 'associated_hostnames') and self.associated_hostnames is not None: + _dict['associated_hostnames'] = self.associated_hostnames + if hasattr(self, 'created_at') and self.created_at is not None: + _dict['created_at'] = self.created_at + if hasattr(self, 'updated_at') and self.updated_at is not None: + _dict['updated_at'] = self.updated_at + if hasattr(self, 'expires_on') and self.expires_on is not None: + _dict['expires_on'] = self.expires_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 CertResult object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'CertResult') -> 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: 'CertResult') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class CertSettingsResult: + """ + CertSettingsResult. + + :param str hostname: (optional) + :param bool china_network: (optional) + :param bool client_certificate_forwarding: (optional) + """ + + def __init__( + self, + *, + hostname: Optional[str] = None, + china_network: Optional[bool] = None, + client_certificate_forwarding: Optional[bool] = None, + ) -> None: + """ + Initialize a CertSettingsResult object. + + :param str hostname: (optional) + :param bool china_network: (optional) + :param bool client_certificate_forwarding: (optional) + """ + self.hostname = hostname + self.china_network = china_network + self.client_certificate_forwarding = client_certificate_forwarding + + @classmethod + def from_dict(cls, _dict: Dict) -> 'CertSettingsResult': + """Initialize a CertSettingsResult object from a json dictionary.""" + args = {} + if (hostname := _dict.get('hostname')) is not None: + args['hostname'] = hostname + if (china_network := _dict.get('china_network')) is not None: + args['china_network'] = china_network + if (client_certificate_forwarding := _dict.get('client_certificate_forwarding')) is not None: + args['client_certificate_forwarding'] = client_certificate_forwarding + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a CertSettingsResult 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, 'hostname') and self.hostname is not None: + _dict['hostname'] = self.hostname + if hasattr(self, 'china_network') and self.china_network is not None: + _dict['china_network'] = self.china_network + if hasattr(self, 'client_certificate_forwarding') and self.client_certificate_forwarding is not None: + _dict['client_certificate_forwarding'] = self.client_certificate_forwarding + 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 CertSettingsResult object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'CertSettingsResult') -> 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: 'CertSettingsResult') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class CreateAccessAppResp: + """ + Create access application response. + + :param bool success: (optional) Was operation successful. + :param List[List[str]] errors: (optional) Array of errors encountered. + :param List[List[str]] messages: (optional) Array of messages returned. + :param CreateAccessAppRespResult result: (optional) Access application details. + """ + + def __init__( + self, + *, + success: Optional[bool] = None, + errors: Optional[List[List[str]]] = None, + messages: Optional[List[List[str]]] = None, + result: Optional['CreateAccessAppRespResult'] = None, + ) -> None: + """ + Initialize a CreateAccessAppResp object. + + :param bool success: (optional) Was operation successful. + :param List[List[str]] errors: (optional) Array of errors encountered. + :param List[List[str]] messages: (optional) Array of messages returned. + :param CreateAccessAppRespResult result: (optional) Access application + details. + """ + self.success = success + self.errors = errors + self.messages = messages + self.result = result + + @classmethod + def from_dict(cls, _dict: Dict) -> 'CreateAccessAppResp': + """Initialize a CreateAccessAppResp object from a json dictionary.""" + args = {} + if (success := _dict.get('success')) is not None: + args['success'] = success + if (errors := _dict.get('errors')) is not None: + args['errors'] = errors + if (messages := _dict.get('messages')) is not None: + args['messages'] = messages + if (result := _dict.get('result')) is not None: + args['result'] = CreateAccessAppRespResult.from_dict(result) + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a CreateAccessAppResp 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 CreateAccessAppResp object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'CreateAccessAppResp') -> 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: 'CreateAccessAppResp') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class DeleteAccessAppResp: + """ + Delete access application response. + + :param bool success: (optional) Was operation successful. + :param List[List[str]] errors: (optional) Array of errors encountered. + :param List[List[str]] messages: (optional) Array of messages returned. + :param DeleteAccessAppRespResult result: (optional) + """ + + def __init__( + self, + *, + success: Optional[bool] = None, + errors: Optional[List[List[str]]] = None, + messages: Optional[List[List[str]]] = None, + result: Optional['DeleteAccessAppRespResult'] = None, + ) -> None: + """ + Initialize a DeleteAccessAppResp object. + + :param bool success: (optional) Was operation successful. + :param List[List[str]] errors: (optional) Array of errors encountered. + :param List[List[str]] messages: (optional) Array of messages returned. + :param DeleteAccessAppRespResult result: (optional) + """ + self.success = success + self.errors = errors + self.messages = messages + self.result = result + + @classmethod + def from_dict(cls, _dict: Dict) -> 'DeleteAccessAppResp': + """Initialize a DeleteAccessAppResp object from a json dictionary.""" + args = {} + if (success := _dict.get('success')) is not None: + args['success'] = success + if (errors := _dict.get('errors')) is not None: + args['errors'] = errors + if (messages := _dict.get('messages')) is not None: + args['messages'] = messages + if (result := _dict.get('result')) is not None: + args['result'] = DeleteAccessAppRespResult.from_dict(result) + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a DeleteAccessAppResp 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 DeleteAccessAppResp object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'DeleteAccessAppResp') -> 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: 'DeleteAccessAppResp') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class DeleteAccessCertResp: + """ + Delete access certificate response. + + :param bool success: (optional) Was operation successful. + :param List[List[str]] errors: (optional) Array of errors encountered. + :param List[List[str]] messages: (optional) Array of messages returned. + :param DeleteAccessCertRespResult result: (optional) + """ + + def __init__( + self, + *, + success: Optional[bool] = None, + errors: Optional[List[List[str]]] = None, + messages: Optional[List[List[str]]] = None, + result: Optional['DeleteAccessCertRespResult'] = None, + ) -> None: + """ + Initialize a DeleteAccessCertResp object. + + :param bool success: (optional) Was operation successful. + :param List[List[str]] errors: (optional) Array of errors encountered. + :param List[List[str]] messages: (optional) Array of messages returned. + :param DeleteAccessCertRespResult result: (optional) + """ + self.success = success + self.errors = errors + self.messages = messages + self.result = result + + @classmethod + def from_dict(cls, _dict: Dict) -> 'DeleteAccessCertResp': + """Initialize a DeleteAccessCertResp object from a json dictionary.""" + args = {} + if (success := _dict.get('success')) is not None: + args['success'] = success + if (errors := _dict.get('errors')) is not None: + args['errors'] = errors + if (messages := _dict.get('messages')) is not None: + args['messages'] = messages + if (result := _dict.get('result')) is not None: + args['result'] = DeleteAccessCertRespResult.from_dict(result) + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a DeleteAccessCertResp 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 DeleteAccessCertResp object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'DeleteAccessCertResp') -> 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: 'DeleteAccessCertResp') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class DeleteAccessPolicyResp: + """ + Delete access policy response. + + :param bool success: (optional) Was operation successful. + :param List[List[str]] errors: (optional) Array of errors encountered. + :param List[List[str]] messages: (optional) Array of messages returned. + :param DeleteAccessPolicyRespResult result: (optional) + """ + + def __init__( + self, + *, + success: Optional[bool] = None, + errors: Optional[List[List[str]]] = None, + messages: Optional[List[List[str]]] = None, + result: Optional['DeleteAccessPolicyRespResult'] = None, + ) -> None: + """ + Initialize a DeleteAccessPolicyResp object. + + :param bool success: (optional) Was operation successful. + :param List[List[str]] errors: (optional) Array of errors encountered. + :param List[List[str]] messages: (optional) Array of messages returned. + :param DeleteAccessPolicyRespResult result: (optional) + """ + self.success = success + self.errors = errors + self.messages = messages + self.result = result + + @classmethod + def from_dict(cls, _dict: Dict) -> 'DeleteAccessPolicyResp': + """Initialize a DeleteAccessPolicyResp object from a json dictionary.""" + args = {} + if (success := _dict.get('success')) is not None: + args['success'] = success + if (errors := _dict.get('errors')) is not None: + args['errors'] = errors + if (messages := _dict.get('messages')) is not None: + args['messages'] = messages + if (result := _dict.get('result')) is not None: + args['result'] = DeleteAccessPolicyRespResult.from_dict(result) + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a DeleteAccessPolicyResp 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 DeleteAccessPolicyResp object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'DeleteAccessPolicyResp') -> 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: 'DeleteAccessPolicyResp') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class ListAccessAppsResp: + """ + List access applications response. + + :param bool success: (optional) Was operation successful. + :param List[List[str]] errors: (optional) Array of errors encountered. + :param List[List[str]] messages: (optional) Array of messages returned. + :param List[AppResult] result: (optional) + """ + + def __init__( + self, + *, + success: Optional[bool] = None, + errors: Optional[List[List[str]]] = None, + messages: Optional[List[List[str]]] = None, + result: Optional[List['AppResult']] = None, + ) -> None: + """ + Initialize a ListAccessAppsResp object. + + :param bool success: (optional) Was operation successful. + :param List[List[str]] errors: (optional) Array of errors encountered. + :param List[List[str]] messages: (optional) Array of messages returned. + :param List[AppResult] result: (optional) + """ + self.success = success + self.errors = errors + self.messages = messages + self.result = result + + @classmethod + def from_dict(cls, _dict: Dict) -> 'ListAccessAppsResp': + """Initialize a ListAccessAppsResp object from a json dictionary.""" + args = {} + if (success := _dict.get('success')) is not None: + args['success'] = success + if (errors := _dict.get('errors')) is not None: + args['errors'] = errors + if (messages := _dict.get('messages')) is not None: + args['messages'] = messages + if (result := _dict.get('result')) is not None: + args['result'] = [AppResult.from_dict(v) for v in result] + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a ListAccessAppsResp 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 ListAccessAppsResp object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'ListAccessAppsResp') -> 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: 'ListAccessAppsResp') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class ListAccessCertsResp: + """ + List access certificate response. + + :param bool success: (optional) Was operation successful. + :param List[List[str]] errors: (optional) Array of errors encountered. + :param List[List[str]] messages: (optional) Array of messages returned. + :param List[CertResult] result: (optional) + """ + + def __init__( + self, + *, + success: Optional[bool] = None, + errors: Optional[List[List[str]]] = None, + messages: Optional[List[List[str]]] = None, + result: Optional[List['CertResult']] = None, + ) -> None: + """ + Initialize a ListAccessCertsResp object. + + :param bool success: (optional) Was operation successful. + :param List[List[str]] errors: (optional) Array of errors encountered. + :param List[List[str]] messages: (optional) Array of messages returned. + :param List[CertResult] result: (optional) + """ + self.success = success + self.errors = errors + self.messages = messages + self.result = result + + @classmethod + def from_dict(cls, _dict: Dict) -> 'ListAccessCertsResp': + """Initialize a ListAccessCertsResp object from a json dictionary.""" + args = {} + if (success := _dict.get('success')) is not None: + args['success'] = success + if (errors := _dict.get('errors')) is not None: + args['errors'] = errors + if (messages := _dict.get('messages')) is not None: + args['messages'] = messages + if (result := _dict.get('result')) is not None: + args['result'] = [CertResult.from_dict(v) for v in result] + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a ListAccessCertsResp 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 ListAccessCertsResp object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'ListAccessCertsResp') -> 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: 'ListAccessCertsResp') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class ListAccessPoliciesResp: + """ + List access policies response. + + :param bool success: (optional) Was operation successful. + :param List[List[str]] errors: (optional) Array of errors encountered. + :param List[List[str]] messages: (optional) Array of messages returned. + :param List[PolicyResult] result: (optional) + """ + + def __init__( + self, + *, + success: Optional[bool] = None, + errors: Optional[List[List[str]]] = None, + messages: Optional[List[List[str]]] = None, + result: Optional[List['PolicyResult']] = None, + ) -> None: + """ + Initialize a ListAccessPoliciesResp object. + + :param bool success: (optional) Was operation successful. + :param List[List[str]] errors: (optional) Array of errors encountered. + :param List[List[str]] messages: (optional) Array of messages returned. + :param List[PolicyResult] result: (optional) + """ + self.success = success + self.errors = errors + self.messages = messages + self.result = result + + @classmethod + def from_dict(cls, _dict: Dict) -> 'ListAccessPoliciesResp': + """Initialize a ListAccessPoliciesResp object from a json dictionary.""" + args = {} + if (success := _dict.get('success')) is not None: + args['success'] = success + if (errors := _dict.get('errors')) is not None: + args['errors'] = errors + if (messages := _dict.get('messages')) is not None: + args['messages'] = messages + if (result := _dict.get('result')) is not None: + args['result'] = [PolicyResult.from_dict(v) for v in result] + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a ListAccessPoliciesResp 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 ListAccessPoliciesResp object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'ListAccessPoliciesResp') -> 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: 'ListAccessPoliciesResp') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class PolicyResult: + """ + Access policies information. + + :param str id: (optional) Policy ID. + :param str name: (optional) Policy name. + :param str decision: (optional) The action Access takes if the policy matches + the user. + :param List[PolicyRule] include: (optional) The include policy works like an OR + logical operator. + :param List[PolicyRule] exclude: (optional) The exclude policy works like a NOT + logical operator. + :param int precedence: (optional) The unique precedence for policies on a single + application. + :param List[PolicyRule] require: (optional) The require policy works like a AND + logical operator. + :param str uid: (optional) UUID, same as ID. + :param str created_at: (optional) Created time of the policy. + :param str updated_at: (optional) Updated time of the policy. + """ + + def __init__( + self, + *, + id: Optional[str] = None, + name: Optional[str] = None, + decision: Optional[str] = None, + include: Optional[List['PolicyRule']] = None, + exclude: Optional[List['PolicyRule']] = None, + precedence: Optional[int] = None, + require: Optional[List['PolicyRule']] = None, + uid: Optional[str] = None, + created_at: Optional[str] = None, + updated_at: Optional[str] = None, + ) -> None: + """ + Initialize a PolicyResult object. + + :param str id: (optional) Policy ID. + :param str name: (optional) Policy name. + :param str decision: (optional) The action Access takes if the policy + matches the user. + :param List[PolicyRule] include: (optional) The include policy works like + an OR logical operator. + :param List[PolicyRule] exclude: (optional) The exclude policy works like a + NOT logical operator. + :param int precedence: (optional) The unique precedence for policies on a + single application. + :param List[PolicyRule] require: (optional) The require policy works like a + AND logical operator. + :param str uid: (optional) UUID, same as ID. + :param str created_at: (optional) Created time of the policy. + :param str updated_at: (optional) Updated time of the policy. + """ + self.id = id + self.name = name + self.decision = decision + self.include = include + self.exclude = exclude + self.precedence = precedence + self.require = require + self.uid = uid + self.created_at = created_at + self.updated_at = updated_at + + @classmethod + def from_dict(cls, _dict: Dict) -> 'PolicyResult': + """Initialize a PolicyResult object from a json dictionary.""" + args = {} + if (id := _dict.get('id')) is not None: + args['id'] = id + if (name := _dict.get('name')) is not None: + args['name'] = name + if (decision := _dict.get('decision')) is not None: + args['decision'] = decision + if (include := _dict.get('include')) is not None: + args['include'] = include + if (exclude := _dict.get('exclude')) is not None: + args['exclude'] = exclude + if (precedence := _dict.get('precedence')) is not None: + args['precedence'] = precedence + if (require := _dict.get('require')) is not None: + args['require'] = require + if (uid := _dict.get('uid')) is not None: + args['uid'] = uid + if (created_at := _dict.get('created_at')) is not None: + args['created_at'] = created_at + if (updated_at := _dict.get('updated_at')) is not None: + args['updated_at'] = updated_at + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a PolicyResult 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, 'name') and self.name is not None: + _dict['name'] = self.name + if hasattr(self, 'decision') and self.decision is not None: + _dict['decision'] = self.decision + if hasattr(self, 'include') and self.include is not None: + include_list = [] + for v in self.include: + if isinstance(v, dict): + include_list.append(v) + else: + include_list.append(v.to_dict()) + _dict['include'] = include_list + if hasattr(self, 'exclude') and self.exclude is not None: + exclude_list = [] + for v in self.exclude: + if isinstance(v, dict): + exclude_list.append(v) + else: + exclude_list.append(v.to_dict()) + _dict['exclude'] = exclude_list + if hasattr(self, 'precedence') and self.precedence is not None: + _dict['precedence'] = self.precedence + if hasattr(self, 'require') and self.require is not None: + require_list = [] + for v in self.require: + if isinstance(v, dict): + require_list.append(v) + else: + require_list.append(v.to_dict()) + _dict['require'] = require_list + if hasattr(self, 'uid') and self.uid is not None: + _dict['uid'] = self.uid + if hasattr(self, 'created_at') and self.created_at is not None: + _dict['created_at'] = self.created_at + if hasattr(self, 'updated_at') and self.updated_at is not None: + _dict['updated_at'] = self.updated_at + 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 PolicyResult object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'PolicyResult') -> 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: 'PolicyResult') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class PolicyRule: + """ + Policy rule. + + """ + + def __init__( + self, + ) -> None: + """ + Initialize a PolicyRule object. + + """ + msg = "Cannot instantiate base class. Instead, instantiate one of the defined subclasses: {0}".format( + ", ".join(['PolicyRulePolicyCertRule', 'PolicyRulePolicyCnRule']) + ) + raise Exception(msg) + + +class PolicyRulePolicyCertRule(PolicyRule): + """ + Policy rule of certificate. + + :param dict certificate: (optional) + """ + + def __init__( + self, + *, + certificate: Optional[dict] = None, + ) -> None: + """ + Initialize a PolicyRulePolicyCertRule object. + + :param dict certificate: (optional) + """ + # pylint: disable=super-init-not-called + self.certificate = certificate + + @classmethod + def from_dict(cls, _dict: Dict) -> 'PolicyRulePolicyCertRule': + """Initialize a PolicyRulePolicyCertRule object from a json dictionary.""" + args = {} + if (certificate := _dict.get('certificate')) is not None: + args['certificate'] = certificate + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a PolicyRulePolicyCertRule 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, 'certificate') and self.certificate is not None: + _dict['certificate'] = self.certificate + 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 PolicyRulePolicyCertRule object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'PolicyRulePolicyCertRule') -> 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: 'PolicyRulePolicyCertRule') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class PolicyRulePolicyCnRule(PolicyRule): + """ + Policy rule of common name. + + :param PolicyCnRuleCommonName common_name: + """ + + def __init__( + self, + common_name: 'PolicyCnRuleCommonName', + ) -> None: + """ + Initialize a PolicyRulePolicyCnRule object. + + :param PolicyCnRuleCommonName common_name: + """ + # pylint: disable=super-init-not-called + self.common_name = common_name + + @classmethod + def from_dict(cls, _dict: Dict) -> 'PolicyRulePolicyCnRule': + """Initialize a PolicyRulePolicyCnRule object from a json dictionary.""" + args = {} + if (common_name := _dict.get('common_name')) is not None: + args['common_name'] = PolicyCnRuleCommonName.from_dict(common_name) + else: + raise ValueError('Required property \'common_name\' not present in PolicyRulePolicyCnRule JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a PolicyRulePolicyCnRule 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, 'common_name') and self.common_name is not None: + if isinstance(self.common_name, dict): + _dict['common_name'] = self.common_name + else: + _dict['common_name'] = self.common_name.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 PolicyRulePolicyCnRule object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'PolicyRulePolicyCnRule') -> 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: 'PolicyRulePolicyCnRule') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other diff --git a/ibm_cloud_networking_services/version.py b/ibm_cloud_networking_services/version.py index 5822790..45f04c4 100644 --- a/ibm_cloud_networking_services/version.py +++ b/ibm_cloud_networking_services/version.py @@ -1,4 +1,4 @@ """ Version of cloud_networking_services """ -__version__ = '0.31.1' +__version__ = '0.33.0' diff --git a/ibm_cloud_networking_services/zones_settings_v1.py b/ibm_cloud_networking_services/zones_settings_v1.py index 9df78b0..8616d5f 100644 --- a/ibm_cloud_networking_services/zones_settings_v1.py +++ b/ibm_cloud_networking_services/zones_settings_v1.py @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -# IBM OpenAPI SDK Code Generator Version: 3.112.0-f88e9264-20260220-115155 +# IBM OpenAPI SDK Code Generator Version: 3.114.0-a902401e-20260427-192904 """ CIS Zones Settings @@ -3712,6 +3712,97 @@ def update_email_obfuscation( response = self.send(request, **kwargs) return response + def get_security_level( + self, + **kwargs, + ) -> DetailedResponse: + """ + Get security level setting. + + Get security level for a zone. + + :param dict headers: A `dict` containing the request headers + :return: A `DetailedResponse` containing the result, headers and HTTP status code. + :rtype: DetailedResponse with `dict` result representing a `SecurityLevelResp` object + """ + + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='get_security_level', + ) + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'zone_identifier'] + path_param_values = self.encode_path_vars(self.crn, self.zone_identifier) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/zones/{zone_identifier}/settings/security_level'.format(**path_param_dict) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + ) + + response = self.send(request, **kwargs) + return response + + def update_security_level( + self, + *, + value: Optional[str] = None, + **kwargs, + ) -> DetailedResponse: + """ + Update security level setting. + + Update security level setting for a zone. + + :param str value: (optional) Value. + :param dict headers: A `dict` containing the request headers + :return: A `DetailedResponse` containing the result, headers and HTTP status code. + :rtype: DetailedResponse with `dict` result representing a `SecurityLevelResp` object + """ + + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='update_security_level', + ) + headers.update(sdk_headers) + + data = { + 'value': value, + } + data = {k: v for (k, v) in data.items() if v is not None} + data = json.dumps(data) + headers['content-type'] = 'application/json' + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'zone_identifier'] + path_param_values = self.encode_path_vars(self.crn, self.zone_identifier) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/zones/{zone_identifier}/settings/security_level'.format(**path_param_dict) + request = self.prepare_request( + method='PATCH', + url=url, + headers=headers, + data=data, + ) + + response = self.send(request, **kwargs) + return response + ############################################################################## # Models @@ -4259,7 +4350,7 @@ class EmailObfuscationRespResult: :param str id: ID. :param str value: Value. :param bool editable: Editable. - :param datetime modified_on: Modified date. + :param datetime modified_on: (optional) Modified date. """ def __init__( @@ -4267,7 +4358,8 @@ def __init__( id: str, value: str, editable: bool, - modified_on: datetime, + *, + modified_on: Optional[datetime] = None, ) -> None: """ Initialize a EmailObfuscationRespResult object. @@ -4275,7 +4367,7 @@ def __init__( :param str id: ID. :param str value: Value. :param bool editable: Editable. - :param datetime modified_on: Modified date. + :param datetime modified_on: (optional) Modified date. """ self.id = id self.value = value @@ -4300,8 +4392,6 @@ def from_dict(cls, _dict: Dict) -> 'EmailObfuscationRespResult': raise ValueError('Required property \'editable\' not present in EmailObfuscationRespResult JSON') if (modified_on := _dict.get('modified_on')) is not None: args['modified_on'] = string_to_datetime(modified_on) - else: - raise ValueError('Required property \'modified_on\' not present in EmailObfuscationRespResult JSON') return cls(**args) @classmethod @@ -6480,7 +6570,7 @@ class ReplaceInsecureJsRespResult: :param str id: ID. :param str value: Value. :param bool editable: Editable. - :param datetime modified_on: Modified date. + :param datetime modified_on: (optional) Modified date. """ def __init__( @@ -6488,7 +6578,8 @@ def __init__( id: str, value: str, editable: bool, - modified_on: datetime, + *, + modified_on: Optional[datetime] = None, ) -> None: """ Initialize a ReplaceInsecureJsRespResult object. @@ -6496,7 +6587,7 @@ def __init__( :param str id: ID. :param str value: Value. :param bool editable: Editable. - :param datetime modified_on: Modified date. + :param datetime modified_on: (optional) Modified date. """ self.id = id self.value = value @@ -6521,8 +6612,6 @@ def from_dict(cls, _dict: Dict) -> 'ReplaceInsecureJsRespResult': raise ValueError('Required property \'editable\' not present in ReplaceInsecureJsRespResult JSON') if (modified_on := _dict.get('modified_on')) is not None: args['modified_on'] = string_to_datetime(modified_on) - else: - raise ValueError('Required property \'modified_on\' not present in ReplaceInsecureJsRespResult JSON') return cls(**args) @classmethod @@ -7166,6 +7255,94 @@ def __ne__(self, other: 'SecurityHeaderSettingValueStrictTransportSecurity') -> return not self == other +class SecurityLevelRespResult: + """ + Container for response information. + + :param str id: ID. + :param str value: Value. + :param bool editable: Editable. + :param datetime modified_on: (optional) Modified date. + """ + + def __init__( + self, + id: str, + value: str, + editable: bool, + *, + modified_on: Optional[datetime] = None, + ) -> None: + """ + Initialize a SecurityLevelRespResult object. + + :param str id: ID. + :param str value: Value. + :param bool editable: Editable. + :param datetime modified_on: (optional) Modified date. + """ + self.id = id + self.value = value + self.editable = editable + self.modified_on = modified_on + + @classmethod + def from_dict(cls, _dict: Dict) -> 'SecurityLevelRespResult': + """Initialize a SecurityLevelRespResult object from a json dictionary.""" + args = {} + if (id := _dict.get('id')) is not None: + args['id'] = id + else: + raise ValueError('Required property \'id\' not present in SecurityLevelRespResult JSON') + if (value := _dict.get('value')) is not None: + args['value'] = value + else: + raise ValueError('Required property \'value\' not present in SecurityLevelRespResult JSON') + if (editable := _dict.get('editable')) is not None: + args['editable'] = editable + else: + raise ValueError('Required property \'editable\' not present in SecurityLevelRespResult JSON') + if (modified_on := _dict.get('modified_on')) is not None: + args['modified_on'] = string_to_datetime(modified_on) + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a SecurityLevelRespResult object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'id') and self.id is not None: + _dict['id'] = self.id + if hasattr(self, 'value') and self.value is not None: + _dict['value'] = self.value + if hasattr(self, 'editable') and self.editable is not None: + _dict['editable'] = self.editable + if hasattr(self, 'modified_on') and self.modified_on is not None: + _dict['modified_on'] = datetime_to_string(self.modified_on) + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this SecurityLevelRespResult object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'SecurityLevelRespResult') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ + + def __ne__(self, other: 'SecurityLevelRespResult') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + class ServerSideExcludeRespResult: """ Container for response information. @@ -8594,6 +8771,7 @@ class EmailObfuscationResp: email address obfuscation response. :param EmailObfuscationRespResult result: Container for response information. + :param dict result_info: (optional) Result information. :param bool success: Was the get successful. :param List[List[str]] errors: Array of errors encountered. :param List[List[str]] messages: Array of messages returned. @@ -8605,6 +8783,8 @@ def __init__( success: bool, errors: List[List[str]], messages: List[List[str]], + *, + result_info: Optional[dict] = None, ) -> None: """ Initialize a EmailObfuscationResp object. @@ -8614,8 +8794,10 @@ def __init__( :param bool success: Was the get successful. :param List[List[str]] errors: Array of errors encountered. :param List[List[str]] messages: Array of messages returned. + :param dict result_info: (optional) Result information. """ self.result = result + self.result_info = result_info self.success = success self.errors = errors self.messages = messages @@ -8628,6 +8810,8 @@ def from_dict(cls, _dict: Dict) -> 'EmailObfuscationResp': args['result'] = EmailObfuscationRespResult.from_dict(result) else: raise ValueError('Required property \'result\' not present in EmailObfuscationResp JSON') + if (result_info := _dict.get('result_info')) is not None: + args['result_info'] = result_info if (success := _dict.get('success')) is not None: args['success'] = success else: @@ -8655,6 +8839,8 @@ def to_dict(self) -> Dict: _dict['result'] = self.result else: _dict['result'] = self.result.to_dict() + if hasattr(self, 'result_info') and self.result_info is not None: + _dict['result_info'] = self.result_info if hasattr(self, 'success') and self.success is not None: _dict['success'] = self.success if hasattr(self, 'errors') and self.errors is not None: @@ -10545,6 +10731,7 @@ class ReplaceInsecureJsResp: Replace insecure Javascript response. :param ReplaceInsecureJsRespResult result: Container for response information. + :param dict result_info: (optional) Result information. :param bool success: Was the get successful. :param List[List[str]] errors: Array of errors encountered. :param List[List[str]] messages: Array of messages returned. @@ -10556,6 +10743,8 @@ def __init__( success: bool, errors: List[List[str]], messages: List[List[str]], + *, + result_info: Optional[dict] = None, ) -> None: """ Initialize a ReplaceInsecureJsResp object. @@ -10565,8 +10754,10 @@ def __init__( :param bool success: Was the get successful. :param List[List[str]] errors: Array of errors encountered. :param List[List[str]] messages: Array of messages returned. + :param dict result_info: (optional) Result information. """ self.result = result + self.result_info = result_info self.success = success self.errors = errors self.messages = messages @@ -10579,6 +10770,8 @@ def from_dict(cls, _dict: Dict) -> 'ReplaceInsecureJsResp': args['result'] = ReplaceInsecureJsRespResult.from_dict(result) else: raise ValueError('Required property \'result\' not present in ReplaceInsecureJsResp JSON') + if (result_info := _dict.get('result_info')) is not None: + args['result_info'] = result_info if (success := _dict.get('success')) is not None: args['success'] = success else: @@ -10606,6 +10799,8 @@ def to_dict(self) -> Dict: _dict['result'] = self.result else: _dict['result'] = self.result.to_dict() + if hasattr(self, 'result_info') and self.result_info is not None: + _dict['result_info'] = self.result_info if hasattr(self, 'success') and self.success is not None: _dict['success'] = self.success if hasattr(self, 'errors') and self.errors is not None: @@ -10912,6 +11107,98 @@ def __ne__(self, other: 'SecurityHeaderResp') -> bool: return not self == other +class SecurityLevelResp: + """ + Security level response. + + :param SecurityLevelRespResult result: Container for response information. + :param bool success: Was the get successful. + :param List[List[str]] errors: Array of errors encountered. + :param List[List[str]] messages: Array of messages returned. + """ + + def __init__( + self, + result: 'SecurityLevelRespResult', + success: bool, + errors: List[List[str]], + messages: List[List[str]], + ) -> None: + """ + Initialize a SecurityLevelResp object. + + :param SecurityLevelRespResult result: Container for response information. + :param bool success: Was the get successful. + :param List[List[str]] errors: Array of errors encountered. + :param List[List[str]] messages: Array of messages returned. + """ + self.result = result + self.success = success + self.errors = errors + self.messages = messages + + @classmethod + def from_dict(cls, _dict: Dict) -> 'SecurityLevelResp': + """Initialize a SecurityLevelResp object from a json dictionary.""" + args = {} + if (result := _dict.get('result')) is not None: + args['result'] = SecurityLevelRespResult.from_dict(result) + else: + raise ValueError('Required property \'result\' not present in SecurityLevelResp JSON') + if (success := _dict.get('success')) is not None: + args['success'] = success + else: + raise ValueError('Required property \'success\' not present in SecurityLevelResp JSON') + if (errors := _dict.get('errors')) is not None: + args['errors'] = errors + else: + raise ValueError('Required property \'errors\' not present in SecurityLevelResp JSON') + if (messages := _dict.get('messages')) is not None: + args['messages'] = messages + else: + raise ValueError('Required property \'messages\' not present in SecurityLevelResp JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a SecurityLevelResp object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'result') and self.result is not None: + if isinstance(self.result, dict): + _dict['result'] = self.result + else: + _dict['result'] = self.result.to_dict() + if hasattr(self, 'success') and self.success is not None: + _dict['success'] = self.success + if hasattr(self, 'errors') and self.errors is not None: + _dict['errors'] = self.errors + if hasattr(self, 'messages') and self.messages is not None: + _dict['messages'] = self.messages + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this SecurityLevelResp object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'SecurityLevelResp') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ + + def __ne__(self, other: 'SecurityLevelResp') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + class ServerSideExcludeResp: """ Response of server side exclude. diff --git a/setup.py b/setup.py index 5db8c33..0805071 100644 --- a/setup.py +++ b/setup.py @@ -17,7 +17,7 @@ import os import sys -__version__ = '0.31.1' +__version__ = '0.33.0' PACKAGE_NAME = 'ibm_cloud_networking_services' PACKAGE_DESC = 'Python client library for IBM Cloud Networking Services' 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/integration/test_mtls_v1.py b/test/integration/test_mtls_v1.py new file mode 100644 index 0000000..7d067ac --- /dev/null +++ b/test/integration/test_mtls_v1.py @@ -0,0 +1,372 @@ +# -*- coding: utf-8 -*- +# (C) Copyright IBM Corp. 2026. + +""" +Integration test code to execute MTLS +""" + +import os +import unittest +from dotenv import load_dotenv, find_dotenv +from ibm_cloud_networking_services import MtlsV1 + +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 TestMtlsV1(unittest.TestCase): + """ Test class to call MTLS sdk functions """ + + @unittest.skip("Authentication failing") + + def setUp(self): + """ test case setup """ + if not os.path.exists(configFile): + raise unittest.SkipTest( + 'External configuration not available, skipping...') + self.crn = os.getenv("CRN") + self.zone_id = os.getenv("ZONE_ID") + self.endpoint = os.getenv("API_ENDPOINT") + self.service = MtlsV1.new_instance( + service_name="cis_services", crn=self.crn) + self.service.set_service_url(self.endpoint) + self._clean_access_policies() + self._clean_access_applications() + self._clean_access_certificates() + + def tearDown(self): + """ tear down """ + # Delete the resources + self._clean_access_policies() + self._clean_access_applications() + self._clean_access_certificates() + print("Clean up complete") + + def _clean_access_certificates(self): + response = self.service.list_access_certificates(zone_id=self.zone_id) + assert response is not None + assert response.status_code == 200 + resp = response.get_result()['result'] + if resp is not None: + for record in resp: + self.service.delete_access_certificate( + zone_id=self.zone_id, + cert_id=record.get("id") + ) + + def _clean_access_applications(self): + response = self.service.list_access_applications(zone_id=self.zone_id) + assert response is not None + assert response.status_code == 200 + resp = response.get_result()['result'] + if resp is not None: + for record in resp: + self.service.delete_access_application( + zone_id=self.zone_id, + app_id=record.get("id") + ) + + def _clean_access_policies(self): + # First get all applications + response = self.service.list_access_applications(zone_id=self.zone_id) + if response is not None and response.status_code == 200: + apps = response.get_result()['result'] + if apps is not None: + for app in apps: + app_id = app.get("id") + # Get policies for each application + policy_response = self.service.list_access_policies( + zone_id=self.zone_id, + app_id=app_id + ) + if policy_response is not None and policy_response.status_code == 200: + policies = policy_response.get_result()['result'] + if policies is not None: + for policy in policies: + self.service.delete_access_policy( + zone_id=self.zone_id, + app_id=app_id, + policy_id=policy.get("id") + ) + + def _create_access_certificate(self, name, certificate): + """ create access certificate """ + response = self.service.create_access_certificate( + zone_id=self.zone_id, + name=name, + certificate=certificate, + associated_hostnames=['example.com'] + ) + assert response is not None and response.get_status_code() == 201 + cert_id = response.get_result()['result']['id'] + return cert_id + + def _create_access_application(self, name, domain): + """ create access application """ + response = self.service.create_access_application( + zone_id=self.zone_id, + name=name, + domain=domain, + session_duration='24h' + ) + assert response is not None and response.get_status_code() == 201 + app_id = response.get_result()['result']['id'] + return app_id + + + ################## create access certificate ###################### + def test_1_create_access_certificate(self): + """ test for success """ + name = 'My Test Certificate' + certificate = '-----BEGIN CERTIFICATE-----\nMIIBkTCB+wIJAIxdK4iNZEqcMA0GCSqGSIb3DQEBCwUAMCExHzAdBgNVBAoMFkF1\ndGhlbnRpY2F0ZWQgT3JpZ2luIENBMB4XDTE5MDEwMTAwMDAwMFoXDTI5MDEwMTAw\nMDAwMFowITEfMB0GA1UECgwWQXV0aGVudGljYXRlZCBPcmlnaW4gQ0EwXDANBgkq\nhkiG9w0BAQEFAANLADBIAkEAqGb8ovgPfTkfz+MichikfnZ0dXIcJmHV81TbC0vj\n+J1FP80X96+OdZJZ+LsWbOB6hBg0+nMjvOAaEuvGj4VDdQIDAQABMA0GCSqGSIb3\nDQEBCwUAA0EAU4BfQKbT1+pxGoVN+cfUwhLAq4hBYB38Sfhn9VYt+VJ2VsPQEb8V\nZgkeJ0Lrry5W7kDBtIMwLJL+FzUjH4Flvw==\n-----END CERTIFICATE-----' + + response = self.service.create_access_certificate( + zone_id=self.zone_id, + name=name, + certificate=certificate, + associated_hostnames=['example.com'] + ) + assert response is not None and response.get_status_code() == 201 + cert_id = response.get_result()['result']['id'] + return cert_id + + + ################## list access certificates ################### + def test_2_list_access_certificates(self): + """ test for success """ + self.test_1_create_access_certificate() + + response = self.service.list_access_certificates(zone_id=self.zone_id) + assert response is not None and response.get_status_code() == 200 + assert len(response.get_result()['result']) >= 1 + + ################## get access certificate by id ################### + def test_3_get_access_certificate(self): + """ test for success """ + cert_id = self.test_1_create_access_certificate() + + response = self.service.get_access_certificate( + zone_id=self.zone_id, + cert_id=cert_id + ) + assert response is not None and response.get_status_code() == 200 + assert response.get_result()['result']['id'] == cert_id + + ################## update access certificate ################### + def test_4_update_access_certificate(self): + """ test for success """ + cert_id = self.test_1_create_access_certificate() + + response = self.service.update_access_certificate( + zone_id=self.zone_id, + cert_id=cert_id, + name='Updated Certificate Name', + associated_hostnames=['updated.example.com'] + ) + assert response is not None and response.get_status_code() == 200 + updated_cert_id = response.get_result()['result']['id'] + assert updated_cert_id == cert_id + return updated_cert_id + + ################## delete access certificate ################### + def test_5_delete_access_certificate(self): + """ test for success """ + cert_id = self.test_4_update_access_certificate() + + response = self.service.delete_access_certificate( + zone_id=self.zone_id, + cert_id=cert_id + ) + assert response is not None and response.get_status_code() == 200 + delete_cert_id = response.get_result()['result']['id'] + assert delete_cert_id == cert_id + + ################## create access application ###################### + def test_6_create_access_application(self): + """ test for success """ + name = 'My Test Application' + domain = 'test.example.com' + + response = self.service.create_access_application( + zone_id=self.zone_id, + name=name, + domain=domain, + session_duration='24h' + ) + assert response is not None and response.get_status_code() == 201 + app_id = response.get_result()['result']['id'] + return app_id + + ################## list access applications ################### + def test_7_list_access_applications(self): + """ test for success """ + self.test_6_create_access_application() + + response = self.service.list_access_applications(zone_id=self.zone_id) + assert response is not None and response.get_status_code() == 200 + assert len(response.get_result()['result']) >= 1 + + ################## get access application by id ################### + def test_8_get_access_application(self): + """ test for success """ + app_id = self.test_6_create_access_application() + + response = self.service.get_access_application( + zone_id=self.zone_id, + app_id=app_id + ) + assert response is not None and response.get_status_code() == 200 + assert response.get_result()['result']['id'] == app_id + + ################## update access application ################### + def test_9_update_access_application(self): + """ test for success """ + app_id = self.test_6_create_access_application() + + response = self.service.update_access_application( + zone_id=self.zone_id, + app_id=app_id, + name='Updated Application Name', + domain='updated.example.com', + session_duration='12h' + ) + assert response is not None and response.get_status_code() == 200 + updated_app_id = response.get_result()['result']['id'] + assert updated_app_id == app_id + return updated_app_id + + ################## delete access application ################### + def test_10_delete_access_application(self): + """ test for success """ + app_id = self.test_9_update_access_application() + + response = self.service.delete_access_application( + zone_id=self.zone_id, + app_id=app_id + ) + assert response is not None and response.get_status_code() == 200 + delete_app_id = response.get_result()['result']['id'] + assert delete_app_id == app_id + + ################## create access policy ###################### + def test_11_create_access_policy(self): + """ test for success """ + app_id = self._create_access_application( + name='Policy Test Application', + domain='policy.example.com' + ) + + # Construct policy rule + policy_rule_model = { + 'certificate': {} + } + + response = self.service.create_access_policy( + zone_id=self.zone_id, + app_id=app_id, + name='My Test Policy', + decision='allow', + include=[policy_rule_model] + ) + assert response is not None and response.get_status_code() == 201 + policy_id = response.get_result()['result']['id'] + return app_id, policy_id + + ################## list access policies ################### + def test_12_list_access_policies(self): + """ test for success """ + app_id, policy_id = self.test_11_create_access_policy() + + response = self.service.list_access_policies( + zone_id=self.zone_id, + app_id=app_id + ) + assert response is not None and response.get_status_code() == 200 + assert len(response.get_result()['result']) >= 1 + + ################## get access policy by id ################### + def test_13_get_access_policy(self): + """ test for success """ + app_id, policy_id = self.test_11_create_access_policy() + + response = self.service.get_access_policy( + zone_id=self.zone_id, + app_id=app_id, + policy_id=policy_id + ) + assert response is not None and response.get_status_code() == 200 + assert response.get_result()['result']['id'] == policy_id + + ################## update access policy ################### + def test_14_update_access_policy(self): + """ test for success """ + app_id, policy_id = self.test_11_create_access_policy() + + # Construct updated policy rule + policy_rule_model = { + 'certificate': {} + } + + response = self.service.update_access_policy( + zone_id=self.zone_id, + app_id=app_id, + policy_id=policy_id, + name='Updated Policy Name', + decision='allow', + include=[policy_rule_model] + ) + assert response is not None and response.get_status_code() == 200 + updated_policy_id = response.get_result()['result']['id'] + assert updated_policy_id == policy_id + return app_id, updated_policy_id + + ################## delete access policy ################### + def test_15_delete_access_policy(self): + """ test for success """ + app_id, policy_id = self.test_14_update_access_policy() + + response = self.service.delete_access_policy( + zone_id=self.zone_id, + app_id=app_id, + policy_id=policy_id + ) + assert response is not None and response.get_status_code() == 200 + delete_policy_id = response.get_result()['result']['id'] + assert delete_policy_id == policy_id + + ################## get access cert settings ################### + def test_16_get_access_cert_settings(self): + """ test for success """ + response = self.service.get_access_cert_settings(zone_id=self.zone_id) + assert response is not None and response.get_status_code() == 200 + + ################## update access cert settings ################### + def test_17_update_access_cert_settings(self): + """ test for success """ + # Construct settings + settings_model = { + 'hostname': 'example.com', + 'client_certificate_forwarding': True + } + + response = self.service.update_access_cert_settings( + zone_id=self.zone_id, + settings=[settings_model] + ) + assert response is not None and response.get_status_code() == 200 + + ################## create access organization ###################### + def test_18_create_access_organization(self): + """ test for success """ + response = self.service.create_access_organization( + name='My Test Organization', + auth_domain='test-org.cloudflareaccess.com' + ) + assert response is not None and response.get_status_code() == 201 + +if __name__ == '__main__': + unittest.main() diff --git a/test/integration/test_zones_settings_v1.py b/test/integration/test_zones_settings_v1.py index 682bdc3..43dd500 100644 --- a/test/integration/test_zones_settings_v1.py +++ b/test/integration/test_zones_settings_v1.py @@ -646,6 +646,26 @@ def test_1_email_obfuscation_setting(self): value=self.value).get_result() assert response is not None and response.get('success') is True + def test_1_get_security_level(self): + """ test for success """ + + #Get security level + response = self.zonesSettings.get_security_level() + assert response is not None and response.get_status_code() == 200 + assert response.get_result()['result'] is not None + + def test_2_update_security_level(self): + """ test for success """ + + # Set up parameter values + value = 'medium' + + # invoke method + response = self.zonesSettings.update_security_level( + value=value + ) + assert response is not None and response.get_status_code() == 200 + assert response.get_result()['result']['value'] == value if __name__ == '__main__': unittest.main() \ No newline at end of file diff --git a/test/unit/test_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 +############################################################################## diff --git a/test/unit/test_mtls_v1.py b/test/unit/test_mtls_v1.py new file mode 100644 index 0000000..3c27f61 --- /dev/null +++ b/test/unit/test_mtls_v1.py @@ -0,0 +1,3053 @@ +# -*- 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 MtlsV1 +""" + +from ibm_cloud_sdk_core.authenticators.no_auth_authenticator import NoAuthAuthenticator +import inspect +import json +import os +import pytest +import re +import responses +import urllib +from ibm_cloud_networking_services.mtls_v1 import * + +crn = 'testString' + +_service = MtlsV1( + authenticator=NoAuthAuthenticator(), + crn=crn, +) + +_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: MutualTLS +############################################################################## +# region + + +class TestNewInstance: + """ + Test Class for new_instance + """ + + def test_new_instance(self): + """ + new_instance() + """ + os.environ['TEST_SERVICE_AUTH_TYPE'] = 'noAuth' + + service = MtlsV1.new_instance( + crn=crn, + service_name='TEST_SERVICE', + ) + + assert service is not None + assert isinstance(service, MtlsV1) + + def test_new_instance_without_authenticator(self): + """ + new_instance_without_authenticator() + """ + with pytest.raises(ValueError, match='authenticator must be provided'): + service = MtlsV1.new_instance( + crn=crn, + 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 = MtlsV1.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 = MtlsV1.new_instance( + crn=None, + ) + + +class TestListAccessCertificates: + """ + Test Class for list_access_certificates + """ + + @responses.activate + def test_list_access_certificates_all_params(self): + """ + list_access_certificates() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/access/certificates') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": [{"id": "21a41336-9001-42c4-8440-c79e0cb86e1f", "name": "test-cert", "fingerprint": "MD5 Fingerprint=38:38:B4:FB:3C:33:CE:2C:8E:8E:D1:1B:94:70:C1:5F", "associated_hostnames": ["test.example.com"], "created_at": "2021-04-19T11:09:11Z", "updated_at": "2021-04-19T11:09:11Z", "expires_on": "2026-04-18T06:26:00Z"}]}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + zone_id = 'testString' + + # Invoke method + response = _service.list_access_certificates( + zone_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_list_access_certificates_all_params_with_retries(self): + # Enable retries and run test_list_access_certificates_all_params. + _service.enable_retries() + self.test_list_access_certificates_all_params() + + # Disable retries and run test_list_access_certificates_all_params. + _service.disable_retries() + self.test_list_access_certificates_all_params() + + @responses.activate + def test_list_access_certificates_value_error(self): + """ + test_list_access_certificates_value_error() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/access/certificates') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": [{"id": "21a41336-9001-42c4-8440-c79e0cb86e1f", "name": "test-cert", "fingerprint": "MD5 Fingerprint=38:38:B4:FB:3C:33:CE:2C:8E:8E:D1:1B:94:70:C1:5F", "associated_hostnames": ["test.example.com"], "created_at": "2021-04-19T11:09:11Z", "updated_at": "2021-04-19T11:09:11Z", "expires_on": "2026-04-18T06:26:00Z"}]}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + zone_id = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "zone_id": zone_id, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.list_access_certificates(**req_copy) + + def test_list_access_certificates_value_error_with_retries(self): + # Enable retries and run test_list_access_certificates_value_error. + _service.enable_retries() + self.test_list_access_certificates_value_error() + + # Disable retries and run test_list_access_certificates_value_error. + _service.disable_retries() + self.test_list_access_certificates_value_error() + + +class TestCreateAccessCertificate: + """ + Test Class for create_access_certificate + """ + + @responses.activate + def test_create_access_certificate_all_params(self): + """ + create_access_certificate() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/access/certificates') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"id": "21a41336-9001-42c4-8440-c79e0cb86e1f", "name": "test-cert", "fingerprint": "MD5 Fingerprint=38:38:B4:FB:3C:33:CE:2C:8E:8E:D1:1B:94:70:C1:5F", "associated_hostnames": ["test.example.com"], "created_at": "2021-04-19T11:09:11Z", "updated_at": "2021-04-19T11:09:11Z", "expires_on": "2026-04-18T06:26:00Z"}}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + zone_id = 'testString' + name = 'test-cert' + certificate = '-----BEGIN CERTIFICATE-----\nMIIGAjCCA+qgAwIBAgIJAI7kymlF7CWT...N4RI7KKB7nikiuUf8vhULKy5IX10\nDrUtmu/B\n-----END CERTIFICATE-----' + associated_hostnames = ['test.example.com'] + + # Invoke method + response = _service.create_access_certificate( + zone_id, + name=name, + certificate=certificate, + associated_hostnames=associated_hostnames, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['name'] == 'test-cert' + assert req_body['certificate'] == '-----BEGIN CERTIFICATE-----\nMIIGAjCCA+qgAwIBAgIJAI7kymlF7CWT...N4RI7KKB7nikiuUf8vhULKy5IX10\nDrUtmu/B\n-----END CERTIFICATE-----' + assert req_body['associated_hostnames'] == ['test.example.com'] + + def test_create_access_certificate_all_params_with_retries(self): + # Enable retries and run test_create_access_certificate_all_params. + _service.enable_retries() + self.test_create_access_certificate_all_params() + + # Disable retries and run test_create_access_certificate_all_params. + _service.disable_retries() + self.test_create_access_certificate_all_params() + + @responses.activate + def test_create_access_certificate_required_params(self): + """ + test_create_access_certificate_required_params() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/access/certificates') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"id": "21a41336-9001-42c4-8440-c79e0cb86e1f", "name": "test-cert", "fingerprint": "MD5 Fingerprint=38:38:B4:FB:3C:33:CE:2C:8E:8E:D1:1B:94:70:C1:5F", "associated_hostnames": ["test.example.com"], "created_at": "2021-04-19T11:09:11Z", "updated_at": "2021-04-19T11:09:11Z", "expires_on": "2026-04-18T06:26:00Z"}}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + zone_id = 'testString' + + # Invoke method + response = _service.create_access_certificate( + zone_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_create_access_certificate_required_params_with_retries(self): + # Enable retries and run test_create_access_certificate_required_params. + _service.enable_retries() + self.test_create_access_certificate_required_params() + + # Disable retries and run test_create_access_certificate_required_params. + _service.disable_retries() + self.test_create_access_certificate_required_params() + + @responses.activate + def test_create_access_certificate_value_error(self): + """ + test_create_access_certificate_value_error() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/access/certificates') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"id": "21a41336-9001-42c4-8440-c79e0cb86e1f", "name": "test-cert", "fingerprint": "MD5 Fingerprint=38:38:B4:FB:3C:33:CE:2C:8E:8E:D1:1B:94:70:C1:5F", "associated_hostnames": ["test.example.com"], "created_at": "2021-04-19T11:09:11Z", "updated_at": "2021-04-19T11:09:11Z", "expires_on": "2026-04-18T06:26:00Z"}}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + zone_id = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "zone_id": zone_id, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.create_access_certificate(**req_copy) + + def test_create_access_certificate_value_error_with_retries(self): + # Enable retries and run test_create_access_certificate_value_error. + _service.enable_retries() + self.test_create_access_certificate_value_error() + + # Disable retries and run test_create_access_certificate_value_error. + _service.disable_retries() + self.test_create_access_certificate_value_error() + + +class TestGetAccessCertificate: + """ + Test Class for get_access_certificate + """ + + @responses.activate + def test_get_access_certificate_all_params(self): + """ + get_access_certificate() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/access/certificates/testString') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"id": "21a41336-9001-42c4-8440-c79e0cb86e1f", "name": "test-cert", "fingerprint": "MD5 Fingerprint=38:38:B4:FB:3C:33:CE:2C:8E:8E:D1:1B:94:70:C1:5F", "associated_hostnames": ["test.example.com"], "created_at": "2021-04-19T11:09:11Z", "updated_at": "2021-04-19T11:09:11Z", "expires_on": "2026-04-18T06:26:00Z"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + zone_id = 'testString' + cert_id = 'testString' + + # Invoke method + response = _service.get_access_certificate( + zone_id, + cert_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_get_access_certificate_all_params_with_retries(self): + # Enable retries and run test_get_access_certificate_all_params. + _service.enable_retries() + self.test_get_access_certificate_all_params() + + # Disable retries and run test_get_access_certificate_all_params. + _service.disable_retries() + self.test_get_access_certificate_all_params() + + @responses.activate + def test_get_access_certificate_value_error(self): + """ + test_get_access_certificate_value_error() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/access/certificates/testString') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"id": "21a41336-9001-42c4-8440-c79e0cb86e1f", "name": "test-cert", "fingerprint": "MD5 Fingerprint=38:38:B4:FB:3C:33:CE:2C:8E:8E:D1:1B:94:70:C1:5F", "associated_hostnames": ["test.example.com"], "created_at": "2021-04-19T11:09:11Z", "updated_at": "2021-04-19T11:09:11Z", "expires_on": "2026-04-18T06:26:00Z"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + zone_id = 'testString' + cert_id = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "zone_id": zone_id, + "cert_id": cert_id, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.get_access_certificate(**req_copy) + + def test_get_access_certificate_value_error_with_retries(self): + # Enable retries and run test_get_access_certificate_value_error. + _service.enable_retries() + self.test_get_access_certificate_value_error() + + # Disable retries and run test_get_access_certificate_value_error. + _service.disable_retries() + self.test_get_access_certificate_value_error() + + +class TestUpdateAccessCertificate: + """ + Test Class for update_access_certificate + """ + + @responses.activate + def test_update_access_certificate_all_params(self): + """ + update_access_certificate() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/access/certificates/testString') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"id": "21a41336-9001-42c4-8440-c79e0cb86e1f", "name": "test-cert", "fingerprint": "MD5 Fingerprint=38:38:B4:FB:3C:33:CE:2C:8E:8E:D1:1B:94:70:C1:5F", "associated_hostnames": ["test.example.com"], "created_at": "2021-04-19T11:09:11Z", "updated_at": "2021-04-19T11:09:11Z", "expires_on": "2026-04-18T06:26:00Z"}}' + responses.add( + responses.PUT, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + zone_id = 'testString' + cert_id = 'testString' + name = 'test-cert' + associated_hostnames = ['test.example.com'] + + # Invoke method + response = _service.update_access_certificate( + zone_id, + cert_id, + name=name, + associated_hostnames=associated_hostnames, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['name'] == 'test-cert' + assert req_body['associated_hostnames'] == ['test.example.com'] + + def test_update_access_certificate_all_params_with_retries(self): + # Enable retries and run test_update_access_certificate_all_params. + _service.enable_retries() + self.test_update_access_certificate_all_params() + + # Disable retries and run test_update_access_certificate_all_params. + _service.disable_retries() + self.test_update_access_certificate_all_params() + + @responses.activate + def test_update_access_certificate_required_params(self): + """ + test_update_access_certificate_required_params() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/access/certificates/testString') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"id": "21a41336-9001-42c4-8440-c79e0cb86e1f", "name": "test-cert", "fingerprint": "MD5 Fingerprint=38:38:B4:FB:3C:33:CE:2C:8E:8E:D1:1B:94:70:C1:5F", "associated_hostnames": ["test.example.com"], "created_at": "2021-04-19T11:09:11Z", "updated_at": "2021-04-19T11:09:11Z", "expires_on": "2026-04-18T06:26:00Z"}}' + responses.add( + responses.PUT, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + zone_id = 'testString' + cert_id = 'testString' + + # Invoke method + response = _service.update_access_certificate( + zone_id, + cert_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_update_access_certificate_required_params_with_retries(self): + # Enable retries and run test_update_access_certificate_required_params. + _service.enable_retries() + self.test_update_access_certificate_required_params() + + # Disable retries and run test_update_access_certificate_required_params. + _service.disable_retries() + self.test_update_access_certificate_required_params() + + @responses.activate + def test_update_access_certificate_value_error(self): + """ + test_update_access_certificate_value_error() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/access/certificates/testString') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"id": "21a41336-9001-42c4-8440-c79e0cb86e1f", "name": "test-cert", "fingerprint": "MD5 Fingerprint=38:38:B4:FB:3C:33:CE:2C:8E:8E:D1:1B:94:70:C1:5F", "associated_hostnames": ["test.example.com"], "created_at": "2021-04-19T11:09:11Z", "updated_at": "2021-04-19T11:09:11Z", "expires_on": "2026-04-18T06:26:00Z"}}' + responses.add( + responses.PUT, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + zone_id = 'testString' + cert_id = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "zone_id": zone_id, + "cert_id": cert_id, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.update_access_certificate(**req_copy) + + def test_update_access_certificate_value_error_with_retries(self): + # Enable retries and run test_update_access_certificate_value_error. + _service.enable_retries() + self.test_update_access_certificate_value_error() + + # Disable retries and run test_update_access_certificate_value_error. + _service.disable_retries() + self.test_update_access_certificate_value_error() + + +class TestDeleteAccessCertificate: + """ + Test Class for delete_access_certificate + """ + + @responses.activate + def test_delete_access_certificate_all_params(self): + """ + delete_access_certificate() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/access/certificates/testString') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"id": "21a41336-9001-42c4-8440-c79e0cb86e1f"}}' + responses.add( + responses.DELETE, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + zone_id = 'testString' + cert_id = 'testString' + + # Invoke method + response = _service.delete_access_certificate( + zone_id, + cert_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_delete_access_certificate_all_params_with_retries(self): + # Enable retries and run test_delete_access_certificate_all_params. + _service.enable_retries() + self.test_delete_access_certificate_all_params() + + # Disable retries and run test_delete_access_certificate_all_params. + _service.disable_retries() + self.test_delete_access_certificate_all_params() + + @responses.activate + def test_delete_access_certificate_value_error(self): + """ + test_delete_access_certificate_value_error() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/access/certificates/testString') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"id": "21a41336-9001-42c4-8440-c79e0cb86e1f"}}' + responses.add( + responses.DELETE, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + zone_id = 'testString' + cert_id = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "zone_id": zone_id, + "cert_id": cert_id, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.delete_access_certificate(**req_copy) + + def test_delete_access_certificate_value_error_with_retries(self): + # Enable retries and run test_delete_access_certificate_value_error. + _service.enable_retries() + self.test_delete_access_certificate_value_error() + + # Disable retries and run test_delete_access_certificate_value_error. + _service.disable_retries() + self.test_delete_access_certificate_value_error() + + +class TestListAccessApplications: + """ + Test Class for list_access_applications + """ + + @responses.activate + def test_list_access_applications_all_params(self): + """ + list_access_applications() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/access/apps') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": [{"id": "de4526d6-d125-4f95-906f-1757510a9cd8", "name": "mtls-test-app", "domain": "test.example.com", "aud": "f8e1744453ea3679d919fdc6db58cff648f2b14b33a729f780fc02e75a42a008", "policies": [{"id": "acabcdb1-afb3-4f61-9dae-d1a353a93661", "name": "mtls-test-policy", "decision": "non_identity", "include": [{"certificate": {"anyKey": "anyValue"}}], "exclude": [{"certificate": {"anyKey": "anyValue"}}], "precedence": 1, "require": [{"certificate": {"anyKey": "anyValue"}}], "uid": "acabcdb1-afb3-4f61-9dae-d1a353a93661", "created_at": "2021-04-19T08:01:21Z", "updated_at": "2021-04-19T08:01:21Z"}], "allowed_idps": ["699d98642c564d2e855e9661899b7252"], "auto_redirect_to_identity": false, "session_duration": "24h", "type": "self_hosted", "uid": "de4526d6-d125-4f95-906f-1757510a9cd8", "created_at": "2021-04-19T07:59:49Z", "updated_at": "2021-04-19T07:59:49Z"}]}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + zone_id = 'testString' + + # Invoke method + response = _service.list_access_applications( + zone_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_list_access_applications_all_params_with_retries(self): + # Enable retries and run test_list_access_applications_all_params. + _service.enable_retries() + self.test_list_access_applications_all_params() + + # Disable retries and run test_list_access_applications_all_params. + _service.disable_retries() + self.test_list_access_applications_all_params() + + @responses.activate + def test_list_access_applications_value_error(self): + """ + test_list_access_applications_value_error() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/access/apps') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": [{"id": "de4526d6-d125-4f95-906f-1757510a9cd8", "name": "mtls-test-app", "domain": "test.example.com", "aud": "f8e1744453ea3679d919fdc6db58cff648f2b14b33a729f780fc02e75a42a008", "policies": [{"id": "acabcdb1-afb3-4f61-9dae-d1a353a93661", "name": "mtls-test-policy", "decision": "non_identity", "include": [{"certificate": {"anyKey": "anyValue"}}], "exclude": [{"certificate": {"anyKey": "anyValue"}}], "precedence": 1, "require": [{"certificate": {"anyKey": "anyValue"}}], "uid": "acabcdb1-afb3-4f61-9dae-d1a353a93661", "created_at": "2021-04-19T08:01:21Z", "updated_at": "2021-04-19T08:01:21Z"}], "allowed_idps": ["699d98642c564d2e855e9661899b7252"], "auto_redirect_to_identity": false, "session_duration": "24h", "type": "self_hosted", "uid": "de4526d6-d125-4f95-906f-1757510a9cd8", "created_at": "2021-04-19T07:59:49Z", "updated_at": "2021-04-19T07:59:49Z"}]}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + zone_id = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "zone_id": zone_id, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.list_access_applications(**req_copy) + + def test_list_access_applications_value_error_with_retries(self): + # Enable retries and run test_list_access_applications_value_error. + _service.enable_retries() + self.test_list_access_applications_value_error() + + # Disable retries and run test_list_access_applications_value_error. + _service.disable_retries() + self.test_list_access_applications_value_error() + + +class TestCreateAccessApplication: + """ + Test Class for create_access_application + """ + + @responses.activate + def test_create_access_application_all_params(self): + """ + create_access_application() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/access/apps') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"id": "de4526d6-d125-4f95-906f-1757510a9cd8", "name": "mtls-test-app", "domain": "test.example.com", "aud": "f8e1744453ea3679d919fdc6db58cff648f2b14b33a729f780fc02e75a42a008", "policies": [{"anyKey": "anyValue"}], "allowed_idps": ["allowed_idps"], "auto_redirect_to_identity": false, "session_duration": "24h", "type": "self_hosted", "uid": "de4526d6-d125-4f95-906f-1757510a9cd8", "created_at": "2021-04-19T07:59:49Z", "updated_at": "2021-04-19T07:59:49Z"}}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + zone_id = 'testString' + name = 'mtls-test-app' + domain = 'test.example.com' + session_duration = '24h' + + # Invoke method + response = _service.create_access_application( + zone_id, + name=name, + domain=domain, + session_duration=session_duration, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['name'] == 'mtls-test-app' + assert req_body['domain'] == 'test.example.com' + assert req_body['session_duration'] == '24h' + + def test_create_access_application_all_params_with_retries(self): + # Enable retries and run test_create_access_application_all_params. + _service.enable_retries() + self.test_create_access_application_all_params() + + # Disable retries and run test_create_access_application_all_params. + _service.disable_retries() + self.test_create_access_application_all_params() + + @responses.activate + def test_create_access_application_required_params(self): + """ + test_create_access_application_required_params() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/access/apps') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"id": "de4526d6-d125-4f95-906f-1757510a9cd8", "name": "mtls-test-app", "domain": "test.example.com", "aud": "f8e1744453ea3679d919fdc6db58cff648f2b14b33a729f780fc02e75a42a008", "policies": [{"anyKey": "anyValue"}], "allowed_idps": ["allowed_idps"], "auto_redirect_to_identity": false, "session_duration": "24h", "type": "self_hosted", "uid": "de4526d6-d125-4f95-906f-1757510a9cd8", "created_at": "2021-04-19T07:59:49Z", "updated_at": "2021-04-19T07:59:49Z"}}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + zone_id = 'testString' + + # Invoke method + response = _service.create_access_application( + zone_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_create_access_application_required_params_with_retries(self): + # Enable retries and run test_create_access_application_required_params. + _service.enable_retries() + self.test_create_access_application_required_params() + + # Disable retries and run test_create_access_application_required_params. + _service.disable_retries() + self.test_create_access_application_required_params() + + @responses.activate + def test_create_access_application_value_error(self): + """ + test_create_access_application_value_error() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/access/apps') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"id": "de4526d6-d125-4f95-906f-1757510a9cd8", "name": "mtls-test-app", "domain": "test.example.com", "aud": "f8e1744453ea3679d919fdc6db58cff648f2b14b33a729f780fc02e75a42a008", "policies": [{"anyKey": "anyValue"}], "allowed_idps": ["allowed_idps"], "auto_redirect_to_identity": false, "session_duration": "24h", "type": "self_hosted", "uid": "de4526d6-d125-4f95-906f-1757510a9cd8", "created_at": "2021-04-19T07:59:49Z", "updated_at": "2021-04-19T07:59:49Z"}}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + zone_id = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "zone_id": zone_id, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.create_access_application(**req_copy) + + def test_create_access_application_value_error_with_retries(self): + # Enable retries and run test_create_access_application_value_error. + _service.enable_retries() + self.test_create_access_application_value_error() + + # Disable retries and run test_create_access_application_value_error. + _service.disable_retries() + self.test_create_access_application_value_error() + + +class TestGetAccessApplication: + """ + Test Class for get_access_application + """ + + @responses.activate + def test_get_access_application_all_params(self): + """ + get_access_application() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/access/apps/testString') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"id": "de4526d6-d125-4f95-906f-1757510a9cd8", "name": "mtls-test-app", "domain": "test.example.com", "aud": "f8e1744453ea3679d919fdc6db58cff648f2b14b33a729f780fc02e75a42a008", "policies": [{"id": "acabcdb1-afb3-4f61-9dae-d1a353a93661", "name": "mtls-test-policy", "decision": "non_identity", "include": [{"certificate": {"anyKey": "anyValue"}}], "exclude": [{"certificate": {"anyKey": "anyValue"}}], "precedence": 1, "require": [{"certificate": {"anyKey": "anyValue"}}], "uid": "acabcdb1-afb3-4f61-9dae-d1a353a93661", "created_at": "2021-04-19T08:01:21Z", "updated_at": "2021-04-19T08:01:21Z"}], "allowed_idps": ["699d98642c564d2e855e9661899b7252"], "auto_redirect_to_identity": false, "session_duration": "24h", "type": "self_hosted", "uid": "de4526d6-d125-4f95-906f-1757510a9cd8", "created_at": "2021-04-19T07:59:49Z", "updated_at": "2021-04-19T07:59:49Z"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + zone_id = 'testString' + app_id = 'testString' + + # Invoke method + response = _service.get_access_application( + zone_id, + app_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_get_access_application_all_params_with_retries(self): + # Enable retries and run test_get_access_application_all_params. + _service.enable_retries() + self.test_get_access_application_all_params() + + # Disable retries and run test_get_access_application_all_params. + _service.disable_retries() + self.test_get_access_application_all_params() + + @responses.activate + def test_get_access_application_value_error(self): + """ + test_get_access_application_value_error() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/access/apps/testString') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"id": "de4526d6-d125-4f95-906f-1757510a9cd8", "name": "mtls-test-app", "domain": "test.example.com", "aud": "f8e1744453ea3679d919fdc6db58cff648f2b14b33a729f780fc02e75a42a008", "policies": [{"id": "acabcdb1-afb3-4f61-9dae-d1a353a93661", "name": "mtls-test-policy", "decision": "non_identity", "include": [{"certificate": {"anyKey": "anyValue"}}], "exclude": [{"certificate": {"anyKey": "anyValue"}}], "precedence": 1, "require": [{"certificate": {"anyKey": "anyValue"}}], "uid": "acabcdb1-afb3-4f61-9dae-d1a353a93661", "created_at": "2021-04-19T08:01:21Z", "updated_at": "2021-04-19T08:01:21Z"}], "allowed_idps": ["699d98642c564d2e855e9661899b7252"], "auto_redirect_to_identity": false, "session_duration": "24h", "type": "self_hosted", "uid": "de4526d6-d125-4f95-906f-1757510a9cd8", "created_at": "2021-04-19T07:59:49Z", "updated_at": "2021-04-19T07:59:49Z"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + zone_id = 'testString' + app_id = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "zone_id": zone_id, + "app_id": app_id, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.get_access_application(**req_copy) + + def test_get_access_application_value_error_with_retries(self): + # Enable retries and run test_get_access_application_value_error. + _service.enable_retries() + self.test_get_access_application_value_error() + + # Disable retries and run test_get_access_application_value_error. + _service.disable_retries() + self.test_get_access_application_value_error() + + +class TestUpdateAccessApplication: + """ + Test Class for update_access_application + """ + + @responses.activate + def test_update_access_application_all_params(self): + """ + update_access_application() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/access/apps/testString') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"id": "de4526d6-d125-4f95-906f-1757510a9cd8", "name": "mtls-test-app", "domain": "test.example.com", "aud": "f8e1744453ea3679d919fdc6db58cff648f2b14b33a729f780fc02e75a42a008", "policies": [{"id": "acabcdb1-afb3-4f61-9dae-d1a353a93661", "name": "mtls-test-policy", "decision": "non_identity", "include": [{"certificate": {"anyKey": "anyValue"}}], "exclude": [{"certificate": {"anyKey": "anyValue"}}], "precedence": 1, "require": [{"certificate": {"anyKey": "anyValue"}}], "uid": "acabcdb1-afb3-4f61-9dae-d1a353a93661", "created_at": "2021-04-19T08:01:21Z", "updated_at": "2021-04-19T08:01:21Z"}], "allowed_idps": ["699d98642c564d2e855e9661899b7252"], "auto_redirect_to_identity": false, "session_duration": "24h", "type": "self_hosted", "uid": "de4526d6-d125-4f95-906f-1757510a9cd8", "created_at": "2021-04-19T07:59:49Z", "updated_at": "2021-04-19T07:59:49Z"}}' + responses.add( + responses.PUT, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + zone_id = 'testString' + app_id = 'testString' + name = 'mtls-test-app' + domain = 'test.example.com' + session_duration = '24h' + + # Invoke method + response = _service.update_access_application( + zone_id, + app_id, + name=name, + domain=domain, + session_duration=session_duration, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['name'] == 'mtls-test-app' + assert req_body['domain'] == 'test.example.com' + assert req_body['session_duration'] == '24h' + + def test_update_access_application_all_params_with_retries(self): + # Enable retries and run test_update_access_application_all_params. + _service.enable_retries() + self.test_update_access_application_all_params() + + # Disable retries and run test_update_access_application_all_params. + _service.disable_retries() + self.test_update_access_application_all_params() + + @responses.activate + def test_update_access_application_required_params(self): + """ + test_update_access_application_required_params() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/access/apps/testString') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"id": "de4526d6-d125-4f95-906f-1757510a9cd8", "name": "mtls-test-app", "domain": "test.example.com", "aud": "f8e1744453ea3679d919fdc6db58cff648f2b14b33a729f780fc02e75a42a008", "policies": [{"id": "acabcdb1-afb3-4f61-9dae-d1a353a93661", "name": "mtls-test-policy", "decision": "non_identity", "include": [{"certificate": {"anyKey": "anyValue"}}], "exclude": [{"certificate": {"anyKey": "anyValue"}}], "precedence": 1, "require": [{"certificate": {"anyKey": "anyValue"}}], "uid": "acabcdb1-afb3-4f61-9dae-d1a353a93661", "created_at": "2021-04-19T08:01:21Z", "updated_at": "2021-04-19T08:01:21Z"}], "allowed_idps": ["699d98642c564d2e855e9661899b7252"], "auto_redirect_to_identity": false, "session_duration": "24h", "type": "self_hosted", "uid": "de4526d6-d125-4f95-906f-1757510a9cd8", "created_at": "2021-04-19T07:59:49Z", "updated_at": "2021-04-19T07:59:49Z"}}' + responses.add( + responses.PUT, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + zone_id = 'testString' + app_id = 'testString' + + # Invoke method + response = _service.update_access_application( + zone_id, + app_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_update_access_application_required_params_with_retries(self): + # Enable retries and run test_update_access_application_required_params. + _service.enable_retries() + self.test_update_access_application_required_params() + + # Disable retries and run test_update_access_application_required_params. + _service.disable_retries() + self.test_update_access_application_required_params() + + @responses.activate + def test_update_access_application_value_error(self): + """ + test_update_access_application_value_error() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/access/apps/testString') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"id": "de4526d6-d125-4f95-906f-1757510a9cd8", "name": "mtls-test-app", "domain": "test.example.com", "aud": "f8e1744453ea3679d919fdc6db58cff648f2b14b33a729f780fc02e75a42a008", "policies": [{"id": "acabcdb1-afb3-4f61-9dae-d1a353a93661", "name": "mtls-test-policy", "decision": "non_identity", "include": [{"certificate": {"anyKey": "anyValue"}}], "exclude": [{"certificate": {"anyKey": "anyValue"}}], "precedence": 1, "require": [{"certificate": {"anyKey": "anyValue"}}], "uid": "acabcdb1-afb3-4f61-9dae-d1a353a93661", "created_at": "2021-04-19T08:01:21Z", "updated_at": "2021-04-19T08:01:21Z"}], "allowed_idps": ["699d98642c564d2e855e9661899b7252"], "auto_redirect_to_identity": false, "session_duration": "24h", "type": "self_hosted", "uid": "de4526d6-d125-4f95-906f-1757510a9cd8", "created_at": "2021-04-19T07:59:49Z", "updated_at": "2021-04-19T07:59:49Z"}}' + responses.add( + responses.PUT, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + zone_id = 'testString' + app_id = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "zone_id": zone_id, + "app_id": app_id, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.update_access_application(**req_copy) + + def test_update_access_application_value_error_with_retries(self): + # Enable retries and run test_update_access_application_value_error. + _service.enable_retries() + self.test_update_access_application_value_error() + + # Disable retries and run test_update_access_application_value_error. + _service.disable_retries() + self.test_update_access_application_value_error() + + +class TestDeleteAccessApplication: + """ + Test Class for delete_access_application + """ + + @responses.activate + def test_delete_access_application_all_params(self): + """ + delete_access_application() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/access/apps/testString') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"id": "de4526d6-d125-4f95-906f-1757510a9cd8"}}' + responses.add( + responses.DELETE, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + zone_id = 'testString' + app_id = 'testString' + + # Invoke method + response = _service.delete_access_application( + zone_id, + app_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_delete_access_application_all_params_with_retries(self): + # Enable retries and run test_delete_access_application_all_params. + _service.enable_retries() + self.test_delete_access_application_all_params() + + # Disable retries and run test_delete_access_application_all_params. + _service.disable_retries() + self.test_delete_access_application_all_params() + + @responses.activate + def test_delete_access_application_value_error(self): + """ + test_delete_access_application_value_error() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/access/apps/testString') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"id": "de4526d6-d125-4f95-906f-1757510a9cd8"}}' + responses.add( + responses.DELETE, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + zone_id = 'testString' + app_id = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "zone_id": zone_id, + "app_id": app_id, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.delete_access_application(**req_copy) + + def test_delete_access_application_value_error_with_retries(self): + # Enable retries and run test_delete_access_application_value_error. + _service.enable_retries() + self.test_delete_access_application_value_error() + + # Disable retries and run test_delete_access_application_value_error. + _service.disable_retries() + self.test_delete_access_application_value_error() + + +class TestListAccessPolicies: + """ + Test Class for list_access_policies + """ + + @responses.activate + def test_list_access_policies_all_params(self): + """ + list_access_policies() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/access/apps/testString/policies') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": [{"id": "acabcdb1-afb3-4f61-9dae-d1a353a93661", "name": "mtls-test-policy", "decision": "non_identity", "include": [{"certificate": {"anyKey": "anyValue"}}], "exclude": [{"certificate": {"anyKey": "anyValue"}}], "precedence": 1, "require": [{"certificate": {"anyKey": "anyValue"}}], "uid": "acabcdb1-afb3-4f61-9dae-d1a353a93661", "created_at": "2021-04-19T08:01:21Z", "updated_at": "2021-04-19T08:01:21Z"}]}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + zone_id = 'testString' + app_id = 'testString' + + # Invoke method + response = _service.list_access_policies( + zone_id, + app_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_list_access_policies_all_params_with_retries(self): + # Enable retries and run test_list_access_policies_all_params. + _service.enable_retries() + self.test_list_access_policies_all_params() + + # Disable retries and run test_list_access_policies_all_params. + _service.disable_retries() + self.test_list_access_policies_all_params() + + @responses.activate + def test_list_access_policies_value_error(self): + """ + test_list_access_policies_value_error() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/access/apps/testString/policies') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": [{"id": "acabcdb1-afb3-4f61-9dae-d1a353a93661", "name": "mtls-test-policy", "decision": "non_identity", "include": [{"certificate": {"anyKey": "anyValue"}}], "exclude": [{"certificate": {"anyKey": "anyValue"}}], "precedence": 1, "require": [{"certificate": {"anyKey": "anyValue"}}], "uid": "acabcdb1-afb3-4f61-9dae-d1a353a93661", "created_at": "2021-04-19T08:01:21Z", "updated_at": "2021-04-19T08:01:21Z"}]}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + zone_id = 'testString' + app_id = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "zone_id": zone_id, + "app_id": app_id, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.list_access_policies(**req_copy) + + def test_list_access_policies_value_error_with_retries(self): + # Enable retries and run test_list_access_policies_value_error. + _service.enable_retries() + self.test_list_access_policies_value_error() + + # Disable retries and run test_list_access_policies_value_error. + _service.disable_retries() + self.test_list_access_policies_value_error() + + +class TestCreateAccessPolicy: + """ + Test Class for create_access_policy + """ + + @responses.activate + def test_create_access_policy_all_params(self): + """ + create_access_policy() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/access/apps/testString/policies') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"id": "acabcdb1-afb3-4f61-9dae-d1a353a93661", "name": "mtls-test-policy", "decision": "non_identity", "include": [{"certificate": {"anyKey": "anyValue"}}], "exclude": [{"certificate": {"anyKey": "anyValue"}}], "precedence": 1, "require": [{"certificate": {"anyKey": "anyValue"}}], "uid": "acabcdb1-afb3-4f61-9dae-d1a353a93661", "created_at": "2021-04-19T08:01:21Z", "updated_at": "2021-04-19T08:01:21Z"}}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Construct a dict representation of a PolicyRulePolicyCertRule model + policy_rule_model = {} + policy_rule_model['certificate'] = {} + + # Set up parameter values + zone_id = 'testString' + app_id = 'testString' + name = 'mtls-test-policy' + decision = 'non_identity' + include = [policy_rule_model] + + # Invoke method + response = _service.create_access_policy( + zone_id, + app_id, + name=name, + decision=decision, + include=include, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['name'] == 'mtls-test-policy' + assert req_body['decision'] == 'non_identity' + assert req_body['include'] == [policy_rule_model] + + def test_create_access_policy_all_params_with_retries(self): + # Enable retries and run test_create_access_policy_all_params. + _service.enable_retries() + self.test_create_access_policy_all_params() + + # Disable retries and run test_create_access_policy_all_params. + _service.disable_retries() + self.test_create_access_policy_all_params() + + @responses.activate + def test_create_access_policy_required_params(self): + """ + test_create_access_policy_required_params() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/access/apps/testString/policies') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"id": "acabcdb1-afb3-4f61-9dae-d1a353a93661", "name": "mtls-test-policy", "decision": "non_identity", "include": [{"certificate": {"anyKey": "anyValue"}}], "exclude": [{"certificate": {"anyKey": "anyValue"}}], "precedence": 1, "require": [{"certificate": {"anyKey": "anyValue"}}], "uid": "acabcdb1-afb3-4f61-9dae-d1a353a93661", "created_at": "2021-04-19T08:01:21Z", "updated_at": "2021-04-19T08:01:21Z"}}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + zone_id = 'testString' + app_id = 'testString' + + # Invoke method + response = _service.create_access_policy( + zone_id, + app_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_create_access_policy_required_params_with_retries(self): + # Enable retries and run test_create_access_policy_required_params. + _service.enable_retries() + self.test_create_access_policy_required_params() + + # Disable retries and run test_create_access_policy_required_params. + _service.disable_retries() + self.test_create_access_policy_required_params() + + @responses.activate + def test_create_access_policy_value_error(self): + """ + test_create_access_policy_value_error() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/access/apps/testString/policies') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"id": "acabcdb1-afb3-4f61-9dae-d1a353a93661", "name": "mtls-test-policy", "decision": "non_identity", "include": [{"certificate": {"anyKey": "anyValue"}}], "exclude": [{"certificate": {"anyKey": "anyValue"}}], "precedence": 1, "require": [{"certificate": {"anyKey": "anyValue"}}], "uid": "acabcdb1-afb3-4f61-9dae-d1a353a93661", "created_at": "2021-04-19T08:01:21Z", "updated_at": "2021-04-19T08:01:21Z"}}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + zone_id = 'testString' + app_id = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "zone_id": zone_id, + "app_id": app_id, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.create_access_policy(**req_copy) + + def test_create_access_policy_value_error_with_retries(self): + # Enable retries and run test_create_access_policy_value_error. + _service.enable_retries() + self.test_create_access_policy_value_error() + + # Disable retries and run test_create_access_policy_value_error. + _service.disable_retries() + self.test_create_access_policy_value_error() + + +class TestGetAccessPolicy: + """ + Test Class for get_access_policy + """ + + @responses.activate + def test_get_access_policy_all_params(self): + """ + get_access_policy() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/access/apps/testString/policies/testString') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"id": "acabcdb1-afb3-4f61-9dae-d1a353a93661", "name": "mtls-test-policy", "decision": "non_identity", "include": [{"certificate": {"anyKey": "anyValue"}}], "exclude": [{"certificate": {"anyKey": "anyValue"}}], "precedence": 1, "require": [{"certificate": {"anyKey": "anyValue"}}], "uid": "acabcdb1-afb3-4f61-9dae-d1a353a93661", "created_at": "2021-04-19T08:01:21Z", "updated_at": "2021-04-19T08:01:21Z"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + zone_id = 'testString' + app_id = 'testString' + policy_id = 'testString' + + # Invoke method + response = _service.get_access_policy( + zone_id, + app_id, + policy_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_get_access_policy_all_params_with_retries(self): + # Enable retries and run test_get_access_policy_all_params. + _service.enable_retries() + self.test_get_access_policy_all_params() + + # Disable retries and run test_get_access_policy_all_params. + _service.disable_retries() + self.test_get_access_policy_all_params() + + @responses.activate + def test_get_access_policy_value_error(self): + """ + test_get_access_policy_value_error() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/access/apps/testString/policies/testString') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"id": "acabcdb1-afb3-4f61-9dae-d1a353a93661", "name": "mtls-test-policy", "decision": "non_identity", "include": [{"certificate": {"anyKey": "anyValue"}}], "exclude": [{"certificate": {"anyKey": "anyValue"}}], "precedence": 1, "require": [{"certificate": {"anyKey": "anyValue"}}], "uid": "acabcdb1-afb3-4f61-9dae-d1a353a93661", "created_at": "2021-04-19T08:01:21Z", "updated_at": "2021-04-19T08:01:21Z"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + zone_id = 'testString' + app_id = 'testString' + policy_id = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "zone_id": zone_id, + "app_id": app_id, + "policy_id": policy_id, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.get_access_policy(**req_copy) + + def test_get_access_policy_value_error_with_retries(self): + # Enable retries and run test_get_access_policy_value_error. + _service.enable_retries() + self.test_get_access_policy_value_error() + + # Disable retries and run test_get_access_policy_value_error. + _service.disable_retries() + self.test_get_access_policy_value_error() + + +class TestUpdateAccessPolicy: + """ + Test Class for update_access_policy + """ + + @responses.activate + def test_update_access_policy_all_params(self): + """ + update_access_policy() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/access/apps/testString/policies/testString') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"id": "acabcdb1-afb3-4f61-9dae-d1a353a93661", "name": "mtls-test-policy", "decision": "non_identity", "include": [{"certificate": {"anyKey": "anyValue"}}], "exclude": [{"certificate": {"anyKey": "anyValue"}}], "precedence": 1, "require": [{"certificate": {"anyKey": "anyValue"}}], "uid": "acabcdb1-afb3-4f61-9dae-d1a353a93661", "created_at": "2021-04-19T08:01:21Z", "updated_at": "2021-04-19T08:01:21Z"}}' + responses.add( + responses.PUT, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Construct a dict representation of a PolicyRulePolicyCertRule model + policy_rule_model = {} + policy_rule_model['certificate'] = {} + + # Set up parameter values + zone_id = 'testString' + app_id = 'testString' + policy_id = 'testString' + name = 'mtls-test-policy' + decision = 'non_identity' + include = [policy_rule_model] + + # Invoke method + response = _service.update_access_policy( + zone_id, + app_id, + policy_id, + name=name, + decision=decision, + include=include, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['name'] == 'mtls-test-policy' + assert req_body['decision'] == 'non_identity' + assert req_body['include'] == [policy_rule_model] + + def test_update_access_policy_all_params_with_retries(self): + # Enable retries and run test_update_access_policy_all_params. + _service.enable_retries() + self.test_update_access_policy_all_params() + + # Disable retries and run test_update_access_policy_all_params. + _service.disable_retries() + self.test_update_access_policy_all_params() + + @responses.activate + def test_update_access_policy_required_params(self): + """ + test_update_access_policy_required_params() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/access/apps/testString/policies/testString') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"id": "acabcdb1-afb3-4f61-9dae-d1a353a93661", "name": "mtls-test-policy", "decision": "non_identity", "include": [{"certificate": {"anyKey": "anyValue"}}], "exclude": [{"certificate": {"anyKey": "anyValue"}}], "precedence": 1, "require": [{"certificate": {"anyKey": "anyValue"}}], "uid": "acabcdb1-afb3-4f61-9dae-d1a353a93661", "created_at": "2021-04-19T08:01:21Z", "updated_at": "2021-04-19T08:01:21Z"}}' + responses.add( + responses.PUT, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + zone_id = 'testString' + app_id = 'testString' + policy_id = 'testString' + + # Invoke method + response = _service.update_access_policy( + zone_id, + app_id, + policy_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_update_access_policy_required_params_with_retries(self): + # Enable retries and run test_update_access_policy_required_params. + _service.enable_retries() + self.test_update_access_policy_required_params() + + # Disable retries and run test_update_access_policy_required_params. + _service.disable_retries() + self.test_update_access_policy_required_params() + + @responses.activate + def test_update_access_policy_value_error(self): + """ + test_update_access_policy_value_error() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/access/apps/testString/policies/testString') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"id": "acabcdb1-afb3-4f61-9dae-d1a353a93661", "name": "mtls-test-policy", "decision": "non_identity", "include": [{"certificate": {"anyKey": "anyValue"}}], "exclude": [{"certificate": {"anyKey": "anyValue"}}], "precedence": 1, "require": [{"certificate": {"anyKey": "anyValue"}}], "uid": "acabcdb1-afb3-4f61-9dae-d1a353a93661", "created_at": "2021-04-19T08:01:21Z", "updated_at": "2021-04-19T08:01:21Z"}}' + responses.add( + responses.PUT, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + zone_id = 'testString' + app_id = 'testString' + policy_id = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "zone_id": zone_id, + "app_id": app_id, + "policy_id": policy_id, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.update_access_policy(**req_copy) + + def test_update_access_policy_value_error_with_retries(self): + # Enable retries and run test_update_access_policy_value_error. + _service.enable_retries() + self.test_update_access_policy_value_error() + + # Disable retries and run test_update_access_policy_value_error. + _service.disable_retries() + self.test_update_access_policy_value_error() + + +class TestDeleteAccessPolicy: + """ + Test Class for delete_access_policy + """ + + @responses.activate + def test_delete_access_policy_all_params(self): + """ + delete_access_policy() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/access/apps/testString/policies/testString') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"id": "acabcdb1-afb3-4f61-9dae-d1a353a93661"}}' + responses.add( + responses.DELETE, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + zone_id = 'testString' + app_id = 'testString' + policy_id = 'testString' + + # Invoke method + response = _service.delete_access_policy( + zone_id, + app_id, + policy_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_delete_access_policy_all_params_with_retries(self): + # Enable retries and run test_delete_access_policy_all_params. + _service.enable_retries() + self.test_delete_access_policy_all_params() + + # Disable retries and run test_delete_access_policy_all_params. + _service.disable_retries() + self.test_delete_access_policy_all_params() + + @responses.activate + def test_delete_access_policy_value_error(self): + """ + test_delete_access_policy_value_error() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/access/apps/testString/policies/testString') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"id": "acabcdb1-afb3-4f61-9dae-d1a353a93661"}}' + responses.add( + responses.DELETE, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + zone_id = 'testString' + app_id = 'testString' + policy_id = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "zone_id": zone_id, + "app_id": app_id, + "policy_id": policy_id, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.delete_access_policy(**req_copy) + + def test_delete_access_policy_value_error_with_retries(self): + # Enable retries and run test_delete_access_policy_value_error. + _service.enable_retries() + self.test_delete_access_policy_value_error() + + # Disable retries and run test_delete_access_policy_value_error. + _service.disable_retries() + self.test_delete_access_policy_value_error() + + +class TestGetAccessCertSettings: + """ + Test Class for get_access_cert_settings + """ + + @responses.activate + def test_get_access_cert_settings_all_params(self): + """ + get_access_cert_settings() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/access/certificates/settings') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": [{"hostname": "test.example.com", "china_network": false, "client_certificate_forwarding": true}]}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + zone_id = 'testString' + + # Invoke method + response = _service.get_access_cert_settings( + zone_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_get_access_cert_settings_all_params_with_retries(self): + # Enable retries and run test_get_access_cert_settings_all_params. + _service.enable_retries() + self.test_get_access_cert_settings_all_params() + + # Disable retries and run test_get_access_cert_settings_all_params. + _service.disable_retries() + self.test_get_access_cert_settings_all_params() + + @responses.activate + def test_get_access_cert_settings_value_error(self): + """ + test_get_access_cert_settings_value_error() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/access/certificates/settings') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": [{"hostname": "test.example.com", "china_network": false, "client_certificate_forwarding": true}]}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + zone_id = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "zone_id": zone_id, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.get_access_cert_settings(**req_copy) + + def test_get_access_cert_settings_value_error_with_retries(self): + # Enable retries and run test_get_access_cert_settings_value_error. + _service.enable_retries() + self.test_get_access_cert_settings_value_error() + + # Disable retries and run test_get_access_cert_settings_value_error. + _service.disable_retries() + self.test_get_access_cert_settings_value_error() + + +class TestUpdateAccessCertSettings: + """ + Test Class for update_access_cert_settings + """ + + @responses.activate + def test_update_access_cert_settings_all_params(self): + """ + update_access_cert_settings() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/access/certificates/settings') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": [{"hostname": "test.example.com", "china_network": false, "client_certificate_forwarding": true}]}' + responses.add( + responses.PUT, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Construct a dict representation of a AccessCertSettingsInputArray model + access_cert_settings_input_array_model = {} + access_cert_settings_input_array_model['hostname'] = 'test.example.com' + access_cert_settings_input_array_model['client_certificate_forwarding'] = True + + # Set up parameter values + zone_id = 'testString' + settings = [access_cert_settings_input_array_model] + + # Invoke method + response = _service.update_access_cert_settings( + zone_id, + settings=settings, + 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['settings'] == [access_cert_settings_input_array_model] + + def test_update_access_cert_settings_all_params_with_retries(self): + # Enable retries and run test_update_access_cert_settings_all_params. + _service.enable_retries() + self.test_update_access_cert_settings_all_params() + + # Disable retries and run test_update_access_cert_settings_all_params. + _service.disable_retries() + self.test_update_access_cert_settings_all_params() + + @responses.activate + def test_update_access_cert_settings_required_params(self): + """ + test_update_access_cert_settings_required_params() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/access/certificates/settings') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": [{"hostname": "test.example.com", "china_network": false, "client_certificate_forwarding": true}]}' + responses.add( + responses.PUT, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + zone_id = 'testString' + + # Invoke method + response = _service.update_access_cert_settings( + zone_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_update_access_cert_settings_required_params_with_retries(self): + # Enable retries and run test_update_access_cert_settings_required_params. + _service.enable_retries() + self.test_update_access_cert_settings_required_params() + + # Disable retries and run test_update_access_cert_settings_required_params. + _service.disable_retries() + self.test_update_access_cert_settings_required_params() + + @responses.activate + def test_update_access_cert_settings_value_error(self): + """ + test_update_access_cert_settings_value_error() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/access/certificates/settings') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": [{"hostname": "test.example.com", "china_network": false, "client_certificate_forwarding": true}]}' + responses.add( + responses.PUT, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + zone_id = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "zone_id": zone_id, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.update_access_cert_settings(**req_copy) + + def test_update_access_cert_settings_value_error_with_retries(self): + # Enable retries and run test_update_access_cert_settings_value_error. + _service.enable_retries() + self.test_update_access_cert_settings_value_error() + + # Disable retries and run test_update_access_cert_settings_value_error. + _service.disable_retries() + self.test_update_access_cert_settings_value_error() + + +class TestCreateAccessOrganization: + """ + Test Class for create_access_organization + """ + + @responses.activate + def test_create_access_organization_all_params(self): + """ + create_access_organization() + """ + # Set up mock + url = preprocess_url('/v1/testString/access/organizations') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"auth_domain": "01652b251c3ae2787110a995d8db0135.cloudflareaccess.com", "name": "MTLS enabled", "login_design": {"anyKey": "anyValue"}, "created_at": "2019-08-13T16:31:42Z", "updated_at": "2019-08-13T16:31:42Z"}}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + name = 'MTLS enabled' + auth_domain = '01652b251c3ae2787110a995d8db0135.cloudflareaccess.com' + + # Invoke method + response = _service.create_access_organization( + name=name, + auth_domain=auth_domain, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['name'] == 'MTLS enabled' + assert req_body['auth_domain'] == '01652b251c3ae2787110a995d8db0135.cloudflareaccess.com' + + def test_create_access_organization_all_params_with_retries(self): + # Enable retries and run test_create_access_organization_all_params. + _service.enable_retries() + self.test_create_access_organization_all_params() + + # Disable retries and run test_create_access_organization_all_params. + _service.disable_retries() + self.test_create_access_organization_all_params() + + @responses.activate + def test_create_access_organization_required_params(self): + """ + test_create_access_organization_required_params() + """ + # Set up mock + url = preprocess_url('/v1/testString/access/organizations') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"auth_domain": "01652b251c3ae2787110a995d8db0135.cloudflareaccess.com", "name": "MTLS enabled", "login_design": {"anyKey": "anyValue"}, "created_at": "2019-08-13T16:31:42Z", "updated_at": "2019-08-13T16:31:42Z"}}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Invoke method + response = _service.create_access_organization() + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_create_access_organization_required_params_with_retries(self): + # Enable retries and run test_create_access_organization_required_params. + _service.enable_retries() + self.test_create_access_organization_required_params() + + # Disable retries and run test_create_access_organization_required_params. + _service.disable_retries() + self.test_create_access_organization_required_params() + + @responses.activate + def test_create_access_organization_value_error(self): + """ + test_create_access_organization_value_error() + """ + # Set up mock + url = preprocess_url('/v1/testString/access/organizations') + mock_response = '{"success": true, "errors": [["errors"]], "messages": [["messages"]], "result": {"auth_domain": "01652b251c3ae2787110a995d8db0135.cloudflareaccess.com", "name": "MTLS enabled", "login_design": {"anyKey": "anyValue"}, "created_at": "2019-08-13T16:31:42Z", "updated_at": "2019-08-13T16:31:42Z"}}' + 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_access_organization(**req_copy) + + def test_create_access_organization_value_error_with_retries(self): + # Enable retries and run test_create_access_organization_value_error. + _service.enable_retries() + self.test_create_access_organization_value_error() + + # Disable retries and run test_create_access_organization_value_error. + _service.disable_retries() + self.test_create_access_organization_value_error() + + +# endregion +############################################################################## +# End of Service: MutualTLS +############################################################################## + + +############################################################################## +# Start of Model Tests +############################################################################## +# region + + +class TestModel_AccessOrgRespResult: + """ + Test Class for AccessOrgRespResult + """ + + def test_access_org_resp_result_serialization(self): + """ + Test serialization/deserialization for AccessOrgRespResult + """ + + # Construct a json representation of a AccessOrgRespResult model + access_org_resp_result_model_json = {} + access_org_resp_result_model_json['auth_domain'] = '01652b251c3ae2787110a995d8db0135.cloudflareaccess.com' + access_org_resp_result_model_json['name'] = 'MTLS enabled' + access_org_resp_result_model_json['login_design'] = {} + access_org_resp_result_model_json['created_at'] = '2019-08-13T16:31:42Z' + access_org_resp_result_model_json['updated_at'] = '2019-08-13T16:31:42Z' + + # Construct a model instance of AccessOrgRespResult by calling from_dict on the json representation + access_org_resp_result_model = AccessOrgRespResult.from_dict(access_org_resp_result_model_json) + assert access_org_resp_result_model != False + + # Construct a model instance of AccessOrgRespResult by calling from_dict on the json representation + access_org_resp_result_model_dict = AccessOrgRespResult.from_dict(access_org_resp_result_model_json).__dict__ + access_org_resp_result_model2 = AccessOrgRespResult(**access_org_resp_result_model_dict) + + # Verify the model instances are equivalent + assert access_org_resp_result_model == access_org_resp_result_model2 + + # Convert model instance back to dict and verify no loss of data + access_org_resp_result_model_json2 = access_org_resp_result_model.to_dict() + assert access_org_resp_result_model_json2 == access_org_resp_result_model_json + + +class TestModel_CreateAccessAppRespResult: + """ + Test Class for CreateAccessAppRespResult + """ + + def test_create_access_app_resp_result_serialization(self): + """ + Test serialization/deserialization for CreateAccessAppRespResult + """ + + # Construct a json representation of a CreateAccessAppRespResult model + create_access_app_resp_result_model_json = {} + create_access_app_resp_result_model_json['id'] = 'de4526d6-d125-4f95-906f-1757510a9cd8' + create_access_app_resp_result_model_json['name'] = 'mtls-test-app' + create_access_app_resp_result_model_json['domain'] = 'test.example.com' + create_access_app_resp_result_model_json['aud'] = 'f8e1744453ea3679d919fdc6db58cff648f2b14b33a729f780fc02e75a42a008' + create_access_app_resp_result_model_json['policies'] = [] + create_access_app_resp_result_model_json['allowed_idps'] = [] + create_access_app_resp_result_model_json['auto_redirect_to_identity'] = False + create_access_app_resp_result_model_json['session_duration'] = '24h' + create_access_app_resp_result_model_json['type'] = 'self_hosted' + create_access_app_resp_result_model_json['uid'] = 'de4526d6-d125-4f95-906f-1757510a9cd8' + create_access_app_resp_result_model_json['created_at'] = '2021-04-19T07:59:49Z' + create_access_app_resp_result_model_json['updated_at'] = '2021-04-19T07:59:49Z' + + # Construct a model instance of CreateAccessAppRespResult by calling from_dict on the json representation + create_access_app_resp_result_model = CreateAccessAppRespResult.from_dict(create_access_app_resp_result_model_json) + assert create_access_app_resp_result_model != False + + # Construct a model instance of CreateAccessAppRespResult by calling from_dict on the json representation + create_access_app_resp_result_model_dict = CreateAccessAppRespResult.from_dict(create_access_app_resp_result_model_json).__dict__ + create_access_app_resp_result_model2 = CreateAccessAppRespResult(**create_access_app_resp_result_model_dict) + + # Verify the model instances are equivalent + assert create_access_app_resp_result_model == create_access_app_resp_result_model2 + + # Convert model instance back to dict and verify no loss of data + create_access_app_resp_result_model_json2 = create_access_app_resp_result_model.to_dict() + assert create_access_app_resp_result_model_json2 == create_access_app_resp_result_model_json + + +class TestModel_DeleteAccessAppRespResult: + """ + Test Class for DeleteAccessAppRespResult + """ + + def test_delete_access_app_resp_result_serialization(self): + """ + Test serialization/deserialization for DeleteAccessAppRespResult + """ + + # Construct a json representation of a DeleteAccessAppRespResult model + delete_access_app_resp_result_model_json = {} + delete_access_app_resp_result_model_json['id'] = 'de4526d6-d125-4f95-906f-1757510a9cd8' + + # Construct a model instance of DeleteAccessAppRespResult by calling from_dict on the json representation + delete_access_app_resp_result_model = DeleteAccessAppRespResult.from_dict(delete_access_app_resp_result_model_json) + assert delete_access_app_resp_result_model != False + + # Construct a model instance of DeleteAccessAppRespResult by calling from_dict on the json representation + delete_access_app_resp_result_model_dict = DeleteAccessAppRespResult.from_dict(delete_access_app_resp_result_model_json).__dict__ + delete_access_app_resp_result_model2 = DeleteAccessAppRespResult(**delete_access_app_resp_result_model_dict) + + # Verify the model instances are equivalent + assert delete_access_app_resp_result_model == delete_access_app_resp_result_model2 + + # Convert model instance back to dict and verify no loss of data + delete_access_app_resp_result_model_json2 = delete_access_app_resp_result_model.to_dict() + assert delete_access_app_resp_result_model_json2 == delete_access_app_resp_result_model_json + + +class TestModel_DeleteAccessCertRespResult: + """ + Test Class for DeleteAccessCertRespResult + """ + + def test_delete_access_cert_resp_result_serialization(self): + """ + Test serialization/deserialization for DeleteAccessCertRespResult + """ + + # Construct a json representation of a DeleteAccessCertRespResult model + delete_access_cert_resp_result_model_json = {} + delete_access_cert_resp_result_model_json['id'] = '21a41336-9001-42c4-8440-c79e0cb86e1f' + + # Construct a model instance of DeleteAccessCertRespResult by calling from_dict on the json representation + delete_access_cert_resp_result_model = DeleteAccessCertRespResult.from_dict(delete_access_cert_resp_result_model_json) + assert delete_access_cert_resp_result_model != False + + # Construct a model instance of DeleteAccessCertRespResult by calling from_dict on the json representation + delete_access_cert_resp_result_model_dict = DeleteAccessCertRespResult.from_dict(delete_access_cert_resp_result_model_json).__dict__ + delete_access_cert_resp_result_model2 = DeleteAccessCertRespResult(**delete_access_cert_resp_result_model_dict) + + # Verify the model instances are equivalent + assert delete_access_cert_resp_result_model == delete_access_cert_resp_result_model2 + + # Convert model instance back to dict and verify no loss of data + delete_access_cert_resp_result_model_json2 = delete_access_cert_resp_result_model.to_dict() + assert delete_access_cert_resp_result_model_json2 == delete_access_cert_resp_result_model_json + + +class TestModel_DeleteAccessPolicyRespResult: + """ + Test Class for DeleteAccessPolicyRespResult + """ + + def test_delete_access_policy_resp_result_serialization(self): + """ + Test serialization/deserialization for DeleteAccessPolicyRespResult + """ + + # Construct a json representation of a DeleteAccessPolicyRespResult model + delete_access_policy_resp_result_model_json = {} + delete_access_policy_resp_result_model_json['id'] = 'acabcdb1-afb3-4f61-9dae-d1a353a93661' + + # Construct a model instance of DeleteAccessPolicyRespResult by calling from_dict on the json representation + delete_access_policy_resp_result_model = DeleteAccessPolicyRespResult.from_dict(delete_access_policy_resp_result_model_json) + assert delete_access_policy_resp_result_model != False + + # Construct a model instance of DeleteAccessPolicyRespResult by calling from_dict on the json representation + delete_access_policy_resp_result_model_dict = DeleteAccessPolicyRespResult.from_dict(delete_access_policy_resp_result_model_json).__dict__ + delete_access_policy_resp_result_model2 = DeleteAccessPolicyRespResult(**delete_access_policy_resp_result_model_dict) + + # Verify the model instances are equivalent + assert delete_access_policy_resp_result_model == delete_access_policy_resp_result_model2 + + # Convert model instance back to dict and verify no loss of data + delete_access_policy_resp_result_model_json2 = delete_access_policy_resp_result_model.to_dict() + assert delete_access_policy_resp_result_model_json2 == delete_access_policy_resp_result_model_json + + +class TestModel_PolicyCnRuleCommonName: + """ + Test Class for PolicyCnRuleCommonName + """ + + def test_policy_cn_rule_common_name_serialization(self): + """ + Test serialization/deserialization for PolicyCnRuleCommonName + """ + + # Construct a json representation of a PolicyCnRuleCommonName model + policy_cn_rule_common_name_model_json = {} + policy_cn_rule_common_name_model_json['common_name'] = 'Access Testing CA' + + # Construct a model instance of PolicyCnRuleCommonName by calling from_dict on the json representation + policy_cn_rule_common_name_model = PolicyCnRuleCommonName.from_dict(policy_cn_rule_common_name_model_json) + assert policy_cn_rule_common_name_model != False + + # Construct a model instance of PolicyCnRuleCommonName by calling from_dict on the json representation + policy_cn_rule_common_name_model_dict = PolicyCnRuleCommonName.from_dict(policy_cn_rule_common_name_model_json).__dict__ + policy_cn_rule_common_name_model2 = PolicyCnRuleCommonName(**policy_cn_rule_common_name_model_dict) + + # Verify the model instances are equivalent + assert policy_cn_rule_common_name_model == policy_cn_rule_common_name_model2 + + # Convert model instance back to dict and verify no loss of data + policy_cn_rule_common_name_model_json2 = policy_cn_rule_common_name_model.to_dict() + assert policy_cn_rule_common_name_model_json2 == policy_cn_rule_common_name_model_json + + +class TestModel_AccessAppResp: + """ + Test Class for AccessAppResp + """ + + def test_access_app_resp_serialization(self): + """ + Test serialization/deserialization for AccessAppResp + """ + + # Construct dict forms of any model objects needed in order to build this model. + + policy_rule_model = {} # PolicyRulePolicyCertRule + policy_rule_model['certificate'] = {} + + policy_result_model = {} # PolicyResult + policy_result_model['id'] = 'acabcdb1-afb3-4f61-9dae-d1a353a93661' + policy_result_model['name'] = 'mtls-test-policy' + policy_result_model['decision'] = 'non_identity' + policy_result_model['include'] = [policy_rule_model] + policy_result_model['exclude'] = [policy_rule_model] + policy_result_model['precedence'] = 1 + policy_result_model['require'] = [policy_rule_model] + policy_result_model['uid'] = 'acabcdb1-afb3-4f61-9dae-d1a353a93661' + policy_result_model['created_at'] = '2021-04-19T08:01:21Z' + policy_result_model['updated_at'] = '2021-04-19T08:01:21Z' + + app_result_model = {} # AppResult + app_result_model['id'] = 'de4526d6-d125-4f95-906f-1757510a9cd8' + app_result_model['name'] = 'mtls-test-app' + app_result_model['domain'] = 'test.example.com' + app_result_model['aud'] = 'f8e1744453ea3679d919fdc6db58cff648f2b14b33a729f780fc02e75a42a008' + app_result_model['policies'] = [policy_result_model] + app_result_model['allowed_idps'] = ['699d98642c564d2e855e9661899b7252'] + app_result_model['auto_redirect_to_identity'] = False + app_result_model['session_duration'] = '24h' + app_result_model['type'] = 'self_hosted' + app_result_model['uid'] = 'de4526d6-d125-4f95-906f-1757510a9cd8' + app_result_model['created_at'] = '2021-04-19T07:59:49Z' + app_result_model['updated_at'] = '2021-04-19T07:59:49Z' + + # Construct a json representation of a AccessAppResp model + access_app_resp_model_json = {} + access_app_resp_model_json['success'] = True + access_app_resp_model_json['errors'] = [] + access_app_resp_model_json['messages'] = [] + access_app_resp_model_json['result'] = app_result_model + + # Construct a model instance of AccessAppResp by calling from_dict on the json representation + access_app_resp_model = AccessAppResp.from_dict(access_app_resp_model_json) + assert access_app_resp_model != False + + # Construct a model instance of AccessAppResp by calling from_dict on the json representation + access_app_resp_model_dict = AccessAppResp.from_dict(access_app_resp_model_json).__dict__ + access_app_resp_model2 = AccessAppResp(**access_app_resp_model_dict) + + # Verify the model instances are equivalent + assert access_app_resp_model == access_app_resp_model2 + + # Convert model instance back to dict and verify no loss of data + access_app_resp_model_json2 = access_app_resp_model.to_dict() + assert access_app_resp_model_json2 == access_app_resp_model_json + + +class TestModel_AccessCertResp: + """ + Test Class for AccessCertResp + """ + + def test_access_cert_resp_serialization(self): + """ + Test serialization/deserialization for AccessCertResp + """ + + # Construct dict forms of any model objects needed in order to build this model. + + cert_result_model = {} # CertResult + cert_result_model['id'] = '21a41336-9001-42c4-8440-c79e0cb86e1f' + cert_result_model['name'] = 'test-cert' + cert_result_model['fingerprint'] = 'MD5 Fingerprint=38:38:B4:FB:3C:33:CE:2C:8E:8E:D1:1B:94:70:C1:5F' + cert_result_model['associated_hostnames'] = ['test.example.com'] + cert_result_model['created_at'] = '2021-04-19T11:09:11Z' + cert_result_model['updated_at'] = '2021-04-19T11:09:11Z' + cert_result_model['expires_on'] = '2026-04-18T06:26:00Z' + + # Construct a json representation of a AccessCertResp model + access_cert_resp_model_json = {} + access_cert_resp_model_json['success'] = True + access_cert_resp_model_json['errors'] = [] + access_cert_resp_model_json['messages'] = [] + access_cert_resp_model_json['result'] = cert_result_model + + # Construct a model instance of AccessCertResp by calling from_dict on the json representation + access_cert_resp_model = AccessCertResp.from_dict(access_cert_resp_model_json) + assert access_cert_resp_model != False + + # Construct a model instance of AccessCertResp by calling from_dict on the json representation + access_cert_resp_model_dict = AccessCertResp.from_dict(access_cert_resp_model_json).__dict__ + access_cert_resp_model2 = AccessCertResp(**access_cert_resp_model_dict) + + # Verify the model instances are equivalent + assert access_cert_resp_model == access_cert_resp_model2 + + # Convert model instance back to dict and verify no loss of data + access_cert_resp_model_json2 = access_cert_resp_model.to_dict() + assert access_cert_resp_model_json2 == access_cert_resp_model_json + + +class TestModel_AccessCertSettingsInputArray: + """ + Test Class for AccessCertSettingsInputArray + """ + + def test_access_cert_settings_input_array_serialization(self): + """ + Test serialization/deserialization for AccessCertSettingsInputArray + """ + + # Construct a json representation of a AccessCertSettingsInputArray model + access_cert_settings_input_array_model_json = {} + access_cert_settings_input_array_model_json['hostname'] = 'test.example.com' + access_cert_settings_input_array_model_json['client_certificate_forwarding'] = True + + # Construct a model instance of AccessCertSettingsInputArray by calling from_dict on the json representation + access_cert_settings_input_array_model = AccessCertSettingsInputArray.from_dict(access_cert_settings_input_array_model_json) + assert access_cert_settings_input_array_model != False + + # Construct a model instance of AccessCertSettingsInputArray by calling from_dict on the json representation + access_cert_settings_input_array_model_dict = AccessCertSettingsInputArray.from_dict(access_cert_settings_input_array_model_json).__dict__ + access_cert_settings_input_array_model2 = AccessCertSettingsInputArray(**access_cert_settings_input_array_model_dict) + + # Verify the model instances are equivalent + assert access_cert_settings_input_array_model == access_cert_settings_input_array_model2 + + # Convert model instance back to dict and verify no loss of data + access_cert_settings_input_array_model_json2 = access_cert_settings_input_array_model.to_dict() + assert access_cert_settings_input_array_model_json2 == access_cert_settings_input_array_model_json + + +class TestModel_AccessCertSettingsResp: + """ + Test Class for AccessCertSettingsResp + """ + + def test_access_cert_settings_resp_serialization(self): + """ + Test serialization/deserialization for AccessCertSettingsResp + """ + + # Construct dict forms of any model objects needed in order to build this model. + + cert_settings_result_model = {} # CertSettingsResult + cert_settings_result_model['hostname'] = 'test.example.com' + cert_settings_result_model['china_network'] = False + cert_settings_result_model['client_certificate_forwarding'] = True + + # Construct a json representation of a AccessCertSettingsResp model + access_cert_settings_resp_model_json = {} + access_cert_settings_resp_model_json['success'] = True + access_cert_settings_resp_model_json['errors'] = [] + access_cert_settings_resp_model_json['messages'] = [] + access_cert_settings_resp_model_json['result'] = [cert_settings_result_model] + + # Construct a model instance of AccessCertSettingsResp by calling from_dict on the json representation + access_cert_settings_resp_model = AccessCertSettingsResp.from_dict(access_cert_settings_resp_model_json) + assert access_cert_settings_resp_model != False + + # Construct a model instance of AccessCertSettingsResp by calling from_dict on the json representation + access_cert_settings_resp_model_dict = AccessCertSettingsResp.from_dict(access_cert_settings_resp_model_json).__dict__ + access_cert_settings_resp_model2 = AccessCertSettingsResp(**access_cert_settings_resp_model_dict) + + # Verify the model instances are equivalent + assert access_cert_settings_resp_model == access_cert_settings_resp_model2 + + # Convert model instance back to dict and verify no loss of data + access_cert_settings_resp_model_json2 = access_cert_settings_resp_model.to_dict() + assert access_cert_settings_resp_model_json2 == access_cert_settings_resp_model_json + + +class TestModel_AccessOrgResp: + """ + Test Class for AccessOrgResp + """ + + def test_access_org_resp_serialization(self): + """ + Test serialization/deserialization for AccessOrgResp + """ + + # Construct dict forms of any model objects needed in order to build this model. + + access_org_resp_result_model = {} # AccessOrgRespResult + access_org_resp_result_model['auth_domain'] = '01652b251c3ae2787110a995d8db0135.cloudflareaccess.com' + access_org_resp_result_model['name'] = 'MTLS enabled' + access_org_resp_result_model['login_design'] = {} + access_org_resp_result_model['created_at'] = '2019-08-13T16:31:42Z' + access_org_resp_result_model['updated_at'] = '2019-08-13T16:31:42Z' + + # Construct a json representation of a AccessOrgResp model + access_org_resp_model_json = {} + access_org_resp_model_json['success'] = True + access_org_resp_model_json['errors'] = [] + access_org_resp_model_json['messages'] = [] + access_org_resp_model_json['result'] = access_org_resp_result_model + + # Construct a model instance of AccessOrgResp by calling from_dict on the json representation + access_org_resp_model = AccessOrgResp.from_dict(access_org_resp_model_json) + assert access_org_resp_model != False + + # Construct a model instance of AccessOrgResp by calling from_dict on the json representation + access_org_resp_model_dict = AccessOrgResp.from_dict(access_org_resp_model_json).__dict__ + access_org_resp_model2 = AccessOrgResp(**access_org_resp_model_dict) + + # Verify the model instances are equivalent + assert access_org_resp_model == access_org_resp_model2 + + # Convert model instance back to dict and verify no loss of data + access_org_resp_model_json2 = access_org_resp_model.to_dict() + assert access_org_resp_model_json2 == access_org_resp_model_json + + +class TestModel_AccessPolicyResp: + """ + Test Class for AccessPolicyResp + """ + + def test_access_policy_resp_serialization(self): + """ + Test serialization/deserialization for AccessPolicyResp + """ + + # Construct dict forms of any model objects needed in order to build this model. + + policy_rule_model = {} # PolicyRulePolicyCertRule + policy_rule_model['certificate'] = {} + + policy_result_model = {} # PolicyResult + policy_result_model['id'] = 'acabcdb1-afb3-4f61-9dae-d1a353a93661' + policy_result_model['name'] = 'mtls-test-policy' + policy_result_model['decision'] = 'non_identity' + policy_result_model['include'] = [policy_rule_model] + policy_result_model['exclude'] = [policy_rule_model] + policy_result_model['precedence'] = 1 + policy_result_model['require'] = [policy_rule_model] + policy_result_model['uid'] = 'acabcdb1-afb3-4f61-9dae-d1a353a93661' + policy_result_model['created_at'] = '2021-04-19T08:01:21Z' + policy_result_model['updated_at'] = '2021-04-19T08:01:21Z' + + # Construct a json representation of a AccessPolicyResp model + access_policy_resp_model_json = {} + access_policy_resp_model_json['success'] = True + access_policy_resp_model_json['errors'] = [] + access_policy_resp_model_json['messages'] = [] + access_policy_resp_model_json['result'] = policy_result_model + + # Construct a model instance of AccessPolicyResp by calling from_dict on the json representation + access_policy_resp_model = AccessPolicyResp.from_dict(access_policy_resp_model_json) + assert access_policy_resp_model != False + + # Construct a model instance of AccessPolicyResp by calling from_dict on the json representation + access_policy_resp_model_dict = AccessPolicyResp.from_dict(access_policy_resp_model_json).__dict__ + access_policy_resp_model2 = AccessPolicyResp(**access_policy_resp_model_dict) + + # Verify the model instances are equivalent + assert access_policy_resp_model == access_policy_resp_model2 + + # Convert model instance back to dict and verify no loss of data + access_policy_resp_model_json2 = access_policy_resp_model.to_dict() + assert access_policy_resp_model_json2 == access_policy_resp_model_json + + +class TestModel_AppResult: + """ + Test Class for AppResult + """ + + def test_app_result_serialization(self): + """ + Test serialization/deserialization for AppResult + """ + + # Construct dict forms of any model objects needed in order to build this model. + + policy_rule_model = {} # PolicyRulePolicyCertRule + policy_rule_model['certificate'] = {} + + policy_result_model = {} # PolicyResult + policy_result_model['id'] = 'acabcdb1-afb3-4f61-9dae-d1a353a93661' + policy_result_model['name'] = 'mtls-test-policy' + policy_result_model['decision'] = 'non_identity' + policy_result_model['include'] = [policy_rule_model] + policy_result_model['exclude'] = [policy_rule_model] + policy_result_model['precedence'] = 1 + policy_result_model['require'] = [policy_rule_model] + policy_result_model['uid'] = 'acabcdb1-afb3-4f61-9dae-d1a353a93661' + policy_result_model['created_at'] = '2021-04-19T08:01:21Z' + policy_result_model['updated_at'] = '2021-04-19T08:01:21Z' + + # Construct a json representation of a AppResult model + app_result_model_json = {} + app_result_model_json['id'] = 'de4526d6-d125-4f95-906f-1757510a9cd8' + app_result_model_json['name'] = 'mtls-test-app' + app_result_model_json['domain'] = 'test.example.com' + app_result_model_json['aud'] = 'f8e1744453ea3679d919fdc6db58cff648f2b14b33a729f780fc02e75a42a008' + app_result_model_json['policies'] = [policy_result_model] + app_result_model_json['allowed_idps'] = ['699d98642c564d2e855e9661899b7252'] + app_result_model_json['auto_redirect_to_identity'] = False + app_result_model_json['session_duration'] = '24h' + app_result_model_json['type'] = 'self_hosted' + app_result_model_json['uid'] = 'de4526d6-d125-4f95-906f-1757510a9cd8' + app_result_model_json['created_at'] = '2021-04-19T07:59:49Z' + app_result_model_json['updated_at'] = '2021-04-19T07:59:49Z' + + # Construct a model instance of AppResult by calling from_dict on the json representation + app_result_model = AppResult.from_dict(app_result_model_json) + assert app_result_model != False + + # Construct a model instance of AppResult by calling from_dict on the json representation + app_result_model_dict = AppResult.from_dict(app_result_model_json).__dict__ + app_result_model2 = AppResult(**app_result_model_dict) + + # Verify the model instances are equivalent + assert app_result_model == app_result_model2 + + # Convert model instance back to dict and verify no loss of data + app_result_model_json2 = app_result_model.to_dict() + assert app_result_model_json2 == app_result_model_json + + +class TestModel_CertResult: + """ + Test Class for CertResult + """ + + def test_cert_result_serialization(self): + """ + Test serialization/deserialization for CertResult + """ + + # Construct a json representation of a CertResult model + cert_result_model_json = {} + cert_result_model_json['id'] = '21a41336-9001-42c4-8440-c79e0cb86e1f' + cert_result_model_json['name'] = 'test-cert' + cert_result_model_json['fingerprint'] = 'MD5 Fingerprint=38:38:B4:FB:3C:33:CE:2C:8E:8E:D1:1B:94:70:C1:5F' + cert_result_model_json['associated_hostnames'] = ['test.example.com'] + cert_result_model_json['created_at'] = '2021-04-19T11:09:11Z' + cert_result_model_json['updated_at'] = '2021-04-19T11:09:11Z' + cert_result_model_json['expires_on'] = '2026-04-18T06:26:00Z' + + # Construct a model instance of CertResult by calling from_dict on the json representation + cert_result_model = CertResult.from_dict(cert_result_model_json) + assert cert_result_model != False + + # Construct a model instance of CertResult by calling from_dict on the json representation + cert_result_model_dict = CertResult.from_dict(cert_result_model_json).__dict__ + cert_result_model2 = CertResult(**cert_result_model_dict) + + # Verify the model instances are equivalent + assert cert_result_model == cert_result_model2 + + # Convert model instance back to dict and verify no loss of data + cert_result_model_json2 = cert_result_model.to_dict() + assert cert_result_model_json2 == cert_result_model_json + + +class TestModel_CertSettingsResult: + """ + Test Class for CertSettingsResult + """ + + def test_cert_settings_result_serialization(self): + """ + Test serialization/deserialization for CertSettingsResult + """ + + # Construct a json representation of a CertSettingsResult model + cert_settings_result_model_json = {} + cert_settings_result_model_json['hostname'] = 'test.example.com' + cert_settings_result_model_json['china_network'] = False + cert_settings_result_model_json['client_certificate_forwarding'] = True + + # Construct a model instance of CertSettingsResult by calling from_dict on the json representation + cert_settings_result_model = CertSettingsResult.from_dict(cert_settings_result_model_json) + assert cert_settings_result_model != False + + # Construct a model instance of CertSettingsResult by calling from_dict on the json representation + cert_settings_result_model_dict = CertSettingsResult.from_dict(cert_settings_result_model_json).__dict__ + cert_settings_result_model2 = CertSettingsResult(**cert_settings_result_model_dict) + + # Verify the model instances are equivalent + assert cert_settings_result_model == cert_settings_result_model2 + + # Convert model instance back to dict and verify no loss of data + cert_settings_result_model_json2 = cert_settings_result_model.to_dict() + assert cert_settings_result_model_json2 == cert_settings_result_model_json + + +class TestModel_CreateAccessAppResp: + """ + Test Class for CreateAccessAppResp + """ + + def test_create_access_app_resp_serialization(self): + """ + Test serialization/deserialization for CreateAccessAppResp + """ + + # Construct dict forms of any model objects needed in order to build this model. + + create_access_app_resp_result_model = {} # CreateAccessAppRespResult + create_access_app_resp_result_model['id'] = 'de4526d6-d125-4f95-906f-1757510a9cd8' + create_access_app_resp_result_model['name'] = 'mtls-test-app' + create_access_app_resp_result_model['domain'] = 'test.example.com' + create_access_app_resp_result_model['aud'] = 'f8e1744453ea3679d919fdc6db58cff648f2b14b33a729f780fc02e75a42a008' + create_access_app_resp_result_model['policies'] = [] + create_access_app_resp_result_model['allowed_idps'] = [] + create_access_app_resp_result_model['auto_redirect_to_identity'] = False + create_access_app_resp_result_model['session_duration'] = '24h' + create_access_app_resp_result_model['type'] = 'self_hosted' + create_access_app_resp_result_model['uid'] = 'de4526d6-d125-4f95-906f-1757510a9cd8' + create_access_app_resp_result_model['created_at'] = '2021-04-19T07:59:49Z' + create_access_app_resp_result_model['updated_at'] = '2021-04-19T07:59:49Z' + + # Construct a json representation of a CreateAccessAppResp model + create_access_app_resp_model_json = {} + create_access_app_resp_model_json['success'] = True + create_access_app_resp_model_json['errors'] = [] + create_access_app_resp_model_json['messages'] = [] + create_access_app_resp_model_json['result'] = create_access_app_resp_result_model + + # Construct a model instance of CreateAccessAppResp by calling from_dict on the json representation + create_access_app_resp_model = CreateAccessAppResp.from_dict(create_access_app_resp_model_json) + assert create_access_app_resp_model != False + + # Construct a model instance of CreateAccessAppResp by calling from_dict on the json representation + create_access_app_resp_model_dict = CreateAccessAppResp.from_dict(create_access_app_resp_model_json).__dict__ + create_access_app_resp_model2 = CreateAccessAppResp(**create_access_app_resp_model_dict) + + # Verify the model instances are equivalent + assert create_access_app_resp_model == create_access_app_resp_model2 + + # Convert model instance back to dict and verify no loss of data + create_access_app_resp_model_json2 = create_access_app_resp_model.to_dict() + assert create_access_app_resp_model_json2 == create_access_app_resp_model_json + + +class TestModel_DeleteAccessAppResp: + """ + Test Class for DeleteAccessAppResp + """ + + def test_delete_access_app_resp_serialization(self): + """ + Test serialization/deserialization for DeleteAccessAppResp + """ + + # Construct dict forms of any model objects needed in order to build this model. + + delete_access_app_resp_result_model = {} # DeleteAccessAppRespResult + delete_access_app_resp_result_model['id'] = 'de4526d6-d125-4f95-906f-1757510a9cd8' + + # Construct a json representation of a DeleteAccessAppResp model + delete_access_app_resp_model_json = {} + delete_access_app_resp_model_json['success'] = True + delete_access_app_resp_model_json['errors'] = [] + delete_access_app_resp_model_json['messages'] = [] + delete_access_app_resp_model_json['result'] = delete_access_app_resp_result_model + + # Construct a model instance of DeleteAccessAppResp by calling from_dict on the json representation + delete_access_app_resp_model = DeleteAccessAppResp.from_dict(delete_access_app_resp_model_json) + assert delete_access_app_resp_model != False + + # Construct a model instance of DeleteAccessAppResp by calling from_dict on the json representation + delete_access_app_resp_model_dict = DeleteAccessAppResp.from_dict(delete_access_app_resp_model_json).__dict__ + delete_access_app_resp_model2 = DeleteAccessAppResp(**delete_access_app_resp_model_dict) + + # Verify the model instances are equivalent + assert delete_access_app_resp_model == delete_access_app_resp_model2 + + # Convert model instance back to dict and verify no loss of data + delete_access_app_resp_model_json2 = delete_access_app_resp_model.to_dict() + assert delete_access_app_resp_model_json2 == delete_access_app_resp_model_json + + +class TestModel_DeleteAccessCertResp: + """ + Test Class for DeleteAccessCertResp + """ + + def test_delete_access_cert_resp_serialization(self): + """ + Test serialization/deserialization for DeleteAccessCertResp + """ + + # Construct dict forms of any model objects needed in order to build this model. + + delete_access_cert_resp_result_model = {} # DeleteAccessCertRespResult + delete_access_cert_resp_result_model['id'] = '21a41336-9001-42c4-8440-c79e0cb86e1f' + + # Construct a json representation of a DeleteAccessCertResp model + delete_access_cert_resp_model_json = {} + delete_access_cert_resp_model_json['success'] = True + delete_access_cert_resp_model_json['errors'] = [] + delete_access_cert_resp_model_json['messages'] = [] + delete_access_cert_resp_model_json['result'] = delete_access_cert_resp_result_model + + # Construct a model instance of DeleteAccessCertResp by calling from_dict on the json representation + delete_access_cert_resp_model = DeleteAccessCertResp.from_dict(delete_access_cert_resp_model_json) + assert delete_access_cert_resp_model != False + + # Construct a model instance of DeleteAccessCertResp by calling from_dict on the json representation + delete_access_cert_resp_model_dict = DeleteAccessCertResp.from_dict(delete_access_cert_resp_model_json).__dict__ + delete_access_cert_resp_model2 = DeleteAccessCertResp(**delete_access_cert_resp_model_dict) + + # Verify the model instances are equivalent + assert delete_access_cert_resp_model == delete_access_cert_resp_model2 + + # Convert model instance back to dict and verify no loss of data + delete_access_cert_resp_model_json2 = delete_access_cert_resp_model.to_dict() + assert delete_access_cert_resp_model_json2 == delete_access_cert_resp_model_json + + +class TestModel_DeleteAccessPolicyResp: + """ + Test Class for DeleteAccessPolicyResp + """ + + def test_delete_access_policy_resp_serialization(self): + """ + Test serialization/deserialization for DeleteAccessPolicyResp + """ + + # Construct dict forms of any model objects needed in order to build this model. + + delete_access_policy_resp_result_model = {} # DeleteAccessPolicyRespResult + delete_access_policy_resp_result_model['id'] = 'acabcdb1-afb3-4f61-9dae-d1a353a93661' + + # Construct a json representation of a DeleteAccessPolicyResp model + delete_access_policy_resp_model_json = {} + delete_access_policy_resp_model_json['success'] = True + delete_access_policy_resp_model_json['errors'] = [] + delete_access_policy_resp_model_json['messages'] = [] + delete_access_policy_resp_model_json['result'] = delete_access_policy_resp_result_model + + # Construct a model instance of DeleteAccessPolicyResp by calling from_dict on the json representation + delete_access_policy_resp_model = DeleteAccessPolicyResp.from_dict(delete_access_policy_resp_model_json) + assert delete_access_policy_resp_model != False + + # Construct a model instance of DeleteAccessPolicyResp by calling from_dict on the json representation + delete_access_policy_resp_model_dict = DeleteAccessPolicyResp.from_dict(delete_access_policy_resp_model_json).__dict__ + delete_access_policy_resp_model2 = DeleteAccessPolicyResp(**delete_access_policy_resp_model_dict) + + # Verify the model instances are equivalent + assert delete_access_policy_resp_model == delete_access_policy_resp_model2 + + # Convert model instance back to dict and verify no loss of data + delete_access_policy_resp_model_json2 = delete_access_policy_resp_model.to_dict() + assert delete_access_policy_resp_model_json2 == delete_access_policy_resp_model_json + + +class TestModel_ListAccessAppsResp: + """ + Test Class for ListAccessAppsResp + """ + + def test_list_access_apps_resp_serialization(self): + """ + Test serialization/deserialization for ListAccessAppsResp + """ + + # Construct dict forms of any model objects needed in order to build this model. + + policy_rule_model = {} # PolicyRulePolicyCertRule + policy_rule_model['certificate'] = {} + + policy_result_model = {} # PolicyResult + policy_result_model['id'] = 'acabcdb1-afb3-4f61-9dae-d1a353a93661' + policy_result_model['name'] = 'mtls-test-policy' + policy_result_model['decision'] = 'non_identity' + policy_result_model['include'] = [policy_rule_model] + policy_result_model['exclude'] = [policy_rule_model] + policy_result_model['precedence'] = 1 + policy_result_model['require'] = [policy_rule_model] + policy_result_model['uid'] = 'acabcdb1-afb3-4f61-9dae-d1a353a93661' + policy_result_model['created_at'] = '2021-04-19T08:01:21Z' + policy_result_model['updated_at'] = '2021-04-19T08:01:21Z' + + app_result_model = {} # AppResult + app_result_model['id'] = 'de4526d6-d125-4f95-906f-1757510a9cd8' + app_result_model['name'] = 'mtls-test-app' + app_result_model['domain'] = 'test.example.com' + app_result_model['aud'] = 'f8e1744453ea3679d919fdc6db58cff648f2b14b33a729f780fc02e75a42a008' + app_result_model['policies'] = [policy_result_model] + app_result_model['allowed_idps'] = ['699d98642c564d2e855e9661899b7252'] + app_result_model['auto_redirect_to_identity'] = False + app_result_model['session_duration'] = '24h' + app_result_model['type'] = 'self_hosted' + app_result_model['uid'] = 'de4526d6-d125-4f95-906f-1757510a9cd8' + app_result_model['created_at'] = '2021-04-19T07:59:49Z' + app_result_model['updated_at'] = '2021-04-19T07:59:49Z' + + # Construct a json representation of a ListAccessAppsResp model + list_access_apps_resp_model_json = {} + list_access_apps_resp_model_json['success'] = True + list_access_apps_resp_model_json['errors'] = [] + list_access_apps_resp_model_json['messages'] = [] + list_access_apps_resp_model_json['result'] = [app_result_model] + + # Construct a model instance of ListAccessAppsResp by calling from_dict on the json representation + list_access_apps_resp_model = ListAccessAppsResp.from_dict(list_access_apps_resp_model_json) + assert list_access_apps_resp_model != False + + # Construct a model instance of ListAccessAppsResp by calling from_dict on the json representation + list_access_apps_resp_model_dict = ListAccessAppsResp.from_dict(list_access_apps_resp_model_json).__dict__ + list_access_apps_resp_model2 = ListAccessAppsResp(**list_access_apps_resp_model_dict) + + # Verify the model instances are equivalent + assert list_access_apps_resp_model == list_access_apps_resp_model2 + + # Convert model instance back to dict and verify no loss of data + list_access_apps_resp_model_json2 = list_access_apps_resp_model.to_dict() + assert list_access_apps_resp_model_json2 == list_access_apps_resp_model_json + + +class TestModel_ListAccessCertsResp: + """ + Test Class for ListAccessCertsResp + """ + + def test_list_access_certs_resp_serialization(self): + """ + Test serialization/deserialization for ListAccessCertsResp + """ + + # Construct dict forms of any model objects needed in order to build this model. + + cert_result_model = {} # CertResult + cert_result_model['id'] = '21a41336-9001-42c4-8440-c79e0cb86e1f' + cert_result_model['name'] = 'test-cert' + cert_result_model['fingerprint'] = 'MD5 Fingerprint=38:38:B4:FB:3C:33:CE:2C:8E:8E:D1:1B:94:70:C1:5F' + cert_result_model['associated_hostnames'] = ['test.example.com'] + cert_result_model['created_at'] = '2021-04-19T11:09:11Z' + cert_result_model['updated_at'] = '2021-04-19T11:09:11Z' + cert_result_model['expires_on'] = '2026-04-18T06:26:00Z' + + # Construct a json representation of a ListAccessCertsResp model + list_access_certs_resp_model_json = {} + list_access_certs_resp_model_json['success'] = True + list_access_certs_resp_model_json['errors'] = [] + list_access_certs_resp_model_json['messages'] = [] + list_access_certs_resp_model_json['result'] = [cert_result_model] + + # Construct a model instance of ListAccessCertsResp by calling from_dict on the json representation + list_access_certs_resp_model = ListAccessCertsResp.from_dict(list_access_certs_resp_model_json) + assert list_access_certs_resp_model != False + + # Construct a model instance of ListAccessCertsResp by calling from_dict on the json representation + list_access_certs_resp_model_dict = ListAccessCertsResp.from_dict(list_access_certs_resp_model_json).__dict__ + list_access_certs_resp_model2 = ListAccessCertsResp(**list_access_certs_resp_model_dict) + + # Verify the model instances are equivalent + assert list_access_certs_resp_model == list_access_certs_resp_model2 + + # Convert model instance back to dict and verify no loss of data + list_access_certs_resp_model_json2 = list_access_certs_resp_model.to_dict() + assert list_access_certs_resp_model_json2 == list_access_certs_resp_model_json + + +class TestModel_ListAccessPoliciesResp: + """ + Test Class for ListAccessPoliciesResp + """ + + def test_list_access_policies_resp_serialization(self): + """ + Test serialization/deserialization for ListAccessPoliciesResp + """ + + # Construct dict forms of any model objects needed in order to build this model. + + policy_rule_model = {} # PolicyRulePolicyCertRule + policy_rule_model['certificate'] = {} + + policy_result_model = {} # PolicyResult + policy_result_model['id'] = 'acabcdb1-afb3-4f61-9dae-d1a353a93661' + policy_result_model['name'] = 'mtls-test-policy' + policy_result_model['decision'] = 'non_identity' + policy_result_model['include'] = [policy_rule_model] + policy_result_model['exclude'] = [policy_rule_model] + policy_result_model['precedence'] = 1 + policy_result_model['require'] = [policy_rule_model] + policy_result_model['uid'] = 'acabcdb1-afb3-4f61-9dae-d1a353a93661' + policy_result_model['created_at'] = '2021-04-19T08:01:21Z' + policy_result_model['updated_at'] = '2021-04-19T08:01:21Z' + + # Construct a json representation of a ListAccessPoliciesResp model + list_access_policies_resp_model_json = {} + list_access_policies_resp_model_json['success'] = True + list_access_policies_resp_model_json['errors'] = [] + list_access_policies_resp_model_json['messages'] = [] + list_access_policies_resp_model_json['result'] = [policy_result_model] + + # Construct a model instance of ListAccessPoliciesResp by calling from_dict on the json representation + list_access_policies_resp_model = ListAccessPoliciesResp.from_dict(list_access_policies_resp_model_json) + assert list_access_policies_resp_model != False + + # Construct a model instance of ListAccessPoliciesResp by calling from_dict on the json representation + list_access_policies_resp_model_dict = ListAccessPoliciesResp.from_dict(list_access_policies_resp_model_json).__dict__ + list_access_policies_resp_model2 = ListAccessPoliciesResp(**list_access_policies_resp_model_dict) + + # Verify the model instances are equivalent + assert list_access_policies_resp_model == list_access_policies_resp_model2 + + # Convert model instance back to dict and verify no loss of data + list_access_policies_resp_model_json2 = list_access_policies_resp_model.to_dict() + assert list_access_policies_resp_model_json2 == list_access_policies_resp_model_json + + +class TestModel_PolicyResult: + """ + Test Class for PolicyResult + """ + + def test_policy_result_serialization(self): + """ + Test serialization/deserialization for PolicyResult + """ + + # Construct dict forms of any model objects needed in order to build this model. + + policy_rule_model = {} # PolicyRulePolicyCertRule + policy_rule_model['certificate'] = {} + + # Construct a json representation of a PolicyResult model + policy_result_model_json = {} + policy_result_model_json['id'] = 'acabcdb1-afb3-4f61-9dae-d1a353a93661' + policy_result_model_json['name'] = 'mtls-test-policy' + policy_result_model_json['decision'] = 'non_identity' + policy_result_model_json['include'] = [policy_rule_model] + policy_result_model_json['exclude'] = [policy_rule_model] + policy_result_model_json['precedence'] = 1 + policy_result_model_json['require'] = [policy_rule_model] + policy_result_model_json['uid'] = 'acabcdb1-afb3-4f61-9dae-d1a353a93661' + policy_result_model_json['created_at'] = '2021-04-19T08:01:21Z' + policy_result_model_json['updated_at'] = '2021-04-19T08:01:21Z' + + # Construct a model instance of PolicyResult by calling from_dict on the json representation + policy_result_model = PolicyResult.from_dict(policy_result_model_json) + assert policy_result_model != False + + # Construct a model instance of PolicyResult by calling from_dict on the json representation + policy_result_model_dict = PolicyResult.from_dict(policy_result_model_json).__dict__ + policy_result_model2 = PolicyResult(**policy_result_model_dict) + + # Verify the model instances are equivalent + assert policy_result_model == policy_result_model2 + + # Convert model instance back to dict and verify no loss of data + policy_result_model_json2 = policy_result_model.to_dict() + assert policy_result_model_json2 == policy_result_model_json + + +class TestModel_PolicyRulePolicyCertRule: + """ + Test Class for PolicyRulePolicyCertRule + """ + + def test_policy_rule_policy_cert_rule_serialization(self): + """ + Test serialization/deserialization for PolicyRulePolicyCertRule + """ + + # Construct a json representation of a PolicyRulePolicyCertRule model + policy_rule_policy_cert_rule_model_json = {} + policy_rule_policy_cert_rule_model_json['certificate'] = {} + + # Construct a model instance of PolicyRulePolicyCertRule by calling from_dict on the json representation + policy_rule_policy_cert_rule_model = PolicyRulePolicyCertRule.from_dict(policy_rule_policy_cert_rule_model_json) + assert policy_rule_policy_cert_rule_model != False + + # Construct a model instance of PolicyRulePolicyCertRule by calling from_dict on the json representation + policy_rule_policy_cert_rule_model_dict = PolicyRulePolicyCertRule.from_dict(policy_rule_policy_cert_rule_model_json).__dict__ + policy_rule_policy_cert_rule_model2 = PolicyRulePolicyCertRule(**policy_rule_policy_cert_rule_model_dict) + + # Verify the model instances are equivalent + assert policy_rule_policy_cert_rule_model == policy_rule_policy_cert_rule_model2 + + # Convert model instance back to dict and verify no loss of data + policy_rule_policy_cert_rule_model_json2 = policy_rule_policy_cert_rule_model.to_dict() + assert policy_rule_policy_cert_rule_model_json2 == policy_rule_policy_cert_rule_model_json + + +class TestModel_PolicyRulePolicyCnRule: + """ + Test Class for PolicyRulePolicyCnRule + """ + + def test_policy_rule_policy_cn_rule_serialization(self): + """ + Test serialization/deserialization for PolicyRulePolicyCnRule + """ + + # Construct dict forms of any model objects needed in order to build this model. + + policy_cn_rule_common_name_model = {} # PolicyCnRuleCommonName + policy_cn_rule_common_name_model['common_name'] = 'Access Testing CA' + + # Construct a json representation of a PolicyRulePolicyCnRule model + policy_rule_policy_cn_rule_model_json = {} + policy_rule_policy_cn_rule_model_json['common_name'] = policy_cn_rule_common_name_model + + # Construct a model instance of PolicyRulePolicyCnRule by calling from_dict on the json representation + policy_rule_policy_cn_rule_model = PolicyRulePolicyCnRule.from_dict(policy_rule_policy_cn_rule_model_json) + assert policy_rule_policy_cn_rule_model != False + + # Construct a model instance of PolicyRulePolicyCnRule by calling from_dict on the json representation + policy_rule_policy_cn_rule_model_dict = PolicyRulePolicyCnRule.from_dict(policy_rule_policy_cn_rule_model_json).__dict__ + policy_rule_policy_cn_rule_model2 = PolicyRulePolicyCnRule(**policy_rule_policy_cn_rule_model_dict) + + # Verify the model instances are equivalent + assert policy_rule_policy_cn_rule_model == policy_rule_policy_cn_rule_model2 + + # Convert model instance back to dict and verify no loss of data + policy_rule_policy_cn_rule_model_json2 = policy_rule_policy_cn_rule_model.to_dict() + assert policy_rule_policy_cn_rule_model_json2 == policy_rule_policy_cn_rule_model_json + + +# endregion +############################################################################## +# End of Model Tests +############################################################################## diff --git a/test/unit/test_zones_settings_v1.py b/test/unit/test_zones_settings_v1.py index b4c0cd5..a72c84c 100644 --- a/test/unit/test_zones_settings_v1.py +++ b/test/unit/test_zones_settings_v1.py @@ -6963,7 +6963,7 @@ def test_get_replace_insecure_js_all_params(self): """ # Set up mock url = preprocess_url('/v1/testString/zones/testString/settings/replace_insecure_js') - mock_response = '{"result": {"id": "replace_insecure_js", "value": "off", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' + mock_response = '{"result": {"id": "replace_insecure_js", "value": "off", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "result_info": {"anyKey": "anyValue"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' responses.add( responses.GET, url, @@ -6995,7 +6995,7 @@ def test_get_replace_insecure_js_value_error(self): """ # Set up mock url = preprocess_url('/v1/testString/zones/testString/settings/replace_insecure_js') - mock_response = '{"result": {"id": "replace_insecure_js", "value": "off", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' + mock_response = '{"result": {"id": "replace_insecure_js", "value": "off", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "result_info": {"anyKey": "anyValue"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' responses.add( responses.GET, url, @@ -7034,7 +7034,7 @@ def test_update_replace_insecure_js_all_params(self): """ # Set up mock url = preprocess_url('/v1/testString/zones/testString/settings/replace_insecure_js') - mock_response = '{"result": {"id": "replace_insecure_js", "value": "off", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' + mock_response = '{"result": {"id": "replace_insecure_js", "value": "off", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "result_info": {"anyKey": "anyValue"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' responses.add( responses.PATCH, url, @@ -7075,7 +7075,7 @@ def test_update_replace_insecure_js_required_params(self): """ # Set up mock url = preprocess_url('/v1/testString/zones/testString/settings/replace_insecure_js') - mock_response = '{"result": {"id": "replace_insecure_js", "value": "off", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' + mock_response = '{"result": {"id": "replace_insecure_js", "value": "off", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "result_info": {"anyKey": "anyValue"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' responses.add( responses.PATCH, url, @@ -7107,7 +7107,7 @@ def test_update_replace_insecure_js_value_error(self): """ # Set up mock url = preprocess_url('/v1/testString/zones/testString/settings/replace_insecure_js') - mock_response = '{"result": {"id": "replace_insecure_js", "value": "off", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' + mock_response = '{"result": {"id": "replace_insecure_js", "value": "off", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "result_info": {"anyKey": "anyValue"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' responses.add( responses.PATCH, url, @@ -7146,7 +7146,7 @@ def test_get_email_obfuscation_all_params(self): """ # Set up mock url = preprocess_url('/v1/testString/zones/testString/settings/email_obfuscation') - mock_response = '{"result": {"id": "email_obfuscation", "value": "off", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' + mock_response = '{"result": {"id": "email_obfuscation", "value": "off", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "result_info": {"anyKey": "anyValue"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' responses.add( responses.GET, url, @@ -7178,7 +7178,7 @@ def test_get_email_obfuscation_value_error(self): """ # Set up mock url = preprocess_url('/v1/testString/zones/testString/settings/email_obfuscation') - mock_response = '{"result": {"id": "email_obfuscation", "value": "off", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' + mock_response = '{"result": {"id": "email_obfuscation", "value": "off", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "result_info": {"anyKey": "anyValue"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' responses.add( responses.GET, url, @@ -7217,7 +7217,7 @@ def test_update_email_obfuscation_all_params(self): """ # Set up mock url = preprocess_url('/v1/testString/zones/testString/settings/email_obfuscation') - mock_response = '{"result": {"id": "email_obfuscation", "value": "off", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' + mock_response = '{"result": {"id": "email_obfuscation", "value": "off", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "result_info": {"anyKey": "anyValue"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' responses.add( responses.PATCH, url, @@ -7258,7 +7258,7 @@ def test_update_email_obfuscation_required_params(self): """ # Set up mock url = preprocess_url('/v1/testString/zones/testString/settings/email_obfuscation') - mock_response = '{"result": {"id": "email_obfuscation", "value": "off", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' + mock_response = '{"result": {"id": "email_obfuscation", "value": "off", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "result_info": {"anyKey": "anyValue"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' responses.add( responses.PATCH, url, @@ -7290,7 +7290,7 @@ def test_update_email_obfuscation_value_error(self): """ # Set up mock url = preprocess_url('/v1/testString/zones/testString/settings/email_obfuscation') - mock_response = '{"result": {"id": "email_obfuscation", "value": "off", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' + mock_response = '{"result": {"id": "email_obfuscation", "value": "off", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "result_info": {"anyKey": "anyValue"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' responses.add( responses.PATCH, url, @@ -7317,6 +7317,189 @@ def test_update_email_obfuscation_value_error_with_retries(self): self.test_update_email_obfuscation_value_error() +class TestGetSecurityLevel: + """ + Test Class for get_security_level + """ + + @responses.activate + def test_get_security_level_all_params(self): + """ + get_security_level() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/settings/security_level') + mock_response = '{"result": {"id": "security_level", "value": "medium", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Invoke method + response = _service.get_security_level() + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_get_security_level_all_params_with_retries(self): + # Enable retries and run test_get_security_level_all_params. + _service.enable_retries() + self.test_get_security_level_all_params() + + # Disable retries and run test_get_security_level_all_params. + _service.disable_retries() + self.test_get_security_level_all_params() + + @responses.activate + def test_get_security_level_value_error(self): + """ + test_get_security_level_value_error() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/settings/security_level') + mock_response = '{"result": {"id": "security_level", "value": "medium", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.get_security_level(**req_copy) + + def test_get_security_level_value_error_with_retries(self): + # Enable retries and run test_get_security_level_value_error. + _service.enable_retries() + self.test_get_security_level_value_error() + + # Disable retries and run test_get_security_level_value_error. + _service.disable_retries() + self.test_get_security_level_value_error() + + +class TestUpdateSecurityLevel: + """ + Test Class for update_security_level + """ + + @responses.activate + def test_update_security_level_all_params(self): + """ + update_security_level() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/settings/security_level') + mock_response = '{"result": {"id": "security_level", "value": "medium", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' + responses.add( + responses.PATCH, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + value = 'medium' + + # Invoke method + response = _service.update_security_level( + value=value, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['value'] == 'medium' + + def test_update_security_level_all_params_with_retries(self): + # Enable retries and run test_update_security_level_all_params. + _service.enable_retries() + self.test_update_security_level_all_params() + + # Disable retries and run test_update_security_level_all_params. + _service.disable_retries() + self.test_update_security_level_all_params() + + @responses.activate + def test_update_security_level_required_params(self): + """ + test_update_security_level_required_params() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/settings/security_level') + mock_response = '{"result": {"id": "security_level", "value": "medium", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' + responses.add( + responses.PATCH, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Invoke method + response = _service.update_security_level() + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_update_security_level_required_params_with_retries(self): + # Enable retries and run test_update_security_level_required_params. + _service.enable_retries() + self.test_update_security_level_required_params() + + # Disable retries and run test_update_security_level_required_params. + _service.disable_retries() + self.test_update_security_level_required_params() + + @responses.activate + def test_update_security_level_value_error(self): + """ + test_update_security_level_value_error() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/settings/security_level') + mock_response = '{"result": {"id": "security_level", "value": "medium", "editable": true, "modified_on": "2017-01-01T05:20:00.123Z"}, "success": true, "errors": [["errors"]], "messages": [["messages"]]}' + responses.add( + responses.PATCH, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.update_security_level(**req_copy) + + def test_update_security_level_value_error_with_retries(self): + # Enable retries and run test_update_security_level_value_error. + _service.enable_retries() + self.test_update_security_level_value_error() + + # Disable retries and run test_update_security_level_value_error. + _service.disable_retries() + self.test_update_security_level_value_error() + + # endregion ############################################################################## # End of Service: ZonesSettings @@ -8649,6 +8832,39 @@ def test_security_header_setting_value_strict_transport_security_serialization(s assert security_header_setting_value_strict_transport_security_model_json2 == security_header_setting_value_strict_transport_security_model_json +class TestModel_SecurityLevelRespResult: + """ + Test Class for SecurityLevelRespResult + """ + + def test_security_level_resp_result_serialization(self): + """ + Test serialization/deserialization for SecurityLevelRespResult + """ + + # Construct a json representation of a SecurityLevelRespResult model + security_level_resp_result_model_json = {} + security_level_resp_result_model_json['id'] = 'security_level' + security_level_resp_result_model_json['value'] = 'medium' + security_level_resp_result_model_json['editable'] = True + security_level_resp_result_model_json['modified_on'] = '2017-01-01T05:20:00.123000Z' + + # Construct a model instance of SecurityLevelRespResult by calling from_dict on the json representation + security_level_resp_result_model = SecurityLevelRespResult.from_dict(security_level_resp_result_model_json) + assert security_level_resp_result_model != False + + # Construct a model instance of SecurityLevelRespResult by calling from_dict on the json representation + security_level_resp_result_model_dict = SecurityLevelRespResult.from_dict(security_level_resp_result_model_json).__dict__ + security_level_resp_result_model2 = SecurityLevelRespResult(**security_level_resp_result_model_dict) + + # Verify the model instances are equivalent + assert security_level_resp_result_model == security_level_resp_result_model2 + + # Convert model instance back to dict and verify no loss of data + security_level_resp_result_model_json2 = security_level_resp_result_model.to_dict() + assert security_level_resp_result_model_json2 == security_level_resp_result_model_json + + class TestModel_ServerSideExcludeRespResult: """ Test Class for ServerSideExcludeRespResult @@ -9227,6 +9443,7 @@ def test_email_obfuscation_resp_serialization(self): # Construct a json representation of a EmailObfuscationResp model email_obfuscation_resp_model_json = {} email_obfuscation_resp_model_json['result'] = email_obfuscation_resp_result_model + email_obfuscation_resp_model_json['result_info'] = {'anyKey': 'anyValue'} email_obfuscation_resp_model_json['success'] = True email_obfuscation_resp_model_json['errors'] = [['testString']] email_obfuscation_resp_model_json['messages'] = [['testString']] @@ -10095,6 +10312,7 @@ def test_replace_insecure_js_resp_serialization(self): # Construct a json representation of a ReplaceInsecureJsResp model replace_insecure_js_resp_model_json = {} replace_insecure_js_resp_model_json['result'] = replace_insecure_js_resp_result_model + replace_insecure_js_resp_model_json['result_info'] = {'anyKey': 'anyValue'} replace_insecure_js_resp_model_json['success'] = True replace_insecure_js_resp_model_json['errors'] = [['testString']] replace_insecure_js_resp_model_json['messages'] = [['testString']] @@ -10248,6 +10466,47 @@ def test_security_header_resp_serialization(self): assert security_header_resp_model_json2 == security_header_resp_model_json +class TestModel_SecurityLevelResp: + """ + Test Class for SecurityLevelResp + """ + + def test_security_level_resp_serialization(self): + """ + Test serialization/deserialization for SecurityLevelResp + """ + + # Construct dict forms of any model objects needed in order to build this model. + + security_level_resp_result_model = {} # SecurityLevelRespResult + security_level_resp_result_model['id'] = 'security_level' + security_level_resp_result_model['value'] = 'medium' + security_level_resp_result_model['editable'] = True + security_level_resp_result_model['modified_on'] = '2017-01-01T05:20:00.123000Z' + + # Construct a json representation of a SecurityLevelResp model + security_level_resp_model_json = {} + security_level_resp_model_json['result'] = security_level_resp_result_model + security_level_resp_model_json['success'] = True + security_level_resp_model_json['errors'] = [['testString']] + security_level_resp_model_json['messages'] = [['testString']] + + # Construct a model instance of SecurityLevelResp by calling from_dict on the json representation + security_level_resp_model = SecurityLevelResp.from_dict(security_level_resp_model_json) + assert security_level_resp_model != False + + # Construct a model instance of SecurityLevelResp by calling from_dict on the json representation + security_level_resp_model_dict = SecurityLevelResp.from_dict(security_level_resp_model_json).__dict__ + security_level_resp_model2 = SecurityLevelResp(**security_level_resp_model_dict) + + # Verify the model instances are equivalent + assert security_level_resp_model == security_level_resp_model2 + + # Convert model instance back to dict and verify no loss of data + security_level_resp_model_json2 = security_level_resp_model.to_dict() + assert security_level_resp_model_json2 == security_level_resp_model_json + + class TestModel_ServerSideExcludeResp: """ Test Class for ServerSideExcludeResp