pulp_ansible_client 0.2.0b1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/Gemfile.lock +79 -0
  4. data/README.md +150 -0
  5. data/Rakefile +10 -0
  6. data/docs/AnsibleCollectionsApi.md +66 -0
  7. data/docs/AnsibleDistribution.md +31 -0
  8. data/docs/AnsibleRemote.md +45 -0
  9. data/docs/AsyncOperationResponse.md +17 -0
  10. data/docs/Collection.md +41 -0
  11. data/docs/CollectionRemote.md +47 -0
  12. data/docs/ContentCollectionsApi.md +134 -0
  13. data/docs/ContentRolesApi.md +186 -0
  14. data/docs/DistributionsAnsibleApi.md +352 -0
  15. data/docs/GalaxyCollection.md +25 -0
  16. data/docs/GalaxyRole.md +21 -0
  17. data/docs/GalaxyRoleVersion.md +19 -0
  18. data/docs/InlineResponse200.md +23 -0
  19. data/docs/InlineResponse2001.md +23 -0
  20. data/docs/InlineResponse2002.md +23 -0
  21. data/docs/InlineResponse2003.md +23 -0
  22. data/docs/InlineResponse2004.md +23 -0
  23. data/docs/InlineResponse2005.md +23 -0
  24. data/docs/InlineResponse2006.md +23 -0
  25. data/docs/InlineResponse2007.md +23 -0
  26. data/docs/PulpAnsibleApiApi.md +60 -0
  27. data/docs/PulpAnsibleGalaxyApiCollectionsApi.md +113 -0
  28. data/docs/PulpAnsibleGalaxyApiRolesApi.md +67 -0
  29. data/docs/PulpAnsibleGalaxyApiV1VersionsApi.md +69 -0
  30. data/docs/PulpAnsibleGalaxyApiV2VersionsApi.md +67 -0
  31. data/docs/RemotesAnsibleApi.md +411 -0
  32. data/docs/RemotesCollectionApi.md +411 -0
  33. data/docs/RepositorySyncURL.md +19 -0
  34. data/docs/Role.md +29 -0
  35. data/git_push.sh +55 -0
  36. data/lib/pulp_ansible_client/api/ansible_collections_api.rb +94 -0
  37. data/lib/pulp_ansible_client/api/content_collections_api.rb +169 -0
  38. data/lib/pulp_ansible_client/api/content_roles_api.rb +228 -0
  39. data/lib/pulp_ansible_client/api/distributions_ansible_api.rb +430 -0
  40. data/lib/pulp_ansible_client/api/pulp_ansible_api_api.rb +80 -0
  41. data/lib/pulp_ansible_client/api/pulp_ansible_galaxy_api_collections_api.rb +140 -0
  42. data/lib/pulp_ansible_client/api/pulp_ansible_galaxy_api_roles_api.rb +88 -0
  43. data/lib/pulp_ansible_client/api/pulp_ansible_galaxy_api_v1_versions_api.rb +94 -0
  44. data/lib/pulp_ansible_client/api/pulp_ansible_galaxy_api_v2_versions_api.rb +88 -0
  45. data/lib/pulp_ansible_client/api/remotes_ansible_api.rb +504 -0
  46. data/lib/pulp_ansible_client/api/remotes_collection_api.rb +504 -0
  47. data/lib/pulp_ansible_client/api_client.rb +387 -0
  48. data/lib/pulp_ansible_client/api_error.rb +57 -0
  49. data/lib/pulp_ansible_client/configuration.rb +251 -0
  50. data/lib/pulp_ansible_client/models/ansible_distribution.rb +347 -0
  51. data/lib/pulp_ansible_client/models/ansible_remote.rb +539 -0
  52. data/lib/pulp_ansible_client/models/async_operation_response.rb +202 -0
  53. data/lib/pulp_ansible_client/models/collection.rb +494 -0
  54. data/lib/pulp_ansible_client/models/collection_remote.rb +572 -0
  55. data/lib/pulp_ansible_client/models/galaxy_collection.rb +304 -0
  56. data/lib/pulp_ansible_client/models/galaxy_role.rb +262 -0
  57. data/lib/pulp_ansible_client/models/galaxy_role_version.rb +229 -0
  58. data/lib/pulp_ansible_client/models/inline_response200.rb +235 -0
  59. data/lib/pulp_ansible_client/models/inline_response2001.rb +235 -0
  60. data/lib/pulp_ansible_client/models/inline_response2002.rb +235 -0
  61. data/lib/pulp_ansible_client/models/inline_response2003.rb +235 -0
  62. data/lib/pulp_ansible_client/models/inline_response2004.rb +235 -0
  63. data/lib/pulp_ansible_client/models/inline_response2005.rb +235 -0
  64. data/lib/pulp_ansible_client/models/inline_response2006.rb +235 -0
  65. data/lib/pulp_ansible_client/models/inline_response2007.rb +235 -0
  66. data/lib/pulp_ansible_client/models/repository_sync_url.rb +214 -0
  67. data/lib/pulp_ansible_client/models/role.rb +344 -0
  68. data/lib/pulp_ansible_client/version.rb +15 -0
  69. data/lib/pulp_ansible_client.rb +68 -0
  70. data/pulp_ansible_client.gemspec +45 -0
  71. data/spec/api/ansible_collections_api_spec.rb +48 -0
  72. data/spec/api/content_collections_api_spec.rb +67 -0
  73. data/spec/api/content_roles_api_spec.rb +78 -0
  74. data/spec/api/distributions_ansible_api_spec.rb +116 -0
  75. data/spec/api/pulp_ansible_api_api_spec.rb +46 -0
  76. data/spec/api/pulp_ansible_galaxy_api_collections_api_spec.rb +57 -0
  77. data/spec/api/pulp_ansible_galaxy_api_roles_api_spec.rb +48 -0
  78. data/spec/api/pulp_ansible_galaxy_api_v1_versions_api_spec.rb +49 -0
  79. data/spec/api/pulp_ansible_galaxy_api_v2_versions_api_spec.rb +48 -0
  80. data/spec/api/remotes_ansible_api_spec.rb +130 -0
  81. data/spec/api/remotes_collection_api_spec.rb +130 -0
  82. data/spec/api_client_spec.rb +226 -0
  83. data/spec/configuration_spec.rb +42 -0
  84. data/spec/models/ansible_distribution_spec.rb +83 -0
  85. data/spec/models/ansible_remote_spec.rb +129 -0
  86. data/spec/models/async_operation_response_spec.rb +41 -0
  87. data/spec/models/collection_remote_spec.rb +135 -0
  88. data/spec/models/collection_spec.rb +113 -0
  89. data/spec/models/galaxy_collection_spec.rb +65 -0
  90. data/spec/models/galaxy_role_spec.rb +53 -0
  91. data/spec/models/galaxy_role_version_spec.rb +47 -0
  92. data/spec/models/inline_response2001_spec.rb +59 -0
  93. data/spec/models/inline_response2002_spec.rb +59 -0
  94. data/spec/models/inline_response2003_spec.rb +59 -0
  95. data/spec/models/inline_response2004_spec.rb +59 -0
  96. data/spec/models/inline_response2005_spec.rb +59 -0
  97. data/spec/models/inline_response2006_spec.rb +59 -0
  98. data/spec/models/inline_response2007_spec.rb +59 -0
  99. data/spec/models/inline_response200_spec.rb +59 -0
  100. data/spec/models/repository_sync_url_spec.rb +47 -0
  101. data/spec/models/role_spec.rb +77 -0
  102. data/spec/spec_helper.rb +111 -0
  103. metadata +357 -0
