diff --git a/ibm_cloud_networking_services/authenticated_origin_pull_api_v1.py b/ibm_cloud_networking_services/authenticated_origin_pull_api_v1.py new file mode 100644 index 0000000..16fc880 --- /dev/null +++ b/ibm_cloud_networking_services/authenticated_origin_pull_api_v1.py @@ -0,0 +1,1644 @@ +# coding: utf-8 + +# (C) Copyright IBM Corp. 2022. +# +# 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.49.0-be9b22fb-20220504-154308 + +""" +Authenticated Origin Pull + +API Version: 1.0.0 +""" + +from datetime import datetime +from typing import Dict, List +import json + +from ibm_cloud_sdk_core import BaseService, DetailedResponse +from ibm_cloud_sdk_core.authenticators.authenticator import Authenticator +from ibm_cloud_sdk_core.get_authenticator import get_authenticator_from_environment +from ibm_cloud_sdk_core.utils import convert_model, datetime_to_string, string_to_datetime + +from .common import get_sdk_headers + +############################################################################## +# Service +############################################################################## + +class AuthenticatedOriginPullApiV1(BaseService): + """The Authenticated Origin Pull API V1 service.""" + + DEFAULT_SERVICE_URL = 'https://api.cis.cloud.ibm.com' + DEFAULT_SERVICE_NAME = 'authenticated_origin_pull_api' + + @classmethod + def new_instance(cls, + crn: str, + zone_identifier: str, + service_name: str = DEFAULT_SERVICE_NAME, + ) -> 'AuthenticatedOriginPullApiV1': + """ + Return a new client for the Authenticated Origin Pull API service using the + specified parameters and external configuration. + + :param str crn: cloud resource name. + + :param str zone_identifier: zone identifier. + """ + if crn is None: + raise ValueError('crn must be provided') + if zone_identifier is None: + raise ValueError('zone_identifier must be provided') + + authenticator = get_authenticator_from_environment(service_name) + service = cls( + crn, + zone_identifier, + authenticator + ) + service.configure_service(service_name) + return service + + def __init__(self, + crn: str, + zone_identifier: str, + authenticator: Authenticator = None, + ) -> None: + """ + Construct a new client for the Authenticated Origin Pull API service. + + :param str crn: cloud resource name. + + :param str zone_identifier: zone 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 zone_identifier is None: + raise ValueError('zone_identifier must be provided') + + BaseService.__init__(self, + service_url=self.DEFAULT_SERVICE_URL, + authenticator=authenticator) + self.crn = crn + self.zone_identifier = zone_identifier + + + ######################### + # Zone-Level Authenticated Origin Pull + ######################### + + + def get_zone_origin_pull_settings(self, + *, + x_correlation_id: str = None, + **kwargs + ) -> DetailedResponse: + """ + Get Zone level Authenticated Origin Pull Settings. + + Get whether zone-level authenticated origin pulls is enabled or not. It is false + by default. + + :param str x_correlation_id: (optional) Uniquely identifying a request. + :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 `GetZoneOriginPullSettingsResp` object + """ + + headers = { + 'X-Correlation-ID': x_correlation_id + } + sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='get_zone_origin_pull_settings') + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'zone_identifier'] + path_param_values = self.encode_path_vars(self.crn, self.zone_identifier) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/zones/{zone_identifier}/origin_tls_client_auth/settings'.format(**path_param_dict) + request = self.prepare_request(method='GET', + url=url, + headers=headers) + + response = self.send(request, **kwargs) + return response + + + def set_zone_origin_pull_settings(self, + *, + enabled: bool = None, + x_correlation_id: str = None, + **kwargs + ) -> DetailedResponse: + """ + Set Zone level Authenticated Origin Pull Settings. + + Enable or disable zone-level authenticated origin pulls. 'enabled' should be set + true either before/after the certificate is uploaded to see the certificate in + use. + + :param bool enabled: (optional) enabled. + :param str x_correlation_id: (optional) Uniquely identifying a request. + :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 `GetZoneOriginPullSettingsResp` object + """ + + headers = { + 'X-Correlation-ID': x_correlation_id + } + sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='set_zone_origin_pull_settings') + headers.update(sdk_headers) + + data = { + 'enabled': enabled + } + data = {k: v for (k, v) in data.items() if v is not None} + data = json.dumps(data) + headers['content-type'] = 'application/json' + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'zone_identifier'] + 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}/origin_tls_client_auth/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 list_zone_origin_pull_certificates(self, + *, + x_correlation_id: str = None, + **kwargs + ) -> DetailedResponse: + """ + List Zone level Authenticated Origin Pull Certificates. + + List zone-level authenticated origin pulls certificates. + + :param str x_correlation_id: (optional) Uniquely identifying a request. + :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 `ListZoneOriginPullCertificatesResp` object + """ + + headers = { + 'X-Correlation-ID': x_correlation_id + } + sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='list_zone_origin_pull_certificates') + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'zone_identifier'] + path_param_values = self.encode_path_vars(self.crn, self.zone_identifier) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/zones/{zone_identifier}/origin_tls_client_auth'.format(**path_param_dict) + request = self.prepare_request(method='GET', + url=url, + headers=headers) + + response = self.send(request, **kwargs) + return response + + + def upload_zone_origin_pull_certificate(self, + *, + certificate: str = None, + private_key: str = None, + x_correlation_id: str = None, + **kwargs + ) -> DetailedResponse: + """ + Upload Zone level Authenticated Origin Pull Certificate. + + Upload your own certificate you want Cloudflare to use for edge-to-origin + communication to override the shared certificate Please note that it is important + to keep only one certificate active. Also, make sure to enable zone-level + authenticated origin pulls by making a PUT call to settings endpoint to see the + uploaded certificate in use. + + :param str certificate: (optional) the zone's leaf certificate. + :param str private_key: (optional) the zone's private key. + :param str x_correlation_id: (optional) Uniquely identifying a request. + :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 `ZoneOriginPullCertificateResp` object + """ + + headers = { + 'X-Correlation-ID': x_correlation_id + } + sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='upload_zone_origin_pull_certificate') + headers.update(sdk_headers) + + data = { + 'certificate': certificate, + 'private_key': private_key + } + data = {k: v for (k, v) in data.items() if v is not None} + data = json.dumps(data) + headers['content-type'] = 'application/json' + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'zone_identifier'] + 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}/origin_tls_client_auth'.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_zone_origin_pull_certificate(self, + cert_identifier: str, + *, + x_correlation_id: str = None, + **kwargs + ) -> DetailedResponse: + """ + Get a Zone level Authenticated Origin Pull Certificate. + + Get a zone-level authenticated origin pulls certificate. + + :param str cert_identifier: cedrtificate identifier. + :param str x_correlation_id: (optional) Uniquely identifying a request. + :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 `ZoneOriginPullCertificateResp` object + """ + + if cert_identifier is None: + raise ValueError('cert_identifier must be provided') + headers = { + 'X-Correlation-ID': x_correlation_id + } + sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='get_zone_origin_pull_certificate') + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'zone_identifier', 'cert_identifier'] + path_param_values = self.encode_path_vars(self.crn, self.zone_identifier, cert_identifier) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/zones/{zone_identifier}/origin_tls_client_auth/{cert_identifier}'.format(**path_param_dict) + request = self.prepare_request(method='GET', + url=url, + headers=headers) + + response = self.send(request, **kwargs) + return response + + + def delete_zone_origin_pull_certificate(self, + cert_identifier: str, + *, + x_correlation_id: str = None, + **kwargs + ) -> DetailedResponse: + """ + Delete a Zone level Authenticated Origin Pull Certificate. + + Delete a zone-level authenticated origin pulls certificate. + + :param str cert_identifier: cedrtificate identifier. + :param str x_correlation_id: (optional) Uniquely identifying a request. + :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 `ZoneOriginPullCertificateResp` object + """ + + if cert_identifier is None: + raise ValueError('cert_identifier must be provided') + headers = { + 'X-Correlation-ID': x_correlation_id + } + sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='delete_zone_origin_pull_certificate') + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'zone_identifier', 'cert_identifier'] + path_param_values = self.encode_path_vars(self.crn, self.zone_identifier, cert_identifier) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/zones/{zone_identifier}/origin_tls_client_auth/{cert_identifier}'.format(**path_param_dict) + request = self.prepare_request(method='DELETE', + url=url, + headers=headers) + + response = self.send(request, **kwargs) + return response + + ######################### + # Per-hostname Authenticated Origin Pull + ######################### + + + def set_hostname_origin_pull_settings(self, + *, + config: List['HostnameOriginPullSettings'] = None, + x_correlation_id: str = None, + **kwargs + ) -> DetailedResponse: + """ + Set Hostname level Authenticated Origin Pull Settings. + + Associate a hostname to a certificate and enable, disable or invalidate the + association. If disabled, client certificate will not be sent to the hostname even + if activated at the zone level. 100 maximum associations on a single certificate + are allowed. + + :param List[HostnameOriginPullSettings] config: (optional) An array with + items in the settings request. + :param str x_correlation_id: (optional) Uniquely identifying a request. + :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 `ListHostnameOriginPullSettingsResp` object + """ + + if config is not None: + config = [convert_model(x) for x in config] + headers = { + 'X-Correlation-ID': x_correlation_id + } + sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='set_hostname_origin_pull_settings') + headers.update(sdk_headers) + + data = { + 'config': config + } + data = {k: v for (k, v) in data.items() if v is not None} + data = json.dumps(data) + headers['content-type'] = 'application/json' + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'zone_identifier'] + 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}/origin_tls_client_auth/hostnames'.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_hostname_origin_pull_settings(self, + hostname: str, + *, + x_correlation_id: str = None, + **kwargs + ) -> DetailedResponse: + """ + Get Hostname level Authenticated Origin Pull Settings. + + Get hostname-level authenticated origin pulls settings. + + :param str hostname: the hostname on the origin for which the client + certificate associate. + :param str x_correlation_id: (optional) Uniquely identifying a request. + :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 `GetHostnameOriginPullSettingsResp` object + """ + + if hostname is None: + raise ValueError('hostname must be provided') + headers = { + 'X-Correlation-ID': x_correlation_id + } + sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='get_hostname_origin_pull_settings') + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'zone_identifier', 'hostname'] + path_param_values = self.encode_path_vars(self.crn, self.zone_identifier, hostname) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/zones/{zone_identifier}/origin_tls_client_auth/hostnames/{hostname}'.format(**path_param_dict) + request = self.prepare_request(method='GET', + url=url, + headers=headers) + + response = self.send(request, **kwargs) + return response + + + def upload_hostname_origin_pull_certificate(self, + *, + certificate: str = None, + private_key: str = None, + x_correlation_id: str = None, + **kwargs + ) -> DetailedResponse: + """ + Upload Hostname level Authenticated Origin Pull Certificate. + + Upload a certificate to be used for client authentication on a hostname. 10 + hostname certificates per zone are allowed. + + :param str certificate: (optional) the zone's leaf certificate. + :param str private_key: (optional) the zone's private key. + :param str x_correlation_id: (optional) Uniquely identifying a request. + :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 `HostnameOriginPullCertificateResp` object + """ + + headers = { + 'X-Correlation-ID': x_correlation_id + } + sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='upload_hostname_origin_pull_certificate') + headers.update(sdk_headers) + + data = { + 'certificate': certificate, + 'private_key': private_key + } + data = {k: v for (k, v) in data.items() if v is not None} + data = json.dumps(data) + headers['content-type'] = 'application/json' + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'zone_identifier'] + 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}/origin_tls_client_auth/hostnames/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_hostname_origin_pull_certificate(self, + cert_identifier: str, + *, + x_correlation_id: str = None, + **kwargs + ) -> DetailedResponse: + """ + Get a Hostname level Authenticated Origin Pull Certificate. + + Get the certificate by ID to be used for client authentication on a hostname. + + :param str cert_identifier: cedrtificate identifier. + :param str x_correlation_id: (optional) Uniquely identifying a request. + :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 `HostnameOriginPullCertificateResp` object + """ + + if cert_identifier is None: + raise ValueError('cert_identifier must be provided') + headers = { + 'X-Correlation-ID': x_correlation_id + } + sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='get_hostname_origin_pull_certificate') + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'zone_identifier', 'cert_identifier'] + path_param_values = self.encode_path_vars(self.crn, self.zone_identifier, cert_identifier) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/zones/{zone_identifier}/origin_tls_client_auth/hostnames/certificates/{cert_identifier}'.format(**path_param_dict) + request = self.prepare_request(method='GET', + url=url, + headers=headers) + + response = self.send(request, **kwargs) + return response + + + def delete_hostname_origin_pull_certificate(self, + cert_identifier: str, + *, + x_correlation_id: str = None, + **kwargs + ) -> DetailedResponse: + """ + Delete a Hostname level Authenticated Origin Pull Certificate. + + Delete the certificate by ID to be used for client authentication on a hostname. + + :param str cert_identifier: cedrtificate identifier. + :param str x_correlation_id: (optional) Uniquely identifying a request. + :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 `HostnameOriginPullCertificateResp` object + """ + + if cert_identifier is None: + raise ValueError('cert_identifier must be provided') + headers = { + 'X-Correlation-ID': x_correlation_id + } + sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='delete_hostname_origin_pull_certificate') + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + headers['Accept'] = 'application/json' + + path_param_keys = ['crn', 'zone_identifier', 'cert_identifier'] + path_param_values = self.encode_path_vars(self.crn, self.zone_identifier, cert_identifier) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/{crn}/zones/{zone_identifier}/origin_tls_client_auth/hostnames/certificates/{cert_identifier}'.format(**path_param_dict) + request = self.prepare_request(method='DELETE', + url=url, + headers=headers) + + response = self.send(request, **kwargs) + return response + + +############################################################################## +# Models +############################################################################## + + +class GetZoneOriginPullSettingsRespResult(): + """ + result. + + :attr bool enabled: enabled. + """ + + def __init__(self, + enabled: bool) -> None: + """ + Initialize a GetZoneOriginPullSettingsRespResult object. + + :param bool enabled: enabled. + """ + self.enabled = enabled + + @classmethod + def from_dict(cls, _dict: Dict) -> 'GetZoneOriginPullSettingsRespResult': + """Initialize a GetZoneOriginPullSettingsRespResult object from a json dictionary.""" + args = {} + if 'enabled' in _dict: + args['enabled'] = _dict.get('enabled') + else: + raise ValueError('Required property \'enabled\' not present in GetZoneOriginPullSettingsRespResult JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a GetZoneOriginPullSettingsRespResult 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, 'enabled') and self.enabled is not None: + _dict['enabled'] = self.enabled + 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 GetZoneOriginPullSettingsRespResult object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'GetZoneOriginPullSettingsRespResult') -> 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: 'GetZoneOriginPullSettingsRespResult') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + +class CertificatePack(): + """ + certificate pack. + + :attr str id: (optional) certificate identifier tag. + :attr str certificate: (optional) the zone's leaf certificate. + :attr str issuer: (optional) the certificate authority that issued the + certificate. + :attr str signature: (optional) the type of hash used for the certificate. + :attr str status: (optional) status of the certificate activation. + :attr str expires_on: (optional) when the certificate from the authority + expires. + :attr str uploaded_on: (optional) the time the certificate was uploaded. + """ + + def __init__(self, + *, + id: str = None, + certificate: str = None, + issuer: str = None, + signature: str = None, + status: str = None, + expires_on: str = None, + uploaded_on: str = None) -> None: + """ + Initialize a CertificatePack object. + + :param str id: (optional) certificate identifier tag. + :param str certificate: (optional) the zone's leaf certificate. + :param str issuer: (optional) the certificate authority that issued the + certificate. + :param str signature: (optional) the type of hash used for the certificate. + :param str status: (optional) status of the certificate activation. + :param str expires_on: (optional) when the certificate from the authority + expires. + :param str uploaded_on: (optional) the time the certificate was uploaded. + """ + self.id = id + self.certificate = certificate + self.issuer = issuer + self.signature = signature + self.status = status + self.expires_on = expires_on + self.uploaded_on = uploaded_on + + @classmethod + def from_dict(cls, _dict: Dict) -> 'CertificatePack': + """Initialize a CertificatePack object from a json dictionary.""" + args = {} + if 'id' in _dict: + args['id'] = _dict.get('id') + if 'certificate' in _dict: + args['certificate'] = _dict.get('certificate') + if 'issuer' in _dict: + args['issuer'] = _dict.get('issuer') + if 'signature' in _dict: + args['signature'] = _dict.get('signature') + if 'status' in _dict: + args['status'] = _dict.get('status') + if 'expires_on' in _dict: + args['expires_on'] = _dict.get('expires_on') + if 'uploaded_on' in _dict: + args['uploaded_on'] = _dict.get('uploaded_on') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a CertificatePack 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, 'certificate') and self.certificate is not None: + _dict['certificate'] = self.certificate + if hasattr(self, 'issuer') and self.issuer is not None: + _dict['issuer'] = self.issuer + if hasattr(self, 'signature') and self.signature is not None: + _dict['signature'] = self.signature + if hasattr(self, 'status') and self.status is not None: + _dict['status'] = self.status + if hasattr(self, 'expires_on') and self.expires_on is not None: + _dict['expires_on'] = self.expires_on + if hasattr(self, 'uploaded_on') and self.uploaded_on is not None: + _dict['uploaded_on'] = self.uploaded_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 CertificatePack object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'CertificatePack') -> 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: 'CertificatePack') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + +class GetHostnameOriginPullSettingsResp(): + """ + detail of the hostname level authenticated origin pull settings response. + + :attr HostnameSettingsResp result: (optional) hostname level authenticated + origin pull settings response. + :attr bool success: (optional) success. + :attr List[str] errors: (optional) + :attr List[str] messages: (optional) + """ + + def __init__(self, + *, + result: 'HostnameSettingsResp' = None, + success: bool = None, + errors: List[str] = None, + messages: List[str] = None) -> None: + """ + Initialize a GetHostnameOriginPullSettingsResp object. + + :param HostnameSettingsResp result: (optional) hostname level authenticated + origin pull settings response. + :param bool success: (optional) success. + :param List[str] errors: (optional) + :param List[str] messages: (optional) + """ + self.result = result + self.success = success + self.errors = errors + self.messages = messages + + @classmethod + def from_dict(cls, _dict: Dict) -> 'GetHostnameOriginPullSettingsResp': + """Initialize a GetHostnameOriginPullSettingsResp object from a json dictionary.""" + args = {} + if 'result' in _dict: + args['result'] = HostnameSettingsResp.from_dict(_dict.get('result')) + if 'success' in _dict: + args['success'] = _dict.get('success') + if 'errors' in _dict: + args['errors'] = _dict.get('errors') + if 'messages' in _dict: + args['messages'] = _dict.get('messages') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a GetHostnameOriginPullSettingsResp 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: + _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 GetHostnameOriginPullSettingsResp object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'GetHostnameOriginPullSettingsResp') -> 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: 'GetHostnameOriginPullSettingsResp') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + +class GetZoneOriginPullSettingsResp(): + """ + zone level authenticated origin pull settings response. + + :attr GetZoneOriginPullSettingsRespResult result: (optional) result. + :attr bool success: (optional) success. + :attr List[str] errors: (optional) + :attr List[str] messages: (optional) + """ + + def __init__(self, + *, + result: 'GetZoneOriginPullSettingsRespResult' = None, + success: bool = None, + errors: List[str] = None, + messages: List[str] = None) -> None: + """ + Initialize a GetZoneOriginPullSettingsResp object. + + :param GetZoneOriginPullSettingsRespResult result: (optional) result. + :param bool success: (optional) success. + :param List[str] errors: (optional) + :param List[str] messages: (optional) + """ + self.result = result + self.success = success + self.errors = errors + self.messages = messages + + @classmethod + def from_dict(cls, _dict: Dict) -> 'GetZoneOriginPullSettingsResp': + """Initialize a GetZoneOriginPullSettingsResp object from a json dictionary.""" + args = {} + if 'result' in _dict: + args['result'] = GetZoneOriginPullSettingsRespResult.from_dict(_dict.get('result')) + if 'success' in _dict: + args['success'] = _dict.get('success') + if 'errors' in _dict: + args['errors'] = _dict.get('errors') + if 'messages' in _dict: + args['messages'] = _dict.get('messages') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a GetZoneOriginPullSettingsResp 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: + _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 GetZoneOriginPullSettingsResp object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'GetZoneOriginPullSettingsResp') -> 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: 'GetZoneOriginPullSettingsResp') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + +class HostnameCertificatePack(): + """ + certificate pack. + + :attr str id: (optional) certificate identifier tag. + :attr str certificate: (optional) the zone's leaf certificate. + :attr str issuer: (optional) the certificate authority that issued the + certificate. + :attr str signature: (optional) the type of hash used for the certificate. + :attr str serial_number: (optional) the serial number on the uploaded + certificate. + :attr str status: (optional) status of the certificate activation. + :attr str expires_on: (optional) when the certificate from the authority + expires. + :attr str uploaded_on: (optional) the time the certificate was uploaded. + """ + + def __init__(self, + *, + id: str = None, + certificate: str = None, + issuer: str = None, + signature: str = None, + serial_number: str = None, + status: str = None, + expires_on: str = None, + uploaded_on: str = None) -> None: + """ + Initialize a HostnameCertificatePack object. + + :param str id: (optional) certificate identifier tag. + :param str certificate: (optional) the zone's leaf certificate. + :param str issuer: (optional) the certificate authority that issued the + certificate. + :param str signature: (optional) the type of hash used for the certificate. + :param str serial_number: (optional) the serial number on the uploaded + certificate. + :param str status: (optional) status of the certificate activation. + :param str expires_on: (optional) when the certificate from the authority + expires. + :param str uploaded_on: (optional) the time the certificate was uploaded. + """ + self.id = id + self.certificate = certificate + self.issuer = issuer + self.signature = signature + self.serial_number = serial_number + self.status = status + self.expires_on = expires_on + self.uploaded_on = uploaded_on + + @classmethod + def from_dict(cls, _dict: Dict) -> 'HostnameCertificatePack': + """Initialize a HostnameCertificatePack object from a json dictionary.""" + args = {} + if 'id' in _dict: + args['id'] = _dict.get('id') + if 'certificate' in _dict: + args['certificate'] = _dict.get('certificate') + if 'issuer' in _dict: + args['issuer'] = _dict.get('issuer') + if 'signature' in _dict: + args['signature'] = _dict.get('signature') + if 'serial_number' in _dict: + args['serial_number'] = _dict.get('serial_number') + if 'status' in _dict: + args['status'] = _dict.get('status') + if 'expires_on' in _dict: + args['expires_on'] = _dict.get('expires_on') + if 'uploaded_on' in _dict: + args['uploaded_on'] = _dict.get('uploaded_on') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a HostnameCertificatePack 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, 'certificate') and self.certificate is not None: + _dict['certificate'] = self.certificate + if hasattr(self, 'issuer') and self.issuer is not None: + _dict['issuer'] = self.issuer + if hasattr(self, 'signature') and self.signature is not None: + _dict['signature'] = self.signature + if hasattr(self, 'serial_number') and self.serial_number is not None: + _dict['serial_number'] = self.serial_number + if hasattr(self, 'status') and self.status is not None: + _dict['status'] = self.status + if hasattr(self, 'expires_on') and self.expires_on is not None: + _dict['expires_on'] = self.expires_on + if hasattr(self, 'uploaded_on') and self.uploaded_on is not None: + _dict['uploaded_on'] = self.uploaded_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 HostnameCertificatePack object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'HostnameCertificatePack') -> 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: 'HostnameCertificatePack') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + +class HostnameOriginPullCertificateResp(): + """ + certificate response. + + :attr HostnameCertificatePack result: (optional) certificate pack. + :attr bool success: (optional) success. + :attr List[str] errors: (optional) + :attr List[str] messages: (optional) + """ + + def __init__(self, + *, + result: 'HostnameCertificatePack' = None, + success: bool = None, + errors: List[str] = None, + messages: List[str] = None) -> None: + """ + Initialize a HostnameOriginPullCertificateResp object. + + :param HostnameCertificatePack result: (optional) certificate pack. + :param bool success: (optional) success. + :param List[str] errors: (optional) + :param List[str] messages: (optional) + """ + self.result = result + self.success = success + self.errors = errors + self.messages = messages + + @classmethod + def from_dict(cls, _dict: Dict) -> 'HostnameOriginPullCertificateResp': + """Initialize a HostnameOriginPullCertificateResp object from a json dictionary.""" + args = {} + if 'result' in _dict: + args['result'] = HostnameCertificatePack.from_dict(_dict.get('result')) + if 'success' in _dict: + args['success'] = _dict.get('success') + if 'errors' in _dict: + args['errors'] = _dict.get('errors') + if 'messages' in _dict: + args['messages'] = _dict.get('messages') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a HostnameOriginPullCertificateResp 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: + _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 HostnameOriginPullCertificateResp object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'HostnameOriginPullCertificateResp') -> 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: 'HostnameOriginPullCertificateResp') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + +class HostnameOriginPullSettings(): + """ + hostname-level authenticated origin pull settings request. + + :attr str hostname: the hostname on the origin for which the client certificate + uploaded will be used. + :attr str cert_id: certificate identifier tag. + :attr bool enabled: enabled. + """ + + def __init__(self, + hostname: str, + cert_id: str, + enabled: bool) -> None: + """ + Initialize a HostnameOriginPullSettings object. + + :param str hostname: the hostname on the origin for which the client + certificate uploaded will be used. + :param str cert_id: certificate identifier tag. + :param bool enabled: enabled. + """ + self.hostname = hostname + self.cert_id = cert_id + self.enabled = enabled + + @classmethod + def from_dict(cls, _dict: Dict) -> 'HostnameOriginPullSettings': + """Initialize a HostnameOriginPullSettings object from a json dictionary.""" + args = {} + if 'hostname' in _dict: + args['hostname'] = _dict.get('hostname') + else: + raise ValueError('Required property \'hostname\' not present in HostnameOriginPullSettings JSON') + if 'cert_id' in _dict: + args['cert_id'] = _dict.get('cert_id') + else: + raise ValueError('Required property \'cert_id\' not present in HostnameOriginPullSettings JSON') + if 'enabled' in _dict: + args['enabled'] = _dict.get('enabled') + else: + raise ValueError('Required property \'enabled\' not present in HostnameOriginPullSettings JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a HostnameOriginPullSettings 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, 'cert_id') and self.cert_id is not None: + _dict['cert_id'] = self.cert_id + if hasattr(self, 'enabled') and self.enabled is not None: + _dict['enabled'] = self.enabled + 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 HostnameOriginPullSettings object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'HostnameOriginPullSettings') -> 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: 'HostnameOriginPullSettings') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + +class HostnameSettingsResp(): + """ + hostname level authenticated origin pull settings response. + + :attr str hostname: (optional) the hostname on the origin for which the client + certificate uploaded will be used. + :attr str cert_id: (optional) certificate identifier tag. + :attr bool enabled: (optional) enabled. + :attr str status: (optional) status of the certificate activation. + :attr datetime created_at: (optional) the time when the certificate was created. + :attr datetime updated_at: (optional) the time when the certificate was updated. + :attr str cert_status: (optional) status of the certificate or the association. + :attr str issuer: (optional) the certificate authority that issued the + certificate. + :attr str signature: (optional) the type of hash used for the certificate. + :attr str serial_number: (optional) the serial number on the uploaded + certificate. + :attr str certificate: (optional) the zone's leaf certificate. + :attr datetime cert_uploaded_on: (optional) the time the certificate was + uploaded. + :attr datetime cert_updated_at: (optional) the time when the certificate was + updated. + :attr datetime expires_on: (optional) the date when the certificate expires. + """ + + def __init__(self, + *, + hostname: str = None, + cert_id: str = None, + enabled: bool = None, + status: str = None, + created_at: datetime = None, + updated_at: datetime = None, + cert_status: str = None, + issuer: str = None, + signature: str = None, + serial_number: str = None, + certificate: str = None, + cert_uploaded_on: datetime = None, + cert_updated_at: datetime = None, + expires_on: datetime = None) -> None: + """ + Initialize a HostnameSettingsResp object. + + :param str hostname: (optional) the hostname on the origin for which the + client certificate uploaded will be used. + :param str cert_id: (optional) certificate identifier tag. + :param bool enabled: (optional) enabled. + :param str status: (optional) status of the certificate activation. + :param datetime created_at: (optional) the time when the certificate was + created. + :param datetime updated_at: (optional) the time when the certificate was + updated. + :param str cert_status: (optional) status of the certificate or the + association. + :param str issuer: (optional) the certificate authority that issued the + certificate. + :param str signature: (optional) the type of hash used for the certificate. + :param str serial_number: (optional) the serial number on the uploaded + certificate. + :param str certificate: (optional) the zone's leaf certificate. + :param datetime cert_uploaded_on: (optional) the time the certificate was + uploaded. + :param datetime cert_updated_at: (optional) the time when the certificate + was updated. + :param datetime expires_on: (optional) the date when the certificate + expires. + """ + self.hostname = hostname + self.cert_id = cert_id + self.enabled = enabled + self.status = status + self.created_at = created_at + self.updated_at = updated_at + self.cert_status = cert_status + self.issuer = issuer + self.signature = signature + self.serial_number = serial_number + self.certificate = certificate + self.cert_uploaded_on = cert_uploaded_on + self.cert_updated_at = cert_updated_at + self.expires_on = expires_on + + @classmethod + def from_dict(cls, _dict: Dict) -> 'HostnameSettingsResp': + """Initialize a HostnameSettingsResp object from a json dictionary.""" + args = {} + if 'hostname' in _dict: + args['hostname'] = _dict.get('hostname') + if 'cert_id' in _dict: + args['cert_id'] = _dict.get('cert_id') + if 'enabled' in _dict: + args['enabled'] = _dict.get('enabled') + if 'status' in _dict: + args['status'] = _dict.get('status') + if 'created_at' in _dict: + args['created_at'] = string_to_datetime(_dict.get('created_at')) + if 'updated_at' in _dict: + args['updated_at'] = string_to_datetime(_dict.get('updated_at')) + if 'cert_status' in _dict: + args['cert_status'] = _dict.get('cert_status') + if 'issuer' in _dict: + args['issuer'] = _dict.get('issuer') + if 'signature' in _dict: + args['signature'] = _dict.get('signature') + if 'serial_number' in _dict: + args['serial_number'] = _dict.get('serial_number') + if 'certificate' in _dict: + args['certificate'] = _dict.get('certificate') + if 'cert_uploaded_on' in _dict: + args['cert_uploaded_on'] = string_to_datetime(_dict.get('cert_uploaded_on')) + if 'cert_updated_at' in _dict: + args['cert_updated_at'] = string_to_datetime(_dict.get('cert_updated_at')) + if 'expires_on' in _dict: + args['expires_on'] = string_to_datetime(_dict.get('expires_on')) + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a HostnameSettingsResp 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, 'cert_id') and self.cert_id is not None: + _dict['cert_id'] = self.cert_id + if hasattr(self, 'enabled') and self.enabled is not None: + _dict['enabled'] = self.enabled + if hasattr(self, 'status') and self.status is not None: + _dict['status'] = self.status + if hasattr(self, 'created_at') and self.created_at is not None: + _dict['created_at'] = datetime_to_string(self.created_at) + if hasattr(self, 'updated_at') and self.updated_at is not None: + _dict['updated_at'] = datetime_to_string(self.updated_at) + if hasattr(self, 'cert_status') and self.cert_status is not None: + _dict['cert_status'] = self.cert_status + if hasattr(self, 'issuer') and self.issuer is not None: + _dict['issuer'] = self.issuer + if hasattr(self, 'signature') and self.signature is not None: + _dict['signature'] = self.signature + if hasattr(self, 'serial_number') and self.serial_number is not None: + _dict['serial_number'] = self.serial_number + if hasattr(self, 'certificate') and self.certificate is not None: + _dict['certificate'] = self.certificate + if hasattr(self, 'cert_uploaded_on') and self.cert_uploaded_on is not None: + _dict['cert_uploaded_on'] = datetime_to_string(self.cert_uploaded_on) + if hasattr(self, 'cert_updated_at') and self.cert_updated_at is not None: + _dict['cert_updated_at'] = datetime_to_string(self.cert_updated_at) + if hasattr(self, 'expires_on') and self.expires_on is not None: + _dict['expires_on'] = datetime_to_string(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 HostnameSettingsResp object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'HostnameSettingsResp') -> 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: 'HostnameSettingsResp') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + +class ListHostnameOriginPullSettingsResp(): + """ + array of hostname level authenticated origin pull settings response. + + :attr List[HostnameSettingsResp] result: (optional) array of hostname settings + response. + :attr bool success: (optional) success. + :attr List[str] errors: (optional) + :attr List[str] messages: (optional) + """ + + def __init__(self, + *, + result: List['HostnameSettingsResp'] = None, + success: bool = None, + errors: List[str] = None, + messages: List[str] = None) -> None: + """ + Initialize a ListHostnameOriginPullSettingsResp object. + + :param List[HostnameSettingsResp] result: (optional) array of hostname + settings response. + :param bool success: (optional) success. + :param List[str] errors: (optional) + :param List[str] messages: (optional) + """ + self.result = result + self.success = success + self.errors = errors + self.messages = messages + + @classmethod + def from_dict(cls, _dict: Dict) -> 'ListHostnameOriginPullSettingsResp': + """Initialize a ListHostnameOriginPullSettingsResp object from a json dictionary.""" + args = {} + if 'result' in _dict: + args['result'] = [HostnameSettingsResp.from_dict(x) for x in _dict.get('result')] + if 'success' in _dict: + args['success'] = _dict.get('success') + if 'errors' in _dict: + args['errors'] = _dict.get('errors') + if 'messages' in _dict: + args['messages'] = _dict.get('messages') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a ListHostnameOriginPullSettingsResp 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: + _dict['result'] = [x.to_dict() for x in self.result] + 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 ListHostnameOriginPullSettingsResp object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'ListHostnameOriginPullSettingsResp') -> 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: 'ListHostnameOriginPullSettingsResp') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + +class ListZoneOriginPullCertificatesResp(): + """ + certificate response. + + :attr List[CertificatePack] result: (optional) list certificate packs. + :attr bool success: (optional) success. + :attr List[str] errors: (optional) + :attr List[str] messages: (optional) + """ + + def __init__(self, + *, + result: List['CertificatePack'] = None, + success: bool = None, + errors: List[str] = None, + messages: List[str] = None) -> None: + """ + Initialize a ListZoneOriginPullCertificatesResp object. + + :param List[CertificatePack] result: (optional) list certificate packs. + :param bool success: (optional) success. + :param List[str] errors: (optional) + :param List[str] messages: (optional) + """ + self.result = result + self.success = success + self.errors = errors + self.messages = messages + + @classmethod + def from_dict(cls, _dict: Dict) -> 'ListZoneOriginPullCertificatesResp': + """Initialize a ListZoneOriginPullCertificatesResp object from a json dictionary.""" + args = {} + if 'result' in _dict: + args['result'] = [CertificatePack.from_dict(x) for x in _dict.get('result')] + if 'success' in _dict: + args['success'] = _dict.get('success') + if 'errors' in _dict: + args['errors'] = _dict.get('errors') + if 'messages' in _dict: + args['messages'] = _dict.get('messages') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a ListZoneOriginPullCertificatesResp 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: + _dict['result'] = [x.to_dict() for x in self.result] + 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 ListZoneOriginPullCertificatesResp object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'ListZoneOriginPullCertificatesResp') -> 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: 'ListZoneOriginPullCertificatesResp') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + +class ZoneOriginPullCertificateResp(): + """ + zone level authenticated origin pull certificate response. + + :attr CertificatePack result: (optional) certificate pack. + :attr bool success: (optional) success. + :attr List[str] errors: (optional) + :attr List[str] messages: (optional) + """ + + def __init__(self, + *, + result: 'CertificatePack' = None, + success: bool = None, + errors: List[str] = None, + messages: List[str] = None) -> None: + """ + Initialize a ZoneOriginPullCertificateResp object. + + :param CertificatePack result: (optional) certificate pack. + :param bool success: (optional) success. + :param List[str] errors: (optional) + :param List[str] messages: (optional) + """ + self.result = result + self.success = success + self.errors = errors + self.messages = messages + + @classmethod + def from_dict(cls, _dict: Dict) -> 'ZoneOriginPullCertificateResp': + """Initialize a ZoneOriginPullCertificateResp object from a json dictionary.""" + args = {} + if 'result' in _dict: + args['result'] = CertificatePack.from_dict(_dict.get('result')) + if 'success' in _dict: + args['success'] = _dict.get('success') + if 'errors' in _dict: + args['errors'] = _dict.get('errors') + if 'messages' in _dict: + args['messages'] = _dict.get('messages') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a ZoneOriginPullCertificateResp 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: + _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 ZoneOriginPullCertificateResp object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'ZoneOriginPullCertificateResp') -> 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: 'ZoneOriginPullCertificateResp') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other diff --git a/test/integration/test_authenticated_origin_pull_api_v1.py b/test/integration/test_authenticated_origin_pull_api_v1.py new file mode 100644 index 0000000..cfe3795 --- /dev/null +++ b/test/integration/test_authenticated_origin_pull_api_v1.py @@ -0,0 +1,172 @@ +# -*- coding: utf-8 -*- +# (C) Copyright IBM Corp. 2020. + +""" +Integration test code to execute caching api +""" + +from cgitb import enable +from http.client import responses +import os +import unittest +from dotenv import load_dotenv, find_dotenv +from ibm_cloud_networking_services.authenticated_origin_pull_api_v1 import AuthenticatedOriginPullApiV1 +from ibm_cloud_networking_services.ssl_certificate_api_v1 import Certificate + +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') + +############################################################################## +# ZoneLevelAuthenticatedOriginPull +############################################################################## + +class TestZoneAuthenticatedOriginPullApiV1(unittest.TestCase): + """ Test class for Zone Level Authenticated Origin Pull APIs""" + + def setUp(self): + 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.auth = AuthenticatedOriginPullApiV1.new_instance( + crn=self.crn, zone_identifier=self.zone_id, service_name="cis_services") + self.auth.set_service_url(self.endpoint) + + self. certificate_name = "-----BEGIN CERTIFICATE-----\nMIICljCCAX4CCQDXCJC5bOv97DANBgkqhkiG9w0BAQsFADANMQswCQYDVQQGEwJJ\nTjAeFw0yMjA1MTYwNDQxMjFaFw0yMzA1MTYwNDQxMjFaMA0xCzAJBgNVBAYTAklO\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3ka/M7mE6Exrc2VhHe9z\nCSU6D2Z45+u9IO5TghXM6luZzrPr2CuV/HAKTyG5YZtgIlYFV+CXI1a+hVnJnV6f\nHvkFlXgST7xjqqdff6P72gMJ06HPoR30tvTHzIGF7+ZEoAfSfZZOR/BJRowW9PoA\nvA8BtfNai3Jm+NYQfQxFf4LT25k2AHJW/2o7cGIbfPsEC+mKWBOzXMd38ZSMFq17\nxX81fnMrz0YK1x/tkJwIL5P6HPoLsYNCcpTZ3/f9gJJ+4j8c3xl97j8dh2Zab3rP\noBaDJt4oymanjyLqRZBBx+Xb6dv7L8MUJ9LM80Y9fmAK3Iui5R1s0k21qsA9VbF0\nCQIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQA6xuG19P4wckXQIRJz4t2me601FuBp\nHsfBXd8oKw4JEVrKtVtPb4bl7qMorC6Mz520QoAVKYe+nRpk63A4LkZ3asjyDs+Z\no2LawLE2goN6/elA6fQd92EtjipKwFK0Z4NrF/ekPheNjPtWUtqXo0JmHb4qDHHf\nsLq/oFym1J0Um8lW8hrpsf7C9Bnh10zvBtl/y7H6mTN7nOafS+puoVTzz+Rj4P6N\nBjFZixpmVgVFL+x9GnsJwSQFybMDfmBgfAEfqxPLTKoV0PlHktTuWSkMoaJBKC1Q\nZa/qK1n5UWhvIVuzbbd5dFQxE/N8P/+4O4YYGEqNmRo3SoId6uCYAEn0\n-----END CERTIFICATE-----\n" + self.private_key = "-----BEGIN PRIVATE KEY-----\nMIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDeRr8zuYToTGtz\nZWEd73MJJToPZnjn670g7lOCFczqW5nOs+vYK5X8cApPIblhm2AiVgVX4JcjVr6F\nWcmdXp8e+QWVeBJPvGOqp19/o/vaAwnToc+hHfS29MfMgYXv5kSgB9J9lk5H8ElG\njBb0+gC8DwG181qLcmb41hB9DEV/gtPbmTYAclb/ajtwYht8+wQL6YpYE7Ncx3fx\nlIwWrXvFfzV+cyvPRgrXH+2QnAgvk/oc+guxg0JylNnf9/2Akn7iPxzfGX3uPx2H\nZlpves+gFoMm3ijKZqePIupFkEHH5dvp2/svwxQn0szzRj1+YArci6LlHWzSTbWq\nwD1VsXQJAgMBAAECggEATaCXlhDsgdRuklaNnE7L9h2yMT6waw7BdobFU2EZt59W\nEAJ2E4DlWMwoTYqRm60P3e3837voDMd2skuxReyN1dtSP+k3O/GnPSpHB+TVSEZX\nYDnasYIsvNiwDpQNmsLopJsWwBWGMUmRzbmPKu9E4mi7SDg9HwZNQApCp+lpPCZl\n527ZM4ikgMbu7zNl5zDaTMXNs4PllPMraimBJSw5/PCgDHGMxn8xzLIPMxvS1lVC\nbgwNQtsbVQ1kqe7MmC/mxNx33F1NGTRy+fGw5HaBgmS+DlWWS29gnO4LXf/sL/KT\n9nSFkggNdWg2LNHVtdJ/G1PZqM8vr3wkhFEkUbmEIQKBgQD4IUDDYD64mX9GDu3/\nnBdOw0hz8TrzNOLdA9NwMzwFX/tvX7wiUj+8H033RW8h3uiru7giGBQ/B9daltdt\n/9/jzMJSjiH7G5WbC8uRapZeW4LWkKcMKZpVvBSHLE8P/v8KbQkIodsHi/PZGoRt\nyoIgwPfnsaAeYTGAXWjYP+dt1wKBgQDlU5H5zV413trx6W+T7jxdh/q3zrbTYmdr\ncfMXQBVl1HCRzrPkQ7aq7XbrDQsCkQDt4mSX6sQg2pTD1ZIgSpoZpMwEHEua6NXv\nIOj1VPuj5y4cOO/skPyA7oqUtuFWeQKxLI5Fm3HDcXvb5kSw7PPIIUVKrHS1+/Bo\neqTgceMxHwKBgDCC59OK5JhYwk5jKtrXnKL0gRzR4/GavGPzlIoSKkDuxAzBTdnz\n9KwF/stCUvjvSNQSjmx0ArlUAiGe7h1+cjpqVO+pBDHA8d3vT2xtx1pJT+o9O7ug\nAqGSdPz8h7Sb6ScTrDl404bFMPaYPZ3tgsV+lLlCvAhUfkYXfSESVV/fAoGACP8V\nS/J1jrF2b2UT/n6rGZQ7DrjqTTKgEgP/YFsgO8VwwReV0Q+i++Oi9aemVexwV+S4\nw4jvNsa8bU5UlDW5A+aGJmchxCr8MYxd9znlQVHRakQFjYdGkJxLDXh7MJRAucig\nsDRf6yXpkP/gk/xHuAMuH7bSQU1n6gFdtHxjSEsCgYAsItXD1hV1aXnYdXeZkMew\nSUWJ6pvLUj+FpuRqJ+zJsv7G1MT9OINwnfXG1hTpxpJ2Igx/cO6ZXvl8AXf5B5rA\nii/573Z7XGUENDfE8LYOKa6eFLyl2fCbSbs/8K+Y6UlsmPmwF1J3eK2oIOKrsyyH\nyN60AdUg197VxTkO6bjBvA==\n-----END PRIVATE KEY-----\n" + + self.x_correlation_id = "12345" + self.url = os.getenv("URL") + + def test_1_zone_origin_pull(self): + + # To check if Authenticated Origin Pull settings is enabled or not + resp = self.auth.get_zone_origin_pull_settings() + assert resp is not None + assert resp.status_code == 202 + assert resp.get_result().get("success") == True + + # To set Authenticated Origin Pull settings enabled -> True or False + values = [True, False] + for value in values: + resp = self.auth.set_zone_origin_pull_settings(enabled=value) + assert resp is not None + assert resp.status_code == 202 + assert resp.get_result().get("success") == True + assert resp.get_result().get("result")["enabled"] == value + + # To fetch list of certificates in the zone + resp = self.auth.list_zone_origin_pull_certificates() + assert resp is not None + assert resp.status_code == 200 + assert resp.get_result().get("success") == True + assert isinstance(resp.get_result().get("result"), list) + + # Set Authenticated Origin Pull settings as enabled before uploading + self.auth.set_zone_origin_pull_settings(enabled=True) + + # Upload certificate + resp = self.auth.upload_zone_origin_pull_certificate(certificate=self.certificate_name, private_key=self.private_key) + assert resp is not None + assert resp.status_code == 201 + assert resp.get_result().get("success") == True + assert resp.get_result().get("result")["certificate"] == self.certificate_name + + cert_identifier = resp.get_result().get("result")["id"] + + # Fetch certificate with ID + resp = self.auth.get_zone_origin_pull_certificate(cert_identifier=cert_identifier, x_correlation_id=self.x_correlation_id) + assert resp is not None + assert resp.status_code == 200 + assert resp.get_result().get("success") == True + assert resp.get_result().get("result")["id"] == cert_identifier + + # Delete certificate with ID + resp = self.auth.delete_zone_origin_pull_certificate(cert_identifier=cert_identifier, x_correlation_id=self.x_correlation_id) + assert resp is not None + assert resp.status_code == 200 + assert resp.get_result().get("success") == True + + +############################################################################## +# PerHostnameAuthenticatedOriginPull +############################################################################## + + +class TestHostnameAuthenticatedOriginPullApiV1(unittest.TestCase): + """ Test class for Hostname Authenticated Origin Pull APIs""" + + def setUp(self): + 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.auth = AuthenticatedOriginPullApiV1.new_instance( + crn=self.crn, zone_identifier=self.zone_id, service_name="cis_services") + self.auth.set_service_url(self.endpoint) + + self. certificate_name = "-----BEGIN CERTIFICATE-----\nMIICljCCAX4CCQDXCJC5bOv97DANBgkqhkiG9w0BAQsFADANMQswCQYDVQQGEwJJ\nTjAeFw0yMjA1MTYwNDQxMjFaFw0yMzA1MTYwNDQxMjFaMA0xCzAJBgNVBAYTAklO\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3ka/M7mE6Exrc2VhHe9z\nCSU6D2Z45+u9IO5TghXM6luZzrPr2CuV/HAKTyG5YZtgIlYFV+CXI1a+hVnJnV6f\nHvkFlXgST7xjqqdff6P72gMJ06HPoR30tvTHzIGF7+ZEoAfSfZZOR/BJRowW9PoA\nvA8BtfNai3Jm+NYQfQxFf4LT25k2AHJW/2o7cGIbfPsEC+mKWBOzXMd38ZSMFq17\nxX81fnMrz0YK1x/tkJwIL5P6HPoLsYNCcpTZ3/f9gJJ+4j8c3xl97j8dh2Zab3rP\noBaDJt4oymanjyLqRZBBx+Xb6dv7L8MUJ9LM80Y9fmAK3Iui5R1s0k21qsA9VbF0\nCQIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQA6xuG19P4wckXQIRJz4t2me601FuBp\nHsfBXd8oKw4JEVrKtVtPb4bl7qMorC6Mz520QoAVKYe+nRpk63A4LkZ3asjyDs+Z\no2LawLE2goN6/elA6fQd92EtjipKwFK0Z4NrF/ekPheNjPtWUtqXo0JmHb4qDHHf\nsLq/oFym1J0Um8lW8hrpsf7C9Bnh10zvBtl/y7H6mTN7nOafS+puoVTzz+Rj4P6N\nBjFZixpmVgVFL+x9GnsJwSQFybMDfmBgfAEfqxPLTKoV0PlHktTuWSkMoaJBKC1Q\nZa/qK1n5UWhvIVuzbbd5dFQxE/N8P/+4O4YYGEqNmRo3SoId6uCYAEn0\n-----END CERTIFICATE-----\n" + self.private_key = "-----BEGIN PRIVATE KEY-----\nMIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDeRr8zuYToTGtz\nZWEd73MJJToPZnjn670g7lOCFczqW5nOs+vYK5X8cApPIblhm2AiVgVX4JcjVr6F\nWcmdXp8e+QWVeBJPvGOqp19/o/vaAwnToc+hHfS29MfMgYXv5kSgB9J9lk5H8ElG\njBb0+gC8DwG181qLcmb41hB9DEV/gtPbmTYAclb/ajtwYht8+wQL6YpYE7Ncx3fx\nlIwWrXvFfzV+cyvPRgrXH+2QnAgvk/oc+guxg0JylNnf9/2Akn7iPxzfGX3uPx2H\nZlpves+gFoMm3ijKZqePIupFkEHH5dvp2/svwxQn0szzRj1+YArci6LlHWzSTbWq\nwD1VsXQJAgMBAAECggEATaCXlhDsgdRuklaNnE7L9h2yMT6waw7BdobFU2EZt59W\nEAJ2E4DlWMwoTYqRm60P3e3837voDMd2skuxReyN1dtSP+k3O/GnPSpHB+TVSEZX\nYDnasYIsvNiwDpQNmsLopJsWwBWGMUmRzbmPKu9E4mi7SDg9HwZNQApCp+lpPCZl\n527ZM4ikgMbu7zNl5zDaTMXNs4PllPMraimBJSw5/PCgDHGMxn8xzLIPMxvS1lVC\nbgwNQtsbVQ1kqe7MmC/mxNx33F1NGTRy+fGw5HaBgmS+DlWWS29gnO4LXf/sL/KT\n9nSFkggNdWg2LNHVtdJ/G1PZqM8vr3wkhFEkUbmEIQKBgQD4IUDDYD64mX9GDu3/\nnBdOw0hz8TrzNOLdA9NwMzwFX/tvX7wiUj+8H033RW8h3uiru7giGBQ/B9daltdt\n/9/jzMJSjiH7G5WbC8uRapZeW4LWkKcMKZpVvBSHLE8P/v8KbQkIodsHi/PZGoRt\nyoIgwPfnsaAeYTGAXWjYP+dt1wKBgQDlU5H5zV413trx6W+T7jxdh/q3zrbTYmdr\ncfMXQBVl1HCRzrPkQ7aq7XbrDQsCkQDt4mSX6sQg2pTD1ZIgSpoZpMwEHEua6NXv\nIOj1VPuj5y4cOO/skPyA7oqUtuFWeQKxLI5Fm3HDcXvb5kSw7PPIIUVKrHS1+/Bo\neqTgceMxHwKBgDCC59OK5JhYwk5jKtrXnKL0gRzR4/GavGPzlIoSKkDuxAzBTdnz\n9KwF/stCUvjvSNQSjmx0ArlUAiGe7h1+cjpqVO+pBDHA8d3vT2xtx1pJT+o9O7ug\nAqGSdPz8h7Sb6ScTrDl404bFMPaYPZ3tgsV+lLlCvAhUfkYXfSESVV/fAoGACP8V\nS/J1jrF2b2UT/n6rGZQ7DrjqTTKgEgP/YFsgO8VwwReV0Q+i++Oi9aemVexwV+S4\nw4jvNsa8bU5UlDW5A+aGJmchxCr8MYxd9znlQVHRakQFjYdGkJxLDXh7MJRAucig\nsDRf6yXpkP/gk/xHuAMuH7bSQU1n6gFdtHxjSEsCgYAsItXD1hV1aXnYdXeZkMew\nSUWJ6pvLUj+FpuRqJ+zJsv7G1MT9OINwnfXG1hTpxpJ2Igx/cO6ZXvl8AXf5B5rA\nii/573Z7XGUENDfE8LYOKa6eFLyl2fCbSbs/8K+Y6UlsmPmwF1J3eK2oIOKrsyyH\nyN60AdUg197VxTkO6bjBvA==\n-----END PRIVATE KEY-----\n" + + self.x_correlation_id = "98765" + self.url = os.getenv("URL") + + def test_1_hostname_origin_pull(self): + + # Get settings for the hostname + resp = self.auth.get_hostname_origin_pull_settings(hostname=self.url) + assert resp is not None + assert resp.status_code == 200 + assert resp.get_result().get("success") == True + + + # Upload certificate + resp = self.auth.upload_hostname_origin_pull_certificate(certificate=self.certificate_name, private_key=self.private_key, x_correlation_id = self.x_correlation_id) + assert resp is not None + assert resp.status_code == 201 + assert resp.get_result().get("success") == True + assert resp.get_result().get("result")["certificate"] == self.certificate_name + + cert_identifier = resp.get_result().get("result")["id"] + + # Set a hostname to a certificate + values = [True, False] + for value in values: + config = [ + { + "hostname": self.url, + "cert_id": cert_identifier, + "enabled": value + } + ] + resp = self.auth.set_hostname_origin_pull_settings(config=config) + assert resp is not None + assert resp.status_code == 202 + assert resp.get_result().get("success") == True + assert resp.get_result().get("result")[0]["cert_id"] == cert_identifier + assert resp.get_result().get("result")[0]["enabled"] == value + + # Get certificate with ID + resp = self.auth.get_hostname_origin_pull_certificate(cert_identifier=cert_identifier, x_correlation_id=self.x_correlation_id) + assert resp is not None + assert resp.status_code == 200 + assert resp.get_result().get("success") == True + + # Delete certificate with ID + resp = self.auth.delete_hostname_origin_pull_certificate(cert_identifier=cert_identifier, x_correlation_id=self.x_correlation_id) + assert resp is not None + assert resp.status_code == 200 + assert resp.get_result().get("success") == True + + +if __name__ == '__main__': + unittest.main() diff --git a/test/unit/test_authenticated_origin_pull_api_v1.py b/test/unit/test_authenticated_origin_pull_api_v1.py new file mode 100644 index 0000000..fb6f082 --- /dev/null +++ b/test/unit/test_authenticated_origin_pull_api_v1.py @@ -0,0 +1,1865 @@ +# -*- coding: utf-8 -*- +# (C) Copyright IBM Corp. 2022. +# +# 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 AuthenticatedOriginPullApiV1 +""" + +from datetime import datetime, timezone +from ibm_cloud_sdk_core.authenticators.no_auth_authenticator import NoAuthAuthenticator +from ibm_cloud_sdk_core.utils import datetime_to_string, string_to_datetime +import inspect +import json +import os +import pytest +import re +import responses +import urllib +from ibm_cloud_networking_services.authenticated_origin_pull_api_v1 import * + +crn = 'testString' +zone_identifier = 'testString' + +_service = AuthenticatedOriginPullApiV1( + authenticator=NoAuthAuthenticator(), + crn=crn, + zone_identifier=zone_identifier +) + +_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. + """ + # First, unquote the path since it might have some quoted/escaped characters in it + # due to how the generator inserts the operation paths into the unit test code. + operation_path = urllib.parse.unquote(operation_path) + + # Next, quote the path using urllib so that we approximate what will + # happen during request processing. + operation_path = urllib.parse.quote(operation_path, safe='/') + + # Finally, 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 re.fullmatch('.*/+', request_url) is None: + return request_url + else: + return re.compile(request_url.rstrip('/') + '/+') + + +############################################################################## +# Start of Service: ZoneLevelAuthenticatedOriginPull +############################################################################## +# region + +class TestNewInstance(): + """ + Test Class for new_instance + """ + + def test_new_instance(self): + """ + new_instance() + """ + os.environ['TEST_SERVICE_AUTH_TYPE'] = 'noAuth' + + service = AuthenticatedOriginPullApiV1.new_instance( + crn=crn, + zone_identifier=zone_identifier, + service_name='TEST_SERVICE', + ) + + assert service is not None + assert isinstance(service, AuthenticatedOriginPullApiV1) + + def test_new_instance_without_authenticator(self): + """ + new_instance_without_authenticator() + """ + with pytest.raises(ValueError, match='authenticator must be provided'): + service = AuthenticatedOriginPullApiV1.new_instance( + crn=crn, + zone_identifier=zone_identifier, + 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 = AuthenticatedOriginPullApiV1.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 = AuthenticatedOriginPullApiV1.new_instance( + crn=None, + zone_identifier=None, + ) +class TestGetZoneOriginPullSettings(): + """ + Test Class for get_zone_origin_pull_settings + """ + + @responses.activate + def test_get_zone_origin_pull_settings_all_params(self): + """ + get_zone_origin_pull_settings() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/origin_tls_client_auth/settings') + mock_response = '{"result": {"enabled": true}, "success": true, "errors": ["errors"], "messages": ["messages"]}' + responses.add(responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Set up parameter values + x_correlation_id = 'testString' + + # Invoke method + response = _service.get_zone_origin_pull_settings( + x_correlation_id=x_correlation_id, + headers={} + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_get_zone_origin_pull_settings_all_params_with_retries(self): + # Enable retries and run test_get_zone_origin_pull_settings_all_params. + _service.enable_retries() + self.test_get_zone_origin_pull_settings_all_params() + + # Disable retries and run test_get_zone_origin_pull_settings_all_params. + _service.disable_retries() + self.test_get_zone_origin_pull_settings_all_params() + + @responses.activate + def test_get_zone_origin_pull_settings_required_params(self): + """ + test_get_zone_origin_pull_settings_required_params() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/origin_tls_client_auth/settings') + mock_response = '{"result": {"enabled": true}, "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_zone_origin_pull_settings() + + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_get_zone_origin_pull_settings_required_params_with_retries(self): + # Enable retries and run test_get_zone_origin_pull_settings_required_params. + _service.enable_retries() + self.test_get_zone_origin_pull_settings_required_params() + + # Disable retries and run test_get_zone_origin_pull_settings_required_params. + _service.disable_retries() + self.test_get_zone_origin_pull_settings_required_params() + + @responses.activate + def test_get_zone_origin_pull_settings_value_error(self): + """ + test_get_zone_origin_pull_settings_value_error() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/origin_tls_client_auth/settings') + mock_response = '{"result": {"enabled": true}, "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_zone_origin_pull_settings(**req_copy) + + + def test_get_zone_origin_pull_settings_value_error_with_retries(self): + # Enable retries and run test_get_zone_origin_pull_settings_value_error. + _service.enable_retries() + self.test_get_zone_origin_pull_settings_value_error() + + # Disable retries and run test_get_zone_origin_pull_settings_value_error. + _service.disable_retries() + self.test_get_zone_origin_pull_settings_value_error() + +class TestSetZoneOriginPullSettings(): + """ + Test Class for set_zone_origin_pull_settings + """ + + @responses.activate + def test_set_zone_origin_pull_settings_all_params(self): + """ + set_zone_origin_pull_settings() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/origin_tls_client_auth/settings') + mock_response = '{"result": {"enabled": true}, "success": true, "errors": ["errors"], "messages": ["messages"]}' + responses.add(responses.PUT, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Set up parameter values + enabled = True + x_correlation_id = 'testString' + + # Invoke method + response = _service.set_zone_origin_pull_settings( + enabled=enabled, + x_correlation_id=x_correlation_id, + 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['enabled'] == True + + def test_set_zone_origin_pull_settings_all_params_with_retries(self): + # Enable retries and run test_set_zone_origin_pull_settings_all_params. + _service.enable_retries() + self.test_set_zone_origin_pull_settings_all_params() + + # Disable retries and run test_set_zone_origin_pull_settings_all_params. + _service.disable_retries() + self.test_set_zone_origin_pull_settings_all_params() + + @responses.activate + def test_set_zone_origin_pull_settings_required_params(self): + """ + test_set_zone_origin_pull_settings_required_params() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/origin_tls_client_auth/settings') + mock_response = '{"result": {"enabled": true}, "success": true, "errors": ["errors"], "messages": ["messages"]}' + responses.add(responses.PUT, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Invoke method + response = _service.set_zone_origin_pull_settings() + + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_set_zone_origin_pull_settings_required_params_with_retries(self): + # Enable retries and run test_set_zone_origin_pull_settings_required_params. + _service.enable_retries() + self.test_set_zone_origin_pull_settings_required_params() + + # Disable retries and run test_set_zone_origin_pull_settings_required_params. + _service.disable_retries() + self.test_set_zone_origin_pull_settings_required_params() + + @responses.activate + def test_set_zone_origin_pull_settings_value_error(self): + """ + test_set_zone_origin_pull_settings_value_error() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/origin_tls_client_auth/settings') + mock_response = '{"result": {"enabled": true}, "success": true, "errors": ["errors"], "messages": ["messages"]}' + 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.set_zone_origin_pull_settings(**req_copy) + + + def test_set_zone_origin_pull_settings_value_error_with_retries(self): + # Enable retries and run test_set_zone_origin_pull_settings_value_error. + _service.enable_retries() + self.test_set_zone_origin_pull_settings_value_error() + + # Disable retries and run test_set_zone_origin_pull_settings_value_error. + _service.disable_retries() + self.test_set_zone_origin_pull_settings_value_error() + +class TestListZoneOriginPullCertificates(): + """ + Test Class for list_zone_origin_pull_certificates + """ + + @responses.activate + def test_list_zone_origin_pull_certificates_all_params(self): + """ + list_zone_origin_pull_certificates() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/origin_tls_client_auth') + mock_response = '{"result": [{"id": "0f405ba2-8c18-49eb-a30b-28b85427780f", "certificate": "-----BEGIN CERTIFICATE-----\n......\n-----END CERTIFICATE-----\n", "issuer": "GlobalSign", "signature": "SHA256WithRSA", "status": "active", "expires_on": "2100-01-01T05:20:00Z", "uploaded_on": "2100-01-01T05:20:00Z"}], "success": true, "errors": ["errors"], "messages": ["messages"]}' + responses.add(responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Set up parameter values + x_correlation_id = 'testString' + + # Invoke method + response = _service.list_zone_origin_pull_certificates( + x_correlation_id=x_correlation_id, + headers={} + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_list_zone_origin_pull_certificates_all_params_with_retries(self): + # Enable retries and run test_list_zone_origin_pull_certificates_all_params. + _service.enable_retries() + self.test_list_zone_origin_pull_certificates_all_params() + + # Disable retries and run test_list_zone_origin_pull_certificates_all_params. + _service.disable_retries() + self.test_list_zone_origin_pull_certificates_all_params() + + @responses.activate + def test_list_zone_origin_pull_certificates_required_params(self): + """ + test_list_zone_origin_pull_certificates_required_params() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/origin_tls_client_auth') + mock_response = '{"result": [{"id": "0f405ba2-8c18-49eb-a30b-28b85427780f", "certificate": "-----BEGIN CERTIFICATE-----\n......\n-----END CERTIFICATE-----\n", "issuer": "GlobalSign", "signature": "SHA256WithRSA", "status": "active", "expires_on": "2100-01-01T05:20:00Z", "uploaded_on": "2100-01-01T05:20:00Z"}], "success": true, "errors": ["errors"], "messages": ["messages"]}' + responses.add(responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Invoke method + response = _service.list_zone_origin_pull_certificates() + + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_list_zone_origin_pull_certificates_required_params_with_retries(self): + # Enable retries and run test_list_zone_origin_pull_certificates_required_params. + _service.enable_retries() + self.test_list_zone_origin_pull_certificates_required_params() + + # Disable retries and run test_list_zone_origin_pull_certificates_required_params. + _service.disable_retries() + self.test_list_zone_origin_pull_certificates_required_params() + + @responses.activate + def test_list_zone_origin_pull_certificates_value_error(self): + """ + test_list_zone_origin_pull_certificates_value_error() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/origin_tls_client_auth') + mock_response = '{"result": [{"id": "0f405ba2-8c18-49eb-a30b-28b85427780f", "certificate": "-----BEGIN CERTIFICATE-----\n......\n-----END CERTIFICATE-----\n", "issuer": "GlobalSign", "signature": "SHA256WithRSA", "status": "active", "expires_on": "2100-01-01T05:20:00Z", "uploaded_on": "2100-01-01T05:20:00Z"}], "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.list_zone_origin_pull_certificates(**req_copy) + + + def test_list_zone_origin_pull_certificates_value_error_with_retries(self): + # Enable retries and run test_list_zone_origin_pull_certificates_value_error. + _service.enable_retries() + self.test_list_zone_origin_pull_certificates_value_error() + + # Disable retries and run test_list_zone_origin_pull_certificates_value_error. + _service.disable_retries() + self.test_list_zone_origin_pull_certificates_value_error() + +class TestUploadZoneOriginPullCertificate(): + """ + Test Class for upload_zone_origin_pull_certificate + """ + + @responses.activate + def test_upload_zone_origin_pull_certificate_all_params(self): + """ + upload_zone_origin_pull_certificate() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/origin_tls_client_auth') + mock_response = '{"result": {"id": "0f405ba2-8c18-49eb-a30b-28b85427780f", "certificate": "-----BEGIN CERTIFICATE-----\n......\n-----END CERTIFICATE-----\n", "issuer": "GlobalSign", "signature": "SHA256WithRSA", "status": "active", "expires_on": "2100-01-01T05:20:00Z", "uploaded_on": "2100-01-01T05:20:00Z"}, "success": true, "errors": ["errors"], "messages": ["messages"]}' + responses.add(responses.POST, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Set up parameter values + certificate = '-----BEGIN CERTIFICATE-----\n......\n-----END CERTIFICATE-----\n' + private_key = '-----BEGIN RSA PRIVATE KEY-----\n......\n-----END RSA PRIVATE KEY-----\n' + x_correlation_id = 'testString' + + # Invoke method + response = _service.upload_zone_origin_pull_certificate( + certificate=certificate, + private_key=private_key, + x_correlation_id=x_correlation_id, + 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['certificate'] == '-----BEGIN CERTIFICATE-----\n......\n-----END CERTIFICATE-----\n' + assert req_body['private_key'] == '-----BEGIN RSA PRIVATE KEY-----\n......\n-----END RSA PRIVATE KEY-----\n' + + def test_upload_zone_origin_pull_certificate_all_params_with_retries(self): + # Enable retries and run test_upload_zone_origin_pull_certificate_all_params. + _service.enable_retries() + self.test_upload_zone_origin_pull_certificate_all_params() + + # Disable retries and run test_upload_zone_origin_pull_certificate_all_params. + _service.disable_retries() + self.test_upload_zone_origin_pull_certificate_all_params() + + @responses.activate + def test_upload_zone_origin_pull_certificate_required_params(self): + """ + test_upload_zone_origin_pull_certificate_required_params() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/origin_tls_client_auth') + mock_response = '{"result": {"id": "0f405ba2-8c18-49eb-a30b-28b85427780f", "certificate": "-----BEGIN CERTIFICATE-----\n......\n-----END CERTIFICATE-----\n", "issuer": "GlobalSign", "signature": "SHA256WithRSA", "status": "active", "expires_on": "2100-01-01T05:20:00Z", "uploaded_on": "2100-01-01T05:20:00Z"}, "success": true, "errors": ["errors"], "messages": ["messages"]}' + responses.add(responses.POST, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Invoke method + response = _service.upload_zone_origin_pull_certificate() + + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_upload_zone_origin_pull_certificate_required_params_with_retries(self): + # Enable retries and run test_upload_zone_origin_pull_certificate_required_params. + _service.enable_retries() + self.test_upload_zone_origin_pull_certificate_required_params() + + # Disable retries and run test_upload_zone_origin_pull_certificate_required_params. + _service.disable_retries() + self.test_upload_zone_origin_pull_certificate_required_params() + + @responses.activate + def test_upload_zone_origin_pull_certificate_value_error(self): + """ + test_upload_zone_origin_pull_certificate_value_error() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/origin_tls_client_auth') + mock_response = '{"result": {"id": "0f405ba2-8c18-49eb-a30b-28b85427780f", "certificate": "-----BEGIN CERTIFICATE-----\n......\n-----END CERTIFICATE-----\n", "issuer": "GlobalSign", "signature": "SHA256WithRSA", "status": "active", "expires_on": "2100-01-01T05:20:00Z", "uploaded_on": "2100-01-01T05:20:00Z"}, "success": true, "errors": ["errors"], "messages": ["messages"]}' + 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.upload_zone_origin_pull_certificate(**req_copy) + + + def test_upload_zone_origin_pull_certificate_value_error_with_retries(self): + # Enable retries and run test_upload_zone_origin_pull_certificate_value_error. + _service.enable_retries() + self.test_upload_zone_origin_pull_certificate_value_error() + + # Disable retries and run test_upload_zone_origin_pull_certificate_value_error. + _service.disable_retries() + self.test_upload_zone_origin_pull_certificate_value_error() + +class TestGetZoneOriginPullCertificate(): + """ + Test Class for get_zone_origin_pull_certificate + """ + + @responses.activate + def test_get_zone_origin_pull_certificate_all_params(self): + """ + get_zone_origin_pull_certificate() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/origin_tls_client_auth/testString') + mock_response = '{"result": {"id": "0f405ba2-8c18-49eb-a30b-28b85427780f", "certificate": "-----BEGIN CERTIFICATE-----\n......\n-----END CERTIFICATE-----\n", "issuer": "GlobalSign", "signature": "SHA256WithRSA", "status": "active", "expires_on": "2100-01-01T05:20:00Z", "uploaded_on": "2100-01-01T05:20:00Z"}, "success": true, "errors": ["errors"], "messages": ["messages"]}' + responses.add(responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Set up parameter values + cert_identifier = 'testString' + x_correlation_id = 'testString' + + # Invoke method + response = _service.get_zone_origin_pull_certificate( + cert_identifier, + x_correlation_id=x_correlation_id, + headers={} + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_get_zone_origin_pull_certificate_all_params_with_retries(self): + # Enable retries and run test_get_zone_origin_pull_certificate_all_params. + _service.enable_retries() + self.test_get_zone_origin_pull_certificate_all_params() + + # Disable retries and run test_get_zone_origin_pull_certificate_all_params. + _service.disable_retries() + self.test_get_zone_origin_pull_certificate_all_params() + + @responses.activate + def test_get_zone_origin_pull_certificate_required_params(self): + """ + test_get_zone_origin_pull_certificate_required_params() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/origin_tls_client_auth/testString') + mock_response = '{"result": {"id": "0f405ba2-8c18-49eb-a30b-28b85427780f", "certificate": "-----BEGIN CERTIFICATE-----\n......\n-----END CERTIFICATE-----\n", "issuer": "GlobalSign", "signature": "SHA256WithRSA", "status": "active", "expires_on": "2100-01-01T05:20:00Z", "uploaded_on": "2100-01-01T05:20:00Z"}, "success": true, "errors": ["errors"], "messages": ["messages"]}' + responses.add(responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Set up parameter values + cert_identifier = 'testString' + + # Invoke method + response = _service.get_zone_origin_pull_certificate( + cert_identifier, + headers={} + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_get_zone_origin_pull_certificate_required_params_with_retries(self): + # Enable retries and run test_get_zone_origin_pull_certificate_required_params. + _service.enable_retries() + self.test_get_zone_origin_pull_certificate_required_params() + + # Disable retries and run test_get_zone_origin_pull_certificate_required_params. + _service.disable_retries() + self.test_get_zone_origin_pull_certificate_required_params() + + @responses.activate + def test_get_zone_origin_pull_certificate_value_error(self): + """ + test_get_zone_origin_pull_certificate_value_error() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/origin_tls_client_auth/testString') + mock_response = '{"result": {"id": "0f405ba2-8c18-49eb-a30b-28b85427780f", "certificate": "-----BEGIN CERTIFICATE-----\n......\n-----END CERTIFICATE-----\n", "issuer": "GlobalSign", "signature": "SHA256WithRSA", "status": "active", "expires_on": "2100-01-01T05:20:00Z", "uploaded_on": "2100-01-01T05:20:00Z"}, "success": true, "errors": ["errors"], "messages": ["messages"]}' + responses.add(responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Set up parameter values + cert_identifier = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "cert_identifier": cert_identifier, + } + for param in req_param_dict.keys(): + req_copy = {key:val if key is not param else None for (key,val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.get_zone_origin_pull_certificate(**req_copy) + + + def test_get_zone_origin_pull_certificate_value_error_with_retries(self): + # Enable retries and run test_get_zone_origin_pull_certificate_value_error. + _service.enable_retries() + self.test_get_zone_origin_pull_certificate_value_error() + + # Disable retries and run test_get_zone_origin_pull_certificate_value_error. + _service.disable_retries() + self.test_get_zone_origin_pull_certificate_value_error() + +class TestDeleteZoneOriginPullCertificate(): + """ + Test Class for delete_zone_origin_pull_certificate + """ + + @responses.activate + def test_delete_zone_origin_pull_certificate_all_params(self): + """ + delete_zone_origin_pull_certificate() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/origin_tls_client_auth/testString') + mock_response = '{"result": {"id": "0f405ba2-8c18-49eb-a30b-28b85427780f", "certificate": "-----BEGIN CERTIFICATE-----\n......\n-----END CERTIFICATE-----\n", "issuer": "GlobalSign", "signature": "SHA256WithRSA", "status": "active", "expires_on": "2100-01-01T05:20:00Z", "uploaded_on": "2100-01-01T05:20:00Z"}, "success": true, "errors": ["errors"], "messages": ["messages"]}' + responses.add(responses.DELETE, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Set up parameter values + cert_identifier = 'testString' + x_correlation_id = 'testString' + + # Invoke method + response = _service.delete_zone_origin_pull_certificate( + cert_identifier, + x_correlation_id=x_correlation_id, + headers={} + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_delete_zone_origin_pull_certificate_all_params_with_retries(self): + # Enable retries and run test_delete_zone_origin_pull_certificate_all_params. + _service.enable_retries() + self.test_delete_zone_origin_pull_certificate_all_params() + + # Disable retries and run test_delete_zone_origin_pull_certificate_all_params. + _service.disable_retries() + self.test_delete_zone_origin_pull_certificate_all_params() + + @responses.activate + def test_delete_zone_origin_pull_certificate_required_params(self): + """ + test_delete_zone_origin_pull_certificate_required_params() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/origin_tls_client_auth/testString') + mock_response = '{"result": {"id": "0f405ba2-8c18-49eb-a30b-28b85427780f", "certificate": "-----BEGIN CERTIFICATE-----\n......\n-----END CERTIFICATE-----\n", "issuer": "GlobalSign", "signature": "SHA256WithRSA", "status": "active", "expires_on": "2100-01-01T05:20:00Z", "uploaded_on": "2100-01-01T05:20:00Z"}, "success": true, "errors": ["errors"], "messages": ["messages"]}' + responses.add(responses.DELETE, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Set up parameter values + cert_identifier = 'testString' + + # Invoke method + response = _service.delete_zone_origin_pull_certificate( + cert_identifier, + headers={} + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_delete_zone_origin_pull_certificate_required_params_with_retries(self): + # Enable retries and run test_delete_zone_origin_pull_certificate_required_params. + _service.enable_retries() + self.test_delete_zone_origin_pull_certificate_required_params() + + # Disable retries and run test_delete_zone_origin_pull_certificate_required_params. + _service.disable_retries() + self.test_delete_zone_origin_pull_certificate_required_params() + + @responses.activate + def test_delete_zone_origin_pull_certificate_value_error(self): + """ + test_delete_zone_origin_pull_certificate_value_error() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/origin_tls_client_auth/testString') + mock_response = '{"result": {"id": "0f405ba2-8c18-49eb-a30b-28b85427780f", "certificate": "-----BEGIN CERTIFICATE-----\n......\n-----END CERTIFICATE-----\n", "issuer": "GlobalSign", "signature": "SHA256WithRSA", "status": "active", "expires_on": "2100-01-01T05:20:00Z", "uploaded_on": "2100-01-01T05:20:00Z"}, "success": true, "errors": ["errors"], "messages": ["messages"]}' + responses.add(responses.DELETE, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Set up parameter values + cert_identifier = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "cert_identifier": cert_identifier, + } + for param in req_param_dict.keys(): + req_copy = {key:val if key is not param else None for (key,val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.delete_zone_origin_pull_certificate(**req_copy) + + + def test_delete_zone_origin_pull_certificate_value_error_with_retries(self): + # Enable retries and run test_delete_zone_origin_pull_certificate_value_error. + _service.enable_retries() + self.test_delete_zone_origin_pull_certificate_value_error() + + # Disable retries and run test_delete_zone_origin_pull_certificate_value_error. + _service.disable_retries() + self.test_delete_zone_origin_pull_certificate_value_error() + +# endregion +############################################################################## +# End of Service: ZoneLevelAuthenticatedOriginPull +############################################################################## + +############################################################################## +# Start of Service: PerHostnameAuthenticatedOriginPull +############################################################################## +# region + +class TestNewInstance(): + """ + Test Class for new_instance + """ + + def test_new_instance(self): + """ + new_instance() + """ + os.environ['TEST_SERVICE_AUTH_TYPE'] = 'noAuth' + + service = AuthenticatedOriginPullApiV1.new_instance( + crn=crn, + zone_identifier=zone_identifier, + service_name='TEST_SERVICE', + ) + + assert service is not None + assert isinstance(service, AuthenticatedOriginPullApiV1) + + def test_new_instance_without_authenticator(self): + """ + new_instance_without_authenticator() + """ + with pytest.raises(ValueError, match='authenticator must be provided'): + service = AuthenticatedOriginPullApiV1.new_instance( + crn=crn, + zone_identifier=zone_identifier, + 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 = AuthenticatedOriginPullApiV1.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 = AuthenticatedOriginPullApiV1.new_instance( + crn=None, + zone_identifier=None, + ) +class TestSetHostnameOriginPullSettings(): + """ + Test Class for set_hostname_origin_pull_settings + """ + + @responses.activate + def test_set_hostname_origin_pull_settings_all_params(self): + """ + set_hostname_origin_pull_settings() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/origin_tls_client_auth/hostnames') + mock_response = '{"result": [{"hostname": "app.example.com", "cert_id": "2458ce5a-0c35-4c7f-82c7-8e9487d3ff60", "enabled": true, "status": "active", "created_at": "2100-01-01T05:20:00.000Z", "updated_at": "2100-01-01T05:20:00.000Z", "cert_status": "active", "issuer": "GlobalSign", "signature": "SHA256WithRSA", "serial_number": "6743787633689793699141714808227354901", "certificate": "-----BEGIN CERTIFICATE-----\n......\n-----END CERTIFICATE-----\n", "cert_uploaded_on": "2019-10-28T18:11:23.374Z", "cert_updated_at": "2100-01-01T05:20:00.000Z", "expires_on": "2100-01-01T05:20:00.000Z"}], "success": true, "errors": ["errors"], "messages": ["messages"]}' + responses.add(responses.PUT, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Construct a dict representation of a HostnameOriginPullSettings model + hostname_origin_pull_settings_model = {} + hostname_origin_pull_settings_model['hostname'] = 'app.example.com' + hostname_origin_pull_settings_model['cert_id'] = '2458ce5a-0c35-4c7f-82c7-8e9487d3ff60' + hostname_origin_pull_settings_model['enabled'] = True + + # Set up parameter values + config = [hostname_origin_pull_settings_model] + x_correlation_id = 'testString' + + # Invoke method + response = _service.set_hostname_origin_pull_settings( + config=config, + x_correlation_id=x_correlation_id, + 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['config'] == [hostname_origin_pull_settings_model] + + def test_set_hostname_origin_pull_settings_all_params_with_retries(self): + # Enable retries and run test_set_hostname_origin_pull_settings_all_params. + _service.enable_retries() + self.test_set_hostname_origin_pull_settings_all_params() + + # Disable retries and run test_set_hostname_origin_pull_settings_all_params. + _service.disable_retries() + self.test_set_hostname_origin_pull_settings_all_params() + + @responses.activate + def test_set_hostname_origin_pull_settings_required_params(self): + """ + test_set_hostname_origin_pull_settings_required_params() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/origin_tls_client_auth/hostnames') + mock_response = '{"result": [{"hostname": "app.example.com", "cert_id": "2458ce5a-0c35-4c7f-82c7-8e9487d3ff60", "enabled": true, "status": "active", "created_at": "2100-01-01T05:20:00.000Z", "updated_at": "2100-01-01T05:20:00.000Z", "cert_status": "active", "issuer": "GlobalSign", "signature": "SHA256WithRSA", "serial_number": "6743787633689793699141714808227354901", "certificate": "-----BEGIN CERTIFICATE-----\n......\n-----END CERTIFICATE-----\n", "cert_uploaded_on": "2019-10-28T18:11:23.374Z", "cert_updated_at": "2100-01-01T05:20:00.000Z", "expires_on": "2100-01-01T05:20:00.000Z"}], "success": true, "errors": ["errors"], "messages": ["messages"]}' + responses.add(responses.PUT, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Invoke method + response = _service.set_hostname_origin_pull_settings() + + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_set_hostname_origin_pull_settings_required_params_with_retries(self): + # Enable retries and run test_set_hostname_origin_pull_settings_required_params. + _service.enable_retries() + self.test_set_hostname_origin_pull_settings_required_params() + + # Disable retries and run test_set_hostname_origin_pull_settings_required_params. + _service.disable_retries() + self.test_set_hostname_origin_pull_settings_required_params() + + @responses.activate + def test_set_hostname_origin_pull_settings_value_error(self): + """ + test_set_hostname_origin_pull_settings_value_error() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/origin_tls_client_auth/hostnames') + mock_response = '{"result": [{"hostname": "app.example.com", "cert_id": "2458ce5a-0c35-4c7f-82c7-8e9487d3ff60", "enabled": true, "status": "active", "created_at": "2100-01-01T05:20:00.000Z", "updated_at": "2100-01-01T05:20:00.000Z", "cert_status": "active", "issuer": "GlobalSign", "signature": "SHA256WithRSA", "serial_number": "6743787633689793699141714808227354901", "certificate": "-----BEGIN CERTIFICATE-----\n......\n-----END CERTIFICATE-----\n", "cert_uploaded_on": "2019-10-28T18:11:23.374Z", "cert_updated_at": "2100-01-01T05:20:00.000Z", "expires_on": "2100-01-01T05:20:00.000Z"}], "success": true, "errors": ["errors"], "messages": ["messages"]}' + 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.set_hostname_origin_pull_settings(**req_copy) + + + def test_set_hostname_origin_pull_settings_value_error_with_retries(self): + # Enable retries and run test_set_hostname_origin_pull_settings_value_error. + _service.enable_retries() + self.test_set_hostname_origin_pull_settings_value_error() + + # Disable retries and run test_set_hostname_origin_pull_settings_value_error. + _service.disable_retries() + self.test_set_hostname_origin_pull_settings_value_error() + +class TestGetHostnameOriginPullSettings(): + """ + Test Class for get_hostname_origin_pull_settings + """ + + @responses.activate + def test_get_hostname_origin_pull_settings_all_params(self): + """ + get_hostname_origin_pull_settings() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/origin_tls_client_auth/hostnames/testString') + mock_response = '{"result": {"hostname": "app.example.com", "cert_id": "2458ce5a-0c35-4c7f-82c7-8e9487d3ff60", "enabled": true, "status": "active", "created_at": "2100-01-01T05:20:00.000Z", "updated_at": "2100-01-01T05:20:00.000Z", "cert_status": "active", "issuer": "GlobalSign", "signature": "SHA256WithRSA", "serial_number": "6743787633689793699141714808227354901", "certificate": "-----BEGIN CERTIFICATE-----\n......\n-----END CERTIFICATE-----\n", "cert_uploaded_on": "2019-10-28T18:11:23.374Z", "cert_updated_at": "2100-01-01T05:20:00.000Z", "expires_on": "2100-01-01T05:20:00.000Z"}, "success": true, "errors": ["errors"], "messages": ["messages"]}' + responses.add(responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Set up parameter values + hostname = 'testString' + x_correlation_id = 'testString' + + # Invoke method + response = _service.get_hostname_origin_pull_settings( + hostname, + x_correlation_id=x_correlation_id, + headers={} + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_get_hostname_origin_pull_settings_all_params_with_retries(self): + # Enable retries and run test_get_hostname_origin_pull_settings_all_params. + _service.enable_retries() + self.test_get_hostname_origin_pull_settings_all_params() + + # Disable retries and run test_get_hostname_origin_pull_settings_all_params. + _service.disable_retries() + self.test_get_hostname_origin_pull_settings_all_params() + + @responses.activate + def test_get_hostname_origin_pull_settings_required_params(self): + """ + test_get_hostname_origin_pull_settings_required_params() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/origin_tls_client_auth/hostnames/testString') + mock_response = '{"result": {"hostname": "app.example.com", "cert_id": "2458ce5a-0c35-4c7f-82c7-8e9487d3ff60", "enabled": true, "status": "active", "created_at": "2100-01-01T05:20:00.000Z", "updated_at": "2100-01-01T05:20:00.000Z", "cert_status": "active", "issuer": "GlobalSign", "signature": "SHA256WithRSA", "serial_number": "6743787633689793699141714808227354901", "certificate": "-----BEGIN CERTIFICATE-----\n......\n-----END CERTIFICATE-----\n", "cert_uploaded_on": "2019-10-28T18:11:23.374Z", "cert_updated_at": "2100-01-01T05:20:00.000Z", "expires_on": "2100-01-01T05:20:00.000Z"}, "success": true, "errors": ["errors"], "messages": ["messages"]}' + responses.add(responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Set up parameter values + hostname = 'testString' + + # Invoke method + response = _service.get_hostname_origin_pull_settings( + hostname, + headers={} + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_get_hostname_origin_pull_settings_required_params_with_retries(self): + # Enable retries and run test_get_hostname_origin_pull_settings_required_params. + _service.enable_retries() + self.test_get_hostname_origin_pull_settings_required_params() + + # Disable retries and run test_get_hostname_origin_pull_settings_required_params. + _service.disable_retries() + self.test_get_hostname_origin_pull_settings_required_params() + + @responses.activate + def test_get_hostname_origin_pull_settings_value_error(self): + """ + test_get_hostname_origin_pull_settings_value_error() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/origin_tls_client_auth/hostnames/testString') + mock_response = '{"result": {"hostname": "app.example.com", "cert_id": "2458ce5a-0c35-4c7f-82c7-8e9487d3ff60", "enabled": true, "status": "active", "created_at": "2100-01-01T05:20:00.000Z", "updated_at": "2100-01-01T05:20:00.000Z", "cert_status": "active", "issuer": "GlobalSign", "signature": "SHA256WithRSA", "serial_number": "6743787633689793699141714808227354901", "certificate": "-----BEGIN CERTIFICATE-----\n......\n-----END CERTIFICATE-----\n", "cert_uploaded_on": "2019-10-28T18:11:23.374Z", "cert_updated_at": "2100-01-01T05:20:00.000Z", "expires_on": "2100-01-01T05:20:00.000Z"}, "success": true, "errors": ["errors"], "messages": ["messages"]}' + responses.add(responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Set up parameter values + hostname = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "hostname": hostname, + } + 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_hostname_origin_pull_settings(**req_copy) + + + def test_get_hostname_origin_pull_settings_value_error_with_retries(self): + # Enable retries and run test_get_hostname_origin_pull_settings_value_error. + _service.enable_retries() + self.test_get_hostname_origin_pull_settings_value_error() + + # Disable retries and run test_get_hostname_origin_pull_settings_value_error. + _service.disable_retries() + self.test_get_hostname_origin_pull_settings_value_error() + +class TestUploadHostnameOriginPullCertificate(): + """ + Test Class for upload_hostname_origin_pull_certificate + """ + + @responses.activate + def test_upload_hostname_origin_pull_certificate_all_params(self): + """ + upload_hostname_origin_pull_certificate() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/origin_tls_client_auth/hostnames/certificates') + mock_response = '{"result": {"id": "0f405ba2-8c18-49eb-a30b-28b85427780f", "certificate": "-----BEGIN CERTIFICATE-----\n......\n-----END CERTIFICATE-----\n", "issuer": "GlobalSign", "signature": "SHA256WithRSA", "serial_number": "6743787633689793699141714808227354901", "status": "active", "expires_on": "2100-01-01T05:20:00Z", "uploaded_on": "2100-01-01T05:20:00Z"}, "success": true, "errors": ["errors"], "messages": ["messages"]}' + responses.add(responses.POST, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Set up parameter values + certificate = '-----BEGIN CERTIFICATE-----\n......\n-----END CERTIFICATE-----\n' + private_key = '-----BEGIN RSA PRIVATE KEY-----\n......\n-----END RSA PRIVATE KEY-----\n' + x_correlation_id = 'testString' + + # Invoke method + response = _service.upload_hostname_origin_pull_certificate( + certificate=certificate, + private_key=private_key, + x_correlation_id=x_correlation_id, + 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['certificate'] == '-----BEGIN CERTIFICATE-----\n......\n-----END CERTIFICATE-----\n' + assert req_body['private_key'] == '-----BEGIN RSA PRIVATE KEY-----\n......\n-----END RSA PRIVATE KEY-----\n' + + def test_upload_hostname_origin_pull_certificate_all_params_with_retries(self): + # Enable retries and run test_upload_hostname_origin_pull_certificate_all_params. + _service.enable_retries() + self.test_upload_hostname_origin_pull_certificate_all_params() + + # Disable retries and run test_upload_hostname_origin_pull_certificate_all_params. + _service.disable_retries() + self.test_upload_hostname_origin_pull_certificate_all_params() + + @responses.activate + def test_upload_hostname_origin_pull_certificate_required_params(self): + """ + test_upload_hostname_origin_pull_certificate_required_params() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/origin_tls_client_auth/hostnames/certificates') + mock_response = '{"result": {"id": "0f405ba2-8c18-49eb-a30b-28b85427780f", "certificate": "-----BEGIN CERTIFICATE-----\n......\n-----END CERTIFICATE-----\n", "issuer": "GlobalSign", "signature": "SHA256WithRSA", "serial_number": "6743787633689793699141714808227354901", "status": "active", "expires_on": "2100-01-01T05:20:00Z", "uploaded_on": "2100-01-01T05:20:00Z"}, "success": true, "errors": ["errors"], "messages": ["messages"]}' + responses.add(responses.POST, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Invoke method + response = _service.upload_hostname_origin_pull_certificate() + + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_upload_hostname_origin_pull_certificate_required_params_with_retries(self): + # Enable retries and run test_upload_hostname_origin_pull_certificate_required_params. + _service.enable_retries() + self.test_upload_hostname_origin_pull_certificate_required_params() + + # Disable retries and run test_upload_hostname_origin_pull_certificate_required_params. + _service.disable_retries() + self.test_upload_hostname_origin_pull_certificate_required_params() + + @responses.activate + def test_upload_hostname_origin_pull_certificate_value_error(self): + """ + test_upload_hostname_origin_pull_certificate_value_error() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/origin_tls_client_auth/hostnames/certificates') + mock_response = '{"result": {"id": "0f405ba2-8c18-49eb-a30b-28b85427780f", "certificate": "-----BEGIN CERTIFICATE-----\n......\n-----END CERTIFICATE-----\n", "issuer": "GlobalSign", "signature": "SHA256WithRSA", "serial_number": "6743787633689793699141714808227354901", "status": "active", "expires_on": "2100-01-01T05:20:00Z", "uploaded_on": "2100-01-01T05:20:00Z"}, "success": true, "errors": ["errors"], "messages": ["messages"]}' + 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.upload_hostname_origin_pull_certificate(**req_copy) + + + def test_upload_hostname_origin_pull_certificate_value_error_with_retries(self): + # Enable retries and run test_upload_hostname_origin_pull_certificate_value_error. + _service.enable_retries() + self.test_upload_hostname_origin_pull_certificate_value_error() + + # Disable retries and run test_upload_hostname_origin_pull_certificate_value_error. + _service.disable_retries() + self.test_upload_hostname_origin_pull_certificate_value_error() + +class TestGetHostnameOriginPullCertificate(): + """ + Test Class for get_hostname_origin_pull_certificate + """ + + @responses.activate + def test_get_hostname_origin_pull_certificate_all_params(self): + """ + get_hostname_origin_pull_certificate() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/origin_tls_client_auth/hostnames/certificates/testString') + mock_response = '{"result": {"id": "0f405ba2-8c18-49eb-a30b-28b85427780f", "certificate": "-----BEGIN CERTIFICATE-----\n......\n-----END CERTIFICATE-----\n", "issuer": "GlobalSign", "signature": "SHA256WithRSA", "serial_number": "6743787633689793699141714808227354901", "status": "active", "expires_on": "2100-01-01T05:20:00Z", "uploaded_on": "2100-01-01T05:20:00Z"}, "success": true, "errors": ["errors"], "messages": ["messages"]}' + responses.add(responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Set up parameter values + cert_identifier = 'testString' + x_correlation_id = 'testString' + + # Invoke method + response = _service.get_hostname_origin_pull_certificate( + cert_identifier, + x_correlation_id=x_correlation_id, + headers={} + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_get_hostname_origin_pull_certificate_all_params_with_retries(self): + # Enable retries and run test_get_hostname_origin_pull_certificate_all_params. + _service.enable_retries() + self.test_get_hostname_origin_pull_certificate_all_params() + + # Disable retries and run test_get_hostname_origin_pull_certificate_all_params. + _service.disable_retries() + self.test_get_hostname_origin_pull_certificate_all_params() + + @responses.activate + def test_get_hostname_origin_pull_certificate_required_params(self): + """ + test_get_hostname_origin_pull_certificate_required_params() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/origin_tls_client_auth/hostnames/certificates/testString') + mock_response = '{"result": {"id": "0f405ba2-8c18-49eb-a30b-28b85427780f", "certificate": "-----BEGIN CERTIFICATE-----\n......\n-----END CERTIFICATE-----\n", "issuer": "GlobalSign", "signature": "SHA256WithRSA", "serial_number": "6743787633689793699141714808227354901", "status": "active", "expires_on": "2100-01-01T05:20:00Z", "uploaded_on": "2100-01-01T05:20:00Z"}, "success": true, "errors": ["errors"], "messages": ["messages"]}' + responses.add(responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Set up parameter values + cert_identifier = 'testString' + + # Invoke method + response = _service.get_hostname_origin_pull_certificate( + cert_identifier, + headers={} + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_get_hostname_origin_pull_certificate_required_params_with_retries(self): + # Enable retries and run test_get_hostname_origin_pull_certificate_required_params. + _service.enable_retries() + self.test_get_hostname_origin_pull_certificate_required_params() + + # Disable retries and run test_get_hostname_origin_pull_certificate_required_params. + _service.disable_retries() + self.test_get_hostname_origin_pull_certificate_required_params() + + @responses.activate + def test_get_hostname_origin_pull_certificate_value_error(self): + """ + test_get_hostname_origin_pull_certificate_value_error() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/origin_tls_client_auth/hostnames/certificates/testString') + mock_response = '{"result": {"id": "0f405ba2-8c18-49eb-a30b-28b85427780f", "certificate": "-----BEGIN CERTIFICATE-----\n......\n-----END CERTIFICATE-----\n", "issuer": "GlobalSign", "signature": "SHA256WithRSA", "serial_number": "6743787633689793699141714808227354901", "status": "active", "expires_on": "2100-01-01T05:20:00Z", "uploaded_on": "2100-01-01T05:20:00Z"}, "success": true, "errors": ["errors"], "messages": ["messages"]}' + responses.add(responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Set up parameter values + cert_identifier = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "cert_identifier": cert_identifier, + } + for param in req_param_dict.keys(): + req_copy = {key:val if key is not param else None for (key,val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.get_hostname_origin_pull_certificate(**req_copy) + + + def test_get_hostname_origin_pull_certificate_value_error_with_retries(self): + # Enable retries and run test_get_hostname_origin_pull_certificate_value_error. + _service.enable_retries() + self.test_get_hostname_origin_pull_certificate_value_error() + + # Disable retries and run test_get_hostname_origin_pull_certificate_value_error. + _service.disable_retries() + self.test_get_hostname_origin_pull_certificate_value_error() + +class TestDeleteHostnameOriginPullCertificate(): + """ + Test Class for delete_hostname_origin_pull_certificate + """ + + @responses.activate + def test_delete_hostname_origin_pull_certificate_all_params(self): + """ + delete_hostname_origin_pull_certificate() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/origin_tls_client_auth/hostnames/certificates/testString') + mock_response = '{"result": {"id": "0f405ba2-8c18-49eb-a30b-28b85427780f", "certificate": "-----BEGIN CERTIFICATE-----\n......\n-----END CERTIFICATE-----\n", "issuer": "GlobalSign", "signature": "SHA256WithRSA", "serial_number": "6743787633689793699141714808227354901", "status": "active", "expires_on": "2100-01-01T05:20:00Z", "uploaded_on": "2100-01-01T05:20:00Z"}, "success": true, "errors": ["errors"], "messages": ["messages"]}' + responses.add(responses.DELETE, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Set up parameter values + cert_identifier = 'testString' + x_correlation_id = 'testString' + + # Invoke method + response = _service.delete_hostname_origin_pull_certificate( + cert_identifier, + x_correlation_id=x_correlation_id, + headers={} + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_delete_hostname_origin_pull_certificate_all_params_with_retries(self): + # Enable retries and run test_delete_hostname_origin_pull_certificate_all_params. + _service.enable_retries() + self.test_delete_hostname_origin_pull_certificate_all_params() + + # Disable retries and run test_delete_hostname_origin_pull_certificate_all_params. + _service.disable_retries() + self.test_delete_hostname_origin_pull_certificate_all_params() + + @responses.activate + def test_delete_hostname_origin_pull_certificate_required_params(self): + """ + test_delete_hostname_origin_pull_certificate_required_params() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/origin_tls_client_auth/hostnames/certificates/testString') + mock_response = '{"result": {"id": "0f405ba2-8c18-49eb-a30b-28b85427780f", "certificate": "-----BEGIN CERTIFICATE-----\n......\n-----END CERTIFICATE-----\n", "issuer": "GlobalSign", "signature": "SHA256WithRSA", "serial_number": "6743787633689793699141714808227354901", "status": "active", "expires_on": "2100-01-01T05:20:00Z", "uploaded_on": "2100-01-01T05:20:00Z"}, "success": true, "errors": ["errors"], "messages": ["messages"]}' + responses.add(responses.DELETE, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Set up parameter values + cert_identifier = 'testString' + + # Invoke method + response = _service.delete_hostname_origin_pull_certificate( + cert_identifier, + headers={} + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_delete_hostname_origin_pull_certificate_required_params_with_retries(self): + # Enable retries and run test_delete_hostname_origin_pull_certificate_required_params. + _service.enable_retries() + self.test_delete_hostname_origin_pull_certificate_required_params() + + # Disable retries and run test_delete_hostname_origin_pull_certificate_required_params. + _service.disable_retries() + self.test_delete_hostname_origin_pull_certificate_required_params() + + @responses.activate + def test_delete_hostname_origin_pull_certificate_value_error(self): + """ + test_delete_hostname_origin_pull_certificate_value_error() + """ + # Set up mock + url = preprocess_url('/v1/testString/zones/testString/origin_tls_client_auth/hostnames/certificates/testString') + mock_response = '{"result": {"id": "0f405ba2-8c18-49eb-a30b-28b85427780f", "certificate": "-----BEGIN CERTIFICATE-----\n......\n-----END CERTIFICATE-----\n", "issuer": "GlobalSign", "signature": "SHA256WithRSA", "serial_number": "6743787633689793699141714808227354901", "status": "active", "expires_on": "2100-01-01T05:20:00Z", "uploaded_on": "2100-01-01T05:20:00Z"}, "success": true, "errors": ["errors"], "messages": ["messages"]}' + responses.add(responses.DELETE, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Set up parameter values + cert_identifier = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "cert_identifier": cert_identifier, + } + for param in req_param_dict.keys(): + req_copy = {key:val if key is not param else None for (key,val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.delete_hostname_origin_pull_certificate(**req_copy) + + + def test_delete_hostname_origin_pull_certificate_value_error_with_retries(self): + # Enable retries and run test_delete_hostname_origin_pull_certificate_value_error. + _service.enable_retries() + self.test_delete_hostname_origin_pull_certificate_value_error() + + # Disable retries and run test_delete_hostname_origin_pull_certificate_value_error. + _service.disable_retries() + self.test_delete_hostname_origin_pull_certificate_value_error() + +# endregion +############################################################################## +# End of Service: PerHostnameAuthenticatedOriginPull +############################################################################## + + +############################################################################## +# Start of Model Tests +############################################################################## +# region +class TestModel_GetZoneOriginPullSettingsRespResult(): + """ + Test Class for GetZoneOriginPullSettingsRespResult + """ + + def test_get_zone_origin_pull_settings_resp_result_serialization(self): + """ + Test serialization/deserialization for GetZoneOriginPullSettingsRespResult + """ + + # Construct a json representation of a GetZoneOriginPullSettingsRespResult model + get_zone_origin_pull_settings_resp_result_model_json = {} + get_zone_origin_pull_settings_resp_result_model_json['enabled'] = True + + # Construct a model instance of GetZoneOriginPullSettingsRespResult by calling from_dict on the json representation + get_zone_origin_pull_settings_resp_result_model = GetZoneOriginPullSettingsRespResult.from_dict(get_zone_origin_pull_settings_resp_result_model_json) + assert get_zone_origin_pull_settings_resp_result_model != False + + # Construct a model instance of GetZoneOriginPullSettingsRespResult by calling from_dict on the json representation + get_zone_origin_pull_settings_resp_result_model_dict = GetZoneOriginPullSettingsRespResult.from_dict(get_zone_origin_pull_settings_resp_result_model_json).__dict__ + get_zone_origin_pull_settings_resp_result_model2 = GetZoneOriginPullSettingsRespResult(**get_zone_origin_pull_settings_resp_result_model_dict) + + # Verify the model instances are equivalent + assert get_zone_origin_pull_settings_resp_result_model == get_zone_origin_pull_settings_resp_result_model2 + + # Convert model instance back to dict and verify no loss of data + get_zone_origin_pull_settings_resp_result_model_json2 = get_zone_origin_pull_settings_resp_result_model.to_dict() + assert get_zone_origin_pull_settings_resp_result_model_json2 == get_zone_origin_pull_settings_resp_result_model_json + +class TestModel_CertificatePack(): + """ + Test Class for CertificatePack + """ + + def test_certificate_pack_serialization(self): + """ + Test serialization/deserialization for CertificatePack + """ + + # Construct a json representation of a CertificatePack model + certificate_pack_model_json = {} + certificate_pack_model_json['id'] = '0f405ba2-8c18-49eb-a30b-28b85427780f' + certificate_pack_model_json['certificate'] = '-----BEGIN CERTIFICATE-----\n......\n-----END CERTIFICATE-----\n' + certificate_pack_model_json['issuer'] = 'GlobalSign' + certificate_pack_model_json['signature'] = 'SHA256WithRSA' + certificate_pack_model_json['status'] = 'active' + certificate_pack_model_json['expires_on'] = '2100-01-01T05:20:00Z' + certificate_pack_model_json['uploaded_on'] = '2100-01-01T05:20:00Z' + + # Construct a model instance of CertificatePack by calling from_dict on the json representation + certificate_pack_model = CertificatePack.from_dict(certificate_pack_model_json) + assert certificate_pack_model != False + + # Construct a model instance of CertificatePack by calling from_dict on the json representation + certificate_pack_model_dict = CertificatePack.from_dict(certificate_pack_model_json).__dict__ + certificate_pack_model2 = CertificatePack(**certificate_pack_model_dict) + + # Verify the model instances are equivalent + assert certificate_pack_model == certificate_pack_model2 + + # Convert model instance back to dict and verify no loss of data + certificate_pack_model_json2 = certificate_pack_model.to_dict() + assert certificate_pack_model_json2 == certificate_pack_model_json + +class TestModel_GetHostnameOriginPullSettingsResp(): + """ + Test Class for GetHostnameOriginPullSettingsResp + """ + + def test_get_hostname_origin_pull_settings_resp_serialization(self): + """ + Test serialization/deserialization for GetHostnameOriginPullSettingsResp + """ + + # Construct dict forms of any model objects needed in order to build this model. + + hostname_settings_resp_model = {} # HostnameSettingsResp + hostname_settings_resp_model['hostname'] = 'app.example.com' + hostname_settings_resp_model['cert_id'] = '2458ce5a-0c35-4c7f-82c7-8e9487d3ff60' + hostname_settings_resp_model['enabled'] = True + hostname_settings_resp_model['status'] = 'active' + hostname_settings_resp_model['created_at'] = '2100-01-01T05:20:00Z' + hostname_settings_resp_model['updated_at'] = '2100-01-01T05:20:00Z' + hostname_settings_resp_model['cert_status'] = 'active' + hostname_settings_resp_model['issuer'] = 'GlobalSign' + hostname_settings_resp_model['signature'] = 'SHA256WithRSA' + hostname_settings_resp_model['serial_number'] = '6743787633689793699141714808227354901' + hostname_settings_resp_model['certificate'] = '-----BEGIN CERTIFICATE-----\n......\n-----END CERTIFICATE-----\n' + hostname_settings_resp_model['cert_uploaded_on'] = '2019-10-28T18:11:23.374000Z' + hostname_settings_resp_model['cert_updated_at'] = '2100-01-01T05:20:00Z' + hostname_settings_resp_model['expires_on'] = '2100-01-01T05:20:00Z' + + # Construct a json representation of a GetHostnameOriginPullSettingsResp model + get_hostname_origin_pull_settings_resp_model_json = {} + get_hostname_origin_pull_settings_resp_model_json['result'] = hostname_settings_resp_model + get_hostname_origin_pull_settings_resp_model_json['success'] = True + get_hostname_origin_pull_settings_resp_model_json['errors'] = ['testString'] + get_hostname_origin_pull_settings_resp_model_json['messages'] = ['testString'] + + # Construct a model instance of GetHostnameOriginPullSettingsResp by calling from_dict on the json representation + get_hostname_origin_pull_settings_resp_model = GetHostnameOriginPullSettingsResp.from_dict(get_hostname_origin_pull_settings_resp_model_json) + assert get_hostname_origin_pull_settings_resp_model != False + + # Construct a model instance of GetHostnameOriginPullSettingsResp by calling from_dict on the json representation + get_hostname_origin_pull_settings_resp_model_dict = GetHostnameOriginPullSettingsResp.from_dict(get_hostname_origin_pull_settings_resp_model_json).__dict__ + get_hostname_origin_pull_settings_resp_model2 = GetHostnameOriginPullSettingsResp(**get_hostname_origin_pull_settings_resp_model_dict) + + # Verify the model instances are equivalent + assert get_hostname_origin_pull_settings_resp_model == get_hostname_origin_pull_settings_resp_model2 + + # Convert model instance back to dict and verify no loss of data + get_hostname_origin_pull_settings_resp_model_json2 = get_hostname_origin_pull_settings_resp_model.to_dict() + assert get_hostname_origin_pull_settings_resp_model_json2 == get_hostname_origin_pull_settings_resp_model_json + +class TestModel_GetZoneOriginPullSettingsResp(): + """ + Test Class for GetZoneOriginPullSettingsResp + """ + + def test_get_zone_origin_pull_settings_resp_serialization(self): + """ + Test serialization/deserialization for GetZoneOriginPullSettingsResp + """ + + # Construct dict forms of any model objects needed in order to build this model. + + get_zone_origin_pull_settings_resp_result_model = {} # GetZoneOriginPullSettingsRespResult + get_zone_origin_pull_settings_resp_result_model['enabled'] = True + + # Construct a json representation of a GetZoneOriginPullSettingsResp model + get_zone_origin_pull_settings_resp_model_json = {} + get_zone_origin_pull_settings_resp_model_json['result'] = get_zone_origin_pull_settings_resp_result_model + get_zone_origin_pull_settings_resp_model_json['success'] = True + get_zone_origin_pull_settings_resp_model_json['errors'] = ['testString'] + get_zone_origin_pull_settings_resp_model_json['messages'] = ['testString'] + + # Construct a model instance of GetZoneOriginPullSettingsResp by calling from_dict on the json representation + get_zone_origin_pull_settings_resp_model = GetZoneOriginPullSettingsResp.from_dict(get_zone_origin_pull_settings_resp_model_json) + assert get_zone_origin_pull_settings_resp_model != False + + # Construct a model instance of GetZoneOriginPullSettingsResp by calling from_dict on the json representation + get_zone_origin_pull_settings_resp_model_dict = GetZoneOriginPullSettingsResp.from_dict(get_zone_origin_pull_settings_resp_model_json).__dict__ + get_zone_origin_pull_settings_resp_model2 = GetZoneOriginPullSettingsResp(**get_zone_origin_pull_settings_resp_model_dict) + + # Verify the model instances are equivalent + assert get_zone_origin_pull_settings_resp_model == get_zone_origin_pull_settings_resp_model2 + + # Convert model instance back to dict and verify no loss of data + get_zone_origin_pull_settings_resp_model_json2 = get_zone_origin_pull_settings_resp_model.to_dict() + assert get_zone_origin_pull_settings_resp_model_json2 == get_zone_origin_pull_settings_resp_model_json + +class TestModel_HostnameCertificatePack(): + """ + Test Class for HostnameCertificatePack + """ + + def test_hostname_certificate_pack_serialization(self): + """ + Test serialization/deserialization for HostnameCertificatePack + """ + + # Construct a json representation of a HostnameCertificatePack model + hostname_certificate_pack_model_json = {} + hostname_certificate_pack_model_json['id'] = '0f405ba2-8c18-49eb-a30b-28b85427780f' + hostname_certificate_pack_model_json['certificate'] = '-----BEGIN CERTIFICATE-----\n......\n-----END CERTIFICATE-----\n' + hostname_certificate_pack_model_json['issuer'] = 'GlobalSign' + hostname_certificate_pack_model_json['signature'] = 'SHA256WithRSA' + hostname_certificate_pack_model_json['serial_number'] = '6743787633689793699141714808227354901' + hostname_certificate_pack_model_json['status'] = 'active' + hostname_certificate_pack_model_json['expires_on'] = '2100-01-01T05:20:00Z' + hostname_certificate_pack_model_json['uploaded_on'] = '2100-01-01T05:20:00Z' + + # Construct a model instance of HostnameCertificatePack by calling from_dict on the json representation + hostname_certificate_pack_model = HostnameCertificatePack.from_dict(hostname_certificate_pack_model_json) + assert hostname_certificate_pack_model != False + + # Construct a model instance of HostnameCertificatePack by calling from_dict on the json representation + hostname_certificate_pack_model_dict = HostnameCertificatePack.from_dict(hostname_certificate_pack_model_json).__dict__ + hostname_certificate_pack_model2 = HostnameCertificatePack(**hostname_certificate_pack_model_dict) + + # Verify the model instances are equivalent + assert hostname_certificate_pack_model == hostname_certificate_pack_model2 + + # Convert model instance back to dict and verify no loss of data + hostname_certificate_pack_model_json2 = hostname_certificate_pack_model.to_dict() + assert hostname_certificate_pack_model_json2 == hostname_certificate_pack_model_json + +class TestModel_HostnameOriginPullCertificateResp(): + """ + Test Class for HostnameOriginPullCertificateResp + """ + + def test_hostname_origin_pull_certificate_resp_serialization(self): + """ + Test serialization/deserialization for HostnameOriginPullCertificateResp + """ + + # Construct dict forms of any model objects needed in order to build this model. + + hostname_certificate_pack_model = {} # HostnameCertificatePack + hostname_certificate_pack_model['id'] = '0f405ba2-8c18-49eb-a30b-28b85427780f' + hostname_certificate_pack_model['certificate'] = '-----BEGIN CERTIFICATE-----\n......\n-----END CERTIFICATE-----\n' + hostname_certificate_pack_model['issuer'] = 'GlobalSign' + hostname_certificate_pack_model['signature'] = 'SHA256WithRSA' + hostname_certificate_pack_model['serial_number'] = '6743787633689793699141714808227354901' + hostname_certificate_pack_model['status'] = 'active' + hostname_certificate_pack_model['expires_on'] = '2100-01-01T05:20:00Z' + hostname_certificate_pack_model['uploaded_on'] = '2100-01-01T05:20:00Z' + + # Construct a json representation of a HostnameOriginPullCertificateResp model + hostname_origin_pull_certificate_resp_model_json = {} + hostname_origin_pull_certificate_resp_model_json['result'] = hostname_certificate_pack_model + hostname_origin_pull_certificate_resp_model_json['success'] = True + hostname_origin_pull_certificate_resp_model_json['errors'] = ['testString'] + hostname_origin_pull_certificate_resp_model_json['messages'] = ['testString'] + + # Construct a model instance of HostnameOriginPullCertificateResp by calling from_dict on the json representation + hostname_origin_pull_certificate_resp_model = HostnameOriginPullCertificateResp.from_dict(hostname_origin_pull_certificate_resp_model_json) + assert hostname_origin_pull_certificate_resp_model != False + + # Construct a model instance of HostnameOriginPullCertificateResp by calling from_dict on the json representation + hostname_origin_pull_certificate_resp_model_dict = HostnameOriginPullCertificateResp.from_dict(hostname_origin_pull_certificate_resp_model_json).__dict__ + hostname_origin_pull_certificate_resp_model2 = HostnameOriginPullCertificateResp(**hostname_origin_pull_certificate_resp_model_dict) + + # Verify the model instances are equivalent + assert hostname_origin_pull_certificate_resp_model == hostname_origin_pull_certificate_resp_model2 + + # Convert model instance back to dict and verify no loss of data + hostname_origin_pull_certificate_resp_model_json2 = hostname_origin_pull_certificate_resp_model.to_dict() + assert hostname_origin_pull_certificate_resp_model_json2 == hostname_origin_pull_certificate_resp_model_json + +class TestModel_HostnameOriginPullSettings(): + """ + Test Class for HostnameOriginPullSettings + """ + + def test_hostname_origin_pull_settings_serialization(self): + """ + Test serialization/deserialization for HostnameOriginPullSettings + """ + + # Construct a json representation of a HostnameOriginPullSettings model + hostname_origin_pull_settings_model_json = {} + hostname_origin_pull_settings_model_json['hostname'] = 'app.example.com' + hostname_origin_pull_settings_model_json['cert_id'] = '2458ce5a-0c35-4c7f-82c7-8e9487d3ff60' + hostname_origin_pull_settings_model_json['enabled'] = True + + # Construct a model instance of HostnameOriginPullSettings by calling from_dict on the json representation + hostname_origin_pull_settings_model = HostnameOriginPullSettings.from_dict(hostname_origin_pull_settings_model_json) + assert hostname_origin_pull_settings_model != False + + # Construct a model instance of HostnameOriginPullSettings by calling from_dict on the json representation + hostname_origin_pull_settings_model_dict = HostnameOriginPullSettings.from_dict(hostname_origin_pull_settings_model_json).__dict__ + hostname_origin_pull_settings_model2 = HostnameOriginPullSettings(**hostname_origin_pull_settings_model_dict) + + # Verify the model instances are equivalent + assert hostname_origin_pull_settings_model == hostname_origin_pull_settings_model2 + + # Convert model instance back to dict and verify no loss of data + hostname_origin_pull_settings_model_json2 = hostname_origin_pull_settings_model.to_dict() + assert hostname_origin_pull_settings_model_json2 == hostname_origin_pull_settings_model_json + +class TestModel_HostnameSettingsResp(): + """ + Test Class for HostnameSettingsResp + """ + + def test_hostname_settings_resp_serialization(self): + """ + Test serialization/deserialization for HostnameSettingsResp + """ + + # Construct a json representation of a HostnameSettingsResp model + hostname_settings_resp_model_json = {} + hostname_settings_resp_model_json['hostname'] = 'app.example.com' + hostname_settings_resp_model_json['cert_id'] = '2458ce5a-0c35-4c7f-82c7-8e9487d3ff60' + hostname_settings_resp_model_json['enabled'] = True + hostname_settings_resp_model_json['status'] = 'active' + hostname_settings_resp_model_json['created_at'] = '2100-01-01T05:20:00Z' + hostname_settings_resp_model_json['updated_at'] = '2100-01-01T05:20:00Z' + hostname_settings_resp_model_json['cert_status'] = 'active' + hostname_settings_resp_model_json['issuer'] = 'GlobalSign' + hostname_settings_resp_model_json['signature'] = 'SHA256WithRSA' + hostname_settings_resp_model_json['serial_number'] = '6743787633689793699141714808227354901' + hostname_settings_resp_model_json['certificate'] = '-----BEGIN CERTIFICATE-----\n......\n-----END CERTIFICATE-----\n' + hostname_settings_resp_model_json['cert_uploaded_on'] = '2019-10-28T18:11:23.374000Z' + hostname_settings_resp_model_json['cert_updated_at'] = '2100-01-01T05:20:00Z' + hostname_settings_resp_model_json['expires_on'] = '2100-01-01T05:20:00Z' + + # Construct a model instance of HostnameSettingsResp by calling from_dict on the json representation + hostname_settings_resp_model = HostnameSettingsResp.from_dict(hostname_settings_resp_model_json) + assert hostname_settings_resp_model != False + + # Construct a model instance of HostnameSettingsResp by calling from_dict on the json representation + hostname_settings_resp_model_dict = HostnameSettingsResp.from_dict(hostname_settings_resp_model_json).__dict__ + hostname_settings_resp_model2 = HostnameSettingsResp(**hostname_settings_resp_model_dict) + + # Verify the model instances are equivalent + assert hostname_settings_resp_model == hostname_settings_resp_model2 + + # Convert model instance back to dict and verify no loss of data + hostname_settings_resp_model_json2 = hostname_settings_resp_model.to_dict() + assert hostname_settings_resp_model_json2 == hostname_settings_resp_model_json + +class TestModel_ListHostnameOriginPullSettingsResp(): + """ + Test Class for ListHostnameOriginPullSettingsResp + """ + + def test_list_hostname_origin_pull_settings_resp_serialization(self): + """ + Test serialization/deserialization for ListHostnameOriginPullSettingsResp + """ + + # Construct dict forms of any model objects needed in order to build this model. + + hostname_settings_resp_model = {} # HostnameSettingsResp + hostname_settings_resp_model['hostname'] = 'app.example.com' + hostname_settings_resp_model['cert_id'] = '2458ce5a-0c35-4c7f-82c7-8e9487d3ff60' + hostname_settings_resp_model['enabled'] = True + hostname_settings_resp_model['status'] = 'active' + hostname_settings_resp_model['created_at'] = '2100-01-01T05:20:00Z' + hostname_settings_resp_model['updated_at'] = '2100-01-01T05:20:00Z' + hostname_settings_resp_model['cert_status'] = 'active' + hostname_settings_resp_model['issuer'] = 'GlobalSign' + hostname_settings_resp_model['signature'] = 'SHA256WithRSA' + hostname_settings_resp_model['serial_number'] = '6743787633689793699141714808227354901' + hostname_settings_resp_model['certificate'] = '-----BEGIN CERTIFICATE-----\n......\n-----END CERTIFICATE-----\n' + hostname_settings_resp_model['cert_uploaded_on'] = '2019-10-28T18:11:23.374000Z' + hostname_settings_resp_model['cert_updated_at'] = '2100-01-01T05:20:00Z' + hostname_settings_resp_model['expires_on'] = '2100-01-01T05:20:00Z' + + # Construct a json representation of a ListHostnameOriginPullSettingsResp model + list_hostname_origin_pull_settings_resp_model_json = {} + list_hostname_origin_pull_settings_resp_model_json['result'] = [hostname_settings_resp_model] + list_hostname_origin_pull_settings_resp_model_json['success'] = True + list_hostname_origin_pull_settings_resp_model_json['errors'] = ['testString'] + list_hostname_origin_pull_settings_resp_model_json['messages'] = ['testString'] + + # Construct a model instance of ListHostnameOriginPullSettingsResp by calling from_dict on the json representation + list_hostname_origin_pull_settings_resp_model = ListHostnameOriginPullSettingsResp.from_dict(list_hostname_origin_pull_settings_resp_model_json) + assert list_hostname_origin_pull_settings_resp_model != False + + # Construct a model instance of ListHostnameOriginPullSettingsResp by calling from_dict on the json representation + list_hostname_origin_pull_settings_resp_model_dict = ListHostnameOriginPullSettingsResp.from_dict(list_hostname_origin_pull_settings_resp_model_json).__dict__ + list_hostname_origin_pull_settings_resp_model2 = ListHostnameOriginPullSettingsResp(**list_hostname_origin_pull_settings_resp_model_dict) + + # Verify the model instances are equivalent + assert list_hostname_origin_pull_settings_resp_model == list_hostname_origin_pull_settings_resp_model2 + + # Convert model instance back to dict and verify no loss of data + list_hostname_origin_pull_settings_resp_model_json2 = list_hostname_origin_pull_settings_resp_model.to_dict() + assert list_hostname_origin_pull_settings_resp_model_json2 == list_hostname_origin_pull_settings_resp_model_json + +class TestModel_ListZoneOriginPullCertificatesResp(): + """ + Test Class for ListZoneOriginPullCertificatesResp + """ + + def test_list_zone_origin_pull_certificates_resp_serialization(self): + """ + Test serialization/deserialization for ListZoneOriginPullCertificatesResp + """ + + # Construct dict forms of any model objects needed in order to build this model. + + certificate_pack_model = {} # CertificatePack + certificate_pack_model['id'] = '0f405ba2-8c18-49eb-a30b-28b85427780f' + certificate_pack_model['certificate'] = '-----BEGIN CERTIFICATE-----\n......\n-----END CERTIFICATE-----\n' + certificate_pack_model['issuer'] = 'GlobalSign' + certificate_pack_model['signature'] = 'SHA256WithRSA' + certificate_pack_model['status'] = 'active' + certificate_pack_model['expires_on'] = '2100-01-01T05:20:00Z' + certificate_pack_model['uploaded_on'] = '2100-01-01T05:20:00Z' + + # Construct a json representation of a ListZoneOriginPullCertificatesResp model + list_zone_origin_pull_certificates_resp_model_json = {} + list_zone_origin_pull_certificates_resp_model_json['result'] = [certificate_pack_model] + list_zone_origin_pull_certificates_resp_model_json['success'] = True + list_zone_origin_pull_certificates_resp_model_json['errors'] = ['testString'] + list_zone_origin_pull_certificates_resp_model_json['messages'] = ['testString'] + + # Construct a model instance of ListZoneOriginPullCertificatesResp by calling from_dict on the json representation + list_zone_origin_pull_certificates_resp_model = ListZoneOriginPullCertificatesResp.from_dict(list_zone_origin_pull_certificates_resp_model_json) + assert list_zone_origin_pull_certificates_resp_model != False + + # Construct a model instance of ListZoneOriginPullCertificatesResp by calling from_dict on the json representation + list_zone_origin_pull_certificates_resp_model_dict = ListZoneOriginPullCertificatesResp.from_dict(list_zone_origin_pull_certificates_resp_model_json).__dict__ + list_zone_origin_pull_certificates_resp_model2 = ListZoneOriginPullCertificatesResp(**list_zone_origin_pull_certificates_resp_model_dict) + + # Verify the model instances are equivalent + assert list_zone_origin_pull_certificates_resp_model == list_zone_origin_pull_certificates_resp_model2 + + # Convert model instance back to dict and verify no loss of data + list_zone_origin_pull_certificates_resp_model_json2 = list_zone_origin_pull_certificates_resp_model.to_dict() + assert list_zone_origin_pull_certificates_resp_model_json2 == list_zone_origin_pull_certificates_resp_model_json + +class TestModel_ZoneOriginPullCertificateResp(): + """ + Test Class for ZoneOriginPullCertificateResp + """ + + def test_zone_origin_pull_certificate_resp_serialization(self): + """ + Test serialization/deserialization for ZoneOriginPullCertificateResp + """ + + # Construct dict forms of any model objects needed in order to build this model. + + certificate_pack_model = {} # CertificatePack + certificate_pack_model['id'] = '0f405ba2-8c18-49eb-a30b-28b85427780f' + certificate_pack_model['certificate'] = '-----BEGIN CERTIFICATE-----\n......\n-----END CERTIFICATE-----\n' + certificate_pack_model['issuer'] = 'GlobalSign' + certificate_pack_model['signature'] = 'SHA256WithRSA' + certificate_pack_model['status'] = 'active' + certificate_pack_model['expires_on'] = '2100-01-01T05:20:00Z' + certificate_pack_model['uploaded_on'] = '2100-01-01T05:20:00Z' + + # Construct a json representation of a ZoneOriginPullCertificateResp model + zone_origin_pull_certificate_resp_model_json = {} + zone_origin_pull_certificate_resp_model_json['result'] = certificate_pack_model + zone_origin_pull_certificate_resp_model_json['success'] = True + zone_origin_pull_certificate_resp_model_json['errors'] = ['testString'] + zone_origin_pull_certificate_resp_model_json['messages'] = ['testString'] + + # Construct a model instance of ZoneOriginPullCertificateResp by calling from_dict on the json representation + zone_origin_pull_certificate_resp_model = ZoneOriginPullCertificateResp.from_dict(zone_origin_pull_certificate_resp_model_json) + assert zone_origin_pull_certificate_resp_model != False + + # Construct a model instance of ZoneOriginPullCertificateResp by calling from_dict on the json representation + zone_origin_pull_certificate_resp_model_dict = ZoneOriginPullCertificateResp.from_dict(zone_origin_pull_certificate_resp_model_json).__dict__ + zone_origin_pull_certificate_resp_model2 = ZoneOriginPullCertificateResp(**zone_origin_pull_certificate_resp_model_dict) + + # Verify the model instances are equivalent + assert zone_origin_pull_certificate_resp_model == zone_origin_pull_certificate_resp_model2 + + # Convert model instance back to dict and verify no loss of data + zone_origin_pull_certificate_resp_model_json2 = zone_origin_pull_certificate_resp_model.to_dict() + assert zone_origin_pull_certificate_resp_model_json2 == zone_origin_pull_certificate_resp_model_json + + +# endregion +############################################################################## +# End of Model Tests +##############################################################################