def list_bucket(bucket_name):
 url = 'https://www.googleapis.com/storage/v1/b/{0}/o'.format(bucket_name)
 try:
  response = gcs_get_request(url)
  if (response.status_code != HTTP_OK):
   logging.error('Error on listing objects in GCS bucket: {0}. Error: {1}'.format(bucket_name, response.status_code))
   return []
  content = json.loads(response.content)
 except requests.HTTPError as error:
  logging.error('Error on listing objects in GCS bucket: {0}. Error: {1}'.format(bucket_name, error))
  return []
 if ('items' not in content.keys()):
  return []
 objects = []
 for item in content['items']:
  objects.append(item['name'])
 logging.debug('Bucket contents: {0}'.format(objects))
 return objects

def list_bucket ( bucket_name ) : url = 'https://www.googleapis.com/storage/v1/b/{0}/o' . format ( bucket_name ) try : response = gcs_get_request ( url ) if ( response . status_code != HTTP_OK ) : logging . error ( 'Error on listing objects in GCS bucket: {0}. Error: {1}' . format ( bucket_name , response . status_code ) ) return [ ] content = json . loads ( response . content ) except requests . HTTPError as error : logging . error ( 'Error on listing objects in GCS bucket: {0}. Error: {1}' . format ( bucket_name , error ) ) return [ ] if ( 'items' not in content . keys ( ) ) : return [ ] objects = [ ] for item in content [ 'items' ] : objects . append ( item [ 'name' ] ) logging . debug ( 'Bucket contents: {0}' . format ( objects ) ) return objects
returns a list of metadata of the objects within the given bucket .