@@ -0,0 +1,229 @@
1
+ =begin
2
+ #Pulp 3 API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: v3
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.0.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module PulpAnsibleClient
16
+ class GalaxyRoleVersion
17
+ attr_accessor :name
18
+
19
+ attr_accessor :source
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'name' => :'name',
25
+ :'source' => :'source'
26
+ }
27
+ end
28
+
29
+ # Attribute type mapping.
30
+ def self.openapi_types
31
+ {
32
+ :'name' => :'String',
33
+ :'source' => :'String'
34
+ }
35
+ end
36
+
37
+ # Initializes the object
38
+ # @param [Hash] attributes Model attributes in the form of hash
39
+ def initialize(attributes = {})
40
+ if (!attributes.is_a?(Hash))
41
+ fail ArgumentError, "The input argument (attributes) must be a hash in `PulpAnsibleClient::GalaxyRoleVersion` initialize method"
42
+ end
43
+
44
+ # check to see if the attribute exists and convert string to symbol for hash key
45
+ attributes = attributes.each_with_object({}) { |(k, v), h|
46
+ if (!self.class.attribute_map.key?(k.to_sym))
47
+ fail ArgumentError, "`#{k}` is not a valid attribute in `PulpAnsibleClient::GalaxyRoleVersion`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
48
+ end
49
+ h[k.to_sym] = v
50
+ }
51
+
52
+ if attributes.key?(:'name')
53
+ self.name = attributes[:'name']
54
+ end
55
+
56
+ if attributes.key?(:'source')
57
+ self.source = attributes[:'source']
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 @name.nil?
66
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
67
+ end
68
+
69
+ if @name.to_s.length < 1
70
+ invalid_properties.push('invalid value for "name", the character length must be great than or equal to 1.')
71
+ end
72
+
73
+ invalid_properties
74
+ end
75
+
76
+ # Check to see if the all the properties in the model are valid
77
+ # @return true if the model is valid
78
+ def valid?
79
+ return false if @name.nil?
80
+ return false if @name.to_s.length < 1
81
+ true
82
+ end
83
+
84
+ # Custom attribute writer method with validation
85
+ # @param [Object] name Value to be assigned
86
+ def name=(name)
87
+ if name.nil?
88
+ fail ArgumentError, 'name cannot be nil'
89
+ end
90
+
91
+ if name.to_s.length < 1
92
+ fail ArgumentError, 'invalid value for "name", the character length must be great than or equal to 1.'
93
+ end
94
+
95
+ @name = name
96
+ end
97
+
98
+ # Checks equality by comparing each attribute.
99
+ # @param [Object] Object to be compared
100
+ def ==(o)
101
+ return true if self.equal?(o)
102
+ self.class == o.class &&
103
+ name == o.name &&
104
+ source == o.source
105
+ end
106
+
107
+ # @see the `==` method
108
+ # @param [Object] Object to be compared
109
+ def eql?(o)
110
+ self == o
111
+ end
112
+
113
+ # Calculates hash code according to all attributes.
114
+ # @return [Integer] Hash code
115
+ def hash
116
+ [name, source].hash
117
+ end
118
+
119
+ # Builds the object from hash
120
+ # @param [Hash] attributes Model attributes in the form of hash
121
+ # @return [Object] Returns the model itself
122
+ def self.build_from_hash(attributes)
123
+ new.build_from_hash(attributes)
124
+ end
125
+
126
+ # Builds the object from hash
127
+ # @param [Hash] attributes Model attributes in the form of hash
128
+ # @return [Object] Returns the model itself
129
+ def build_from_hash(attributes)
130
+ return nil unless attributes.is_a?(Hash)
131
+ self.class.openapi_types.each_pair do |key, type|
132
+ if type =~ /\AArray<(.*)>/i
133
+ # check to ensure the input is an array given that the attribute
134
+ # is documented as an array but the input is not
135
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
136
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
137
+ end
138
+ elsif !attributes[self.class.attribute_map[key]].nil?
139
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
140
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
141
+ end
142
+
143
+ self
144
+ end
145
+
146
+ # Deserializes the data based on type
147
+ # @param string type Data type
148
+ # @param string value Value to be deserialized
149
+ # @return [Object] Deserialized data
150
+ def _deserialize(type, value)
151
+ case type.to_sym
152
+ when :DateTime
153
+ DateTime.parse(value)
154
+ when :Date
155
+ Date.parse(value)
156
+ when :String
157
+ value.to_s
158
+ when :Integer
159
+ value.to_i
160
+ when :Float
161
+ value.to_f
162
+ when :Boolean
163
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
164
+ true
165
+ else
166
+ false
167
+ end
168
+ when :Object
169
+ # generic object (usually a Hash), return directly
170
+ value
171
+ when /\AArray<(?<inner_type>.+)>\z/
172
+ inner_type = Regexp.last_match[:inner_type]
173
+ value.map { |v| _deserialize(inner_type, v) }
174
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
175
+ k_type = Regexp.last_match[:k_type]
176
+ v_type = Regexp.last_match[:v_type]
177
+ {}.tap do |hash|
178
+ value.each do |k, v|
179
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
180
+ end
181
+ end
182
+ else # model
183
+ PulpAnsibleClient.const_get(type).build_from_hash(value)
184
+ end
185
+ end
186
+
187
+ # Returns the string representation of the object
188
+ # @return [String] String presentation of the object
189
+ def to_s
190
+ to_hash.to_s
191
+ end
192
+
193
+ # to_body is an alias to to_hash (backward compatibility)
194
+ # @return [Hash] Returns the object in the form of hash
195
+ def to_body
196
+ to_hash
197
+ end
198
+
199
+ # Returns the object in the form of hash
200
+ # @return [Hash] Returns the object in the form of hash
201
+ def to_hash
202
+ hash = {}
203
+ self.class.attribute_map.each_pair do |attr, param|
204
+ value = self.send(attr)
205
+ next if value.nil?
206
+ hash[param] = _to_hash(value)
207
+ end
208
+ hash
209
+ end
210
+
211
+ # Outputs non-array value in the form of hash
212
+ # For object, use to_hash. Otherwise, just return the value
213
+ # @param [Object] value Any valid value
214
+ # @return [Hash] Returns the value in the form of hash
215
+ def _to_hash(value)
216
+ if value.is_a?(Array)
217
+ value.compact.map { |v| _to_hash(v) }
218
+ elsif value.is_a?(Hash)
219
+ {}.tap do |hash|
220
+ value.each { |k, v| hash[k] = _to_hash(v) }
221
+ end
222
+ elsif value.respond_to? :to_hash
223
+ value.to_hash
224
+ else
225
+ value
226
+ end
227
+ end
228
+ end
229
+ end
@@ -0,0 +1,235 @@
1
+ =begin
2
+ #Pulp 3 API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: v3
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.0.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module PulpAnsibleClient
16
+ class InlineResponse200
17
+ attr_accessor :_next
18
+
19
+ attr_accessor :previous
20
+
21
+ attr_accessor :count
22
+
23
+ attr_accessor :results
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'_next' => :'next',
29
+ :'previous' => :'previous',
30
+ :'count' => :'count',
31
+ :'results' => :'results'
32
+ }
33
+ end
34
+
35
+ # Attribute type mapping.
36
+ def self.openapi_types
37
+ {
38
+ :'_next' => :'String',
39
+ :'previous' => :'String',
40
+ :'count' => :'Integer',
41
+ :'results' => :'Array<Collection>'
42
+ }
43
+ end
44
+
45
+ # Initializes the object
46
+ # @param [Hash] attributes Model attributes in the form of hash
47
+ def initialize(attributes = {})
48
+ if (!attributes.is_a?(Hash))
49
+ fail ArgumentError, "The input argument (attributes) must be a hash in `PulpAnsibleClient::InlineResponse200` initialize method"
50
+ end
51
+
52
+ # check to see if the attribute exists and convert string to symbol for hash key
53
+ attributes = attributes.each_with_object({}) { |(k, v), h|
54
+ if (!self.class.attribute_map.key?(k.to_sym))
55
+ fail ArgumentError, "`#{k}` is not a valid attribute in `PulpAnsibleClient::InlineResponse200`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
56
+ end
57
+ h[k.to_sym] = v
58
+ }
59
+
60
+ if attributes.key?(:'_next')
61
+ self._next = attributes[:'_next']
62
+ end
63
+
64
+ if attributes.key?(:'previous')
65
+ self.previous = attributes[:'previous']
66
+ end
67
+
68
+ if attributes.key?(:'count')
69
+ self.count = attributes[:'count']
70
+ end
71
+
72
+ if attributes.key?(:'results')
73
+ if (value = attributes[:'results']).is_a?(Array)
74
+ self.results = value
75
+ end
76
+ end
77
+ end
78
+
79
+ # Show invalid properties with the reasons. Usually used together with valid?
80
+ # @return Array for valid properties with the reasons
81
+ def list_invalid_properties
82
+ invalid_properties = Array.new
83
+ if @count.nil?
84
+ invalid_properties.push('invalid value for "count", count cannot be nil.')
85
+ end
86
+
87
+ if @results.nil?
88
+ invalid_properties.push('invalid value for "results", results cannot be nil.')
89
+ end
90
+
91
+ invalid_properties
92
+ end
93
+
94
+ # Check to see if the all the properties in the model are valid
95
+ # @return true if the model is valid
96
+ def valid?
97
+ return false if @count.nil?
98
+ return false if @results.nil?
99
+ true
100
+ end
101
+
102
+ # Checks equality by comparing each attribute.
103
+ # @param [Object] Object to be compared
104
+ def ==(o)
105
+ return true if self.equal?(o)
106
+ self.class == o.class &&
107
+ _next == o._next &&
108
+ previous == o.previous &&
109
+ count == o.count &&
110
+ results == o.results
111
+ end
112
+
113
+ # @see the `==` method
114
+ # @param [Object] Object to be compared
115
+ def eql?(o)
116
+ self == o
117
+ end
118
+
119
+ # Calculates hash code according to all attributes.
120
+ # @return [Integer] Hash code
121
+ def hash
122
+ [_next, previous, count, results].hash
123
+ end
124
+
125
+ # Builds the object from hash
126
+ # @param [Hash] attributes Model attributes in the form of hash
127
+ # @return [Object] Returns the model itself
128
+ def self.build_from_hash(attributes)
129
+ new.build_from_hash(attributes)
130
+ end
131
+
132
+ # Builds the object from hash
133
+ # @param [Hash] attributes Model attributes in the form of hash
134
+ # @return [Object] Returns the model itself
135
+ def build_from_hash(attributes)
136
+ return nil unless attributes.is_a?(Hash)
137
+ self.class.openapi_types.each_pair do |key, type|
138
+ if type =~ /\AArray<(.*)>/i
139
+ # check to ensure the input is an array given that the attribute
140
+ # is documented as an array but the input is not
141
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
142
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
143
+ end
144
+ elsif !attributes[self.class.attribute_map[key]].nil?
145
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
146
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
147
+ end
148
+
149
+ self
150
+ end
151
+
152
+ # Deserializes the data based on type
153
+ # @param string type Data type
154
+ # @param string value Value to be deserialized
155
+ # @return [Object] Deserialized data
156
+ def _deserialize(type, value)
157
+ case type.to_sym
158
+ when :DateTime
159
+ DateTime.parse(value)
160
+ when :Date
161
+ Date.parse(value)
162
+ when :String
163
+ value.to_s
164
+ when :Integer
165
+ value.to_i
166
+ when :Float
167
+ value.to_f
168
+ when :Boolean
169
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
170
+ true
171
+ else
172
+ false
173
+ end
174
+ when :Object
175
+ # generic object (usually a Hash), return directly
176
+ value
177
+ when /\AArray<(?<inner_type>.+)>\z/
178
+ inner_type = Regexp.last_match[:inner_type]
179
+ value.map { |v| _deserialize(inner_type, v) }
180
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
181
+ k_type = Regexp.last_match[:k_type]
182
+ v_type = Regexp.last_match[:v_type]
183
+ {}.tap do |hash|
184
+ value.each do |k, v|
185
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
186
+ end
187
+ end
188
+ else # model
189
+ PulpAnsibleClient.const_get(type).build_from_hash(value)
190
+ end
191
+ end
192
+
193
+ # Returns the string representation of the object
194
+ # @return [String] String presentation of the object
195
+ def to_s
196
+ to_hash.to_s
197
+ end
198
+
199
+ # to_body is an alias to to_hash (backward compatibility)
200
+ # @return [Hash] Returns the object in the form of hash
201
+ def to_body
202
+ to_hash
203
+ end
204
+
205
+ # Returns the object in the form of hash
206
+ # @return [Hash] Returns the object in the form of hash
207
+ def to_hash
208
+ hash = {}
209
+ self.class.attribute_map.each_pair do |attr, param|
210
+ value = self.send(attr)
211
+ next if value.nil?
212
+ hash[param] = _to_hash(value)
213
+ end
214
+ hash
215
+ end
216
+
217
+ # Outputs non-array value in the form of hash
218
+ # For object, use to_hash. Otherwise, just return the value
219
+ # @param [Object] value Any valid value
220
+ # @return [Hash] Returns the value in the form of hash
221
+ def _to_hash(value)
222
+ if value.is_a?(Array)
223
+ value.compact.map { |v| _to_hash(v) }
224
+ elsif value.is_a?(Hash)
225
+ {}.tap do |hash|
226
+ value.each { |k, v| hash[k] = _to_hash(v) }
227
+ end
228
+ elsif value.respond_to? :to_hash
229
+ value.to_hash
230
+ else
231
+ value
232
+ end
233
+ end
234
+ end
235
+ end
@@ -0,0 +1,235 @@
1
+ =begin
2
+ #Pulp 3 API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: v3
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.0.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module PulpAnsibleClient
16
+ class InlineResponse2001
17
+ attr_accessor :_next
18
+
19
+ attr_accessor :previous
20
+
21
+ attr_accessor :count
22
+
23
+ attr_accessor :results
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'_next' => :'next',
29
+ :'previous' => :'previous',
30
+ :'count' => :'count',
31
+ :'results' => :'results'
32
+ }
33
+ end
34
+
35
+ # Attribute type mapping.
36
+ def self.openapi_types
37
+ {
38
+ :'_next' => :'String',
39
+ :'previous' => :'String',
40
+ :'count' => :'Integer',
41
+ :'results' => :'Array<Role>'
42
+ }
43
+ end
44
+
45
+ # Initializes the object
46
+ # @param [Hash] attributes Model attributes in the form of hash
47
+ def initialize(attributes = {})
48
+ if (!attributes.is_a?(Hash))
49
+ fail ArgumentError, "The input argument (attributes) must be a hash in `PulpAnsibleClient::InlineResponse2001` initialize method"
50
+ end
51
+
52
+ # check to see if the attribute exists and convert string to symbol for hash key
53
+ attributes = attributes.each_with_object({}) { |(k, v), h|
54
+ if (!self.class.attribute_map.key?(k.to_sym))
55
+ fail ArgumentError, "`#{k}` is not a valid attribute in `PulpAnsibleClient::InlineResponse2001`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
56
+ end
57
+ h[k.to_sym] = v
58
+ }
59
+
60
+ if attributes.key?(:'_next')
61
+ self._next = attributes[:'_next']
62
+ end
63
+
64
+ if attributes.key?(:'previous')
65
+ self.previous = attributes[:'previous']
66
+ end
67
+
68
+ if attributes.key?(:'count')
69
+ self.count = attributes[:'count']
70
+ end
71
+
72
+ if attributes.key?(:'results')
73
+ if (value = attributes[:'results']).is_a?(Array)
74
+ self.results = value
75
+ end
76
+ end
77
+ end
78
+
79
+ # Show invalid properties with the reasons. Usually used together with valid?
80
+ # @return Array for valid properties with the reasons
81
+ def list_invalid_properties
82
+ invalid_properties = Array.new
83
+ if @count.nil?
84
+ invalid_properties.push('invalid value for "count", count cannot be nil.')
85
+ end
86
+
87
+ if @results.nil?
88
+ invalid_properties.push('invalid value for "results", results cannot be nil.')
89
+ end
90
+
91
+ invalid_properties
92
+ end
93
+
94
+ # Check to see if the all the properties in the model are valid
95
+ # @return true if the model is valid
96
+ def valid?
97
+ return false if @count.nil?
98
+ return false if @results.nil?
99
+ true
100
+ end
101
+
102
+ # Checks equality by comparing each attribute.
103
+ # @param [Object] Object to be compared
104
+ def ==(o)
105
+ return true if self.equal?(o)
106
+ self.class == o.class &&
107
+ _next == o._next &&
108
+ previous == o.previous &&
109
+ count == o.count &&
110
+ results == o.results
111
+ end
112
+
113
+ # @see the `==` method
114
+ # @param [Object] Object to be compared
115
+ def eql?(o)
116
+ self == o
117
+ end
118
+
119
+ # Calculates hash code according to all attributes.
120
+ # @return [Integer] Hash code
121
+ def hash
122
+ [_next, previous, count, results].hash
123
+ end
124
+
125
+ # Builds the object from hash
126
+ # @param [Hash] attributes Model attributes in the form of hash
127
+ # @return [Object] Returns the model itself
128
+ def self.build_from_hash(attributes)
129
+ new.build_from_hash(attributes)
130
+ end
131
+
132
+ # Builds the object from hash
133
+ # @param [Hash] attributes Model attributes in the form of hash
134
+ # @return [Object] Returns the model itself
135
+ def build_from_hash(attributes)
136
+ return nil unless attributes.is_a?(Hash)
137
+ self.class.openapi_types.each_pair do |key, type|
138
+ if type =~ /\AArray<(.*)>/i
139
+ # check to ensure the input is an array given that the attribute
140
+ # is documented as an array but the input is not
141
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
142
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
143
+ end
144
+ elsif !attributes[self.class.attribute_map[key]].nil?
145
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
146
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
147
+ end
148
+
149
+ self
150
+ end
151
+
152
+ # Deserializes the data based on type
153
+ # @param string type Data type
154
+ # @param string value Value to be deserialized
155
+ # @return [Object] Deserialized data
156
+ def _deserialize(type, value)
157
+ case type.to_sym
158
+ when :DateTime
159
+ DateTime.parse(value)
160
+ when :Date
161
+ Date.parse(value)
162
+ when :String
163
+ value.to_s
164
+ when :Integer
165
+ value.to_i
166
+ when :Float
167
+ value.to_f
168
+ when :Boolean
169
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
170
+ true
171
+ else
172
+ false
173
+ end
174
+ when :Object
175
+ # generic object (usually a Hash), return directly
176
+ value
177
+ when /\AArray<(?<inner_type>.+)>\z/
178
+ inner_type = Regexp.last_match[:inner_type]
179
+ value.map { |v| _deserialize(inner_type, v) }
180
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
181
+ k_type = Regexp.last_match[:k_type]
182
+ v_type = Regexp.last_match[:v_type]
183
+ {}.tap do |hash|
184
+ value.each do |k, v|
185
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
186
+ end
187
+ end
188
+ else # model
189
+ PulpAnsibleClient.const_get(type).build_from_hash(value)
190
+ end
191
+ end
192
+
193
+ # Returns the string representation of the object
194
+ # @return [String] String presentation of the object
195
+ def to_s
196
+ to_hash.to_s
197
+ end
198
+
199
+ # to_body is an alias to to_hash (backward compatibility)
200
+ # @return [Hash] Returns the object in the form of hash
201
+ def to_body
202
+ to_hash
203
+ end
204
+
205
+ # Returns the object in the form of hash
206
+ # @return [Hash] Returns the object in the form of hash
207
+ def to_hash
208
+ hash = {}
209
+ self.class.attribute_map.each_pair do |attr, param|
210
+ value = self.send(attr)
211
+ next if value.nil?
212
+ hash[param] = _to_hash(value)
213
+ end
214
+ hash
215
+ end
216
+
217
+ # Outputs non-array value in the form of hash
218
+ # For object, use to_hash. Otherwise, just return the value
219
+ # @param [Object] value Any valid value
220
+ # @return [Hash] Returns the value in the form of hash
221
+ def _to_hash(value)
222
+ if value.is_a?(Array)
223
+ value.compact.map { |v| _to_hash(v) }
224
+ elsif value.is_a?(Hash)
225
+ {}.tap do |hash|
226
+ value.each { |k, v| hash[k] = _to_hash(v) }
227
+ end
228
+ elsif value.respond_to? :to_hash
229
+ value.to_hash
230
+ else
231
+ value
232
+ end
233
+ end
234
+ end
235
+ end