o ckF[@sddlZddlZddlZddlZddlmZddlmZddlm Z ddlm Z ddl m Z m Z ddl mZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddlmZddl m!Z!ddl"m#Z#dZ$dZ%dZ&dZ'dZ(dZ)e*dZ+GdddeZdS)N)handler) ResultSet)GSResponseError)InvalidAclError)ACLCannedACLStrings)SupportedPermissionsVersionedBucketListResultSet)Cors)EncryptionConfig)LifecycleConfig)Key)Policy)Bucket)get_utf8_value)sixdefaultObjectAclaclcorsencryptionConfig lifecycle storageClassz"
(?P
.*)
cs>eZdZdZdZdZdZdZdZdZ dZ d Z d d e ffd d Z d dZddZ dkddZ  dlfdd Z  dmddZddZ dkddZ dnddZdod d!Zd"d#Zd$d%Z dpd&d'Z dpd(d)Zdod*d+Z dqd,d-Z drd/d0Z dnd1d2Zdod3d4Zdod5d6Z dod7d8Z!dod9d:Z"dod;d<Z#dod=d>Z$ dsd?d@Z%  dsdAdBZ&  dsdCdDZ'dodEdFZ(dodGdHZ)dtdIdJZ*dodKdLZ+dodMdNZ, dudOdPZ-dodQdRZ.dodSdTZ/dodUdVZ0dodWdXZ1dodYdZZ2dod[d\Z3dod]d^Z4dod_d`Z5dodadbZ6dsdcddZ7dodedfZ8dodgdhZ9dtdidjZ:Z;S)vrz)Represents a Google Cloud Storage bucket.zu %sz\ %sz)%szF %szm %szX %s%sz#%sz%sNcstt||||dSN)superr__init__)self connectionname key_class __class__0/usr/lib/python3/dist-packages/boto/gs/bucket.pyrKszBucket.__init__cCsdSrr")rrattrsrr"r"r# startElementNszBucket.startElementcCs4|dkr ||_dS|dkr||_dSt|||dS)NName CreationDate)r creation_datesetattr)rrvaluerr"r"r# endElementQs   zBucket.endElementc Csg}|r |d||r#t|D]\}}|d|t|fqz |j|||d\} } W| StyO} z| jdkrJd| jvrJd|j |f| _d} ~ ww)afReturns a Key instance for an object in this bucket. Note that this method uses a HEAD request to check for the existence of the key. :type key_name: string :param key_name: The name of the key to retrieve :type response_headers: dict :param response_headers: A dictionary containing HTTP headers/values that will override any headers associated with the stored object in the response. See http://goo.gl/06N3b for details. :type version_id: string :param version_id: Unused in this subclass. :type generation: int :param generation: A specific generation number to fetch the key at. If not specified, the latest generation is fetched. :rtype: :class:`boto.gs.key.Key` :returns: A Key object from this bucket. generation=%sz%s=%s) query_args_l ForbiddenzAccess denied to 'gs://%s/%s'.N) appendr iteritemsurllibquote_get_key_internalrstatusreasonr) rkey_nameheaders version_idresponse_headers generationr-rkrvkeyresper"r"r#get_keyYs&  zBucket.get_keySTANDARDFc s:| r | pi} t| | d<tt|j|||||||| | d S)aCreate a new key in the bucket by copying an existing key. :type new_key_name: string :param new_key_name: The name of the new key :type src_bucket_name: string :param src_bucket_name: The name of the source bucket :type src_key_name: string :param src_key_name: The name of the source key :type src_generation: int :param src_generation: The generation number of the source key to copy. If not specified, the latest generation is copied. :type metadata: dict :param metadata: Metadata to be associated with new key. If metadata is supplied, it will replace the metadata of the source key being copied. If no metadata is supplied, the source key's metadata will be copied to the new key. :type version_id: string :param version_id: Unused in this subclass. :type storage_class: string :param storage_class: The storage class of the new key. By default, the new key will use the standard storage class. Possible values are: STANDARD | DURABLE_REDUCED_AVAILABILITY :type preserve_acl: bool :param preserve_acl: If True, the ACL from the source key will be copied to the destination key. If False, the destination key will have the default ACL. Note that preserving the ACL in the new key object will require two additional API calls to GCS, one to retrieve the current ACL and one to set that ACL on the new object. If you don't care about the ACL (or if you have a default ACL set on the bucket), a value of False will be significantly more efficient. :type encrypt_key: bool :param encrypt_key: Included for compatibility with S3. This argument is ignored. :type headers: dict :param headers: A dictionary of header name/value pairs. :type query_args: string :param query_args: A string of additional querystring arguments to append to the request :rtype: :class:`boto.gs.key.Key` :returns: An instance of the newly created key object zx-goog-copy-source-generation)metadata storage_class preserve_acl encrypt_keyr8 query_args)strrrcopy_key) r new_key_namesrc_bucket_name src_key_namerCsrc_version_idrDrErFr8rGsrc_generationr r"r#rIs:  zBucket.copy_keycCst||||||S)a List versioned objects within a bucket. This returns an instance of an VersionedBucketListResultSet that automatically handles all of the result paging, etc. from GCS. You just need to keep iterating until there are no more results. Called with no arguments, this will return an iterator object across all keys within the bucket. :type prefix: string :param prefix: allows you to limit the listing to a particular prefix. For example, if you call the method with prefix='/foo/' then the iterator will only cycle through the keys that begin with the string '/foo/'. :type delimiter: string :param delimiter: can be used in conjunction with the prefix to allow you to organize and browse your keys hierarchically. See: https://developers.google.com/storage/docs/reference-headers#delimiter for more details. :type marker: string :param marker: The "marker" of where you are in the result set :type generation_marker: string :param generation_marker: The "generation marker" of where you are in the result set. :type headers: dict :param headers: A dictionary of header name/value pairs. :rtype: :class:`boto.gs.bucketlistresultset.VersionedBucketListResultSet` :return: an instance of a BucketListResultSet that handles paging, etc. r )rprefix delimitermarkergeneration_markerr8r"r"r# list_versionss%zBucket.list_versionscCs||gddS)z9 See documentation in boto/s3/bucket.py. )version_id_markerrQrRrSrPmax_keysN)validate_kwarg_names)rparamsr"r"r# validate_get_all_versions_paramssz'Bucket.validate_get_all_versions_paramscCs.g}|r |d||j|||||ddS)a Deletes a key from the bucket. :type key_name: string :param key_name: The key name to delete :type headers: dict :param headers: A dictionary of header name/value pairs. :type version_id: string :param version_id: Unused in this subclass. :type mfa_token: tuple or list of strings :param mfa_token: Unused in this subclass. :type generation: int :param generation: The generation number of the key to delete. If not specified, the latest generation number will be deleted. :rtype: :class:`boto.gs.key.Key` :returns: A key object holding information on what was deleted. r,)r8r9 mfa_tokenr-N)r0_delete_key_internal)rr7r8r9rZr;r-r"r"r# delete_keys zBucket.delete_keycCsTt|tr tdt|tr|j||||||ddS|j||||||ddS)aSets or changes a bucket's or key's ACL. :type acl_or_str: string or :class:`boto.gs.acl.ACL` :param acl_or_str: A canned ACL string (see :data:`~.gs.acl.CannedACLStrings`) or an ACL object. :type key_name: string :param key_name: A key name within the bucket to set the ACL for. If not specified, the ACL for the bucket will be set. :type headers: dict :param headers: Additional headers to set during the request. :type version_id: string :param version_id: Unused in this subclass. :type generation: int :param generation: If specified, sets the ACL for a specific generation of a versioned object. If not specified, the current version is modified. :type if_generation: int :param if_generation: (optional) If set to a generation number, the acl will only be updated if its current generation number is this value. :type if_metageneration: int :param if_metageneration: (optional) If set to a metageneration number, the acl will only be updated if its current metageneration number is this value. "Attempt to set S3 Policy on GS ACL)r8r; if_generationif_metagenerationN) isinstancerrr set_xml_aclto_xmlset_canned_acl)r acl_or_strr7r8r9r;r^r_r"r"r#set_acls    zBucket.set_aclcCsDt|tr tdt|tr|j||ddS|j||ddS)aFSets or changes a bucket's default ACL. :type acl_or_str: string or :class:`boto.gs.acl.ACL` :param acl_or_str: A canned ACL string (see :data:`~.gs.acl.CannedACLStrings`) or an ACL object. :type headers: dict :param headers: Additional headers to set during the request. r]r8N)r`rrrset_def_xml_aclrbset_def_canned_acl)rrdr8r"r"r# set_def_aclEs  zBucket.set_def_aclcCs|jjd|j|||d}|}|jdkr@|jdkr5t|}|r&|dnd}|r5d|}t t||}|jj |j|j ||S)zBProvides common functionality for get_xml_acl and _get_acl_helper.GETrGr8r.detailsNzP
%s. Note that Full Control access is required to access ACLs.
) r make_requestrreadr5ERROR_DETAILS_REGEXsearchgroupresubproviderstorage_response_errorr6)rr7r8rGresponsebodymatchrmr"r"r#_get_xml_acl_helperVs$    zBucket._get_xml_acl_helpercCs4||||}t|}t||}tj|||S)z:Provides common functionality for get_acl and get_def_acl.)rzrr XmlHandlerxmlsax parseString)rr7r8rGrxrhr"r"r#_get_acl_helperis  zBucket._get_acl_helpercC"t}|r |d|7}||||S)aReturns the ACL of the bucket or an object in the bucket. :param str key_name: The name of the object to get the ACL for. If not specified, the ACL for the bucket will be returned. :param dict headers: Additional headers to set during the request. :type version_id: string :param version_id: Unused in this subclass. :param int generation: If specified, gets the ACL for a specific generation of a versioned object. If not specified, the current version is returned. This parameter is only valid when retrieving the ACL of an object, not a bucket. :rtype: :class:`.gs.acl.ACL` &generation=%s) STANDARD_ACLrrr7r8r9r;rGr"r"r#get_aclq zBucket.get_aclcCr)aReturns the ACL string of the bucket or an object in the bucket. :param str key_name: The name of the object to get the ACL for. If not specified, the ACL for the bucket will be returned. :param dict headers: Additional headers to set during the request. :type version_id: string :param version_id: Unused in this subclass. :param int generation: If specified, gets the ACL for a specific generation of a versioned object. If not specified, the current version is returned. This parameter is only valid when retrieving the ACL of an object, not a bucket. :rtype: str r)rrzrr"r"r# get_xml_aclrzBucket.get_xml_aclcCs|d|tS)zReturns the bucket's default ACL. :param dict headers: Additional headers to set during the request. :rtype: :class:`.gs.acl.ACL` rO)r DEF_OBJ_ACLrr8r"r"r# get_def_aclszBucket.get_def_aclc Cs|pi}d} |r|||jjj<n|} |r|d|7}|dur&|dur&td|s0|s,|r0td|dur:t||d<|durDt||d<|jjdt|jt|t| ||d } | } | j d krk|jj | j | j | dS) zProvides common functionality for set_acl, set_xml_acl, set_canned_acl, set_def_acl, set_def_xml_acl, and set_def_canned_acl().rOrNzReceived if_metageneration argument with no if_generation argument. A metageneration has no meaning without a content generation.zXReceived if_generation or if_metageneration parameter while setting the ACL of a bucket.zx-goog-if-generation-matchzx-goog-if-metageneration-matchPUT)datar8rGrl) rru acl_header ValueErrorrHrnrrror5rvr6) rrdr7r8rGr;r^r_cannedrrwrxr"r"r#_set_acl_helpers2       zBucket._set_acl_helperrc Cs|j|||||||dS)aSets a bucket's or objects's ACL to an XML string. :type acl_str: string :param acl_str: A string containing the ACL XML. :type key_name: string :param key_name: A key name within the bucket to set the ACL for. If not specified, the ACL for the bucket will be set. :type headers: dict :param headers: Additional headers to set during the request. :type version_id: string :param version_id: Unused in this subclass. :type query_args: str :param query_args: The query parameters to pass with the request. :type generation: int :param generation: If specified, sets the ACL for a specific generation of a versioned object. If not specified, the current version is modified. :type if_generation: int :param if_generation: (optional) If set to a generation number, the acl will only be updated if its current generation number is this value. :type if_metageneration: int :param if_metageneration: (optional) If set to a metageneration number, the acl will only be updated if its current metageneration number is this value. )r7r8rGr;r^r_)r) racl_strr7r8r9rGr;r^r_r"r"r#ras #zBucket.set_xml_aclc Cs2|tvr td|t}|j|||||||ddS)aSets a bucket's or objects's ACL using a predefined (canned) value. :type acl_str: string :param acl_str: A canned ACL string. See :data:`~.gs.acl.CannedACLStrings`. :type key_name: string :param key_name: A key name within the bucket to set the ACL for. If not specified, the ACL for the bucket will be set. :type headers: dict :param headers: Additional headers to set during the request. :type version_id: string :param version_id: Unused in this subclass. :type generation: int :param generation: If specified, sets the ACL for a specific generation of a versioned object. If not specified, the current version is modified. :type if_generation: int :param if_generation: (optional) If set to a generation number, the acl will only be updated if its current generation number is this value. :type if_metageneration: int :param if_metageneration: (optional) If set to a metageneration number, the acl will only be updated if its current metageneration number is this value. -Provided canned ACL string (%s) is not valid.T)r)rrrr) rrr7r8r9r;r^r_rGr"r"r#rcs! zBucket.set_canned_aclc Cs2|tvr td|t}|j|d||dddddS)a)Sets a bucket's default ACL using a predefined (canned) value. :type acl_str: string :param acl_str: A canned ACL string. See :data:`~.gs.acl.CannedACLStrings`. :type headers: dict :param headers: Additional headers to set during the request. rrONT)r;r^r_r)rrrr)rrr8rGr"r"r#rh!s  zBucket.set_def_canned_aclcCs|j|d|tdS)zSets a bucket's default ACL to an XML string. :type acl_str: string :param acl_str: A string containing the ACL XML. :type headers: dict :param headers: Additional headers to set during the request. rO)rG)rar)rrr8r"r"r#rg3s zBucket.set_def_xml_aclcCb|jjd|jt|d}|}|jdkr&t}t||}t j |||S|jj |j|j|)zReturns a bucket's CORS XML document. :param dict headers: Additional headers to send with the request. :rtype: :class:`~.cors.Cors` rjrkrl)rrnrCORS_ARGror5r rr{r|r}r~rurvr6)rr8rwrxrrr"r"r#get_cors?s    zBucket.get_corscCsL|jjdt|jt|t|d}|}|jdkr$|jj|j|j |dS)zSets a bucket's CORS XML document. :param str cors: A string containing the CORS XML. :param dict headers: Additional headers to send with the request. rrrGr8rlN) rrnrrrror5rurvr6)rrr8rwrxr"r"r#set_corsSs  zBucket.set_corscCsf|jjd|jt|d}|}|jdkr(t|}t||}t j |||j S|jj |j|j|)z Returns the StorageClass for the bucket. :rtype: str :return: The StorageClass for the bucket. rjrkrl)rrnrSTORAGE_CLASS_ARGror5rrr{r|r}r~ StorageClassrurvr6)rr8rwrxrsrr"r"r#get_storage_classas    zBucket.get_storage_classcCs"|jt|}|jt||ddS)z Sets a bucket's storage class. :param str storage_class: A string containing the storage class. :param dict headers: Additional headers to send with the request. rfN)StorageClassBodyrset_subresourcer)rrDr8req_bodyr"r"r#set_storage_classuszBucket.set_storage_classcCf|tvr |jjd||j|d}||||j||d|r/|D] }|j|||dq$dSdS)a Convenience method that provides a quick way to add an email grant to a bucket. This method retrieves the current ACL, creates a new grant based on the parameters passed in, adds that grant to the ACL and then PUT's the new ACL back to GCS. :type permission: string :param permission: The permission being granted. Should be one of: (READ, WRITE, FULL_CONTROL). :type email_address: string :param email_address: The email address associated with the GS account your are granting the permission to. :type recursive: bool :param recursive: A boolean value to controls whether the call will apply the grant to all keys within the bucket or not. The default value is False. By passing a True value, the call will iterate through all keys in the bucket and apply the same grant to each key. CAUTION: If you have a lot of keys, this could take a long time! Unknown Permission: %srfN) GSPermissionsrrustorage_permissions_errorradd_email_grantrer permission email_address recursiver8rr>r"r"r#r  zBucket.add_email_grantcCr)a Convenience method that provides a quick way to add a canonical user grant to a bucket. This method retrieves the current ACL, creates a new grant based on the parameters passed in, adds that grant to the ACL and then PUTs the new ACL back to GCS. :type permission: string :param permission: The permission being granted. Should be one of: (READ|WRITE|FULL_CONTROL) :type user_id: string :param user_id: The canonical user id associated with the GS account you are granting the permission to. :type recursive: bool :param recursive: A boolean value to controls whether the call will apply the grant to all keys within the bucket or not. The default value is False. By passing a True value, the call will iterate through all keys in the bucket and apply the same grant to each key. CAUTION: If you have a lot of keys, this could take a long time! rrfN)rrrurradd_user_grantre)rruser_idrr8rr>r"r"r#rrzBucket.add_user_grantcCr)a Convenience method that provides a quick way to add an email group grant to a bucket. This method retrieves the current ACL, creates a new grant based on the parameters passed in, adds that grant to the ACL and then PUT's the new ACL back to GCS. :type permission: string :param permission: The permission being granted. Should be one of: READ|WRITE|FULL_CONTROL See http://code.google.com/apis/storage/docs/developer-guide.html#authorization for more details on permissions. :type email_address: string :param email_address: The email address associated with the Google Group to which you are granting the permission. :type recursive: bool :param recursive: A boolean value to controls whether the call will apply the grant to all keys within the bucket or not. The default value is False. By passing a True value, the call will iterate through all keys in the bucket and apply the same grant to each key. CAUTION: If you have a lot of keys, this could take a long time! rrfN)rrrurradd_group_email_grantrerr"r"r#rs  zBucket.add_group_email_grantcCs|j|d}|jS)zReturns the ACL entries applied to this bucket. :param dict headers: Additional headers to send with the request. :rtype: list containing :class:`~.gs.acl.Entry` objects. rf)rentries)rr8rr"r"r# list_grantss zBucket.list_grantscCsd}|jd||ddS)zsDisable logging on this bucket. :param dict headers: Additional headers to send with the request. z0loggingrfN)r)rr8xml_strr"r"r#disable_loggingszBucket.disable_loggingcCsLt|tr|j}d}|d|}|r|d|}|d}|jd||ddS)aEnable logging on a bucket. :type target_bucket: bucket or string :param target_bucket: The bucket to log to. :type target_prefix: string :param target_prefix: The prefix which should be prepended to the generated log files written to the target_bucket. :param dict headers: Additional headers to send with the request. z/z%sz%%sz rrfN)r`rrr)r target_bucket target_prefixr8rr"r"r#enable_loggings  zBucket.enable_loggingcCt|jjd|jd|d}|}tj||jdkr%|jj |j|j |tj }tj |d}||||fS)aMReturns the current status of logging configuration on the bucket as unparsed XML. :param dict headers: Additional headers to send with the request. :rtype: 2-Tuple :returns: 2-tuple containing: 1) A dictionary containing the parsed XML response from GCS. The overall structure is: * Logging * LogObjectPrefix: Prefix that is prepended to log objects. * LogBucket: Target bucket for log objects. 2) Unparsed XML describing the bucket's logging configuration. rjrrkrlNrrnrrobotologdebugr5rurvr6 jsonresponseElementr{parserr8rwrxr@rr"r"r#get_logging_config_with_xmls      z"Bucket.get_logging_config_with_xmlcC||dS)aReturns the current status of logging configuration on the bucket. :param dict headers: Additional headers to send with the request. :rtype: dict :returns: A dictionary containing the parsed XML response from GCS. The overall structure is: * Logging * LogObjectPrefix: Prefix that is prepended to log objects. * LogBucket: Target bucket for log objects. r)rrr"r"r#get_logging_config<szBucket.get_logging_configcCs|r|j|}nd}|r|j|}nd}|j||f}|jjdt|jt|d|d}|}|jdkr6dS|jj |j|j |)aQConfigure this bucket to act as a website :type main_page_suffix: str :param main_page_suffix: Suffix that is appended to a request that is for a "directory" on the website endpoint (e.g. if the suffix is index.html and you make a request to samplebucket/images/ the data that is returned will be for the object with the key name images/index.html). The suffix must not be empty and must not include a slash character. This parameter is optional and the property is disabled if excluded. :type error_key: str :param error_key: The object key name to use when a 400 error occurs. This parameter is optional and the property is disabled if excluded. :param dict headers: Additional headers to send with the request. rOr websiteConfigrrlT) WebsiteMainPageFragmentWebsiteErrorFragment WebsiteBodyrrnrrror5rurvr6)rmain_page_suffix error_keyr8main_page_frag error_fragrxrwr"r"r#configure_websiteLs"    zBucket.configure_websitecCr)a6Returns the current status of website configuration on the bucket. :param dict headers: Additional headers to send with the request. :rtype: dict :returns: A dictionary containing the parsed XML response from GCS. The overall structure is: * WebsiteConfiguration * MainPageSuffix: suffix that is appended to request that is for a "directory" on the website endpoint. * NotFoundPage: name of an object to serve when site visitors encounter a 404. r)"get_website_configuration_with_xmlrr"r"r#get_website_configurationtsz Bucket.get_website_configurationcCr)aReturns the current status of website configuration on the bucket as unparsed XML. :param dict headers: Additional headers to send with the request. :rtype: 2-Tuple :returns: 2-tuple containing: 1) A dictionary containing the parsed XML response from GCS. The overall structure is: * WebsiteConfiguration * MainPageSuffix: suffix that is appended to request that is for a "directory" on the website endpoint. * NotFoundPage: name of an object to serve when site visitors encounter a 404 2) Unparsed XML describing the bucket's website configuration. rjrrkrlNrrr"r"r#rs      z)Bucket.get_website_configuration_with_xmlcCs|j|ddS)zRemove the website configuration from this bucket. :param dict headers: Additional headers to send with the request. rfN)rrr"r"r#delete_website_configurationsz#Bucket.delete_website_configurationcCs|jjd|jd|d}|}tj||jdkr%|jj |j|j |tj }tj |d||d}d|voA|ddkS) zdReturns the current status of versioning configuration on the bucket. :rtype: bool rj versioningrkrlNVersioningConfigurationStatusEnabledr)rr8rwrx resp_jsonr"r"r#get_versioning_statuss     zBucket.get_versioning_statuscC2|dkr |jd}n|jd}|jd||ddS)zConfigure versioning for this bucket. :param bool enabled: If set to True, enables versioning on this bucket. If set to False, disables versioning. :param dict headers: Additional headers to send with the request. Tr SuspendedrrfN)VersioningBodyr)renabledr8rr"r"r#configure_versioning  zBucket.configure_versioningcCsn|jjd|jt|d}|}tj||jdkr,t }t ||}t j |||S|jj|j|j|)a Returns the current lifecycle configuration on the bucket. :rtype: :class:`boto.gs.lifecycle.LifecycleConfig` :returns: A LifecycleConfig object that describes all current lifecycle rules in effect for the bucket. rjrkrl)rrnr LIFECYCLE_ARGrorrrr5r rr{r|r}r~rurvr6)rr8rwrxlifecycle_configrr"r"r#get_lifecycle_configs     zBucket.get_lifecycle_configcCsT|}|jjdt|jt|t|d}|}|jdkrdS|jj |j|j |)z Configure lifecycle for this bucket. :type lifecycle_config: :class:`boto.gs.lifecycle.LifecycleConfig` :param lifecycle_config: The lifecycle configuration you want to configure for this bucket. rrrlT) rbrrnrrrror5rurvr6)rrr8r|rwrxr"r"r#configure_lifecycles  zBucket.configure_lifecyclecCr)atReturns the current status of billing configuration on the bucket. :param dict headers: Additional headers to send with the request. :rtype: dict :returns: A dictionary containing the parsed XML response from GCS. The overall structure is: * BillingConfiguration * RequesterPays: Enabled/Disabled. r)"get_billing_configuration_with_xmlrr"r"r#get_billing_configs zBucket.get_billing_configcCr)aReturns the current status of billing configuration on the bucket as unparsed XML. :param dict headers: Additional headers to send with the request. :rtype: 2-Tuple :returns: 2-tuple containing: 1) A dictionary containing the parsed XML response from GCS. The overall structure is: * BillingConfiguration * RequesterPays: Enabled/Disabled. 2) Unparsed XML describing the bucket's website configuration. rjbillingrkrlNrrr"r"r#rs      z)Bucket.get_billing_configuration_with_xmlcCr)aConfigure billing for this bucket. :param bool requester_pays: If set to True, enables requester pays on this bucket. If set to False, disables requester pays. :param dict headers: Additional headers to send with the request. TrDisabledrrfN) BillingBodyr)rrequester_paysr8rr"r"r#configure_billing(rzBucket.configure_billingcCr)zReturns a bucket's EncryptionConfig. :param dict headers: Additional headers to send with the request. :rtype: :class:`~.encryption_config.EncryptionConfig` rjrkrl)rrnrENCRYPTION_CONFIG_ARGror5r rr{r|r}r~rurvr6)rr8rwrxencryption_configrr"r"r#get_encryption_config6s    zBucket.get_encryption_configcCs|r|j|}nd}|j|S)aCreates an XML document for setting a bucket's EncryptionConfig. This method is internal as it's only here for testing purposes. As managing Cloud KMS resources for testing is complex, we settle for testing that we're creating correctly-formed XML for setting a bucket's encryption configuration. :param str default_kms_key_name: A string containing a fully-qualified Cloud KMS key name. :rtype: str rO)&EncryptionConfigDefaultKeyNameFragmentEncryptionConfigBody)rdefault_kms_key_namedefault_kms_key_name_fragr"r"r# _construct_encryption_config_xmlIs  z'Bucket._construct_encryption_config_xmlcCsX|j|d}|jjdt|jt|t|d}|}|jdkr*|jj |j|j |dS)zSets a bucket's EncryptionConfig XML document. :param str default_kms_key_name: A string containing a fully-qualified Cloud KMS key name. :param dict headers: Additional headers to send with the request. )rrrrlN) rrrnrrrror5rurvr6)rrr8rxrwr"r"r#set_encryption_config_s  zBucket.set_encryption_config)NNNN)NNrBFFNNN)rOrOrOrON)rONNNNNr)rONNN)F)rONNrNNN)FN)NN)NNN)<__name__ __module__ __qualname____doc__rrrrrrrrGSKeyrr%r+rArIrTrYr\rerirzrrrrrrarcrhrgrrrrrrrrrrrrrrrrrrrrrrrrrr __classcell__r"r"r r#r4s -B )   -   % ) )     % # )   " (  #       !  r),rsr2xml.saxr|rrboto.resultsetrboto.exceptionrr boto.gs.aclrrrrboto.gs.bucketlistresultsetr boto.gs.corsr boto.gs.encryptionconfigr boto.gs.lifecycler boto.gs.keyrr boto.s3.aclrboto.s3.bucketrS3Bucket boto.utilsr boto.compatrrrrrrrcompilerpr"r"r"r#s6