rbac-api-client 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/README.md +175 -0
  4. data/Rakefile +10 -0
  5. data/client-meta.json +8 -0
  6. data/docs/Access.md +19 -0
  7. data/docs/AccessApi.md +68 -0
  8. data/docs/AccessPagination.md +21 -0
  9. data/docs/AccessPaginationAllOf.md +17 -0
  10. data/docs/AdditionalGroup.md +19 -0
  11. data/docs/Error.md +17 -0
  12. data/docs/Error403.md +17 -0
  13. data/docs/Group.md +19 -0
  14. data/docs/GroupApi.md +623 -0
  15. data/docs/GroupOut.md +33 -0
  16. data/docs/GroupPagination.md +21 -0
  17. data/docs/GroupPaginationAllOf.md +17 -0
  18. data/docs/GroupPrincipalIn.md +17 -0
  19. data/docs/GroupRoleIn.md +17 -0
  20. data/docs/GroupRolesPagination.md +21 -0
  21. data/docs/GroupWithPrincipals.md +27 -0
  22. data/docs/GroupWithPrincipalsAllOf.md +17 -0
  23. data/docs/GroupWithPrincipalsAndRoles.md +29 -0
  24. data/docs/GroupWithPrincipalsAndRolesAllOf.md +19 -0
  25. data/docs/InlineResponse200.md +17 -0
  26. data/docs/ListPagination.md +19 -0
  27. data/docs/PaginationLinks.md +23 -0
  28. data/docs/PaginationMeta.md +17 -0
  29. data/docs/Policy.md +19 -0
  30. data/docs/PolicyApi.md +283 -0
  31. data/docs/PolicyExtended.md +29 -0
  32. data/docs/PolicyExtendedAllOf.md +19 -0
  33. data/docs/PolicyIn.md +23 -0
  34. data/docs/PolicyInAllOf.md +19 -0
  35. data/docs/PolicyPagination.md +21 -0
  36. data/docs/PolicyPaginationAllOf.md +17 -0
  37. data/docs/Principal.md +25 -0
  38. data/docs/PrincipalApi.md +68 -0
  39. data/docs/PrincipalIn.md +17 -0
  40. data/docs/PrincipalOut.md +27 -0
  41. data/docs/PrincipalPagination.md +21 -0
  42. data/docs/PrincipalPaginationAllOf.md +17 -0
  43. data/docs/ResourceDefinition.md +17 -0
  44. data/docs/ResourceDefinitionFilter.md +21 -0
  45. data/docs/Role.md +19 -0
  46. data/docs/RoleApi.md +340 -0
  47. data/docs/RoleIn.md +21 -0
  48. data/docs/RoleInAllOf.md +17 -0
  49. data/docs/RoleOut.md +35 -0
  50. data/docs/RoleOutDynamic.md +39 -0
  51. data/docs/RoleOutDynamicAllOf.md +29 -0
  52. data/docs/RolePagination.md +21 -0
  53. data/docs/RolePaginationDynamic.md +21 -0
  54. data/docs/RolePaginationDynamicAllOf.md +17 -0
  55. data/docs/RoleWithAccess.md +37 -0
  56. data/docs/Status.md +27 -0
  57. data/docs/StatusApi.md +56 -0
  58. data/docs/Timestamped.md +19 -0
  59. data/docs/UUID.md +17 -0
  60. data/generate.sh +7 -0
  61. data/git_push.sh +58 -0
  62. data/lib/rbac-api-client.rb +93 -0
  63. data/lib/rbac-api-client/api/access_api.rb +104 -0
  64. data/lib/rbac-api-client/api/group_api.rb +800 -0
  65. data/lib/rbac-api-client/api/policy_api.rb +363 -0
  66. data/lib/rbac-api-client/api/principal_api.rb +104 -0
  67. data/lib/rbac-api-client/api/role_api.rb +445 -0
  68. data/lib/rbac-api-client/api/status_api.rb +76 -0
  69. data/lib/rbac-api-client/api_client.rb +386 -0
  70. data/lib/rbac-api-client/api_error.rb +57 -0
  71. data/lib/rbac-api-client/configuration.rb +248 -0
  72. data/lib/rbac-api-client/models/access.rb +227 -0
  73. data/lib/rbac-api-client/models/access_pagination.rb +239 -0
  74. data/lib/rbac-api-client/models/access_pagination_all_of.rb +213 -0
  75. data/lib/rbac-api-client/models/additional_group.rb +215 -0
  76. data/lib/rbac-api-client/models/error.rb +213 -0
  77. data/lib/rbac-api-client/models/error403.rb +213 -0
  78. data/lib/rbac-api-client/models/group.rb +220 -0
  79. data/lib/rbac-api-client/models/group_out.rb +341 -0
  80. data/lib/rbac-api-client/models/group_pagination.rb +239 -0
  81. data/lib/rbac-api-client/models/group_pagination_all_of.rb +213 -0
  82. data/lib/rbac-api-client/models/group_principal_in.rb +213 -0
  83. data/lib/rbac-api-client/models/group_role_in.rb +213 -0
  84. data/lib/rbac-api-client/models/group_roles_pagination.rb +239 -0
  85. data/lib/rbac-api-client/models/group_with_principals.rb +288 -0
  86. data/lib/rbac-api-client/models/group_with_principals_all_of.rb +213 -0
  87. data/lib/rbac-api-client/models/group_with_principals_and_roles.rb +304 -0
  88. data/lib/rbac-api-client/models/group_with_principals_and_roles_all_of.rb +229 -0
  89. data/lib/rbac-api-client/models/inline_response200.rb +213 -0
  90. data/lib/rbac-api-client/models/list_pagination.rb +215 -0
  91. data/lib/rbac-api-client/models/pagination_links.rb +233 -0
  92. data/lib/rbac-api-client/models/pagination_meta.rb +206 -0
  93. data/lib/rbac-api-client/models/policy.rb +220 -0
  94. data/lib/rbac-api-client/models/policy_extended.rb +302 -0
  95. data/lib/rbac-api-client/models/policy_extended_all_of.rb +227 -0
  96. data/lib/rbac-api-client/models/policy_in.rb +258 -0
  97. data/lib/rbac-api-client/models/policy_in_all_of.rb +227 -0
  98. data/lib/rbac-api-client/models/policy_pagination.rb +239 -0
  99. data/lib/rbac-api-client/models/policy_pagination_all_of.rb +213 -0
  100. data/lib/rbac-api-client/models/principal.rb +252 -0
  101. data/lib/rbac-api-client/models/principal_in.rb +211 -0
  102. data/lib/rbac-api-client/models/principal_out.rb +274 -0
  103. data/lib/rbac-api-client/models/principal_pagination.rb +239 -0
  104. data/lib/rbac-api-client/models/principal_pagination_all_of.rb +213 -0
  105. data/lib/rbac-api-client/models/resource_definition.rb +211 -0
  106. data/lib/rbac-api-client/models/resource_definition_filter.rb +273 -0
  107. data/lib/rbac-api-client/models/role.rb +220 -0
  108. data/lib/rbac-api-client/models/role_in.rb +244 -0
  109. data/lib/rbac-api-client/models/role_in_all_of.rb +213 -0
  110. data/lib/rbac-api-client/models/role_out.rb +352 -0
  111. data/lib/rbac-api-client/models/role_out_dynamic.rb +421 -0
  112. data/lib/rbac-api-client/models/role_out_dynamic_all_of.rb +346 -0
  113. data/lib/rbac-api-client/models/role_pagination.rb +239 -0
  114. data/lib/rbac-api-client/models/role_pagination_dynamic.rb +239 -0
  115. data/lib/rbac-api-client/models/role_pagination_dynamic_all_of.rb +213 -0
  116. data/lib/rbac-api-client/models/role_with_access.rb +367 -0
  117. data/lib/rbac-api-client/models/status.rb +256 -0
  118. data/lib/rbac-api-client/models/timestamped.rb +225 -0
  119. data/lib/rbac-api-client/models/uuid.rb +211 -0
  120. data/lib/rbac-api-client/version.rb +15 -0
  121. data/openapi.json +2613 -0
  122. data/rbac-api-client.gemspec +39 -0
  123. data/spec/api/access_api_spec.rb +49 -0
  124. data/spec/api/group_api_spec.rb +176 -0
  125. data/spec/api/policy_api_spec.rb +97 -0
  126. data/spec/api/principal_api_spec.rb +49 -0
  127. data/spec/api/role_api_spec.rb +110 -0
  128. data/spec/api/status_api_spec.rb +45 -0
  129. data/spec/api_client_spec.rb +226 -0
  130. data/spec/configuration_spec.rb +42 -0
  131. data/spec/models/access_pagination_all_of_spec.rb +41 -0
  132. data/spec/models/access_pagination_spec.rb +53 -0
  133. data/spec/models/access_spec.rb +47 -0
  134. data/spec/models/additional_group_spec.rb +47 -0
  135. data/spec/models/error403_spec.rb +41 -0
  136. data/spec/models/error_spec.rb +41 -0
  137. data/spec/models/group_out_spec.rb +89 -0
  138. data/spec/models/group_pagination_all_of_spec.rb +41 -0
  139. data/spec/models/group_pagination_spec.rb +53 -0
  140. data/spec/models/group_principal_in_spec.rb +41 -0
  141. data/spec/models/group_role_in_spec.rb +41 -0
  142. data/spec/models/group_roles_pagination_spec.rb +53 -0
  143. data/spec/models/group_spec.rb +47 -0
  144. data/spec/models/group_with_principals_all_of_spec.rb +41 -0
  145. data/spec/models/group_with_principals_and_roles_all_of_spec.rb +47 -0
  146. data/spec/models/group_with_principals_and_roles_spec.rb +77 -0
  147. data/spec/models/group_with_principals_spec.rb +71 -0
  148. data/spec/models/inline_response200_spec.rb +41 -0
  149. data/spec/models/list_pagination_spec.rb +47 -0
  150. data/spec/models/pagination_links_spec.rb +59 -0
  151. data/spec/models/pagination_meta_spec.rb +41 -0
  152. data/spec/models/policy_extended_all_of_spec.rb +47 -0
  153. data/spec/models/policy_extended_spec.rb +77 -0
  154. data/spec/models/policy_in_all_of_spec.rb +47 -0
  155. data/spec/models/policy_in_spec.rb +59 -0
  156. data/spec/models/policy_pagination_all_of_spec.rb +41 -0
  157. data/spec/models/policy_pagination_spec.rb +53 -0
  158. data/spec/models/policy_spec.rb +47 -0
  159. data/spec/models/principal_in_spec.rb +41 -0
  160. data/spec/models/principal_out_spec.rb +71 -0
  161. data/spec/models/principal_pagination_all_of_spec.rb +41 -0
  162. data/spec/models/principal_pagination_spec.rb +53 -0
  163. data/spec/models/principal_spec.rb +65 -0
  164. data/spec/models/resource_definition_filter_spec.rb +57 -0
  165. data/spec/models/resource_definition_spec.rb +41 -0
  166. data/spec/models/role_in_all_of_spec.rb +41 -0
  167. data/spec/models/role_in_spec.rb +53 -0
  168. data/spec/models/role_out_dynamic_all_of_spec.rb +77 -0
  169. data/spec/models/role_out_dynamic_spec.rb +107 -0
  170. data/spec/models/role_out_spec.rb +95 -0
  171. data/spec/models/role_pagination_dynamic_all_of_spec.rb +41 -0
  172. data/spec/models/role_pagination_dynamic_spec.rb +53 -0
  173. data/spec/models/role_pagination_spec.rb +53 -0
  174. data/spec/models/role_spec.rb +47 -0
  175. data/spec/models/role_with_access_spec.rb +101 -0
  176. data/spec/models/status_spec.rb +71 -0
  177. data/spec/models/timestamped_spec.rb +47 -0
  178. data/spec/models/uuid_spec.rb +41 -0
  179. data/spec/spec_helper.rb +111 -0
  180. metadata +338 -0
