Skip to content

Commit 6d48f6e

Browse files
authored
feat(webhosting): replace domain conf options (#906)
1 parent badb5c7 commit 6d48f6e

File tree

8 files changed

+274
-54
lines changed

8 files changed

+274
-54
lines changed

scaleway-async/scaleway_async/webhosting/v1/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from .types import OfferOption
2929
from .types import PlatformControlPanel
3030
from .types import CreateDatabaseRequestUser
31+
from .types import AutoConfigDomainDns
3132
from .types import CreateHostingRequestDomainConfiguration
3233
from .types import OfferOptionRequest
3334
from .types import SyncDomainDnsRecordsRequestRecord
@@ -133,6 +134,7 @@
133134
"OfferOption",
134135
"PlatformControlPanel",
135136
"CreateDatabaseRequestUser",
137+
"AutoConfigDomainDns",
136138
"CreateHostingRequestDomainConfiguration",
137139
"OfferOptionRequest",
138140
"SyncDomainDnsRecordsRequestRecord",

scaleway-async/scaleway_async/webhosting/v1/api.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
ListMailAccountsRequestOrderBy,
2323
ListOffersRequestOrderBy,
2424
ListWebsitesRequestOrderBy,
25+
AutoConfigDomainDns,
2526
CheckUserOwnsDomainResponse,
2627
ControlPanel,
2728
CreateDatabaseRequestUser,
@@ -836,33 +837,31 @@ async def sync_domain_dns_records(
836837
self,
837838
*,
838839
domain: str,
839-
update_web_records: bool,
840-
update_mail_records: bool,
841-
update_all_records: bool,
842-
update_nameservers: bool,
843840
region: Optional[ScwRegion] = None,
841+
update_web_records: Optional[bool] = None,
842+
update_mail_records: Optional[bool] = None,
843+
update_all_records: Optional[bool] = None,
844+
update_nameservers: Optional[bool] = None,
844845
custom_records: Optional[List[SyncDomainDnsRecordsRequestRecord]] = None,
846+
auto_config_domain_dns: Optional[AutoConfigDomainDns] = None,
845847
) -> DnsRecords:
846848
"""
847849
Synchronize your DNS records on the Elements Console and on cPanel.
848850
:param domain: Domain for which the DNS records will be synchronized.
849-
:param update_web_records: Whether or not to synchronize the web records.
850-
:param update_mail_records: Whether or not to synchronize the mail records.
851-
:param update_all_records: Whether or not to synchronize all types of records. This one has priority.
852-
:param update_nameservers: Whether or not to synchronize domain nameservers.
853851
:param region: Region to target. If none is passed will use default region from the config.
852+
:param update_web_records: Whether or not to synchronize the web records (deprecated, use auto_config_domain_dns).
853+
:param update_mail_records: Whether or not to synchronize the mail records (deprecated, use auto_config_domain_dns).
854+
:param update_all_records: Whether or not to synchronize all types of records. This one has priority (deprecated, use auto_config_domain_dns).
855+
:param update_nameservers: Whether or not to synchronize domain nameservers (deprecated, use auto_config_domain_dns).
854856
:param custom_records: Custom records to synchronize.
857+
:param auto_config_domain_dns: Whether or not to synchronize each types of records.
855858
:return: :class:`DnsRecords <DnsRecords>`
856859
857860
Usage:
858861
::
859862
860863
result = await api.sync_domain_dns_records(
861864
domain="example",
862-
update_web_records=False,
863-
update_mail_records=False,
864-
update_all_records=False,
865-
update_nameservers=False,
866865
)
867866
"""
868867

@@ -877,12 +876,13 @@ async def sync_domain_dns_records(
877876
body=marshal_DnsApiSyncDomainDnsRecordsRequest(
878877
DnsApiSyncDomainDnsRecordsRequest(
879878
domain=domain,
879+
region=region,
880880
update_web_records=update_web_records,
881881
update_mail_records=update_mail_records,
882882
update_all_records=update_all_records,
883883
update_nameservers=update_nameservers,
884-
region=region,
885884
custom_records=custom_records,
885+
auto_config_domain_dns=auto_config_domain_dns,
886886
),
887887
self.client,
888888
),
@@ -1116,6 +1116,7 @@ async def create_hosting(
11161116
language: Optional[StdLanguageCode] = None,
11171117
domain_configuration: Optional[CreateHostingRequestDomainConfiguration] = None,
11181118
skip_welcome_email: Optional[bool] = None,
1119+
auto_config_domain_dns: Optional[AutoConfigDomainDns] = None,
11191120
) -> Hosting:
11201121
"""
11211122
Order a Web Hosting plan.
@@ -1128,8 +1129,9 @@ async def create_hosting(
11281129
:param tags: List of tags for the Web Hosting plan.
11291130
:param offer_options: List of the Web Hosting plan options IDs with their quantities.
11301131
:param language: Default language for the control panel interface.
1131-
:param domain_configuration: Indicates whether to update hosting domain name servers and DNS records for domains managed by Scaleway Elements.
1132+
:param domain_configuration: Indicates whether to update hosting domain name servers and DNS records for domains managed by Scaleway Elements (deprecated, use auto_config_domain_dns instead).
11321133
:param skip_welcome_email: Indicates whether to skip a welcome email to the contact email containing hosting info.
1134+
:param auto_config_domain_dns: Indicates whether to update hosting domain name servers and DNS records for domains managed by Scaleway Elements (deprecated, use auto_update_* fields instead).
11331135
:return: :class:`Hosting <Hosting>`
11341136
11351137
Usage:
@@ -1161,6 +1163,7 @@ async def create_hosting(
11611163
language=language,
11621164
domain_configuration=domain_configuration,
11631165
skip_welcome_email=skip_welcome_email,
1166+
auto_config_domain_dns=auto_config_domain_dns,
11641167
),
11651168
self.client,
11661169
),

scaleway-async/scaleway_async/webhosting/v1/marshalling.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
DnsRecord,
2525
Nameserver,
2626
DnsRecords,
27+
AutoConfigDomainDns,
2728
Domain,
2829
PlatformControlPanelUrls,
2930
OfferOption,
@@ -260,6 +261,33 @@ def unmarshal_DnsRecords(data: Any) -> DnsRecords:
260261
return DnsRecords(**args)
261262

262263

264+
def unmarshal_AutoConfigDomainDns(data: Any) -> AutoConfigDomainDns:
265+
if not isinstance(data, dict):
266+
raise TypeError(
267+
"Unmarshalling the type 'AutoConfigDomainDns' failed as data isn't a dictionary."
268+
)
269+
270+
args: Dict[str, Any] = {}
271+
272+
field = data.get("nameservers", None)
273+
if field is not None:
274+
args["nameservers"] = field
275+
276+
field = data.get("web_records", None)
277+
if field is not None:
278+
args["web_records"] = field
279+
280+
field = data.get("mail_records", None)
281+
if field is not None:
282+
args["mail_records"] = field
283+
284+
field = data.get("all_records", None)
285+
if field is not None:
286+
args["all_records"] = field
287+
288+
return AutoConfigDomainDns(**args)
289+
290+
263291
def unmarshal_Domain(data: Any) -> Domain:
264292
if not isinstance(data, dict):
265293
raise TypeError(
@@ -291,6 +319,14 @@ def unmarshal_Domain(data: Any) -> Domain:
291319
args["available_dns_actions"] = (
292320
[DomainDnsAction(v) for v in field] if field is not None else None
293321
)
322+
else:
323+
args["available_dns_actions"] = None
324+
325+
field = data.get("auto_config_domain_dns", None)
326+
if field is not None:
327+
args["auto_config_domain_dns"] = unmarshal_AutoConfigDomainDns(field)
328+
else:
329+
args["auto_config_domain_dns"] = None
294330

295331
return Domain(**args)
296332

@@ -1070,6 +1106,27 @@ def marshal_DnsApiCheckUserOwnsDomainRequest(
10701106
return output
10711107

10721108

1109+
def marshal_AutoConfigDomainDns(
1110+
request: AutoConfigDomainDns,
1111+
defaults: ProfileDefaults,
1112+
) -> Dict[str, Any]:
1113+
output: Dict[str, Any] = {}
1114+
1115+
if request.nameservers is not None:
1116+
output["nameservers"] = request.nameservers
1117+
1118+
if request.web_records is not None:
1119+
output["web_records"] = request.web_records
1120+
1121+
if request.mail_records is not None:
1122+
output["mail_records"] = request.mail_records
1123+
1124+
if request.all_records is not None:
1125+
output["all_records"] = request.all_records
1126+
1127+
return output
1128+
1129+
10731130
def marshal_SyncDomainDnsRecordsRequestRecord(
10741131
request: SyncDomainDnsRecordsRequestRecord,
10751132
defaults: ProfileDefaults,
@@ -1109,6 +1166,11 @@ def marshal_DnsApiSyncDomainDnsRecordsRequest(
11091166
for item in request.custom_records
11101167
]
11111168

1169+
if request.auto_config_domain_dns is not None:
1170+
output["auto_config_domain_dns"] = marshal_AutoConfigDomainDns(
1171+
request.auto_config_domain_dns, defaults
1172+
)
1173+
11121174
return output
11131175

11141176

@@ -1217,6 +1279,11 @@ def marshal_HostingApiCreateHostingRequest(
12171279
if request.skip_welcome_email is not None:
12181280
output["skip_welcome_email"] = request.skip_welcome_email
12191281

1282+
if request.auto_config_domain_dns is not None:
1283+
output["auto_config_domain_dns"] = marshal_AutoConfigDomainDns(
1284+
request.auto_config_domain_dns, defaults
1285+
)
1286+
12201287
return output
12211288

12221289

scaleway-async/scaleway_async/webhosting/v1/types.py

Lines changed: 51 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,29 @@ class CreateDatabaseRequestUser:
307307
password: str
308308

309309

310+
@dataclass
311+
class AutoConfigDomainDns:
312+
nameservers: bool
313+
"""
314+
Whether or not to synchronize domain nameservers.
315+
"""
316+
317+
web_records: bool
318+
"""
319+
Whether or not to synchronize web records.
320+
"""
321+
322+
mail_records: bool
323+
"""
324+
Whether or not to synchronize mail records.
325+
"""
326+
327+
all_records: bool
328+
"""
329+
Whether or not to synchronize all types of records. Takes priority over the other fields.
330+
"""
331+
332+
310333
@dataclass
311334
class CreateHostingRequestDomainConfiguration:
312335
update_nameservers: bool
@@ -1019,36 +1042,41 @@ class DnsApiSyncDomainDnsRecordsRequest:
10191042
Domain for which the DNS records will be synchronized.
10201043
"""
10211044

1022-
update_web_records: bool
1045+
region: Optional[ScwRegion]
10231046
"""
1024-
Whether or not to synchronize the web records.
1047+
Region to target. If none is passed will use default region from the config.
10251048
"""
10261049

1027-
update_mail_records: bool
1050+
update_web_records: Optional[bool]
10281051
"""
1029-
Whether or not to synchronize the mail records.
1052+
Whether or not to synchronize the web records (deprecated, use auto_config_domain_dns).
10301053
"""
10311054

1032-
update_all_records: bool
1055+
update_mail_records: Optional[bool]
10331056
"""
1034-
Whether or not to synchronize all types of records. This one has priority.
1057+
Whether or not to synchronize the mail records (deprecated, use auto_config_domain_dns).
10351058
"""
10361059

1037-
update_nameservers: bool
1060+
update_all_records: Optional[bool]
10381061
"""
1039-
Whether or not to synchronize domain nameservers.
1062+
Whether or not to synchronize all types of records. This one has priority (deprecated, use auto_config_domain_dns).
10401063
"""
10411064

1042-
region: Optional[ScwRegion]
1065+
update_nameservers: Optional[bool]
10431066
"""
1044-
Region to target. If none is passed will use default region from the config.
1067+
Whether or not to synchronize domain nameservers (deprecated, use auto_config_domain_dns).
10451068
"""
10461069

10471070
custom_records: Optional[List[SyncDomainDnsRecordsRequestRecord]]
10481071
"""
10491072
Custom records to synchronize.
10501073
"""
10511074

1075+
auto_config_domain_dns: Optional[AutoConfigDomainDns]
1076+
"""
1077+
Whether or not to synchronize each types of records.
1078+
"""
1079+
10521080

10531081
@dataclass
10541082
class DnsRecords:
@@ -1095,9 +1123,14 @@ class Domain:
10951123
A list of actions that can be performed on the domain.
10961124
"""
10971125

1098-
available_dns_actions: List[DomainDnsAction]
1126+
available_dns_actions: Optional[List[DomainDnsAction]]
1127+
"""
1128+
A list of DNS-related actions that can be auto configured for the domain (deprecated, use auto_config_domain_dns instead).
1129+
"""
1130+
1131+
auto_config_domain_dns: Optional[AutoConfigDomainDns]
10991132
"""
1100-
A list of DNS-related actions that can be auto configured for the domain.
1133+
Whether or not to synchronize each type of record.
11011134
"""
11021135

11031136

@@ -1325,14 +1358,19 @@ class HostingApiCreateHostingRequest:
13251358

13261359
domain_configuration: Optional[CreateHostingRequestDomainConfiguration]
13271360
"""
1328-
Indicates whether to update hosting domain name servers and DNS records for domains managed by Scaleway Elements.
1361+
Indicates whether to update hosting domain name servers and DNS records for domains managed by Scaleway Elements (deprecated, use auto_config_domain_dns instead).
13291362
"""
13301363

13311364
skip_welcome_email: Optional[bool]
13321365
"""
13331366
Indicates whether to skip a welcome email to the contact email containing hosting info.
13341367
"""
13351368

1369+
auto_config_domain_dns: Optional[AutoConfigDomainDns]
1370+
"""
1371+
Indicates whether to update hosting domain name servers and DNS records for domains managed by Scaleway Elements (deprecated, use auto_update_* fields instead).
1372+
"""
1373+
13361374

13371375
@dataclass
13381376
class HostingApiCreateSessionRequest:

scaleway/scaleway/webhosting/v1/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from .types import OfferOption
2929
from .types import PlatformControlPanel
3030
from .types import CreateDatabaseRequestUser
31+
from .types import AutoConfigDomainDns
3132
from .types import CreateHostingRequestDomainConfiguration
3233
from .types import OfferOptionRequest
3334
from .types import SyncDomainDnsRecordsRequestRecord
@@ -133,6 +134,7 @@
133134
"OfferOption",
134135
"PlatformControlPanel",
135136
"CreateDatabaseRequestUser",
137+
"AutoConfigDomainDns",
136138
"CreateHostingRequestDomainConfiguration",
137139
"OfferOptionRequest",
138140
"SyncDomainDnsRecordsRequestRecord",

0 commit comments

Comments
 (0)