formatjet 0.1.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 (153) hide show
  1. formatjet/__init__.py +53 -0
  2. formatjet/_client.py +417 -0
  3. formatjet/_errors.py +75 -0
  4. formatjet/_transport.py +66 -0
  5. formatjet/_webhooks.py +93 -0
  6. formatjet/openapi/__init__.py +9 -0
  7. formatjet/openapi/api/__init__.py +1 -0
  8. formatjet/openapi/api/account/__init__.py +1 -0
  9. formatjet/openapi/api/account/get_account.py +144 -0
  10. formatjet/openapi/api/account/get_usage.py +197 -0
  11. formatjet/openapi/api/catalog/__init__.py +1 -0
  12. formatjet/openapi/api/catalog/get_pricing.py +128 -0
  13. formatjet/openapi/api/catalog/list_formats.py +128 -0
  14. formatjet/openapi/api/catalog/list_operations.py +193 -0
  15. formatjet/openapi/api/jobs/__init__.py +1 -0
  16. formatjet/openapi/api/jobs/cancel_job.py +220 -0
  17. formatjet/openapi/api/jobs/convert.py +396 -0
  18. formatjet/openapi/api/jobs/create_job.py +241 -0
  19. formatjet/openapi/api/jobs/create_upload.py +230 -0
  20. formatjet/openapi/api/jobs/delete_job.py +188 -0
  21. formatjet/openapi/api/jobs/estimate_job.py +239 -0
  22. formatjet/openapi/api/jobs/get_job.py +188 -0
  23. formatjet/openapi/api/jobs/list_jobs.py +208 -0
  24. formatjet/openapi/api/jobs/stream_job_events.py +194 -0
  25. formatjet/openapi/api/webhooks/__init__.py +1 -0
  26. formatjet/openapi/api/webhooks/create_webhook.py +225 -0
  27. formatjet/openapi/api/webhooks/delete_webhook.py +174 -0
  28. formatjet/openapi/api/webhooks/get_webhook.py +176 -0
  29. formatjet/openapi/api/webhooks/list_webhook_deliveries.py +234 -0
  30. formatjet/openapi/api/webhooks/list_webhooks.py +144 -0
  31. formatjet/openapi/api/webhooks/replay_webhook_event.py +242 -0
  32. formatjet/openapi/api/webhooks/rotate_webhook_secret.py +224 -0
  33. formatjet/openapi/api/webhooks/update_webhook.py +214 -0
  34. formatjet/openapi/client.py +280 -0
  35. formatjet/openapi/errors.py +16 -0
  36. formatjet/openapi/models/__init__.py +231 -0
  37. formatjet/openapi/models/account.py +114 -0
  38. formatjet/openapi/models/account_credits.py +102 -0
  39. formatjet/openapi/models/account_credits_monthly_type_0.py +78 -0
  40. formatjet/openapi/models/account_key.py +107 -0
  41. formatjet/openapi/models/account_key_mode.py +16 -0
  42. formatjet/openapi/models/account_key_scopes_item.py +17 -0
  43. formatjet/openapi/models/account_limits.py +111 -0
  44. formatjet/openapi/models/account_organization.py +69 -0
  45. formatjet/openapi/models/account_plan.py +69 -0
  46. formatjet/openapi/models/convert_files_body.py +75 -0
  47. formatjet/openapi/models/convert_from.py +95 -0
  48. formatjet/openapi/models/convert_to.py +95 -0
  49. formatjet/openapi/models/deletion_receipt_response.py +79 -0
  50. formatjet/openapi/models/deletion_receipt_response_receipt.py +50 -0
  51. formatjet/openapi/models/estimate.py +136 -0
  52. formatjet/openapi/models/estimate_credit_weight.py +70 -0
  53. formatjet/openapi/models/estimate_from.py +95 -0
  54. formatjet/openapi/models/estimate_request.py +79 -0
  55. formatjet/openapi/models/estimate_request_steps_item.py +124 -0
  56. formatjet/openapi/models/estimate_request_steps_item_from.py +95 -0
  57. formatjet/openapi/models/estimate_request_steps_item_op.py +15 -0
  58. formatjet/openapi/models/estimate_request_steps_item_options.py +47 -0
  59. formatjet/openapi/models/estimate_request_steps_item_to.py +95 -0
  60. formatjet/openapi/models/estimate_to.py +95 -0
  61. formatjet/openapi/models/format_.py +109 -0
  62. formatjet/openapi/models/job.py +297 -0
  63. formatjet/openapi/models/job_error_type_0.py +69 -0
  64. formatjet/openapi/models/job_estimate.py +61 -0
  65. formatjet/openapi/models/job_input.py +163 -0
  66. formatjet/openapi/models/job_input_format_type_1.py +95 -0
  67. formatjet/openapi/models/job_input_format_type_2_type_1.py +95 -0
  68. formatjet/openapi/models/job_input_format_type_3_type_1.py +95 -0
  69. formatjet/openapi/models/job_inputs_item.py +165 -0
  70. formatjet/openapi/models/job_inputs_item_format_type_1.py +95 -0
  71. formatjet/openapi/models/job_inputs_item_format_type_2_type_1.py +97 -0
  72. formatjet/openapi/models/job_inputs_item_format_type_3_type_1.py +97 -0
  73. formatjet/openapi/models/job_links.py +69 -0
  74. formatjet/openapi/models/job_metadata.py +45 -0
  75. formatjet/openapi/models/job_mode.py +14 -0
  76. formatjet/openapi/models/job_outputs_item.py +133 -0
  77. formatjet/openapi/models/job_request.py +213 -0
  78. formatjet/openapi/models/job_request_input_type_0.py +42 -0
  79. formatjet/openapi/models/job_request_input_type_1.py +53 -0
  80. formatjet/openapi/models/job_request_input_type_2.py +54 -0
  81. formatjet/openapi/models/job_request_inputs_item_type_0.py +42 -0
  82. formatjet/openapi/models/job_request_inputs_item_type_1.py +53 -0
  83. formatjet/openapi/models/job_request_metadata.py +47 -0
  84. formatjet/openapi/models/job_request_output.py +51 -0
  85. formatjet/openapi/models/job_request_steps_item.py +120 -0
  86. formatjet/openapi/models/job_request_steps_item_from.py +95 -0
  87. formatjet/openapi/models/job_request_steps_item_op.py +15 -0
  88. formatjet/openapi/models/job_request_steps_item_options.py +47 -0
  89. formatjet/openapi/models/job_request_steps_item_to.py +95 -0
  90. formatjet/openapi/models/job_status.py +29 -0
  91. formatjet/openapi/models/job_steps_item.py +234 -0
  92. formatjet/openapi/models/job_steps_item_from_type_1.py +95 -0
  93. formatjet/openapi/models/job_steps_item_from_type_2_type_1.py +95 -0
  94. formatjet/openapi/models/job_steps_item_from_type_3_type_1.py +95 -0
  95. formatjet/openapi/models/job_steps_item_op.py +15 -0
  96. formatjet/openapi/models/job_steps_item_options.py +45 -0
  97. formatjet/openapi/models/job_steps_item_status.py +29 -0
  98. formatjet/openapi/models/job_steps_item_to_type_1.py +95 -0
  99. formatjet/openapi/models/job_steps_item_to_type_2_type_1.py +95 -0
  100. formatjet/openapi/models/job_steps_item_to_type_3_type_1.py +95 -0
  101. formatjet/openapi/models/job_summary.py +160 -0
  102. formatjet/openapi/models/job_summary_mode.py +16 -0
  103. formatjet/openapi/models/job_summary_status.py +29 -0
  104. formatjet/openapi/models/list_formats_response_200.py +84 -0
  105. formatjet/openapi/models/list_jobs_response_200.py +95 -0
  106. formatjet/openapi/models/list_operations_from.py +95 -0
  107. formatjet/openapi/models/list_operations_response_200.py +82 -0
  108. formatjet/openapi/models/list_operations_to.py +95 -0
  109. formatjet/openapi/models/list_webhook_deliveries_response_200.py +95 -0
  110. formatjet/openapi/models/list_webhooks_response_200.py +81 -0
  111. formatjet/openapi/models/operation.py +148 -0
  112. formatjet/openapi/models/operation_credits.py +69 -0
  113. formatjet/openapi/models/operation_engines_item.py +87 -0
  114. formatjet/openapi/models/operation_engines_item_engines_item.py +69 -0
  115. formatjet/openapi/models/operation_files.py +70 -0
  116. formatjet/openapi/models/operation_kind.py +16 -0
  117. formatjet/openapi/models/operation_options_schema.py +45 -0
  118. formatjet/openapi/models/pricing.py +153 -0
  119. formatjet/openapi/models/pricing_credit_packs_item.py +77 -0
  120. formatjet/openapi/models/pricing_credit_weights_item.py +85 -0
  121. formatjet/openapi/models/pricing_plans_item.py +156 -0
  122. formatjet/openapi/models/pricing_plans_item_overage_type_1.py +61 -0
  123. formatjet/openapi/models/problem.py +155 -0
  124. formatjet/openapi/models/problem_code.py +47 -0
  125. formatjet/openapi/models/problem_errors_item.py +69 -0
  126. formatjet/openapi/models/replay_webhook_event_body.py +45 -0
  127. formatjet/openapi/models/upload.py +115 -0
  128. formatjet/openapi/models/upload_headers.py +47 -0
  129. formatjet/openapi/models/upload_method.py +15 -0
  130. formatjet/openapi/models/upload_request.py +56 -0
  131. formatjet/openapi/models/usage.py +93 -0
  132. formatjet/openapi/models/usage_days_item.py +93 -0
  133. formatjet/openapi/models/usage_totals.py +85 -0
  134. formatjet/openapi/models/webhook_delivery.py +204 -0
  135. formatjet/openapi/models/webhook_delivery_event_type.py +17 -0
  136. formatjet/openapi/models/webhook_delivery_mode.py +16 -0
  137. formatjet/openapi/models/webhook_endpoint.py +258 -0
  138. formatjet/openapi/models/webhook_endpoint_disabled_reason_type_1.py +20 -0
  139. formatjet/openapi/models/webhook_endpoint_disabled_reason_type_2_type_1.py +20 -0
  140. formatjet/openapi/models/webhook_endpoint_disabled_reason_type_3_type_1.py +20 -0
  141. formatjet/openapi/models/webhook_endpoint_events_item.py +17 -0
  142. formatjet/openapi/models/webhook_endpoint_mode.py +16 -0
  143. formatjet/openapi/models/webhook_endpoint_request.py +84 -0
  144. formatjet/openapi/models/webhook_endpoint_request_events_item.py +21 -0
  145. formatjet/openapi/models/webhook_endpoint_update.py +101 -0
  146. formatjet/openapi/models/webhook_endpoint_update_events_item.py +19 -0
  147. formatjet/openapi/models/webhook_endpoint_with_secret.py +267 -0
  148. formatjet/openapi/types.py +54 -0
  149. formatjet/py.typed +0 -0
  150. formatjet-0.1.0.dist-info/METADATA +126 -0
  151. formatjet-0.1.0.dist-info/RECORD +153 -0
  152. formatjet-0.1.0.dist-info/WHEEL +4 -0
  153. formatjet-0.1.0.dist-info/licenses/LICENSE +21 -0
