
    Ѯh(                     f    d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 ddl	mZ  G d d	e      Zy
)zConfigure HMAC keys that can be used to authenticate requests to Google Cloud Storage.

See [HMAC keys documentation](https://cloud.google.com/storage/docs/authentication/hmackeys)
    )NotFound)_rfc3339_nanos_to_datetime)create_trace_span)_DEFAULT_TIMEOUT)DEFAULT_RETRY)DEFAULT_RETRY_IF_ETAG_IN_JSONc                   2   e Zd ZdZdZ	 dZ	 dZ	 eefZddZd Z	d Z
ed	        Zed
        Zed        Zed        Zed        Zed        Zej$                  d        Zed        Zed        Zed        Zed        ZeefdZeefdZeefdZeefdZy)HMACKeyMetadataa   Metadata about an HMAC service account key withn Cloud Storage.

    :type client: :class:`~google.cloud.stoage.client.Client`
    :param client: client associated with the key metadata.

    :type access_id: str
    :param access_id: (Optional) Unique ID of an existing key.

    :type project_id: str
    :param project_id: (Optional) Project ID of an existing key.
        Defaults to client's project.

    :type user_project: str
    :param user_project: (Optional) This parameter is currently ignored.
    ACTIVEINACTIVEDELETEDNc                 r    || _         i | _        ||| j                  d<   ||| j                  d<   || _        y )NaccessId	projectId)_client_properties_user_project)selfclient	access_id
project_iduser_projects        o/home/www/academy-backend.kofcorporation.com/venv/lib/python3.12/site-packages/google/cloud/storage/hmac_key.py__init__zHMACKeyMetadata.__init__:   sE     +4DZ(!,6D[))    c                     t        || j                        st        S | j                  |j                  k(  xr | j                  |j                  k(  S N)
isinstance	__class__NotImplementedr   r   )r   others     r   __eq__zHMACKeyMetadata.__eq__F   s;    %0!!||u}},R5??1RRr   c                 X    t        | j                        t        | j                        z   S r   )hashr   r   r   s    r   __hash__zHMACKeyMetadata.__hash__L   s    DLL!D$888r   c                 8    | j                   j                  d      S )z|Access ID of the key.

        :rtype: str or None
        :returns: unique identifier of the key within a project.
        r   r   getr%   s    r   r   zHMACKeyMetadata.access_idO   s     ##J//r   c                 8    | j                   j                  d      S )zETag identifying the version of the key metadata.

        :rtype: str or None
        :returns: ETag for the version of the key's metadata.
        etagr(   r%   s    r   r+   zHMACKeyMetadata.etagX   s     ##F++r   c                 8    | j                   j                  d      S )zID of the key, including the Project ID and the Access ID.

        :rtype: str or None
        :returns: ID of the key.
        idr(   r%   s    r   r-   zHMACKeyMetadata.ida   s     ##D))r   c                 8    | j                   j                  d      S )zzProject ID associated with the key.

        :rtype: str or None
        :returns: project identfier for the key.
        r   r(   r%   s    r   projectzHMACKeyMetadata.projectj   s     ##K00r   c                 8    | j                   j                  d      S )zService account e-mail address associated with the key.

        :rtype: str or None
        :returns: e-mail address for the service account which created the key.
        serviceAccountEmailr(   r%   s    r   service_account_emailz%HMACKeyMetadata.service_account_emails   s     ##$9::r   c                 8    | j                   j                  d      S )zGet / set key's state.

        One of:
            - ``ACTIVE``
            - ``INACTIVE``
            - ``DELETED``

        :rtype: str or None
        :returns: key's current state.
        stater(   r%   s    r   r4   zHMACKeyMetadata.state|   s     ##G,,r   c                 "    || j                   d<   y )Nr4   )r   r   values     r   r4   zHMACKeyMetadata.state   s    $)!r   c                 T    | j                   j                  d      }|t        |      S y)3  Retrieve the timestamp at which the HMAC key was created.

        :rtype: :class:`datetime.datetime` or ``NoneType``
        :returns: Datetime object parsed from RFC3339 valid timestamp, or
                  ``None`` if the bucket's resource has not been loaded
                  from the server.
        timeCreatedNr   r)   r   r6   s     r   time_createdzHMACKeyMetadata.time_created   s0       $$]3-e44 r   c                 T    | j                   j                  d      }|t        |      S y)r9   updatedNr;   r6   s     r   r>   zHMACKeyMetadata.updated   s0       $$Y/-e44 r   c                     | j                   t        d      | j                  }|| j                  j                  }d| d| j                    S )z%Resource path for the metadata's key.zNo 'access_id' set.z
