pulp_python_client 3.0.0b9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/README.md +175 -0
  4. data/Rakefile +10 -0
  5. data/docs/AsyncOperationResponse.md +17 -0
  6. data/docs/ContentPackagesApi.md +262 -0
  7. data/docs/ContentSummary.md +21 -0
  8. data/docs/DistributionsPypiApi.md +364 -0
  9. data/docs/InlineResponse200.md +23 -0
  10. data/docs/InlineResponse2001.md +23 -0
  11. data/docs/InlineResponse2002.md +23 -0
  12. data/docs/InlineResponse2003.md +23 -0
  13. data/docs/InlineResponse2004.md +23 -0
  14. data/docs/InlineResponse2005.md +23 -0
  15. data/docs/ProjectSpecifier.md +19 -0
  16. data/docs/PublicationsPypiApi.md +253 -0
  17. data/docs/PythonPythonDistribution.md +29 -0
  18. data/docs/PythonPythonDistributionRead.md +29 -0
  19. data/docs/PythonPythonPackageContentRead.md +69 -0
  20. data/docs/PythonPythonPublication.md +25 -0
  21. data/docs/PythonPythonPublicationRead.md +25 -0
  22. data/docs/PythonPythonRemote.md +49 -0
  23. data/docs/PythonPythonRemoteRead.md +49 -0
  24. data/docs/PythonPythonRepository.md +27 -0
  25. data/docs/PythonPythonRepositoryRead.md +27 -0
  26. data/docs/RemotesPythonApi.md +368 -0
  27. data/docs/RepositoriesPythonApi.md +468 -0
  28. data/docs/RepositoriesPythonVersionsApi.md +269 -0
  29. data/docs/RepositoryAddRemoveContent.md +21 -0
  30. data/docs/RepositorySyncURL.md +19 -0
  31. data/docs/RepositoryVersion.md +25 -0
  32. data/docs/RepositoryVersionRead.md +25 -0
  33. data/git_push.sh +58 -0
  34. data/lib/pulp_python_client.rb +67 -0
  35. data/lib/pulp_python_client/api/content_packages_api.rb +349 -0
  36. data/lib/pulp_python_client/api/distributions_pypi_api.rb +445 -0
  37. data/lib/pulp_python_client/api/publications_pypi_api.rb +306 -0
  38. data/lib/pulp_python_client/api/remotes_python_api.rb +451 -0
  39. data/lib/pulp_python_client/api/repositories_python_api.rb +573 -0
  40. data/lib/pulp_python_client/api/repositories_python_versions_api.rb +336 -0
  41. data/lib/pulp_python_client/api_client.rb +402 -0
  42. data/lib/pulp_python_client/api_error.rb +57 -0
  43. data/lib/pulp_python_client/configuration.rb +243 -0
  44. data/lib/pulp_python_client/models/async_operation_response.rb +212 -0
  45. data/lib/pulp_python_client/models/content_summary.rb +246 -0
  46. data/lib/pulp_python_client/models/inline_response200.rb +247 -0
  47. data/lib/pulp_python_client/models/inline_response2001.rb +247 -0
  48. data/lib/pulp_python_client/models/inline_response2002.rb +247 -0
  49. data/lib/pulp_python_client/models/inline_response2003.rb +247 -0
  50. data/lib/pulp_python_client/models/inline_response2004.rb +247 -0
  51. data/lib/pulp_python_client/models/inline_response2005.rb +247 -0
  52. data/lib/pulp_python_client/models/project_specifier.rb +242 -0
  53. data/lib/pulp_python_client/models/python_python_distribution.rb +331 -0
  54. data/lib/pulp_python_client/models/python_python_distribution_read.rb +331 -0
  55. data/lib/pulp_python_client/models/python_python_package_content_read.rb +550 -0
  56. data/lib/pulp_python_client/models/python_python_publication.rb +247 -0
  57. data/lib/pulp_python_client/models/python_python_publication_read.rb +247 -0
  58. data/lib/pulp_python_client/models/python_python_remote.rb +565 -0
  59. data/lib/pulp_python_client/models/python_python_remote_read.rb +565 -0
  60. data/lib/pulp_python_client/models/python_python_repository.rb +294 -0
  61. data/lib/pulp_python_client/models/python_python_repository_read.rb +294 -0
  62. data/lib/pulp_python_client/models/repository_add_remove_content.rb +231 -0
  63. data/lib/pulp_python_client/models/repository_sync_url.rb +224 -0
  64. data/lib/pulp_python_client/models/repository_version.rb +244 -0
  65. data/lib/pulp_python_client/models/repository_version_read.rb +244 -0
  66. data/lib/pulp_python_client/version.rb +15 -0
  67. data/pulp_python_client.gemspec +39 -0
  68. data/spec/api/content_packages_api_spec.rb +114 -0
  69. data/spec/api/distributions_pypi_api_spec.rb +121 -0
  70. data/spec/api/publications_pypi_api_spec.rb +96 -0
  71. data/spec/api/remotes_python_api_spec.rb +123 -0
  72. data/spec/api/repositories_python_api_spec.rb +143 -0
  73. data/spec/api/repositories_python_versions_api_spec.rb +103 -0
  74. data/spec/api_client_spec.rb +188 -0
  75. data/spec/configuration_spec.rb +42 -0
  76. data/spec/models/async_operation_response_spec.rb +41 -0
  77. data/spec/models/content_summary_spec.rb +53 -0
  78. data/spec/models/inline_response2001_spec.rb +59 -0
  79. data/spec/models/inline_response2002_spec.rb +59 -0
  80. data/spec/models/inline_response2003_spec.rb +59 -0
  81. data/spec/models/inline_response2004_spec.rb +59 -0
  82. data/spec/models/inline_response2005_spec.rb +59 -0
  83. data/spec/models/inline_response200_spec.rb +59 -0
  84. data/spec/models/project_specifier_spec.rb +47 -0
  85. data/spec/models/python_python_distribution_read_spec.rb +77 -0
  86. data/spec/models/python_python_distribution_spec.rb +77 -0
  87. data/spec/models/python_python_package_content_read_spec.rb +197 -0
  88. data/spec/models/python_python_publication_read_spec.rb +65 -0
  89. data/spec/models/python_python_publication_spec.rb +65 -0
  90. data/spec/models/python_python_remote_read_spec.rb +141 -0
  91. data/spec/models/python_python_remote_spec.rb +141 -0
  92. data/spec/models/python_python_repository_read_spec.rb +71 -0
  93. data/spec/models/python_python_repository_spec.rb +71 -0
  94. data/spec/models/repository_add_remove_content_spec.rb +53 -0
  95. data/spec/models/repository_sync_url_spec.rb +47 -0
  96. data/spec/models/repository_version_read_spec.rb +65 -0
  97. data/spec/models/repository_version_spec.rb +65 -0
  98. data/spec/spec_helper.rb +111 -0
  99. metadata +225 -0