formatjet/_webhooks.py ADDED
@@ -0,0 +1,93 @@
1
+ from __future__ import annotations
2
+
3
+ import hashlib
4
+ import hmac
5
+ import json
6
+ import re
7
+ import time
8
+ from dataclasses import dataclass
9
+ from typing import Any, Literal
10
+
11
+ #: The header each delivery carries: ``t=<unix seconds>,v1=<hex HMAC-SHA256>[,v1=…]``.
12
+ SIGNATURE_HEADER = "FormatJet-Signature"
13
+
14
+ #: Deliveries signed longer ago than this (5 minutes) are refused, so a copy can't be replayed.
15
+ DEFAULT_TOLERANCE_SECONDS = 300
16
+
17
+ WebhookFailure = Literal["missing_header", "malformed_header", "timestamp_out_of_range", "no_match"]
18
+
19
+ _TIMESTAMP = re.compile(r"^\d{1,12}$")
20
+ _SIGNATURE = re.compile(r"^[0-9a-f]{64}$")
21
+
22
+
23
+ @dataclass(frozen=True)
24
+ class WebhookVerification:
25
+ ok: bool
26
+ timestamp: int | None = None
27
+ reason: WebhookFailure | None = None
28
+
29
+ def __bool__(self) -> bool:
30
+ return self.ok
31
+
32
+
33
+ class WebhookSignatureError(Exception):
34
+ """A delivery whose signature didn't check out."""
35
+
36
+ def __init__(self, reason: WebhookFailure) -> None:
37
+ super().__init__(f"The webhook signature isn't valid: {reason}")
38
+ self.reason = reason
39
+
40
+
41
+ def verify_webhook(
42
+ body: bytes | str,
43
+ header: str | None,
44
+ secret: str,
45
+ *,
46
+ tolerance_seconds: int = DEFAULT_TOLERANCE_SECONDS,
47
+ now: float | None = None,
48
+ ) -> WebhookVerification:
49
+ """Checks a delivery's signature.
50
+
51
+ ``body`` is the raw request body exactly as it arrived (read it before parsing the JSON),
52
+ ``header`` the ``FormatJet-Signature`` header and ``secret`` the endpoint's secret. Any
53
+ ``v1`` made with the secret is enough (a rotation sends two); a timestamp more than
54
+ ``tolerance_seconds`` from now is refused. The result is truthy when the delivery checks out.
55
+ """
56
+ if not header:
57
+ return WebhookVerification(ok=False, reason="missing_header")
58
+ timestamp: int | None = None
59
+ signatures: list[str] = []
60
+ for part in header.split(","):
61
+ name, _, value = part.strip().partition("=")
62
+ if name == "t" and _TIMESTAMP.match(value):
63
+ timestamp = int(value)
64
+ elif name == "v1" and _SIGNATURE.match(value):
65
+ signatures.append(value)
66
+ if timestamp is None or not signatures:
67
+ return WebhookVerification(ok=False, reason="malformed_header")
68
+ current = int(time.time() if now is None else now)
69
+ if abs(current - timestamp) > tolerance_seconds:
70
+ return WebhookVerification(ok=False, reason="timestamp_out_of_range")
71
+ raw = body.encode() if isinstance(body, str) else bytes(body)
72
+ expected = hmac.new(secret.encode(), f"{timestamp}.".encode() + raw, hashlib.sha256).hexdigest()
73
+ if any(hmac.compare_digest(signature, expected) for signature in signatures):
74
+ return WebhookVerification(ok=True, timestamp=timestamp)
75
+ return WebhookVerification(ok=False, reason="no_match")
76
+
77
+
78
+ def parse_webhook(
79
+ body: bytes | str,
80
+ header: str | None,
81
+ secret: str,
82
+ *,
83
+ tolerance_seconds: int = DEFAULT_TOLERANCE_SECONDS,
84
+ now: float | None = None,
85
+ ) -> dict[str, Any]:
86
+ """Checks a delivery and returns its event (``id``, ``type``, ``created_at``, ``mode``,
87
+ ``data.job``), or raises ``WebhookSignatureError``. Answer 2xx quickly once it's checked:
88
+ a delivery that takes over 10 seconds is retried."""
89
+ result = verify_webhook(body, header, secret, tolerance_seconds=tolerance_seconds, now=now)
90
+ if not result.ok:
91
+ raise WebhookSignatureError(result.reason or "no_match")
92
+ event: dict[str, Any] = json.loads(body)
93
+ return event
@@ -0,0 +1,9 @@
1
+ # Generated by openapi-python-client from apps/api/openapi.json (bun run sdk:generate). Don't edit by hand.
2
+ """A client library for accessing FormatJet API"""
3
+
4
+ from .client import AuthenticatedClient, Client
5
+
6
+ __all__ = (
7
+ "AuthenticatedClient",
8
+ "Client",
9
+ )
@@ -0,0 +1 @@
1
+ """Contains methods for accessing the API"""
@@ -0,0 +1 @@
1
+ """Contains endpoint functions for accessing the API"""
@@ -0,0 +1,144 @@
1
+ from http import HTTPStatus
2
+ from typing import Any
3
+
4
+ import httpx
5
+
6
+ from ... import errors
7
+ from ...client import AuthenticatedClient, Client
8
+ from ...models.account import Account
9
+ from ...models.problem import Problem
10
+ from ...types import Response
11
+
12
+
13
+ def _get_kwargs() -> dict[str, Any]:
14
+
15
+ _kwargs: dict[str, Any] = {
16
+ "method": "get",
17
+ "url": "/v1/account",
18
+ }
19
+
20
+ return _kwargs
21
+
22
+
23
+ def _parse_response(
24
+ *, client: AuthenticatedClient | Client, response: httpx.Response
25
+ ) -> Account | Problem | None:
26
+ if response.status_code == 200:
27
+ response_200 = Account.from_dict(response.json())
28
+
29
+ return response_200
30
+
31
+ if response.status_code == 401:
32
+ response_401 = Problem.from_dict(response.json())
33
+
34
+ return response_401
35
+
36
+ if response.status_code == 403:
37
+ response_403 = Problem.from_dict(response.json())
38
+
39
+ return response_403
40
+
41
+ if response.status_code == 429:
42
+ response_429 = Problem.from_dict(response.json())
43
+
44
+ return response_429
45
+
46
+ if client.raise_on_unexpected_status:
47
+ raise errors.UnexpectedStatus(response.status_code, response.content)
48
+ else:
49
+ return None
50
+
51
+
52
+ def _build_response(
53
+ *, client: AuthenticatedClient | Client, response: httpx.Response
54
+ ) -> Response[Account | Problem]:
55
+ return Response(
56
+ status_code=HTTPStatus(response.status_code),
57
+ content=response.content,
58
+ headers=response.headers,
59
+ parsed=_parse_response(client=client, response=response),
60
+ )
61
+
62
+
63
+ def sync_detailed(
64
+ *,
65
+ client: AuthenticatedClient,
66
+ ) -> Response[Account | Problem]:
67
+ """The account and limits behind your API key
68
+
69
+ Raises:
70
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
71
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
72
+
73
+ Returns:
74
+ Response[Account | Problem]
75
+ """
76
+
77
+ kwargs = _get_kwargs()
78
+
79
+ response = client.get_httpx_client().request(
80
+ **kwargs,
81
+ )
82
+
83
+ return _build_response(client=client, response=response)
84
+
85
+
86
+ def sync(
87
+ *,
88
+ client: AuthenticatedClient,
89
+ ) -> Account | Problem | None:
90
+ """The account and limits behind your API key
91
+
92
+ Raises:
93
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
94
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
95
+
96
+ Returns:
97
+ Account | Problem
98
+ """
99
+
100
+ return sync_detailed(
101
+ client=client,
102
+ ).parsed
103
+
104
+
105
+ async def asyncio_detailed(
106
+ *,
107
+ client: AuthenticatedClient,
108
+ ) -> Response[Account | Problem]:
109
+ """The account and limits behind your API key
110
+
111
+ Raises:
112
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
113
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
114
+
115
+ Returns:
116
+ Response[Account | Problem]
117
+ """
118
+
119
+ kwargs = _get_kwargs()
120
+
121
+ response = await client.get_async_httpx_client().request(**kwargs)
122
+
123
+ return _build_response(client=client, response=response)
124
+
125
+
126
+ async def asyncio(
127
+ *,
128
+ client: AuthenticatedClient,
129
+ ) -> Account | Problem | None:
130
+ """The account and limits behind your API key
131
+
132
+ Raises:
133
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
134
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
135
+
136
+ Returns:
137
+ Account | Problem
138
+ """
139
+
140
+ return (
141
+ await asyncio_detailed(
142
+ client=client,
143
+ )
144
+ ).parsed
@@ -0,0 +1,197 @@
1
+ from http import HTTPStatus
2
+ from typing import Any
3
+
4
+ import httpx
5
+
6
+ from ... import errors
7
+ from ...client import AuthenticatedClient, Client
8
+ from ...models.problem import Problem
9
+ from ...models.usage import Usage
10
+ from ...types import UNSET, Response, Unset
11
+
12
+
13
+ def _get_kwargs(
14
+ *,
15
+ days: int | Unset = 30,
16
+ ) -> dict[str, Any]:
17
+
18
+ params: dict[str, Any] = {}
19
+
20
+ params["days"] = days
21
+
22
+ params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
23
+
24
+ _kwargs: dict[str, Any] = {
25
+ "method": "get",
26
+ "url": "/v1/usage",
27
+ "params": params,
28
+ }
29
+
30
+ return _kwargs
31
+
32
+
33
+ def _parse_response(
34
+ *, client: AuthenticatedClient | Client, response: httpx.Response
35
+ ) -> Problem | Usage | None:
36
+ if response.status_code == 200:
37
+ response_200 = Usage.from_dict(response.json())
38
+
39
+ return response_200
40
+
41
+ if response.status_code == 400:
42
+ response_400 = Problem.from_dict(response.json())
43
+
44
+ return response_400
45
+
46
+ if response.status_code == 401:
47
+ response_401 = Problem.from_dict(response.json())
48
+
49
+ return response_401
50
+
51
+ if response.status_code == 403:
52
+ response_403 = Problem.from_dict(response.json())
53
+
54
+ return response_403
55
+
56
+ if response.status_code == 429:
57
+ response_429 = Problem.from_dict(response.json())
58
+
59
+ return response_429
60
+
61
+ if client.raise_on_unexpected_status:
62
+ raise errors.UnexpectedStatus(response.status_code, response.content)
63
+ else:
64
+ return None
65
+
66
+
67
+ def _build_response(
68
+ *, client: AuthenticatedClient | Client, response: httpx.Response
69
+ ) -> Response[Problem | Usage]:
70
+ return Response(
71
+ status_code=HTTPStatus(response.status_code),
72
+ content=response.content,
73
+ headers=response.headers,
74
+ parsed=_parse_response(client=client, response=response),
75
+ )
76
+
77
+
78
+ def sync_detailed(
79
+ *,
80
+ client: AuthenticatedClient,
81
+ days: int | Unset = 30,
82
+ ) -> Response[Problem | Usage]:
83
+ """Jobs and credits by day
84
+
85
+ The organization’s jobs (website, API and MCP, live and test) and the credits they used, per UTC
86
+ day, oldest first, today included. Exact from job records for the last 30 days, then from daily
87
+ totals.
88
+
89
+ Args:
90
+ days (int | Unset): How many days, 7 to 90 Default: 30.
91
+
92
+ Raises:
93
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
94
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
95
+
96
+ Returns:
97
+ Response[Problem | Usage]
98
+ """
99
+
100
+ kwargs = _get_kwargs(
101
+ days=days,
102
+ )
103
+
104
+ response = client.get_httpx_client().request(
105
+ **kwargs,
106
+ )
107
+
108
+ return _build_response(client=client, response=response)
109
+
110
+
111
+ def sync(
112
+ *,
113
+ client: AuthenticatedClient,
114
+ days: int | Unset = 30,
115
+ ) -> Problem | Usage | None:
116
+ """Jobs and credits by day
117
+
118
+ The organization’s jobs (website, API and MCP, live and test) and the credits they used, per UTC
119
+ day, oldest first, today included. Exact from job records for the last 30 days, then from daily
120
+ totals.
121
+
122
+ Args:
123
+ days (int | Unset): How many days, 7 to 90 Default: 30.
124
+
125
+ Raises:
126
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
127
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
128
+
129
+ Returns:
130
+ Problem | Usage
131
+ """
132
+
133
+ return sync_detailed(
134
+ client=client,
135
+ days=days,
136
+ ).parsed
137
+
138
+
139
+ async def asyncio_detailed(
140
+ *,
141
+ client: AuthenticatedClient,
142
+ days: int | Unset = 30,
143
+ ) -> Response[Problem | Usage]:
144
+ """Jobs and credits by day
145
+
146
+ The organization’s jobs (website, API and MCP, live and test) and the credits they used, per UTC
147
+ day, oldest first, today included. Exact from job records for the last 30 days, then from daily
148
+ totals.
149
+
150
+ Args:
151
+ days (int | Unset): How many days, 7 to 90 Default: 30.
152
+
153
+ Raises:
154
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
155
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
156
+
157
+ Returns:
158
+ Response[Problem | Usage]
159
+ """
160
+
161
+ kwargs = _get_kwargs(
162
+ days=days,
163
+ )
164
+
165
+ response = await client.get_async_httpx_client().request(**kwargs)
166
+
167
+ return _build_response(client=client, response=response)
168
+
169
+
170
+ async def asyncio(
171
+ *,
172
+ client: AuthenticatedClient,
173
+ days: int | Unset = 30,
174
+ ) -> Problem | Usage | None:
175
+ """Jobs and credits by day
176
+
177
+ The organization’s jobs (website, API and MCP, live and test) and the credits they used, per UTC
178
+ day, oldest first, today included. Exact from job records for the last 30 days, then from daily
179
+ totals.
180
+
181
+ Args:
182
+ days (int | Unset): How many days, 7 to 90 Default: 30.
183
+
184
+ Raises:
185
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
186
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
187
+
188
+ Returns:
189
+ Problem | Usage
190
+ """
191
+
192
+ return (
193
+ await asyncio_detailed(
194
+ client=client,
195
+ days=days,
196
+ )
197
+ ).parsed
@@ -0,0 +1 @@
1
+ """Contains endpoint functions for accessing the API"""
@@ -0,0 +1,128 @@
1
+ from http import HTTPStatus
2
+ from typing import Any
3
+
4
+ import httpx
5
+
6
+ from ... import errors
7
+ from ...client import AuthenticatedClient, Client
8
+ from ...models.pricing import Pricing
9
+ from ...types import Response
10
+
11
+
12
+ def _get_kwargs() -> dict[str, Any]:
13
+
14
+ _kwargs: dict[str, Any] = {
15
+ "method": "get",
16
+ "url": "/v1/pricing",
17
+ }
18
+
19
+ return _kwargs
20
+
21
+
22
+ def _parse_response(
23
+ *, client: AuthenticatedClient | Client, response: httpx.Response
24
+ ) -> Pricing | None:
25
+ if response.status_code == 200:
26
+ response_200 = Pricing.from_dict(response.json())
27
+
28
+ return response_200
29
+
30
+ if client.raise_on_unexpected_status:
31
+ raise errors.UnexpectedStatus(response.status_code, response.content)
32
+ else:
33
+ return None
34
+
35
+
36
+ def _build_response(
37
+ *, client: AuthenticatedClient | Client, response: httpx.Response
38
+ ) -> Response[Pricing]:
39
+ return Response(
40
+ status_code=HTTPStatus(response.status_code),
41
+ content=response.content,
42
+ headers=response.headers,
43
+ parsed=_parse_response(client=client, response=response),
44
+ )
45
+
46
+
47
+ def sync_detailed(
48
+ *,
49
+ client: AuthenticatedClient | Client,
50
+ ) -> Response[Pricing]:
51
+ """Credit weights, plans and credit packs
52
+
53
+ Raises:
54
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
55
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
56
+
57
+ Returns:
58
+ Response[Pricing]
59
+ """
60
+
61
+ kwargs = _get_kwargs()
62
+
63
+ response = client.get_httpx_client().request(
64
+ **kwargs,
65
+ )
66
+
67
+ return _build_response(client=client, response=response)
68
+
69
+
70
+ def sync(
71
+ *,
72
+ client: AuthenticatedClient | Client,
73
+ ) -> Pricing | None:
74
+ """Credit weights, plans and credit packs
75
+
76
+ Raises:
77
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
78
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
79
+
80
+ Returns:
81
+ Pricing
82
+ """
83
+
84
+ return sync_detailed(
85
+ client=client,
86
+ ).parsed
87
+
88
+
89
+ async def asyncio_detailed(
90
+ *,
91
+ client: AuthenticatedClient | Client,
92
+ ) -> Response[Pricing]:
93
+ """Credit weights, plans and credit packs
94
+
95
+ Raises:
96
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
97
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
98
+
99
+ Returns:
100
+ Response[Pricing]
101
+ """
102
+
103
+ kwargs = _get_kwargs()
104
+
105
+ response = await client.get_async_httpx_client().request(**kwargs)
106
+
107
+ return _build_response(client=client, response=response)
108
+
109
+
110
+ async def asyncio(
111
+ *,
112
+ client: AuthenticatedClient | Client,
113
+ ) -> Pricing | None:
114
+ """Credit weights, plans and credit packs
115
+
116
+ Raises:
117
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
118
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
119
+
120
+ Returns:
121
+ Pricing
122
+ """
123
+
124
+ return (
125
+ await asyncio_detailed(
126
+ client=client,
127
+ )
128
+ ).parsed
@@ -0,0 +1,128 @@
1
+ from http import HTTPStatus
2
+ from typing import Any
3
+
4
+ import httpx
5
+
6
+ from ... import errors
7
+ from ...client import AuthenticatedClient, Client
8
+ from ...models.list_formats_response_200 import ListFormatsResponse200
9
+ from ...types import Response
10
+
11
+
12
+ def _get_kwargs() -> dict[str, Any]:
13
+
14
+ _kwargs: dict[str, Any] = {
15
+ "method": "get",
16
+ "url": "/v1/formats",
17
+ }
18
+
19
+ return _kwargs
20
+
21
+
22
+ def _parse_response(
23
+ *, client: AuthenticatedClient | Client, response: httpx.Response
24
+ ) -> ListFormatsResponse200 | None:
25
+ if response.status_code == 200:
26
+ response_200 = ListFormatsResponse200.from_dict(response.json())
27
+
28
+ return response_200
29
+
30
+ if client.raise_on_unexpected_status:
31
+ raise errors.UnexpectedStatus(response.status_code, response.content)
32
+ else:
33
+ return None
34
+
35
+
36
+ def _build_response(
37
+ *, client: AuthenticatedClient | Client, response: httpx.Response
38
+ ) -> Response[ListFormatsResponse200]:
39
+ return Response(
40
+ status_code=HTTPStatus(response.status_code),
41
+ content=response.content,
42
+ headers=response.headers,
43
+ parsed=_parse_response(client=client, response=response),
44
+ )
45
+
46
+
47
+ def sync_detailed(
48
+ *,
49
+ client: AuthenticatedClient | Client,
50
+ ) -> Response[ListFormatsResponse200]:
51
+ """List supported formats
52
+
53
+ Raises:
54
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
55
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
56
+
57
+ Returns:
58
+ Response[ListFormatsResponse200]
59
+ """
60
+
61
+ kwargs = _get_kwargs()
62
+
63
+ response = client.get_httpx_client().request(
64
+ **kwargs,
65
+ )
66
+
67
+ return _build_response(client=client, response=response)
68
+
69
+
70
+ def sync(
71
+ *,
72
+ client: AuthenticatedClient | Client,
73
+ ) -> ListFormatsResponse200 | None:
74
+ """List supported formats
75
+
76
+ Raises:
77
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
78
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
79
+
80
+ Returns:
81
+ ListFormatsResponse200
82
+ """
83
+
84
+ return sync_detailed(
85
+ client=client,
86
+ ).parsed
87
+
88
+
89
+ async def asyncio_detailed(
90
+ *,
91
+ client: AuthenticatedClient | Client,
92
+ ) -> Response[ListFormatsResponse200]:
93
+ """List supported formats
94
+
95
+ Raises:
96
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
97
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
98
+
99
+ Returns:
100
+ Response[ListFormatsResponse200]
101
+ """
102
+
103
+ kwargs = _get_kwargs()
104
+
105
+ response = await client.get_async_httpx_client().request(**kwargs)
106
+
107
+ return _build_response(client=client, response=response)
108
+
109
+
110
+ async def asyncio(
111
+ *,
112
+ client: AuthenticatedClient | Client,
113
+ ) -> ListFormatsResponse200 | None:
114
+ """List supported formats
115
+
116
+ Raises:
117
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
118
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
119
+
120
+ Returns:
121
+ ListFormatsResponse200
122
+ """
123
+
124
+ return (
125
+ await asyncio_detailed(
126
+ client=client,
127
+ )
128
+ ).parsed