o
     i(                     @   s`   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	 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                   @   s  e Zd ZdZdZ	 dZ	 dZ	 eefZd)ddZdd	 Z	d
d Z
edd Zedd Zedd Zedd Zedd Zedd Zejdd Zedd Zedd Zedd Zedd  Zeefd!d"Zeefd#d$Zeefd%d&Zeefd'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                 C   s:   || _ i | _|d ur|| jd< |d ur|| jd< || _d S )NaccessId	projectId)_client_properties_user_project)selfclient	access_id
project_iduser_project r   }/var/www/snowflake_co_dev_github/snow_flake_back_end_deploy/env/lib/python3.10/site-packages/google/cloud/storage/hmac_key.py__init__:   s   


zHMACKeyMetadata.__init__c                 C   s(   t || jstS | j|jko| j|jkS N)
isinstance	__class__NotImplementedr   r   )r   otherr   r   r   __eq__F   s   zHMACKeyMetadata.__eq__c                 C   s   t | jt | j S r   )hashr   r   r   r   r   r   __hash__L   s   zHMACKeyMetadata.__hash__c                 C      | 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    r   r   r   r   O      zHMACKeyMetadata.access_idc                 C   r"   )zETag identifying the version of the key metadata.

        :rtype: str or None
        :returns: ETag for the version of the key's metadata.
        etagr#   r    r   r   r   r&   X   r%   zHMACKeyMetadata.etagc                 C   r"   )zID of the key, including the Project ID and the Access ID.

        :rtype: str or None
        :returns: ID of the key.
        idr#   r    r   r   r   r'   a   r%   zHMACKeyMetadata.idc                 C   r"   )zzProject ID associated with the key.

        :rtype: str or None
        :returns: project identfier for the key.
        r   r#   r    r   r   r   projectj   r%   zHMACKeyMetadata.projectc                 C   r"   )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    r   r   r   service_account_emails   r%   z%HMACKeyMetadata.service_account_emailc                 C   r"   )zGet / set key's state.

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

        :rtype: str or None
        :returns: key's current state.
        stater#   r    r   r   r   r+   |   s   zHMACKeyMetadata.statec                 C   s   || j d< d S )Nr+   )r   r   valuer   r   r   r+      s   c                 C       | j d}|dur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   r,   r   r   r   time_created      	zHMACKeyMetadata.time_createdc                 C   r.   )r/   updatedNr1   r,   r   r   r   r4      r3   zHMACKeyMetadata.updatedc                 C   s:   | j du r	td| j}|du r| 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(   r   r   r   path   s   
zHMACKeyMetadata.pathc                 C   s   | 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    r   r   r   r      s   zHMACKeyMetadata.user_projectc              	   C   s   t dd4 zi }| jdur| j|d< | jj| j|||d W n ty/   Y W d   dS w 	 W d   dS 1 s<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retryFT)r   r   r   _get_resourcer6   r   r   r<   r=   	qs_paramsr   r   r   exists   s"   


$zHMACKeyMetadata.existsc                 C   s`   t dd! i }| jdur| j|d< | jj| j|||d| _W d   dS 1 s)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.reloadr7   Nr9   r:   )r   r   r   r>   r6   r   r?   r   r   r   reload   s   


"zHMACKeyMetadata.reloadc                 C   sl   t dd' i }| jdur| j|d< d| ji}| jj| j||||d| _W d   dS 1 s/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.updater7   Nr9   r+   r:   )r   r   r+   r   _put_resourcer6   r   )r   r<   r=   r@   payloadr   r   r   update   s   



"zHMACKeyMetadata.updatec                 C   s^   t dd  i }| jdur| j|d< | jj| j|||d W d   dS 1 s(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.deleter7   Nr9   r:   )r   r   r   _delete_resourcer6   r?   r   r   r   delete  s   

"zHMACKeyMetadata.delete)NNN)__name__
__module____qualname____doc__ACTIVE_STATEINACTIVE_STATEDELETED_STATE_SETTABLE_STATESr   r   r!   propertyr   r&   r'   r(   r*   r+   setterr2   r4   r6   r   r   r   rA   rB   r   rE   rG   r   r   r   r   r      sL    











	!r   N)rK   google.cloud.exceptionsr   google.cloud._helpersr   +google.cloud.storage._opentelemetry_tracingr   google.cloud.storage.constantsr   google.cloud.storage.retryr   r   objectr   r   r   r   r   <module>   s   