File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1818# Imports the Google Cloud client library
1919from 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
2834dataset .create ()
2935# [END bigquery_quickstart]
Original file line number Diff line number Diff line change 1818# Imports the Google Cloud client library
1919from 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
2735entity = datastore_client .get (task_key )
2836# [END datastore_quickstart]
Original file line number Diff line number Diff line change 1818# Imports the Google Cloud client library
1919from 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]
Original file line number Diff line number Diff line change 1818# Imports the Google Cloud client library
1919from 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
2834topic .create ()
2935# [END pubsub_quickstart]
Original file line number Diff line number Diff line change 1818# Imports the Google Cloud client library
1919from 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]
Original file line number Diff line number Diff line change 1818# Imports the Google Cloud client library
1919from 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]
You can’t perform that action at this time.
0 commit comments