Skip to content

Commit 2d9f54f

Browse files
fix(webhosting): add dns autoconfig none option (scaleway#924)
Co-authored-by: Laure-di <[email protected]>
1 parent 1cdf86a commit 2d9f54f

File tree

4 files changed

+108
-58
lines changed

4 files changed

+108
-58
lines changed

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

Lines changed: 42 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
FtpAccount,
2222
MailAccount,
2323
CheckUserOwnsDomainResponse,
24+
AutoConfigDomainDns,
2425
DnsRecord,
2526
Nameserver,
2627
DnsRecords,
27-
AutoConfigDomainDns,
2828
Domain,
2929
PlatformControlPanelUrls,
3030
OfferOption,
@@ -164,6 +164,37 @@ def unmarshal_CheckUserOwnsDomainResponse(data: Any) -> CheckUserOwnsDomainRespo
164164
return CheckUserOwnsDomainResponse(**args)
165165

166166

167+
def unmarshal_AutoConfigDomainDns(data: Any) -> AutoConfigDomainDns:
168+
if not isinstance(data, dict):
169+
raise TypeError(
170+
"Unmarshalling the type 'AutoConfigDomainDns' failed as data isn't a dictionary."
171+
)
172+
173+
args: Dict[str, Any] = {}
174+
175+
field = data.get("nameservers", None)
176+
if field is not None:
177+
args["nameservers"] = field
178+
179+
field = data.get("web_records", None)
180+
if field is not None:
181+
args["web_records"] = field
182+
183+
field = data.get("mail_records", None)
184+
if field is not None:
185+
args["mail_records"] = field
186+
187+
field = data.get("all_records", None)
188+
if field is not None:
189+
args["all_records"] = field
190+
191+
field = data.get("none", None)
192+
if field is not None:
193+
args["none"] = field
194+
195+
return AutoConfigDomainDns(**args)
196+
197+
167198
def unmarshal_DnsRecord(data: Any) -> DnsRecord:
168199
if not isinstance(data, dict):
169200
raise TypeError(
@@ -257,35 +288,16 @@ def unmarshal_DnsRecords(data: Any) -> DnsRecords:
257288
args["dns_config"] = (
258289
[DomainDnsAction(v) for v in field] if field is not None else None
259290
)
291+
else:
292+
args["dns_config"] = None
260293

261-
return DnsRecords(**args)
262-
263-
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)
294+
field = data.get("auto_config_domain_dns", None)
285295
if field is not None:
286-
args["all_records"] = field
296+
args["auto_config_domain_dns"] = unmarshal_AutoConfigDomainDns(field)
297+
else:
298+
args["auto_config_domain_dns"] = None
287299

288-
return AutoConfigDomainDns(**args)
300+
return DnsRecords(**args)
289301

290302

291303
def unmarshal_Domain(data: Any) -> Domain:
@@ -1124,6 +1136,9 @@ def marshal_AutoConfigDomainDns(
11241136
if request.all_records is not None:
11251137
output["all_records"] = request.all_records
11261138

1139+
if request.none is not None:
1140+
output["none"] = request.none
1141+
11271142
return output
11281143

11291144

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,11 @@ class AutoConfigDomainDns:
329329
Whether or not to synchronize all types of records. Takes priority over the other fields.
330330
"""
331331

332+
none: bool
333+
"""
334+
No automatic domain configuration. Users must configure their domain for the Web Hosting to work.
335+
"""
336+
332337

333338
@dataclass
334339
class CreateHostingRequestDomainConfiguration:
@@ -1095,9 +1100,14 @@ class DnsRecords:
10951100
Status of the records.
10961101
"""
10971102

1098-
dns_config: List[DomainDnsAction]
1103+
dns_config: Optional[List[DomainDnsAction]]
1104+
"""
1105+
Records dns auto configuration settings (deprecated, use auto_config_domain_dns).
1106+
"""
1107+
1108+
auto_config_domain_dns: Optional[AutoConfigDomainDns]
10991109
"""
1100-
Records dns auto configuration settings.
1110+
Whether or not to synchronize each types of records.
11011111
"""
11021112

11031113

scaleway/scaleway/webhosting/v1/marshalling.py

Lines changed: 42 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
FtpAccount,
2222
MailAccount,
2323
CheckUserOwnsDomainResponse,
24+
AutoConfigDomainDns,
2425
DnsRecord,
2526
Nameserver,
2627
DnsRecords,
27-
AutoConfigDomainDns,
2828
Domain,
2929
PlatformControlPanelUrls,
3030
OfferOption,
@@ -164,6 +164,37 @@ def unmarshal_CheckUserOwnsDomainResponse(data: Any) -> CheckUserOwnsDomainRespo
164164
return CheckUserOwnsDomainResponse(**args)
165165

166166

167+
def unmarshal_AutoConfigDomainDns(data: Any) -> AutoConfigDomainDns:
168+
if not isinstance(data, dict):
169+
raise TypeError(
170+
"Unmarshalling the type 'AutoConfigDomainDns' failed as data isn't a dictionary."
171+
)
172+
173+
args: Dict[str, Any] = {}
174+
175+
field = data.get("nameservers", None)
176+
if field is not None:
177+
args["nameservers"] = field
178+
179+
field = data.get("web_records", None)
180+
if field is not None:
181+
args["web_records"] = field
182+
183+
field = data.get("mail_records", None)
184+
if field is not None:
185+
args["mail_records"] = field
186+
187+
field = data.get("all_records", None)
188+
if field is not None:
189+
args["all_records"] = field
190+
191+
field = data.get("none", None)
192+
if field is not None:
193+
args["none"] = field
194+
195+
return AutoConfigDomainDns(**args)
196+
197+
167198
def unmarshal_DnsRecord(data: Any) -> DnsRecord:
168199
if not isinstance(data, dict):
169200
raise TypeError(
@@ -257,35 +288,16 @@ def unmarshal_DnsRecords(data: Any) -> DnsRecords:
257288
args["dns_config"] = (
258289
[DomainDnsAction(v) for v in field] if field is not None else None
259290
)
291+
else:
292+
args["dns_config"] = None
260293

261-
return DnsRecords(**args)
262-
263-
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)
294+
field = data.get("auto_config_domain_dns", None)
285295
if field is not None:
286-
args["all_records"] = field
296+
args["auto_config_domain_dns"] = unmarshal_AutoConfigDomainDns(field)
297+
else:
298+
args["auto_config_domain_dns"] = None
287299

288-
return AutoConfigDomainDns(**args)
300+
return DnsRecords(**args)
289301

290302

291303
def unmarshal_Domain(data: Any) -> Domain:
@@ -1124,6 +1136,9 @@ def marshal_AutoConfigDomainDns(
11241136
if request.all_records is not None:
11251137
output["all_records"] = request.all_records
11261138

1139+
if request.none is not None:
1140+
output["none"] = request.none
1141+
11271142
return output
11281143

11291144

scaleway/scaleway/webhosting/v1/types.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,11 @@ class AutoConfigDomainDns:
329329
Whether or not to synchronize all types of records. Takes priority over the other fields.
330330
"""
331331

332+
none: bool
333+
"""
334+
No automatic domain configuration. Users must configure their domain for the Web Hosting to work.
335+
"""
336+
332337

333338
@dataclass
334339
class CreateHostingRequestDomainConfiguration:
@@ -1095,9 +1100,14 @@ class DnsRecords:
10951100
Status of the records.
10961101
"""
10971102

1098-
dns_config: List[DomainDnsAction]
1103+
dns_config: Optional[List[DomainDnsAction]]
1104+
"""
1105+
Records dns auto configuration settings (deprecated, use auto_config_domain_dns).
1106+
"""
1107+
1108+
auto_config_domain_dns: Optional[AutoConfigDomainDns]
10991109
"""
1100-
Records dns auto configuration settings.
1110+
Whether or not to synchronize each types of records.
11011111
"""
11021112

11031113

0 commit comments

Comments
 (0)