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.
- flatmark/__init__.py +8 -0
- flatmark/api/__init__.py +1 -0
- flatmark/api/account/__init__.py +1 -0
- flatmark/api/account/get_me.py +176 -0
- flatmark/api/convert/__init__.py +1 -0
- flatmark/api/convert/convert_document.py +253 -0
- flatmark/api/convert/get_conversion_result.py +237 -0
- flatmark/api/convert/submit_conversion_job.py +284 -0
- flatmark/api/jobs/__init__.py +1 -0
- flatmark/api/jobs/get_job.py +189 -0
- flatmark/api/jobs/list_jobs.py +211 -0
- flatmark/client.py +268 -0
- flatmark/errors.py +16 -0
- flatmark/models/__init__.py +33 -0
- flatmark/models/body_convert_document.py +75 -0
- flatmark/models/body_submit_conversion_job.py +102 -0
- flatmark/models/credits_info.py +95 -0
- flatmark/models/get_conversion_result_format.py +9 -0
- flatmark/models/job_response.py +230 -0
- flatmark/models/job_response_page.py +97 -0
- flatmark/models/job_response_result_type_0.py +45 -0
- flatmark/models/job_submit_response.py +109 -0
- flatmark/models/me_response.py +135 -0
- flatmark/models/problem.py +190 -0
- flatmark/models/problem_errors_type_0_item.py +45 -0
- flatmark/models/rate_limit_info.py +118 -0
- flatmark/models/sync_convert_response.py +87 -0
- flatmark/models/sync_convert_response_meta.py +47 -0
- flatmark/py.typed +1 -0
- flatmark/types.py +54 -0
- flatmark-1.0.0.dist-info/METADATA +50 -0
- flatmark-1.0.0.dist-info/RECORD +33 -0
- flatmark-1.0.0.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,190 @@
|
|
|
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.problem_errors_type_0_item import ProblemErrorsType0Item
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
T = TypeVar("T", bound="Problem")
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@_attrs_define
|
|
19
|
+
class Problem:
|
|
20
|
+
"""The RFC 9457 error body. Every error response uses it.
|
|
21
|
+
|
|
22
|
+
Attributes:
|
|
23
|
+
title (str): Short human-readable summary of the status.
|
|
24
|
+
status (int): The HTTP status code, repeated in the body.
|
|
25
|
+
detail (str): What went wrong with this request.
|
|
26
|
+
instance (str): The request path that produced the error.
|
|
27
|
+
code (str): Stable machine-readable error code. Branch on this, not on the text.
|
|
28
|
+
type_ (str | Unset): Problem type URI (RFC 9457). Default: 'about:blank'.
|
|
29
|
+
request_id (None | str | Unset): Correlation id for this request; quote it when asking for support.
|
|
30
|
+
errors (list[ProblemErrorsType0Item] | None | Unset): Per-field validation failures. Present on 422 only.
|
|
31
|
+
upgrade_url (None | str | Unset): Where to add credits or move to a larger plan. Present on 402/403/429.
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
title: str
|
|
35
|
+
status: int
|
|
36
|
+
detail: str
|
|
37
|
+
instance: str
|
|
38
|
+
code: str
|
|
39
|
+
type_: str | Unset = "about:blank"
|
|
40
|
+
request_id: None | str | Unset = UNSET
|
|
41
|
+
errors: list[ProblemErrorsType0Item] | None | Unset = UNSET
|
|
42
|
+
upgrade_url: None | str | Unset = UNSET
|
|
43
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
44
|
+
|
|
45
|
+
def to_dict(self) -> dict[str, Any]:
|
|
46
|
+
title = self.title
|
|
47
|
+
|
|
48
|
+
status = self.status
|
|
49
|
+
|
|
50
|
+
detail = self.detail
|
|
51
|
+
|
|
52
|
+
instance = self.instance
|
|
53
|
+
|
|
54
|
+
code = self.code
|
|
55
|
+
|
|
56
|
+
type_ = self.type_
|
|
57
|
+
|
|
58
|
+
request_id: None | str | Unset
|
|
59
|
+
if isinstance(self.request_id, Unset):
|
|
60
|
+
request_id = UNSET
|
|
61
|
+
else:
|
|
62
|
+
request_id = self.request_id
|
|
63
|
+
|
|
64
|
+
errors: list[dict[str, Any]] | None | Unset
|
|
65
|
+
if isinstance(self.errors, Unset):
|
|
66
|
+
errors = UNSET
|
|
67
|
+
elif isinstance(self.errors, list):
|
|
68
|
+
errors = []
|
|
69
|
+
for errors_type_0_item_data in self.errors:
|
|
70
|
+
errors_type_0_item = errors_type_0_item_data.to_dict()
|
|
71
|
+
errors.append(errors_type_0_item)
|
|
72
|
+
|
|
73
|
+
else:
|
|
74
|
+
errors = self.errors
|
|
75
|
+
|
|
76
|
+
upgrade_url: None | str | Unset
|
|
77
|
+
if isinstance(self.upgrade_url, Unset):
|
|
78
|
+
upgrade_url = UNSET
|
|
79
|
+
else:
|
|
80
|
+
upgrade_url = self.upgrade_url
|
|
81
|
+
|
|
82
|
+
field_dict: dict[str, Any] = {}
|
|
83
|
+
field_dict.update(self.additional_properties)
|
|
84
|
+
field_dict.update(
|
|
85
|
+
{
|
|
86
|
+
"title": title,
|
|
87
|
+
"status": status,
|
|
88
|
+
"detail": detail,
|
|
89
|
+
"instance": instance,
|
|
90
|
+
"code": code,
|
|
91
|
+
}
|
|
92
|
+
)
|
|
93
|
+
if type_ is not UNSET:
|
|
94
|
+
field_dict["type"] = type_
|
|
95
|
+
if request_id is not UNSET:
|
|
96
|
+
field_dict["request_id"] = request_id
|
|
97
|
+
if errors is not UNSET:
|
|
98
|
+
field_dict["errors"] = errors
|
|
99
|
+
if upgrade_url is not UNSET:
|
|
100
|
+
field_dict["upgrade_url"] = upgrade_url
|
|
101
|
+
|
|
102
|
+
return field_dict
|
|
103
|
+
|
|
104
|
+
@classmethod
|
|
105
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
106
|
+
from ..models.problem_errors_type_0_item import ProblemErrorsType0Item # noqa: PLC0415
|
|
107
|
+
|
|
108
|
+
d = dict(src_dict)
|
|
109
|
+
title = d.pop("title")
|
|
110
|
+
|
|
111
|
+
status = d.pop("status")
|
|
112
|
+
|
|
113
|
+
detail = d.pop("detail")
|
|
114
|
+
|
|
115
|
+
instance = d.pop("instance")
|
|
116
|
+
|
|
117
|
+
code = d.pop("code")
|
|
118
|
+
|
|
119
|
+
type_ = d.pop("type", UNSET)
|
|
120
|
+
|
|
121
|
+
def _parse_request_id(data: object) -> None | str | Unset:
|
|
122
|
+
if data is None:
|
|
123
|
+
return data
|
|
124
|
+
if isinstance(data, Unset):
|
|
125
|
+
return data
|
|
126
|
+
return cast(None | str | Unset, data)
|
|
127
|
+
|
|
128
|
+
request_id = _parse_request_id(d.pop("request_id", UNSET))
|
|
129
|
+
|
|
130
|
+
def _parse_errors(data: object) -> list[ProblemErrorsType0Item] | None | Unset:
|
|
131
|
+
if data is None:
|
|
132
|
+
return data
|
|
133
|
+
if isinstance(data, Unset):
|
|
134
|
+
return data
|
|
135
|
+
try:
|
|
136
|
+
if not isinstance(data, list):
|
|
137
|
+
raise TypeError()
|
|
138
|
+
errors_type_0 = []
|
|
139
|
+
_errors_type_0 = data
|
|
140
|
+
for errors_type_0_item_data in _errors_type_0:
|
|
141
|
+
errors_type_0_item = ProblemErrorsType0Item.from_dict(errors_type_0_item_data)
|
|
142
|
+
|
|
143
|
+
errors_type_0.append(errors_type_0_item)
|
|
144
|
+
|
|
145
|
+
return errors_type_0
|
|
146
|
+
except (TypeError, ValueError, AttributeError, KeyError):
|
|
147
|
+
pass
|
|
148
|
+
return cast(list[ProblemErrorsType0Item] | None | Unset, data)
|
|
149
|
+
|
|
150
|
+
errors = _parse_errors(d.pop("errors", UNSET))
|
|
151
|
+
|
|
152
|
+
def _parse_upgrade_url(data: object) -> None | str | Unset:
|
|
153
|
+
if data is None:
|
|
154
|
+
return data
|
|
155
|
+
if isinstance(data, Unset):
|
|
156
|
+
return data
|
|
157
|
+
return cast(None | str | Unset, data)
|
|
158
|
+
|
|
159
|
+
upgrade_url = _parse_upgrade_url(d.pop("upgrade_url", UNSET))
|
|
160
|
+
|
|
161
|
+
problem = cls(
|
|
162
|
+
title=title,
|
|
163
|
+
status=status,
|
|
164
|
+
detail=detail,
|
|
165
|
+
instance=instance,
|
|
166
|
+
code=code,
|
|
167
|
+
type_=type_,
|
|
168
|
+
request_id=request_id,
|
|
169
|
+
errors=errors,
|
|
170
|
+
upgrade_url=upgrade_url,
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
problem.additional_properties = d
|
|
174
|
+
return problem
|
|
175
|
+
|
|
176
|
+
@property
|
|
177
|
+
def additional_keys(self) -> list[str]:
|
|
178
|
+
return list(self.additional_properties.keys())
|
|
179
|
+
|
|
180
|
+
def __getitem__(self, key: str) -> Any:
|
|
181
|
+
return self.additional_properties[key]
|
|
182
|
+
|
|
183
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
184
|
+
self.additional_properties[key] = value
|
|
185
|
+
|
|
186
|
+
def __delitem__(self, key: str) -> None:
|
|
187
|
+
del self.additional_properties[key]
|
|
188
|
+
|
|
189
|
+
def __contains__(self, key: str) -> bool:
|
|
190
|
+
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="ProblemErrorsType0Item")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@_attrs_define
|
|
13
|
+
class ProblemErrorsType0Item:
|
|
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
|
+
problem_errors_type_0_item = cls()
|
|
27
|
+
|
|
28
|
+
problem_errors_type_0_item.additional_properties = d
|
|
29
|
+
return problem_errors_type_0_item
|
|
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,118 @@
|
|
|
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="RateLimitInfo")
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@_attrs_define
|
|
15
|
+
class RateLimitInfo:
|
|
16
|
+
"""How many requests you may still make in the current window. These are the
|
|
17
|
+
same numbers as the `X-RateLimit-*` response headers. `limit` is the size of the
|
|
18
|
+
window, `remaining` what is left of it, and `reset` how many seconds until
|
|
19
|
+
it refills (not a timestamp). All three are `null` in the rare case the
|
|
20
|
+
counter cannot be read; treat that as "unknown", not zero.
|
|
21
|
+
|
|
22
|
+
Attributes:
|
|
23
|
+
limit (int | None | Unset):
|
|
24
|
+
remaining (int | None | Unset):
|
|
25
|
+
reset (int | None | Unset):
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
limit: int | None | Unset = UNSET
|
|
29
|
+
remaining: int | None | Unset = UNSET
|
|
30
|
+
reset: int | None | Unset = UNSET
|
|
31
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
32
|
+
|
|
33
|
+
def to_dict(self) -> dict[str, Any]:
|
|
34
|
+
limit: int | None | Unset
|
|
35
|
+
if isinstance(self.limit, Unset):
|
|
36
|
+
limit = UNSET
|
|
37
|
+
else:
|
|
38
|
+
limit = self.limit
|
|
39
|
+
|
|
40
|
+
remaining: int | None | Unset
|
|
41
|
+
if isinstance(self.remaining, Unset):
|
|
42
|
+
remaining = UNSET
|
|
43
|
+
else:
|
|
44
|
+
remaining = self.remaining
|
|
45
|
+
|
|
46
|
+
reset: int | None | Unset
|
|
47
|
+
if isinstance(self.reset, Unset):
|
|
48
|
+
reset = UNSET
|
|
49
|
+
else:
|
|
50
|
+
reset = self.reset
|
|
51
|
+
|
|
52
|
+
field_dict: dict[str, Any] = {}
|
|
53
|
+
field_dict.update(self.additional_properties)
|
|
54
|
+
field_dict.update({})
|
|
55
|
+
if limit is not UNSET:
|
|
56
|
+
field_dict["limit"] = limit
|
|
57
|
+
if remaining is not UNSET:
|
|
58
|
+
field_dict["remaining"] = remaining
|
|
59
|
+
if reset is not UNSET:
|
|
60
|
+
field_dict["reset"] = reset
|
|
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
|
+
|
|
68
|
+
def _parse_limit(data: object) -> int | None | Unset:
|
|
69
|
+
if data is None:
|
|
70
|
+
return data
|
|
71
|
+
if isinstance(data, Unset):
|
|
72
|
+
return data
|
|
73
|
+
return cast(int | None | Unset, data)
|
|
74
|
+
|
|
75
|
+
limit = _parse_limit(d.pop("limit", UNSET))
|
|
76
|
+
|
|
77
|
+
def _parse_remaining(data: object) -> int | None | Unset:
|
|
78
|
+
if data is None:
|
|
79
|
+
return data
|
|
80
|
+
if isinstance(data, Unset):
|
|
81
|
+
return data
|
|
82
|
+
return cast(int | None | Unset, data)
|
|
83
|
+
|
|
84
|
+
remaining = _parse_remaining(d.pop("remaining", UNSET))
|
|
85
|
+
|
|
86
|
+
def _parse_reset(data: object) -> int | None | Unset:
|
|
87
|
+
if data is None:
|
|
88
|
+
return data
|
|
89
|
+
if isinstance(data, Unset):
|
|
90
|
+
return data
|
|
91
|
+
return cast(int | None | Unset, data)
|
|
92
|
+
|
|
93
|
+
reset = _parse_reset(d.pop("reset", UNSET))
|
|
94
|
+
|
|
95
|
+
rate_limit_info = cls(
|
|
96
|
+
limit=limit,
|
|
97
|
+
remaining=remaining,
|
|
98
|
+
reset=reset,
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
rate_limit_info.additional_properties = d
|
|
102
|
+
return rate_limit_info
|
|
103
|
+
|
|
104
|
+
@property
|
|
105
|
+
def additional_keys(self) -> list[str]:
|
|
106
|
+
return list(self.additional_properties.keys())
|
|
107
|
+
|
|
108
|
+
def __getitem__(self, key: str) -> Any:
|
|
109
|
+
return self.additional_properties[key]
|
|
110
|
+
|
|
111
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
112
|
+
self.additional_properties[key] = value
|
|
113
|
+
|
|
114
|
+
def __delitem__(self, key: str) -> None:
|
|
115
|
+
del self.additional_properties[key]
|
|
116
|
+
|
|
117
|
+
def __contains__(self, key: str) -> bool:
|
|
118
|
+
return key in self.additional_properties
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from collections.abc import Mapping
|
|
4
|
+
from typing import TYPE_CHECKING, Any, TypeVar
|
|
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.sync_convert_response_meta import SyncConvertResponseMeta
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
T = TypeVar("T", bound="SyncConvertResponse")
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@_attrs_define
|
|
19
|
+
class SyncConvertResponse:
|
|
20
|
+
"""The result of a direct conversion.
|
|
21
|
+
|
|
22
|
+
Attributes:
|
|
23
|
+
markdown (str): The document as Markdown.
|
|
24
|
+
meta (SyncConvertResponseMeta | Unset): Details about the source: `filename`, and `title` when the document has
|
|
25
|
+
one.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
markdown: str
|
|
29
|
+
meta: SyncConvertResponseMeta | Unset = UNSET
|
|
30
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
31
|
+
|
|
32
|
+
def to_dict(self) -> dict[str, Any]:
|
|
33
|
+
markdown = self.markdown
|
|
34
|
+
|
|
35
|
+
meta: dict[str, Any] | Unset = UNSET
|
|
36
|
+
if not isinstance(self.meta, Unset):
|
|
37
|
+
meta = self.meta.to_dict()
|
|
38
|
+
|
|
39
|
+
field_dict: dict[str, Any] = {}
|
|
40
|
+
field_dict.update(self.additional_properties)
|
|
41
|
+
field_dict.update(
|
|
42
|
+
{
|
|
43
|
+
"markdown": markdown,
|
|
44
|
+
}
|
|
45
|
+
)
|
|
46
|
+
if meta is not UNSET:
|
|
47
|
+
field_dict["meta"] = meta
|
|
48
|
+
|
|
49
|
+
return field_dict
|
|
50
|
+
|
|
51
|
+
@classmethod
|
|
52
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
53
|
+
from ..models.sync_convert_response_meta import SyncConvertResponseMeta # noqa: PLC0415
|
|
54
|
+
|
|
55
|
+
d = dict(src_dict)
|
|
56
|
+
markdown = d.pop("markdown")
|
|
57
|
+
|
|
58
|
+
_meta = d.pop("meta", UNSET)
|
|
59
|
+
meta: SyncConvertResponseMeta | Unset
|
|
60
|
+
if isinstance(_meta, Unset):
|
|
61
|
+
meta = UNSET
|
|
62
|
+
else:
|
|
63
|
+
meta = SyncConvertResponseMeta.from_dict(_meta)
|
|
64
|
+
|
|
65
|
+
sync_convert_response = cls(
|
|
66
|
+
markdown=markdown,
|
|
67
|
+
meta=meta,
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
sync_convert_response.additional_properties = d
|
|
71
|
+
return sync_convert_response
|
|
72
|
+
|
|
73
|
+
@property
|
|
74
|
+
def additional_keys(self) -> list[str]:
|
|
75
|
+
return list(self.additional_properties.keys())
|
|
76
|
+
|
|
77
|
+
def __getitem__(self, key: str) -> Any:
|
|
78
|
+
return self.additional_properties[key]
|
|
79
|
+
|
|
80
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
81
|
+
self.additional_properties[key] = value
|
|
82
|
+
|
|
83
|
+
def __delitem__(self, key: str) -> None:
|
|
84
|
+
del self.additional_properties[key]
|
|
85
|
+
|
|
86
|
+
def __contains__(self, key: str) -> bool:
|
|
87
|
+
return key in self.additional_properties
|
|
@@ -0,0 +1,47 @@
|
|
|
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="SyncConvertResponseMeta")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@_attrs_define
|
|
13
|
+
class SyncConvertResponseMeta:
|
|
14
|
+
"""Details about the source: `filename`, and `title` when the document has one."""
|
|
15
|
+
|
|
16
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
17
|
+
|
|
18
|
+
def to_dict(self) -> dict[str, Any]:
|
|
19
|
+
|
|
20
|
+
field_dict: dict[str, Any] = {}
|
|
21
|
+
field_dict.update(self.additional_properties)
|
|
22
|
+
|
|
23
|
+
return field_dict
|
|
24
|
+
|
|
25
|
+
@classmethod
|
|
26
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
27
|
+
d = dict(src_dict)
|
|
28
|
+
sync_convert_response_meta = cls()
|
|
29
|
+
|
|
30
|
+
sync_convert_response_meta.additional_properties = d
|
|
31
|
+
return sync_convert_response_meta
|
|
32
|
+
|
|
33
|
+
@property
|
|
34
|
+
def additional_keys(self) -> list[str]:
|
|
35
|
+
return list(self.additional_properties.keys())
|
|
36
|
+
|
|
37
|
+
def __getitem__(self, key: str) -> Any:
|
|
38
|
+
return self.additional_properties[key]
|
|
39
|
+
|
|
40
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
41
|
+
self.additional_properties[key] = value
|
|
42
|
+
|
|
43
|
+
def __delitem__(self, key: str) -> None:
|
|
44
|
+
del self.additional_properties[key]
|
|
45
|
+
|
|
46
|
+
def __contains__(self, key: str) -> bool:
|
|
47
|
+
return key in self.additional_properties
|
flatmark/py.typed
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Marker file for PEP 561
|
flatmark/types.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"""Contains some shared types for properties"""
|
|
2
|
+
|
|
3
|
+
from collections.abc import Mapping, MutableMapping
|
|
4
|
+
from http import HTTPStatus
|
|
5
|
+
from typing import IO, BinaryIO, Generic, Literal, TypeVar
|
|
6
|
+
|
|
7
|
+
from attrs import define
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Unset:
|
|
11
|
+
def __bool__(self) -> Literal[False]:
|
|
12
|
+
return False
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
UNSET: Unset = Unset()
|
|
16
|
+
|
|
17
|
+
# The types that `httpx.Client(files=)` can accept, copied from that library.
|
|
18
|
+
FileContent = IO[bytes] | bytes | str
|
|
19
|
+
FileTypes = (
|
|
20
|
+
# (filename, file (or bytes), content_type)
|
|
21
|
+
tuple[str | None, FileContent, str | None]
|
|
22
|
+
# (filename, file (or bytes), content_type, headers)
|
|
23
|
+
| tuple[str | None, FileContent, str | None, Mapping[str, str]]
|
|
24
|
+
)
|
|
25
|
+
RequestFiles = list[tuple[str, FileTypes]]
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@define
|
|
29
|
+
class File:
|
|
30
|
+
"""Contains information for file uploads"""
|
|
31
|
+
|
|
32
|
+
payload: BinaryIO
|
|
33
|
+
file_name: str | None = None
|
|
34
|
+
mime_type: str | None = None
|
|
35
|
+
|
|
36
|
+
def to_tuple(self) -> FileTypes:
|
|
37
|
+
"""Return a tuple representation that httpx will accept for multipart/form-data"""
|
|
38
|
+
return self.file_name, self.payload, self.mime_type
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
T = TypeVar("T")
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
@define
|
|
45
|
+
class Response(Generic[T]):
|
|
46
|
+
"""A response from an endpoint"""
|
|
47
|
+
|
|
48
|
+
status_code: HTTPStatus
|
|
49
|
+
content: bytes
|
|
50
|
+
headers: MutableMapping[str, str]
|
|
51
|
+
parsed: T | None
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
__all__ = ["UNSET", "File", "FileTypes", "RequestFiles", "Response", "Unset"]
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: flatmark
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: A client library for accessing flatmark
|
|
5
|
+
Requires-Dist: httpx>=0.23.1,<0.29.0
|
|
6
|
+
Requires-Dist: attrs>=22.2.0
|
|
7
|
+
Requires-Python: >=3.11
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
|
|
10
|
+
# flatmark — Python SDK
|
|
11
|
+
|
|
12
|
+
Document to Markdown API and MCP server for PDF, Word, PowerPoint, Excel and HTML. OCR queue for large files. Hosted in Germany.
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
pip install flatmark
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
[Get an API key](https://flatmark.dev/go/pypi-sdk?to=/app/api-keys) and pass it to the client:
|
|
19
|
+
|
|
20
|
+
```python
|
|
21
|
+
import os
|
|
22
|
+
|
|
23
|
+
from flatmark import AuthenticatedClient
|
|
24
|
+
from flatmark.api.account import get_me
|
|
25
|
+
|
|
26
|
+
client = AuthenticatedClient(
|
|
27
|
+
base_url="https://api.flatmark.dev",
|
|
28
|
+
token=os.environ["FLATMARK_API_KEY"],
|
|
29
|
+
auth_header_name="X-API-Key",
|
|
30
|
+
prefix="",
|
|
31
|
+
)
|
|
32
|
+
print(get_me.sync(client=client))
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Every operation is a module with `sync`, `sync_detailed`, `asyncio` and `asyncio_detailed`; file fields take a `flatmark.types.File(payload=..., file_name=..., mime_type=...)`.
|
|
36
|
+
|
|
37
|
+
`submit_conversion_job` queues a job: poll `get_job` until its `status` is `succeeded` or `failed`, then fetch `get_conversion_result`.
|
|
38
|
+
|
|
39
|
+
## Operations
|
|
40
|
+
|
|
41
|
+
| Operation | Module | What it does |
|
|
42
|
+
|---|---|---|
|
|
43
|
+
| `GET /v1/me` | `flatmark.api.account.get_me` | Your plan, remaining requests, and remaining credits |
|
|
44
|
+
| `GET /v1/jobs/{job_id}` | `flatmark.api.jobs.get_job` | Get one queued job by ID |
|
|
45
|
+
| `GET /v1/jobs` | `flatmark.api.jobs.list_jobs` | List your queued jobs, newest first |
|
|
46
|
+
| `POST /v1/convert` | `flatmark.api.convert.convert_document` | Convert a document to Markdown in one call |
|
|
47
|
+
| `POST /v1/convert/jobs` | `flatmark.api.convert.submit_conversion_job` | Queue a document for conversion with OCR and tables |
|
|
48
|
+
| `GET /v1/convert/jobs/{job_id}/result` | `flatmark.api.convert.get_conversion_result` | Download a queued job's Markdown or JSON |
|
|
49
|
+
|
|
50
|
+
Generated with openapi-python-client from [`openapi.sdk.json`](../openapi.sdk.json). API reference: https://flatmark.dev/docs · Support: https://flatmark.dev/support
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
flatmark/__init__.py,sha256=VBx6tksa3kON7SQ2NU2DOOX_8J7Bj5B_B-678ZJl8Zw,151
|
|
2
|
+
flatmark/api/__init__.py,sha256=zTSiG_ujSjAqWPyc435YXaX9XTlpMjiJWBbV-f-YtdA,45
|
|
3
|
+
flatmark/api/account/__init__.py,sha256=5vd9uJWAjRqa9xzxzYkLD1yoZ12Ld_bAaNB5WX4fbE8,56
|
|
4
|
+
flatmark/api/account/get_me.py,sha256=GN9Sw2c9RoiM0c_8sPGfo-NyYOjHK5CgpqCafIg6LBw,5563
|
|
5
|
+
flatmark/api/convert/__init__.py,sha256=5vd9uJWAjRqa9xzxzYkLD1yoZ12Ld_bAaNB5WX4fbE8,56
|
|
6
|
+
flatmark/api/convert/convert_document.py,sha256=ITtuJHYT-uyakG7PGz6FOZ24QvI_7dX6pHg9q0swNIE,7607
|
|
7
|
+
flatmark/api/convert/get_conversion_result.py,sha256=KAT7Qxj_9OGHPWwd7i-IGHCShA4thZNt1KWWWiWwgxI,7226
|
|
8
|
+
flatmark/api/convert/submit_conversion_job.py,sha256=zydSD8oquAHKzRrFwbLYHEo_9Pe-zPpsZdEyYZ5ICA4,9587
|
|
9
|
+
flatmark/api/jobs/__init__.py,sha256=5vd9uJWAjRqa9xzxzYkLD1yoZ12Ld_bAaNB5WX4fbE8,56
|
|
10
|
+
flatmark/api/jobs/get_job.py,sha256=L2YTXq7DacaBtHW-EJBSy4gmj3NI4ix0bC3x5w5rekM,4836
|
|
11
|
+
flatmark/api/jobs/list_jobs.py,sha256=cEQy8Mir_Zb4-9wnknIg5avOxKF0WQ4YPDciYp-Jp3E,5739
|
|
12
|
+
flatmark/client.py,sha256=fwU0xJF8ktG6_uvCFZh3I6Lqsmg3WKP89ODUdTunB1A,12306
|
|
13
|
+
flatmark/errors.py,sha256=gO8GBmKqmSNgAg-E5oT-oOyxztvp7V_6XG7OUTT15q0,546
|
|
14
|
+
flatmark/models/__init__.py,sha256=Sv3P-OTUK0e-60LmHo1LjCfi-egoU1IHIUeZxLoZjKo,1137
|
|
15
|
+
flatmark/models/body_convert_document.py,sha256=J867ZqW5crdXhewkbrgT9wslzLNVi8MqUGp2lloW7_M,2001
|
|
16
|
+
flatmark/models/body_submit_conversion_job.py,sha256=haTynh0pY5yU3epBR_v2LBb-VGKgt8pc8aAFhHHft-M,3163
|
|
17
|
+
flatmark/models/credits_info.py,sha256=pz87wsrf0euu3fR-FkZij11VCt70KagsUWT26K0ZEU0,2667
|
|
18
|
+
flatmark/models/get_conversion_result_format.py,sha256=e5XRCuYJo_cAXlVjYilgfBTXxo9dImJUDuOPU9w3-E0,175
|
|
19
|
+
flatmark/models/job_response.py,sha256=akSZO1AYeix20gPxVXwvYKRBcbodnzzqErbrLV3Bb_g,7521
|
|
20
|
+
flatmark/models/job_response_page.py,sha256=kFHOm5MkdLKSXPNeJTVt2oN-Bh_398syVkeL71cj1eY,2720
|
|
21
|
+
flatmark/models/job_response_result_type_0.py,sha256=24Dba3re9lj1i5Q8rENNg34zIFvou8xBlvPWFSkK1gM,1288
|
|
22
|
+
flatmark/models/job_submit_response.py,sha256=ovImvzbssUcNsOFCsRNiKsGi29RLmIuBIvFqIyi61ho,3142
|
|
23
|
+
flatmark/models/me_response.py,sha256=-EQs-1Hsy5HA5zwRBXcwNPlKZckW6CIEofGorStF5qw,4494
|
|
24
|
+
flatmark/models/problem.py,sha256=B65lZ3Qy9T54XPYqwVGGjuhGrvS6037H0SC7ZQNAxfA,6030
|
|
25
|
+
flatmark/models/problem_errors_type_0_item.py,sha256=9VQ3QEopiHNaPf53p_IqChik798_mkZ-KasOf1U3bgc,1288
|
|
26
|
+
flatmark/models/rate_limit_info.py,sha256=YSnjO1M9XjEhEwMlCpysfABaUL-oyA487v4zrVUm2-M,3633
|
|
27
|
+
flatmark/models/sync_convert_response.py,sha256=jp2mqiLtA7J9skKI6Z78EVWuS_DlohADaVLy3Lu75tI,2488
|
|
28
|
+
flatmark/models/sync_convert_response_meta.py,sha256=nVZxT3tixJl6KB8OD7YGxt9pIze5uM8JvzPDcMNfTPE,1378
|
|
29
|
+
flatmark/py.typed,sha256=8ZJUsxZiuOy1oJeVhsTWQhTG_6pTVHVXk5hJL79ebTk,25
|
|
30
|
+
flatmark/types.py,sha256=0We4NPvhIYASRpQ3le41nmJeEAVm42-2VKdzlJ4Ogok,1343
|
|
31
|
+
flatmark-1.0.0.dist-info/WHEEL,sha256=rp-k_VZaX8oABFEtLwG_Df95p8LSKt9-uPyQ4jKH0P4,81
|
|
32
|
+
flatmark-1.0.0.dist-info/METADATA,sha256=Nh70KaIUmtqTsfa0_1X_YBvs4nTY60XCxqtAvequjM0,2023
|
|
33
|
+
flatmark-1.0.0.dist-info/RECORD,,
|