pnap_rancher_api 1.0.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.
Files changed (48) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/README.md +154 -0
  4. data/Rakefile +10 -0
  5. data/VERSION +1 -0
  6. data/docs/Cluster.md +36 -0
  7. data/docs/ClustersApi.md +286 -0
  8. data/docs/DeleteResult.md +20 -0
  9. data/docs/Error.md +20 -0
  10. data/docs/Node.md +18 -0
  11. data/docs/NodePool.md +26 -0
  12. data/docs/RancherClusterCertificates.md +22 -0
  13. data/docs/RancherClusterConfig.md +30 -0
  14. data/docs/RancherServerMetadata.md +22 -0
  15. data/docs/SshConfig.md +22 -0
  16. data/docs/WorkloadClusterConfig.md +24 -0
  17. data/lib/pnap_rancher_api/api/clusters_api.rb +269 -0
  18. data/lib/pnap_rancher_api/api_client.rb +392 -0
  19. data/lib/pnap_rancher_api/api_error.rb +57 -0
  20. data/lib/pnap_rancher_api/configuration.rb +278 -0
  21. data/lib/pnap_rancher_api/models/cluster.rb +341 -0
  22. data/lib/pnap_rancher_api/models/delete_result.rb +235 -0
  23. data/lib/pnap_rancher_api/models/error.rb +236 -0
  24. data/lib/pnap_rancher_api/models/node.rb +220 -0
  25. data/lib/pnap_rancher_api/models/node_pool.rb +264 -0
  26. data/lib/pnap_rancher_api/models/rancher_cluster_certificates.rb +240 -0
  27. data/lib/pnap_rancher_api/models/rancher_cluster_config.rb +284 -0
  28. data/lib/pnap_rancher_api/models/rancher_server_metadata.rb +240 -0
  29. data/lib/pnap_rancher_api/models/ssh_config.rb +246 -0
  30. data/lib/pnap_rancher_api/models/workload_cluster_config.rb +264 -0
  31. data/lib/pnap_rancher_api/version.rb +19 -0
  32. data/lib/pnap_rancher_api.rb +50 -0
  33. data/pnap_rancher_api.gemspec +39 -0
  34. data/spec/api/clusters_api_spec.rb +82 -0
  35. data/spec/api_client_spec.rb +226 -0
  36. data/spec/configuration_spec.rb +42 -0
  37. data/spec/models/cluster_spec.rb +88 -0
  38. data/spec/models/delete_result_spec.rb +40 -0
  39. data/spec/models/error_spec.rb +40 -0
  40. data/spec/models/node_pool_spec.rb +58 -0
  41. data/spec/models/node_spec.rb +34 -0
  42. data/spec/models/rancher_cluster_certificates_spec.rb +46 -0
  43. data/spec/models/rancher_cluster_config_spec.rb +70 -0
  44. data/spec/models/rancher_server_metadata_spec.rb +46 -0
  45. data/spec/models/ssh_config_spec.rb +46 -0
  46. data/spec/models/workload_cluster_config_spec.rb +52 -0
  47. data/spec/spec_helper.rb +111 -0
  48. metadata +144 -0
