akeyless 3.0.1 → 3.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +36 -3
  3. data/docs/AttributeTypeAndValue.md +20 -0
  4. data/docs/CertificateChainInfo.md +22 -0
  5. data/docs/CertificateExpirationEvent.md +18 -0
  6. data/docs/CertificateInfo.md +62 -0
  7. data/docs/Connect.md +2 -0
  8. data/docs/CreateCertificate.md +38 -0
  9. data/docs/CreateCertificateOutput.md +18 -0
  10. data/docs/CreateEventForwarder.md +48 -0
  11. data/docs/CreateEventForwarderOutput.md +18 -0
  12. data/docs/CreateRotatedSecret.md +2 -0
  13. data/docs/DeleteEventForwarder.md +24 -0
  14. data/docs/EmailEntry.md +20 -0
  15. data/docs/Extension.md +22 -0
  16. data/docs/GatewayUpdateItem.md +2 -0
  17. data/docs/GatewayUpdateTlsCert.md +26 -0
  18. data/docs/GatewayUpdateTlsCertOutput.md +18 -0
  19. data/docs/GetCertificateValue.md +26 -0
  20. data/docs/GetCertificateValueOutput.md +20 -0
  21. data/docs/GetEventForwarder.md +24 -0
  22. data/docs/GetEventForwarderOutput.md +18 -0
  23. data/docs/Item.md +4 -0
  24. data/docs/ItemGeneralInfo.md +2 -0
  25. data/docs/ListSRABastions.md +2 -0
  26. data/docs/ListSharedItems.md +24 -0
  27. data/docs/Name.md +28 -0
  28. data/docs/NotiForwarder.md +56 -0
  29. data/docs/RequestAccess.md +28 -0
  30. data/docs/RequestAccessOutput.md +18 -0
  31. data/docs/RotateKey.md +2 -0
  32. data/docs/Target.md +4 -0
  33. data/docs/UpdateCertificateOutput.md +18 -0
  34. data/docs/UpdateCertificateValue.md +32 -0
  35. data/docs/UpdateEventForwarder.md +40 -0
  36. data/docs/UpdateRotatedSecret.md +2 -0
  37. data/docs/V2Api.md +631 -65
  38. data/lib/akeyless/api/v2_api.rb +664 -88
  39. data/lib/akeyless/api_error.rb +1 -0
  40. data/lib/akeyless/configuration.rb +11 -0
  41. data/lib/akeyless/models/attribute_type_and_value.rb +231 -0
  42. data/lib/akeyless/models/certificate_chain_info.rb +241 -0
  43. data/lib/akeyless/models/certificate_expiration_event.rb +219 -0
  44. data/lib/akeyless/models/certificate_info.rb +434 -0
  45. data/lib/akeyless/models/connect.rb +11 -1
  46. data/lib/akeyless/models/create_certificate.rb +329 -0
  47. data/lib/akeyless/models/create_certificate_output.rb +219 -0
  48. data/lib/akeyless/models/create_event_forwarder.rb +394 -0
  49. data/lib/akeyless/models/create_event_forwarder_output.rb +219 -0
  50. data/lib/akeyless/models/create_rotated_secret.rb +11 -1
  51. data/lib/akeyless/models/delete_event_forwarder.rb +255 -0
  52. data/lib/akeyless/models/email_entry.rb +228 -0
  53. data/lib/akeyless/models/extension.rb +237 -0
  54. data/lib/akeyless/models/gateway_update_item.rb +11 -1
  55. data/lib/akeyless/models/gateway_update_tls_cert.rb +261 -0
  56. data/lib/akeyless/models/gateway_update_tls_cert_output.rb +219 -0
  57. data/lib/akeyless/models/get_certificate_value.rb +265 -0
  58. data/lib/akeyless/models/get_certificate_value_output.rb +228 -0
  59. data/lib/akeyless/models/get_event_forwarder.rb +255 -0
  60. data/lib/akeyless/models/get_event_forwarder_output.rb +219 -0
  61. data/lib/akeyless/models/item.rb +19 -1
  62. data/lib/akeyless/models/item_general_info.rb +10 -1
  63. data/lib/akeyless/models/list_shared_items.rb +253 -0
  64. data/lib/akeyless/models/list_sra_bastions.rb +10 -1
  65. data/lib/akeyless/models/name.rb +277 -0
  66. data/lib/akeyless/models/noti_forwarder.rb +400 -0
  67. data/lib/akeyless/models/request_access.rb +282 -0
  68. data/lib/akeyless/models/request_access_output.rb +219 -0
  69. data/lib/akeyless/models/rotate_key.rb +11 -1
  70. data/lib/akeyless/models/target.rb +19 -1
  71. data/lib/akeyless/models/update_certificate_output.rb +219 -0
  72. data/lib/akeyless/models/update_certificate_value.rb +297 -0
  73. data/lib/akeyless/models/update_event_forwarder.rb +341 -0
  74. data/lib/akeyless/models/update_rotated_secret.rb +11 -1
  75. data/lib/akeyless/version.rb +1 -1
  76. data/lib/akeyless.rb +25 -1
  77. data/spec/models/attribute_type_and_value_spec.rb +40 -0
  78. data/spec/models/certificate_chain_info_spec.rb +46 -0
  79. data/spec/models/certificate_expiration_event_spec.rb +34 -0
  80. data/spec/models/certificate_info_spec.rb +166 -0
  81. data/spec/models/create_certificate_output_spec.rb +34 -0
  82. data/spec/models/create_certificate_spec.rb +94 -0
  83. data/spec/models/create_event_forwarder_output_spec.rb +34 -0
  84. data/spec/models/create_event_forwarder_spec.rb +124 -0
  85. data/spec/models/delete_event_forwarder_spec.rb +52 -0
  86. data/spec/models/email_entry_spec.rb +40 -0
  87. data/spec/models/extension_spec.rb +46 -0
  88. data/spec/models/gateway_update_tls_cert_output_spec.rb +34 -0
  89. data/spec/models/gateway_update_tls_cert_spec.rb +58 -0
  90. data/spec/models/get_certificate_value_output_spec.rb +40 -0
  91. data/spec/models/get_certificate_value_spec.rb +58 -0
  92. data/spec/models/get_event_forwarder_output_spec.rb +34 -0
  93. data/spec/models/get_event_forwarder_spec.rb +52 -0
  94. data/spec/models/list_shared_items_spec.rb +52 -0
  95. data/spec/models/name_spec.rb +64 -0
  96. data/spec/models/noti_forwarder_spec.rb +148 -0
  97. data/spec/models/request_access_output_spec.rb +34 -0
  98. data/spec/models/request_access_spec.rb +64 -0
  99. data/spec/models/update_certificate_output_spec.rb +34 -0
  100. data/spec/models/update_certificate_value_spec.rb +76 -0
  101. data/spec/models/update_event_forwarder_spec.rb +100 -0
  102. metadata +630 -530
@@ -31,6 +31,9 @@ module Akeyless
31
31
  # Protection from accidental deletion of this item
32
32
  attr_accessor :delete_protection
33
33
 
34
+ # Base64-encoded service account private key text
35
+ attr_accessor :gcp_key
36
+
34
37
  # Set output format to JSON
35
38
  attr_accessor :json
36
39
 
@@ -85,6 +88,7 @@ module Akeyless
85
88
  :'auto_rotate' => :'auto-rotate',
86
89
  :'custom_payload' => :'custom-payload',
87
90
  :'delete_protection' => :'delete_protection',
91
+ :'gcp_key' => :'gcp-key',
88
92
  :'json' => :'json',
89
93
  :'keep_prev_version' => :'keep-prev-version',
90
94
  :'key' => :'key',
@@ -118,6 +122,7 @@ module Akeyless
118
122
  :'auto_rotate' => :'String',
119
123
  :'custom_payload' => :'String',
120
124
  :'delete_protection' => :'String',
125
+ :'gcp_key' => :'String',
121
126
  :'json' => :'Boolean',
122
127
  :'keep_prev_version' => :'String',
123
128
  :'key' => :'String',
@@ -184,6 +189,10 @@ module Akeyless
184
189
  self.delete_protection = attributes[:'delete_protection']
