Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
35 lines (27 sloc) 1011 Bytes
'''
File Name: Project.py
Shows how to perform project operations.
@version: 1.0
@author: mielem@gmail.com
'''
import boto
# URI scheme for Google Cloud Storage.
GOOGLE_STORAGE = "gs"
def list_buckets(project_id, debug_level):
'''
Perform a GET Service operation to list the buckets
contained in the specified project.
@param project_id: The id of the project that contains the buckets to list.
@param debug_level: The level of debug messages to be printed.
'''
try:
# Define the project URI
uri = boto.storage_uri("", GOOGLE_STORAGE, debug_level)
# Define the header values.
header_values = {"x-goog-api-version": "2",
"x-goog-project-id": str(project_id)}
# List the buckets in the projects.
for bucket in uri.get_all_buckets(headers=header_values):
print bucket.name
except boto.exception, e:
logging.error("list_buckets, error occurred: %s", e)