ibm_cloud_iam 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/README.md +131 -0
  4. data/Rakefile +10 -0
  5. data/docs/ApiKey.md +43 -0
  6. data/docs/ApiKeyInsideCreateServiceIdRequest.md +23 -0
  7. data/docs/ApiKeyList.md +29 -0
  8. data/docs/CreateApiKeyRequest.md +27 -0
  9. data/docs/CreateServiceIdRequest.md +25 -0
  10. data/docs/EnityHistoryRecord.md +27 -0
  11. data/docs/Error.md +23 -0
  12. data/docs/ExceptionResponse.md +23 -0
  13. data/docs/ExceptionResponseContext.md +39 -0
  14. data/docs/IdentityOperationsApi.md +828 -0
  15. data/docs/InlineObject.md +19 -0
  16. data/docs/InlineObject1.md +23 -0
  17. data/docs/InlineObject2.md +21 -0
  18. data/docs/InlineObject3.md +25 -0
  19. data/docs/MFARequirementsResponse.md +21 -0
  20. data/docs/OidcExceptionResponse.md +25 -0
  21. data/docs/ResponseContext.md +37 -0
  22. data/docs/ServiceId.md +43 -0
  23. data/docs/ServiceIdList.md +29 -0
  24. data/docs/TokenOperationsApi.md +226 -0
  25. data/docs/TokenResponse.md +27 -0
  26. data/docs/UpdateApiKeyRequest.md +19 -0
  27. data/docs/UpdateServiceIdRequest.md +21 -0
  28. data/git_push.sh +58 -0
  29. data/ibm_cloud_iam-1.0.0.gem +0 -0
  30. data/ibm_cloud_iam.gemspec +38 -0
  31. data/lib/ibm_cloud_iam.rb +62 -0
  32. data/lib/ibm_cloud_iam/api/identity_operations_api.rb +1083 -0
  33. data/lib/ibm_cloud_iam/api/token_operations_api.rb +351 -0
  34. data/lib/ibm_cloud_iam/api_client.rb +387 -0
  35. data/lib/ibm_cloud_iam/api_error.rb +57 -0
  36. data/lib/ibm_cloud_iam/configuration.rb +241 -0
  37. data/lib/ibm_cloud_iam/models/api_key.rb +381 -0
  38. data/lib/ibm_cloud_iam/models/api_key_inside_create_service_id_request.rb +245 -0
  39. data/lib/ibm_cloud_iam/models/api_key_list.rb +276 -0
  40. data/lib/ibm_cloud_iam/models/create_api_key_request.rb +270 -0
  41. data/lib/ibm_cloud_iam/models/create_service_id_request.rb +261 -0
  42. data/lib/ibm_cloud_iam/models/enity_history_record.rb +292 -0
  43. data/lib/ibm_cloud_iam/models/error.rb +255 -0
  44. data/lib/ibm_cloud_iam/models/exception_response.rb +251 -0
  45. data/lib/ibm_cloud_iam/models/exception_response_context.rb +320 -0
  46. data/lib/ibm_cloud_iam/models/inline_object.rb +229 -0
  47. data/lib/ibm_cloud_iam/models/inline_object1.rb +254 -0
  48. data/lib/ibm_cloud_iam/models/inline_object2.rb +244 -0
  49. data/lib/ibm_cloud_iam/models/inline_object3.rb +269 -0
  50. data/lib/ibm_cloud_iam/models/mfa_requirements_response.rb +245 -0
  51. data/lib/ibm_cloud_iam/models/oidc_exception_response.rb +258 -0
  52. data/lib/ibm_cloud_iam/models/response_context.rb +310 -0
  53. data/lib/ibm_cloud_iam/models/service_id.rb +377 -0
  54. data/lib/ibm_cloud_iam/models/service_id_list.rb +276 -0
  55. data/lib/ibm_cloud_iam/models/token_response.rb +260 -0
  56. data/lib/ibm_cloud_iam/models/update_api_key_request.rb +220 -0
  57. data/lib/ibm_cloud_iam/models/update_service_id_request.rb +232 -0
  58. data/lib/ibm_cloud_iam/version.rb +15 -0
  59. data/spec/api/identity_operations_api_spec.rb +253 -0
  60. data/spec/api/token_operations_api_spec.rb +94 -0
  61. data/spec/api_client_spec.rb +226 -0
  62. data/spec/configuration_spec.rb +42 -0
  63. data/spec/models/api_key_inside_create_service_id_request_spec.rb +59 -0
  64. data/spec/models/api_key_list_spec.rb +77 -0
  65. data/spec/models/api_key_spec.rb +119 -0
  66. data/spec/models/create_api_key_request_spec.rb +71 -0
  67. data/spec/models/create_service_id_request_spec.rb +65 -0
  68. data/spec/models/enity_history_record_spec.rb +71 -0
  69. data/spec/models/error_spec.rb +59 -0
  70. data/spec/models/exception_response_context_spec.rb +107 -0
  71. data/spec/models/exception_response_spec.rb +59 -0
  72. data/spec/models/inline_object1_spec.rb +59 -0
  73. data/spec/models/inline_object2_spec.rb +53 -0
  74. data/spec/models/inline_object3_spec.rb +65 -0
  75. data/spec/models/inline_object_spec.rb +47 -0
  76. data/spec/models/mfa_requirements_response_spec.rb +53 -0
  77. data/spec/models/oidc_exception_response_spec.rb +65 -0
  78. data/spec/models/response_context_spec.rb +101 -0
  79. data/spec/models/service_id_list_spec.rb +77 -0
  80. data/spec/models/service_id_spec.rb +119 -0
  81. data/spec/models/token_response_spec.rb +71 -0
  82. data/spec/models/update_api_key_request_spec.rb +47 -0
  83. data/spec/models/update_service_id_request_spec.rb +53 -0
  84. data/spec/spec_helper.rb +111 -0
  85. metadata +192 -0
