Skip to content

Commit

Permalink
[Refactor] Refactor Update functions
Browse files Browse the repository at this point in the history
  • Loading branch information
muneeb-jan committed Nov 27, 2024
1 parent e903611 commit b54177b
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 59 deletions.
1 change: 1 addition & 0 deletions openstack/cce/v3/clusters/Update.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func Update(client *golangsdk.ServiceClient, clusterId string, opts UpdateOpts)
return nil, err
}

// PUT /api/v3/projects/{project_id}/clusters/{cluster_id}
raw, err := client.Put(client.ServiceURL("clusters", clusterId), b, nil, &golangsdk.RequestOpts{
OkCodes: []int{200},
})
Expand Down
34 changes: 34 additions & 0 deletions openstack/cce/v3/clusters/UpdateMasterIP.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package clusters

import (
golangsdk "github.com/opentelekomcloud/gophertelekomcloud"
"github.com/opentelekomcloud/gophertelekomcloud/internal/build"
)

type UpdateIpOpts struct {
Action string `json:"action" required:"true"`
Spec IpSpec `json:"spec,omitempty"`
ElasticIp string `json:"elasticIp"`
}

type IpSpec struct {
ID string `json:"id" required:"true"`
}

// Update the access information of a specified cluster.
func UpdateMasterIp(client *golangsdk.ServiceClient, clusterId string, opts UpdateOpts) error {
b, err := build.RequestBody(opts, "")
if err != nil {
return err
}

// PUT /api/v3/projects/{project_id}/clusters/{cluster_id}/mastereip
_, err = client.Put(client.ServiceURL("clusters", clusterId, "mastereip"), b, nil, &golangsdk.RequestOpts{
OkCodes: []int{200},
})
if err != nil {
return err
}

return nil
}
36 changes: 0 additions & 36 deletions openstack/cce/v3/clusters/requests.go

This file was deleted.

6 changes: 0 additions & 6 deletions openstack/cce/v3/clusters/results.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,3 @@ func (r GetCertResult) ExtractMap() (map[string]interface{}, error) {
err := r.ExtractInto(&s)
return s, err
}

// UpdateIpResult represents the result of an update operation. Call its Extract
// method to interpret it as a Cluster.
type UpdateIpResult struct {
golangsdk.ErrResult
}
17 changes: 0 additions & 17 deletions openstack/cce/v3/clusters/urls.go

This file was deleted.

0 comments on commit b54177b

Please sign in to comment.