lockss-pyclient 0.1.0.dev1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. lockss/pyclient/__init__.py +67 -0
  2. lockss/pyclient/config/__init__.py +42 -0
  3. lockss/pyclient/config/api/__init__.py +12 -0
  4. lockss/pyclient/config/api/aus_api.py +2195 -0
  5. lockss/pyclient/config/api/config_api.py +718 -0
  6. lockss/pyclient/config/api/plugins_api.py +128 -0
  7. lockss/pyclient/config/api/status_api.py +120 -0
  8. lockss/pyclient/config/api/tdb_api.py +318 -0
  9. lockss/pyclient/config/api/users_api.py +516 -0
  10. lockss/pyclient/config/api/utils_api.py +128 -0
  11. lockss/pyclient/config/api_client.py +632 -0
  12. lockss/pyclient/config/configuration.py +254 -0
  13. lockss/pyclient/config/models/__init__.py +30 -0
  14. lockss/pyclient/config/models/api_status.py +344 -0
  15. lockss/pyclient/config/models/au_configuration.py +142 -0
  16. lockss/pyclient/config/models/au_status.py +113 -0
  17. lockss/pyclient/config/models/au_ws_result.py +113 -0
  18. lockss/pyclient/config/models/auids_body.py +168 -0
  19. lockss/pyclient/config/models/check_substance_result.py +212 -0
  20. lockss/pyclient/config/models/content_configuration_result.py +200 -0
  21. lockss/pyclient/config/models/file_section_name_body.py +113 -0
  22. lockss/pyclient/config/models/platform_configuration_ws_result.py +113 -0
  23. lockss/pyclient/config/models/plugin_ws_result.py +345 -0
  24. lockss/pyclient/config/models/request_au_control_result.py +171 -0
  25. lockss/pyclient/config/models/tdb_au_ws_result.py +360 -0
  26. lockss/pyclient/config/models/tdb_publisher_ws_result.py +113 -0
  27. lockss/pyclient/config/models/tdb_title_ws_result.py +390 -0
  28. lockss/pyclient/config/rest.py +317 -0
  29. lockss/pyclient/crawler/__init__.py +45 -0
  30. lockss/pyclient/crawler/api/__init__.py +10 -0
  31. lockss/pyclient/crawler/api/crawlers_api.py +215 -0
  32. lockss/pyclient/crawler/api/crawls_api.py +952 -0
  33. lockss/pyclient/crawler/api/jobs_api.py +504 -0
  34. lockss/pyclient/crawler/api/status_api.py +120 -0
  35. lockss/pyclient/crawler/api/ws_api.py +128 -0
  36. lockss/pyclient/crawler/api_client.py +632 -0
  37. lockss/pyclient/crawler/configuration.py +254 -0
  38. lockss/pyclient/crawler/models/__init__.py +35 -0
  39. lockss/pyclient/crawler/models/api_status.py +344 -0
  40. lockss/pyclient/crawler/models/counter.py +142 -0
  41. lockss/pyclient/crawler/models/crawl_desc.py +344 -0
  42. lockss/pyclient/crawler/models/crawl_job.py +280 -0
  43. lockss/pyclient/crawler/models/crawl_pager.py +140 -0
  44. lockss/pyclient/crawler/models/crawl_status.py +780 -0
  45. lockss/pyclient/crawler/models/crawl_ws_result.py +814 -0
  46. lockss/pyclient/crawler/models/crawl_ws_result_pages_with_errors.py +162 -0
  47. lockss/pyclient/crawler/models/crawler_config.py +142 -0
  48. lockss/pyclient/crawler/models/crawler_status.py +279 -0
  49. lockss/pyclient/crawler/models/crawler_statuses.py +112 -0
  50. lockss/pyclient/crawler/models/error_result.py +164 -0
  51. lockss/pyclient/crawler/models/job_pager.py +140 -0
  52. lockss/pyclient/crawler/models/job_status.py +147 -0
  53. lockss/pyclient/crawler/models/mime_counter.py +169 -0
  54. lockss/pyclient/crawler/models/page_info.py +228 -0
  55. lockss/pyclient/crawler/models/url_error.py +148 -0
  56. lockss/pyclient/crawler/models/url_info.py +167 -0
  57. lockss/pyclient/crawler/models/url_pager.py +140 -0
  58. lockss/pyclient/crawler/rest.py +317 -0
  59. lockss/pyclient/md/__init__.py +36 -0
  60. lockss/pyclient/md/api/__init__.py +9 -0
  61. lockss/pyclient/md/api/mdupdates_api.py +508 -0
  62. lockss/pyclient/md/api/metadata_api.py +136 -0
  63. lockss/pyclient/md/api/status_api.py +120 -0
  64. lockss/pyclient/md/api/urls_api.py +224 -0
  65. lockss/pyclient/md/api_client.py +632 -0
  66. lockss/pyclient/md/configuration.py +254 -0
  67. lockss/pyclient/md/models/__init__.py +27 -0
  68. lockss/pyclient/md/models/api_status.py +344 -0
  69. lockss/pyclient/md/models/au.py +169 -0
  70. lockss/pyclient/md/models/au_metadata_page_info.py +140 -0
  71. lockss/pyclient/md/models/error_result.py +164 -0
  72. lockss/pyclient/md/models/item_metadata.py +196 -0
  73. lockss/pyclient/md/models/job.py +280 -0
  74. lockss/pyclient/md/models/job_page_info.py +140 -0
  75. lockss/pyclient/md/models/metadata_update_spec.py +142 -0
  76. lockss/pyclient/md/models/page_info.py +228 -0
  77. lockss/pyclient/md/models/status.py +142 -0
  78. lockss/pyclient/md/models/url_info.py +142 -0
  79. lockss/pyclient/md/rest.py +317 -0
  80. lockss/pyclient/poller/__init__.py +54 -0
  81. lockss/pyclient/poller/api/__init__.py +13 -0
  82. lockss/pyclient/poller/api/export_api.py +156 -0
  83. lockss/pyclient/poller/api/hash_api.py +413 -0
  84. lockss/pyclient/poller/api/import_api.py +157 -0
  85. lockss/pyclient/poller/api/poll_detail_api.py +374 -0
  86. lockss/pyclient/poller/api/poller_polls_api.py +223 -0
  87. lockss/pyclient/poller/api/repo_api.py +223 -0
  88. lockss/pyclient/poller/api/service_api.py +694 -0
  89. lockss/pyclient/poller/api/voter_polls_api.py +223 -0
  90. lockss/pyclient/poller/api_client.py +632 -0
  91. lockss/pyclient/poller/configuration.py +254 -0
  92. lockss/pyclient/poller/models/__init__.py +41 -0
  93. lockss/pyclient/poller/models/api_status.py +344 -0
  94. lockss/pyclient/poller/models/aus_import_body.py +199 -0
  95. lockss/pyclient/poller/models/cached_uri_set_spec.py +169 -0
  96. lockss/pyclient/poller/models/error_result.py +164 -0
  97. lockss/pyclient/poller/models/hasher_ws_params.py +432 -0
  98. lockss/pyclient/poller/models/link_desc.py +141 -0
  99. lockss/pyclient/poller/models/page_desc.py +227 -0
  100. lockss/pyclient/poller/models/peer_data.py +638 -0
  101. lockss/pyclient/poller/models/peer_ws_result.py +113 -0
  102. lockss/pyclient/poller/models/poll_desc.py +285 -0
  103. lockss/pyclient/poller/models/poll_ws_result.py +142 -0
  104. lockss/pyclient/poller/models/poller_detail.py +613 -0
  105. lockss/pyclient/poller/models/poller_pager.py +139 -0
  106. lockss/pyclient/poller/models/poller_summary.py +452 -0
  107. lockss/pyclient/poller/models/repair_data.py +176 -0
  108. lockss/pyclient/poller/models/repair_pager.py +139 -0
  109. lockss/pyclient/poller/models/repair_queue.py +249 -0
  110. lockss/pyclient/poller/models/repository_space_ws_result.py +113 -0
  111. lockss/pyclient/poller/models/repository_ws_result.py +113 -0
  112. lockss/pyclient/poller/models/tally_data.py +471 -0
  113. lockss/pyclient/poller/models/url_pager.py +139 -0
  114. lockss/pyclient/poller/models/vote_ws_result.py +142 -0
  115. lockss/pyclient/poller/models/voter_detail.py +701 -0
  116. lockss/pyclient/poller/models/voter_pager.py +139 -0
  117. lockss/pyclient/poller/models/voter_summary.py +284 -0
  118. lockss/pyclient/poller/rest.py +317 -0
  119. lockss/pyclient/rs/__init__.py +41 -0
  120. lockss/pyclient/rs/api/__init__.py +10 -0
  121. lockss/pyclient/rs/api/artifacts_api.py +988 -0
  122. lockss/pyclient/rs/api/aus_api.py +334 -0
  123. lockss/pyclient/rs/api/repo_api.py +379 -0
  124. lockss/pyclient/rs/api/status_api.py +120 -0
  125. lockss/pyclient/rs/api/wayback_api.py +386 -0
  126. lockss/pyclient/rs/api_client.py +632 -0
  127. lockss/pyclient/rs/configuration.py +247 -0
  128. lockss/pyclient/rs/models/__init__.py +31 -0
  129. lockss/pyclient/rs/models/api_status.py +344 -0
  130. lockss/pyclient/rs/models/archives_body.py +142 -0
  131. lockss/pyclient/rs/models/artifact.py +344 -0
  132. lockss/pyclient/rs/models/artifact_page_info.py +140 -0
  133. lockss/pyclient/rs/models/artifact_properties.py +344 -0
  134. lockss/pyclient/rs/models/artifacts_body.py +170 -0
  135. lockss/pyclient/rs/models/au_size.py +162 -0
  136. lockss/pyclient/rs/models/auid_page_info.py +140 -0
  137. lockss/pyclient/rs/models/error_result.py +164 -0
  138. lockss/pyclient/rs/models/import_status.py +298 -0
  139. lockss/pyclient/rs/models/page_info.py +229 -0
  140. lockss/pyclient/rs/models/repository_info.py +164 -0
  141. lockss/pyclient/rs/models/repository_statistics.py +112 -0
  142. lockss/pyclient/rs/models/storage_info.py +287 -0
  143. lockss/pyclient/rs/models/streaming_response_body.py +84 -0
  144. lockss/pyclient/rs/rest.py +317 -0
  145. lockss_pyclient-0.1.0.dev1.dist-info/LICENSE +27 -0
  146. lockss_pyclient-0.1.0.dev1.dist-info/METADATA +29 -0
  147. lockss_pyclient-0.1.0.dev1.dist-info/RECORD +148 -0
  148. lockss_pyclient-0.1.0.dev1.dist-info/WHEEL +4 -0
