|
26 | 26 | AutoConfigDomainDns, |
27 | 27 | Backup, |
28 | 28 | BackupApiRestoreBackupItemsRequest, |
| 29 | + CheckFreeDomainAvailabilityResponse, |
29 | 30 | CheckUserOwnsDomainResponse, |
30 | 31 | ControlPanel, |
31 | 32 | CreateDatabaseRequestUser, |
|
41 | 42 | DnsApiSyncDomainDnsRecordsRequest, |
42 | 43 | DnsRecords, |
43 | 44 | Domain, |
| 45 | + FreeDomainApiCheckFreeDomainAvailabilityRequest, |
44 | 46 | FtpAccount, |
45 | 47 | FtpAccountApiChangeFtpAccountPasswordRequest, |
46 | 48 | FtpAccountApiCreateFtpAccountRequest, |
|
54 | 56 | ListControlPanelsResponse, |
55 | 57 | ListDatabaseUsersResponse, |
56 | 58 | ListDatabasesResponse, |
| 59 | + ListFreeRootDomainsResponse, |
57 | 60 | ListFtpAccountsResponse, |
58 | 61 | ListHostingsResponse, |
59 | 62 | ListMailAccountsResponse, |
|
86 | 89 | unmarshal_FtpAccount, |
87 | 90 | unmarshal_HostingSummary, |
88 | 91 | unmarshal_MailAccount, |
| 92 | + unmarshal_CheckFreeDomainAvailabilityResponse, |
89 | 93 | unmarshal_CheckUserOwnsDomainResponse, |
90 | 94 | unmarshal_DnsRecords, |
91 | 95 | unmarshal_Domain, |
|
95 | 99 | unmarshal_ListControlPanelsResponse, |
96 | 100 | unmarshal_ListDatabaseUsersResponse, |
97 | 101 | unmarshal_ListDatabasesResponse, |
| 102 | + unmarshal_ListFreeRootDomainsResponse, |
98 | 103 | unmarshal_ListFtpAccountsResponse, |
99 | 104 | unmarshal_ListHostingsResponse, |
100 | 105 | unmarshal_ListMailAccountsResponse, |
|
114 | 119 | marshal_DatabaseApiUnassignDatabaseUserRequest, |
115 | 120 | marshal_DnsApiCheckUserOwnsDomainRequest, |
116 | 121 | marshal_DnsApiSyncDomainDnsRecordsRequest, |
| 122 | + marshal_FreeDomainApiCheckFreeDomainAvailabilityRequest, |
117 | 123 | marshal_FtpAccountApiChangeFtpAccountPasswordRequest, |
118 | 124 | marshal_FtpAccountApiCreateFtpAccountRequest, |
119 | 125 | marshal_HostingApiAddCustomDomainRequest, |
@@ -1938,6 +1944,122 @@ async def remove_custom_domain( |
1938 | 1944 | return unmarshal_HostingSummary(res.json()) |
1939 | 1945 |
|
1940 | 1946 |
|
| 1947 | +class WebhostingV1FreeDomainAPI(API): |
| 1948 | + """ |
| 1949 | + This API allows you to list and check a free domain's validity. |
| 1950 | + """ |
| 1951 | + |
| 1952 | + async def check_free_domain_availability( |
| 1953 | + self, |
| 1954 | + *, |
| 1955 | + slug: str, |
| 1956 | + root_domain: str, |
| 1957 | + region: Optional[ScwRegion] = None, |
| 1958 | + ) -> CheckFreeDomainAvailabilityResponse: |
| 1959 | + """ |
| 1960 | + Check whether a given slug and free domain combination is available. |
| 1961 | + :param slug: Custom prefix used for the free domain. |
| 1962 | + :param root_domain: Free root domain provided by Web Hosting, selected from the list returned by `ListFreeRootDomains`. |
| 1963 | + :param region: Region to target. If none is passed will use default region from the config. |
| 1964 | + :return: :class:`CheckFreeDomainAvailabilityResponse <CheckFreeDomainAvailabilityResponse>` |
| 1965 | +
|
| 1966 | + Usage: |
| 1967 | + :: |
| 1968 | +
|
| 1969 | + result = await api.check_free_domain_availability( |
| 1970 | + slug="example", |
| 1971 | + root_domain="example", |
| 1972 | + ) |
| 1973 | + """ |
| 1974 | + |
| 1975 | + param_region = validate_path_param( |
| 1976 | + "region", region or self.client.default_region |
| 1977 | + ) |
| 1978 | + |
| 1979 | + res = self._request( |
| 1980 | + "POST", |
| 1981 | + f"/webhosting/v1/regions/{param_region}/free-domains/check-availability", |
| 1982 | + body=marshal_FreeDomainApiCheckFreeDomainAvailabilityRequest( |
| 1983 | + FreeDomainApiCheckFreeDomainAvailabilityRequest( |
| 1984 | + slug=slug, |
| 1985 | + root_domain=root_domain, |
| 1986 | + region=region, |
| 1987 | + ), |
| 1988 | + self.client, |
| 1989 | + ), |
| 1990 | + ) |
| 1991 | + |
| 1992 | + self._throw_on_error(res) |
| 1993 | + return unmarshal_CheckFreeDomainAvailabilityResponse(res.json()) |
| 1994 | + |
| 1995 | + async def list_free_root_domains( |
| 1996 | + self, |
| 1997 | + *, |
| 1998 | + region: Optional[ScwRegion] = None, |
| 1999 | + page: Optional[int] = None, |
| 2000 | + page_size: Optional[int] = None, |
| 2001 | + ) -> ListFreeRootDomainsResponse: |
| 2002 | + """ |
| 2003 | + Retrieve the list of free root domains available for a Web Hosting. |
| 2004 | + :param region: Region to target. If none is passed will use default region from the config. |
| 2005 | + :param page: Page number to return, from the paginated results (must be a positive integer). |
| 2006 | + :param page_size: Number of free root domains to return (must be a positive integer lower or equal to 100). |
| 2007 | + :return: :class:`ListFreeRootDomainsResponse <ListFreeRootDomainsResponse>` |
| 2008 | +
|
| 2009 | + Usage: |
| 2010 | + :: |
| 2011 | +
|
| 2012 | + result = await api.list_free_root_domains() |
| 2013 | + """ |
| 2014 | + |
| 2015 | + param_region = validate_path_param( |
| 2016 | + "region", region or self.client.default_region |
| 2017 | + ) |
| 2018 | + |
| 2019 | + res = self._request( |
| 2020 | + "GET", |
| 2021 | + f"/webhosting/v1/regions/{param_region}/free-domains/root-domains", |
| 2022 | + params={ |
| 2023 | + "page": page, |
| 2024 | + "page_size": page_size or self.client.default_page_size, |
| 2025 | + }, |
| 2026 | + ) |
| 2027 | + |
| 2028 | + self._throw_on_error(res) |
| 2029 | + return unmarshal_ListFreeRootDomainsResponse(res.json()) |
| 2030 | + |
| 2031 | + async def list_free_root_domains_all( |
| 2032 | + self, |
| 2033 | + *, |
| 2034 | + region: Optional[ScwRegion] = None, |
| 2035 | + page: Optional[int] = None, |
| 2036 | + page_size: Optional[int] = None, |
| 2037 | + ) -> List[str]: |
| 2038 | + """ |
| 2039 | + Retrieve the list of free root domains available for a Web Hosting. |
| 2040 | + :param region: Region to target. If none is passed will use default region from the config. |
| 2041 | + :param page: Page number to return, from the paginated results (must be a positive integer). |
| 2042 | + :param page_size: Number of free root domains to return (must be a positive integer lower or equal to 100). |
| 2043 | + :return: :class:`List[str] <List[str]>` |
| 2044 | +
|
| 2045 | + Usage: |
| 2046 | + :: |
| 2047 | +
|
| 2048 | + result = await api.list_free_root_domains_all() |
| 2049 | + """ |
| 2050 | + |
| 2051 | + return await fetch_all_pages_async( |
| 2052 | + type=ListFreeRootDomainsResponse, |
| 2053 | + key="root_domains", |
| 2054 | + fetcher=self.list_free_root_domains, |
| 2055 | + args={ |
| 2056 | + "region": region, |
| 2057 | + "page": page, |
| 2058 | + "page_size": page_size, |
| 2059 | + }, |
| 2060 | + ) |
| 2061 | + |
| 2062 | + |
1941 | 2063 | class WebhostingV1FtpAccountAPI(API): |
1942 | 2064 | """ |
1943 | 2065 | This API allows you to manage your FTP accounts for your Web Hosting services. |
|
0 commit comments