pulp_ansible_client 0.2.0b1 → 0.2.0b2

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