google-apis-core 0.1.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.
@@ -0,0 +1,22 @@
1
+ # Copyright 2020 Google LLC
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
+ module Google
16
+ module Apis
17
+ module Core
18
+ # Core version
19
+ VERSION = "0.1.0".freeze
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,89 @@
1
+ # Copyright 2020 Google LLC
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
+ module Google
16
+ module Apis
17
+ # Base error, capable of wrapping another
18
+ class Error < StandardError
19
+ attr_reader :status_code
20
+ attr_reader :header
21
+ attr_reader :body
22
+
23
+ def initialize(err, status_code: nil, header: nil, body: nil)
24
+ @cause = nil
25
+
26
+ if err.respond_to?(:backtrace)
27
+ super(err.message)
28
+ @cause = err
29
+ else
30
+ super(err.to_s)
31
+ end
32
+ @status_code = status_code
33
+ @header = header.dup unless header.nil?
34
+ @body = body
35
+ end
36
+
37
+ def backtrace
38
+ if @cause
39
+ @cause.backtrace
40
+ else
41
+ super
42
+ end
43
+ end
44
+
45
+ def inspect
46
+ extra = ""
47
+ extra << " status_code: #{status_code.inspect}" unless status_code.nil?
48
+ extra << " header: #{header.inspect}" unless header.nil?
49
+ extra << " body: #{body.inspect}" unless body.nil?
50
+
51
+ "#<#{self.class.name}: #{message}#{extra}>"
52
+ end
53
+ end
54
+
55
+ # An error which is raised when there is an unexpected response or other
56
+ # transport error that prevents an operation from succeeding.
57
+ class TransmissionError < Error
58
+ end
59
+
60
+ # An exception that is raised if a redirect is required
61
+ #
62
+ class RedirectError < Error
63
+ end
64
+
65
+ # A 4xx class HTTP error occurred.
66
+ class ClientError < Error
67
+ end
68
+
69
+ # A 4xx class HTTP error occurred.
70
+ class RateLimitError < Error
71
+ end
72
+
73
+ # A 403 HTTP error occurred.
74
+ class ProjectNotLinkedError < Error
75
+ end
76
+
77
+ # A 401 HTTP error occurred.
78
+ class AuthorizationError < Error
79
+ end
80
+
81
+ # A 5xx class HTTP error occurred.
82
+ class ServerError < Error
83
+ end
84
+
85
+ # Error class for problems in batch requests.
86
+ class BatchError < Error
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,116 @@
1
+ # Copyright 2020 Google LLC
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
+ module Google
16
+ module Apis
17
+ # General options for API requests
18
+ ClientOptions = Struct.new(
19
+ :application_name,
20
+ :application_version,
21
+ :proxy_url,
22
+ :open_timeout_sec,
23
+ :read_timeout_sec,
24
+ :send_timeout_sec,
25
+ :log_http_requests,
26
+ :transparent_gzip_decompression)
27
+
28
+ RequestOptions = Struct.new(
29
+ :authorization,
30
+ :retries,
31
+ :header,
32
+ :normalize_unicode,
33
+ :skip_serialization,
34
+ :skip_deserialization,
35
+ :api_format_version,
36
+ :use_opencensus,
37
+ :quota_project,
38
+ :query)
39
+
40
+ # General client options
41
+ class ClientOptions
42
+ # @!attribute [rw] application_name
43
+ # @return [String] Name of the application, for identification in the User-Agent header
44
+ # @!attribute [rw] application_version
45
+ # @return [String] Version of the application, for identification in the User-Agent header
46
+ # @!attribute [rw] proxy_url
47
+ # @return [String] URL of a proxy server
48
+ # @!attribute [rw] log_http_requests
49
+ # @return [Boolean] True if raw HTTP requests should be logged
50
+ # @!attribute [rw] open_timeout_sec
51
+ # @return [Fixnum] How long, in seconds, before failed connections time out
52
+ # @!attribute [rw] read_timeout_sec
53
+ # @return [Fixnum] How long, in seconds, before requests time out
54
+ # @!attribute [rw] transparent_gzip_decompression
55
+ # @return [Boolean] True if gzip compression needs to be enabled
56
+ # Get the default options
57
+ # @return [Google::Apis::ClientOptions]
58
+ def self.default
59
+ @options ||= ClientOptions.new
60
+ end
61
+ end
62
+
63
+ # Request options
64
+ class RequestOptions
65
+ # @!attribute [rw] authorization
66
+ # @return [Signet::OAuth2::Client, #apply(Hash)] OAuth2 credentials.
67
+ # @!attribute [rw] retries
68
+ # @return [Fixnum] Number of times to retry requests on server error.
69
+ # @!attribute [rw] header
70
+ # @return [Hash<String,String>] Additional HTTP headers to include in requests.
71
+ # @!attribute [rw] normalize_unicode
72
+ # @return [Boolean] True if unicode strings should be normalized in path parameters.
73
+ # @!attribute [rw] skip_serialization
74
+ # @return [Boolean] True if body object should be treated as raw text instead of an object.
75
+ # @!attribute [rw] skip_deserialization
76
+ # @return [Boolean] True if response should be returned in raw form instead of deserialized.
77
+ # @!attribute [rw] api_format_version
78
+ # @return [Fixnum] Version of the error format to request/expect.
79
+ # @!attribute [rw] use_opencensus
80
+ # @return [Boolean] Whether OpenCensus spans should be generated for requests. Default is true.
81
+ # @!attribute [rw] quota_project
82
+ # @return [String] Project ID to charge quota, or `nil` to default to the credentials-specified project.
83
+ # @!attribute [rw] query
84
+ # @return [Hash<String,String>] Additional HTTP URL query parameters to include in requests.
85
+
86
+ # Get the default options
87
+ # @return [Google::Apis::RequestOptions]
88
+ def self.default
89
+ @options ||= RequestOptions.new
90
+ end
91
+
92
+ def merge(options)
93
+ return self if options.nil?
94
+
95
+ new_options = dup
96
+ members.each do |opt|
97
+ opt = opt.to_sym
98
+ new_options[opt] = options[opt] unless options[opt].nil?
99
+ end
100
+ new_options
101
+ end
102
+ end
103
+
104
+ ClientOptions.default.log_http_requests = false
105
+ ClientOptions.default.application_name = 'unknown'
106
+ ClientOptions.default.application_version = '0.0.0'
107
+ ClientOptions.default.transparent_gzip_decompression = true
108
+ RequestOptions.default.retries = 0
109
+ RequestOptions.default.normalize_unicode = false
110
+ RequestOptions.default.skip_serialization = false
111
+ RequestOptions.default.skip_deserialization = false
112
+ RequestOptions.default.api_format_version = nil
113
+ RequestOptions.default.use_opencensus = true
114
+ RequestOptions.default.quota_project = nil
115
+ end
116
+ end
metadata ADDED
@@ -0,0 +1,202 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: google-apis-core
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Google LLC
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-01-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: representable
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: retriable
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '4.0'
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '2.0'
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '4.0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: addressable
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '2.5'
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 2.5.1
57
+ type: :runtime
58
+ prerelease: false
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '2.5'
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 2.5.1
67
+ - !ruby/object:Gem::Dependency
68
+ name: mini_mime
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "~>"
72
+ - !ruby/object:Gem::Version
73
+ version: '1.0'
74
+ type: :runtime
75
+ prerelease: false
76
+ version_requirements: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - "~>"
79
+ - !ruby/object:Gem::Version
80
+ version: '1.0'
81
+ - !ruby/object:Gem::Dependency
82
+ name: signet
83
+ requirement: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - "~>"
86
+ - !ruby/object:Gem::Version
87
+ version: '0.14'
88
+ type: :runtime
89
+ prerelease: false
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - "~>"
93
+ - !ruby/object:Gem::Version
94
+ version: '0.14'
95
+ - !ruby/object:Gem::Dependency
96
+ name: googleauth
97
+ requirement: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - "~>"
100
+ - !ruby/object:Gem::Version
101
+ version: '0.14'
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - "~>"
107
+ - !ruby/object:Gem::Version
108
+ version: '0.14'
109
+ - !ruby/object:Gem::Dependency
110
+ name: httpclient
111
+ requirement: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: 2.8.1
116
+ - - "<"
117
+ - !ruby/object:Gem::Version
118
+ version: '3.0'
119
+ type: :runtime
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: 2.8.1
126
+ - - "<"
127
+ - !ruby/object:Gem::Version
128
+ version: '3.0'
129
+ - !ruby/object:Gem::Dependency
130
+ name: rexml
131
+ requirement: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ type: :runtime
137
+ prerelease: false
138
+ version_requirements: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ description:
144
+ email: googleapis-packages@google.com
145
+ executables: []
146
+ extensions: []
147
+ extra_rdoc_files: []
148
+ files:
149
+ - ".yardopts"
150
+ - CHANGELOG.md
151
+ - LICENSE.md
152
+ - OVERVIEW.md
153
+ - lib/google/api_client/auth/installed_app.rb
154
+ - lib/google/api_client/auth/key_utils.rb
155
+ - lib/google/api_client/auth/storage.rb
156
+ - lib/google/api_client/auth/storages/file_store.rb
157
+ - lib/google/api_client/auth/storages/redis_store.rb
158
+ - lib/google/api_client/client_secrets.rb
159
+ - lib/google/apis.rb
160
+ - lib/google/apis/core.rb
161
+ - lib/google/apis/core/api_command.rb
162
+ - lib/google/apis/core/base_service.rb
163
+ - lib/google/apis/core/batch.rb
164
+ - lib/google/apis/core/composite_io.rb
165
+ - lib/google/apis/core/download.rb
166
+ - lib/google/apis/core/hashable.rb
167
+ - lib/google/apis/core/http_command.rb
168
+ - lib/google/apis/core/json_representation.rb
169
+ - lib/google/apis/core/logging.rb
170
+ - lib/google/apis/core/multipart.rb
171
+ - lib/google/apis/core/upload.rb
172
+ - lib/google/apis/core/version.rb
173
+ - lib/google/apis/errors.rb
174
+ - lib/google/apis/options.rb
175
+ homepage: https://github.com/google/google-api-ruby-client
176
+ licenses:
177
+ - Apache-2.0
178
+ metadata:
179
+ bug_tracker_uri: https://github.com/googleapis/google-api-ruby-client/issues
180
+ changelog_uri: https://github.com/googleapis/google-api-ruby-client/tree/master/google-apis-core/CHANGELOG.md
181
+ documentation_uri: https://googleapis.dev/ruby/google-apis-core/v0.1.0
182
+ source_code_uri: https://github.com/googleapis/google-api-ruby-client/tree/master/google-apis-core
183
+ post_install_message:
184
+ rdoc_options: []
185
+ require_paths:
186
+ - lib
187
+ required_ruby_version: !ruby/object:Gem::Requirement
188
+ requirements:
189
+ - - ">="
190
+ - !ruby/object:Gem::Version
191
+ version: '2.4'
192
+ required_rubygems_version: !ruby/object:Gem::Requirement
193
+ requirements:
194
+ - - ">="
195
+ - !ruby/object:Gem::Version
196
+ version: '0'
197
+ requirements: []
198
+ rubygems_version: 3.1.4
199
+ signing_key:
200
+ specification_version: 4
201
+ summary: Common utility and base classes for legacy Google REST clients
202
+ test_files: []