4040 _ = namegenerator .GetRandomName
4141)
4242
43+ type DNSRecordStatus string
44+
45+ const (
46+ DNSRecordStatusUnknownStatus = DNSRecordStatus ("unknown_status" )
47+ DNSRecordStatusValid = DNSRecordStatus ("valid" )
48+ DNSRecordStatusInvalid = DNSRecordStatus ("invalid" )
49+ )
50+
51+ func (enum DNSRecordStatus ) String () string {
52+ if enum == "" {
53+ // return default value if empty
54+ return "unknown_status"
55+ }
56+ return string (enum )
57+ }
58+
59+ func (enum DNSRecordStatus ) Values () []DNSRecordStatus {
60+ return []DNSRecordStatus {
61+ "unknown_status" ,
62+ "valid" ,
63+ "invalid" ,
64+ }
65+ }
66+
67+ func (enum DNSRecordStatus ) MarshalJSON () ([]byte , error ) {
68+ return []byte (fmt .Sprintf (`"%s"` , enum )), nil
69+ }
70+
71+ func (enum * DNSRecordStatus ) UnmarshalJSON (data []byte ) error {
72+ tmp := ""
73+
74+ if err := json .Unmarshal (data , & tmp ); err != nil {
75+ return err
76+ }
77+
78+ * enum = DNSRecordStatus (DNSRecordStatus (tmp ).String ())
79+ return nil
80+ }
81+
82+ type DNSRecordType string
83+
84+ const (
85+ DNSRecordTypeUnknownType = DNSRecordType ("unknown_type" )
86+ DNSRecordTypeA = DNSRecordType ("a" )
87+ DNSRecordTypeCname = DNSRecordType ("cname" )
88+ DNSRecordTypeMx = DNSRecordType ("mx" )
89+ DNSRecordTypeTxt = DNSRecordType ("txt" )
90+ DNSRecordTypeNs = DNSRecordType ("ns" )
91+ DNSRecordTypeAaaa = DNSRecordType ("aaaa" )
92+ )
93+
94+ func (enum DNSRecordType ) String () string {
95+ if enum == "" {
96+ // return default value if empty
97+ return "unknown_type"
98+ }
99+ return string (enum )
100+ }
101+
102+ func (enum DNSRecordType ) Values () []DNSRecordType {
103+ return []DNSRecordType {
104+ "unknown_type" ,
105+ "a" ,
106+ "cname" ,
107+ "mx" ,
108+ "txt" ,
109+ "ns" ,
110+ "aaaa" ,
111+ }
112+ }
113+
114+ func (enum DNSRecordType ) MarshalJSON () ([]byte , error ) {
115+ return []byte (fmt .Sprintf (`"%s"` , enum )), nil
116+ }
117+
118+ func (enum * DNSRecordType ) UnmarshalJSON (data []byte ) error {
119+ tmp := ""
120+
121+ if err := json .Unmarshal (data , & tmp ); err != nil {
122+ return err
123+ }
124+
125+ * enum = DNSRecordType (DNSRecordType (tmp ).String ())
126+ return nil
127+ }
128+
43129type DNSRecordsStatus string
44130
45131const (
@@ -434,6 +520,45 @@ func (enum *ListWebsitesRequestOrderBy) UnmarshalJSON(data []byte) error {
434520 return nil
435521}
436522
523+ type NameserverStatus string
524+
525+ const (
526+ NameserverStatusUnknownStatus = NameserverStatus ("unknown_status" )
527+ NameserverStatusValid = NameserverStatus ("valid" )
528+ NameserverStatusInvalid = NameserverStatus ("invalid" )
529+ )
530+
531+ func (enum NameserverStatus ) String () string {
532+ if enum == "" {
533+ // return default value if empty
534+ return "unknown_status"
535+ }
536+ return string (enum )
537+ }
538+
539+ func (enum NameserverStatus ) Values () []NameserverStatus {
540+ return []NameserverStatus {
541+ "unknown_status" ,
542+ "valid" ,
543+ "invalid" ,
544+ }
545+ }
546+
547+ func (enum NameserverStatus ) MarshalJSON () ([]byte , error ) {
548+ return []byte (fmt .Sprintf (`"%s"` , enum )), nil
549+ }
550+
551+ func (enum * NameserverStatus ) UnmarshalJSON (data []byte ) error {
552+ tmp := ""
553+
554+ if err := json .Unmarshal (data , & tmp ); err != nil {
555+ return err
556+ }
557+
558+ * enum = NameserverStatus (NameserverStatus (tmp ).String ())
559+ return nil
560+ }
561+
437562type OfferOptionName string
438563
439564const (
@@ -592,6 +717,9 @@ type OfferOption struct {
592717 // QuotaWarning: defines a warning if the maximum value for the option has been reached.
593718 // Default value: unknown_warning
594719 QuotaWarning OfferOptionWarning `json:"quota_warning"`
720+
721+ // Price: price of the option for 1 value.
722+ Price * scw.Money `json:"price"`
595723}
596724
597725// PlatformControlPanel: platform control panel.
@@ -623,6 +751,42 @@ type OfferOptionRequest struct {
623751 Quantity int64 `json:"quantity"`
624752}
625753
754+ // DNSRecord: dns record.
755+ type DNSRecord struct {
756+ // Name: record name.
757+ Name string `json:"name"`
758+
759+ // Type: record type.
760+ // Default value: unknown_type
761+ Type DNSRecordType `json:"type"`
762+
763+ // TTL: record time-to-live.
764+ TTL uint32 `json:"ttl"`
765+
766+ // Value: record value.
767+ Value string `json:"value"`
768+
769+ // Priority: record priority level.
770+ Priority * uint32 `json:"priority"`
771+
772+ // Status: record status.
773+ // Default value: unknown_status
774+ Status DNSRecordStatus `json:"status"`
775+ }
776+
777+ // Nameserver: nameserver.
778+ type Nameserver struct {
779+ // Hostname: hostname of the nameserver.
780+ Hostname string `json:"hostname"`
781+
782+ // Status: status of the nameserver.
783+ // Default value: unknown_status
784+ Status NameserverStatus `json:"status"`
785+
786+ // IsDefault: defines whether the nameserver is the default one.
787+ IsDefault bool `json:"is_default"`
788+ }
789+
626790// HostingUser: hosting user.
627791type HostingUser struct {
628792 // Username: main Web Hosting cPanel username.
@@ -772,6 +936,12 @@ type Website struct {
772936 SslStatus bool `json:"ssl_status"`
773937}
774938
939+ // CheckUserOwnsDomainResponse: check user owns domain response.
940+ type CheckUserOwnsDomainResponse struct {
941+ // OwnsDomain: indicates whether the specified project owns the domain.
942+ OwnsDomain bool `json:"owns_domain"`
943+ }
944+
775945// ControlPanelAPIListControlPanelsRequest: control panel api list control panels request.
776946type ControlPanelAPIListControlPanelsRequest struct {
777947 // Region: region to target. If none is passed will use default region from the config.
@@ -784,6 +954,40 @@ type ControlPanelAPIListControlPanelsRequest struct {
784954 PageSize * uint32 `json:"-"`
785955}
786956
957+ // DNSAPICheckUserOwnsDomainRequest: dnsapi check user owns domain request.
958+ type DNSAPICheckUserOwnsDomainRequest struct {
959+ // Region: region to target. If none is passed will use default region from the config.
960+ Region scw.Region `json:"-"`
961+
962+ // Domain: domain for which ownership is to be verified.
963+ Domain string `json:"-"`
964+
965+ // ProjectID: ID of the project currently in use.
966+ ProjectID string `json:"project_id"`
967+ }
968+
969+ // DNSAPIGetDomainDNSRecordsRequest: dnsapi get domain dns records request.
970+ type DNSAPIGetDomainDNSRecordsRequest struct {
971+ // Region: region to target. If none is passed will use default region from the config.
972+ Region scw.Region `json:"-"`
973+
974+ // Domain: domain associated with the DNS records.
975+ Domain string `json:"-"`
976+ }
977+
978+ // DNSRecords: dns records.
979+ type DNSRecords struct {
980+ // Records: list of DNS records.
981+ Records []* DNSRecord `json:"records"`
982+
983+ // NameServers: list of nameservers.
984+ NameServers []* Nameserver `json:"name_servers"`
985+
986+ // Status: status of the records.
987+ // Default value: unknown_status
988+ Status DNSRecordsStatus `json:"status"`
989+ }
990+
787991// DatabaseAPIAssignDatabaseUserRequest: database api assign database user request.
788992type DatabaseAPIAssignDatabaseUserRequest struct {
789993 // Region: region to target. If none is passed will use default region from the config.
@@ -1570,7 +1774,7 @@ func NewControlPanelAPI(client *scw.Client) *ControlPanelAPI {
15701774 }
15711775}
15721776func (s * ControlPanelAPI ) Regions () []scw.Region {
1573- return []scw.Region {scw .RegionFrPar , scw .RegionNlAms }
1777+ return []scw.Region {scw .RegionFrPar , scw .RegionNlAms , scw . RegionPlWaw }
15741778}
15751779
15761780// ListControlPanels: "List the control panels type: cpanel or plesk.".
@@ -2041,6 +2245,93 @@ func (s *DatabaseAPI) UnassignDatabaseUser(req *DatabaseAPIUnassignDatabaseUserR
20412245 return & resp , nil
20422246}
20432247
2248+ // This API allows you to manage your Web Hosting services.
2249+ type DnsAPI struct {
2250+ client * scw.Client
2251+ }
2252+
2253+ // NewDnsAPI returns a DnsAPI object from a Scaleway client.
2254+ func NewDnsAPI (client * scw.Client ) * DnsAPI {
2255+ return & DnsAPI {
2256+ client : client ,
2257+ }
2258+ }
2259+ func (s * DnsAPI ) Regions () []scw.Region {
2260+ return []scw.Region {scw .RegionFrPar , scw .RegionNlAms , scw .RegionPlWaw }
2261+ }
2262+
2263+ // GetDomainDNSRecords: Get the set of DNS records of a specified domain associated with a Web Hosting plan's domain.
2264+ func (s * DnsAPI ) GetDomainDNSRecords (req * DNSAPIGetDomainDNSRecordsRequest , opts ... scw.RequestOption ) (* DNSRecords , error ) {
2265+ var err error
2266+
2267+ if req .Region == "" {
2268+ defaultRegion , _ := s .client .GetDefaultRegion ()
2269+ req .Region = defaultRegion
2270+ }
2271+
2272+ if fmt .Sprint (req .Region ) == "" {
2273+ return nil , errors .New ("field Region cannot be empty in request" )
2274+ }
2275+
2276+ if fmt .Sprint (req .Domain ) == "" {
2277+ return nil , errors .New ("field Domain cannot be empty in request" )
2278+ }
2279+
2280+ scwReq := & scw.ScalewayRequest {
2281+ Method : "GET" ,
2282+ Path : "/webhosting/v1/regions/" + fmt .Sprint (req .Region ) + "/domains/" + fmt .Sprint (req .Domain ) + "/dns-records" ,
2283+ }
2284+
2285+ var resp DNSRecords
2286+
2287+ err = s .client .Do (scwReq , & resp , opts ... )
2288+ if err != nil {
2289+ return nil , err
2290+ }
2291+ return & resp , nil
2292+ }
2293+
2294+ // CheckUserOwnsDomain: "Check whether you own this domain or not.".
2295+ func (s * DnsAPI ) CheckUserOwnsDomain (req * DNSAPICheckUserOwnsDomainRequest , opts ... scw.RequestOption ) (* CheckUserOwnsDomainResponse , error ) {
2296+ var err error
2297+
2298+ if req .Region == "" {
2299+ defaultRegion , _ := s .client .GetDefaultRegion ()
2300+ req .Region = defaultRegion
2301+ }
2302+
2303+ if req .ProjectID == "" {
2304+ defaultProjectID , _ := s .client .GetDefaultProjectID ()
2305+ req .ProjectID = defaultProjectID
2306+ }
2307+
2308+ if fmt .Sprint (req .Region ) == "" {
2309+ return nil , errors .New ("field Region cannot be empty in request" )
2310+ }
2311+
2312+ if fmt .Sprint (req .Domain ) == "" {
2313+ return nil , errors .New ("field Domain cannot be empty in request" )
2314+ }
2315+
2316+ scwReq := & scw.ScalewayRequest {
2317+ Method : "POST" ,
2318+ Path : "/webhosting/v1/regions/" + fmt .Sprint (req .Region ) + "/domains/" + fmt .Sprint (req .Domain ) + "/check-ownership" ,
2319+ }
2320+
2321+ err = scwReq .SetBody (req )
2322+ if err != nil {
2323+ return nil , err
2324+ }
2325+
2326+ var resp CheckUserOwnsDomainResponse
2327+
2328+ err = s .client .Do (scwReq , & resp , opts ... )
2329+ if err != nil {
2330+ return nil , err
2331+ }
2332+ return & resp , nil
2333+ }
2334+
20442335// This API allows you to manage your offer for your Web Hosting services.
20452336type OfferAPI struct {
20462337 client * scw.Client
0 commit comments