catocli 1.0.13__py3-none-any.whl → 1.0.15__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 (253) hide show
  1. catocli/Utils/clidriver.py +15 -2
  2. catocli/__init__.py +1 -1
  3. catocli/parsers/custom/customLib.py +3 -1
  4. catocli/parsers/mutation_accountManagement/README.md +7 -0
  5. catocli/parsers/mutation_accountManagement/__init__.py +51 -0
  6. catocli/parsers/mutation_accountManagement_addAccount/README.md +17 -0
  7. catocli/parsers/mutation_accountManagement_removeAccount/README.md +16 -0
  8. catocli/parsers/mutation_accountManagement_updateAccount/README.md +17 -0
  9. catocli/parsers/mutation_admin_addAdmin/README.md +2 -2
  10. catocli/parsers/mutation_admin_updateAdmin/README.md +2 -2
  11. catocli/parsers/mutation_container_delete/README.md +2 -2
  12. catocli/parsers/mutation_policy_internetFirewall_addRule/README.md +3 -3
  13. catocli/parsers/mutation_policy_internetFirewall_addSection/README.md +3 -3
  14. catocli/parsers/mutation_policy_internetFirewall_createPolicyRevision/README.md +3 -3
  15. catocli/parsers/mutation_policy_internetFirewall_discardPolicyRevision/README.md +3 -3
  16. catocli/parsers/mutation_policy_internetFirewall_moveRule/README.md +3 -3
  17. catocli/parsers/mutation_policy_internetFirewall_moveSection/README.md +3 -3
  18. catocli/parsers/mutation_policy_internetFirewall_publishPolicyRevision/README.md +3 -3
  19. catocli/parsers/mutation_policy_internetFirewall_removeRule/README.md +3 -3
  20. catocli/parsers/mutation_policy_internetFirewall_removeSection/README.md +3 -3
  21. catocli/parsers/mutation_policy_internetFirewall_updatePolicy/README.md +3 -3
  22. catocli/parsers/mutation_policy_internetFirewall_updateRule/README.md +3 -3
  23. catocli/parsers/mutation_policy_internetFirewall_updateSection/README.md +3 -3
  24. catocli/parsers/mutation_policy_wanFirewall_addRule/README.md +3 -3
  25. catocli/parsers/mutation_policy_wanFirewall_addSection/README.md +3 -3
  26. catocli/parsers/mutation_policy_wanFirewall_createPolicyRevision/README.md +3 -3
  27. catocli/parsers/mutation_policy_wanFirewall_discardPolicyRevision/README.md +3 -3
  28. catocli/parsers/mutation_policy_wanFirewall_moveRule/README.md +3 -3
  29. catocli/parsers/mutation_policy_wanFirewall_moveSection/README.md +3 -3
  30. catocli/parsers/mutation_policy_wanFirewall_publishPolicyRevision/README.md +3 -3
  31. catocli/parsers/mutation_policy_wanFirewall_removeRule/README.md +3 -3
  32. catocli/parsers/mutation_policy_wanFirewall_removeSection/README.md +3 -3
  33. catocli/parsers/mutation_policy_wanFirewall_updatePolicy/README.md +3 -3
  34. catocli/parsers/mutation_policy_wanFirewall_updateRule/README.md +3 -3
  35. catocli/parsers/mutation_policy_wanFirewall_updateSection/README.md +3 -3
  36. catocli/parsers/mutation_site/__init__.py +14 -0
  37. catocli/parsers/mutation_site_addIpsecIkeV2Site/README.md +2 -2
  38. catocli/parsers/mutation_site_addIpsecIkeV2SiteTunnels/README.md +2 -2
  39. catocli/parsers/mutation_site_addNetworkRange/README.md +2 -2
  40. catocli/parsers/mutation_site_addSocketSite/README.md +2 -2
  41. catocli/parsers/mutation_site_addStaticHost/README.md +2 -2
  42. catocli/parsers/mutation_site_removeIpsecIkeV2SiteTunnels/README.md +18 -0
  43. catocli/parsers/mutation_site_updateHa/README.md +2 -2
  44. catocli/parsers/mutation_site_updateIpsecIkeV2SiteGeneralDetails/README.md +2 -2
  45. catocli/parsers/mutation_site_updateIpsecIkeV2SiteTunnels/README.md +2 -2
  46. catocli/parsers/mutation_site_updateNetworkRange/README.md +2 -2
  47. catocli/parsers/mutation_site_updateSiteGeneralDetails/README.md +2 -2
  48. catocli/parsers/mutation_site_updateSocketInterface/README.md +2 -2
  49. catocli/parsers/mutation_site_updateStaticHost/README.md +2 -2
  50. catocli/parsers/mutation_sites/__init__.py +14 -0
  51. catocli/parsers/mutation_sites_addIpsecIkeV2Site/README.md +2 -2
  52. catocli/parsers/mutation_sites_addIpsecIkeV2SiteTunnels/README.md +2 -2
  53. catocli/parsers/mutation_sites_addNetworkRange/README.md +2 -2
  54. catocli/parsers/mutation_sites_addSocketSite/README.md +2 -2
  55. catocli/parsers/mutation_sites_addStaticHost/README.md +2 -2
  56. catocli/parsers/mutation_sites_removeIpsecIkeV2SiteTunnels/README.md +18 -0
  57. catocli/parsers/mutation_sites_updateHa/README.md +2 -2
  58. catocli/parsers/mutation_sites_updateIpsecIkeV2SiteGeneralDetails/README.md +2 -2
  59. catocli/parsers/mutation_sites_updateIpsecIkeV2SiteTunnels/README.md +2 -2
  60. catocli/parsers/mutation_sites_updateNetworkRange/README.md +2 -2
  61. catocli/parsers/mutation_sites_updateSiteGeneralDetails/README.md +2 -2
  62. catocli/parsers/mutation_sites_updateSocketInterface/README.md +2 -2
  63. catocli/parsers/mutation_sites_updateStaticHost/README.md +2 -2
  64. catocli/parsers/parserApiClient.py +7 -4
  65. catocli/parsers/query_accountManagement/README.md +16 -0
  66. catocli/parsers/query_accountManagement/__init__.py +17 -0
  67. catocli/parsers/query_admins/README.md +2 -2
  68. catocli/parsers/query_appStats/README.md +5 -5
  69. catocli/parsers/query_appStatsTimeSeries/README.md +4 -4
  70. catocli/parsers/query_auditFeed/README.md +2 -2
  71. catocli/parsers/query_container/README.md +8 -8
  72. catocli/parsers/query_entityLookup/README.md +6 -6
  73. catocli/parsers/query_events/README.md +5 -5
  74. catocli/parsers/query_eventsFeed/README.md +2 -2
  75. catocli/parsers/query_eventsTimeSeries/README.md +4 -4
  76. catocli/parsers/query_hardwareManagement/README.md +2 -2
  77. catocli/parsers/query_policy/README.md +3 -3
  78. catocli/parsers/query_xdr_stories/README.md +2 -2
  79. {catocli-1.0.13.dist-info → catocli-1.0.15.dist-info}/METADATA +1 -1
  80. catocli-1.0.15.dist-info/RECORD +275 -0
  81. {catocli-1.0.13.dist-info → catocli-1.0.15.dist-info}/top_level.txt +0 -2
  82. graphql_client/api_client_types.py +4 -0
  83. models/mutation.accountManagement.addAccount.json +908 -0
  84. models/mutation.accountManagement.removeAccount.json +446 -0
  85. models/mutation.accountManagement.updateAccount.json +524 -0
  86. models/mutation.admin.addAdmin.json +103 -103
  87. models/mutation.admin.removeAdmin.json +3 -3
  88. models/mutation.admin.updateAdmin.json +121 -121
  89. models/mutation.container.delete.json +67 -67
  90. models/mutation.policy.internetFirewall.addRule.json +2497 -1889
  91. models/mutation.policy.internetFirewall.addSection.json +92 -92
  92. models/mutation.policy.internetFirewall.createPolicyRevision.json +734 -546
  93. models/mutation.policy.internetFirewall.discardPolicyRevision.json +734 -546
  94. models/mutation.policy.internetFirewall.moveRule.json +723 -535
  95. models/mutation.policy.internetFirewall.moveSection.json +85 -85
  96. models/mutation.policy.internetFirewall.publishPolicyRevision.json +734 -546
  97. models/mutation.policy.internetFirewall.removeRule.json +710 -522
  98. models/mutation.policy.internetFirewall.removeSection.json +72 -72
  99. models/mutation.policy.internetFirewall.updatePolicy.json +734 -546
  100. models/mutation.policy.internetFirewall.updateRule.json +2476 -1885
  101. models/mutation.policy.internetFirewall.updateSection.json +85 -85
  102. models/mutation.policy.wanFirewall.addRule.json +2577 -1225
  103. models/mutation.policy.wanFirewall.addSection.json +92 -92
  104. models/mutation.policy.wanFirewall.createPolicyRevision.json +800 -455
  105. models/mutation.policy.wanFirewall.discardPolicyRevision.json +800 -455
  106. models/mutation.policy.wanFirewall.moveRule.json +789 -444
  107. models/mutation.policy.wanFirewall.moveSection.json +85 -85
  108. models/mutation.policy.wanFirewall.publishPolicyRevision.json +800 -455
  109. models/mutation.policy.wanFirewall.removeRule.json +776 -431
  110. models/mutation.policy.wanFirewall.removeSection.json +72 -72
  111. models/mutation.policy.wanFirewall.updatePolicy.json +800 -455
  112. models/mutation.policy.wanFirewall.updateRule.json +2597 -1265
  113. models/mutation.policy.wanFirewall.updateSection.json +85 -85
  114. models/mutation.site.addIpsecIkeV2Site.json +43 -43
  115. models/mutation.site.addIpsecIkeV2SiteTunnels.json +505 -102
  116. models/mutation.site.addNetworkRange.json +53 -53
  117. models/mutation.site.addSocketSite.json +43 -43
  118. models/mutation.site.addStaticHost.json +33 -33
  119. models/mutation.site.removeIpsecIkeV2SiteTunnels.json +861 -0
  120. models/mutation.site.removeNetworkRange.json +3 -3
  121. models/mutation.site.removeSite.json +3 -3
  122. models/mutation.site.removeStaticHost.json +3 -3
  123. models/mutation.site.updateHa.json +54 -54
  124. models/mutation.site.updateIpsecIkeV2SiteGeneralDetails.json +79 -79
  125. models/mutation.site.updateIpsecIkeV2SiteTunnels.json +123 -123
  126. models/mutation.site.updateNetworkRange.json +74 -74
  127. models/mutation.site.updateSiteGeneralDetails.json +73 -73
  128. models/mutation.site.updateSocketInterface.json +282 -282
  129. models/mutation.site.updateStaticHost.json +54 -54
  130. models/mutation.sites.addIpsecIkeV2Site.json +43 -43
  131. models/mutation.sites.addIpsecIkeV2SiteTunnels.json +505 -102
  132. models/mutation.sites.addNetworkRange.json +53 -53
  133. models/mutation.sites.addSocketSite.json +43 -43
  134. models/mutation.sites.addStaticHost.json +33 -33
  135. models/mutation.sites.removeIpsecIkeV2SiteTunnels.json +861 -0
  136. models/mutation.sites.removeNetworkRange.json +3 -3
  137. models/mutation.sites.removeSite.json +3 -3
  138. models/mutation.sites.removeStaticHost.json +3 -3
  139. models/mutation.sites.updateHa.json +54 -54
  140. models/mutation.sites.updateIpsecIkeV2SiteGeneralDetails.json +79 -79
  141. models/mutation.sites.updateIpsecIkeV2SiteTunnels.json +123 -123
  142. models/mutation.sites.updateNetworkRange.json +74 -74
  143. models/mutation.sites.updateSiteGeneralDetails.json +73 -73
  144. models/mutation.sites.updateSocketInterface.json +282 -282
  145. models/mutation.sites.updateStaticHost.json +54 -54
  146. models/query.accountManagement.json +355 -0
  147. models/query.accountMetrics.json +235 -235
  148. models/query.accountRoles.json +3 -3
  149. models/query.accountSnapshot.json +278 -118
  150. models/query.admin.json +24 -24
  151. models/query.admins.json +138 -138
  152. models/query.appStats.json +92 -92
  153. models/query.appStatsTimeSeries.json +78 -78
  154. models/query.auditFeed.json +77 -77
  155. models/query.container.json +192 -192
  156. models/query.entityLookup.json +154 -154
  157. models/query.events.json +54 -54
  158. models/query.eventsFeed.json +38 -38
  159. models/query.eventsTimeSeries.json +78 -78
  160. models/query.hardwareManagement.json +125 -125
  161. models/query.licensing.json +933 -249
  162. models/query.policy.json +1502 -970
  163. models/query.xdr.stories.json +842 -842
  164. models/query.xdr.story.json +610 -610
  165. schema/catolib.py +12 -13
  166. build/lib/catocli/Utils/clidriver.py +0 -117
  167. build/lib/catocli/__init__.py +0 -2
  168. build/lib/catocli/__main__.py +0 -12
  169. build/lib/catocli/parsers/custom/__init__.py +0 -47
  170. build/lib/catocli/parsers/custom/customLib.py +0 -70
  171. build/lib/catocli/parsers/mutation_admin/__init__.py +0 -51
  172. build/lib/catocli/parsers/mutation_container/__init__.py +0 -23
  173. build/lib/catocli/parsers/mutation_policy/__init__.py +0 -357
  174. build/lib/catocli/parsers/mutation_site/__init__.py +0 -219
  175. build/lib/catocli/parsers/mutation_sites/__init__.py +0 -219
  176. build/lib/catocli/parsers/parserApiClient.py +0 -309
  177. build/lib/catocli/parsers/query_accountBySubdomain/__init__.py +0 -17
  178. build/lib/catocli/parsers/query_accountMetrics/__init__.py +0 -17
  179. build/lib/catocli/parsers/query_accountRoles/__init__.py +0 -17
  180. build/lib/catocli/parsers/query_accountSnapshot/__init__.py +0 -17
  181. build/lib/catocli/parsers/query_admin/__init__.py +0 -17
  182. build/lib/catocli/parsers/query_admins/__init__.py +0 -17
  183. build/lib/catocli/parsers/query_appStats/__init__.py +0 -17
  184. build/lib/catocli/parsers/query_appStatsTimeSeries/__init__.py +0 -17
  185. build/lib/catocli/parsers/query_auditFeed/__init__.py +0 -17
  186. build/lib/catocli/parsers/query_container/__init__.py +0 -17
  187. build/lib/catocli/parsers/query_entityLookup/__init__.py +0 -17
  188. build/lib/catocli/parsers/query_events/__init__.py +0 -17
  189. build/lib/catocli/parsers/query_eventsFeed/__init__.py +0 -17
  190. build/lib/catocli/parsers/query_eventsTimeSeries/__init__.py +0 -17
  191. build/lib/catocli/parsers/query_hardwareManagement/__init__.py +0 -17
  192. build/lib/catocli/parsers/query_licensing/__init__.py +0 -17
  193. build/lib/catocli/parsers/query_policy/__init__.py +0 -17
  194. build/lib/catocli/parsers/query_siteLocation/__init__.py +0 -17
  195. build/lib/catocli/parsers/query_subDomains/__init__.py +0 -17
  196. build/lib/catocli/parsers/query_xdr/__init__.py +0 -37
  197. build/lib/catocli/parsers/raw/__init__.py +0 -9
  198. build/lib/graphql_client/__init__.py +0 -11
  199. build/lib/graphql_client/api/__init__.py +0 -3
  200. build/lib/graphql_client/api/call_api.py +0 -73
  201. build/lib/graphql_client/api_client.py +0 -192
  202. build/lib/graphql_client/api_client_types.py +0 -404
  203. build/lib/graphql_client/configuration.py +0 -230
  204. build/lib/graphql_client/models/__init__.py +0 -13
  205. build/lib/graphql_client/models/no_schema.py +0 -71
  206. build/lib/schema/catolib.py +0 -1016
  207. build/lib/schema/importSchema.py +0 -60
  208. build/lib/vendor/certifi/__init__.py +0 -4
  209. build/lib/vendor/certifi/__main__.py +0 -12
  210. build/lib/vendor/certifi/core.py +0 -114
  211. build/lib/vendor/certifi/py.typed +0 -0
  212. build/lib/vendor/six.py +0 -998
  213. build/lib/vendor/urllib3/__init__.py +0 -211
  214. build/lib/vendor/urllib3/_base_connection.py +0 -172
  215. build/lib/vendor/urllib3/_collections.py +0 -483
  216. build/lib/vendor/urllib3/_request_methods.py +0 -278
  217. build/lib/vendor/urllib3/_version.py +0 -16
  218. build/lib/vendor/urllib3/connection.py +0 -1033
  219. build/lib/vendor/urllib3/connectionpool.py +0 -1182
  220. build/lib/vendor/urllib3/contrib/__init__.py +0 -0
  221. build/lib/vendor/urllib3/contrib/emscripten/__init__.py +0 -18
  222. build/lib/vendor/urllib3/contrib/emscripten/connection.py +0 -254
  223. build/lib/vendor/urllib3/contrib/emscripten/fetch.py +0 -418
  224. build/lib/vendor/urllib3/contrib/emscripten/request.py +0 -22
  225. build/lib/vendor/urllib3/contrib/emscripten/response.py +0 -285
  226. build/lib/vendor/urllib3/contrib/pyopenssl.py +0 -552
  227. build/lib/vendor/urllib3/contrib/socks.py +0 -228
  228. build/lib/vendor/urllib3/exceptions.py +0 -321
  229. build/lib/vendor/urllib3/fields.py +0 -341
  230. build/lib/vendor/urllib3/filepost.py +0 -89
  231. build/lib/vendor/urllib3/http2/__init__.py +0 -53
  232. build/lib/vendor/urllib3/http2/connection.py +0 -356
  233. build/lib/vendor/urllib3/http2/probe.py +0 -87
  234. build/lib/vendor/urllib3/poolmanager.py +0 -637
  235. build/lib/vendor/urllib3/py.typed +0 -2
  236. build/lib/vendor/urllib3/response.py +0 -1265
  237. build/lib/vendor/urllib3/util/__init__.py +0 -42
  238. build/lib/vendor/urllib3/util/connection.py +0 -137
  239. build/lib/vendor/urllib3/util/proxy.py +0 -43
  240. build/lib/vendor/urllib3/util/request.py +0 -256
  241. build/lib/vendor/urllib3/util/response.py +0 -101
  242. build/lib/vendor/urllib3/util/retry.py +0 -533
  243. build/lib/vendor/urllib3/util/ssl_.py +0 -513
  244. build/lib/vendor/urllib3/util/ssl_match_hostname.py +0 -159
  245. build/lib/vendor/urllib3/util/ssltransport.py +0 -276
  246. build/lib/vendor/urllib3/util/timeout.py +0 -275
  247. build/lib/vendor/urllib3/util/url.py +0 -471
  248. build/lib/vendor/urllib3/util/util.py +0 -42
  249. build/lib/vendor/urllib3/util/wait.py +0 -124
  250. catocli-1.0.13.dist-info/RECORD +0 -344
  251. {catocli-1.0.13.dist-info → catocli-1.0.15.dist-info}/LICENSE +0 -0
  252. {catocli-1.0.13.dist-info → catocli-1.0.15.dist-info}/WHEEL +0 -0
  253. {catocli-1.0.13.dist-info → catocli-1.0.15.dist-info}/entry_points.txt +0 -0
