ó
è?F[c           @   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 d e f d „  ƒ  YZ	 d e f d	 „  ƒ  YZ
 d
 S(   iÿÿÿÿ(   t   Bucket(   t   S3Connection(   t   SubdomainCallingFormat(   t   check_lowercase_bucketname(   t   get_utf8_valuet   Locationc           B   s   e  Z d  Z d Z RS(   t   USt   EU(   t   __name__t
   __module__t   DEFAULTR   (    (    (    s1   lib/python2.7/site-packages/boto/gs/connection.pyR      s   t   GSConnectionc           B   sq   e  Z d  Z d Z d d e d d d d d e d d e ƒ  d e d „ Z d e j	 d d d „ Z
 e d d „ Z RS(	   s   storage.googleapis.coms)   Signature=%s&Expires=%d&GoogleAccessId=%si    t   /c         C   sJ   t  t |  ƒ j | | | | | | | | |	 |
 | | | d t d | ƒd  S(   Nt   googlet   suppress_consec_slashes(   t   superR   t   __init__R    (   t   selft   gs_access_key_idt   gs_secret_access_keyt	   is_securet   portt   proxyt
   proxy_portt
   proxy_usert
   proxy_passt   hostt   debugt   https_connection_factoryt   calling_formatt   pathR   (    (    s1   lib/python2.7/site-packages/boto/gs/connection.pyR   %   s
    	t   STANDARDc         C   s+  t  | ƒ | r? | r) | | |  j j <q? i | |  j j 6} n  | sQ t j } n  d | } | rn d | } n d } d | | f } |  j d t | ƒ d | d t | ƒ ƒ}	 |	 j ƒ  }
 |	 j d k rê |  j j	 |	 j |	 j
 |
 ƒ ‚ n  |	 j d	 k r	|  j |  | ƒ S|  j j |	 j |	 j
 |
 ƒ ‚ d
 S(   s‰  
        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'.

        s+   <LocationConstraint>%s</LocationConstraint>s   <StorageClass>%s</StorageClass>t    s;   <CreateBucketConfiguration>%s%s</CreateBucketConfiguration>t   PUTt   headerst   datai™  iÈ   N(   R   t   providert
   acl_headerR   R
   t   make_requestR   t   readt   statust   storage_create_errort   reasont   bucket_classt   storage_response_error(   R   t   bucket_nameR"   t   locationt   policyt   storage_classt   location_elemt   storage_class_elemR#   t   responset   body(    (    s1   lib/python2.7/site-packages/boto/gs/connection.pyt   create_bucket1   s4    

		c         C   s2   |  j  |  | ƒ } | r. | j | d d ƒn  | S(   s–  
        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``)
        t   maxkeysi    (   R+   t   get_all_keys(   R   R-   t   validateR"   t   bucket(    (    s1   lib/python2.7/site-packages/boto/gs/connection.pyt
   get_bucketj   s    N(   R   R	   t   DefaultHostt   QueryStringt   Nonet   TrueR   R   R   R
   R5   R:   (    (    (    s1   lib/python2.7/site-packages/boto/gs/connection.pyR       s   			7N(   t   boto.gs.bucketR    t   boto.s3.connectionR   R   R   t
   boto.utilsR   t   objectR   R   (    (    (    s1   lib/python2.7/site-packages/boto/gs/connection.pyt   <module>   s   