Package: gcloud
Python idiomatic client forGoogle Cloud Platformservices.google-cloudWarning: This package has moved. It has been renamed togoogle-cloud on PyPI. No new releases will be made forgcloud.OverviewHomepageAPI DocumentationThis client supports the following Google Cloud Platform services:Google CloudDatastoreGoogle CloudStorageGoogle CloudPub/SubGoogleBigQueryGoogle CloudResource ManagerGoogleStackdriver LoggingIf you need support for other Google APIs, check out theGoogle APIs Python Client library.Quick Start$ pip install --upgrade gcloudExample Applicationsgetting-started-python- A sample andtutorialthat demonstrates how to build a complete web application using Cloud Datastore, Cloud Storage, and Cloud Pub/Sub and deploy it to Google App Engine or Google Compute Engine.gcloud-python-expenses-demo- A sample expenses demo using Cloud Datastore and Cloud StorageAuthenticationWithgcloud-pythonwe try to make authentication as painless as possible.
Check out theAuthentication sectionin our documentation to learn more.
You may also find theauthentication documentshared by all thegcloud-*libraries to be helpful.Google Cloud DatastoreGoogleCloud Datastore(Datastore API docs) is a fully managed, schemaless
database for storing non-relational data. Cloud Datastore automatically scales
with your users and supports ACID transactions, high availability of reads and
writes, strong consistency for reads and ancestor queries, and eventual
consistency for all other queries.See thegcloud-pythonAPIdatastore documentationto learn how to
interact with the Cloud Datastore using this Client Library.See theofficial Google Cloud Datastore documentationfor more details on how
to activate Cloud Datastore for your project.fromgcloudimportdatastore# Create, populate and persist an entityentity=datastore.Entity(key=datastore.Key('EntityKind'))entity.update({'foo':u'bar','baz':1337,'qux':False,})# Then query for entitiesquery=datastore.Query(kind='EntityKind')forresultinquery.fetch():printresultGoogle Cloud StorageGoogleCloud Storage(Storage API docs) allows you to store data on Google
infrastructure with very high reliability, performance and availability, and can
be used to distribute large data objects to users via direct download.See thegcloud-pythonAPIstorage documentationto learn how to connect
to Cloud Storage using this Client Library.You need to create a Google Cloud Storage bucket to use this client library.
Follow along with theofficial Google Cloud Storage documentationto learn
how to create a bucket.fromgcloudimportstorageclient=storage.Client()bucket=client.get_bucket('bucket-id-here')# Then do other things...blob=bucket.get_blob('remote/path/to/file.txt')printblob.download_as_string()blob.upload_from_string('New contents!')blob2=bucket.blob('remote/path/storage.txt')blob2.upload_from_filename(filename='/local/path.txt')Google Cloud Pub/SubGoogleCloud Pub/Sub(Pub/Sub API docs) is designed to provide reliable,
many-to-many, asynchronous messaging between applications. Publisher
applications can send messages to atopicand other applications can
subscribe to that topic to receive the messages. By decoupling senders and
receivers, Google Cloud Pub/Sub allows developers to communicate between
independently written applications.See thegcloud-pythonAPIPub/Sub documentationto learn how to connect
to Cloud Pub/Sub using this Client Library.To get started with this API, you’ll need to createfromgcloudimportpubsubclient=pubsub.Client()topic=client.topic('topic_name')topic.create()topic.publish('this is the message_payload',attr1='value1',attr2='value2')Google BigQueryQuerying massive datasets can be time consuming and expensive without the
right hardware and infrastructure. GoogleBigQuery(BigQuery API docs)
solves this problem by enabling super-fast, SQL-like queries against
append-only tables, using the processing power of Google’s infrastructure.This package is still being implemented, but it is almost complete!Load data from CSVimportcsvfromgcloudimportbigqueryfromgcloud.bigqueryimportSchemaFieldclient=bigquery.Client()dataset=client.dataset('dataset_name')dataset.create()# API requestSCHEMA=[SchemaField('full_name','STRING',mode='required'),SchemaField('age','INTEGER',mode='required'),]table=dataset.table('table_name',SCHEMA)table.create()withopen('csv_file','rb')asreadable:table.upload_from_file(readable,source_format='CSV',skip_leading_rows=1)Perform a synchronous query# Perform a synchronous query.QUERY=('SELECT name FROM [bigquery-public-data:usa_names.usa_1910_2013] ''WHERE state = "TX"')query=client.run_sync_query('%sLIMIT 100'%QUERY)query.timeout_ms=TIMEOUT_MSquery.run()forrowinquery.rows:printrowSee thegcloud-pythonAPIBigQuery documentationto learn how to connect
to BigQuery using this Client Library.Google Cloud Resource ManagerThe CloudResource ManagerAPI (Resource Manager API docs) provides
methods that you can use to programmatically manage your projects in the
Google Cloud Platform.See thegcloud-pythonAPIResource Manager documentationto learn how to
manage projects using this Client Library.Google Stackdriver LoggingStackdriver LoggingAPI (Logging API docs) allows you to store, search,
analyze, monitor, and alert on log data and events from Google Cloud Platform.fromgcloudimportloggingclient=logging.Client()logger=client.logger('log_name')logger.log_text("A simple entry")# API callExample of fetching entries:entries,token=logger.list_entries()forentryinentries:printentry.payloadSee thegcloud-pythonAPIlogging documentationto learn how to connect
to Stackdriver Logging using this Client Library.ContributingContributions to this library are always welcome and highly encouraged.SeeCONTRIBUTING docfor more information on how to get started.LicenseApache 2.0 - Seethe LICENSEfor more information.