o
    ɶd                     @   s   d dl mZ d dlmZ d dlmZ d dlmZmZ d dlm	Z	 d dl
mZmZ d dlmZ d dlmZmZmZ d	d
lmZ edZG dd deZdS )    )absolute_import)requests)six)retrycircuit_breaker)
BaseClient)get_config_value_or_defaultvalidate_config)Signer)Sentinel#get_signer_from_authentication_typeAUTHENTICATION_TYPE_FIELD_NAME   )certificates_type_mappingZMissingc                   @   s@   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Zdd Z	dS )CertificatesClientz*
    API for retrieving certificates.
    c              
   K   s  t ||dd d|v r|d }n"t|v rt|}nt|d |d |d |dt|d|dd	}d
|dddi |dd|dtj|dd}d|v rY|d|d< |ddu retj|d< d|v rp|d|d< t	d||t
fi || _|d| _|d| _dS )a  
        Creates a new service client

        :param dict config:
            Configuration keys and values as per `SDK and Tool Configuration <https://docs.cloud.oracle.com/Content/API/Concepts/sdkconfig.htm>`__.
            The :py:meth:`~oci.config.from_file` method can be used to load configuration from a file. Alternatively, a ``dict`` can be passed. You can validate_config
            the dict using :py:meth:`~oci.config.validate_config`

        :param str service_endpoint: (optional)
            The endpoint of the service to call using this client. For example ``https://iaas.us-ashburn-1.oraclecloud.com``. If this keyword argument is
            not provided then it will be derived using the region in the config parameter. You should only provide this keyword argument if you have an explicit
            need to specify a service endpoint.

        :param timeout: (optional)
            The connection and read timeouts for the client. The default values are connection timeout 10 seconds and read timeout 60 seconds. This keyword argument can be provided
            as a single float, in which case the value provided is used for both the read and connection timeouts, or as a tuple of two floats. If
            a tuple is provided then the first value is used as the connection timeout and the second value as the read timeout.
        :type timeout: float or tuple(float, float)

        :param signer: (optional)
            The signer to use when signing requests made by the service client. The default is to use a :py:class:`~oci.signer.Signer` based on the values
            provided in the config parameter.

            One use case for this parameter is for `Instance Principals authentication <https://docs.cloud.oracle.com/Content/Identity/Tasks/callingservicesfrominstances.htm>`__
            by passing an instance of :py:class:`~oci.auth.signers.InstancePrincipalsSecurityTokenSigner` as the value for this keyword argument
        :type signer: :py:class:`~oci.signer.AbstractBaseSigner`

        :param obj retry_strategy: (optional)
            A retry strategy to apply to all calls made by this service client (i.e. at the client level). There is no retry strategy applied by default.
            Retry strategies can also be applied at the operation level by passing a ``retry_strategy`` keyword argument as part of calling the operation.
            Any value provided at the operation level will override whatever is specified at the client level.

            This should be one of the strategies available in the :py:mod:`~oci.retry` module. A convenience :py:data:`~oci.retry.DEFAULT_RETRY_STRATEGY`
            is also available. The specifics of the default retry strategy are described `here <https://docs.oracle.com/en-us/iaas/tools/python/latest/sdk_behaviors/retries.html>`__.

        :param obj circuit_breaker_strategy: (optional)
            A circuit breaker strategy to apply to all calls made by this service client (i.e. at the client level).
            This client uses :py:data:`~oci.circuit_breaker.DEFAULT_CIRCUIT_BREAKER_STRATEGY` as default if no circuit breaker strategy is provided.
            The specifics of circuit breaker strategy are described `here <https://docs.oracle.com/en-us/iaas/tools/python/latest/sdk_behaviors/circuit_breakers.html>`__.

        :param function circuit_breaker_callback: (optional)
            Callback function to receive any exceptions triggerred by the circuit breaker.

        :param bool client_level_realm_specific_endpoint_template_enabled: (optional)
            A boolean flag to indicate whether or not this client should be created with realm specific endpoint template enabled or disable. By default, this will be set as None.

        :param allow_control_chars: (optional)
            allow_control_chars is a boolean to indicate whether or not this client should allow control characters in the response object. By default, the client will not
            allow control characters to be in the response object.
        signer)r   tenancyuserfingerprintZkey_filepass_phraseZkey_content)r   r   r   Zprivate_key_file_locationr   Zprivate_key_contentTservice_endpointz	/20210224z5https://certificates.{region}.oci.{secondLevelDomain}skip_deserializationFcircuit_breaker_strategy5client_level_realm_specific_endpoint_template_enabled)Zregional_clientr   	base_pathZservice_endpoint_templateZ#service_endpoint_template_per_realmr   r   r   timeoutNallow_control_charsZcertificatesretry_strategycircuit_breaker_callback)r	   getr   r   r
   r   r   ZGLOBAL_CIRCUIT_BREAKER_STRATEGYZ DEFAULT_CIRCUIT_BREAKER_STRATEGYr   r   base_clientr   r   )selfconfigkwargsr   Zbase_client_init_kwargs r$   Husr/lib/python3.10/site-packages/oci/certificates/certificates_client.py__init__   s>   3





