pulp_ostree_client 2.0.0a1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/README.md +174 -0
  4. data/Rakefile +10 -0
  5. data/docs/AsyncOperationResponse.md +17 -0
  6. data/docs/ContentCommitsApi.md +138 -0
  7. data/docs/ContentConfigsApi.md +138 -0
  8. data/docs/ContentObjectsApi.md +138 -0
  9. data/docs/ContentRefsApi.md +138 -0
  10. data/docs/ContentSummariesApi.md +138 -0
  11. data/docs/ContentSummary.md +21 -0
  12. data/docs/ContentSummaryResponse.md +21 -0
  13. data/docs/DistributionsOstreeApi.md +372 -0
  14. data/docs/OstreeOstreeCommitResponse.md +25 -0
  15. data/docs/OstreeOstreeConfigResponse.md +21 -0
  16. data/docs/OstreeOstreeDistribution.md +27 -0
  17. data/docs/OstreeOstreeDistributionResponse.md +33 -0
  18. data/docs/OstreeOstreeObjectResponse.md +27 -0
  19. data/docs/OstreeOstreeRefResponse.md +25 -0
  20. data/docs/OstreeOstreeRemote.md +59 -0
  21. data/docs/OstreeOstreeRemoteResponse.md +55 -0
  22. data/docs/OstreeOstreeRepository.md +25 -0
  23. data/docs/OstreeOstreeRepositoryResponse.md +33 -0
  24. data/docs/OstreeOstreeSummaryResponse.md +21 -0
  25. data/docs/OstreeRepoImport.md +23 -0
  26. data/docs/PaginatedRepositoryVersionResponseList.md +23 -0
  27. data/docs/PaginatedostreeOstreeCommitResponseList.md +23 -0
  28. data/docs/PaginatedostreeOstreeConfigResponseList.md +23 -0
  29. data/docs/PaginatedostreeOstreeDistributionResponseList.md +23 -0
  30. data/docs/PaginatedostreeOstreeObjectResponseList.md +23 -0
  31. data/docs/PaginatedostreeOstreeRefResponseList.md +23 -0
  32. data/docs/PaginatedostreeOstreeRemoteResponseList.md +23 -0
  33. data/docs/PaginatedostreeOstreeRepositoryResponseList.md +23 -0
  34. data/docs/PaginatedostreeOstreeSummaryResponseList.md +23 -0
  35. data/docs/PatchedostreeOstreeDistribution.md +27 -0
  36. data/docs/PatchedostreeOstreeRemote.md +59 -0
  37. data/docs/PatchedostreeOstreeRepository.md +25 -0
  38. data/docs/PolicyEnum.md +16 -0
  39. data/docs/RemotesOstreeApi.md +376 -0
  40. data/docs/RepositoriesOstreeApi.md +532 -0
  41. data/docs/RepositoriesOstreeVersionsApi.md +271 -0
  42. data/docs/RepositoryAddRemoveContent.md +21 -0
  43. data/docs/RepositorySyncURL.md +19 -0
  44. data/docs/RepositoryVersion.md +17 -0
  45. data/docs/RepositoryVersionResponse.md +27 -0
  46. data/git_push.sh +58 -0
  47. data/lib/pulp_ostree_client/api/content_commits_api.rb +170 -0
  48. data/lib/pulp_ostree_client/api/content_configs_api.rb +170 -0
  49. data/lib/pulp_ostree_client/api/content_objects_api.rb +170 -0
  50. data/lib/pulp_ostree_client/api/content_refs_api.rb +170 -0
  51. data/lib/pulp_ostree_client/api/content_summaries_api.rb +170 -0
  52. data/lib/pulp_ostree_client/api/distributions_ostree_api.rb +457 -0
  53. data/lib/pulp_ostree_client/api/remotes_ostree_api.rb +463 -0
  54. data/lib/pulp_ostree_client/api/repositories_ostree_api.rb +655 -0
  55. data/lib/pulp_ostree_client/api/repositories_ostree_versions_api.rb +339 -0
  56. data/lib/pulp_ostree_client/api_client.rb +406 -0
  57. data/lib/pulp_ostree_client/api_error.rb +57 -0
  58. data/lib/pulp_ostree_client/configuration.rb +250 -0
  59. data/lib/pulp_ostree_client/models/async_operation_response.rb +213 -0
  60. data/lib/pulp_ostree_client/models/content_summary.rb +246 -0
  61. data/lib/pulp_ostree_client/models/content_summary_response.rb +246 -0
  62. data/lib/pulp_ostree_client/models/ostree_ostree_commit_response.rb +256 -0
  63. data/lib/pulp_ostree_client/models/ostree_ostree_config_response.rb +232 -0
  64. data/lib/pulp_ostree_client/models/ostree_ostree_distribution.rb +270 -0
  65. data/lib/pulp_ostree_client/models/ostree_ostree_distribution_response.rb +299 -0
  66. data/lib/pulp_ostree_client/models/ostree_ostree_object_response.rb +275 -0
  67. data/lib/pulp_ostree_client/models/ostree_ostree_ref_response.rb +260 -0
  68. data/lib/pulp_ostree_client/models/ostree_ostree_remote.rb +536 -0
  69. data/lib/pulp_ostree_client/models/ostree_ostree_remote_response.rb +510 -0
  70. data/lib/pulp_ostree_client/models/ostree_ostree_repository.rb +270 -0
  71. data/lib/pulp_ostree_client/models/ostree_ostree_repository_response.rb +307 -0
  72. data/lib/pulp_ostree_client/models/ostree_ostree_summary_response.rb +232 -0
  73. data/lib/pulp_ostree_client/models/ostree_repo_import.rb +248 -0
  74. data/lib/pulp_ostree_client/models/paginated_repository_version_response_list.rb +237 -0
  75. data/lib/pulp_ostree_client/models/paginatedostree_ostree_commit_response_list.rb +237 -0
  76. data/lib/pulp_ostree_client/models/paginatedostree_ostree_config_response_list.rb +237 -0
  77. data/lib/pulp_ostree_client/models/paginatedostree_ostree_distribution_response_list.rb +237 -0
  78. data/lib/pulp_ostree_client/models/paginatedostree_ostree_object_response_list.rb +237 -0
  79. data/lib/pulp_ostree_client/models/paginatedostree_ostree_ref_response_list.rb +237 -0
  80. data/lib/pulp_ostree_client/models/paginatedostree_ostree_remote_response_list.rb +237 -0
  81. data/lib/pulp_ostree_client/models/paginatedostree_ostree_repository_response_list.rb +237 -0
  82. data/lib/pulp_ostree_client/models/paginatedostree_ostree_summary_response_list.rb +237 -0
  83. data/lib/pulp_ostree_client/models/patchedostree_ostree_distribution.rb +260 -0
  84. data/lib/pulp_ostree_client/models/patchedostree_ostree_remote.rb +526 -0
  85. data/lib/pulp_ostree_client/models/patchedostree_ostree_repository.rb +265 -0
  86. data/lib/pulp_ostree_client/models/policy_enum.rb +36 -0
  87. data/lib/pulp_ostree_client/models/repository_add_remove_content.rb +232 -0
  88. data/lib/pulp_ostree_client/models/repository_sync_url.rb +220 -0
  89. data/lib/pulp_ostree_client/models/repository_version.rb +208 -0
  90. data/lib/pulp_ostree_client/models/repository_version_response.rb +255 -0
  91. data/lib/pulp_ostree_client/version.rb +15 -0
  92. data/lib/pulp_ostree_client.rb +80 -0
  93. data/pulp_ostree_client.gemspec +39 -0
  94. data/spec/api/content_commits_api_spec.rb +68 -0
  95. data/spec/api/content_configs_api_spec.rb +68 -0
  96. data/spec/api/content_objects_api_spec.rb +68 -0
  97. data/spec/api/content_refs_api_spec.rb +68 -0
  98. data/spec/api/content_summaries_api_spec.rb +68 -0
  99. data/spec/api/distributions_ostree_api_spec.rb +125 -0
  100. data/spec/api/remotes_ostree_api_spec.rb +127 -0
  101. data/spec/api/repositories_ostree_api_spec.rb +160 -0
  102. data/spec/api/repositories_ostree_versions_api_spec.rb +104 -0
  103. data/spec/api_client_spec.rb +188 -0
  104. data/spec/configuration_spec.rb +42 -0
  105. data/spec/models/async_operation_response_spec.rb +41 -0
  106. data/spec/models/content_summary_response_spec.rb +53 -0
  107. data/spec/models/content_summary_spec.rb +53 -0
  108. data/spec/models/ostree_ostree_commit_response_spec.rb +65 -0
  109. data/spec/models/ostree_ostree_config_response_spec.rb +53 -0
  110. data/spec/models/ostree_ostree_distribution_response_spec.rb +89 -0
  111. data/spec/models/ostree_ostree_distribution_spec.rb +71 -0
  112. data/spec/models/ostree_ostree_object_response_spec.rb +71 -0
  113. data/spec/models/ostree_ostree_ref_response_spec.rb +65 -0
  114. data/spec/models/ostree_ostree_remote_response_spec.rb +155 -0
  115. data/spec/models/ostree_ostree_remote_spec.rb +167 -0
  116. data/spec/models/ostree_ostree_repository_response_spec.rb +89 -0
  117. data/spec/models/ostree_ostree_repository_spec.rb +65 -0
  118. data/spec/models/ostree_ostree_summary_response_spec.rb +53 -0
  119. data/spec/models/ostree_repo_import_spec.rb +59 -0
  120. data/spec/models/paginated_repository_version_response_list_spec.rb +59 -0
  121. data/spec/models/paginatedostree_ostree_commit_response_list_spec.rb +59 -0
  122. data/spec/models/paginatedostree_ostree_config_response_list_spec.rb +59 -0
  123. data/spec/models/paginatedostree_ostree_distribution_response_list_spec.rb +59 -0
  124. data/spec/models/paginatedostree_ostree_object_response_list_spec.rb +59 -0
  125. data/spec/models/paginatedostree_ostree_ref_response_list_spec.rb +59 -0
  126. data/spec/models/paginatedostree_ostree_remote_response_list_spec.rb +59 -0
  127. data/spec/models/paginatedostree_ostree_repository_response_list_spec.rb +59 -0
  128. data/spec/models/paginatedostree_ostree_summary_response_list_spec.rb +59 -0
  129. data/spec/models/patchedostree_ostree_distribution_spec.rb +71 -0
  130. data/spec/models/patchedostree_ostree_remote_spec.rb +167 -0
  131. data/spec/models/patchedostree_ostree_repository_spec.rb +65 -0
  132. data/spec/models/policy_enum_spec.rb +35 -0
  133. data/spec/models/repository_add_remove_content_spec.rb +53 -0
  134. data/spec/models/repository_sync_url_spec.rb +47 -0
  135. data/spec/models/repository_version_response_spec.rb +71 -0
  136. data/spec/models/repository_version_spec.rb +41 -0
  137. data/spec/spec_helper.rb +111 -0
  138. metadata +277 -0
