@@ -9,9 +9,11 @@ Google Cloud Python Client
99
1010- `Homepage `_
1111- `API Documentation `_
12+ - `Read The Docs Documentation `_
1213
1314.. _Homepage : https://googlecloudplatform.github.io/google-cloud-python/
1415.. _API Documentation : http://googlecloudplatform.github.io/google-cloud-python/
16+ .. _Read The Docs Documentation : http://google-cloud-python.readthedocs.io/en/stable/
1517
1618This client supports the following Google Cloud Platform services:
1719
@@ -20,18 +22,28 @@ This client supports the following Google Cloud Platform services:
2022- `Google Cloud Pub/Sub `_
2123- `Google BigQuery `_
2224- `Google Cloud Resource Manager `_
23- - `Google Stackdriver Logging `_
24- - `Google Stackdriver Monitoring `_
25+ - `Stackdriver Logging `_
26+ - `Stackdriver Monitoring `_
2527- `Google Cloud Bigtable `_
26-
27- .. _Google Cloud Datastore : https://github.com/GoogleCloudPlatform/google-cloud-python#google-cloud-datastore
28- .. _Google Cloud Storage : https://github.com/GoogleCloudPlatform/google-cloud-python#google-cloud-storage
29- .. _Google Cloud Pub/Sub : https://github.com/GoogleCloudPlatform/google-cloud-python#google-cloud-pubsub
30- .. _Google BigQuery : https://github.com/GoogleCloudPlatform/google-cloud-python#google-bigquery
31- .. _Google Cloud Resource Manager : https://github.com/GoogleCloudPlatform/google-cloud-python#google-cloud-resource-manager
32- .. _Google Stackdriver Logging : https://github.com/GoogleCloudPlatform/google-cloud-python#google-stackdriver-logging
33- .. _Google Stackdriver Monitoring : https://github.com/GoogleCloudPlatform/google-cloud-python#google-stackdriver-monitoring
28+ - `Google Cloud DNS `_
29+ - `Stackdriver Error Reporting `_
30+ - `Google Cloud Natural Language `_
31+ - `Google Translate `_
32+ - `Google Cloud Vision `_
33+
34+ .. _Google Cloud Datastore : https://github.com/GoogleCloudPlatform/google-cloud-python/tree/master/datastore
35+ .. _Google Cloud Storage : https://github.com/GoogleCloudPlatform/google-cloud-python/tree/master/storage
36+ .. _Google Cloud Pub/Sub : https://github.com/GoogleCloudPlatform/google-cloud-python/tree/master/pubsub
37+ .. _Google BigQuery : https://github.com/GoogleCloudPlatform/google-cloud-python/tree/master/bigquery
38+ .. _Google Cloud Resource Manager : https://github.com/GoogleCloudPlatform/google-cloud-python/tree/master/resource_manager
39+ .. _Stackdriver Logging : https://github.com/GoogleCloudPlatform/google-cloud-python/tree/master/logging
40+ .. _Stackdriver Monitoring : https://github.com/GoogleCloudPlatform/google-cloud-python/tree/master/monitoring
3441.. _Google Cloud Bigtable : https://github.com/GoogleCloudPlatform/google-cloud-python/tree/master/bigtable
42+ .. _Google Cloud DNS : https://github.com/GoogleCloudPlatform/google-cloud-python/tree/master/dns
43+ .. _Stackdriver Error Reporting : https://github.com/GoogleCloudPlatform/google-cloud-python/tree/master/error_reporting
44+ .. _Google Cloud Natural Language : https://github.com/GoogleCloudPlatform/google-cloud-python/tree/master/language
45+ .. _Google Translate : https://github.com/GoogleCloudPlatform/google-cloud-python/tree/master/translate
46+ .. _Google Cloud Vision : https://github.com/GoogleCloudPlatform/google-cloud-python/tree/master/vision
3547
3648If you need support for other Google APIs, check out the
3749`Google APIs Python Client library `_.
@@ -66,250 +78,6 @@ You may also find the `authentication document`_ shared by all the
6678.. _Authentication section : http://google-cloud-python.readthedocs.io/en/latest/google-cloud-auth.html
6779.. _authentication document : https://github.com/GoogleCloudPlatform/gcloud-common/tree/master/authentication
6880
69- Google Cloud Datastore
70- ----------------------
71-
72- Google `Cloud Datastore `_ (`Datastore API docs `_) is a fully managed, schemaless
73- database for storing non-relational data. Cloud Datastore automatically scales
74- with your users and supports ACID transactions, high availability of reads and
75- writes, strong consistency for reads and ancestor queries, and eventual
76- consistency for all other queries.
77-
78- .. _Cloud Datastore : https://cloud.google.com/datastore/docs
79- .. _Datastore API docs : https://cloud.google.com/datastore/docs/
80-
81- See the ``google-cloud-python `` API `datastore documentation `_ to learn how to
82- interact with the Cloud Datastore using this Client Library.
83-
84- .. _datastore documentation : https://googlecloudplatform.github.io/google-cloud-python/stable/datastore-client.html
85-
86- See the `official Google Cloud Datastore documentation `_ for more details on how
87- to activate Cloud Datastore for your project.
88-
89- .. _official Google Cloud Datastore documentation : https://cloud.google.com/datastore/docs/activate
90-
91- .. code :: python
92-
93- from google.cloud import datastore
94- # Create, populate and persist an entity
95- entity = datastore.Entity(key = datastore.Key(' EntityKind' ))
96- entity.update({
97- ' foo' : u ' bar' ,
98- ' baz' : 1337 ,
99- ' qux' : False ,
100- })
101- # Then query for entities
102- query = datastore.Query(kind = ' EntityKind' )
103- for result in query.fetch():
104- print (result)
105-
106- Google Cloud Storage
107- --------------------
108-
109- Google `Cloud Storage `_ (`Storage API docs `_) allows you to store data on Google
110- infrastructure with very high reliability, performance and availability, and can
111- be used to distribute large data objects to users via direct download.
112-
113- .. _Cloud Storage : https://cloud.google.com/storage/docs
114- .. _Storage API docs : https://cloud.google.com/storage/docs/json_api/v1
115-
116- See the ``google-cloud-python `` API `storage documentation `_ to learn how to connect
117- to Cloud Storage using this Client Library.
118-
119- .. _storage documentation : https://googlecloudplatform.github.io/google-cloud-python/stable/storage-client.html
120-
121- You need to create a Google Cloud Storage bucket to use this client library.
122- Follow along with the `official Google Cloud Storage documentation `_ to learn
123- how to create a bucket.
124-
125- .. _official Google Cloud Storage documentation : https://cloud.google.com/storage/docs/cloud-console#_creatingbuckets
126-
127- .. code :: python
128-
129- from google.cloud import storage
130- client = storage.Client()
131- bucket = client.get_bucket(' bucket-id-here' )
132- # Then do other things...
133- blob = bucket.get_blob(' remote/path/to/file.txt' )
134- print (blob.download_as_string())
135- blob.upload_from_string(' New contents!' )
136- blob2 = bucket.blob(' remote/path/storage.txt' )
137- blob2.upload_from_filename(filename = ' /local/path.txt' )
138-
139- Google Cloud Pub/Sub
140- --------------------
141-
142- Google `Cloud Pub/Sub `_ (`Pub/Sub API docs `_) is designed to provide reliable,
143- many-to-many, asynchronous messaging between applications. Publisher
144- applications can send messages to a ``topic `` and other applications can
145- subscribe to that topic to receive the messages. By decoupling senders and
146- receivers, Google Cloud Pub/Sub allows developers to communicate between
147- independently written applications.
148-
149- .. _Cloud Pub/Sub : https://cloud.google.com/pubsub/docs
150- .. _Pub/Sub API docs : https://cloud.google.com/pubsub/docs/reference/rest/
151-
152- See the ``google-cloud-python `` API `Pub/Sub documentation `_ to learn how to connect
153- to Cloud Pub/Sub using this Client Library.
154-
155- .. _Pub/Sub documentation : https://googlecloudplatform.github.io/google-cloud-python/stable/pubsub-usage.html
156-
157- To get started with this API, you'll need to create
158-
159- .. code :: python
160-
161- from google.cloud import pubsub
162-
163- client = pubsub.Client()
164- topic = client.topic(' topic_name' )
165- topic.create()
166-
167- topic.publish(' this is the message_payload' ,
168- attr1 = ' value1' , attr2 = ' value2' )
169-
170- Google BigQuery
171- ---------------
172-
173- Querying massive datasets can be time consuming and expensive without the
174- right hardware and infrastructure. Google `BigQuery `_ (`BigQuery API docs `_)
175- solves this problem by enabling super-fast, SQL-like queries against
176- append-only tables, using the processing power of Google's infrastructure.
177-
178- .. _BigQuery : https://cloud.google.com/bigquery/what-is-bigquery
179- .. _BigQuery API docs : https://cloud.google.com/bigquery/docs/reference/v2/
180-
181- This package is still being implemented, but it is almost complete!
182-
183- Load data from CSV
184- ~~~~~~~~~~~~~~~~~~
185-
186- .. code :: python
187-
188- import csv
189-
190- from google.cloud import bigquery
191- from google.cloud.bigquery import SchemaField
192-
193- client = bigquery.Client()
194-
195- dataset = client.dataset(' dataset_name' )
196- dataset.create() # API request
197-
198- SCHEMA = [
199- SchemaField(' full_name' , ' STRING' , mode = ' required' ),
200- SchemaField(' age' , ' INTEGER' , mode = ' required' ),
201- ]
202- table = dataset.table(' table_name' , SCHEMA )
203- table.create()
204-
205- with open (' csv_file' , ' rb' ) as readable:
206- table.upload_from_file(
207- readable, source_format = ' CSV' , skip_leading_rows = 1 )
208-
209- Perform a synchronous query
210- ~~~~~~~~~~~~~~~~~~~~~~~~~~~
211-
212- .. code :: python
213-
214- # Perform a synchronous query.
215- QUERY = (
216- ' SELECT name FROM [bigquery-public-data:usa_names.usa_1910_2013] '
217- ' WHERE state = "TX"' )
218- query = client.run_sync_query(' %s LIMIT 100' % QUERY )
219- query.timeout_ms = TIMEOUT_MS
220- query.run()
221-
222- for row in query.rows:
223- print (row)
224-
225-
226- See the ``google-cloud-python `` API `BigQuery documentation `_ to learn how to connect
227- to BigQuery using this Client Library.
228-
229- .. _BigQuery documentation : https://googlecloudplatform.github.io/google-cloud-python/stable/bigquery-usage.html
230-
231- Google Cloud Resource Manager
232- -----------------------------
233-
234- The Cloud `Resource Manager `_ API (`Resource Manager API docs `_) provides
235- methods that you can use to programmatically manage your projects in the
236- Google Cloud Platform.
237-
238- .. _Resource Manager : https://cloud.google.com/resource-manager/
239- .. _Resource Manager API docs : https://cloud.google.com/resource-manager/reference/rest/
240-
241- See the ``google-cloud-python `` API `Resource Manager documentation `_ to learn how to
242- manage projects using this Client Library.
243-
244- .. _Resource Manager documentation : https://googlecloudplatform.github.io/google-cloud-python/stable/resource-manager-api.html
245-
246- Google Stackdriver Logging
247- --------------------------
248-
249- `Stackdriver Logging `_ API (`Logging API docs `_) allows you to store, search,
250- analyze, monitor, and alert on log data and events from Google Cloud Platform.
251-
252- .. _Stackdriver Logging : https://cloud.google.com/logging/
253- .. _Logging API docs : https://cloud.google.com/logging/docs/
254-
255- .. code :: python
256-
257- from google.cloud import logging
258- client = logging.Client()
259- logger = client.logger(' log_name' )
260- logger.log_text(" A simple entry" ) # API call
261-
262- Example of fetching entries:
263-
264- .. code :: python
265-
266- entries, token = logger.list_entries()
267- for entry in entries:
268- print (entry.payload)
269-
270- See the ``google-cloud-python `` API `logging documentation `_ to learn how to connect
271- to Stackdriver Logging using this Client Library.
272-
273- .. _logging documentation : https://googlecloudplatform.github.io/google-cloud-python/stable/logging-usage.html
274-
275- Google Stackdriver Monitoring
276- -----------------------------
277-
278- `Stackdriver Monitoring `_ (`Monitoring API docs `_) collects metrics,
279- events, and metadata from Google Cloud Platform, Amazon Web Services (AWS),
280- hosted uptime probes, application instrumentation, and a variety of common
281- application components including Cassandra, Nginx, Apache Web Server,
282- Elasticsearch and many others. Stackdriver ingests that data and generates
283- insights via dashboards, charts, and alerts.
284-
285- This package currently supports all Monitoring API operations other than
286- writing custom metrics.
287-
288- .. _Stackdriver Monitoring : https://cloud.google.com/monitoring/
289- .. _Monitoring API docs : https://cloud.google.com/monitoring/api/ref_v3/rest/
290-
291- List available metric types:
292-
293- .. code :: python
294-
295- from google.cloud import monitoring
296- client = monitoring.Client()
297- for descriptor in client.list_metric_descriptors():
298- print (descriptor.type)
299-
300- Display CPU utilization across your GCE instances during the last five minutes:
301-
302- .. code :: python
303-
304- metric = ' compute.googleapis.com/instance/cpu/utilization'
305- query = client.query(metric, minutes = 5 )
306- print (query.as_dataframe())
307-
308- See the ``google-cloud-python `` API `monitoring documentation `_ to learn how to connect
309- to Stackdriver Monitoring using this Client Library.
310-
311- .. _monitoring documentation : https://googlecloudplatform.github.io/google-cloud-python/stable/monitoring-usage.html
312-
31381Contributing
31482------------
31583
0 commit comments