Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions openstack/cce/v3/clusters/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,34 @@ func Delete(c *golangsdk.ServiceClient, id string) (r DeleteResult) {
})
return
}

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"`
}

type UpdateIpOptsBuilder interface {
ToMasterIpUpdateMap() (map[string]interface{}, error)
}

func (opts UpdateIpOpts) ToMasterIpUpdateMap() (map[string]interface{}, error) {
return golangsdk.BuildRequestBody(opts, "spec")
}

// Update the access information of a specified cluster.
func UpdateMasterIp(c *golangsdk.ServiceClient, id string, opts UpdateIpOptsBuilder) (r UpdateIpResult) {
b, err := opts.ToMasterIpUpdateMap()
if err != nil {
r.Err = err
return
}
_, r.Err = c.Put(masterIpURL(c, id), b, &r.Body, &golangsdk.RequestOpts{
OkCodes: []int{200},
})
return
}
6 changes: 6 additions & 0 deletions openstack/cce/v3/clusters/results.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,3 +287,9 @@ func (r GetCertResult) Extract() (*Certificate, 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
}
9 changes: 7 additions & 2 deletions openstack/cce/v3/clusters/urls.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package clusters
import "github.com/huaweicloud/golangsdk"

const (
rootPath = "clusters"
certPath = "clustercert"
rootPath = "clusters"
certPath = "clustercert"
masterIpPath = "mastereip"
)

func rootURL(client *golangsdk.ServiceClient) string {
Expand All @@ -18,3 +19,7 @@ func resourceURL(c *golangsdk.ServiceClient, id string) string {
func certificateURL(c *golangsdk.ServiceClient, id string) string {
return c.ServiceURL(rootPath, id, certPath)
}

func masterIpURL(c *golangsdk.ServiceClient, id string) string {
return c.ServiceURL(rootPath, id, masterIpPath)
}