Skip to content

Commit 4373720

Browse files
authored
feat(tem): generate offers cli (#910)
1 parent 121fe1f commit 4373720

File tree

8 files changed

+1680
-0
lines changed

8 files changed

+1680
-0
lines changed

scaleway-async/scaleway_async/tem/v1alpha1/__init__.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
from .types import ListEmailsRequestOrderBy
1515
from .types import ListWebhookEventsRequestOrderBy
1616
from .types import ListWebhooksRequestOrderBy
17+
from .types import OfferName
18+
from .types import PoolStatus
1719
from .types import ProjectSettingsPeriodicReportFrequency
1820
from .types import WebhookEventStatus
1921
from .types import WebhookEventType
@@ -32,6 +34,9 @@
3234
from .types import DomainLastStatusDmarcRecord
3335
from .types import DomainLastStatusSpfRecord
3436
from .types import Domain
37+
from .types import OfferSubscription
38+
from .types import Offer
39+
from .types import Pool
3540
from .types import WebhookEvent
3641
from .types import Webhook
3742
from .types import ProjectSettingsPeriodicReport
@@ -50,6 +55,7 @@
5055
from .types import GetDomainLastStatusRequest
5156
from .types import GetDomainRequest
5257
from .types import GetEmailRequest
58+
from .types import GetProjectConsumptionRequest
5359
from .types import GetProjectSettingsRequest
5460
from .types import GetStatisticsRequest
5561
from .types import GetWebhookRequest
@@ -59,14 +65,22 @@
5965
from .types import ListDomainsResponse
6066
from .types import ListEmailsRequest
6167
from .types import ListEmailsResponse
68+
from .types import ListOfferSubscriptionsRequest
69+
from .types import ListOfferSubscriptionsResponse
70+
from .types import ListOffersRequest
71+
from .types import ListOffersResponse
72+
from .types import ListPoolsRequest
73+
from .types import ListPoolsResponse
6274
from .types import ListWebhookEventsRequest
6375
from .types import ListWebhookEventsResponse
6476
from .types import ListWebhooksRequest
6577
from .types import ListWebhooksResponse
78+
from .types import ProjectConsumption
6679
from .types import ProjectSettings
6780
from .types import RevokeDomainRequest
6881
from .types import Statistics
6982
from .types import UpdateDomainRequest
83+
from .types import UpdateOfferSubscriptionRequest
7084
from .types import UpdateProjectSettingsRequest
7185
from .types import UpdateWebhookRequest
7286
from .api import TemV1Alpha1API
@@ -86,6 +100,8 @@
86100
"ListEmailsRequestOrderBy",
87101
"ListWebhookEventsRequestOrderBy",
88102
"ListWebhooksRequestOrderBy",
103+
"OfferName",
104+
"PoolStatus",
89105
"ProjectSettingsPeriodicReportFrequency",
90106
"WebhookEventStatus",
91107
"WebhookEventType",
@@ -104,6 +120,9 @@
104120
"DomainLastStatusDmarcRecord",
105121
"DomainLastStatusSpfRecord",
106122
"Domain",
123+
"OfferSubscription",
124+
"Offer",
125+
"Pool",
107126
"WebhookEvent",
108127
"Webhook",
109128
"ProjectSettingsPeriodicReport",
@@ -122,6 +141,7 @@
122141
"GetDomainLastStatusRequest",
123142
"GetDomainRequest",
124143
"GetEmailRequest",
144+
"GetProjectConsumptionRequest",
125145
"GetProjectSettingsRequest",
126146
"GetStatisticsRequest",
127147
"GetWebhookRequest",
@@ -131,14 +151,22 @@
131151
"ListDomainsResponse",
132152
"ListEmailsRequest",
133153
"ListEmailsResponse",
154+
"ListOfferSubscriptionsRequest",
155+
"ListOfferSubscriptionsResponse",
156+
"ListOffersRequest",
157+
"ListOffersResponse",
158+
"ListPoolsRequest",
159+
"ListPoolsResponse",
134160
"ListWebhookEventsRequest",
135161
"ListWebhookEventsResponse",
136162
"ListWebhooksRequest",
137163
"ListWebhooksResponse",
164+
"ProjectConsumption",
138165
"ProjectSettings",
139166
"RevokeDomainRequest",
140167
"Statistics",
141168
"UpdateDomainRequest",
169+
"UpdateOfferSubscriptionRequest",
142170
"UpdateProjectSettingsRequest",
143171
"UpdateWebhookRequest",
144172
"TemV1Alpha1API",

scaleway-async/scaleway_async/tem/v1alpha1/api.py

Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
ListEmailsRequestOrderBy,
2424
ListWebhookEventsRequestOrderBy,
2525
ListWebhooksRequestOrderBy,
26+
OfferName,
2627
WebhookEventStatus,
2728
WebhookEventType,
2829
Blocklist,
@@ -41,11 +42,18 @@
4142
ListBlocklistsResponse,
4243
ListDomainsResponse,
4344
ListEmailsResponse,
45+
ListOfferSubscriptionsResponse,
46+
ListOffersResponse,
47+
ListPoolsResponse,
4448
ListWebhookEventsResponse,
4549
ListWebhooksResponse,
50+
OfferSubscription,
51+
Pool,
52+
ProjectConsumption,
4653
ProjectSettings,
4754
Statistics,
4855
UpdateDomainRequest,
56+
UpdateOfferSubscriptionRequest,
4957
UpdateProjectSettingsRequest,
5058
UpdateProjectSettingsRequestUpdatePeriodicReport,
5159
UpdateWebhookRequest,
@@ -59,22 +67,28 @@
5967
from .marshalling import (
6068
unmarshal_Email,
6169
unmarshal_Domain,
70+
unmarshal_OfferSubscription,
6271
unmarshal_Webhook,
6372
unmarshal_BulkCreateBlocklistsResponse,
6473
unmarshal_CreateEmailResponse,
6574
unmarshal_DomainLastStatus,
6675
unmarshal_ListBlocklistsResponse,
6776
unmarshal_ListDomainsResponse,
6877
unmarshal_ListEmailsResponse,
78+
unmarshal_ListOfferSubscriptionsResponse,
79+
unmarshal_ListOffersResponse,
80+
unmarshal_ListPoolsResponse,
6981
unmarshal_ListWebhookEventsResponse,
7082
unmarshal_ListWebhooksResponse,
83+
unmarshal_ProjectConsumption,
7184
unmarshal_ProjectSettings,
7285
unmarshal_Statistics,
7386
marshal_BulkCreateBlocklistsRequest,
7487
marshal_CreateDomainRequest,
7588
marshal_CreateEmailRequest,
7689
marshal_CreateWebhookRequest,
7790
marshal_UpdateDomainRequest,
91+
marshal_UpdateOfferSubscriptionRequest,
7892
marshal_UpdateProjectSettingsRequest,
7993
marshal_UpdateWebhookRequest,
8094
)
@@ -1469,3 +1483,214 @@ async def delete_blocklist(
14691483
)
14701484

14711485
self._throw_on_error(res)
1486+
1487+
async def list_offer_subscriptions(
1488+
self,
1489+
*,
1490+
region: Optional[ScwRegion] = None,
1491+
project_id: Optional[str] = None,
1492+
) -> ListOfferSubscriptionsResponse:
1493+
"""
1494+
Get information about subscribed offers.
1495+
Retrieve information about the offers you are subscribed to using the `project_id` and `region` parameters.
1496+
:param region: Region to target. If none is passed will use default region from the config.
1497+
:param project_id: ID of the Project.
1498+
:return: :class:`ListOfferSubscriptionsResponse <ListOfferSubscriptionsResponse>`
1499+
1500+
Usage:
1501+
::
1502+
1503+
result = await api.list_offer_subscriptions()
1504+
"""
1505+
1506+
param_region = validate_path_param(
1507+
"region", region or self.client.default_region
1508+
)
1509+
1510+
res = self._request(
1511+
"GET",
1512+
f"/transactional-email/v1alpha1/regions/{param_region}/offer-subscriptions",
1513+
params={
1514+
"project_id": project_id or self.client.default_project_id,
1515+
},
1516+
)
1517+
1518+
self._throw_on_error(res)
1519+
return unmarshal_ListOfferSubscriptionsResponse(res.json())
1520+
1521+
async def update_offer_subscription(
1522+
self,
1523+
*,
1524+
region: Optional[ScwRegion] = None,
1525+
project_id: Optional[str] = None,
1526+
name: Optional[OfferName] = None,
1527+
) -> OfferSubscription:
1528+
"""
1529+
Update a subscribed offer.
1530+
:param region: Region to target. If none is passed will use default region from the config.
1531+
:param project_id: ID of the Project.
1532+
:param name: Name of the offer-subscription.
1533+
:return: :class:`OfferSubscription <OfferSubscription>`
1534+
1535+
Usage:
1536+
::
1537+
1538+
result = await api.update_offer_subscription()
1539+
"""
1540+
1541+
param_region = validate_path_param(
1542+
"region", region or self.client.default_region
1543+
)
1544+
1545+
res = self._request(
1546+
"PATCH",
1547+
f"/transactional-email/v1alpha1/regions/{param_region}/offer-subscriptions",
1548+
body=marshal_UpdateOfferSubscriptionRequest(
1549+
UpdateOfferSubscriptionRequest(
1550+
region=region,
1551+
project_id=project_id,
1552+
name=name,
1553+
),
1554+
self.client,
1555+
),
1556+
)
1557+
1558+
self._throw_on_error(res)
1559+
return unmarshal_OfferSubscription(res.json())
1560+
1561+
async def list_offers(
1562+
self,
1563+
*,
1564+
region: Optional[ScwRegion] = None,
1565+
) -> ListOffersResponse:
1566+
"""
1567+
List the available offers.
1568+
Retrieve the list of the available and free-of-charge offers you can subscribe to.
1569+
:param region: Region to target. If none is passed will use default region from the config.
1570+
:return: :class:`ListOffersResponse <ListOffersResponse>`
1571+
1572+
Usage:
1573+
::
1574+
1575+
result = await api.list_offers()
1576+
"""
1577+
1578+
param_region = validate_path_param(
1579+
"region", region or self.client.default_region
1580+
)
1581+
1582+
res = self._request(
1583+
"GET",
1584+
f"/transactional-email/v1alpha1/regions/{param_region}/offers",
1585+
)
1586+
1587+
self._throw_on_error(res)
1588+
return unmarshal_ListOffersResponse(res.json())
1589+
1590+
async def list_pools(
1591+
self,
1592+
*,
1593+
region: Optional[ScwRegion] = None,
1594+
page: Optional[int] = None,
1595+
page_size: Optional[int] = None,
1596+
project_id: Optional[str] = None,
1597+
) -> ListPoolsResponse:
1598+
"""
1599+
Get information about a sending pool.
1600+
Retrieve information about a sending pool, including its creation status and configuration parameters.
1601+
:param region: Region to target. If none is passed will use default region from the config.
1602+
:param page: Requested page number. Value must be greater or equal to 1.
1603+
:param page_size: Requested page size. Value must be between 1 and 1000.
1604+
:param project_id: ID of the Project.
1605+
:return: :class:`ListPoolsResponse <ListPoolsResponse>`
1606+
1607+
Usage:
1608+
::
1609+
1610+
result = await api.list_pools()
1611+
"""
1612+
1613+
param_region = validate_path_param(
1614+
"region", region or self.client.default_region
1615+
)
1616+
1617+
res = self._request(
1618+
"GET",
1619+
f"/transactional-email/v1alpha1/regions/{param_region}/pools",
1620+
params={
1621+
"page": page,
1622+
"page_size": page_size or self.client.default_page_size,
1623+
"project_id": project_id or self.client.default_project_id,
1624+
},
1625+
)
1626+
1627+
self._throw_on_error(res)
1628+
return unmarshal_ListPoolsResponse(res.json())
1629+
1630+
async def list_pools_all(
1631+
self,
1632+
*,
1633+
region: Optional[ScwRegion] = None,
1634+
page: Optional[int] = None,
1635+
page_size: Optional[int] = None,
1636+
project_id: Optional[str] = None,
1637+
) -> List[Pool]:
1638+
"""
1639+
Get information about a sending pool.
1640+
Retrieve information about a sending pool, including its creation status and configuration parameters.
1641+
:param region: Region to target. If none is passed will use default region from the config.
1642+
:param page: Requested page number. Value must be greater or equal to 1.
1643+
:param page_size: Requested page size. Value must be between 1 and 1000.
1644+
:param project_id: ID of the Project.
1645+
:return: :class:`List[Pool] <List[Pool]>`
1646+
1647+
Usage:
1648+
::
1649+
1650+
result = await api.list_pools_all()
1651+
"""
1652+
1653+
return await fetch_all_pages_async(
1654+
type=ListPoolsResponse,
1655+
key="pools",
1656+
fetcher=self.list_pools,
1657+
args={
1658+
"region": region,
1659+
"page": page,
1660+
"page_size": page_size,
1661+
"project_id": project_id,
1662+
},
1663+
)
1664+
1665+
async def get_project_consumption(
1666+
self,
1667+
*,
1668+
region: Optional[ScwRegion] = None,
1669+
project_id: Optional[str] = None,
1670+
) -> ProjectConsumption:
1671+
"""
1672+
Get project resource consumption.
1673+
:param region: Region to target. If none is passed will use default region from the config.
1674+
:param project_id: ID of the project.
1675+
:return: :class:`ProjectConsumption <ProjectConsumption>`
1676+
1677+
Usage:
1678+
::
1679+
1680+
result = await api.get_project_consumption()
1681+
"""
1682+
1683+
param_region = validate_path_param(
1684+
"region", region or self.client.default_region
1685+
)
1686+
1687+
res = self._request(
1688+
"GET",
1689+
f"/transactional-email/v1alpha1/regions/{param_region}/project-consumption",
1690+
params={
1691+
"project_id": project_id or self.client.default_project_id,
1692+
},
1693+
)
1694+
1695+
self._throw_on_error(res)
1696+
return unmarshal_ProjectConsumption(res.json())

0 commit comments

Comments
 (0)