catocli 2.0.3__py3-none-any.whl → 2.0.5__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.

Potentially problematic release.


This version of catocli might be problematic. Click here for more details.

Files changed (291) hide show
  1. build/lib/catocli/Utils/clidriver.py +268 -0
  2. build/lib/catocli/Utils/profile_manager.py +188 -0
  3. build/lib/catocli/Utils/version_checker.py +192 -0
  4. build/lib/catocli/__init__.py +2 -0
  5. build/lib/catocli/__main__.py +12 -0
  6. build/lib/catocli/parsers/configure/__init__.py +115 -0
  7. build/lib/catocli/parsers/configure/configure.py +307 -0
  8. build/lib/catocli/parsers/custom/__init__.py +57 -0
  9. build/lib/catocli/parsers/custom/customLib.py +561 -0
  10. build/lib/catocli/parsers/custom/export_rules/__init__.py +42 -0
  11. build/lib/catocli/parsers/custom/export_rules/export_rules.py +234 -0
  12. build/lib/catocli/parsers/custom/export_sites/__init__.py +21 -0
  13. build/lib/catocli/parsers/custom/export_sites/export_sites.py +372 -0
  14. build/lib/catocli/parsers/custom/import_rules_to_tf/__init__.py +58 -0
  15. build/lib/catocli/parsers/custom/import_rules_to_tf/import_rules_to_tf.py +451 -0
  16. build/lib/catocli/parsers/custom/import_sites_to_tf/__init__.py +45 -0
  17. build/lib/catocli/parsers/custom/import_sites_to_tf/import_sites_to_tf.py +891 -0
  18. build/lib/catocli/parsers/mutation_accountManagement/__init__.py +48 -0
  19. build/lib/catocli/parsers/mutation_admin/__init__.py +48 -0
  20. build/lib/catocli/parsers/mutation_container/__init__.py +138 -0
  21. build/lib/catocli/parsers/mutation_hardware/__init__.py +22 -0
  22. build/lib/catocli/parsers/mutation_policy/__init__.py +1305 -0
  23. build/lib/catocli/parsers/mutation_sandbox/__init__.py +35 -0
  24. build/lib/catocli/parsers/mutation_site/__init__.py +373 -0
  25. build/lib/catocli/parsers/mutation_sites/__init__.py +373 -0
  26. build/lib/catocli/parsers/mutation_xdr/__init__.py +48 -0
  27. build/lib/catocli/parsers/parserApiClient.py +513 -0
  28. build/lib/catocli/parsers/query_accountBySubdomain/__init__.py +16 -0
  29. build/lib/catocli/parsers/query_accountManagement/__init__.py +16 -0
  30. build/lib/catocli/parsers/query_accountMetrics/__init__.py +16 -0
  31. build/lib/catocli/parsers/query_accountRoles/__init__.py +16 -0
  32. build/lib/catocli/parsers/query_accountSnapshot/__init__.py +16 -0
  33. build/lib/catocli/parsers/query_admin/__init__.py +16 -0
  34. build/lib/catocli/parsers/query_admins/__init__.py +16 -0
  35. build/lib/catocli/parsers/query_appStats/__init__.py +16 -0
  36. build/lib/catocli/parsers/query_appStatsTimeSeries/__init__.py +16 -0
  37. build/lib/catocli/parsers/query_auditFeed/__init__.py +16 -0
  38. build/lib/catocli/parsers/query_catalogs/__init__.py +16 -0
  39. build/lib/catocli/parsers/query_container/__init__.py +16 -0
  40. build/lib/catocli/parsers/query_devices/__init__.py +16 -0
  41. build/lib/catocli/parsers/query_entityLookup/__init__.py +16 -0
  42. build/lib/catocli/parsers/query_events/__init__.py +16 -0
  43. build/lib/catocli/parsers/query_eventsFeed/__init__.py +16 -0
  44. build/lib/catocli/parsers/query_eventsTimeSeries/__init__.py +16 -0
  45. build/lib/catocli/parsers/query_hardware/__init__.py +16 -0
  46. build/lib/catocli/parsers/query_hardwareManagement/__init__.py +16 -0
  47. build/lib/catocli/parsers/query_licensing/__init__.py +16 -0
  48. build/lib/catocli/parsers/query_policy/__init__.py +161 -0
  49. build/lib/catocli/parsers/query_sandbox/__init__.py +16 -0
  50. build/lib/catocli/parsers/query_site/__init__.py +100 -0
  51. build/lib/catocli/parsers/query_siteLocation/__init__.py +13 -0
  52. build/lib/catocli/parsers/query_subDomains/__init__.py +16 -0
  53. build/lib/catocli/parsers/query_xdr/__init__.py +35 -0
  54. build/lib/catocli/parsers/raw/__init__.py +12 -0
  55. build/lib/graphql_client/__init__.py +11 -0
  56. build/lib/graphql_client/api/__init__.py +3 -0
  57. build/lib/graphql_client/api/call_api.py +84 -0
  58. build/lib/graphql_client/api_client.py +192 -0
  59. build/lib/graphql_client/api_client_types.py +409 -0
  60. build/lib/graphql_client/configuration.py +232 -0
  61. build/lib/graphql_client/models/__init__.py +13 -0
  62. build/lib/graphql_client/models/no_schema.py +71 -0
  63. build/lib/schema/catolib.py +1141 -0
  64. build/lib/schema/importSchema.py +60 -0
  65. build/lib/schema/remove_policyid.py +89 -0
  66. build/lib/schema/remove_policyid_mutations.py +89 -0
  67. build/lib/scripts/catolib.py +62 -0
  68. build/lib/scripts/export_if_rules_to_json.py +188 -0
  69. build/lib/scripts/export_wf_rules_to_json.py +111 -0
  70. build/lib/scripts/import_wf_rules_to_tfstate.py +331 -0
  71. build/lib/vendor/certifi/__init__.py +4 -0
  72. build/lib/vendor/certifi/__main__.py +12 -0
  73. build/lib/vendor/certifi/core.py +114 -0
  74. build/lib/vendor/certifi/py.typed +0 -0
  75. build/lib/vendor/six.py +998 -0
  76. build/lib/vendor/urllib3/__init__.py +211 -0
  77. build/lib/vendor/urllib3/_base_connection.py +172 -0
  78. build/lib/vendor/urllib3/_collections.py +483 -0
  79. build/lib/vendor/urllib3/_request_methods.py +278 -0
  80. build/lib/vendor/urllib3/_version.py +16 -0
  81. build/lib/vendor/urllib3/connection.py +1033 -0
  82. build/lib/vendor/urllib3/connectionpool.py +1182 -0
  83. build/lib/vendor/urllib3/contrib/__init__.py +0 -0
  84. build/lib/vendor/urllib3/contrib/emscripten/__init__.py +18 -0
  85. build/lib/vendor/urllib3/contrib/emscripten/connection.py +254 -0
  86. build/lib/vendor/urllib3/contrib/emscripten/fetch.py +418 -0
  87. build/lib/vendor/urllib3/contrib/emscripten/request.py +22 -0
  88. build/lib/vendor/urllib3/contrib/emscripten/response.py +285 -0
  89. build/lib/vendor/urllib3/contrib/pyopenssl.py +552 -0
  90. build/lib/vendor/urllib3/contrib/socks.py +228 -0
  91. build/lib/vendor/urllib3/exceptions.py +321 -0
  92. build/lib/vendor/urllib3/fields.py +341 -0
  93. build/lib/vendor/urllib3/filepost.py +89 -0
  94. build/lib/vendor/urllib3/http2/__init__.py +53 -0
  95. build/lib/vendor/urllib3/http2/connection.py +356 -0
  96. build/lib/vendor/urllib3/http2/probe.py +87 -0
  97. build/lib/vendor/urllib3/poolmanager.py +637 -0
  98. build/lib/vendor/urllib3/py.typed +2 -0
  99. build/lib/vendor/urllib3/response.py +1265 -0
  100. build/lib/vendor/urllib3/util/__init__.py +42 -0
  101. build/lib/vendor/urllib3/util/connection.py +137 -0
  102. build/lib/vendor/urllib3/util/proxy.py +43 -0
  103. build/lib/vendor/urllib3/util/request.py +256 -0
  104. build/lib/vendor/urllib3/util/response.py +101 -0
  105. build/lib/vendor/urllib3/util/retry.py +533 -0
  106. build/lib/vendor/urllib3/util/ssl_.py +513 -0
  107. build/lib/vendor/urllib3/util/ssl_match_hostname.py +159 -0
  108. build/lib/vendor/urllib3/util/ssltransport.py +276 -0
  109. build/lib/vendor/urllib3/util/timeout.py +275 -0
  110. build/lib/vendor/urllib3/util/url.py +471 -0
  111. build/lib/vendor/urllib3/util/util.py +42 -0
  112. build/lib/vendor/urllib3/util/wait.py +124 -0
  113. catocli/Utils/clidriver.py +1 -4
  114. catocli/__init__.py +1 -1
  115. catocli/parsers/custom/export_rules/__init__.py +2 -0
  116. catocli/parsers/custom/export_rules/export_rules.py +29 -5
  117. catocli/parsers/custom/export_sites/__init__.py +1 -0
  118. catocli/parsers/custom/export_sites/export_sites.py +10 -3
  119. catocli/parsers/mutation_container/__init__.py +116 -0
  120. catocli/parsers/mutation_container_fqdn/README.md +7 -0
  121. catocli/parsers/mutation_container_fqdn_addValues/README.md +17 -0
  122. catocli/parsers/mutation_container_fqdn_createFromFile/README.md +17 -0
  123. catocli/parsers/mutation_container_fqdn_removeValues/README.md +17 -0
  124. catocli/parsers/mutation_container_fqdn_updateFromFile/README.md +17 -0
  125. catocli/parsers/mutation_container_ipAddressRange/README.md +7 -0
  126. catocli/parsers/mutation_container_ipAddressRange_addValues/README.md +17 -0
  127. catocli/parsers/mutation_container_ipAddressRange_createFromFile/README.md +17 -0
  128. catocli/parsers/mutation_container_ipAddressRange_removeValues/README.md +17 -0
  129. catocli/parsers/mutation_container_ipAddressRange_updateFromFile/README.md +17 -0
  130. catocli/parsers/mutation_policy_internetFirewall_addRule/README.md +1 -1
  131. catocli/parsers/mutation_policy_internetFirewall_updateRule/README.md +1 -1
  132. catocli/parsers/mutation_policy_wanFirewall_addRule/README.md +1 -1
  133. catocli/parsers/mutation_policy_wanFirewall_updateRule/README.md +1 -1
  134. catocli/parsers/parserApiClient.py +183 -7
  135. catocli/parsers/query_policy/README.md +0 -17
  136. catocli/parsers/query_policy/__init__.py +153 -8
  137. catocli/parsers/query_policy_appTenantRestriction/README.md +7 -0
  138. catocli/parsers/query_policy_appTenantRestriction_policy/README.md +17 -0
  139. catocli/parsers/query_policy_dynamicIpAllocation/README.md +7 -0
  140. catocli/parsers/query_policy_dynamicIpAllocation_policy/README.md +17 -0
  141. catocli/parsers/query_policy_internetFirewall/README.md +7 -0
  142. catocli/parsers/query_policy_internetFirewall_policy/README.md +17 -0
  143. catocli/parsers/query_policy_remotePortFwd/README.md +7 -0
  144. catocli/parsers/query_policy_remotePortFwd_policy/README.md +17 -0
  145. catocli/parsers/query_policy_socketLan/README.md +7 -0
  146. catocli/parsers/query_policy_socketLan_policy/README.md +17 -0
  147. catocli/parsers/query_policy_terminalServer/README.md +7 -0
  148. catocli/parsers/query_policy_terminalServer_policy/README.md +17 -0
  149. catocli/parsers/query_policy_wanFirewall/README.md +7 -0
  150. catocli/parsers/query_policy_wanFirewall_policy/README.md +17 -0
  151. catocli/parsers/query_policy_wanNetwork/README.md +7 -0
  152. catocli/parsers/query_policy_wanNetwork_policy/README.md +17 -0
  153. catocli/parsers/query_site/README.md +0 -16
  154. catocli/parsers/query_site/__init__.py +92 -8
  155. catocli/parsers/query_site_availableVersionList/README.md +17 -0
  156. catocli/parsers/query_site_bgpPeer/README.md +17 -0
  157. catocli/parsers/query_site_bgpPeerList/README.md +17 -0
  158. catocli/parsers/query_site_cloudInterconnectConnectionConnectivity/README.md +17 -0
  159. catocli/parsers/query_site_cloudInterconnectPhysicalConnection/README.md +17 -0
  160. catocli/parsers/query_site_cloudInterconnectPhysicalConnectionId/README.md +17 -0
  161. catocli/parsers/query_site_siteBgpStatus/README.md +17 -0
  162. {catocli-2.0.3.dist-info → catocli-2.0.5.dist-info}/METADATA +1 -1
  163. {catocli-2.0.3.dist-info → catocli-2.0.5.dist-info}/RECORD +291 -121
  164. {catocli-2.0.3.dist-info → catocli-2.0.5.dist-info}/top_level.txt +1 -0
  165. graphql_client/api/call_api.py +4 -3
  166. models/mutation.container.fqdn.addValues.json +866 -0
  167. models/mutation.container.fqdn.createFromFile.json +819 -0
  168. models/mutation.container.fqdn.removeValues.json +866 -0
  169. models/mutation.container.fqdn.updateFromFile.json +1045 -0
  170. models/mutation.container.ipAddressRange.addValues.json +1020 -0
  171. models/mutation.container.ipAddressRange.createFromFile.json +819 -0
  172. models/mutation.container.ipAddressRange.removeValues.json +1020 -0
  173. models/mutation.container.ipAddressRange.updateFromFile.json +1045 -0
  174. models/mutation.policy.appTenantRestriction.addRule.json +8 -8
  175. models/mutation.policy.appTenantRestriction.addSection.json +1 -1
  176. models/mutation.policy.appTenantRestriction.createPolicyRevision.json +2 -2
  177. models/mutation.policy.appTenantRestriction.discardPolicyRevision.json +2 -2
  178. models/mutation.policy.appTenantRestriction.moveRule.json +2 -2
  179. models/mutation.policy.appTenantRestriction.moveSection.json +1 -1
  180. models/mutation.policy.appTenantRestriction.publishPolicyRevision.json +2 -2
  181. models/mutation.policy.appTenantRestriction.removeRule.json +2 -2
  182. models/mutation.policy.appTenantRestriction.removeSection.json +1 -1
  183. models/mutation.policy.appTenantRestriction.updatePolicy.json +2 -2
  184. models/mutation.policy.appTenantRestriction.updateRule.json +8 -8
  185. models/mutation.policy.appTenantRestriction.updateSection.json +1 -1
  186. models/mutation.policy.dynamicIpAllocation.addRule.json +1 -1
  187. models/mutation.policy.dynamicIpAllocation.addSection.json +1 -1
  188. models/mutation.policy.dynamicIpAllocation.createPolicyRevision.json +1 -1
  189. models/mutation.policy.dynamicIpAllocation.discardPolicyRevision.json +1 -1
  190. models/mutation.policy.dynamicIpAllocation.moveRule.json +1 -1
  191. models/mutation.policy.dynamicIpAllocation.moveSection.json +1 -1
  192. models/mutation.policy.dynamicIpAllocation.publishPolicyRevision.json +1 -1
  193. models/mutation.policy.dynamicIpAllocation.removeRule.json +1 -1
  194. models/mutation.policy.dynamicIpAllocation.removeSection.json +1 -1
  195. models/mutation.policy.dynamicIpAllocation.updatePolicy.json +1 -1
  196. models/mutation.policy.dynamicIpAllocation.updateRule.json +1 -1
  197. models/mutation.policy.dynamicIpAllocation.updateSection.json +1 -1
  198. models/mutation.policy.internetFirewall.addRule.json +502 -55
  199. models/mutation.policy.internetFirewall.addSection.json +1 -1
  200. models/mutation.policy.internetFirewall.createPolicyRevision.json +127 -10
  201. models/mutation.policy.internetFirewall.discardPolicyRevision.json +127 -10
  202. models/mutation.policy.internetFirewall.moveRule.json +127 -10
  203. models/mutation.policy.internetFirewall.moveSection.json +1 -1
  204. models/mutation.policy.internetFirewall.publishPolicyRevision.json +127 -10
  205. models/mutation.policy.internetFirewall.removeRule.json +127 -10
  206. models/mutation.policy.internetFirewall.removeSection.json +1 -1
  207. models/mutation.policy.internetFirewall.updatePolicy.json +127 -10
  208. models/mutation.policy.internetFirewall.updateRule.json +493 -55
  209. models/mutation.policy.internetFirewall.updateSection.json +1 -1
  210. models/mutation.policy.remotePortFwd.addRule.json +5 -5
  211. models/mutation.policy.remotePortFwd.addSection.json +1 -1
  212. models/mutation.policy.remotePortFwd.createPolicyRevision.json +2 -2
  213. models/mutation.policy.remotePortFwd.discardPolicyRevision.json +2 -2
  214. models/mutation.policy.remotePortFwd.moveRule.json +2 -2
  215. models/mutation.policy.remotePortFwd.moveSection.json +1 -1
  216. models/mutation.policy.remotePortFwd.publishPolicyRevision.json +2 -2
  217. models/mutation.policy.remotePortFwd.removeRule.json +2 -2
  218. models/mutation.policy.remotePortFwd.removeSection.json +1 -1
  219. models/mutation.policy.remotePortFwd.updatePolicy.json +2 -2
  220. models/mutation.policy.remotePortFwd.updateRule.json +5 -5
  221. models/mutation.policy.remotePortFwd.updateSection.json +1 -1
  222. models/mutation.policy.socketLan.addRule.json +16 -16
  223. models/mutation.policy.socketLan.addSection.json +1 -1
  224. models/mutation.policy.socketLan.createPolicyRevision.json +4 -4
  225. models/mutation.policy.socketLan.discardPolicyRevision.json +4 -4
  226. models/mutation.policy.socketLan.moveRule.json +4 -4
  227. models/mutation.policy.socketLan.moveSection.json +1 -1
  228. models/mutation.policy.socketLan.publishPolicyRevision.json +4 -4
  229. models/mutation.policy.socketLan.removeRule.json +4 -4
  230. models/mutation.policy.socketLan.removeSection.json +1 -1
  231. models/mutation.policy.socketLan.updatePolicy.json +4 -4
  232. models/mutation.policy.socketLan.updateRule.json +16 -16
  233. models/mutation.policy.socketLan.updateSection.json +1 -1
  234. models/mutation.policy.terminalServer.addRule.json +1 -1
  235. models/mutation.policy.terminalServer.addSection.json +1 -1
  236. models/mutation.policy.terminalServer.createPolicyRevision.json +1 -1
  237. models/mutation.policy.terminalServer.discardPolicyRevision.json +1 -1
  238. models/mutation.policy.terminalServer.moveRule.json +1 -1
  239. models/mutation.policy.terminalServer.moveSection.json +1 -1
  240. models/mutation.policy.terminalServer.publishPolicyRevision.json +1 -1
  241. models/mutation.policy.terminalServer.removeRule.json +1 -1
  242. models/mutation.policy.terminalServer.removeSection.json +1 -1
  243. models/mutation.policy.terminalServer.updatePolicy.json +1 -1
  244. models/mutation.policy.terminalServer.updateRule.json +1 -1
  245. models/mutation.policy.terminalServer.updateSection.json +1 -1
  246. models/mutation.policy.wanFirewall.addRule.json +500 -53
  247. models/mutation.policy.wanFirewall.addSection.json +1 -1
  248. models/mutation.policy.wanFirewall.createPolicyRevision.json +128 -11
  249. models/mutation.policy.wanFirewall.discardPolicyRevision.json +128 -11
  250. models/mutation.policy.wanFirewall.moveRule.json +128 -11
  251. models/mutation.policy.wanFirewall.moveSection.json +1 -1
  252. models/mutation.policy.wanFirewall.publishPolicyRevision.json +128 -11
  253. models/mutation.policy.wanFirewall.removeRule.json +128 -11
  254. models/mutation.policy.wanFirewall.removeSection.json +1 -1
  255. models/mutation.policy.wanFirewall.updatePolicy.json +128 -11
  256. models/mutation.policy.wanFirewall.updateRule.json +491 -53
  257. models/mutation.policy.wanFirewall.updateSection.json +1 -1
  258. models/mutation.policy.wanNetwork.addRule.json +13 -13
  259. models/mutation.policy.wanNetwork.addSection.json +1 -1
  260. models/mutation.policy.wanNetwork.createPolicyRevision.json +1 -1
  261. models/mutation.policy.wanNetwork.discardPolicyRevision.json +1 -1
  262. models/mutation.policy.wanNetwork.moveRule.json +1 -1
  263. models/mutation.policy.wanNetwork.moveSection.json +1 -1
  264. models/mutation.policy.wanNetwork.publishPolicyRevision.json +1 -1
  265. models/mutation.policy.wanNetwork.removeRule.json +1 -1
  266. models/mutation.policy.wanNetwork.removeSection.json +1 -1
  267. models/mutation.policy.wanNetwork.updatePolicy.json +1 -1
  268. models/mutation.policy.wanNetwork.updateRule.json +13 -13
  269. models/mutation.policy.wanNetwork.updateSection.json +1 -1
  270. models/query.policy.appTenantRestriction.policy.json +3086 -0
  271. models/query.policy.dynamicIpAllocation.policy.json +1934 -0
  272. models/query.policy.internetFirewall.policy.json +7833 -0
  273. models/query.policy.json +233 -0
  274. models/query.policy.remotePortFwd.policy.json +2387 -0
  275. models/query.policy.socketLan.policy.json +7140 -0
  276. models/query.policy.terminalServer.policy.json +1632 -0
  277. models/query.policy.wanFirewall.policy.json +9212 -0
  278. models/query.policy.wanNetwork.policy.json +8010 -0
  279. models/query.site.availableVersionList.json +365 -0
  280. models/query.site.bgpPeer.json +1917 -0
  281. models/query.site.bgpPeerList.json +2076 -0
  282. models/query.site.cloudInterconnectConnectionConnectivity.json +298 -0
  283. models/query.site.cloudInterconnectPhysicalConnection.json +728 -0
  284. models/query.site.cloudInterconnectPhysicalConnectionId.json +660 -0
  285. models/query.site.siteBgpStatus.json +869 -0
  286. schema/catolib.py +13 -6
  287. schema/remove_policyid.py +89 -0
  288. schema/remove_policyid_mutations.py +89 -0
  289. {catocli-2.0.3.dist-info → catocli-2.0.5.dist-info}/LICENSE +0 -0
  290. {catocli-2.0.3.dist-info → catocli-2.0.5.dist-info}/WHEEL +0 -0
  291. {catocli-2.0.3.dist-info → catocli-2.0.5.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,211 @@
1
+ """
2
+ Python HTTP library with thread-safe connection pooling, file post support, user friendly, and more
3
+ """
4
+
5
+ from __future__ import annotations
6
+
7
+ # Set default logging handler to avoid "No handler found" warnings.
8
+ import logging
9
+ import sys
10
+ import typing
11
+ import warnings
12
+ from logging import NullHandler
13
+
14
+ from . import exceptions
15
+ from ._base_connection import _TYPE_BODY
16
+ from ._collections import HTTPHeaderDict
17
+ from ._version import __version__
18
+ from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool, connection_from_url
19
+ from .filepost import _TYPE_FIELDS, encode_multipart_formdata
20
+ from .poolmanager import PoolManager, ProxyManager, proxy_from_url
21
+ from .response import BaseHTTPResponse, HTTPResponse
22
+ from .util.request import make_headers
23
+ from .util.retry import Retry
24
+ from .util.timeout import Timeout
25
+
26
+ # Ensure that Python is compiled with OpenSSL 1.1.1+
27
+ # If the 'ssl' module isn't available at all that's
28
+ # fine, we only care if the module is available.
29
+ try:
30
+ import ssl
31
+ except ImportError:
32
+ pass
33
+ else:
34
+ if not ssl.OPENSSL_VERSION.startswith("OpenSSL "): # Defensive:
35
+ warnings.warn(
36
+ "urllib3 v2 only supports OpenSSL 1.1.1+, currently "
37
+ f"the 'ssl' module is compiled with {ssl.OPENSSL_VERSION!r}. "
38
+ "See: https://github.com/urllib3/urllib3/issues/3020",
39
+ exceptions.NotOpenSSLWarning,
40
+ )
41
+ elif ssl.OPENSSL_VERSION_INFO < (1, 1, 1): # Defensive:
42
+ raise ImportError(
43
+ "urllib3 v2 only supports OpenSSL 1.1.1+, currently "
44
+ f"the 'ssl' module is compiled with {ssl.OPENSSL_VERSION!r}. "
45
+ "See: https://github.com/urllib3/urllib3/issues/2168"
46
+ )
47
+
48
+ __author__ = "Andrey Petrov (andrey.petrov@shazow.net)"
49
+ __license__ = "MIT"
50
+ __version__ = __version__
51
+
52
+ __all__ = (
53
+ "HTTPConnectionPool",
54
+ "HTTPHeaderDict",
55
+ "HTTPSConnectionPool",
56
+ "PoolManager",
57
+ "ProxyManager",
58
+ "HTTPResponse",
59
+ "Retry",
60
+ "Timeout",
61
+ "add_stderr_logger",
62
+ "connection_from_url",
63
+ "disable_warnings",
64
+ "encode_multipart_formdata",
65
+ "make_headers",
66
+ "proxy_from_url",
67
+ "request",
68
+ "BaseHTTPResponse",
69
+ )
70
+
71
+ logging.getLogger(__name__).addHandler(NullHandler())
72
+
73
+
74
+ def add_stderr_logger(
75
+ level: int = logging.DEBUG,
76
+ ) -> logging.StreamHandler[typing.TextIO]:
77
+ """
78
+ Helper for quickly adding a StreamHandler to the logger. Useful for
79
+ debugging.
80
+
81
+ Returns the handler after adding it.
82
+ """
83
+ # This method needs to be in this __init__.py to get the __name__ correct
84
+ # even if urllib3 is vendored within another package.
85
+ logger = logging.getLogger(__name__)
86
+ handler = logging.StreamHandler()
87
+ handler.setFormatter(logging.Formatter("%(asctime)s %(levelname)s %(message)s"))
88
+ logger.addHandler(handler)
89
+ logger.setLevel(level)
90
+ logger.debug("Added a stderr logging handler to logger: %s", __name__)
91
+ return handler
92
+
93
+
94
+ # ... Clean up.
95
+ del NullHandler
96
+
97
+
98
+ # All warning filters *must* be appended unless you're really certain that they
99
+ # shouldn't be: otherwise, it's very hard for users to use most Python
100
+ # mechanisms to silence them.
101
+ # SecurityWarning's always go off by default.
102
+ warnings.simplefilter("always", exceptions.SecurityWarning, append=True)
103
+ # InsecurePlatformWarning's don't vary between requests, so we keep it default.
104
+ warnings.simplefilter("default", exceptions.InsecurePlatformWarning, append=True)
105
+
106
+
107
+ def disable_warnings(category: type[Warning] = exceptions.HTTPWarning) -> None:
108
+ """
109
+ Helper for quickly disabling all urllib3 warnings.
110
+ """
111
+ warnings.simplefilter("ignore", category)
112
+
113
+
114
+ _DEFAULT_POOL = PoolManager()
115
+
116
+
117
+ def request(
118
+ method: str,
119
+ url: str,
120
+ *,
121
+ body: _TYPE_BODY | None = None,
122
+ fields: _TYPE_FIELDS | None = None,
123
+ headers: typing.Mapping[str, str] | None = None,
124
+ preload_content: bool | None = True,
125
+ decode_content: bool | None = True,
126
+ redirect: bool | None = True,
127
+ retries: Retry | bool | int | None = None,
128
+ timeout: Timeout | float | int | None = 3,
129
+ json: typing.Any | None = None,
130
+ ) -> BaseHTTPResponse:
131
+ """
132
+ A convenience, top-level request method. It uses a module-global ``PoolManager`` instance.
133
+ Therefore, its side effects could be shared across dependencies relying on it.
134
+ To avoid side effects create a new ``PoolManager`` instance and use it instead.
135
+ The method does not accept low-level ``**urlopen_kw`` keyword arguments.
136
+
137
+ :param method:
138
+ HTTP request method (such as GET, POST, PUT, etc.)
139
+
140
+ :param url:
141
+ The URL to perform the request on.
142
+
143
+ :param body:
144
+ Data to send in the request body, either :class:`str`, :class:`bytes`,
145
+ an iterable of :class:`str`/:class:`bytes`, or a file-like object.
146
+
147
+ :param fields:
148
+ Data to encode and send in the request body.
149
+
150
+ :param headers:
151
+ Dictionary of custom headers to send, such as User-Agent,
152
+ If-None-Match, etc.
153
+
154
+ :param bool preload_content:
155
+ If True, the response's body will be preloaded into memory.
156
+
157
+ :param bool decode_content:
158
+ If True, will attempt to decode the body based on the
159
+ 'content-encoding' header.
160
+
161
+ :param redirect:
162
+ If True, automatically handle redirects (status codes 301, 302,
163
+ 303, 307, 308). Each redirect counts as a retry. Disabling retries
164
+ will disable redirect, too.
165
+
166
+ :param retries:
167
+ Configure the number of retries to allow before raising a
168
+ :class:`~urllib3.exceptions.MaxRetryError` exception.
169
+
170
+ If ``None`` (default) will retry 3 times, see ``Retry.DEFAULT``. Pass a
171
+ :class:`~urllib3.util.retry.Retry` object for fine-grained control
172
+ over different types of retries.
173
+ Pass an integer number to retry connection errors that many times,
174
+ but no other types of errors. Pass zero to never retry.
175
+
176
+ If ``False``, then retries are disabled and any exception is raised
177
+ immediately. Also, instead of raising a MaxRetryError on redirects,
178
+ the redirect response will be returned.
179
+
180
+ :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int.
181
+
182
+ :param timeout:
183
+ If specified, overrides the default timeout for this one
184
+ request. It may be a float (in seconds) or an instance of
185
+ :class:`urllib3.util.Timeout`.
186
+
187
+ :param json:
188
+ Data to encode and send as JSON with UTF-encoded in the request body.
189
+ The ``"Content-Type"`` header will be set to ``"application/json"``
190
+ unless specified otherwise.
191
+ """
192
+
193
+ return _DEFAULT_POOL.request(
194
+ method,
195
+ url,
196
+ body=body,
197
+ fields=fields,
198
+ headers=headers,
199
+ preload_content=preload_content,
200
+ decode_content=decode_content,
201
+ redirect=redirect,
202
+ retries=retries,
203
+ timeout=timeout,
204
+ json=json,
205
+ )
206
+
207
+
208
+ if sys.platform == "emscripten":
209
+ from .contrib.emscripten import inject_into_urllib3 # noqa: 401
210
+
211
+ inject_into_urllib3()
@@ -0,0 +1,172 @@
1
+ from __future__ import annotations
2
+
3
+ import typing
4
+
5
+ from .util.connection import _TYPE_SOCKET_OPTIONS
6
+ from .util.timeout import _DEFAULT_TIMEOUT, _TYPE_TIMEOUT
7
+ from .util.url import Url
8
+
9
+ _TYPE_BODY = typing.Union[bytes, typing.IO[typing.Any], typing.Iterable[bytes], str]
10
+
11
+
12
+ class ProxyConfig(typing.NamedTuple):
13
+ ssl_context: ssl.SSLContext | None
14
+ use_forwarding_for_https: bool
15
+ assert_hostname: None | str | typing.Literal[False]
16
+ assert_fingerprint: str | None
17
+
18
+
19
+ class _ResponseOptions(typing.NamedTuple):
20
+ # TODO: Remove this in favor of a better
21
+ # HTTP request/response lifecycle tracking.
22
+ request_method: str
23
+ request_url: str
24
+ preload_content: bool
25
+ decode_content: bool
26
+ enforce_content_length: bool
27
+
28
+
29
+ if typing.TYPE_CHECKING:
30
+ import ssl
31
+ from typing import Protocol
32
+
33
+ from .response import BaseHTTPResponse
34
+
35
+ class BaseHTTPConnection(Protocol):
36
+ default_port: typing.ClassVar[int]
37
+ default_socket_options: typing.ClassVar[_TYPE_SOCKET_OPTIONS]
38
+
39
+ host: str
40
+ port: int
41
+ timeout: None | (
42
+ float
43
+ ) # Instance doesn't store _DEFAULT_TIMEOUT, must be resolved.
44
+ blocksize: int
45
+ source_address: tuple[str, int] | None
46
+ socket_options: _TYPE_SOCKET_OPTIONS | None
47
+
48
+ proxy: Url | None
49
+ proxy_config: ProxyConfig | None
50
+
51
+ is_verified: bool
52
+ proxy_is_verified: bool | None
53
+
54
+ def __init__(
55
+ self,
56
+ host: str,
57
+ port: int | None = None,
58
+ *,
59
+ timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT,
60
+ source_address: tuple[str, int] | None = None,
61
+ blocksize: int = 8192,
62
+ socket_options: _TYPE_SOCKET_OPTIONS | None = ...,
63
+ proxy: Url | None = None,
64
+ proxy_config: ProxyConfig | None = None,
65
+ ) -> None:
66
+ ...
67
+
68
+ def set_tunnel(
69
+ self,
70
+ host: str,
71
+ port: int | None = None,
72
+ headers: typing.Mapping[str, str] | None = None,
73
+ scheme: str = "http",
74
+ ) -> None:
75
+ ...
76
+
77
+ def connect(self) -> None:
78
+ ...
79
+
80
+ def request(
81
+ self,
82
+ method: str,
83
+ url: str,
84
+ body: _TYPE_BODY | None = None,
85
+ headers: typing.Mapping[str, str] | None = None,
86
+ # We know *at least* botocore is depending on the order of the
87
+ # first 3 parameters so to be safe we only mark the later ones
88
+ # as keyword-only to ensure we have space to extend.
89
+ *,
90
+ chunked: bool = False,
91
+ preload_content: bool = True,
92
+ decode_content: bool = True,
93
+ enforce_content_length: bool = True,
94
+ ) -> None:
95
+ ...
96
+
97
+ def getresponse(self) -> BaseHTTPResponse:
98
+ ...
99
+
100
+ def close(self) -> None:
101
+ ...
102
+
103
+ @property
104
+ def is_closed(self) -> bool:
105
+ """Whether the connection either is brand new or has been previously closed.
106
+ If this property is True then both ``is_connected`` and ``has_connected_to_proxy``
107
+ properties must be False.
108
+ """
109
+
110
+ @property
111
+ def is_connected(self) -> bool:
112
+ """Whether the connection is actively connected to any origin (proxy or target)"""
113
+
114
+ @property
115
+ def has_connected_to_proxy(self) -> bool:
116
+ """Whether the connection has successfully connected to its proxy.
117
+ This returns False if no proxy is in use. Used to determine whether
118
+ errors are coming from the proxy layer or from tunnelling to the target origin.
119
+ """
120
+
121
+ class BaseHTTPSConnection(BaseHTTPConnection, Protocol):
122
+ default_port: typing.ClassVar[int]
123
+ default_socket_options: typing.ClassVar[_TYPE_SOCKET_OPTIONS]
124
+
125
+ # Certificate verification methods
126
+ cert_reqs: int | str | None
127
+ assert_hostname: None | str | typing.Literal[False]
128
+ assert_fingerprint: str | None
129
+ ssl_context: ssl.SSLContext | None
130
+
131
+ # Trusted CAs
132
+ ca_certs: str | None
133
+ ca_cert_dir: str | None
134
+ ca_cert_data: None | str | bytes
135
+
136
+ # TLS version
137
+ ssl_minimum_version: int | None
138
+ ssl_maximum_version: int | None
139
+ ssl_version: int | str | None # Deprecated
140
+
141
+ # Client certificates
142
+ cert_file: str | None
143
+ key_file: str | None
144
+ key_password: str | None
145
+
146
+ def __init__(
147
+ self,
148
+ host: str,
149
+ port: int | None = None,
150
+ *,
151
+ timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT,
152
+ source_address: tuple[str, int] | None = None,
153
+ blocksize: int = 16384,
154
+ socket_options: _TYPE_SOCKET_OPTIONS | None = ...,
155
+ proxy: Url | None = None,
156
+ proxy_config: ProxyConfig | None = None,
157
+ cert_reqs: int | str | None = None,
158
+ assert_hostname: None | str | typing.Literal[False] = None,
159
+ assert_fingerprint: str | None = None,
160
+ server_hostname: str | None = None,
161
+ ssl_context: ssl.SSLContext | None = None,
162
+ ca_certs: str | None = None,
163
+ ca_cert_dir: str | None = None,
164
+ ca_cert_data: None | str | bytes = None,
165
+ ssl_minimum_version: int | None = None,
166
+ ssl_maximum_version: int | None = None,
167
+ ssl_version: int | str | None = None, # Deprecated
168
+ cert_file: str | None = None,
169
+ key_file: str | None = None,
170
+ key_password: str | None = None,
171
+ ) -> None:
172
+ ...