pulp_2to3_migration_client 0.2.0b3.dev01592314856 → 0.2.0b4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -4
  3. data/lib/pulp_2to3_migration_client/version.rb +1 -1
  4. metadata +2 -41
  5. data/pulpcore/__init__.py +0 -2
  6. data/pulpcore/client/__init__.py +0 -2
  7. data/pulpcore/client/pulp_2to3_migration/__init__.py +0 -42
  8. data/pulpcore/client/pulp_2to3_migration/api/__init__.py +0 -8
  9. data/pulpcore/client/pulp_2to3_migration/api/migration_plans_api.py +0 -609
  10. data/pulpcore/client/pulp_2to3_migration/api/pulp2content_api.py +0 -317
  11. data/pulpcore/client/pulp_2to3_migration/api/pulp2repositories_api.py +0 -289
  12. data/pulpcore/client/pulp_2to3_migration/api_client.py +0 -647
  13. data/pulpcore/client/pulp_2to3_migration/configuration.py +0 -387
  14. data/pulpcore/client/pulp_2to3_migration/exceptions.py +0 -120
  15. data/pulpcore/client/pulp_2to3_migration/models/__init__.py +0 -25
  16. data/pulpcore/client/pulp_2to3_migration/models/async_operation_response.py +0 -123
  17. data/pulpcore/client/pulp_2to3_migration/models/inline_response200.py +0 -198
  18. data/pulpcore/client/pulp_2to3_migration/models/inline_response2001.py +0 -198
  19. data/pulpcore/client/pulp_2to3_migration/models/inline_response2002.py +0 -198
  20. data/pulpcore/client/pulp_2to3_migration/models/migration_plan_run.py +0 -150
  21. data/pulpcore/client/pulp_2to3_migration/models/pulp2to3_migration_migration_plan.py +0 -177
  22. data/pulpcore/client/pulp_2to3_migration/models/pulp2to3_migration_migration_plan_read.py +0 -177
  23. data/pulpcore/client/pulp_2to3_migration/models/pulp2to3_migration_pulp2_content_read.py +0 -353
  24. data/pulpcore/client/pulp_2to3_migration/models/pulp2to3_migration_pulp2_repository_read.py +0 -441
  25. data/pulpcore/client/pulp_2to3_migration/rest.py +0 -296
  26. data/requirements.txt +0 -6
  27. data/setup.cfg +0 -2
  28. data/setup.py +0 -41
  29. data/test-requirements.txt +0 -3
  30. data/test/__init__.py +0 -0
  31. data/test/test_async_operation_response.py +0 -53
  32. data/test/test_inline_response200.py +0 -67
  33. data/test/test_inline_response2001.py +0 -79
  34. data/test/test_inline_response2002.py +0 -89
  35. data/test/test_migration_plan_run.py +0 -53
  36. data/test/test_migration_plans_api.py +0 -68
  37. data/test/test_pulp2content_api.py +0 -47
  38. data/test/test_pulp2repositories_api.py +0 -47
  39. data/test/test_pulp2to3_migration_migration_plan.py +0 -55
  40. data/test/test_pulp2to3_migration_migration_plan_read.py +0 -55
  41. data/test/test_pulp2to3_migration_pulp2_content_read.py +0 -64
  42. data/test/test_pulp2to3_migration_pulp2_repository_read.py +0 -68
  43. data/tox.ini +0 -9
