indico-client 7.13.0__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 (70) hide show
  1. indico/__init__.py +19 -0
  2. indico/client/__init__.py +2 -0
  3. indico/client/client.py +255 -0
  4. indico/client/request.py +229 -0
  5. indico/config/__init__.py +1 -0
  6. indico/config/config.py +71 -0
  7. indico/errors.py +59 -0
  8. indico/filters/__init__.py +344 -0
  9. indico/filters/base.py +41 -0
  10. indico/filters/field_blueprints.py +59 -0
  11. indico/filters/submission_fields.py +67 -0
  12. indico/http/__init__.py +0 -0
  13. indico/http/client.py +428 -0
  14. indico/http/retry.py +85 -0
  15. indico/http/serialization.py +183 -0
  16. indico/py.typed +0 -0
  17. indico/queries/__init__.py +16 -0
  18. indico/queries/custom_blueprint.py +143 -0
  19. indico/queries/datasets.py +605 -0
  20. indico/queries/document_report.py +76 -0
  21. indico/queries/documents.py +121 -0
  22. indico/queries/example.py +89 -0
  23. indico/queries/export.py +265 -0
  24. indico/queries/field_blueprints.py +419 -0
  25. indico/queries/forms.py +65 -0
  26. indico/queries/gallery.py +135 -0
  27. indico/queries/integration.py +138 -0
  28. indico/queries/jobs.py +114 -0
  29. indico/queries/model_export.py +195 -0
  30. indico/queries/model_groups/__init__.py +1 -0
  31. indico/queries/model_groups/metrics.py +145 -0
  32. indico/queries/model_groups/model_groups.py +340 -0
  33. indico/queries/model_import.py +130 -0
  34. indico/queries/questionnaire.py +199 -0
  35. indico/queries/storage.py +205 -0
  36. indico/queries/submission.py +666 -0
  37. indico/queries/submission_management.py +108 -0
  38. indico/queries/usermetrics.py +234 -0
  39. indico/queries/workflow.py +584 -0
  40. indico/queries/workflow_components.py +758 -0
  41. indico/queries/workflow_metrics.py +190 -0
  42. indico/types/__init__.py +16 -0
  43. indico/types/base.py +95 -0
  44. indico/types/component_blueprint.py +99 -0
  45. indico/types/custom_blueprint.py +16 -0
  46. indico/types/datafile.py +67 -0
  47. indico/types/dataset.py +252 -0
  48. indico/types/document_report.py +24 -0
  49. indico/types/export.py +44 -0
  50. indico/types/field_blueprint.py +29 -0
  51. indico/types/integration.py +52 -0
  52. indico/types/jobs.py +34 -0
  53. indico/types/model.py +62 -0
  54. indico/types/model_export.py +31 -0
  55. indico/types/model_group.py +170 -0
  56. indico/types/model_metrics.py +73 -0
  57. indico/types/output_file.py +22 -0
  58. indico/types/questionnaire.py +45 -0
  59. indico/types/submission.py +177 -0
  60. indico/types/submission_file.py +30 -0
  61. indico/types/user_metrics.py +132 -0
  62. indico/types/utils.py +37 -0
  63. indico/types/workflow.py +136 -0
  64. indico/types/workflow_metrics.py +301 -0
  65. indico/typing.py +4 -0
  66. indico_client-7.13.0.dist-info/METADATA +73 -0
  67. indico_client-7.13.0.dist-info/RECORD +70 -0
  68. indico_client-7.13.0.dist-info/WHEEL +4 -0
  69. indico_client-7.13.0.dist-info/licenses/AUTHORS +2 -0
  70. indico_client-7.13.0.dist-info/licenses/LICENSE +20 -0
