Skip to content

Commit

Permalink
feat(redis): add UpdateEndpointRequest and make tags nullable in Upda…
Browse files Browse the repository at this point in the history
…teClusterRequest (#1266)
  • Loading branch information
scaleway-bot authored May 31, 2022
1 parent 6daeac1 commit e581d26
Showing 1 changed file with 49 additions and 2 deletions.
51 changes: 49 additions & 2 deletions api/redis/v1alpha1/redis_sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ type Cluster struct {
// ACLRules: list of acl rules
ACLRules []*ACLRule `json:"acl_rules"`
// ClusterSize: number of nodes of the cluster
ClusterSize int32 `json:"cluster_size"`
ClusterSize uint32 `json:"cluster_size"`
// Zone: zone of the cluster
Zone scw.Zone `json:"zone"`
}
Expand Down Expand Up @@ -521,7 +521,7 @@ type UpdateClusterRequest struct {
// Name: name of the cluster
Name *string `json:"name"`
// Tags: tags of a given cluster
Tags []string `json:"tags"`
Tags *[]string `json:"tags"`
// UserName: name of the cluster user
UserName *string `json:"user_name"`
// Password: password of the cluster user
Expand Down Expand Up @@ -1510,6 +1510,53 @@ func (s *API) GetEndpoint(req *GetEndpointRequest, opts ...scw.RequestOption) (*
return &resp, nil
}

type UpdateEndpointRequest struct {
// Zone:
//
// Zone to target. If none is passed will use default zone from the config
Zone scw.Zone `json:"-"`

EndpointID string `json:"-"`

Endpoint *EndpointSpec `json:"endpoint"`
}

func (s *API) UpdateEndpoint(req *UpdateEndpointRequest, opts ...scw.RequestOption) (*Endpoint, error) {
var err error

if req.Zone == "" {
defaultZone, _ := s.client.GetDefaultZone()
req.Zone = defaultZone
}

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

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

scwReq := &scw.ScalewayRequest{
Method: "PATCH",
Path: "/redis/v1alpha1/zones/" + fmt.Sprint(req.Zone) + "/endpoints/" + fmt.Sprint(req.EndpointID) + "",
Headers: http.Header{},
}

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

var resp Endpoint

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

// UnsafeGetTotalCount should not be used
// Internal usage only
func (r *ListClustersResponse) UnsafeGetTotalCount() uint32 {
Expand Down

0 comments on commit e581d26

Please sign in to comment.