Skip to content

Commit

Permalink
Change quickstart style.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmdobry committed Sep 29, 2016
1 parent f257ce8 commit 8bc413d
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 26 deletions.
16 changes: 11 additions & 5 deletions bigquery/cloud-client/quickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,18 @@
# Imports the Google Cloud client library
from gcloud import bigquery

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

# Prepares a new dataset
dataset = bigquery_client.dataset('my_new_dataset')
# Instantiates a client
bigquery_client = bigquery.Client(project=project_id)

# Creates the dataset
# The name for the new dataset
dataset_name = 'my_new_dataset'

# Prepares the new dataset
dataset = bigquery_client.dataset(dataset_name)

# Creates the new dataset
dataset.create()
# [END bigquery_quickstart]
16 changes: 12 additions & 4 deletions datastore/api/quickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,19 @@
# Imports the Google Cloud client library
from gcloud import datastore

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

task_key = datastore_client.key('Task', 1234)
# Instantiates a client
datastore_client = datastore.Client(project=project_id)

# Retrieves an entity
# The kind of the entity to retrieve
kind = 'Task'
# The id of the entity to retrieve
id = 1234567890
# The Datastore key for the entity
task_key = datastore_client.key(kind, id)

# Retrieves the entity
entity = datastore_client.get(task_key)
# [END datastore_quickstart]
18 changes: 13 additions & 5 deletions logging/cloud-client/quickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,20 @@
# Imports the Google Cloud client library
from gcloud import logging

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

# Instantiates a client
logging_client = logging.Client(project=project_id)

# The name of the log to write to
log_name = 'my-log'
# Selects the log to write to
logger = logging_client.logger('my-log')
logger = logging_client.logger(log_name)

# The data to log
text = 'Hello, world!'

# Writes a log entry
logger.log_text('Hello, world!')
# Writes the log entry
logger.log_text(text)
# [END logging_quickstart]
16 changes: 11 additions & 5 deletions pubsub/cloud-client/quickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,18 @@
# Imports the Google Cloud client library
from gcloud import pubsub

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

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

# Creates the topic
# The name for the new topic
topic_name = 'my-new-topic'

# Prepares the new topic
topic = pubsub_client.topic(topic_name)

# Creates the new topic
topic.create()
# [END pubsub_quickstart]
14 changes: 10 additions & 4 deletions storage/cloud-client/quickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,15 @@
# Imports the Google Cloud client library
from gcloud import storage

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

# Creates a new bucket
bucket = storage_client.create_bucket('my-new-bucket')
# Instantiates a client
storage_client = storage.Client(project=project_id)

# The name for the new bucket
bucket_name = 'my-new-bucket'

# Creates the new bucket
bucket = storage_client.create_bucket(bucket_name)
# [END storage_quickstart]
14 changes: 11 additions & 3 deletions translate/cloud-client/quickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,17 @@
# Imports the Google Cloud client library
from gcloud import translate

# Instantiates the client library
translate_client = translate.Client('YOUR_API_KEY')
# Your Translate API key
api_key = 'YOUR_API_KEY'

# Instantiates a client
translate_client = translate.Client(api_key)

# The text to translate
text = 'Hello, world!'
# The target language
target = 'ru'

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

0 comments on commit 8bc413d

Please sign in to comment.