@@ -1,441 +0,0 @@
1
- # coding: utf-8
2
-
3
- """
4
- Pulp 3 API
5
-
6
- No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501
7
-
8
- The version of the OpenAPI document: v3
9
- Generated by: https://openapi-generator.tech
10
- """
11
-
12
-
13
- import pprint
14
- import re # noqa: F401
15
-
16
- import six
17
-
18
- from pulpcore.client.pulp_2to3_migration.configuration import Configuration
19
-
20
-
21
- class Pulp2to3MigrationPulp2RepositoryRead(object):
22
- """NOTE: This class is auto generated by OpenAPI Generator.
23
- Ref: https://openapi-generator.tech
24
-
25
- Do not edit the class manually.
26
- """
27
-
28
- """
29
- Attributes:
30
- openapi_types (dict): The key is attribute name
31
- and the value is attribute type.
32
- attribute_map (dict): The key is attribute name
33
- and the value is json key in definition.
34
- """
35
- openapi_types = {
36
- 'pulp_href': 'str',
37
- 'pulp_created': 'datetime',
38
- 'pulp2_object_id': 'str',
39
- 'pulp2_repo_id': 'str',
40
- 'pulp2_repo_type': 'str',
41
- 'is_migrated': 'bool',
42
- 'not_in_plan': 'bool',
43
- 'pulp3_repository_version': 'str',
44
- 'pulp3_remote_href': 'str',
45
- 'pulp3_publication_href': 'str',
46
- 'pulp3_distribution_hrefs': 'list[str]',
47
- 'pulp3_repository_href': 'str'
48
- }
49
-
50
- attribute_map = {
51
- 'pulp_href': 'pulp_href',
52
- 'pulp_created': 'pulp_created',
53
- 'pulp2_object_id': 'pulp2_object_id',
54
- 'pulp2_repo_id': 'pulp2_repo_id',
55
- 'pulp2_repo_type': 'pulp2_repo_type',
56
- 'is_migrated': 'is_migrated',
57
- 'not_in_plan': 'not_in_plan',
58
- 'pulp3_repository_version': 'pulp3_repository_version',
59
- 'pulp3_remote_href': 'pulp3_remote_href',
60
- 'pulp3_publication_href': 'pulp3_publication_href',
61
- 'pulp3_distribution_hrefs': 'pulp3_distribution_hrefs',
62
- 'pulp3_repository_href': 'pulp3_repository_href'
63
- }
64
-
65
- def __init__(self, pulp_href=None, pulp_created=None, pulp2_object_id=None, pulp2_repo_id=None, pulp2_repo_type=None, is_migrated=False, not_in_plan=False, pulp3_repository_version=None, pulp3_remote_href=None, pulp3_publication_href=None, pulp3_distribution_hrefs=None, pulp3_repository_href=None, local_vars_configuration=None): # noqa: E501
66
- """Pulp2to3MigrationPulp2RepositoryRead - a model defined in OpenAPI""" # noqa: E501
67
- if local_vars_configuration is None:
68
- local_vars_configuration = Configuration()
69
- self.local_vars_configuration = local_vars_configuration
70
-
71
- self._pulp_href = None
72
- self._pulp_created = None
73
- self._pulp2_object_id = None
74
- self._pulp2_repo_id = None
75
- self._pulp2_repo_type = None
76
- self._is_migrated = None
77
- self._not_in_plan = None
78
- self._pulp3_repository_version = None
79
- self._pulp3_remote_href = None
80
- self._pulp3_publication_href = None
81
- self._pulp3_distribution_hrefs = None
82
- self._pulp3_repository_href = None
83
- self.discriminator = None
84
-
85
- if pulp_href is not None:
86
- self.pulp_href = pulp_href
87
- if pulp_created is not None:
88
- self.pulp_created = pulp_created
89
- self.pulp2_object_id = pulp2_object_id
90
- self.pulp2_repo_id = pulp2_repo_id
91
- self.pulp2_repo_type = pulp2_repo_type
92
- if is_migrated is not None:
93
- self.is_migrated = is_migrated
94
- if not_in_plan is not None:
95
- self.not_in_plan = not_in_plan
96
- self.pulp3_repository_version = pulp3_repository_version
97
- if pulp3_remote_href is not None:
98
- self.pulp3_remote_href = pulp3_remote_href
99
- if pulp3_publication_href is not None:
100
- self.pulp3_publication_href = pulp3_publication_href
101
- if pulp3_distribution_hrefs is not None:
102
- self.pulp3_distribution_hrefs = pulp3_distribution_hrefs
103
- if pulp3_repository_href is not None:
104
- self.pulp3_repository_href = pulp3_repository_href
105
-
106
- @property
107
- def pulp_href(self):
108
- """Gets the pulp_href of this Pulp2to3MigrationPulp2RepositoryRead. # noqa: E501
109
-
110
-
111
- :return: The pulp_href of this Pulp2to3MigrationPulp2RepositoryRead. # noqa: E501
112
- :rtype: str
113
- """
114
- return self._pulp_href
115
-
116
- @pulp_href.setter
117
- def pulp_href(self, pulp_href):
118
- """Sets the pulp_href of this Pulp2to3MigrationPulp2RepositoryRead.
119
-
120
-
121
- :param pulp_href: The pulp_href of this Pulp2to3MigrationPulp2RepositoryRead. # noqa: E501
122
- :type: str
123
- """
124
-
125
- self._pulp_href = pulp_href
126
-
127
- @property
128
- def pulp_created(self):
129
- """Gets the pulp_created of this Pulp2to3MigrationPulp2RepositoryRead. # noqa: E501
130
-
131
- Timestamp of creation. # noqa: E501
132
-
133
- :return: The pulp_created of this Pulp2to3MigrationPulp2RepositoryRead. # noqa: E501
134
- :rtype: datetime
135
- """
136
- return self._pulp_created
137
-
138
- @pulp_created.setter
139
- def pulp_created(self, pulp_created):
140
- """Sets the pulp_created of this Pulp2to3MigrationPulp2RepositoryRead.
141
-
142
- Timestamp of creation. # noqa: E501
143
-
144
- :param pulp_created: The pulp_created of this Pulp2to3MigrationPulp2RepositoryRead. # noqa: E501
145
- :type: datetime
146
- """
147
-
148
- self._pulp_created = pulp_created
149
-
150
- @property
151
- def pulp2_object_id(self):
152
- """Gets the pulp2_object_id of this Pulp2to3MigrationPulp2RepositoryRead. # noqa: E501
153
-
154
-
155
- :return: The pulp2_object_id of this Pulp2to3MigrationPulp2RepositoryRead. # noqa: E501
156
- :rtype: str
157
- """
158
- return self._pulp2_object_id
159
-
160
- @pulp2_object_id.setter
161
- def pulp2_object_id(self, pulp2_object_id):
162
- """Sets the pulp2_object_id of this Pulp2to3MigrationPulp2RepositoryRead.
163
-
164
-
165
- :param pulp2_object_id: The pulp2_object_id of this Pulp2to3MigrationPulp2RepositoryRead. # noqa: E501
166
- :type: str
167
- """
168
- if self.local_vars_configuration.client_side_validation and pulp2_object_id is None: # noqa: E501
169
- raise ValueError("Invalid value for `pulp2_object_id`, must not be `None`") # noqa: E501
170
- if (self.local_vars_configuration.client_side_validation and
171
- pulp2_object_id is not None and len(pulp2_object_id) > 255):
172
- raise ValueError("Invalid value for `pulp2_object_id`, length must be less than or equal to `255`") # noqa: E501
173
- if (self.local_vars_configuration.client_side_validation and
174
- pulp2_object_id is not None and len(pulp2_object_id) < 1):
175
- raise ValueError("Invalid value for `pulp2_object_id`, length must be greater than or equal to `1`") # noqa: E501
176
-
177
- self._pulp2_object_id = pulp2_object_id
178
-
179
- @property
180
- def pulp2_repo_id(self):
181
- """Gets the pulp2_repo_id of this Pulp2to3MigrationPulp2RepositoryRead. # noqa: E501
182
-
183
-
184
- :return: The pulp2_repo_id of this Pulp2to3MigrationPulp2RepositoryRead. # noqa: E501
185
- :rtype: str
186
- """
187
- return self._pulp2_repo_id
188
-
189
- @pulp2_repo_id.setter
190
- def pulp2_repo_id(self, pulp2_repo_id):
191
- """Sets the pulp2_repo_id of this Pulp2to3MigrationPulp2RepositoryRead.
192
-
193
-
194
- :param pulp2_repo_id: The pulp2_repo_id of this Pulp2to3MigrationPulp2RepositoryRead. # noqa: E501
195
- :type: str
196
- """
197
- if self.local_vars_configuration.client_side_validation and pulp2_repo_id is None: # noqa: E501
198
- raise ValueError("Invalid value for `pulp2_repo_id`, must not be `None`") # noqa: E501
199
- if (self.local_vars_configuration.client_side_validation and
200
- pulp2_repo_id is not None and len(pulp2_repo_id) < 1):
201
- raise ValueError("Invalid value for `pulp2_repo_id`, length must be greater than or equal to `1`") # noqa: E501
202
-
203
- self._pulp2_repo_id = pulp2_repo_id
204
-
205
- @property
206
- def pulp2_repo_type(self):
207
- """Gets the pulp2_repo_type of this Pulp2to3MigrationPulp2RepositoryRead. # noqa: E501
208
-
209
-
210
- :return: The pulp2_repo_type of this Pulp2to3MigrationPulp2RepositoryRead. # noqa: E501
211
- :rtype: str
212
- """
213
- return self._pulp2_repo_type
214
-
215
- @pulp2_repo_type.setter
216
- def pulp2_repo_type(self, pulp2_repo_type):
217
- """Sets the pulp2_repo_type of this Pulp2to3MigrationPulp2RepositoryRead.
218
-
219
-
220
- :param pulp2_repo_type: The pulp2_repo_type of this Pulp2to3MigrationPulp2RepositoryRead. # noqa: E501
221
- :type: str
222
- """
223
- if self.local_vars_configuration.client_side_validation and pulp2_repo_type is None: # noqa: E501
224
- raise ValueError("Invalid value for `pulp2_repo_type`, must not be `None`") # noqa: E501
225
- if (self.local_vars_configuration.client_side_validation and
226
- pulp2_repo_type is not None and len(pulp2_repo_type) < 1):
227
- raise ValueError("Invalid value for `pulp2_repo_type`, length must be greater than or equal to `1`") # noqa: E501
228
-
229
- self._pulp2_repo_type = pulp2_repo_type
230
-
231
- @property
232
- def is_migrated(self):
233
- """Gets the is_migrated of this Pulp2to3MigrationPulp2RepositoryRead. # noqa: E501
234
-
235
-
236
- :return: The is_migrated of this Pulp2to3MigrationPulp2RepositoryRead. # noqa: E501
237
- :rtype: bool
238
- """
239
- return self._is_migrated
240
-
241
- @is_migrated.setter
242
- def is_migrated(self, is_migrated):
243
- """Sets the is_migrated of this Pulp2to3MigrationPulp2RepositoryRead.
244
-
245
-
246
- :param is_migrated: The is_migrated of this Pulp2to3MigrationPulp2RepositoryRead. # noqa: E501
247
- :type: bool
248
- """
249
-
250
- self._is_migrated = is_migrated
251
-
252
- @property
253
- def not_in_plan(self):
254
- """Gets the not_in_plan of this Pulp2to3MigrationPulp2RepositoryRead. # noqa: E501
255
-
256
-
257
- :return: The not_in_plan of this Pulp2to3MigrationPulp2RepositoryRead. # noqa: E501
258
- :rtype: bool
259
- """
260
- return self._not_in_plan
261
-
262
- @not_in_plan.setter
263
- def not_in_plan(self, not_in_plan):
264
- """Sets the not_in_plan of this Pulp2to3MigrationPulp2RepositoryRead.
265
-
266
-
267
- :param not_in_plan: The not_in_plan of this Pulp2to3MigrationPulp2RepositoryRead. # noqa: E501
268
- :type: bool
269
- """
270
-
271
- self._not_in_plan = not_in_plan
272
-
273
- @property
274
- def pulp3_repository_version(self):
275
- """Gets the pulp3_repository_version of this Pulp2to3MigrationPulp2RepositoryRead. # noqa: E501
276
-
277
- RepositoryVersion to be served # noqa: E501
278
-
279
- :return: The pulp3_repository_version of this Pulp2to3MigrationPulp2RepositoryRead. # noqa: E501
280
- :rtype: str
281
- """
282
- return self._pulp3_repository_version
283
-
284
- @pulp3_repository_version.setter
285
- def pulp3_repository_version(self, pulp3_repository_version):
286
- """Sets the pulp3_repository_version of this Pulp2to3MigrationPulp2RepositoryRead.
287
-
288
- RepositoryVersion to be served # noqa: E501
289
-
290
- :param pulp3_repository_version: The pulp3_repository_version of this Pulp2to3MigrationPulp2RepositoryRead. # noqa: E501
291
- :type: str
292
- """
293
-
294
- self._pulp3_repository_version = pulp3_repository_version
295
-
296
- @property
297
- def pulp3_remote_href(self):
298
- """Gets the pulp3_remote_href of this Pulp2to3MigrationPulp2RepositoryRead. # noqa: E501
299
-
300
- Get pulp3_remote_href from pulp2repo # noqa: E501
301
-
302
- :return: The pulp3_remote_href of this Pulp2to3MigrationPulp2RepositoryRead. # noqa: E501
303
- :rtype: str
304
- """
305
- return self._pulp3_remote_href
306
-
307
- @pulp3_remote_href.setter
308
- def pulp3_remote_href(self, pulp3_remote_href):
309
- """Sets the pulp3_remote_href of this Pulp2to3MigrationPulp2RepositoryRead.
310
-
311
- Get pulp3_remote_href from pulp2repo # noqa: E501
312
-
313
- :param pulp3_remote_href: The pulp3_remote_href of this Pulp2to3MigrationPulp2RepositoryRead. # noqa: E501
314
- :type: str
315
- """
316
- if (self.local_vars_configuration.client_side_validation and
317
- pulp3_remote_href is not None and len(pulp3_remote_href) < 1):
318
- raise ValueError("Invalid value for `pulp3_remote_href`, length must be greater than or equal to `1`") # noqa: E501
319
-
320
- self._pulp3_remote_href = pulp3_remote_href
321
-
322
- @property
323
- def pulp3_publication_href(self):
324
- """Gets the pulp3_publication_href of this Pulp2to3MigrationPulp2RepositoryRead. # noqa: E501
325
-
326
- Get pulp3_publication_href from pulp3_repository_version # noqa: E501
327
-
328
- :return: The pulp3_publication_href of this Pulp2to3MigrationPulp2RepositoryRead. # noqa: E501
329
- :rtype: str
330
- """
331
- return self._pulp3_publication_href
332
-
333
- @pulp3_publication_href.setter
334
- def pulp3_publication_href(self, pulp3_publication_href):
335
- """Sets the pulp3_publication_href of this Pulp2to3MigrationPulp2RepositoryRead.
336
-
337
- Get pulp3_publication_href from pulp3_repository_version # noqa: E501
338
-
339
- :param pulp3_publication_href: The pulp3_publication_href of this Pulp2to3MigrationPulp2RepositoryRead. # noqa: E501
340
- :type: str
341
- """
342
- if (self.local_vars_configuration.client_side_validation and
343
- pulp3_publication_href is not None and len(pulp3_publication_href) < 1):
344
- raise ValueError("Invalid value for `pulp3_publication_href`, length must be greater than or equal to `1`") # noqa: E501
345
-
346
- self._pulp3_publication_href = pulp3_publication_href
347
-
348
- @property
349
- def pulp3_distribution_hrefs(self):
350
- """Gets the pulp3_distribution_hrefs of this Pulp2to3MigrationPulp2RepositoryRead. # noqa: E501
351
-
352
- Get pulp3_distribution_hrefs from pulp3_repository_version # noqa: E501
353
-
354
- :return: The pulp3_distribution_hrefs of this Pulp2to3MigrationPulp2RepositoryRead. # noqa: E501
355
- :rtype: list[str]
356
- """
357
- return self._pulp3_distribution_hrefs
358
-
359
- @pulp3_distribution_hrefs.setter
360
- def pulp3_distribution_hrefs(self, pulp3_distribution_hrefs):
361
- """Sets the pulp3_distribution_hrefs of this Pulp2to3MigrationPulp2RepositoryRead.
362
-
363
- Get pulp3_distribution_hrefs from pulp3_repository_version # noqa: E501
364
-
365
- :param pulp3_distribution_hrefs: The pulp3_distribution_hrefs of this Pulp2to3MigrationPulp2RepositoryRead. # noqa: E501
366
- :type: list[str]
367
- """
368
-
369
- self._pulp3_distribution_hrefs = pulp3_distribution_hrefs
370
-
371
- @property
372
- def pulp3_repository_href(self):
373
- """Gets the pulp3_repository_href of this Pulp2to3MigrationPulp2RepositoryRead. # noqa: E501
374
-
375
- Get pulp3_repository_href from pulp2repo # noqa: E501
376
-
377
- :return: The pulp3_repository_href of this Pulp2to3MigrationPulp2RepositoryRead. # noqa: E501
378
- :rtype: str
379
- """
380
- return self._pulp3_repository_href
381
-
382
- @pulp3_repository_href.setter
383
- def pulp3_repository_href(self, pulp3_repository_href):
384
- """Sets the pulp3_repository_href of this Pulp2to3MigrationPulp2RepositoryRead.
385
-
386
- Get pulp3_repository_href from pulp2repo # noqa: E501
387
-
388
- :param pulp3_repository_href: The pulp3_repository_href of this Pulp2to3MigrationPulp2RepositoryRead. # noqa: E501
389
- :type: str
390
- """
391
- if (self.local_vars_configuration.client_side_validation and
392
- pulp3_repository_href is not None and len(pulp3_repository_href) < 1):
393
- raise ValueError("Invalid value for `pulp3_repository_href`, length must be greater than or equal to `1`") # noqa: E501
394
-
395
- self._pulp3_repository_href = pulp3_repository_href
396
-
397
- def to_dict(self):
398
- """Returns the model properties as a dict"""
399
- result = {}
400
-
401
- for attr, _ in six.iteritems(self.openapi_types):
402
- value = getattr(self, attr)
403
- if isinstance(value, list):
404
- result[attr] = list(map(
405
- lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
406
- value
407
- ))
408
- elif hasattr(value, "to_dict"):
409
- result[attr] = value.to_dict()
410
- elif isinstance(value, dict):
411
- result[attr] = dict(map(
412
- lambda item: (item[0], item[1].to_dict())
413
- if hasattr(item[1], "to_dict") else item,
414
- value.items()
415
- ))
416
- else:
417
- result[attr] = value
418
-
419
- return result
420
-
421
- def to_str(self):
422
- """Returns the string representation of the model"""
423
- return pprint.pformat(self.to_dict())
424
-
425
- def __repr__(self):
426
- """For `print` and `pprint`"""
427
- return self.to_str()
428
-
429
- def __eq__(self, other):
430
- """Returns true if both objects are equal"""
431
- if not isinstance(other, Pulp2to3MigrationPulp2RepositoryRead):
432
- return False
433
-
434
- return self.to_dict() == other.to_dict()
435
-
436
- def __ne__(self, other):
437
- """Returns true if both objects are not equal"""
438
- if not isinstance(other, Pulp2to3MigrationPulp2RepositoryRead):
439
- return True
440
-
441
- return self.to_dict() != other.to_dict()
@@ -1,296 +0,0 @@
1
- # coding: utf-8
2
-
3
- """
4
- Pulp 3 API
5
-
6
- No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501
7
-
8
- The version of the OpenAPI document: v3
9
- Generated by: https://openapi-generator.tech
10
- """
11
-
12
-
13
- from __future__ import absolute_import
14
-
15
- import io
16
- import json
17
- import logging
18
- import re
19
- import ssl
20
-
21
- import certifi
22
- # python 2 and python 3 compatibility library
23
- import six
24
- from six.moves.urllib.parse import urlencode
25
- import urllib3
26
-
27
- from pulpcore.client.pulp_2to3_migration.exceptions import ApiException, ApiValueError
28
-
29
-
30
- logger = logging.getLogger(__name__)
31
-
32
-
33
- class RESTResponse(io.IOBase):
34
-
35
- def __init__(self, resp):
36
- self.urllib3_response = resp
37
- self.status = resp.status
38
- self.reason = resp.reason
39
- self.data = resp.data
40
-
41
- def getheaders(self):
42
- """Returns a dictionary of the response headers."""
43
- return self.urllib3_response.getheaders()
44
-
45
- def getheader(self, name, default=None):
46
- """Returns a given response header."""
47
- return self.urllib3_response.getheader(name, default)
48
-
49
-
50
- class RESTClientObject(object):
51
-
52
- def __init__(self, configuration, pools_size=4, maxsize=None):
53
- # urllib3.PoolManager will pass all kw parameters to connectionpool
54
- # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/poolmanager.py#L75 # noqa: E501
55
- # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/connectionpool.py#L680 # noqa: E501
56
- # maxsize is the number of requests to host that are allowed in parallel # noqa: E501
57
- # Custom SSL certificates and client certificates: http://urllib3.readthedocs.io/en/latest/advanced-usage.html # noqa: E501
58
-
59
- # cert_reqs
60
- if configuration.verify_ssl:
61
- cert_reqs = ssl.CERT_REQUIRED
62
- else:
63
- cert_reqs = ssl.CERT_NONE
64
-
65
- # ca_certs
66
- if configuration.ssl_ca_cert:
67
- ca_certs = configuration.ssl_ca_cert
68
- else:
69
- # if not set certificate file, use Mozilla's root certificates.
70
- ca_certs = certifi.where()
71
-
72
- addition_pool_args = {}
73
- if configuration.assert_hostname is not None:
74
- addition_pool_args['assert_hostname'] = configuration.assert_hostname # noqa: E501
75
-
76
- if configuration.retries is not None:
77
- addition_pool_args['retries'] = configuration.retries
78
-
79
- if maxsize is None:
80
- if configuration.connection_pool_maxsize is not None:
81
- maxsize = configuration.connection_pool_maxsize
82
- else:
83
- maxsize = 4
84
-
85
- # https pool manager
86
- if configuration.proxy:
87
- self.pool_manager = urllib3.ProxyManager(
88
- num_pools=pools_size,
89
- maxsize=maxsize,
90
- cert_reqs=cert_reqs,
91
- ca_certs=ca_certs,
92
- cert_file=configuration.cert_file,
93
- key_file=configuration.key_file,
94
- proxy_url=configuration.proxy,
95
- proxy_headers=configuration.proxy_headers,
96
- **addition_pool_args
97
- )
98
- else:
99
- self.pool_manager = urllib3.PoolManager(
100
- num_pools=pools_size,
101
- maxsize=maxsize,
102
- cert_reqs=cert_reqs,
103
- ca_certs=ca_certs,
104
- cert_file=configuration.cert_file,
105
- key_file=configuration.key_file,
106
- **addition_pool_args
107
- )
108
-
109
- def request(self, method, url, query_params=None, headers=None,
110
- body=None, post_params=None, _preload_content=True,
111
- _request_timeout=None):
112
- """Perform requests.
113
-
114
- :param method: http request method
115
- :param url: http request url
116
- :param query_params: query parameters in the url
117
- :param headers: http request headers
118
- :param body: request json body, for `application/json`
119
- :param post_params: request post parameters,
120
- `application/x-www-form-urlencoded`
121
- and `multipart/form-data`
122
- :param _preload_content: if False, the urllib3.HTTPResponse object will
123
- be returned without reading/decoding response
124
- data. Default is True.
125
- :param _request_timeout: timeout setting for this request. If one
126
- number provided, it will be total request
127
- timeout. It can also be a pair (tuple) of
128
- (connection, read) timeouts.
129
- """
130
- method = method.upper()
131
- assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT',
132
- 'PATCH', 'OPTIONS']
133
-
134
- if post_params and body:
135
- raise ApiValueError(
136
- "body parameter cannot be used with post_params parameter."
137
- )
138
-
139
- post_params = post_params or {}
140
- headers = headers or {}
141
-
142
- timeout = None
143
- if _request_timeout:
144
- if isinstance(_request_timeout, (int, ) if six.PY3 else (int, long)): # noqa: E501,F821
145
- timeout = urllib3.Timeout(total=_request_timeout)
146
- elif (isinstance(_request_timeout, tuple) and
147
- len(_request_timeout) == 2):
148
- timeout = urllib3.Timeout(
149
- connect=_request_timeout[0], read=_request_timeout[1])
150
-
151
- if 'Content-Type' not in headers:
152
- headers['Content-Type'] = 'application/json'
153
-
154
- try:
155
- # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE`
156
- if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']:
157
- if query_params:
158
- url += '?' + urlencode(query_params)
159
- if re.search('json', headers['Content-Type'], re.IGNORECASE):
160
- request_body = None
161
- if body is not None:
162
- request_body = json.dumps(body)
163
- r = self.pool_manager.request(
164
- method, url,
165
- body=request_body,
166
- preload_content=_preload_content,
167
- timeout=timeout,
168
- headers=headers)
169
- elif headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501
170
- r = self.pool_manager.request(
171
- method, url,
172
- fields=post_params,
173
- encode_multipart=False,
174
- preload_content=_preload_content,
175
- timeout=timeout,
176
- headers=headers)
177
- elif headers['Content-Type'] == 'multipart/form-data':
178
- # must del headers['Content-Type'], or the correct
179
- # Content-Type which generated by urllib3 will be
180
- # overwritten.
181
- del headers['Content-Type']
182
- r = self.pool_manager.request(
183
- method, url,
184
- fields=post_params,
185
- encode_multipart=True,
186
- preload_content=_preload_content,
187
- timeout=timeout,
188
- headers=headers)
189
- # Pass a `string` parameter directly in the body to support
190
- # other content types than Json when `body` argument is
191
- # provided in serialized form
192
- elif isinstance(body, str) or isinstance(body, bytes):
193
- request_body = body
194
- r = self.pool_manager.request(
195
- method, url,
196
- body=request_body,
197
- preload_content=_preload_content,
198
- timeout=timeout,
199
- headers=headers)
200
- else:
201
- # Cannot generate the request from given parameters
202
- msg = """Cannot prepare a request message for provided
203
- arguments. Please check that your arguments match
204
- declared content type."""
205
- raise ApiException(status=0, reason=msg)
206
- # For `GET`, `HEAD`
207
- else:
208
- r = self.pool_manager.request(method, url,
209
- fields=query_params,
210
- preload_content=_preload_content,
211
- timeout=timeout,
212
- headers=headers)
213
- except urllib3.exceptions.SSLError as e:
214
- msg = "{0}\n{1}".format(type(e).__name__, str(e))
215
- raise ApiException(status=0, reason=msg)
216
-
217
- if _preload_content:
218
- r = RESTResponse(r)
219
-
220
- # In the python 3, the response.data is bytes.
221
- # we need to decode it to string.
222
- if six.PY3:
223
- r.data = r.data.decode('utf8')
224
-
225
- # log response body
226
- logger.debug("response body: %s", r.data)
227
-
228
- if not 200 <= r.status <= 299:
229
- raise ApiException(http_resp=r)
230
-
231
- return r
232
-
233
- def GET(self, url, headers=None, query_params=None, _preload_content=True,
234
- _request_timeout=None):
235
- return self.request("GET", url,
236
- headers=headers,
237
- _preload_content=_preload_content,
238
- _request_timeout=_request_timeout,
239
- query_params=query_params)
240
-
241
- def HEAD(self, url, headers=None, query_params=None, _preload_content=True,
242
- _request_timeout=None):
243
- return self.request("HEAD", url,
244
- headers=headers,
245
- _preload_content=_preload_content,
246
- _request_timeout=_request_timeout,
247
- query_params=query_params)
248
-
249
- def OPTIONS(self, url, headers=None, query_params=None, post_params=None,
250
- body=None, _preload_content=True, _request_timeout=None):
251
- return self.request("OPTIONS", url,
252
- headers=headers,
253
- query_params=query_params,
254
- post_params=post_params,
255
- _preload_content=_preload_content,
256
- _request_timeout=_request_timeout,
257
- body=body)
258
-
259
- def DELETE(self, url, headers=None, query_params=None, body=None,
260
- _preload_content=True, _request_timeout=None):
261
- return self.request("DELETE", url,
262
- headers=headers,
263
- query_params=query_params,
264
- _preload_content=_preload_content,
265
- _request_timeout=_request_timeout,
266
- body=body)
267
-
268
- def POST(self, url, headers=None, query_params=None, post_params=None,
269
- body=None, _preload_content=True, _request_timeout=None):
270
- return self.request("POST", url,
271
- headers=headers,
272
- query_params=query_params,
273
- post_params=post_params,
274
- _preload_content=_preload_content,
275
- _request_timeout=_request_timeout,
276
- body=body)
277
-
278
- def PUT(self, url, headers=None, query_params=None, post_params=None,
279
- body=None, _preload_content=True, _request_timeout=None):
280
- return self.request("PUT", url,
281
- headers=headers,
282
- query_params=query_params,
283
- post_params=post_params,
284
- _preload_content=_preload_content,
285
- _request_timeout=_request_timeout,
286
- body=body)
287
-
288
- def PATCH(self, url, headers=None, query_params=None, post_params=None,
289
- body=None, _preload_content=True, _request_timeout=None):
290
- return self.request("PATCH", url,
291
- headers=headers,
292
- query_params=query_params,
293
- post_params=post_params,
294
- _preload_content=_preload_content,
295
- _request_timeout=_request_timeout,
296
- body=body)