U
    $FZh                     @   sR   d Z ddl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j	Z
dS )	z8Create / interact with Google Cloud Storage connections.    N)_http)__version__)_helpers)create_trace_spanc                       sD   e Zd ZdZe ZdZd	 fdd	Zej	Z
dZ fddZ  ZS )

Connectiona  A connection to Google Cloud Storage via the JSON REST API.

    Mutual TLS will be enabled if the "GOOGLE_API_USE_CLIENT_CERTIFICATE"
    environment variable is set to the exact string "true" (case-sensitive).

    Mutual TLS is not compatible with any API endpoint or universe domain
    override at this time. If such settings are enabled along with
    "GOOGLE_API_USE_CLIENT_CERTIFICATE", a ValueError will be raised.

    :type client: :class:`~google.cloud.storage.client.Client`
    :param client: The client that owns the current connection.

    :type client_info: :class:`~google.api_core.client_info.ClientInfo`
    :param client_info: (Optional) instance used to generate user agent.

    :type api_endpoint: str
    :param api_endpoint: (Optional) api endpoint to use.
    z#https://storage.mtls.googleapis.comNc                    s~   t t| || |p| j| _| j| _|d k| _t| j	_
| j	jd krLd| j	_dt }|| j	jkrz| j	 jd| d7  _d S )N zgcloud-python/ )superr   __init__DEFAULT_API_ENDPOINTZAPI_BASE_URLDEFAULT_API_MTLS_ENDPOINTZAPI_BASE_MTLS_URLZALLOW_AUTO_SWITCH_TO_MTLS_URLr   Z_client_infoZclient_library_version
user_agent)selfclientZclient_infoZapi_endpointZagent_version	__class__ a/home/aprabhat/apps/x.techxrdev.in/venv/lib/python3.8/site-packages/google/cloud/storage/_http.pyr
   /   s    

zConnection.__init__z*{api_base_url}/storage/{api_version}{path}c              
      s   | dd }t }||d< d|i}tjtt| jf||}td|| j	||dJ |rz|j
f |}W n tk
r|   Y nX |r||}| W  5 Q R  S Q R X d S )NretryZextra_api_infozgccl-invocation-idzStorage.Connection.api_request)name
attributesr   api_requestr   )popr   Z_get_invocation_id	functoolspartialr	   r   r   r   Z_clientZ"get_retry_policy_if_conditions_metAttributeError)r   argskwargsr   Zinvocation_idZspan_attributescallr   r   r   r   C   s,     zConnection.api_request)NN)__name__
__module____qualname____doc__r   Z_get_default_storage_base_urlr   r   r
   Z_API_VERSIONZAPI_VERSIONZAPI_URL_TEMPLATEr   __classcell__r   r   r   r   r      s   r   )r"   r   Zgoogle.cloudr   Zgoogle.cloud.storager   r   Z+google.cloud.storage._opentelemetry_tracingr   ZJSONConnectionr   r   r   r   r   <module>   s   