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