From 56f3d69f30c2b0a27f16b47896b8472baf67dcd4 Mon Sep 17 00:00:00 2001 From: scaleway-bot Date: Thu, 4 Jan 2024 14:22:32 +0000 Subject: [PATCH] feat: update generated APIs --- .../billing/v2beta1/__init__.py | 33 ++ .../scaleway_async/billing/v2beta1/api.py | 443 ++++++++++++++++ .../billing/v2beta1/marshalling.py | 206 ++++++++ .../scaleway_async/billing/v2beta1/types.py | 485 ++++++++++++++++++ .../scaleway_async/container/v1beta1/types.py | 8 +- .../scaleway_async/function/v1beta1/types.py | 8 +- scaleway/scaleway/billing/v2beta1/__init__.py | 33 ++ scaleway/scaleway/billing/v2beta1/api.py | 443 ++++++++++++++++ .../scaleway/billing/v2beta1/marshalling.py | 206 ++++++++ scaleway/scaleway/billing/v2beta1/types.py | 485 ++++++++++++++++++ scaleway/scaleway/container/v1beta1/types.py | 8 +- scaleway/scaleway/function/v1beta1/types.py | 16 +- 12 files changed, 2354 insertions(+), 20 deletions(-) create mode 100644 scaleway-async/scaleway_async/billing/v2beta1/__init__.py create mode 100644 scaleway-async/scaleway_async/billing/v2beta1/api.py create mode 100644 scaleway-async/scaleway_async/billing/v2beta1/marshalling.py create mode 100644 scaleway-async/scaleway_async/billing/v2beta1/types.py create mode 100644 scaleway/scaleway/billing/v2beta1/__init__.py create mode 100644 scaleway/scaleway/billing/v2beta1/api.py create mode 100644 scaleway/scaleway/billing/v2beta1/marshalling.py create mode 100644 scaleway/scaleway/billing/v2beta1/types.py diff --git a/scaleway-async/scaleway_async/billing/v2beta1/__init__.py b/scaleway-async/scaleway_async/billing/v2beta1/__init__.py new file mode 100644 index 000000000..2755c24c4 --- /dev/null +++ b/scaleway-async/scaleway_async/billing/v2beta1/__init__.py @@ -0,0 +1,33 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from .types import DownloadInvoiceRequestFileType +from .types import ExportInvoicesRequestFileType +from .types import ExportInvoicesRequestOrderBy +from .types import InvoiceType +from .types import ListConsumptionsRequestOrderBy +from .types import ListInvoicesRequestOrderBy +from .types import ListTaxesRequestOrderBy +from .types import Invoice +from .types import ListConsumptionsResponse +from .types import ListConsumptionsResponseConsumption +from .types import ListInvoicesResponse +from .types import ListTaxesResponse +from .types import ListTaxesResponseTax +from .api import BillingV2Beta1API + +__all__ = [ + "DownloadInvoiceRequestFileType", + "ExportInvoicesRequestFileType", + "ExportInvoicesRequestOrderBy", + "InvoiceType", + "ListConsumptionsRequestOrderBy", + "ListInvoicesRequestOrderBy", + "ListTaxesRequestOrderBy", + "Invoice", + "ListConsumptionsResponse", + "ListConsumptionsResponseConsumption", + "ListInvoicesResponse", + "ListTaxesResponse", + "ListTaxesResponseTax", + "BillingV2Beta1API", +] diff --git a/scaleway-async/scaleway_async/billing/v2beta1/api.py b/scaleway-async/scaleway_async/billing/v2beta1/api.py new file mode 100644 index 000000000..b8d9bf087 --- /dev/null +++ b/scaleway-async/scaleway_async/billing/v2beta1/api.py @@ -0,0 +1,443 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. + +from datetime import datetime +from typing import List, Optional + +from scaleway_core.api import API +from scaleway_core.bridge import ( + ScwFile, + unmarshal_ScwFile, +) +from scaleway_core.utils import ( + OneOfPossibility, + fetch_all_pages_async, + resolve_one_of, + validate_path_param, +) +from .types import ( + DownloadInvoiceRequestFileType, + ExportInvoicesRequestFileType, + ExportInvoicesRequestOrderBy, + InvoiceType, + ListConsumptionsRequestOrderBy, + ListInvoicesRequestOrderBy, + ListTaxesRequestOrderBy, + Invoice, + ListConsumptionsResponse, + ListConsumptionsResponseConsumption, + ListInvoicesResponse, + ListTaxesResponse, + ListTaxesResponseTax, +) +from .marshalling import ( + unmarshal_Invoice, + unmarshal_ListConsumptionsResponse, + unmarshal_ListInvoicesResponse, + unmarshal_ListTaxesResponse, +) + + +class BillingV2Beta1API(API): + """ + Billing API. + + This API allows you to query your consumption. + Billing API. + """ + + async def list_consumptions( + self, + *, + order_by: ListConsumptionsRequestOrderBy = ListConsumptionsRequestOrderBy.UPDATED_AT_DATE_DESC, + page: Optional[int] = None, + page_size: Optional[int] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + category_name: Optional[str] = None, + billing_period: Optional[str] = None, + ) -> ListConsumptionsResponse: + """ + Get monthly consumption. + Consumption allows you to retrieve your past or current consumption cost, by project or category. + :param order_by: Order consumptions list in the response by their update date. + :param page: Positive integer to choose the page to return. + :param page_size: Positive integer lower or equal to 100 to select the number of items to return. + :param organization_id: Filter by Organization ID. + + One-of ('project_identifier'): at most one of 'organization_id', 'project_id' could be set. + :param project_id: Filter by Project ID. + + One-of ('project_identifier'): at most one of 'organization_id', 'project_id' could be set. + :param category_name: Filter by name of a Category as they are shown in the invoice (Compute, Network, Observability). + :param billing_period: Filter by the billing period in the YYYY-MM format. If it is empty the current billing period will be used as default. + :return: :class:`ListConsumptionsResponse ` + + Usage: + :: + + result = await api.list_consumptions() + """ + + res = self._request( + "GET", + f"/billing/v2beta1/consumptions", + params={ + "billing_period": billing_period, + "category_name": category_name, + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + **resolve_one_of( + [ + OneOfPossibility( + "project_id", project_id, self.client.default_project_id + ), + OneOfPossibility( + "organization_id", + organization_id, + self.client.default_organization_id, + ), + ] + ), + }, + ) + + self._throw_on_error(res) + return unmarshal_ListConsumptionsResponse(res.json()) + + async def list_consumptions_all( + self, + *, + order_by: Optional[ListConsumptionsRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + category_name: Optional[str] = None, + billing_period: Optional[str] = None, + ) -> List[ListConsumptionsResponseConsumption]: + """ + Get monthly consumption. + Consumption allows you to retrieve your past or current consumption cost, by project or category. + :param order_by: Order consumptions list in the response by their update date. + :param page: Positive integer to choose the page to return. + :param page_size: Positive integer lower or equal to 100 to select the number of items to return. + :param organization_id: Filter by Organization ID. + + One-of ('project_identifier'): at most one of 'organization_id', 'project_id' could be set. + :param project_id: Filter by Project ID. + + One-of ('project_identifier'): at most one of 'organization_id', 'project_id' could be set. + :param category_name: Filter by name of a Category as they are shown in the invoice (Compute, Network, Observability). + :param billing_period: Filter by the billing period in the YYYY-MM format. If it is empty the current billing period will be used as default. + :return: :class:`List[ListConsumptionsResponse] ` + + Usage: + :: + + result = await api.list_consumptions_all() + """ + + return await fetch_all_pages_async( + type=ListConsumptionsResponse, + key="consumptions", + fetcher=self.list_consumptions, + args={ + "order_by": order_by, + "page": page, + "page_size": page_size, + "organization_id": organization_id, + "project_id": project_id, + "category_name": category_name, + "billing_period": billing_period, + }, + ) + + async def list_taxes( + self, + *, + order_by: ListTaxesRequestOrderBy = ListTaxesRequestOrderBy.UPDATED_AT_DATE_DESC, + page: Optional[int] = None, + page_size: Optional[int] = None, + organization_id: Optional[str] = None, + billing_period: Optional[str] = None, + ) -> ListTaxesResponse: + """ + Get monthly consumption taxes. + Consumption Tax allows you to retrieve your past or current tax charges, by project or category. + :param order_by: Order consumed taxes list in the response by their update date. + :param page: Page number. + :param page_size: Positive integer lower or equal to 100 to select the number of items to return. + :param organization_id: Filter by Organization ID. + :param billing_period: Filter by the billing period in the YYYY-MM format. If it is empty the current billing period will be used as default. + :return: :class:`ListTaxesResponse ` + + Usage: + :: + + result = await api.list_taxes() + """ + + res = self._request( + "GET", + f"/billing/v2beta1/taxes", + params={ + "billing_period": billing_period, + "order_by": order_by, + "organization_id": organization_id + or self.client.default_organization_id, + "page": page, + "page_size": page_size or self.client.default_page_size, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListTaxesResponse(res.json()) + + async def list_taxes_all( + self, + *, + order_by: Optional[ListTaxesRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + organization_id: Optional[str] = None, + billing_period: Optional[str] = None, + ) -> List[ListTaxesResponseTax]: + """ + Get monthly consumption taxes. + Consumption Tax allows you to retrieve your past or current tax charges, by project or category. + :param order_by: Order consumed taxes list in the response by their update date. + :param page: Page number. + :param page_size: Positive integer lower or equal to 100 to select the number of items to return. + :param organization_id: Filter by Organization ID. + :param billing_period: Filter by the billing period in the YYYY-MM format. If it is empty the current billing period will be used as default. + :return: :class:`List[ListTaxesResponse] ` + + Usage: + :: + + result = await api.list_taxes_all() + """ + + return await fetch_all_pages_async( + type=ListTaxesResponse, + key="taxes", + fetcher=self.list_taxes, + args={ + "order_by": order_by, + "page": page, + "page_size": page_size, + "organization_id": organization_id, + "billing_period": billing_period, + }, + ) + + async def list_invoices( + self, + *, + organization_id: Optional[str] = None, + billing_period_start_after: Optional[datetime] = None, + billing_period_start_before: Optional[datetime] = None, + invoice_type: InvoiceType = InvoiceType.UNKNOWN_TYPE, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: ListInvoicesRequestOrderBy = ListInvoicesRequestOrderBy.INVOICE_NUMBER_DESC, + ) -> ListInvoicesResponse: + """ + List invoices. + List all your invoices, filtering by `start_date` and `invoice_type`. Each invoice has its own ID. + :param organization_id: Organization ID. If specified, only invoices from this Organization will be returned. + :param billing_period_start_after: Return only invoice with start date greater than billing_period_start. + :param billing_period_start_before: Return only invoice with start date less than billing_period_start. + :param invoice_type: Invoice type. It can either be `periodic` or `purchase`. + :param page: Page number. + :param page_size: Positive integer lower or equal to 100 to select the number of items to return. + :param order_by: How invoices are ordered in the response. + :return: :class:`ListInvoicesResponse ` + + Usage: + :: + + result = await api.list_invoices() + """ + + res = self._request( + "GET", + f"/billing/v2beta1/invoices", + params={ + "billing_period_start_after": billing_period_start_after, + "billing_period_start_before": billing_period_start_before, + "invoice_type": invoice_type, + "order_by": order_by, + "organization_id": organization_id + or self.client.default_organization_id, + "page": page, + "page_size": page_size or self.client.default_page_size, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListInvoicesResponse(res.json()) + + async def list_invoices_all( + self, + *, + organization_id: Optional[str] = None, + billing_period_start_after: Optional[datetime] = None, + billing_period_start_before: Optional[datetime] = None, + invoice_type: Optional[InvoiceType] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListInvoicesRequestOrderBy] = None, + ) -> List[Invoice]: + """ + List invoices. + List all your invoices, filtering by `start_date` and `invoice_type`. Each invoice has its own ID. + :param organization_id: Organization ID. If specified, only invoices from this Organization will be returned. + :param billing_period_start_after: Return only invoice with start date greater than billing_period_start. + :param billing_period_start_before: Return only invoice with start date less than billing_period_start. + :param invoice_type: Invoice type. It can either be `periodic` or `purchase`. + :param page: Page number. + :param page_size: Positive integer lower or equal to 100 to select the number of items to return. + :param order_by: How invoices are ordered in the response. + :return: :class:`List[ListInvoicesResponse] ` + + Usage: + :: + + result = await api.list_invoices_all() + """ + + return await fetch_all_pages_async( + type=ListInvoicesResponse, + key="invoices", + fetcher=self.list_invoices, + args={ + "organization_id": organization_id, + "billing_period_start_after": billing_period_start_after, + "billing_period_start_before": billing_period_start_before, + "invoice_type": invoice_type, + "page": page, + "page_size": page_size, + "order_by": order_by, + }, + ) + + async def export_invoices( + self, + *, + invoice_type: InvoiceType, + order_by: ExportInvoicesRequestOrderBy, + file_type: ExportInvoicesRequestFileType, + organization_id: Optional[str] = None, + billing_period_start_after: Optional[datetime] = None, + billing_period_start_before: Optional[datetime] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Optional[ScwFile]: + """ + Export invoices. + Export invoices in a CSV file. + :param organization_id: Organization ID. If specified, only invoices from this Organization will be returned. + :param billing_period_start_after: Return only invoice with start date greater than billing_period_start. + :param billing_period_start_before: Return only invoice with start date less than billing_period_start. + :param invoice_type: Invoice type. It can either be `periodic` or `purchase`. + :param page: Page number. + :param page_size: Positive integer lower or equal to 100 to select the number of items to return. + :param order_by: How invoices are ordered in the response. + :param file_type: File format for exporting the invoice list. + :return: :class:`Optional[ScwFile] ` + + Usage: + :: + + result = await api.export_invoices( + invoice_type=unknown_type, + order_by=invoice_number_desc, + file_type=csv, + ) + """ + + res = self._request( + "GET", + f"/billing/v2beta1/export-invoices", + params={ + "billing_period_start_after": billing_period_start_after, + "billing_period_start_before": billing_period_start_before, + "file_type": file_type, + "invoice_type": invoice_type, + "order_by": order_by, + "organization_id": organization_id + or self.client.default_organization_id, + "page": page, + "page_size": page_size or self.client.default_page_size, + }, + ) + + self._throw_on_error(res) + json = res.json() + return unmarshal_ScwFile(json) if json is not None else None + + async def get_invoice( + self, + *, + invoice_id: str, + ) -> Invoice: + """ + Get an invoice. + Get a specific invoice, specified by its ID. + :param invoice_id: Invoice ID. + :return: :class:`Invoice ` + + Usage: + :: + + result = await api.get_invoice(invoice_id="example") + """ + + param_invoice_id = validate_path_param("invoice_id", invoice_id) + + res = self._request( + "GET", + f"/billing/v2beta1/invoices/{param_invoice_id}", + ) + + self._throw_on_error(res) + return unmarshal_Invoice(res.json()) + + async def download_invoice( + self, + *, + invoice_id: str, + file_type: DownloadInvoiceRequestFileType, + ) -> Optional[ScwFile]: + """ + Download an invoice. + Download a specific invoice, specified by its ID. + :param invoice_id: Invoice ID. + :param file_type: File type. PDF by default. + :return: :class:`Optional[ScwFile] ` + + Usage: + :: + + result = await api.download_invoice( + invoice_id="example", + file_type=pdf, + ) + """ + + param_invoice_id = validate_path_param("invoice_id", invoice_id) + + res = self._request( + "GET", + f"/billing/v2beta1/invoices/{param_invoice_id}/download", + params={ + "file_type": file_type, + }, + ) + + self._throw_on_error(res) + json = res.json() + return unmarshal_ScwFile(json) if json is not None else None diff --git a/scaleway-async/scaleway_async/billing/v2beta1/marshalling.py b/scaleway-async/scaleway_async/billing/v2beta1/marshalling.py new file mode 100644 index 000000000..31d92400c --- /dev/null +++ b/scaleway-async/scaleway_async/billing/v2beta1/marshalling.py @@ -0,0 +1,206 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. + +from typing import Any, Dict + +from scaleway_core.bridge import ( + unmarshal_Money, +) +from dateutil import parser +from .types import ( + Invoice, + ListConsumptionsResponse, + ListConsumptionsResponseConsumption, + ListInvoicesResponse, + ListTaxesResponse, + ListTaxesResponseTax, +) + + +def unmarshal_Invoice(data: Any) -> Invoice: + if type(data) is not dict: + raise TypeError( + f"Unmarshalling the type 'Invoice' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("billing_period", None) + args["billing_period"] = parser.isoparse(field) if type(field) is str else field + + field = data.get("customer_name", None) + args["customer_name"] = field + + field = data.get("due_date", None) + args["due_date"] = parser.isoparse(field) if type(field) is str else field + + field = data.get("id", None) + args["id"] = field + + field = data.get("issued_date", None) + args["issued_date"] = parser.isoparse(field) if type(field) is str else field + + field = data.get("number", None) + args["number"] = field + + field = data.get("organization_id", None) + args["organization_id"] = field + + field = data.get("organization_name", None) + args["organization_name"] = field + + field = data.get("seller_name", None) + args["seller_name"] = field + + field = data.get("start_date", None) + args["start_date"] = parser.isoparse(field) if type(field) is str else field + + field = data.get("state", None) + args["state"] = field + + field = data.get("stop_date", None) + args["stop_date"] = parser.isoparse(field) if type(field) is str else field + + field = data.get("total_discount", None) + args["total_discount"] = unmarshal_Money(field) if field is not None else None + + field = data.get("total_tax", None) + args["total_tax"] = unmarshal_Money(field) if field is not None else None + + field = data.get("total_taxed", None) + args["total_taxed"] = unmarshal_Money(field) if field is not None else None + + field = data.get("total_undiscount", None) + args["total_undiscount"] = unmarshal_Money(field) if field is not None else None + + field = data.get("total_untaxed", None) + args["total_untaxed"] = unmarshal_Money(field) if field is not None else None + + field = data.get("type", None) + args["type_"] = field + + return Invoice(**args) + + +def unmarshal_ListConsumptionsResponseConsumption( + data: Any, +) -> ListConsumptionsResponseConsumption: + if type(data) is not dict: + raise TypeError( + f"Unmarshalling the type 'ListConsumptionsResponseConsumption' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("category_name", None) + args["category_name"] = field + + field = data.get("product_name", None) + args["product_name"] = field + + field = data.get("project_id", None) + args["project_id"] = field + + field = data.get("resource_name", None) + args["resource_name"] = field + + field = data.get("sku", None) + args["sku"] = field + + field = data.get("value", None) + args["value"] = unmarshal_Money(field) if field is not None else None + + return ListConsumptionsResponseConsumption(**args) + + +def unmarshal_ListTaxesResponseTax(data: Any) -> ListTaxesResponseTax: + if type(data) is not dict: + raise TypeError( + f"Unmarshalling the type 'ListTaxesResponseTax' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("currency", None) + args["currency"] = field + + field = data.get("description", None) + args["description"] = field + + field = data.get("rate", None) + args["rate"] = field + + field = data.get("total_tax_value", None) + args["total_tax_value"] = field + + return ListTaxesResponseTax(**args) + + +def unmarshal_ListConsumptionsResponse(data: Any) -> ListConsumptionsResponse: + if type(data) is not dict: + raise TypeError( + f"Unmarshalling the type 'ListConsumptionsResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("consumptions", None) + args["consumptions"] = ( + [unmarshal_ListConsumptionsResponseConsumption(v) for v in field] + if field is not None + else None + ) + + field = data.get("total_count", None) + args["total_count"] = field + + field = data.get("total_discount_untaxed_value", None) + args["total_discount_untaxed_value"] = field + + field = data.get("updated_at", None) + args["updated_at"] = parser.isoparse(field) if type(field) is str else field + + return ListConsumptionsResponse(**args) + + +def unmarshal_ListInvoicesResponse(data: Any) -> ListInvoicesResponse: + if type(data) is not dict: + raise TypeError( + f"Unmarshalling the type 'ListInvoicesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("invoices", None) + args["invoices"] = ( + [unmarshal_Invoice(v) for v in field] if field is not None else None + ) + + field = data.get("total_count", None) + args["total_count"] = field + + return ListInvoicesResponse(**args) + + +def unmarshal_ListTaxesResponse(data: Any) -> ListTaxesResponse: + if type(data) is not dict: + raise TypeError( + f"Unmarshalling the type 'ListTaxesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("taxes", None) + args["taxes"] = ( + [unmarshal_ListTaxesResponseTax(v) for v in field] + if field is not None + else None + ) + + field = data.get("total_count", None) + args["total_count"] = field + + field = data.get("updated_at", None) + args["updated_at"] = parser.isoparse(field) if type(field) is str else field + + return ListTaxesResponse(**args) diff --git a/scaleway-async/scaleway_async/billing/v2beta1/types.py b/scaleway-async/scaleway_async/billing/v2beta1/types.py new file mode 100644 index 000000000..a2c2f05cc --- /dev/null +++ b/scaleway-async/scaleway_async/billing/v2beta1/types.py @@ -0,0 +1,485 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from __future__ import annotations + +from dataclasses import dataclass +from datetime import datetime +from enum import Enum +from typing import List, Optional + +from scaleway_core.bridge import ( + Money, +) +from scaleway_core.utils import ( + StrEnumMeta, +) + + +class DownloadInvoiceRequestFileType(str, Enum, metaclass=StrEnumMeta): + PDF = "pdf" + + def __str__(self) -> str: + return str(self.value) + + +class ExportInvoicesRequestFileType(str, Enum, metaclass=StrEnumMeta): + CSV = "csv" + + def __str__(self) -> str: + return str(self.value) + + +class ExportInvoicesRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + INVOICE_NUMBER_DESC = "invoice_number_desc" + INVOICE_NUMBER_ASC = "invoice_number_asc" + START_DATE_DESC = "start_date_desc" + START_DATE_ASC = "start_date_asc" + ISSUED_DATE_DESC = "issued_date_desc" + ISSUED_DATE_ASC = "issued_date_asc" + DUE_DATE_DESC = "due_date_desc" + DUE_DATE_ASC = "due_date_asc" + TOTAL_UNTAXED_DESC = "total_untaxed_desc" + TOTAL_UNTAXED_ASC = "total_untaxed_asc" + TOTAL_TAXED_DESC = "total_taxed_desc" + TOTAL_TAXED_ASC = "total_taxed_asc" + INVOICE_TYPE_DESC = "invoice_type_desc" + INVOICE_TYPE_ASC = "invoice_type_asc" + + def __str__(self) -> str: + return str(self.value) + + +class InvoiceType(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_TYPE = "unknown_type" + PERIODIC = "periodic" + PURCHASE = "purchase" + + def __str__(self) -> str: + return str(self.value) + + +class ListConsumptionsRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + UPDATED_AT_DATE_DESC = "updated_at_date_desc" + UPDATED_AT_DATE_ASC = "updated_at_date_asc" + CATEGORY_NAME_DESC = "category_name_desc" + CATEGORY_NAME_ASC = "category_name_asc" + + def __str__(self) -> str: + return str(self.value) + + +class ListInvoicesRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + INVOICE_NUMBER_DESC = "invoice_number_desc" + INVOICE_NUMBER_ASC = "invoice_number_asc" + START_DATE_DESC = "start_date_desc" + START_DATE_ASC = "start_date_asc" + ISSUED_DATE_DESC = "issued_date_desc" + ISSUED_DATE_ASC = "issued_date_asc" + DUE_DATE_DESC = "due_date_desc" + DUE_DATE_ASC = "due_date_asc" + TOTAL_UNTAXED_DESC = "total_untaxed_desc" + TOTAL_UNTAXED_ASC = "total_untaxed_asc" + TOTAL_TAXED_DESC = "total_taxed_desc" + TOTAL_TAXED_ASC = "total_taxed_asc" + INVOICE_TYPE_DESC = "invoice_type_desc" + INVOICE_TYPE_ASC = "invoice_type_asc" + + def __str__(self) -> str: + return str(self.value) + + +class ListTaxesRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + UPDATED_AT_DATE_DESC = "updated_at_date_desc" + UPDATED_AT_DATE_ASC = "updated_at_date_asc" + CATEGORY_NAME_DESC = "category_name_desc" + CATEGORY_NAME_ASC = "category_name_asc" + + def __str__(self) -> str: + return str(self.value) + + +@dataclass +class Invoice: + """ + Invoice. + """ + + id: str + """ + Invoice ID. + """ + + organization_id: str + + organization_name: str + + start_date: Optional[datetime] + """ + Start date of the billing period. + """ + + stop_date: Optional[datetime] + + billing_period: Optional[datetime] + """ + The billing period of the invoice in the YYYY-MM format. + """ + + issued_date: Optional[datetime] + """ + Date when the invoice was sent to the customer. + """ + + due_date: Optional[datetime] + """ + Payment time limit, set according to the Organization's payment conditions. + """ + + total_untaxed: Optional[Money] + """ + Total amount, untaxed. + """ + + total_taxed: Optional[Money] + """ + Total amount, taxed. + """ + + total_tax: Optional[Money] + """ + The total tax amount of the invoice. + """ + + total_discount: Optional[Money] + """ + The total discount amount of the invoice. + """ + + total_undiscount: Optional[Money] + """ + The total amount of the invoice before applying the discount. + """ + + type_: InvoiceType + """ + Type of invoice, either periodic or purchase. + """ + + state: str + """ + The state of the Invoice. + """ + + number: int + """ + Invoice number. + """ + + seller_name: str + + customer_name: str + """ + Customer name associated to this organization. + """ + + +@dataclass +class ListConsumptionsResponse: + """ + List consumptions response. + """ + + consumptions: List[ListConsumptionsResponseConsumption] + """ + Detailed consumption list. + """ + + total_count: int + """ + Total number of returned items. + """ + + total_discount_untaxed_value: float + """ + Sum of all discounts, displayed only when no category or project ID filter is applied. + """ + + updated_at: Optional[datetime] + """ + Last consumption update date. + """ + + +@dataclass +class ListConsumptionsResponseConsumption: + """ + List consumptions response. consumption. + """ + + value: Optional[Money] + """ + Monetary value of the consumption. + """ + + product_name: str + """ + The product name. For example, "VPC Public Gateway S", "VPC Public Gateway M" for the VPC product. + """ + + resource_name: str + """ + Identifies the reference based on the category. + """ + + sku: str + """ + Unique identifier of the product. + """ + + project_id: str + """ + Project ID of the consumption. + """ + + category_name: str + """ + Name of consumption category. + """ + + +@dataclass +class ListInvoicesResponse: + """ + List invoices response. + """ + + total_count: int + """ + Total number of invoices. + """ + + invoices: List[Invoice] + """ + Paginated returned invoices. + """ + + +@dataclass +class ListTaxesResponse: + """ + List taxes response. + """ + + taxes: List[ListTaxesResponseTax] + """ + Detailed consumption tax. + """ + + total_count: int + """ + Total number of returned items. + """ + + updated_at: Optional[datetime] + """ + Last consumption update date. + """ + + +@dataclass +class ListTaxesResponseTax: + """ + List taxes response. tax. + """ + + description: str + """ + Description of the tax applied. + """ + + currency: str + """ + The three-letter currency code. + """ + + rate: Optional[float] + """ + Applied tax rate (0.2 means a VAT of 20%). + """ + + total_tax_value: Optional[float] + """ + The total tax value of the consumption. + """ + + +@dataclass +class ListConsumptionsRequest: + order_by: Optional[ListConsumptionsRequestOrderBy] + """ + Order consumptions list in the response by their update date. + """ + + page: Optional[int] + """ + Positive integer to choose the page to return. + """ + + page_size: Optional[int] + """ + Positive integer lower or equal to 100 to select the number of items to return. + """ + + organization_id: Optional[str] + """ + Filter by Organization ID. + + One-of ('project_identifier'): at most one of 'organization_id', 'project_id' could be set. + """ + + project_id: Optional[str] + """ + Filter by Project ID. + + One-of ('project_identifier'): at most one of 'organization_id', 'project_id' could be set. + """ + + category_name: Optional[str] + """ + Filter by name of a Category as they are shown in the invoice (Compute, Network, Observability). + """ + + billing_period: Optional[str] + """ + Filter by the billing period in the YYYY-MM format. If it is empty the current billing period will be used as default. + """ + + +@dataclass +class ListTaxesRequest: + order_by: Optional[ListTaxesRequestOrderBy] + """ + Order consumed taxes list in the response by their update date. + """ + + page: Optional[int] + """ + Page number. + """ + + page_size: Optional[int] + """ + Positive integer lower or equal to 100 to select the number of items to return. + """ + + organization_id: Optional[str] + """ + Filter by Organization ID. + """ + + billing_period: Optional[str] + """ + Filter by the billing period in the YYYY-MM format. If it is empty the current billing period will be used as default. + """ + + +@dataclass +class ListInvoicesRequest: + organization_id: Optional[str] + """ + Organization ID. If specified, only invoices from this Organization will be returned. + """ + + billing_period_start_after: Optional[datetime] + """ + Return only invoice with start date greater than billing_period_start. + """ + + billing_period_start_before: Optional[datetime] + """ + Return only invoice with start date less than billing_period_start. + """ + + invoice_type: Optional[InvoiceType] + """ + Invoice type. It can either be `periodic` or `purchase`. + """ + + page: Optional[int] + """ + Page number. + """ + + page_size: Optional[int] + """ + Positive integer lower or equal to 100 to select the number of items to return. + """ + + order_by: Optional[ListInvoicesRequestOrderBy] + """ + How invoices are ordered in the response. + """ + + +@dataclass +class ExportInvoicesRequest: + organization_id: Optional[str] + """ + Organization ID. If specified, only invoices from this Organization will be returned. + """ + + billing_period_start_after: Optional[datetime] + """ + Return only invoice with start date greater than billing_period_start. + """ + + billing_period_start_before: Optional[datetime] + """ + Return only invoice with start date less than billing_period_start. + """ + + invoice_type: InvoiceType + """ + Invoice type. It can either be `periodic` or `purchase`. + """ + + page: Optional[int] + """ + Page number. + """ + + page_size: Optional[int] + """ + Positive integer lower or equal to 100 to select the number of items to return. + """ + + order_by: ExportInvoicesRequestOrderBy + """ + How invoices are ordered in the response. + """ + + file_type: ExportInvoicesRequestFileType + """ + File format for exporting the invoice list. + """ + + +@dataclass +class GetInvoiceRequest: + invoice_id: str + """ + Invoice ID. + """ + + +@dataclass +class DownloadInvoiceRequest: + invoice_id: str + """ + Invoice ID. + """ + + file_type: DownloadInvoiceRequestFileType + """ + File type. PDF by default. + """ diff --git a/scaleway-async/scaleway_async/container/v1beta1/types.py b/scaleway-async/scaleway_async/container/v1beta1/types.py index 1da3c93c0..6662661b0 100644 --- a/scaleway-async/scaleway_async/container/v1beta1/types.py +++ b/scaleway-async/scaleway_async/container/v1beta1/types.py @@ -327,14 +327,14 @@ class CreateTriggerRequestMnqNatsClientConfig: Create trigger request. mnq nats client config. """ - subject: str + mnq_namespace_id: Optional[str] """ - Name of the NATS subject the trigger should listen to. + :deprecated """ - mnq_namespace_id: Optional[str] + subject: str """ - :deprecated + Name of the NATS subject the trigger should listen to. """ mnq_nats_account_id: str diff --git a/scaleway-async/scaleway_async/function/v1beta1/types.py b/scaleway-async/scaleway_async/function/v1beta1/types.py index 900a7a8e7..ce7a5362e 100644 --- a/scaleway-async/scaleway_async/function/v1beta1/types.py +++ b/scaleway-async/scaleway_async/function/v1beta1/types.py @@ -929,14 +929,14 @@ class TriggerMnqSqsClientConfig: Trigger. mnq sqs client config. """ - mnq_namespace_id: Optional[str] + queue: str """ - :deprecated + Name of the SQS queue the trigger listens to. """ - queue: str + mnq_namespace_id: Optional[str] """ - Name of the SQS queue the trigger listens to. + :deprecated """ mnq_project_id: str diff --git a/scaleway/scaleway/billing/v2beta1/__init__.py b/scaleway/scaleway/billing/v2beta1/__init__.py new file mode 100644 index 000000000..2755c24c4 --- /dev/null +++ b/scaleway/scaleway/billing/v2beta1/__init__.py @@ -0,0 +1,33 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from .types import DownloadInvoiceRequestFileType +from .types import ExportInvoicesRequestFileType +from .types import ExportInvoicesRequestOrderBy +from .types import InvoiceType +from .types import ListConsumptionsRequestOrderBy +from .types import ListInvoicesRequestOrderBy +from .types import ListTaxesRequestOrderBy +from .types import Invoice +from .types import ListConsumptionsResponse +from .types import ListConsumptionsResponseConsumption +from .types import ListInvoicesResponse +from .types import ListTaxesResponse +from .types import ListTaxesResponseTax +from .api import BillingV2Beta1API + +__all__ = [ + "DownloadInvoiceRequestFileType", + "ExportInvoicesRequestFileType", + "ExportInvoicesRequestOrderBy", + "InvoiceType", + "ListConsumptionsRequestOrderBy", + "ListInvoicesRequestOrderBy", + "ListTaxesRequestOrderBy", + "Invoice", + "ListConsumptionsResponse", + "ListConsumptionsResponseConsumption", + "ListInvoicesResponse", + "ListTaxesResponse", + "ListTaxesResponseTax", + "BillingV2Beta1API", +] diff --git a/scaleway/scaleway/billing/v2beta1/api.py b/scaleway/scaleway/billing/v2beta1/api.py new file mode 100644 index 000000000..e0a46255d --- /dev/null +++ b/scaleway/scaleway/billing/v2beta1/api.py @@ -0,0 +1,443 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. + +from datetime import datetime +from typing import List, Optional + +from scaleway_core.api import API +from scaleway_core.bridge import ( + ScwFile, + unmarshal_ScwFile, +) +from scaleway_core.utils import ( + OneOfPossibility, + fetch_all_pages, + resolve_one_of, + validate_path_param, +) +from .types import ( + DownloadInvoiceRequestFileType, + ExportInvoicesRequestFileType, + ExportInvoicesRequestOrderBy, + InvoiceType, + ListConsumptionsRequestOrderBy, + ListInvoicesRequestOrderBy, + ListTaxesRequestOrderBy, + Invoice, + ListConsumptionsResponse, + ListConsumptionsResponseConsumption, + ListInvoicesResponse, + ListTaxesResponse, + ListTaxesResponseTax, +) +from .marshalling import ( + unmarshal_Invoice, + unmarshal_ListConsumptionsResponse, + unmarshal_ListInvoicesResponse, + unmarshal_ListTaxesResponse, +) + + +class BillingV2Beta1API(API): + """ + Billing API. + + This API allows you to query your consumption. + Billing API. + """ + + def list_consumptions( + self, + *, + order_by: ListConsumptionsRequestOrderBy = ListConsumptionsRequestOrderBy.UPDATED_AT_DATE_DESC, + page: Optional[int] = None, + page_size: Optional[int] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + category_name: Optional[str] = None, + billing_period: Optional[str] = None, + ) -> ListConsumptionsResponse: + """ + Get monthly consumption. + Consumption allows you to retrieve your past or current consumption cost, by project or category. + :param order_by: Order consumptions list in the response by their update date. + :param page: Positive integer to choose the page to return. + :param page_size: Positive integer lower or equal to 100 to select the number of items to return. + :param organization_id: Filter by Organization ID. + + One-of ('project_identifier'): at most one of 'organization_id', 'project_id' could be set. + :param project_id: Filter by Project ID. + + One-of ('project_identifier'): at most one of 'organization_id', 'project_id' could be set. + :param category_name: Filter by name of a Category as they are shown in the invoice (Compute, Network, Observability). + :param billing_period: Filter by the billing period in the YYYY-MM format. If it is empty the current billing period will be used as default. + :return: :class:`ListConsumptionsResponse ` + + Usage: + :: + + result = api.list_consumptions() + """ + + res = self._request( + "GET", + f"/billing/v2beta1/consumptions", + params={ + "billing_period": billing_period, + "category_name": category_name, + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + **resolve_one_of( + [ + OneOfPossibility( + "project_id", project_id, self.client.default_project_id + ), + OneOfPossibility( + "organization_id", + organization_id, + self.client.default_organization_id, + ), + ] + ), + }, + ) + + self._throw_on_error(res) + return unmarshal_ListConsumptionsResponse(res.json()) + + def list_consumptions_all( + self, + *, + order_by: Optional[ListConsumptionsRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + category_name: Optional[str] = None, + billing_period: Optional[str] = None, + ) -> List[ListConsumptionsResponseConsumption]: + """ + Get monthly consumption. + Consumption allows you to retrieve your past or current consumption cost, by project or category. + :param order_by: Order consumptions list in the response by their update date. + :param page: Positive integer to choose the page to return. + :param page_size: Positive integer lower or equal to 100 to select the number of items to return. + :param organization_id: Filter by Organization ID. + + One-of ('project_identifier'): at most one of 'organization_id', 'project_id' could be set. + :param project_id: Filter by Project ID. + + One-of ('project_identifier'): at most one of 'organization_id', 'project_id' could be set. + :param category_name: Filter by name of a Category as they are shown in the invoice (Compute, Network, Observability). + :param billing_period: Filter by the billing period in the YYYY-MM format. If it is empty the current billing period will be used as default. + :return: :class:`List[ListConsumptionsResponse] ` + + Usage: + :: + + result = api.list_consumptions_all() + """ + + return fetch_all_pages( + type=ListConsumptionsResponse, + key="consumptions", + fetcher=self.list_consumptions, + args={ + "order_by": order_by, + "page": page, + "page_size": page_size, + "organization_id": organization_id, + "project_id": project_id, + "category_name": category_name, + "billing_period": billing_period, + }, + ) + + def list_taxes( + self, + *, + order_by: ListTaxesRequestOrderBy = ListTaxesRequestOrderBy.UPDATED_AT_DATE_DESC, + page: Optional[int] = None, + page_size: Optional[int] = None, + organization_id: Optional[str] = None, + billing_period: Optional[str] = None, + ) -> ListTaxesResponse: + """ + Get monthly consumption taxes. + Consumption Tax allows you to retrieve your past or current tax charges, by project or category. + :param order_by: Order consumed taxes list in the response by their update date. + :param page: Page number. + :param page_size: Positive integer lower or equal to 100 to select the number of items to return. + :param organization_id: Filter by Organization ID. + :param billing_period: Filter by the billing period in the YYYY-MM format. If it is empty the current billing period will be used as default. + :return: :class:`ListTaxesResponse ` + + Usage: + :: + + result = api.list_taxes() + """ + + res = self._request( + "GET", + f"/billing/v2beta1/taxes", + params={ + "billing_period": billing_period, + "order_by": order_by, + "organization_id": organization_id + or self.client.default_organization_id, + "page": page, + "page_size": page_size or self.client.default_page_size, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListTaxesResponse(res.json()) + + def list_taxes_all( + self, + *, + order_by: Optional[ListTaxesRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + organization_id: Optional[str] = None, + billing_period: Optional[str] = None, + ) -> List[ListTaxesResponseTax]: + """ + Get monthly consumption taxes. + Consumption Tax allows you to retrieve your past or current tax charges, by project or category. + :param order_by: Order consumed taxes list in the response by their update date. + :param page: Page number. + :param page_size: Positive integer lower or equal to 100 to select the number of items to return. + :param organization_id: Filter by Organization ID. + :param billing_period: Filter by the billing period in the YYYY-MM format. If it is empty the current billing period will be used as default. + :return: :class:`List[ListTaxesResponse] ` + + Usage: + :: + + result = api.list_taxes_all() + """ + + return fetch_all_pages( + type=ListTaxesResponse, + key="taxes", + fetcher=self.list_taxes, + args={ + "order_by": order_by, + "page": page, + "page_size": page_size, + "organization_id": organization_id, + "billing_period": billing_period, + }, + ) + + def list_invoices( + self, + *, + organization_id: Optional[str] = None, + billing_period_start_after: Optional[datetime] = None, + billing_period_start_before: Optional[datetime] = None, + invoice_type: InvoiceType = InvoiceType.UNKNOWN_TYPE, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: ListInvoicesRequestOrderBy = ListInvoicesRequestOrderBy.INVOICE_NUMBER_DESC, + ) -> ListInvoicesResponse: + """ + List invoices. + List all your invoices, filtering by `start_date` and `invoice_type`. Each invoice has its own ID. + :param organization_id: Organization ID. If specified, only invoices from this Organization will be returned. + :param billing_period_start_after: Return only invoice with start date greater than billing_period_start. + :param billing_period_start_before: Return only invoice with start date less than billing_period_start. + :param invoice_type: Invoice type. It can either be `periodic` or `purchase`. + :param page: Page number. + :param page_size: Positive integer lower or equal to 100 to select the number of items to return. + :param order_by: How invoices are ordered in the response. + :return: :class:`ListInvoicesResponse ` + + Usage: + :: + + result = api.list_invoices() + """ + + res = self._request( + "GET", + f"/billing/v2beta1/invoices", + params={ + "billing_period_start_after": billing_period_start_after, + "billing_period_start_before": billing_period_start_before, + "invoice_type": invoice_type, + "order_by": order_by, + "organization_id": organization_id + or self.client.default_organization_id, + "page": page, + "page_size": page_size or self.client.default_page_size, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListInvoicesResponse(res.json()) + + def list_invoices_all( + self, + *, + organization_id: Optional[str] = None, + billing_period_start_after: Optional[datetime] = None, + billing_period_start_before: Optional[datetime] = None, + invoice_type: Optional[InvoiceType] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListInvoicesRequestOrderBy] = None, + ) -> List[Invoice]: + """ + List invoices. + List all your invoices, filtering by `start_date` and `invoice_type`. Each invoice has its own ID. + :param organization_id: Organization ID. If specified, only invoices from this Organization will be returned. + :param billing_period_start_after: Return only invoice with start date greater than billing_period_start. + :param billing_period_start_before: Return only invoice with start date less than billing_period_start. + :param invoice_type: Invoice type. It can either be `periodic` or `purchase`. + :param page: Page number. + :param page_size: Positive integer lower or equal to 100 to select the number of items to return. + :param order_by: How invoices are ordered in the response. + :return: :class:`List[ListInvoicesResponse] ` + + Usage: + :: + + result = api.list_invoices_all() + """ + + return fetch_all_pages( + type=ListInvoicesResponse, + key="invoices", + fetcher=self.list_invoices, + args={ + "organization_id": organization_id, + "billing_period_start_after": billing_period_start_after, + "billing_period_start_before": billing_period_start_before, + "invoice_type": invoice_type, + "page": page, + "page_size": page_size, + "order_by": order_by, + }, + ) + + def export_invoices( + self, + *, + invoice_type: InvoiceType, + order_by: ExportInvoicesRequestOrderBy, + file_type: ExportInvoicesRequestFileType, + organization_id: Optional[str] = None, + billing_period_start_after: Optional[datetime] = None, + billing_period_start_before: Optional[datetime] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Optional[ScwFile]: + """ + Export invoices. + Export invoices in a CSV file. + :param organization_id: Organization ID. If specified, only invoices from this Organization will be returned. + :param billing_period_start_after: Return only invoice with start date greater than billing_period_start. + :param billing_period_start_before: Return only invoice with start date less than billing_period_start. + :param invoice_type: Invoice type. It can either be `periodic` or `purchase`. + :param page: Page number. + :param page_size: Positive integer lower or equal to 100 to select the number of items to return. + :param order_by: How invoices are ordered in the response. + :param file_type: File format for exporting the invoice list. + :return: :class:`Optional[ScwFile] ` + + Usage: + :: + + result = api.export_invoices( + invoice_type=unknown_type, + order_by=invoice_number_desc, + file_type=csv, + ) + """ + + res = self._request( + "GET", + f"/billing/v2beta1/export-invoices", + params={ + "billing_period_start_after": billing_period_start_after, + "billing_period_start_before": billing_period_start_before, + "file_type": file_type, + "invoice_type": invoice_type, + "order_by": order_by, + "organization_id": organization_id + or self.client.default_organization_id, + "page": page, + "page_size": page_size or self.client.default_page_size, + }, + ) + + self._throw_on_error(res) + json = res.json() + return unmarshal_ScwFile(json) if json is not None else None + + def get_invoice( + self, + *, + invoice_id: str, + ) -> Invoice: + """ + Get an invoice. + Get a specific invoice, specified by its ID. + :param invoice_id: Invoice ID. + :return: :class:`Invoice ` + + Usage: + :: + + result = api.get_invoice(invoice_id="example") + """ + + param_invoice_id = validate_path_param("invoice_id", invoice_id) + + res = self._request( + "GET", + f"/billing/v2beta1/invoices/{param_invoice_id}", + ) + + self._throw_on_error(res) + return unmarshal_Invoice(res.json()) + + def download_invoice( + self, + *, + invoice_id: str, + file_type: DownloadInvoiceRequestFileType, + ) -> Optional[ScwFile]: + """ + Download an invoice. + Download a specific invoice, specified by its ID. + :param invoice_id: Invoice ID. + :param file_type: File type. PDF by default. + :return: :class:`Optional[ScwFile] ` + + Usage: + :: + + result = api.download_invoice( + invoice_id="example", + file_type=pdf, + ) + """ + + param_invoice_id = validate_path_param("invoice_id", invoice_id) + + res = self._request( + "GET", + f"/billing/v2beta1/invoices/{param_invoice_id}/download", + params={ + "file_type": file_type, + }, + ) + + self._throw_on_error(res) + json = res.json() + return unmarshal_ScwFile(json) if json is not None else None diff --git a/scaleway/scaleway/billing/v2beta1/marshalling.py b/scaleway/scaleway/billing/v2beta1/marshalling.py new file mode 100644 index 000000000..31d92400c --- /dev/null +++ b/scaleway/scaleway/billing/v2beta1/marshalling.py @@ -0,0 +1,206 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. + +from typing import Any, Dict + +from scaleway_core.bridge import ( + unmarshal_Money, +) +from dateutil import parser +from .types import ( + Invoice, + ListConsumptionsResponse, + ListConsumptionsResponseConsumption, + ListInvoicesResponse, + ListTaxesResponse, + ListTaxesResponseTax, +) + + +def unmarshal_Invoice(data: Any) -> Invoice: + if type(data) is not dict: + raise TypeError( + f"Unmarshalling the type 'Invoice' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("billing_period", None) + args["billing_period"] = parser.isoparse(field) if type(field) is str else field + + field = data.get("customer_name", None) + args["customer_name"] = field + + field = data.get("due_date", None) + args["due_date"] = parser.isoparse(field) if type(field) is str else field + + field = data.get("id", None) + args["id"] = field + + field = data.get("issued_date", None) + args["issued_date"] = parser.isoparse(field) if type(field) is str else field + + field = data.get("number", None) + args["number"] = field + + field = data.get("organization_id", None) + args["organization_id"] = field + + field = data.get("organization_name", None) + args["organization_name"] = field + + field = data.get("seller_name", None) + args["seller_name"] = field + + field = data.get("start_date", None) + args["start_date"] = parser.isoparse(field) if type(field) is str else field + + field = data.get("state", None) + args["state"] = field + + field = data.get("stop_date", None) + args["stop_date"] = parser.isoparse(field) if type(field) is str else field + + field = data.get("total_discount", None) + args["total_discount"] = unmarshal_Money(field) if field is not None else None + + field = data.get("total_tax", None) + args["total_tax"] = unmarshal_Money(field) if field is not None else None + + field = data.get("total_taxed", None) + args["total_taxed"] = unmarshal_Money(field) if field is not None else None + + field = data.get("total_undiscount", None) + args["total_undiscount"] = unmarshal_Money(field) if field is not None else None + + field = data.get("total_untaxed", None) + args["total_untaxed"] = unmarshal_Money(field) if field is not None else None + + field = data.get("type", None) + args["type_"] = field + + return Invoice(**args) + + +def unmarshal_ListConsumptionsResponseConsumption( + data: Any, +) -> ListConsumptionsResponseConsumption: + if type(data) is not dict: + raise TypeError( + f"Unmarshalling the type 'ListConsumptionsResponseConsumption' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("category_name", None) + args["category_name"] = field + + field = data.get("product_name", None) + args["product_name"] = field + + field = data.get("project_id", None) + args["project_id"] = field + + field = data.get("resource_name", None) + args["resource_name"] = field + + field = data.get("sku", None) + args["sku"] = field + + field = data.get("value", None) + args["value"] = unmarshal_Money(field) if field is not None else None + + return ListConsumptionsResponseConsumption(**args) + + +def unmarshal_ListTaxesResponseTax(data: Any) -> ListTaxesResponseTax: + if type(data) is not dict: + raise TypeError( + f"Unmarshalling the type 'ListTaxesResponseTax' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("currency", None) + args["currency"] = field + + field = data.get("description", None) + args["description"] = field + + field = data.get("rate", None) + args["rate"] = field + + field = data.get("total_tax_value", None) + args["total_tax_value"] = field + + return ListTaxesResponseTax(**args) + + +def unmarshal_ListConsumptionsResponse(data: Any) -> ListConsumptionsResponse: + if type(data) is not dict: + raise TypeError( + f"Unmarshalling the type 'ListConsumptionsResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("consumptions", None) + args["consumptions"] = ( + [unmarshal_ListConsumptionsResponseConsumption(v) for v in field] + if field is not None + else None + ) + + field = data.get("total_count", None) + args["total_count"] = field + + field = data.get("total_discount_untaxed_value", None) + args["total_discount_untaxed_value"] = field + + field = data.get("updated_at", None) + args["updated_at"] = parser.isoparse(field) if type(field) is str else field + + return ListConsumptionsResponse(**args) + + +def unmarshal_ListInvoicesResponse(data: Any) -> ListInvoicesResponse: + if type(data) is not dict: + raise TypeError( + f"Unmarshalling the type 'ListInvoicesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("invoices", None) + args["invoices"] = ( + [unmarshal_Invoice(v) for v in field] if field is not None else None + ) + + field = data.get("total_count", None) + args["total_count"] = field + + return ListInvoicesResponse(**args) + + +def unmarshal_ListTaxesResponse(data: Any) -> ListTaxesResponse: + if type(data) is not dict: + raise TypeError( + f"Unmarshalling the type 'ListTaxesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("taxes", None) + args["taxes"] = ( + [unmarshal_ListTaxesResponseTax(v) for v in field] + if field is not None + else None + ) + + field = data.get("total_count", None) + args["total_count"] = field + + field = data.get("updated_at", None) + args["updated_at"] = parser.isoparse(field) if type(field) is str else field + + return ListTaxesResponse(**args) diff --git a/scaleway/scaleway/billing/v2beta1/types.py b/scaleway/scaleway/billing/v2beta1/types.py new file mode 100644 index 000000000..a2c2f05cc --- /dev/null +++ b/scaleway/scaleway/billing/v2beta1/types.py @@ -0,0 +1,485 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from __future__ import annotations + +from dataclasses import dataclass +from datetime import datetime +from enum import Enum +from typing import List, Optional + +from scaleway_core.bridge import ( + Money, +) +from scaleway_core.utils import ( + StrEnumMeta, +) + + +class DownloadInvoiceRequestFileType(str, Enum, metaclass=StrEnumMeta): + PDF = "pdf" + + def __str__(self) -> str: + return str(self.value) + + +class ExportInvoicesRequestFileType(str, Enum, metaclass=StrEnumMeta): + CSV = "csv" + + def __str__(self) -> str: + return str(self.value) + + +class ExportInvoicesRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + INVOICE_NUMBER_DESC = "invoice_number_desc" + INVOICE_NUMBER_ASC = "invoice_number_asc" + START_DATE_DESC = "start_date_desc" + START_DATE_ASC = "start_date_asc" + ISSUED_DATE_DESC = "issued_date_desc" + ISSUED_DATE_ASC = "issued_date_asc" + DUE_DATE_DESC = "due_date_desc" + DUE_DATE_ASC = "due_date_asc" + TOTAL_UNTAXED_DESC = "total_untaxed_desc" + TOTAL_UNTAXED_ASC = "total_untaxed_asc" + TOTAL_TAXED_DESC = "total_taxed_desc" + TOTAL_TAXED_ASC = "total_taxed_asc" + INVOICE_TYPE_DESC = "invoice_type_desc" + INVOICE_TYPE_ASC = "invoice_type_asc" + + def __str__(self) -> str: + return str(self.value) + + +class InvoiceType(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_TYPE = "unknown_type" + PERIODIC = "periodic" + PURCHASE = "purchase" + + def __str__(self) -> str: + return str(self.value) + + +class ListConsumptionsRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + UPDATED_AT_DATE_DESC = "updated_at_date_desc" + UPDATED_AT_DATE_ASC = "updated_at_date_asc" + CATEGORY_NAME_DESC = "category_name_desc" + CATEGORY_NAME_ASC = "category_name_asc" + + def __str__(self) -> str: + return str(self.value) + + +class ListInvoicesRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + INVOICE_NUMBER_DESC = "invoice_number_desc" + INVOICE_NUMBER_ASC = "invoice_number_asc" + START_DATE_DESC = "start_date_desc" + START_DATE_ASC = "start_date_asc" + ISSUED_DATE_DESC = "issued_date_desc" + ISSUED_DATE_ASC = "issued_date_asc" + DUE_DATE_DESC = "due_date_desc" + DUE_DATE_ASC = "due_date_asc" + TOTAL_UNTAXED_DESC = "total_untaxed_desc" + TOTAL_UNTAXED_ASC = "total_untaxed_asc" + TOTAL_TAXED_DESC = "total_taxed_desc" + TOTAL_TAXED_ASC = "total_taxed_asc" + INVOICE_TYPE_DESC = "invoice_type_desc" + INVOICE_TYPE_ASC = "invoice_type_asc" + + def __str__(self) -> str: + return str(self.value) + + +class ListTaxesRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + UPDATED_AT_DATE_DESC = "updated_at_date_desc" + UPDATED_AT_DATE_ASC = "updated_at_date_asc" + CATEGORY_NAME_DESC = "category_name_desc" + CATEGORY_NAME_ASC = "category_name_asc" + + def __str__(self) -> str: + return str(self.value) + + +@dataclass +class Invoice: + """ + Invoice. + """ + + id: str + """ + Invoice ID. + """ + + organization_id: str + + organization_name: str + + start_date: Optional[datetime] + """ + Start date of the billing period. + """ + + stop_date: Optional[datetime] + + billing_period: Optional[datetime] + """ + The billing period of the invoice in the YYYY-MM format. + """ + + issued_date: Optional[datetime] + """ + Date when the invoice was sent to the customer. + """ + + due_date: Optional[datetime] + """ + Payment time limit, set according to the Organization's payment conditions. + """ + + total_untaxed: Optional[Money] + """ + Total amount, untaxed. + """ + + total_taxed: Optional[Money] + """ + Total amount, taxed. + """ + + total_tax: Optional[Money] + """ + The total tax amount of the invoice. + """ + + total_discount: Optional[Money] + """ + The total discount amount of the invoice. + """ + + total_undiscount: Optional[Money] + """ + The total amount of the invoice before applying the discount. + """ + + type_: InvoiceType + """ + Type of invoice, either periodic or purchase. + """ + + state: str + """ + The state of the Invoice. + """ + + number: int + """ + Invoice number. + """ + + seller_name: str + + customer_name: str + """ + Customer name associated to this organization. + """ + + +@dataclass +class ListConsumptionsResponse: + """ + List consumptions response. + """ + + consumptions: List[ListConsumptionsResponseConsumption] + """ + Detailed consumption list. + """ + + total_count: int + """ + Total number of returned items. + """ + + total_discount_untaxed_value: float + """ + Sum of all discounts, displayed only when no category or project ID filter is applied. + """ + + updated_at: Optional[datetime] + """ + Last consumption update date. + """ + + +@dataclass +class ListConsumptionsResponseConsumption: + """ + List consumptions response. consumption. + """ + + value: Optional[Money] + """ + Monetary value of the consumption. + """ + + product_name: str + """ + The product name. For example, "VPC Public Gateway S", "VPC Public Gateway M" for the VPC product. + """ + + resource_name: str + """ + Identifies the reference based on the category. + """ + + sku: str + """ + Unique identifier of the product. + """ + + project_id: str + """ + Project ID of the consumption. + """ + + category_name: str + """ + Name of consumption category. + """ + + +@dataclass +class ListInvoicesResponse: + """ + List invoices response. + """ + + total_count: int + """ + Total number of invoices. + """ + + invoices: List[Invoice] + """ + Paginated returned invoices. + """ + + +@dataclass +class ListTaxesResponse: + """ + List taxes response. + """ + + taxes: List[ListTaxesResponseTax] + """ + Detailed consumption tax. + """ + + total_count: int + """ + Total number of returned items. + """ + + updated_at: Optional[datetime] + """ + Last consumption update date. + """ + + +@dataclass +class ListTaxesResponseTax: + """ + List taxes response. tax. + """ + + description: str + """ + Description of the tax applied. + """ + + currency: str + """ + The three-letter currency code. + """ + + rate: Optional[float] + """ + Applied tax rate (0.2 means a VAT of 20%). + """ + + total_tax_value: Optional[float] + """ + The total tax value of the consumption. + """ + + +@dataclass +class ListConsumptionsRequest: + order_by: Optional[ListConsumptionsRequestOrderBy] + """ + Order consumptions list in the response by their update date. + """ + + page: Optional[int] + """ + Positive integer to choose the page to return. + """ + + page_size: Optional[int] + """ + Positive integer lower or equal to 100 to select the number of items to return. + """ + + organization_id: Optional[str] + """ + Filter by Organization ID. + + One-of ('project_identifier'): at most one of 'organization_id', 'project_id' could be set. + """ + + project_id: Optional[str] + """ + Filter by Project ID. + + One-of ('project_identifier'): at most one of 'organization_id', 'project_id' could be set. + """ + + category_name: Optional[str] + """ + Filter by name of a Category as they are shown in the invoice (Compute, Network, Observability). + """ + + billing_period: Optional[str] + """ + Filter by the billing period in the YYYY-MM format. If it is empty the current billing period will be used as default. + """ + + +@dataclass +class ListTaxesRequest: + order_by: Optional[ListTaxesRequestOrderBy] + """ + Order consumed taxes list in the response by their update date. + """ + + page: Optional[int] + """ + Page number. + """ + + page_size: Optional[int] + """ + Positive integer lower or equal to 100 to select the number of items to return. + """ + + organization_id: Optional[str] + """ + Filter by Organization ID. + """ + + billing_period: Optional[str] + """ + Filter by the billing period in the YYYY-MM format. If it is empty the current billing period will be used as default. + """ + + +@dataclass +class ListInvoicesRequest: + organization_id: Optional[str] + """ + Organization ID. If specified, only invoices from this Organization will be returned. + """ + + billing_period_start_after: Optional[datetime] + """ + Return only invoice with start date greater than billing_period_start. + """ + + billing_period_start_before: Optional[datetime] + """ + Return only invoice with start date less than billing_period_start. + """ + + invoice_type: Optional[InvoiceType] + """ + Invoice type. It can either be `periodic` or `purchase`. + """ + + page: Optional[int] + """ + Page number. + """ + + page_size: Optional[int] + """ + Positive integer lower or equal to 100 to select the number of items to return. + """ + + order_by: Optional[ListInvoicesRequestOrderBy] + """ + How invoices are ordered in the response. + """ + + +@dataclass +class ExportInvoicesRequest: + organization_id: Optional[str] + """ + Organization ID. If specified, only invoices from this Organization will be returned. + """ + + billing_period_start_after: Optional[datetime] + """ + Return only invoice with start date greater than billing_period_start. + """ + + billing_period_start_before: Optional[datetime] + """ + Return only invoice with start date less than billing_period_start. + """ + + invoice_type: InvoiceType + """ + Invoice type. It can either be `periodic` or `purchase`. + """ + + page: Optional[int] + """ + Page number. + """ + + page_size: Optional[int] + """ + Positive integer lower or equal to 100 to select the number of items to return. + """ + + order_by: ExportInvoicesRequestOrderBy + """ + How invoices are ordered in the response. + """ + + file_type: ExportInvoicesRequestFileType + """ + File format for exporting the invoice list. + """ + + +@dataclass +class GetInvoiceRequest: + invoice_id: str + """ + Invoice ID. + """ + + +@dataclass +class DownloadInvoiceRequest: + invoice_id: str + """ + Invoice ID. + """ + + file_type: DownloadInvoiceRequestFileType + """ + File type. PDF by default. + """ diff --git a/scaleway/scaleway/container/v1beta1/types.py b/scaleway/scaleway/container/v1beta1/types.py index 6662661b0..d51f72485 100644 --- a/scaleway/scaleway/container/v1beta1/types.py +++ b/scaleway/scaleway/container/v1beta1/types.py @@ -360,14 +360,14 @@ class CreateTriggerRequestMnqSqsClientConfig: Create trigger request. mnq sqs client config. """ - mnq_namespace_id: Optional[str] + queue: str """ - :deprecated + Name of the SQS queue the trigger should listen to. """ - queue: str + mnq_namespace_id: Optional[str] """ - Name of the SQS queue the trigger should listen to. + :deprecated """ mnq_project_id: str diff --git a/scaleway/scaleway/function/v1beta1/types.py b/scaleway/scaleway/function/v1beta1/types.py index 42519825f..266baa331 100644 --- a/scaleway/scaleway/function/v1beta1/types.py +++ b/scaleway/scaleway/function/v1beta1/types.py @@ -279,14 +279,14 @@ class CreateTriggerRequestMnqSqsClientConfig: Create trigger request. mnq sqs client config. """ - queue: str + mnq_namespace_id: Optional[str] """ - Name of the SQS queue the trigger should listen to. + :deprecated """ - mnq_namespace_id: Optional[str] + queue: str """ - :deprecated + Name of the SQS queue the trigger should listen to. """ mnq_project_id: str @@ -891,14 +891,14 @@ class TriggerMnqNatsClientConfig: Trigger. mnq nats client config. """ - mnq_namespace_id: Optional[str] + subject: str """ - :deprecated + Name of the NATS subject the trigger listens to. """ - subject: str + mnq_namespace_id: Optional[str] """ - Name of the NATS subject the trigger listens to. + :deprecated """ mnq_nats_account_id: str