zCertificatesClient.__init__c                    s^  dg}d}d}d}d}g d  fddt |D }|r$td	|d|i}	d
d t |	D }	t |	D ]\}
}|du sMt|t jrTt| dkrTtd|
q7dd|	dt
d}dd t |D }| jj|	d| jd}|rt|tjs| j| || j |j| jj|||	|d|	d|||d
S | jj|||	|d|	d|||d	S )a  
        Gets a ca-bundle bundle.


        :param str ca_bundle_id: (required)
            The OCID of the CA bundle.

        :param str opc_request_id: (optional)
            Unique Oracle-assigned identifier for the request. If you need to contact Oracle about a particular request,
            please provide the request ID.

        :param obj retry_strategy: (optional)
            A retry strategy to apply to this specific operation/call. This will override any retry strategy set at the client-level.

            This should be one of the strategies available in the :py:mod:`~oci.retry` module. This operation will not retry by default, users can also use the convenient :py:data:`~oci.retry.DEFAULT_RETRY_STRATEGY` provided by the SDK to enable retries for it.
            The specifics of the default retry strategy are described `here <https://docs.oracle.com/en-us/iaas/tools/python/latest/sdk_behaviors/retries.html>`__.

            To have this operation explicitly not perform any retries, pass an instance of :py:class:`~oci.retry.NoneRetryStrategy`.

        :param bool allow_control_chars: (optional)
            allow_control_chars is a boolean to indicate whether or not this request should allow control characters in the response object.
            By default, the response will not allow control characters in strings

        :return: A :class:`~oci.response.Response` object with data of type :class:`~oci.certificates.models.CaBundle`
        :rtype: :class:`~oci.response.Response`

        :example:
        Click `here <https://docs.cloud.oracle.com/en-us/iaas/tools/python-sdk-examples/latest/certificates/get_ca_bundle.py.html>`__ to see an example of how to use get_ca_bundle API.
        Z
