Skip to content

Commit

Permalink
feat(tem): add support for UpdateDomain (#2174)
Browse files Browse the repository at this point in the history
  • Loading branch information
scaleway-bot committed Aug 27, 2024
1 parent ba0daae commit f1b5ded
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions api/tem/v1alpha1/tem_sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -1347,6 +1347,18 @@ type Statistics struct {
CanceledCount uint32 `json:"canceled_count"`
}

// UpdateDomainRequest: update domain request.
type UpdateDomainRequest struct {
// Region: region to target. If none is passed will use default region from the config.
Region scw.Region `json:"-"`

// DomainID: ID of the domain to update.
DomainID string `json:"-"`

// Autoconfig: (Optional) If set to true, activate auto-configuration of the domain's DNS zone.
Autoconfig *bool `json:"autoconfig,omitempty"`
}

// UpdateWebhookRequest: update webhook request.
type UpdateWebhookRequest struct {
// Region: region to target. If none is passed will use default region from the config.
Expand Down Expand Up @@ -1781,6 +1793,42 @@ func (s *API) GetDomainLastStatus(req *GetDomainLastStatusRequest, opts ...scw.R
return &resp, nil
}

// UpdateDomain: Update a domain auto-configuration.
func (s *API) UpdateDomain(req *UpdateDomainRequest, opts ...scw.RequestOption) (*Domain, error) {
var err error

if req.Region == "" {
defaultRegion, _ := s.client.GetDefaultRegion()
req.Region = defaultRegion
}

if fmt.Sprint(req.Region) == "" {
return nil, errors.New("field Region cannot be empty in request")
}

if fmt.Sprint(req.DomainID) == "" {
return nil, errors.New("field DomainID cannot be empty in request")
}

scwReq := &scw.ScalewayRequest{
Method: "PATCH",
Path: "/transactional-email/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/domains/" + fmt.Sprint(req.DomainID) + "",
}

err = scwReq.SetBody(req)
if err != nil {
return nil, err
}

var resp Domain

err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}

// CreateWebhook: Create a new Webhook triggered by a list of event types and pushed to a Scaleway SNS ARN.
func (s *API) CreateWebhook(req *CreateWebhookRequest, opts ...scw.RequestOption) (*Webhook, error) {
var err error
Expand Down

0 comments on commit f1b5ded

Please sign in to comment.