Exemple #1
0
 def _get_acl_helper(self, key_name, headers, query_args):
     """Provides common functionality for get_acl and get_def_acl."""
     body = self._get_xml_acl_helper(key_name, headers, query_args)
     acl = ACL(self)
     h = handler.XmlHandler(acl, self)
     xml.sax.parseString(body, h)
     return acl
Exemple #2
0
 def get_all_buckets(self, headers=None):
     response = self.make_request('GET', headers=headers)
     body = response.read()
     if response.status > 300:
         raise self.provider.storage_response_error(response.status,
                                                    response.reason, body)
     rs = ResultSet([('Bucket', self.bucket_class)])
     h = handler.XmlHandler(rs, self)
     if not isinstance(body, bytes):
         body = body.encode('utf-8')
     xml.sax.parseString(body, h)
     return rs
Exemple #3
0
    def get_storage_class(self):
        """
        Returns the StorageClass for the bucket.

        :rtype: str
        :return: The StorageClass for the bucket.
        """
        response = self.connection.make_request('GET',
                                                self.name,
                                                query_args='storageClass')
        body = response.read()
        if response.status == 200:
            rs = ResultSet(self)
            h = handler.XmlHandler(rs, self)
            xml.sax.parseString(body, h)
            return rs.StorageClass
        else:
            raise self.connection.provider.storage_response_error(
                response.status, response.reason, body)
Exemple #4
0
    def get_cors(self, headers=None):
        """Returns a bucket's CORS XML document.

        :param dict headers: Additional headers to send with the request.
        :rtype: :class:`~.cors.Cors`
        """
        response = self.connection.make_request('GET',
                                                self.name,
                                                query_args=CORS_ARG,
                                                headers=headers)
        body = response.read()
        if response.status == 200:
            # Success - parse XML and return Cors object.
            cors = Cors()
            h = handler.XmlHandler(cors, self)
            xml.sax.parseString(body, h)
            return cors
        else:
            raise self.connection.provider.storage_response_error(
                response.status, response.reason, body)
Exemple #5
0
    def get_lifecycle_config(self, headers=None):
        """
        Returns the current lifecycle configuration on the bucket.

        :rtype: :class:`mssapi.gs.lifecycle.LifecycleConfig`
        :returns: A LifecycleConfig object that describes all current
            lifecycle rules in effect for the bucket.
        """
        response = self.connection.make_request('GET',
                                                self.name,
                                                query_args=LIFECYCLE_ARG,
                                                headers=headers)
        body = response.read()
        mssapi.log.debug(body)
        if response.status == 200:
            lifecycle_config = LifecycleConfig()
            h = handler.XmlHandler(lifecycle_config, self)
            xml.sax.parseString(body, h)
            return lifecycle_config
        else:
            raise self.connection.provider.storage_response_error(
                response.status, response.reason, body)