Skip to content

Commit 35c11c7

Browse files
feat(webhosting): add support for SyncDomainDNSRecords (scaleway#2366)
Co-authored-by: Rémy Léone <[email protected]>
1 parent 4db71e9 commit 35c11c7

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

api/webhosting/v1/webhosting_sdk.go

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,14 @@ type OfferOptionRequest struct {
758758
Quantity int64 `json:"quantity"`
759759
}
760760

761+
// SyncDomainDNSRecordsRequestRecord: sync domain dns records request record.
762+
type SyncDomainDNSRecordsRequestRecord struct {
763+
Name string `json:"name"`
764+
765+
// Type: default value: unknown_type
766+
Type DNSRecordType `json:"type"`
767+
}
768+
761769
// DNSRecord: dns record.
762770
type DNSRecord struct {
763771
// Name: record name.
@@ -989,6 +997,27 @@ type DNSAPIGetDomainDNSRecordsRequest struct {
989997
Domain string `json:"-"`
990998
}
991999

1000+
// DNSAPISyncDomainDNSRecordsRequest: dnsapi sync domain dns records request.
1001+
type DNSAPISyncDomainDNSRecordsRequest struct {
1002+
// Region: region to target. If none is passed will use default region from the config.
1003+
Region scw.Region `json:"-"`
1004+
1005+
// Domain: domain for which the DNS records will be synchronized.
1006+
Domain string `json:"-"`
1007+
1008+
// UpdateWebRecords: whether or not to synchronize the web records.
1009+
UpdateWebRecords bool `json:"update_web_records"`
1010+
1011+
// UpdateMailRecords: whether or not to synchronize the mail records.
1012+
UpdateMailRecords bool `json:"update_mail_records"`
1013+
1014+
// UpdateAllRecords: whether or not to synchronize all types of records. This one has priority.
1015+
UpdateAllRecords bool `json:"update_all_records"`
1016+
1017+
// CustomRecords: custom records to synchronize.
1018+
CustomRecords []*SyncDomainDNSRecordsRequestRecord `json:"custom_records"`
1019+
}
1020+
9921021
// DNSRecords: dns records.
9931022
type DNSRecords struct {
9941023
// Records: list of DNS records.
@@ -2354,6 +2383,42 @@ func (s *DnsAPI) CheckUserOwnsDomain(req *DNSAPICheckUserOwnsDomainRequest, opts
23542383
return &resp, nil
23552384
}
23562385

2386+
// SyncDomainDNSRecords: "Synchronize your DNS records on the Elements Console and on cPanel.".
2387+
func (s *DnsAPI) SyncDomainDNSRecords(req *DNSAPISyncDomainDNSRecordsRequest, opts ...scw.RequestOption) (*DNSRecords, error) {
2388+
var err error
2389+
2390+
if req.Region == "" {
2391+
defaultRegion, _ := s.client.GetDefaultRegion()
2392+
req.Region = defaultRegion
2393+
}
2394+
2395+
if fmt.Sprint(req.Region) == "" {
2396+
return nil, errors.New("field Region cannot be empty in request")
2397+
}
2398+
2399+
if fmt.Sprint(req.Domain) == "" {
2400+
return nil, errors.New("field Domain cannot be empty in request")
2401+
}
2402+
2403+
scwReq := &scw.ScalewayRequest{
2404+
Method: "POST",
2405+
Path: "/webhosting/v1/regions/" + fmt.Sprint(req.Region) + "/domains/" + fmt.Sprint(req.Domain) + "/sync-domain-dns-records",
2406+
}
2407+
2408+
err = scwReq.SetBody(req)
2409+
if err != nil {
2410+
return nil, err
2411+
}
2412+
2413+
var resp DNSRecords
2414+
2415+
err = s.client.Do(scwReq, &resp, opts...)
2416+
if err != nil {
2417+
return nil, err
2418+
}
2419+
return &resp, nil
2420+
}
2421+
23572422
// This API allows you to manage your offer for your Web Hosting services.
23582423
type OfferAPI struct {
23592424
client *scw.Client

0 commit comments

Comments
 (0)