diff --git a/scaleway-async/scaleway_async/webhosting/v1/__init__.py b/scaleway-async/scaleway_async/webhosting/v1/__init__.py index 820010080..6da8dd39a 100644 --- a/scaleway-async/scaleway_async/webhosting/v1/__init__.py +++ b/scaleway-async/scaleway_async/webhosting/v1/__init__.py @@ -1,5 +1,7 @@ # 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 DnsRecordStatus +from .types import DnsRecordType from .types import DnsRecordsStatus from .types import HostingStatus from .content import HOSTING_TRANSIENT_STATUSES @@ -12,6 +14,7 @@ from .types import ListMailAccountsRequestOrderBy from .types import ListOffersRequestOrderBy from .types import ListWebsitesRequestOrderBy +from .types import NameserverStatus from .types import OfferOptionName from .types import OfferOptionWarning from .types import PlatformPlatformGroup @@ -20,6 +23,8 @@ from .types import PlatformControlPanel from .types import CreateHostingRequestDomainConfiguration from .types import OfferOptionRequest +from .types import DnsRecord +from .types import Nameserver from .types import HostingUser from .types import Offer from .types import Platform @@ -30,6 +35,7 @@ from .types import HostingSummary from .types import MailAccount from .types import Website +from .types import CheckUserOwnsDomainResponse from .types import ControlPanelApiListControlPanelsRequest from .types import DatabaseApiAssignDatabaseUserRequest from .types import DatabaseApiChangeDatabaseUserPasswordRequest @@ -42,6 +48,9 @@ from .types import DatabaseApiListDatabaseUsersRequest from .types import DatabaseApiListDatabasesRequest from .types import DatabaseApiUnassignDatabaseUserRequest +from .types import DnsApiCheckUserOwnsDomainRequest +from .types import DnsApiGetDomainDnsRecordsRequest +from .types import DnsRecords from .types import FtpAccountApiChangeFtpAccountPasswordRequest from .types import FtpAccountApiCreateFtpAccountRequest from .types import FtpAccountApiListFtpAccountsRequest @@ -74,6 +83,7 @@ from .types import WebsiteApiListWebsitesRequest from .api import WebhostingV1ControlPanelAPI from .api import WebhostingV1DatabaseAPI +from .api import WebhostingV1DnsAPI from .api import WebhostingV1OfferAPI from .api import WebhostingV1HostingAPI from .api import WebhostingV1FtpAccountAPI @@ -81,6 +91,8 @@ from .api import WebhostingV1WebsiteAPI __all__ = [ + "DnsRecordStatus", + "DnsRecordType", "DnsRecordsStatus", "HostingStatus", "HOSTING_TRANSIENT_STATUSES", @@ -93,6 +105,7 @@ "ListMailAccountsRequestOrderBy", "ListOffersRequestOrderBy", "ListWebsitesRequestOrderBy", + "NameserverStatus", "OfferOptionName", "OfferOptionWarning", "PlatformPlatformGroup", @@ -101,6 +114,8 @@ "PlatformControlPanel", "CreateHostingRequestDomainConfiguration", "OfferOptionRequest", + "DnsRecord", + "Nameserver", "HostingUser", "Offer", "Platform", @@ -111,6 +126,7 @@ "HostingSummary", "MailAccount", "Website", + "CheckUserOwnsDomainResponse", "ControlPanelApiListControlPanelsRequest", "DatabaseApiAssignDatabaseUserRequest", "DatabaseApiChangeDatabaseUserPasswordRequest", @@ -123,6 +139,9 @@ "DatabaseApiListDatabaseUsersRequest", "DatabaseApiListDatabasesRequest", "DatabaseApiUnassignDatabaseUserRequest", + "DnsApiCheckUserOwnsDomainRequest", + "DnsApiGetDomainDnsRecordsRequest", + "DnsRecords", "FtpAccountApiChangeFtpAccountPasswordRequest", "FtpAccountApiCreateFtpAccountRequest", "FtpAccountApiListFtpAccountsRequest", @@ -155,6 +174,7 @@ "WebsiteApiListWebsitesRequest", "WebhostingV1ControlPanelAPI", "WebhostingV1DatabaseAPI", + "WebhostingV1DnsAPI", "WebhostingV1OfferAPI", "WebhostingV1HostingAPI", "WebhostingV1FtpAccountAPI", diff --git a/scaleway-async/scaleway_async/webhosting/v1/api.py b/scaleway-async/scaleway_async/webhosting/v1/api.py index 9f1fc4e67..c23c0bf75 100644 --- a/scaleway-async/scaleway_async/webhosting/v1/api.py +++ b/scaleway-async/scaleway_async/webhosting/v1/api.py @@ -22,6 +22,7 @@ ListMailAccountsRequestOrderBy, ListOffersRequestOrderBy, ListWebsitesRequestOrderBy, + CheckUserOwnsDomainResponse, ControlPanel, CreateHostingRequestDomainConfiguration, Database, @@ -31,6 +32,8 @@ DatabaseApiCreateDatabaseUserRequest, DatabaseApiUnassignDatabaseUserRequest, DatabaseUser, + DnsApiCheckUserOwnsDomainRequest, + DnsRecords, FtpAccount, FtpAccountApiChangeFtpAccountPasswordRequest, FtpAccountApiCreateFtpAccountRequest, @@ -65,6 +68,8 @@ unmarshal_Database, unmarshal_FtpAccount, unmarshal_MailAccount, + unmarshal_CheckUserOwnsDomainResponse, + unmarshal_DnsRecords, unmarshal_Hosting, unmarshal_ListControlPanelsResponse, unmarshal_ListDatabaseUsersResponse, @@ -82,6 +87,7 @@ marshal_DatabaseApiCreateDatabaseRequest, marshal_DatabaseApiCreateDatabaseUserRequest, marshal_DatabaseApiUnassignDatabaseUserRequest, + marshal_DnsApiCheckUserOwnsDomainRequest, marshal_FtpAccountApiChangeFtpAccountPasswordRequest, marshal_FtpAccountApiCreateFtpAccountRequest, marshal_HostingApiCreateHostingRequest, @@ -727,6 +733,89 @@ async def unassign_database_user( return unmarshal_DatabaseUser(res.json()) +class WebhostingV1DnsAPI(API): + """ + This API allows you to manage your Web Hosting services. + """ + + async def get_domain_dns_records( + self, + *, + domain: str, + region: Optional[Region] = None, + ) -> DnsRecords: + """ + Get DNS records. + Get the set of DNS records of a specified domain associated with a Web Hosting plan's domain. + :param domain: Domain associated with the DNS records. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`DnsRecords ` + + Usage: + :: + + result = await api.get_domain_dns_records( + domain="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_domain = validate_path_param("domain", domain) + + res = self._request( + "GET", + f"/webhosting/v1/regions/{param_region}/domains/{param_domain}/dns-records", + ) + + self._throw_on_error(res) + return unmarshal_DnsRecords(res.json()) + + async def check_user_owns_domain( + self, + *, + domain: str, + region: Optional[Region] = None, + project_id: Optional[str] = None, + ) -> CheckUserOwnsDomainResponse: + """ + "Check whether you own this domain or not.". + :param domain: Domain for which ownership is to be verified. + :param region: Region to target. If none is passed will use default region from the config. + :param project_id: ID of the project currently in use. + :return: :class:`CheckUserOwnsDomainResponse ` + + Usage: + :: + + result = await api.check_user_owns_domain( + domain="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_domain = validate_path_param("domain", domain) + + res = self._request( + "POST", + f"/webhosting/v1/regions/{param_region}/domains/{param_domain}/check-ownership", + body=marshal_DnsApiCheckUserOwnsDomainRequest( + DnsApiCheckUserOwnsDomainRequest( + domain=domain, + region=region, + project_id=project_id, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_CheckUserOwnsDomainResponse(res.json()) + + class WebhostingV1OfferAPI(API): """ This API allows you to manage your offer for your Web Hosting services. diff --git a/scaleway-async/scaleway_async/webhosting/v1/marshalling.py b/scaleway-async/scaleway_async/webhosting/v1/marshalling.py index 586bee2b4..1edf72fcc 100644 --- a/scaleway-async/scaleway_async/webhosting/v1/marshalling.py +++ b/scaleway-async/scaleway_async/webhosting/v1/marshalling.py @@ -13,6 +13,10 @@ Database, FtpAccount, MailAccount, + CheckUserOwnsDomainResponse, + DnsRecord, + Nameserver, + DnsRecords, PlatformControlPanelUrls, OfferOption, PlatformControlPanel, @@ -39,6 +43,7 @@ DatabaseApiCreateDatabaseRequest, DatabaseApiCreateDatabaseUserRequest, DatabaseApiUnassignDatabaseUserRequest, + DnsApiCheckUserOwnsDomainRequest, FtpAccountApiChangeFtpAccountPasswordRequest, FtpAccountApiCreateFtpAccountRequest, CreateHostingRequestDomainConfiguration, @@ -130,6 +135,108 @@ def unmarshal_MailAccount(data: Any) -> MailAccount: return MailAccount(**args) +def unmarshal_CheckUserOwnsDomainResponse(data: Any) -> CheckUserOwnsDomainResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'CheckUserOwnsDomainResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("owns_domain", None) + if field is not None: + args["owns_domain"] = field + + return CheckUserOwnsDomainResponse(**args) + + +def unmarshal_DnsRecord(data: Any) -> DnsRecord: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'DnsRecord' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("name", None) + if field is not None: + args["name"] = field + + field = data.get("type", None) + if field is not None: + args["type_"] = field + + field = data.get("ttl", None) + if field is not None: + args["ttl"] = field + + field = data.get("value", None) + if field is not None: + args["value"] = field + + field = data.get("status", None) + if field is not None: + args["status"] = field + + field = data.get("priority", None) + if field is not None: + args["priority"] = field + else: + args["priority"] = None + + return DnsRecord(**args) + + +def unmarshal_Nameserver(data: Any) -> Nameserver: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Nameserver' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("hostname", None) + if field is not None: + args["hostname"] = field + + field = data.get("status", None) + if field is not None: + args["status"] = field + + field = data.get("is_default", None) + if field is not None: + args["is_default"] = field + + return Nameserver(**args) + + +def unmarshal_DnsRecords(data: Any) -> DnsRecords: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'DnsRecords' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("records", None) + if field is not None: + args["records"] = ( + [unmarshal_DnsRecord(v) for v in field] if field is not None else None + ) + + field = data.get("name_servers", None) + if field is not None: + args["name_servers"] = ( + [unmarshal_Nameserver(v) for v in field] if field is not None else None + ) + + field = data.get("status", None) + if field is not None: + args["status"] = field + + return DnsRecords(**args) + + def unmarshal_PlatformControlPanelUrls(data: Any) -> PlatformControlPanelUrls: if not isinstance(data, dict): raise TypeError( @@ -185,6 +292,12 @@ def unmarshal_OfferOption(data: Any) -> OfferOption: if field is not None: args["quota_warning"] = field + field = data.get("price", None) + if field is not None: + args["price"] = unmarshal_Money(field) + else: + args["price"] = None + return OfferOption(**args) @@ -778,6 +891,18 @@ def marshal_DatabaseApiUnassignDatabaseUserRequest( return output +def marshal_DnsApiCheckUserOwnsDomainRequest( + request: DnsApiCheckUserOwnsDomainRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.project_id is not None: + output["project_id"] = request.project_id or defaults.default_project_id + + return output + + def marshal_FtpAccountApiChangeFtpAccountPasswordRequest( request: FtpAccountApiChangeFtpAccountPasswordRequest, defaults: ProfileDefaults, diff --git a/scaleway-async/scaleway_async/webhosting/v1/types.py b/scaleway-async/scaleway_async/webhosting/v1/types.py index 0bdcc8a3e..1521f5bdc 100644 --- a/scaleway-async/scaleway_async/webhosting/v1/types.py +++ b/scaleway-async/scaleway_async/webhosting/v1/types.py @@ -20,6 +20,28 @@ ) +class DnsRecordStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + VALID = "valid" + INVALID = "invalid" + + def __str__(self) -> str: + return str(self.value) + + +class DnsRecordType(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_TYPE = "unknown_type" + A = "a" + CNAME = "cname" + MX = "mx" + TXT = "txt" + NS = "ns" + AAAA = "aaaa" + + def __str__(self) -> str: + return str(self.value) + + class DnsRecordsStatus(str, Enum, metaclass=StrEnumMeta): UNKNOWN_STATUS = "unknown_status" VALID = "valid" @@ -112,6 +134,15 @@ def __str__(self) -> str: return str(self.value) +class NameserverStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + VALID = "valid" + INVALID = "invalid" + + def __str__(self) -> str: + return str(self.value) + + class OfferOptionName(str, Enum, metaclass=StrEnumMeta): UNKNOWN_NAME = "unknown_name" DOMAIN_COUNT = "domain_count" @@ -193,6 +224,11 @@ class OfferOption: Defines a warning if the maximum value for the option has been reached. """ + price: Optional[Money] + """ + Price of the option for 1 value. + """ + @dataclass class PlatformControlPanel: @@ -231,6 +267,57 @@ class OfferOptionRequest: """ +@dataclass +class DnsRecord: + name: str + """ + Record name. + """ + + type_: DnsRecordType + """ + Record type. + """ + + ttl: int + """ + Record time-to-live. + """ + + value: str + """ + Record value. + """ + + status: DnsRecordStatus + """ + Record status. + """ + + priority: Optional[int] + """ + Record priority level. + """ + + +@dataclass +class Nameserver: + hostname: str + """ + Hostname of the nameserver. + """ + + status: NameserverStatus + """ + Status of the nameserver. + """ + + is_default: bool + """ + Defines whether the nameserver is the default one. + """ + + @dataclass class HostingUser: username: str @@ -456,6 +543,14 @@ class Website: """ +@dataclass +class CheckUserOwnsDomainResponse: + owns_domain: bool + """ + Indicates whether the specified project owns the domain. + """ + + @dataclass class ControlPanelApiListControlPanelsRequest: region: Optional[Region] @@ -712,6 +807,55 @@ class DatabaseApiUnassignDatabaseUserRequest: """ +@dataclass +class DnsApiCheckUserOwnsDomainRequest: + domain: str + """ + Domain for which ownership is to be verified. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + project_id: Optional[str] + """ + ID of the project currently in use. + """ + + +@dataclass +class DnsApiGetDomainDnsRecordsRequest: + domain: str + """ + Domain associated with the DNS records. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class DnsRecords: + records: List[DnsRecord] + """ + List of DNS records. + """ + + name_servers: List[Nameserver] + """ + List of nameservers. + """ + + status: DnsRecordsStatus + """ + Status of the records. + """ + + @dataclass class FtpAccountApiChangeFtpAccountPasswordRequest: hosting_id: str diff --git a/scaleway/scaleway/webhosting/v1/__init__.py b/scaleway/scaleway/webhosting/v1/__init__.py index 820010080..6da8dd39a 100644 --- a/scaleway/scaleway/webhosting/v1/__init__.py +++ b/scaleway/scaleway/webhosting/v1/__init__.py @@ -1,5 +1,7 @@ # 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 DnsRecordStatus +from .types import DnsRecordType from .types import DnsRecordsStatus from .types import HostingStatus from .content import HOSTING_TRANSIENT_STATUSES @@ -12,6 +14,7 @@ from .types import ListMailAccountsRequestOrderBy from .types import ListOffersRequestOrderBy from .types import ListWebsitesRequestOrderBy +from .types import NameserverStatus from .types import OfferOptionName from .types import OfferOptionWarning from .types import PlatformPlatformGroup @@ -20,6 +23,8 @@ from .types import PlatformControlPanel from .types import CreateHostingRequestDomainConfiguration from .types import OfferOptionRequest +from .types import DnsRecord +from .types import Nameserver from .types import HostingUser from .types import Offer from .types import Platform @@ -30,6 +35,7 @@ from .types import HostingSummary from .types import MailAccount from .types import Website +from .types import CheckUserOwnsDomainResponse from .types import ControlPanelApiListControlPanelsRequest from .types import DatabaseApiAssignDatabaseUserRequest from .types import DatabaseApiChangeDatabaseUserPasswordRequest @@ -42,6 +48,9 @@ from .types import DatabaseApiListDatabaseUsersRequest from .types import DatabaseApiListDatabasesRequest from .types import DatabaseApiUnassignDatabaseUserRequest +from .types import DnsApiCheckUserOwnsDomainRequest +from .types import DnsApiGetDomainDnsRecordsRequest +from .types import DnsRecords from .types import FtpAccountApiChangeFtpAccountPasswordRequest from .types import FtpAccountApiCreateFtpAccountRequest from .types import FtpAccountApiListFtpAccountsRequest @@ -74,6 +83,7 @@ from .types import WebsiteApiListWebsitesRequest from .api import WebhostingV1ControlPanelAPI from .api import WebhostingV1DatabaseAPI +from .api import WebhostingV1DnsAPI from .api import WebhostingV1OfferAPI from .api import WebhostingV1HostingAPI from .api import WebhostingV1FtpAccountAPI @@ -81,6 +91,8 @@ from .api import WebhostingV1WebsiteAPI __all__ = [ + "DnsRecordStatus", + "DnsRecordType", "DnsRecordsStatus", "HostingStatus", "HOSTING_TRANSIENT_STATUSES", @@ -93,6 +105,7 @@ "ListMailAccountsRequestOrderBy", "ListOffersRequestOrderBy", "ListWebsitesRequestOrderBy", + "NameserverStatus", "OfferOptionName", "OfferOptionWarning", "PlatformPlatformGroup", @@ -101,6 +114,8 @@ "PlatformControlPanel", "CreateHostingRequestDomainConfiguration", "OfferOptionRequest", + "DnsRecord", + "Nameserver", "HostingUser", "Offer", "Platform", @@ -111,6 +126,7 @@ "HostingSummary", "MailAccount", "Website", + "CheckUserOwnsDomainResponse", "ControlPanelApiListControlPanelsRequest", "DatabaseApiAssignDatabaseUserRequest", "DatabaseApiChangeDatabaseUserPasswordRequest", @@ -123,6 +139,9 @@ "DatabaseApiListDatabaseUsersRequest", "DatabaseApiListDatabasesRequest", "DatabaseApiUnassignDatabaseUserRequest", + "DnsApiCheckUserOwnsDomainRequest", + "DnsApiGetDomainDnsRecordsRequest", + "DnsRecords", "FtpAccountApiChangeFtpAccountPasswordRequest", "FtpAccountApiCreateFtpAccountRequest", "FtpAccountApiListFtpAccountsRequest", @@ -155,6 +174,7 @@ "WebsiteApiListWebsitesRequest", "WebhostingV1ControlPanelAPI", "WebhostingV1DatabaseAPI", + "WebhostingV1DnsAPI", "WebhostingV1OfferAPI", "WebhostingV1HostingAPI", "WebhostingV1FtpAccountAPI", diff --git a/scaleway/scaleway/webhosting/v1/api.py b/scaleway/scaleway/webhosting/v1/api.py index a60674a3d..42f4eddf0 100644 --- a/scaleway/scaleway/webhosting/v1/api.py +++ b/scaleway/scaleway/webhosting/v1/api.py @@ -22,6 +22,7 @@ ListMailAccountsRequestOrderBy, ListOffersRequestOrderBy, ListWebsitesRequestOrderBy, + CheckUserOwnsDomainResponse, ControlPanel, CreateHostingRequestDomainConfiguration, Database, @@ -31,6 +32,8 @@ DatabaseApiCreateDatabaseUserRequest, DatabaseApiUnassignDatabaseUserRequest, DatabaseUser, + DnsApiCheckUserOwnsDomainRequest, + DnsRecords, FtpAccount, FtpAccountApiChangeFtpAccountPasswordRequest, FtpAccountApiCreateFtpAccountRequest, @@ -65,6 +68,8 @@ unmarshal_Database, unmarshal_FtpAccount, unmarshal_MailAccount, + unmarshal_CheckUserOwnsDomainResponse, + unmarshal_DnsRecords, unmarshal_Hosting, unmarshal_ListControlPanelsResponse, unmarshal_ListDatabaseUsersResponse, @@ -82,6 +87,7 @@ marshal_DatabaseApiCreateDatabaseRequest, marshal_DatabaseApiCreateDatabaseUserRequest, marshal_DatabaseApiUnassignDatabaseUserRequest, + marshal_DnsApiCheckUserOwnsDomainRequest, marshal_FtpAccountApiChangeFtpAccountPasswordRequest, marshal_FtpAccountApiCreateFtpAccountRequest, marshal_HostingApiCreateHostingRequest, @@ -727,6 +733,89 @@ def unassign_database_user( return unmarshal_DatabaseUser(res.json()) +class WebhostingV1DnsAPI(API): + """ + This API allows you to manage your Web Hosting services. + """ + + def get_domain_dns_records( + self, + *, + domain: str, + region: Optional[Region] = None, + ) -> DnsRecords: + """ + Get DNS records. + Get the set of DNS records of a specified domain associated with a Web Hosting plan's domain. + :param domain: Domain associated with the DNS records. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`DnsRecords ` + + Usage: + :: + + result = api.get_domain_dns_records( + domain="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_domain = validate_path_param("domain", domain) + + res = self._request( + "GET", + f"/webhosting/v1/regions/{param_region}/domains/{param_domain}/dns-records", + ) + + self._throw_on_error(res) + return unmarshal_DnsRecords(res.json()) + + def check_user_owns_domain( + self, + *, + domain: str, + region: Optional[Region] = None, + project_id: Optional[str] = None, + ) -> CheckUserOwnsDomainResponse: + """ + "Check whether you own this domain or not.". + :param domain: Domain for which ownership is to be verified. + :param region: Region to target. If none is passed will use default region from the config. + :param project_id: ID of the project currently in use. + :return: :class:`CheckUserOwnsDomainResponse ` + + Usage: + :: + + result = api.check_user_owns_domain( + domain="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_domain = validate_path_param("domain", domain) + + res = self._request( + "POST", + f"/webhosting/v1/regions/{param_region}/domains/{param_domain}/check-ownership", + body=marshal_DnsApiCheckUserOwnsDomainRequest( + DnsApiCheckUserOwnsDomainRequest( + domain=domain, + region=region, + project_id=project_id, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_CheckUserOwnsDomainResponse(res.json()) + + class WebhostingV1OfferAPI(API): """ This API allows you to manage your offer for your Web Hosting services. diff --git a/scaleway/scaleway/webhosting/v1/marshalling.py b/scaleway/scaleway/webhosting/v1/marshalling.py index 586bee2b4..1edf72fcc 100644 --- a/scaleway/scaleway/webhosting/v1/marshalling.py +++ b/scaleway/scaleway/webhosting/v1/marshalling.py @@ -13,6 +13,10 @@ Database, FtpAccount, MailAccount, + CheckUserOwnsDomainResponse, + DnsRecord, + Nameserver, + DnsRecords, PlatformControlPanelUrls, OfferOption, PlatformControlPanel, @@ -39,6 +43,7 @@ DatabaseApiCreateDatabaseRequest, DatabaseApiCreateDatabaseUserRequest, DatabaseApiUnassignDatabaseUserRequest, + DnsApiCheckUserOwnsDomainRequest, FtpAccountApiChangeFtpAccountPasswordRequest, FtpAccountApiCreateFtpAccountRequest, CreateHostingRequestDomainConfiguration, @@ -130,6 +135,108 @@ def unmarshal_MailAccount(data: Any) -> MailAccount: return MailAccount(**args) +def unmarshal_CheckUserOwnsDomainResponse(data: Any) -> CheckUserOwnsDomainResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'CheckUserOwnsDomainResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("owns_domain", None) + if field is not None: + args["owns_domain"] = field + + return CheckUserOwnsDomainResponse(**args) + + +def unmarshal_DnsRecord(data: Any) -> DnsRecord: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'DnsRecord' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("name", None) + if field is not None: + args["name"] = field + + field = data.get("type", None) + if field is not None: + args["type_"] = field + + field = data.get("ttl", None) + if field is not None: + args["ttl"] = field + + field = data.get("value", None) + if field is not None: + args["value"] = field + + field = data.get("status", None) + if field is not None: + args["status"] = field + + field = data.get("priority", None) + if field is not None: + args["priority"] = field + else: + args["priority"] = None + + return DnsRecord(**args) + + +def unmarshal_Nameserver(data: Any) -> Nameserver: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Nameserver' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("hostname", None) + if field is not None: + args["hostname"] = field + + field = data.get("status", None) + if field is not None: + args["status"] = field + + field = data.get("is_default", None) + if field is not None: + args["is_default"] = field + + return Nameserver(**args) + + +def unmarshal_DnsRecords(data: Any) -> DnsRecords: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'DnsRecords' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("records", None) + if field is not None: + args["records"] = ( + [unmarshal_DnsRecord(v) for v in field] if field is not None else None + ) + + field = data.get("name_servers", None) + if field is not None: + args["name_servers"] = ( + [unmarshal_Nameserver(v) for v in field] if field is not None else None + ) + + field = data.get("status", None) + if field is not None: + args["status"] = field + + return DnsRecords(**args) + + def unmarshal_PlatformControlPanelUrls(data: Any) -> PlatformControlPanelUrls: if not isinstance(data, dict): raise TypeError( @@ -185,6 +292,12 @@ def unmarshal_OfferOption(data: Any) -> OfferOption: if field is not None: args["quota_warning"] = field + field = data.get("price", None) + if field is not None: + args["price"] = unmarshal_Money(field) + else: + args["price"] = None + return OfferOption(**args) @@ -778,6 +891,18 @@ def marshal_DatabaseApiUnassignDatabaseUserRequest( return output +def marshal_DnsApiCheckUserOwnsDomainRequest( + request: DnsApiCheckUserOwnsDomainRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.project_id is not None: + output["project_id"] = request.project_id or defaults.default_project_id + + return output + + def marshal_FtpAccountApiChangeFtpAccountPasswordRequest( request: FtpAccountApiChangeFtpAccountPasswordRequest, defaults: ProfileDefaults, diff --git a/scaleway/scaleway/webhosting/v1/types.py b/scaleway/scaleway/webhosting/v1/types.py index 0bdcc8a3e..1521f5bdc 100644 --- a/scaleway/scaleway/webhosting/v1/types.py +++ b/scaleway/scaleway/webhosting/v1/types.py @@ -20,6 +20,28 @@ ) +class DnsRecordStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + VALID = "valid" + INVALID = "invalid" + + def __str__(self) -> str: + return str(self.value) + + +class DnsRecordType(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_TYPE = "unknown_type" + A = "a" + CNAME = "cname" + MX = "mx" + TXT = "txt" + NS = "ns" + AAAA = "aaaa" + + def __str__(self) -> str: + return str(self.value) + + class DnsRecordsStatus(str, Enum, metaclass=StrEnumMeta): UNKNOWN_STATUS = "unknown_status" VALID = "valid" @@ -112,6 +134,15 @@ def __str__(self) -> str: return str(self.value) +class NameserverStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + VALID = "valid" + INVALID = "invalid" + + def __str__(self) -> str: + return str(self.value) + + class OfferOptionName(str, Enum, metaclass=StrEnumMeta): UNKNOWN_NAME = "unknown_name" DOMAIN_COUNT = "domain_count" @@ -193,6 +224,11 @@ class OfferOption: Defines a warning if the maximum value for the option has been reached. """ + price: Optional[Money] + """ + Price of the option for 1 value. + """ + @dataclass class PlatformControlPanel: @@ -231,6 +267,57 @@ class OfferOptionRequest: """ +@dataclass +class DnsRecord: + name: str + """ + Record name. + """ + + type_: DnsRecordType + """ + Record type. + """ + + ttl: int + """ + Record time-to-live. + """ + + value: str + """ + Record value. + """ + + status: DnsRecordStatus + """ + Record status. + """ + + priority: Optional[int] + """ + Record priority level. + """ + + +@dataclass +class Nameserver: + hostname: str + """ + Hostname of the nameserver. + """ + + status: NameserverStatus + """ + Status of the nameserver. + """ + + is_default: bool + """ + Defines whether the nameserver is the default one. + """ + + @dataclass class HostingUser: username: str @@ -456,6 +543,14 @@ class Website: """ +@dataclass +class CheckUserOwnsDomainResponse: + owns_domain: bool + """ + Indicates whether the specified project owns the domain. + """ + + @dataclass class ControlPanelApiListControlPanelsRequest: region: Optional[Region] @@ -712,6 +807,55 @@ class DatabaseApiUnassignDatabaseUserRequest: """ +@dataclass +class DnsApiCheckUserOwnsDomainRequest: + domain: str + """ + Domain for which ownership is to be verified. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + project_id: Optional[str] + """ + ID of the project currently in use. + """ + + +@dataclass +class DnsApiGetDomainDnsRecordsRequest: + domain: str + """ + Domain associated with the DNS records. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class DnsRecords: + records: List[DnsRecord] + """ + List of DNS records. + """ + + name_servers: List[Nameserver] + """ + List of nameservers. + """ + + status: DnsRecordsStatus + """ + Status of the records. + """ + + @dataclass class FtpAccountApiChangeFtpAccountPasswordRequest: hosting_id: str