
    .
0h(                     n    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d
S )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                   l   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dS )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                 `    || _         i | _        |
|| j        d<   |
|| j        d<   || _        d S )NaccessId	projectId)_client_properties_user_project)selfclient	access_id
project_iduser_projects        X/var/www/html/nourish/venv/lib/python3.11/site-packages/google/cloud/storage/hmac_key.py__init__zHMACKeyMetadata.__init__:   sE     +4DZ(!,6D[))    c                 z    t          || j                  st          S | j        |j        k    o| j        |j        k    S N)
isinstance	__class__NotImplementedr   r   )r   others     r   __eq__zHMACKeyMetadata.__eq__F   s9    %00 	"!!|u},R5?1RRr   c                 T    t          | j                  t          | j                  z   S r   )hashr   r   r   s    r   __hash__zHMACKeyMetadata.__hash__L   s!    DL!!D$8$888r   c                 6    | 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                 6    | 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                 6    | 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                 6    | 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00r   c                 6    | 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                 6    | 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<   d S )Nr4   )r   r   values     r   r4   zHMACKeyMetadata.state   s    $)!!!r   c                 \    | j                             d          }|t          |          S dS )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   s6      $$]33-e444 r   c                 \    | j                             d          }|t          |          S dS )r9   updatedNr;   r6   s     r   r>   zHMACKeyMetadata.updated   s6      $$Y//-e444 r   c                 r    | j         t          d          | j        }|| j        j        }d| d| j          S )z%Resource path for the metadata's key.NzNo 'access_id' set.z
/projects/z
/hmacKeys/)r   
ValueErrorr/   r   )r   r/   s     r   pathzHMACKeyMetadata.path   sI     >!2333,?l*G?G??t~???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        |||           	 ddd           dS # t
          $ r Y ddd           dS w xY w# 1 swxY w Y   dS )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,**I!*#	 +    !	 	 	 	 	 	 	 	    	 	 	 	 	 	 	 		 	 	 	 	 	 	 	 	 	s4   A36A	A3
A0!A3/A00A33A7:A7c                     t          d          5  i }| j        
| j        |d<   | j                            | j        |||          | _        ddd           dS # 1 swxY w Y   dS )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   s     $<=== 	 	I ,+/+<	-(#|99	&	  :    D	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   <AA!Ac                     t          d          5  i }| j        
| j        |d<   d| j        i}| j                            | j        ||||          | _        ddd           dS # 1 swxY w Y   dS )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A$$A(+A(c                     t          d          5  i }| j        
| j        |d<   | j                            | j        |||           ddd           dS # 1 swxY w Y   dS )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  s     $<=== 
	 
	I ,+/+<	-(L))	&	 *   
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	s   7A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
      s          L:N M5$n5
* 
* 
* 
*S S S9 9 9 0 0 X0 , , X, * * X* 1 1 X1 ; ; X; - - X- \* * \* 
5 
5 X
5 
5 
5 X
5 
@ 
@ X
@ " " X" .]    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 I I I I I ; ; ; ; ; ; 4 4 4 4 4 4 D D D D D DU U U U Uf U U U U Ur   