fal 0.12.1__py3-none-any.whl → 0.12.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of fal might be problematic. Click here for more details.

Files changed (116) hide show
  1. fal/__init__.py +12 -3
  2. fal/_serialization.py +18 -0
  3. fal/api.py +140 -59
  4. fal/app.py +309 -86
  5. fal/apps.py +92 -8
  6. fal/auth/__init__.py +20 -1
  7. fal/auth/auth0.py +32 -22
  8. fal/cli.py +34 -52
  9. fal/env.py +0 -4
  10. fal/exceptions/handlers.py +3 -2
  11. fal/flags.py +5 -0
  12. fal/logging/__init__.py +0 -2
  13. fal/logging/trace.py +8 -1
  14. fal/logging/user.py +2 -1
  15. fal/rest_client.py +2 -2
  16. fal/sdk.py +46 -31
  17. fal/sync.py +3 -3
  18. fal/toolkit/__init__.py +18 -1
  19. fal/toolkit/file/file.py +98 -11
  20. fal/toolkit/file/providers/fal.py +43 -2
  21. fal/toolkit/file/types.py +1 -1
  22. fal/toolkit/image/image.py +26 -4
  23. fal/toolkit/optimize.py +50 -0
  24. fal/toolkit/utils/download_utils.py +59 -13
  25. {fal-0.12.1.dist-info → fal-0.12.3.dist-info}/METADATA +7 -7
  26. fal-0.12.3.dist-info/RECORD +66 -0
  27. openapi_fal_rest/models/__init__.py +2 -70
  28. openapi_fal_rest/models/customer_details.py +26 -0
  29. openapi_fal_rest/models/lock_reason.py +16 -0
  30. fal/logging/datadog.py +0 -77
  31. fal-0.12.1.dist-info/RECORD +0 -147
  32. openapi_fal_rest/api/admin/get_invoice_users.py +0 -142
  33. openapi_fal_rest/api/admin/get_usage_per_user.py +0 -199
  34. openapi_fal_rest/api/admin/handle_user_lock.py +0 -191
  35. openapi_fal_rest/api/admin/set_billing_type.py +0 -186
  36. openapi_fal_rest/api/applications/get_status_applications_app_user_id_app_alias_or_id_status_get.py +0 -179
  37. openapi_fal_rest/api/billing/delete_payment_method.py +0 -162
  38. openapi_fal_rest/api/billing/get_checkout_page.py +0 -198
  39. openapi_fal_rest/api/billing/get_setup_intent_key.py +0 -141
  40. openapi_fal_rest/api/billing/get_user_invoices.py +0 -152
  41. openapi_fal_rest/api/billing/get_user_payment_methods.py +0 -152
  42. openapi_fal_rest/api/billing/get_user_price.py +0 -186
  43. openapi_fal_rest/api/billing/get_user_spending.py +0 -192
  44. openapi_fal_rest/api/billing/handle_stripe_webhook.py +0 -173
  45. openapi_fal_rest/api/billing/upcoming_invoice.py +0 -143
  46. openapi_fal_rest/api/billing/update_customer_budget.py +0 -183
  47. openapi_fal_rest/api/files/delete.py +0 -162
  48. openapi_fal_rest/api/files/download.py +0 -162
  49. openapi_fal_rest/api/files/file_exists.py +0 -183
  50. openapi_fal_rest/api/files/list_directory.py +0 -173
  51. openapi_fal_rest/api/files/list_root.py +0 -152
  52. openapi_fal_rest/api/files/upload_from_url.py +0 -179
  53. openapi_fal_rest/api/health/__init__.py +0 -0
  54. openapi_fal_rest/api/health/check.py +0 -136
  55. openapi_fal_rest/api/keys/__init__.py +0 -0
  56. openapi_fal_rest/api/keys/create_key.py +0 -188
  57. openapi_fal_rest/api/keys/delete_key.py +0 -162
  58. openapi_fal_rest/api/keys/list_keys.py +0 -152
  59. openapi_fal_rest/api/logs/__init__.py +0 -0
  60. openapi_fal_rest/api/logs/list_since.py +0 -224
  61. openapi_fal_rest/api/requests/__init__.py +0 -0
  62. openapi_fal_rest/api/requests/requests.py +0 -247
  63. openapi_fal_rest/api/storage/__init__.py +0 -0
  64. openapi_fal_rest/api/storage/get_file_link.py +0 -200
  65. openapi_fal_rest/api/storage/initiate_upload.py +0 -172
  66. openapi_fal_rest/api/storage/upload_file.py +0 -172
  67. openapi_fal_rest/api/tokens/__init__.py +0 -0
  68. openapi_fal_rest/api/tokens/create_token.py +0 -166
  69. openapi_fal_rest/api/usage/__init__.py +0 -0
  70. openapi_fal_rest/api/usage/get_custom_usage_per_machine.py +0 -203
  71. openapi_fal_rest/api/usage/get_gateway_request_stats.py +0 -247
  72. openapi_fal_rest/api/usage/get_gateway_request_stats_by_time.py +0 -236
  73. openapi_fal_rest/api/usage/get_gateway_stats_for_yesterday.py +0 -152
  74. openapi_fal_rest/api/usage/get_shared_usage_per_app.py +0 -203
  75. openapi_fal_rest/api/usage/get_usage_records.py +0 -253
  76. openapi_fal_rest/api/usage/per_machine_usage.py +0 -218
  77. openapi_fal_rest/api/usage/per_machine_usage_details.py +0 -173
  78. openapi_fal_rest/api/users/__init__.py +0 -0
  79. openapi_fal_rest/api/users/handle_user_registration.py +0 -228
  80. openapi_fal_rest/models/billing_type.py +0 -9
  81. openapi_fal_rest/models/body_create_token.py +0 -68
  82. openapi_fal_rest/models/body_upload_file.py +0 -75
  83. openapi_fal_rest/models/file_spec.py +0 -110
  84. openapi_fal_rest/models/gateway_stats_by_time.py +0 -115
  85. openapi_fal_rest/models/gateway_usage_stats.py +0 -147
  86. openapi_fal_rest/models/get_gateway_request_stats_by_time_response_get_gateway_request_stats_by_time.py +0 -70
  87. openapi_fal_rest/models/grouped_usage_detail.py +0 -85
  88. openapi_fal_rest/models/handle_stripe_webhook_response_handle_stripe_webhook.py +0 -43
  89. openapi_fal_rest/models/initiate_upload_info.py +0 -64
  90. openapi_fal_rest/models/invoice.py +0 -129
  91. openapi_fal_rest/models/invoice_item.py +0 -85
  92. openapi_fal_rest/models/key_scope.py +0 -9
  93. openapi_fal_rest/models/log_entry.py +0 -104
  94. openapi_fal_rest/models/log_entry_labels.py +0 -43
  95. openapi_fal_rest/models/new_user_key.py +0 -64
  96. openapi_fal_rest/models/payment_method.py +0 -96
  97. openapi_fal_rest/models/per_app_usage_detail.py +0 -88
  98. openapi_fal_rest/models/persisted_usage_record.py +0 -118
  99. openapi_fal_rest/models/persisted_usage_record_meta.py +0 -43
  100. openapi_fal_rest/models/presigned_upload_url.py +0 -64
  101. openapi_fal_rest/models/request_io.py +0 -112
  102. openapi_fal_rest/models/request_io_json_input.py +0 -43
  103. openapi_fal_rest/models/request_io_json_output.py +0 -43
  104. openapi_fal_rest/models/run_type.py +0 -9
  105. openapi_fal_rest/models/stats_timeframe.py +0 -12
  106. openapi_fal_rest/models/status.py +0 -82
  107. openapi_fal_rest/models/status_health.py +0 -10
  108. openapi_fal_rest/models/uploaded_file_result.py +0 -64
  109. openapi_fal_rest/models/url_file_upload.py +0 -57
  110. openapi_fal_rest/models/usage_per_machine_type.py +0 -115
  111. openapi_fal_rest/models/usage_per_user.py +0 -71
  112. openapi_fal_rest/models/usage_run_detail.py +0 -73
  113. openapi_fal_rest/models/user_key_info.py +0 -84
  114. /openapi_fal_rest/api/admin/__init__.py → /fal/py.typed +0 -0
  115. {fal-0.12.1.dist-info → fal-0.12.3.dist-info}/WHEEL +0 -0
  116. {fal-0.12.1.dist-info → fal-0.12.3.dist-info}/entry_points.txt +0 -0
