| 
									
										
										
										
											2020-12-28 01:31:47 +00:00
										 |  |  | # Copyright 2020 Google LLC | 
					
						
							| 
									
										
										
										
											2015-04-17 00:28:38 +00:00
										 |  |  | # | 
					
						
							|  |  |  | # Licensed under the Apache License, Version 2.0 (the "License"); | 
					
						
							|  |  |  | # you may not use this file except in compliance with the License. | 
					
						
							|  |  |  | # You may obtain a copy of the License at | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | #      http://www.apache.org/licenses/LICENSE-2.0 | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | # Unless required by applicable law or agreed to in writing, software | 
					
						
							|  |  |  | # distributed under the License is distributed on an "AS IS" BASIS, | 
					
						
							|  |  |  | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
					
						
							|  |  |  | # See the License for the specific language governing permissions and | 
					
						
							|  |  |  | # limitations under the License. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | module Google | 
					
						
							|  |  |  |   module Apis | 
					
						
							|  |  |  |     # General options for API requests | 
					
						
							| 
									
										
										
										
											2017-04-03 18:10:54 +00:00
										 |  |  |     ClientOptions = Struct.new( | 
					
						
							| 
									
										
										
										
											2015-04-17 00:28:38 +00:00
										 |  |  |       :application_name, | 
					
						
							|  |  |  |       :application_version, | 
					
						
							| 
									
										
										
										
											2015-12-18 22:37:21 +00:00
										 |  |  |       :proxy_url, | 
					
						
							| 
									
										
										
										
											2017-04-03 18:10:54 +00:00
										 |  |  |       :open_timeout_sec, | 
					
						
							|  |  |  |       :read_timeout_sec, | 
					
						
							|  |  |  |       :send_timeout_sec, | 
					
						
							| 
									
										
										
										
											2017-11-29 20:45:11 +00:00
										 |  |  |       :log_http_requests, | 
					
						
							|  |  |  |       :transparent_gzip_decompression) | 
					
						
							| 
									
										
										
										
											2015-04-17 00:28:38 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     RequestOptions = Struct.new( | 
					
						
							|  |  |  |       :authorization, | 
					
						
							|  |  |  |       :retries, | 
					
						
							|  |  |  |       :header, | 
					
						
							| 
									
										
										
										
											2017-03-31 22:26:51 +00:00
										 |  |  |       :normalize_unicode, | 
					
						
							|  |  |  |       :skip_serialization, | 
					
						
							| 
									
										
										
										
											2017-05-19 23:16:22 +00:00
										 |  |  |       :skip_deserialization, | 
					
						
							| 
									
										
										
										
											2018-10-10 20:23:11 +00:00
										 |  |  |       :api_format_version, | 
					
						
							| 
									
										
										
										
											2020-06-03 20:21:09 +00:00
										 |  |  |       :use_opencensus, | 
					
						
							| 
									
										
										
										
											2020-10-20 23:01:42 +00:00
										 |  |  |       :quota_project, | 
					
						
							|  |  |  |       :query) | 
					
						
							| 
									
										
										
										
											2015-04-17 00:28:38 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # General client options | 
					
						
							|  |  |  |     class ClientOptions | 
					
						
							|  |  |  |       # @!attribute [rw] application_name | 
					
						
							|  |  |  |       #   @return [String] Name of the application, for identification in the User-Agent header | 
					
						
							|  |  |  |       # @!attribute [rw] application_version | 
					
						
							|  |  |  |       #   @return [String] Version of the application, for identification in the User-Agent header | 
					
						
							|  |  |  |       # @!attribute [rw] proxy_url | 
					
						
							|  |  |  |       #   @return [String] URL of a proxy server | 
					
						
							| 
									
										
										
										
											2017-04-03 18:10:54 +00:00
										 |  |  |       # @!attribute [rw] log_http_requests | 
					
						
							|  |  |  |       #   @return [Boolean] True if raw HTTP requests should be logged | 
					
						
							|  |  |  |       # @!attribute [rw] open_timeout_sec | 
					
						
							|  |  |  |       #   @return [Fixnum] How long, in seconds, before failed connections time out | 
					
						
							|  |  |  |       # @!attribute [rw] read_timeout_sec | 
					
						
							|  |  |  |       #   @return [Fixnum] How long, in seconds, before requests time out | 
					
						
							| 
									
										
										
										
											2017-11-29 20:45:11 +00:00
										 |  |  |       # @!attribute [rw] transparent_gzip_decompression | 
					
						
							|  |  |  |       # @return [Boolean] True if gzip compression needs to be enabled | 
					
						
							| 
									
										
										
										
											2015-04-17 00:28:38 +00:00
										 |  |  |       # Get the default options | 
					
						
							|  |  |  |       # @return [Google::Apis::ClientOptions] | 
					
						
							|  |  |  |       def self.default | 
					
						
							|  |  |  |         @options ||= ClientOptions.new | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Request options | 
					
						
							|  |  |  |     class RequestOptions | 
					
						
							| 
									
										
										
										
											2015-08-18 11:13:21 +00:00
										 |  |  |       # @!attribute [rw] authorization | 
					
						
							| 
									
										
										
										
											2020-10-20 23:01:42 +00:00
										 |  |  |       #   @return [Signet::OAuth2::Client, #apply(Hash)] OAuth2 credentials. | 
					
						
							| 
									
										
										
										
											2015-04-17 00:28:38 +00:00
										 |  |  |       # @!attribute [rw] retries | 
					
						
							| 
									
										
										
										
											2020-10-20 23:01:42 +00:00
										 |  |  |       #   @return [Fixnum] Number of times to retry requests on server error. | 
					
						
							| 
									
										
										
										
											2015-04-17 00:28:38 +00:00
										 |  |  |       # @!attribute [rw] header | 
					
						
							| 
									
										
										
										
											2020-10-20 23:01:42 +00:00
										 |  |  |       #   @return [Hash<String,String>] Additional HTTP headers to include in requests. | 
					
						
							| 
									
										
										
										
											2017-03-30 19:33:49 +00:00
										 |  |  |       # @!attribute [rw] normalize_unicode | 
					
						
							| 
									
										
										
										
											2020-10-20 23:01:42 +00:00
										 |  |  |       #   @return [Boolean] True if unicode strings should be normalized in path parameters. | 
					
						
							| 
									
										
										
										
											2017-03-31 22:26:51 +00:00
										 |  |  |       # @!attribute [rw] skip_serialization | 
					
						
							|  |  |  |       #   @return [Boolean] True if body object should be treated as raw text instead of an object. | 
					
						
							|  |  |  |       # @!attribute [rw] skip_deserialization | 
					
						
							|  |  |  |       #   @return [Boolean] True if response should be returned in raw form instead of deserialized. | 
					
						
							| 
									
										
										
										
											2017-05-19 23:16:22 +00:00
										 |  |  |       # @!attribute [rw] api_format_version | 
					
						
							|  |  |  |       #   @return [Fixnum] Version of the error format to request/expect. | 
					
						
							| 
									
										
										
										
											2018-10-10 20:23:11 +00:00
										 |  |  |       # @!attribute [rw] use_opencensus | 
					
						
							|  |  |  |       #   @return [Boolean] Whether OpenCensus spans should be generated for requests. Default is true. | 
					
						
							| 
									
										
										
										
											2020-06-03 20:21:09 +00:00
										 |  |  |       # @!attribute [rw] quota_project | 
					
						
							|  |  |  |       #   @return [String] Project ID to charge quota, or `nil` to default to the credentials-specified project. | 
					
						
							| 
									
										
										
										
											2020-10-20 23:01:42 +00:00
										 |  |  |       # @!attribute [rw] query | 
					
						
							|  |  |  |       #   @return [Hash<String,String>] Additional HTTP URL query parameters to include in requests. | 
					
						
							| 
									
										
										
										
											2015-04-17 00:28:38 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |       # Get the default options | 
					
						
							|  |  |  |       # @return [Google::Apis::RequestOptions] | 
					
						
							|  |  |  |       def self.default | 
					
						
							|  |  |  |         @options ||= RequestOptions.new | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       def merge(options) | 
					
						
							|  |  |  |         return self if options.nil? | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         new_options = dup | 
					
						
							| 
									
										
										
										
											2015-08-18 11:13:21 +00:00
										 |  |  |         members.each do |opt| | 
					
						
							| 
									
										
										
										
											2015-04-17 00:28:38 +00:00
										 |  |  |           opt = opt.to_sym | 
					
						
							|  |  |  |           new_options[opt] = options[opt] unless options[opt].nil? | 
					
						
							|  |  |  |         end | 
					
						
							|  |  |  |         new_options | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							| 
									
										
										
										
											2017-05-19 23:16:22 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-03 18:10:54 +00:00
										 |  |  |     ClientOptions.default.log_http_requests = false | 
					
						
							| 
									
										
										
										
											2015-04-17 00:28:38 +00:00
										 |  |  |     ClientOptions.default.application_name = 'unknown' | 
					
						
							|  |  |  |     ClientOptions.default.application_version = '0.0.0' | 
					
						
							| 
									
										
										
										
											2017-11-29 20:45:11 +00:00
										 |  |  |     ClientOptions.default.transparent_gzip_decompression = true | 
					
						
							| 
									
										
										
										
											2015-04-17 00:28:38 +00:00
										 |  |  |     RequestOptions.default.retries = 0
 | 
					
						
							| 
									
										
										
										
											2017-03-30 19:33:49 +00:00
										 |  |  |     RequestOptions.default.normalize_unicode = false | 
					
						
							| 
									
										
										
										
											2017-03-31 22:26:51 +00:00
										 |  |  |     RequestOptions.default.skip_serialization = false | 
					
						
							|  |  |  |     RequestOptions.default.skip_deserialization = false | 
					
						
							| 
									
										
										
										
											2017-05-19 23:16:22 +00:00
										 |  |  |     RequestOptions.default.api_format_version = nil | 
					
						
							| 
									
										
										
										
											2018-10-10 20:23:11 +00:00
										 |  |  |     RequestOptions.default.use_opencensus = true | 
					
						
							| 
									
										
										
										
											2020-06-03 20:21:09 +00:00
										 |  |  |     RequestOptions.default.quota_project = nil | 
					
						
							| 
									
										
										
										
											2015-04-17 00:28:38 +00:00
										 |  |  |   end | 
					
						
							|  |  |  | end |