diff --git a/.github/workflows/integration_tests.yaml b/.github/workflows/integration_tests.yaml index e44eab34..3a22424f 100644 --- a/.github/workflows/integration_tests.yaml +++ b/.github/workflows/integration_tests.yaml @@ -19,7 +19,7 @@ jobs: - uses: actions/setup-python@v4 with: - python-version: "3.9" + python-version: "3.10" - name: Install dependencies run: | diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index efc6a016..40cfdb0e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,7 +19,8 @@ repos: - id: black exclude: | (?x)( - ^projects/fal/src/fal/toolkit/image/image.py + ^projects/fal/src/fal/toolkit/image/image.py | + ^projects/fal/openapi-fal-rest/ ) - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.3.0 diff --git a/projects/fal/openapi-fal-rest/openapi_fal_rest/api/admin/get_invoice_users.py b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/admin/get_invoice_users.py new file mode 100644 index 00000000..4e0c0e2f --- /dev/null +++ b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/admin/get_invoice_users.py @@ -0,0 +1,142 @@ +from http import HTTPStatus +from typing import Any, Dict, List, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import Client +from ...models.http_validation_error import HTTPValidationError +from ...types import Response + + +def _get_kwargs( + *, + client: Client, +) -> Dict[str, Any]: + url = "{}/admin/users/invoice_users".format(client.base_url) + + headers: Dict[str, str] = client.get_headers() + cookies: Dict[str, Any] = client.get_cookies() + + return { + "method": "get", + "url": url, + "headers": headers, + "cookies": cookies, + "timeout": client.get_timeout(), + "follow_redirects": client.follow_redirects, + } + + +def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[HTTPValidationError, List[str]]]: + if response.status_code == HTTPStatus.OK: + response_200 = cast(List[str], response.json()) + + return response_200 + if response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY: + response_422 = HTTPValidationError.from_dict(response.json()) + + return response_422 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[HTTPValidationError, List[str]]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Client, +) -> Response[Union[HTTPValidationError, List[str]]]: + """Get Invoice Users + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, List[str]]] + """ + + kwargs = _get_kwargs( + client=client, + ) + + response = httpx.request( + verify=client.verify_ssl, + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Client, +) -> Optional[Union[HTTPValidationError, List[str]]]: + """Get Invoice Users + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[HTTPValidationError, List[str]] + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed( + *, + client: Client, +) -> Response[Union[HTTPValidationError, List[str]]]: + """Get Invoice Users + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, List[str]]] + """ + + kwargs = _get_kwargs( + client=client, + ) + + async with httpx.AsyncClient(verify=client.verify_ssl) as _client: + response = await _client.request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Client, +) -> Optional[Union[HTTPValidationError, List[str]]]: + """Get Invoice Users + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[HTTPValidationError, List[str]] + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/projects/fal/openapi-fal-rest/openapi_fal_rest/api/admin/handle_user_lock.py b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/admin/handle_user_lock.py index db3f2880..7b338387 100644 --- a/projects/fal/openapi-fal-rest/openapi_fal_rest/api/admin/handle_user_lock.py +++ b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/admin/handle_user_lock.py @@ -38,9 +38,7 @@ def _get_kwargs( } -def _parse_response( - *, client: Client, response: httpx.Response -) -> Optional[Union[HTTPValidationError, str]]: +def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[HTTPValidationError, str]]: if response.status_code == HTTPStatus.OK: response_200 = cast(str, response.json()) return response_200 @@ -54,9 +52,7 @@ def _parse_response( return None -def _build_response( - *, client: Client, response: httpx.Response -) -> Response[Union[HTTPValidationError, str]]: +def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[HTTPValidationError, str]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/projects/fal/openapi-fal-rest/openapi_fal_rest/api/admin/set_billing_type.py b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/admin/set_billing_type.py new file mode 100644 index 00000000..0955bbb3 --- /dev/null +++ b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/admin/set_billing_type.py @@ -0,0 +1,186 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import Client +from ...models.billing_type import BillingType +from ...models.http_validation_error import HTTPValidationError +from ...types import UNSET, Response + + +def _get_kwargs( + *, + client: Client, + user_id: str, + billing_type: BillingType, +) -> Dict[str, Any]: + url = "{}/admin/users/set_billing_type".format(client.base_url) + + headers: Dict[str, str] = client.get_headers() + cookies: Dict[str, Any] = client.get_cookies() + + params: Dict[str, Any] = {} + params["user_id"] = user_id + + json_billing_type = billing_type.value + + params["billing_type"] = json_billing_type + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + return { + "method": "post", + "url": url, + "headers": headers, + "cookies": cookies, + "timeout": client.get_timeout(), + "follow_redirects": client.follow_redirects, + "params": params, + } + + +def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[HTTPValidationError, bool]]: + if response.status_code == HTTPStatus.OK: + response_200 = cast(bool, response.json()) + return response_200 + if response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY: + response_422 = HTTPValidationError.from_dict(response.json()) + + return response_422 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[HTTPValidationError, bool]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Client, + user_id: str, + billing_type: BillingType, +) -> Response[Union[HTTPValidationError, bool]]: + """Set Billing Type + + Args: + user_id (str): + billing_type (BillingType): An enumeration. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, bool]] + """ + + kwargs = _get_kwargs( + client=client, + user_id=user_id, + billing_type=billing_type, + ) + + response = httpx.request( + verify=client.verify_ssl, + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Client, + user_id: str, + billing_type: BillingType, +) -> Optional[Union[HTTPValidationError, bool]]: + """Set Billing Type + + Args: + user_id (str): + billing_type (BillingType): An enumeration. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[HTTPValidationError, bool] + """ + + return sync_detailed( + client=client, + user_id=user_id, + billing_type=billing_type, + ).parsed + + +async def asyncio_detailed( + *, + client: Client, + user_id: str, + billing_type: BillingType, +) -> Response[Union[HTTPValidationError, bool]]: + """Set Billing Type + + Args: + user_id (str): + billing_type (BillingType): An enumeration. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, bool]] + """ + + kwargs = _get_kwargs( + client=client, + user_id=user_id, + billing_type=billing_type, + ) + + async with httpx.AsyncClient(verify=client.verify_ssl) as _client: + response = await _client.request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Client, + user_id: str, + billing_type: BillingType, +) -> Optional[Union[HTTPValidationError, bool]]: + """Set Billing Type + + Args: + user_id (str): + billing_type (BillingType): An enumeration. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[HTTPValidationError, bool] + """ + + return ( + await asyncio_detailed( + client=client, + user_id=user_id, + billing_type=billing_type, + ) + ).parsed diff --git a/projects/fal/openapi-fal-rest/openapi_fal_rest/api/applications/get_status_applications_app_user_id_app_alias_or_id_status_get.py b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/applications/get_status_applications_app_user_id_app_alias_or_id_status_get.py index 9d4e7d70..646e6758 100644 --- a/projects/fal/openapi-fal-rest/openapi_fal_rest/api/applications/get_status_applications_app_user_id_app_alias_or_id_status_get.py +++ b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/applications/get_status_applications_app_user_id_app_alias_or_id_status_get.py @@ -33,9 +33,7 @@ def _get_kwargs( } -def _parse_response( - *, client: Client, response: httpx.Response -) -> Optional[Union[HTTPValidationError, Status]]: +def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[HTTPValidationError, Status]]: if response.status_code == HTTPStatus.OK: response_200 = Status.from_dict(response.json()) @@ -50,9 +48,7 @@ def _parse_response( return None -def _build_response( - *, client: Client, response: httpx.Response -) -> Response[Union[HTTPValidationError, Status]]: +def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[HTTPValidationError, Status]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/projects/fal/openapi-fal-rest/openapi_fal_rest/api/billing/delete_payment_method.py b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/billing/delete_payment_method.py index f3b5213d..ddf0273d 100644 --- a/projects/fal/openapi-fal-rest/openapi_fal_rest/api/billing/delete_payment_method.py +++ b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/billing/delete_payment_method.py @@ -14,9 +14,7 @@ def _get_kwargs( *, client: Client, ) -> Dict[str, Any]: - url = "{}/billing/payment_methods/{payment_method_id}".format( - client.base_url, payment_method_id=payment_method_id - ) + url = "{}/billing/payment_methods/{payment_method_id}".format(client.base_url, payment_method_id=payment_method_id) headers: Dict[str, str] = client.get_headers() cookies: Dict[str, Any] = client.get_cookies() @@ -31,9 +29,7 @@ def _get_kwargs( } -def _parse_response( - *, client: Client, response: httpx.Response -) -> Optional[Union[HTTPValidationError, bool]]: +def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[HTTPValidationError, bool]]: if response.status_code == HTTPStatus.OK: response_200 = cast(bool, response.json()) return response_200 @@ -47,9 +43,7 @@ def _parse_response( return None -def _build_response( - *, client: Client, response: httpx.Response -) -> Response[Union[HTTPValidationError, bool]]: +def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[HTTPValidationError, bool]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/projects/fal/openapi-fal-rest/openapi_fal_rest/api/billing/get_checkout_page.py b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/billing/get_checkout_page.py new file mode 100644 index 00000000..3e156b58 --- /dev/null +++ b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/billing/get_checkout_page.py @@ -0,0 +1,198 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import Client +from ...models.http_validation_error import HTTPValidationError +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + client: Client, + quantity: int, + product: Union[Unset, None, str] = "fal_credits", + success_url: Union[Unset, None, str] = "https://fal.ai/dashboard/billing", +) -> Dict[str, Any]: + url = "{}/billing/checkout".format(client.base_url) + + headers: Dict[str, str] = client.get_headers() + cookies: Dict[str, Any] = client.get_cookies() + + params: Dict[str, Any] = {} + params["quantity"] = quantity + + params["product"] = product + + params["success_url"] = success_url + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + return { + "method": "post", + "url": url, + "headers": headers, + "cookies": cookies, + "timeout": client.get_timeout(), + "follow_redirects": client.follow_redirects, + "params": params, + } + + +def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[HTTPValidationError, str]]: + if response.status_code == HTTPStatus.OK: + response_200 = cast(str, response.json()) + return response_200 + if response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY: + response_422 = HTTPValidationError.from_dict(response.json()) + + return response_422 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[HTTPValidationError, str]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Client, + quantity: int, + product: Union[Unset, None, str] = "fal_credits", + success_url: Union[Unset, None, str] = "https://fal.ai/dashboard/billing", +) -> Response[Union[HTTPValidationError, str]]: + """Get Checkout Page + + Args: + quantity (int): + product (Union[Unset, None, str]): Default: 'fal_credits'. + success_url (Union[Unset, None, str]): Default: 'https://fal.ai/dashboard/billing'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, str]] + """ + + kwargs = _get_kwargs( + client=client, + quantity=quantity, + product=product, + success_url=success_url, + ) + + response = httpx.request( + verify=client.verify_ssl, + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Client, + quantity: int, + product: Union[Unset, None, str] = "fal_credits", + success_url: Union[Unset, None, str] = "https://fal.ai/dashboard/billing", +) -> Optional[Union[HTTPValidationError, str]]: + """Get Checkout Page + + Args: + quantity (int): + product (Union[Unset, None, str]): Default: 'fal_credits'. + success_url (Union[Unset, None, str]): Default: 'https://fal.ai/dashboard/billing'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[HTTPValidationError, str] + """ + + return sync_detailed( + client=client, + quantity=quantity, + product=product, + success_url=success_url, + ).parsed + + +async def asyncio_detailed( + *, + client: Client, + quantity: int, + product: Union[Unset, None, str] = "fal_credits", + success_url: Union[Unset, None, str] = "https://fal.ai/dashboard/billing", +) -> Response[Union[HTTPValidationError, str]]: + """Get Checkout Page + + Args: + quantity (int): + product (Union[Unset, None, str]): Default: 'fal_credits'. + success_url (Union[Unset, None, str]): Default: 'https://fal.ai/dashboard/billing'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, str]] + """ + + kwargs = _get_kwargs( + client=client, + quantity=quantity, + product=product, + success_url=success_url, + ) + + async with httpx.AsyncClient(verify=client.verify_ssl) as _client: + response = await _client.request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Client, + quantity: int, + product: Union[Unset, None, str] = "fal_credits", + success_url: Union[Unset, None, str] = "https://fal.ai/dashboard/billing", +) -> Optional[Union[HTTPValidationError, str]]: + """Get Checkout Page + + Args: + quantity (int): + product (Union[Unset, None, str]): Default: 'fal_credits'. + success_url (Union[Unset, None, str]): Default: 'https://fal.ai/dashboard/billing'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[HTTPValidationError, str] + """ + + return ( + await asyncio_detailed( + client=client, + quantity=quantity, + product=product, + success_url=success_url, + ) + ).parsed diff --git a/projects/fal/openapi-fal-rest/openapi_fal_rest/api/billing/get_setup_intent_key.py b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/billing/get_setup_intent_key.py index d06419d8..a4eac7bb 100644 --- a/projects/fal/openapi-fal-rest/openapi_fal_rest/api/billing/get_setup_intent_key.py +++ b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/billing/get_setup_intent_key.py @@ -28,9 +28,7 @@ def _get_kwargs( } -def _parse_response( - *, client: Client, response: httpx.Response -) -> Optional[Union[HTTPValidationError, str]]: +def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[HTTPValidationError, str]]: if response.status_code == HTTPStatus.OK: response_200 = cast(str, response.json()) return response_200 @@ -44,9 +42,7 @@ def _parse_response( return None -def _build_response( - *, client: Client, response: httpx.Response -) -> Response[Union[HTTPValidationError, str]]: +def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[HTTPValidationError, str]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/projects/fal/openapi-fal-rest/openapi_fal_rest/api/billing/get_user_price.py b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/billing/get_user_price.py index 87541013..84169cec 100644 --- a/projects/fal/openapi-fal-rest/openapi_fal_rest/api/billing/get_user_price.py +++ b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/billing/get_user_price.py @@ -41,9 +41,7 @@ def _get_kwargs( } -def _parse_response( - *, client: Client, response: httpx.Response -) -> Optional[Union[HTTPValidationError, float]]: +def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[HTTPValidationError, float]]: if response.status_code == HTTPStatus.OK: response_200 = cast(float, response.json()) return response_200 @@ -57,9 +55,7 @@ def _parse_response( return None -def _build_response( - *, client: Client, response: httpx.Response -) -> Response[Union[HTTPValidationError, float]]: +def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[HTTPValidationError, float]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/projects/fal/openapi-fal-rest/openapi_fal_rest/api/billing/get_user_spending.py b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/billing/get_user_spending.py index 88c7dee3..f9c81490 100644 --- a/projects/fal/openapi-fal-rest/openapi_fal_rest/api/billing/get_user_spending.py +++ b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/billing/get_user_spending.py @@ -47,9 +47,7 @@ def _get_kwargs( } -def _parse_response( - *, client: Client, response: httpx.Response -) -> Optional[Union[HTTPValidationError, float]]: +def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[HTTPValidationError, float]]: if response.status_code == HTTPStatus.OK: response_200 = cast(float, response.json()) return response_200 @@ -63,9 +61,7 @@ def _parse_response( return None -def _build_response( - *, client: Client, response: httpx.Response -) -> Response[Union[HTTPValidationError, float]]: +def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[HTTPValidationError, float]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/projects/fal/openapi-fal-rest/openapi_fal_rest/api/billing/handle_stripe_webhook.py b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/billing/handle_stripe_webhook.py index aa937e7d..5a6288ec 100644 --- a/projects/fal/openapi-fal-rest/openapi_fal_rest/api/billing/handle_stripe_webhook.py +++ b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/billing/handle_stripe_webhook.py @@ -37,13 +37,9 @@ def _get_kwargs( def _parse_response( *, client: Client, response: httpx.Response -) -> Optional[ - Union[HTTPValidationError, HandleStripeWebhookResponseHandleStripeWebhook] -]: +) -> Optional[Union[HTTPValidationError, HandleStripeWebhookResponseHandleStripeWebhook]]: if response.status_code == HTTPStatus.OK: - response_200 = HandleStripeWebhookResponseHandleStripeWebhook.from_dict( - response.json() - ) + response_200 = HandleStripeWebhookResponseHandleStripeWebhook.from_dict(response.json()) return response_200 if response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY: @@ -58,9 +54,7 @@ def _parse_response( def _build_response( *, client: Client, response: httpx.Response -) -> Response[ - Union[HTTPValidationError, HandleStripeWebhookResponseHandleStripeWebhook] -]: +) -> Response[Union[HTTPValidationError, HandleStripeWebhookResponseHandleStripeWebhook]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -73,9 +67,7 @@ def sync_detailed( *, client: Client, stripe_signature: Union[Unset, str] = UNSET, -) -> Response[ - Union[HTTPValidationError, HandleStripeWebhookResponseHandleStripeWebhook] -]: +) -> Response[Union[HTTPValidationError, HandleStripeWebhookResponseHandleStripeWebhook]]: """Handle Stripe Webhook Args: @@ -106,9 +98,7 @@ def sync( *, client: Client, stripe_signature: Union[Unset, str] = UNSET, -) -> Optional[ - Union[HTTPValidationError, HandleStripeWebhookResponseHandleStripeWebhook] -]: +) -> Optional[Union[HTTPValidationError, HandleStripeWebhookResponseHandleStripeWebhook]]: """Handle Stripe Webhook Args: @@ -132,9 +122,7 @@ async def asyncio_detailed( *, client: Client, stripe_signature: Union[Unset, str] = UNSET, -) -> Response[ - Union[HTTPValidationError, HandleStripeWebhookResponseHandleStripeWebhook] -]: +) -> Response[Union[HTTPValidationError, HandleStripeWebhookResponseHandleStripeWebhook]]: """Handle Stripe Webhook Args: @@ -163,9 +151,7 @@ async def asyncio( *, client: Client, stripe_signature: Union[Unset, str] = UNSET, -) -> Optional[ - Union[HTTPValidationError, HandleStripeWebhookResponseHandleStripeWebhook] -]: +) -> Optional[Union[HTTPValidationError, HandleStripeWebhookResponseHandleStripeWebhook]]: """Handle Stripe Webhook Args: diff --git a/projects/fal/openapi-fal-rest/openapi_fal_rest/api/billing/upcoming_invoice.py b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/billing/upcoming_invoice.py index 08343199..c6c01964 100644 --- a/projects/fal/openapi-fal-rest/openapi_fal_rest/api/billing/upcoming_invoice.py +++ b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/billing/upcoming_invoice.py @@ -29,9 +29,7 @@ def _get_kwargs( } -def _parse_response( - *, client: Client, response: httpx.Response -) -> Optional[Union[HTTPValidationError, Invoice]]: +def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[HTTPValidationError, Invoice]]: if response.status_code == HTTPStatus.OK: response_200 = Invoice.from_dict(response.json()) @@ -46,9 +44,7 @@ def _parse_response( return None -def _build_response( - *, client: Client, response: httpx.Response -) -> Response[Union[HTTPValidationError, Invoice]]: +def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[HTTPValidationError, Invoice]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/projects/fal/openapi-fal-rest/openapi_fal_rest/api/billing/update_customer_budget.py b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/billing/update_customer_budget.py index b43de544..de5d1bbf 100644 --- a/projects/fal/openapi-fal-rest/openapi_fal_rest/api/billing/update_customer_budget.py +++ b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/billing/update_customer_budget.py @@ -38,9 +38,7 @@ def _get_kwargs( } -def _parse_response( - *, client: Client, response: httpx.Response -) -> Optional[Union[Any, HTTPValidationError]]: +def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[Any, HTTPValidationError]]: if response.status_code == HTTPStatus.OK: response_200 = cast(Any, response.json()) return response_200 @@ -54,9 +52,7 @@ def _parse_response( return None -def _build_response( - *, client: Client, response: httpx.Response -) -> Response[Union[Any, HTTPValidationError]]: +def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[Any, HTTPValidationError]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/projects/fal/openapi-fal-rest/openapi_fal_rest/api/files/check_dir_hash.py b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/files/check_dir_hash.py index 54c3537c..6ec7a76d 100644 --- a/projects/fal/openapi-fal-rest/openapi_fal_rest/api/files/check_dir_hash.py +++ b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/files/check_dir_hash.py @@ -16,9 +16,7 @@ def _get_kwargs( client: Client, json_body: HashCheck, ) -> Dict[str, Any]: - url = "{}/files/dir/check_hash/{target_path}".format( - client.base_url, target_path=target_path - ) + url = "{}/files/dir/check_hash/{target_path}".format(client.base_url, target_path=target_path) headers: Dict[str, str] = client.get_headers() cookies: Dict[str, Any] = client.get_cookies() @@ -36,9 +34,7 @@ def _get_kwargs( } -def _parse_response( - *, client: Client, response: httpx.Response -) -> Optional[Union[HTTPValidationError, bool]]: +def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[HTTPValidationError, bool]]: if response.status_code == HTTPStatus.OK: response_200 = cast(bool, response.json()) return response_200 @@ -52,9 +48,7 @@ def _parse_response( return None -def _build_response( - *, client: Client, response: httpx.Response -) -> Response[Union[HTTPValidationError, bool]]: +def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[HTTPValidationError, bool]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/projects/fal/openapi-fal-rest/openapi_fal_rest/api/files/delete.py b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/files/delete.py index cf9cf737..7d369487 100644 --- a/projects/fal/openapi-fal-rest/openapi_fal_rest/api/files/delete.py +++ b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/files/delete.py @@ -29,9 +29,7 @@ def _get_kwargs( } -def _parse_response( - *, client: Client, response: httpx.Response -) -> Optional[Union[HTTPValidationError, bool]]: +def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[HTTPValidationError, bool]]: if response.status_code == HTTPStatus.OK: response_200 = cast(bool, response.json()) return response_200 @@ -45,9 +43,7 @@ def _parse_response( return None -def _build_response( - *, client: Client, response: httpx.Response -) -> Response[Union[HTTPValidationError, bool]]: +def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[HTTPValidationError, bool]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/projects/fal/openapi-fal-rest/openapi_fal_rest/api/files/download.py b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/files/download.py index fd55f372..080e6115 100644 --- a/projects/fal/openapi-fal-rest/openapi_fal_rest/api/files/download.py +++ b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/files/download.py @@ -29,9 +29,7 @@ def _get_kwargs( } -def _parse_response( - *, client: Client, response: httpx.Response -) -> Optional[Union[Any, HTTPValidationError]]: +def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[Any, HTTPValidationError]]: if response.status_code == HTTPStatus.OK: response_200 = cast(Any, response.json()) return response_200 @@ -45,9 +43,7 @@ def _parse_response( return None -def _build_response( - *, client: Client, response: httpx.Response -) -> Response[Union[Any, HTTPValidationError]]: +def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[Any, HTTPValidationError]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/projects/fal/openapi-fal-rest/openapi_fal_rest/api/files/file_exists.py b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/files/file_exists.py index f5ee03ca..c54b608b 100644 --- a/projects/fal/openapi-fal-rest/openapi_fal_rest/api/files/file_exists.py +++ b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/files/file_exists.py @@ -37,9 +37,7 @@ def _get_kwargs( } -def _parse_response( - *, client: Client, response: httpx.Response -) -> Optional[Union[FileSpec, HTTPValidationError]]: +def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[FileSpec, HTTPValidationError]]: if response.status_code == HTTPStatus.OK: response_200 = FileSpec.from_dict(response.json()) @@ -54,9 +52,7 @@ def _parse_response( return None -def _build_response( - *, client: Client, response: httpx.Response -) -> Response[Union[FileSpec, HTTPValidationError]]: +def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[FileSpec, HTTPValidationError]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/projects/fal/openapi-fal-rest/openapi_fal_rest/api/files/upload_from_url.py b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/files/upload_from_url.py index 6d263a1b..333a05e8 100644 --- a/projects/fal/openapi-fal-rest/openapi_fal_rest/api/files/upload_from_url.py +++ b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/files/upload_from_url.py @@ -34,9 +34,7 @@ def _get_kwargs( } -def _parse_response( - *, client: Client, response: httpx.Response -) -> Optional[Union[HTTPValidationError, bool]]: +def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[HTTPValidationError, bool]]: if response.status_code == HTTPStatus.OK: response_200 = cast(bool, response.json()) return response_200 @@ -50,9 +48,7 @@ def _parse_response( return None -def _build_response( - *, client: Client, response: httpx.Response -) -> Response[Union[HTTPValidationError, bool]]: +def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[HTTPValidationError, bool]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/projects/fal/openapi-fal-rest/openapi_fal_rest/api/files/upload_local_file.py b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/files/upload_local_file.py index 562e5a94..4e57b78a 100644 --- a/projects/fal/openapi-fal-rest/openapi_fal_rest/api/files/upload_local_file.py +++ b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/files/upload_local_file.py @@ -17,9 +17,7 @@ def _get_kwargs( multipart_data: BodyUploadLocalFile, unzip: Union[Unset, None, bool] = False, ) -> Dict[str, Any]: - url = "{}/files/file/local/{target_path}".format( - client.base_url, target_path=target_path - ) + url = "{}/files/file/local/{target_path}".format(client.base_url, target_path=target_path) headers: Dict[str, str] = client.get_headers() cookies: Dict[str, Any] = client.get_cookies() @@ -43,9 +41,7 @@ def _get_kwargs( } -def _parse_response( - *, client: Client, response: httpx.Response -) -> Optional[Union[HTTPValidationError, bool]]: +def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[HTTPValidationError, bool]]: if response.status_code == HTTPStatus.OK: response_200 = cast(bool, response.json()) return response_200 @@ -59,9 +55,7 @@ def _parse_response( return None -def _build_response( - *, client: Client, response: httpx.Response -) -> Response[Union[HTTPValidationError, bool]]: +def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[HTTPValidationError, bool]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/projects/fal/openapi-fal-rest/openapi_fal_rest/api/keys/create_key.py b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/keys/create_key.py index 16405163..5320abff 100644 --- a/projects/fal/openapi-fal-rest/openapi_fal_rest/api/keys/create_key.py +++ b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/keys/create_key.py @@ -42,9 +42,7 @@ def _get_kwargs( } -def _parse_response( - *, client: Client, response: httpx.Response -) -> Optional[Union[HTTPValidationError, NewUserKey]]: +def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[HTTPValidationError, NewUserKey]]: if response.status_code == HTTPStatus.CREATED: response_201 = NewUserKey.from_dict(response.json()) @@ -59,9 +57,7 @@ def _parse_response( return None -def _build_response( - *, client: Client, response: httpx.Response -) -> Response[Union[HTTPValidationError, NewUserKey]]: +def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[HTTPValidationError, NewUserKey]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/projects/fal/openapi-fal-rest/openapi_fal_rest/api/keys/delete_key.py b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/keys/delete_key.py index 43f1c80b..6539f8ce 100644 --- a/projects/fal/openapi-fal-rest/openapi_fal_rest/api/keys/delete_key.py +++ b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/keys/delete_key.py @@ -29,9 +29,7 @@ def _get_kwargs( } -def _parse_response( - *, client: Client, response: httpx.Response -) -> Optional[Union[Any, HTTPValidationError]]: +def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[Any, HTTPValidationError]]: if response.status_code == HTTPStatus.NO_CONTENT: response_204 = cast(Any, None) return response_204 @@ -45,9 +43,7 @@ def _parse_response( return None -def _build_response( - *, client: Client, response: httpx.Response -) -> Response[Union[Any, HTTPValidationError]]: +def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[Any, HTTPValidationError]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/projects/fal/openapi-fal-rest/openapi_fal_rest/api/tokens/create_token.py b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/tokens/create_token.py index 49c6d586..0d286f24 100644 --- a/projects/fal/openapi-fal-rest/openapi_fal_rest/api/tokens/create_token.py +++ b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/tokens/create_token.py @@ -33,9 +33,7 @@ def _get_kwargs( } -def _parse_response( - *, client: Client, response: httpx.Response -) -> Optional[Union[HTTPValidationError, str]]: +def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[HTTPValidationError, str]]: if response.status_code == HTTPStatus.CREATED: response_201 = cast(str, response.json()) return response_201 @@ -49,9 +47,7 @@ def _parse_response( return None -def _build_response( - *, client: Client, response: httpx.Response -) -> Response[Union[HTTPValidationError, str]]: +def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[HTTPValidationError, str]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/projects/fal/openapi-fal-rest/openapi_fal_rest/api/usage/get_gateway_request_stats_by_time.py b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/usage/get_gateway_request_stats_by_time.py index ac07e91d..2394f111 100644 --- a/projects/fal/openapi-fal-rest/openapi_fal_rest/api/usage/get_gateway_request_stats_by_time.py +++ b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/usage/get_gateway_request_stats_by_time.py @@ -64,18 +64,9 @@ def _get_kwargs( def _parse_response( *, client: Client, response: httpx.Response -) -> Optional[ - Union[ - GetGatewayRequestStatsByTimeResponseGetGatewayRequestStatsByTime, - HTTPValidationError, - ] -]: +) -> Optional[Union[GetGatewayRequestStatsByTimeResponseGetGatewayRequestStatsByTime, HTTPValidationError]]: if response.status_code == HTTPStatus.OK: - response_200 = ( - GetGatewayRequestStatsByTimeResponseGetGatewayRequestStatsByTime.from_dict( - response.json() - ) - ) + response_200 = GetGatewayRequestStatsByTimeResponseGetGatewayRequestStatsByTime.from_dict(response.json()) return response_200 if response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY: @@ -90,12 +81,7 @@ def _parse_response( def _build_response( *, client: Client, response: httpx.Response -) -> Response[ - Union[ - GetGatewayRequestStatsByTimeResponseGetGatewayRequestStatsByTime, - HTTPValidationError, - ] -]: +) -> Response[Union[GetGatewayRequestStatsByTimeResponseGetGatewayRequestStatsByTime, HTTPValidationError]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -111,12 +97,7 @@ def sync_detailed( end_time: datetime.datetime, timeframe: StatsTimeframe, app_aliases: Union[Unset, None, List[str]] = UNSET, -) -> Response[ - Union[ - GetGatewayRequestStatsByTimeResponseGetGatewayRequestStatsByTime, - HTTPValidationError, - ] -]: +) -> Response[Union[GetGatewayRequestStatsByTimeResponseGetGatewayRequestStatsByTime, HTTPValidationError]]: """Get Gateway Request Stats By Time Args: @@ -156,12 +137,7 @@ def sync( end_time: datetime.datetime, timeframe: StatsTimeframe, app_aliases: Union[Unset, None, List[str]] = UNSET, -) -> Optional[ - Union[ - GetGatewayRequestStatsByTimeResponseGetGatewayRequestStatsByTime, - HTTPValidationError, - ] -]: +) -> Optional[Union[GetGatewayRequestStatsByTimeResponseGetGatewayRequestStatsByTime, HTTPValidationError]]: """Get Gateway Request Stats By Time Args: @@ -194,12 +170,7 @@ async def asyncio_detailed( end_time: datetime.datetime, timeframe: StatsTimeframe, app_aliases: Union[Unset, None, List[str]] = UNSET, -) -> Response[ - Union[ - GetGatewayRequestStatsByTimeResponseGetGatewayRequestStatsByTime, - HTTPValidationError, - ] -]: +) -> Response[Union[GetGatewayRequestStatsByTimeResponseGetGatewayRequestStatsByTime, HTTPValidationError]]: """Get Gateway Request Stats By Time Args: @@ -237,12 +208,7 @@ async def asyncio( end_time: datetime.datetime, timeframe: StatsTimeframe, app_aliases: Union[Unset, None, List[str]] = UNSET, -) -> Optional[ - Union[ - GetGatewayRequestStatsByTimeResponseGetGatewayRequestStatsByTime, - HTTPValidationError, - ] -]: +) -> Optional[Union[GetGatewayRequestStatsByTimeResponseGetGatewayRequestStatsByTime, HTTPValidationError]]: """Get Gateway Request Stats By Time Args: diff --git a/projects/fal/openapi-fal-rest/openapi_fal_rest/api/usage/get_gateway_stats_for_yesterday.py b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/usage/get_gateway_stats_for_yesterday.py new file mode 100644 index 00000000..6bce2e96 --- /dev/null +++ b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/usage/get_gateway_stats_for_yesterday.py @@ -0,0 +1,152 @@ +from http import HTTPStatus +from typing import Any, Dict, List, Optional, Union + +import httpx + +from ... import errors +from ...client import Client +from ...models.http_validation_error import HTTPValidationError +from ...models.per_app_usage_detail import PerAppUsageDetail +from ...types import Response + + +def _get_kwargs( + *, + client: Client, +) -> Dict[str, Any]: + url = "{}/usage/stats/yesterday".format(client.base_url) + + headers: Dict[str, str] = client.get_headers() + cookies: Dict[str, Any] = client.get_cookies() + + return { + "method": "get", + "url": url, + "headers": headers, + "cookies": cookies, + "timeout": client.get_timeout(), + "follow_redirects": client.follow_redirects, + } + + +def _parse_response( + *, client: Client, response: httpx.Response +) -> Optional[Union[HTTPValidationError, List["PerAppUsageDetail"]]]: + if response.status_code == HTTPStatus.OK: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in _response_200: + response_200_item = PerAppUsageDetail.from_dict(response_200_item_data) + + response_200.append(response_200_item) + + return response_200 + if response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY: + response_422 = HTTPValidationError.from_dict(response.json()) + + return response_422 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Client, response: httpx.Response +) -> Response[Union[HTTPValidationError, List["PerAppUsageDetail"]]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Client, +) -> Response[Union[HTTPValidationError, List["PerAppUsageDetail"]]]: + """Get Gateway Stats For Yesterday + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, List['PerAppUsageDetail']]] + """ + + kwargs = _get_kwargs( + client=client, + ) + + response = httpx.request( + verify=client.verify_ssl, + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Client, +) -> Optional[Union[HTTPValidationError, List["PerAppUsageDetail"]]]: + """Get Gateway Stats For Yesterday + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[HTTPValidationError, List['PerAppUsageDetail']] + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed( + *, + client: Client, +) -> Response[Union[HTTPValidationError, List["PerAppUsageDetail"]]]: + """Get Gateway Stats For Yesterday + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, List['PerAppUsageDetail']]] + """ + + kwargs = _get_kwargs( + client=client, + ) + + async with httpx.AsyncClient(verify=client.verify_ssl) as _client: + response = await _client.request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Client, +) -> Optional[Union[HTTPValidationError, List["PerAppUsageDetail"]]]: + """Get Gateway Stats For Yesterday + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[HTTPValidationError, List['PerAppUsageDetail']] + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/projects/fal/openapi-fal-rest/openapi_fal_rest/api/usage/per_machine_usage_details.py b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/usage/per_machine_usage_details.py index 0c18a018..79a8059c 100644 --- a/projects/fal/openapi-fal-rest/openapi_fal_rest/api/usage/per_machine_usage_details.py +++ b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/usage/per_machine_usage_details.py @@ -15,9 +15,7 @@ def _get_kwargs( *, client: Client, ) -> Dict[str, Any]: - url = "{}/usage/machine_type/{machine_type}".format( - client.base_url, machine_type=machine_type - ) + url = "{}/usage/machine_type/{machine_type}".format(client.base_url, machine_type=machine_type) headers: Dict[str, str] = client.get_headers() cookies: Dict[str, Any] = client.get_cookies() diff --git a/projects/fal/openapi-fal-rest/openapi_fal_rest/api/users/__init__.py b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/users/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/projects/fal/openapi-fal-rest/openapi_fal_rest/api/users/handle_user_registration.py b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/users/handle_user_registration.py new file mode 100644 index 00000000..12fd1310 --- /dev/null +++ b/projects/fal/openapi-fal-rest/openapi_fal_rest/api/users/handle_user_registration.py @@ -0,0 +1,228 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import Client +from ...models.http_validation_error import HTTPValidationError +from ...types import UNSET, Response + + +def _get_kwargs( + *, + client: Client, + user_id: str, + user_nickname: str, + user_email: str, + user_name: str, + secret: str, +) -> Dict[str, Any]: + url = "{}/users/register".format(client.base_url) + + headers: Dict[str, str] = client.get_headers() + cookies: Dict[str, Any] = client.get_cookies() + + params: Dict[str, Any] = {} + params["user_id"] = user_id + + params["user_nickname"] = user_nickname + + params["user_email"] = user_email + + params["user_name"] = user_name + + params["secret"] = secret + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + return { + "method": "post", + "url": url, + "headers": headers, + "cookies": cookies, + "timeout": client.get_timeout(), + "follow_redirects": client.follow_redirects, + "params": params, + } + + +def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[HTTPValidationError, str]]: + if response.status_code == HTTPStatus.OK: + response_200 = cast(str, response.json()) + return response_200 + if response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY: + response_422 = HTTPValidationError.from_dict(response.json()) + + return response_422 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[HTTPValidationError, str]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Client, + user_id: str, + user_nickname: str, + user_email: str, + user_name: str, + secret: str, +) -> Response[Union[HTTPValidationError, str]]: + """Handle User Registration + + Args: + user_id (str): + user_nickname (str): + user_email (str): + user_name (str): + secret (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, str]] + """ + + kwargs = _get_kwargs( + client=client, + user_id=user_id, + user_nickname=user_nickname, + user_email=user_email, + user_name=user_name, + secret=secret, + ) + + response = httpx.request( + verify=client.verify_ssl, + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Client, + user_id: str, + user_nickname: str, + user_email: str, + user_name: str, + secret: str, +) -> Optional[Union[HTTPValidationError, str]]: + """Handle User Registration + + Args: + user_id (str): + user_nickname (str): + user_email (str): + user_name (str): + secret (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[HTTPValidationError, str] + """ + + return sync_detailed( + client=client, + user_id=user_id, + user_nickname=user_nickname, + user_email=user_email, + user_name=user_name, + secret=secret, + ).parsed + + +async def asyncio_detailed( + *, + client: Client, + user_id: str, + user_nickname: str, + user_email: str, + user_name: str, + secret: str, +) -> Response[Union[HTTPValidationError, str]]: + """Handle User Registration + + Args: + user_id (str): + user_nickname (str): + user_email (str): + user_name (str): + secret (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, str]] + """ + + kwargs = _get_kwargs( + client=client, + user_id=user_id, + user_nickname=user_nickname, + user_email=user_email, + user_name=user_name, + secret=secret, + ) + + async with httpx.AsyncClient(verify=client.verify_ssl) as _client: + response = await _client.request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Client, + user_id: str, + user_nickname: str, + user_email: str, + user_name: str, + secret: str, +) -> Optional[Union[HTTPValidationError, str]]: + """Handle User Registration + + Args: + user_id (str): + user_nickname (str): + user_email (str): + user_name (str): + secret (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[HTTPValidationError, str] + """ + + return ( + await asyncio_detailed( + client=client, + user_id=user_id, + user_nickname=user_nickname, + user_email=user_email, + user_name=user_name, + secret=secret, + ) + ).parsed diff --git a/projects/fal/openapi-fal-rest/openapi_fal_rest/models/__init__.py b/projects/fal/openapi-fal-rest/openapi_fal_rest/models/__init__.py index 9581643b..4c9498bd 100644 --- a/projects/fal/openapi-fal-rest/openapi_fal_rest/models/__init__.py +++ b/projects/fal/openapi-fal-rest/openapi_fal_rest/models/__init__.py @@ -1,6 +1,7 @@ """ Contains all the data models used in inputs/outputs """ from .app_metadata_response_app_metadata import AppMetadataResponseAppMetadata +from .billing_type import BillingType from .body_create_token import BodyCreateToken from .body_upload_file import BodyUploadFile from .body_upload_local_file import BodyUploadLocalFile @@ -12,9 +13,7 @@ GetGatewayRequestStatsByTimeResponseGetGatewayRequestStatsByTime, ) from .grouped_usage_detail import GroupedUsageDetail -from .handle_stripe_webhook_response_handle_stripe_webhook import ( - HandleStripeWebhookResponseHandleStripeWebhook, -) +from .handle_stripe_webhook_response_handle_stripe_webhook import HandleStripeWebhookResponseHandleStripeWebhook from .hash_check import HashCheck from .http_validation_error import HTTPValidationError from .initiate_upload_info import InitiateUploadInfo @@ -25,6 +24,7 @@ from .log_entry_labels import LogEntryLabels from .new_user_key import NewUserKey from .payment_method import PaymentMethod +from .per_app_usage_detail import PerAppUsageDetail from .persisted_usage_record import PersistedUsageRecord from .persisted_usage_record_meta import PersistedUsageRecordMeta from .presigned_upload_url import PresignedUploadUrl @@ -45,6 +45,7 @@ __all__ = ( "AppMetadataResponseAppMetadata", + "BillingType", "BodyCreateToken", "BodyUploadFile", "BodyUploadLocalFile", @@ -65,6 +66,7 @@ "LogEntryLabels", "NewUserKey", "PaymentMethod", + "PerAppUsageDetail", "PersistedUsageRecord", "PersistedUsageRecordMeta", "PresignedUploadUrl", diff --git a/projects/fal/openapi-fal-rest/openapi_fal_rest/models/billing_type.py b/projects/fal/openapi-fal-rest/openapi_fal_rest/models/billing_type.py new file mode 100644 index 00000000..c3b3d6a9 --- /dev/null +++ b/projects/fal/openapi-fal-rest/openapi_fal_rest/models/billing_type.py @@ -0,0 +1,9 @@ +from enum import Enum + + +class BillingType(str, Enum): + INVOICE = "invoice" + TOP_UP = "top_up" + + def __str__(self) -> str: + return str(self.value) diff --git a/projects/fal/openapi-fal-rest/openapi_fal_rest/models/body_upload_file.py b/projects/fal/openapi-fal-rest/openapi_fal_rest/models/body_upload_file.py index 9af21068..c5c822ff 100644 --- a/projects/fal/openapi-fal-rest/openapi_fal_rest/models/body_upload_file.py +++ b/projects/fal/openapi-fal-rest/openapi_fal_rest/models/body_upload_file.py @@ -36,10 +36,7 @@ def to_multipart(self) -> Dict[str, Any]: field_dict: Dict[str, Any] = {} field_dict.update( - { - key: (None, str(value).encode(), "text/plain") - for key, value in self.additional_properties.items() - } + {key: (None, str(value).encode(), "text/plain") for key, value in self.additional_properties.items()} ) field_dict.update( { diff --git a/projects/fal/openapi-fal-rest/openapi_fal_rest/models/body_upload_local_file.py b/projects/fal/openapi-fal-rest/openapi_fal_rest/models/body_upload_local_file.py index ba52be5a..d2500fbb 100644 --- a/projects/fal/openapi-fal-rest/openapi_fal_rest/models/body_upload_local_file.py +++ b/projects/fal/openapi-fal-rest/openapi_fal_rest/models/body_upload_local_file.py @@ -36,10 +36,7 @@ def to_multipart(self) -> Dict[str, Any]: field_dict: Dict[str, Any] = {} field_dict.update( - { - key: (None, str(value).encode(), "text/plain") - for key, value in self.additional_properties.items() - } + {key: (None, str(value).encode(), "text/plain") for key, value in self.additional_properties.items()} ) field_dict.update( { diff --git a/projects/fal/openapi-fal-rest/openapi_fal_rest/models/customer_details.py b/projects/fal/openapi-fal-rest/openapi_fal_rest/models/customer_details.py index 3052159c..433c3789 100644 --- a/projects/fal/openapi-fal-rest/openapi_fal_rest/models/customer_details.py +++ b/projects/fal/openapi-fal-rest/openapi_fal_rest/models/customer_details.py @@ -15,12 +15,14 @@ class CustomerDetails: soft_monthly_budget (Union[Unset, int]): hard_monthly_budget (Union[Unset, int]): current_balance (Union[Unset, int]): + is_paying (Union[Unset, bool]): """ user_id: str soft_monthly_budget: Union[Unset, int] = UNSET hard_monthly_budget: Union[Unset, int] = UNSET current_balance: Union[Unset, int] = 0 + is_paying: Union[Unset, bool] = False additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict) def to_dict(self) -> Dict[str, Any]: @@ -28,6 +30,7 @@ def to_dict(self) -> Dict[str, Any]: soft_monthly_budget = self.soft_monthly_budget hard_monthly_budget = self.hard_monthly_budget current_balance = self.current_balance + is_paying = self.is_paying field_dict: Dict[str, Any] = {} field_dict.update(self.additional_properties) @@ -42,6 +45,8 @@ def to_dict(self) -> Dict[str, Any]: field_dict["hard_monthly_budget"] = hard_monthly_budget if current_balance is not UNSET: field_dict["current_balance"] = current_balance + if is_paying is not UNSET: + field_dict["is_paying"] = is_paying return field_dict @@ -56,11 +61,14 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: current_balance = d.pop("current_balance", UNSET) + is_paying = d.pop("is_paying", UNSET) + customer_details = cls( user_id=user_id, soft_monthly_budget=soft_monthly_budget, hard_monthly_budget=hard_monthly_budget, current_balance=current_balance, + is_paying=is_paying, ) customer_details.additional_properties = d diff --git a/projects/fal/openapi-fal-rest/openapi_fal_rest/models/get_gateway_request_stats_by_time_response_get_gateway_request_stats_by_time.py b/projects/fal/openapi-fal-rest/openapi_fal_rest/models/get_gateway_request_stats_by_time_response_get_gateway_request_stats_by_time.py index 230482ba..e665c5c6 100644 --- a/projects/fal/openapi-fal-rest/openapi_fal_rest/models/get_gateway_request_stats_by_time_response_get_gateway_request_stats_by_time.py +++ b/projects/fal/openapi-fal-rest/openapi_fal_rest/models/get_gateway_request_stats_by_time_response_get_gateway_request_stats_by_time.py @@ -6,18 +6,14 @@ from ..models.gateway_stats_by_time import GatewayStatsByTime -T = TypeVar( - "T", bound="GetGatewayRequestStatsByTimeResponseGetGatewayRequestStatsByTime" -) +T = TypeVar("T", bound="GetGatewayRequestStatsByTimeResponseGetGatewayRequestStatsByTime") @attr.s(auto_attribs=True) class GetGatewayRequestStatsByTimeResponseGetGatewayRequestStatsByTime: """ """ - additional_properties: Dict[str, List["GatewayStatsByTime"]] = attr.ib( - init=False, factory=dict - ) + additional_properties: Dict[str, List["GatewayStatsByTime"]] = attr.ib(init=False, factory=dict) def to_dict(self) -> Dict[str, Any]: pass @@ -39,18 +35,14 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: from ..models.gateway_stats_by_time import GatewayStatsByTime d = src_dict.copy() - get_gateway_request_stats_by_time_response_get_gateway_request_stats_by_time = ( - cls() - ) + get_gateway_request_stats_by_time_response_get_gateway_request_stats_by_time = cls() additional_properties = {} for prop_name, prop_dict in d.items(): additional_property = [] _additional_property = prop_dict for additional_property_item_data in _additional_property: - additional_property_item = GatewayStatsByTime.from_dict( - additional_property_item_data - ) + additional_property_item = GatewayStatsByTime.from_dict(additional_property_item_data) additional_property.append(additional_property_item) @@ -59,9 +51,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: get_gateway_request_stats_by_time_response_get_gateway_request_stats_by_time.additional_properties = ( additional_properties ) - return ( - get_gateway_request_stats_by_time_response_get_gateway_request_stats_by_time - ) + return get_gateway_request_stats_by_time_response_get_gateway_request_stats_by_time @property def additional_keys(self) -> List[str]: diff --git a/projects/fal/openapi-fal-rest/openapi_fal_rest/models/per_app_usage_detail.py b/projects/fal/openapi-fal-rest/openapi_fal_rest/models/per_app_usage_detail.py new file mode 100644 index 00000000..dd8c0f51 --- /dev/null +++ b/projects/fal/openapi-fal-rest/openapi_fal_rest/models/per_app_usage_detail.py @@ -0,0 +1,88 @@ +import datetime +from typing import Any, Dict, List, Type, TypeVar + +import attr +from dateutil.parser import isoparse + +T = TypeVar("T", bound="PerAppUsageDetail") + + +@attr.s(auto_attribs=True) +class PerAppUsageDetail: + """ + Attributes: + date (datetime.datetime): + machine_type (str): + request_count (int): + application_alias (str): + total_billable_duration (int): + """ + + date: datetime.datetime + machine_type: str + request_count: int + application_alias: str + total_billable_duration: int + additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict) + + def to_dict(self) -> Dict[str, Any]: + date = self.date.isoformat() + + machine_type = self.machine_type + request_count = self.request_count + application_alias = self.application_alias + total_billable_duration = self.total_billable_duration + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "date": date, + "machine_type": machine_type, + "request_count": request_count, + "application_alias": application_alias, + "total_billable_duration": total_billable_duration, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + date = isoparse(d.pop("date")) + + machine_type = d.pop("machine_type") + + request_count = d.pop("request_count") + + application_alias = d.pop("application_alias") + + total_billable_duration = d.pop("total_billable_duration") + + per_app_usage_detail = cls( + date=date, + machine_type=machine_type, + request_count=request_count, + application_alias=application_alias, + total_billable_duration=total_billable_duration, + ) + + per_app_usage_detail.additional_properties = d + return per_app_usage_detail + + @property + def additional_keys(self) -> List[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties