akeyless 3.1.0 → 3.1.1

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 (35) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +13 -1
  3. data/docs/CreateCertificate.md +38 -0
  4. data/docs/CreateCertificateOutput.md +18 -0
  5. data/docs/GatewayUpdateTlsCert.md +26 -0
  6. data/docs/GatewayUpdateTlsCertOutput.md +18 -0
  7. data/docs/GetCertificateValue.md +26 -0
  8. data/docs/GetCertificateValueOutput.md +20 -0
  9. data/docs/ListSRABastions.md +2 -0
  10. data/docs/RotateKey.md +2 -0
  11. data/docs/UpdateCertificateOutput.md +18 -0
  12. data/docs/UpdateCertificateValue.md +32 -0
  13. data/docs/V2Api.md +252 -0
  14. data/lib/akeyless/api/v2_api.rb +256 -0
  15. data/lib/akeyless/models/create_certificate.rb +329 -0
  16. data/lib/akeyless/models/create_certificate_output.rb +219 -0
  17. data/lib/akeyless/models/gateway_update_tls_cert.rb +261 -0
  18. data/lib/akeyless/models/gateway_update_tls_cert_output.rb +219 -0
  19. data/lib/akeyless/models/get_certificate_value.rb +265 -0
  20. data/lib/akeyless/models/get_certificate_value_output.rb +228 -0
  21. data/lib/akeyless/models/list_sra_bastions.rb +10 -1
  22. data/lib/akeyless/models/rotate_key.rb +11 -1
  23. data/lib/akeyless/models/update_certificate_output.rb +219 -0
  24. data/lib/akeyless/models/update_certificate_value.rb +297 -0
  25. data/lib/akeyless/version.rb +1 -1
  26. data/lib/akeyless.rb +8 -0
  27. data/spec/models/create_certificate_output_spec.rb +34 -0
  28. data/spec/models/create_certificate_spec.rb +94 -0
  29. data/spec/models/gateway_update_tls_cert_output_spec.rb +34 -0
  30. data/spec/models/gateway_update_tls_cert_spec.rb +58 -0
  31. data/spec/models/get_certificate_value_output_spec.rb +40 -0
  32. data/spec/models/get_certificate_value_spec.rb +58 -0
  33. data/spec/models/update_certificate_output_spec.rb +34 -0
  34. data/spec/models/update_certificate_value_spec.rb +76 -0
  35. metadata +572 -540
@@ -1299,6 +1299,70 @@ module Akeyless
1299
1299
  return data, status_code, headers
1300
1300
  end
1301
1301
 
1302
+ # @param body [CreateCertificate]
1303
+ # @param [Hash] opts the optional parameters
1304
+ # @return [CreateCertificateOutput]
1305
+ def create_certificate(body, opts = {})
1306
+ data, _status_code, _headers = create_certificate_with_http_info(body, opts)
1307
+ data
1308
+ end
1309
+
1310
+ # @param body [CreateCertificate]
1311
+ # @param [Hash] opts the optional parameters
1312
+ # @return [Array<(CreateCertificateOutput, Integer, Hash)>] CreateCertificateOutput data, response status code and response headers
1313
+ def create_certificate_with_http_info(body, opts = {})
1314
+ if @api_client.config.debugging
1315
+ @api_client.config.logger.debug 'Calling API: V2Api.create_certificate ...'
1316
+ end
1317
+ # verify the required parameter 'body' is set
1318
+ if @api_client.config.client_side_validation && body.nil?
1319
+ fail ArgumentError, "Missing the required parameter 'body' when calling V2Api.create_certificate"
1320
+ end
1321
+ # resource path
1322
+ local_var_path = '/create-certificate'
1323
+
1324
+ # query parameters
1325
+ query_params = opts[:query_params] || {}
1326
+
1327
+ # header parameters
1328
+ header_params = opts[:header_params] || {}
1329
+ # HTTP header 'Accept' (if needed)
1330
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
1331
+ # HTTP header 'Content-Type'
1332
+ content_type = @api_client.select_header_content_type(['application/json'])
1333
+ if !content_type.nil?
1334
+ header_params['Content-Type'] = content_type
1335
+ end
1336
+
1337
+ # form parameters
1338
+ form_params = opts[:form_params] || {}
1339
+
1340
+ # http body (model)
1341
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(body)
1342
+
1343
+ # return_type
1344
+ return_type = opts[:debug_return_type] || 'CreateCertificateOutput'
1345
+
1346
+ # auth_names
1347
+ auth_names = opts[:debug_auth_names] || []
1348
+
1349
+ new_options = opts.merge(
1350
+ :operation => :"V2Api.create_certificate",
1351
+ :header_params => header_params,
1352
+ :query_params => query_params,
1353
+ :form_params => form_params,
1354
+ :body => post_body,
1355
+ :auth_names => auth_names,
1356
+ :return_type => return_type
1357
+ )
1358
+
1359
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
1360
+ if @api_client.config.debugging
1361
+ @api_client.config.logger.debug "API called: V2Api#create_certificate\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
1362
+ end
1363
+ return data, status_code, headers
1364
+ end
1365
+
1302
1366
  # @param body [CreateClassicKey]
