Skip to content

Commit 33f87ea

Browse files
committed
Change quickstart style.
1 parent 78f2c7d commit 33f87ea

6 files changed

Lines changed: 68 additions & 26 deletions

File tree

bigquery/cloud-client/quickstart.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,18 @@
1818
# Imports the Google Cloud client library
1919
from gcloud import bigquery
2020

21-
# Instantiates the client library
22-
bigquery_client = bigquery.Client(project='YOUR_PROJECT_ID')
21+
# Your Google Cloud Platform project ID
22+
project_id = 'YOUR_PROJECT_ID'
2323

24-
# Prepares a new dataset
25-
dataset = bigquery_client.dataset('my_new_dataset')
24+
# Instantiates a client
25+
bigquery_client = bigquery.Client(project=project_id)
2626

27-
# Creates the dataset
27+
# The name for the new dataset
28+
dataset_name = 'my_new_dataset'
29+
30+
# Prepares the new dataset
31+
dataset = bigquery_client.dataset(dataset_name)
32+
33+
# Creates the new dataset
2834
dataset.create()
2935
# [END bigquery_quickstart]

datastore/api/quickstart.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,19 @@
1818
# Imports the Google Cloud client library
1919
from gcloud import datastore
2020

21-
# Instantiates the client library
22-
datastore_client = datastore.Client(project='YOUR_PROJECT_ID')
21+
# Your Google Cloud Platform project ID
22+
project_id = 'YOUR_PROJECT_ID'
2323

24-
task_key = datastore_client.key('Task', 1234)
24+
# Instantiates a client
25+
datastore_client = datastore.Client(project=project_id)
2526

26-
# Retrieves an entity
27+
# The kind of the entity to retrieve
28+
kind = 'Task'
29+
# The id of the entity to retrieve
30+
id = 1234567890
31+
# The Datastore key for the entity
32+
task_key = datastore_client.key(kind, id)
33+
34+
# Retrieves the entity
2735
entity = datastore_client.get(task_key)
2836
# [END datastore_quickstart]

logging/cloud-client/quickstart.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,20 @@
1818
# Imports the Google Cloud client library
1919
from gcloud import logging
2020

21-
# Instantiates the client library
22-
logging_client = logging.Client(project='YOUR_PROJECT_ID')
21+
# Your Google Cloud Platform project ID
22+
project_id = 'YOUR_PROJECT_ID'
2323

24+
# Instantiates a client
25+
logging_client = logging.Client(project=project_id)
26+
27+
# The name of the log to write to
28+
log_name = 'my-log'
2429
# Selects the log to write to
25-
logger = logging_client.logger('my-log')
30+
logger = logging_client.logger(log_name)
31+
32+
# The data to log
33+
text = 'Hello, world!'
2634

27-
# Writes a log entry
28-
logger.log_text('Hello, world!')
35+
# Writes the log entry
36+
logger.log_text(text)
2937
# [END logging_quickstart]

pubsub/cloud-client/quickstart.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,18 @@
1818
# Imports the Google Cloud client library
1919
from gcloud import pubsub
2020

21-
# Instantiates the client library
22-
pubsub_client = pubsub.Client(project='YOUR_PROJECT_ID')
21+
# Your Google Cloud Platform project ID
22+
project_id = 'YOUR_PROJECT_ID'
2323

24-
# Prepares a new topic
25-
topic = pubsub_client.topic('my-new-topic')
24+
# Instantiates a client
25+
pubsub_client = pubsub.Client(project=project_id)
2626

27-
# Creates the topic
27+
# The name for the new topic
28+
topic_name = 'my-new-topic'
29+
30+
# Prepares the new topic
31+
topic = pubsub_client.topic(topic_name)
32+
33+
# Creates the new topic
2834
topic.create()
2935
# [END pubsub_quickstart]

storage/cloud-client/quickstart.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,15 @@
1818
# Imports the Google Cloud client library
1919
from gcloud import storage
2020

21-
# Instantiates the client library
22-
storage_client = storage.Client(project='YOUR_PROJECT_ID')
21+
# Your Google Cloud Platform project ID
22+
project_id = 'YOUR_PROJECT_ID'
2323

24-
# Creates a new bucket
25-
bucket = storage_client.create_bucket('my-new-bucket')
24+
# Instantiates a client
25+
storage_client = storage.Client(project=project_id)
26+
27+
# The name for the new bucket
28+
bucket_name = 'my-new-bucket'
29+
30+
# Creates the new bucket
31+
bucket = storage_client.create_bucket(bucket_name)
2632
# [END storage_quickstart]

translate/cloud-client/quickstart.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,17 @@
1818
# Imports the Google Cloud client library
1919
from gcloud import translate
2020

21-
# Instantiates the client library
22-
translate_client = translate.Client('YOUR_API_KEY')
21+
# Your Translate API key
22+
api_key = 'YOUR_API_KEY'
23+
24+
# Instantiates a client
25+
translate_client = translate.Client(api_key)
26+
27+
# The text to translate
28+
text = 'Hello, world!'
29+
# The target language
30+
target = 'ru'
2331

2432
# Translates some text into Russian
25-
translation = translate_client.translate('Hello, world!', target_language='ru')
33+
translation = translate_client.translate(text, target_language=target)
2634
# [END translate_quickstart]

0 commit comments

Comments
 (0)