Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat(webhosting): replace domain conf options #906

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions scaleway-async/scaleway_async/webhosting/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from .types import OfferOption
from .types import PlatformControlPanel
from .types import CreateDatabaseRequestUser
from .types import AutoConfigDomainDns
from .types import CreateHostingRequestDomainConfiguration
from .types import OfferOptionRequest
from .types import SyncDomainDnsRecordsRequestRecord
Expand Down Expand Up @@ -133,6 +134,7 @@
"OfferOption",
"PlatformControlPanel",
"CreateDatabaseRequestUser",
"AutoConfigDomainDns",
"CreateHostingRequestDomainConfiguration",
"OfferOptionRequest",
"SyncDomainDnsRecordsRequestRecord",
Expand Down
31 changes: 17 additions & 14 deletions scaleway-async/scaleway_async/webhosting/v1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
ListMailAccountsRequestOrderBy,
ListOffersRequestOrderBy,
ListWebsitesRequestOrderBy,
AutoConfigDomainDns,
CheckUserOwnsDomainResponse,
ControlPanel,
CreateDatabaseRequestUser,
Expand Down Expand Up @@ -836,33 +837,31 @@ async def sync_domain_dns_records(
self,
*,
domain: str,
update_web_records: bool,
update_mail_records: bool,
update_all_records: bool,
update_nameservers: bool,
region: Optional[ScwRegion] = None,
update_web_records: Optional[bool] = None,
update_mail_records: Optional[bool] = None,
update_all_records: Optional[bool] = None,
update_nameservers: Optional[bool] = None,
custom_records: Optional[List[SyncDomainDnsRecordsRequestRecord]] = None,
auto_config_domain_dns: Optional[AutoConfigDomainDns] = None,
) -> DnsRecords:
"""
Synchronize your DNS records on the Elements Console and on cPanel.
:param domain: Domain for which the DNS records will be synchronized.
:param update_web_records: Whether or not to synchronize the web records.
:param update_mail_records: Whether or not to synchronize the mail records.
:param update_all_records: Whether or not to synchronize all types of records. This one has priority.
:param update_nameservers: Whether or not to synchronize domain nameservers.
:param region: Region to target. If none is passed will use default region from the config.
:param update_web_records: Whether or not to synchronize the web records (deprecated, use auto_config_domain_dns).
:param update_mail_records: Whether or not to synchronize the mail records (deprecated, use auto_config_domain_dns).
:param update_all_records: Whether or not to synchronize all types of records. This one has priority (deprecated, use auto_config_domain_dns).
:param update_nameservers: Whether or not to synchronize domain nameservers (deprecated, use auto_config_domain_dns).
:param custom_records: Custom records to synchronize.
:param auto_config_domain_dns: Whether or not to synchronize each types of records.
:return: :class:`DnsRecords <DnsRecords>`

Usage:
::

result = await api.sync_domain_dns_records(
domain="example",
update_web_records=False,
update_mail_records=False,
update_all_records=False,
update_nameservers=False,
)
"""