@@ -0,0 +1,57 @@
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
+ module PulpOstreeClient
14
+ class ApiError < StandardError
15
+ attr_reader :code, :response_headers, :response_body
16
+
17
+ # Usage examples:
18
+ # ApiError.new
19
+ # ApiError.new("message")
20
+ # ApiError.new(:code => 500, :response_headers => {}, :response_body => "")
21
+ # ApiError.new(:code => 404, :message => "Not Found")
22
+ def initialize(arg = nil)
23
+ if arg.is_a? Hash
24
+ if arg.key?(:message) || arg.key?('message')
25
+ super(arg[:message] || arg['message'])
26
+ else
27
+ super arg
28
+ end
29
+
30
+ arg.each do |k, v|
31
+ instance_variable_set "@#{k}", v
32
+ end
33
+ else
34
+ super arg
35
+ end
36
+ end
37
+
38
+ # Override to_s to display a friendly error message
39
+ def to_s
40
+ message
41
+ end
42
+
43
+ def message
44
+ if @message.nil?
45
+ msg = "Error message: the server returns an error"
46
+ else
47
+ msg = @message
48
+ end
49
+
50
+ msg += "\nHTTP status code: #{code}" if code
51
+ msg += "\nResponse headers: #{response_headers}" if response_headers
52
+ msg += "\nResponse body: #{response_body}" if response_body
53
+
54
+ msg
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,250 @@
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
+ module PulpOstreeClient
14
+ class Configuration
15
+ # Defines url scheme
16
+ attr_accessor :scheme
17
+
18
+ # Defines url host
19
+ attr_accessor :host
20
+
21
+ # Defines url base path
22
+ attr_accessor :base_path
23
+
24
+ # Defines API keys used with API Key authentications.
25
+ #
26
+ # @return [Hash] key: parameter name, value: parameter value (API key)
27
+ #
28
+ # @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
29
+ # config.api_key['api_key'] = 'xxx'
30
+ attr_accessor :api_key
31
+
32
+ # Defines API key prefixes used with API Key authentications.
33
+ #
34
+ # @return [Hash] key: parameter name, value: API key prefix
35
+ #
36
+ # @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
37
+ # config.api_key_prefix['api_key'] = 'Token'
38
+ attr_accessor :api_key_prefix
39
+
40
+ # Defines the username used with HTTP basic authentication.
41
+ #
42
+ # @return [String]
43
+ attr_accessor :username
44
+
45
+ # Defines the password used with HTTP basic authentication.
46
+ #
47
+ # @return [String]
48
+ attr_accessor :password
49
+
50
+ # Defines the access token (Bearer) used with OAuth2.
51
+ attr_accessor :access_token
52
+
53
+ # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
54
+ # details will be logged with `logger.debug` (see the `logger` attribute).
55
+ # Default to false.
56
+ #
57
+ # @return [true, false]
58
+ attr_accessor :debugging
59
+
60
+ # Defines the logger used for debugging.
61
+ # Default to `Rails.logger` (when in Rails) or logging to STDOUT.
62
+ #
63
+ # @return [#debug]
64
+ attr_accessor :logger
65
+
66
+ # Defines the temporary folder to store downloaded files
67
+ # (for API endpoints that have file response).
68
+ # Default to use `Tempfile`.
69
+ #
70
+ # @return [String]
71
+ attr_accessor :temp_folder_path
72
+
73
+ # The time limit for HTTP request in seconds.
74
+ # Default to 0 (never times out).
75
+ attr_accessor :timeout
76
+
77
+ # Set this to false to skip client side validation in the operation.
78
+ # Default to true.
79
+ # @return [true, false]
80
+ attr_accessor :client_side_validation
81
+
82
+ ### TLS/SSL setting
83
+ # Set this to false to skip verifying SSL certificate when calling API from https server.
84
+ # Default to true.
85
+ #
86
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
87
+ #
88
+ # @return [true, false]
89
+ attr_accessor :ssl_verify
90
+
91
+ ### TLS/SSL setting
92
+ # Any `OpenSSL::SSL::` constant (see https://ruby-doc.org/stdlib-2.5.1/libdoc/openssl/rdoc/OpenSSL/SSL.html)
93
+ #
94
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
95
+ #
96
+ attr_accessor :ssl_verify_mode
97
+
98
+ ### TLS/SSL setting
99
+ # Set this to customize the certificate file to verify the peer.
100
+ #
101
+ # @return [String] the path to the certificate file
102
+ attr_accessor :ssl_ca_file
103
+
104
+ ### TLS/SSL setting
105
+ # Client certificate file (for client certificate)
106
+ attr_accessor :ssl_client_cert
107
+
108
+ ### TLS/SSL setting
109
+ # Client private key file (for client certificate)
110
+ attr_accessor :ssl_client_key
111
+
112
+ # Set this to customize parameters encoder of array parameter.
113
+ # Default to nil. Faraday uses NestedParamsEncoder when nil.
114
+ #
115
+ # @see The params_encoder option of Faraday. Related source code:
116
+ # https://github.com/lostisland/faraday/tree/main/lib/faraday/encoders
117
+ attr_accessor :params_encoder
118
+ # Set this to customize parameters encoding of array parameter with multi collectionFormat.
119
+ # Default to nil.
120
+ #
121
+ # @see The params_encoding option of Ethon. Related source code:
122
+ # https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
123
+ attr_accessor :params_encoding
124
+
125
+ attr_accessor :inject_format
126
+
127
+ attr_accessor :force_ending_format
128
+
129
+ def initialize
130
+ @scheme = 'https'
131
+ @host = 'pulp'
132
+ @base_path = ''
133
+ @api_key = {}
134
+ @api_key_prefix = {}
135
+ @timeout = 0
136
+ @client_side_validation = true
137
+ @ssl_verify = true
138
+ @ssl_verify_mode = nil
139
+ @ssl_ca_file = nil
140
+ @ssl_client_cert = nil
141
+ @ssl_client_key = nil
142
+ @params_encoder = nil
143
+ @debugging = false
144
+ @inject_format = false
145
+ @force_ending_format = false
146
+ @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
147
+
148
+ yield(self) if block_given?
149
+ end
150
+
151
+ # The default Configuration object.
152
+ def self.default
153
+ @@default ||= Configuration.new
154
+ end
155
+
156
+ def configure
157
+ yield(self) if block_given?
158
+ end
159
+
160
+ def scheme=(scheme)
161
+ # remove :// from scheme
162
+ @scheme = scheme.sub(/:\/\//, '')
163
+ end
164
+
165
+ def host=(host)
166
+ # remove http(s):// and anything after a slash
167
+ @host = host.sub(/https?:\/\//, '').split('/').first
168
+ end
169
+
170
+ def base_path=(base_path)
171
+ # Add leading and trailing slashes to base_path
172
+ @base_path = "/#{base_path}".gsub(/\/+/, '/')
173
+ @base_path = '' if @base_path == '/'
174
+ end
175
+
176
+ def base_url
177
+ "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
178
+ end
179
+
180
+ # Gets API key (with prefix if set).
181
+ # @param [String] param_name the parameter name of API key auth
182
+ def api_key_with_prefix(param_name)
183
+ if @api_key_prefix[param_name]
184
+ "#{@api_key_prefix[param_name]} #{@api_key[param_name]}"
185
+ else
186
+ @api_key[param_name]
187
+ end
188
+ end
189
+
190
+ # Gets Basic Auth token string
191
+ def basic_auth_token
192
+ 'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
193
+ end
194
+
195
+ # Returns Auth Settings hash for api client.
196
+ def auth_settings
197
+ {
198
+ 'basicAuth' =>
199
+ {
200
+ type: 'basic',
201
+ in: 'header',
202
+ key: 'Authorization',
203
+ value: basic_auth_token
204
+ },
205
+ }
206
+ end
207
+
208
+ # Returns an array of Server setting
209
+ def server_settings
210
+ [
211
+ {
212
+ url: "https://pulp/",
213
+ description: "No description provided",
214
+ }
215
+ ]
216
+ end
217
+
218
+ # Returns URL based on server settings
219
+ #
220
+ # @param index array index of the server settings
221
+ # @param variables hash of variable and the corresponding value
222
+ def server_url(index, variables = {})
223
+ servers = server_settings
224
+
225
+ # check array index out of bound
226
+ if (index < 0 || index >= servers.size)
227
+ fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
228
+ end
229
+
230
+ server = servers[index]
231
+ url = server[:url]
232
+
233
+ # go through variable and assign a value
234
+ server[:variables].each do |name, variable|
235
+ if variables.key?(name)
236
+ if (server[:variables][name][:enum_values].include? variables[name])
237
+ url.gsub! "{" + name.to_s + "}", variables[name]
238
+ else
239
+ fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
240
+ end
241
+ else
242
+ # use default value
243
+ url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
244
+ end
245
+ end
246
+
247
+ url
248
+ end
249
+ end
250
+ end
@@ -0,0 +1,213 @@
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 PulpOstreeClient
16
+ # Serializer for asynchronous operations.
17
+ class AsyncOperationResponse
18
+ # The href of the task.
19
+ attr_accessor :task
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'task' => :'task'
25
+ }
26
+ end
27
+
28
+ # Attribute type mapping.
29
+ def self.openapi_types
30
+ {
31
+ :'task' => :'String'
32
+ }
33
+ end
34
+
35
+ # List of attributes with nullable: true
36
+ def self.openapi_nullable
37
+ Set.new([
38
+ ])
39
+ end
40
+
41
+ # Initializes the object
42
+ # @param [Hash] attributes Model attributes in the form of hash
43
+ def initialize(attributes = {})
44
+ if (!attributes.is_a?(Hash))
45
+ fail ArgumentError, "The input argument (attributes) must be a hash in `PulpOstreeClient::AsyncOperationResponse` initialize method"
46
+ end
47
+
48
+ # check to see if the attribute exists and convert string to symbol for hash key
49
+ attributes = attributes.each_with_object({}) { |(k, v), h|
50
+ if (!self.class.attribute_map.key?(k.to_sym))
51
+ fail ArgumentError, "`#{k}` is not a valid attribute in `PulpOstreeClient::AsyncOperationResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
52
+ end
53
+ h[k.to_sym] = v
54
+ }
55
+
56
+ if attributes.key?(:'task')
57
+ self.task = attributes[:'task']
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 @task.nil?
66
+ invalid_properties.push('invalid value for "task", task cannot be nil.')
67
+ end
68
+
69
+ invalid_properties
70
+ end
71
+
72
+ # Check to see if the all the properties in the model are valid
73
+ # @return true if the model is valid
74
+ def valid?
75
+ return false if @task.nil?
76
+ true
77
+ end
78
+
79
+ # Checks equality by comparing each attribute.
80
+ # @param [Object] Object to be compared
81
+ def ==(o)
82
+ return true if self.equal?(o)
83
+ self.class == o.class &&
84
+ task == o.task
85
+ end
86
+
87
+ # @see the `==` method
88
+ # @param [Object] Object to be compared
89
+ def eql?(o)
90
+ self == o
91
+ end
92
+
93
+ # Calculates hash code according to all attributes.
94
+ # @return [Integer] Hash code
95
+ def hash
96
+ [task].hash
97
+ end
98
+
99
+ # Builds the object from hash
100
+ # @param [Hash] attributes Model attributes in the form of hash
101
+ # @return [Object] Returns the model itself
102
+ def self.build_from_hash(attributes)
103
+ new.build_from_hash(attributes)
104
+ end
105
+
106
+ # Builds the object from hash
107
+ # @param [Hash] attributes Model attributes in the form of hash
108
+ # @return [Object] Returns the model itself
109
+ def build_from_hash(attributes)
110
+ return nil unless attributes.is_a?(Hash)
111
+ self.class.openapi_types.each_pair do |key, type|
112
+ if type =~ /\AArray<(.*)>/i
113
+ # check to ensure the input is an array given that the attribute
114
+ # is documented as an array but the input is not
115
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
116
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
117
+ end
118
+ elsif !attributes[self.class.attribute_map[key]].nil?
119
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
120
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
121
+ end
122
+
123
+ self
124
+ end
125
+
126
+ # Deserializes the data based on type
127
+ # @param string type Data type
128
+ # @param string value Value to be deserialized
129
+ # @return [Object] Deserialized data
130
+ def _deserialize(type, value)
131
+ case type.to_sym
132
+ when :DateTime
133
+ DateTime.parse(value)
134
+ when :Date
135
+ Date.parse(value)
136
+ when :String
137
+ value.to_s
138
+ when :Integer
139
+ value.to_i
140
+ when :Float
141
+ value.to_f
142
+ when :Boolean
143
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
144
+ true
145
+ else
146
+ false
147
+ end
148
+ when :Object
149
+ # generic object (usually a Hash), return directly
150
+ value
151
+ when /\AArray<(?<inner_type>.+)>\z/
152
+ inner_type = Regexp.last_match[:inner_type]
153
+ value.map { |v| _deserialize(inner_type, v) }
154
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
155
+ k_type = Regexp.last_match[:k_type]
156
+ v_type = Regexp.last_match[:v_type]
157
+ {}.tap do |hash|
158
+ value.each do |k, v|
159
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
160
+ end
161
+ end
162
+ else # model
163
+ PulpOstreeClient.const_get(type).build_from_hash(value)
164
+ end
165
+ end
166
+
167
+ # Returns the string representation of the object
168
+ # @return [String] String presentation of the object
169
+ def to_s
170
+ to_hash.to_s
171
+ end
172
+
173
+ # to_body is an alias to to_hash (backward compatibility)
174
+ # @return [Hash] Returns the object in the form of hash
175
+ def to_body
176
+ to_hash
177
+ end
178
+
179
+ # Returns the object in the form of hash
180
+ # @return [Hash] Returns the object in the form of hash
181
+ def to_hash
182
+ hash = {}
183
+ self.class.attribute_map.each_pair do |attr, param|
184
+ value = self.send(attr)
185
+ if value.nil?
186
+ is_nullable = self.class.openapi_nullable.include?(attr)
187
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
188
+ end
189
+
190
+ hash[param] = _to_hash(value)
191
+ end
192
+ hash
193
+ end
194
+
195
+ # Outputs non-array value in the form of hash
196
+ # For object, use to_hash. Otherwise, just return the value
197
+ # @param [Object] value Any valid value
198
+ # @return [Hash] Returns the value in the form of hash
199
+ def _to_hash(value)
200
+ if value.is_a?(Array)
201
+ value.compact.map { |v| _to_hash(v) }
202
+ elsif value.is_a?(Hash)
203
+ {}.tap do |hash|
204
+ value.each { |k, v| hash[k] = _to_hash(v) }
205
+ end
206
+ elsif value.respond_to? :to_hash
207
+ value.to_hash
208
+ else
209
+ value
210
+ end
211
+ end
212
+ end
213
+ end