google-api-client 0.52.0 → 0.53.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +0 -14
- data/CHANGELOG.md +6 -0
- data/OVERVIEW.md +36 -27
- data/generated/google/apis/accesscontextmanager_v1.rb +1 -1
- data/generated/google/apis/accesscontextmanager_v1/classes.rb +326 -0
- data/generated/google/apis/accesscontextmanager_v1/representations.rb +139 -0
- data/generated/google/apis/admin_directory_v1.rb +1 -1
- data/generated/google/apis/admin_directory_v1/service.rb +2 -2
- data/generated/google/apis/analyticsadmin_v1alpha.rb +2 -2
- data/generated/google/apis/analyticsadmin_v1alpha/classes.rb +8 -0
- data/generated/google/apis/analyticsadmin_v1alpha/representations.rb +1 -0
- data/generated/google/apis/analyticsadmin_v1alpha/service.rb +12 -1
- data/{lib/google/apis/core/logging.rb → generated/google/apis/apigateway_v1.rb} +14 -10
- data/generated/google/apis/apigateway_v1/classes.rb +1116 -0
- data/generated/google/apis/apigateway_v1/representations.rb +442 -0
- data/generated/google/apis/apigateway_v1/service.rb +1172 -0
- data/generated/google/apis/apigateway_v1beta.rb +1 -1
- data/generated/google/apis/apigateway_v1beta/classes.rb +19 -8
- data/generated/google/apis/apigateway_v1beta/representations.rb +1 -0
- data/generated/google/apis/apigee_v1.rb +1 -1
- data/generated/google/apis/apigee_v1/classes.rb +24 -22
- data/generated/google/apis/apigee_v1/service.rb +50 -48
- data/generated/google/apis/artifactregistry_v1.rb +38 -0
- data/generated/google/apis/artifactregistry_v1/classes.rb +242 -0
- data/generated/google/apis/artifactregistry_v1/representations.rb +116 -0
- data/generated/google/apis/artifactregistry_v1/service.rb +210 -0
- data/generated/google/apis/artifactregistry_v1beta1.rb +1 -1
- data/generated/google/apis/artifactregistry_v1beta1/classes.rb +0 -120
- data/generated/google/apis/artifactregistry_v1beta1/representations.rb +0 -62
- data/generated/google/apis/artifactregistry_v1beta2.rb +1 -1
- data/generated/google/apis/artifactregistry_v1beta2/classes.rb +0 -120
- data/generated/google/apis/artifactregistry_v1beta2/representations.rb +0 -62
- data/generated/google/apis/chat_v1.rb +1 -1
- data/generated/google/apis/chat_v1/service.rb +132 -0
- data/generated/google/apis/cloudasset_v1.rb +1 -1
- data/generated/google/apis/cloudasset_v1/classes.rb +326 -0
- data/generated/google/apis/cloudasset_v1/representations.rb +139 -0
- data/generated/google/apis/cloudasset_v1beta1.rb +1 -1
- data/generated/google/apis/cloudasset_v1beta1/classes.rb +326 -0
- data/generated/google/apis/cloudasset_v1beta1/representations.rb +139 -0
- data/generated/google/apis/cloudasset_v1p5beta1.rb +1 -1
- data/generated/google/apis/cloudasset_v1p5beta1/classes.rb +326 -0
- data/generated/google/apis/cloudasset_v1p5beta1/representations.rb +139 -0
- data/generated/google/apis/cloudbuild_v1.rb +1 -1
- data/generated/google/apis/cloudbuild_v1/classes.rb +3 -3
- data/generated/google/apis/cloudbuild_v1alpha1.rb +1 -1
- data/generated/google/apis/cloudbuild_v1alpha1/classes.rb +3 -3
- data/generated/google/apis/cloudbuild_v1alpha2.rb +1 -1
- data/generated/google/apis/cloudbuild_v1alpha2/classes.rb +3 -3
- data/generated/google/apis/cloudidentity_v1beta1.rb +1 -1
- data/generated/google/apis/cloudidentity_v1beta1/classes.rb +1 -1
- data/generated/google/apis/cloudresourcemanager_v1.rb +1 -1
- data/generated/google/apis/cloudresourcemanager_v1/classes.rb +0 -26
- data/generated/google/apis/cloudresourcemanager_v1/representations.rb +0 -24
- data/generated/google/apis/cloudresourcemanager_v1beta1.rb +1 -1
- data/generated/google/apis/cloudresourcemanager_v1beta1/classes.rb +0 -26
- data/generated/google/apis/cloudresourcemanager_v1beta1/representations.rb +0 -24
- data/generated/google/apis/cloudresourcemanager_v2.rb +1 -1
- data/generated/google/apis/cloudresourcemanager_v2/classes.rb +0 -26
- data/generated/google/apis/cloudresourcemanager_v2/representations.rb +0 -24
- data/generated/google/apis/cloudresourcemanager_v2beta1.rb +1 -1
- data/generated/google/apis/cloudresourcemanager_v2beta1/classes.rb +0 -26
- data/generated/google/apis/cloudresourcemanager_v2beta1/representations.rb +0 -24
- data/generated/google/apis/container_v1.rb +1 -1
- data/generated/google/apis/container_v1/classes.rb +7 -7
- data/generated/google/apis/container_v1beta1.rb +1 -1
- data/generated/google/apis/container_v1beta1/classes.rb +7 -7
- data/generated/google/apis/content_v2_1.rb +1 -1
- data/generated/google/apis/content_v2_1/classes.rb +434 -0
- data/generated/google/apis/content_v2_1/representations.rb +187 -0
- data/generated/google/apis/content_v2_1/service.rb +116 -0
- data/generated/google/apis/datacatalog_v1beta1.rb +1 -1
- data/generated/google/apis/datacatalog_v1beta1/classes.rb +6 -0
- data/generated/google/apis/datacatalog_v1beta1/representations.rb +1 -0
- data/generated/google/apis/dataflow_v1b3.rb +1 -1
- data/generated/google/apis/datalabeling_v1beta1.rb +1 -1
- data/generated/google/apis/dataproc_v1.rb +1 -1
- data/generated/google/apis/dataproc_v1/classes.rb +29 -1
- data/generated/google/apis/dataproc_v1/representations.rb +14 -0
- data/generated/google/apis/dataproc_v1/service.rb +42 -0
- data/generated/google/apis/dataproc_v1beta2.rb +1 -1
- data/generated/google/apis/dataproc_v1beta2/classes.rb +29 -1
- data/generated/google/apis/dataproc_v1beta2/representations.rb +14 -0
- data/generated/google/apis/dataproc_v1beta2/service.rb +42 -0
- data/generated/google/apis/dialogflow_v2.rb +1 -1
- data/generated/google/apis/dialogflow_v2/classes.rb +4041 -678
- data/generated/google/apis/dialogflow_v2/representations.rb +1851 -298
- data/generated/google/apis/dialogflow_v2beta1.rb +1 -1
- data/generated/google/apis/dialogflow_v2beta1/classes.rb +4047 -684
- data/generated/google/apis/dialogflow_v2beta1/representations.rb +1862 -309
- data/generated/google/apis/dialogflow_v3.rb +1 -1
- data/generated/google/apis/dialogflow_v3/classes.rb +3120 -311
- data/generated/google/apis/dialogflow_v3/representations.rb +2002 -617
- data/generated/google/apis/dialogflow_v3/service.rb +408 -0
- data/generated/google/apis/dialogflow_v3beta1.rb +1 -1
- data/generated/google/apis/dialogflow_v3beta1/classes.rb +5145 -2336
- data/generated/google/apis/dialogflow_v3beta1/representations.rb +1729 -344
- data/generated/google/apis/dialogflow_v3beta1/service.rb +408 -0
- data/generated/google/apis/dlp_v2.rb +1 -1
- data/generated/google/apis/dlp_v2/service.rb +3 -9
- data/generated/google/apis/documentai_v1beta2.rb +1 -1
- data/generated/google/apis/documentai_v1beta2/classes.rb +5 -92
- data/generated/google/apis/documentai_v1beta2/representations.rb +2 -15
- data/generated/google/apis/documentai_v1beta3.rb +1 -1
- data/generated/google/apis/documentai_v1beta3/classes.rb +5 -92
- data/generated/google/apis/documentai_v1beta3/representations.rb +2 -15
- data/generated/google/apis/gameservices_v1.rb +1 -1
- data/generated/google/apis/gameservices_v1/service.rb +14 -14
- data/generated/google/apis/gameservices_v1beta.rb +1 -1
- data/generated/google/apis/gameservices_v1beta/service.rb +14 -14
- data/generated/google/apis/localservices_v1.rb +4 -1
- data/generated/google/apis/manufacturers_v1.rb +1 -1
- data/generated/google/apis/manufacturers_v1/classes.rb +2 -2
- data/generated/google/apis/monitoring_v3.rb +1 -1
- data/generated/google/apis/monitoring_v3/classes.rb +2 -2
- data/generated/google/apis/notebooks_v1.rb +1 -1
- data/generated/google/apis/notebooks_v1/classes.rb +13 -0
- data/generated/google/apis/notebooks_v1/representations.rb +12 -0
- data/generated/google/apis/notebooks_v1/service.rb +34 -0
- data/generated/google/apis/prod_tt_sasportal_v1alpha1.rb +1 -1
- data/generated/google/apis/prod_tt_sasportal_v1alpha1/classes.rb +0 -37
- data/generated/google/apis/prod_tt_sasportal_v1alpha1/representations.rb +0 -18
- data/generated/google/apis/recommendationengine_v1beta1.rb +1 -1
- data/generated/google/apis/recommendationengine_v1beta1/service.rb +2 -1
- data/generated/google/apis/securitycenter_v1.rb +1 -1
- data/generated/google/apis/securitycenter_v1/classes.rb +18 -10
- data/generated/google/apis/securitycenter_v1/representations.rb +1 -0
- data/generated/google/apis/securitycenter_v1/service.rb +30 -30
- data/generated/google/apis/securitycenter_v1beta1.rb +1 -1
- data/generated/google/apis/securitycenter_v1beta1/classes.rb +7 -0
- data/generated/google/apis/securitycenter_v1beta1/representations.rb +1 -0
- data/generated/google/apis/securitycenter_v1beta2.rb +1 -1
- data/generated/google/apis/securitycenter_v1beta2/classes.rb +7 -0
- data/generated/google/apis/securitycenter_v1beta2/representations.rb +1 -0
- data/generated/google/apis/servicemanagement_v1.rb +1 -1
- data/generated/google/apis/servicemanagement_v1/classes.rb +11 -10
- data/generated/google/apis/sqladmin_v1beta4.rb +1 -1
- data/generated/google/apis/sqladmin_v1beta4/classes.rb +7 -7
- data/generated/google/apis/sqladmin_v1beta4/service.rb +4 -1
- data/generated/google/apis/storagetransfer_v1.rb +1 -1
- data/generated/google/apis/storagetransfer_v1/classes.rb +25 -0
- data/generated/google/apis/storagetransfer_v1/representations.rb +3 -0
- data/generated/google/apis/webmasters_v3/classes.rb +8 -0
- data/generated/google/apis/webmasters_v3/representations.rb +1 -0
- data/generated/google/apis/youtube_v3.rb +1 -1
- data/generated/google/apis/youtube_v3/classes.rb +18 -143
- data/generated/google/apis/youtube_v3/representations.rb +0 -57
- data/generated/google/apis/youtube_v3/service.rb +0 -43
- data/lib/google/apis/version.rb +1 -23
- metadata +27 -263
- data/.github/CONTRIBUTING.md +0 -31
- data/.github/ISSUE_TEMPLATE/bug_report.md +0 -36
- data/.github/ISSUE_TEMPLATE/feature_request.md +0 -21
- data/.github/ISSUE_TEMPLATE/support_request.md +0 -7
- data/.github/workflows/autoapprove.yml +0 -49
- data/.github/workflows/release-please.yml +0 -57
- data/.gitignore +0 -23
- data/.kokoro/build.bat +0 -11
- data/.kokoro/build.sh +0 -4
- data/.kokoro/continuous/common.cfg +0 -25
- data/.kokoro/continuous/linux.cfg +0 -25
- data/.kokoro/continuous/osx.cfg +0 -8
- data/.kokoro/continuous/post.cfg +0 -30
- data/.kokoro/continuous/windows.cfg +0 -29
- data/.kokoro/osx.sh +0 -4
- data/.kokoro/presubmit/common.cfg +0 -24
- data/.kokoro/presubmit/linux.cfg +0 -24
- data/.kokoro/presubmit/osx.cfg +0 -8
- data/.kokoro/presubmit/windows.cfg +0 -29
- data/.kokoro/release.cfg +0 -94
- data/.kokoro/trampoline.bat +0 -10
- data/.kokoro/trampoline.sh +0 -4
- data/.repo-metadata.json +0 -5
- data/.rspec +0 -2
- data/.rubocop.yml +0 -12
- data/.rubocop_todo.yml +0 -63
- data/CODE_OF_CONDUCT.md +0 -43
- data/Gemfile +0 -55
- data/MIGRATING.md +0 -215
- data/README.md +0 -402
- data/Rakefile +0 -131
- data/api_list_config.yaml +0 -9
- data/api_names.yaml +0 -1082
- data/bin/generate-api +0 -194
- data/docs/api-keys.md +0 -20
- data/docs/auth.md +0 -53
- data/docs/client-secrets.md +0 -69
- data/docs/getting-started.md +0 -340
- data/docs/installation.md +0 -0
- data/docs/logging.md +0 -34
- data/docs/media-upload.md +0 -25
- data/docs/oauth-installed.md +0 -191
- data/docs/oauth-server.md +0 -133
- data/docs/oauth-web.md +0 -280
- data/docs/oauth.md +0 -268
- data/docs/pagination.md +0 -29
- data/docs/performance.md +0 -25
- data/google-api-client.gemspec +0 -36
- data/lib/google/api_client/auth/installed_app.rb +0 -143
- data/lib/google/api_client/auth/key_utils.rb +0 -94
- data/lib/google/api_client/auth/storage.rb +0 -104
- data/lib/google/api_client/auth/storages/file_store.rb +0 -57
- data/lib/google/api_client/auth/storages/redis_store.rb +0 -59
- data/lib/google/api_client/client_secrets.rb +0 -176
- data/lib/google/apis.rb +0 -58
- data/lib/google/apis/core/api_command.rb +0 -209
- data/lib/google/apis/core/base_service.rb +0 -447
- data/lib/google/apis/core/batch.rb +0 -236
- data/lib/google/apis/core/composite_io.rb +0 -97
- data/lib/google/apis/core/download.rb +0 -118
- data/lib/google/apis/core/hashable.rb +0 -44
- data/lib/google/apis/core/http_command.rb +0 -447
- data/lib/google/apis/core/json_representation.rb +0 -153
- data/lib/google/apis/core/multipart.rb +0 -135
- data/lib/google/apis/core/upload.rb +0 -273
- data/lib/google/apis/errors.rb +0 -89
- data/lib/google/apis/generator.rb +0 -71
- data/lib/google/apis/generator/annotator.rb +0 -339
- data/lib/google/apis/generator/helpers.rb +0 -76
- data/lib/google/apis/generator/model.rb +0 -187
- data/lib/google/apis/generator/template.rb +0 -124
- data/lib/google/apis/generator/templates/_class.tmpl +0 -43
- data/lib/google/apis/generator/templates/_method.tmpl +0 -92
- data/lib/google/apis/generator/templates/_representation.tmpl +0 -51
- data/lib/google/apis/generator/templates/_representation_stub.tmpl +0 -17
- data/lib/google/apis/generator/templates/_representation_type.tmpl +0 -10
- data/lib/google/apis/generator/templates/classes.rb.tmpl +0 -29
- data/lib/google/apis/generator/templates/module.rb.tmpl +0 -40
- data/lib/google/apis/generator/templates/representations.rb.tmpl +0 -32
- data/lib/google/apis/generator/templates/service.rb.tmpl +0 -61
- data/lib/google/apis/options.rb +0 -116
- data/rakelib/devsite/devsite_builder.rb +0 -126
- data/rakelib/devsite/link_checker.rb +0 -64
- data/rakelib/devsite/repo_metadata.rb +0 -56
- data/rakelib/metrics.rake +0 -22
- data/rakelib/rubocop.rake +0 -10
- data/rakelib/spec.rake +0 -11
- data/rakelib/yard.rake +0 -11
- data/samples/cli/.env +0 -4
- data/samples/cli/Gemfile +0 -7
- data/samples/cli/README.md +0 -51
- data/samples/cli/google-api-samples +0 -32
- data/samples/cli/lib/base_cli.rb +0 -95
- data/samples/cli/lib/samples/adsense.rb +0 -99
- data/samples/cli/lib/samples/analytics.rb +0 -80
- data/samples/cli/lib/samples/androidpublisher.rb +0 -47
- data/samples/cli/lib/samples/bigquery.rb +0 -101
- data/samples/cli/lib/samples/calendar.rb +0 -83
- data/samples/cli/lib/samples/drive.rb +0 -82
- data/samples/cli/lib/samples/gmail.rb +0 -157
- data/samples/cli/lib/samples/pubsub.rb +0 -114
- data/samples/cli/lib/samples/sheets.rb +0 -61
- data/samples/cli/lib/samples/translate.rb +0 -44
- data/samples/cli/lib/samples/vision.rb +0 -69
- data/samples/cli/lib/samples/you_tube.rb +0 -47
- data/samples/web/Gemfile +0 -9
- data/samples/web/README.md +0 -44
- data/samples/web/app.rb +0 -120
- data/samples/web/views/calendar.erb +0 -34
- data/samples/web/views/drive.erb +0 -33
- data/samples/web/views/home.erb +0 -34
- data/samples/web/views/layout.erb +0 -40
- data/synth.py +0 -40
@@ -1,114 +0,0 @@
|
|
1
|
-
# Copyright 2016 Google Inc.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
require 'google/apis/pubsub_v1'
|
16
|
-
require 'base_cli'
|
17
|
-
|
18
|
-
|
19
|
-
module Samples
|
20
|
-
# Examples for the Google Cloud Pub/Sub API.
|
21
|
-
#
|
22
|
-
# Sample usage session:
|
23
|
-
#
|
24
|
-
# $ ./google-api-samples pubsub create_topic mytopic --project=623040240964
|
25
|
-
# # ./google-api-samples pubsub subscribe mysub --topic=mytopic --project=623040240964
|
26
|
-
# $ ./google-api-samples pubsub publish 'Hello!' --topic=mytopic --project=623040240964
|
27
|
-
# $ ./google-api-samples pubsub pull mysub --project=623040240964
|
28
|
-
# Received: Hello!
|
29
|
-
# $ ./google-api-samples pubsub unsubscribe mysub --project=623040240964
|
30
|
-
# $ ./google-api-samples pubsub delete_topic mytopic --project=623040240964
|
31
|
-
#
|
32
|
-
class PubSub < BaseCli
|
33
|
-
Pubsub = Google::Apis::PubsubV1
|
34
|
-
|
35
|
-
desc 'create_topic TOPIC_NAME', 'Create a topic'
|
36
|
-
method_option :project, type: :string, required: true
|
37
|
-
def create_topic(name)
|
38
|
-
pubsub = Pubsub::PubsubService.new
|
39
|
-
pubsub.authorization = Google::Auth.get_application_default([Pubsub::AUTH_PUBSUB])
|
40
|
-
topic = "projects/#{options[:project]}/topics/#{name}"
|
41
|
-
|
42
|
-
pubsub.create_topic(topic)
|
43
|
-
end
|
44
|
-
|
45
|
-
desc 'delete_topic TOPIC_NAME', 'Delete a topic'
|
46
|
-
method_option :project, type: :string, required: true
|
47
|
-
def delete_topic(name)
|
48
|
-
pubsub = Pubsub::PubsubService.new
|
49
|
-
pubsub.authorization = Google::Auth.get_application_default([Pubsub::AUTH_PUBSUB])
|
50
|
-
|
51
|
-
topic = "projects/#{options[:project]}/topics/#{name}"
|
52
|
-
|
53
|
-
pubsub.delete_topic(topic)
|
54
|
-
end
|
55
|
-
|
56
|
-
desc 'subscribe SUBSCRIPTION_NAME', 'Subscribe to a topic'
|
57
|
-
method_option :project, type: :string, required: true
|
58
|
-
method_option :topic, type: :string, required: true
|
59
|
-
def subscribe(name)
|
60
|
-
pubsub = Pubsub::PubsubService.new
|
61
|
-
pubsub.authorization = Google::Auth.get_application_default([Pubsub::AUTH_PUBSUB])
|
62
|
-
|
63
|
-
topic = "projects/#{options[:project]}/topics/#{options[:topic]}"
|
64
|
-
subscription = "projects/#{options[:project]}/subscriptions/#{name}"
|
65
|
-
pubsub.create_subscription(subscription, Pubsub::Subscription.new(topic: topic))
|
66
|
-
end
|
67
|
-
|
68
|
-
desc 'unsubscribe subscription_name', 'Ububscribe from a topic'
|
69
|
-
method_option :project, type: :string, required: true
|
70
|
-
def unsubscribe(name)
|
71
|
-
pubsub = Pubsub::PubsubService.new
|
72
|
-
pubsub.authorization = Google::Auth.get_application_default([Pubsub::AUTH_PUBSUB])
|
73
|
-
|
74
|
-
subscription = "projects/#{options[:project]}/subscriptions/#{name}"
|
75
|
-
pubsub.delete_subscription(subscription)
|
76
|
-
end
|
77
|
-
|
78
|
-
|
79
|
-
desc 'publish MESSAGE', 'Publish a message to a topic'
|
80
|
-
method_option :project, type: :string, required: true
|
81
|
-
method_option :topic, type: :string, required: true
|
82
|
-
def publish(message)
|
83
|
-
pubsub = Pubsub::PubsubService.new
|
84
|
-
pubsub.authorization = Google::Auth.get_application_default([Pubsub::AUTH_PUBSUB])
|
85
|
-
topic = "projects/#{options[:project]}/topics/#{options[:topic]}"
|
86
|
-
|
87
|
-
request = Pubsub::PublishRequest.new(messages: [])
|
88
|
-
request.messages << Pubsub::Message.new(data: message)
|
89
|
-
|
90
|
-
pubsub.publish_topic(topic, request)
|
91
|
-
end
|
92
|
-
|
93
|
-
desc 'pull SUBSCRIPTION_NAME', 'Pull message(s) from the topic'
|
94
|
-
method_option :project, type: :string, required: true
|
95
|
-
method_option :max, type: :numeric, default: 5
|
96
|
-
def pull(name)
|
97
|
-
pubsub = Pubsub::PubsubService.new
|
98
|
-
pubsub.authorization = Google::Auth.get_application_default([Pubsub::AUTH_PUBSUB])
|
99
|
-
|
100
|
-
subscription = "projects/#{options[:project]}/subscriptions/#{name}"
|
101
|
-
|
102
|
-
# Pull messages
|
103
|
-
response = pubsub.pull_subscription(subscription, Pubsub::PullRequest.new(max_messages: options[:max]))
|
104
|
-
response.received_messages.each do |received_message|
|
105
|
-
data = received_message.message.data
|
106
|
-
puts "Received: #{data}"
|
107
|
-
end
|
108
|
-
|
109
|
-
# Acknowledge receipt
|
110
|
-
ack_ids = response.received_messages.map{ |msg| msg.ack_id }
|
111
|
-
pubsub.acknowledge_subscription(subscription, Pubsub::AcknowledgeRequest.new(ack_ids: ack_ids))
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
@@ -1,61 +0,0 @@
|
|
1
|
-
# Copyright 2016 Google Inc.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
require 'google/apis/sheets_v4'
|
16
|
-
require 'base_cli'
|
17
|
-
|
18
|
-
|
19
|
-
module Samples
|
20
|
-
# Examples for the Google Sheets API
|
21
|
-
#
|
22
|
-
# Sample usage:
|
23
|
-
#
|
24
|
-
# $ ./google-api-samples sheets get_values --spreadsheet_key='1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms' --range='Class Data!A1:F'
|
25
|
-
#
|
26
|
-
# Student Name Gender Class Level Home State Major Extracurricular Activity
|
27
|
-
# Alexandra Female 4. Senior CA English Drama Club
|
28
|
-
# Andrew Male 1. Freshman SD Math Lacrosse
|
29
|
-
# Anna Female 1. Freshman NC English Basketball
|
30
|
-
# Becky Female 2. Sophomore SD Art Baseball
|
31
|
-
# Benjamin Male 4. Senior WI English Basketball
|
32
|
-
# Carl Male 3. Junior MD Art Debate
|
33
|
-
# Carrie Female 3. Junior NE English Track & Field
|
34
|
-
# Dorothy Female 4. Senior MD Math Lacrosse
|
35
|
-
# Dylan Male 1. Freshman MA Math Baseball
|
36
|
-
# Edward Male 3. Junior FL English Drama Club
|
37
|
-
# Ellen Female 1. Freshman WI Physics Drama Club
|
38
|
-
# Fiona Female 1. Freshman MA Art Debate
|
39
|
-
# John Male 3. Junior CA Physics Basketball
|
40
|
-
# Jonathan Male 2. Sophomore SC Math Debate
|
41
|
-
class Sheets < BaseCli
|
42
|
-
Sheets = Google::Apis::SheetsV4
|
43
|
-
|
44
|
-
desc 'get_values', 'Get values from Google Spreadseets '
|
45
|
-
method_option :spreadsheet_key, type: :string, required: true
|
46
|
-
method_option :range, type: :string, required: true
|
47
|
-
def get_values
|
48
|
-
sheets = Sheets::SheetsService.new
|
49
|
-
sheets.authorization = user_credentials_for(Sheets::AUTH_SPREADSHEETS_READONLY)
|
50
|
-
result = sheets.get_spreadsheet_values(options[:spreadsheet_key], options[:range])
|
51
|
-
data = []
|
52
|
-
rows = result.values.length
|
53
|
-
rows.times.each do |row|
|
54
|
-
data.push(result.values[row])
|
55
|
-
end
|
56
|
-
print_table(data)
|
57
|
-
end
|
58
|
-
|
59
|
-
default_task :get_values
|
60
|
-
end
|
61
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
# Copyright 2016 Google Inc.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
require 'google/apis/translate_v2'
|
16
|
-
require 'base_cli'
|
17
|
-
|
18
|
-
|
19
|
-
module Samples
|
20
|
-
# Examples for the Google Translate API
|
21
|
-
#
|
22
|
-
# Sample usage:
|
23
|
-
#
|
24
|
-
# $ ./google-api-samples translate 'Hola!' --target='en'
|
25
|
-
# Hello
|
26
|
-
#
|
27
|
-
class Translate < BaseCli
|
28
|
-
Translate = Google::Apis::TranslateV2
|
29
|
-
|
30
|
-
desc 'translate PHRASE', 'Translate a phrase'
|
31
|
-
method_option :source, type: :string
|
32
|
-
method_option :target, type: :string, required: true
|
33
|
-
def translate(phrase)
|
34
|
-
translate = Translate::TranslateService.new
|
35
|
-
translate.key = api_key
|
36
|
-
|
37
|
-
result = translate.list_translations(phrase, options[:target], source: options[:source])
|
38
|
-
puts result.translations.first.translated_text
|
39
|
-
end
|
40
|
-
|
41
|
-
default_task :translate
|
42
|
-
|
43
|
-
end
|
44
|
-
end
|
@@ -1,69 +0,0 @@
|
|
1
|
-
# Copyright 2016 Google Inc.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
require 'google/apis/vision_v1'
|
16
|
-
require 'base_cli'
|
17
|
-
|
18
|
-
|
19
|
-
module Samples
|
20
|
-
# Examples for the Vision APIs
|
21
|
-
#
|
22
|
-
# Sample usage:
|
23
|
-
#
|
24
|
-
# $ ./google-api-samples vision process ~/my_image.jpg --feature='TEXT_DETECTION'
|
25
|
-
#
|
26
|
-
class Vision < BaseCli
|
27
|
-
Vision = Google::Apis::VisionV1
|
28
|
-
|
29
|
-
attr_reader :image_path
|
30
|
-
|
31
|
-
desc 'process FILE', 'Process an image'
|
32
|
-
method_option :feature, type: :string, required: true
|
33
|
-
method_option :max_results, type: :numeric
|
34
|
-
def process(image_path)
|
35
|
-
@image_path = image_path
|
36
|
-
|
37
|
-
vision = Vision::VisionService.new
|
38
|
-
vision.key = api_key
|
39
|
-
|
40
|
-
result = vision.annotate_image(requests)
|
41
|
-
print "\nImage processed! - Response:\n\n"
|
42
|
-
p result
|
43
|
-
end
|
44
|
-
|
45
|
-
private
|
46
|
-
|
47
|
-
def image
|
48
|
-
@image ||= Vision::Image.new(content: File.open(image_path).read)
|
49
|
-
end
|
50
|
-
|
51
|
-
def feature
|
52
|
-
@feature ||= Vision::Feature.new(
|
53
|
-
type: options[:feature],
|
54
|
-
max_results: options[:max_results] || 1
|
55
|
-
)
|
56
|
-
end
|
57
|
-
|
58
|
-
def requests
|
59
|
-
@requests ||= Vision::BatchAnnotateImagesRequest.new(
|
60
|
-
requests: [
|
61
|
-
Vision::AnnotateImageRequest.new(
|
62
|
-
image: image,
|
63
|
-
features: [feature]
|
64
|
-
)
|
65
|
-
]
|
66
|
-
)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
# Copyright 2016 Google Inc.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
require 'google/apis/youtube_v3'
|
16
|
-
require 'base_cli'
|
17
|
-
|
18
|
-
|
19
|
-
module Samples
|
20
|
-
# Examples for the YouTube APIs
|
21
|
-
#
|
22
|
-
# Sample usage:
|
23
|
-
#
|
24
|
-
# $ ./google-api-samples youtube upload ~/myvideo.mov --title="So funny!"
|
25
|
-
#
|
26
|
-
class YouTube < BaseCli
|
27
|
-
YT = Google::Apis::YoutubeV3
|
28
|
-
|
29
|
-
desc 'upload FILE', 'Upload a video to YouTube'
|
30
|
-
method_option :title, type: :string
|
31
|
-
def upload(file)
|
32
|
-
youtube = YT::YouTubeService.new
|
33
|
-
youtube.authorization = user_credentials_for(YT::AUTH_YOUTUBE)
|
34
|
-
|
35
|
-
metadata = {
|
36
|
-
snippet: {
|
37
|
-
title: options[:title] || file
|
38
|
-
},
|
39
|
-
status: {
|
40
|
-
privacy_status: 'unlisted'
|
41
|
-
}
|
42
|
-
}
|
43
|
-
result = youtube.insert_video('snippet,status', metadata, upload_source: file)
|
44
|
-
say "Upload complete"
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
data/samples/web/Gemfile
DELETED
data/samples/web/README.md
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
# API Samples
|
2
|
-
|
3
|
-
This directory contains a simple Sinatra web app illustrating how to use the client
|
4
|
-
in a server-side web environment.
|
5
|
-
|
6
|
-
It illustrates a few key concepts:
|
7
|
-
|
8
|
-
* Using [Google Sign-in](https://developers.google.com/identity) for authentication.
|
9
|
-
* Using the [googleauth gem](https://github.com/google/google-auth-library-ruby) to
|
10
|
-
request incremental authorization as more permissions are needed.
|
11
|
-
|
12
|
-
# Setup
|
13
|
-
|
14
|
-
* Create a project at https://console.developers.google.com
|
15
|
-
* Go to the `API Manager` and enable the `Drive` and `Calendar` APIs
|
16
|
-
* Go to `Credentials` and create a new OAuth Client ID of type 'Web application'
|
17
|
-
* Use `http://localhost:4567/oauth2callback` as the redirect URL
|
18
|
-
* Use `http://localhost:4567` as the JavaScript origin
|
19
|
-
|
20
|
-
Additional details on how to enable APIs and create credentials can be
|
21
|
-
found in the help guide in the console.
|
22
|
-
|
23
|
-
## Example Environment Settings
|
24
|
-
|
25
|
-
For convenience, application credentials can be read from the shell environment
|
26
|
-
or placed in a .env file.
|
27
|
-
|
28
|
-
After setup, your .env file might look something like:
|
29
|
-
|
30
|
-
```
|
31
|
-
GOOGLE_CLIENT_ID=479164972499-i7j6av7bp2s4on5ltb7pjXXXXXXXXXX.apps.googleusercontent.com
|
32
|
-
GOOGLE_CLIENT_SECRET=JBotCTG5biFWGzXXXXXXXXXX
|
33
|
-
```
|
34
|
-
|
35
|
-
# Running the samples
|
36
|
-
|
37
|
-
To start the server, run
|
38
|
-
|
39
|
-
```
|
40
|
-
ruby app.rb
|
41
|
-
```
|
42
|
-
|
43
|
-
Open `http://localhost:4567/` in your browser to explore the sample.
|
44
|
-
|
data/samples/web/app.rb
DELETED
@@ -1,120 +0,0 @@
|
|
1
|
-
# Copyright 2015 Google Inc.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
require 'sinatra'
|
16
|
-
require 'googleauth'
|
17
|
-
require 'googleauth/stores/redis_token_store'
|
18
|
-
require 'google/apis/drive_v3'
|
19
|
-
require 'google/apis/calendar_v3'
|
20
|
-
require 'google-id-token'
|
21
|
-
require 'dotenv'
|
22
|
-
|
23
|
-
LOGIN_URL = '/'
|
24
|
-
|
25
|
-
configure do
|
26
|
-
Dotenv.load
|
27
|
-
|
28
|
-
Google::Apis::ClientOptions.default.application_name = 'Ruby client samples'
|
29
|
-
Google::Apis::ClientOptions.default.application_version = '0.9'
|
30
|
-
Google::Apis::RequestOptions.default.retries = 3
|
31
|
-
|
32
|
-
enable :sessions
|
33
|
-
set :show_exceptions, false
|
34
|
-
set :client_id, Google::Auth::ClientId.new(ENV['GOOGLE_CLIENT_ID'],
|
35
|
-
ENV['GOOGLE_CLIENT_SECRET'])
|
36
|
-
set :token_store, Google::Auth::Stores::RedisTokenStore.new(redis: Redis.new)
|
37
|
-
end
|
38
|
-
|
39
|
-
helpers do
|
40
|
-
# Returns credentials authorized for the requested scopes. If no credentials are available,
|
41
|
-
# redirects the user to authorize access.
|
42
|
-
def credentials_for(scope)
|
43
|
-
authorizer = Google::Auth::WebUserAuthorizer.new(settings.client_id, scope, settings.token_store)
|
44
|
-
user_id = session[:user_id]
|
45
|
-
redirect LOGIN_URL if user_id.nil?
|
46
|
-
credentials = authorizer.get_credentials(user_id, request)
|
47
|
-
if credentials.nil?
|
48
|
-
redirect authorizer.get_authorization_url(login_hint: user_id, request: request)
|
49
|
-
end
|
50
|
-
credentials
|
51
|
-
end
|
52
|
-
|
53
|
-
def resize(url, width)
|
54
|
-
url.sub(/s220/, sprintf('s%d', width))
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
# Home page
|
59
|
-
get('/') do
|
60
|
-
@client_id = settings.client_id.id
|
61
|
-
erb :home
|
62
|
-
end
|
63
|
-
|
64
|
-
# Log in the user by validating the identity token generated by the Google Sign-In button.
|
65
|
-
# This checks that the token is signed by Google, current, and is intended for this application.
|
66
|
-
#
|
67
|
-
post('/signin') do
|
68
|
-
audience = settings.client_id.id
|
69
|
-
# Important: The google-id-token gem is not production ready. If using, consider fetching and
|
70
|
-
# supplying the valid keys separately rather than using the built-in certificate fetcher.
|
71
|
-
validator = GoogleIDToken::Validator.new
|
72
|
-
claim = validator.check(params['id_token'], audience, audience)
|
73
|
-
if claim
|
74
|
-
session[:user_id] = claim['sub']
|
75
|
-
session[:user_email] = claim['email']
|
76
|
-
200
|
77
|
-
else
|
78
|
-
logger.info('No valid identity token present')
|
79
|
-
401
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
# Retrieve the 10 most recently modified files in Google Drive
|
84
|
-
get('/drive') do
|
85
|
-
drive = Google::Apis::DriveV3::DriveService.new
|
86
|
-
drive.authorization = credentials_for(Google::Apis::DriveV3::AUTH_DRIVE)
|
87
|
-
@result = drive.list_files(page_size: 10,
|
88
|
-
fields: 'files(name,modified_time,web_view_link),next_page_token')
|
89
|
-
erb :drive
|
90
|
-
end
|
91
|
-
|
92
|
-
# Retrieve the next 10 upcoming events from Google Calendar
|
93
|
-
get('/calendar') do
|
94
|
-
calendar = Google::Apis::CalendarV3::CalendarService.new
|
95
|
-
calendar.authorization = credentials_for(Google::Apis::CalendarV3::AUTH_CALENDAR)
|
96
|
-
calendar_id = 'primary'
|
97
|
-
@result = calendar.list_events(calendar_id,
|
98
|
-
max_results: 10,
|
99
|
-
single_events: true,
|
100
|
-
order_by: 'startTime',
|
101
|
-
time_min: Time.now.iso8601)
|
102
|
-
erb :calendar
|
103
|
-
end
|
104
|
-
|
105
|
-
|
106
|
-
# Callback for authorization requests. This saves the autorization code and
|
107
|
-
# redirects back to the URL that originally requested authorization. The code is
|
108
|
-
# redeemed on the next request.
|
109
|
-
#
|
110
|
-
# Important: While the deferred approach is generally easier, it doesn't play well
|
111
|
-
# with developer mode and sinatra's default cookie-based session implementation. Changes to the
|
112
|
-
# session state are lost if the page doesn't render due to error, which can lead to further
|
113
|
-
# errors indicating the code has already been redeemed.
|
114
|
-
#
|
115
|
-
# Disabling show_exceptions or using a different session provider (E.g. Rack::Session::Memcache)
|
116
|
-
# avoids the issue.
|
117
|
-
get('/oauth2callback') do
|
118
|
-
target_url = Google::Auth::WebUserAuthorizer.handle_auth_callback_deferred(request)
|
119
|
-
redirect target_url
|
120
|
-
end
|