Skip to content

Commit

Permalink
feta: update generation
Browse files Browse the repository at this point in the history
  • Loading branch information
quantumsheep committed Oct 26, 2023
1 parent 33e03ee commit 642bade
Show file tree
Hide file tree
Showing 92 changed files with 2,670 additions and 11,362 deletions.
24 changes: 8 additions & 16 deletions scaleway-async/scaleway_async/billing/v2alpha1/__init__.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,27 @@
# 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 DiscountDiscountMode
from .types import DiscountFilterType
from .types import DownloadInvoiceRequestFileType
from .types import InvoiceType
from .types import ListDiscountsRequestOrderBy
from .types import ListInvoicesRequestOrderBy
from .types import Discount
from .types import DiscountCoupon
from .types import DiscountFilter
from .types import GetConsumptionResponse
from .types import GetConsumptionResponseConsumption
from .types import Invoice
from .types import ListDiscountsResponse
from .types import DownloadInvoiceRequest
from .types import GetConsumptionRequest
from .types import GetConsumptionResponse
from .types import ListInvoicesRequest
from .types import ListInvoicesResponse
from .api import BillingV2Alpha1API

__all__ = [
"DiscountDiscountMode",
"DiscountFilterType",
"DownloadInvoiceRequestFileType",
"InvoiceType",
"ListDiscountsRequestOrderBy",
"ListInvoicesRequestOrderBy",
"Discount",
"DiscountCoupon",
"DiscountFilter",
"GetConsumptionResponse",
"GetConsumptionResponseConsumption",
"Invoice",
"ListDiscountsResponse",
"DownloadInvoiceRequest",
"GetConsumptionRequest",
"GetConsumptionResponse",
"ListInvoicesRequest",
"ListInvoicesResponse",
"BillingV2Alpha1API",
]
80 changes: 1 addition & 79 deletions scaleway-async/scaleway_async/billing/v2alpha1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,13 @@
from .types import (
DownloadInvoiceRequestFileType,
InvoiceType,
ListDiscountsRequestOrderBy,
ListInvoicesRequestOrderBy,
Discount,
GetConsumptionResponse,
Invoice,
ListDiscountsResponse,
ListInvoicesResponse,
)
from .marshalling import (
unmarshal_GetConsumptionResponse,
unmarshal_ListDiscountsResponse,
unmarshal_ListInvoicesResponse,
)

Expand Down Expand Up @@ -189,78 +185,4 @@ async def download_invoice(
)

self._throw_on_error(res)
json = res.json()
return unmarshal_ScwFile(json) if json is not None else None

async def list_discounts(
self,
*,
order_by: ListDiscountsRequestOrderBy = ListDiscountsRequestOrderBy.CREATION_DATE_DESC,
page: Optional[int] = None,
page_size: Optional[int] = None,
organization_id: Optional[str] = None,
) -> ListDiscountsResponse:
"""
List all user's discounts.
List all discounts for an organization and usable categories/products/offers/references/regions/zones where the discount can be applied.
:param order_by: Order discounts in the response by their description.
: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: ID of the organization.
:return: :class:`ListDiscountsResponse <ListDiscountsResponse>`
Usage:
::
result = await api.list_discounts()
"""