@@ -1,179 +0,0 @@
1
- from http import HTTPStatus
2
- from typing import Any, Dict, Optional, Union
3
-
4
- import httpx
5
-
6
- from ... import errors
7
- from ...client import Client
8
- from ...models.http_validation_error import HTTPValidationError
9
- from ...models.status import Status
10
- from ...types import Response
11
-
12
-
13
- def _get_kwargs(
14
- app_user_id: str,
15
- app_alias_or_id: str,
16
- *,
17
- client: Client,
18
- ) -> Dict[str, Any]:
19
- url = "{}/applications/{app_user_id}/{app_alias_or_id}/status".format(
20
- client.base_url, app_user_id=app_user_id, app_alias_or_id=app_alias_or_id
21
- )
22
-
23
- headers: Dict[str, str] = client.get_headers()
24
- cookies: Dict[str, Any] = client.get_cookies()
25
-
26
- return {
27
- "method": "get",
28
- "url": url,
29
- "headers": headers,
30
- "cookies": cookies,
31
- "timeout": client.get_timeout(),
32
- "follow_redirects": client.follow_redirects,
33
- }
34
-
35
-
36
- def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[HTTPValidationError, Status]]:
37
- if response.status_code == HTTPStatus.OK:
38
- response_200 = Status.from_dict(response.json())
39
-
40
- return response_200
41
- if response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY:
42
- response_422 = HTTPValidationError.from_dict(response.json())
43
-
44
- return response_422
45
- if client.raise_on_unexpected_status:
46
- raise errors.UnexpectedStatus(response.status_code, response.content)
47
- else:
48
- return None
49
-
50
-
51
- def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[HTTPValidationError, Status]]:
52
- return Response(
53
- status_code=HTTPStatus(response.status_code),
54
- content=response.content,
55
- headers=response.headers,
56
- parsed=_parse_response(client=client, response=response),
57
- )
58
-
59
-
60
- def sync_detailed(
61
- app_user_id: str,
62
- app_alias_or_id: str,
63
- *,
64
- client: Client,
65
- ) -> Response[Union[HTTPValidationError, Status]]:
66
- """Get Status
67
-
68
- Args:
69
- app_user_id (str):
70
- app_alias_or_id (str):
71
-
72
- Raises:
73
- errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
74
- httpx.TimeoutException: If the request takes longer than Client.timeout.
75
-
76
- Returns:
77
- Response[Union[HTTPValidationError, Status]]
78
- """
79
-
80
- kwargs = _get_kwargs(
81
- app_user_id=app_user_id,
82
- app_alias_or_id=app_alias_or_id,
83
- client=client,
84
- )
85
-
86
- response = httpx.request(
87
- verify=client.verify_ssl,
88
- **kwargs,
89
- )
90
-
91
- return _build_response(client=client, response=response)
92
-
93
-
94
- def sync(
95
- app_user_id: str,
96
- app_alias_or_id: str,
97
- *,
98
- client: Client,
99
- ) -> Optional[Union[HTTPValidationError, Status]]:
100
- """Get Status
101
-
102
- Args:
103
- app_user_id (str):
104
- app_alias_or_id (str):
105
-
106
- Raises:
107
- errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
108
- httpx.TimeoutException: If the request takes longer than Client.timeout.
109
-
110
- Returns:
111
- Union[HTTPValidationError, Status]
112
- """
113
-
114
- return sync_detailed(
115
- app_user_id=app_user_id,
116
- app_alias_or_id=app_alias_or_id,
117
- client=client,
118
- ).parsed
119
-
120
-
121
- async def asyncio_detailed(
122
- app_user_id: str,
123
- app_alias_or_id: str,
124
- *,
125
- client: Client,
126
- ) -> Response[Union[HTTPValidationError, Status]]:
127
- """Get Status
128
-
129
- Args:
130
- app_user_id (str):
131
- app_alias_or_id (str):
132
-
133
- Raises:
134
- errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
135
- httpx.TimeoutException: If the request takes longer than Client.timeout.
136
-
137
- Returns:
138
- Response[Union[HTTPValidationError, Status]]
139
- """
140
-
141
- kwargs = _get_kwargs(
142
- app_user_id=app_user_id,
143
- app_alias_or_id=app_alias_or_id,
144
- client=client,
145
- )
146
-
147
- async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
148
- response = await _client.request(**kwargs)
149
-
150
- return _build_response(client=client, response=response)
151
-
152
-
153
- async def asyncio(
154
- app_user_id: str,
155
- app_alias_or_id: str,
156
- *,
157
- client: Client,
158
- ) -> Optional[Union[HTTPValidationError, Status]]:
159
- """Get Status
160
-
161
- Args:
162
- app_user_id (str):
163
- app_alias_or_id (str):
164
-
165
- Raises:
166
- errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
167
- httpx.TimeoutException: If the request takes longer than Client.timeout.
168
-
169
- Returns:
170
- Union[HTTPValidationError, Status]
171
- """
172
-
173
- return (
174
- await asyncio_detailed(
175
- app_user_id=app_user_id,
176
- app_alias_or_id=app_alias_or_id,
177
- client=client,
178
- )
179
- ).parsed
@@ -1,162 +0,0 @@
1
- from http import HTTPStatus
2
- from typing import Any, Dict, Optional, Union, cast
3
-
4
- import httpx
5
-
6
- from ... import errors
7
- from ...client import Client
8
- from ...models.http_validation_error import HTTPValidationError
9
- from ...types import Response
10
-
11
-
12
- def _get_kwargs(
13
- payment_method_id: str,
14
- *,
15
- client: Client,
16
- ) -> Dict[str, Any]:
17
- url = "{}/billing/payment_methods/{payment_method_id}".format(client.base_url, payment_method_id=payment_method_id)
18
-
19
- headers: Dict[str, str] = client.get_headers()
20
- cookies: Dict[str, Any] = client.get_cookies()
21
-
22
- return {
23
- "method": "delete",
24
- "url": url,
25
- "headers": headers,
26
- "cookies": cookies,
27
- "timeout": client.get_timeout(),
28
- "follow_redirects": client.follow_redirects,
29
- }
30
-
31
-
32
- def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[HTTPValidationError, bool]]:
33
- if response.status_code == HTTPStatus.OK:
34
- response_200 = cast(bool, response.json())
35
- return response_200
36
- if response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY:
37
- response_422 = HTTPValidationError.from_dict(response.json())
38
-
39
- return response_422
40
- if client.raise_on_unexpected_status:
41
- raise errors.UnexpectedStatus(response.status_code, response.content)
42
- else:
43
- return None
44
-
45
-
46
- def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[HTTPValidationError, bool]]:
47
- return Response(
48
- status_code=HTTPStatus(response.status_code),
49
- content=response.content,
50
- headers=response.headers,
51
- parsed=_parse_response(client=client, response=response),
52
- )
53
-
54
-
55
- def sync_detailed(
56
- payment_method_id: str,
57
- *,
58
- client: Client,
59
- ) -> Response[Union[HTTPValidationError, bool]]:
60
- """Delete Payment Method
61
-
62
- Args:
63
- payment_method_id (str):
64
-
65
- Raises:
66
- errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
67
- httpx.TimeoutException: If the request takes longer than Client.timeout.
68
-
69
- Returns:
70
- Response[Union[HTTPValidationError, bool]]
71
- """
72
-
73
- kwargs = _get_kwargs(
74
- payment_method_id=payment_method_id,
75
- client=client,
76
- )
77
-
78
- response = httpx.request(
79
- verify=client.verify_ssl,
80
- **kwargs,
81
- )
82
-
83
- return _build_response(client=client, response=response)
84
-
85
-
86
- def sync(
87
- payment_method_id: str,
88
- *,
89
- client: Client,
90
- ) -> Optional[Union[HTTPValidationError, bool]]:
91
- """Delete Payment Method
92
-
93
- Args:
94
- payment_method_id (str):
95
-
96
- Raises:
97
- errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
98
- httpx.TimeoutException: If the request takes longer than Client.timeout.
99
-
100
- Returns:
101
- Union[HTTPValidationError, bool]
102
- """
103
-
104
- return sync_detailed(
105
- payment_method_id=payment_method_id,
106
- client=client,
107
- ).parsed
108
-
109
-
110
- async def asyncio_detailed(
111
- payment_method_id: str,
112
- *,
113
- client: Client,
114
- ) -> Response[Union[HTTPValidationError, bool]]:
115
- """Delete Payment Method
116
-
117
- Args:
118
- payment_method_id (str):
119
-
120
- Raises:
121
- errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
122
- httpx.TimeoutException: If the request takes longer than Client.timeout.
123
-
124
- Returns:
125
- Response[Union[HTTPValidationError, bool]]
126
- """
127
-
128
- kwargs = _get_kwargs(
129
- payment_method_id=payment_method_id,
130
- client=client,
131
- )
132
-
133
- async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
134
- response = await _client.request(**kwargs)
135
-
136
- return _build_response(client=client, response=response)
137
-
138
-
139
- async def asyncio(
140
- payment_method_id: str,
141
- *,
142
- client: Client,
143
- ) -> Optional[Union[HTTPValidationError, bool]]:
144
- """Delete Payment Method
145
-
146
- Args:
147
- payment_method_id (str):
148
-
149
- Raises:
150
- errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
151
- httpx.TimeoutException: If the request takes longer than Client.timeout.
152
-
153
- Returns:
154
- Union[HTTPValidationError, bool]
155
- """
156
-
157
- return (
158
- await asyncio_detailed(
159
- payment_method_id=payment_method_id,
160
- client=client,
161
- )
162
- ).parsed
@@ -1,198 +0,0 @@
1
- from http import HTTPStatus
2
- from typing import Any, Dict, Optional, Union, cast
3
-
4
- import httpx
5
-
6
- from ... import errors
7
- from ...client import Client
8
- from ...models.http_validation_error import HTTPValidationError
9
- from ...types import UNSET, Response, Unset
10
-
11
-
12
- def _get_kwargs(
13
- *,
14
- client: Client,
15
- quantity: int,
16
- product: Union[Unset, None, str] = "fal_credits",
17
- success_url: Union[Unset, None, str] = "https://fal.ai/dashboard/billing",
18
- ) -> Dict[str, Any]:
19
- url = "{}/billing/checkout".format(client.base_url)
20
-
21
- headers: Dict[str, str] = client.get_headers()
22
- cookies: Dict[str, Any] = client.get_cookies()
23
-
24
- params: Dict[str, Any] = {}
25
- params["quantity"] = quantity
26
-
27
- params["product"] = product
28
-
29
- params["success_url"] = success_url
30
-
31
- params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
32
-
33
- return {
34
- "method": "post",
35
- "url": url,
36
- "headers": headers,
37
- "cookies": cookies,
38
- "timeout": client.get_timeout(),
39
- "follow_redirects": client.follow_redirects,
40
- "params": params,
41
- }
42
-
43
-
44
- def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[HTTPValidationError, str]]:
45
- if response.status_code == HTTPStatus.OK:
46
- response_200 = cast(str, response.json())
47
- return response_200
48
- if response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY:
49
- response_422 = HTTPValidationError.from_dict(response.json())
50
-
51
- return response_422
52
- if client.raise_on_unexpected_status:
53
- raise errors.UnexpectedStatus(response.status_code, response.content)
54
- else:
55
- return None
56
-
57
-
58
- def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[HTTPValidationError, str]]:
59
- return Response(
60
- status_code=HTTPStatus(response.status_code),
61
- content=response.content,
62
- headers=response.headers,
63
- parsed=_parse_response(client=client, response=response),
64
- )
65
-
66
-
67
- def sync_detailed(
68
- *,
69
- client: Client,
70
- quantity: int,
71
- product: Union[Unset, None, str] = "fal_credits",
72
- success_url: Union[Unset, None, str] = "https://fal.ai/dashboard/billing",
73
- ) -> Response[Union[HTTPValidationError, str]]:
74
- """Get Checkout Page
75
-
76
- Args:
77
- quantity (int):
78
- product (Union[Unset, None, str]): Default: 'fal_credits'.
79
- success_url (Union[Unset, None, str]): Default: 'https://fal.ai/dashboard/billing'.
80
-
81
- Raises:
82
- errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
83
- httpx.TimeoutException: If the request takes longer than Client.timeout.
84
-
85
- Returns:
86
- Response[Union[HTTPValidationError, str]]
87
- """
88
-
89
- kwargs = _get_kwargs(
90
- client=client,
91
- quantity=quantity,
92
- product=product,
93
- success_url=success_url,
94
- )
95
-
96
- response = httpx.request(
97
- verify=client.verify_ssl,
98
- **kwargs,
99
- )
100
-
101
- return _build_response(client=client, response=response)
102
-
103
-
104
- def sync(
105
- *,
106
- client: Client,
107
- quantity: int,
108
- product: Union[Unset, None, str] = "fal_credits",
109
- success_url: Union[Unset, None, str] = "https://fal.ai/dashboard/billing",
110
- ) -> Optional[Union[HTTPValidationError, str]]:
111
- """Get Checkout Page
112
-
113
- Args:
114
- quantity (int):
115
- product (Union[Unset, None, str]): Default: 'fal_credits'.
116
- success_url (Union[Unset, None, str]): Default: 'https://fal.ai/dashboard/billing'.
117
-
118
- Raises:
119
- errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
120
- httpx.TimeoutException: If the request takes longer than Client.timeout.
121
-
122
- Returns:
123
- Union[HTTPValidationError, str]
124
- """
125
-
126
- return sync_detailed(
127
- client=client,
128
- quantity=quantity,
129
- product=product,
130
- success_url=success_url,
131
- ).parsed
132
-
133
-
134
- async def asyncio_detailed(
135
- *,
136
- client: Client,
137
- quantity: int,
138
- product: Union[Unset, None, str] = "fal_credits",
139
- success_url: Union[Unset, None, str] = "https://fal.ai/dashboard/billing",
140
- ) -> Response[Union[HTTPValidationError, str]]:
141
- """Get Checkout Page
142
-
143
- Args:
144
- quantity (int):
145
- product (Union[Unset, None, str]): Default: 'fal_credits'.
146
- success_url (Union[Unset, None, str]): Default: 'https://fal.ai/dashboard/billing'.
147
-
148
- Raises:
149
- errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
150
- httpx.TimeoutException: If the request takes longer than Client.timeout.
151
-
152
- Returns:
153
- Response[Union[HTTPValidationError, str]]
154
- """
155
-
156
- kwargs = _get_kwargs(
157
- client=client,
158
- quantity=quantity,
159
- product=product,
160
- success_url=success_url,
161
- )
162
-
163
- async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
164
- response = await _client.request(**kwargs)
165
-
166
- return _build_response(client=client, response=response)
167
-
168
-
169
- async def asyncio(
170
- *,
171
- client: Client,
172
- quantity: int,
173
- product: Union[Unset, None, str] = "fal_credits",
174
- success_url: Union[Unset, None, str] = "https://fal.ai/dashboard/billing",
175
- ) -> Optional[Union[HTTPValidationError, str]]:
176
- """Get Checkout Page
177
-
178
- Args:
179
- quantity (int):
180
- product (Union[Unset, None, str]): Default: 'fal_credits'.
181
- success_url (Union[Unset, None, str]): Default: 'https://fal.ai/dashboard/billing'.
182
-
183
- Raises:
184
- errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
185
- httpx.TimeoutException: If the request takes longer than Client.timeout.
186
-
187
- Returns:
188
- Union[HTTPValidationError, str]
189
- """
190
-
191
- return (
192
- await asyncio_detailed(
193
- client=client,
194
- quantity=quantity,
195
- product=product,
196
- success_url=success_url,
197
- )
198
- ).parsed
@@ -1,141 +0,0 @@
1
- from http import HTTPStatus
2
- from typing import Any, Dict, Optional, Union, cast
3
-
4
- import httpx
5
-
6
- from ... import errors
7
- from ...client import Client
8
- from ...models.http_validation_error import HTTPValidationError
9
- from ...types import Response
10
-
11
-
12
- def _get_kwargs(
13
- *,
14
- client: Client,
15
- ) -> Dict[str, Any]:
16
- url = "{}/billing/setup_intent_key".format(client.base_url)
17
-
18
- headers: Dict[str, str] = client.get_headers()
19
- cookies: Dict[str, Any] = client.get_cookies()
20
-
21
- return {
22
- "method": "get",
23
- "url": url,
24
- "headers": headers,
25
- "cookies": cookies,
26
- "timeout": client.get_timeout(),
27
- "follow_redirects": client.follow_redirects,
28
- }
29
-
30
-
31
- def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[HTTPValidationError, str]]:
32
- if response.status_code == HTTPStatus.OK:
33
- response_200 = cast(str, response.json())
34
- return response_200
35
- if response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY:
36
- response_422 = HTTPValidationError.from_dict(response.json())
37
-
38
- return response_422
39
- if client.raise_on_unexpected_status:
40
- raise errors.UnexpectedStatus(response.status_code, response.content)
41
- else:
42
- return None
43
-
44
-
45
- def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[HTTPValidationError, str]]:
46
- return Response(
47
- status_code=HTTPStatus(response.status_code),
48
- content=response.content,
49
- headers=response.headers,
50
- parsed=_parse_response(client=client, response=response),
51
- )
52
-
53
-
54
- def sync_detailed(
55
- *,
56
- client: Client,
57
- ) -> Response[Union[HTTPValidationError, str]]:
58
- """Get Setup Intent Key
59
-
60
- Raises:
61
- errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
62
- httpx.TimeoutException: If the request takes longer than Client.timeout.
63
-
64
- Returns:
65
- Response[Union[HTTPValidationError, str]]
66
- """
67
-
68
- kwargs = _get_kwargs(
69
- client=client,
70
- )
71
-
72
- response = httpx.request(
73
- verify=client.verify_ssl,
74
- **kwargs,
75
- )
76
-
77
- return _build_response(client=client, response=response)
78
-
79
-
80
- def sync(
81
- *,
82
- client: Client,
83
- ) -> Optional[Union[HTTPValidationError, str]]:
84
- """Get Setup Intent Key
85
-
86
- Raises:
87
- errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
88
- httpx.TimeoutException: If the request takes longer than Client.timeout.
89
-
90
- Returns:
91
- Union[HTTPValidationError, str]
92
- """
93
-
94
- return sync_detailed(
95
- client=client,
96
- ).parsed
97
-
98
-
99
- async def asyncio_detailed(
100
- *,
101
- client: Client,
102
- ) -> Response[Union[HTTPValidationError, str]]:
103
- """Get Setup Intent Key
104
-
105
- Raises:
106
- errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
107
- httpx.TimeoutException: If the request takes longer than Client.timeout.
108
-
109
- Returns:
110
- Response[Union[HTTPValidationError, str]]
111
- """
112
-
113
- kwargs = _get_kwargs(
114
- client=client,
115
- )
116
-
117
- async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
118
- response = await _client.request(**kwargs)
119
-
120
- return _build_response(client=client, response=response)
121
-
122
-
123
- async def asyncio(
124
- *,
125
- client: Client,
126
- ) -> Optional[Union[HTTPValidationError, str]]:
127
- """Get Setup Intent Key
128
-
129
- Raises:
130
- errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
131
- httpx.TimeoutException: If the request takes longer than Client.timeout.
132
-
133
- Returns:
134
- Union[HTTPValidationError, str]
135
- """
136
-
137
- return (
138
- await asyncio_detailed(
139
- client=client,
140
- )
141
- ).parsed