1303
1367
  # @param [Hash] opts the optional parameters
1304
1368
  # @return [CreateClassicKeyOutput]
@@ -8711,6 +8775,70 @@ module Akeyless
8711
8775
  return data, status_code, headers
8712
8776
  end
8713
8777
 
8778
+ # @param body [GatewayUpdateTlsCert]
8779
+ # @param [Hash] opts the optional parameters
8780
+ # @return [GatewayUpdateTlsCertOutput]
8781
+ def gateway_update_tls_cert(body, opts = {})
8782
+ data, _status_code, _headers = gateway_update_tls_cert_with_http_info(body, opts)
8783
+ data
8784
+ end
8785
+
8786
+ # @param body [GatewayUpdateTlsCert]
8787
+ # @param [Hash] opts the optional parameters
8788
+ # @return [Array<(GatewayUpdateTlsCertOutput, Integer, Hash)>] GatewayUpdateTlsCertOutput data, response status code and response headers
8789
+ def gateway_update_tls_cert_with_http_info(body, opts = {})
8790
+ if @api_client.config.debugging
8791
+ @api_client.config.logger.debug 'Calling API: V2Api.gateway_update_tls_cert ...'
8792
+ end
8793
+ # verify the required parameter 'body' is set
8794
+ if @api_client.config.client_side_validation && body.nil?
8795
+ fail ArgumentError, "Missing the required parameter 'body' when calling V2Api.gateway_update_tls_cert"
8796
+ end
8797
+ # resource path
8798
+ local_var_path = '/gateway-update-tls-cert'
8799
+
8800
+ # query parameters
8801
+ query_params = opts[:query_params] || {}
8802
+
8803
+ # header parameters
8804
+ header_params = opts[:header_params] || {}
8805
+ # HTTP header 'Accept' (if needed)
8806
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
8807
+ # HTTP header 'Content-Type'
8808
+ content_type = @api_client.select_header_content_type(['application/json'])
8809
+ if !content_type.nil?
8810
+ header_params['Content-Type'] = content_type
8811
+ end
8812
+
8813
+ # form parameters
8814
+ form_params = opts[:form_params] || {}
8815
+
8816
+ # http body (model)
8817
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(body)
8818
+
8819
+ # return_type
8820
+ return_type = opts[:debug_return_type] || 'GatewayUpdateTlsCertOutput'
8821
+
8822
+ # auth_names
8823
+ auth_names = opts[:debug_auth_names] || []
8824
+
8825
+ new_options = opts.merge(
8826
+ :operation => :"V2Api.gateway_update_tls_cert",
8827
+ :header_params => header_params,
8828
+ :query_params => query_params,
8829
+ :form_params => form_params,
8830
+ :body => post_body,
8831
+ :auth_names => auth_names,
8832
+ :return_type => return_type
8833
+ )
8834
+
8835
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
8836
+ if @api_client.config.debugging
8837
+ @api_client.config.logger.debug "API called: V2Api#gateway_update_tls_cert\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
8838
+ end
8839
+ return data, status_code, headers
8840
+ end
8841
+
8714
8842
  # @param body [GatewayUpdateTmpUsers]
