ibm_cloud_iam 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +9 -0
- data/README.md +131 -0
- data/Rakefile +10 -0
- data/docs/ApiKey.md +43 -0
- data/docs/ApiKeyInsideCreateServiceIdRequest.md +23 -0
- data/docs/ApiKeyList.md +29 -0
- data/docs/CreateApiKeyRequest.md +27 -0
- data/docs/CreateServiceIdRequest.md +25 -0
- data/docs/EnityHistoryRecord.md +27 -0
- data/docs/Error.md +23 -0
- data/docs/ExceptionResponse.md +23 -0
- data/docs/ExceptionResponseContext.md +39 -0
- data/docs/IdentityOperationsApi.md +828 -0
- data/docs/InlineObject.md +19 -0
- data/docs/InlineObject1.md +23 -0
- data/docs/InlineObject2.md +21 -0
- data/docs/InlineObject3.md +25 -0
- data/docs/MFARequirementsResponse.md +21 -0
- data/docs/OidcExceptionResponse.md +25 -0
- data/docs/ResponseContext.md +37 -0
- data/docs/ServiceId.md +43 -0
- data/docs/ServiceIdList.md +29 -0
- data/docs/TokenOperationsApi.md +226 -0
- data/docs/TokenResponse.md +27 -0
- data/docs/UpdateApiKeyRequest.md +19 -0
- data/docs/UpdateServiceIdRequest.md +21 -0
- data/git_push.sh +58 -0
- data/ibm_cloud_iam-1.0.0.gem +0 -0
- data/ibm_cloud_iam.gemspec +38 -0
- data/lib/ibm_cloud_iam.rb +62 -0
- data/lib/ibm_cloud_iam/api/identity_operations_api.rb +1083 -0
- data/lib/ibm_cloud_iam/api/token_operations_api.rb +351 -0
- data/lib/ibm_cloud_iam/api_client.rb +387 -0
- data/lib/ibm_cloud_iam/api_error.rb +57 -0
- data/lib/ibm_cloud_iam/configuration.rb +241 -0
- data/lib/ibm_cloud_iam/models/api_key.rb +381 -0
- data/lib/ibm_cloud_iam/models/api_key_inside_create_service_id_request.rb +245 -0
- data/lib/ibm_cloud_iam/models/api_key_list.rb +276 -0
- data/lib/ibm_cloud_iam/models/create_api_key_request.rb +270 -0
- data/lib/ibm_cloud_iam/models/create_service_id_request.rb +261 -0
- data/lib/ibm_cloud_iam/models/enity_history_record.rb +292 -0
- data/lib/ibm_cloud_iam/models/error.rb +255 -0
- data/lib/ibm_cloud_iam/models/exception_response.rb +251 -0
- data/lib/ibm_cloud_iam/models/exception_response_context.rb +320 -0
- data/lib/ibm_cloud_iam/models/inline_object.rb +229 -0
- data/lib/ibm_cloud_iam/models/inline_object1.rb +254 -0
- data/lib/ibm_cloud_iam/models/inline_object2.rb +244 -0
- data/lib/ibm_cloud_iam/models/inline_object3.rb +269 -0
- data/lib/ibm_cloud_iam/models/mfa_requirements_response.rb +245 -0
- data/lib/ibm_cloud_iam/models/oidc_exception_response.rb +258 -0
- data/lib/ibm_cloud_iam/models/response_context.rb +310 -0
- data/lib/ibm_cloud_iam/models/service_id.rb +377 -0
- data/lib/ibm_cloud_iam/models/service_id_list.rb +276 -0
- data/lib/ibm_cloud_iam/models/token_response.rb +260 -0
- data/lib/ibm_cloud_iam/models/update_api_key_request.rb +220 -0
- data/lib/ibm_cloud_iam/models/update_service_id_request.rb +232 -0
- data/lib/ibm_cloud_iam/version.rb +15 -0
- data/spec/api/identity_operations_api_spec.rb +253 -0
- data/spec/api/token_operations_api_spec.rb +94 -0
- data/spec/api_client_spec.rb +226 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/models/api_key_inside_create_service_id_request_spec.rb +59 -0
- data/spec/models/api_key_list_spec.rb +77 -0
- data/spec/models/api_key_spec.rb +119 -0
- data/spec/models/create_api_key_request_spec.rb +71 -0
- data/spec/models/create_service_id_request_spec.rb +65 -0
- data/spec/models/enity_history_record_spec.rb +71 -0
- data/spec/models/error_spec.rb +59 -0
- data/spec/models/exception_response_context_spec.rb +107 -0
- data/spec/models/exception_response_spec.rb +59 -0
- data/spec/models/inline_object1_spec.rb +59 -0
- data/spec/models/inline_object2_spec.rb +53 -0
- data/spec/models/inline_object3_spec.rb +65 -0
- data/spec/models/inline_object_spec.rb +47 -0
- data/spec/models/mfa_requirements_response_spec.rb +53 -0
- data/spec/models/oidc_exception_response_spec.rb +65 -0
- data/spec/models/response_context_spec.rb +101 -0
- data/spec/models/service_id_list_spec.rb +77 -0
- data/spec/models/service_id_spec.rb +119 -0
- data/spec/models/token_response_spec.rb +71 -0
- data/spec/models/update_api_key_request_spec.rb +47 -0
- data/spec/models/update_service_id_request_spec.rb +53 -0
- data/spec/spec_helper.rb +111 -0
- metadata +192 -0
@@ -0,0 +1,245 @@
|
|
1
|
+
=begin
|
2
|
+
#IAM Identity Services API
|
3
|
+
|
4
|
+
#The IAM Identity Service API allows for the management of Identities (Service IDs, ApiKeys).
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 5.0.0-beta2
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module IbmCloudIam
|
16
|
+
# Parameters for the API key in the Create service Id V1 REST request.
|
17
|
+
class ApiKeyInsideCreateServiceIdRequest
|
18
|
+
# Name of the API key. The name is not checked for uniqueness. Therefore multiple names with the same value can exist. Access is done via the UUID of the API key.
|
19
|
+
attr_accessor :name
|
20
|
+
|
21
|
+
# The optional description of the API key. The 'description' property is only available if a description was provided during a create of an API key.
|
22
|
+
attr_accessor :description
|
23
|
+
|
24
|
+
# You can optionally passthrough the API key value for this API key. If passed, NO validation of that apiKey value is done, i.e. the value can be non-URL safe. If omitted, the API key management will create an URL safe opaque API key value. The value of the API key is checked for uniqueness. Please ensure enough variations when passing in this value.
|
25
|
+
attr_accessor :apikey
|
26
|
+
|
27
|
+
# Send true or false to set whether the API key value is retrievable in the future by using the Get details of an API key request. If you create an API key for a user, you must specify `false` or omit the value. We don't allow storing of API keys for users.
|
28
|
+
attr_accessor :store_value
|
29
|
+
|
30
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
31
|
+
def self.attribute_map
|
32
|
+
{
|
33
|
+
:'name' => :'name',
|
34
|
+
:'description' => :'description',
|
35
|
+
:'apikey' => :'apikey',
|
36
|
+
:'store_value' => :'store_value'
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
# Attribute type mapping.
|
41
|
+
def self.openapi_types
|
42
|
+
{
|
43
|
+
:'name' => :'String',
|
44
|
+
:'description' => :'String',
|
45
|
+
:'apikey' => :'String',
|
46
|
+
:'store_value' => :'Boolean'
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
# List of attributes with nullable: true
|
51
|
+
def self.openapi_nullable
|
52
|
+
Set.new([
|
53
|
+
])
|
54
|
+
end
|
55
|
+
|
56
|
+
# Initializes the object
|
57
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
58
|
+
def initialize(attributes = {})
|
59
|
+
if (!attributes.is_a?(Hash))
|
60
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `IbmCloudIam::ApiKeyInsideCreateServiceIdRequest` initialize method"
|
61
|
+
end
|
62
|
+
|
63
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
64
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
65
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
66
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `IbmCloudIam::ApiKeyInsideCreateServiceIdRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
67
|
+
end
|
68
|
+
h[k.to_sym] = v
|
69
|
+
}
|
70
|
+
|
71
|
+
if attributes.key?(:'name')
|
72
|
+
self.name = attributes[:'name']
|
73
|
+
end
|
74
|
+
|
75
|
+
if attributes.key?(:'description')
|
76
|
+
self.description = attributes[:'description']
|
77
|
+
end
|
78
|
+
|
79
|
+
if attributes.key?(:'apikey')
|
80
|
+
self.apikey = attributes[:'apikey']
|
81
|
+
end
|
82
|
+
|
83
|
+
if attributes.key?(:'store_value')
|
84
|
+
self.store_value = attributes[:'store_value']
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
89
|
+
# @return Array for valid properties with the reasons
|
90
|
+
def list_invalid_properties
|
91
|
+
invalid_properties = Array.new
|
92
|
+
if @name.nil?
|
93
|
+
invalid_properties.push('invalid value for "name", name cannot be nil.')
|
94
|
+
end
|
95
|
+
|
96
|
+
invalid_properties
|
97
|
+
end
|
98
|
+
|
99
|
+
# Check to see if the all the properties in the model are valid
|
100
|
+
# @return true if the model is valid
|
101
|
+
def valid?
|
102
|
+
return false if @name.nil?
|
103
|
+
true
|
104
|
+
end
|
105
|
+
|
106
|
+
# Checks equality by comparing each attribute.
|
107
|
+
# @param [Object] Object to be compared
|
108
|
+
def ==(o)
|
109
|
+
return true if self.equal?(o)
|
110
|
+
self.class == o.class &&
|
111
|
+
name == o.name &&
|
112
|
+
description == o.description &&
|
113
|
+
apikey == o.apikey &&
|
114
|
+
store_value == o.store_value
|
115
|
+
end
|
116
|
+
|
117
|
+
# @see the `==` method
|
118
|
+
# @param [Object] Object to be compared
|
119
|
+
def eql?(o)
|
120
|
+
self == o
|
121
|
+
end
|
122
|
+
|
123
|
+
# Calculates hash code according to all attributes.
|
124
|
+
# @return [Integer] Hash code
|
125
|
+
def hash
|
126
|
+
[name, description, apikey, store_value].hash
|
127
|
+
end
|
128
|
+
|
129
|
+
# Builds the object from hash
|
130
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
131
|
+
# @return [Object] Returns the model itself
|
132
|
+
def self.build_from_hash(attributes)
|
133
|
+
new.build_from_hash(attributes)
|
134
|
+
end
|
135
|
+
|
136
|
+
# Builds the object from hash
|
137
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
138
|
+
# @return [Object] Returns the model itself
|
139
|
+
def build_from_hash(attributes)
|
140
|
+
return nil unless attributes.is_a?(Hash)
|
141
|
+
self.class.openapi_types.each_pair do |key, type|
|
142
|
+
if type =~ /\AArray<(.*)>/i
|
143
|
+
# check to ensure the input is an array given that the attribute
|
144
|
+
# is documented as an array but the input is not
|
145
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
146
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
147
|
+
end
|
148
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
149
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
150
|
+
elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
151
|
+
self.send("#{key}=", nil)
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
self
|
156
|
+
end
|
157
|
+
|
158
|
+
# Deserializes the data based on type
|
159
|
+
# @param string type Data type
|
160
|
+
# @param string value Value to be deserialized
|
161
|
+
# @return [Object] Deserialized data
|
162
|
+
def _deserialize(type, value)
|
163
|
+
case type.to_sym
|
164
|
+
when :DateTime
|
165
|
+
DateTime.parse(value)
|
166
|
+
when :Date
|
167
|
+
Date.parse(value)
|
168
|
+
when :String
|
169
|
+
value.to_s
|
170
|
+
when :Integer
|
171
|
+
value.to_i
|
172
|
+
when :Float
|
173
|
+
value.to_f
|
174
|
+
when :Boolean
|
175
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
176
|
+
true
|
177
|
+
else
|
178
|
+
false
|
179
|
+
end
|
180
|
+
when :Object
|
181
|
+
# generic object (usually a Hash), return directly
|
182
|
+
value
|
183
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
184
|
+
inner_type = Regexp.last_match[:inner_type]
|
185
|
+
value.map { |v| _deserialize(inner_type, v) }
|
186
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
187
|
+
k_type = Regexp.last_match[:k_type]
|
188
|
+
v_type = Regexp.last_match[:v_type]
|
189
|
+
{}.tap do |hash|
|
190
|
+
value.each do |k, v|
|
191
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
192
|
+
end
|
193
|
+
end
|
194
|
+
else # model
|
195
|
+
IbmCloudIam.const_get(type).build_from_hash(value)
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
# Returns the string representation of the object
|
200
|
+
# @return [String] String presentation of the object
|
201
|
+
def to_s
|
202
|
+
to_hash.to_s
|
203
|
+
end
|
204
|
+
|
205
|
+
# to_body is an alias to to_hash (backward compatibility)
|
206
|
+
# @return [Hash] Returns the object in the form of hash
|
207
|
+
def to_body
|
208
|
+
to_hash
|
209
|
+
end
|
210
|
+
|
211
|
+
# Returns the object in the form of hash
|
212
|
+
# @return [Hash] Returns the object in the form of hash
|
213
|
+
def to_hash
|
214
|
+
hash = {}
|
215
|
+
self.class.attribute_map.each_pair do |attr, param|
|
216
|
+
value = self.send(attr)
|
217
|
+
if value.nil?
|
218
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
219
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
220
|
+
end
|
221
|
+
|
222
|
+
hash[param] = _to_hash(value)
|
223
|
+
end
|
224
|
+
hash
|
225
|
+
end
|
226
|
+
|
227
|
+
# Outputs non-array value in the form of hash
|
228
|
+
# For object, use to_hash. Otherwise, just return the value
|
229
|
+
# @param [Object] value Any valid value
|
230
|
+
# @return [Hash] Returns the value in the form of hash
|
231
|
+
def _to_hash(value)
|
232
|
+
if value.is_a?(Array)
|
233
|
+
value.compact.map { |v| _to_hash(v) }
|
234
|
+
elsif value.is_a?(Hash)
|
235
|
+
{}.tap do |hash|
|
236
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
237
|
+
end
|
238
|
+
elsif value.respond_to? :to_hash
|
239
|
+
value.to_hash
|
240
|
+
else
|
241
|
+
value
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|
245
|
+
end
|
@@ -0,0 +1,276 @@
|
|
1
|
+
=begin
|
2
|
+
#IAM Identity Services API
|
3
|
+
|
4
|
+
#The IAM Identity Service API allows for the management of Identities (Service IDs, ApiKeys).
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 5.0.0-beta2
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module IbmCloudIam
|
16
|
+
# Response body format for the List API keys V1 REST request
|
17
|
+
class ApiKeyList
|
18
|
+
attr_accessor :context
|
19
|
+
|
20
|
+
# The offset of the current page.
|
21
|
+
attr_accessor :offset
|
22
|
+
|
23
|
+
# Optional size of a single page. Default is 20 items per page. Valid range is 1 to 100
|
24
|
+
attr_accessor :limit
|
25
|
+
|
26
|
+
# Link to the first page.
|
27
|
+
attr_accessor :first
|
28
|
+
|
29
|
+
# Link to the previous available page. If 'previous' property is not part of the response no previous page is available.
|
30
|
+
attr_accessor :previous
|
31
|
+
|
32
|
+
# Link to the next available page. If 'next' property is not part of the response no next page is available.
|
33
|
+
attr_accessor :_next
|
34
|
+
|
35
|
+
# List of API keys based on the query paramters and the page size. The apikeys array is always part of the response but might be empty depending on the query parameters values provided.
|
36
|
+
attr_accessor :apikeys
|
37
|
+
|
38
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
39
|
+
def self.attribute_map
|
40
|
+
{
|
41
|
+
:'context' => :'context',
|
42
|
+
:'offset' => :'offset',
|
43
|
+
:'limit' => :'limit',
|
44
|
+
:'first' => :'first',
|
45
|
+
:'previous' => :'previous',
|
46
|
+
:'_next' => :'next',
|
47
|
+
:'apikeys' => :'apikeys'
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
# Attribute type mapping.
|
52
|
+
def self.openapi_types
|
53
|
+
{
|
54
|
+
:'context' => :'ResponseContext',
|
55
|
+
:'offset' => :'Integer',
|
56
|
+
:'limit' => :'Integer',
|
57
|
+
:'first' => :'String',
|
58
|
+
:'previous' => :'String',
|
59
|
+
:'_next' => :'String',
|
60
|
+
:'apikeys' => :'Array<ApiKey>'
|
61
|
+
}
|
62
|
+
end
|
63
|
+
|
64
|
+
# List of attributes with nullable: true
|
65
|
+
def self.openapi_nullable
|
66
|
+
Set.new([
|
67
|
+
])
|
68
|
+
end
|
69
|
+
|
70
|
+
# Initializes the object
|
71
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
72
|
+
def initialize(attributes = {})
|
73
|
+
if (!attributes.is_a?(Hash))
|
74
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `IbmCloudIam::ApiKeyList` initialize method"
|
75
|
+
end
|
76
|
+
|
77
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
78
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
79
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
80
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `IbmCloudIam::ApiKeyList`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
81
|
+
end
|
82
|
+
h[k.to_sym] = v
|
83
|
+
}
|
84
|
+
|
85
|
+
if attributes.key?(:'context')
|
86
|
+
self.context = attributes[:'context']
|
87
|
+
end
|
88
|
+
|
89
|
+
if attributes.key?(:'offset')
|
90
|
+
self.offset = attributes[:'offset']
|
91
|
+
end
|
92
|
+
|
93
|
+
if attributes.key?(:'limit')
|
94
|
+
self.limit = attributes[:'limit']
|
95
|
+
end
|
96
|
+
|
97
|
+
if attributes.key?(:'first')
|
98
|
+
self.first = attributes[:'first']
|
99
|
+
end
|
100
|
+
|
101
|
+
if attributes.key?(:'previous')
|
102
|
+
self.previous = attributes[:'previous']
|
103
|
+
end
|
104
|
+
|
105
|
+
if attributes.key?(:'_next')
|
106
|
+
self._next = attributes[:'_next']
|
107
|
+
end
|
108
|
+
|
109
|
+
if attributes.key?(:'apikeys')
|
110
|
+
if (value = attributes[:'apikeys']).is_a?(Array)
|
111
|
+
self.apikeys = value
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
117
|
+
# @return Array for valid properties with the reasons
|
118
|
+
def list_invalid_properties
|
119
|
+
invalid_properties = Array.new
|
120
|
+
if @apikeys.nil?
|
121
|
+
invalid_properties.push('invalid value for "apikeys", apikeys cannot be nil.')
|
122
|
+
end
|
123
|
+
|
124
|
+
invalid_properties
|
125
|
+
end
|
126
|
+
|
127
|
+
# Check to see if the all the properties in the model are valid
|
128
|
+
# @return true if the model is valid
|
129
|
+
def valid?
|
130
|
+
return false if @apikeys.nil?
|
131
|
+
true
|
132
|
+
end
|
133
|
+
|
134
|
+
# Checks equality by comparing each attribute.
|
135
|
+
# @param [Object] Object to be compared
|
136
|
+
def ==(o)
|
137
|
+
return true if self.equal?(o)
|
138
|
+
self.class == o.class &&
|
139
|
+
context == o.context &&
|
140
|
+
offset == o.offset &&
|
141
|
+
limit == o.limit &&
|
142
|
+
first == o.first &&
|
143
|
+
previous == o.previous &&
|
144
|
+
_next == o._next &&
|
145
|
+
apikeys == o.apikeys
|
146
|
+
end
|
147
|
+
|
148
|
+
# @see the `==` method
|
149
|
+
# @param [Object] Object to be compared
|
150
|
+
def eql?(o)
|
151
|
+
self == o
|
152
|
+
end
|
153
|
+
|
154
|
+
# Calculates hash code according to all attributes.
|
155
|
+
# @return [Integer] Hash code
|
156
|
+
def hash
|
157
|
+
[context, offset, limit, first, previous, _next, apikeys].hash
|
158
|
+
end
|
159
|
+
|
160
|
+
# Builds the object from hash
|
161
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
162
|
+
# @return [Object] Returns the model itself
|
163
|
+
def self.build_from_hash(attributes)
|
164
|
+
new.build_from_hash(attributes)
|
165
|
+
end
|
166
|
+
|
167
|
+
# Builds the object from hash
|
168
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
169
|
+
# @return [Object] Returns the model itself
|
170
|
+
def build_from_hash(attributes)
|
171
|
+
return nil unless attributes.is_a?(Hash)
|
172
|
+
self.class.openapi_types.each_pair do |key, type|
|
173
|
+
if type =~ /\AArray<(.*)>/i
|
174
|
+
# check to ensure the input is an array given that the attribute
|
175
|
+
# is documented as an array but the input is not
|
176
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
177
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
178
|
+
end
|
179
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
180
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
181
|
+
elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
182
|
+
self.send("#{key}=", nil)
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
self
|
187
|
+
end
|
188
|
+
|
189
|
+
# Deserializes the data based on type
|
190
|
+
# @param string type Data type
|
191
|
+
# @param string value Value to be deserialized
|
192
|
+
# @return [Object] Deserialized data
|
193
|
+
def _deserialize(type, value)
|
194
|
+
case type.to_sym
|
195
|
+
when :DateTime
|
196
|
+
DateTime.parse(value)
|
197
|
+
when :Date
|
198
|
+
Date.parse(value)
|
199
|
+
when :String
|
200
|
+
value.to_s
|
201
|
+
when :Integer
|
202
|
+
value.to_i
|
203
|
+
when :Float
|
204
|
+
value.to_f
|
205
|
+
when :Boolean
|
206
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
207
|
+
true
|
208
|
+
else
|
209
|
+
false
|
210
|
+
end
|
211
|
+
when :Object
|
212
|
+
# generic object (usually a Hash), return directly
|
213
|
+
value
|
214
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
215
|
+
inner_type = Regexp.last_match[:inner_type]
|
216
|
+
value.map { |v| _deserialize(inner_type, v) }
|
217
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
218
|
+
k_type = Regexp.last_match[:k_type]
|
219
|
+
v_type = Regexp.last_match[:v_type]
|
220
|
+
{}.tap do |hash|
|
221
|
+
value.each do |k, v|
|
222
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
223
|
+
end
|
224
|
+
end
|
225
|
+
else # model
|
226
|
+
IbmCloudIam.const_get(type).build_from_hash(value)
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
# Returns the string representation of the object
|
231
|
+
# @return [String] String presentation of the object
|
232
|
+
def to_s
|
233
|
+
to_hash.to_s
|
234
|
+
end
|
235
|
+
|
236
|
+
# to_body is an alias to to_hash (backward compatibility)
|
237
|
+
# @return [Hash] Returns the object in the form of hash
|
238
|
+
def to_body
|
239
|
+
to_hash
|
240
|
+
end
|
241
|
+
|
242
|
+
# Returns the object in the form of hash
|
243
|
+
# @return [Hash] Returns the object in the form of hash
|
244
|
+
def to_hash
|
245
|
+
hash = {}
|
246
|
+
self.class.attribute_map.each_pair do |attr, param|
|
247
|
+
value = self.send(attr)
|
248
|
+
if value.nil?
|
249
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
250
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
251
|
+
end
|
252
|
+
|
253
|
+
hash[param] = _to_hash(value)
|
254
|
+
end
|
255
|
+
hash
|
256
|
+
end
|
257
|
+
|
258
|
+
# Outputs non-array value in the form of hash
|
259
|
+
# For object, use to_hash. Otherwise, just return the value
|
260
|
+
# @param [Object] value Any valid value
|
261
|
+
# @return [Hash] Returns the value in the form of hash
|
262
|
+
def _to_hash(value)
|
263
|
+
if value.is_a?(Array)
|
264
|
+
value.compact.map { |v| _to_hash(v) }
|
265
|
+
elsif value.is_a?(Hash)
|
266
|
+
{}.tap do |hash|
|
267
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
268
|
+
end
|
269
|
+
elsif value.respond_to? :to_hash
|
270
|
+
value.to_hash
|
271
|
+
else
|
272
|
+
value
|
273
|
+
end
|
274
|
+
end
|
275
|
+
end
|
276
|
+
end
|