File tree Expand file tree Collapse file tree 7 files changed +208
-0
lines changed Expand file tree Collapse file tree 7 files changed +208
-0
lines changed Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python
2+
3+ # Copyright 2016 Google Inc. All Rights Reserved.
4+ #
5+ # Licensed under the Apache License, Version 2.0 (the "License");
6+ # you may not use this file except in compliance with the License.
7+ # You may obtain a copy of the License at
8+ #
9+ # http://www.apache.org/licenses/LICENSE-2.0
10+ #
11+ # Unless required by applicable law or agreed to in writing, software
12+ # distributed under the License is distributed on an "AS IS" BASIS,
13+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+ # See the License for the specific language governing permissions and
15+ # limitations under the License.
16+
17+ # [START bigquery_quickstart]
18+ # Imports the Google Cloud client library
19+ from google .cloud import bigquery
20+
21+ # Instantiates a client
22+ bigquery_client = bigquery .Client ()
23+
24+ # The name for the new dataset
25+ dataset_name = 'my_new_dataset'
26+
27+ # Prepares the new dataset
28+ dataset = bigquery_client .dataset (dataset_name )
29+
30+ # Creates the new dataset
31+ dataset .create ()
32+
33+ print ('Dataset {} created' .format (dataset .name ))
34+ # [END bigquery_quickstart]
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python
2+
3+ # Copyright 2016 Google Inc. All Rights Reserved.
4+ #
5+ # Licensed under the Apache License, Version 2.0 (the "License");
6+ # you may not use this file except in compliance with the License.
7+ # You may obtain a copy of the License at
8+ #
9+ # http://www.apache.org/licenses/LICENSE-2.0
10+ #
11+ # Unless required by applicable law or agreed to in writing, software
12+ # distributed under the License is distributed on an "AS IS" BASIS,
13+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+ # See the License for the specific language governing permissions and
15+ # limitations under the License.
16+
17+ # [START datastore_quickstart]
18+ # Imports the Google Cloud client library
19+ from google .cloud import datastore
20+
21+ # Instantiates a client
22+ datastore_client = datastore .Client ()
23+
24+ # The kind of the entity to retrieve
25+ kind = 'Task'
26+ # The id of the entity to retrieve
27+ id = 1234567890
28+ # The Datastore key for the entity
29+ task_key = datastore_client .key (kind , id )
30+
31+ # Retrieves the entity
32+ entity = datastore_client .get (task_key )
33+
34+ print ('Got entity: {}' .format (entity .key .id ))
35+ # [END datastore_quickstart]
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python
2+
3+ # Copyright 2016 Google Inc. All Rights Reserved.
4+ #
5+ # Licensed under the Apache License, Version 2.0 (the "License");
6+ # you may not use this file except in compliance with the License.
7+ # You may obtain a copy of the License at
8+ #
9+ # http://www.apache.org/licenses/LICENSE-2.0
10+ #
11+ # Unless required by applicable law or agreed to in writing, software
12+ # distributed under the License is distributed on an "AS IS" BASIS,
13+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+ # See the License for the specific language governing permissions and
15+ # limitations under the License.
16+
17+ # [START logging_quickstart]
18+ # Imports the Google Cloud client library
19+ from google .cloud import logging
20+
21+ # Instantiates a client
22+ logging_client = logging .Client ()
23+
24+ # The name of the log to write to
25+ log_name = 'my-log'
26+ # Selects the log to write to
27+ logger = logging_client .logger (log_name )
28+
29+ # The data to log
30+ text = 'Hello, world!'
31+
32+ # Writes the log entry
33+ logger .log_text (text )
34+
35+ print ('Logged: {}' .format (text ))
36+ # [END logging_quickstart]
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python
2+
3+ # Copyright 2016 Google Inc. All Rights Reserved.
4+ #
5+ # Licensed under the Apache License, Version 2.0 (the "License");
6+ # you may not use this file except in compliance with the License.
7+ # You may obtain a copy of the License at
8+ #
9+ # http://www.apache.org/licenses/LICENSE-2.0
10+ #
11+ # Unless required by applicable law or agreed to in writing, software
12+ # distributed under the License is distributed on an "AS IS" BASIS,
13+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+ # See the License for the specific language governing permissions and
15+ # limitations under the License.
16+
17+ # [START pubsub_quickstart]
18+ # Imports the Google Cloud client library
19+ from google .cloud import pubsub
20+
21+ # Instantiates a client
22+ pubsub_client = pubsub .Client ()
23+
24+ # The name for the new topic
25+ topic_name = 'my-new-topic'
26+
27+ # Prepares the new topic
28+ topic = pubsub_client .topic (topic_name )
29+
30+ # Creates the new topic
31+ topic .create ()
32+
33+ print ('Topic {} created' .format (topic .name ))
34+ # [END pubsub_quickstart]
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python
2+
3+ # Copyright 2016 Google Inc. All Rights Reserved.
4+ #
5+ # Licensed under the Apache License, Version 2.0 (the "License");
6+ # you may not use this file except in compliance with the License.
7+ # You may obtain a copy of the License at
8+ #
9+ # http://www.apache.org/licenses/LICENSE-2.0
10+ #
11+ # Unless required by applicable law or agreed to in writing, software
12+ # distributed under the License is distributed on an "AS IS" BASIS,
13+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+ # See the License for the specific language governing permissions and
15+ # limitations under the License.
16+
17+ # [START storage_quickstart]
18+ # Imports the Google Cloud client library
19+ from google .cloud import storage
20+
21+ # Instantiates a client
22+ storage_client = storage .Client ()
23+
24+ # The name for the new bucket
25+ bucket_name = 'my-new-bucket'
26+
27+ # Creates the new bucket
28+ bucket = storage_client .create_bucket (bucket_name )
29+
30+ print ('Bucket {} created' .format (bucket .name ))
31+ # [END storage_quickstart]
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python
2+
3+ # Copyright 2016 Google Inc. All Rights Reserved.
4+ #
5+ # Licensed under the Apache License, Version 2.0 (the "License");
6+ # you may not use this file except in compliance with the License.
7+ # You may obtain a copy of the License at
8+ #
9+ # http://www.apache.org/licenses/LICENSE-2.0
10+ #
11+ # Unless required by applicable law or agreed to in writing, software
12+ # distributed under the License is distributed on an "AS IS" BASIS,
13+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+ # See the License for the specific language governing permissions and
15+ # limitations under the License.
16+
17+ # [START translate_quickstart]
18+ # Imports the Google Cloud client library
19+ from google .cloud import translate
20+
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'
31+
32+ # Translates some text into Russian
33+ translation = translate_client .translate (text , target_language = target )
34+
35+ print ('Text: {}' .format (text ))
36+ print ('Translation: {}' .format (translation ['translatedText' ].encode ('utf-8' )))
37+ # [END translate_quickstart]
Original file line number Diff line number Diff line change 1+ google-cloud-translate == 0.20.0
You can’t perform that action at this time.
0 commit comments