Expand All @@ -877,12 +876,13 @@ async def sync_domain_dns_records(
body=marshal_DnsApiSyncDomainDnsRecordsRequest(
DnsApiSyncDomainDnsRecordsRequest(
domain=domain,
region=region,
update_web_records=update_web_records,
update_mail_records=update_mail_records,
update_all_records=update_all_records,
update_nameservers=update_nameservers,
region=region,
custom_records=custom_records,
auto_config_domain_dns=auto_config_domain_dns,
),
self.client,
),
Expand Down Expand Up @@ -1116,6 +1116,7 @@ async def create_hosting(
language: Optional[StdLanguageCode] = None,
domain_configuration: Optional[CreateHostingRequestDomainConfiguration] = None,
skip_welcome_email: Optional[bool] = None,
auto_config_domain_dns: Optional[AutoConfigDomainDns] = None,
) -> Hosting:
"""
Order a Web Hosting plan.
Expand All @@ -1128,8 +1129,9 @@ async def create_hosting(
:param tags: List of tags for the Web Hosting plan.
:param offer_options: List of the Web Hosting plan options IDs with their quantities.
:param language: Default language for the control panel interface.
:param domain_configuration: Indicates whether to update hosting domain name servers and DNS records for domains managed by Scaleway Elements.
: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).
:param skip_welcome_email: Indicates whether to skip a welcome email to the contact email containing hosting info.
: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).
:return: :class:`Hosting <Hosting>`

Usage:
Expand Down Expand Up @@ -1161,6 +1163,7 @@ async def create_hosting(
language=language,
domain_configuration=domain_configuration,
skip_welcome_email=skip_welcome_email,
auto_config_domain_dns=auto_config_domain_dns,
),
self.client,
),
Expand Down
67 changes: 67 additions & 0 deletions scaleway-async/scaleway_async/webhosting/v1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
DnsRecord,
Nameserver,
DnsRecords,
AutoConfigDomainDns,
Domain,
PlatformControlPanelUrls,
OfferOption,
Expand Down Expand Up @@ -260,6 +261,33 @@ def unmarshal_DnsRecords(data: Any) -> DnsRecords:
return DnsRecords(**args)


def unmarshal_AutoConfigDomainDns(data: Any) -> AutoConfigDomainDns:
if not isinstance(data, dict):
raise TypeError(
"Unmarshalling the type 'AutoConfigDomainDns' failed as data isn't a dictionary."
)

args: Dict[str, Any] = {}

field = data.get("nameservers", None)
if field is not None:
args["nameservers"] = field

field = data.get("web_records", None)
if field is not None:
args["web_records"] = field

field = data.get("mail_records", None)
if field is not None:
args["mail_records"] = field

field = data.get("all_records", None)
if field is not None:
args["all_records"] = field

return AutoConfigDomainDns(**args)


def unmarshal_Domain(data: Any) -> Domain:
if not isinstance(data, dict):
raise TypeError(
Expand Down Expand Up @@ -291,6 +319,14 @@ def unmarshal_Domain(data: Any) -> Domain:
args["available_dns_actions"] = (
[DomainDnsAction(v) for v in field] if field is not None else None
)
else:
args["available_dns_actions"] = None

field = data.get("auto_config_domain_dns", None)
if field is not None:
args["auto_config_domain_dns"] = unmarshal_AutoConfigDomainDns(field)
else:
args["auto_config_domain_dns"] = None

return Domain(**args)

Expand Down Expand Up @@ -1070,6 +1106,27 @@ def marshal_DnsApiCheckUserOwnsDomainRequest(
return output


def marshal_AutoConfigDomainDns(
request: AutoConfigDomainDns,
defaults: ProfileDefaults,
) -> Dict[str, Any]:
output: Dict[str, Any] = {}

if request.nameservers is not None:
output["nameservers"] = request.nameservers

if request.web_records is not None:
output["web_records"] = request.web_records

if request.mail_records is not None:
output["mail_records"] = request.mail_records

if request.all_records is not None:
output["all_records"] = request.all_records

return output


def marshal_SyncDomainDnsRecordsRequestRecord(
request: SyncDomainDnsRecordsRequestRecord,
defaults: ProfileDefaults,
Expand Down Expand Up @@ -1109,6 +1166,11 @@ def marshal_DnsApiSyncDomainDnsRecordsRequest(
for item in request.custom_records
]

if request.auto_config_domain_dns is not None:
output["auto_config_domain_dns"] = marshal_AutoConfigDomainDns(
request.auto_config_domain_dns, defaults
)

return output


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

if request.auto_config_domain_dns is not None:
output["auto_config_domain_dns"] = marshal_AutoConfigDomainDns(
request.auto_config_domain_dns, defaults
)

return output


Expand Down
64 changes: 51 additions & 13 deletions scaleway-async/scaleway_async/webhosting/v1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,29 @@ class CreateDatabaseRequestUser:
password: str


@dataclass
class AutoConfigDomainDns:
nameservers: bool
"""
Whether or not to synchronize domain nameservers.
"""

web_records: bool
"""
Whether or not to synchronize web records.
"""

mail_records: bool
"""
Whether or not to synchronize mail records.
"""

all_records: bool
"""
Whether or not to synchronize all types of records. Takes priority over the other fields.
"""


@dataclass
class CreateHostingRequestDomainConfiguration:
update_nameservers: bool
Expand Down Expand Up @@ -1019,36 +1042,41 @@ class DnsApiSyncDomainDnsRecordsRequest:
Domain for which the DNS records will be synchronized.
"""

update_web_records: bool
region: Optional[ScwRegion]
"""
Whether or not to synchronize the web records.
Region to target. If none is passed will use default region from the config.
"""

update_mail_records: bool
update_web_records: Optional[bool]
"""
Whether or not to synchronize the mail records.
Whether or not to synchronize the web records (deprecated, use auto_config_domain_dns).
"""

update_all_records: bool
update_mail_records: Optional[bool]
"""
Whether or not to synchronize all types of records. This one has priority.
Whether or not to synchronize the mail records (deprecated, use auto_config_domain_dns).
"""

update_nameservers: bool
update_all_records: Optional[bool]
"""
Whether or not to synchronize domain nameservers.
Whether or not to synchronize all types of records. This one has priority (deprecated, use auto_config_domain_dns).
"""

region: Optional[ScwRegion]
update_nameservers: Optional[bool]
"""
Region to target. If none is passed will use default region from the config.
Whether or not to synchronize domain nameservers (deprecated, use auto_config_domain_dns).
"""

custom_records: Optional[List[SyncDomainDnsRecordsRequestRecord]]
"""
Custom records to synchronize.
"""

auto_config_domain_dns: Optional[AutoConfigDomainDns]
"""
Whether or not to synchronize each types of records.
"""


@dataclass
class DnsRecords:
Expand Down Expand Up @@ -1095,9 +1123,14 @@ class Domain:
A list of actions that can be performed on the domain.
"""

available_dns_actions: List[DomainDnsAction]
available_dns_actions: Optional[List[DomainDnsAction]]
"""
A list of DNS-related actions that can be auto configured for the domain (deprecated, use auto_config_domain_dns instead).
"""

auto_config_domain_dns: Optional[AutoConfigDomainDns]
"""
A list of DNS-related actions that can be auto configured for the domain.
Whether or not to synchronize each type of record.
"""


Expand Down Expand Up @@ -1325,14 +1358,19 @@ class HostingApiCreateHostingRequest:

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

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

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


@dataclass
class HostingApiCreateSessionRequest:
Expand Down
2 changes: 2 additions & 0 deletions scaleway/scaleway/webhosting/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from .types import OfferOption
from .types import PlatformControlPanel
from .types import CreateDatabaseRequestUser
from .types import AutoConfigDomainDns
from .types import CreateHostingRequestDomainConfiguration
from .types import OfferOptionRequest
from .types import SyncDomainDnsRecordsRequestRecord
Expand Down Expand Up @@ -133,6 +134,7 @@
"OfferOption",
"PlatformControlPanel",
"CreateDatabaseRequestUser",
"AutoConfigDomainDns",
"CreateHostingRequestDomainConfiguration",
"OfferOptionRequest",
"SyncDomainDnsRecordsRequestRecord",
Expand Down
Loading