@@ -0,0 +1,390 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ LOCKSS Configuration Service REST API
5
+
6
+ REST API of the LOCKSS Configuration Service # noqa: E501
7
+
8
+ OpenAPI spec version: 2.0.0
9
+ Contact: lockss-support@lockss.org
10
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
11
+ """
12
+
13
+ import pprint
14
+ import re # noqa: F401
15
+
16
+ import six
17
+
18
+ class TdbTitleWsResult(object):
19
+ """NOTE: This class is auto generated by the swagger code generator program.
20
+
21
+ Do not edit the class manually.
22
+ """
23
+ """
24
+ Attributes:
25
+ swagger_types (dict): The key is attribute name
26
+ and the value is attribute type.
27
+ attribute_map (dict): The key is attribute name
28
+ and the value is json key in definition.
29
+ """
30
+ swagger_types = {
31
+ 'name': 'str',
32
+ 'tdb_publisher': 'TdbPublisherWsResult',
33
+ 'id': 'str',
34
+ 'proprietaryid': 'str',
35
+ 'proprietaryids': 'list[str]',
36
+ 'publicationtype': 'str',
37
+ 'issn': 'str',
38
+ 'issnl': 'str',
39
+ 'eissn': 'str',
40
+ 'printissn': 'str',
41
+ 'issns': 'list[str]'
42
+ }
43
+
44
+ attribute_map = {
45
+ 'name': 'name',
46
+ 'tdb_publisher': 'tdbPublisher',
47
+ 'id': 'id',
48
+ 'proprietaryid': 'proprietaryid',
49
+ 'proprietaryids': 'proprietaryids',
50
+ 'publicationtype': 'publicationtype',
51
+ 'issn': 'issn',
52
+ 'issnl': 'issnl',
53
+ 'eissn': 'eissn',
54
+ 'printissn': 'printissn',
55
+ 'issns': 'issns'
56
+ }
57
+
58
+ def __init__(self, name=None, tdb_publisher=None, id=None, proprietaryid=None, proprietaryids=None, publicationtype=None, issn=None, issnl=None, eissn=None, printissn=None, issns=None): # noqa: E501
59
+ """TdbTitleWsResult - a model defined in Swagger""" # noqa: E501
60
+ self._name = None
61
+ self._tdb_publisher = None
62
+ self._id = None
63
+ self._proprietaryid = None
64
+ self._proprietaryids = None
65
+ self._publicationtype = None
66
+ self._issn = None
67
+ self._issnl = None
68
+ self._eissn = None
69
+ self._printissn = None
70
+ self._issns = None
71
+ self.discriminator = None
72
+ if name is not None:
73
+ self.name = name
74
+ if tdb_publisher is not None:
75
+ self.tdb_publisher = tdb_publisher
76
+ if id is not None:
77
+ self.id = id
78
+ if proprietaryid is not None:
79
+ self.proprietaryid = proprietaryid
80
+ if proprietaryids is not None:
81
+ self.proprietaryids = proprietaryids
82
+ if publicationtype is not None:
83
+ self.publicationtype = publicationtype
84
+ if issn is not None:
85
+ self.issn = issn
86
+ if issnl is not None:
87
+ self.issnl = issnl
88
+ if eissn is not None:
89
+ self.eissn = eissn
90
+ if printissn is not None:
91
+ self.printissn = printissn
92
+ if issns is not None:
93
+ self.issns = issns
94
+
95
+ @property
96
+ def name(self):
97
+ """Gets the name of this TdbTitleWsResult. # noqa: E501
98
+
99
+ The name of the TDB Title # noqa: E501
100
+
101
+ :return: The name of this TdbTitleWsResult. # noqa: E501
102
+ :rtype: str
103
+ """
104
+ return self._name
105
+
106
+ @name.setter
107
+ def name(self, name):
108
+ """Sets the name of this TdbTitleWsResult.
109
+
110
+ The name of the TDB Title # noqa: E501
111
+
112
+ :param name: The name of this TdbTitleWsResult. # noqa: E501
113
+ :type: str
114
+ """
115
+
116
+ self._name = name
117
+
118
+ @property
119
+ def tdb_publisher(self):
120
+ """Gets the tdb_publisher of this TdbTitleWsResult. # noqa: E501
121
+
122
+
123
+ :return: The tdb_publisher of this TdbTitleWsResult. # noqa: E501
124
+ :rtype: TdbPublisherWsResult
125
+ """
126
+ return self._tdb_publisher
127
+
128
+ @tdb_publisher.setter
129
+ def tdb_publisher(self, tdb_publisher):
130
+ """Sets the tdb_publisher of this TdbTitleWsResult.
131
+
132
+
133
+ :param tdb_publisher: The tdb_publisher of this TdbTitleWsResult. # noqa: E501
134
+ :type: TdbPublisherWsResult
135
+ """
136
+
137
+ self._tdb_publisher = tdb_publisher
138
+
139
+ @property
140
+ def id(self):
141
+ """Gets the id of this TdbTitleWsResult. # noqa: E501
142
+
143
+ The identifier of the TDB Title # noqa: E501
144
+
145
+ :return: The id of this TdbTitleWsResult. # noqa: E501
146
+ :rtype: str
147
+ """
148
+ return self._id
149
+
150
+ @id.setter
151
+ def id(self, id):
152
+ """Sets the id of this TdbTitleWsResult.
153
+
154
+ The identifier of the TDB Title # noqa: E501
155
+
156
+ :param id: The id of this TdbTitleWsResult. # noqa: E501
157
+ :type: str
158
+ """
159
+
160
+ self._id = id
161
+
162
+ @property
163
+ def proprietaryid(self):
164
+ """Gets the proprietaryid of this TdbTitleWsResult. # noqa: E501
165
+
166
+ The proprietary identifier of the TDB Title # noqa: E501
167
+
168
+ :return: The proprietaryid of this TdbTitleWsResult. # noqa: E501
169
+ :rtype: str
170
+ """
171
+ return self._proprietaryid
172
+
173
+ @proprietaryid.setter
174
+ def proprietaryid(self, proprietaryid):
175
+ """Sets the proprietaryid of this TdbTitleWsResult.
176
+
177
+ The proprietary identifier of the TDB Title # noqa: E501
178
+
179
+ :param proprietaryid: The proprietaryid of this TdbTitleWsResult. # noqa: E501
180
+ :type: str
181
+ """
182
+
183
+ self._proprietaryid = proprietaryid
184
+
185
+ @property
186
+ def proprietaryids(self):
187
+ """Gets the proprietaryids of this TdbTitleWsResult. # noqa: E501
188
+
189
+ The proprietary identifiers of the TDB Title # noqa: E501
190
+
191
+ :return: The proprietaryids of this TdbTitleWsResult. # noqa: E501
192
+ :rtype: list[str]
193
+ """
194
+ return self._proprietaryids
195
+
196
+ @proprietaryids.setter
197
+ def proprietaryids(self, proprietaryids):
198
+ """Sets the proprietaryids of this TdbTitleWsResult.
199
+
200
+ The proprietary identifiers of the TDB Title # noqa: E501
201
+
202
+ :param proprietaryids: The proprietaryids of this TdbTitleWsResult. # noqa: E501
203
+ :type: list[str]
204
+ """
205
+
206
+ self._proprietaryids = proprietaryids
207
+
208
+ @property
209
+ def publicationtype(self):
210
+ """Gets the publicationtype of this TdbTitleWsResult. # noqa: E501
211
+
212
+ The publication type of the TDB Title # noqa: E501
213
+
214
+ :return: The publicationtype of this TdbTitleWsResult. # noqa: E501
215
+ :rtype: str
216
+ """
217
+ return self._publicationtype
218
+
219
+ @publicationtype.setter
220
+ def publicationtype(self, publicationtype):
221
+ """Sets the publicationtype of this TdbTitleWsResult.
222
+
223
+ The publication type of the TDB Title # noqa: E501
224
+
225
+ :param publicationtype: The publicationtype of this TdbTitleWsResult. # noqa: E501
226
+ :type: str
227
+ """
228
+
229
+ self._publicationtype = publicationtype
230
+
231
+ @property
232
+ def issn(self):
233
+ """Gets the issn of this TdbTitleWsResult. # noqa: E501
234
+
235
+ The ISSN of the TDB Title # noqa: E501
236
+
237
+ :return: The issn of this TdbTitleWsResult. # noqa: E501
238
+ :rtype: str
239
+ """
240
+ return self._issn
241
+
242
+ @issn.setter
243
+ def issn(self, issn):
244
+ """Sets the issn of this TdbTitleWsResult.
245
+
246
+ The ISSN of the TDB Title # noqa: E501
247
+
248
+ :param issn: The issn of this TdbTitleWsResult. # noqa: E501
249
+ :type: str
250
+ """
251
+
252
+ self._issn = issn
253
+
254
+ @property
255
+ def issnl(self):
256
+ """Gets the issnl of this TdbTitleWsResult. # noqa: E501
257
+
258
+ The ISSNL of the TDB Title # noqa: E501
259
+
260
+ :return: The issnl of this TdbTitleWsResult. # noqa: E501
261
+ :rtype: str
262
+ """
263
+ return self._issnl
264
+
265
+ @issnl.setter
266
+ def issnl(self, issnl):
267
+ """Sets the issnl of this TdbTitleWsResult.
268
+
269
+ The ISSNL of the TDB Title # noqa: E501
270
+
271
+ :param issnl: The issnl of this TdbTitleWsResult. # noqa: E501
272
+ :type: str
273
+ """
274
+
275
+ self._issnl = issnl
276
+
277
+ @property
278
+ def eissn(self):
279
+ """Gets the eissn of this TdbTitleWsResult. # noqa: E501
280
+
281
+ The eISSN of the TDB Title # noqa: E501
282
+
283
+ :return: The eissn of this TdbTitleWsResult. # noqa: E501
284
+ :rtype: str
285
+ """
286
+ return self._eissn
287
+
288
+ @eissn.setter
289
+ def eissn(self, eissn):
290
+ """Sets the eissn of this TdbTitleWsResult.
291
+
292
+ The eISSN of the TDB Title # noqa: E501
293
+
294
+ :param eissn: The eissn of this TdbTitleWsResult. # noqa: E501
295
+ :type: str
296
+ """
297
+
298
+ self._eissn = eissn
299
+
300
+ @property
301
+ def printissn(self):
302
+ """Gets the printissn of this TdbTitleWsResult. # noqa: E501
303
+
304
+ The print ISSN of the TDB Title # noqa: E501
305
+
306
+ :return: The printissn of this TdbTitleWsResult. # noqa: E501
307
+ :rtype: str
308
+ """
309
+ return self._printissn
310
+
311
+ @printissn.setter
312
+ def printissn(self, printissn):
313
+ """Sets the printissn of this TdbTitleWsResult.
314
+
315
+ The print ISSN of the TDB Title # noqa: E501
316
+
317
+ :param printissn: The printissn of this TdbTitleWsResult. # noqa: E501
318
+ :type: str
319
+ """
320
+
321
+ self._printissn = printissn
322
+
323
+ @property
324
+ def issns(self):
325
+ """Gets the issns of this TdbTitleWsResult. # noqa: E501
326
+
327
+ The ISSNs of the TDB Title # noqa: E501
328
+
329
+ :return: The issns of this TdbTitleWsResult. # noqa: E501
330
+ :rtype: list[str]
331
+ """
332
+ return self._issns
333
+
334
+ @issns.setter
335
+ def issns(self, issns):
336
+ """Sets the issns of this TdbTitleWsResult.
337
+
338
+ The ISSNs of the TDB Title # noqa: E501
339
+
340
+ :param issns: The issns of this TdbTitleWsResult. # noqa: E501
341
+ :type: list[str]
342
+ """
343
+
344
+ self._issns = issns
345
+
346
+ def to_dict(self):
347
+ """Returns the model properties as a dict"""
348
+ result = {}
349
+
350
+ for attr, _ in six.iteritems(self.swagger_types):
351
+ value = getattr(self, attr)
352
+ if isinstance(value, list):
353
+ result[attr] = list(map(
354
+ lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
355
+ value
356
+ ))
357
+ elif hasattr(value, "to_dict"):
358
+ result[attr] = value.to_dict()
359
+ elif isinstance(value, dict):
360
+ result[attr] = dict(map(
361
+ lambda item: (item[0], item[1].to_dict())
362
+ if hasattr(item[1], "to_dict") else item,
363
+ value.items()
364
+ ))
365
+ else:
366
+ result[attr] = value
367
+ if issubclass(TdbTitleWsResult, dict):
368
+ for key, value in self.items():
369
+ result[key] = value
370
+
371
+ return result
372
+
373
+ def to_str(self):
374
+ """Returns the string representation of the model"""
375
+ return pprint.pformat(self.to_dict())
376
+
377
+ def __repr__(self):
378
+ """For `print` and `pprint`"""
379
+ return self.to_str()
380
+
381
+ def __eq__(self, other):
382
+ """Returns true if both objects are equal"""
383
+ if not isinstance(other, TdbTitleWsResult):
384
+ return False
385
+
386
+ return self.__dict__ == other.__dict__
387
+
388
+ def __ne__(self, other):
389
+ """Returns true if both objects are not equal"""
390
+ return not self == other
@@ -0,0 +1,317 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ LOCKSS Configuration Service REST API
5
+
6
+ REST API of the LOCKSS Configuration Service # noqa: E501
7
+
8
+ OpenAPI spec version: 2.0.0
9
+ Contact: lockss-support@lockss.org
10
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
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
+
26
+ try:
27
+ import urllib3
28
+ except ImportError:
29
+ raise ImportError('Swagger python client requires urllib3.')
30
+
31
+
32
+ logger = logging.getLogger(__name__)
33
+
34
+
35
+ class RESTResponse(io.IOBase):
36
+
37
+ def __init__(self, resp):
38
+ self.urllib3_response = resp
39
+ self.status = resp.status
40
+ self.reason = resp.reason
41
+ self.data = resp.data
42
+
43
+ def getheaders(self):
44
+ """Returns a dictionary of the response headers."""
45
+ return self.urllib3_response.headers
46
+
47
+ def getheader(self, name, default=None):
48
+ """Returns a given response header."""
49
+ return self.urllib3_response.headers.get(name, default)
50
+
51
+
52
+ class RESTClientObject(object):
53
+
54
+ def __init__(self, configuration, pools_size=4, maxsize=None):
55
+ # urllib3.PoolManager will pass all kw parameters to connectionpool
56
+ # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/poolmanager.py#L75 # noqa: E501
57
+ # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/connectionpool.py#L680 # noqa: E501
58
+ # maxsize is the number of requests to host that are allowed in parallel # noqa: E501
59
+ # Custom SSL certificates and client certificates: http://urllib3.readthedocs.io/en/latest/advanced-usage.html # noqa: E501
60
+
61
+ # cert_reqs
62
+ if configuration.verify_ssl:
63
+ cert_reqs = ssl.CERT_REQUIRED
64
+ else:
65
+ cert_reqs = ssl.CERT_NONE
66
+
67
+ # ca_certs
68
+ if configuration.ssl_ca_cert:
69
+ ca_certs = configuration.ssl_ca_cert
70
+ else:
71
+ # if not set certificate file, use Mozilla's root certificates.
72
+ ca_certs = certifi.where()
73
+
74
+ addition_pool_args = {}
75
+ if configuration.assert_hostname is not None:
76
+ addition_pool_args['assert_hostname'] = configuration.assert_hostname # noqa: E501
77
+
78
+ if maxsize is None:
79
+ if configuration.connection_pool_maxsize is not None:
80
+ maxsize = configuration.connection_pool_maxsize
81
+ else:
82
+ maxsize = 4
83
+
84
+ # https pool manager
85
+ if configuration.proxy:
86
+ self.pool_manager = urllib3.ProxyManager(
87
+ num_pools=pools_size,
88
+ maxsize=maxsize,
89
+ cert_reqs=cert_reqs,
90
+ ca_certs=ca_certs,
91
+ cert_file=configuration.cert_file,
92
+ key_file=configuration.key_file,
93
+ proxy_url=configuration.proxy,
94
+ **addition_pool_args
95
+ )
96
+ else:
97
+ self.pool_manager = urllib3.PoolManager(
98
+ num_pools=pools_size,
99
+ maxsize=maxsize,
100
+ cert_reqs=cert_reqs,
101
+ ca_certs=ca_certs,
102
+ cert_file=configuration.cert_file,
103
+ key_file=configuration.key_file,
104
+ **addition_pool_args
105
+ )
106
+
107
+ def request(self, method, url, query_params=None, headers=None,
108
+ body=None, post_params=None, _preload_content=True,
109
+ _request_timeout=None):
110
+ """Perform requests.
111
+
112
+ :param method: http request method
113
+ :param url: http request url
114
+ :param query_params: query parameters in the url
115
+ :param headers: http request headers
116
+ :param body: request json body, for `application/json`
117
+ :param post_params: request post parameters,
118
+ `application/x-www-form-urlencoded`
119
+ and `multipart/form-data`
120
+ :param _preload_content: if False, the urllib3.HTTPResponse object will
121
+ be returned without reading/decoding response
122
+ data. Default is True.
123
+ :param _request_timeout: timeout setting for this request. If one
124
+ number provided, it will be total request
125
+ timeout. It can also be a pair (tuple) of
126
+ (connection, read) timeouts.
127
+ """
128
+ method = method.upper()
129
+ assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT',
130
+ 'PATCH', 'OPTIONS']
131
+
132
+ if post_params and body:
133
+ raise ValueError(
134
+ "body parameter cannot be used with post_params parameter."
135
+ )
136
+
137
+ post_params = post_params or {}
138
+ headers = headers or {}
139
+
140
+ timeout = None
141
+ if _request_timeout:
142
+ if isinstance(_request_timeout, (int, ) if six.PY3 else (int, long)): # noqa: E501,F821
143
+ timeout = urllib3.Timeout(total=_request_timeout)
144
+ elif (isinstance(_request_timeout, tuple) and
145
+ len(_request_timeout) == 2):
146
+ timeout = urllib3.Timeout(
147
+ connect=_request_timeout[0], read=_request_timeout[1])
148
+
149
+ if 'Content-Type' not in headers:
150
+ headers['Content-Type'] = 'application/json'
151
+
152
+ try:
153
+ # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE`
154
+ if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']:
155
+ if query_params:
156
+ url += '?' + urlencode(query_params)
157
+ if re.search('json', headers['Content-Type'], re.IGNORECASE):
158
+ request_body = '{}'
159
+ if body is not None:
160
+ request_body = json.dumps(body)
161
+ r = self.pool_manager.request(
162
+ method, url,
163
+ body=request_body,
164
+ preload_content=_preload_content,
165
+ timeout=timeout,
166
+ headers=headers)
167
+ elif headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501
168
+ r = self.pool_manager.request(
169
+ method, url,
170
+ fields=post_params,
171
+ encode_multipart=False,
172
+ preload_content=_preload_content,
173
+ timeout=timeout,
174
+ headers=headers)
175
+ elif headers['Content-Type'] == 'multipart/form-data':
176
+ # must del headers['Content-Type'], or the correct
177
+ # Content-Type which generated by urllib3 will be
178
+ # overwritten.
179
+ del headers['Content-Type']
180
+ r = self.pool_manager.request(
181
+ method, url,
182
+ fields=post_params,
183
+ encode_multipart=True,
184
+ preload_content=_preload_content,
185
+ timeout=timeout,
186
+ headers=headers)
187
+ # Pass a `string` parameter directly in the body to support
188
+ # other content types than Json when `body` argument is
189
+ # provided in serialized form
190
+ elif isinstance(body, str):
191
+ request_body = body
192
+ r = self.pool_manager.request(
193
+ method, url,
194
+ body=request_body,
195
+ preload_content=_preload_content,
196
+ timeout=timeout,
197
+ headers=headers)
198
+ else:
199
+ # Cannot generate the request from given parameters
200
+ msg = """Cannot prepare a request message for provided
201
+ arguments. Please check that your arguments match
202
+ declared content type."""
203
+ raise ApiException(status=0, reason=msg)
204
+ # For `GET`, `HEAD`
205
+ else:
206
+ r = self.pool_manager.request(method, url,
207
+ fields=query_params,
208
+ preload_content=_preload_content,
209
+ timeout=timeout,
210
+ headers=headers)
211
+ except urllib3.exceptions.SSLError as e:
212
+ msg = "{0}\n{1}".format(type(e).__name__, str(e))
213
+ raise ApiException(status=0, reason=msg)
214
+
215
+ if _preload_content:
216
+ r = RESTResponse(r)
217
+
218
+ # log response body
219
+ logger.debug("response body: %s", r.data)
220
+
221
+ if not 200 <= r.status <= 299:
222
+ raise ApiException(http_resp=r)
223
+
224
+ return r
225
+
226
+ def GET(self, url, headers=None, query_params=None, _preload_content=True,
227
+ _request_timeout=None):
228
+ return self.request("GET", url,
229
+ headers=headers,
230
+ _preload_content=_preload_content,
231
+ _request_timeout=_request_timeout,
232
+ query_params=query_params)
233
+
234
+ def HEAD(self, url, headers=None, query_params=None, _preload_content=True,
235
+ _request_timeout=None):
236
+ return self.request("HEAD", url,
237
+ headers=headers,
238
+ _preload_content=_preload_content,
239
+ _request_timeout=_request_timeout,
240
+ query_params=query_params)
241
+
242
+ def OPTIONS(self, url, headers=None, query_params=None, post_params=None,
243
+ body=None, _preload_content=True, _request_timeout=None):
244
+ return self.request("OPTIONS", url,
245
+ headers=headers,
246
+ query_params=query_params,
247
+ post_params=post_params,
248
+ _preload_content=_preload_content,
249
+ _request_timeout=_request_timeout,
250
+ body=body)
251
+
252
+ def DELETE(self, url, headers=None, query_params=None, body=None,
253
+ _preload_content=True, _request_timeout=None):
254
+ return self.request("DELETE", url,
255
+ headers=headers,
256
+ query_params=query_params,
257
+ _preload_content=_preload_content,
258
+ _request_timeout=_request_timeout,
259
+ body=body)
260
+
261
+ def POST(self, url, headers=None, query_params=None, post_params=None,
262
+ body=None, _preload_content=True, _request_timeout=None):
263
+ return self.request("POST", url,
264
+ headers=headers,
265
+ query_params=query_params,
266
+ post_params=post_params,
267
+ _preload_content=_preload_content,
268
+ _request_timeout=_request_timeout,
269
+ body=body)
270
+
271
+ def PUT(self, url, headers=None, query_params=None, post_params=None,
272
+ body=None, _preload_content=True, _request_timeout=None):
273
+ return self.request("PUT", url,
274
+ headers=headers,
275
+ query_params=query_params,
276
+ post_params=post_params,
277
+ _preload_content=_preload_content,
278
+ _request_timeout=_request_timeout,
279
+ body=body)
280
+
281
+ def PATCH(self, url, headers=None, query_params=None, post_params=None,
282
+ body=None, _preload_content=True, _request_timeout=None):
283
+ return self.request("PATCH", url,
284
+ headers=headers,
285
+ query_params=query_params,
286
+ post_params=post_params,
287
+ _preload_content=_preload_content,
288
+ _request_timeout=_request_timeout,
289
+ body=body)
290
+
291
+
292
+ class ApiException(Exception):
293
+
294
+ def __init__(self, status=None, reason=None, http_resp=None):
295
+ if http_resp:
296
+ self.status = http_resp.status
297
+ self.reason = http_resp.reason
298
+ self.body = http_resp.data
299
+ self.headers = http_resp.getheaders()
300
+ else:
301
+ self.status = status
302
+ self.reason = reason
303
+ self.body = None
304
+ self.headers = None
305
+
306
+ def __str__(self):
307
+ """Custom error messages for exception"""
308
+ error_message = "({0})\n"\
309
+ "Reason: {1}\n".format(self.status, self.reason)
310
+ if self.headers:
311
+ error_message += "HTTP response headers: {0}\n".format(
312
+ self.headers)
313
+
314
+ if self.body:
315
+ error_message += "HTTP response body: {0}\n".format(self.body)
316
+
317
+ return error_message