185
190
  end
186
191
 
192
+ if attributes.key?(:'gcp_key')
193
+ self.gcp_key = attributes[:'gcp_key']
194
+ end
195
+
187
196
  if attributes.key?(:'json')
188
197
  self.json = attributes[:'json']
189
198
  end
@@ -289,6 +298,7 @@ module Akeyless
289
298
  auto_rotate == o.auto_rotate &&
290
299
  custom_payload == o.custom_payload &&
291
300
  delete_protection == o.delete_protection &&
301
+ gcp_key == o.gcp_key &&
292
302
  json == o.json &&
293
303
  keep_prev_version == o.keep_prev_version &&
294
304
  key == o.key &&
@@ -316,7 +326,7 @@ module Akeyless
316
326
  # Calculates hash code according to all attributes.
317
327
  # @return [Integer] Hash code
318
328
  def hash
319
- [add_tag, api_id, api_key, auto_rotate, custom_payload, delete_protection, json, keep_prev_version, key, name, new_metadata, new_name, new_version, rm_tag, rotated_password, rotated_username, rotation_hour, rotation_interval, rotator_creds_type, token, type, uid_token].hash
329
+ [add_tag, api_id, api_key, auto_rotate, custom_payload, delete_protection, gcp_key, json, keep_prev_version, key, name, new_metadata, new_name, new_version, rm_tag, rotated_password, rotated_username, rotation_hour, rotation_interval, rotator_creds_type, token, type, uid_token].hash
320
330
  end
321
331
 
322
332
  # Builds the object from hash
