Ejemplo n.º 1
0
 def get_bucket(self, bucket_name, **kwargs):
     """Get a bucket information.
     :param str bucket_name: the bucket name
     :returns BucketInfo:
     :see: http://docs.ceph.com/docs/master/radosgw/adminops/#get-bucket-info
     """
     params = {'bucket': bucket_name}
     _kwargs_get('stats', kwargs, params, True)
     _kwargs_get('format', kwargs, params, 'json')
     response = self.make_request('GET',
                                  path='/bucket',
                                  query_params=params)
     body = self._process_response(response)
     bucket_dict = json.loads(body)
     # XXX: print(json.dumps(bucket_dict, indent=4, sort_keys=True))
     bucket = BucketInfo(self, bucket_dict)
     return bucket
Ejemplo n.º 2
0
 def get_buckets(self, uid=None, **kwargs):
     """Get all, or user specific, buckets information.
     :param str uid: the user id
     :returns iterator: iterator of buckets information
     :see: http://docs.ceph.com/docs/master/radosgw/adminops/#get-bucket-info
     """
     params = {'stats': True}
     if uid:
         params['uid'] = uid
     # optional query parameters
     _kwargs_get('format', kwargs, params, 'json')
     response = self.make_request('GET',
                                  path='/bucket',
                                  query_params=params)
     body = self._process_response(response)
     body_json = json.loads(body)
     boto.log.debug('%d buckets' % len(body_json))
     for bucket_dict in body_json:
         bucket = BucketInfo(self, bucket_dict)
         yield bucket