apcera 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +7 -0
  2. data/apcera.gemspec +31 -0
  3. data/lib/apcera/api/default_api.rb +128 -0
  4. data/lib/apcera/api/instances_api.rb +280 -0
  5. data/lib/apcera/api/jobs_api.rb +1428 -0
  6. data/lib/apcera/api/logs_api.rb +120 -0
  7. data/lib/apcera/api/metrics_api.rb +280 -0
  8. data/lib/apcera/api/packages_api.rb +541 -0
  9. data/lib/apcera/api/providers_api.rb +175 -0
  10. data/lib/apcera/api/rules_api.rb +228 -0
  11. data/lib/apcera/api/services_and_bindings_api.rb +278 -0
  12. data/lib/apcera/api/staging_pipelines_api.rb +281 -0
  13. data/lib/apcera/api/utilities_api.rb +327 -0
  14. data/lib/apcera/api_client.rb +294 -0
  15. data/lib/apcera/api_error.rb +24 -0
  16. data/lib/apcera/configuration.rb +173 -0
  17. data/lib/apcera/models/apc_version_object.rb +37 -0
  18. data/lib/apcera/models/api_error.rb +143 -0
  19. data/lib/apcera/models/audit_log_item.rb +117 -0
  20. data/lib/apcera/models/audit_log_item_old.rb +85 -0
  21. data/lib/apcera/models/base_object.rb +96 -0
  22. data/lib/apcera/models/binding.rb +137 -0
  23. data/lib/apcera/models/create_docker_job_request.rb +197 -0
  24. data/lib/apcera/models/create_docker_job_response.rb +37 -0
  25. data/lib/apcera/models/dependency.rb +53 -0
  26. data/lib/apcera/models/dependency_resolve.rb +45 -0
  27. data/lib/apcera/models/docker_origin.rb +63 -0
  28. data/lib/apcera/models/drain.rb +61 -0
  29. data/lib/apcera/models/drain_config.rb +53 -0
  30. data/lib/apcera/models/file_listing.rb +45 -0
  31. data/lib/apcera/models/info.rb +53 -0
  32. data/lib/apcera/models/instance_manager.rb +105 -0
  33. data/lib/apcera/models/instance_state.rb +117 -0
  34. data/lib/apcera/models/instances.rb +109 -0
  35. data/lib/apcera/models/job.rb +243 -0
  36. data/lib/apcera/models/job_health.rb +63 -0
  37. data/lib/apcera/models/job_preferences.rb +37 -0
  38. data/lib/apcera/models/log.rb +53 -0
  39. data/lib/apcera/models/metric_series.rb +49 -0
  40. data/lib/apcera/models/metric_series_hash.rb +29 -0
  41. data/lib/apcera/models/metrics.rb +49 -0
  42. data/lib/apcera/models/namespace.rb +37 -0
  43. data/lib/apcera/models/package.rb +183 -0
  44. data/lib/apcera/models/package_depends_request.rb +47 -0
  45. data/lib/apcera/models/package_info.rb +69 -0
  46. data/lib/apcera/models/package_resource.rb +61 -0
  47. data/lib/apcera/models/policy_error.rb +63 -0
  48. data/lib/apcera/models/port.rb +55 -0
  49. data/lib/apcera/models/process.rb +37 -0
  50. data/lib/apcera/models/process_object.rb +115 -0
  51. data/lib/apcera/models/provide.rb +53 -0
  52. data/lib/apcera/models/provider.rb +85 -0
  53. data/lib/apcera/models/resource.rb +69 -0
  54. data/lib/apcera/models/restart_config.rb +53 -0
  55. data/lib/apcera/models/rollout_config.rb +69 -0
  56. data/lib/apcera/models/route.rb +53 -0
  57. data/lib/apcera/models/rule.rb +101 -0
  58. data/lib/apcera/models/runtime.rb +47 -0
  59. data/lib/apcera/models/semi_pipe_rule.rb +101 -0
  60. data/lib/apcera/models/semi_pipe_rule_action.rb +37 -0
  61. data/lib/apcera/models/stager_job.rb +37 -0
  62. data/lib/apcera/models/staging_pipeline.rb +103 -0
  63. data/lib/apcera/models/sub_task.rb +61 -0
  64. data/lib/apcera/models/task.rb +87 -0
  65. data/lib/apcera/models/task_event.rb +113 -0
  66. data/lib/apcera/models/task_progress.rb +45 -0
  67. data/lib/apcera/models/unbind_parameter_object.rb +53 -0
  68. data/lib/apcera/models/unlink_parameter_object.rb +53 -0
  69. data/lib/apcera/version.rb +3 -0
  70. data/lib/apcera.rb +90 -0
  71. metadata +293 -0