8715
8843
  # @param [Hash] opts the optional parameters
8716
8844
  # @return [nil]
@@ -8956,6 +9084,70 @@ module Akeyless
8956
9084
  return data, status_code, headers
8957
9085
  end
8958
9086
 
9087
+ # @param body [GetCertificateValue]
9088
+ # @param [Hash] opts the optional parameters
9089
+ # @return [GetCertificateValueOutput]
9090
+ def get_certificate_value(body, opts = {})
9091
+ data, _status_code, _headers = get_certificate_value_with_http_info(body, opts)
9092
+ data
9093
+ end
9094
+
9095
+ # @param body [GetCertificateValue]
9096
+ # @param [Hash] opts the optional parameters
9097
+ # @return [Array<(GetCertificateValueOutput, Integer, Hash)>] GetCertificateValueOutput data, response status code and response headers
9098
+ def get_certificate_value_with_http_info(body, opts = {})
9099
+ if @api_client.config.debugging
9100
+ @api_client.config.logger.debug 'Calling API: V2Api.get_certificate_value ...'
9101
+ end
9102
+ # verify the required parameter 'body' is set
9103
+ if @api_client.config.client_side_validation && body.nil?
9104
+ fail ArgumentError, "Missing the required parameter 'body' when calling V2Api.get_certificate_value"
9105
+ end
9106
+ # resource path
9107
+ local_var_path = '/get-certificate-value'
9108
+
9109
+ # query parameters
9110
+ query_params = opts[:query_params] || {}
9111
+
9112
+ # header parameters
9113
+ header_params = opts[:header_params] || {}
9114
+ # HTTP header 'Accept' (if needed)
9115
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
9116
+ # HTTP header 'Content-Type'
9117
+ content_type = @api_client.select_header_content_type(['application/json'])
9118
+ if !content_type.nil?
9119
+ header_params['Content-Type'] = content_type
9120
+ end
9121
+
9122
+ # form parameters
9123
+ form_params = opts[:form_params] || {}
9124
+
9125
+ # http body (model)
9126
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(body)
9127
+
9128
+ # return_type
9129
+ return_type = opts[:debug_return_type] || 'GetCertificateValueOutput'
9130
+
9131
+ # auth_names
9132
+ auth_names = opts[:debug_auth_names] || []
9133
+
9134
+ new_options = opts.merge(
9135
+ :operation => :"V2Api.get_certificate_value",
9136
+ :header_params => header_params,
9137
+ :query_params => query_params,
9138
+ :form_params => form_params,
9139
+ :body => post_body,
9140
+ :auth_names => auth_names,
9141
+ :return_type => return_type
9142
+ )
9143
+
9144
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
9145
+ if @api_client.config.debugging
9146
+ @api_client.config.logger.debug "API called: V2Api#get_certificate_value\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
9147
+ end
9148
+ return data, status_code, headers
9149
+ end
9150
+
8959
9151
  # @param body [GetDynamicSecretValue]
8960
9152
  # @param [Hash] opts the optional parameters
8961
9153
  # @return [Hash<String, String>]
@@ -13433,6 +13625,70 @@ module Akeyless
13433
13625
  return data, status_code, headers
13434
13626
  end
13435
13627
 