res = self._request(
"GET",
f"/billing/v2alpha1/discounts",
params={
"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_ListDiscountsResponse(res.json())

async def list_discounts_all(
self,
*,
order_by: Optional[ListDiscountsRequestOrderBy] = None,
page: Optional[int] = None,
page_size: Optional[int] = None,
organization_id: Optional[str] = None,
) -> List[Discount]:
"""
List all user's discounts.
List all discounts for an organization and usable categories/products/offers/references/regions/zones where the discount can be applied.
:param order_by: Order discounts in the response by their description.
: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: ID of the organization.
:return: :class:`List[ListDiscountsResponse] <List[ListDiscountsResponse]>`
Usage:
::
result = await api.list_discounts_all()
"""

return await fetch_all_pages_async(
type=ListDiscountsResponse,
key="discounts",
fetcher=self.list_discounts,
args={
"order_by": order_by,
"page": page,
"page_size": page_size,
"organization_id": organization_id,
},
)
return unmarshal_ScwFile(res.json())
108 changes: 2 additions & 106 deletions scaleway-async/scaleway_async/billing/v2alpha1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,98 +8,13 @@
unmarshal_Money,
)
from .types import (
Discount,
DiscountCoupon,
DiscountFilter,
GetConsumptionResponse,
GetConsumptionResponseConsumption,
GetConsumptionResponse,
Invoice,
ListDiscountsResponse,
ListInvoicesResponse,
)


def unmarshal_DiscountCoupon(data: Any) -> DiscountCoupon:
if type(data) is not dict:
raise TypeError(
f"Unmarshalling the type 'DiscountCoupon' failed as data isn't a dictionary."
)

args: Dict[str, Any] = {}

field = data.get("description", None)
args["description"] = field

return DiscountCoupon(**args)


def unmarshal_DiscountFilter(data: Any) -> DiscountFilter:
if type(data) is not dict:
raise TypeError(
f"Unmarshalling the type 'DiscountFilter' failed as data isn't a dictionary."
)

args: Dict[str, Any] = {}

field = data.get("type", None)
args["type_"] = field

field = data.get("value", None)
args["value"] = field

return DiscountFilter(**args)


def unmarshal_Discount(data: Any) -> Discount:
if type(data) is not dict:
raise TypeError(
f"Unmarshalling the type 'Discount' failed as data isn't a dictionary."
)

args: Dict[str, Any] = {}

field = data.get("coupon", None)
args["coupon"] = unmarshal_DiscountCoupon(field) if field is not None else None

field = data.get("creation_date", None)
args["creation_date"] = parser.isoparse(field) if type(field) is str else field

field = data.get("description", None)
args["description"] = field

field = data.get("filters", None)
args["filters"] = (
[unmarshal_DiscountFilter(v) for v in field] if field is not None else None
)

field = data.get("id", None)
args["id"] = field

field = data.get("mode", None)
args["mode"] = field

field = data.get("organization_id", None)
args["organization_id"] = field

field = data.get("start_date", None)
args["start_date"] = parser.isoparse(field) if type(field) is str else field

field = data.get("stop_date", None)
args["stop_date"] = parser.isoparse(field) if type(field) is str else field

field = data.get("value", None)
args["value"] = field

field = data.get("value_remaining", None)
args["value_remaining"] = field

field = data.get("value_used", None)
args["value_used"] = field

return Discount(**args)


def unmarshal_GetConsumptionResponseConsumption(
data: Any,
) -> GetConsumptionResponseConsumption:
Expand Down Expand Up @@ -149,27 +64,8 @@ def unmarshal_GetConsumptionResponse(data: Any) -> GetConsumptionResponse:
return GetConsumptionResponse(**args)


def unmarshal_ListDiscountsResponse(data: Any) -> ListDiscountsResponse:
if type(data) is not dict:
raise TypeError(
f"Unmarshalling the type 'ListDiscountsResponse' failed as data isn't a dictionary."
)

args: Dict[str, Any] = {}

field = data.get("discounts", None)
args["discounts"] = (
[unmarshal_Discount(v) for v in field] if field is not None else None
)

field = data.get("total_count", None)
args["total_count"] = field

return ListDiscountsResponse(**args)


def unmarshal_ListInvoicesResponse(data: Any) -> ListInvoicesResponse:
if type(data) is not dict:
def unmarshal_Invoice(data: Any) -> Invoice:
if not isinstance(data, dict):
raise TypeError(
"Unmarshalling the type 'Invoice' failed as data isn't a dictionary."
)
Expand Down
Loading

0 comments on commit 642bade

Please sign in to comment.