/projects/z
/hmacKeys/)r   
ValueErrorr/   r   )r   r/   s     r   pathzHMACKeyMetadata.path   sO     >>!233,,?ll**GG9Jt~~.>??r   c                     | j                   S )zProject ID to be billed for API requests made via this bucket.

        This property is currently ignored by the server.

        :rtype: str
        )r   r%   s    r   r   zHMACKeyMetadata.user_project   s     !!!r   c                    t        d      5  	 i }| j                  | j                  |d<   | j                  j                  | j                  |||       	 ddd       y# t
        $ r Y ddd       yw xY w# 1 sw Y   yxY w)a#  Determine whether or not the key for this metadata exists.

        :type timeout: float or tuple
        :param timeout:
            (Optional) The amount of time, in seconds, to wait
            for the server response.  See: :ref:`configuring_timeouts`

        :type retry: google.api_core.retry.Retry or google.cloud.storage.retry.ConditionalRetryPolicy
        :param retry:
            (Optional) How to retry the RPC. See: :ref:`configuring_retries`

        :rtype: bool
        :returns: True if the key exists in Cloud Storage.
        zStorage.HmacKey.existsnameNuserProjectquery_paramstimeoutretryTF)r   r   r   _get_resourcerA   r   r   rI   rJ   	qs_paramss       r   existszHMACKeyMetadata.exists   s     $<= 		$$0/3/@/@Im,**II!*#	 +  !	 	  	 		 	s/   A6AAA6	A3(A62A33A66A?c                     t        d      5  i }| j                  | j                  |d<   | j                  j                  | j                  |||      | _        ddd       y# 1 sw Y   yxY w)a4  Reload properties from Cloud Storage.

        :type timeout: float or tuple
        :param timeout:
            (Optional) The amount of time, in seconds, to wait
            for the server response.  See: :ref:`configuring_timeouts`

        :type retry: google.api_core.retry.Retry or google.cloud.storage.retry.ConditionalRetryPolicy
        :param retry:
            (Optional) How to retry the RPC. See: :ref:`configuring_retries`

        :raises :class:`~google.api_core.exceptions.NotFound`:
            if the key does not exist on the back-end.
        zStorage.HmacKey.reloadrD   NrF   rG   )r   r   r   rK   rA   r   rL   s       r   reloadzHMACKeyMetadata.reload   so     $<= 	I  ,+/+<+<	-(#||99		&	  :  D	 	 	s   AA""A+c                     t        d      5  i }| j                  | j                  |d<   d| j                  i}| j                  j	                  | j
                  ||||      | _        ddd       y# 1 sw Y   yxY w)a9  Save writable properties to Cloud Storage.

        :type timeout: float or tuple
        :param timeout:
            (Optional) The amount of time, in seconds, to wait
            for the server response.  See: :ref:`configuring_timeouts`

        :type retry: google.api_core.retry.Retry or google.cloud.storage.retry.ConditionalRetryPolicy
        :param retry:
            (Optional) How to retry the RPC. See: :ref:`configuring_retries`

        :raises :class:`~google.api_core.exceptions.NotFound`:
            if the key does not exist on the back-end.
        zStorage.HmacKey.updaterD   NrF   r4   rG   )r   r   r4   r   _put_resourcerA   r   )r   rI   rJ   rM   payloads        r   updatezHMACKeyMetadata.update   s     $<= 	I  ,+/+<+<	-(

+G#||99		&  :  D	 	 	s   AA11A:c                     t        d      5  i }| j                  | j                  |d<   | j                  j                  | j                  |||       ddd       y# 1 sw Y   yxY w)a1  Delete the key from Cloud Storage.

        :type timeout: float or tuple
        :param timeout:
            (Optional) The amount of time, in seconds, to wait
            for the server response.  See: :ref:`configuring_timeouts`

        :type retry: google.api_core.retry.Retry or google.cloud.storage.retry.ConditionalRetryPolicy
        :param retry:
            (Optional) How to retry the RPC. See: :ref:`configuring_retries`

        :raises :class:`~google.api_core.exceptions.NotFound`:
            if the key does not exist on the back-end.
        zStorage.HmacKey.deleterD   NrF   rG   )r   r   r   _delete_resourcerA   rL   s       r   deletezHMACKeyMetadata.delete  sj     $<= 
	I  ,+/+<+<	-(LL))		&	 * 
	 
	 
	s   AAA&)NNN)__name__
__module____qualname____doc__ACTIVE_STATEINACTIVE_STATEDELETED_STATE_SETTABLE_STATESr   r"   r&   propertyr   r+   r-   r/   r2   r4   setterr<   r>   rA   r   r   r   rN   rP   r   rT   rW    r   r   r
   r
      sT     L:N M5$n5
*S9 0 0 , , * * 1 1 ; ; - - \\* * 
5 
5 
5 
5 
@ 
@ " " .] B .] 8 .5R : .] r   r
   N)r[   google.cloud.exceptionsr   google.cloud._helpersr   +google.cloud.storage._opentelemetry_tracingr   google.cloud.storage.constantsr   google.cloud.storage.retryr   r   objectr
   rb   r   r   <module>ri      s,   
 - < I ; 4 DUf Ur   