@@ -0,0 +1,294 @@
1
+ require 'date'
2
+ require 'json'
3
+ require 'logger'
4
+ require 'tempfile'
5
+ require 'typhoeus'
6
+ require 'uri'
7
+
8
+ module Apcera
9
+ class ApiClient
10
+
11
+ attr_accessor :host
12
+
13
+ # Defines the headers to be used in HTTP requests of all API calls by default.
14
+ #
15
+ # @return [Hash]
16
+ attr_accessor :default_headers
17
+
18
+ # Stores the HTTP response from the last API call using this API client.
19
+ attr_accessor :last_response
20
+
21
+ def initialize(host = nil)
22
+ @host = host || Configuration.base_url
23
+ @format = 'json'
24
+ @user_agent = "ruby-swagger-#{VERSION}"
25
+ @default_headers = {
26
+ 'Content-Type' => "application/#{@format.downcase}",
27
+ 'User-Agent' => @user_agent
28
+ }
29
+ end
30
+
31
+ def call_api(http_method, path, opts = {})
32
+ request = build_request(http_method, path, opts)
33
+ response = request.run
34
+
35
+ # record as last response
36
+ @last_response = response
37
+
38
+ if Configuration.debugging
39
+ Configuration.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
40
+ end
41
+
42
+ unless response.success?
43
+ fail ApiError.new(:code => response.code,
44
+ :response_headers => response.headers,
45
+ :response_body => response.body),
46
+ response.status_message
47
+ end
48
+
49
+ if opts[:return_type]
50
+ deserialize(response, opts[:return_type])
51
+ else
52
+ nil
53
+ end
54
+ end
55
+
56
+ def build_request(http_method, path, opts = {})
57
+ url = build_request_url(path)
58
+ http_method = http_method.to_sym.downcase
59
+
60
+ header_params = @default_headers.merge(opts[:header_params] || {})
61
+ query_params = opts[:query_params] || {}
62
+ form_params = opts[:form_params] || {}
63
+
64
+
65
+ update_params_for_auth! header_params, query_params, opts[:auth_names]
66
+
67
+
68
+ req_opts = {
69
+ :method => http_method,
70
+ :headers => header_params,
71
+ :params => query_params,
72
+ :ssl_verifypeer => Configuration.verify_ssl,
73
+ :cainfo => Configuration.ssl_ca_cert,
74
+ :verbose => Configuration.debugging
75
+ }
76
+
77
+ if [:post, :patch, :put, :delete].include?(http_method)
78
+ req_body = build_request_body(header_params, form_params, opts[:body])
79
+ req_opts.update :body => req_body
80
+ if Configuration.debugging
81
+ # JRS: If it contains a null, it is probably binary
82
+ #
83
+ if (!req_body.nil? && req_body !~ /\x00/ )
84
+ Configuration.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
85
+ else
86
+ Configuration.logger.debug "HTTP request body param ~(Skipping likely binary body)"
87
+ end
88
+ end
89
+ end
90
+
91
+ Typhoeus::Request.new(url, req_opts)
92
+ end
93
+
94
+ # Deserialize the response to the given return type.
95
+ #
96
+ # @param [String] return_type some examples: "User", "Array[User]", "Hash[String,Integer]"
97
+ def deserialize(response, return_type)
98
+ body = response.body
99
+ return nil if body.nil? || body.empty?
100
+
101
+ # handle file downloading - save response body into a tmp file and return the File instance
102
+ return download_file(response) if return_type == 'File'
103
+
104
+ # ensuring a default content type
105
+ content_type = response.headers['Content-Type'] || 'application/json'
106
+
107
+ # JRS handle application/octet-stream by brute force
108
+ #
109
+ if content_type.start_with?('application/octet-stream')
110
+ return body
111
+ end
112
+
113
+ unless content_type.start_with?('application/json')
114
+ fail "Content-Type is not supported: #{content_type}"
115
+ end
116
+
117
+ begin
118
+ data = JSON.parse("[#{body}]", :symbolize_names => true)[0]
119
+ rescue JSON::ParserError => e
120
+ if %w(String Date DateTime).include?(return_type)
121
+ data = body
122
+ else
123
+ raise e
124
+ end
125
+ end
126
+
127
+ convert_to_type data, return_type
128
+ end
129
+
130
+ # Convert data to the given return type.
131
+ def convert_to_type(data, return_type)
132
+ return nil if data.nil?
133
+ case return_type
134
+ when 'String'
135
+ data.to_s
136
+ when 'Integer'
137
+ data.to_i
138
+ when 'Float'
139
+ data.to_f
140
+ when 'BOOLEAN'
141
+ data == true
142
+ when 'DateTime'
143
+ # parse date time (expecting ISO 8601 format)
144
+ DateTime.parse data
145
+ when 'Date'
146
+ # parse date time (expecting ISO 8601 format)
147
+ Date.parse data
148
+ when 'Object'
149
+ # generic object, return directly
150
+ data
151
+ when /\AArray<(.+)>\z/
152
+ # e.g. Array<Pet>
153
+ sub_type = $1
154
+ data.map {|item| convert_to_type(item, sub_type) }
155
+ when /\AHash\<String, (.+)\>\z/
156
+ # e.g. Hash<String, Integer>
157
+ sub_type = $1
158
+ {}.tap do |hash|
159
+ data.each {|k, v| hash[k] = convert_to_type(v, sub_type) }
160
+ end
161
+ else
162
+ # models, e.g. Pet
163
+ Apcera.const_get(return_type).new.tap do |model|
164
+ # JRS
165
+ if Configuration.debugging
166
+ Configuration.logger.info "#{model.class.name} hash: " + JSON.pretty_generate(data)
167
+ end
168
+ model.build_from_hash data
169
+ end
170
+ end
171
+ end
172
+
173
+ # Save response body into a file in (the defined) temporary folder, using the filename
174
+ # from the "Content-Disposition" header if provided, otherwise a random filename.
175
+ #
176
+ # @see Configuration#temp_folder_path
177
+ # @return [File] the file downloaded
178
+ def download_file(response)
179
+ tmp_file = Tempfile.new '', Configuration.temp_folder_path
180
+ content_disposition = response.headers['Content-Disposition']
181
+ if content_disposition
182
+ filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
183
+ path = File.join File.dirname(tmp_file), filename
184
+ else
185
+ path = tmp_file.path
186
+ end
187
+ # close and delete temp file
188
+ tmp_file.close!
189
+
190
+ File.open(path, 'w') { |file| file.write(response.body) }
191
+ Configuration.logger.info "File written to #{path}. Please move the file to a proper "\
192
+ "folder for further processing and delete the temp afterwards"
193
+ File.new(path)
194
+ end
195
+
196
+ def build_request_url(path)
197
+ # Add leading and trailing slashes to path
198
+ path = "/#{path}".gsub(/\/+/, '/')
199
+ URI.encode(host + path)
200
+ end
201
+
202
+ def build_request_body(header_params, form_params, body)
203
+ # http form
204
+ if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
205
+ header_params['Content-Type'] == 'multipart/form-data'
206
+ data = form_params.dup
207
+ data.each do |key, value|
208
+ data[key] = value.to_s if value && !value.is_a?(File)
209
+ end
210
+ elsif body
211
+ data = body.is_a?(String) ? body : body.to_json
212
+ else
213
+ data = nil
214
+ end
215
+ data
216
+ end
217
+
218
+ # Update hearder and query params based on authentication settings.
219
+ def update_params_for_auth!(header_params, query_params, auth_names)
220
+ Array(auth_names).each do |auth_name|
221
+ auth_setting = Configuration.auth_settings[auth_name]
222
+ next unless auth_setting
223
+ case auth_setting[:in]
224
+ when 'header' then header_params[auth_setting[:key]] = auth_setting[:value]
225
+ when 'query' then query_params[auth_setting[:key]] = auth_setting[:value]
226
+ else fail ArgumentError, 'Authentication token must be in `query` of `header`'
227
+ end
228
+ end
229
+ end
230
+
231
+ def user_agent=(user_agent)
232
+ @user_agent = user_agent
233
+ @default_headers['User-Agent'] = @user_agent
234
+ end
235
+
236
+ # Return Accept header based on an array of accepts provided.
237
+ # @param [Array] accepts array for Accept
238
+ # @return [String] the Accept header (e.g. application/json)
239
+ def select_header_accept(accepts)
240
+ if accepts.empty?
241
+ return
242
+ elsif accepts.any?{ |s| s.casecmp('application/json') == 0 }
243
+ 'application/json' # look for json data by default
244
+ else
245
+ accepts.join(',')
246
+ end
247
+ end
248
+
249
+ # Return Content-Type header based on an array of content types provided.
250
+ # @param [Array] content_types array for Content-Type
251
+ # @return [String] the Content-Type header (e.g. application/json)
252
+ def select_header_content_type(content_types)
253
+ if content_types.empty?
254
+ 'application/json' # use application/json by default
255
+ elsif content_types.any?{ |s| s.casecmp('application/json')==0 }
256
+ 'application/json' # use application/json if it's included
257
+ else
258
+ content_types[0] # otherwise, use the first one
259
+ end
260
+ end
261
+
262
+ # Convert object (array, hash, object, etc) to JSON string.
263
+ # @param [Object] model object to be converted into JSON string
264
+ # @return [String] JSON string representation of the object
265
+ def object_to_http_body(model)
266
+ return if model.nil?
267
+ _body = nil
268
+ if model.is_a?(Array)
269
+ _body = model.map{|m| object_to_hash(m) }
270
+ else
271
+ _body = object_to_hash(model)
272
+ end
273
+
274
+ # JRS: might be binary, if it doesn't work w/ to_json just fall back
275
+ #
276
+ begin
277
+ _body.to_json
278
+ rescue
279
+ _body
280
+ end
281
+ end
282
+
283
+ # Convert object(non-array) to hash.
284
+ # @param [Object] obj object to be converted into JSON string
285
+ # @return [String] JSON string representation of the object
286
+ def object_to_hash(obj)
287
+ if obj.respond_to?(:to_hash)
288
+ obj.to_hash
289
+ else
290
+ obj
291
+ end
292
+ end
293
+ end
294
+ end
@@ -0,0 +1,24 @@
1
+ module Apcera
2
+ class ApiError < StandardError
3
+ attr_reader :code, :response_headers, :response_body
4
+
5
+ # Usage examples:
6
+ # ApiError.new
7
+ # ApiError.new("message")
8
+ # ApiError.new(:code => 500, :response_headers => {}, :response_body => "")
9
+ # ApiError.new(:code => 404, :message => "Not Found")
10
+ def initialize(arg = nil)
11
+ if arg.is_a? Hash
12
+ arg.each do |k, v|
13
+ if k.to_s == 'message'
14
+ super v
15
+ else
16
+ instance_variable_set "@#{k}", v
17
+ end
18
+ end
19
+ else
20
+ super arg
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,173 @@
1
+ require 'uri'
2
+ require 'singleton'
3
+
4
+ module Apcera
5
+ class Configuration
6
+
7
+ include Singleton
8
+
9
+ # Default api client
10
+ attr_accessor :api_client
11
+
12
+ # Defines url scheme
13
+ attr_accessor :scheme
14
+
15
+ # Defines url host
16
+ attr_accessor :host
17
+
18
+ # Defines url base path
19
+ attr_accessor :base_path
20
+
21
+ # Defines API keys used with API Key authentications.
22
+ #
23
+ # @return [Hash] key: parameter name, value: parameter value (API key)
24
+ #
25
+ # @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
26
+ # config.api_key['api_key'] = 'xxx'
27
+ attr_accessor :api_key
28
+
29
+ # Defines API key prefixes used with API Key authentications.
30
+ #
31
+ # @return [Hash] key: parameter name, value: API key prefix
32
+ #
33
+ # @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
34
+ # config.api_key_prefix['api_key'] = 'Token'
35
+ attr_accessor :api_key_prefix
36
+
37
+ # Defines the username used with HTTP basic authentication.
38
+ #
39
+ # @return [String]
40
+ attr_accessor :username
41
+
42
+ # Defines the password used with HTTP basic authentication.
43
+ #
44
+ # @return [String]
45
+ attr_accessor :password
46
+
47
+ # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
48
+ # details will be logged with `logger.debug` (see the `logger` attribute).
49
+ # Default to false.
50
+ #
51
+ # @return [true, false]
52
+ attr_accessor :debugging
53
+
54
+ # Defines the logger used for debugging.
55
+ # Default to `Rails.logger` (when in Rails) or logging to STDOUT.
56
+ #
57
+ # @return [#debug]
58
+ attr_accessor :logger
59
+
60
+ # Defines the temporary folder to store downloaded files
61
+ # (for API endpoints that have file response).
62
+ # Default to use `Tempfile`.
63
+ #
64
+ # @return [String]
65
+ attr_accessor :temp_folder_path
66
+
67
+ ### TLS/SSL
68
+ # Set this to false to skip verifying SSL certificate when calling API from https server.
69
+ # Default to true.
70
+ #
71
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
72
+ #
73
+ # @return [true, false]
74
+ attr_accessor :verify_ssl
75
+
76
+ # Set this to customize the certificate file to verify the peer.
77
+ #
78
+ # @return [String] the path to the certificate file
79
+ #
80
+ # @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
81
+ # https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
82
+ attr_accessor :ssl_ca_cert
83
+
84
+ # Client certificate file (for client certificate)
85
+ attr_accessor :cert_file
86
+
87
+ # Client private key file (for client certificate)
88
+ attr_accessor :key_file
89
+
90
+ attr_accessor :inject_format
91
+
92
+ attr_accessor :force_ending_format
93
+
94
+ class << self
95
+ def method_missing(method_name, *args, &block)
96
+ config = Configuration.instance
97
+ if config.respond_to?(method_name)
98
+ config.send(method_name, *args, &block)
99
+ else
100
+ super
101
+ end
102
+ end
103
+ end
104
+
105
+ def initialize
106
+ @scheme = 'https'
107
+ @host = 'apiDoc.zeppole.buffalo.im'
108
+ @base_path = '/v1'
109
+ @api_key = {}
110
+ @api_key_prefix = {}
111
+ @verify_ssl = true
112
+ @cert_file = nil
113
+ @key_file = nil
114
+ @debugging = false
115
+ @inject_format = false
116
+ @force_ending_format = false
117
+ @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
118
+ end
119
+
120
+ def api_client
121
+ @api_client ||= ApiClient.new
122
+ end
123
+
124
+ def scheme=(scheme)
125
+ # remove :// from scheme
126
+ @scheme = scheme.sub(/:\/\//, '')
127
+ end
128
+
129
+ def host=(host)
130
+ # remove http(s):// and anything after a slash
131
+ @host = host.sub(/https?:\/\//, '').split('/').first
132
+ end
133
+
134
+ def base_path=(base_path)
135
+ # Add leading and trailing slashes to base_path
136
+ @base_path = "/#{base_path}".gsub(/\/+/, '/')
137
+ @base_path = "" if @base_path == "/"
138
+ end
139
+
140
+ def base_url
141
+ url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}"
142
+ URI.encode(url)
143
+ end
144
+
145
+ # Gets API key (with prefix if set).
146
+ # @param [String] param_name the parameter name of API key auth
147
+ def api_key_with_prefix(param_name)
148
+ if @api_key_prefix[param_name]
149
+ "#{@api_key_prefix[param_name]} #{@api_key[param_name]}"
150
+ else
151
+ @api_key[param_name]
152
+ end
153
+ end
154
+
155
+ # Gets Basic Auth token string
156
+ def basic_auth_token
157
+ 'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
158
+ end
159
+
160
+ # Returns Auth Settings hash for api client.
161
+ def auth_settings
162
+ {
163
+ 'authorization' =>
164
+ {
165
+ type: 'api_key',
166
+ in: 'header',
167
+ key: 'authorization',
168
+ value: api_key_with_prefix('authorization')
169
+ },
170
+ }
171
+ end
172
+ end
173
+ end
@@ -0,0 +1,37 @@
1
+ module Apcera
2
+ #
3
+ class APCVersionObject < BaseObject
4
+ attr_accessor :version
5
+ # attribute mapping from ruby-style variable name to JSON key
6
+ def self.attribute_map
7
+ {
8
+
9
+ # Current version of APC.
10
+ :'version' => :'version'
11
+
12
+ }
13
+ end
14
+
15
+ # attribute type
16
+ def self.swagger_types
17
+ {
18
+ :'version' => :'String'
19
+
20
+ }
21
+ end
22
+
23
+ def initialize(attributes = {})
24
+ return if !attributes.is_a?(Hash) || attributes.empty?
25
+
26
+ # convert string to symbol for hash key
27
+ attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
28
+
29
+
30
+ if attributes[:'version']
31
+ self.version = attributes[:'version']
32
+ end
33
+
34
+ end
35
+
36
+ end
37
+ end
@@ -0,0 +1,143 @@
1
+ module Apcera
2
+ #
3
+ class APIError < BaseObject
4
+ attr_accessor :client_side, :code, :duplicate_key, :fatal, :message, :missing_claims, :policy_error, :request_id, :request_invalid, :requires_restart, :resource_missing, :_retry, :token_invalid, :try_again_in_ms
5
+ # attribute mapping from ruby-style variable name to JSON key
6
+ def self.attribute_map
7
+ {
8
+
9
+ # If `true`, the error was due to a client-side error (e.g., invalid data); otherwise, the error was due to a server-side error (e.g. a NATS timeout).
10
+ :'client_side' => :'client_side',
11
+
12
+ # HTTP status code returned to the user.
13
+ :'code' => :'code',
14
+
15
+ # If `true`, the resource that&#39;s being sought already exists.
16
+ :'duplicate_key' => :'duplicate_key',
17
+
18
+ # If `true`, the action was fatal and should not be retried.
19
+ :'fatal' => :'fatal',
20
+
21
+ # Error message string.
22
+ :'message' => :'message',
23
+
24
+ # A list of missing policy claim(s) on policy denials.
25
+ :'missing_claims' => :'missing_claims',
26
+
27
+ #
28
+ :'policy_error' => :'policy_error',
29
+
30
+ # ID of the NATS message or HTTP request that generated the error.
31
+ :'request_id' => :'request_id',
32
+
33
+ # If `true`, the request cannot be processed due to a conflict.
34
+ :'request_invalid' => :'request_invalid',
35
+
36
+ # If `true`, the targeted resource is in a state where the request cannot be fulfilled; for instance, a job in the `started` state may not have its resources changed.
37
+ :'requires_restart' => :'requires_restart',
38
+
39
+ # If `true`, the requested resource could not be located.
40
+ :'resource_missing' => :'resource_missing',
41
+
42
+ # If `true`, the problem encountered was transient, and the same payload can be delivered again.
43
+ :'_retry' => :'retry',
44
+
45
+ # If `true`, the requestor&#39;s token was invalid (e.g., due to a timeout.)
46
+ :'token_invalid' => :'token_invalid',
47
+
48
+ # Specifies the amount of time in milliseconds that the client should wait before retrying the request.
49
+ :'try_again_in_ms' => :'try_again_in_ms'
50
+
51
+ }
52
+ end
53
+
54
+ # attribute type
55
+ def self.swagger_types
56
+ {
57
+ :'client_side' => :'BOOLEAN',
58
+ :'code' => :'Integer',
59
+ :'duplicate_key' => :'BOOLEAN',
60
+ :'fatal' => :'BOOLEAN',
61
+ :'message' => :'String',
62
+ :'missing_claims' => :'Array<String>',
63
+ :'policy_error' => :'PolicyError',
64
+ :'request_id' => :'String',
65
+ :'request_invalid' => :'BOOLEAN',
66
+ :'requires_restart' => :'BOOLEAN',
67
+ :'resource_missing' => :'BOOLEAN',
68
+ :'_retry' => :'BOOLEAN',
69
+ :'token_invalid' => :'BOOLEAN',
70
+ :'try_again_in_ms' => :'Integer'
71
+
72
+ }
73
+ end
74
+
75
+ def initialize(attributes = {})
76
+ return if !attributes.is_a?(Hash) || attributes.empty?
77
+
78
+ # convert string to symbol for hash key
79
+ attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
80
+
81
+
82
+ if attributes[:'client_side']
83
+ self.client_side = attributes[:'client_side']
84
+ end
85
+
86
+ if attributes[:'code']
87
+ self.code = attributes[:'code']
88
+ end
89
+
90
+ if attributes[:'duplicate_key']
91
+ self.duplicate_key = attributes[:'duplicate_key']
92
+ end
93
+
94
+ if attributes[:'fatal']
95
+ self.fatal = attributes[:'fatal']
96
+ end
97
+
98
+ if attributes[:'message']
99
+ self.message = attributes[:'message']
100
+ end
101
+
102
+ if attributes[:'missing_claims']
103
+ if (value = attributes[:'missing_claims']).is_a?(Array)
104
+ self.missing_claims = value
105
+ end
106
+ end
107
+
108
+ if attributes[:'policy_error']
109
+ self.policy_error = attributes[:'policy_error']
110
+ end
111
+
112
+ if attributes[:'request_id']
113
+ self.request_id = attributes[:'request_id']
114
+ end
115
+
116
+ if attributes[:'request_invalid']
117
+ self.request_invalid = attributes[:'request_invalid']
118
+ end
119
+
120
+ if attributes[:'requires_restart']
121
+ self.requires_restart = attributes[:'requires_restart']
122
+ end
123
+
124
+ if attributes[:'resource_missing']
125
+ self.resource_missing = attributes[:'resource_missing']
126
+ end
127
+
128
+ if attributes[:'retry']
129
+ self._retry = attributes[:'retry']
130
+ end
131
+
132
+ if attributes[:'token_invalid']
133
+ self.token_invalid = attributes[:'token_invalid']
134
+ end
135
+
136
+ if attributes[:'try_again_in_ms']
137
+ self.try_again_in_ms = attributes[:'try_again_in_ms']
138
+ end
139
+
140
+ end
141
+
142
+ end
143
+ end