@@ -0,0 +1,261 @@
1
+ =begin
2
+ #Akeyless API
3
+
4
+ #The purpose of this application is to provide access to Akeyless API.
5
+
6
+ The version of the OpenAPI document: 2.0
7
+ Contact: support@akeyless.io
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.3.0-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Akeyless
17
+ # gatewayUpdateTlsCert is a command that updates Gateway TLS certificate
18
+ class GatewayUpdateTlsCert
19
+ # TLS Certificate (base64 encoded)
20
+ attr_accessor :cert_data
21
+
22
+ # Set output format to JSON
23
+ attr_accessor :json
24
+
25
+ # TLS Private Key (base64 encoded)
26
+ attr_accessor :key_data
27
+
28
+ # Authentication token (see `/auth` and `/configure`)
29
+ attr_accessor :token
30
+
31
+ # The universal identity token, Required only for universal_identity authentication
32
+ attr_accessor :uid_token
33
+
34
+ # Attribute mapping from ruby-style variable name to JSON key.
35
+ def self.attribute_map
36
+ {
37
+ :'cert_data' => :'cert-data',
38
+ :'json' => :'json',
39
+ :'key_data' => :'key-data',
40
+ :'token' => :'token',
41
+ :'uid_token' => :'uid-token'
42
+ }
43
+ end
44
+
45
+ # Returns all the JSON keys this model knows about
46
+ def self.acceptable_attributes
47
+ attribute_map.values
48
+ end
49
+
50
+ # Attribute type mapping.
51
+ def self.openapi_types
52
+ {
53
+ :'cert_data' => :'String',
54
+ :'json' => :'Boolean',
55
+ :'key_data' => :'String',
56
+ :'token' => :'String',
57
+ :'uid_token' => :'String'
58
+ }
59
+ end
60
+
61
+ # List of attributes with nullable: true
62
+ def self.openapi_nullable
63
+ Set.new([
64
+ ])
65
+ end
66
+
67
+ # Initializes the object
68
+ # @param [Hash] attributes Model attributes in the form of hash
69
+ def initialize(attributes = {})
70
+ if (!attributes.is_a?(Hash))
71
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Akeyless::GatewayUpdateTlsCert` initialize method"
72
+ end
73
+
74
+ # check to see if the attribute exists and convert string to symbol for hash key
75
+ attributes = attributes.each_with_object({}) { |(k, v), h|
76
+ if (!self.class.attribute_map.key?(k.to_sym))
77
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Akeyless::GatewayUpdateTlsCert`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
78
+ end
79
+ h[k.to_sym] = v
80
+ }
81
+
82
+ if attributes.key?(:'cert_data')
83
+ self.cert_data = attributes[:'cert_data']
84
+ end
85
+
86
+ if attributes.key?(:'json')
87
+ self.json = attributes[:'json']
88
+ end
89
+
90
+ if attributes.key?(:'key_data')
91
+ self.key_data = attributes[:'key_data']
92
+ end
93
+
94
+ if attributes.key?(:'token')
95
+ self.token = attributes[:'token']
96
+ end
97
+
98
+ if attributes.key?(:'uid_token')
99
+ self.uid_token = attributes[:'uid_token']
100
+ end
101
+ end
102
+
103
+ # Show invalid properties with the reasons. Usually used together with valid?
104
+ # @return Array for valid properties with the reasons
105
+ def list_invalid_properties
106
+ invalid_properties = Array.new
107
+ invalid_properties
108
+ end
109
+
110
+ # Check to see if the all the properties in the model are valid
111
+ # @return true if the model is valid
112
+ def valid?
113
+ true
114
+ end
115
+
116
+ # Checks equality by comparing each attribute.
117
+ # @param [Object] Object to be compared
118
+ def ==(o)
119
+ return true if self.equal?(o)
120
+ self.class == o.class &&
121
+ cert_data == o.cert_data &&
122
+ json == o.json &&
123
+ key_data == o.key_data &&
124
+ token == o.token &&
125
+ uid_token == o.uid_token
126
+ end
127
+
128
+ # @see the `==` method
129
+ # @param [Object] Object to be compared
130
+ def eql?(o)
131
+ self == o
132
+ end
133
+
134
+ # Calculates hash code according to all attributes.
135
+ # @return [Integer] Hash code
136
+ def hash
137
+ [cert_data, json, key_data, token, uid_token].hash
138
+ end
139
+
140
+ # Builds the object from hash
141
+ # @param [Hash] attributes Model attributes in the form of hash
142
+ # @return [Object] Returns the model itself
143
+ def self.build_from_hash(attributes)
144
+ new.build_from_hash(attributes)
145
+ end
146
+
147
+ # Builds the object from hash
148
+ # @param [Hash] attributes Model attributes in the form of hash
149
+ # @return [Object] Returns the model itself
150
+ def build_from_hash(attributes)
151
+ return nil unless attributes.is_a?(Hash)
152
+ attributes = attributes.transform_keys(&:to_sym)
153
+ self.class.openapi_types.each_pair do |key, type|
154
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
155
+ self.send("#{key}=", nil)
156
+ elsif type =~ /\AArray<(.*)>/i
157
+ # check to ensure the input is an array given that the attribute
158
+ # is documented as an array but the input is not
159
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
160
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
161
+ end
162
+ elsif !attributes[self.class.attribute_map[key]].nil?
163
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
164
+ end
165
+ end
166
+
167
+ self
168
+ end
169
+
170
+ # Deserializes the data based on type
171
+ # @param string type Data type
172
+ # @param string value Value to be deserialized
173
+ # @return [Object] Deserialized data
174
+ def _deserialize(type, value)
175
+ case type.to_sym
176
+ when :Time
177
+ Time.parse(value)
178
+ when :Date
179
+ Date.parse(value)
180
+ when :String
181
+ value.to_s
182
+ when :Integer
183
+ value.to_i
184
+ when :Float
185
+ value.to_f
186
+ when :Boolean
187
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
188
+ true
189
+ else
190
+ false
191
+ end
192
+ when :Object
193
+ # generic object (usually a Hash), return directly
194
+ value
195
+ when /\AArray<(?<inner_type>.+)>\z/
196
+ inner_type = Regexp.last_match[:inner_type]
197
+ value.map { |v| _deserialize(inner_type, v) }
198
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
199
+ k_type = Regexp.last_match[:k_type]
200
+ v_type = Regexp.last_match[:v_type]
201
+ {}.tap do |hash|
202
+ value.each do |k, v|
203
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
204
+ end
205
+ end
206
+ else # model
207
+ # models (e.g. Pet) or oneOf
208
+ klass = Akeyless.const_get(type)
209
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
210
+ end
211
+ end
212
+
213
+ # Returns the string representation of the object
214
+ # @return [String] String presentation of the object
215
+ def to_s
216
+ to_hash.to_s
217
+ end
218
+
219
+ # to_body is an alias to to_hash (backward compatibility)
220
+ # @return [Hash] Returns the object in the form of hash
221
+ def to_body
222
+ to_hash
223
+ end
224
+
225
+ # Returns the object in the form of hash
226
+ # @return [Hash] Returns the object in the form of hash
227
+ def to_hash
228
+ hash = {}
229
+ self.class.attribute_map.each_pair do |attr, param|
230
+ value = self.send(attr)
231
+ if value.nil?
232
+ is_nullable = self.class.openapi_nullable.include?(attr)
233
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
234
+ end
235
+
236
+ hash[param] = _to_hash(value)
237
+ end
238
+ hash
239
+ end
240
+
241
+ # Outputs non-array value in the form of hash
242
+ # For object, use to_hash. Otherwise, just return the value
243
+ # @param [Object] value Any valid value
244
+ # @return [Hash] Returns the value in the form of hash
245
+ def _to_hash(value)
246
+ if value.is_a?(Array)
247
+ value.compact.map { |v| _to_hash(v) }
248
+ elsif value.is_a?(Hash)
249
+ {}.tap do |hash|
250
+ value.each { |k, v| hash[k] = _to_hash(v) }
251
+ end
252
+ elsif value.respond_to? :to_hash
253
+ value.to_hash
254
+ else
255
+ value
256
+ end
257
+ end
258
+
259
+ end
260
+
261
+ end
@@ -0,0 +1,219 @@
1
+ =begin
2
+ #Akeyless API
3
+
4
+ #The purpose of this application is to provide access to Akeyless API.
5
+
6
+ The version of the OpenAPI document: 2.0
7
+ Contact: support@akeyless.io
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.3.0-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Akeyless
17
+ class GatewayUpdateTlsCertOutput
18
+ attr_accessor :updated
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+ :'updated' => :'updated'
24
+ }
25
+ end
26
+
27
+ # Returns all the JSON keys this model knows about
28
+ def self.acceptable_attributes
29
+ attribute_map.values
30
+ end
31
+
32
+ # Attribute type mapping.
33
+ def self.openapi_types
34
+ {
35
+ :'updated' => :'Boolean'
36
+ }
37
+ end
38
+
39
+ # List of attributes with nullable: true
40
+ def self.openapi_nullable
41
+ Set.new([
42
+ ])
43
+ end
44
+
45
+ # Initializes the object
46
+ # @param [Hash] attributes Model attributes in the form of hash
47
+ def initialize(attributes = {})
48
+ if (!attributes.is_a?(Hash))
49
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Akeyless::GatewayUpdateTlsCertOutput` initialize method"
50
+ end
51
+
52
+ # check to see if the attribute exists and convert string to symbol for hash key
53
+ attributes = attributes.each_with_object({}) { |(k, v), h|
54
+ if (!self.class.attribute_map.key?(k.to_sym))
55
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Akeyless::GatewayUpdateTlsCertOutput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
56
+ end
57
+ h[k.to_sym] = v
58
+ }
59
+
60
+ if attributes.key?(:'updated')
61
+ self.updated = attributes[:'updated']
62
+ end
63
+ end
64
+
65
+ # Show invalid properties with the reasons. Usually used together with valid?
66
+ # @return Array for valid properties with the reasons
67
+ def list_invalid_properties
68
+ invalid_properties = Array.new
69
+ invalid_properties
70
+ end
71
+
72
+ # Check to see if the all the properties in the model are valid
73
+ # @return true if the model is valid
74
+ def valid?
75
+ true
76
+ end
77
+
78
+ # Checks equality by comparing each attribute.
79
+ # @param [Object] Object to be compared
80
+ def ==(o)
81
+ return true if self.equal?(o)
82
+ self.class == o.class &&
83
+ updated == o.updated
84
+ end
85
+
86
+ # @see the `==` method
87
+ # @param [Object] Object to be compared
88
+ def eql?(o)
89
+ self == o
90
+ end
91
+
92
+ # Calculates hash code according to all attributes.
93
+ # @return [Integer] Hash code
94
+ def hash
95
+ [updated].hash
96
+ end
97
+
98
+ # Builds the object from hash
99
+ # @param [Hash] attributes Model attributes in the form of hash
100
+ # @return [Object] Returns the model itself
101
+ def self.build_from_hash(attributes)
102
+ new.build_from_hash(attributes)
103
+ end
104
+
105
+ # Builds the object from hash
106
+ # @param [Hash] attributes Model attributes in the form of hash
107
+ # @return [Object] Returns the model itself
108
+ def build_from_hash(attributes)
109
+ return nil unless attributes.is_a?(Hash)
110
+ attributes = attributes.transform_keys(&:to_sym)
111
+ self.class.openapi_types.each_pair do |key, type|
112
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
113
+ self.send("#{key}=", nil)
114
+ elsif type =~ /\AArray<(.*)>/i
115
+ # check to ensure the input is an array given that the attribute
116
+ # is documented as an array but the input is not
117
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
118
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
119
+ end
120
+ elsif !attributes[self.class.attribute_map[key]].nil?
121
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
122
+ end
123
+ end
124
+
125
+ self
126
+ end
127
+
128
+ # Deserializes the data based on type
129
+ # @param string type Data type
130
+ # @param string value Value to be deserialized
131
+ # @return [Object] Deserialized data
132
+ def _deserialize(type, value)
133
+ case type.to_sym
134
+ when :Time
135
+ Time.parse(value)
136
+ when :Date
137
+ Date.parse(value)
138
+ when :String
139
+ value.to_s
140
+ when :Integer
141
+ value.to_i
142
+ when :Float
143
+ value.to_f
144
+ when :Boolean
145
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
146
+ true
147
+ else
148
+ false
149
+ end
150
+ when :Object
151
+ # generic object (usually a Hash), return directly
152
+ value
153
+ when /\AArray<(?<inner_type>.+)>\z/
154
+ inner_type = Regexp.last_match[:inner_type]
155
+ value.map { |v| _deserialize(inner_type, v) }
156
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
157
+ k_type = Regexp.last_match[:k_type]
158
+ v_type = Regexp.last_match[:v_type]
159
+ {}.tap do |hash|
160
+ value.each do |k, v|
161
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
162
+ end
163
+ end
164
+ else # model
165
+ # models (e.g. Pet) or oneOf
166
+ klass = Akeyless.const_get(type)
167
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
168
+ end
169
+ end
170
+
171
+ # Returns the string representation of the object
172
+ # @return [String] String presentation of the object
173
+ def to_s
174
+ to_hash.to_s
175
+ end
176
+
177
+ # to_body is an alias to to_hash (backward compatibility)
178
+ # @return [Hash] Returns the object in the form of hash
179
+ def to_body
180
+ to_hash
181
+ end
182
+
183
+ # Returns the object in the form of hash
184
+ # @return [Hash] Returns the object in the form of hash
185
+ def to_hash
186
+ hash = {}
187
+ self.class.attribute_map.each_pair do |attr, param|
188
+ value = self.send(attr)
189
+ if value.nil?
190
+ is_nullable = self.class.openapi_nullable.include?(attr)
191
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
192
+ end
193
+
194
+ hash[param] = _to_hash(value)
195
+ end
196
+ hash
197
+ end
198
+
199
+ # Outputs non-array value in the form of hash
200
+ # For object, use to_hash. Otherwise, just return the value
201
+ # @param [Object] value Any valid value
202
+ # @return [Hash] Returns the value in the form of hash
203
+ def _to_hash(value)
204
+ if value.is_a?(Array)
205
+ value.compact.map { |v| _to_hash(v) }
206
+ elsif value.is_a?(Hash)
207
+ {}.tap do |hash|
208
+ value.each { |k, v| hash[k] = _to_hash(v) }
209
+ end
210
+ elsif value.respond_to? :to_hash
211
+ value.to_hash
212
+ else
213
+ value
214
+ end
215
+ end
216
+
217
+ end
218
+
219
+ end