indico/__init__.py ADDED
@@ -0,0 +1,19 @@
1
+ import logging
2
+
3
+ from indico.client import * # noqa: F403
4
+ from indico.client.request import * # noqa: F403
5
+
6
+ try:
7
+ from importlib.metadata import version as _get_version_stdlib
8
+
9
+ __version__ = _get_version_stdlib("indico-client")
10
+ except (ImportError, Exception):
11
+ try:
12
+ from importlib_metadata import version as _get_version
13
+
14
+ __version__ = _get_version("indico-client")
15
+ except (ImportError, Exception):
16
+ __version__ = "0.0.0"
17
+
18
+ logging.basicConfig()
19
+ Version = version = VERSION = __version__
@@ -0,0 +1,2 @@
1
+ from .client import *
2
+ from .request import *
@@ -0,0 +1,255 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ import asyncio
4
+ import time
5
+ from typing import TYPE_CHECKING, cast
6
+
7
+ import urllib3
8
+
9
+ from indico.client.request import Delay, GraphQLRequest, HTTPRequest, RequestChain
10
+ from indico.config import IndicoConfig
11
+ from indico.errors import IndicoError
12
+ from indico.http.client import AIOHTTPClient, HTTPClient
13
+
14
+ if TYPE_CHECKING: # pragma: no cover
15
+ from types import TracebackType
16
+ from typing import AsyncIterator, Iterator, Optional, Type, TypeVar, Union
17
+
18
+ from typing_extensions import Self
19
+
20
+ from indico.client.request import PagedRequest, PagedRequestV2
21
+ from indico.typing import Payload
22
+
23
+ ReturnType = TypeVar("ReturnType")
24
+
25
+
26
+ # here to avoid circular imports
27
+ class GetIPAVersion(GraphQLRequest[str]):
28
+ query = """
29
+ query getIPAVersion {
30
+ ipaVersion
31
+ }
32
+ """
33
+
34
+ def __init__(self) -> None:
35
+ super().__init__(self.query)
36
+
37
+ def process_response(self, response: "Payload") -> str:
38
+ version: str = super().parse_payload(response)["ipaVersion"]
39
+ return version
40
+
41
+
42
+ class IndicoClient:
43
+ """
44
+ The Indico GraphQL Client.
45
+
46
+ IndicoClient is the primary way to interact with the Indico Platform.
47
+
48
+ Args:
49
+ config= (IndicoConfig, optional): IndicoConfig object with environment configuration
50
+
51
+ Returns:
52
+ IndicoConfig object
53
+
54
+ Raises:
55
+ RuntimeError: If api_token_path does not exist.
56
+ """
57
+
58
+ def __init__(self, config: "Optional[IndicoConfig]" = None):
59
+ if not config:
60
+ config = IndicoConfig()
61
+
62
+ if not config.verify_ssl:
63
+ urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
64
+
65
+ self.config = config
66
+ self._http = HTTPClient(config)
67
+
68
+ def _handle_request_chain(
69
+ self,
70
+ chain: "RequestChain[ReturnType]",
71
+ ) -> "ReturnType":
72
+ response: "Optional[ReturnType]" = None
73
+
74
+ for request in chain.requests():
75
+ if isinstance(request, RequestChain):
76
+ response = self._handle_request_chain(request)
77
+ chain.previous = response
78
+ elif isinstance(request, HTTPRequest):
79
+ response = self._http.execute_request(request)
80
+ chain.previous = response
81
+ elif isinstance(request, Delay):
82
+ time.sleep(request.seconds)
83
+
84
+ if chain.result is not None:
85
+ return chain.result
86
+
87
+ return cast("ReturnType", response)
88
+
89
+ def get_ipa_version(self) -> str:
90
+ return self.call(GetIPAVersion())
91
+
92
+ def call(
93
+ self,
94
+ request: "Union[HTTPRequest[ReturnType], RequestChain[ReturnType]]",
95
+ ) -> "ReturnType":
96
+ """
97
+ Make a call to the Indico IPA Platform
98
+
99
+ Args:
100
+ request (GraphQLRequest or RequestChain): GraphQL request to send to the Indico Platform
101
+
102
+ Returns:
103
+ Response appropriate to the class of the provided request parameter. Often JSON, but not always.
104
+
105
+ Raises:
106
+ IndicoRequestError: With errors in processing the request
107
+ """
108
+
109
+ if isinstance(request, RequestChain):
110
+ return self._handle_request_chain(request)
111
+ elif isinstance(request, HTTPRequest):
112
+ return self._http.execute_request(request)
113
+ else:
114
+ raise ValueError(
115
+ "Invalid request type! Must be one of HTTPRequest or RequestChain."
116
+ )
117
+
118
+ def paginate(
119
+ self, request: "PagedRequest[ReturnType] | PagedRequestV2[ReturnType]"
120
+ ) -> "Iterator[ReturnType]":
121
+ """
122
+ Provides a generator that continues paging through responses
123
+ Available with List<> Requests that offer pagination
124
+
125
+ Example:
126
+ for s in client.paginate(ListSubmissions()):
127
+ print("Submission", s)
128
+ """
129
+ while request.has_next_page:
130
+ r = self._http.execute_request(request)
131
+ yield r
132
+
133
+
134
+ class AsyncIndicoClient:
135
+ """
136
+ The Async Indico GraphQL Client.
137
+ Notably, this client does not offer the usage of
138
+ `_disable_cookie_domain`
139
+
140
+ You must explicitly create and close this client
141
+ client = await AsyncIndicoClient(config=config).create()
142
+ # ... do stuff
143
+ await client.cleanup()
144
+
145
+ or implicitly using a `with` statement
146
+ async with AsyncIndicoClient(config=config) as client:
147
+ # ... do stuff
148
+
149
+ Args:
150
+ config= (IndicoConfig, optional): IndicoConfig object with environment configuration
151
+
152
+ Returns:
153
+ IndicoConfig object
154
+
155
+ Raises:
156
+ RuntimeError: If api_token_path does not exist.
157
+ """
158
+
159
+ def __init__(self, config: "Optional[IndicoConfig]" = None):
160
+ if not config:
161
+ config = IndicoConfig()
162
+ if not config.verify_ssl:
163
+ urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
164
+
165
+ self.config = config
166
+ self._http = AIOHTTPClient(config)
167
+ self._created: bool = False
168
+
169
+ async def __aenter__(self) -> "Self":
170
+ return await self.create()
171
+
172
+ async def __aexit__(
173
+ self,
174
+ exc_type: "Optional[Type[BaseException]]",
175
+ exc: "Optional[BaseException]",
176
+ tb: "Optional[TracebackType]",
177
+ ) -> None:
178
+ await self.cleanup()
179
+
180
+ async def create(self) -> "Self":
181
+ await self._http.get_short_lived_access_token()
182
+ self._created = True
183
+ return self
184
+
185
+ async def cleanup(self) -> None:
186
+ await self._http.request_session.close()
187
+
188
+ async def _handle_request_chain(
189
+ self,
190
+ chain: "RequestChain[ReturnType]",
191
+ ) -> "ReturnType":
192
+ response: "Optional[ReturnType]" = None
193
+
194
+ for request in chain.requests():
195
+ if isinstance(request, RequestChain):
196
+ response = await self._handle_request_chain(request)
197
+ chain.previous = response
198
+ elif isinstance(request, HTTPRequest):
199
+ response = await self._http.execute_request(request)
200
+ chain.previous = response
201
+ elif isinstance(request, Delay):
202
+ await asyncio.sleep(request.seconds)
203
+
204
+ if chain.result is not None:
205
+ return chain.result
206
+
207
+ return cast("ReturnType", response)
208
+
209
+ async def get_ipa_version(self) -> str:
210
+ return await self.call(GetIPAVersion())
211
+
212
+ async def call(
213
+ self,
214
+ request: "Union[HTTPRequest[ReturnType], RequestChain[ReturnType]]",
215
+ ) -> "ReturnType":
216
+ """
217
+ Make a call to the Indico IPA Platform
218
+
219
+ Args:
220
+ request (GraphQLRequest or RequestChain): GraphQL request to send to the Indico Platform
221
+
222
+ Returns:
223
+ Response appropriate to the class of the provided request parameter. Often JSON but not always.
224
+
225
+ Raises:
226
+ IndicoRequestError: With errors in processing the request
227
+ """
228
+ if not self._created:
229
+ raise IndicoError("Please .create() your client")
230
+
231
+ if isinstance(request, RequestChain):
232
+ return await self._handle_request_chain(request)
233
+ elif isinstance(request, HTTPRequest):
234
+ return await self._http.execute_request(request)
235
+ else:
236
+ raise ValueError(
237
+ "Invalid request type! Must be one of HTTPRequest or RequestChain."
238
+ )
239
+
240
+ async def paginate(
241
+ self, request: "PagedRequest[ReturnType]"
242
+ ) -> "AsyncIterator[ReturnType]":
243
+ """
244
+ Provides a generator that continues paging through responses
245
+ Available with List<> Requests that offer pagination
246
+
247
+ Example:
248
+ async for s in client.paginate(ListSubmissions()):
249
+ print("Submission", s)
250
+ """
251
+ if not self._created:
252
+ raise IndicoError("Please .create() your client")
253
+ while request.has_next_page:
254
+ r = await self._http.execute_request(request)
255
+ yield r
@@ -0,0 +1,229 @@
1
+ from abc import abstractmethod
2
+ from enum import Enum
3
+ from typing import TYPE_CHECKING, Generic, TypeVar, cast
4
+
5
+ from indico.errors import IndicoInputError, IndicoRequestError
6
+ from indico.typing import AnyDict
7
+
8
+ if TYPE_CHECKING: # pragma: no cover
9
+ from typing import Any, Dict, Iterator, List, Optional, Union
10
+
11
+ from indico.typing import AnyDict
12
+
13
+ ResponseType = TypeVar("ResponseType", covariant=True)
14
+
15
+
16
+ class HTTPMethod(Enum):
17
+ GET = "GET"
18
+ POST = "POST"
19
+ PUT = "PUT"
20
+ DELETE = "DELETE"
21
+ HEAD = "HEAD"
22
+ OPTIONS = "OPTIONS"
23
+
24
+
25
+ class HTTPRequest(Generic[ResponseType]):
26
+ """
27
+ A request against the configured platform host.
28
+
29
+ Args:
30
+ raw_response (bool): return the body as bytes, skipping content-type decoding,
31
+ `.json` forcing and gzip decompression. Defaults to False
32
+ """
33
+
34
+ def __init__(
35
+ self,
36
+ method: HTTPMethod,
37
+ path: str,
38
+ *,
39
+ raw_response: bool = False,
40
+ **kwargs: "Any",
41
+ ):
42
+ self.method: HTTPMethod = method
43
+ self.path: str = path
44
+ self.raw_response: bool = raw_response
45
+ self._kwargs: "AnyDict" = kwargs
46
+
47
+ @property
48
+ def kwargs(self) -> "AnyDict":
49
+ return self._kwargs
50
+
51
+ def process_response(self, response: "Any") -> "ResponseType":
52
+ return cast("ResponseType", response)
53
+
54
+
55
+ class GraphQLRequest(Generic[ResponseType], HTTPRequest[ResponseType]):
56
+ def __init__(self, query: str, variables: "Optional[AnyDict]" = None):
57
+ self.query: str = query
58
+ self.variables: "Optional[AnyDict]" = variables
59
+
60
+ super().__init__(HTTPMethod.POST, "/graph/api/graphql")
61
+
62
+ @property
63
+ def kwargs(self) -> "AnyDict":
64
+ return {"json": {"query": self.query, "variables": self.variables}}
65
+
66
+ def parse_payload(self, response: "AnyDict") -> "Any":
67
+ raw_response: "AnyDict" = cast("AnyDict", super().process_response(response))
68
+ errors: "List[AnyDict]" = raw_response.pop("errors", [])
69
+
70
+ if errors:
71
+ extras: "Dict[str, List[Any]]" = {
72
+ "locations": [error.pop("locations", None) for error in errors]
73
+ }
74
+
75
+ raise IndicoRequestError(
76
+ error="\n".join(error["message"] for error in errors),
77
+ code=400,
78
+ extras=extras,
79
+ )
80
+
81
+ return raw_response["data"]
82
+
83
+ def process_response(self, response: "AnyDict") -> "ResponseType":
84
+ raw_response = self.parse_payload(response)
85
+ # technically incorrect, but necessary for backwards compatibility
86
+ return cast("ResponseType", raw_response)
87
+
88
+
89
+ def _parse_nested_response(
90
+ response: "AnyDict", nested_keys: "List[str | int]"
91
+ ) -> "Any":
92
+ composite: "Any" = response
93
+ for key in nested_keys:
94
+ if isinstance(composite, list):
95
+ if not isinstance(key, int):
96
+ raise IndicoInputError(
97
+ f"Invalid nested key type: {type(key)}",
98
+ )
99
+ composite = composite[int(key)]
100
+ continue
101
+
102
+ if isinstance(composite, dict):
103
+ if key not in composite.keys():
104
+ raise IndicoInputError(
105
+ f"Nested key not found in response: {key}",
106
+ )
107
+ composite = composite[key]
108
+
109
+ return composite
110
+
111
+
112
+ class PagedRequest(GraphQLRequest[ResponseType]):
113
+ """
114
+ To enable pagination, query must include $after as an argument
115
+ and request pageInfo
116
+ query Name(
117
+ ...
118
+ $after: Int
119
+ ){
120
+ items(
121
+ ...
122
+ after: $after
123
+ ){
124
+ items {...}
125
+ pageInfo {
126
+ endCursor
127
+ hasNextPage
128
+ }
129
+ }
130
+ }
131
+ """
132
+
133
+ def __init__(self, query: str, variables: "Optional[AnyDict]" = None):
134
+ if variables is None:
135
+ variables = {}
136
+
137
+ variables["after"] = None
138
+ self.has_next_page = True
139
+ super().__init__(query, variables=variables)
140
+
141
+ def parse_payload(
142
+ self, response: "AnyDict", nested_keys: "Optional[List[str | int]]" = None
143
+ ) -> "Any":
144
+ raw_response: "AnyDict" = cast("AnyDict", super().parse_payload(response))
145
+ if nested_keys:
146
+ composite: "Any" = _parse_nested_response(raw_response, nested_keys)
147
+ _pg = composite.get("pageInfo")
148
+ else:
149
+ _pg = next(iter(raw_response.values())).get("pageInfo")
150
+
151
+ if not _pg:
152
+ raise ValueError("The supplied GraphQL must include 'pageInfo'.")
153
+
154
+ self.has_next_page = _pg["hasNextPage"]
155
+ cast("AnyDict", self.variables)["after"] = (
156
+ _pg["endCursor"] if self.has_next_page else None
157
+ )
158
+
159
+ return raw_response
160
+
161
+
162
+ class PagedRequestV2(GraphQLRequest[ResponseType]):
163
+ """
164
+ A new version of PagedRequest that supports pagination using cursor and total.
165
+ The GraphQL query should follow this structure:
166
+ query Name(
167
+ ...
168
+ $cursor: String
169
+ ){
170
+ items(
171
+ ...
172
+ cursor: $cursor
173
+ ){
174
+ items {...}
175
+ cursor
176
+ total
177
+ }
178
+ }
179
+ """
180
+
181
+ def __init__(self, query: str, variables: "Optional[AnyDict]" = None):
182
+ if variables is None:
183
+ variables = {}
184
+
185
+ variables["cursor"] = None
186
+ self.has_next_page = True
187
+ self.total = 0
188
+ super().__init__(query, variables=variables)
189
+
190
+ def parse_payload(
191
+ self, response: "AnyDict", nested_keys: "Optional[List[str | int]]" = None
192
+ ) -> "Any":
193
+ raw_response: "AnyDict" = cast("AnyDict", super().parse_payload(response))
194
+
195
+ if nested_keys:
196
+ composite: "Any" = _parse_nested_response(raw_response, nested_keys)
197
+ pagination_data = composite
198
+ else:
199
+ pagination_data = next(iter(raw_response.values()))
200
+
201
+ if "cursor" not in pagination_data or "total" not in pagination_data:
202
+ raise ValueError(
203
+ "The supplied GraphQL query should respond with 'cursor' and 'total' fields."
204
+ )
205
+
206
+ self.total = pagination_data["total"]
207
+ self.has_next_page = pagination_data["cursor"] is not None
208
+ cast("AnyDict", self.variables)["cursor"] = pagination_data["cursor"]
209
+
210
+ return raw_response
211
+
212
+
213
+ class RequestChain(Generic[ResponseType]):
214
+ previous: "Any" = None
215
+ result: "Optional[ResponseType]" = None
216
+
217
+ @abstractmethod
218
+ def requests(
219
+ self,
220
+ ) -> "Iterator[Union[RequestChain[Any], HTTPRequest[Any], Delay]]":
221
+ raise NotImplementedError(
222
+ "RequestChains must define an iterator for their requests;"
223
+ "otherwise, subclass GraphQLResponse instead."
224
+ )
225
+
226
+
227
+ class Delay:
228
+ def __init__(self, seconds: "Union[int, float]" = 2):
229
+ self.seconds = seconds
@@ -0,0 +1 @@
1
+ from .config import *
@@ -0,0 +1,71 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ import os
4
+ from pathlib import Path
5
+ from typing import TYPE_CHECKING
6
+
7
+ from indico.errors import IndicoInvalidConfigSetting
8
+
9
+ if TYPE_CHECKING: # pragma: no cover
10
+ from typing import Any, Optional, Tuple, Union
11
+
12
+ from indico.typing import AnyDict
13
+
14
+
15
+ class IndicoConfig:
16
+ """
17
+ Configuration for the IndicoClient.
18
+
19
+ Args:
20
+ host= (str, optional): Indico Platform hostname (eg mycluster.indico.io )
21
+ api_token_path= (str, optional): Path to the Indico API token file indico_api_token.txt. Defaults to user's home directory. Ignored if api_token is provided.
22
+ api_token= (str, optional): The actual text of the API Token. Takes precedence over api_token_path
23
+ verify_ssl= (bool, optional): Whether to verify the host's SSL certificate. Default=True
24
+ requests_params= (dict, optional): Dictionary of requests. Session parameters to set
25
+
26
+ Returns:
27
+ IndicoConfig object
28
+
29
+ Raises:
30
+ RuntimeError: If api_token_path does not exist.
31
+ """
32
+
33
+ def __init__(self, **kwargs: "Any"):
34
+ self.host: str = os.getenv("INDICO_HOST", "")
35
+ self.protocol: str = os.getenv("INDICO_PROTOCOL", "https")
36
+ self.serializer: str = os.getenv("INDICO_SERIALIZER", "msgpack")
37
+ self.api_token_path: "Union[str, Path]" = os.getenv(
38
+ "INDICO_API_TOKEN_PATH", Path.home()
39
+ )
40
+ self.api_token: "Optional[str]" = os.getenv("INDICO_API_TOKEN")
41
+ self.verify_ssl: bool = True
42
+ self.requests_params: "Optional[AnyDict]" = None
43
+ self._disable_cookie_domain: bool = False
44
+
45
+ for key, value in kwargs.items():
46
+ if hasattr(self, key):
47
+ setattr(self, key, value)
48
+ else:
49
+ raise IndicoInvalidConfigSetting(key)
50
+
51
+ if not self.api_token:
52
+ self.api_token_path, self.api_token = self._resolve_api_token()
53
+
54
+ def _resolve_api_token(self) -> "Tuple[Path, str]":
55
+ path = self.api_token_path
56
+
57
+ if not isinstance(path, Path):
58
+ path = Path(path)
59
+
60
+ if not path.exists():
61
+ path = Path.home()
62
+ if not path.is_file():
63
+ path = path / "indico_api_token.txt"
64
+
65
+ if not path.exists():
66
+ raise RuntimeError(
67
+ "Expected indico_api_token.txt in home directory, "
68
+ "or provided as indicoio.config.api_token_path"
69
+ )
70
+
71
+ return path, path.read_text().strip()
indico/errors.py ADDED
@@ -0,0 +1,59 @@
1
+ from typing import TYPE_CHECKING
2
+
3
+ if TYPE_CHECKING: # pragma: no cover
4
+ from typing import Any, Union
5
+
6
+
7
+ class IndicoError(Exception):
8
+ """Base exception for known error modes"""
9
+
10
+
11
+ class IndicoRequestError(IndicoError):
12
+ def __init__(
13
+ self,
14
+ error: str,
15
+ code: "Union[int, str]",
16
+ extras: "Any" = None,
17
+ ):
18
+ super().__init__(f"Status: {code}, Error: {error}\n\tExtras: {extras}")
19
+
20
+
21
+ class IndicoTimeoutError(IndicoError):
22
+ def __init__(self, duration: "Union[int, float]"):
23
+ super().__init__(f"Request timed out after {duration:0.3f} seconds.")
24
+
25
+
26
+ class IndicoDecodingError(IndicoError):
27
+ def __init__(self, mime: str, charset: str, content: str):
28
+ super().__init__(f"Failed to decode with {mime}:{charset}. Content {content}")
29
+
30
+
31
+ class IndicoInputError(IndicoError):
32
+ def __init__(self, msg: str):
33
+ super().__init__(msg)
34
+
35
+
36
+ class IndicoInvalidConfigSetting(IndicoError):
37
+ def __init__(
38
+ self,
39
+ setting_name: str,
40
+ ):
41
+ super().__init__(f"{setting_name} is not a valid configuration setting")
42
+
43
+
44
+ class IndicoNotFound(IndicoError):
45
+ def __init__(self, cls: str):
46
+ super().__init__(f"Could not find {cls}")
47
+
48
+
49
+ class IndicoAuthenticationFailed(IndicoError):
50
+ def __init__(self) -> None:
51
+ super().__init__("Failed to authenticate")
52
+
53
+
54
+ class IndicoHibernationError(IndicoError):
55
+ def __init__(self, after: int):
56
+ self.after: int = after
57
+ super().__init__(
58
+ f"Platform is currently hibernating. Wait {after} seconds and retry this request."
59
+ )