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
34 changes: 34 additions & 0 deletions openstack/aom/v1/icagents/requests.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package icagents

import (
"github.com/huaweicloud/golangsdk"
)

type CreateOptsBuilder interface {
ToIcAgentIstallMap() (map[string]interface{}, error)
}

// Installing parameters for ICagent in cce cluster
type InstallParam struct {
// The ID of Cluster
ClusterId string `json:"clusterId" required:"true"`
// Namespace for agent
NameSpace string `json:"nameSpace" required:"true"`
}

// ToIcAgentIstallMap builds a create request body from InstallParam.
func (installParam InstallParam) ToIcAgentIstallMap() (map[string]interface{}, error) {
return golangsdk.BuildRequestBody(installParam, "")
}

// Create accepts a CreateOpts struct and uses the values to intall ic agent in cluster.
func Create(c *golangsdk.ServiceClient, opts CreateOptsBuilder) (r CreateResult) {
b, err := opts.ToIcAgentIstallMap()
if err != nil {
r.Err = err
return
}
reqOpt := &golangsdk.RequestOpts{OkCodes: []int{200}}
_, r.Err = c.Post(rootURL(c), b, &r.Body, reqOpt)
return
}
12 changes: 12 additions & 0 deletions openstack/aom/v1/icagents/results.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package icagents

import (
"github.com/huaweicloud/golangsdk"
)

type commonResult struct {
golangsdk.Result
}
type CreateResult struct {
commonResult
}
11 changes: 11 additions & 0 deletions openstack/aom/v1/icagents/urls.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package icagents

import "github.com/huaweicloud/golangsdk"

const (
rootPath = "agents"
)

func rootURL(client *golangsdk.ServiceClient) string {
return client.ServiceURL(rootPath)
}