@@ -0,0 +1,310 @@
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
+ # Context with key properties for problem determination.
17
+ class ResponseContext
18
+ # The transaction ID of the inbound REST request.
19
+ attr_accessor :transaction_id
20
+
21
+ # The operation of the inbound REST request.
22
+ attr_accessor :operation
23
+
24
+ # The user agent of the inbound REST request.
25
+ attr_accessor :user_agent
26
+
27
+ # The URL of that cluster.
28
+ attr_accessor :url
29
+
30
+ # The instance ID of the server instance processing the request.
31
+ attr_accessor :instance_id
32
+
33
+ # The thread ID of the server instance processing the request.
34
+ attr_accessor :thread_id
35
+
36
+ # The host of the server instance processing the request.
37
+ attr_accessor :host
38
+
39
+ # The start time of the request.
40
+ attr_accessor :start_time
41
+
42
+ # The finish time of the request.
43
+ attr_accessor :end_time
44
+
45
+ # The elapsed time in msec.
46
+ attr_accessor :elapsed_time
47
+
48
+ # The cluster name.
49
+ attr_accessor :cluster_name
50
+
51
+ # Attribute mapping from ruby-style variable name to JSON key.
52
+ def self.attribute_map
53
+ {
54
+ :'transaction_id' => :'transaction_id',
55
+ :'operation' => :'operation',
56
+ :'user_agent' => :'user_agent',
57
+ :'url' => :'url',
58
+ :'instance_id' => :'instance_id',
59
+ :'thread_id' => :'thread_id',
60
+ :'host' => :'host',
61
+ :'start_time' => :'start_time',
62
+ :'end_time' => :'end_time',
63
+ :'elapsed_time' => :'elapsed_time',
64
+ :'cluster_name' => :'cluster_name'
65
+ }
66
+ end
67
+
68
+ # Attribute type mapping.
69
+ def self.openapi_types
70
+ {
71
+ :'transaction_id' => :'String',
72
+ :'operation' => :'String',
73
+ :'user_agent' => :'String',
74
+ :'url' => :'String',
75
+ :'instance_id' => :'String',
76
+ :'thread_id' => :'String',
77
+ :'host' => :'String',
78
+ :'start_time' => :'String',
79
+ :'end_time' => :'String',
80
+ :'elapsed_time' => :'String',
81
+ :'cluster_name' => :'String'
82
+ }
83
+ end
84
+
85
+ # List of attributes with nullable: true
86
+ def self.openapi_nullable
87
+ Set.new([
88
+ ])
89
+ end
90
+
91
+ # Initializes the object
92
+ # @param [Hash] attributes Model attributes in the form of hash
93
+ def initialize(attributes = {})
94
+ if (!attributes.is_a?(Hash))
95
+ fail ArgumentError, "The input argument (attributes) must be a hash in `IbmCloudIam::ResponseContext` initialize method"
96
+ end
97
+
98
+ # check to see if the attribute exists and convert string to symbol for hash key
99
+ attributes = attributes.each_with_object({}) { |(k, v), h|
100
+ if (!self.class.attribute_map.key?(k.to_sym))
101
+ fail ArgumentError, "`#{k}` is not a valid attribute in `IbmCloudIam::ResponseContext`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
102
+ end
103
+ h[k.to_sym] = v
104
+ }
105
+
106
+ if attributes.key?(:'transaction_id')
107
+ self.transaction_id = attributes[:'transaction_id']
108
+ end
109
+
110
+ if attributes.key?(:'operation')
111
+ self.operation = attributes[:'operation']
112
+ end
113
+
114
+ if attributes.key?(:'user_agent')
115
+ self.user_agent = attributes[:'user_agent']
116
+ end
117
+
118
+ if attributes.key?(:'url')
119
+ self.url = attributes[:'url']
120
+ end
121
+
122
+ if attributes.key?(:'instance_id')
123
+ self.instance_id = attributes[:'instance_id']
124
+ end
125
+
126
+ if attributes.key?(:'thread_id')
127
+ self.thread_id = attributes[:'thread_id']
128
+ end
129
+
130
+ if attributes.key?(:'host')
131
+ self.host = attributes[:'host']
132
+ end
133
+
134
+ if attributes.key?(:'start_time')
135
+ self.start_time = attributes[:'start_time']
136
+ end
137
+
138
+ if attributes.key?(:'end_time')
139
+ self.end_time = attributes[:'end_time']
140
+ end
141
+
142
+ if attributes.key?(:'elapsed_time')
143
+ self.elapsed_time = attributes[:'elapsed_time']
144
+ end
145
+
146
+ if attributes.key?(:'cluster_name')
147
+ self.cluster_name = attributes[:'cluster_name']
148
+ end
149
+ end
150
+
151
+ # Show invalid properties with the reasons. Usually used together with valid?
152
+ # @return Array for valid properties with the reasons
153
+ def list_invalid_properties
154
+ invalid_properties = Array.new
155
+ invalid_properties
156
+ end
157
+
158
+ # Check to see if the all the properties in the model are valid
159
+ # @return true if the model is valid
160
+ def valid?
161
+ true
162
+ end
163
+
164
+ # Checks equality by comparing each attribute.
165
+ # @param [Object] Object to be compared
166
+ def ==(o)
167
+ return true if self.equal?(o)
168
+ self.class == o.class &&
169
+ transaction_id == o.transaction_id &&
170
+ operation == o.operation &&
171
+ user_agent == o.user_agent &&
172
+ url == o.url &&
173
+ instance_id == o.instance_id &&
174
+ thread_id == o.thread_id &&
175
+ host == o.host &&
176
+ start_time == o.start_time &&
177
+ end_time == o.end_time &&
178
+ elapsed_time == o.elapsed_time &&
179
+ cluster_name == o.cluster_name
180
+ end
181
+
182
+ # @see the `==` method
183
+ # @param [Object] Object to be compared
184
+ def eql?(o)
185
+ self == o
186
+ end
187
+
188
+ # Calculates hash code according to all attributes.
189
+ # @return [Integer] Hash code
190
+ def hash
191
+ [transaction_id, operation, user_agent, url, instance_id, thread_id, host, start_time, end_time, elapsed_time, cluster_name].hash
192
+ end
193
+
194
+ # Builds the object from hash
195
+ # @param [Hash] attributes Model attributes in the form of hash
196
+ # @return [Object] Returns the model itself
197
+ def self.build_from_hash(attributes)
198
+ new.build_from_hash(attributes)
199
+ end
200
+
201
+ # Builds the object from hash
202
+ # @param [Hash] attributes Model attributes in the form of hash
203
+ # @return [Object] Returns the model itself
204
+ def build_from_hash(attributes)
205
+ return nil unless attributes.is_a?(Hash)
206
+ self.class.openapi_types.each_pair do |key, type|
207
+ if type =~ /\AArray<(.*)>/i
208
+ # check to ensure the input is an array given that the attribute
209
+ # is documented as an array but the input is not
210
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
211
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
212
+ end
213
+ elsif !attributes[self.class.attribute_map[key]].nil?
214
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
215
+ elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
216
+ self.send("#{key}=", nil)
217
+ end
218
+ end
219
+
220
+ self
221
+ end
222
+
223
+ # Deserializes the data based on type
224
+ # @param string type Data type
225
+ # @param string value Value to be deserialized
226
+ # @return [Object] Deserialized data
227
+ def _deserialize(type, value)
228
+ case type.to_sym
229
+ when :DateTime
230
+ DateTime.parse(value)
231
+ when :Date
232
+ Date.parse(value)
233
+ when :String
234
+ value.to_s
235
+ when :Integer
236
+ value.to_i
237
+ when :Float
238
+ value.to_f
239
+ when :Boolean
240
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
241
+ true
242
+ else
243
+ false
244
+ end
245
+ when :Object
246
+ # generic object (usually a Hash), return directly
247
+ value
248
+ when /\AArray<(?<inner_type>.+)>\z/
249
+ inner_type = Regexp.last_match[:inner_type]
250
+ value.map { |v| _deserialize(inner_type, v) }
251
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
252
+ k_type = Regexp.last_match[:k_type]
253
+ v_type = Regexp.last_match[:v_type]
254
+ {}.tap do |hash|
255
+ value.each do |k, v|
256
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
257
+ end
258
+ end
259
+ else # model
260
+ IbmCloudIam.const_get(type).build_from_hash(value)
261
+ end
262
+ end
263
+
264
+ # Returns the string representation of the object
265
+ # @return [String] String presentation of the object
266
+ def to_s
267
+ to_hash.to_s
268
+ end
269
+
270
+ # to_body is an alias to to_hash (backward compatibility)
271
+ # @return [Hash] Returns the object in the form of hash
272
+ def to_body
273
+ to_hash
274
+ end
275
+
276
+ # Returns the object in the form of hash
277
+ # @return [Hash] Returns the object in the form of hash
278
+ def to_hash
279
+ hash = {}
280
+ self.class.attribute_map.each_pair do |attr, param|
281
+ value = self.send(attr)
282
+ if value.nil?
283
+ is_nullable = self.class.openapi_nullable.include?(attr)
284
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
285
+ end
286
+
287
+ hash[param] = _to_hash(value)
288
+ end
289
+ hash
290
+ end
291
+
292
+ # Outputs non-array value in the form of hash
293
+ # For object, use to_hash. Otherwise, just return the value
294
+ # @param [Object] value Any valid value
295
+ # @return [Hash] Returns the value in the form of hash
296
+ def _to_hash(value)
297
+ if value.is_a?(Array)
298
+ value.compact.map { |v| _to_hash(v) }
299
+ elsif value.is_a?(Hash)
300
+ {}.tap do |hash|
301
+ value.each { |k, v| hash[k] = _to_hash(v) }
302
+ end
303
+ elsif value.respond_to? :to_hash
304
+ value.to_hash
305
+ else
306
+ value
307
+ end
308
+ end
309
+ end
310
+ end
@@ -0,0 +1,377 @@
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 service ID V1 REST requests.
17
+ class ServiceId
18
+ attr_accessor :context
19
+
20
+ # Unique identifier of this Service Id.
21
+ attr_accessor :id
22
+
23
+ # Cloud wide identifier for identities of this service ID.
24
+ attr_accessor :iam_id
25
+
26
+ # Version of the service ID details object. You need to specify this value when updating the service ID to avoid stale updates.
27
+ attr_accessor :entity_tag
28
+
29
+ # Cloud Resource Name of the item. Example Cloud Resource Name: 'crn:v1:bluemix:public:iam-identity:us-south:a/myaccount::serviceid:1234-5678-9012'
30
+ attr_accessor :crn
31
+
32
+ # The service ID cannot be changed if set to true.
33
+ attr_accessor :locked
34
+
35
+ # If set contains a date time string of the creation date in ISO format
36
+ attr_accessor :created_at
37
+
38
+ # If set contains a date time string of the last modification date in ISO format
39
+ attr_accessor :modified_at
40
+
41
+ # ID of the account the service ID belongs to.
42
+ attr_accessor :account_id
43
+
44
+ # Name of the Service Id. The name is not checked for uniqueness. Therefore multiple names with the same value can exist. Access is done via the UUID of the Service Id.
45
+ attr_accessor :name
46
+
47
+ # The optional description of the Service Id. The 'description' property is only available if a description was provided during a create of a Service Id.
48
+ attr_accessor :description
49
+
50
+ # Optional list of CRNs (string array) which point to the services connected to the service ID.
51
+ attr_accessor :unique_instance_crns
52
+
53
+ # History of the Service ID
54
+ attr_accessor :history
55
+
56
+ attr_accessor :apikey
57
+
58
+ # Attribute mapping from ruby-style variable name to JSON key.
59
+ def self.attribute_map
60
+ {
61
+ :'context' => :'context',
62
+ :'id' => :'id',
63
+ :'iam_id' => :'iam_id',
64
+ :'entity_tag' => :'entity_tag',
65
+ :'crn' => :'crn',
66
+ :'locked' => :'locked',
67
+ :'created_at' => :'created_at',
68
+ :'modified_at' => :'modified_at',
69
+ :'account_id' => :'account_id',
70
+ :'name' => :'name',
71
+ :'description' => :'description',
72
+ :'unique_instance_crns' => :'unique_instance_crns',
73
+ :'history' => :'history',
74
+ :'apikey' => :'apikey'
75
+ }
76
+ end
77
+
78
+ # Attribute type mapping.
79
+ def self.openapi_types
80
+ {
81
+ :'context' => :'ResponseContext',
82
+ :'id' => :'String',
83
+ :'iam_id' => :'String',
84
+ :'entity_tag' => :'String',
85
+ :'crn' => :'String',
86
+ :'locked' => :'Boolean',
87
+ :'created_at' => :'DateTime',
88
+ :'modified_at' => :'DateTime',
89
+ :'account_id' => :'String',
90
+ :'name' => :'String',
91
+ :'description' => :'String',
92
+ :'unique_instance_crns' => :'Array<String>',
93
+ :'history' => :'Array<EnityHistoryRecord>',
94
+ :'apikey' => :'ApiKey'
95
+ }
96
+ end
97
+
98
+ # List of attributes with nullable: true
99
+ def self.openapi_nullable
100
+ Set.new([
101
+ ])
102
+ end
103
+
104
+ # Initializes the object
105
+ # @param [Hash] attributes Model attributes in the form of hash
106
+ def initialize(attributes = {})
107
+ if (!attributes.is_a?(Hash))
108
+ fail ArgumentError, "The input argument (attributes) must be a hash in `IbmCloudIam::ServiceId` initialize method"
109
+ end
110
+
111
+ # check to see if the attribute exists and convert string to symbol for hash key
112
+ attributes = attributes.each_with_object({}) { |(k, v), h|
113
+ if (!self.class.attribute_map.key?(k.to_sym))
114
+ fail ArgumentError, "`#{k}` is not a valid attribute in `IbmCloudIam::ServiceId`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
115
+ end
116
+ h[k.to_sym] = v
117
+ }
118
+
119
+ if attributes.key?(:'context')
120
+ self.context = attributes[:'context']
121
+ end
122
+
123
+ if attributes.key?(:'id')
124
+ self.id = attributes[:'id']
125
+ end
126
+
127
+ if attributes.key?(:'iam_id')
128
+ self.iam_id = attributes[:'iam_id']
129
+ end
130
+
131
+ if attributes.key?(:'entity_tag')
132
+ self.entity_tag = attributes[:'entity_tag']
133
+ end
134
+
135
+ if attributes.key?(:'crn')
136
+ self.crn = attributes[:'crn']
137
+ end
138
+
139
+ if attributes.key?(:'locked')
140
+ self.locked = attributes[:'locked']
141
+ end
142
+
143
+ if attributes.key?(:'created_at')
144
+ self.created_at = attributes[:'created_at']
145
+ end
146
+
147
+ if attributes.key?(:'modified_at')
148
+ self.modified_at = attributes[:'modified_at']
149
+ end
150
+
151
+ if attributes.key?(:'account_id')
152
+ self.account_id = attributes[:'account_id']
153
+ end
154
+
155
+ if attributes.key?(:'name')
156
+ self.name = attributes[:'name']
157
+ end
158
+
159
+ if attributes.key?(:'description')
160
+ self.description = attributes[:'description']
161
+ end
162
+
163
+ if attributes.key?(:'unique_instance_crns')
164
+ if (value = attributes[:'unique_instance_crns']).is_a?(Array)
165
+ self.unique_instance_crns = value
166
+ end
167
+ end
168
+
169
+ if attributes.key?(:'history')
170
+ if (value = attributes[:'history']).is_a?(Array)
171
+ self.history = value
172
+ end
173
+ end
174
+
175
+ if attributes.key?(:'apikey')
176
+ self.apikey = attributes[:'apikey']
177
+ end
178
+ end
179
+
180
+ # Show invalid properties with the reasons. Usually used together with valid?
181
+ # @return Array for valid properties with the reasons
182
+ def list_invalid_properties
183
+ invalid_properties = Array.new
184
+ if @id.nil?
185
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
186
+ end
187
+
188
+ if @iam_id.nil?
189
+ invalid_properties.push('invalid value for "iam_id", iam_id cannot be nil.')
190
+ end
191
+
192
+ if @crn.nil?
193
+ invalid_properties.push('invalid value for "crn", crn cannot be nil.')
194
+ end
195
+
196
+ if @locked.nil?
197
+ invalid_properties.push('invalid value for "locked", locked cannot be nil.')
198
+ end
199
+
200
+ if @account_id.nil?
201
+ invalid_properties.push('invalid value for "account_id", account_id cannot be nil.')
202
+ end
203
+
204
+ if @name.nil?
205
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
206
+ end
207
+
208
+ if @apikey.nil?
209
+ invalid_properties.push('invalid value for "apikey", apikey cannot be nil.')
210
+ end
211
+
212
+ invalid_properties
213
+ end
214
+
215
+ # Check to see if the all the properties in the model are valid
216
+ # @return true if the model is valid
217
+ def valid?
218
+ return false if @id.nil?
219
+ return false if @iam_id.nil?
220
+ return false if @crn.nil?
221
+ return false if @locked.nil?
222
+ return false if @account_id.nil?
223
+ return false if @name.nil?
224
+ return false if @apikey.nil?
225
+ true
226
+ end
227
+
228
+ # Checks equality by comparing each attribute.
229
+ # @param [Object] Object to be compared
230
+ def ==(o)
231
+ return true if self.equal?(o)
232
+ self.class == o.class &&
233
+ context == o.context &&
234
+ id == o.id &&
235
+ iam_id == o.iam_id &&
236
+ entity_tag == o.entity_tag &&
237
+ crn == o.crn &&
238
+ locked == o.locked &&
239
+ created_at == o.created_at &&
240
+ modified_at == o.modified_at &&
241
+ account_id == o.account_id &&
242
+ name == o.name &&
243
+ description == o.description &&
244
+ unique_instance_crns == o.unique_instance_crns &&
245
+ history == o.history &&
246
+ apikey == o.apikey
247
+ end
248
+
249
+ # @see the `==` method
250
+ # @param [Object] Object to be compared
251
+ def eql?(o)
252
+ self == o
253
+ end
254
+
255
+ # Calculates hash code according to all attributes.
256
+ # @return [Integer] Hash code
257
+ def hash
258
+ [context, id, iam_id, entity_tag, crn, locked, created_at, modified_at, account_id, name, description, unique_instance_crns, history, apikey].hash
259
+ end
260
+
261
+ # Builds the object from hash
262
+ # @param [Hash] attributes Model attributes in the form of hash
263
+ # @return [Object] Returns the model itself
264
+ def self.build_from_hash(attributes)
265
+ new.build_from_hash(attributes)
266
+ end
267
+
268
+ # Builds the object from hash
269
+ # @param [Hash] attributes Model attributes in the form of hash
270
+ # @return [Object] Returns the model itself
271
+ def build_from_hash(attributes)
272
+ return nil unless attributes.is_a?(Hash)
273
+ self.class.openapi_types.each_pair do |key, type|
274
+ if type =~ /\AArray<(.*)>/i
275
+ # check to ensure the input is an array given that the attribute
276
+ # is documented as an array but the input is not
277
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
278
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
279
+ end
280
+ elsif !attributes[self.class.attribute_map[key]].nil?
281
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
282
+ elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
283
+ self.send("#{key}=", nil)
284
+ end
285
+ end
286
+
287
+ self
288
+ end
289
+
290
+ # Deserializes the data based on type
291
+ # @param string type Data type
292
+ # @param string value Value to be deserialized
293
+ # @return [Object] Deserialized data
294
+ def _deserialize(type, value)
295
+ case type.to_sym
296
+ when :DateTime
297
+ DateTime.parse(value)
298
+ when :Date
299
+ Date.parse(value)
300
+ when :String
301
+ value.to_s
302
+ when :Integer
303
+ value.to_i
304
+ when :Float
305
+ value.to_f
306
+ when :Boolean
307
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
308
+ true
309
+ else
310
+ false
311
+ end
312
+ when :Object
313
+ # generic object (usually a Hash), return directly
314
+ value
315
+ when /\AArray<(?<inner_type>.+)>\z/
316
+ inner_type = Regexp.last_match[:inner_type]
317
+ value.map { |v| _deserialize(inner_type, v) }
318
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
319
+ k_type = Regexp.last_match[:k_type]
320
+ v_type = Regexp.last_match[:v_type]
321
+ {}.tap do |hash|
322
+ value.each do |k, v|
323
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
324
+ end
325
+ end
326
+ else # model
327
+ IbmCloudIam.const_get(type).build_from_hash(value)
328
+ end
329
+ end
330
+
331
+ # Returns the string representation of the object
332
+ # @return [String] String presentation of the object
333
+ def to_s
334
+ to_hash.to_s
335
+ end
336
+
337
+ # to_body is an alias to to_hash (backward compatibility)
338
+ # @return [Hash] Returns the object in the form of hash
339
+ def to_body
340
+ to_hash
341
+ end
342
+
343
+ # Returns the object in the form of hash
344
+ # @return [Hash] Returns the object in the form of hash
345
+ def to_hash
346
+ hash = {}
347
+ self.class.attribute_map.each_pair do |attr, param|
348
+ value = self.send(attr)
349
+ if value.nil?
350
+ is_nullable = self.class.openapi_nullable.include?(attr)
351
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
352
+ end
353
+
354
+ hash[param] = _to_hash(value)
355
+ end
356
+ hash
357
+ end
358
+
359
+ # Outputs non-array value in the form of hash
360
+ # For object, use to_hash. Otherwise, just return the value
361
+ # @param [Object] value Any valid value
362
+ # @return [Hash] Returns the value in the form of hash
363
+ def _to_hash(value)
364
+ if value.is_a?(Array)
365
+ value.compact.map { |v| _to_hash(v) }
366
+ elsif value.is_a?(Hash)
367
+ {}.tap do |hash|
368
+ value.each { |k, v| hash[k] = _to_hash(v) }
369
+ end
370
+ elsif value.respond_to? :to_hash
371
+ value.to_hash
372
+ else
373
+ value
374
+ end
375
+ end
376
+ end
377
+ end