Skip to content

Commit

Permalink
Merge pull request #73 from GoogleCloudPlatform/storage
Browse files Browse the repository at this point in the history
Add annotation for just the list_bucket part
  • Loading branch information
Jonathan Wayne Parrott committed Sep 2, 2015
2 parents e3111b4 + 087a270 commit 25d0540
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions storage/list_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,24 @@ def main(argv):
# Parse the command-line flags.
args = parser.parse_args(argv[1:])

# [START list_bucket]
# Get the application default credentials. When running locally, these are
# available after running `gcloud auth login`. When running on compute
# engine, these are available from the environment.
credentials = GoogleCredentials.get_application_default()

# Construct the service object for interacting with the Cloud Storage API.
# Construct the service object for interacting with the Cloud Storage API -
# the 'storage' service, at version 'v1'.
# You can browse other available api services and versions here:
# https://developers.google.com/api-client-library/python/apis/
service = discovery.build('storage', 'v1', credentials=credentials)

# Make a request to buckets.get to retrieve information about the bucket.
# Make a request to buckets.get to retrieve a list of objects in the
# specified bucket.
req = service.buckets().get(bucket=args.bucket)
resp = req.execute()
print json.dumps(resp, indent=2)
# [END list_bucket]

# Create a request to objects.list to retrieve a list of objects.
fields_to_return = \
Expand Down

0 comments on commit 25d0540

Please sign in to comment.