catocli 1.0.12__py3-none-any.whl → 1.0.13__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 (105) hide show
  1. build/lib/catocli/Utils/clidriver.py +117 -0
  2. build/lib/catocli/__init__.py +2 -0
  3. build/lib/catocli/__main__.py +12 -0
  4. build/lib/catocli/parsers/custom/__init__.py +47 -0
  5. build/lib/catocli/parsers/custom/customLib.py +70 -0
  6. build/lib/catocli/parsers/mutation_admin/__init__.py +51 -0
  7. build/lib/catocli/parsers/mutation_container/__init__.py +23 -0
  8. build/lib/catocli/parsers/mutation_policy/__init__.py +357 -0
  9. build/lib/catocli/parsers/mutation_site/__init__.py +219 -0
  10. build/lib/catocli/parsers/mutation_sites/__init__.py +219 -0
  11. build/lib/catocli/parsers/parserApiClient.py +309 -0
  12. build/lib/catocli/parsers/query_accountBySubdomain/__init__.py +17 -0
  13. build/lib/catocli/parsers/query_accountMetrics/__init__.py +17 -0
  14. build/lib/catocli/parsers/query_accountRoles/__init__.py +17 -0
  15. build/lib/catocli/parsers/query_accountSnapshot/__init__.py +17 -0
  16. build/lib/catocli/parsers/query_admin/__init__.py +17 -0
  17. build/lib/catocli/parsers/query_admins/__init__.py +17 -0
  18. build/lib/catocli/parsers/query_appStats/__init__.py +17 -0
  19. build/lib/catocli/parsers/query_appStatsTimeSeries/__init__.py +17 -0
  20. build/lib/catocli/parsers/query_auditFeed/__init__.py +17 -0
  21. build/lib/catocli/parsers/query_container/__init__.py +17 -0
  22. build/lib/catocli/parsers/query_entityLookup/__init__.py +17 -0
  23. build/lib/catocli/parsers/query_events/__init__.py +17 -0
  24. build/lib/catocli/parsers/query_eventsFeed/__init__.py +17 -0
  25. build/lib/catocli/parsers/query_eventsTimeSeries/__init__.py +17 -0
  26. build/lib/catocli/parsers/query_hardwareManagement/__init__.py +17 -0
  27. build/lib/catocli/parsers/query_licensing/__init__.py +17 -0
  28. build/lib/catocli/parsers/query_policy/__init__.py +17 -0
  29. build/lib/catocli/parsers/query_siteLocation/__init__.py +17 -0
  30. build/lib/catocli/parsers/query_subDomains/__init__.py +17 -0
  31. build/lib/catocli/parsers/query_xdr/__init__.py +37 -0
  32. build/lib/catocli/parsers/raw/__init__.py +9 -0
  33. build/lib/graphql_client/__init__.py +11 -0
  34. build/lib/graphql_client/api/__init__.py +3 -0
  35. build/lib/graphql_client/api/call_api.py +73 -0
  36. build/lib/graphql_client/api_client.py +192 -0
  37. build/lib/graphql_client/api_client_types.py +404 -0
  38. build/lib/graphql_client/configuration.py +230 -0
  39. build/lib/graphql_client/models/__init__.py +13 -0
  40. build/lib/graphql_client/models/no_schema.py +71 -0
  41. build/lib/schema/catolib.py +1016 -0
  42. build/lib/schema/importSchema.py +60 -0
  43. build/lib/vendor/certifi/__init__.py +4 -0
  44. build/lib/vendor/certifi/__main__.py +12 -0
  45. build/lib/vendor/certifi/core.py +114 -0
  46. build/lib/vendor/certifi/py.typed +0 -0
  47. build/lib/vendor/six.py +998 -0
  48. build/lib/vendor/urllib3/__init__.py +211 -0
  49. build/lib/vendor/urllib3/_base_connection.py +172 -0
  50. build/lib/vendor/urllib3/_collections.py +483 -0
  51. build/lib/vendor/urllib3/_request_methods.py +278 -0
  52. build/lib/vendor/urllib3/_version.py +16 -0
  53. build/lib/vendor/urllib3/connection.py +1033 -0
  54. build/lib/vendor/urllib3/connectionpool.py +1182 -0
  55. build/lib/vendor/urllib3/contrib/__init__.py +0 -0
  56. build/lib/vendor/urllib3/contrib/emscripten/__init__.py +18 -0
  57. build/lib/vendor/urllib3/contrib/emscripten/connection.py +254 -0
  58. build/lib/vendor/urllib3/contrib/emscripten/fetch.py +418 -0
  59. build/lib/vendor/urllib3/contrib/emscripten/request.py +22 -0
  60. build/lib/vendor/urllib3/contrib/emscripten/response.py +285 -0
  61. build/lib/vendor/urllib3/contrib/pyopenssl.py +552 -0
  62. build/lib/vendor/urllib3/contrib/socks.py +228 -0
  63. build/lib/vendor/urllib3/exceptions.py +321 -0
  64. build/lib/vendor/urllib3/fields.py +341 -0
  65. build/lib/vendor/urllib3/filepost.py +89 -0
  66. build/lib/vendor/urllib3/http2/__init__.py +53 -0
  67. build/lib/vendor/urllib3/http2/connection.py +356 -0
  68. build/lib/vendor/urllib3/http2/probe.py +87 -0
  69. build/lib/vendor/urllib3/poolmanager.py +637 -0
  70. build/lib/vendor/urllib3/py.typed +2 -0
  71. build/lib/vendor/urllib3/response.py +1265 -0
  72. build/lib/vendor/urllib3/util/__init__.py +42 -0
  73. build/lib/vendor/urllib3/util/connection.py +137 -0
  74. build/lib/vendor/urllib3/util/proxy.py +43 -0
  75. build/lib/vendor/urllib3/util/request.py +256 -0
  76. build/lib/vendor/urllib3/util/response.py +101 -0
  77. build/lib/vendor/urllib3/util/retry.py +533 -0
  78. build/lib/vendor/urllib3/util/ssl_.py +513 -0
  79. build/lib/vendor/urllib3/util/ssl_match_hostname.py +159 -0
  80. build/lib/vendor/urllib3/util/ssltransport.py +276 -0
  81. build/lib/vendor/urllib3/util/timeout.py +275 -0
  82. build/lib/vendor/urllib3/util/url.py +471 -0
  83. build/lib/vendor/urllib3/util/util.py +42 -0
  84. build/lib/vendor/urllib3/util/wait.py +124 -0
  85. catocli/__init__.py +1 -1
  86. catocli/parsers/custom/__init__.py +1 -1
  87. catocli/parsers/custom/customLib.py +1 -2
  88. catocli/parsers/mutation_site_updateSiteGeneralDetails/README.md +1 -1
  89. catocli/parsers/mutation_sites_updateSiteGeneralDetails/README.md +1 -1
  90. catocli/parsers/query_eventsFeed/README.md +1 -1
  91. {catocli-1.0.12.dist-info → catocli-1.0.13.dist-info}/METADATA +1 -1
  92. {catocli-1.0.12.dist-info → catocli-1.0.13.dist-info}/RECORD +104 -21
  93. {catocli-1.0.12.dist-info → catocli-1.0.13.dist-info}/top_level.txt +2 -0
  94. models/mutation.site.updateSiteGeneralDetails.json +57 -0
  95. models/mutation.sites.updateSiteGeneralDetails.json +57 -0
  96. models/query.accountMetrics.json +80 -0
  97. models/query.accountSnapshot.json +40 -0
  98. models/query.auditFeed.json +60 -0
  99. models/query.events.json +240 -0
  100. models/query.eventsFeed.json +60 -0
  101. models/query.eventsTimeSeries.json +180 -0
  102. vendor/.DS_Store +0 -0
  103. {catocli-1.0.12.dist-info → catocli-1.0.13.dist-info}/LICENSE +0 -0
  104. {catocli-1.0.12.dist-info → catocli-1.0.13.dist-info}/WHEEL +0 -0
  105. {catocli-1.0.12.dist-info → catocli-1.0.13.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,228 @@
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
@@ -0,0 +1,321 @@
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"""