flatmark 1.0.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.
@@ -0,0 +1,230 @@
1
+ from __future__ import annotations
2
+
3
+ import datetime
4
+ from collections.abc import Mapping
5
+ from typing import TYPE_CHECKING, Any, TypeVar, cast
6
+
7
+ from attrs import define as _attrs_define
8
+ from attrs import field as _attrs_field
9
+
10
+ from ..types import UNSET, Unset
11
+
12
+ if TYPE_CHECKING:
13
+ from ..models.job_response_result_type_0 import JobResponseResultType0
14
+
15
+
16
+ T = TypeVar("T", bound="JobResponse")
17
+
18
+
19
+ @_attrs_define
20
+ class JobResponse:
21
+ """A job's status and result. The webhook secret is not included. The submit
22
+ response returns it once.
23
+
24
+ Attributes:
25
+ id (str): The job ID.
26
+ kind (str):
27
+ status (str):
28
+ result (JobResponseResultType0 | None | Unset):
29
+ error (None | str | Unset):
30
+ created_at (datetime.datetime | None | Unset):
31
+ started_at (datetime.datetime | None | Unset):
32
+ finished_at (datetime.datetime | None | Unset):
33
+ """
34
+
35
+ id: str
36
+ kind: str
37
+ status: str
38
+ result: JobResponseResultType0 | None | Unset = UNSET
39
+ error: None | str | Unset = UNSET
40
+ created_at: datetime.datetime | None | Unset = UNSET
41
+ started_at: datetime.datetime | None | Unset = UNSET
42
+ finished_at: datetime.datetime | None | Unset = UNSET
43
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
44
+
45
+ def to_dict(self) -> dict[str, Any]:
46
+ from ..models.job_response_result_type_0 import JobResponseResultType0 # noqa: PLC0415
47
+
48
+ id = self.id
49
+
50
+ kind = self.kind
51
+
52
+ status = self.status
53
+
54
+ result: dict[str, Any] | None | Unset
55
+ if isinstance(self.result, Unset):
56
+ result = UNSET
57
+ elif isinstance(self.result, JobResponseResultType0):
58
+ result = self.result.to_dict()
59
+ else:
60
+ result = self.result
61
+
62
+ error: None | str | Unset
63
+ if isinstance(self.error, Unset):
64
+ error = UNSET
65
+ else:
66
+ error = self.error
67
+
68
+ created_at: None | str | Unset
69
+ if isinstance(self.created_at, Unset):
70
+ created_at = UNSET
71
+ elif isinstance(self.created_at, datetime.datetime):
72
+ created_at = self.created_at.isoformat()
73
+ else:
74
+ created_at = self.created_at
75
+
76
+ started_at: None | str | Unset
77
+ if isinstance(self.started_at, Unset):
78
+ started_at = UNSET
79
+ elif isinstance(self.started_at, datetime.datetime):
80
+ started_at = self.started_at.isoformat()
81
+ else:
82
+ started_at = self.started_at
83
+
84
+ finished_at: None | str | Unset
85
+ if isinstance(self.finished_at, Unset):
86
+ finished_at = UNSET
87
+ elif isinstance(self.finished_at, datetime.datetime):
88
+ finished_at = self.finished_at.isoformat()
89
+ else:
90
+ finished_at = self.finished_at
91
+
92
+ field_dict: dict[str, Any] = {}
93
+ field_dict.update(self.additional_properties)
94
+ field_dict.update(
95
+ {
96
+ "id": id,
97
+ "kind": kind,
98
+ "status": status,
99
+ }
100
+ )
101
+ if result is not UNSET:
102
+ field_dict["result"] = result
103
+ if error is not UNSET:
104
+ field_dict["error"] = error
105
+ if created_at is not UNSET:
106
+ field_dict["created_at"] = created_at
107
+ if started_at is not UNSET:
108
+ field_dict["started_at"] = started_at
109
+ if finished_at is not UNSET:
110
+ field_dict["finished_at"] = finished_at
111
+
112
+ return field_dict
113
+
114
+ @classmethod
115
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
116
+ from ..models.job_response_result_type_0 import JobResponseResultType0 # noqa: PLC0415
117
+
118
+ d = dict(src_dict)
119
+ id = d.pop("id")
120
+
121
+ kind = d.pop("kind")
122
+
123
+ status = d.pop("status")
124
+
125
+ def _parse_result(data: object) -> JobResponseResultType0 | None | Unset:
126
+ if data is None:
127
+ return data
128
+ if isinstance(data, Unset):
129
+ return data
130
+ try:
131
+ if not isinstance(data, dict):
132
+ raise TypeError()
133
+ result_type_0 = JobResponseResultType0.from_dict(data)
134
+
135
+ return result_type_0
136
+ except (TypeError, ValueError, AttributeError, KeyError):
137
+ pass
138
+ return cast(JobResponseResultType0 | None | Unset, data)
139
+
140
+ result = _parse_result(d.pop("result", UNSET))
141
+
142
+ def _parse_error(data: object) -> None | str | Unset:
143
+ if data is None:
144
+ return data
145
+ if isinstance(data, Unset):
146
+ return data
147
+ return cast(None | str | Unset, data)
148
+
149
+ error = _parse_error(d.pop("error", UNSET))
150
+
151
+ def _parse_created_at(data: object) -> datetime.datetime | None | Unset:
152
+ if data is None:
153
+ return data
154
+ if isinstance(data, Unset):
155
+ return data
156
+ try:
157
+ if not isinstance(data, str):
158
+ raise TypeError()
159
+ created_at_type_0 = datetime.datetime.fromisoformat(data)
160
+
161
+ return created_at_type_0
162
+ except (TypeError, ValueError, AttributeError, KeyError):
163
+ pass
164
+ return cast(datetime.datetime | None | Unset, data)
165
+
166
+ created_at = _parse_created_at(d.pop("created_at", UNSET))
167
+
168
+ def _parse_started_at(data: object) -> datetime.datetime | None | Unset:
169
+ if data is None:
170
+ return data
171
+ if isinstance(data, Unset):
172
+ return data
173
+ try:
174
+ if not isinstance(data, str):
175
+ raise TypeError()
176
+ started_at_type_0 = datetime.datetime.fromisoformat(data)
177
+
178
+ return started_at_type_0
179
+ except (TypeError, ValueError, AttributeError, KeyError):
180
+ pass
181
+ return cast(datetime.datetime | None | Unset, data)
182
+
183
+ started_at = _parse_started_at(d.pop("started_at", UNSET))
184
+
185
+ def _parse_finished_at(data: object) -> datetime.datetime | None | Unset:
186
+ if data is None:
187
+ return data
188
+ if isinstance(data, Unset):
189
+ return data
190
+ try:
191
+ if not isinstance(data, str):
192
+ raise TypeError()
193
+ finished_at_type_0 = datetime.datetime.fromisoformat(data)
194
+
195
+ return finished_at_type_0
196
+ except (TypeError, ValueError, AttributeError, KeyError):
197
+ pass
198
+ return cast(datetime.datetime | None | Unset, data)
199
+
200
+ finished_at = _parse_finished_at(d.pop("finished_at", UNSET))
201
+
202
+ job_response = cls(
203
+ id=id,
204
+ kind=kind,
205
+ status=status,
206
+ result=result,
207
+ error=error,
208
+ created_at=created_at,
209
+ started_at=started_at,
210
+ finished_at=finished_at,
211
+ )
212
+
213
+ job_response.additional_properties = d
214
+ return job_response
215
+
216
+ @property
217
+ def additional_keys(self) -> list[str]:
218
+ return list(self.additional_properties.keys())
219
+
220
+ def __getitem__(self, key: str) -> Any:
221
+ return self.additional_properties[key]
222
+
223
+ def __setitem__(self, key: str, value: Any) -> None:
224
+ self.additional_properties[key] = value
225
+
226
+ def __delitem__(self, key: str) -> None:
227
+ del self.additional_properties[key]
228
+
229
+ def __contains__(self, key: str) -> bool:
230
+ return key in self.additional_properties
@@ -0,0 +1,97 @@
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Mapping
4
+ from typing import TYPE_CHECKING, Any, TypeVar, cast
5
+
6
+ from attrs import define as _attrs_define
7
+ from attrs import field as _attrs_field
8
+
9
+ from ..types import UNSET, Unset
10
+
11
+ if TYPE_CHECKING:
12
+ from ..models.job_response import JobResponse
13
+
14
+
15
+ T = TypeVar("T", bound="JobResponsePage")
16
+
17
+
18
+ @_attrs_define
19
+ class JobResponsePage:
20
+ """
21
+ Attributes:
22
+ items (list[JobResponse]):
23
+ next_cursor (None | str | Unset):
24
+ """
25
+
26
+ items: list[JobResponse]
27
+ next_cursor: None | str | Unset = UNSET
28
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
29
+
30
+ def to_dict(self) -> dict[str, Any]:
31
+ items = []
32
+ for items_item_data in self.items:
33
+ items_item = items_item_data.to_dict()
34
+ items.append(items_item)
35
+
36
+ next_cursor: None | str | Unset
37
+ if isinstance(self.next_cursor, Unset):
38
+ next_cursor = UNSET
39
+ else:
40
+ next_cursor = self.next_cursor
41
+
42
+ field_dict: dict[str, Any] = {}
43
+ field_dict.update(self.additional_properties)
44
+ field_dict.update(
45
+ {
46
+ "items": items,
47
+ }
48
+ )
49
+ if next_cursor is not UNSET:
50
+ field_dict["next_cursor"] = next_cursor
51
+
52
+ return field_dict
53
+
54
+ @classmethod
55
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
56
+ from ..models.job_response import JobResponse # noqa: PLC0415
57
+
58
+ d = dict(src_dict)
59
+ items = []
60
+ _items = d.pop("items")
61
+ for items_item_data in _items:
62
+ items_item = JobResponse.from_dict(items_item_data)
63
+
64
+ items.append(items_item)
65
+
66
+ def _parse_next_cursor(data: object) -> None | str | Unset:
67
+ if data is None:
68
+ return data
69
+ if isinstance(data, Unset):
70
+ return data
71
+ return cast(None | str | Unset, data)
72
+
73
+ next_cursor = _parse_next_cursor(d.pop("next_cursor", UNSET))
74
+
75
+ job_response_page = cls(
76
+ items=items,
77
+ next_cursor=next_cursor,
78
+ )
79
+
80
+ job_response_page.additional_properties = d
81
+ return job_response_page
82
+
83
+ @property
84
+ def additional_keys(self) -> list[str]:
85
+ return list(self.additional_properties.keys())
86
+
87
+ def __getitem__(self, key: str) -> Any:
88
+ return self.additional_properties[key]
89
+
90
+ def __setitem__(self, key: str, value: Any) -> None:
91
+ self.additional_properties[key] = value
92
+
93
+ def __delitem__(self, key: str) -> None:
94
+ del self.additional_properties[key]
95
+
96
+ def __contains__(self, key: str) -> bool:
97
+ return key in self.additional_properties
@@ -0,0 +1,45 @@
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Mapping
4
+ from typing import Any, TypeVar
5
+
6
+ from attrs import define as _attrs_define
7
+ from attrs import field as _attrs_field
8
+
9
+ T = TypeVar("T", bound="JobResponseResultType0")
10
+
11
+
12
+ @_attrs_define
13
+ class JobResponseResultType0:
14
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
15
+
16
+ def to_dict(self) -> dict[str, Any]:
17
+
18
+ field_dict: dict[str, Any] = {}
19
+ field_dict.update(self.additional_properties)
20
+
21
+ return field_dict
22
+
23
+ @classmethod
24
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
25
+ d = dict(src_dict)
26
+ job_response_result_type_0 = cls()
27
+
28
+ job_response_result_type_0.additional_properties = d
29
+ return job_response_result_type_0
30
+
31
+ @property
32
+ def additional_keys(self) -> list[str]:
33
+ return list(self.additional_properties.keys())
34
+
35
+ def __getitem__(self, key: str) -> Any:
36
+ return self.additional_properties[key]
37
+
38
+ def __setitem__(self, key: str, value: Any) -> None:
39
+ self.additional_properties[key] = value
40
+
41
+ def __delitem__(self, key: str) -> None:
42
+ del self.additional_properties[key]
43
+
44
+ def __contains__(self, key: str) -> bool:
45
+ return key in self.additional_properties
@@ -0,0 +1,109 @@
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Mapping
4
+ from typing import Any, TypeVar, cast
5
+
6
+ from attrs import define as _attrs_define
7
+ from attrs import field as _attrs_field
8
+
9
+ from ..types import UNSET, Unset
10
+
11
+ T = TypeVar("T", bound="JobSubmitResponse")
12
+
13
+
14
+ @_attrs_define
15
+ class JobSubmitResponse:
16
+ """A queued conversion job.
17
+
18
+ Attributes:
19
+ job_id (str): The job id.
20
+ status (str): `queued` at submission.
21
+ result_url (str): Where to download the result once the job succeeded.
22
+ poll_url (str): Where to check the job's status.
23
+ webhook_secret (None | str | Unset): The key for checking the webhook signature. Only set when you sent
24
+ `webhook_url`, and only shown in this response.
25
+ """
26
+
27
+ job_id: str
28
+ status: str
29
+ result_url: str
30
+ poll_url: str
31
+ webhook_secret: None | str | Unset = UNSET
32
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
33
+
34
+ def to_dict(self) -> dict[str, Any]:
35
+ job_id = self.job_id
36
+
37
+ status = self.status
38
+
39
+ result_url = self.result_url
40
+
41
+ poll_url = self.poll_url
42
+
43
+ webhook_secret: None | str | Unset
44
+ if isinstance(self.webhook_secret, Unset):
45
+ webhook_secret = UNSET
46
+ else:
47
+ webhook_secret = self.webhook_secret
48
+
49
+ field_dict: dict[str, Any] = {}
50
+ field_dict.update(self.additional_properties)
51
+ field_dict.update(
52
+ {
53
+ "job_id": job_id,
54
+ "status": status,
55
+ "result_url": result_url,
56
+ "poll_url": poll_url,
57
+ }
58
+ )
59
+ if webhook_secret is not UNSET:
60
+ field_dict["webhook_secret"] = webhook_secret
61
+
62
+ return field_dict
63
+
64
+ @classmethod
65
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
66
+ d = dict(src_dict)
67
+ job_id = d.pop("job_id")
68
+
69
+ status = d.pop("status")
70
+
71
+ result_url = d.pop("result_url")
72
+
73
+ poll_url = d.pop("poll_url")
74
+
75
+ def _parse_webhook_secret(data: object) -> None | str | Unset:
76
+ if data is None:
77
+ return data
78
+ if isinstance(data, Unset):
79
+ return data
80
+ return cast(None | str | Unset, data)
81
+
82
+ webhook_secret = _parse_webhook_secret(d.pop("webhook_secret", UNSET))
83
+
84
+ job_submit_response = cls(
85
+ job_id=job_id,
86
+ status=status,
87
+ result_url=result_url,
88
+ poll_url=poll_url,
89
+ webhook_secret=webhook_secret,
90
+ )
91
+
92
+ job_submit_response.additional_properties = d
93
+ return job_submit_response
94
+
95
+ @property
96
+ def additional_keys(self) -> list[str]:
97
+ return list(self.additional_properties.keys())
98
+
99
+ def __getitem__(self, key: str) -> Any:
100
+ return self.additional_properties[key]
101
+
102
+ def __setitem__(self, key: str, value: Any) -> None:
103
+ self.additional_properties[key] = value
104
+
105
+ def __delitem__(self, key: str) -> None:
106
+ del self.additional_properties[key]
107
+
108
+ def __contains__(self, key: str) -> bool:
109
+ return key in self.additional_properties
@@ -0,0 +1,135 @@
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Mapping
4
+ from typing import TYPE_CHECKING, Any, TypeVar, cast
5
+
6
+ from attrs import define as _attrs_define
7
+ from attrs import field as _attrs_field
8
+
9
+ from ..types import UNSET, Unset
10
+
11
+ if TYPE_CHECKING:
12
+ from ..models.credits_info import CreditsInfo
13
+ from ..models.rate_limit_info import RateLimitInfo
14
+
15
+
16
+ T = TypeVar("T", bound="MeResponse")
17
+
18
+
19
+ @_attrs_define
20
+ class MeResponse:
21
+ """The `GET /v1/me` payload: who the request is authenticated as, what is
22
+ left of your request and credit allowances, and which features your plan
23
+ includes.
24
+
25
+ Attributes:
26
+ tier (str): The plan this request is served on.
27
+ is_keyed (bool): Whether the request carried a valid API key. Without an `X-API-Key`, the call runs anonymously
28
+ at the rate limit for calls without a key.
29
+ rate_limit (RateLimitInfo): How many requests you may still make in the current window. These are the
30
+ same numbers as the `X-RateLimit-*` response headers. `limit` is the size of the
31
+ window, `remaining` what is left of it, and `reset` how many seconds until
32
+ it refills (not a timestamp). All three are `null` in the rare case the
33
+ counter cannot be read; treat that as "unknown", not zero.
34
+ features (list[str]): The features your plan includes.
35
+ credits_ (CreditsInfo | None | Unset): Null on plans that are not priced in credits.
36
+ """
37
+
38
+ tier: str
39
+ is_keyed: bool
40
+ rate_limit: RateLimitInfo
41
+ features: list[str]
42
+ credits_: CreditsInfo | None | Unset = UNSET
43
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
44
+
45
+ def to_dict(self) -> dict[str, Any]:
46
+ from ..models.credits_info import CreditsInfo # noqa: PLC0415
47
+
48
+ tier = self.tier
49
+
50
+ is_keyed = self.is_keyed
51
+
52
+ rate_limit = self.rate_limit.to_dict()
53
+
54
+ features = self.features
55
+
56
+ credits_: dict[str, Any] | None | Unset
57
+ if isinstance(self.credits_, Unset):
58
+ credits_ = UNSET
59
+ elif isinstance(self.credits_, CreditsInfo):
60
+ credits_ = self.credits_.to_dict()
61
+ else:
62
+ credits_ = self.credits_
63
+
64
+ field_dict: dict[str, Any] = {}
65
+ field_dict.update(self.additional_properties)
66
+ field_dict.update(
67
+ {
68
+ "tier": tier,
69
+ "is_keyed": is_keyed,
70
+ "rate_limit": rate_limit,
71
+ "features": features,
72
+ }
73
+ )
74
+ if credits_ is not UNSET:
75
+ field_dict["credits"] = credits_
76
+
77
+ return field_dict
78
+
79
+ @classmethod
80
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
81
+ from ..models.credits_info import CreditsInfo # noqa: PLC0415
82
+ from ..models.rate_limit_info import RateLimitInfo # noqa: PLC0415
83
+
84
+ d = dict(src_dict)
85
+ tier = d.pop("tier")
86
+
87
+ is_keyed = d.pop("is_keyed")
88
+
89
+ rate_limit = RateLimitInfo.from_dict(d.pop("rate_limit"))
90
+
91
+ features = cast(list[str], d.pop("features"))
92
+
93
+ def _parse_credits_(data: object) -> CreditsInfo | None | Unset:
94
+ if data is None:
95
+ return data
96
+ if isinstance(data, Unset):
97
+ return data
98
+ try:
99
+ if not isinstance(data, dict):
100
+ raise TypeError()
101
+ credits_type_0 = CreditsInfo.from_dict(data)
102
+
103
+ return credits_type_0
104
+ except (TypeError, ValueError, AttributeError, KeyError):
105
+ pass
106
+ return cast(CreditsInfo | None | Unset, data)
107
+
108
+ credits_ = _parse_credits_(d.pop("credits", UNSET))
109
+
110
+ me_response = cls(
111
+ tier=tier,
112
+ is_keyed=is_keyed,
113
+ rate_limit=rate_limit,
114
+ features=features,
115
+ credits_=credits_,
116
+ )
117
+
118
+ me_response.additional_properties = d
119
+ return me_response
120
+
121
+ @property
122
+ def additional_keys(self) -> list[str]:
123
+ return list(self.additional_properties.keys())
124
+
125
+ def __getitem__(self, key: str) -> Any:
126
+ return self.additional_properties[key]
127
+
128
+ def __setitem__(self, key: str, value: Any) -> None:
129
+ self.additional_properties[key] = value
130
+
131
+ def __delitem__(self, key: str) -> None:
132
+ del self.additional_properties[key]
133
+
134
+ def __contains__(self, key: str) -> bool:
135
+ return key in self.additional_properties