o
    ȷef                     @   s`   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	G dd	 d	eZ
d
S )    )Bucket)S3Connection)SubdomainCallingFormat)check_lowercase_bucketname)get_utf8_valuec                   @   s   e Zd ZdZdZdS )LocationUSEUN)__name__
__module____qualname__DEFAULTr	    r   r   I/var/www/ideatree/venv/lib/python3.10/site-packages/boto/gs/connection.pyr      s    r   c                       sb   e Zd ZdZdZddddddddedde ddf fdd	Zdejdd	fd
dZ	dddZ
  ZS )GSConnectionzstorage.googleapis.comz)Signature=%s&Expires=%d&GoogleAccessId=%sNTr   /c                    s4   t t| j|||||||||	|
|||dt|d d S )Ngoogle)suppress_consec_slashes)superr   __init__r   )selfgs_access_key_idgs_secret_access_key	is_secureportproxy
proxy_port
proxy_user
proxy_passhostdebughttps_connection_factorycalling_formatpathr   	__class__r   r   r   %   s   

zGSConnection.__init__STANDARDc                 C   s   t | |r|r||| jj< n| jj|i}|stj}d| }|r%d| }nd}d||f }| jdt||t|d}	|	 }
|	jdkrM| j	|	j|	j
|
|	jdkrX| | |S | j|	j|	j
|
)	a  
        Creates a new bucket. By default it's located in the USA. You can
        pass Location.EU to create bucket in the EU. You can also pass
        a LocationConstraint for where the bucket should be located, and
        a StorageClass describing how the data should be stored.

        :type bucket_name: string
        :param bucket_name: The name of the new bucket.

        :type headers: dict
        :param headers: Additional headers to pass along with the request to GCS.

        :type location: :class:`boto.gs.connection.Location`
        :param location: The location of the new bucket.

        :type policy: :class:`boto.gs.acl.CannedACLStrings`
        :param policy: A canned ACL policy that will be applied to the new key
                       in GCS.

        :type storage_class: string
        :param storage_class: Either 'STANDARD' or 'DURABLE_REDUCED_AVAILABILITY'.

        z+<LocationConstraint>%s</LocationConstraint>z<StorageClass>%s</StorageClass> z;<CreateBucketConfiguration>%s%s</CreateBucketConfiguration>PUT)headersdatai     )r   provider
acl_headerr   r   make_requestr   readstatusstorage_create_errorreasonbucket_classstorage_response_error)r   bucket_namer)   locationpolicystorage_classlocation_elemstorage_class_elemr*   responsebodyr   r   r   create_bucket1   s@   




zGSConnection.create_bucketc                 C   s"   |  | |}|r|j|dd |S )a  
        Retrieves a bucket by name.

        If the bucket does not exist, an ``S3ResponseError`` will be raised. If
        you are unsure if the bucket exists or not, you can use the
        ``S3Connection.lookup`` method, which will either return a valid bucket
        or ``None``.

        :type bucket_name: string
        :param bucket_name: The name of the bucket

        :type headers: dict
        :param headers: Additional headers to pass along with the request to
            AWS.

        :type validate: boolean
        :param validate: If ``True``, it will try to fetch all keys within the
            given bucket. (Default: ``True``)
        r   )maxkeys)r3   get_all_keys)r   r5   validater)   bucketr   r   r   
get_bucketj   s   zGSConnection.get_bucket)TN)r
   r   r   DefaultHostQueryStringr   r   r   r   r=   rB   __classcell__r   r   r$   r   r       s    
9r   N)boto.gs.bucketr   boto.s3.connectionr   r   r   
boto.utilsr   objectr   r   r   r   r   r   <module>   s   