pulpcore_client 3.20.0 → 3.21.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +8 -84
  3. data/docs/ContentApi.md +1 -115
  4. data/docs/ContentguardsApi.md +1 -280
  5. data/docs/DistributionsApi.md +3 -281
  6. data/docs/PublicationsApi.md +0 -113
  7. data/docs/PulpImport.md +3 -1
  8. data/docs/RemotesApi.md +0 -280
  9. data/docs/RepositoriesApi.md +3 -281
  10. data/docs/UploadsApi.md +228 -0
  11. data/lib/pulpcore_client/api/content_api.rb +2 -134
  12. data/lib/pulpcore_client/api/contentguards_api.rb +2 -334
  13. data/lib/pulpcore_client/api/distributions_api.rb +5 -336
  14. data/lib/pulpcore_client/api/publications_api.rb +0 -128
  15. data/lib/pulpcore_client/api/remotes_api.rb +0 -334
  16. data/lib/pulpcore_client/api/repositories_api.rb +5 -336
  17. data/lib/pulpcore_client/api/repository_versions_api.rb +1 -1
  18. data/lib/pulpcore_client/api/uploads_api.rb +268 -0
  19. data/lib/pulpcore_client/api_client.rb +1 -1
  20. data/lib/pulpcore_client/models/pulp_import.rb +16 -4
  21. data/lib/pulpcore_client/version.rb +1 -1
  22. data/lib/pulpcore_client.rb +0 -31
  23. data/pulpcore_client.gemspec +3 -3
  24. data/spec/api/content_api_spec.rb +1 -27
  25. data/spec/api/contentguards_api_spec.rb +1 -65
  26. data/spec/api/distributions_api_spec.rb +2 -65
  27. data/spec/api/publications_api_spec.rb +0 -26
  28. data/spec/api/remotes_api_spec.rb +0 -64
  29. data/spec/api/repositories_api_spec.rb +2 -65
  30. data/spec/api/uploads_api_spec.rb +50 -0
  31. data/spec/models/pulp_import_spec.rb +6 -0
  32. metadata +136 -261
  33. data/docs/AcsApi.md +0 -417
  34. data/docs/AlternateContentSource.md +0 -23
  35. data/docs/AlternateContentSourceResponse.md +0 -27
  36. data/docs/ContentGuard.md +0 -19
  37. data/docs/Distribution.md +0 -25
  38. data/docs/Export.md +0 -17
  39. data/docs/ExportResponse.md +0 -25
  40. data/docs/Exporter.md +0 -17
  41. data/docs/ExporterResponse.md +0 -21
  42. data/docs/ExportersApi.md +0 -362
  43. data/docs/ExportersExportsApi.md +0 -241
  44. data/docs/Import.md +0 -19
  45. data/docs/Importer.md +0 -17
  46. data/docs/ImporterResponse.md +0 -21
  47. data/docs/ImportersApi.md +0 -361
  48. data/docs/ImportersImportsApi.md +0 -241
  49. data/docs/MultipleArtifactContent.md +0 -17
  50. data/docs/PaginatedAlternateContentSourceResponseList.md +0 -23
  51. data/docs/PaginatedExportResponseList.md +0 -23
  52. data/docs/PaginatedExporterResponseList.md +0 -23
  53. data/docs/PaginatedImporterResponseList.md +0 -23
  54. data/docs/PatchedAlternateContentSource.md +0 -23
  55. data/docs/PatchedContentGuard.md +0 -19
  56. data/docs/PatchedDistribution.md +0 -25
  57. data/docs/PatchedExporter.md +0 -17
  58. data/docs/PatchedImporter.md +0 -17
  59. data/docs/PatchedRemote.md +0 -57
  60. data/docs/PatchedRepository.md +0 -25
  61. data/docs/Remote.md +0 -57
  62. data/docs/RepositoriesVersionsApi.md +0 -271
  63. data/docs/Repository.md +0 -25
  64. data/git_push.sh +0 -58
  65. data/lib/pulpcore_client/api/acs_api.rb +0 -514
  66. data/lib/pulpcore_client/api/exporters_api.rb +0 -446
  67. data/lib/pulpcore_client/api/exporters_exports_api.rb +0 -294
  68. data/lib/pulpcore_client/api/importers_api.rb +0 -444
  69. data/lib/pulpcore_client/api/importers_imports_api.rb +0 -294
  70. data/lib/pulpcore_client/api/repositories_versions_api.rb +0 -343
  71. data/lib/pulpcore_client/models/alternate_content_source.rb +0 -270
  72. data/lib/pulpcore_client/models/alternate_content_source_response.rb +0 -270
  73. data/lib/pulpcore_client/models/content_guard.rb +0 -258
  74. data/lib/pulpcore_client/models/distribution.rb +0 -297
  75. data/lib/pulpcore_client/models/export.rb +0 -209
  76. data/lib/pulpcore_client/models/export_response.rb +0 -250
  77. data/lib/pulpcore_client/models/exporter.rb +0 -232
  78. data/lib/pulpcore_client/models/exporter_response.rb +0 -232
  79. data/lib/pulpcore_client/models/import.rb +0 -228
  80. data/lib/pulpcore_client/models/importer.rb +0 -232
  81. data/lib/pulpcore_client/models/importer_response.rb +0 -232
  82. data/lib/pulpcore_client/models/multiple_artifact_content.rb +0 -213
  83. data/lib/pulpcore_client/models/paginated_alternate_content_source_response_list.rb +0 -237
  84. data/lib/pulpcore_client/models/paginated_export_response_list.rb +0 -237
  85. data/lib/pulpcore_client/models/paginated_exporter_response_list.rb +0 -237
  86. data/lib/pulpcore_client/models/paginated_importer_response_list.rb +0 -237
  87. data/lib/pulpcore_client/models/patched_alternate_content_source.rb +0 -256
  88. data/lib/pulpcore_client/models/patched_content_guard.rb +0 -249
  89. data/lib/pulpcore_client/models/patched_distribution.rb +0 -279
  90. data/lib/pulpcore_client/models/patched_exporter.rb +0 -223
  91. data/lib/pulpcore_client/models/patched_importer.rb +0 -223
  92. data/lib/pulpcore_client/models/patched_remote.rb +0 -649
  93. data/lib/pulpcore_client/models/patched_repository.rb +0 -295
  94. data/lib/pulpcore_client/models/remote.rb +0 -667
  95. data/lib/pulpcore_client/models/repository.rb +0 -304
  96. data/spec/api/acs_api_spec.rb +0 -132
  97. data/spec/api/exporters_api_spec.rb +0 -120
  98. data/spec/api/exporters_exports_api_spec.rb +0 -90
  99. data/spec/api/importers_api_spec.rb +0 -120
  100. data/spec/api/importers_imports_api_spec.rb +0 -90
  101. data/spec/api/repositories_versions_api_spec.rb +0 -104
  102. data/spec/models/alternate_content_source_response_spec.rb +0 -71
  103. data/spec/models/alternate_content_source_spec.rb +0 -59
  104. data/spec/models/content_guard_spec.rb +0 -47
  105. data/spec/models/distribution_spec.rb +0 -65
  106. data/spec/models/export_response_spec.rb +0 -65
  107. data/spec/models/export_spec.rb +0 -41
  108. data/spec/models/exporter_response_spec.rb +0 -53
  109. data/spec/models/exporter_spec.rb +0 -41
  110. data/spec/models/import_spec.rb +0 -47
  111. data/spec/models/importer_response_spec.rb +0 -53
  112. data/spec/models/importer_spec.rb +0 -41
  113. data/spec/models/multiple_artifact_content_spec.rb +0 -41
  114. data/spec/models/paginated_alternate_content_source_response_list_spec.rb +0 -59
  115. data/spec/models/paginated_export_response_list_spec.rb +0 -59
  116. data/spec/models/paginated_exporter_response_list_spec.rb +0 -59
  117. data/spec/models/paginated_importer_response_list_spec.rb +0 -59
  118. data/spec/models/patched_alternate_content_source_spec.rb +0 -59
  119. data/spec/models/patched_content_guard_spec.rb +0 -47
  120. data/spec/models/patched_distribution_spec.rb +0 -65
  121. data/spec/models/patched_exporter_spec.rb +0 -41
  122. data/spec/models/patched_importer_spec.rb +0 -41
  123. data/spec/models/patched_remote_spec.rb +0 -161
  124. data/spec/models/patched_repository_spec.rb +0 -65
  125. data/spec/models/remote_spec.rb +0 -161
  126. data/spec/models/repository_spec.rb +0 -65