caBundleIdz/caBundles/{caBundleId}GETget_ca_bundlezPhttps://docs.oracle.com/iaas/api/#/en/certificates/20210224/CaBundle/GetCaBundle)r   r   opc_request_idc                       g | ]}| vr|qS r$   r$   .0_keyZexpected_kwargsr$   r%   
<listcomp>       z4CertificatesClient.get_ca_bundle.<locals>.<listcomp>z&get_ca_bundle got unknown kwargs: {!r}c                 S      i | ]\}}|t ur||qS r$   missingr,   kvr$   r$   r%   
<dictcomp>       z4CertificatesClient.get_ca_bundle.<locals>.<dictcomp>Nr   7Parameter {} cannot be None, whitespace or empty stringapplication/jsonr)   acceptzcontent-typezopc-request-idc                 S   &   i | ]\}}|t ur|d ur||qS Nr2   r4   r$   r$   r%   r7         & r   Zoperation_retry_strategyZclient_retry_strategyZCaBundler   )	resource_pathmethodpath_paramsheader_paramsresponse_typer   operation_nameapi_reference_linkrequired_argumentsr   Ziterkeys
ValueErrorformatZ	iteritems
isinstanceZstring_typeslenstripr   r3   r    Zget_preferred_retry_strategyr   r   ZNoneRetryStrategyZadd_opc_client_retries_headerZadd_circuit_breaker_callbackr   Zmake_retrying_callZcall_api)r!   Zca_bundle_idr#   rH   rA   rB   rF   rG   extra_kwargsrC   r5   r6   rD   r   r$   r.   r%   r(   r   sl   $
z CertificatesClient.get_ca_bundlec                    s  dg}d}d}d}d}g d  fddt |D }|r$td	|d|i}	d
d t |	D }	t |	D ]\}
}|du sMt|t jrTt| dkrTtd|
q7d|v rjg d}|d |vrjtd||	dt
|	dt
|	dt
d}dd t |D }dd|	dt
d}dd t |D }| jj|	d| jd}|rt|tjs| j| || j |j| jj|||	||d|	d|||dS | jj|||	||d|	d|||d
S )a:
  
        Gets a certificate authority bundle that matches either the specified `stage`, `name`, or `versionNumber` parameter.
        If none of these parameters are provided, the bundle for the certificate authority version marked as `CURRENT` will be returned.


        :param str certificate_authority_id: (required)
            The OCID of the certificate authority (CA).

        :param str opc_request_id: (optional)
            Unique Oracle-assigned identifier for the request. If you need to contact Oracle about a particular request,
            please provide the request ID.

        :param int version_number: (optional)
            The version number of the certificate authority (CA).

        :param str certificate_authority_version_name: (optional)
            The name of the certificate authority (CA). (This might be referred to as the name of the CA version, as every CA consists of at least one version.) Names are unique across versions of a given CA.

        :param str stage: (optional)
            The rotation state of the certificate version.

            Allowed values are: "CURRENT", "PENDING", "LATEST", "PREVIOUS", "DEPRECATED"

        :param obj retry_strategy: (optional)
            A retry strategy to apply to this specific operation/call. This will override any retry strategy set at the client-level.

            This should be one of the strategies available in the :py:mod:`~oci.retry` module. This operation will not retry by default, users can also use the convenient :py:data:`~oci.retry.DEFAULT_RETRY_STRATEGY` provided by the SDK to enable retries for it.
            The specifics of the default retry strategy are described `here <https://docs.oracle.com/en-us/iaas/tools/python/latest/sdk_behaviors/retries.html>`__.

            To have this operation explicitly not perform any retries, pass an instance of :py:class:`~oci.retry.NoneRetryStrategy`.

        :param bool allow_control_chars: (optional)
            allow_control_chars is a boolean to indicate whether or not this request should allow control characters in the response object.
            By default, the response will not allow control characters in strings

        :return: A :class:`~oci.response.Response` object with data of type :class:`~oci.certificates.models.CertificateAuthorityBundle`
        :rtype: :class:`~oci.response.Response`

        :example:
        Click `here <https://docs.cloud.oracle.com/en-us/iaas/tools/python-sdk-examples/latest/certificates/get_certificate_authority_bundle.py.html>`__ to see an example of how to use get_certificate_authority_bundle API.
        certificateAuthorityIdz5/certificateAuthorityBundles/{certificateAuthorityId}r'    get_certificate_authority_bundlezthttps://docs.oracle.com/iaas/api/#/en/certificates/20210224/CertificateAuthorityBundle/GetCertificateAuthorityBundle)r   r   r)   version_number"certificate_authority_version_namestagec                    r*   r$   r$   r+   r.   r$   r%   r/     r0   zGCertificatesClient.get_certificate_authority_bundle.<locals>.<listcomp>z9get_certificate_authority_bundle got unknown kwargs: {!r}c                 S   r1   r$   r2   r4   r$   r$   r%   r7     r8   zGCertificatesClient.get_certificate_authority_bundle.<locals>.<dictcomp>Nr   r9   rT   ZCURRENTZPENDINGZLATESTZPREVIOUSZ
DEPRECATED-Invalid value for `stage`, must be one of {0}rR   rS   )versionNumberZcertificateAuthorityVersionNamerT   c                 S   r=   r>   r2   r4   r$   r$   r%   r7   (  r?   r:   r)   r;   c                 S   r=   r>   r2   r4   r$   r$   r%   r7   /  r?   r   r@   ZCertificateAuthorityBundler   
rA   rB   rC   query_paramsrD   rE   r   rF   rG   rH   rI   )r!   certificate_authority_idr#   rH   rA   rB   rF   rG   rO   rC   r5   r6   stage_allowed_valuesrY   rD   r   r$   r.   r%   rQ      s   +$



