akeyless 3.2.8 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +25 -1
- data/docs/CreateESM.md +36 -0
- data/docs/CreateESMOutput.md +20 -0
- data/docs/CreateRotatedSecret.md +1 -1
- data/docs/CreateSSHCertIssuer.md +1 -1
- data/docs/CreateSecret.md +1 -1
- data/docs/CreateWindowsTarget.md +8 -4
- data/docs/DSProducerDetails.md +2 -0
- data/docs/DescribeItem.md +2 -0
- data/docs/EsmCreate.md +34 -0
- data/docs/EsmCreateSecretOutput.md +20 -0
- data/docs/EsmDelete.md +26 -0
- data/docs/EsmGet.md +26 -0
- data/docs/EsmGetSecretOutput.md +20 -0
- data/docs/EsmList.md +24 -0
- data/docs/EsmListSecretsOutput.md +18 -0
- data/docs/EsmUpdate.md +34 -0
- data/docs/EsmUpdateSecretOutput.md +20 -0
- data/docs/GatewayCreateProducerHanaDb.md +1 -1
- data/docs/GatewayCreateProducerMSSQL.md +1 -1
- data/docs/GatewayCreateProducerMongo.md +1 -1
- data/docs/GatewayCreateProducerMySQL.md +1 -1
- data/docs/GatewayCreateProducerOracleDb.md +1 -1
- data/docs/GatewayCreateProducerPostgreSQL.md +1 -1
- data/docs/GatewayCreateProducerRdp.md +1 -1
- data/docs/GatewayCreateProducerRedis.md +48 -0
- data/docs/GatewayCreateProducerRedisOutput.md +18 -0
- data/docs/GatewayCreateProducerRedshift.md +1 -1
- data/docs/GatewayUpdateProducerHanaDb.md +1 -1
- data/docs/GatewayUpdateProducerMSSQL.md +1 -1
- data/docs/GatewayUpdateProducerMongo.md +1 -1
- data/docs/GatewayUpdateProducerMySQL.md +1 -1
- data/docs/GatewayUpdateProducerOracleDb.md +1 -1
- data/docs/GatewayUpdateProducerPostgreSQL.md +1 -1
- data/docs/GatewayUpdateProducerRdp.md +1 -1
- data/docs/GatewayUpdateProducerRedis.md +50 -0
- data/docs/GatewayUpdateProducerRedisOutput.md +18 -0
- data/docs/GatewayUpdateProducerRedshift.md +1 -1
- data/docs/Item.md +2 -0
- data/docs/LastStatusInfo.md +3 -1
- data/docs/SecretInfo.md +36 -0
- data/docs/TargetTypeDetailsInput.md +4 -0
- data/docs/UpdateItem.md +1 -1
- data/docs/UpdateRotatedSecret.md +1 -1
- data/docs/UpdateSSHCertIssuer.md +1 -1
- data/docs/UpdateWindowsTarget.md +8 -4
- data/docs/V2Api.md +503 -2
- data/lib/akeyless/api/v2_api.rb +501 -0
- data/lib/akeyless/models/create_esm.rb +325 -0
- data/lib/akeyless/models/create_esm_output.rb +228 -0
- data/lib/akeyless/models/create_rotated_secret.rb +1 -1
- data/lib/akeyless/models/create_secret.rb +1 -1
- data/lib/akeyless/models/create_ssh_cert_issuer.rb +1 -1
- data/lib/akeyless/models/create_windows_target.rb +40 -3
- data/lib/akeyless/models/describe_item.rb +13 -1
- data/lib/akeyless/models/ds_producer_details.rb +12 -1
- data/lib/akeyless/models/esm_create.rb +320 -0
- data/lib/akeyless/models/esm_create_secret_output.rb +228 -0
- data/lib/akeyless/models/esm_delete.rb +273 -0
- data/lib/akeyless/models/esm_get.rb +273 -0
- data/lib/akeyless/models/esm_get_secret_output.rb +228 -0
- data/lib/akeyless/models/esm_list.rb +258 -0
- data/lib/akeyless/models/esm_list_secrets_output.rb +221 -0
- data/lib/akeyless/models/esm_update.rb +320 -0
- data/lib/akeyless/models/esm_update_secret_output.rb +228 -0
- data/lib/akeyless/models/gateway_create_producer_hana_db.rb +1 -1
- data/lib/akeyless/models/gateway_create_producer_mongo.rb +1 -1
- data/lib/akeyless/models/gateway_create_producer_mssql.rb +1 -1
- data/lib/akeyless/models/gateway_create_producer_my_sql.rb +1 -1
- data/lib/akeyless/models/gateway_create_producer_oracle_db.rb +1 -1
- data/lib/akeyless/models/gateway_create_producer_postgre_sql.rb +1 -1
- data/lib/akeyless/models/gateway_create_producer_rdp.rb +1 -1
- data/lib/akeyless/models/gateway_create_producer_redis.rb +388 -0
- data/lib/akeyless/models/gateway_create_producer_redis_output.rb +219 -0
- data/lib/akeyless/models/gateway_create_producer_redshift.rb +1 -1
- data/lib/akeyless/models/gateway_update_producer_hana_db.rb +1 -1
- data/lib/akeyless/models/gateway_update_producer_mongo.rb +1 -1
- data/lib/akeyless/models/gateway_update_producer_mssql.rb +1 -1
- data/lib/akeyless/models/gateway_update_producer_my_sql.rb +1 -1
- data/lib/akeyless/models/gateway_update_producer_oracle_db.rb +1 -1
- data/lib/akeyless/models/gateway_update_producer_postgre_sql.rb +1 -1
- data/lib/akeyless/models/gateway_update_producer_rdp.rb +1 -1
- data/lib/akeyless/models/gateway_update_producer_redis.rb +398 -0
- data/lib/akeyless/models/gateway_update_producer_redis_output.rb +219 -0
- data/lib/akeyless/models/gateway_update_producer_redshift.rb +1 -1
- data/lib/akeyless/models/item.rb +10 -1
- data/lib/akeyless/models/last_status_info.rb +14 -4
- data/lib/akeyless/models/secret_info.rb +302 -0
- data/lib/akeyless/models/target_type_details_input.rb +19 -1
- data/lib/akeyless/models/update_item.rb +1 -1
- data/lib/akeyless/models/update_rotated_secret.rb +1 -1
- data/lib/akeyless/models/update_ssh_cert_issuer.rb +1 -1
- data/lib/akeyless/models/update_windows_target.rb +40 -3
- data/lib/akeyless/version.rb +1 -1
- data/lib/akeyless.rb +16 -0
- data/spec/models/create_esm_output_spec.rb +40 -0
- data/spec/models/create_esm_spec.rb +88 -0
- data/spec/models/esm_create_secret_output_spec.rb +40 -0
- data/spec/models/esm_create_spec.rb +82 -0
- data/spec/models/esm_delete_spec.rb +58 -0
- data/spec/models/esm_get_secret_output_spec.rb +40 -0
- data/spec/models/esm_get_spec.rb +58 -0
- data/spec/models/esm_list_secrets_output_spec.rb +34 -0
- data/spec/models/esm_list_spec.rb +52 -0
- data/spec/models/esm_update_secret_output_spec.rb +40 -0
- data/spec/models/esm_update_spec.rb +82 -0
- data/spec/models/gateway_create_producer_redis_output_spec.rb +34 -0
- data/spec/models/gateway_create_producer_redis_spec.rb +124 -0
- data/spec/models/gateway_update_producer_redis_output_spec.rb +34 -0
- data/spec/models/gateway_update_producer_redis_spec.rb +130 -0
- data/spec/models/secret_info_spec.rb +88 -0
- metadata +647 -583
@@ -0,0 +1,273 @@
|
|
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.5.0-SNAPSHOT
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module Akeyless
|
17
|
+
# esmGet is a command that gets the value and interal details of a secret from an External Secrets Manager
|
18
|
+
class EsmGet
|
19
|
+
# Name of the External Secrets Manager item
|
20
|
+
attr_accessor :esm_name
|
21
|
+
|
22
|
+
# Set output format to JSON
|
23
|
+
attr_accessor :json
|
24
|
+
|
25
|
+
# The secret id (or name, for AWS, Azure or K8s targets) to get from the External Secrets Manager
|
26
|
+
attr_accessor :secret_id
|
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
|
+
:'esm_name' => :'esm-name',
|
38
|
+
:'json' => :'json',
|
39
|
+
:'secret_id' => :'secret-id',
|
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
|
+
:'esm_name' => :'String',
|
54
|
+
:'json' => :'Boolean',
|
55
|
+
:'secret_id' => :'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::EsmGet` 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::EsmGet`. 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?(:'esm_name')
|
83
|
+
self.esm_name = attributes[:'esm_name']
|
84
|
+
end
|
85
|
+
|
86
|
+
if attributes.key?(:'json')
|
87
|
+
self.json = attributes[:'json']
|
88
|
+
else
|
89
|
+
self.json = false
|
90
|
+
end
|
91
|
+
|
92
|
+
if attributes.key?(:'secret_id')
|
93
|
+
self.secret_id = attributes[:'secret_id']
|
94
|
+
end
|
95
|
+
|
96
|
+
if attributes.key?(:'token')
|
97
|
+
self.token = attributes[:'token']
|
98
|
+
end
|
99
|
+
|
100
|
+
if attributes.key?(:'uid_token')
|
101
|
+
self.uid_token = attributes[:'uid_token']
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
106
|
+
# @return Array for valid properties with the reasons
|
107
|
+
def list_invalid_properties
|
108
|
+
invalid_properties = Array.new
|
109
|
+
if @esm_name.nil?
|
110
|
+
invalid_properties.push('invalid value for "esm_name", esm_name cannot be nil.')
|
111
|
+
end
|
112
|
+
|
113
|
+
if @secret_id.nil?
|
114
|
+
invalid_properties.push('invalid value for "secret_id", secret_id cannot be nil.')
|
115
|
+
end
|
116
|
+
|
117
|
+
invalid_properties
|
118
|
+
end
|
119
|
+
|
120
|
+
# Check to see if the all the properties in the model are valid
|
121
|
+
# @return true if the model is valid
|
122
|
+
def valid?
|
123
|
+
return false if @esm_name.nil?
|
124
|
+
return false if @secret_id.nil?
|
125
|
+
true
|
126
|
+
end
|
127
|
+
|
128
|
+
# Checks equality by comparing each attribute.
|
129
|
+
# @param [Object] Object to be compared
|
130
|
+
def ==(o)
|
131
|
+
return true if self.equal?(o)
|
132
|
+
self.class == o.class &&
|
133
|
+
esm_name == o.esm_name &&
|
134
|
+
json == o.json &&
|
135
|
+
secret_id == o.secret_id &&
|
136
|
+
token == o.token &&
|
137
|
+
uid_token == o.uid_token
|
138
|
+
end
|
139
|
+
|
140
|
+
# @see the `==` method
|
141
|
+
# @param [Object] Object to be compared
|
142
|
+
def eql?(o)
|
143
|
+
self == o
|
144
|
+
end
|
145
|
+
|
146
|
+
# Calculates hash code according to all attributes.
|
147
|
+
# @return [Integer] Hash code
|
148
|
+
def hash
|
149
|
+
[esm_name, json, secret_id, token, uid_token].hash
|
150
|
+
end
|
151
|
+
|
152
|
+
# Builds the object from hash
|
153
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
154
|
+
# @return [Object] Returns the model itself
|
155
|
+
def self.build_from_hash(attributes)
|
156
|
+
new.build_from_hash(attributes)
|
157
|
+
end
|
158
|
+
|
159
|
+
# Builds the object from hash
|
160
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
161
|
+
# @return [Object] Returns the model itself
|
162
|
+
def build_from_hash(attributes)
|
163
|
+
return nil unless attributes.is_a?(Hash)
|
164
|
+
attributes = attributes.transform_keys(&:to_sym)
|
165
|
+
self.class.openapi_types.each_pair do |key, type|
|
166
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
167
|
+
self.send("#{key}=", nil)
|
168
|
+
elsif type =~ /\AArray<(.*)>/i
|
169
|
+
# check to ensure the input is an array given that the attribute
|
170
|
+
# is documented as an array but the input is not
|
171
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
172
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
173
|
+
end
|
174
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
175
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
self
|
180
|
+
end
|
181
|
+
|
182
|
+
# Deserializes the data based on type
|
183
|
+
# @param string type Data type
|
184
|
+
# @param string value Value to be deserialized
|
185
|
+
# @return [Object] Deserialized data
|
186
|
+
def _deserialize(type, value)
|
187
|
+
case type.to_sym
|
188
|
+
when :Time
|
189
|
+
Time.parse(value)
|
190
|
+
when :Date
|
191
|
+
Date.parse(value)
|
192
|
+
when :String
|
193
|
+
value.to_s
|
194
|
+
when :Integer
|
195
|
+
value.to_i
|
196
|
+
when :Float
|
197
|
+
value.to_f
|
198
|
+
when :Boolean
|
199
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
200
|
+
true
|
201
|
+
else
|
202
|
+
false
|
203
|
+
end
|
204
|
+
when :Object
|
205
|
+
# generic object (usually a Hash), return directly
|
206
|
+
value
|
207
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
208
|
+
inner_type = Regexp.last_match[:inner_type]
|
209
|
+
value.map { |v| _deserialize(inner_type, v) }
|
210
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
211
|
+
k_type = Regexp.last_match[:k_type]
|
212
|
+
v_type = Regexp.last_match[:v_type]
|
213
|
+
{}.tap do |hash|
|
214
|
+
value.each do |k, v|
|
215
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
216
|
+
end
|
217
|
+
end
|
218
|
+
else # model
|
219
|
+
# models (e.g. Pet) or oneOf
|
220
|
+
klass = Akeyless.const_get(type)
|
221
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
# Returns the string representation of the object
|
226
|
+
# @return [String] String presentation of the object
|
227
|
+
def to_s
|
228
|
+
to_hash.to_s
|
229
|
+
end
|
230
|
+
|
231
|
+
# to_body is an alias to to_hash (backward compatibility)
|
232
|
+
# @return [Hash] Returns the object in the form of hash
|
233
|
+
def to_body
|
234
|
+
to_hash
|
235
|
+
end
|
236
|
+
|
237
|
+
# Returns the object in the form of hash
|
238
|
+
# @return [Hash] Returns the object in the form of hash
|
239
|
+
def to_hash
|
240
|
+
hash = {}
|
241
|
+
self.class.attribute_map.each_pair do |attr, param|
|
242
|
+
value = self.send(attr)
|
243
|
+
if value.nil?
|
244
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
245
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
246
|
+
end
|
247
|
+
|
248
|
+
hash[param] = _to_hash(value)
|
249
|
+
end
|
250
|
+
hash
|
251
|
+
end
|
252
|
+
|
253
|
+
# Outputs non-array value in the form of hash
|
254
|
+
# For object, use to_hash. Otherwise, just return the value
|
255
|
+
# @param [Object] value Any valid value
|
256
|
+
# @return [Hash] Returns the value in the form of hash
|
257
|
+
def _to_hash(value)
|
258
|
+
if value.is_a?(Array)
|
259
|
+
value.compact.map { |v| _to_hash(v) }
|
260
|
+
elsif value.is_a?(Hash)
|
261
|
+
{}.tap do |hash|
|
262
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
263
|
+
end
|
264
|
+
elsif value.respond_to? :to_hash
|
265
|
+
value.to_hash
|
266
|
+
else
|
267
|
+
value
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
end
|
272
|
+
|
273
|
+
end
|
@@ -0,0 +1,228 @@
|
|
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.5.0-SNAPSHOT
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module Akeyless
|
17
|
+
class EsmGetSecretOutput
|
18
|
+
attr_accessor :metadata
|
19
|
+
|
20
|
+
attr_accessor :value
|
21
|
+
|
22
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
23
|
+
def self.attribute_map
|
24
|
+
{
|
25
|
+
:'metadata' => :'metadata',
|
26
|
+
:'value' => :'value'
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
# Returns all the JSON keys this model knows about
|
31
|
+
def self.acceptable_attributes
|
32
|
+
attribute_map.values
|
33
|
+
end
|
34
|
+
|
35
|
+
# Attribute type mapping.
|
36
|
+
def self.openapi_types
|
37
|
+
{
|
38
|
+
:'metadata' => :'Object',
|
39
|
+
:'value' => :'String'
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
# List of attributes with nullable: true
|
44
|
+
def self.openapi_nullable
|
45
|
+
Set.new([
|
46
|
+
])
|
47
|
+
end
|
48
|
+
|
49
|
+
# Initializes the object
|
50
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
51
|
+
def initialize(attributes = {})
|
52
|
+
if (!attributes.is_a?(Hash))
|
53
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Akeyless::EsmGetSecretOutput` initialize method"
|
54
|
+
end
|
55
|
+
|
56
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
57
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
58
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
59
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Akeyless::EsmGetSecretOutput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
60
|
+
end
|
61
|
+
h[k.to_sym] = v
|
62
|
+
}
|
63
|
+
|
64
|
+
if attributes.key?(:'metadata')
|
65
|
+
self.metadata = attributes[:'metadata']
|
66
|
+
end
|
67
|
+
|
68
|
+
if attributes.key?(:'value')
|
69
|
+
self.value = attributes[:'value']
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
74
|
+
# @return Array for valid properties with the reasons
|
75
|
+
def list_invalid_properties
|
76
|
+
invalid_properties = Array.new
|
77
|
+
invalid_properties
|
78
|
+
end
|
79
|
+
|
80
|
+
# Check to see if the all the properties in the model are valid
|
81
|
+
# @return true if the model is valid
|
82
|
+
def valid?
|
83
|
+
true
|
84
|
+
end
|
85
|
+
|
86
|
+
# Checks equality by comparing each attribute.
|
87
|
+
# @param [Object] Object to be compared
|
88
|
+
def ==(o)
|
89
|
+
return true if self.equal?(o)
|
90
|
+
self.class == o.class &&
|
91
|
+
metadata == o.metadata &&
|
92
|
+
value == o.value
|
93
|
+
end
|
94
|
+
|
95
|
+
# @see the `==` method
|
96
|
+
# @param [Object] Object to be compared
|
97
|
+
def eql?(o)
|
98
|
+
self == o
|
99
|
+
end
|
100
|
+
|
101
|
+
# Calculates hash code according to all attributes.
|
102
|
+
# @return [Integer] Hash code
|
103
|
+
def hash
|
104
|
+
[metadata, value].hash
|
105
|
+
end
|
106
|
+
|
107
|
+
# Builds the object from hash
|
108
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
109
|
+
# @return [Object] Returns the model itself
|
110
|
+
def self.build_from_hash(attributes)
|
111
|
+
new.build_from_hash(attributes)
|
112
|
+
end
|
113
|
+
|
114
|
+
# Builds the object from hash
|
115
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
116
|
+
# @return [Object] Returns the model itself
|
117
|
+
def build_from_hash(attributes)
|
118
|
+
return nil unless attributes.is_a?(Hash)
|
119
|
+
attributes = attributes.transform_keys(&:to_sym)
|
120
|
+
self.class.openapi_types.each_pair do |key, type|
|
121
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
122
|
+
self.send("#{key}=", nil)
|
123
|
+
elsif type =~ /\AArray<(.*)>/i
|
124
|
+
# check to ensure the input is an array given that the attribute
|
125
|
+
# is documented as an array but the input is not
|
126
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
127
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
128
|
+
end
|
129
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
130
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
self
|
135
|
+
end
|
136
|
+
|
137
|
+
# Deserializes the data based on type
|
138
|
+
# @param string type Data type
|
139
|
+
# @param string value Value to be deserialized
|
140
|
+
# @return [Object] Deserialized data
|
141
|
+
def _deserialize(type, value)
|
142
|
+
case type.to_sym
|
143
|
+
when :Time
|
144
|
+
Time.parse(value)
|
145
|
+
when :Date
|
146
|
+
Date.parse(value)
|
147
|
+
when :String
|
148
|
+
value.to_s
|
149
|
+
when :Integer
|
150
|
+
value.to_i
|
151
|
+
when :Float
|
152
|
+
value.to_f
|
153
|
+
when :Boolean
|
154
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
155
|
+
true
|
156
|
+
else
|
157
|
+
false
|
158
|
+
end
|
159
|
+
when :Object
|
160
|
+
# generic object (usually a Hash), return directly
|
161
|
+
value
|
162
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
163
|
+
inner_type = Regexp.last_match[:inner_type]
|
164
|
+
value.map { |v| _deserialize(inner_type, v) }
|
165
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
166
|
+
k_type = Regexp.last_match[:k_type]
|
167
|
+
v_type = Regexp.last_match[:v_type]
|
168
|
+
{}.tap do |hash|
|
169
|
+
value.each do |k, v|
|
170
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
171
|
+
end
|
172
|
+
end
|
173
|
+
else # model
|
174
|
+
# models (e.g. Pet) or oneOf
|
175
|
+
klass = Akeyless.const_get(type)
|
176
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
# Returns the string representation of the object
|
181
|
+
# @return [String] String presentation of the object
|
182
|
+
def to_s
|
183
|
+
to_hash.to_s
|
184
|
+
end
|
185
|
+
|
186
|
+
# to_body is an alias to to_hash (backward compatibility)
|
187
|
+
# @return [Hash] Returns the object in the form of hash
|
188
|
+
def to_body
|
189
|
+
to_hash
|
190
|
+
end
|
191
|
+
|
192
|
+
# Returns the object in the form of hash
|
193
|
+
# @return [Hash] Returns the object in the form of hash
|
194
|
+
def to_hash
|
195
|
+
hash = {}
|
196
|
+
self.class.attribute_map.each_pair do |attr, param|
|
197
|
+
value = self.send(attr)
|
198
|
+
if value.nil?
|
199
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
200
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
201
|
+
end
|
202
|
+
|
203
|
+
hash[param] = _to_hash(value)
|
204
|
+
end
|
205
|
+
hash
|
206
|
+
end
|
207
|
+
|
208
|
+
# Outputs non-array value in the form of hash
|
209
|
+
# For object, use to_hash. Otherwise, just return the value
|
210
|
+
# @param [Object] value Any valid value
|
211
|
+
# @return [Hash] Returns the value in the form of hash
|
212
|
+
def _to_hash(value)
|
213
|
+
if value.is_a?(Array)
|
214
|
+
value.compact.map { |v| _to_hash(v) }
|
215
|
+
elsif value.is_a?(Hash)
|
216
|
+
{}.tap do |hash|
|
217
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
218
|
+
end
|
219
|
+
elsif value.respond_to? :to_hash
|
220
|
+
value.to_hash
|
221
|
+
else
|
222
|
+
value
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
end
|
227
|
+
|
228
|
+
end
|