@@ -0,0 +1,288 @@
1
+ =begin
2
+ #Role Based Access Control
3
+
4
+ #The API for Role Based Access Control.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.2.2
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module RBACApiClient
16
+ class GroupWithPrincipals
17
+ attr_accessor :name
18
+
19
+ attr_accessor :description
20
+
21
+ attr_accessor :uuid
22
+
23
+ attr_accessor :created
24
+
25
+ attr_accessor :modified
26
+
27
+ attr_accessor :principals
28
+
29
+ # Attribute mapping from ruby-style variable name to JSON key.
30
+ def self.attribute_map
31
+ {
32
+ :'name' => :'name',
33
+ :'description' => :'description',
34
+ :'uuid' => :'uuid',
35
+ :'created' => :'created',
36
+ :'modified' => :'modified',
37
+ :'principals' => :'principals'
38
+ }
39
+ end
40
+
41
+ # Attribute type mapping.
42
+ def self.openapi_types
43
+ {
44
+ :'name' => :'String',
45
+ :'description' => :'String',
46
+ :'uuid' => :'String',
47
+ :'created' => :'DateTime',
48
+ :'modified' => :'DateTime',
49
+ :'principals' => :'Array<Principal>'
50
+ }
51
+ end
52
+
53
+ # List of attributes with nullable: true
54
+ def self.openapi_nullable
55
+ Set.new([
56
+ ])
57
+ end
58
+
59
+ # List of class defined in allOf (OpenAPI v3)
60
+ def self.openapi_all_of
61
+ [
62
+ :'Group',
63
+ :'GroupWithPrincipalsAllOf',
64
+ :'Timestamped',
65
+ :'UUID'
66
+ ]
67
+ end
68
+
69
+ # Initializes the object
70
+ # @param [Hash] attributes Model attributes in the form of hash
71
+ def initialize(attributes = {})
72
+ if (!attributes.is_a?(Hash))
73
+ fail ArgumentError, "The input argument (attributes) must be a hash in `RBACApiClient::GroupWithPrincipals` initialize method"
74
+ end
75
+
76
+ # check to see if the attribute exists and convert string to symbol for hash key
77
+ attributes = attributes.each_with_object({}) { |(k, v), h|
78
+ if (!self.class.attribute_map.key?(k.to_sym))
79
+ fail ArgumentError, "`#{k}` is not a valid attribute in `RBACApiClient::GroupWithPrincipals`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
80
+ end
81
+ h[k.to_sym] = v
82
+ }
83
+
84
+ if attributes.key?(:'name')
85
+ self.name = attributes[:'name']
86
+ end
87
+
88
+ if attributes.key?(:'description')
89
+ self.description = attributes[:'description']
90
+ end
91
+
92
+ if attributes.key?(:'uuid')
93
+ self.uuid = attributes[:'uuid']
94
+ end
95
+
96
+ if attributes.key?(:'created')
97
+ self.created = attributes[:'created']
98
+ end
99
+
100
+ if attributes.key?(:'modified')
101
+ self.modified = attributes[:'modified']
102
+ end
103
+
104
+ if attributes.key?(:'principals')
105
+ if (value = attributes[:'principals']).is_a?(Array)
106
+ self.principals = value
107
+ end
108
+ end
109
+ end
110
+
111
+ # Show invalid properties with the reasons. Usually used together with valid?
112
+ # @return Array for valid properties with the reasons
113
+ def list_invalid_properties
114
+ invalid_properties = Array.new
115
+ if @name.nil?
116
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
117
+ end
118
+
119
+ if @uuid.nil?
120
+ invalid_properties.push('invalid value for "uuid", uuid cannot be nil.')
121
+ end
122
+
123
+ if @created.nil?
124
+ invalid_properties.push('invalid value for "created", created cannot be nil.')
125
+ end
126
+
127
+ if @modified.nil?
128
+ invalid_properties.push('invalid value for "modified", modified cannot be nil.')
129
+ end
130
+
131
+ if @principals.nil?
132
+ invalid_properties.push('invalid value for "principals", principals cannot be nil.')
133
+ end
134
+
135
+ invalid_properties
136
+ end
137
+
138
+ # Check to see if the all the properties in the model are valid
139
+ # @return true if the model is valid
140
+ def valid?
141
+ return false if @name.nil?
142
+ return false if @uuid.nil?
143
+ return false if @created.nil?
144
+ return false if @modified.nil?
145
+ return false if @principals.nil?
146
+ true
147
+ end
148
+
149
+ # Checks equality by comparing each attribute.
150
+ # @param [Object] Object to be compared
151
+ def ==(o)
152
+ return true if self.equal?(o)
153
+ self.class == o.class &&
154
+ name == o.name &&
155
+ description == o.description &&
156
+ uuid == o.uuid &&
157
+ created == o.created &&
158
+ modified == o.modified &&
159
+ principals == o.principals
160
+ end
161
+
162
+ # @see the `==` method
163
+ # @param [Object] Object to be compared
164
+ def eql?(o)
165
+ self == o
166
+ end
167
+
168
+ # Calculates hash code according to all attributes.
169
+ # @return [Integer] Hash code
170
+ def hash
171
+ [name, description, uuid, created, modified, principals].hash
172
+ end
173
+
174
+ # Builds the object from hash
175
+ # @param [Hash] attributes Model attributes in the form of hash
176
+ # @return [Object] Returns the model itself
177
+ def self.build_from_hash(attributes)
178
+ new.build_from_hash(attributes)
179
+ end
180
+
181
+ # Builds the object from hash
182
+ # @param [Hash] attributes Model attributes in the form of hash
183
+ # @return [Object] Returns the model itself
184
+ def build_from_hash(attributes)
185
+ return nil unless attributes.is_a?(Hash)
186
+ self.class.openapi_types.each_pair do |key, type|
187
+ if type =~ /\AArray<(.*)>/i
188
+ # check to ensure the input is an array given that the attribute
189
+ # is documented as an array but the input is not
190
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
191
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
192
+ end
193
+ elsif !attributes[self.class.attribute_map[key]].nil?
194
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
195
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
196
+ end
197
+
198
+ self
199
+ end
200
+
201
+ # Deserializes the data based on type
202
+ # @param string type Data type
203
+ # @param string value Value to be deserialized
204
+ # @return [Object] Deserialized data
205
+ def _deserialize(type, value)
206
+ case type.to_sym
207
+ when :DateTime
208
+ DateTime.parse(value)
209
+ when :Date
210
+ Date.parse(value)
211
+ when :String
212
+ value.to_s
213
+ when :Integer
214
+ value.to_i
215
+ when :Float
216
+ value.to_f
217
+ when :Boolean
218
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
219
+ true
220
+ else
221
+ false
222
+ end
223
+ when :Object
224
+ # generic object (usually a Hash), return directly
225
+ value
226
+ when /\AArray<(?<inner_type>.+)>\z/
227
+ inner_type = Regexp.last_match[:inner_type]
228
+ value.map { |v| _deserialize(inner_type, v) }
229
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
230
+ k_type = Regexp.last_match[:k_type]
231
+ v_type = Regexp.last_match[:v_type]
232
+ {}.tap do |hash|
233
+ value.each do |k, v|
234
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
235
+ end
236
+ end
237
+ else # model
238
+ RBACApiClient.const_get(type).build_from_hash(value)
239
+ end
240
+ end
241
+
242
+ # Returns the string representation of the object
243
+ # @return [String] String presentation of the object
244
+ def to_s
245
+ to_hash.to_s
246
+ end
247
+
248
+ # to_body is an alias to to_hash (backward compatibility)
249
+ # @return [Hash] Returns the object in the form of hash
250
+ def to_body
251
+ to_hash
252
+ end
253
+
254
+ # Returns the object in the form of hash
255
+ # @return [Hash] Returns the object in the form of hash
256
+ def to_hash
257
+ hash = {}
258
+ self.class.attribute_map.each_pair do |attr, param|
259
+ value = self.send(attr)
260
+ if value.nil?
261
+ is_nullable = self.class.openapi_nullable.include?(attr)
262
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
263
+ end
264
+
265
+ hash[param] = _to_hash(value)
266
+ end
267
+ hash
268
+ end
269
+
270
+ # Outputs non-array value in the form of hash
271
+ # For object, use to_hash. Otherwise, just return the value
272
+ # @param [Object] value Any valid value
273
+ # @return [Hash] Returns the value in the form of hash
274
+ def _to_hash(value)
275
+ if value.is_a?(Array)
276
+ value.compact.map { |v| _to_hash(v) }
277
+ elsif value.is_a?(Hash)
278
+ {}.tap do |hash|
279
+ value.each { |k, v| hash[k] = _to_hash(v) }
280
+ end
281
+ elsif value.respond_to? :to_hash
282
+ value.to_hash
283
+ else
284
+ value
285
+ end
286
+ end
287
+ end
288
+ end
@@ -0,0 +1,213 @@
1
+ =begin
2
+ #Role Based Access Control
3
+
4
+ #The API for Role Based Access Control.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.2.2
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module RBACApiClient
16
+ class GroupWithPrincipalsAllOf
17
+ attr_accessor :principals
18
+
19
+ # Attribute mapping from ruby-style variable name to JSON key.
20
+ def self.attribute_map
21
+ {
22
+ :'principals' => :'principals'
23
+ }
24
+ end
25
+
26
+ # Attribute type mapping.
27
+ def self.openapi_types
28
+ {
29
+ :'principals' => :'Array<Principal>'
30
+ }
31
+ end
32
+
33
+ # List of attributes with nullable: true
34
+ def self.openapi_nullable
35
+ Set.new([
36
+ ])
37
+ end
38
+
39
+ # Initializes the object
40
+ # @param [Hash] attributes Model attributes in the form of hash
41
+ def initialize(attributes = {})
42
+ if (!attributes.is_a?(Hash))
43
+ fail ArgumentError, "The input argument (attributes) must be a hash in `RBACApiClient::GroupWithPrincipalsAllOf` initialize method"
44
+ end
45
+
46
+ # check to see if the attribute exists and convert string to symbol for hash key
47
+ attributes = attributes.each_with_object({}) { |(k, v), h|
48
+ if (!self.class.attribute_map.key?(k.to_sym))
49
+ fail ArgumentError, "`#{k}` is not a valid attribute in `RBACApiClient::GroupWithPrincipalsAllOf`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
50
+ end
51
+ h[k.to_sym] = v
52
+ }
53
+
54
+ if attributes.key?(:'principals')
55
+ if (value = attributes[:'principals']).is_a?(Array)
56
+ self.principals = value
57
+ end
58
+ end
59
+ end
60
+
61
+ # Show invalid properties with the reasons. Usually used together with valid?
62
+ # @return Array for valid properties with the reasons
63
+ def list_invalid_properties
64
+ invalid_properties = Array.new
65
+ if @principals.nil?
66
+ invalid_properties.push('invalid value for "principals", principals cannot be nil.')
67
+ end
68
+
69
+ invalid_properties
70
+ end
71
+
72
+ # Check to see if the all the properties in the model are valid
73
+ # @return true if the model is valid
74
+ def valid?
75
+ return false if @principals.nil?
76
+ true
77
+ end
78
+
79
+ # Checks equality by comparing each attribute.
80
+ # @param [Object] Object to be compared
81
+ def ==(o)
82
+ return true if self.equal?(o)
83
+ self.class == o.class &&
84
+ principals == o.principals
85
+ end
86
+
87
+ # @see the `==` method
88
+ # @param [Object] Object to be compared
89
+ def eql?(o)
90
+ self == o
91
+ end
92
+
93
+ # Calculates hash code according to all attributes.
94
+ # @return [Integer] Hash code
95
+ def hash
96
+ [principals].hash
97
+ end
98
+
99
+ # Builds the object from hash
100
+ # @param [Hash] attributes Model attributes in the form of hash
101
+ # @return [Object] Returns the model itself
102
+ def self.build_from_hash(attributes)
103
+ new.build_from_hash(attributes)
104
+ end
105
+
106
+ # Builds the object from hash
107
+ # @param [Hash] attributes Model attributes in the form of hash
108
+ # @return [Object] Returns the model itself
109
+ def build_from_hash(attributes)
110
+ return nil unless attributes.is_a?(Hash)
111
+ self.class.openapi_types.each_pair do |key, type|
112
+ if type =~ /\AArray<(.*)>/i
113
+ # check to ensure the input is an array given that the attribute
114
+ # is documented as an array but the input is not
115
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
116
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
117
+ end
118
+ elsif !attributes[self.class.attribute_map[key]].nil?
119
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
120
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
121
+ end
122
+
123
+ self
124
+ end
125
+
126
+ # Deserializes the data based on type
127
+ # @param string type Data type
128
+ # @param string value Value to be deserialized
129
+ # @return [Object] Deserialized data
130
+ def _deserialize(type, value)
131
+ case type.to_sym
132
+ when :DateTime
133
+ DateTime.parse(value)
134
+ when :Date
135
+ Date.parse(value)
136
+ when :String
137
+ value.to_s
138
+ when :Integer
139
+ value.to_i
140
+ when :Float
141
+ value.to_f
142
+ when :Boolean
143
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
144
+ true
145
+ else
146
+ false
147
+ end
148
+ when :Object
149
+ # generic object (usually a Hash), return directly
150
+ value
151
+ when /\AArray<(?<inner_type>.+)>\z/
152
+ inner_type = Regexp.last_match[:inner_type]
153
+ value.map { |v| _deserialize(inner_type, v) }
154
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
155
+ k_type = Regexp.last_match[:k_type]
156
+ v_type = Regexp.last_match[:v_type]
157
+ {}.tap do |hash|
158
+ value.each do |k, v|
159
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
160
+ end
161
+ end
162
+ else # model
163
+ RBACApiClient.const_get(type).build_from_hash(value)
164
+ end
165
+ end
166
+
167
+ # Returns the string representation of the object
168
+ # @return [String] String presentation of the object
169
+ def to_s
170
+ to_hash.to_s
171
+ end
172
+
173
+ # to_body is an alias to to_hash (backward compatibility)
174
+ # @return [Hash] Returns the object in the form of hash
175
+ def to_body
176
+ to_hash
177
+ end
178
+
179
+ # Returns the object in the form of hash
180
+ # @return [Hash] Returns the object in the form of hash
181
+ def to_hash
182
+ hash = {}
183
+ self.class.attribute_map.each_pair do |attr, param|
184
+ value = self.send(attr)
185
+ if value.nil?
186
+ is_nullable = self.class.openapi_nullable.include?(attr)
187
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
188
+ end
189
+
190
+ hash[param] = _to_hash(value)
191
+ end
192
+ hash
193
+ end
194
+
195
+ # Outputs non-array value in the form of hash
196
+ # For object, use to_hash. Otherwise, just return the value
197
+ # @param [Object] value Any valid value
198
+ # @return [Hash] Returns the value in the form of hash
199
+ def _to_hash(value)
200
+ if value.is_a?(Array)
201
+ value.compact.map { |v| _to_hash(v) }
202
+ elsif value.is_a?(Hash)
203
+ {}.tap do |hash|
204
+ value.each { |k, v| hash[k] = _to_hash(v) }
205
+ end
206
+ elsif value.respond_to? :to_hash
207
+ value.to_hash
208
+ else
209
+ value
210
+ end
211
+ end
212
+ end
213
+ end