packer-cn/vendor/github.com/xanzy/go-cloudstack/cloudstack/AutoScaleService.go

2805 lines
68 KiB
Go
Raw Normal View History

2016-10-07 10:39:28 -04:00
//
// Copyright 2018, Sander van Harmelen
2016-10-07 10:39:28 -04:00
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package cloudstack
import (
"encoding/json"
"fmt"
"net/url"
"strconv"
"strings"
)
type CreateAutoScalePolicyParams struct {
2016-10-07 10:39:28 -04:00
p map[string]interface{}
}
func (p *CreateAutoScalePolicyParams) toURLValues() url.Values {
2016-10-07 10:39:28 -04:00
u := url.Values{}
if p.p == nil {
return u
}
if v, found := p.p["action"]; found {
u.Set("action", v.(string))
2016-10-07 10:39:28 -04:00
}
if v, found := p.p["conditionids"]; found {
vv := strings.Join(v.([]string), ",")
u.Set("conditionids", vv)
2016-10-07 10:39:28 -04:00
}
if v, found := p.p["duration"]; found {
vv := strconv.Itoa(v.(int))
u.Set("duration", vv)
}
if v, found := p.p["quiettime"]; found {
vv := strconv.Itoa(v.(int))
u.Set("quiettime", vv)
2016-10-07 10:39:28 -04:00
}
return u
}
func (p *CreateAutoScalePolicyParams) SetAction(v string) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["action"] = v
2016-10-07 10:39:28 -04:00
return
}
func (p *CreateAutoScalePolicyParams) SetConditionids(v []string) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["conditionids"] = v
2016-10-07 10:39:28 -04:00
return
}
func (p *CreateAutoScalePolicyParams) SetDuration(v int) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["duration"] = v
2016-10-07 10:39:28 -04:00
return
}
func (p *CreateAutoScalePolicyParams) SetQuiettime(v int) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["quiettime"] = v
return
}
// You should always use this function to get a new CreateAutoScalePolicyParams instance,
2016-10-07 10:39:28 -04:00
// as then you are sure you have configured all required params
func (s *AutoScaleService) NewCreateAutoScalePolicyParams(action string, conditionids []string, duration int) *CreateAutoScalePolicyParams {
p := &CreateAutoScalePolicyParams{}
2016-10-07 10:39:28 -04:00
p.p = make(map[string]interface{})
p.p["action"] = action
p.p["conditionids"] = conditionids
p.p["duration"] = duration
2016-10-07 10:39:28 -04:00
return p
}
// Creates an autoscale policy for a provision or deprovision action, the action is taken when the all the conditions evaluates to true for the specified duration. The policy is in effect once it is attached to a autscale vm group.
func (s *AutoScaleService) CreateAutoScalePolicy(p *CreateAutoScalePolicyParams) (*CreateAutoScalePolicyResponse, error) {
resp, err := s.cs.newRequest("createAutoScalePolicy", p.toURLValues())
2016-10-07 10:39:28 -04:00
if err != nil {
return nil, err
}
var r CreateAutoScalePolicyResponse
2016-10-07 10:39:28 -04:00
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
// If we have a async client, we need to wait for the async result
if s.cs.async {
b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
if err != nil {
if err == AsyncTimeoutErr {
return &r, err
}
return nil, err
}
b, err = getRawValue(b)
if err != nil {
return nil, err
}
if err := json.Unmarshal(b, &r); err != nil {
return nil, err
}
}
2016-10-07 10:39:28 -04:00
return &r, nil
}
type CreateAutoScalePolicyResponse struct {
Account string `json:"account"`
Action string `json:"action"`
Conditions []string `json:"conditions"`
Domain string `json:"domain"`
Domainid string `json:"domainid"`
Duration int `json:"duration"`
Id string `json:"id"`
2019-05-26 05:58:26 -04:00
JobID string `json:"jobid"`
Jobstatus int `json:"jobstatus"`
Project string `json:"project"`
Projectid string `json:"projectid"`
Quiettime int `json:"quiettime"`
2016-10-07 10:39:28 -04:00
}
type CreateAutoScaleVmGroupParams struct {
2016-10-07 10:39:28 -04:00
p map[string]interface{}
}
func (p *CreateAutoScaleVmGroupParams) toURLValues() url.Values {
2016-10-07 10:39:28 -04:00
u := url.Values{}
if p.p == nil {
return u
}
if v, found := p.p["fordisplay"]; found {
vv := strconv.FormatBool(v.(bool))
u.Set("fordisplay", vv)
2016-10-07 10:39:28 -04:00
}
if v, found := p.p["interval"]; found {
vv := strconv.Itoa(v.(int))
u.Set("interval", vv)
2016-10-07 10:39:28 -04:00
}
if v, found := p.p["lbruleid"]; found {
u.Set("lbruleid", v.(string))
2016-10-07 10:39:28 -04:00
}
if v, found := p.p["maxmembers"]; found {
vv := strconv.Itoa(v.(int))
u.Set("maxmembers", vv)
2016-10-07 10:39:28 -04:00
}
if v, found := p.p["minmembers"]; found {
vv := strconv.Itoa(v.(int))
u.Set("minmembers", vv)
2016-10-07 10:39:28 -04:00
}
if v, found := p.p["scaledownpolicyids"]; found {
vv := strings.Join(v.([]string), ",")
u.Set("scaledownpolicyids", vv)
2016-10-07 10:39:28 -04:00
}
if v, found := p.p["scaleuppolicyids"]; found {
vv := strings.Join(v.([]string), ",")
u.Set("scaleuppolicyids", vv)
}
if v, found := p.p["vmprofileid"]; found {
u.Set("vmprofileid", v.(string))
}
return u
2016-10-07 10:39:28 -04:00
}
func (p *CreateAutoScaleVmGroupParams) SetFordisplay(v bool) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["fordisplay"] = v
2016-10-07 10:39:28 -04:00
return
}
func (p *CreateAutoScaleVmGroupParams) SetInterval(v int) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["interval"] = v
2016-10-07 10:39:28 -04:00
return
}
func (p *CreateAutoScaleVmGroupParams) SetLbruleid(v string) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["lbruleid"] = v
2016-10-07 10:39:28 -04:00
return
}
func (p *CreateAutoScaleVmGroupParams) SetMaxmembers(v int) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["maxmembers"] = v
2016-10-07 10:39:28 -04:00
return
}
func (p *CreateAutoScaleVmGroupParams) SetMinmembers(v int) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["minmembers"] = v
2016-10-07 10:39:28 -04:00
return
}
func (p *CreateAutoScaleVmGroupParams) SetScaledownpolicyids(v []string) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["scaledownpolicyids"] = v
2016-10-07 10:39:28 -04:00
return
}
func (p *CreateAutoScaleVmGroupParams) SetScaleuppolicyids(v []string) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["scaleuppolicyids"] = v
2016-10-07 10:39:28 -04:00
return
}
func (p *CreateAutoScaleVmGroupParams) SetVmprofileid(v string) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["vmprofileid"] = v
2016-10-07 10:39:28 -04:00
return
}
// You should always use this function to get a new CreateAutoScaleVmGroupParams instance,
2016-10-07 10:39:28 -04:00
// as then you are sure you have configured all required params
func (s *AutoScaleService) NewCreateAutoScaleVmGroupParams(lbruleid string, maxmembers int, minmembers int, scaledownpolicyids []string, scaleuppolicyids []string, vmprofileid string) *CreateAutoScaleVmGroupParams {
p := &CreateAutoScaleVmGroupParams{}
2016-10-07 10:39:28 -04:00
p.p = make(map[string]interface{})
p.p["lbruleid"] = lbruleid
p.p["maxmembers"] = maxmembers
p.p["minmembers"] = minmembers
p.p["scaledownpolicyids"] = scaledownpolicyids
p.p["scaleuppolicyids"] = scaleuppolicyids
p.p["vmprofileid"] = vmprofileid
2016-10-07 10:39:28 -04:00
return p
}
// Creates and automatically starts a virtual machine based on a service offering, disk offering, and template.
func (s *AutoScaleService) CreateAutoScaleVmGroup(p *CreateAutoScaleVmGroupParams) (*CreateAutoScaleVmGroupResponse, error) {
resp, err := s.cs.newRequest("createAutoScaleVmGroup", p.toURLValues())
2016-10-07 10:39:28 -04:00
if err != nil {
return nil, err
}
var r CreateAutoScaleVmGroupResponse
2016-10-07 10:39:28 -04:00
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
// If we have a async client, we need to wait for the async result
if s.cs.async {
b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
if err != nil {
if err == AsyncTimeoutErr {
return &r, err
}
return nil, err
}
b, err = getRawValue(b)
if err != nil {
return nil, err
}
if err := json.Unmarshal(b, &r); err != nil {
return nil, err
}
}
2016-10-07 10:39:28 -04:00
return &r, nil
}
type CreateAutoScaleVmGroupResponse struct {
Account string `json:"account"`
Domain string `json:"domain"`
Domainid string `json:"domainid"`
Fordisplay bool `json:"fordisplay"`
Id string `json:"id"`
Interval int `json:"interval"`
2019-05-26 05:58:26 -04:00
JobID string `json:"jobid"`
Jobstatus int `json:"jobstatus"`
Lbruleid string `json:"lbruleid"`
Maxmembers int `json:"maxmembers"`
Minmembers int `json:"minmembers"`
Project string `json:"project"`
Projectid string `json:"projectid"`
Scaledownpolicies []string `json:"scaledownpolicies"`
Scaleuppolicies []string `json:"scaleuppolicies"`
State string `json:"state"`
Vmprofileid string `json:"vmprofileid"`
2016-10-07 10:39:28 -04:00
}
type CreateAutoScaleVmProfileParams struct {
p map[string]interface{}
}
func (p *CreateAutoScaleVmProfileParams) toURLValues() url.Values {
u := url.Values{}
if p.p == nil {
return u
}
if v, found := p.p["autoscaleuserid"]; found {
u.Set("autoscaleuserid", v.(string))
}
if v, found := p.p["counterparam"]; found {
i := 0
for k, vv := range v.(map[string]string) {
u.Set(fmt.Sprintf("counterparam[%d].key", i), k)
u.Set(fmt.Sprintf("counterparam[%d].value", i), vv)
i++
}
}
if v, found := p.p["destroyvmgraceperiod"]; found {
vv := strconv.Itoa(v.(int))
u.Set("destroyvmgraceperiod", vv)
}
if v, found := p.p["fordisplay"]; found {
vv := strconv.FormatBool(v.(bool))
u.Set("fordisplay", vv)
}
if v, found := p.p["otherdeployparams"]; found {
u.Set("otherdeployparams", v.(string))
}
if v, found := p.p["serviceofferingid"]; found {
u.Set("serviceofferingid", v.(string))
}
if v, found := p.p["templateid"]; found {
u.Set("templateid", v.(string))
}
if v, found := p.p["zoneid"]; found {
u.Set("zoneid", v.(string))
}
return u
}
func (p *CreateAutoScaleVmProfileParams) SetAutoscaleuserid(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["autoscaleuserid"] = v
return
}
func (p *CreateAutoScaleVmProfileParams) SetCounterparam(v map[string]string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["counterparam"] = v
return
}
func (p *CreateAutoScaleVmProfileParams) SetDestroyvmgraceperiod(v int) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["destroyvmgraceperiod"] = v
return
}
func (p *CreateAutoScaleVmProfileParams) SetFordisplay(v bool) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["fordisplay"] = v
return
}
func (p *CreateAutoScaleVmProfileParams) SetOtherdeployparams(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["otherdeployparams"] = v
return
}
func (p *CreateAutoScaleVmProfileParams) SetServiceofferingid(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["serviceofferingid"] = v
return
}
func (p *CreateAutoScaleVmProfileParams) SetTemplateid(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["templateid"] = v
return
}
func (p *CreateAutoScaleVmProfileParams) SetZoneid(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["zoneid"] = v
return
}
// You should always use this function to get a new CreateAutoScaleVmProfileParams instance,
// as then you are sure you have configured all required params
func (s *AutoScaleService) NewCreateAutoScaleVmProfileParams(serviceofferingid string, templateid string, zoneid string) *CreateAutoScaleVmProfileParams {
p := &CreateAutoScaleVmProfileParams{}
p.p = make(map[string]interface{})
p.p["serviceofferingid"] = serviceofferingid
p.p["templateid"] = templateid
p.p["zoneid"] = zoneid
return p
}
// Creates a profile that contains information about the virtual machine which will be provisioned automatically by autoscale feature.
func (s *AutoScaleService) CreateAutoScaleVmProfile(p *CreateAutoScaleVmProfileParams) (*CreateAutoScaleVmProfileResponse, error) {
resp, err := s.cs.newRequest("createAutoScaleVmProfile", p.toURLValues())
if err != nil {
return nil, err
}
var r CreateAutoScaleVmProfileResponse
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
// If we have a async client, we need to wait for the async result
if s.cs.async {
b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
if err != nil {
if err == AsyncTimeoutErr {
return &r, err
}
return nil, err
}
b, err = getRawValue(b)
if err != nil {
return nil, err
}
if err := json.Unmarshal(b, &r); err != nil {
return nil, err
}
}
2016-10-07 10:39:28 -04:00
return &r, nil
}
type CreateAutoScaleVmProfileResponse struct {
Account string `json:"account"`
Autoscaleuserid string `json:"autoscaleuserid"`
Destroyvmgraceperiod int `json:"destroyvmgraceperiod"`
Domain string `json:"domain"`
Domainid string `json:"domainid"`
Fordisplay bool `json:"fordisplay"`
Id string `json:"id"`
2019-05-26 05:58:26 -04:00
JobID string `json:"jobid"`
Jobstatus int `json:"jobstatus"`
Otherdeployparams string `json:"otherdeployparams"`
Project string `json:"project"`
Projectid string `json:"projectid"`
Serviceofferingid string `json:"serviceofferingid"`
Templateid string `json:"templateid"`
Zoneid string `json:"zoneid"`
2016-10-07 10:39:28 -04:00
}
type CreateConditionParams struct {
2016-10-07 10:39:28 -04:00
p map[string]interface{}
}
func (p *CreateConditionParams) toURLValues() url.Values {
2016-10-07 10:39:28 -04:00
u := url.Values{}
if p.p == nil {
return u
}
if v, found := p.p["account"]; found {
u.Set("account", v.(string))
2016-10-07 10:39:28 -04:00
}
if v, found := p.p["counterid"]; found {
u.Set("counterid", v.(string))
2016-10-07 10:39:28 -04:00
}
if v, found := p.p["domainid"]; found {
u.Set("domainid", v.(string))
2016-10-07 10:39:28 -04:00
}
if v, found := p.p["relationaloperator"]; found {
u.Set("relationaloperator", v.(string))
2016-10-07 10:39:28 -04:00
}
if v, found := p.p["threshold"]; found {
vv := strconv.FormatInt(v.(int64), 10)
u.Set("threshold", vv)
2016-10-07 10:39:28 -04:00
}
return u
}
func (p *CreateConditionParams) SetAccount(v string) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["account"] = v
2016-10-07 10:39:28 -04:00
return
}
func (p *CreateConditionParams) SetCounterid(v string) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["counterid"] = v
2016-10-07 10:39:28 -04:00
return
}
func (p *CreateConditionParams) SetDomainid(v string) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["domainid"] = v
2016-10-07 10:39:28 -04:00
return
}
func (p *CreateConditionParams) SetRelationaloperator(v string) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["relationaloperator"] = v
2016-10-07 10:39:28 -04:00
return
}
func (p *CreateConditionParams) SetThreshold(v int64) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["threshold"] = v
2016-10-07 10:39:28 -04:00
return
}
// You should always use this function to get a new CreateConditionParams instance,
2016-10-07 10:39:28 -04:00
// as then you are sure you have configured all required params
func (s *AutoScaleService) NewCreateConditionParams(counterid string, relationaloperator string, threshold int64) *CreateConditionParams {
p := &CreateConditionParams{}
2016-10-07 10:39:28 -04:00
p.p = make(map[string]interface{})
p.p["counterid"] = counterid
p.p["relationaloperator"] = relationaloperator
p.p["threshold"] = threshold
2016-10-07 10:39:28 -04:00
return p
}
// Creates a condition
func (s *AutoScaleService) CreateCondition(p *CreateConditionParams) (*CreateConditionResponse, error) {
resp, err := s.cs.newRequest("createCondition", p.toURLValues())
2016-10-07 10:39:28 -04:00
if err != nil {
return nil, err
}
var r CreateConditionResponse
2016-10-07 10:39:28 -04:00
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
// If we have a async client, we need to wait for the async result
if s.cs.async {
b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
if err != nil {
if err == AsyncTimeoutErr {
return &r, err
}
return nil, err
}
b, err = getRawValue(b)
if err != nil {
return nil, err
}
if err := json.Unmarshal(b, &r); err != nil {
return nil, err
}
}
2016-10-07 10:39:28 -04:00
return &r, nil
}
type CreateConditionResponse struct {
Account string `json:"account"`
Counter []string `json:"counter"`
Domain string `json:"domain"`
Domainid string `json:"domainid"`
Id string `json:"id"`
2019-05-26 05:58:26 -04:00
JobID string `json:"jobid"`
Jobstatus int `json:"jobstatus"`
Project string `json:"project"`
Projectid string `json:"projectid"`
Relationaloperator string `json:"relationaloperator"`
Threshold int64 `json:"threshold"`
Zoneid string `json:"zoneid"`
2016-10-07 10:39:28 -04:00
}
type CreateCounterParams struct {
2016-10-07 10:39:28 -04:00
p map[string]interface{}
}
func (p *CreateCounterParams) toURLValues() url.Values {
2016-10-07 10:39:28 -04:00
u := url.Values{}
if p.p == nil {
return u
}
if v, found := p.p["name"]; found {
u.Set("name", v.(string))
}
if v, found := p.p["source"]; found {
u.Set("source", v.(string))
}
if v, found := p.p["value"]; found {
u.Set("value", v.(string))
2016-10-07 10:39:28 -04:00
}
return u
}
func (p *CreateCounterParams) SetName(v string) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["name"] = v
2016-10-07 10:39:28 -04:00
return
}
func (p *CreateCounterParams) SetSource(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["source"] = v
return
}
func (p *CreateCounterParams) SetValue(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["value"] = v
return
}
// You should always use this function to get a new CreateCounterParams instance,
2016-10-07 10:39:28 -04:00
// as then you are sure you have configured all required params
func (s *AutoScaleService) NewCreateCounterParams(name string, source string, value string) *CreateCounterParams {
p := &CreateCounterParams{}
2016-10-07 10:39:28 -04:00
p.p = make(map[string]interface{})
p.p["name"] = name
p.p["source"] = source
p.p["value"] = value
2016-10-07 10:39:28 -04:00
return p
}
// Adds metric counter
func (s *AutoScaleService) CreateCounter(p *CreateCounterParams) (*CreateCounterResponse, error) {
resp, err := s.cs.newRequest("createCounter", p.toURLValues())
2016-10-07 10:39:28 -04:00
if err != nil {
return nil, err
}
var r CreateCounterResponse
2016-10-07 10:39:28 -04:00
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
// If we have a async client, we need to wait for the async result
if s.cs.async {
b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
if err != nil {
if err == AsyncTimeoutErr {
return &r, err
}
return nil, err
}
b, err = getRawValue(b)
if err != nil {
return nil, err
}
2016-10-07 10:39:28 -04:00
if err := json.Unmarshal(b, &r); err != nil {
return nil, err
}
}
2016-10-07 10:39:28 -04:00
return &r, nil
}
type CreateCounterResponse struct {
2019-05-26 05:58:26 -04:00
Id string `json:"id"`
JobID string `json:"jobid"`
Jobstatus int `json:"jobstatus"`
Name string `json:"name"`
Source string `json:"source"`
Value string `json:"value"`
Zoneid string `json:"zoneid"`
2016-10-07 10:39:28 -04:00
}
type DeleteAutoScalePolicyParams struct {
2016-10-07 10:39:28 -04:00
p map[string]interface{}
}
func (p *DeleteAutoScalePolicyParams) toURLValues() url.Values {
2016-10-07 10:39:28 -04:00
u := url.Values{}
if p.p == nil {
return u
}
if v, found := p.p["id"]; found {
u.Set("id", v.(string))
}
return u
}
func (p *DeleteAutoScalePolicyParams) SetId(v string) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["id"] = v
return
}
// You should always use this function to get a new DeleteAutoScalePolicyParams instance,
2016-10-07 10:39:28 -04:00
// as then you are sure you have configured all required params
func (s *AutoScaleService) NewDeleteAutoScalePolicyParams(id string) *DeleteAutoScalePolicyParams {
p := &DeleteAutoScalePolicyParams{}
2016-10-07 10:39:28 -04:00
p.p = make(map[string]interface{})
p.p["id"] = id
return p
}
// Deletes a autoscale policy.
func (s *AutoScaleService) DeleteAutoScalePolicy(p *DeleteAutoScalePolicyParams) (*DeleteAutoScalePolicyResponse, error) {
resp, err := s.cs.newRequest("deleteAutoScalePolicy", p.toURLValues())
2016-10-07 10:39:28 -04:00
if err != nil {
return nil, err
}
var r DeleteAutoScalePolicyResponse
2016-10-07 10:39:28 -04:00
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
// If we have a async client, we need to wait for the async result
if s.cs.async {
b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
if err != nil {
if err == AsyncTimeoutErr {
return &r, err
}
return nil, err
}
if err := json.Unmarshal(b, &r); err != nil {
return nil, err
}
}
2016-10-07 10:39:28 -04:00
return &r, nil
}
type DeleteAutoScalePolicyResponse struct {
Displaytext string `json:"displaytext"`
2019-05-26 05:58:26 -04:00
JobID string `json:"jobid"`
Jobstatus int `json:"jobstatus"`
Success bool `json:"success"`
2016-10-07 10:39:28 -04:00
}
type DeleteAutoScaleVmGroupParams struct {
2016-10-07 10:39:28 -04:00
p map[string]interface{}
}
func (p *DeleteAutoScaleVmGroupParams) toURLValues() url.Values {
2016-10-07 10:39:28 -04:00
u := url.Values{}
if p.p == nil {
return u
}
if v, found := p.p["id"]; found {
u.Set("id", v.(string))
}
return u
}
func (p *DeleteAutoScaleVmGroupParams) SetId(v string) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["id"] = v
return
}
// You should always use this function to get a new DeleteAutoScaleVmGroupParams instance,
2016-10-07 10:39:28 -04:00
// as then you are sure you have configured all required params
func (s *AutoScaleService) NewDeleteAutoScaleVmGroupParams(id string) *DeleteAutoScaleVmGroupParams {
p := &DeleteAutoScaleVmGroupParams{}
2016-10-07 10:39:28 -04:00
p.p = make(map[string]interface{})
p.p["id"] = id
return p
}
// Deletes a autoscale vm group.
func (s *AutoScaleService) DeleteAutoScaleVmGroup(p *DeleteAutoScaleVmGroupParams) (*DeleteAutoScaleVmGroupResponse, error) {
resp, err := s.cs.newRequest("deleteAutoScaleVmGroup", p.toURLValues())
2016-10-07 10:39:28 -04:00
if err != nil {
return nil, err
}
var r DeleteAutoScaleVmGroupResponse
2016-10-07 10:39:28 -04:00
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
// If we have a async client, we need to wait for the async result
if s.cs.async {
b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
if err != nil {
if err == AsyncTimeoutErr {
return &r, err
}
return nil, err
}
if err := json.Unmarshal(b, &r); err != nil {
return nil, err
}
}
2016-10-07 10:39:28 -04:00
return &r, nil
}
type DeleteAutoScaleVmGroupResponse struct {
Displaytext string `json:"displaytext"`
2019-05-26 05:58:26 -04:00
JobID string `json:"jobid"`
Jobstatus int `json:"jobstatus"`
Success bool `json:"success"`
2016-10-07 10:39:28 -04:00
}
type DeleteAutoScaleVmProfileParams struct {
p map[string]interface{}
}
func (p *DeleteAutoScaleVmProfileParams) toURLValues() url.Values {
u := url.Values{}
if p.p == nil {
return u
}
if v, found := p.p["id"]; found {
u.Set("id", v.(string))
}
return u
}
func (p *DeleteAutoScaleVmProfileParams) SetId(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["id"] = v
return
}
// You should always use this function to get a new DeleteAutoScaleVmProfileParams instance,
// as then you are sure you have configured all required params
func (s *AutoScaleService) NewDeleteAutoScaleVmProfileParams(id string) *DeleteAutoScaleVmProfileParams {
p := &DeleteAutoScaleVmProfileParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
return p
}
// Deletes a autoscale vm profile.
func (s *AutoScaleService) DeleteAutoScaleVmProfile(p *DeleteAutoScaleVmProfileParams) (*DeleteAutoScaleVmProfileResponse, error) {
resp, err := s.cs.newRequest("deleteAutoScaleVmProfile", p.toURLValues())
if err != nil {
return nil, err
}
var r DeleteAutoScaleVmProfileResponse
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
// If we have a async client, we need to wait for the async result
if s.cs.async {
b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
if err != nil {
if err == AsyncTimeoutErr {
return &r, err
}
return nil, err
}
if err := json.Unmarshal(b, &r); err != nil {
return nil, err
}
}
2016-10-07 10:39:28 -04:00
return &r, nil
}
type DeleteAutoScaleVmProfileResponse struct {
Displaytext string `json:"displaytext"`
2019-05-26 05:58:26 -04:00
JobID string `json:"jobid"`
Jobstatus int `json:"jobstatus"`
Success bool `json:"success"`
2016-10-07 10:39:28 -04:00
}
type DeleteConditionParams struct {
2016-10-07 10:39:28 -04:00
p map[string]interface{}
}
func (p *DeleteConditionParams) toURLValues() url.Values {
2016-10-07 10:39:28 -04:00
u := url.Values{}
if p.p == nil {
return u
}
if v, found := p.p["id"]; found {
u.Set("id", v.(string))
}
return u
}
func (p *DeleteConditionParams) SetId(v string) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["id"] = v
return
}
// You should always use this function to get a new DeleteConditionParams instance,
2016-10-07 10:39:28 -04:00
// as then you are sure you have configured all required params
func (s *AutoScaleService) NewDeleteConditionParams(id string) *DeleteConditionParams {
p := &DeleteConditionParams{}
2016-10-07 10:39:28 -04:00
p.p = make(map[string]interface{})
p.p["id"] = id
return p
}
// Removes a condition
func (s *AutoScaleService) DeleteCondition(p *DeleteConditionParams) (*DeleteConditionResponse, error) {
resp, err := s.cs.newRequest("deleteCondition", p.toURLValues())
2016-10-07 10:39:28 -04:00
if err != nil {
return nil, err
}
var r DeleteConditionResponse
2016-10-07 10:39:28 -04:00
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
// If we have a async client, we need to wait for the async result
if s.cs.async {
b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
if err != nil {
if err == AsyncTimeoutErr {
return &r, err
}
return nil, err
}
if err := json.Unmarshal(b, &r); err != nil {
return nil, err
}
}
2016-10-07 10:39:28 -04:00
return &r, nil
}
type DeleteConditionResponse struct {
Displaytext string `json:"displaytext"`
2019-05-26 05:58:26 -04:00
JobID string `json:"jobid"`
Jobstatus int `json:"jobstatus"`
Success bool `json:"success"`
2016-10-07 10:39:28 -04:00
}
type DeleteCounterParams struct {
2016-10-07 10:39:28 -04:00
p map[string]interface{}
}
func (p *DeleteCounterParams) toURLValues() url.Values {
2016-10-07 10:39:28 -04:00
u := url.Values{}
if p.p == nil {
return u
}
if v, found := p.p["id"]; found {
u.Set("id", v.(string))
}
return u
}
func (p *DeleteCounterParams) SetId(v string) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["id"] = v
return
}
// You should always use this function to get a new DeleteCounterParams instance,
// as then you are sure you have configured all required params
func (s *AutoScaleService) NewDeleteCounterParams(id string) *DeleteCounterParams {
p := &DeleteCounterParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
return p
2016-10-07 10:39:28 -04:00
}
// Deletes a counter
func (s *AutoScaleService) DeleteCounter(p *DeleteCounterParams) (*DeleteCounterResponse, error) {
resp, err := s.cs.newRequest("deleteCounter", p.toURLValues())
if err != nil {
return nil, err
2016-10-07 10:39:28 -04:00
}
var r DeleteCounterResponse
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
2016-10-07 10:39:28 -04:00
}
// If we have a async client, we need to wait for the async result
if s.cs.async {
b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
if err != nil {
if err == AsyncTimeoutErr {
return &r, err
}
return nil, err
}
if err := json.Unmarshal(b, &r); err != nil {
return nil, err
}
}
return &r, nil
2016-10-07 10:39:28 -04:00
}
type DeleteCounterResponse struct {
Displaytext string `json:"displaytext"`
2019-05-26 05:58:26 -04:00
JobID string `json:"jobid"`
Jobstatus int `json:"jobstatus"`
Success bool `json:"success"`
}
type DisableAutoScaleVmGroupParams struct {
p map[string]interface{}
}
func (p *DisableAutoScaleVmGroupParams) toURLValues() url.Values {
u := url.Values{}
2016-10-07 10:39:28 -04:00
if p.p == nil {
return u
2016-10-07 10:39:28 -04:00
}
if v, found := p.p["id"]; found {
u.Set("id", v.(string))
}
return u
2016-10-07 10:39:28 -04:00
}
func (p *DisableAutoScaleVmGroupParams) SetId(v string) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["id"] = v
2016-10-07 10:39:28 -04:00
return
}
// You should always use this function to get a new DisableAutoScaleVmGroupParams instance,
2016-10-07 10:39:28 -04:00
// as then you are sure you have configured all required params
func (s *AutoScaleService) NewDisableAutoScaleVmGroupParams(id string) *DisableAutoScaleVmGroupParams {
p := &DisableAutoScaleVmGroupParams{}
2016-10-07 10:39:28 -04:00
p.p = make(map[string]interface{})
p.p["id"] = id
2016-10-07 10:39:28 -04:00
return p
}
// Disables an AutoScale Vm Group
func (s *AutoScaleService) DisableAutoScaleVmGroup(p *DisableAutoScaleVmGroupParams) (*DisableAutoScaleVmGroupResponse, error) {
resp, err := s.cs.newRequest("disableAutoScaleVmGroup", p.toURLValues())
2016-10-07 10:39:28 -04:00
if err != nil {
return nil, err
2016-10-07 10:39:28 -04:00
}
var r DisableAutoScaleVmGroupResponse
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
2016-10-07 10:39:28 -04:00
}
// If we have a async client, we need to wait for the async result
if s.cs.async {
b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
if err != nil {
if err == AsyncTimeoutErr {
return &r, err
2016-10-07 10:39:28 -04:00
}
return nil, err
2016-10-07 10:39:28 -04:00
}
b, err = getRawValue(b)
if err != nil {
return nil, err
}
2016-10-07 10:39:28 -04:00
if err := json.Unmarshal(b, &r); err != nil {
return nil, err
}
2016-10-07 10:39:28 -04:00
}
return &r, nil
2016-10-07 10:39:28 -04:00
}
type DisableAutoScaleVmGroupResponse struct {
Account string `json:"account"`
Domain string `json:"domain"`
Domainid string `json:"domainid"`
Fordisplay bool `json:"fordisplay"`
Id string `json:"id"`
Interval int `json:"interval"`
2019-05-26 05:58:26 -04:00
JobID string `json:"jobid"`
Jobstatus int `json:"jobstatus"`
Lbruleid string `json:"lbruleid"`
Maxmembers int `json:"maxmembers"`
Minmembers int `json:"minmembers"`
Project string `json:"project"`
Projectid string `json:"projectid"`
Scaledownpolicies []string `json:"scaledownpolicies"`
Scaleuppolicies []string `json:"scaleuppolicies"`
State string `json:"state"`
Vmprofileid string `json:"vmprofileid"`
}
2016-10-07 10:39:28 -04:00
type EnableAutoScaleVmGroupParams struct {
p map[string]interface{}
}
2016-10-07 10:39:28 -04:00
func (p *EnableAutoScaleVmGroupParams) toURLValues() url.Values {
u := url.Values{}
if p.p == nil {
return u
2016-10-07 10:39:28 -04:00
}
if v, found := p.p["id"]; found {
u.Set("id", v.(string))
2016-10-07 10:39:28 -04:00
}
return u
}
2016-10-07 10:39:28 -04:00
func (p *EnableAutoScaleVmGroupParams) SetId(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
2016-10-07 10:39:28 -04:00
}
p.p["id"] = v
return
}
2016-10-07 10:39:28 -04:00
// You should always use this function to get a new EnableAutoScaleVmGroupParams instance,
// as then you are sure you have configured all required params
func (s *AutoScaleService) NewEnableAutoScaleVmGroupParams(id string) *EnableAutoScaleVmGroupParams {
p := &EnableAutoScaleVmGroupParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
return p
2016-10-07 10:39:28 -04:00
}
// Enables an AutoScale Vm Group
func (s *AutoScaleService) EnableAutoScaleVmGroup(p *EnableAutoScaleVmGroupParams) (*EnableAutoScaleVmGroupResponse, error) {
resp, err := s.cs.newRequest("enableAutoScaleVmGroup", p.toURLValues())
2016-10-07 10:39:28 -04:00
if err != nil {
return nil, err
}
var r EnableAutoScaleVmGroupResponse
2016-10-07 10:39:28 -04:00
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
// If we have a async client, we need to wait for the async result
if s.cs.async {
b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
if err != nil {
if err == AsyncTimeoutErr {
return &r, err
}
return nil, err
}
b, err = getRawValue(b)
if err != nil {
return nil, err
}
if err := json.Unmarshal(b, &r); err != nil {
return nil, err
}
}
return &r, nil
2016-10-07 10:39:28 -04:00
}
type EnableAutoScaleVmGroupResponse struct {
Account string `json:"account"`
Domain string `json:"domain"`
Domainid string `json:"domainid"`
Fordisplay bool `json:"fordisplay"`
Id string `json:"id"`
Interval int `json:"interval"`
2019-05-26 05:58:26 -04:00
JobID string `json:"jobid"`
Jobstatus int `json:"jobstatus"`
Lbruleid string `json:"lbruleid"`
Maxmembers int `json:"maxmembers"`
Minmembers int `json:"minmembers"`
Project string `json:"project"`
Projectid string `json:"projectid"`
Scaledownpolicies []string `json:"scaledownpolicies"`
Scaleuppolicies []string `json:"scaleuppolicies"`
State string `json:"state"`
Vmprofileid string `json:"vmprofileid"`
2016-10-07 10:39:28 -04:00
}
type ListAutoScalePoliciesParams struct {
2016-10-07 10:39:28 -04:00
p map[string]interface{}
}
func (p *ListAutoScalePoliciesParams) toURLValues() url.Values {
2016-10-07 10:39:28 -04:00
u := url.Values{}
if p.p == nil {
return u
}
if v, found := p.p["account"]; found {
u.Set("account", v.(string))
}
if v, found := p.p["action"]; found {
u.Set("action", v.(string))
}
if v, found := p.p["conditionid"]; found {
u.Set("conditionid", v.(string))
2016-10-07 10:39:28 -04:00
}
if v, found := p.p["domainid"]; found {
u.Set("domainid", v.(string))
}
if v, found := p.p["id"]; found {
u.Set("id", v.(string))
}
if v, found := p.p["isrecursive"]; found {
vv := strconv.FormatBool(v.(bool))
u.Set("isrecursive", vv)
}
if v, found := p.p["keyword"]; found {
u.Set("keyword", v.(string))
}
if v, found := p.p["listall"]; found {
vv := strconv.FormatBool(v.(bool))
u.Set("listall", vv)
}
if v, found := p.p["page"]; found {
vv := strconv.Itoa(v.(int))
u.Set("page", vv)
}
if v, found := p.p["pagesize"]; found {
vv := strconv.Itoa(v.(int))
u.Set("pagesize", vv)
}
if v, found := p.p["vmgroupid"]; found {
u.Set("vmgroupid", v.(string))
2016-10-07 10:39:28 -04:00
}
return u
}
func (p *ListAutoScalePoliciesParams) SetAccount(v string) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["account"] = v
return
}
func (p *ListAutoScalePoliciesParams) SetAction(v string) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["action"] = v
2016-10-07 10:39:28 -04:00
return
}
func (p *ListAutoScalePoliciesParams) SetConditionid(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["conditionid"] = v
return
}
func (p *ListAutoScalePoliciesParams) SetDomainid(v string) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["domainid"] = v
return
}
func (p *ListAutoScalePoliciesParams) SetId(v string) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["id"] = v
return
}
func (p *ListAutoScalePoliciesParams) SetIsrecursive(v bool) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["isrecursive"] = v
return
}
func (p *ListAutoScalePoliciesParams) SetKeyword(v string) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["keyword"] = v
return
}
func (p *ListAutoScalePoliciesParams) SetListall(v bool) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["listall"] = v
return
}
func (p *ListAutoScalePoliciesParams) SetPage(v int) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["page"] = v
return
}
func (p *ListAutoScalePoliciesParams) SetPagesize(v int) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["pagesize"] = v
return
}
func (p *ListAutoScalePoliciesParams) SetVmgroupid(v string) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["vmgroupid"] = v
2016-10-07 10:39:28 -04:00
return
}
// You should always use this function to get a new ListAutoScalePoliciesParams instance,
2016-10-07 10:39:28 -04:00
// as then you are sure you have configured all required params
func (s *AutoScaleService) NewListAutoScalePoliciesParams() *ListAutoScalePoliciesParams {
p := &ListAutoScalePoliciesParams{}
2016-10-07 10:39:28 -04:00
p.p = make(map[string]interface{})
return p
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *AutoScaleService) GetAutoScalePolicyByID(id string, opts ...OptionFunc) (*AutoScalePolicy, int, error) {
p := &ListAutoScalePoliciesParams{}
2016-10-07 10:39:28 -04:00
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range append(s.cs.options, opts...) {
2016-10-07 10:39:28 -04:00
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListAutoScalePolicies(p)
2016-10-07 10:39:28 -04:00
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
"Invalid parameter id value=%s due to incorrect long value format, "+
"or entity does not exist", id)) {
return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l)
}
return nil, -1, err
}
if l.Count == 0 {
return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l)
}
if l.Count == 1 {
return l.AutoScalePolicies[0], l.Count, nil
2016-10-07 10:39:28 -04:00
}
return nil, l.Count, fmt.Errorf("There is more then one result for AutoScalePolicy UUID: %s!", id)
2016-10-07 10:39:28 -04:00
}
// Lists autoscale policies.
func (s *AutoScaleService) ListAutoScalePolicies(p *ListAutoScalePoliciesParams) (*ListAutoScalePoliciesResponse, error) {
resp, err := s.cs.newRequest("listAutoScalePolicies", p.toURLValues())
2016-10-07 10:39:28 -04:00
if err != nil {
return nil, err
}
var r ListAutoScalePoliciesResponse
2016-10-07 10:39:28 -04:00
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
2016-10-07 10:39:28 -04:00
return &r, nil
}
type ListAutoScalePoliciesResponse struct {
Count int `json:"count"`
AutoScalePolicies []*AutoScalePolicy `json:"autoscalepolicy"`
2016-10-07 10:39:28 -04:00
}
type AutoScalePolicy struct {
Account string `json:"account"`
Action string `json:"action"`
Conditions []string `json:"conditions"`
Domain string `json:"domain"`
Domainid string `json:"domainid"`
Duration int `json:"duration"`
Id string `json:"id"`
2019-05-26 05:58:26 -04:00
JobID string `json:"jobid"`
Jobstatus int `json:"jobstatus"`
Project string `json:"project"`
Projectid string `json:"projectid"`
Quiettime int `json:"quiettime"`
2016-10-07 10:39:28 -04:00
}
type ListAutoScaleVmGroupsParams struct {
2016-10-07 10:39:28 -04:00
p map[string]interface{}
}
func (p *ListAutoScaleVmGroupsParams) toURLValues() url.Values {
2016-10-07 10:39:28 -04:00
u := url.Values{}
if p.p == nil {
return u
}
if v, found := p.p["account"]; found {
u.Set("account", v.(string))
}
if v, found := p.p["domainid"]; found {
u.Set("domainid", v.(string))
}
if v, found := p.p["fordisplay"]; found {
vv := strconv.FormatBool(v.(bool))
u.Set("fordisplay", vv)
}
2016-10-07 10:39:28 -04:00
if v, found := p.p["id"]; found {
u.Set("id", v.(string))
}
if v, found := p.p["isrecursive"]; found {
vv := strconv.FormatBool(v.(bool))
u.Set("isrecursive", vv)
}
if v, found := p.p["keyword"]; found {
u.Set("keyword", v.(string))
}
if v, found := p.p["lbruleid"]; found {
u.Set("lbruleid", v.(string))
}
2016-10-07 10:39:28 -04:00
if v, found := p.p["listall"]; found {
vv := strconv.FormatBool(v.(bool))
u.Set("listall", vv)
}
if v, found := p.p["page"]; found {
vv := strconv.Itoa(v.(int))
u.Set("page", vv)
}
if v, found := p.p["pagesize"]; found {
vv := strconv.Itoa(v.(int))
u.Set("pagesize", vv)
}
if v, found := p.p["policyid"]; found {
u.Set("policyid", v.(string))
}
if v, found := p.p["projectid"]; found {
u.Set("projectid", v.(string))
}
if v, found := p.p["vmprofileid"]; found {
u.Set("vmprofileid", v.(string))
}
if v, found := p.p["zoneid"]; found {
u.Set("zoneid", v.(string))
2016-10-07 10:39:28 -04:00
}
return u
}
func (p *ListAutoScaleVmGroupsParams) SetAccount(v string) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["account"] = v
return
}
func (p *ListAutoScaleVmGroupsParams) SetDomainid(v string) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["domainid"] = v
2016-10-07 10:39:28 -04:00
return
}
func (p *ListAutoScaleVmGroupsParams) SetFordisplay(v bool) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["fordisplay"] = v
2016-10-07 10:39:28 -04:00
return
}
func (p *ListAutoScaleVmGroupsParams) SetId(v string) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["id"] = v
2016-10-07 10:39:28 -04:00
return
}
func (p *ListAutoScaleVmGroupsParams) SetIsrecursive(v bool) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["isrecursive"] = v
2016-10-07 10:39:28 -04:00
return
}
func (p *ListAutoScaleVmGroupsParams) SetKeyword(v string) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["keyword"] = v
2016-10-07 10:39:28 -04:00
return
}
func (p *ListAutoScaleVmGroupsParams) SetLbruleid(v string) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["lbruleid"] = v
2016-10-07 10:39:28 -04:00
return
}
func (p *ListAutoScaleVmGroupsParams) SetListall(v bool) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["listall"] = v
return
}
func (p *ListAutoScaleVmGroupsParams) SetPage(v int) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["page"] = v
return
}
func (p *ListAutoScaleVmGroupsParams) SetPagesize(v int) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["pagesize"] = v
return
}
func (p *ListAutoScaleVmGroupsParams) SetPolicyid(v string) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["policyid"] = v
2016-10-07 10:39:28 -04:00
return
}
func (p *ListAutoScaleVmGroupsParams) SetProjectid(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["projectid"] = v
return
}
func (p *ListAutoScaleVmGroupsParams) SetVmprofileid(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["vmprofileid"] = v
return
}
func (p *ListAutoScaleVmGroupsParams) SetZoneid(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["zoneid"] = v
return
}
// You should always use this function to get a new ListAutoScaleVmGroupsParams instance,
2016-10-07 10:39:28 -04:00
// as then you are sure you have configured all required params
func (s *AutoScaleService) NewListAutoScaleVmGroupsParams() *ListAutoScaleVmGroupsParams {
p := &ListAutoScaleVmGroupsParams{}
2016-10-07 10:39:28 -04:00
p.p = make(map[string]interface{})
return p
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *AutoScaleService) GetAutoScaleVmGroupByID(id string, opts ...OptionFunc) (*AutoScaleVmGroup, int, error) {
p := &ListAutoScaleVmGroupsParams{}
2016-10-07 10:39:28 -04:00
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range append(s.cs.options, opts...) {
2016-10-07 10:39:28 -04:00
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListAutoScaleVmGroups(p)
2016-10-07 10:39:28 -04:00
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
"Invalid parameter id value=%s due to incorrect long value format, "+
"or entity does not exist", id)) {
return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l)
}
return nil, -1, err
}
if l.Count == 0 {
return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l)
}
if l.Count == 1 {
return l.AutoScaleVmGroups[0], l.Count, nil
2016-10-07 10:39:28 -04:00
}
return nil, l.Count, fmt.Errorf("There is more then one result for AutoScaleVmGroup UUID: %s!", id)
2016-10-07 10:39:28 -04:00
}
// Lists autoscale vm groups.
func (s *AutoScaleService) ListAutoScaleVmGroups(p *ListAutoScaleVmGroupsParams) (*ListAutoScaleVmGroupsResponse, error) {
resp, err := s.cs.newRequest("listAutoScaleVmGroups", p.toURLValues())
2016-10-07 10:39:28 -04:00
if err != nil {
return nil, err
}
var r ListAutoScaleVmGroupsResponse
2016-10-07 10:39:28 -04:00
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
2016-10-07 10:39:28 -04:00
return &r, nil
}
type ListAutoScaleVmGroupsResponse struct {
Count int `json:"count"`
AutoScaleVmGroups []*AutoScaleVmGroup `json:"autoscalevmgroup"`
2016-10-07 10:39:28 -04:00
}
type AutoScaleVmGroup struct {
Account string `json:"account"`
Domain string `json:"domain"`
Domainid string `json:"domainid"`
Fordisplay bool `json:"fordisplay"`
Id string `json:"id"`
Interval int `json:"interval"`
2019-05-26 05:58:26 -04:00
JobID string `json:"jobid"`
Jobstatus int `json:"jobstatus"`
Lbruleid string `json:"lbruleid"`
Maxmembers int `json:"maxmembers"`
Minmembers int `json:"minmembers"`
Project string `json:"project"`
Projectid string `json:"projectid"`
Scaledownpolicies []string `json:"scaledownpolicies"`
Scaleuppolicies []string `json:"scaleuppolicies"`
State string `json:"state"`
Vmprofileid string `json:"vmprofileid"`
2016-10-07 10:39:28 -04:00
}
type ListAutoScaleVmProfilesParams struct {
p map[string]interface{}
}
func (p *ListAutoScaleVmProfilesParams) toURLValues() url.Values {
u := url.Values{}
if p.p == nil {
return u
}
if v, found := p.p["account"]; found {
u.Set("account", v.(string))
}
if v, found := p.p["domainid"]; found {
u.Set("domainid", v.(string))
}
if v, found := p.p["fordisplay"]; found {
vv := strconv.FormatBool(v.(bool))
u.Set("fordisplay", vv)
}
if v, found := p.p["id"]; found {
u.Set("id", v.(string))
}
if v, found := p.p["isrecursive"]; found {
vv := strconv.FormatBool(v.(bool))
u.Set("isrecursive", vv)
}
if v, found := p.p["keyword"]; found {
u.Set("keyword", v.(string))
}
if v, found := p.p["listall"]; found {
vv := strconv.FormatBool(v.(bool))
u.Set("listall", vv)
}
if v, found := p.p["otherdeployparams"]; found {
u.Set("otherdeployparams", v.(string))
}
if v, found := p.p["page"]; found {
vv := strconv.Itoa(v.(int))
u.Set("page", vv)
}
if v, found := p.p["pagesize"]; found {
vv := strconv.Itoa(v.(int))
u.Set("pagesize", vv)
}
if v, found := p.p["projectid"]; found {
u.Set("projectid", v.(string))
}
if v, found := p.p["serviceofferingid"]; found {
u.Set("serviceofferingid", v.(string))
}
if v, found := p.p["templateid"]; found {
u.Set("templateid", v.(string))
}
if v, found := p.p["zoneid"]; found {
u.Set("zoneid", v.(string))
}
return u
}
func (p *ListAutoScaleVmProfilesParams) SetAccount(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["account"] = v
return
}
func (p *ListAutoScaleVmProfilesParams) SetDomainid(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["domainid"] = v
return
}
func (p *ListAutoScaleVmProfilesParams) SetFordisplay(v bool) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["fordisplay"] = v
return
}
func (p *ListAutoScaleVmProfilesParams) SetId(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["id"] = v
return
}
func (p *ListAutoScaleVmProfilesParams) SetIsrecursive(v bool) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["isrecursive"] = v
return
}
func (p *ListAutoScaleVmProfilesParams) SetKeyword(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["keyword"] = v
return
}
func (p *ListAutoScaleVmProfilesParams) SetListall(v bool) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["listall"] = v
return
}
func (p *ListAutoScaleVmProfilesParams) SetOtherdeployparams(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["otherdeployparams"] = v
return
}
func (p *ListAutoScaleVmProfilesParams) SetPage(v int) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["page"] = v
return
}
func (p *ListAutoScaleVmProfilesParams) SetPagesize(v int) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["pagesize"] = v
return
}
func (p *ListAutoScaleVmProfilesParams) SetProjectid(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["projectid"] = v
return
}
func (p *ListAutoScaleVmProfilesParams) SetServiceofferingid(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["serviceofferingid"] = v
return
}
func (p *ListAutoScaleVmProfilesParams) SetTemplateid(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["templateid"] = v
return
}
func (p *ListAutoScaleVmProfilesParams) SetZoneid(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["zoneid"] = v
return
}
// You should always use this function to get a new ListAutoScaleVmProfilesParams instance,
// as then you are sure you have configured all required params
func (s *AutoScaleService) NewListAutoScaleVmProfilesParams() *ListAutoScaleVmProfilesParams {
p := &ListAutoScaleVmProfilesParams{}
p.p = make(map[string]interface{})
return p
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *AutoScaleService) GetAutoScaleVmProfileByID(id string, opts ...OptionFunc) (*AutoScaleVmProfile, int, error) {
p := &ListAutoScaleVmProfilesParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range append(s.cs.options, opts...) {
2016-10-07 10:39:28 -04:00
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListAutoScaleVmProfiles(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
"Invalid parameter id value=%s due to incorrect long value format, "+
"or entity does not exist", id)) {
return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l)
}
return nil, -1, err
}
if l.Count == 0 {
return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l)
}
if l.Count == 1 {
return l.AutoScaleVmProfiles[0], l.Count, nil
}
return nil, l.Count, fmt.Errorf("There is more then one result for AutoScaleVmProfile UUID: %s!", id)
}
// Lists autoscale vm profiles.
func (s *AutoScaleService) ListAutoScaleVmProfiles(p *ListAutoScaleVmProfilesParams) (*ListAutoScaleVmProfilesResponse, error) {
resp, err := s.cs.newRequest("listAutoScaleVmProfiles", p.toURLValues())
if err != nil {
return nil, err
}
var r ListAutoScaleVmProfilesResponse
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
2016-10-07 10:39:28 -04:00
return &r, nil
}
type ListAutoScaleVmProfilesResponse struct {
Count int `json:"count"`
AutoScaleVmProfiles []*AutoScaleVmProfile `json:"autoscalevmprofile"`
}
type AutoScaleVmProfile struct {
Account string `json:"account"`
Autoscaleuserid string `json:"autoscaleuserid"`
Destroyvmgraceperiod int `json:"destroyvmgraceperiod"`
Domain string `json:"domain"`
Domainid string `json:"domainid"`
Fordisplay bool `json:"fordisplay"`
Id string `json:"id"`
2019-05-26 05:58:26 -04:00
JobID string `json:"jobid"`
Jobstatus int `json:"jobstatus"`
Otherdeployparams string `json:"otherdeployparams"`
Project string `json:"project"`
Projectid string `json:"projectid"`
Serviceofferingid string `json:"serviceofferingid"`
Templateid string `json:"templateid"`
Zoneid string `json:"zoneid"`
2016-10-07 10:39:28 -04:00
}
type ListConditionsParams struct {
2016-10-07 10:39:28 -04:00
p map[string]interface{}
}
func (p *ListConditionsParams) toURLValues() url.Values {
2016-10-07 10:39:28 -04:00
u := url.Values{}
if p.p == nil {
return u
}
if v, found := p.p["account"]; found {
u.Set("account", v.(string))
}
if v, found := p.p["counterid"]; found {
u.Set("counterid", v.(string))
}
2016-10-07 10:39:28 -04:00
if v, found := p.p["domainid"]; found {
u.Set("domainid", v.(string))
}
if v, found := p.p["id"]; found {
u.Set("id", v.(string))
}
if v, found := p.p["isrecursive"]; found {
vv := strconv.FormatBool(v.(bool))
u.Set("isrecursive", vv)
}
if v, found := p.p["keyword"]; found {
u.Set("keyword", v.(string))
}
if v, found := p.p["listall"]; found {
vv := strconv.FormatBool(v.(bool))
u.Set("listall", vv)
}
if v, found := p.p["page"]; found {
vv := strconv.Itoa(v.(int))
u.Set("page", vv)
}
if v, found := p.p["pagesize"]; found {
vv := strconv.Itoa(v.(int))
u.Set("pagesize", vv)
}
if v, found := p.p["policyid"]; found {
u.Set("policyid", v.(string))
}
return u
}
func (p *ListConditionsParams) SetAccount(v string) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["account"] = v
return
}
func (p *ListConditionsParams) SetCounterid(v string) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["counterid"] = v
2016-10-07 10:39:28 -04:00
return
}
func (p *ListConditionsParams) SetDomainid(v string) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["domainid"] = v
2016-10-07 10:39:28 -04:00
return
}
func (p *ListConditionsParams) SetId(v string) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["id"] = v
return
}
func (p *ListConditionsParams) SetIsrecursive(v bool) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["isrecursive"] = v
return
}
func (p *ListConditionsParams) SetKeyword(v string) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["keyword"] = v
return
}
func (p *ListConditionsParams) SetListall(v bool) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["listall"] = v
return
}
func (p *ListConditionsParams) SetPage(v int) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["page"] = v
return
}
func (p *ListConditionsParams) SetPagesize(v int) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["pagesize"] = v
return
}
func (p *ListConditionsParams) SetPolicyid(v string) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["policyid"] = v
return
}
// You should always use this function to get a new ListConditionsParams instance,
2016-10-07 10:39:28 -04:00
// as then you are sure you have configured all required params
func (s *AutoScaleService) NewListConditionsParams() *ListConditionsParams {
p := &ListConditionsParams{}
2016-10-07 10:39:28 -04:00
p.p = make(map[string]interface{})
return p
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *AutoScaleService) GetConditionByID(id string, opts ...OptionFunc) (*Condition, int, error) {
p := &ListConditionsParams{}
2016-10-07 10:39:28 -04:00
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range append(s.cs.options, opts...) {
2016-10-07 10:39:28 -04:00
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListConditions(p)
2016-10-07 10:39:28 -04:00
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
"Invalid parameter id value=%s due to incorrect long value format, "+
"or entity does not exist", id)) {
return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l)
}
return nil, -1, err
}
if l.Count == 0 {
return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l)
}
if l.Count == 1 {
return l.Conditions[0], l.Count, nil
2016-10-07 10:39:28 -04:00
}
return nil, l.Count, fmt.Errorf("There is more then one result for Condition UUID: %s!", id)
2016-10-07 10:39:28 -04:00
}
// List Conditions for the specific user
func (s *AutoScaleService) ListConditions(p *ListConditionsParams) (*ListConditionsResponse, error) {
resp, err := s.cs.newRequest("listConditions", p.toURLValues())
2016-10-07 10:39:28 -04:00
if err != nil {
return nil, err
}
var r ListConditionsResponse
2016-10-07 10:39:28 -04:00
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
2016-10-07 10:39:28 -04:00
return &r, nil
}
type ListConditionsResponse struct {
Count int `json:"count"`
Conditions []*Condition `json:"condition"`
2016-10-07 10:39:28 -04:00
}
type Condition struct {
Account string `json:"account"`
Counter []string `json:"counter"`
Domain string `json:"domain"`
Domainid string `json:"domainid"`
Id string `json:"id"`
2019-05-26 05:58:26 -04:00
JobID string `json:"jobid"`
Jobstatus int `json:"jobstatus"`
Project string `json:"project"`
Projectid string `json:"projectid"`
Relationaloperator string `json:"relationaloperator"`
Threshold int64 `json:"threshold"`
Zoneid string `json:"zoneid"`
2016-10-07 10:39:28 -04:00
}
type ListCountersParams struct {
2016-10-07 10:39:28 -04:00
p map[string]interface{}
}
func (p *ListCountersParams) toURLValues() url.Values {
2016-10-07 10:39:28 -04:00
u := url.Values{}
if p.p == nil {
return u
}
if v, found := p.p["id"]; found {
u.Set("id", v.(string))
}
if v, found := p.p["keyword"]; found {
u.Set("keyword", v.(string))
}
if v, found := p.p["name"]; found {
u.Set("name", v.(string))
}
if v, found := p.p["page"]; found {
vv := strconv.Itoa(v.(int))
u.Set("page", vv)
}
if v, found := p.p["pagesize"]; found {
vv := strconv.Itoa(v.(int))
u.Set("pagesize", vv)
}
if v, found := p.p["source"]; found {
u.Set("source", v.(string))
}
2016-10-07 10:39:28 -04:00
return u
}
func (p *ListCountersParams) SetId(v string) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["id"] = v
return
}
func (p *ListCountersParams) SetKeyword(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["keyword"] = v
return
}
func (p *ListCountersParams) SetName(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["name"] = v
return
}
func (p *ListCountersParams) SetPage(v int) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["page"] = v
return
}
func (p *ListCountersParams) SetPagesize(v int) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["pagesize"] = v
return
}
func (p *ListCountersParams) SetSource(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["source"] = v
return
}
// You should always use this function to get a new ListCountersParams instance,
2016-10-07 10:39:28 -04:00
// as then you are sure you have configured all required params
func (s *AutoScaleService) NewListCountersParams() *ListCountersParams {
p := &ListCountersParams{}
2016-10-07 10:39:28 -04:00
p.p = make(map[string]interface{})
return p
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *AutoScaleService) GetCounterID(name string, opts ...OptionFunc) (string, int, error) {
p := &ListCountersParams{}
p.p = make(map[string]interface{})
p.p["name"] = name
for _, fn := range append(s.cs.options, opts...) {
if err := fn(s.cs, p); err != nil {
return "", -1, err
}
}
l, err := s.ListCounters(p)
2016-10-07 10:39:28 -04:00
if err != nil {
return "", -1, err
2016-10-07 10:39:28 -04:00
}
if l.Count == 0 {
return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
2016-10-07 10:39:28 -04:00
}
if l.Count == 1 {
return l.Counters[0].Id, l.Count, nil
}
if l.Count > 1 {
for _, v := range l.Counters {
if v.Name == name {
return v.Id, l.Count, nil
2016-10-07 10:39:28 -04:00
}
}
}
return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l)
}
2016-10-07 10:39:28 -04:00
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *AutoScaleService) GetCounterByName(name string, opts ...OptionFunc) (*Counter, int, error) {
id, count, err := s.GetCounterID(name, opts...)
if err != nil {
return nil, count, err
}
2016-10-07 10:39:28 -04:00
r, count, err := s.GetCounterByID(id, opts...)
if err != nil {
return nil, count, err
2016-10-07 10:39:28 -04:00
}
return r, count, nil
2016-10-07 10:39:28 -04:00
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *AutoScaleService) GetCounterByID(id string, opts ...OptionFunc) (*Counter, int, error) {
p := &ListCountersParams{}
p.p = make(map[string]interface{})
2016-10-07 10:39:28 -04:00
p.p["id"] = id
2016-10-07 10:39:28 -04:00
for _, fn := range append(s.cs.options, opts...) {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
2016-10-07 10:39:28 -04:00
}
l, err := s.ListCounters(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
"Invalid parameter id value=%s due to incorrect long value format, "+
"or entity does not exist", id)) {
return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l)
}
return nil, -1, err
2016-10-07 10:39:28 -04:00
}
if l.Count == 0 {
return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l)
2016-10-07 10:39:28 -04:00
}
if l.Count == 1 {
return l.Counters[0], l.Count, nil
}
return nil, l.Count, fmt.Errorf("There is more then one result for Counter UUID: %s!", id)
2016-10-07 10:39:28 -04:00
}
// List the counters
func (s *AutoScaleService) ListCounters(p *ListCountersParams) (*ListCountersResponse, error) {
resp, err := s.cs.newRequest("listCounters", p.toURLValues())
2016-10-07 10:39:28 -04:00
if err != nil {
return nil, err
}
var r ListCountersResponse
2016-10-07 10:39:28 -04:00
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
return &r, nil
}
type ListCountersResponse struct {
Count int `json:"count"`
Counters []*Counter `json:"counter"`
}
type Counter struct {
2019-05-26 05:58:26 -04:00
Id string `json:"id"`
JobID string `json:"jobid"`
Jobstatus int `json:"jobstatus"`
Name string `json:"name"`
Source string `json:"source"`
Value string `json:"value"`
Zoneid string `json:"zoneid"`
2016-10-07 10:39:28 -04:00
}
type UpdateAutoScalePolicyParams struct {
p map[string]interface{}
}
func (p *UpdateAutoScalePolicyParams) toURLValues() url.Values {
u := url.Values{}
if p.p == nil {
return u
}
if v, found := p.p["conditionids"]; found {
vv := strings.Join(v.([]string), ",")
u.Set("conditionids", vv)
}
if v, found := p.p["duration"]; found {
vv := strconv.Itoa(v.(int))
u.Set("duration", vv)
}
if v, found := p.p["id"]; found {
u.Set("id", v.(string))
}
if v, found := p.p["quiettime"]; found {
vv := strconv.Itoa(v.(int))
u.Set("quiettime", vv)
}
return u
}
func (p *UpdateAutoScalePolicyParams) SetConditionids(v []string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["conditionids"] = v
return
}
func (p *UpdateAutoScalePolicyParams) SetDuration(v int) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["duration"] = v
return
}
func (p *UpdateAutoScalePolicyParams) SetId(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["id"] = v
return
}
func (p *UpdateAutoScalePolicyParams) SetQuiettime(v int) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["quiettime"] = v
return
}
// You should always use this function to get a new UpdateAutoScalePolicyParams instance,
// as then you are sure you have configured all required params
func (s *AutoScaleService) NewUpdateAutoScalePolicyParams(id string) *UpdateAutoScalePolicyParams {
p := &UpdateAutoScalePolicyParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
return p
}
// Updates an existing autoscale policy.
func (s *AutoScaleService) UpdateAutoScalePolicy(p *UpdateAutoScalePolicyParams) (*UpdateAutoScalePolicyResponse, error) {
resp, err := s.cs.newRequest("updateAutoScalePolicy", p.toURLValues())
if err != nil {
return nil, err
}
var r UpdateAutoScalePolicyResponse
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
// If we have a async client, we need to wait for the async result
if s.cs.async {
b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
if err != nil {
if err == AsyncTimeoutErr {
return &r, err
}
return nil, err
}
b, err = getRawValue(b)
if err != nil {
return nil, err
}
if err := json.Unmarshal(b, &r); err != nil {
return nil, err
}
}
2016-10-07 10:39:28 -04:00
return &r, nil
}
type UpdateAutoScalePolicyResponse struct {
Account string `json:"account"`
Action string `json:"action"`
Conditions []string `json:"conditions"`
Domain string `json:"domain"`
Domainid string `json:"domainid"`
Duration int `json:"duration"`
Id string `json:"id"`
2019-05-26 05:58:26 -04:00
JobID string `json:"jobid"`
Jobstatus int `json:"jobstatus"`
Project string `json:"project"`
Projectid string `json:"projectid"`
Quiettime int `json:"quiettime"`
2016-10-07 10:39:28 -04:00
}
type UpdateAutoScaleVmGroupParams struct {
2016-10-07 10:39:28 -04:00
p map[string]interface{}
}
func (p *UpdateAutoScaleVmGroupParams) toURLValues() url.Values {
2016-10-07 10:39:28 -04:00
u := url.Values{}
if p.p == nil {
return u
}
if v, found := p.p["customid"]; found {
u.Set("customid", v.(string))
}
if v, found := p.p["fordisplay"]; found {
vv := strconv.FormatBool(v.(bool))
u.Set("fordisplay", vv)
}
if v, found := p.p["id"]; found {
u.Set("id", v.(string))
}
if v, found := p.p["interval"]; found {
vv := strconv.Itoa(v.(int))
u.Set("interval", vv)
}
if v, found := p.p["maxmembers"]; found {
vv := strconv.Itoa(v.(int))
u.Set("maxmembers", vv)
}
if v, found := p.p["minmembers"]; found {
vv := strconv.Itoa(v.(int))
u.Set("minmembers", vv)
}
if v, found := p.p["scaledownpolicyids"]; found {
vv := strings.Join(v.([]string), ",")
u.Set("scaledownpolicyids", vv)
}
if v, found := p.p["scaleuppolicyids"]; found {
vv := strings.Join(v.([]string), ",")
u.Set("scaleuppolicyids", vv)
2016-10-07 10:39:28 -04:00
}
return u
}
func (p *UpdateAutoScaleVmGroupParams) SetCustomid(v string) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["customid"] = v
2016-10-07 10:39:28 -04:00
return
}
func (p *UpdateAutoScaleVmGroupParams) SetFordisplay(v bool) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["fordisplay"] = v
2016-10-07 10:39:28 -04:00
return
}
func (p *UpdateAutoScaleVmGroupParams) SetId(v string) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["id"] = v
2016-10-07 10:39:28 -04:00
return
}
func (p *UpdateAutoScaleVmGroupParams) SetInterval(v int) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["interval"] = v
2016-10-07 10:39:28 -04:00
return
}
func (p *UpdateAutoScaleVmGroupParams) SetMaxmembers(v int) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["maxmembers"] = v
2016-10-07 10:39:28 -04:00
return
}
func (p *UpdateAutoScaleVmGroupParams) SetMinmembers(v int) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["minmembers"] = v
2016-10-07 10:39:28 -04:00
return
}
func (p *UpdateAutoScaleVmGroupParams) SetScaledownpolicyids(v []string) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["scaledownpolicyids"] = v
2016-10-07 10:39:28 -04:00
return
}
func (p *UpdateAutoScaleVmGroupParams) SetScaleuppolicyids(v []string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["scaleuppolicyids"] = v
return
}
// You should always use this function to get a new UpdateAutoScaleVmGroupParams instance,
2016-10-07 10:39:28 -04:00
// as then you are sure you have configured all required params
func (s *AutoScaleService) NewUpdateAutoScaleVmGroupParams(id string) *UpdateAutoScaleVmGroupParams {
p := &UpdateAutoScaleVmGroupParams{}
2016-10-07 10:39:28 -04:00
p.p = make(map[string]interface{})
p.p["id"] = id
return p
}
// Updates an existing autoscale vm group.
func (s *AutoScaleService) UpdateAutoScaleVmGroup(p *UpdateAutoScaleVmGroupParams) (*UpdateAutoScaleVmGroupResponse, error) {
resp, err := s.cs.newRequest("updateAutoScaleVmGroup", p.toURLValues())
2016-10-07 10:39:28 -04:00
if err != nil {
return nil, err
}
var r UpdateAutoScaleVmGroupResponse
2016-10-07 10:39:28 -04:00
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
// If we have a async client, we need to wait for the async result
if s.cs.async {
b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
if err != nil {
if err == AsyncTimeoutErr {
return &r, err
}
return nil, err
}
b, err = getRawValue(b)
if err != nil {
return nil, err
}
if err := json.Unmarshal(b, &r); err != nil {
return nil, err
}
}
2016-10-07 10:39:28 -04:00
return &r, nil
}
type UpdateAutoScaleVmGroupResponse struct {
Account string `json:"account"`
Domain string `json:"domain"`
Domainid string `json:"domainid"`
Fordisplay bool `json:"fordisplay"`
Id string `json:"id"`
Interval int `json:"interval"`
2019-05-26 05:58:26 -04:00
JobID string `json:"jobid"`
Jobstatus int `json:"jobstatus"`
Lbruleid string `json:"lbruleid"`
Maxmembers int `json:"maxmembers"`
Minmembers int `json:"minmembers"`
Project string `json:"project"`
Projectid string `json:"projectid"`
Scaledownpolicies []string `json:"scaledownpolicies"`
Scaleuppolicies []string `json:"scaleuppolicies"`
State string `json:"state"`
Vmprofileid string `json:"vmprofileid"`
2016-10-07 10:39:28 -04:00
}
type UpdateAutoScaleVmProfileParams struct {
2016-10-07 10:39:28 -04:00
p map[string]interface{}
}
func (p *UpdateAutoScaleVmProfileParams) toURLValues() url.Values {
2016-10-07 10:39:28 -04:00
u := url.Values{}
if p.p == nil {
return u
}
if v, found := p.p["autoscaleuserid"]; found {
u.Set("autoscaleuserid", v.(string))
}
if v, found := p.p["counterparam"]; found {
i := 0
for k, vv := range v.(map[string]string) {
u.Set(fmt.Sprintf("counterparam[%d].key", i), k)
u.Set(fmt.Sprintf("counterparam[%d].value", i), vv)
i++
}
}
2016-10-07 10:39:28 -04:00
if v, found := p.p["customid"]; found {
u.Set("customid", v.(string))
}
if v, found := p.p["destroyvmgraceperiod"]; found {
vv := strconv.Itoa(v.(int))
u.Set("destroyvmgraceperiod", vv)
}
2016-10-07 10:39:28 -04:00
if v, found := p.p["fordisplay"]; found {
vv := strconv.FormatBool(v.(bool))
u.Set("fordisplay", vv)
}
if v, found := p.p["id"]; found {
u.Set("id", v.(string))
}
if v, found := p.p["templateid"]; found {
u.Set("templateid", v.(string))
2016-10-07 10:39:28 -04:00
}
return u
}
func (p *UpdateAutoScaleVmProfileParams) SetAutoscaleuserid(v string) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["autoscaleuserid"] = v
2016-10-07 10:39:28 -04:00
return
}
func (p *UpdateAutoScaleVmProfileParams) SetCounterparam(v map[string]string) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["counterparam"] = v
2016-10-07 10:39:28 -04:00
return
}
func (p *UpdateAutoScaleVmProfileParams) SetCustomid(v string) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["customid"] = v
2016-10-07 10:39:28 -04:00
return
}
func (p *UpdateAutoScaleVmProfileParams) SetDestroyvmgraceperiod(v int) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["destroyvmgraceperiod"] = v
2016-10-07 10:39:28 -04:00
return
}
func (p *UpdateAutoScaleVmProfileParams) SetFordisplay(v bool) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["fordisplay"] = v
2016-10-07 10:39:28 -04:00
return
}
func (p *UpdateAutoScaleVmProfileParams) SetId(v string) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["id"] = v
2016-10-07 10:39:28 -04:00
return
}
func (p *UpdateAutoScaleVmProfileParams) SetTemplateid(v string) {
2016-10-07 10:39:28 -04:00
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["templateid"] = v
2016-10-07 10:39:28 -04:00
return
}
// You should always use this function to get a new UpdateAutoScaleVmProfileParams instance,
2016-10-07 10:39:28 -04:00
// as then you are sure you have configured all required params
func (s *AutoScaleService) NewUpdateAutoScaleVmProfileParams(id string) *UpdateAutoScaleVmProfileParams {
p := &UpdateAutoScaleVmProfileParams{}
2016-10-07 10:39:28 -04:00
p.p = make(map[string]interface{})
p.p["id"] = id
return p
}
// Updates an existing autoscale vm profile.
func (s *AutoScaleService) UpdateAutoScaleVmProfile(p *UpdateAutoScaleVmProfileParams) (*UpdateAutoScaleVmProfileResponse, error) {
resp, err := s.cs.newRequest("updateAutoScaleVmProfile", p.toURLValues())
2016-10-07 10:39:28 -04:00
if err != nil {
return nil, err
}
var r UpdateAutoScaleVmProfileResponse
2016-10-07 10:39:28 -04:00
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
// If we have a async client, we need to wait for the async result
if s.cs.async {
b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
if err != nil {
if err == AsyncTimeoutErr {
return &r, err
}
return nil, err
}
b, err = getRawValue(b)
if err != nil {
return nil, err
}
if err := json.Unmarshal(b, &r); err != nil {
return nil, err
}
}
2016-10-07 10:39:28 -04:00
return &r, nil
}
type UpdateAutoScaleVmProfileResponse struct {
Account string `json:"account"`
Autoscaleuserid string `json:"autoscaleuserid"`
Destroyvmgraceperiod int `json:"destroyvmgraceperiod"`
Domain string `json:"domain"`
Domainid string `json:"domainid"`
Fordisplay bool `json:"fordisplay"`
Id string `json:"id"`
2019-05-26 05:58:26 -04:00
JobID string `json:"jobid"`
Jobstatus int `json:"jobstatus"`
Otherdeployparams string `json:"otherdeployparams"`
Project string `json:"project"`
Projectid string `json:"projectid"`
Serviceofferingid string `json:"serviceofferingid"`
Templateid string `json:"templateid"`
Zoneid string `json:"zoneid"`
2016-10-07 10:39:28 -04:00
}