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.
Files changed (264) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +0 -14
  3. data/CHANGELOG.md +6 -0
  4. data/OVERVIEW.md +36 -27
  5. data/generated/google/apis/accesscontextmanager_v1.rb +1 -1
  6. data/generated/google/apis/accesscontextmanager_v1/classes.rb +326 -0
  7. data/generated/google/apis/accesscontextmanager_v1/representations.rb +139 -0
  8. data/generated/google/apis/admin_directory_v1.rb +1 -1
  9. data/generated/google/apis/admin_directory_v1/service.rb +2 -2
  10. data/generated/google/apis/analyticsadmin_v1alpha.rb +2 -2
  11. data/generated/google/apis/analyticsadmin_v1alpha/classes.rb +8 -0
  12. data/generated/google/apis/analyticsadmin_v1alpha/representations.rb +1 -0
  13. data/generated/google/apis/analyticsadmin_v1alpha/service.rb +12 -1
  14. data/{lib/google/apis/core/logging.rb → generated/google/apis/apigateway_v1.rb} +14 -10
  15. data/generated/google/apis/apigateway_v1/classes.rb +1116 -0
  16. data/generated/google/apis/apigateway_v1/representations.rb +442 -0
  17. data/generated/google/apis/apigateway_v1/service.rb +1172 -0
  18. data/generated/google/apis/apigateway_v1beta.rb +1 -1
  19. data/generated/google/apis/apigateway_v1beta/classes.rb +19 -8
  20. data/generated/google/apis/apigateway_v1beta/representations.rb +1 -0
  21. data/generated/google/apis/apigee_v1.rb +1 -1
  22. data/generated/google/apis/apigee_v1/classes.rb +24 -22
  23. data/generated/google/apis/apigee_v1/service.rb +50 -48
  24. data/generated/google/apis/artifactregistry_v1.rb +38 -0
  25. data/generated/google/apis/artifactregistry_v1/classes.rb +242 -0
  26. data/generated/google/apis/artifactregistry_v1/representations.rb +116 -0
  27. data/generated/google/apis/artifactregistry_v1/service.rb +210 -0
  28. data/generated/google/apis/artifactregistry_v1beta1.rb +1 -1
  29. data/generated/google/apis/artifactregistry_v1beta1/classes.rb +0 -120
  30. data/generated/google/apis/artifactregistry_v1beta1/representations.rb +0 -62
  31. data/generated/google/apis/artifactregistry_v1beta2.rb +1 -1
  32. data/generated/google/apis/artifactregistry_v1beta2/classes.rb +0 -120
  33. data/generated/google/apis/artifactregistry_v1beta2/representations.rb +0 -62
  34. data/generated/google/apis/chat_v1.rb +1 -1
  35. data/generated/google/apis/chat_v1/service.rb +132 -0
  36. data/generated/google/apis/cloudasset_v1.rb +1 -1
  37. data/generated/google/apis/cloudasset_v1/classes.rb +326 -0
  38. data/generated/google/apis/cloudasset_v1/representations.rb +139 -0
  39. data/generated/google/apis/cloudasset_v1beta1.rb +1 -1
  40. data/generated/google/apis/cloudasset_v1beta1/classes.rb +326 -0
  41. data/generated/google/apis/cloudasset_v1beta1/representations.rb +139 -0
  42. data/generated/google/apis/cloudasset_v1p5beta1.rb +1 -1
  43. data/generated/google/apis/cloudasset_v1p5beta1/classes.rb +326 -0
  44. data/generated/google/apis/cloudasset_v1p5beta1/representations.rb +139 -0
  45. data/generated/google/apis/cloudbuild_v1.rb +1 -1
  46. data/generated/google/apis/cloudbuild_v1/classes.rb +3 -3
  47. data/generated/google/apis/cloudbuild_v1alpha1.rb +1 -1
  48. data/generated/google/apis/cloudbuild_v1alpha1/classes.rb +3 -3
  49. data/generated/google/apis/cloudbuild_v1alpha2.rb +1 -1
  50. data/generated/google/apis/cloudbuild_v1alpha2/classes.rb +3 -3
  51. data/generated/google/apis/cloudidentity_v1beta1.rb +1 -1
  52. data/generated/google/apis/cloudidentity_v1beta1/classes.rb +1 -1
  53. data/generated/google/apis/cloudresourcemanager_v1.rb +1 -1
  54. data/generated/google/apis/cloudresourcemanager_v1/classes.rb +0 -26
  55. data/generated/google/apis/cloudresourcemanager_v1/representations.rb +0 -24
  56. data/generated/google/apis/cloudresourcemanager_v1beta1.rb +1 -1
  57. data/generated/google/apis/cloudresourcemanager_v1beta1/classes.rb +0 -26
  58. data/generated/google/apis/cloudresourcemanager_v1beta1/representations.rb +0 -24
  59. data/generated/google/apis/cloudresourcemanager_v2.rb +1 -1
  60. data/generated/google/apis/cloudresourcemanager_v2/classes.rb +0 -26
  61. data/generated/google/apis/cloudresourcemanager_v2/representations.rb +0 -24
  62. data/generated/google/apis/cloudresourcemanager_v2beta1.rb +1 -1
  63. data/generated/google/apis/cloudresourcemanager_v2beta1/classes.rb +0 -26
  64. data/generated/google/apis/cloudresourcemanager_v2beta1/representations.rb +0 -24
  65. data/generated/google/apis/container_v1.rb +1 -1
  66. data/generated/google/apis/container_v1/classes.rb +7 -7
  67. data/generated/google/apis/container_v1beta1.rb +1 -1
  68. data/generated/google/apis/container_v1beta1/classes.rb +7 -7
  69. data/generated/google/apis/content_v2_1.rb +1 -1
  70. data/generated/google/apis/content_v2_1/classes.rb +434 -0
  71. data/generated/google/apis/content_v2_1/representations.rb +187 -0
  72. data/generated/google/apis/content_v2_1/service.rb +116 -0
  73. data/generated/google/apis/datacatalog_v1beta1.rb +1 -1
  74. data/generated/google/apis/datacatalog_v1beta1/classes.rb +6 -0
  75. data/generated/google/apis/datacatalog_v1beta1/representations.rb +1 -0
  76. data/generated/google/apis/dataflow_v1b3.rb +1 -1
  77. data/generated/google/apis/datalabeling_v1beta1.rb +1 -1
  78. data/generated/google/apis/dataproc_v1.rb +1 -1
  79. data/generated/google/apis/dataproc_v1/classes.rb +29 -1
  80. data/generated/google/apis/dataproc_v1/representations.rb +14 -0
  81. data/generated/google/apis/dataproc_v1/service.rb +42 -0
  82. data/generated/google/apis/dataproc_v1beta2.rb +1 -1
  83. data/generated/google/apis/dataproc_v1beta2/classes.rb +29 -1
  84. data/generated/google/apis/dataproc_v1beta2/representations.rb +14 -0
  85. data/generated/google/apis/dataproc_v1beta2/service.rb +42 -0
  86. data/generated/google/apis/dialogflow_v2.rb +1 -1
  87. data/generated/google/apis/dialogflow_v2/classes.rb +4041 -678
  88. data/generated/google/apis/dialogflow_v2/representations.rb +1851 -298
  89. data/generated/google/apis/dialogflow_v2beta1.rb +1 -1
  90. data/generated/google/apis/dialogflow_v2beta1/classes.rb +4047 -684
  91. data/generated/google/apis/dialogflow_v2beta1/representations.rb +1862 -309
  92. data/generated/google/apis/dialogflow_v3.rb +1 -1
  93. data/generated/google/apis/dialogflow_v3/classes.rb +3120 -311
  94. data/generated/google/apis/dialogflow_v3/representations.rb +2002 -617
  95. data/generated/google/apis/dialogflow_v3/service.rb +408 -0
  96. data/generated/google/apis/dialogflow_v3beta1.rb +1 -1
  97. data/generated/google/apis/dialogflow_v3beta1/classes.rb +5145 -2336
  98. data/generated/google/apis/dialogflow_v3beta1/representations.rb +1729 -344
  99. data/generated/google/apis/dialogflow_v3beta1/service.rb +408 -0
  100. data/generated/google/apis/dlp_v2.rb +1 -1
  101. data/generated/google/apis/dlp_v2/service.rb +3 -9
  102. data/generated/google/apis/documentai_v1beta2.rb +1 -1
  103. data/generated/google/apis/documentai_v1beta2/classes.rb +5 -92
  104. data/generated/google/apis/documentai_v1beta2/representations.rb +2 -15
  105. data/generated/google/apis/documentai_v1beta3.rb +1 -1
  106. data/generated/google/apis/documentai_v1beta3/classes.rb +5 -92
  107. data/generated/google/apis/documentai_v1beta3/representations.rb +2 -15
  108. data/generated/google/apis/gameservices_v1.rb +1 -1
  109. data/generated/google/apis/gameservices_v1/service.rb +14 -14
  110. data/generated/google/apis/gameservices_v1beta.rb +1 -1
  111. data/generated/google/apis/gameservices_v1beta/service.rb +14 -14
  112. data/generated/google/apis/localservices_v1.rb +4 -1
  113. data/generated/google/apis/manufacturers_v1.rb +1 -1
  114. data/generated/google/apis/manufacturers_v1/classes.rb +2 -2
  115. data/generated/google/apis/monitoring_v3.rb +1 -1
  116. data/generated/google/apis/monitoring_v3/classes.rb +2 -2
  117. data/generated/google/apis/notebooks_v1.rb +1 -1
  118. data/generated/google/apis/notebooks_v1/classes.rb +13 -0
  119. data/generated/google/apis/notebooks_v1/representations.rb +12 -0
  120. data/generated/google/apis/notebooks_v1/service.rb +34 -0
  121. data/generated/google/apis/prod_tt_sasportal_v1alpha1.rb +1 -1
  122. data/generated/google/apis/prod_tt_sasportal_v1alpha1/classes.rb +0 -37
  123. data/generated/google/apis/prod_tt_sasportal_v1alpha1/representations.rb +0 -18
  124. data/generated/google/apis/recommendationengine_v1beta1.rb +1 -1
  125. data/generated/google/apis/recommendationengine_v1beta1/service.rb +2 -1
  126. data/generated/google/apis/securitycenter_v1.rb +1 -1
  127. data/generated/google/apis/securitycenter_v1/classes.rb +18 -10
  128. data/generated/google/apis/securitycenter_v1/representations.rb +1 -0
  129. data/generated/google/apis/securitycenter_v1/service.rb +30 -30
  130. data/generated/google/apis/securitycenter_v1beta1.rb +1 -1
  131. data/generated/google/apis/securitycenter_v1beta1/classes.rb +7 -0
  132. data/generated/google/apis/securitycenter_v1beta1/representations.rb +1 -0
  133. data/generated/google/apis/securitycenter_v1beta2.rb +1 -1
  134. data/generated/google/apis/securitycenter_v1beta2/classes.rb +7 -0
  135. data/generated/google/apis/securitycenter_v1beta2/representations.rb +1 -0
  136. data/generated/google/apis/servicemanagement_v1.rb +1 -1
  137. data/generated/google/apis/servicemanagement_v1/classes.rb +11 -10
  138. data/generated/google/apis/sqladmin_v1beta4.rb +1 -1
  139. data/generated/google/apis/sqladmin_v1beta4/classes.rb +7 -7
  140. data/generated/google/apis/sqladmin_v1beta4/service.rb +4 -1
  141. data/generated/google/apis/storagetransfer_v1.rb +1 -1
  142. data/generated/google/apis/storagetransfer_v1/classes.rb +25 -0
  143. data/generated/google/apis/storagetransfer_v1/representations.rb +3 -0
  144. data/generated/google/apis/webmasters_v3/classes.rb +8 -0
  145. data/generated/google/apis/webmasters_v3/representations.rb +1 -0
  146. data/generated/google/apis/youtube_v3.rb +1 -1
  147. data/generated/google/apis/youtube_v3/classes.rb +18 -143
  148. data/generated/google/apis/youtube_v3/representations.rb +0 -57
  149. data/generated/google/apis/youtube_v3/service.rb +0 -43
  150. data/lib/google/apis/version.rb +1 -23
  151. metadata +27 -263
  152. data/.github/CONTRIBUTING.md +0 -31
  153. data/.github/ISSUE_TEMPLATE/bug_report.md +0 -36
  154. data/.github/ISSUE_TEMPLATE/feature_request.md +0 -21
  155. data/.github/ISSUE_TEMPLATE/support_request.md +0 -7
  156. data/.github/workflows/autoapprove.yml +0 -49
  157. data/.github/workflows/release-please.yml +0 -57
  158. data/.gitignore +0 -23
  159. data/.kokoro/build.bat +0 -11
  160. data/.kokoro/build.sh +0 -4
  161. data/.kokoro/continuous/common.cfg +0 -25
  162. data/.kokoro/continuous/linux.cfg +0 -25
  163. data/.kokoro/continuous/osx.cfg +0 -8
  164. data/.kokoro/continuous/post.cfg +0 -30
  165. data/.kokoro/continuous/windows.cfg +0 -29
  166. data/.kokoro/osx.sh +0 -4
  167. data/.kokoro/presubmit/common.cfg +0 -24
  168. data/.kokoro/presubmit/linux.cfg +0 -24
  169. data/.kokoro/presubmit/osx.cfg +0 -8
  170. data/.kokoro/presubmit/windows.cfg +0 -29
  171. data/.kokoro/release.cfg +0 -94
  172. data/.kokoro/trampoline.bat +0 -10
  173. data/.kokoro/trampoline.sh +0 -4
  174. data/.repo-metadata.json +0 -5
  175. data/.rspec +0 -2
  176. data/.rubocop.yml +0 -12
  177. data/.rubocop_todo.yml +0 -63
  178. data/CODE_OF_CONDUCT.md +0 -43
  179. data/Gemfile +0 -55
  180. data/MIGRATING.md +0 -215
  181. data/README.md +0 -402
  182. data/Rakefile +0 -131
  183. data/api_list_config.yaml +0 -9
  184. data/api_names.yaml +0 -1082
  185. data/bin/generate-api +0 -194
  186. data/docs/api-keys.md +0 -20
  187. data/docs/auth.md +0 -53
  188. data/docs/client-secrets.md +0 -69
  189. data/docs/getting-started.md +0 -340
  190. data/docs/installation.md +0 -0
  191. data/docs/logging.md +0 -34
  192. data/docs/media-upload.md +0 -25
  193. data/docs/oauth-installed.md +0 -191
  194. data/docs/oauth-server.md +0 -133
  195. data/docs/oauth-web.md +0 -280
  196. data/docs/oauth.md +0 -268
  197. data/docs/pagination.md +0 -29
  198. data/docs/performance.md +0 -25
  199. data/google-api-client.gemspec +0 -36
  200. data/lib/google/api_client/auth/installed_app.rb +0 -143
  201. data/lib/google/api_client/auth/key_utils.rb +0 -94
  202. data/lib/google/api_client/auth/storage.rb +0 -104
  203. data/lib/google/api_client/auth/storages/file_store.rb +0 -57
  204. data/lib/google/api_client/auth/storages/redis_store.rb +0 -59
  205. data/lib/google/api_client/client_secrets.rb +0 -176
  206. data/lib/google/apis.rb +0 -58
  207. data/lib/google/apis/core/api_command.rb +0 -209
  208. data/lib/google/apis/core/base_service.rb +0 -447
  209. data/lib/google/apis/core/batch.rb +0 -236
  210. data/lib/google/apis/core/composite_io.rb +0 -97
  211. data/lib/google/apis/core/download.rb +0 -118
  212. data/lib/google/apis/core/hashable.rb +0 -44
  213. data/lib/google/apis/core/http_command.rb +0 -447
  214. data/lib/google/apis/core/json_representation.rb +0 -153
  215. data/lib/google/apis/core/multipart.rb +0 -135
  216. data/lib/google/apis/core/upload.rb +0 -273
  217. data/lib/google/apis/errors.rb +0 -89
  218. data/lib/google/apis/generator.rb +0 -71
  219. data/lib/google/apis/generator/annotator.rb +0 -339
  220. data/lib/google/apis/generator/helpers.rb +0 -76
  221. data/lib/google/apis/generator/model.rb +0 -187
  222. data/lib/google/apis/generator/template.rb +0 -124
  223. data/lib/google/apis/generator/templates/_class.tmpl +0 -43
  224. data/lib/google/apis/generator/templates/_method.tmpl +0 -92
  225. data/lib/google/apis/generator/templates/_representation.tmpl +0 -51
  226. data/lib/google/apis/generator/templates/_representation_stub.tmpl +0 -17
  227. data/lib/google/apis/generator/templates/_representation_type.tmpl +0 -10
  228. data/lib/google/apis/generator/templates/classes.rb.tmpl +0 -29
  229. data/lib/google/apis/generator/templates/module.rb.tmpl +0 -40
  230. data/lib/google/apis/generator/templates/representations.rb.tmpl +0 -32
  231. data/lib/google/apis/generator/templates/service.rb.tmpl +0 -61
  232. data/lib/google/apis/options.rb +0 -116
  233. data/rakelib/devsite/devsite_builder.rb +0 -126
  234. data/rakelib/devsite/link_checker.rb +0 -64
  235. data/rakelib/devsite/repo_metadata.rb +0 -56
  236. data/rakelib/metrics.rake +0 -22
  237. data/rakelib/rubocop.rake +0 -10
  238. data/rakelib/spec.rake +0 -11
  239. data/rakelib/yard.rake +0 -11
  240. data/samples/cli/.env +0 -4
  241. data/samples/cli/Gemfile +0 -7
  242. data/samples/cli/README.md +0 -51
  243. data/samples/cli/google-api-samples +0 -32
  244. data/samples/cli/lib/base_cli.rb +0 -95
  245. data/samples/cli/lib/samples/adsense.rb +0 -99
  246. data/samples/cli/lib/samples/analytics.rb +0 -80
  247. data/samples/cli/lib/samples/androidpublisher.rb +0 -47
  248. data/samples/cli/lib/samples/bigquery.rb +0 -101
  249. data/samples/cli/lib/samples/calendar.rb +0 -83
  250. data/samples/cli/lib/samples/drive.rb +0 -82
  251. data/samples/cli/lib/samples/gmail.rb +0 -157
  252. data/samples/cli/lib/samples/pubsub.rb +0 -114
  253. data/samples/cli/lib/samples/sheets.rb +0 -61
  254. data/samples/cli/lib/samples/translate.rb +0 -44
  255. data/samples/cli/lib/samples/vision.rb +0 -69
  256. data/samples/cli/lib/samples/you_tube.rb +0 -47
  257. data/samples/web/Gemfile +0 -9
  258. data/samples/web/README.md +0 -44
  259. data/samples/web/app.rb +0 -120
  260. data/samples/web/views/calendar.erb +0 -34
  261. data/samples/web/views/drive.erb +0 -33
  262. data/samples/web/views/home.erb +0 -34
  263. data/samples/web/views/layout.erb +0 -40
  264. 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
@@ -1,9 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'google-api-client', '~> 0.9'
4
- gem 'google-id-token', '~> 1.3'
5
- gem 'redis', '~> 3.2'
6
- gem 'dotenv'
7
-
8
- gem 'sinatra'
9
- gem 'mime-types-data'
@@ -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
-
@@ -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