@@ -1,228 +0,0 @@
1
- """
2
- This module contains provisional support for SOCKS proxies from within
3
- urllib3. This module supports SOCKS4, SOCKS4A (an extension of SOCKS4), and
4
- SOCKS5. To enable its functionality, either install PySocks or install this
5
- module with the ``socks`` extra.
6
-
7
- The SOCKS implementation supports the full range of urllib3 features. It also
8
- supports the following SOCKS features:
9
-
10
- - SOCKS4A (``proxy_url='socks4a://...``)
11
- - SOCKS4 (``proxy_url='socks4://...``)
12
- - SOCKS5 with remote DNS (``proxy_url='socks5h://...``)
13
- - SOCKS5 with local DNS (``proxy_url='socks5://...``)
14
- - Usernames and passwords for the SOCKS proxy
15
-
16
- .. note::
17
- It is recommended to use ``socks5h://`` or ``socks4a://`` schemes in
18
- your ``proxy_url`` to ensure that DNS resolution is done from the remote
19
- server instead of client-side when connecting to a domain name.
20
-
21
- SOCKS4 supports IPv4 and domain names with the SOCKS4A extension. SOCKS5
22
- supports IPv4, IPv6, and domain names.
23
-
24
- When connecting to a SOCKS4 proxy the ``username`` portion of the ``proxy_url``
25
- will be sent as the ``userid`` section of the SOCKS request:
26
-
27
- .. code-block:: python
28
-
29
- proxy_url="socks4a://<userid>@proxy-host"
30
-
31
- When connecting to a SOCKS5 proxy the ``username`` and ``password`` portion
32
- of the ``proxy_url`` will be sent as the username/password to authenticate
33
- with the proxy:
34
-
35
- .. code-block:: python
36
-
37
- proxy_url="socks5h://<username>:<password>@proxy-host"
38
-
39
- """
40
-
41
- from __future__ import annotations
42
-
43
- try:
44
- import socks # type: ignore[import-not-found]
45
- except ImportError:
46
- import warnings
47
-
48
- from ..exceptions import DependencyWarning
49
-
50
- warnings.warn(
51
- (
52
- "SOCKS support in urllib3 requires the installation of optional "
53
- "dependencies: specifically, PySocks. For more information, see "
54
- "https://urllib3.readthedocs.io/en/latest/advanced-usage.html#socks-proxies"
55
- ),
56
- DependencyWarning,
57
- )
58
- raise
59
-
60
- import typing
61
- from socket import timeout as SocketTimeout
62
-
63
- from ..connection import HTTPConnection, HTTPSConnection
64
- from ..connectionpool import HTTPConnectionPool, HTTPSConnectionPool
65
- from ..exceptions import ConnectTimeoutError, NewConnectionError
66
- from ..poolmanager import PoolManager
67
- from ..util.url import parse_url
68
-
69
- try:
70
- import ssl
71
- except ImportError:
72
- ssl = None # type: ignore[assignment]
73
-
74
-
75
- class _TYPE_SOCKS_OPTIONS(typing.TypedDict):
76
- socks_version: int
77
- proxy_host: str | None
78
- proxy_port: str | None
79
- username: str | None
80
- password: str | None
81
- rdns: bool
82
-
83
-
84
- class SOCKSConnection(HTTPConnection):
85
- """
86
- A plain-text HTTP connection that connects via a SOCKS proxy.
87
- """
88
-
89
- def __init__(
90
- self,
91
- _socks_options: _TYPE_SOCKS_OPTIONS,
92
- *args: typing.Any,
93
- **kwargs: typing.Any,
94
- ) -> None:
95
- self._socks_options = _socks_options
96
- super().__init__(*args, **kwargs)
97
-
98
- def _new_conn(self) -> socks.socksocket:
99
- """
100
- Establish a new connection via the SOCKS proxy.
101
- """
102
- extra_kw: dict[str, typing.Any] = {}
103
- if self.source_address:
104
- extra_kw["source_address"] = self.source_address
105
-
106
- if self.socket_options:
107
- extra_kw["socket_options"] = self.socket_options
108
-
109
- try:
110
- conn = socks.create_connection(
111
- (self.host, self.port),
112
- proxy_type=self._socks_options["socks_version"],
113
- proxy_addr=self._socks_options["proxy_host"],
114
- proxy_port=self._socks_options["proxy_port"],
115
- proxy_username=self._socks_options["username"],
116
- proxy_password=self._socks_options["password"],
117
- proxy_rdns=self._socks_options["rdns"],
118
- timeout=self.timeout,
119
- **extra_kw,
120
- )
121
-
122
- except SocketTimeout as e:
123
- raise ConnectTimeoutError(
124
- self,
125
- f"Connection to {self.host} timed out. (connect timeout={self.timeout})",
126
- ) from e
127
-
128
- except socks.ProxyError as e:
129
- # This is fragile as hell, but it seems to be the only way to raise
130
- # useful errors here.
131
- if e.socket_err:
132
- error = e.socket_err
133
- if isinstance(error, SocketTimeout):
134
- raise ConnectTimeoutError(
135
- self,
136
- f"Connection to {self.host} timed out. (connect timeout={self.timeout})",
137
- ) from e
138
- else:
139
- # Adding `from e` messes with coverage somehow, so it's omitted.
140
- # See #2386.
141
- raise NewConnectionError(
142
- self, f"Failed to establish a new connection: {error}"
143
- )
144
- else:
145
- raise NewConnectionError(
146
- self, f"Failed to establish a new connection: {e}"
147
- ) from e
148
-
149
- except OSError as e: # Defensive: PySocks should catch all these.
150
- raise NewConnectionError(
151
- self, f"Failed to establish a new connection: {e}"
152
- ) from e
153
-
154
- return conn
155
-
156
-
157
- # We don't need to duplicate the Verified/Unverified distinction from
158
- # urllib3/connection.py here because the HTTPSConnection will already have been
159
- # correctly set to either the Verified or Unverified form by that module. This
160
- # means the SOCKSHTTPSConnection will automatically be the correct type.
161
- class SOCKSHTTPSConnection(SOCKSConnection, HTTPSConnection):
162
- pass
163
-
164
-
165
- class SOCKSHTTPConnectionPool(HTTPConnectionPool):
166
- ConnectionCls = SOCKSConnection
167
-
168
-
169
- class SOCKSHTTPSConnectionPool(HTTPSConnectionPool):
170
- ConnectionCls = SOCKSHTTPSConnection
171
-
172
-
173
- class SOCKSProxyManager(PoolManager):
174
- """
175
- A version of the urllib3 ProxyManager that routes connections via the
176
- defined SOCKS proxy.
177
- """
178
-
179
- pool_classes_by_scheme = {
180
- "http": SOCKSHTTPConnectionPool,
181
- "https": SOCKSHTTPSConnectionPool,
182
- }
183
-
184
- def __init__(
185
- self,
186
- proxy_url: str,
187
- username: str | None = None,
188
- password: str | None = None,
189
- num_pools: int = 10,
190
- headers: typing.Mapping[str, str] | None = None,
191
- **connection_pool_kw: typing.Any,
192
- ):
193
- parsed = parse_url(proxy_url)
194
-
195
- if username is None and password is None and parsed.auth is not None:
196
- split = parsed.auth.split(":")
197
- if len(split) == 2:
198
- username, password = split
199
- if parsed.scheme == "socks5":
200
- socks_version = socks.PROXY_TYPE_SOCKS5
201
- rdns = False
202
- elif parsed.scheme == "socks5h":
203
- socks_version = socks.PROXY_TYPE_SOCKS5
204
- rdns = True
205
- elif parsed.scheme == "socks4":
206
- socks_version = socks.PROXY_TYPE_SOCKS4
207
- rdns = False
208
- elif parsed.scheme == "socks4a":
209
- socks_version = socks.PROXY_TYPE_SOCKS4
210
- rdns = True
211
- else:
212
- raise ValueError(f"Unable to determine SOCKS version from {proxy_url}")
213
-
214
- self.proxy_url = proxy_url
215
-
216
- socks_options = {
217
- "socks_version": socks_version,
218
- "proxy_host": parsed.host,
219
- "proxy_port": parsed.port,
220
- "username": username,
221
- "password": password,
222
- "rdns": rdns,
223
- }
224
- connection_pool_kw["_socks_options"] = socks_options
225
-
226
- super().__init__(num_pools, headers, **connection_pool_kw)
227
-
228
- self.pool_classes_by_scheme = SOCKSProxyManager.pool_classes_by_scheme
@@ -1,321 +0,0 @@
1
- from __future__ import annotations
2
-
3
- import socket
4
- import typing
5
- import warnings
6
- from email.errors import MessageDefect
7
- from http.client import IncompleteRead as httplib_IncompleteRead
8
-
9
- if typing.TYPE_CHECKING:
10
- from .connection import HTTPConnection
11
- from .connectionpool import ConnectionPool
12
- from .response import HTTPResponse
13
- from .util.retry import Retry
14
-
15
- # Base Exceptions
16
-
17
-
18
- class HTTPError(Exception):
19
- """Base exception used by this module."""
20
-
21
-
22
- class HTTPWarning(Warning):
23
- """Base warning used by this module."""
24
-
25
-
26
- _TYPE_REDUCE_RESULT = typing.Tuple[
27
- typing.Callable[..., object], typing.Tuple[object, ...]
28
- ]
29
-
30
-
31
- class PoolError(HTTPError):
32
- """Base exception for errors caused within a pool."""
33
-
34
- def __init__(self, pool: ConnectionPool, message: str) -> None:
35
- self.pool = pool
36
- super().__init__(f"{pool}: {message}")
37
-
38
- def __reduce__(self) -> _TYPE_REDUCE_RESULT:
39
- # For pickling purposes.
40
- return self.__class__, (None, None)
41
-
42
-
43
- class RequestError(PoolError):
44
- """Base exception for PoolErrors that have associated URLs."""
45
-
46
- def __init__(self, pool: ConnectionPool, url: str, message: str) -> None:
47
- self.url = url
48
- super().__init__(pool, message)
49
-
50
- def __reduce__(self) -> _TYPE_REDUCE_RESULT:
51
- # For pickling purposes.
52
- return self.__class__, (None, self.url, None)
53
-
54
-
55
- class SSLError(HTTPError):
56
- """Raised when SSL certificate fails in an HTTPS connection."""
57
-
58
-
59
- class ProxyError(HTTPError):
60
- """Raised when the connection to a proxy fails."""
61
-
62
- # The original error is also available as __cause__.
63
- original_error: Exception
64
-
65
- def __init__(self, message: str, error: Exception) -> None:
66
- super().__init__(message, error)
67
- self.original_error = error
68
-
69
-
70
- class DecodeError(HTTPError):
71
- """Raised when automatic decoding based on Content-Type fails."""
72
-
73
-
74
- class ProtocolError(HTTPError):
75
- """Raised when something unexpected happens mid-request/response."""
76
-
77
-
78
- #: Renamed to ProtocolError but aliased for backwards compatibility.
79
- ConnectionError = ProtocolError
80
-
81
-
82
- # Leaf Exceptions
83
-
84
-
85
- class MaxRetryError(RequestError):
86
- """Raised when the maximum number of retries is exceeded.
87
-
88
- :param pool: The connection pool
89
- :type pool: :class:`~urllib3.connectionpool.HTTPConnectionPool`
90
- :param str url: The requested Url
91
- :param reason: The underlying error
92
- :type reason: :class:`Exception`
93
-
94
- """
95
-
96
- def __init__(
97
- self, pool: ConnectionPool, url: str, reason: Exception | None = None
98
- ) -> None:
99
- self.reason = reason
100
-
101
- message = f"Max retries exceeded with url: {url} (Caused by {reason!r})"
102
-
103
- super().__init__(pool, url, message)
104
-
105
-
106
- class HostChangedError(RequestError):
107
- """Raised when an existing pool gets a request for a foreign host."""
108
-
109
- def __init__(
110
- self, pool: ConnectionPool, url: str, retries: Retry | int = 3
111
- ) -> None:
112
- message = f"Tried to open a foreign host with url: {url}"
113
- super().__init__(pool, url, message)
114
- self.retries = retries
115
-
116
-
117
- class TimeoutStateError(HTTPError):
118
- """Raised when passing an invalid state to a timeout"""
119
-
120
-
121
- class TimeoutError(HTTPError):
122
- """Raised when a socket timeout error occurs.
123
-
124
- Catching this error will catch both :exc:`ReadTimeoutErrors
125
- <ReadTimeoutError>` and :exc:`ConnectTimeoutErrors <ConnectTimeoutError>`.
126
- """
127
-
128
-
129
- class ReadTimeoutError(TimeoutError, RequestError):
130
- """Raised when a socket timeout occurs while receiving data from a server"""
131
-
132
-
133
- # This timeout error does not have a URL attached and needs to inherit from the
134
- # base HTTPError
135
- class ConnectTimeoutError(TimeoutError):
136
- """Raised when a socket timeout occurs while connecting to a server"""
137
-
138
-
139
- class NewConnectionError(ConnectTimeoutError, HTTPError):
140
- """Raised when we fail to establish a new connection. Usually ECONNREFUSED."""
141
-
142
- def __init__(self, conn: HTTPConnection, message: str) -> None:
143
- self.conn = conn
144
- super().__init__(f"{conn}: {message}")
145
-
146
- @property
147
- def pool(self) -> HTTPConnection:
148
- warnings.warn(
149
- "The 'pool' property is deprecated and will be removed "
150
- "in urllib3 v2.1.0. Use 'conn' instead.",
151
- DeprecationWarning,
152
- stacklevel=2,
153
- )
154
-
155
- return self.conn
156
-
157
-
158
- class NameResolutionError(NewConnectionError):
159
- """Raised when host name resolution fails."""
160
-
161
- def __init__(self, host: str, conn: HTTPConnection, reason: socket.gaierror):
162
- message = f"Failed to resolve '{host}' ({reason})"
163
- super().__init__(conn, message)
164
-
165
-
166
- class EmptyPoolError(PoolError):
167
- """Raised when a pool runs out of connections and no more are allowed."""
168
-
169
-
170
- class FullPoolError(PoolError):
171
- """Raised when we try to add a connection to a full pool in blocking mode."""
172
-
173
-
174
- class ClosedPoolError(PoolError):
175
- """Raised when a request enters a pool after the pool has been closed."""
176
-
177
-
178
- class LocationValueError(ValueError, HTTPError):
179
- """Raised when there is something wrong with a given URL input."""
180
-
181
-
182
- class LocationParseError(LocationValueError):
183
- """Raised when get_host or similar fails to parse the URL input."""
184
-
185
- def __init__(self, location: str) -> None:
186
- message = f"Failed to parse: {location}"
187
- super().__init__(message)
188
-
189
- self.location = location
190
-
191
-
192
- class URLSchemeUnknown(LocationValueError):
193
- """Raised when a URL input has an unsupported scheme."""
194
-
195
- def __init__(self, scheme: str):
196
- message = f"Not supported URL scheme {scheme}"
197
- super().__init__(message)
198
-
199
- self.scheme = scheme
200
-
201
-
202
- class ResponseError(HTTPError):
203
- """Used as a container for an error reason supplied in a MaxRetryError."""
204
-
205
- GENERIC_ERROR = "too many error responses"
206
- SPECIFIC_ERROR = "too many {status_code} error responses"
207
-
208
-
209
- class SecurityWarning(HTTPWarning):
210
- """Warned when performing security reducing actions"""
211
-
212
-
213
- class InsecureRequestWarning(SecurityWarning):
214
- """Warned when making an unverified HTTPS request."""
215
-
216
-
217
- class NotOpenSSLWarning(SecurityWarning):
218
- """Warned when using unsupported SSL library"""
219
-
220
-
221
- class SystemTimeWarning(SecurityWarning):
222
- """Warned when system time is suspected to be wrong"""
223
-
224
-
225
- class InsecurePlatformWarning(SecurityWarning):
226
- """Warned when certain TLS/SSL configuration is not available on a platform."""
227
-
228
-
229
- class DependencyWarning(HTTPWarning):
230
- """
231
- Warned when an attempt is made to import a module with missing optional
232
- dependencies.
233
- """
234
-
235
-
236
- class ResponseNotChunked(ProtocolError, ValueError):
237
- """Response needs to be chunked in order to read it as chunks."""
238
-
239
-
240
- class BodyNotHttplibCompatible(HTTPError):
241
- """
242
- Body should be :class:`http.client.HTTPResponse` like
243
- (have an fp attribute which returns raw chunks) for read_chunked().
244
- """
245
-
246
-
247
- class IncompleteRead(HTTPError, httplib_IncompleteRead):
248
- """
249
- Response length doesn't match expected Content-Length
250
-
251
- Subclass of :class:`http.client.IncompleteRead` to allow int value
252
- for ``partial`` to avoid creating large objects on streamed reads.
253
- """
254
-
255
- partial: int # type: ignore[assignment]
256
- expected: int
257
-
258
- def __init__(self, partial: int, expected: int) -> None:
259
- self.partial = partial
260
- self.expected = expected
261
-
262
- def __repr__(self) -> str:
263
- return "IncompleteRead(%i bytes read, %i more expected)" % (
264
- self.partial,
265
- self.expected,
266
- )
267
-
268
-
269
- class InvalidChunkLength(HTTPError, httplib_IncompleteRead):
270
- """Invalid chunk length in a chunked response."""
271
-
272
- def __init__(self, response: HTTPResponse, length: bytes) -> None:
273
- self.partial: int = response.tell() # type: ignore[assignment]
274
- self.expected: int | None = response.length_remaining
275
- self.response = response
276
- self.length = length
277
-
278
- def __repr__(self) -> str:
279
- return "InvalidChunkLength(got length %r, %i bytes read)" % (
280
- self.length,
281
- self.partial,
282
- )
283
-
284
-
285
- class InvalidHeader(HTTPError):
286
- """The header provided was somehow invalid."""
287
-
288
-
289
- class ProxySchemeUnknown(AssertionError, URLSchemeUnknown):
290
- """ProxyManager does not support the supplied scheme"""
291
-
292
- # TODO(t-8ch): Stop inheriting from AssertionError in v2.0.
293
-
294
- def __init__(self, scheme: str | None) -> None:
295
- # 'localhost' is here because our URL parser parses
296
- # localhost:8080 -> scheme=localhost, remove if we fix this.
297
- if scheme == "localhost":
298
- scheme = None
299
- if scheme is None:
300
- message = "Proxy URL had no scheme, should start with http:// or https://"
301
- else:
302
- message = f"Proxy URL had unsupported scheme {scheme}, should use http:// or https://"
303
- super().__init__(message)
304
-
305
-
306
- class ProxySchemeUnsupported(ValueError):
307
- """Fetching HTTPS resources through HTTPS proxies is unsupported"""
308
-
309
-
310
- class HeaderParsingError(HTTPError):
311
- """Raised by assert_header_parsing, but we convert it to a log.warning statement."""
312
-
313
- def __init__(
314
- self, defects: list[MessageDefect], unparsed_data: bytes | str | None
315
- ) -> None:
316
- message = f"{defects or 'Unknown'}, unparsed data: {unparsed_data!r}"
317
- super().__init__(message)
318
-
319
-
320
- class UnrewindableBodyError(HTTPError):
321
- """urllib3 encountered an error when trying to rewind a body"""