google-api-client 0.52.0 → 0.53.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
data/lib/google/apis.rb
DELETED
@@ -1,58 +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 'google/apis/version'
|
16
|
-
require 'logger'
|
17
|
-
|
18
|
-
module Google
|
19
|
-
module Apis
|
20
|
-
ROOT = File.expand_path('..', File.dirname(__dir__))
|
21
|
-
|
22
|
-
# @!attribute [rw] logger
|
23
|
-
# @return [Logger] The logger.
|
24
|
-
def self.logger
|
25
|
-
@logger ||= rails_logger || default_logger
|
26
|
-
end
|
27
|
-
|
28
|
-
class << self
|
29
|
-
attr_writer :logger
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
# Create and configure a logger
|
35
|
-
# @return [Logger]
|
36
|
-
def self.default_logger
|
37
|
-
logger = Logger.new($stdout)
|
38
|
-
logger.level = Logger::WARN
|
39
|
-
logger
|
40
|
-
end
|
41
|
-
|
42
|
-
# Check to see if client is being used in a Rails environment and get the logger if present.
|
43
|
-
# Setting the ENV variable 'GOOGLE_API_USE_RAILS_LOGGER' to false will force the client
|
44
|
-
# to use its own logger.
|
45
|
-
#
|
46
|
-
# @return [Logger]
|
47
|
-
def self.rails_logger
|
48
|
-
if 'true' == ENV.fetch('GOOGLE_API_USE_RAILS_LOGGER', 'true') &&
|
49
|
-
defined?(::Rails) &&
|
50
|
-
::Rails.respond_to?(:logger) &&
|
51
|
-
!::Rails.logger.nil?
|
52
|
-
::Rails.logger
|
53
|
-
else
|
54
|
-
nil
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
@@ -1,209 +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 'addressable/uri'
|
16
|
-
require 'addressable/template'
|
17
|
-
require 'google/apis/core/http_command'
|
18
|
-
require 'google/apis/errors'
|
19
|
-
require 'json'
|
20
|
-
require 'retriable'
|
21
|
-
|
22
|
-
module Google
|
23
|
-
module Apis
|
24
|
-
module Core
|
25
|
-
# Command for executing most basic API request with JSON requests/responses
|
26
|
-
class ApiCommand < HttpCommand
|
27
|
-
JSON_CONTENT_TYPE = 'application/json'
|
28
|
-
FIELDS_PARAM = 'fields'
|
29
|
-
ERROR_REASON_MAPPING = {
|
30
|
-
'rateLimitExceeded' => Google::Apis::RateLimitError,
|
31
|
-
'userRateLimitExceeded' => Google::Apis::RateLimitError,
|
32
|
-
'projectNotLinked' => Google::Apis::ProjectNotLinkedError
|
33
|
-
}
|
34
|
-
|
35
|
-
# JSON serializer for request objects
|
36
|
-
# @return [Google::Apis::Core::JsonRepresentation]
|
37
|
-
attr_accessor :request_representation
|
38
|
-
|
39
|
-
# Request body to serialize
|
40
|
-
# @return [Object]
|
41
|
-
attr_accessor :request_object
|
42
|
-
|
43
|
-
# JSON serializer for response objects
|
44
|
-
# @return [Google::Apis::Core::JsonRepresentation]
|
45
|
-
attr_accessor :response_representation
|
46
|
-
|
47
|
-
# Class to instantiate when de-serializing responses
|
48
|
-
# @return [Object]
|
49
|
-
attr_accessor :response_class
|
50
|
-
|
51
|
-
# Serialize the request body
|
52
|
-
#
|
53
|
-
# @return [void]
|
54
|
-
def prepare!
|
55
|
-
set_api_client_header
|
56
|
-
set_user_project_header
|
57
|
-
if options&.api_format_version
|
58
|
-
header['X-Goog-Api-Format-Version'] = options.api_format_version.to_s
|
59
|
-
end
|
60
|
-
query[FIELDS_PARAM] = normalize_fields_param(query[FIELDS_PARAM]) if query.key?(FIELDS_PARAM)
|
61
|
-
if request_representation && request_object
|
62
|
-
header['Content-Type'] ||= JSON_CONTENT_TYPE
|
63
|
-
if options && options.skip_serialization
|
64
|
-
self.body = request_object
|
65
|
-
else
|
66
|
-
self.body = request_representation.new(request_object).to_json(user_options: { skip_undefined: true })
|
67
|
-
end
|
68
|
-
end
|
69
|
-
super
|
70
|
-
end
|
71
|
-
|
72
|
-
# Deserialize the response body if present
|
73
|
-
#
|
74
|
-
# @param [String] content_type
|
75
|
-
# Content type of body
|
76
|
-
# @param [String, #read] body
|
77
|
-
# Response body
|
78
|
-
# @return [Object]
|
79
|
-
# Response object
|
80
|
-
# noinspection RubyUnusedLocalVariable
|
81
|
-
def decode_response_body(content_type, body)
|
82
|
-
return super unless response_representation
|
83
|
-
return super if options && options.skip_deserialization
|
84
|
-
return super if content_type.nil?
|
85
|
-
return nil unless content_type.start_with?(JSON_CONTENT_TYPE)
|
86
|
-
body = "{}" if body.empty?
|
87
|
-
instance = response_class.new
|
88
|
-
response_representation.new(instance).from_json(body, unwrap: response_class)
|
89
|
-
instance
|
90
|
-
end
|
91
|
-
|
92
|
-
# Check the response and raise error if needed
|
93
|
-
#
|
94
|
-
# @param [Fixnum] status
|
95
|
-
# HTTP status code of response
|
96
|
-
# @param [Hash] header
|
97
|
-
# HTTP response headers
|
98
|
-
# @param [String] body
|
99
|
-
# HTTP response body
|
100
|
-
# @param [String] message
|
101
|
-
# Error message text
|
102
|
-
# @return [void]
|
103
|
-
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
|
104
|
-
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
|
105
|
-
# @raise [Google::Apis::AuthorizationError] Authorization is required
|
106
|
-
def check_status(status, header = nil, body = nil, message = nil)
|
107
|
-
case status
|
108
|
-
when 400, 402...500
|
109
|
-
reason, message = parse_error(body)
|
110
|
-
if reason
|
111
|
-
message = sprintf('%s: %s', reason, message)
|
112
|
-
raise ERROR_REASON_MAPPING[reason].new(
|
113
|
-
message,
|
114
|
-
status_code: status,
|
115
|
-
header: header,
|
116
|
-
body: body
|
117
|
-
) if ERROR_REASON_MAPPING.key?(reason)
|
118
|
-
end
|
119
|
-
super(status, header, body, message)
|
120
|
-
else
|
121
|
-
super(status, header, body, message)
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
def allow_form_encoding?
|
126
|
-
request_representation.nil? && super
|
127
|
-
end
|
128
|
-
|
129
|
-
private
|
130
|
-
|
131
|
-
def set_api_client_header
|
132
|
-
old_xgac = header
|
133
|
-
.find_all { |k, v| k.downcase == 'x-goog-api-client' }
|
134
|
-
.map { |(a, b)| b }
|
135
|
-
.join(' ')
|
136
|
-
.split
|
137
|
-
.find_all { |s| s !~ %r{^gl-ruby/|^gdcl/} }
|
138
|
-
.join(' ')
|
139
|
-
xgac = "gl-ruby/#{RUBY_VERSION} gdcl/#{Google::Apis::VERSION}"
|
140
|
-
xgac = old_xgac.empty? ? xgac : "#{old_xgac} #{xgac}"
|
141
|
-
header.delete_if { |k, v| k.downcase == 'x-goog-api-client' }
|
142
|
-
header['X-Goog-Api-Client'] = xgac
|
143
|
-
end
|
144
|
-
|
145
|
-
def set_user_project_header
|
146
|
-
quota_project_id = options.quota_project
|
147
|
-
if !quota_project_id && options&.authorization.respond_to?(:quota_project_id)
|
148
|
-
quota_project_id = options.authorization.quota_project_id
|
149
|
-
end
|
150
|
-
header['X-Goog-User-Project'] = quota_project_id if quota_project_id
|
151
|
-
end
|
152
|
-
|
153
|
-
# Attempt to parse a JSON error message
|
154
|
-
# @param [String] body
|
155
|
-
# HTTP response body
|
156
|
-
# @return [Array<(String, String)>]
|
157
|
-
# Error reason and message
|
158
|
-
def parse_error(body)
|
159
|
-
obj = JSON.load(body)
|
160
|
-
error = obj['error']
|
161
|
-
if error['details']
|
162
|
-
return extract_v2_error_details(error)
|
163
|
-
elsif error['errors']
|
164
|
-
return extract_v1_error_details(error)
|
165
|
-
else
|
166
|
-
fail 'Can not parse error message. No "details" or "errors" detected'
|
167
|
-
end
|
168
|
-
rescue
|
169
|
-
return [nil, nil]
|
170
|
-
end
|
171
|
-
|
172
|
-
# Extracts details from a v1 error message
|
173
|
-
# @param [Hash] error
|
174
|
-
# Parsed JSON
|
175
|
-
# @return [Array<(String, String)>]
|
176
|
-
# Error reason and message
|
177
|
-
def extract_v1_error_details(error)
|
178
|
-
reason = error['errors'].first['reason']
|
179
|
-
message = error['message']
|
180
|
-
return [reason, message]
|
181
|
-
end
|
182
|
-
|
183
|
-
# Extracts details from a v2error message
|
184
|
-
# @param [Hash] error
|
185
|
-
# Parsed JSON
|
186
|
-
# @return [Array<(String, String)>]
|
187
|
-
# Error reason and message
|
188
|
-
def extract_v2_error_details(error)
|
189
|
-
reason = error['status']
|
190
|
-
message = error['message']
|
191
|
-
return [reason, message]
|
192
|
-
end
|
193
|
-
|
194
|
-
# Convert field names from ruby conventions to original names in JSON
|
195
|
-
#
|
196
|
-
# @param [String] fields
|
197
|
-
# Value of 'fields' param
|
198
|
-
# @return [String]
|
199
|
-
# Updated header value
|
200
|
-
def normalize_fields_param(fields)
|
201
|
-
# TODO: Generate map of parameter names during code gen. Small possibility that camelization fails
|
202
|
-
fields.gsub(/:/, '').gsub(/\w+/) do |str|
|
203
|
-
str.gsub(/(?:^|_)([a-z])/){ Regexp.last_match.begin(0) == 0 ? $1 : $1.upcase }
|
204
|
-
end
|
205
|
-
end
|
206
|
-
end
|
207
|
-
end
|
208
|
-
end
|
209
|
-
end
|
@@ -1,447 +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 'addressable/uri'
|
16
|
-
require 'addressable/template'
|
17
|
-
require 'google/apis/version'
|
18
|
-
require 'google/apis/core/api_command'
|
19
|
-
require 'google/apis/core/batch'
|
20
|
-
require 'google/apis/core/upload'
|
21
|
-
require 'google/apis/core/download'
|
22
|
-
require 'google/apis/options'
|
23
|
-
require 'googleauth'
|
24
|
-
require 'httpclient'
|
25
|
-
|
26
|
-
module Google
|
27
|
-
module Apis
|
28
|
-
module Core
|
29
|
-
# Helper class for enumerating over a result set requiring multiple fetches
|
30
|
-
class PagedResults
|
31
|
-
include Enumerable
|
32
|
-
|
33
|
-
attr_reader :last_result
|
34
|
-
|
35
|
-
# @param [BaseService] service
|
36
|
-
# Current service instance
|
37
|
-
# @param [Fixnum] max
|
38
|
-
# Maximum number of items to iterate over. Nil if no limit
|
39
|
-
# @param [Boolean] cache
|
40
|
-
# True (default) if results should be cached so multiple iterations can be used.
|
41
|
-
# @param [Symbol] items
|
42
|
-
# Name of the field in the result containing the items. Defaults to :items
|
43
|
-
def initialize(service, max: nil, items: :items, cache: true, response_page_token: :next_page_token, &block)
|
44
|
-
@service = service
|
45
|
-
@block = block
|
46
|
-
@max = max
|
47
|
-
@items_field = items
|
48
|
-
@response_page_token_field = response_page_token
|
49
|
-
if cache
|
50
|
-
@result_cache = Hash.new do |h, k|
|
51
|
-
h[k] = @block.call(k, @service)
|
52
|
-
end
|
53
|
-
@fetch_proc = Proc.new { |token| @result_cache[token] }
|
54
|
-
else
|
55
|
-
@fetch_proc = Proc.new { |token| @block.call(token, @service) }
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
# Iterates over result set, fetching additional pages as needed
|
60
|
-
def each
|
61
|
-
page_token = nil
|
62
|
-
item_count = 0
|
63
|
-
loop do
|
64
|
-
@last_result = @fetch_proc.call(page_token)
|
65
|
-
items = @last_result.send(@items_field)
|
66
|
-
if items.kind_of?(Array)
|
67
|
-
for item in items
|
68
|
-
item_count = item_count + 1
|
69
|
-
break if @max && item_count > @max
|
70
|
-
yield item
|
71
|
-
end
|
72
|
-
elsif items.kind_of?(Hash)
|
73
|
-
items.each do |key, val|
|
74
|
-
item_count = item_count + 1
|
75
|
-
break if @max && item_count > @max
|
76
|
-
yield key, val
|
77
|
-
end
|
78
|
-
elsif items
|
79
|
-
# yield singular non-nil items (for genomics API)
|
80
|
-
yield items
|
81
|
-
end
|
82
|
-
break if @max && item_count >= @max
|
83
|
-
next_page_token = @last_result.send(@response_page_token_field)
|
84
|
-
break if next_page_token.nil? || next_page_token == page_token
|
85
|
-
page_token = next_page_token
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
# Base service for all APIs. Not to be used directly.
|
91
|
-
#
|
92
|
-
class BaseService
|
93
|
-
include Logging
|
94
|
-
|
95
|
-
# Root URL (host/port) for the API
|
96
|
-
# @return [Addressable::URI]
|
97
|
-
attr_accessor :root_url
|
98
|
-
|
99
|
-
# Additional path prefix for all API methods
|
100
|
-
# @return [Addressable::URI]
|
101
|
-
attr_accessor :base_path
|
102
|
-
|
103
|
-
# Alternate path prefix for media uploads
|
104
|
-
# @return [Addressable::URI]
|
105
|
-
attr_accessor :upload_path
|
106
|
-
|
107
|
-
# Alternate path prefix for all batch methods
|
108
|
-
# @return [Addressable::URI]
|
109
|
-
attr_accessor :batch_path
|
110
|
-
|
111
|
-
# HTTP client
|
112
|
-
# @return [HTTPClient]
|
113
|
-
attr_accessor :client
|
114
|
-
|
115
|
-
# General settings
|
116
|
-
# @return [Google::Apis::ClientOptions]
|
117
|
-
attr_accessor :client_options
|
118
|
-
|
119
|
-
# Default options for all requests
|
120
|
-
# @return [Google::Apis::RequestOptions]
|
121
|
-
attr_accessor :request_options
|
122
|
-
|
123
|
-
# @param [String,Addressable::URI] root_url
|
124
|
-
# Root URL for the API
|
125
|
-
# @param [String,Addressable::URI] base_path
|
126
|
-
# Additional path prefix for all API methods
|
127
|
-
# @api private
|
128
|
-
def initialize(root_url, base_path)
|
129
|
-
self.root_url = root_url
|
130
|
-
self.base_path = base_path
|
131
|
-
self.upload_path = "upload/#{base_path}"
|
132
|
-
self.batch_path = 'batch'
|
133
|
-
self.client_options = Google::Apis::ClientOptions.default.dup
|
134
|
-
self.request_options = Google::Apis::RequestOptions.default.dup
|
135
|
-
end
|
136
|
-
|
137
|
-
# @!attribute [rw] authorization
|
138
|
-
# @return [Signet::OAuth2::Client]
|
139
|
-
# OAuth2 credentials
|
140
|
-
def authorization=(authorization)
|
141
|
-
request_options.authorization = authorization
|
142
|
-
end
|
143
|
-
|
144
|
-
def authorization
|
145
|
-
request_options.authorization
|
146
|
-
end
|
147
|
-
|
148
|
-
# TODO: with(options) method
|
149
|
-
|
150
|
-
# Perform a batch request. Calls made within the block are sent in a single network
|
151
|
-
# request to the server.
|
152
|
-
#
|
153
|
-
# @example
|
154
|
-
# service.batch do |s|
|
155
|
-
# s.get_item(id1) do |res, err|
|
156
|
-
# # process response for 1st call
|
157
|
-
# end
|
158
|
-
# # ...
|
159
|
-
# s.get_item(idN) do |res, err|
|
160
|
-
# # process response for Nth call
|
161
|
-
# end
|
162
|
-
# end
|
163
|
-
#
|
164
|
-
# @param [Hash, Google::Apis::RequestOptions] options
|
165
|
-
# Request-specific options
|
166
|
-
# @yield [self]
|
167
|
-
# @return [void]
|
168
|
-
def batch(options = nil)
|
169
|
-
batch_command = BatchCommand.new(:post, Addressable::URI.parse(root_url + batch_path))
|
170
|
-
batch_command.options = request_options.merge(options)
|
171
|
-
apply_command_defaults(batch_command)
|
172
|
-
begin
|
173
|
-
start_batch(batch_command)
|
174
|
-
yield self
|
175
|
-
ensure
|
176
|
-
end_batch
|
177
|
-
end
|
178
|
-
batch_command.execute(client)
|
179
|
-
end
|
180
|
-
|
181
|
-
# Perform a batch upload request. Calls made within the block are sent in a single network
|
182
|
-
# request to the server. Batch uploads are useful for uploading multiple small files. For larger
|
183
|
-
# files, use single requests which use a resumable upload protocol.
|
184
|
-
#
|
185
|
-
# @example
|
186
|
-
# service.batch do |s|
|
187
|
-
# s.insert_item(upload_source: 'file1.txt') do |res, err|
|
188
|
-
# # process response for 1st call
|
189
|
-
# end
|
190
|
-
# # ...
|
191
|
-
# s.insert_item(upload_source: 'fileN.txt') do |res, err|
|
192
|
-
# # process response for Nth call
|
193
|
-
# end
|
194
|
-
# end
|
195
|
-
#
|
196
|
-
# @param [Hash, Google::Apis::RequestOptions] options
|
197
|
-
# Request-specific options
|
198
|
-
# @yield [self]
|
199
|
-
# @return [void]
|
200
|
-
def batch_upload(options = nil)
|
201
|
-
batch_command = BatchUploadCommand.new(:put, Addressable::URI.parse(root_url + upload_path))
|
202
|
-
batch_command.options = request_options.merge(options)
|
203
|
-
apply_command_defaults(batch_command)
|
204
|
-
begin
|
205
|
-
start_batch(batch_command)
|
206
|
-
yield self
|
207
|
-
ensure
|
208
|
-
end_batch
|
209
|
-
end
|
210
|
-
batch_command.execute(client)
|
211
|
-
end
|
212
|
-
|
213
|
-
# Get the current HTTP client
|
214
|
-
# @return [HTTPClient]
|
215
|
-
def client
|
216
|
-
@client ||= new_client
|
217
|
-
end
|
218
|
-
|
219
|
-
|
220
|
-
# Simple escape hatch for making API requests directly to a given
|
221
|
-
# URL. This is not intended to be used as a generic HTTP client
|
222
|
-
# and should be used only in cases where no service method exists
|
223
|
-
# (e.g. fetching an export link for a Google Drive file.)
|
224
|
-
#
|
225
|
-
# @param [Symbol] method
|
226
|
-
# HTTP method as symbol (e.g. :get, :post, :put, ...)
|
227
|
-
# @param [String] url
|
228
|
-
# URL to call
|
229
|
-
# @param [Hash<String,String>] params
|
230
|
-
# Optional hash of query parameters
|
231
|
-
# @param [#read] body
|
232
|
-
# Optional body for POST/PUT
|
233
|
-
# @param [IO, String] download_dest
|
234
|
-
# IO stream or filename to receive content download
|
235
|
-
# @param [Google::Apis::RequestOptions] options
|
236
|
-
# Request-specific options
|
237
|
-
#
|
238
|
-
# @yield [result, err] Result & error if block supplied
|
239
|
-
# @yieldparam result [String] HTTP response body
|
240
|
-
# @yieldparam err [StandardError] error object if request failed
|
241
|
-
#
|
242
|
-
# @return [String] HTTP response body
|
243
|
-
def http(method, url, params: nil, body: nil, download_dest: nil, options: nil, &block)
|
244
|
-
if download_dest
|
245
|
-
command = DownloadCommand.new(method, url, body: body)
|
246
|
-
else
|
247
|
-
command = HttpCommand.new(method, url, body: body)
|
248
|
-
end
|
249
|
-
command.options = request_options.merge(options)
|
250
|
-
apply_command_defaults(command)
|
251
|
-
command.query.merge(Hash(params))
|
252
|
-
execute_or_queue_command(command, &block)
|
253
|
-
end
|
254
|
-
|
255
|
-
# Executes a given query with paging, automatically retrieving
|
256
|
-
# additional pages as necessary. Requires a block that returns the
|
257
|
-
# result set of a page. The current page token is supplied as an argument
|
258
|
-
# to the block.
|
259
|
-
#
|
260
|
-
# Note: The returned enumerable also contains a `last_result` field
|
261
|
-
# containing the full result of the last query executed.
|
262
|
-
#
|
263
|
-
# @param [Fixnum] max
|
264
|
-
# Maximum number of items to iterate over. Defaults to nil -- no upper bound.
|
265
|
-
# @param [Symbol] items
|
266
|
-
# Name of the field in the result containing the items. Defaults to :items
|
267
|
-
# @param [Boolean] cache
|
268
|
-
# True (default) if results should be cached so multiple iterations can be used.
|
269
|
-
# @return [Enumerble]
|
270
|
-
# @yield [token, service]
|
271
|
-
# Current page token & service instance
|
272
|
-
# @yieldparam [String] token
|
273
|
-
# Current page token to be used in the query
|
274
|
-
# @yieldparam [service]
|
275
|
-
# Current service instance
|
276
|
-
# @since 0.9.4
|
277
|
-
#
|
278
|
-
# @example Retrieve all files,
|
279
|
-
# file_list = service.fetch_all { |token, s| s.list_files(page_token: token) }
|
280
|
-
# file_list.each { |f| ... }
|
281
|
-
def fetch_all(max: nil, items: :items, cache: true, response_page_token: :next_page_token, &block)
|
282
|
-
fail "fetch_all may not be used inside a batch" if batch?
|
283
|
-
return PagedResults.new(self, max: max, items: items, cache: cache, response_page_token: response_page_token, &block)
|
284
|
-
end
|
285
|
-
|
286
|
-
protected
|
287
|
-
|
288
|
-
# Create a new upload command.
|
289
|
-
#
|
290
|
-
# @param [symbol] method
|
291
|
-
# HTTP method for uploading (typically :put or :post)
|
292
|
-
# @param [String] path
|
293
|
-
# Additional path to upload endpoint, appended to API base path
|
294
|
-
# @param [Hash, Google::Apis::RequestOptions] options
|
295
|
-
# Request-specific options
|
296
|
-
# @return [Google::Apis::Core::UploadCommand]
|
297
|
-
def make_upload_command(method, path, options)
|
298
|
-
template = Addressable::Template.new(root_url + upload_path + path)
|
299
|
-
if batch?
|
300
|
-
command = MultipartUploadCommand.new(method, template)
|
301
|
-
else
|
302
|
-
command = ResumableUploadCommand.new(method, template)
|
303
|
-
end
|
304
|
-
command.options = request_options.merge(options)
|
305
|
-
apply_command_defaults(command)
|
306
|
-
command
|
307
|
-
end
|
308
|
-
|
309
|
-
# Create a new download command.
|
310
|
-
#
|
311
|
-
# @param [symbol] method
|
312
|
-
# HTTP method for uploading (typically :get)
|
313
|
-
# @param [String] path
|
314
|
-
# Additional path to download endpoint, appended to API base path
|
315
|
-
# @param [Hash, Google::Apis::RequestOptions] options
|
316
|
-
# Request-specific options
|
317
|
-
# @return [Google::Apis::Core::DownloadCommand]
|
318
|
-
def make_download_command(method, path, options)
|
319
|
-
template = Addressable::Template.new(root_url + base_path + path)
|
320
|
-
command = DownloadCommand.new(method, template)
|
321
|
-
command.options = request_options.merge(options)
|
322
|
-
command.query['alt'] = 'media'
|
323
|
-
apply_command_defaults(command)
|
324
|
-
command
|
325
|
-
end
|
326
|
-
|
327
|
-
# Create a new command.
|
328
|
-
#
|
329
|
-
# @param [symbol] method
|
330
|
-
# HTTP method (:get, :post, :delete, etc...)
|
331
|
-
# @param [String] path
|
332
|
-
# Additional path, appended to API base path
|
333
|
-
# @param [Hash, Google::Apis::RequestOptions] options
|
334
|
-
# Request-specific options
|
335
|
-
# @return [Google::Apis::Core::DownloadCommand]
|
336
|
-
def make_simple_command(method, path, options)
|
337
|
-
full_path =
|
338
|
-
if path.start_with? "/"
|
339
|
-
path[1..-1]
|
340
|
-
else
|
341
|
-
base_path + path
|
342
|
-
end
|
343
|
-
template = Addressable::Template.new(root_url + full_path)
|
344
|
-
command = ApiCommand.new(method, template)
|
345
|
-
command.options = request_options.merge(options)
|
346
|
-
apply_command_defaults(command)
|
347
|
-
command
|
348
|
-
end
|
349
|
-
|
350
|
-
# Execute the request. If a batch is in progress, the request is added to the batch instead.
|
351
|
-
#
|
352
|
-
# @param [Google::Apis::Core::HttpCommand] command
|
353
|
-
# Command to execute
|
354
|
-
# @return [Object] response object if command executed and no callback supplied
|
355
|
-
# @yield [result, err] Result & error if block supplied
|
356
|
-
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
|
357
|
-
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
|
358
|
-
# @raise [Google::Apis::AuthorizationError] Authorization is required
|
359
|
-
def execute_or_queue_command(command, &callback)
|
360
|
-
batch_command = current_batch
|
361
|
-
if batch_command
|
362
|
-
fail "Can not combine services in a batch" if Thread.current[:google_api_batch_service] != self
|
363
|
-
batch_command.add(command, &callback)
|
364
|
-
nil
|
365
|
-
else
|
366
|
-
command.execute(client, &callback)
|
367
|
-
end
|
368
|
-
end
|
369
|
-
|
370
|
-
# Update commands with service-specific options. To be implemented by subclasses
|
371
|
-
# @param [Google::Apis::Core::HttpCommand] _command
|
372
|
-
def apply_command_defaults(_command)
|
373
|
-
end
|
374
|
-
|
375
|
-
private
|
376
|
-
|
377
|
-
# Get the current batch context
|
378
|
-
#
|
379
|
-
# @return [Google:Apis::Core::BatchRequest]
|
380
|
-
def current_batch
|
381
|
-
Thread.current[:google_api_batch]
|
382
|
-
end
|
383
|
-
|
384
|
-
# Check if a batch is in progress
|
385
|
-
# @return [Boolean]
|
386
|
-
def batch?
|
387
|
-
!current_batch.nil?
|
388
|
-
end
|
389
|
-
|
390
|
-
# Start a new thread-local batch context
|
391
|
-
# @param [Google::Apis::Core::BatchCommand] cmd
|
392
|
-
def start_batch(cmd)
|
393
|
-
fail "Batch already in progress" if batch?
|
394
|
-
Thread.current[:google_api_batch] = cmd
|
395
|
-
Thread.current[:google_api_batch_service] = self
|
396
|
-
end
|
397
|
-
|
398
|
-
# Clear thread-local batch context
|
399
|
-
def end_batch
|
400
|
-
Thread.current[:google_api_batch] = nil
|
401
|
-
Thread.current[:google_api_batch_service] = nil
|
402
|
-
end
|
403
|
-
|
404
|
-
# Create a new HTTP client
|
405
|
-
# @return [HTTPClient]
|
406
|
-
def new_client
|
407
|
-
client = ::HTTPClient.new
|
408
|
-
|
409
|
-
if client_options.transparent_gzip_decompression
|
410
|
-
client.transparent_gzip_decompression = client_options.transparent_gzip_decompression
|
411
|
-
end
|
412
|
-
|
413
|
-
client.proxy = client_options.proxy_url if client_options.proxy_url
|
414
|
-
|
415
|
-
if client_options.open_timeout_sec
|
416
|
-
client.connect_timeout = client_options.open_timeout_sec
|
417
|
-
end
|
418
|
-
|
419
|
-
if client_options.read_timeout_sec
|
420
|
-
client.receive_timeout = client_options.read_timeout_sec
|
421
|
-
end
|
422
|
-
|
423
|
-
if client_options.send_timeout_sec
|
424
|
-
client.send_timeout = client_options.send_timeout_sec
|
425
|
-
end
|
426
|
-
|
427
|
-
client.follow_redirect_count = 5
|
428
|
-
client.default_header = { 'User-Agent' => user_agent }
|
429
|
-
|
430
|
-
client.debug_dev = logger if client_options.log_http_requests
|
431
|
-
client
|
432
|
-
end
|
433
|
-
|
434
|
-
|
435
|
-
# Build the user agent header
|
436
|
-
# @return [String]
|
437
|
-
def user_agent
|
438
|
-
sprintf('%s/%s google-api-ruby-client/%s %s (gzip)',
|
439
|
-
client_options.application_name,
|
440
|
-
client_options.application_version,
|
441
|
-
Google::Apis::VERSION,
|
442
|
-
Google::Apis::OS_VERSION)
|
443
|
-
end
|
444
|
-
end
|
445
|
-
end
|
446
|
-
end
|
447
|
-
end
|