pulp_python_client 3.0.0b9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +9 -0
- data/README.md +175 -0
- data/Rakefile +10 -0
- data/docs/AsyncOperationResponse.md +17 -0
- data/docs/ContentPackagesApi.md +262 -0
- data/docs/ContentSummary.md +21 -0
- data/docs/DistributionsPypiApi.md +364 -0
- data/docs/InlineResponse200.md +23 -0
- data/docs/InlineResponse2001.md +23 -0
- data/docs/InlineResponse2002.md +23 -0
- data/docs/InlineResponse2003.md +23 -0
- data/docs/InlineResponse2004.md +23 -0
- data/docs/InlineResponse2005.md +23 -0
- data/docs/ProjectSpecifier.md +19 -0
- data/docs/PublicationsPypiApi.md +253 -0
- data/docs/PythonPythonDistribution.md +29 -0
- data/docs/PythonPythonDistributionRead.md +29 -0
- data/docs/PythonPythonPackageContentRead.md +69 -0
- data/docs/PythonPythonPublication.md +25 -0
- data/docs/PythonPythonPublicationRead.md +25 -0
- data/docs/PythonPythonRemote.md +49 -0
- data/docs/PythonPythonRemoteRead.md +49 -0
- data/docs/PythonPythonRepository.md +27 -0
- data/docs/PythonPythonRepositoryRead.md +27 -0
- data/docs/RemotesPythonApi.md +368 -0
- data/docs/RepositoriesPythonApi.md +468 -0
- data/docs/RepositoriesPythonVersionsApi.md +269 -0
- data/docs/RepositoryAddRemoveContent.md +21 -0
- data/docs/RepositorySyncURL.md +19 -0
- data/docs/RepositoryVersion.md +25 -0
- data/docs/RepositoryVersionRead.md +25 -0
- data/git_push.sh +58 -0
- data/lib/pulp_python_client.rb +67 -0
- data/lib/pulp_python_client/api/content_packages_api.rb +349 -0
- data/lib/pulp_python_client/api/distributions_pypi_api.rb +445 -0
- data/lib/pulp_python_client/api/publications_pypi_api.rb +306 -0
- data/lib/pulp_python_client/api/remotes_python_api.rb +451 -0
- data/lib/pulp_python_client/api/repositories_python_api.rb +573 -0
- data/lib/pulp_python_client/api/repositories_python_versions_api.rb +336 -0
- data/lib/pulp_python_client/api_client.rb +402 -0
- data/lib/pulp_python_client/api_error.rb +57 -0
- data/lib/pulp_python_client/configuration.rb +243 -0
- data/lib/pulp_python_client/models/async_operation_response.rb +212 -0
- data/lib/pulp_python_client/models/content_summary.rb +246 -0
- data/lib/pulp_python_client/models/inline_response200.rb +247 -0
- data/lib/pulp_python_client/models/inline_response2001.rb +247 -0
- data/lib/pulp_python_client/models/inline_response2002.rb +247 -0
- data/lib/pulp_python_client/models/inline_response2003.rb +247 -0
- data/lib/pulp_python_client/models/inline_response2004.rb +247 -0
- data/lib/pulp_python_client/models/inline_response2005.rb +247 -0
- data/lib/pulp_python_client/models/project_specifier.rb +242 -0
- data/lib/pulp_python_client/models/python_python_distribution.rb +331 -0
- data/lib/pulp_python_client/models/python_python_distribution_read.rb +331 -0
- data/lib/pulp_python_client/models/python_python_package_content_read.rb +550 -0
- data/lib/pulp_python_client/models/python_python_publication.rb +247 -0
- data/lib/pulp_python_client/models/python_python_publication_read.rb +247 -0
- data/lib/pulp_python_client/models/python_python_remote.rb +565 -0
- data/lib/pulp_python_client/models/python_python_remote_read.rb +565 -0
- data/lib/pulp_python_client/models/python_python_repository.rb +294 -0
- data/lib/pulp_python_client/models/python_python_repository_read.rb +294 -0
- data/lib/pulp_python_client/models/repository_add_remove_content.rb +231 -0
- data/lib/pulp_python_client/models/repository_sync_url.rb +224 -0
- data/lib/pulp_python_client/models/repository_version.rb +244 -0
- data/lib/pulp_python_client/models/repository_version_read.rb +244 -0
- data/lib/pulp_python_client/version.rb +15 -0
- data/pulp_python_client.gemspec +39 -0
- data/spec/api/content_packages_api_spec.rb +114 -0
- data/spec/api/distributions_pypi_api_spec.rb +121 -0
- data/spec/api/publications_pypi_api_spec.rb +96 -0
- data/spec/api/remotes_python_api_spec.rb +123 -0
- data/spec/api/repositories_python_api_spec.rb +143 -0
- data/spec/api/repositories_python_versions_api_spec.rb +103 -0
- data/spec/api_client_spec.rb +188 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/models/async_operation_response_spec.rb +41 -0
- data/spec/models/content_summary_spec.rb +53 -0
- data/spec/models/inline_response2001_spec.rb +59 -0
- data/spec/models/inline_response2002_spec.rb +59 -0
- data/spec/models/inline_response2003_spec.rb +59 -0
- data/spec/models/inline_response2004_spec.rb +59 -0
- data/spec/models/inline_response2005_spec.rb +59 -0
- data/spec/models/inline_response200_spec.rb +59 -0
- data/spec/models/project_specifier_spec.rb +47 -0
- data/spec/models/python_python_distribution_read_spec.rb +77 -0
- data/spec/models/python_python_distribution_spec.rb +77 -0
- data/spec/models/python_python_package_content_read_spec.rb +197 -0
- data/spec/models/python_python_publication_read_spec.rb +65 -0
- data/spec/models/python_python_publication_spec.rb +65 -0
- data/spec/models/python_python_remote_read_spec.rb +141 -0
- data/spec/models/python_python_remote_spec.rb +141 -0
- data/spec/models/python_python_repository_read_spec.rb +71 -0
- data/spec/models/python_python_repository_spec.rb +71 -0
- data/spec/models/repository_add_remove_content_spec.rb +53 -0
- data/spec/models/repository_sync_url_spec.rb +47 -0
- data/spec/models/repository_version_read_spec.rb +65 -0
- data/spec/models/repository_version_spec.rb +65 -0
- data/spec/spec_helper.rb +111 -0
- metadata +225 -0
@@ -0,0 +1,57 @@
|
|
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.2.3
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
module PulpPythonClient
|
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,243 @@
|
|
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.2.3
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
module PulpPythonClient
|
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 encoding of array parameter with multi collectionFormat.
|
113
|
+
# Default to nil.
|
114
|
+
#
|
115
|
+
# @see The params_encoding option of Ethon. Related source code:
|
116
|
+
# https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
|
117
|
+
attr_accessor :params_encoding
|
118
|
+
|
119
|
+
attr_accessor :inject_format
|
120
|
+
|
121
|
+
attr_accessor :force_ending_format
|
122
|
+
|
123
|
+
def initialize
|
124
|
+
@scheme = 'http'
|
125
|
+
@host = 'pulp'
|
126
|
+
@base_path = ''
|
127
|
+
@api_key = {}
|
128
|
+
@api_key_prefix = {}
|
129
|
+
@timeout = 0
|
130
|
+
@client_side_validation = true
|
131
|
+
@ssl_verify = true
|
132
|
+
@ssl_verify_mode = nil
|
133
|
+
@ssl_ca_file = nil
|
134
|
+
@ssl_client_cert = nil
|
135
|
+
@ssl_client_key = nil
|
136
|
+
@debugging = false
|
137
|
+
@inject_format = false
|
138
|
+
@force_ending_format = false
|
139
|
+
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
140
|
+
|
141
|
+
yield(self) if block_given?
|
142
|
+
end
|
143
|
+
|
144
|
+
# The default Configuration object.
|
145
|
+
def self.default
|
146
|
+
@@default ||= Configuration.new
|
147
|
+
end
|
148
|
+
|
149
|
+
def configure
|
150
|
+
yield(self) if block_given?
|
151
|
+
end
|
152
|
+
|
153
|
+
def scheme=(scheme)
|
154
|
+
# remove :// from scheme
|
155
|
+
@scheme = scheme.sub(/:\/\//, '')
|
156
|
+
end
|
157
|
+
|
158
|
+
def host=(host)
|
159
|
+
# remove http(s):// and anything after a slash
|
160
|
+
@host = host.sub(/https?:\/\//, '').split('/').first
|
161
|
+
end
|
162
|
+
|
163
|
+
def base_path=(base_path)
|
164
|
+
# Add leading and trailing slashes to base_path
|
165
|
+
@base_path = "/#{base_path}".gsub(/\/+/, '/')
|
166
|
+
@base_path = '' if @base_path == '/'
|
167
|
+
end
|
168
|
+
|
169
|
+
def base_url
|
170
|
+
"#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
|
171
|
+
end
|
172
|
+
|
173
|
+
# Gets API key (with prefix if set).
|
174
|
+
# @param [String] param_name the parameter name of API key auth
|
175
|
+
def api_key_with_prefix(param_name)
|
176
|
+
if @api_key_prefix[param_name]
|
177
|
+
"#{@api_key_prefix[param_name]} #{@api_key[param_name]}"
|
178
|
+
else
|
179
|
+
@api_key[param_name]
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
# Gets Basic Auth token string
|
184
|
+
def basic_auth_token
|
185
|
+
'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
|
186
|
+
end
|
187
|
+
|
188
|
+
# Returns Auth Settings hash for api client.
|
189
|
+
def auth_settings
|
190
|
+
{
|
191
|
+
'Basic' =>
|
192
|
+
{
|
193
|
+
type: 'basic',
|
194
|
+
in: 'header',
|
195
|
+
key: 'Authorization',
|
196
|
+
value: basic_auth_token
|
197
|
+
},
|
198
|
+
}
|
199
|
+
end
|
200
|
+
|
201
|
+
# Returns an array of Server setting
|
202
|
+
def server_settings
|
203
|
+
[
|
204
|
+
{
|
205
|
+
url: "http://pulp/",
|
206
|
+
description: "No description provided",
|
207
|
+
}
|
208
|
+
]
|
209
|
+
end
|
210
|
+
|
211
|
+
# Returns URL based on server settings
|
212
|
+
#
|
213
|
+
# @param index array index of the server settings
|
214
|
+
# @param variables hash of variable and the corresponding value
|
215
|
+
def server_url(index, variables = {})
|
216
|
+
servers = server_settings
|
217
|
+
|
218
|
+
# check array index out of bound
|
219
|
+
if (index < 0 || index >= servers.size)
|
220
|
+
fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
|
221
|
+
end
|
222
|
+
|
223
|
+
server = servers[index]
|
224
|
+
url = server[:url]
|
225
|
+
|
226
|
+
# go through variable and assign a value
|
227
|
+
server[:variables].each do |name, variable|
|
228
|
+
if variables.key?(name)
|
229
|
+
if (server[:variables][name][:enum_values].include? variables[name])
|
230
|
+
url.gsub! "{" + name.to_s + "}", variables[name]
|
231
|
+
else
|
232
|
+
fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
|
233
|
+
end
|
234
|
+
else
|
235
|
+
# use default value
|
236
|
+
url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
url
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|
@@ -0,0 +1,212 @@
|
|
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.2.3
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module PulpPythonClient
|
16
|
+
class AsyncOperationResponse
|
17
|
+
# The href of the task.
|
18
|
+
attr_accessor :task
|
19
|
+
|
20
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
21
|
+
def self.attribute_map
|
22
|
+
{
|
23
|
+
:'task' => :'task'
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
# Attribute type mapping.
|
28
|
+
def self.openapi_types
|
29
|
+
{
|
30
|
+
:'task' => :'String'
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
# List of attributes with nullable: true
|
35
|
+
def self.openapi_nullable
|
36
|
+
Set.new([
|
37
|
+
])
|
38
|
+
end
|
39
|
+
|
40
|
+
# Initializes the object
|
41
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
42
|
+
def initialize(attributes = {})
|
43
|
+
if (!attributes.is_a?(Hash))
|
44
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `PulpPythonClient::AsyncOperationResponse` initialize method"
|
45
|
+
end
|
46
|
+
|
47
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
48
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
49
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
50
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `PulpPythonClient::AsyncOperationResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
51
|
+
end
|
52
|
+
h[k.to_sym] = v
|
53
|
+
}
|
54
|
+
|
55
|
+
if attributes.key?(:'task')
|
56
|
+
self.task = attributes[:'task']
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
61
|
+
# @return Array for valid properties with the reasons
|
62
|
+
def list_invalid_properties
|
63
|
+
invalid_properties = Array.new
|
64
|
+
if @task.nil?
|
65
|
+
invalid_properties.push('invalid value for "task", task cannot be nil.')
|
66
|
+
end
|
67
|
+
|
68
|
+
invalid_properties
|
69
|
+
end
|
70
|
+
|
71
|
+
# Check to see if the all the properties in the model are valid
|
72
|
+
# @return true if the model is valid
|
73
|
+
def valid?
|
74
|
+
return false if @task.nil?
|
75
|
+
true
|
76
|
+
end
|
77
|
+
|
78
|
+
# Checks equality by comparing each attribute.
|
79
|
+
# @param [Object] Object to be compared
|
80
|
+
def ==(o)
|
81
|
+
return true if self.equal?(o)
|
82
|
+
self.class == o.class &&
|
83
|
+
task == o.task
|
84
|
+
end
|
85
|
+
|
86
|
+
# @see the `==` method
|
87
|
+
# @param [Object] Object to be compared
|
88
|
+
def eql?(o)
|
89
|
+
self == o
|
90
|
+
end
|
91
|
+
|
92
|
+
# Calculates hash code according to all attributes.
|
93
|
+
# @return [Integer] Hash code
|
94
|
+
def hash
|
95
|
+
[task].hash
|
96
|
+
end
|
97
|
+
|
98
|
+
# Builds the object from hash
|
99
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
100
|
+
# @return [Object] Returns the model itself
|
101
|
+
def self.build_from_hash(attributes)
|
102
|
+
new.build_from_hash(attributes)
|
103
|
+
end
|
104
|
+
|
105
|
+
# Builds the object from hash
|
106
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
107
|
+
# @return [Object] Returns the model itself
|
108
|
+
def build_from_hash(attributes)
|
109
|
+
return nil unless attributes.is_a?(Hash)
|
110
|
+
self.class.openapi_types.each_pair do |key, type|
|
111
|
+
if type =~ /\AArray<(.*)>/i
|
112
|
+
# check to ensure the input is an array given that the attribute
|
113
|
+
# is documented as an array but the input is not
|
114
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
115
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
116
|
+
end
|
117
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
118
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
119
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
120
|
+
end
|
121
|
+
|
122
|
+
self
|
123
|
+
end
|
124
|
+
|
125
|
+
# Deserializes the data based on type
|
126
|
+
# @param string type Data type
|
127
|
+
# @param string value Value to be deserialized
|
128
|
+
# @return [Object] Deserialized data
|
129
|
+
def _deserialize(type, value)
|
130
|
+
case type.to_sym
|
131
|
+
when :DateTime
|
132
|
+
DateTime.parse(value)
|
133
|
+
when :Date
|
134
|
+
Date.parse(value)
|
135
|
+
when :String
|
136
|
+
value.to_s
|
137
|
+
when :Integer
|
138
|
+
value.to_i
|
139
|
+
when :Float
|
140
|
+
value.to_f
|
141
|
+
when :Boolean
|
142
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
143
|
+
true
|
144
|
+
else
|
145
|
+
false
|
146
|
+
end
|
147
|
+
when :Object
|
148
|
+
# generic object (usually a Hash), return directly
|
149
|
+
value
|
150
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
151
|
+
inner_type = Regexp.last_match[:inner_type]
|
152
|
+
value.map { |v| _deserialize(inner_type, v) }
|
153
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
154
|
+
k_type = Regexp.last_match[:k_type]
|
155
|
+
v_type = Regexp.last_match[:v_type]
|
156
|
+
{}.tap do |hash|
|
157
|
+
value.each do |k, v|
|
158
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
else # model
|
162
|
+
PulpPythonClient.const_get(type).build_from_hash(value)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
# Returns the string representation of the object
|
167
|
+
# @return [String] String presentation of the object
|
168
|
+
def to_s
|
169
|
+
to_hash.to_s
|
170
|
+
end
|
171
|
+
|
172
|
+
# to_body is an alias to to_hash (backward compatibility)
|
173
|
+
# @return [Hash] Returns the object in the form of hash
|
174
|
+
def to_body
|
175
|
+
to_hash
|
176
|
+
end
|
177
|
+
|
178
|
+
# Returns the object in the form of hash
|
179
|
+
# @return [Hash] Returns the object in the form of hash
|
180
|
+
def to_hash
|
181
|
+
hash = {}
|
182
|
+
self.class.attribute_map.each_pair do |attr, param|
|
183
|
+
value = self.send(attr)
|
184
|
+
if value.nil?
|
185
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
186
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
187
|
+
end
|
188
|
+
|
189
|
+
hash[param] = _to_hash(value)
|
190
|
+
end
|
191
|
+
hash
|
192
|
+
end
|
193
|
+
|
194
|
+
# Outputs non-array value in the form of hash
|
195
|
+
# For object, use to_hash. Otherwise, just return the value
|
196
|
+
# @param [Object] value Any valid value
|
197
|
+
# @return [Hash] Returns the value in the form of hash
|
198
|
+
def _to_hash(value)
|
199
|
+
if value.is_a?(Array)
|
200
|
+
value.compact.map { |v| _to_hash(v) }
|
201
|
+
elsif value.is_a?(Hash)
|
202
|
+
{}.tap do |hash|
|
203
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
204
|
+
end
|
205
|
+
elsif value.respond_to? :to_hash
|
206
|
+
value.to_hash
|
207
|
+
else
|
208
|
+
value
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|