z3CertificatesClient.get_certificate_authority_bundlec                    s  dg}d}d}d}d}g d  fddt |D }|r$td	|d|i}	d
d t |	D }	t |	D ]\}
}|du sMt|t jrTt| dkrTtd|
q7d|v rjg d}|d |vrjtd|d|v rddg}|d |vrtd||	dt
|	dt
|	dt
|	dt
d}dd t |D }dd|	dt
d}dd t |D }| jj|	d| jd}|rt|tjs| j| || j |j| jj|||	||d |	d!|||d"S | jj|||	||d |	d!|||d"
S )#a  
        Gets a certificate bundle that matches either the specified `stage`, `versionName`, or `versionNumber` parameter.
        If none of these parameters are provided, the bundle for the certificate version marked as `CURRENT` will be returned.

        By default, the private key is not included in the query result, and a CertificateBundlePublicOnly is returned.
        If the private key is needed, use the CertificateBundleTypeQueryParam parameter to get a CertificateBundleWithPrivateKey response.


        :param str certificate_id: (required)
            The OCID of the certificate.

        :param str opc_request_id: (optional)
            Unique Oracle-assigned identifier for the request. If you need to contact Oracle about a particular request,
            please provide the request ID.

        :param int version_number: (optional)
            The version number of the certificate. The default value is 0, which means that this query parameter is ignored.

        :param str certificate_version_name: (optional)
            The name of the certificate. (This might be referred to as the name of the certificate version, as every certificate consists of at least one version.) Names are unique across versions of a given certificate.

        :param str stage: (optional)
            The rotation state of the certificate version.

            Allowed values are: "CURRENT", "PENDING", "LATEST", "PREVIOUS", "DEPRECATED"

        :param str certificate_bundle_type: (optional)
            The type of certificate bundle. By default, the private key fields are not returned. When querying for certificate bundles, to return results with certificate contents, the private key in PEM format, and the private key passphrase, specify the value of this parameter as `CERTIFICATE_CONTENT_WITH_PRIVATE_KEY`.

            Allowed values are: "CERTIFICATE_CONTENT_PUBLIC_ONLY", "CERTIFICATE_CONTENT_WITH_PRIVATE_KEY"

        :param obj retry_strategy: (optional)
            A retry strategy to apply to this specific operation/call. This will override any retry strategy set at the client-level.

            This should be one of the strategies available in the :py:mod:`~oci.retry` module. This operation will not retry by default, users can also use the convenient :py:data:`~oci.retry.DEFAULT_RETRY_STRATEGY` provided by the SDK to enable retries for it.
            The specifics of the default retry strategy are described `here <https://docs.oracle.com/en-us/iaas/tools/python/latest/sdk_behaviors/retries.html>`__.

            To have this operation explicitly not perform any retries, pass an instance of :py:class:`~oci.retry.NoneRetryStrategy`.

        :param bool allow_control_chars: (optional)
            allow_control_chars is a boolean to indicate whether or not this request should allow control characters in the response object.
            By default, the response will not allow control characters in strings

        :return: A :class:`~oci.response.Response` object with data of type :class:`~oci.certificates.models.CertificateBundle`
        :rtype: :class:`~oci.response.Response`

        :example:
        Click `here <https://docs.cloud.oracle.com/en-us/iaas/tools/python-sdk-examples/latest/certificates/get_certificate_bundle.py.html>`__ to see an example of how to use get_certificate_bundle API.
        certificateIdz#/certificateBundles/{certificateId}r'   get_certificate_bundlezbhttps://docs.oracle.com/iaas/api/#/en/certificates/20210224/CertificateBundle/GetCertificateBundle)r   r   r)   rR   certificate_version_namerT   certificate_bundle_typec                    r*   r$   r$   r+   r.   r$   r%   r/     r0   z=CertificatesClient.get_certificate_bundle.<locals>.<listcomp>z/get_certificate_bundle got unknown kwargs: {!r}c                 S   r1   r$   r2   r4   r$   r$   r%   r7     r8   z=CertificatesClient.get_certificate_bundle.<locals>.<dictcomp>Nr   r9   rT   rU   rV   r_   ZCERTIFICATE_CONTENT_PUBLIC_ONLYZ$CERTIFICATE_CONTENT_WITH_PRIVATE_KEYz?Invalid value for `certificate_bundle_type`, must be one of {0}rR   r^   )rW   ZcertificateVersionNamerT   ZcertificateBundleTypec                 S   r=   r>   r2   r4   r$   r$   r%   r7     r?   r:   r)   r;   c                 S   r=   r>   r2   r4   r$   r$   r%   r7     r?   r   r@   ZCertificateBundler   rX   rI   )r!   certificate_idr#   rH   rA   rB   rF   rG   rO   rC   r5   r6   r[   Z&certificate_bundle_type_allowed_valuesrY   rD   r   r$   r.   r%   r]   S  s   3	$




