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,211 @@
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 PrincipalIn
17
+ attr_accessor :username
18
+
19
+ # Attribute mapping from ruby-style variable name to JSON key.
20
+ def self.attribute_map
21
+ {
22
+ :'username' => :'username'
23
+ }
24
+ end
25
+
26
+ # Attribute type mapping.
27
+ def self.openapi_types
28
+ {
29
+ :'username' => :'String'
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::PrincipalIn` 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::PrincipalIn`. 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?(:'username')
55
+ self.username = attributes[:'username']
56
+ end
57
+ end
58
+
59
+ # Show invalid properties with the reasons. Usually used together with valid?
60
+ # @return Array for valid properties with the reasons
61
+ def list_invalid_properties
62
+ invalid_properties = Array.new
63
+ if @username.nil?
64
+ invalid_properties.push('invalid value for "username", username cannot be nil.')
65
+ end
66
+
67
+ invalid_properties
68
+ end
69
+
70
+ # Check to see if the all the properties in the model are valid
71
+ # @return true if the model is valid
72
+ def valid?
73
+ return false if @username.nil?
74
+ true
75
+ end
76
+
77
+ # Checks equality by comparing each attribute.
78
+ # @param [Object] Object to be compared
79
+ def ==(o)
80
+ return true if self.equal?(o)
81
+ self.class == o.class &&
82
+ username == o.username
83
+ end
84
+
85
+ # @see the `==` method
86
+ # @param [Object] Object to be compared
87
+ def eql?(o)
88
+ self == o
89
+ end
90
+
91
+ # Calculates hash code according to all attributes.
92
+ # @return [Integer] Hash code
93
+ def hash
94
+ [username].hash
95
+ end
96
+
97
+ # Builds the object from hash
98
+ # @param [Hash] attributes Model attributes in the form of hash
99
+ # @return [Object] Returns the model itself
100
+ def self.build_from_hash(attributes)
101
+ new.build_from_hash(attributes)
102
+ end
103
+
104
+ # Builds the object from hash
105
+ # @param [Hash] attributes Model attributes in the form of hash
106
+ # @return [Object] Returns the model itself
107
+ def build_from_hash(attributes)
108
+ return nil unless attributes.is_a?(Hash)
109
+ self.class.openapi_types.each_pair do |key, type|
110
+ if type =~ /\AArray<(.*)>/i
111
+ # check to ensure the input is an array given that the attribute
112
+ # is documented as an array but the input is not
113
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
114
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
115
+ end
116
+ elsif !attributes[self.class.attribute_map[key]].nil?
117
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
118
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
119
+ end
120
+
121
+ self
122
+ end
123
+
124
+ # Deserializes the data based on type
125
+ # @param string type Data type
126
+ # @param string value Value to be deserialized
127
+ # @return [Object] Deserialized data
128
+ def _deserialize(type, value)
129
+ case type.to_sym
130
+ when :DateTime
131
+ DateTime.parse(value)
132
+ when :Date
133
+ Date.parse(value)
134
+ when :String
135
+ value.to_s
136
+ when :Integer
137
+ value.to_i
138
+ when :Float
139
+ value.to_f
140
+ when :Boolean
141
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
142
+ true
143
+ else
144
+ false
145
+ end
146
+ when :Object
147
+ # generic object (usually a Hash), return directly
148
+ value
149
+ when /\AArray<(?<inner_type>.+)>\z/
150
+ inner_type = Regexp.last_match[:inner_type]
151
+ value.map { |v| _deserialize(inner_type, v) }
152
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
153
+ k_type = Regexp.last_match[:k_type]
154
+ v_type = Regexp.last_match[:v_type]
155
+ {}.tap do |hash|
156
+ value.each do |k, v|
157
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
158
+ end
159
+ end
160
+ else # model
161
+ RBACApiClient.const_get(type).build_from_hash(value)
162
+ end
163
+ end
164
+
165
+ # Returns the string representation of the object
166
+ # @return [String] String presentation of the object
167
+ def to_s
168
+ to_hash.to_s
169
+ end
170
+
171
+ # to_body is an alias to to_hash (backward compatibility)
172
+ # @return [Hash] Returns the object in the form of hash
173
+ def to_body
174
+ to_hash
175
+ end
176
+
177
+ # Returns the object in the form of hash
178
+ # @return [Hash] Returns the object in the form of hash
179
+ def to_hash
180
+ hash = {}
181
+ self.class.attribute_map.each_pair do |attr, param|
182
+ value = self.send(attr)
183
+ if value.nil?
184
+ is_nullable = self.class.openapi_nullable.include?(attr)
185
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
186
+ end
187
+
188
+ hash[param] = _to_hash(value)
189
+ end
190
+ hash
191
+ end
192
+
193
+ # Outputs non-array value in the form of hash
194
+ # For object, use to_hash. Otherwise, just return the value
195
+ # @param [Object] value Any valid value
196
+ # @return [Hash] Returns the value in the form of hash
197
+ def _to_hash(value)
198
+ if value.is_a?(Array)
199
+ value.compact.map { |v| _to_hash(v) }
200
+ elsif value.is_a?(Hash)
201
+ {}.tap do |hash|
202
+ value.each { |k, v| hash[k] = _to_hash(v) }
203
+ end
204
+ elsif value.respond_to? :to_hash
205
+ value.to_hash
206
+ else
207
+ value
208
+ end
209
+ end
210
+ end
211
+ end
@@ -0,0 +1,274 @@
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 PrincipalOut
17
+ attr_accessor :username
18
+
19
+ attr_accessor :email
20
+
21
+ attr_accessor :first_name
22
+
23
+ attr_accessor :last_name
24
+
25
+ attr_accessor :is_active
26
+
27
+ attr_accessor :uuid
28
+
29
+ # Attribute mapping from ruby-style variable name to JSON key.
30
+ def self.attribute_map
31
+ {
32
+ :'username' => :'username',
33
+ :'email' => :'email',
34
+ :'first_name' => :'first_name',
35
+ :'last_name' => :'last_name',
36
+ :'is_active' => :'is_active',
37
+ :'uuid' => :'uuid'
38
+ }
39
+ end
40
+
41
+ # Attribute type mapping.
42
+ def self.openapi_types
43
+ {
44
+ :'username' => :'String',
45
+ :'email' => :'String',
46
+ :'first_name' => :'String',
47
+ :'last_name' => :'String',
48
+ :'is_active' => :'Boolean',
49
+ :'uuid' => :'String'
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
+ :'Principal',
63
+ :'UUID'
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 `RBACApiClient::PrincipalOut` 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 `RBACApiClient::PrincipalOut`. 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?(:'username')
83
+ self.username = attributes[:'username']
84
+ end
85
+
86
+ if attributes.key?(:'email')
87
+ self.email = attributes[:'email']
88
+ end
89
+
90
+ if attributes.key?(:'first_name')
91
+ self.first_name = attributes[:'first_name']
92
+ end
93
+
94
+ if attributes.key?(:'last_name')
95
+ self.last_name = attributes[:'last_name']
96
+ end
97
+
98
+ if attributes.key?(:'is_active')
99
+ self.is_active = attributes[:'is_active']
100
+ end
101
+
102
+ if attributes.key?(:'uuid')
103
+ self.uuid = attributes[:'uuid']
104
+ end
105
+ end
106
+
107
+ # Show invalid properties with the reasons. Usually used together with valid?
108
+ # @return Array for valid properties with the reasons
109
+ def list_invalid_properties
110
+ invalid_properties = Array.new
111
+ if @username.nil?
112
+ invalid_properties.push('invalid value for "username", username cannot be nil.')
113
+ end
114
+
115
+ if @email.nil?
116
+ invalid_properties.push('invalid value for "email", email 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
+ invalid_properties
124
+ end
125
+
126
+ # Check to see if the all the properties in the model are valid
127
+ # @return true if the model is valid
128
+ def valid?
129
+ return false if @username.nil?
130
+ return false if @email.nil?
131
+ return false if @uuid.nil?
132
+ true
133
+ end
134
+
135
+ # Checks equality by comparing each attribute.
136
+ # @param [Object] Object to be compared
137
+ def ==(o)
138
+ return true if self.equal?(o)
139
+ self.class == o.class &&
140
+ username == o.username &&
141
+ email == o.email &&
142
+ first_name == o.first_name &&
143
+ last_name == o.last_name &&
144
+ is_active == o.is_active &&
145
+ uuid == o.uuid
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
+ [username, email, first_name, last_name, is_active, uuid].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
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
182
+ end
183
+
184
+ self
185
+ end
186
+
187
+ # Deserializes the data based on type
188
+ # @param string type Data type
189
+ # @param string value Value to be deserialized
190
+ # @return [Object] Deserialized data
191
+ def _deserialize(type, value)
192
+ case type.to_sym
193
+ when :DateTime
194
+ DateTime.parse(value)
195
+ when :Date
196
+ Date.parse(value)
197
+ when :String
198
+ value.to_s
199
+ when :Integer
200
+ value.to_i
201
+ when :Float
202
+ value.to_f
203
+ when :Boolean
204
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
205
+ true
206
+ else
207
+ false
208
+ end
209
+ when :Object
210
+ # generic object (usually a Hash), return directly
211
+ value
212
+ when /\AArray<(?<inner_type>.+)>\z/
213
+ inner_type = Regexp.last_match[:inner_type]
214
+ value.map { |v| _deserialize(inner_type, v) }
215
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
216
+ k_type = Regexp.last_match[:k_type]
217
+ v_type = Regexp.last_match[:v_type]
218
+ {}.tap do |hash|
219
+ value.each do |k, v|
220
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
221
+ end
222
+ end
223
+ else # model
224
+ RBACApiClient.const_get(type).build_from_hash(value)
225
+ end
226
+ end
227
+
228
+ # Returns the string representation of the object
229
+ # @return [String] String presentation of the object
230
+ def to_s
231
+ to_hash.to_s
232
+ end
233
+
234
+ # to_body is an alias to to_hash (backward compatibility)
235
+ # @return [Hash] Returns the object in the form of hash
236
+ def to_body
237
+ to_hash
238
+ end
239
+
240
+ # Returns the object in the form of hash
241
+ # @return [Hash] Returns the object in the form of hash
242
+ def to_hash
243
+ hash = {}
244
+ self.class.attribute_map.each_pair do |attr, param|
245
+ value = self.send(attr)
246
+ if value.nil?
247
+ is_nullable = self.class.openapi_nullable.include?(attr)
248
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
249
+ end
250
+
251
+ hash[param] = _to_hash(value)
252
+ end
253
+ hash
254
+ end
255
+
256
+ # Outputs non-array value in the form of hash
257
+ # For object, use to_hash. Otherwise, just return the value
258
+ # @param [Object] value Any valid value
259
+ # @return [Hash] Returns the value in the form of hash
260
+ def _to_hash(value)
261
+ if value.is_a?(Array)
262
+ value.compact.map { |v| _to_hash(v) }
263
+ elsif value.is_a?(Hash)
264
+ {}.tap do |hash|
265
+ value.each { |k, v| hash[k] = _to_hash(v) }
266
+ end
267
+ elsif value.respond_to? :to_hash
268
+ value.to_hash
269
+ else
270
+ value
271
+ end
272
+ end
273
+ end
274
+ end