Skip to content

Commit

Permalink
Add some simple "quickstart" samples.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmdobry committed Sep 28, 2016
1 parent 0f85ad0 commit f257ce8
Show file tree
Hide file tree
Showing 7 changed files with 168 additions and 0 deletions.
29 changes: 29 additions & 0 deletions bigquery/cloud-client/quickstart.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env python

# Copyright 2016 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# [START bigquery_quickstart]
# Imports the Google Cloud client library
from gcloud import bigquery

# Instantiates the client library
bigquery_client = bigquery.Client(project='YOUR_PROJECT_ID')

# Prepares a new dataset
dataset = bigquery_client.dataset('my_new_dataset')

# Creates the dataset
dataset.create()
# [END bigquery_quickstart]
28 changes: 28 additions & 0 deletions datastore/api/quickstart.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env python

# Copyright 2016 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# [START datastore_quickstart]
# Imports the Google Cloud client library
from gcloud import datastore

# Instantiates the client library
datastore_client = datastore.Client(project='YOUR_PROJECT_ID')

task_key = datastore_client.key('Task', 1234)

# Retrieves an entity
entity = datastore_client.get(task_key)
# [END datastore_quickstart]
29 changes: 29 additions & 0 deletions logging/cloud-client/quickstart.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env python

# Copyright 2016 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# [START logging_quickstart]
# Imports the Google Cloud client library
from gcloud import logging

# Instantiates the client library
logging_client = logging.Client(project='YOUR_PROJECT_ID')

# Selects the log to write to
logger = logging_client.logger('my-log')

# Writes a log entry
logger.log_text('Hello, world!')
# [END logging_quickstart]
29 changes: 29 additions & 0 deletions pubsub/cloud-client/quickstart.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env python

# Copyright 2016 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# [START pubsub_quickstart]
# Imports the Google Cloud client library
from gcloud import pubsub

# Instantiates the client library
pubsub_client = pubsub.Client(project='YOUR_PROJECT_ID')

# Prepares a new topic
topic = pubsub_client.topic('my-new-topic')

# Creates the topic
topic.create()
# [END pubsub_quickstart]
26 changes: 26 additions & 0 deletions storage/cloud-client/quickstart.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env python

# Copyright 2016 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# [START storage_quickstart]
# Imports the Google Cloud client library
from gcloud import storage

# Instantiates the client library
storage_client = storage.Client(project='YOUR_PROJECT_ID')

# Creates a new bucket
bucket = storage_client.create_bucket('my-new-bucket')
# [END storage_quickstart]
26 changes: 26 additions & 0 deletions translate/cloud-client/quickstart.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env python

# Copyright 2016 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# [START translate_quickstart]
# Imports the Google Cloud client library
from gcloud import translate

# Instantiates the client library
translate_client = translate.Client('YOUR_API_KEY')

# Translates some text into Russian
translation = translate_client.translate('Hello, world!', target_language='ru')
# [END translate_quickstart]
1 change: 1 addition & 0 deletions translate/cloud-client/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
gcloud==0.18.1

0 comments on commit f257ce8

Please sign in to comment.