13628
+ # @param body [UpdateCertificateValue]
13629
+ # @param [Hash] opts the optional parameters
13630
+ # @return [UpdateCertificateOutput]
13631
+ def update_certificate_value(body, opts = {})
13632
+ data, _status_code, _headers = update_certificate_value_with_http_info(body, opts)
13633
+ data
13634
+ end
13635
+
13636
+ # @param body [UpdateCertificateValue]
13637
+ # @param [Hash] opts the optional parameters
13638
+ # @return [Array<(UpdateCertificateOutput, Integer, Hash)>] UpdateCertificateOutput data, response status code and response headers
13639
+ def update_certificate_value_with_http_info(body, opts = {})
13640
+ if @api_client.config.debugging
13641
+ @api_client.config.logger.debug 'Calling API: V2Api.update_certificate_value ...'
13642
+ end
13643
+ # verify the required parameter 'body' is set
13644
+ if @api_client.config.client_side_validation && body.nil?
13645
+ fail ArgumentError, "Missing the required parameter 'body' when calling V2Api.update_certificate_value"
13646
+ end
13647
+ # resource path
13648
+ local_var_path = '/update-certificate-value'
13649
+
13650
+ # query parameters
13651
+ query_params = opts[:query_params] || {}
13652
+
13653
+ # header parameters
13654
+ header_params = opts[:header_params] || {}
13655
+ # HTTP header 'Accept' (if needed)
13656
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
13657
+ # HTTP header 'Content-Type'
13658
+ content_type = @api_client.select_header_content_type(['application/json'])
13659
+ if !content_type.nil?
13660
+ header_params['Content-Type'] = content_type
13661
+ end
13662
+
13663
+ # form parameters
13664
+ form_params = opts[:form_params] || {}
13665
+
13666
+ # http body (model)
13667
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(body)
13668
+
13669
+ # return_type
13670
+ return_type = opts[:debug_return_type] || 'UpdateCertificateOutput'
13671
+
13672
+ # auth_names
13673
+ auth_names = opts[:debug_auth_names] || []
13674
+
13675
+ new_options = opts.merge(
13676
+ :operation => :"V2Api.update_certificate_value",
13677
+ :header_params => header_params,
13678
+ :query_params => query_params,
13679
+ :form_params => form_params,
13680
+ :body => post_body,
13681
+ :auth_names => auth_names,
13682
+ :return_type => return_type
13683
+ )
13684
+
13685
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
13686
+ if @api_client.config.debugging
13687
+ @api_client.config.logger.debug "API called: V2Api#update_certificate_value\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
13688
+ end
13689
+ return data, status_code, headers
13690
+ end
13691
+
13436
13692
  # @param body [UpdateDBTarget]
13437
13693
  # @param [Hash] opts the optional parameters
13438
13694
  # @return [UpdateDBTargetOutput]