@@ -0,0 +1,278 @@
1
+ =begin
2
+ #Rancher Solution API
3
+
4
+ #Simplify enterprise-grade Kubernetes cluster operations and management with Rancher on Bare Metal Cloud. Deploy Kubernetes clusters using a few API calls.<br> <br> <span class='pnap-api-knowledge-base-link'> Knowledge base articles to help you can be found <a href='https://phoenixnap.com/kb/rancher-bmc-integration-kubernetes' target='_blank'>here</a> </span><br> <br> <b>All URLs are relative to (https://api.phoenixnap.com/solutions/rancher/v1beta)</b>
5
+
6
+ The version of the OpenAPI document: 0.1
7
+ Contact: support@phoenixnap.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.4.0
10
+
11
+ =end
12
+
13
+ module RancherApi
14
+ class Configuration
15
+ # Defines url scheme
16
+ attr_accessor :scheme
17
+
18
+ # Defines url host
19
+ attr_accessor :host
20
+
21
+ # Defines url base path
22
+ attr_accessor :base_path
23
+
24
+ # Define server configuration index
25
+ attr_accessor :server_index
26
+
27
+ # Define server operation configuration index
28
+ attr_accessor :server_operation_index
29
+
30
+ # Default server variables
31
+ attr_accessor :server_variables
32
+
33
+ # Default server operation variables
34
+ attr_accessor :server_operation_variables
35
+
36
+ # Defines API keys used with API Key authentications.
37
+ #
38
+ # @return [Hash] key: parameter name, value: parameter value (API key)
39
+ #
40
+ # @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
41
+ # config.api_key['api_key'] = 'xxx'
42
+ attr_accessor :api_key
43
+
44
+ # Defines API key prefixes used with API Key authentications.
45
+ #
46
+ # @return [Hash] key: parameter name, value: API key prefix
47
+ #
48
+ # @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
49
+ # config.api_key_prefix['api_key'] = 'Token'
50
+ attr_accessor :api_key_prefix
51
+
52
+ # Defines the username used with HTTP basic authentication.
53
+ #
54
+ # @return [String]
55
+ attr_accessor :username
56
+
57
+ # Defines the password used with HTTP basic authentication.
58
+ #
59
+ # @return [String]
60
+ attr_accessor :password
61
+
62
+ # Defines the access token (Bearer) used with OAuth2.
63
+ attr_accessor :access_token
64
+
65
+ # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
66
+ # details will be logged with `logger.debug` (see the `logger` attribute).
67
+ # Default to false.
68
+ #
69
+ # @return [true, false]
70
+ attr_accessor :debugging
71
+
72
+ # Defines the logger used for debugging.
73
+ # Default to `Rails.logger` (when in Rails) or logging to STDOUT.
74
+ #
75
+ # @return [#debug]
76
+ attr_accessor :logger
77
+
78
+ # Defines the temporary folder to store downloaded files
79
+ # (for API endpoints that have file response).
80
+ # Default to use `Tempfile`.
81
+ #
82
+ # @return [String]
83
+ attr_accessor :temp_folder_path
84
+
85
+ # The time limit for HTTP request in seconds.
86
+ # Default to 0 (never times out).
87
+ attr_accessor :timeout
88
+
89
+ # Set this to false to skip client side validation in the operation.
90
+ # Default to true.
91
+ # @return [true, false]
92
+ attr_accessor :client_side_validation
93
+
94
+ ### TLS/SSL setting
95
+ # Set this to false to skip verifying SSL certificate when calling API from https server.
96
+ # Default to true.
97
+ #
98
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
99
+ #
100
+ # @return [true, false]
101
+ attr_accessor :verify_ssl
102
+
103
+ ### TLS/SSL setting
104
+ # Set this to false to skip verifying SSL host name
105
+ # Default to true.
106
+ #
107
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
108
+ #
109
+ # @return [true, false]
110
+ attr_accessor :verify_ssl_host
111
+
112
+ ### TLS/SSL setting
113
+ # Set this to customize the certificate file to verify the peer.
114
+ #
115
+ # @return [String] the path to the certificate file
116
+ #
117
+ # @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
118
+ # https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
119
+ attr_accessor :ssl_ca_cert
120
+
121
+ ### TLS/SSL setting
122
+ # Client certificate file (for client certificate)
123
+ attr_accessor :cert_file
124
+
125
+ ### TLS/SSL setting
126
+ # Client private key file (for client certificate)
127
+ attr_accessor :key_file
128
+
129
+ # Set this to customize parameters encoding of array parameter with multi collectionFormat.
130
+ # Default to nil.
131
+ #
132
+ # @see The params_encoding option of Ethon. Related source code:
133
+ # https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
134
+ attr_accessor :params_encoding
135
+
136
+ attr_accessor :inject_format
137
+
138
+ attr_accessor :force_ending_format
139
+
140
+ def initialize
141
+ @scheme = 'https'
142
+ @host = 'api.phoenixnap.com'
143
+ @base_path = '/solutions/rancher/v1beta'
144
+ @server_index = 0
145
+ @server_operation_index = {}
146
+ @server_variables = {}
147
+ @server_operation_variables = {}
148
+ @api_key = {}
149
+ @api_key_prefix = {}
150
+ @client_side_validation = true
151
+ @verify_ssl = true
152
+ @verify_ssl_host = true
153
+ @params_encoding = nil
154
+ @cert_file = nil
155
+ @key_file = nil
156
+ @timeout = 0
157
+ @debugging = false
158
+ @inject_format = false
159
+ @force_ending_format = false
160
+ @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
161
+
162
+ yield(self) if block_given?
163
+ end
164
+
165
+ # The default Configuration object.
166
+ def self.default
167
+ @@default ||= Configuration.new
168
+ end
169
+
170
+ def configure
171
+ yield(self) if block_given?
172
+ end
173
+
174
+ def scheme=(scheme)
175
+ # remove :// from scheme
176
+ @scheme = scheme.sub(/:\/\//, '')
177
+ end
178
+
179
+ def host=(host)
180
+ # remove http(s):// and anything after a slash
181
+ @host = host.sub(/https?:\/\//, '').split('/').first
182
+ end
183
+
184
+ def base_path=(base_path)
185
+ # Add leading and trailing slashes to base_path
186
+ @base_path = "/#{base_path}".gsub(/\/+/, '/')
187
+ @base_path = '' if @base_path == '/'
188
+ end
189
+
190
+ # Returns base URL for specified operation based on server settings
191
+ def base_url(operation = nil)
192
+ index = server_operation_index.fetch(operation, server_index)
193
+ return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if index == nil
194
+
195
+ server_url(index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
196
+ end
197
+
198
+ # Gets API key (with prefix if set).
199
+ # @param [String] param_name the parameter name of API key auth
200
+ def api_key_with_prefix(param_name, param_alias = nil)
201
+ key = @api_key[param_name]
202
+ key = @api_key.fetch(param_alias, key) unless param_alias.nil?
203
+ if @api_key_prefix[param_name]
204
+ "#{@api_key_prefix[param_name]} #{key}"
205
+ else
206
+ key
207
+ end
208
+ end
209
+
210
+ # Gets Basic Auth token string
211
+ def basic_auth_token
212
+ 'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
213
+ end
214
+
215
+ # Returns Auth Settings hash for api client.
216
+ def auth_settings
217
+ {
218
+ 'OAuth2' =>
219
+ {
220
+ type: 'oauth2',
221
+ in: 'header',
222
+ key: 'Authorization',
223
+ value: "Bearer #{access_token}"
224
+ },
225
+ }
226
+ end
227
+
228
+ # Returns an array of Server setting
229
+ def server_settings
230
+ [
231
+ {
232
+ url: "https://api.phoenixnap.com/solutions/rancher/v1beta",
233
+ description: "No description provided",
234
+ }
235
+ ]
236
+ end
237
+
238
+ def operation_server_settings
239
+ {
240
+ }
241
+ end
242
+
243
+ # Returns URL based on server settings
244
+ #
245
+ # @param index array index of the server settings
246
+ # @param variables hash of variable and the corresponding value
247
+ def server_url(index, variables = {}, servers = nil)
248
+ servers = server_settings if servers == nil
249
+
250
+ # check array index out of bound
251
+ if (index < 0 || index >= servers.size)
252
+ fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
253
+ end
254
+
255
+ server = servers[index]
256
+ url = server[:url]
257
+
258
+ return url unless server.key? :variables
259
+
260
+ # go through variable and assign a value
261
+ server[:variables].each do |name, variable|
262
+ if variables.key?(name)
263
+ if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
264
+ url.gsub! "{" + name.to_s + "}", variables[name]
265
+ else
266
+ fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
267
+ end
268
+ else
269
+ # use default value
270
+ url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
271
+ end
272
+ end
273
+
274
+ url
275
+ end
276
+
277
+ end
278
+ end
@@ -0,0 +1,341 @@
1
+ =begin
2
+ #Rancher Solution API
3
+
4
+ #Simplify enterprise-grade Kubernetes cluster operations and management with Rancher on Bare Metal Cloud. Deploy Kubernetes clusters using a few API calls.<br> <br> <span class='pnap-api-knowledge-base-link'> Knowledge base articles to help you can be found <a href='https://phoenixnap.com/kb/rancher-bmc-integration-kubernetes' target='_blank'>here</a> </span><br> <br> <b>All URLs are relative to (https://api.phoenixnap.com/solutions/rancher/v1beta)</b>
5
+
6
+ The version of the OpenAPI document: 0.1
7
+ Contact: support@phoenixnap.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.4.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module RancherApi
17
+ # Cluster details.
18
+ class Cluster
19
+ # (Read-only) The Cluster identifier.
20
+ attr_accessor :id
21
+
22
+ # Cluster name. This field is autogenerated if not provided.
23
+ attr_accessor :name
24
+
25
+ # Cluster description.
26
+ attr_accessor :description
27
+
28
+ # Deployment location. Cannot be changed once a cluster is created. Currently this field should be set to `PHX`, `ASH`, `SGP`, `NLD`, `CHI`, `SEA` or `AUS`.
29
+ attr_accessor :location
30
+
31
+ # (Read-only) The Rancher version that was installed on the cluster during the first creation process.
32
+ attr_accessor :initial_cluster_version
33
+
34
+ # The node pools associated with the cluster.
35
+ attr_accessor :node_pools
36
+
37
+ attr_accessor :configuration
38
+
39
+ attr_accessor :metadata
40
+
41
+ attr_accessor :workload_configuration
42
+
43
+ # The cluster status
44
+ attr_accessor :status_description
45
+
46
+ # Attribute mapping from ruby-style variable name to JSON key.
47
+ def self.attribute_map
48
+ {
49
+ :'id' => :'id',
50
+ :'name' => :'name',
51
+ :'description' => :'description',
52
+ :'location' => :'location',
53
+ :'initial_cluster_version' => :'initialClusterVersion',
54
+ :'node_pools' => :'nodePools',
55
+ :'configuration' => :'configuration',
56
+ :'metadata' => :'metadata',
57
+ :'workload_configuration' => :'workloadConfiguration',
58
+ :'status_description' => :'statusDescription'
59
+ }
60
+ end
61
+
62
+ # Returns all the JSON keys this model knows about
63
+ def self.acceptable_attributes
64
+ attribute_map.values
65
+ end
66
+
67
+ # Attribute type mapping.
68
+ def self.openapi_types
69
+ {
70
+ :'id' => :'String',
71
+ :'name' => :'String',
72
+ :'description' => :'String',
73
+ :'location' => :'String',
74
+ :'initial_cluster_version' => :'String',
75
+ :'node_pools' => :'Array<NodePool>',
76
+ :'configuration' => :'RancherClusterConfig',
77
+ :'metadata' => :'RancherServerMetadata',
78
+ :'workload_configuration' => :'WorkloadClusterConfig',
79
+ :'status_description' => :'String'
80
+ }
81
+ end
82
+
83
+ # List of attributes with nullable: true
84
+ def self.openapi_nullable
85
+ Set.new([
86
+ :'configuration',
87
+ :'metadata',
88
+ :'workload_configuration',
89
+ ])
90
+ end
91
+
92
+ # Initializes the object
93
+ # @param [Hash] attributes Model attributes in the form of hash
94
+ def initialize(attributes = {})
95
+ if (!attributes.is_a?(Hash))
96
+ fail ArgumentError, "The input argument (attributes) must be a hash in `RancherApi::Cluster` initialize method"
97
+ end
98
+
99
+ # check to see if the attribute exists and convert string to symbol for hash key
100
+ attributes = attributes.each_with_object({}) { |(k, v), h|
101
+ if (!self.class.attribute_map.key?(k.to_sym))
102
+ fail ArgumentError, "`#{k}` is not a valid attribute in `RancherApi::Cluster`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
103
+ end
104
+ h[k.to_sym] = v
105
+ }
106
+
107
+ if attributes.key?(:'id')
108
+ self.id = attributes[:'id']
109
+ end
110
+
111
+ if attributes.key?(:'name')
112
+ self.name = attributes[:'name']
113
+ end
114
+
115
+ if attributes.key?(:'description')
116
+ self.description = attributes[:'description']
117
+ end
118
+
119
+ if attributes.key?(:'location')
120
+ self.location = attributes[:'location']
121
+ end
122
+
123
+ if attributes.key?(:'initial_cluster_version')
124
+ self.initial_cluster_version = attributes[:'initial_cluster_version']
125
+ end
126
+
127
+ if attributes.key?(:'node_pools')
128
+ if (value = attributes[:'node_pools']).is_a?(Array)
129
+ self.node_pools = value
130
+ end
131
+ end
132
+
133
+ if attributes.key?(:'configuration')
134
+ self.configuration = attributes[:'configuration']
135
+ end
136
+
137
+ if attributes.key?(:'metadata')
138
+ self.metadata = attributes[:'metadata']
139
+ end
140
+
141
+ if attributes.key?(:'workload_configuration')
142
+ self.workload_configuration = attributes[:'workload_configuration']
143
+ end
144
+
145
+ if attributes.key?(:'status_description')
146
+ self.status_description = attributes[:'status_description']
147
+ end
148
+ end
149
+
150
+ # Show invalid properties with the reasons. Usually used together with valid?
151
+ # @return Array for valid properties with the reasons
152
+ def list_invalid_properties
153
+ invalid_properties = Array.new
154
+ if @location.nil?
155
+ invalid_properties.push('invalid value for "location", location cannot be nil.')
156
+ end
157
+
158
+ if !@node_pools.nil? && @node_pools.length > 1
159
+ invalid_properties.push('invalid value for "node_pools", number of items must be less than or equal to 1.')
160
+ end
161
+
162
+ if !@node_pools.nil? && @node_pools.length < 1
163
+ invalid_properties.push('invalid value for "node_pools", number of items must be greater than or equal to 1.')
164
+ end
165
+
166
+ invalid_properties
167
+ end
168
+
169
+ # Check to see if the all the properties in the model are valid
170
+ # @return true if the model is valid
171
+ def valid?
172
+ return false if @location.nil?
173
+ return false if !@node_pools.nil? && @node_pools.length > 1
174
+ return false if !@node_pools.nil? && @node_pools.length < 1
175
+ true
176
+ end
177
+
178
+ # Custom attribute writer method with validation
179
+ # @param [Object] node_pools Value to be assigned
180
+ def node_pools=(node_pools)
181
+ if !node_pools.nil? && node_pools.length > 1
182
+ fail ArgumentError, 'invalid value for "node_pools", number of items must be less than or equal to 1.'
183
+ end
184
+
185
+ if !node_pools.nil? && node_pools.length < 1
186
+ fail ArgumentError, 'invalid value for "node_pools", number of items must be greater than or equal to 1.'
187
+ end
188
+
189
+ @node_pools = node_pools
190
+ end
191
+
192
+ # Checks equality by comparing each attribute.
193
+ # @param [Object] Object to be compared
194
+ def ==(o)
195
+ return true if self.equal?(o)
196
+ self.class == o.class &&
197
+ id == o.id &&
198
+ name == o.name &&
199
+ description == o.description &&
200
+ location == o.location &&
201
+ initial_cluster_version == o.initial_cluster_version &&
202
+ node_pools == o.node_pools &&
203
+ configuration == o.configuration &&
204
+ metadata == o.metadata &&
205
+ workload_configuration == o.workload_configuration &&
206
+ status_description == o.status_description
207
+ end
208
+
209
+ # @see the `==` method
210
+ # @param [Object] Object to be compared
211
+ def eql?(o)
212
+ self == o
213
+ end
214
+
215
+ # Calculates hash code according to all attributes.
216
+ # @return [Integer] Hash code
217
+ def hash
218
+ [id, name, description, location, initial_cluster_version, node_pools, configuration, metadata, workload_configuration, status_description].hash
219
+ end
220
+
221
+ # Builds the object from hash
222
+ # @param [Hash] attributes Model attributes in the form of hash
223
+ # @return [Object] Returns the model itself
224
+ def self.build_from_hash(attributes)
225
+ new.build_from_hash(attributes)
226
+ end
227
+
228
+ # Builds the object from hash
229
+ # @param [Hash] attributes Model attributes in the form of hash
230
+ # @return [Object] Returns the model itself
231
+ def build_from_hash(attributes)
232
+ return nil unless attributes.is_a?(Hash)
233
+ self.class.openapi_types.each_pair do |key, type|
234
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
235
+ self.send("#{key}=", nil)
236
+ elsif type =~ /\AArray<(.*)>/i
237
+ # check to ensure the input is an array given that the attribute
238
+ # is documented as an array but the input is not
239
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
240
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
241
+ end
242
+ elsif !attributes[self.class.attribute_map[key]].nil?
243
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
244
+ end
245
+ end
246
+
247
+ self
248
+ end
249
+
250
+ # Deserializes the data based on type
251
+ # @param string type Data type
252
+ # @param string value Value to be deserialized
253
+ # @return [Object] Deserialized data
254
+ def _deserialize(type, value)
255
+ case type.to_sym
256
+ when :Time
257
+ Time.parse(value)
258
+ when :Date
259
+ Date.parse(value)
260
+ when :String
261
+ value.to_s
262
+ when :Integer
263
+ value.to_i
264
+ when :Float
265
+ value.to_f
266
+ when :Boolean
267
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
268
+ true
269
+ else
270
+ false
271
+ end
272
+ when :Object
273
+ # generic object (usually a Hash), return directly
274
+ value
275
+ when /\AArray<(?<inner_type>.+)>\z/
276
+ inner_type = Regexp.last_match[:inner_type]
277
+ value.map { |v| _deserialize(inner_type, v) }
278
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
279
+ k_type = Regexp.last_match[:k_type]
280
+ v_type = Regexp.last_match[:v_type]
281
+ {}.tap do |hash|
282
+ value.each do |k, v|
283
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
284
+ end
285
+ end
286
+ else # model
287
+ # models (e.g. Pet) or oneOf
288
+ klass = RancherApi.const_get(type)
289
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
290
+ end
291
+ end
292
+
293
+ # Returns the string representation of the object
294
+ # @return [String] String presentation of the object
295
+ def to_s
296
+ to_hash.to_s
297
+ end
298
+
299
+ # to_body is an alias to to_hash (backward compatibility)
300
+ # @return [Hash] Returns the object in the form of hash
301
+ def to_body
302
+ to_hash
303
+ end
304
+
305
+ # Returns the object in the form of hash
306
+ # @return [Hash] Returns the object in the form of hash
307
+ def to_hash
308
+ hash = {}
309
+ self.class.attribute_map.each_pair do |attr, param|
310
+ value = self.send(attr)
311
+ if value.nil?
312
+ is_nullable = self.class.openapi_nullable.include?(attr)
313
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
314
+ end
315
+
316
+ hash[param] = _to_hash(value)
317
+ end
318
+ hash
319
+ end
320
+
321
+ # Outputs non-array value in the form of hash
322
+ # For object, use to_hash. Otherwise, just return the value
323
+ # @param [Object] value Any valid value
324
+ # @return [Hash] Returns the value in the form of hash
325
+ def _to_hash(value)
326
+ if value.is_a?(Array)
327
+ value.compact.map { |v| _to_hash(v) }
328
+ elsif value.is_a?(Hash)
329
+ {}.tap do |hash|
330
+ value.each { |k, v| hash[k] = _to_hash(v) }
331
+ end
332
+ elsif value.respond_to? :to_hash
333
+ value.to_hash
334
+ else
335
+ value
336
+ end
337
+ end
338
+
339
+ end
340
+
341
+ end