@@ -1,258 +0,0 @@
1
- =begin
2
- #Pulp 3 API
3
-
4
- #Fetch, Upload, Organize, and Distribute Software Packages
5
-
6
- The version of the OpenAPI document: v3
7
- Contact: pulp-list@redhat.com
8
- Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 4.3.1
10
-
11
- =end
12
-
13
- require 'date'
14
-
15
- module PulpcoreClient
16
- # Base serializer for use with :class:`pulpcore.app.models.Model` This ensures that all Serializers provide values for the 'pulp_href` field. The class provides a default for the ``ref_name`` attribute in the ModelSerializers's ``Meta`` class. This ensures that the OpenAPI definitions of plugins are namespaced properly.
17
- class ContentGuard
18
- # The unique name.
19
- attr_accessor :name
20
-
21
- # An optional description.
22
- attr_accessor :description
23
-
24
- # Attribute mapping from ruby-style variable name to JSON key.
25
- def self.attribute_map
26
- {
27
- :'name' => :'name',
28
- :'description' => :'description'
29
- }
30
- end
31
-
32
- # Attribute type mapping.
33
- def self.openapi_types
34
- {
35
- :'name' => :'String',
36
- :'description' => :'String'
37
- }
38
- end
39
-
40
- # List of attributes with nullable: true
41
- def self.openapi_nullable
42
- Set.new([
43
- :'description'
44
- ])
45
- end
46
-
47
- # Initializes the object
48
- # @param [Hash] attributes Model attributes in the form of hash
49
- def initialize(attributes = {})
50
- if (!attributes.is_a?(Hash))
51
- fail ArgumentError, "The input argument (attributes) must be a hash in `PulpcoreClient::ContentGuard` initialize method"
52
- end
53
-
54
- # check to see if the attribute exists and convert string to symbol for hash key
55
- attributes = attributes.each_with_object({}) { |(k, v), h|
56
- if (!self.class.attribute_map.key?(k.to_sym))
57
- fail ArgumentError, "`#{k}` is not a valid attribute in `PulpcoreClient::ContentGuard`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
58
- end
59
- h[k.to_sym] = v
60
- }
61
-
62
- if attributes.key?(:'name')
63
- self.name = attributes[:'name']
64
- end
65
-
66
- if attributes.key?(:'description')
67
- self.description = attributes[:'description']
68
- end
69
- end
70
-
71
- # Show invalid properties with the reasons. Usually used together with valid?
72
- # @return Array for valid properties with the reasons
73
- def list_invalid_properties
74
- invalid_properties = Array.new
75
- if @name.nil?
76
- invalid_properties.push('invalid value for "name", name cannot be nil.')
77
- end
78
-
79
- if @name.to_s.length < 1
80
- invalid_properties.push('invalid value for "name", the character length must be great than or equal to 1.')
81
- end
82
-
83
- if !@description.nil? && @description.to_s.length < 1
84
- invalid_properties.push('invalid value for "description", the character length must be great than or equal to 1.')
85
- end
86
-
87
- invalid_properties
88
- end
89
-
90
- # Check to see if the all the properties in the model are valid
91
- # @return true if the model is valid
92
- def valid?
93
- return false if @name.nil?
94
- return false if @name.to_s.length < 1
95
- return false if !@description.nil? && @description.to_s.length < 1
96
- true
97
- end
98
-
99
- # Custom attribute writer method with validation
100
- # @param [Object] name Value to be assigned
101
- def name=(name)
102
- if name.nil?
103
- fail ArgumentError, 'name cannot be nil'
104
- end
105
-
106
- if name.to_s.length < 1
107
- fail ArgumentError, 'invalid value for "name", the character length must be great than or equal to 1.'
108
- end
109
-
110
- @name = name
111
- end
112
-
113
- # Custom attribute writer method with validation
114
- # @param [Object] description Value to be assigned
115
- def description=(description)
116
- if !description.nil? && description.to_s.length < 1
117
- fail ArgumentError, 'invalid value for "description", the character length must be great than or equal to 1.'
118
- end
119
-
120
- @description = description
121
- end
122
-
123
- # Checks equality by comparing each attribute.
124
- # @param [Object] Object to be compared
125
- def ==(o)
126
- return true if self.equal?(o)
127
- self.class == o.class &&
128
- name == o.name &&
129
- description == o.description
130
- end
131
-
132
- # @see the `==` method
133
- # @param [Object] Object to be compared
134
- def eql?(o)
135
- self == o
136
- end
137
-
138
- # Calculates hash code according to all attributes.
139
- # @return [Integer] Hash code
140
- def hash
141
- [name, description].hash
142
- end
143
-
144
- # Builds the object from hash
145
- # @param [Hash] attributes Model attributes in the form of hash
146
- # @return [Object] Returns the model itself
147
- def self.build_from_hash(attributes)
148
- new.build_from_hash(attributes)
149
- end
150
-
151
- # Builds the object from hash
152
- # @param [Hash] attributes Model attributes in the form of hash
153
- # @return [Object] Returns the model itself
154
- def build_from_hash(attributes)
155
- return nil unless attributes.is_a?(Hash)
156
- self.class.openapi_types.each_pair do |key, type|
157
- if type =~ /\AArray<(.*)>/i
158
- # check to ensure the input is an array given that the attribute
159
- # is documented as an array but the input is not
160
- if attributes[self.class.attribute_map[key]].is_a?(Array)
161
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
162
- end
163
- elsif !attributes[self.class.attribute_map[key]].nil?
164
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
165
- end # or else data not found in attributes(hash), not an issue as the data can be optional
166
- end
167
-
168
- self
169
- end
170
-
171
- # Deserializes the data based on type
172
- # @param string type Data type
173
- # @param string value Value to be deserialized
174
- # @return [Object] Deserialized data
175
- def _deserialize(type, value)
176
- case type.to_sym
177
- when :DateTime
178
- DateTime.parse(value)
179
- when :Date
180
- Date.parse(value)
181
- when :String
182
- value.to_s
183
- when :Integer
184
- value.to_i
185
- when :Float
186
- value.to_f
187
- when :Boolean
188
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
189
- true
190
- else
191
- false
192
- end
193
- when :Object
194
- # generic object (usually a Hash), return directly
195
- value
196
- when /\AArray<(?<inner_type>.+)>\z/
197
- inner_type = Regexp.last_match[:inner_type]
198
- value.map { |v| _deserialize(inner_type, v) }
199
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
200
- k_type = Regexp.last_match[:k_type]
201
- v_type = Regexp.last_match[:v_type]
202
- {}.tap do |hash|
203
- value.each do |k, v|
204
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
205
- end
206
- end
207
- else # model
208
- PulpcoreClient.const_get(type).build_from_hash(value)
209
- end
210
- end
211
-
212
- # Returns the string representation of the object
213
- # @return [String] String presentation of the object
214
- def to_s
215
- to_hash.to_s
216
- end
217
-
218
- # to_body is an alias to to_hash (backward compatibility)
219
- # @return [Hash] Returns the object in the form of hash
220
- def to_body
221
- to_hash
222
- end
223
-
224
- # Returns the object in the form of hash
225
- # @return [Hash] Returns the object in the form of hash
226
- def to_hash
227
- hash = {}
228
- self.class.attribute_map.each_pair do |attr, param|
229
- value = self.send(attr)
230
- if value.nil?
231
- is_nullable = self.class.openapi_nullable.include?(attr)
232
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
233
- end
234
-
235
- hash[param] = _to_hash(value)
236
- end
237
- hash
238
- end
239
-
240
- # Outputs non-array value in the form of hash
241
- # For object, use to_hash. Otherwise, just return the value
242
- # @param [Object] value Any valid value
243
- # @return [Hash] Returns the value in the form of hash
244
- def _to_hash(value)
245
- if value.is_a?(Array)
246
- value.compact.map { |v| _to_hash(v) }
247
- elsif value.is_a?(Hash)
248
- {}.tap do |hash|
249
- value.each { |k, v| hash[k] = _to_hash(v) }
250
- end
251
- elsif value.respond_to? :to_hash
252
- value.to_hash
253
- else
254
- value
255
- end
256
- end
257
- end
258
- end
@@ -1,297 +0,0 @@
1
- =begin
2
- #Pulp 3 API
3
-
4
- #Fetch, Upload, Organize, and Distribute Software Packages
5
-
6
- The version of the OpenAPI document: v3
7
- Contact: pulp-list@redhat.com
8
- Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 4.3.1
10
-
11
- =end
12
-
13
- require 'date'
14
-
15
- module PulpcoreClient
16
- # The Serializer for the Distribution model. The serializer deliberately omits the `publication` and `repository_version` field due to plugins typically requiring one or the other but not both. To include the ``publication`` field, it is recommended plugins define the field:: publication = DetailRelatedField( required=False, help_text=_(\"Publication to be served\"), view_name_pattern=r\"publications(-.*/.*)?-detail\", queryset=models.Publication.objects.exclude(complete=False), allow_null=True, ) To include the ``repository_version`` field, it is recommended plugins define the field:: repository_version = RepositoryVersionRelatedField( required=False, help_text=_(\"RepositoryVersion to be served\"), allow_null=True ) Additionally, the serializer omits the ``remote`` field, which is used for pull-through caching feature and only by plugins which use publications. Plugins implementing a pull-through caching should define the field in their derived serializer class like this:: remote = DetailRelatedField( required=False, help_text=_('Remote that can be used to fetch content when using pull-through caching.'), queryset=models.Remote.objects.all(), allow_null=True )
17
- class Distribution
18
- # The base (relative) path component of the published url. Avoid paths that overlap with other distribution base paths (e.g. \"foo\" and \"foo/bar\")
19
- attr_accessor :base_path
20
-
21
- # An optional content-guard.
22
- attr_accessor :content_guard
23
-
24
- attr_accessor :pulp_labels
25
-
26
- # A unique name. Ex, `rawhide` and `stable`.
27
- attr_accessor :name
28
-
29
- # The latest RepositoryVersion for this Repository will be served.
30
- attr_accessor :repository
31
-
32
- # Attribute mapping from ruby-style variable name to JSON key.
33
- def self.attribute_map
34
- {
35
- :'base_path' => :'base_path',
36
- :'content_guard' => :'content_guard',
37
- :'pulp_labels' => :'pulp_labels',
38
- :'name' => :'name',
39
- :'repository' => :'repository'
40
- }
41
- end
42
-
43
- # Attribute type mapping.
44
- def self.openapi_types
45
- {
46
- :'base_path' => :'String',
47
- :'content_guard' => :'String',
48
- :'pulp_labels' => :'Object',
49
- :'name' => :'String',
50
- :'repository' => :'String'
51
- }
52
- end
53
-
54
- # List of attributes with nullable: true
55
- def self.openapi_nullable
56
- Set.new([
57
- :'content_guard',
58
- :'repository'
59
- ])
60
- end
61
-
62
- # Initializes the object
63
- # @param [Hash] attributes Model attributes in the form of hash
64
- def initialize(attributes = {})
65
- if (!attributes.is_a?(Hash))
66
- fail ArgumentError, "The input argument (attributes) must be a hash in `PulpcoreClient::Distribution` initialize method"
67
- end
68
-
69
- # check to see if the attribute exists and convert string to symbol for hash key
70
- attributes = attributes.each_with_object({}) { |(k, v), h|
71
- if (!self.class.attribute_map.key?(k.to_sym))
72
- fail ArgumentError, "`#{k}` is not a valid attribute in `PulpcoreClient::Distribution`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
73
- end
74
- h[k.to_sym] = v
75
- }
76
-
77
- if attributes.key?(:'base_path')
78
- self.base_path = attributes[:'base_path']
79
- end
80
-
81
- if attributes.key?(:'content_guard')
82
- self.content_guard = attributes[:'content_guard']
83
- end
84
-
85
- if attributes.key?(:'pulp_labels')
86
- self.pulp_labels = attributes[:'pulp_labels']
87
- end
88
-
89
- if attributes.key?(:'name')
90
- self.name = attributes[:'name']
91
- end
92
-
93
- if attributes.key?(:'repository')
94
- self.repository = attributes[:'repository']
95
- end
96
- end
97
-
98
- # Show invalid properties with the reasons. Usually used together with valid?
99
- # @return Array for valid properties with the reasons
100
- def list_invalid_properties
101
- invalid_properties = Array.new
102
- if @base_path.nil?
103
- invalid_properties.push('invalid value for "base_path", base_path cannot be nil.')
104
- end
105
-
106
- if @base_path.to_s.length < 1
107
- invalid_properties.push('invalid value for "base_path", the character length must be great than or equal to 1.')
108
- end
109
-
110
- if @name.nil?
111
- invalid_properties.push('invalid value for "name", name cannot be nil.')
112
- end
113
-
114
- if @name.to_s.length < 1
115
- invalid_properties.push('invalid value for "name", the character length must be great than or equal to 1.')
116
- end
117
-
118
- invalid_properties
119
- end
120
-
121
- # Check to see if the all the properties in the model are valid
122
- # @return true if the model is valid
123
- def valid?
124
- return false if @base_path.nil?
125
- return false if @base_path.to_s.length < 1
126
- return false if @name.nil?
127
- return false if @name.to_s.length < 1
128
- true
129
- end
130
-
131
- # Custom attribute writer method with validation
132
- # @param [Object] base_path Value to be assigned
133
- def base_path=(base_path)
134
- if base_path.nil?
135
- fail ArgumentError, 'base_path cannot be nil'
136
- end
137
-
138
- if base_path.to_s.length < 1
139
- fail ArgumentError, 'invalid value for "base_path", the character length must be great than or equal to 1.'
140
- end
141
-
142
- @base_path = base_path
143
- end
144
-
145
- # Custom attribute writer method with validation
146
- # @param [Object] name Value to be assigned
147
- def name=(name)
148
- if name.nil?
149
- fail ArgumentError, 'name cannot be nil'
150
- end
151
-
152
- if name.to_s.length < 1
153
- fail ArgumentError, 'invalid value for "name", the character length must be great than or equal to 1.'
154
- end
155
-
156
- @name = name
157
- end
158
-
159
- # Checks equality by comparing each attribute.
160
- # @param [Object] Object to be compared
161
- def ==(o)
162
- return true if self.equal?(o)
163
- self.class == o.class &&
164
- base_path == o.base_path &&
165
- content_guard == o.content_guard &&
166
- pulp_labels == o.pulp_labels &&
167
- name == o.name &&
168
- repository == o.repository
169
- end
170
-
171
- # @see the `==` method
172
- # @param [Object] Object to be compared
173
- def eql?(o)
174
- self == o
175
- end
176
-
177
- # Calculates hash code according to all attributes.
178
- # @return [Integer] Hash code
179
- def hash
180
- [base_path, content_guard, pulp_labels, name, repository].hash
181
- end
182
-
183
- # Builds the object from hash
184
- # @param [Hash] attributes Model attributes in the form of hash
185
- # @return [Object] Returns the model itself
186
- def self.build_from_hash(attributes)
187
- new.build_from_hash(attributes)
188
- end
189
-
190
- # Builds the object from hash
191
- # @param [Hash] attributes Model attributes in the form of hash
192
- # @return [Object] Returns the model itself
193
- def build_from_hash(attributes)
194
- return nil unless attributes.is_a?(Hash)
195
- self.class.openapi_types.each_pair do |key, type|
196
- if type =~ /\AArray<(.*)>/i
197
- # check to ensure the input is an array given that the attribute
198
- # is documented as an array but the input is not
199
- if attributes[self.class.attribute_map[key]].is_a?(Array)
200
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
201
- end
202
- elsif !attributes[self.class.attribute_map[key]].nil?
203
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
204
- end # or else data not found in attributes(hash), not an issue as the data can be optional
205
- end
206
-
207
- self
208
- end
209
-
210
- # Deserializes the data based on type
211
- # @param string type Data type
212
- # @param string value Value to be deserialized
213
- # @return [Object] Deserialized data
214
- def _deserialize(type, value)
215
- case type.to_sym
216
- when :DateTime
217
- DateTime.parse(value)
218
- when :Date
219
- Date.parse(value)
220
- when :String
221
- value.to_s
222
- when :Integer
223
- value.to_i
224
- when :Float
225
- value.to_f
226
- when :Boolean
227
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
228
- true
229
- else
230
- false
231
- end
232
- when :Object
233
- # generic object (usually a Hash), return directly
234
- value
235
- when /\AArray<(?<inner_type>.+)>\z/
236
- inner_type = Regexp.last_match[:inner_type]
237
- value.map { |v| _deserialize(inner_type, v) }
238
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
239
- k_type = Regexp.last_match[:k_type]
240
- v_type = Regexp.last_match[:v_type]
241
- {}.tap do |hash|
242
- value.each do |k, v|
243
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
244
- end
245
- end
246
- else # model
247
- PulpcoreClient.const_get(type).build_from_hash(value)
248
- end
249
- end
250
-
251
- # Returns the string representation of the object
252
- # @return [String] String presentation of the object
253
- def to_s
254
- to_hash.to_s
255
- end
256
-
257
- # to_body is an alias to to_hash (backward compatibility)
258
- # @return [Hash] Returns the object in the form of hash
259
- def to_body
260
- to_hash
261
- end
262
-
263
- # Returns the object in the form of hash
264
- # @return [Hash] Returns the object in the form of hash
265
- def to_hash
266
- hash = {}
267
- self.class.attribute_map.each_pair do |attr, param|
268
- value = self.send(attr)
269
- if value.nil?
270
- is_nullable = self.class.openapi_nullable.include?(attr)
271
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
272
- end
273
-
274
- hash[param] = _to_hash(value)
275
- end
276
- hash
277
- end
278
-
279
- # Outputs non-array value in the form of hash
280
- # For object, use to_hash. Otherwise, just return the value
281
- # @param [Object] value Any valid value
282
- # @return [Hash] Returns the value in the form of hash
283
- def _to_hash(value)
284
- if value.is_a?(Array)
285
- value.compact.map { |v| _to_hash(v) }
286
- elsif value.is_a?(Hash)
287
- {}.tap do |hash|
288
- value.each { |k, v| hash[k] = _to_hash(v) }
289
- end
290
- elsif value.respond_to? :to_hash
291
- value.to_hash
292
- else
293
- value
294
- end
295
- end
296
- end
297
- end