z)CertificatesClient.get_certificate_bundlec                      dg}d}d}d}d}g d  fddt |D }|r$td	|d|i}	d
d t |	D }	t |	D ]\}
}|du sMt|t jrTt| dkrTtd|
q7d|v ridg}|d |vritd|d|v r~ddg}|d |vr~td||	dt
|	dt
d}dd t |D }dd|	dt
d}dd t |D }| jj|	d| jd}|rt|tjs| j| || j |j| jj|||	||d|	d|||d S | jj|||	||d|	d|||d 
S )!a
	  
        Lists all certificate authority bundle versions for the specified certificate authority.


        :param str certificate_authority_id: (required)
            The OCID of the certificate authority (CA).

        :param str opc_request_id: (optional)
            Unique Oracle-assigned identifier for the request. If you need to contact Oracle about a particular request,
            please provide the request ID.

        :param str sort_by: (optional)
            The field to sort by. You can specify only one sort order. The default
            order for `VERSION_NUMBER` is ascending.

            Allowed values are: "VERSION_NUMBER"

        :param str sort_order: (optional)
            The sort order to use, either ascending (`ASC`) or descending (`DESC`).

            Allowed values are: "ASC", "DESC"

        :param obj retry_strategy: (optional)
            A retry strategy to apply to this specific operation/call. This will override any retry strategy set at the client-level.

            This should be one of the strategies available in the :py:mod:`~oci.retry` module. This operation will not retry by default, users can also use the convenient :py:data:`~oci.retry.DEFAULT_RETRY_STRATEGY` provided by the SDK to enable retries for it.
            The specifics of the default retry strategy are described `here <https://docs.oracle.com/en-us/iaas/tools/python/latest/sdk_behaviors/retries.html>`__.

            To have this operation explicitly not perform any retries, pass an instance of :py:class:`~oci.retry.NoneRetryStrategy`.

        :param bool allow_control_chars: (optional)
            allow_control_chars is a boolean to indicate whether or not this request should allow control characters in the response object.
            By default, the response will not allow control characters in strings

        :return: A :class:`~oci.response.Response` object with data of type :class:`~oci.certificates.models.CertificateAuthorityBundleVersionCollection`
        :rtype: :class:`~oci.response.Response`

        :example:
        Click `here <https://docs.cloud.oracle.com/en-us/iaas/tools/python-sdk-examples/latest/certificates/list_certificate_authority_bundle_versions.py.html>`__ to see an example of how to use list_certificate_authority_bundle_versions API.
        rP   z>/certificateAuthorityBundles/{certificateAuthorityId}/versionsr'   *list_certificate_authority_bundle_versionszhttps://docs.oracle.com/iaas/api/#/en/certificates/20210224/CertificateAuthorityBundleVersionSummary/ListCertificateAuthorityBundleVersionsr   r   r)   sort_by