@@ -0,0 +1,336 @@
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 'cgi'
14
+
15
+ module PulpPythonClient
16
+ class RepositoriesPythonVersionsApi
17
+ attr_accessor :api_client
18
+
19
+ def initialize(api_client = ApiClient.default)
20
+ @api_client = api_client
21
+ end
22
+ # Delete a repository version
23
+ # Trigger an asynchronous task to delete a repositroy version.
24
+ # @param python_repository_version_href [String] URI of Repository Version. e.g.: /pulp/api/v3/repositories/python/python/1/versions/1/
25
+ # @param [Hash] opts the optional parameters
26
+ # @return [AsyncOperationResponse]
27
+ def delete(python_repository_version_href, opts = {})
28
+ data, _status_code, _headers = delete_with_http_info(python_repository_version_href, opts)
29
+ data
30
+ end
31
+
32
+ # Delete a repository version
33
+ # Trigger an asynchronous task to delete a repositroy version.
34
+ # @param python_repository_version_href [String] URI of Repository Version. e.g.: /pulp/api/v3/repositories/python/python/1/versions/1/
35
+ # @param [Hash] opts the optional parameters
36
+ # @return [Array<(AsyncOperationResponse, Integer, Hash)>] AsyncOperationResponse data, response status code and response headers
37
+ def delete_with_http_info(python_repository_version_href, opts = {})
38
+ if @api_client.config.debugging
39
+ @api_client.config.logger.debug 'Calling API: RepositoriesPythonVersionsApi.delete ...'
40
+ end
41
+ # verify the required parameter 'python_repository_version_href' is set
42
+ if @api_client.config.client_side_validation && python_repository_version_href.nil?
43
+ fail ArgumentError, "Missing the required parameter 'python_repository_version_href' when calling RepositoriesPythonVersionsApi.delete"
44
+ end
45
+ # resource path
46
+ local_var_path = '{python_repository_version_href}'.sub('{' + 'python_repository_version_href' + '}', CGI.escape(python_repository_version_href.to_s).gsub('%2F', '/'))
47
+
48
+ # query parameters
49
+ query_params = opts[:query_params] || {}
50
+
51
+ # header parameters
52
+ header_params = opts[:header_params] || {}
53
+ # HTTP header 'Accept' (if needed)
54
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
55
+
56
+ # form parameters
57
+ form_params = opts[:form_params] || {}
58
+
59
+ # http body (model)
60
+ post_body = opts[:body]
61
+
62
+ # return_type
63
+ return_type = opts[:return_type] || 'AsyncOperationResponse'
64
+
65
+ # auth_names
66
+ auth_names = opts[:auth_names] || ['Basic']
67
+
68
+ new_options = opts.merge(
69
+ :header_params => header_params,
70
+ :query_params => query_params,
71
+ :form_params => form_params,
72
+ :body => post_body,
73
+ :auth_names => auth_names,
74
+ :return_type => return_type
75
+ )
76
+
77
+ data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
78
+ if @api_client.config.debugging
79
+ @api_client.config.logger.debug "API called: RepositoriesPythonVersionsApi#delete\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
80
+ end
81
+ return data, status_code, headers
82
+ end
83
+
84
+ # List repository versions
85
+ # PythonRepositoryVersion represents a single Python repository version.
86
+ # @param python_repository_href [String] URI of Python Repository. e.g.: /pulp/api/v3/repositories/python/python/1/
87
+ # @param [Hash] opts the optional parameters
88
+ # @option opts [String] :ordering Which field to use when ordering the results.
89
+ # @option opts [Float] :number
90
+ # @option opts [Float] :number__lt Filter results where number is less than value
91
+ # @option opts [Float] :number__lte Filter results where number is less than or equal to value
92
+ # @option opts [Float] :number__gt Filter results where number is greater than value
93
+ # @option opts [Float] :number__gte Filter results where number is greater than or equal to value
94
+ # @option opts [Float] :number__range Filter results where number is between two comma separated values
95
+ # @option opts [String] :pulp_created__lt Filter results where pulp_created is less than value
96
+ # @option opts [String] :pulp_created__lte Filter results where pulp_created is less than or equal to value
97
+ # @option opts [String] :pulp_created__gt Filter results where pulp_created is greater than value
98
+ # @option opts [String] :pulp_created__gte Filter results where pulp_created is greater than or equal to value
99
+ # @option opts [String] :pulp_created__range Filter results where pulp_created is between two comma separated values
100
+ # @option opts [String] :content Content Unit referenced by HREF
101
+ # @option opts [String] :pulp_created ISO 8601 formatted dates are supported
102
+ # @option opts [Integer] :limit Number of results to return per page.
103
+ # @option opts [Integer] :offset The initial index from which to return the results.
104
+ # @option opts [String] :fields A list of fields to include in the response.
105
+ # @option opts [String] :exclude_fields A list of fields to exclude from the response.
106
+ # @return [InlineResponse2005]
107
+ def list(python_repository_href, opts = {})
108
+ data, _status_code, _headers = list_with_http_info(python_repository_href, opts)
109
+ data
110
+ end
111
+
112
+ # List repository versions
113
+ # PythonRepositoryVersion represents a single Python repository version.
114
+ # @param python_repository_href [String] URI of Python Repository. e.g.: /pulp/api/v3/repositories/python/python/1/
115
+ # @param [Hash] opts the optional parameters
116
+ # @option opts [String] :ordering Which field to use when ordering the results.
117
+ # @option opts [Float] :number
118
+ # @option opts [Float] :number__lt Filter results where number is less than value
119
+ # @option opts [Float] :number__lte Filter results where number is less than or equal to value
120
+ # @option opts [Float] :number__gt Filter results where number is greater than value
121
+ # @option opts [Float] :number__gte Filter results where number is greater than or equal to value
122
+ # @option opts [Float] :number__range Filter results where number is between two comma separated values
123
+ # @option opts [String] :pulp_created__lt Filter results where pulp_created is less than value
124
+ # @option opts [String] :pulp_created__lte Filter results where pulp_created is less than or equal to value
125
+ # @option opts [String] :pulp_created__gt Filter results where pulp_created is greater than value
126
+ # @option opts [String] :pulp_created__gte Filter results where pulp_created is greater than or equal to value
127
+ # @option opts [String] :pulp_created__range Filter results where pulp_created is between two comma separated values
128
+ # @option opts [String] :content Content Unit referenced by HREF
129
+ # @option opts [String] :pulp_created ISO 8601 formatted dates are supported
130
+ # @option opts [Integer] :limit Number of results to return per page.
131
+ # @option opts [Integer] :offset The initial index from which to return the results.
132
+ # @option opts [String] :fields A list of fields to include in the response.
133
+ # @option opts [String] :exclude_fields A list of fields to exclude from the response.
134
+ # @return [Array<(InlineResponse2005, Integer, Hash)>] InlineResponse2005 data, response status code and response headers
135
+ def list_with_http_info(python_repository_href, opts = {})
136
+ if @api_client.config.debugging
137
+ @api_client.config.logger.debug 'Calling API: RepositoriesPythonVersionsApi.list ...'
138
+ end
139
+ # verify the required parameter 'python_repository_href' is set
140
+ if @api_client.config.client_side_validation && python_repository_href.nil?
141
+ fail ArgumentError, "Missing the required parameter 'python_repository_href' when calling RepositoriesPythonVersionsApi.list"
142
+ end
143
+ # resource path
144
+ local_var_path = '{python_repository_href}versions/'.sub('{' + 'python_repository_href' + '}', CGI.escape(python_repository_href.to_s).gsub('%2F', '/'))
145
+
146
+ # query parameters
147
+ query_params = opts[:query_params] || {}
148
+ query_params[:'ordering'] = opts[:'ordering'] if !opts[:'ordering'].nil?
149
+ query_params[:'number'] = opts[:'number'] if !opts[:'number'].nil?
150
+ query_params[:'number__lt'] = opts[:'number__lt'] if !opts[:'number__lt'].nil?
151
+ query_params[:'number__lte'] = opts[:'number__lte'] if !opts[:'number__lte'].nil?
152
+ query_params[:'number__gt'] = opts[:'number__gt'] if !opts[:'number__gt'].nil?
153
+ query_params[:'number__gte'] = opts[:'number__gte'] if !opts[:'number__gte'].nil?
154
+ query_params[:'number__range'] = opts[:'number__range'] if !opts[:'number__range'].nil?
155
+ query_params[:'pulp_created__lt'] = opts[:'pulp_created__lt'] if !opts[:'pulp_created__lt'].nil?
156
+ query_params[:'pulp_created__lte'] = opts[:'pulp_created__lte'] if !opts[:'pulp_created__lte'].nil?
157
+ query_params[:'pulp_created__gt'] = opts[:'pulp_created__gt'] if !opts[:'pulp_created__gt'].nil?
158
+ query_params[:'pulp_created__gte'] = opts[:'pulp_created__gte'] if !opts[:'pulp_created__gte'].nil?
159
+ query_params[:'pulp_created__range'] = opts[:'pulp_created__range'] if !opts[:'pulp_created__range'].nil?
160
+ query_params[:'content'] = opts[:'content'] if !opts[:'content'].nil?
161
+ query_params[:'pulp_created'] = opts[:'pulp_created'] if !opts[:'pulp_created'].nil?
162
+ query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
163
+ query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?
164
+ query_params[:'fields'] = opts[:'fields'] if !opts[:'fields'].nil?
165
+ query_params[:'exclude_fields'] = opts[:'exclude_fields'] if !opts[:'exclude_fields'].nil?
166
+
167
+ # header parameters
168
+ header_params = opts[:header_params] || {}
169
+ # HTTP header 'Accept' (if needed)
170
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
171
+
172
+ # form parameters
173
+ form_params = opts[:form_params] || {}
174
+
175
+ # http body (model)
176
+ post_body = opts[:body]
177
+
178
+ # return_type
179
+ return_type = opts[:return_type] || 'InlineResponse2005'
180
+
181
+ # auth_names
182
+ auth_names = opts[:auth_names] || ['Basic']
183
+
184
+ new_options = opts.merge(
185
+ :header_params => header_params,
186
+ :query_params => query_params,
187
+ :form_params => form_params,
188
+ :body => post_body,
189
+ :auth_names => auth_names,
190
+ :return_type => return_type
191
+ )
192
+
193
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
194
+ if @api_client.config.debugging
195
+ @api_client.config.logger.debug "API called: RepositoriesPythonVersionsApi#list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
196
+ end
197
+ return data, status_code, headers
198
+ end
199
+
200
+ # Inspect a repository version
201
+ # PythonRepositoryVersion represents a single Python repository version.
202
+ # @param python_repository_version_href [String] URI of Repository Version. e.g.: /pulp/api/v3/repositories/python/python/1/versions/1/
203
+ # @param [Hash] opts the optional parameters
204
+ # @option opts [String] :fields A list of fields to include in the response.
205
+ # @option opts [String] :exclude_fields A list of fields to exclude from the response.
206
+ # @return [RepositoryVersionRead]
207
+ def read(python_repository_version_href, opts = {})
208
+ data, _status_code, _headers = read_with_http_info(python_repository_version_href, opts)
209
+ data
210
+ end
211
+
212
+ # Inspect a repository version
213
+ # PythonRepositoryVersion represents a single Python repository version.
214
+ # @param python_repository_version_href [String] URI of Repository Version. e.g.: /pulp/api/v3/repositories/python/python/1/versions/1/
215
+ # @param [Hash] opts the optional parameters
216
+ # @option opts [String] :fields A list of fields to include in the response.
217
+ # @option opts [String] :exclude_fields A list of fields to exclude from the response.
218
+ # @return [Array<(RepositoryVersionRead, Integer, Hash)>] RepositoryVersionRead data, response status code and response headers
219
+ def read_with_http_info(python_repository_version_href, opts = {})
220
+ if @api_client.config.debugging
221
+ @api_client.config.logger.debug 'Calling API: RepositoriesPythonVersionsApi.read ...'
222
+ end
223
+ # verify the required parameter 'python_repository_version_href' is set
224
+ if @api_client.config.client_side_validation && python_repository_version_href.nil?
225
+ fail ArgumentError, "Missing the required parameter 'python_repository_version_href' when calling RepositoriesPythonVersionsApi.read"
226
+ end
227
+ # resource path
228
+ local_var_path = '{python_repository_version_href}'.sub('{' + 'python_repository_version_href' + '}', CGI.escape(python_repository_version_href.to_s).gsub('%2F', '/'))
229
+
230
+ # query parameters
231
+ query_params = opts[:query_params] || {}
232
+ query_params[:'fields'] = opts[:'fields'] if !opts[:'fields'].nil?
233
+ query_params[:'exclude_fields'] = opts[:'exclude_fields'] if !opts[:'exclude_fields'].nil?
234
+
235
+ # header parameters
236
+ header_params = opts[:header_params] || {}
237
+ # HTTP header 'Accept' (if needed)
238
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
239
+
240
+ # form parameters
241
+ form_params = opts[:form_params] || {}
242
+
243
+ # http body (model)
244
+ post_body = opts[:body]
245
+
246
+ # return_type
247
+ return_type = opts[:return_type] || 'RepositoryVersionRead'
248
+
249
+ # auth_names
250
+ auth_names = opts[:auth_names] || ['Basic']
251
+
252
+ new_options = opts.merge(
253
+ :header_params => header_params,
254
+ :query_params => query_params,
255
+ :form_params => form_params,
256
+ :body => post_body,
257
+ :auth_names => auth_names,
258
+ :return_type => return_type
259
+ )
260
+
261
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
262
+ if @api_client.config.debugging
263
+ @api_client.config.logger.debug "API called: RepositoriesPythonVersionsApi#read\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
264
+ end
265
+ return data, status_code, headers
266
+ end
267
+
268
+ # Trigger an asynchronous task to repair a repositroy version.
269
+ # @param python_repository_version_href [String] URI of Repository Version. e.g.: /pulp/api/v3/repositories/python/python/1/versions/1/
270
+ # @param data [RepositoryVersion]
271
+ # @param [Hash] opts the optional parameters
272
+ # @return [AsyncOperationResponse]
273
+ def repair(python_repository_version_href, data, opts = {})
274
+ data, _status_code, _headers = repair_with_http_info(python_repository_version_href, data, opts)
275
+ data
276
+ end
277
+
278
+ # Trigger an asynchronous task to repair a repositroy version.
279
+ # @param python_repository_version_href [String] URI of Repository Version. e.g.: /pulp/api/v3/repositories/python/python/1/versions/1/
280
+ # @param data [RepositoryVersion]
281
+ # @param [Hash] opts the optional parameters
282
+ # @return [Array<(AsyncOperationResponse, Integer, Hash)>] AsyncOperationResponse data, response status code and response headers
283
+ def repair_with_http_info(python_repository_version_href, data, opts = {})
284
+ if @api_client.config.debugging
285
+ @api_client.config.logger.debug 'Calling API: RepositoriesPythonVersionsApi.repair ...'
286
+ end
287
+ # verify the required parameter 'python_repository_version_href' is set
288
+ if @api_client.config.client_side_validation && python_repository_version_href.nil?
289
+ fail ArgumentError, "Missing the required parameter 'python_repository_version_href' when calling RepositoriesPythonVersionsApi.repair"
290
+ end
291
+ # verify the required parameter 'data' is set
292
+ if @api_client.config.client_side_validation && data.nil?
293
+ fail ArgumentError, "Missing the required parameter 'data' when calling RepositoriesPythonVersionsApi.repair"
294
+ end
295
+ # resource path
296
+ local_var_path = '{python_repository_version_href}repair/'.sub('{' + 'python_repository_version_href' + '}', CGI.escape(python_repository_version_href.to_s).gsub('%2F', '/'))
297
+
298
+ # query parameters
299
+ query_params = opts[:query_params] || {}
300
+
301
+ # header parameters
302
+ header_params = opts[:header_params] || {}
303
+ # HTTP header 'Accept' (if needed)
304
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
305
+ # HTTP header 'Content-Type'
306
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
307
+
308
+ # form parameters
309
+ form_params = opts[:form_params] || {}
310
+
311
+ # http body (model)
312
+ post_body = opts[:body] || @api_client.object_to_http_body(data)
313
+
314
+ # return_type
315
+ return_type = opts[:return_type] || 'AsyncOperationResponse'
316
+
317
+ # auth_names
318
+ auth_names = opts[:auth_names] || ['Basic']
319
+
320
+ new_options = opts.merge(
321
+ :header_params => header_params,
322
+ :query_params => query_params,
323
+ :form_params => form_params,
324
+ :body => post_body,
325
+ :auth_names => auth_names,
326
+ :return_type => return_type
327
+ )
328
+
329
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
330
+ if @api_client.config.debugging
331
+ @api_client.config.logger.debug "API called: RepositoriesPythonVersionsApi#repair\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
332
+ end
333
+ return data, status_code, headers
334
+ end
335
+ end
336
+ end
@@ -0,0 +1,402 @@
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
+ require 'json'
15
+ require 'logger'
16
+ require 'tempfile'
17
+ require 'faraday'
18
+
19
+ module PulpPythonClient
20
+ class ApiClient
21
+ # The Configuration object holding settings to be used in the API client.
22
+ attr_accessor :config
23
+
24
+ # Defines the headers to be used in HTTP requests of all API calls by default.
25
+ #
26
+ # @return [Hash]
27
+ attr_accessor :default_headers
28
+
29
+ # Initializes the ApiClient
30
+ # @option config [Configuration] Configuration for initializing the object, default to Configuration.default
31
+ def initialize(config = Configuration.default)
32
+ @config = config
33
+ @user_agent = "OpenAPI-Generator/#{VERSION}/ruby"
34
+ @default_headers = {
35
+ 'Content-Type' => 'application/json',
36
+ 'User-Agent' => @user_agent
37
+ }
38
+ end
39
+
40
+ def self.default
41
+ @@default ||= ApiClient.new
42
+ end
43
+
44
+ # Call an API with given options.
45
+ #
46
+ # @return [Array<(Object, Integer, Hash)>] an array of 3 elements:
47
+ # the data deserialized from response body (could be nil), response status code and response headers.
48
+ def call_api(http_method, path, opts = {})
49
+ ssl_options = {
50
+ :ca_file => @config.ssl_ca_file,
51
+ :verify => @config.ssl_verify,
52
+ :verify_mode => @config.ssl_verify_mode,
53
+ :client_cert => @config.ssl_client_cert,
54
+ :client_key => @config.ssl_client_key
55
+ }
56
+
57
+ connection = Faraday.new(:url => config.base_url, :ssl => ssl_options) do |conn|
58
+ conn.basic_auth(config.username, config.password)
59
+ if opts[:header_params]["Content-Type"] == "multipart/form-data"
60
+ conn.request :multipart
61
+ conn.request :url_encoded
62
+ end
63
+ conn.adapter(Faraday.default_adapter)
64
+ end
65
+
66
+ begin
67
+ response = connection.public_send(http_method.to_sym.downcase) do |req|
68
+ build_request(http_method, path, req, opts)
69
+ end
70
+
71
+ if @config.debugging
72
+ @config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
73
+ end
74
+
75
+ unless response.success?
76
+ if response.status == 0
77
+ # Errors from libcurl will be made visible here
78
+ fail ApiError.new(:code => 0,
79
+ :message => response.return_message)
80
+ else
81
+ fail ApiError.new(:code => response.status,
82
+ :response_headers => response.headers,
83
+ :response_body => response.body),
84
+ response.reason_phrase
85
+ end
86
+ end
87
+ rescue Faraday::TimeoutError
88
+ fail ApiError.new('Connection timed out')
89
+ end
90
+
91
+ if opts[:return_type]
92
+ data = deserialize(response, opts[:return_type])
93
+ else
94
+ data = nil
95
+ end
96
+ return data, response.status, response.headers
97
+ end
98
+
99
+ # Builds the HTTP request
100
+ #
101
+ # @param [String] http_method HTTP method/verb (e.g. POST)
102
+ # @param [String] path URL path (e.g. /account/new)
103
+ # @option opts [Hash] :header_params Header parameters
104
+ # @option opts [Hash] :query_params Query parameters
105
+ # @option opts [Hash] :form_params Query parameters
106
+ # @option opts [Object] :body HTTP body (JSON/XML)
107
+ # @return [Typhoeus::Request] A Typhoeus Request
108
+ def build_request(http_method, path, request, opts = {})
109
+ url = build_request_url(path)
110
+ http_method = http_method.to_sym.downcase
111
+
112
+ header_params = @default_headers.merge(opts[:header_params] || {})
113
+ query_params = opts[:query_params] || {}
114
+ form_params = opts[:form_params] || {}
115
+
116
+ update_params_for_auth! header_params, query_params, opts[:auth_names]
117
+
118
+ req_opts = {
119
+ :method => http_method,
120
+ :headers => header_params,
121
+ :params => query_params,
122
+ :params_encoding => @config.params_encoding,
123
+ :timeout => @config.timeout,
124
+ :verbose => @config.debugging
125
+ }
126
+
127
+ if [:post, :patch, :put, :delete].include?(http_method)
128
+ req_body = build_request_body(header_params, form_params, opts[:body])
129
+ req_opts.update :body => req_body
130
+ if @config.debugging
131
+ @config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
132
+ end
133
+ end
134
+ request.headers = header_params
135
+ request.body = req_body
136
+ request.url url
137
+ request.params = query_params
138
+ download_file(request) if opts[:return_type] == 'File'
139
+ request
140
+ end
141
+
142
+ # Builds the HTTP request body
143
+ #
144
+ # @param [Hash] header_params Header parameters
145
+ # @param [Hash] form_params Query parameters
146
+ # @param [Object] body HTTP body (JSON/XML)
147
+ # @return [String] HTTP body data in the form of string
148
+ def build_request_body(header_params, form_params, body)
149
+ # http form
150
+ if header_params['Content-Type'] == 'application/x-www-form-urlencoded'
151
+ data = URI.encode_www_form(form_params)
152
+ elsif header_params['Content-Type'] == 'multipart/form-data'
153
+ data = {}
154
+ form_params.each do |key, value|
155
+ case value
156
+ when ::File, ::Tempfile
157
+ # TODO hardcode to application/octet-stream, need better way to detect content type
158
+ data[key] = Faraday::UploadIO.new(value.path, 'application/octet-stream', value.path)
159
+ when ::Array, nil
160
+ # let Faraday handle Array and nil parameters
161
+ data[key] = value
162
+ else
163
+ data[key] = value.to_s
164
+ end
165
+ end
166
+ elsif body
167
+ data = body.is_a?(String) ? body : body.to_json
168
+ else
169
+ data = nil
170
+ end
171
+ data
172
+ end
173
+
174
+ # Check if the given MIME is a JSON MIME.
175
+ # JSON MIME examples:
176
+ # application/json
177
+ # application/json; charset=UTF8
178
+ # APPLICATION/JSON
179
+ # */*
180
+ # @param [String] mime MIME
181
+ # @return [Boolean] True if the MIME is application/json
182
+ def json_mime?(mime)
183
+ (mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
184
+ end
185
+
186
+ # Deserialize the response to the given return type.
187
+ #
188
+ # @param [Response] response HTTP response
189
+ # @param [String] return_type some examples: "User", "Array<User>", "Hash<String, Integer>"
190
+ def deserialize(response, return_type)
191
+ body = response.body
192
+
193
+ # handle file downloading - return the File instance processed in request callbacks
194
+ # note that response body is empty when the file is written in chunks in request on_body callback
195
+ return @tempfile if return_type == 'File'
196
+
197
+ return nil if body.nil? || body.empty?
198
+
199
+ # return response body directly for String return type
200
+ return body if return_type == 'String'
201
+
202
+ # ensuring a default content type
203
+ content_type = response.headers['Content-Type'] || 'application/json'
204
+
205
+ fail "Content-Type is not supported: #{content_type}" unless json_mime?(content_type)
206
+
207
+ begin
208
+ data = JSON.parse("[#{body}]", :symbolize_names => true)[0]
209
+ rescue JSON::ParserError => e
210
+ if %w(String Date DateTime).include?(return_type)
211
+ data = body
212
+ else
213
+ raise e
214
+ end
215
+ end
216
+
217
+ convert_to_type data, return_type
218
+ end
219
+
220
+ # Convert data to the given return type.
221
+ # @param [Object] data Data to be converted
222
+ # @param [String] return_type Return type
223
+ # @return [Mixed] Data in a particular type
224
+ def convert_to_type(data, return_type)
225
+ return nil if data.nil?
226
+ case return_type
227
+ when 'String'
228
+ data.to_s
229
+ when 'Integer'
230
+ data.to_i
231
+ when 'Float'
232
+ data.to_f
233
+ when 'Boolean'
234
+ data == true
235
+ when 'DateTime'
236
+ # parse date time (expecting ISO 8601 format)
237
+ DateTime.parse data
238
+ when 'Date'
239
+ # parse date time (expecting ISO 8601 format)
240
+ Date.parse data
241
+ when 'Object'
242
+ # generic object (usually a Hash), return directly
243
+ data
244
+ when /\AArray<(.+)>\z/
245
+ # e.g. Array<Pet>
246
+ sub_type = $1
247
+ data.map { |item| convert_to_type(item, sub_type) }
248
+ when /\AHash\<String, (.+)\>\z/
249
+ # e.g. Hash<String, Integer>
250
+ sub_type = $1
251
+ {}.tap do |hash|
252
+ data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
253
+ end
254
+ else
255
+ # models, e.g. Pet
256
+ PulpPythonClient.const_get(return_type).build_from_hash(data)
257
+ end
258
+ end
259
+
260
+ # Save response body into a file in (the defined) temporary folder, using the filename
261
+ # from the "Content-Disposition" header if provided, otherwise a random filename.
262
+ # The response body is written to the file in chunks in order to handle files which
263
+ # size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
264
+ # process can use.
265
+ #
266
+ # @see Configuration#temp_folder_path
267
+ def download_file(request)
268
+ tempfile = nil
269
+ encoding = nil
270
+ request.on_headers do |response|
271
+ content_disposition = response.headers['Content-Disposition']
272
+ if content_disposition && content_disposition =~ /filename=/i
273
+ filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
274
+ prefix = sanitize_filename(filename)
275
+ else
276
+ prefix = 'download-'
277
+ end
278
+ prefix = prefix + '-' unless prefix.end_with?('-')
279
+ encoding = response.body.encoding
280
+ tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
281
+ @tempfile = tempfile
282
+ end
283
+ request.on_body do |chunk|
284
+ chunk.force_encoding(encoding)
285
+ tempfile.write(chunk)
286
+ end
287
+ request.on_complete do |response|
288
+ tempfile.close if tempfile
289
+ @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
290
+ "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
291
+ "will be deleted automatically with GC. It's also recommended to delete the temp file "\
292
+ "explicitly with `tempfile.delete`"
293
+ end
294
+ end
295
+
296
+ # Sanitize filename by removing path.
297
+ # e.g. ../../sun.gif becomes sun.gif
298
+ #
299
+ # @param [String] filename the filename to be sanitized
300
+ # @return [String] the sanitized filename
301
+ def sanitize_filename(filename)
302
+ filename.gsub(/.*[\/\\]/, '')
303
+ end
304
+
305
+ def build_request_url(path)
306
+ # Add leading and trailing slashes to path
307
+ path = "/#{path}".gsub(/\/+/, '/')
308
+ @config.base_url + path
309
+ end
310
+
311
+ # Update hearder and query params based on authentication settings.
312
+ #
313
+ # @param [Hash] header_params Header parameters
314
+ # @param [Hash] query_params Query parameters
315
+ # @param [String] auth_names Authentication scheme name
316
+ def update_params_for_auth!(header_params, query_params, auth_names)
317
+ Array(auth_names).each do |auth_name|
318
+ auth_setting = @config.auth_settings[auth_name]
319
+ next unless auth_setting
320
+ case auth_setting[:in]
321
+ when 'header' then header_params[auth_setting[:key]] = auth_setting[:value]
322
+ when 'query' then query_params[auth_setting[:key]] = auth_setting[:value]
323
+ else fail ArgumentError, 'Authentication token must be in `query` of `header`'
324
+ end
325
+ end
326
+ end
327
+
328
+ # Sets user agent in HTTP header
329
+ #
330
+ # @param [String] user_agent User agent (e.g. openapi-generator/ruby/1.0.0)
331
+ def user_agent=(user_agent)
332
+ @user_agent = user_agent
333
+ @default_headers['User-Agent'] = @user_agent
334
+ end
335
+
336
+ # Return Accept header based on an array of accepts provided.
337
+ # @param [Array] accepts array for Accept
338
+ # @return [String] the Accept header (e.g. application/json)
339
+ def select_header_accept(accepts)
340
+ return nil if accepts.nil? || accepts.empty?
341
+ # use JSON when present, otherwise use all of the provided
342
+ json_accept = accepts.find { |s| json_mime?(s) }
343
+ json_accept || accepts.join(',')
344
+ end
345
+
346
+ # Return Content-Type header based on an array of content types provided.
347
+ # @param [Array] content_types array for Content-Type
348
+ # @return [String] the Content-Type header (e.g. application/json)
349
+ def select_header_content_type(content_types)
350
+ # use application/json by default
351
+ return 'application/json' if content_types.nil? || content_types.empty?
352
+ # use JSON when present, otherwise use the first one
353
+ json_content_type = content_types.find { |s| json_mime?(s) }
354
+ json_content_type || content_types.first
355
+ end
356
+
357
+ # Convert object (array, hash, object, etc) to JSON string.
358
+ # @param [Object] model object to be converted into JSON string
359
+ # @return [String] JSON string representation of the object
360
+ def object_to_http_body(model)
361
+ return model if model.nil? || model.is_a?(String)
362
+ local_body = nil
363
+ if model.is_a?(Array)
364
+ local_body = model.map { |m| object_to_hash(m) }
365
+ else
366
+ local_body = object_to_hash(model)
367
+ end
368
+ local_body.to_json
369
+ end
370
+
371
+ # Convert object(non-array) to hash.
372
+ # @param [Object] obj object to be converted into JSON string
373
+ # @return [String] JSON string representation of the object
374
+ def object_to_hash(obj)
375
+ if obj.respond_to?(:to_hash)
376
+ obj.to_hash
377
+ else
378
+ obj
379
+ end
380
+ end
381
+
382
+ # Build parameter value according to the given collection format.
383
+ # @param [String] collection_format one of :csv, :ssv, :tsv, :pipes and :multi
384
+ def build_collection_param(param, collection_format)
385
+ case collection_format
386
+ when :csv
387
+ param.join(',')
388
+ when :ssv
389
+ param.join(' ')
390
+ when :tsv
391
+ param.join("\t")
392
+ when :pipes
393
+ param.join('|')
394
+ when :multi
395
+ # return the array directly as typhoeus will handle it as expected
396
+ param
397
+ else
398
+ fail "unknown collection format: #{collection_format.inspect}"
399
+ end
400
+ end
401
+ end
402
+ end