@@ -0,0 +1,329 @@
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 CreateCertificate
18
+ # Content of the certificate PEM in a Base64 format.
19
+ attr_accessor :certificate_data
20
+
21
+ # Protection from accidental deletion of this item
22
+ attr_accessor :delete_protection
23
+
24
+ # How many days before the expiration of the certificate would you like to be notified.
25
+ attr_accessor :expiration_event_in
26
+
27
+ # Set output format to JSON
28
+ attr_accessor :json
29
+
30
+ # The name of a key to use to encrypt the certificate's key (if empty, the account default protectionKey key will be used)
31
+ attr_accessor :key
32
+
33
+ # Content of the certificate's private key PEM in a Base64 format.
34
+ attr_accessor :key_data
35
+
36
+ # Metadata about the certificate
37
+ attr_accessor :metadata
38
+
39
+ # Certificate name
40
+ attr_accessor :name
41
+
42
+ # List of the tags attached to this certificate
43
+ attr_accessor :tags
44
+
45
+ # Authentication token (see `/auth` and `/configure`)
46
+ attr_accessor :token
47
+
48
+ # The universal identity token, Required only for universal_identity authentication
49
+ attr_accessor :uid_token
50
+
51
+ # Attribute mapping from ruby-style variable name to JSON key.
52
+ def self.attribute_map
53
+ {
54
+ :'certificate_data' => :'certificate-data',
55
+ :'delete_protection' => :'delete_protection',
56
+ :'expiration_event_in' => :'expiration-event-in',
57
+ :'json' => :'json',
58
+ :'key' => :'key',
59
+ :'key_data' => :'key-data',
60
+ :'metadata' => :'metadata',
61
+ :'name' => :'name',
62
+ :'tags' => :'tags',
63
+ :'token' => :'token',
64
+ :'uid_token' => :'uid-token'
65
+ }
66
+ end
67
+
68
+ # Returns all the JSON keys this model knows about
69
+ def self.acceptable_attributes
70
+ attribute_map.values
71
+ end
72
+
73
+ # Attribute type mapping.
74
+ def self.openapi_types
75
+ {
76
+ :'certificate_data' => :'String',
77
+ :'delete_protection' => :'String',
78
+ :'expiration_event_in' => :'Array<String>',
79
+ :'json' => :'Boolean',
80
+ :'key' => :'String',
81
+ :'key_data' => :'String',
82
+ :'metadata' => :'String',
83
+ :'name' => :'String',
84
+ :'tags' => :'Array<String>',
85
+ :'token' => :'String',
86
+ :'uid_token' => :'String'
87
+ }
88
+ end
89
+
90
+ # List of attributes with nullable: true
91
+ def self.openapi_nullable
92
+ Set.new([
93
+ ])
94
+ end
95
+
96
+ # Initializes the object
97
+ # @param [Hash] attributes Model attributes in the form of hash
98
+ def initialize(attributes = {})
99
+ if (!attributes.is_a?(Hash))
100
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Akeyless::CreateCertificate` initialize method"
101
+ end
102
+
103
+ # check to see if the attribute exists and convert string to symbol for hash key
104
+ attributes = attributes.each_with_object({}) { |(k, v), h|
105
+ if (!self.class.attribute_map.key?(k.to_sym))
106
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Akeyless::CreateCertificate`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
107
+ end
108
+ h[k.to_sym] = v
109
+ }
110
+
111
+ if attributes.key?(:'certificate_data')
112
+ self.certificate_data = attributes[:'certificate_data']
113
+ end
114
+
115
+ if attributes.key?(:'delete_protection')
116
+ self.delete_protection = attributes[:'delete_protection']
117
+ end
118
+
119
+ if attributes.key?(:'expiration_event_in')
120
+ if (value = attributes[:'expiration_event_in']).is_a?(Array)
121
+ self.expiration_event_in = value
122
+ end
123
+ end
124
+
125
+ if attributes.key?(:'json')
126
+ self.json = attributes[:'json']
127
+ end
128
+
129
+ if attributes.key?(:'key')
130
+ self.key = attributes[:'key']
131
+ end
132
+
133
+ if attributes.key?(:'key_data')
134
+ self.key_data = attributes[:'key_data']
135
+ end
136
+
137
+ if attributes.key?(:'metadata')
138
+ self.metadata = attributes[:'metadata']
139
+ end
140
+
141
+ if attributes.key?(:'name')
142
+ self.name = attributes[:'name']
143
+ end
144
+
145
+ if attributes.key?(:'tags')
146
+ if (value = attributes[:'tags']).is_a?(Array)
147
+ self.tags = value
148
+ end
149
+ end
150
+
151
+ if attributes.key?(:'token')
152
+ self.token = attributes[:'token']
153
+ end
154
+
155
+ if attributes.key?(:'uid_token')
156
+ self.uid_token = attributes[:'uid_token']
157
+ end
158
+ end
159
+
160
+ # Show invalid properties with the reasons. Usually used together with valid?
161
+ # @return Array for valid properties with the reasons
162
+ def list_invalid_properties
163
+ invalid_properties = Array.new
164
+ if @name.nil?
165
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
166
+ end
167
+
168
+ invalid_properties
169
+ end
170
+
171
+ # Check to see if the all the properties in the model are valid
172
+ # @return true if the model is valid
173
+ def valid?
174
+ return false if @name.nil?
175
+ true
176
+ end
177
+
178
+ # Checks equality by comparing each attribute.
179
+ # @param [Object] Object to be compared
180
+ def ==(o)
181
+ return true if self.equal?(o)
182
+ self.class == o.class &&
183
+ certificate_data == o.certificate_data &&
184
+ delete_protection == o.delete_protection &&
185
+ expiration_event_in == o.expiration_event_in &&
186
+ json == o.json &&
187
+ key == o.key &&
188
+ key_data == o.key_data &&
189
+ metadata == o.metadata &&
190
+ name == o.name &&
191
+ tags == o.tags &&
192
+ token == o.token &&
193
+ uid_token == o.uid_token
194
+ end
195
+
196
+ # @see the `==` method
197
+ # @param [Object] Object to be compared
198
+ def eql?(o)
199
+ self == o
200
+ end
201
+
202
+ # Calculates hash code according to all attributes.
203
+ # @return [Integer] Hash code
204
+ def hash
205
+ [certificate_data, delete_protection, expiration_event_in, json, key, key_data, metadata, name, tags, token, uid_token].hash
206
+ end
207
+
208
+ # Builds the object from hash
209
+ # @param [Hash] attributes Model attributes in the form of hash
210
+ # @return [Object] Returns the model itself
211
+ def self.build_from_hash(attributes)
212
+ new.build_from_hash(attributes)
213
+ end
214
+
215
+ # Builds the object from hash
216
+ # @param [Hash] attributes Model attributes in the form of hash
217
+ # @return [Object] Returns the model itself
218
+ def build_from_hash(attributes)
219
+ return nil unless attributes.is_a?(Hash)
220
+ attributes = attributes.transform_keys(&:to_sym)
221
+ self.class.openapi_types.each_pair do |key, type|
222
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
223
+ self.send("#{key}=", nil)
224
+ elsif type =~ /\AArray<(.*)>/i
225
+ # check to ensure the input is an array given that the attribute
226
+ # is documented as an array but the input is not
227
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
228
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
229
+ end
230
+ elsif !attributes[self.class.attribute_map[key]].nil?
231
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
232
+ end
233
+ end
234
+
235
+ self
236
+ end
237
+
238
+ # Deserializes the data based on type
239
+ # @param string type Data type
240
+ # @param string value Value to be deserialized
241
+ # @return [Object] Deserialized data
242
+ def _deserialize(type, value)
243
+ case type.to_sym
244
+ when :Time
245
+ Time.parse(value)
246
+ when :Date
247
+ Date.parse(value)
248
+ when :String
249
+ value.to_s
250
+ when :Integer
251
+ value.to_i
252
+ when :Float
253
+ value.to_f
254
+ when :Boolean
255
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
256
+ true
257
+ else
258
+ false
259
+ end
260
+ when :Object
261
+ # generic object (usually a Hash), return directly
262
+ value
263
+ when /\AArray<(?<inner_type>.+)>\z/
264
+ inner_type = Regexp.last_match[:inner_type]
265
+ value.map { |v| _deserialize(inner_type, v) }
266
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
267
+ k_type = Regexp.last_match[:k_type]
268
+ v_type = Regexp.last_match[:v_type]
269
+ {}.tap do |hash|
270
+ value.each do |k, v|
271
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
272
+ end
273
+ end
274
+ else # model
275
+ # models (e.g. Pet) or oneOf
276
+ klass = Akeyless.const_get(type)
277
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
278
+ end
279
+ end
280
+
281
+ # Returns the string representation of the object
282
+ # @return [String] String presentation of the object
283
+ def to_s
284
+ to_hash.to_s
285
+ end
286
+
287
+ # to_body is an alias to to_hash (backward compatibility)
288
+ # @return [Hash] Returns the object in the form of hash
289
+ def to_body
290
+ to_hash
291
+ end
292
+
293
+ # Returns the object in the form of hash
294
+ # @return [Hash] Returns the object in the form of hash
295
+ def to_hash
296
+ hash = {}
297
+ self.class.attribute_map.each_pair do |attr, param|
298
+ value = self.send(attr)
299
+ if value.nil?
300
+ is_nullable = self.class.openapi_nullable.include?(attr)
301
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
302
+ end
303
+
304
+ hash[param] = _to_hash(value)
305
+ end
306
+ hash
307
+ end
308
+
309
+ # Outputs non-array value in the form of hash
310
+ # For object, use to_hash. Otherwise, just return the value
311
+ # @param [Object] value Any valid value
312
+ # @return [Hash] Returns the value in the form of hash
313
+ def _to_hash(value)
314
+ if value.is_a?(Array)
315
+ value.compact.map { |v| _to_hash(v) }
316
+ elsif value.is_a?(Hash)
317
+ {}.tap do |hash|
318
+ value.each { |k, v| hash[k] = _to_hash(v) }
319
+ end
320
+ elsif value.respond_to? :to_hash
321
+ value.to_hash
322
+ else
323
+ value
324
+ end
325
+ end
326
+
327
+ end
328
+
329
+ end