github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/aom/v1/icagents/requests.go (about)

     1  package icagents
     2  
     3  import (
     4  	"github.com/huaweicloud/golangsdk"
     5  )
     6  
     7  type CreateOptsBuilder interface {
     8  	ToIcAgentIstallMap() (map[string]interface{}, error)
     9  }
    10  
    11  // Installing parameters for ICagent in cce cluster
    12  type InstallParam struct {
    13  	// The ID of Cluster
    14  	ClusterId string `json:"clusterId" required:"true"`
    15  	// Namespace for agent
    16  	NameSpace string `json:"nameSpace" required:"true"`
    17  }
    18  
    19  // ToIcAgentIstallMap builds a create request body from InstallParam.
    20  func (installParam InstallParam) ToIcAgentIstallMap() (map[string]interface{}, error) {
    21  	return golangsdk.BuildRequestBody(installParam, "")
    22  }
    23  
    24  // Create accepts a CreateOpts struct and uses the values to intall ic agent in cluster.
    25  func Create(c *golangsdk.ServiceClient, opts CreateOptsBuilder) (r CreateResult) {
    26  	b, err := opts.ToIcAgentIstallMap()
    27  	if err != nil {
    28  		r.Err = err
    29  		return
    30  	}
    31  	reqOpt := &golangsdk.RequestOpts{OkCodes: []int{200}}
    32  	_, r.Err = c.Post(rootURL(c), b, &r.Body, reqOpt)
    33  	return
    34  }