U
    çû8b  ã                   @   sz   d Z ddlZddlZddlZddlmZ ddlmZ e d¡dkrde 	d¡j
Zee d¡k rded	ƒ‚G d
d„ dejƒZdS )z8Create / interact with Google Cloud Storage connections.é    N)Ú_http)Ú__version__Z!GOOGLE_API_USE_CLIENT_CERTIFICATEÚtruezgoogle-cloud-corez1.6.0z:google-cloud-core >= 1.6.0 is required to use mTLS featurec                       s>   e Zd ZdZdZdZd‡ fdd„	ZdZdZ‡ fd	d
„Z	‡  Z
S )Ú
Connectiona  A connection to Google Cloud Storage via the JSON REST API. Mutual TLS feature will be
    enabled if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is set to "true".

    :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.googleapis.comz#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rx| j	 jd |¡7  _d S )NÚ zgcloud-python/{}z {} )Ú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Úformat)ÚselfÚclientZclient_infoZapi_endpointZagent_version©Ú	__class__© úS/var/www/flask_sites/venv/lib/python3.8/site-packages/google/cloud/storage/_http.pyr   1   s    

zConnection.__init__Úv1z*{api_base_url}/storage/{api_version}{path}c                    sb   |  dd ¡}tjtt| ƒjf|ž|Ž}|r\z|jf |Ž}W n tk
rN   Y nX |r\||ƒ}|ƒ S )NÚretry)ÚpopÚ	functoolsÚpartialr   r   Úapi_requestZ"get_retry_policy_if_conditions_metÚAttributeError)r   ÚargsÚkwargsr   Úcallr   r   r   r   E   s    zConnection.api_request)NN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r	   r
   r   ZAPI_VERSIONZAPI_URL_TEMPLATEr   Ú__classcell__r   r   r   r   r       s   r   )r    r   ÚosÚpkg_resourcesZgoogle.cloudr   Zgoogle.cloud.storager   ÚgetenvÚget_distributionÚparsed_versionÚreleaseÚparse_versionÚImportErrorZJSONConnectionr   r   r   r   r   Ú<module>   s   