sort_orderc                    r*   r$   r$   r+   r.   r$   r%   r/     r0   zQCertificatesClient.list_certificate_authority_bundle_versions.<locals>.<listcomp>zClist_certificate_authority_bundle_versions got unknown kwargs: {!r}c                 S   r1   r$   r2   r4   r$   r$   r%   r7   %  r8   zQCertificatesClient.list_certificate_authority_bundle_versions.<locals>.<dictcomp>Nr   r9   rd   VERSION_NUMBER/Invalid value for `sort_by`, must be one of {0}re   ASCDESC2Invalid value for `sort_order`, must be one of {0}ZsortByZ	sortOrderc                 S   r=   r>   r2   r4   r$   r$   r%   r7   =  r?   r:   r)   r;   c                 S   r=   r>   r2   r4   r$   r$   r%   r7   D  r?   r   r@   Z+CertificateAuthorityBundleVersionCollectionr   rX   rI   )r!   rZ   r#   rH   rA   rB   rF   rG   rO   rC   r5   r6   sort_by_allowed_valuessort_order_allowed_valuesrY   rD   r   r$   r.   r%   rb        *$


z=CertificatesClient.list_certificate_authority_bundle_versionsc                    ra   )!a  
        Lists all certificate bundle versions for the specified certificate.


        :param str certificate_id: (required)
            The OCID of the certificate.

        :param str opc_request_id: (optional)
            Unique Oracle-assigned identifier for the request. If you need to contact Oracle about a particular request,
            please provide the request ID.

        :param str sort_by: (optional)
            The field to sort by. You can specify only one sort order. The default
            order for `VERSION_NUMBER` is ascending.

            Allowed values are: "VERSION_NUMBER"

        :param str sort_order: (optional)
            The sort order to use, either ascending (`ASC`) or descending (`DESC`).

            Allowed values are: "ASC", "DESC"

        :param obj retry_strategy: (optional)
            A retry strategy to apply to this specific operation/call. This will override any retry strategy set at the client-level.

            This should be one of the strategies available in the :py:mod:`~oci.retry` module. This operation will not retry by default, users can also use the convenient :py:data:`~oci.retry.DEFAULT_RETRY_STRATEGY` provided by the SDK to enable retries for it.
            The specifics of the default retry strategy are described `here <https://docs.oracle.com/en-us/iaas/tools/python/latest/sdk_behaviors/retries.html>`__.

            To have this operation explicitly not perform any retries, pass an instance of :py:class:`~oci.retry.NoneRetryStrategy`.

        :param bool allow_control_chars: (optional)
            allow_control_chars is a boolean to indicate whether or not this request should allow control characters in the response object.
            By default, the response will not allow control characters in strings

        :return: A :class:`~oci.response.Response` object with data of type :class:`~oci.certificates.models.CertificateBundleVersionCollection`
        :rtype: :class:`~oci.response.Response`

        :example:
        Click `here <https://docs.cloud.oracle.com/en-us/iaas/tools/python-sdk-examples/latest/certificates/list_certificate_bundle_versions.py.html>`__ to see an example of how to use list_certificate_bundle_versions API.
        r\   z,/certificateBundles/{certificateId}/versionsr'    list_certificate_bundle_versionszyhttps://docs.oracle.com/iaas/api/#/en/certificates/20210224/CertificateBundleVersionSummary/ListCertificateBundleVersionsrc   c                    r*   r$   r$   r+   r.   r$   r%   r/     r0   zGCertificatesClient.list_certificate_bundle_versions.<locals>.<listcomp>z9list_certificate_bundle_versions got unknown kwargs: {!r}c                 S   r1   r$   r2   r4   r$   r$   r%   r7     r8   zGCertificatesClient.list_certificate_bundle_versions.<locals>.<dictcomp>Nr   r9   rd   rf   rg   re   rh   ri   rj   rk   c                 S   r=   r>   r2   r4   r$   r$   r%   r7     r?   r:   r)   r;   c                 S   r=   r>   r2   r4   r$   r$   r%   r7     r?   r   r@   Z"CertificateBundleVersionCollectionr   rX   rI   )r!   r`   r#   rH   rA   rB   rF   rG   rO   rC   r5   r6   rl   rm   rY   rD   r   r$   r.   r%   ro   h  rn   z3CertificatesClient.list_certificate_bundle_versionsN)
__name__
__module____qualname____doc__r&   r(   rQ   r]   rb   ro   r$   r$   r$   r%   r      s    Xa   r   N)
__future__r   Zoci._vendorr   r   ocir   r   Zoci.base_clientr   Z
oci.configr   r	   Z
oci.signerr
   Zoci.utilr   r   r   Zmodelsr   r3   objectr   r$   r$   r$   r%   <module>   s   