2016-10-07 10:39:28 -04:00
//
2019-02-01 14:26:40 -05: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"
)
2019-02-01 14:26:40 -05:00
type CreateAutoScalePolicyParams struct {
2016-10-07 10:39:28 -04:00
p map [ string ] interface { }
}
2019-02-01 14:26:40 -05:00
func ( p * CreateAutoScalePolicyParams ) toURLValues ( ) url . Values {
2016-10-07 10:39:28 -04:00
u := url . Values { }
if p . p == nil {
return u
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "action" ] ; found {
u . Set ( "action" , v . ( string ) )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05: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
}
2019-02-01 14:26:40 -05: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
}
2019-02-01 14:26:40 -05:00
func ( p * CreateAutoScalePolicyParams ) SetAction ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "action" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * CreateAutoScalePolicyParams ) SetConditionids ( v [ ] string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "conditionids" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * CreateAutoScalePolicyParams ) SetDuration ( v int ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "duration" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
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
2019-02-01 14:26:40 -05:00
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 { } )
2019-02-01 14:26:40 -05:00
p . p [ "action" ] = action
p . p [ "conditionids" ] = conditionids
p . p [ "duration" ] = duration
2016-10-07 10:39:28 -04:00
return p
}
2019-02-01 14:26:40 -05:00
// 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
}
2019-02-01 14:26:40 -05:00
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
}
}
2019-02-01 14:26:40 -05:00
2016-10-07 10:39:28 -04:00
return & r , nil
}
2019-02-01 14:26:40 -05:00
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" `
2019-02-01 14:26:40 -05:00
Project string ` json:"project" `
Projectid string ` json:"projectid" `
Quiettime int ` json:"quiettime" `
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
type CreateAutoScaleVmGroupParams struct {
2016-10-07 10:39:28 -04:00
p map [ string ] interface { }
}
2019-02-01 14:26:40 -05:00
func ( p * CreateAutoScaleVmGroupParams ) toURLValues ( ) url . Values {
2016-10-07 10:39:28 -04:00
u := url . Values { }
if p . p == nil {
return u
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "fordisplay" ] ; found {
vv := strconv . FormatBool ( v . ( bool ) )
u . Set ( "fordisplay" , vv )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05: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
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "lbruleid" ] ; found {
u . Set ( "lbruleid" , v . ( string ) )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05: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
}
2019-02-01 14:26:40 -05: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
}
2019-02-01 14:26:40 -05: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
}
2019-02-01 14:26:40 -05: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
}
2019-02-01 14:26:40 -05: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 { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "fordisplay" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * CreateAutoScaleVmGroupParams ) SetInterval ( v int ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "interval" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * CreateAutoScaleVmGroupParams ) SetLbruleid ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "lbruleid" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * CreateAutoScaleVmGroupParams ) SetMaxmembers ( v int ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "maxmembers" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * CreateAutoScaleVmGroupParams ) SetMinmembers ( v int ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "minmembers" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * CreateAutoScaleVmGroupParams ) SetScaledownpolicyids ( v [ ] string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "scaledownpolicyids" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * CreateAutoScaleVmGroupParams ) SetScaleuppolicyids ( v [ ] string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "scaleuppolicyids" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * CreateAutoScaleVmGroupParams ) SetVmprofileid ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "vmprofileid" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
// 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
2019-02-01 14:26:40 -05:00
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 { } )
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
// 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
}
2019-02-01 14:26:40 -05:00
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
}
}
2019-02-01 14:26:40 -05:00
2016-10-07 10:39:28 -04:00
return & r , nil
}
2019-02-01 14:26:40 -05:00
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" `
2019-02-01 14:26:40 -05:00
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
}
}
2019-02-01 14:26:40 -05:00
2016-10-07 10:39:28 -04:00
return & r , nil
}
type CreateAutoScaleVmProfileResponse struct {
2019-02-01 14:26:40 -05:00
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" `
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
type CreateConditionParams struct {
2016-10-07 10:39:28 -04:00
p map [ string ] interface { }
}
2019-02-01 14:26:40 -05:00
func ( p * CreateConditionParams ) toURLValues ( ) url . Values {
2016-10-07 10:39:28 -04:00
u := url . Values { }
if p . p == nil {
return u
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "account" ] ; found {
u . Set ( "account" , v . ( string ) )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "counterid" ] ; found {
u . Set ( "counterid" , v . ( string ) )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "domainid" ] ; found {
u . Set ( "domainid" , v . ( string ) )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "relationaloperator" ] ; found {
u . Set ( "relationaloperator" , v . ( string ) )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05: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
}
2019-02-01 14:26:40 -05:00
func ( p * CreateConditionParams ) SetAccount ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "account" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * CreateConditionParams ) SetCounterid ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "counterid" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * CreateConditionParams ) SetDomainid ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "domainid" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * CreateConditionParams ) SetRelationaloperator ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "relationaloperator" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * CreateConditionParams ) SetThreshold ( v int64 ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "threshold" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
// 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
2019-02-01 14:26:40 -05:00
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 { } )
2019-02-01 14:26:40 -05:00
p . p [ "counterid" ] = counterid
p . p [ "relationaloperator" ] = relationaloperator
p . p [ "threshold" ] = threshold
2016-10-07 10:39:28 -04:00
return p
}
2019-02-01 14:26:40 -05:00
// 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
}
2019-02-01 14:26:40 -05:00
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
}
}
2019-02-01 14:26:40 -05:00
2016-10-07 10:39:28 -04:00
return & r , nil
}
2019-02-01 14:26:40 -05:00
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" `
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
type CreateCounterParams struct {
2016-10-07 10:39:28 -04:00
p map [ string ] interface { }
}
2019-02-01 14:26:40 -05:00
func ( p * CreateCounterParams ) toURLValues ( ) url . Values {
2016-10-07 10:39:28 -04:00
u := url . Values { }
if p . p == nil {
return u
}
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
func ( p * CreateCounterParams ) SetName ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "name" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
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
2019-02-01 14:26:40 -05:00
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 { } )
2019-02-01 14:26:40 -05:00
p . p [ "name" ] = name
p . p [ "source" ] = source
p . p [ "value" ] = value
2016-10-07 10:39:28 -04:00
return p
}
2019-02-01 14:26:40 -05:00
// 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
}
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05: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
}
}
2019-02-01 14:26:40 -05:00
2016-10-07 10:39:28 -04:00
return & r , nil
}
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
type DeleteAutoScalePolicyParams struct {
2016-10-07 10:39:28 -04:00
p map [ string ] interface { }
}
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
// 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
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
// 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
}
2019-02-01 14:26:40 -05:00
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
}
}
2019-02-01 14:26:40 -05:00
2016-10-07 10:39:28 -04:00
return & r , nil
}
2019-02-01 14:26:40 -05:00
type DeleteAutoScalePolicyResponse struct {
Displaytext string ` json:"displaytext" `
2019-05-26 05:58:26 -04:00
JobID string ` json:"jobid" `
Jobstatus int ` json:"jobstatus" `
2019-02-01 14:26:40 -05:00
Success bool ` json:"success" `
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
type DeleteAutoScaleVmGroupParams struct {
2016-10-07 10:39:28 -04:00
p map [ string ] interface { }
}
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
// 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
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
// 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
}
2019-02-01 14:26:40 -05:00
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
}
}
2019-02-01 14:26:40 -05:00
2016-10-07 10:39:28 -04:00
return & r , nil
}
2019-02-01 14:26:40 -05:00
type DeleteAutoScaleVmGroupResponse struct {
Displaytext string ` json:"displaytext" `
2019-05-26 05:58:26 -04:00
JobID string ` json:"jobid" `
Jobstatus int ` json:"jobstatus" `
2019-02-01 14:26:40 -05:00
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
}
}
2019-02-01 14:26:40 -05:00
2016-10-07 10:39:28 -04:00
return & r , nil
}
type DeleteAutoScaleVmProfileResponse struct {
2019-02-01 14:26:40 -05:00
Displaytext string ` json:"displaytext" `
2019-05-26 05:58:26 -04:00
JobID string ` json:"jobid" `
Jobstatus int ` json:"jobstatus" `
2019-02-01 14:26:40 -05:00
Success bool ` json:"success" `
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
type DeleteConditionParams struct {
2016-10-07 10:39:28 -04:00
p map [ string ] interface { }
}
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
// 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
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
// 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
}
2019-02-01 14:26:40 -05:00
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
}
}
2019-02-01 14:26:40 -05:00
2016-10-07 10:39:28 -04:00
return & r , nil
}
2019-02-01 14:26:40 -05:00
type DeleteConditionResponse struct {
Displaytext string ` json:"displaytext" `
2019-05-26 05:58:26 -04:00
JobID string ` json:"jobid" `
Jobstatus int ` json:"jobstatus" `
2019-02-01 14:26:40 -05:00
Success bool ` json:"success" `
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
type DeleteCounterParams struct {
2016-10-07 10:39:28 -04:00
p map [ string ] interface { }
}
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
// 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
}
2019-02-01 14:26:40 -05: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
}
2019-02-01 14:26:40 -05:00
var r DeleteCounterResponse
if err := json . Unmarshal ( resp , & r ) ; err != nil {
return nil , err
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05: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
}
2019-02-01 14:26:40 -05:00
type DeleteCounterResponse struct {
Displaytext string ` json:"displaytext" `
2019-05-26 05:58:26 -04:00
JobID string ` json:"jobid" `
Jobstatus int ` json:"jobstatus" `
2019-02-01 14:26:40 -05:00
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 {
2019-02-01 14:26:40 -05:00
return u
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "id" ] ; found {
u . Set ( "id" , v . ( string ) )
}
return u
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05: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 { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "id" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
// 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
2019-02-01 14:26:40 -05:00
func ( s * AutoScaleService ) NewDisableAutoScaleVmGroupParams ( id string ) * DisableAutoScaleVmGroupParams {
p := & DisableAutoScaleVmGroupParams { }
2016-10-07 10:39:28 -04:00
p . p = make ( map [ string ] interface { } )
2019-02-01 14:26:40 -05:00
p . p [ "id" ] = id
2016-10-07 10:39:28 -04:00
return p
}
2019-02-01 14:26:40 -05:00
// 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 {
2019-02-01 14:26:40 -05:00
return nil , err
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
var r DisableAutoScaleVmGroupResponse
if err := json . Unmarshal ( resp , & r ) ; err != nil {
return nil , err
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05: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
}
2019-02-01 14:26:40 -05:00
return nil , err
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
b , err = getRawValue ( b )
if err != nil {
return nil , err
}
2016-10-07 10:39:28 -04:00
2019-02-01 14:26:40 -05:00
if err := json . Unmarshal ( b , & r ) ; err != nil {
return nil , err
}
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
return & r , nil
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05: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" `
2019-02-01 14:26:40 -05:00
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
2019-02-01 14:26:40 -05:00
type EnableAutoScaleVmGroupParams struct {
p map [ string ] interface { }
}
2016-10-07 10:39:28 -04:00
2019-02-01 14:26:40 -05:00
func ( p * EnableAutoScaleVmGroupParams ) toURLValues ( ) url . Values {
u := url . Values { }
if p . p == nil {
return u
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "id" ] ; found {
u . Set ( "id" , v . ( string ) )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
return u
}
2016-10-07 10:39:28 -04:00
2019-02-01 14:26:40 -05: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
}
2019-02-01 14:26:40 -05:00
p . p [ "id" ] = v
return
}
2016-10-07 10:39:28 -04:00
2019-02-01 14:26:40 -05: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
}
2019-02-01 14:26:40 -05: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
}
2019-02-01 14:26:40 -05:00
var r EnableAutoScaleVmGroupResponse
2016-10-07 10:39:28 -04:00
if err := json . Unmarshal ( resp , & r ) ; err != nil {
return nil , err
}
2019-02-01 14:26:40 -05: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
}
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
}
2019-02-01 14:26:40 -05: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" `
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
type ListAutoScalePoliciesParams struct {
2016-10-07 10:39:28 -04:00
p map [ string ] interface { }
}
2019-02-01 14:26:40 -05:00
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 ) )
}
2019-02-01 14:26:40 -05:00
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 )
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "vmgroupid" ] ; found {
u . Set ( "vmgroupid" , v . ( string ) )
2016-10-07 10:39:28 -04:00
}
return u
}
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
func ( p * ListAutoScalePoliciesParams ) SetAction ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "action" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
func ( p * ListAutoScalePoliciesParams ) SetVmgroupid ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "vmgroupid" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
// 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
2019-02-01 14:26:40 -05:00
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!
2019-02-01 14:26:40 -05:00
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
2019-02-01 14:26:40 -05:00
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
}
}
2019-02-01 14:26:40 -05:00
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 {
2019-02-01 14:26:40 -05:00
return l . AutoScalePolicies [ 0 ] , l . Count , nil
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05: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
}
2019-02-01 14:26:40 -05: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
}
2019-02-01 14:26:40 -05:00
var r ListAutoScalePoliciesResponse
2016-10-07 10:39:28 -04:00
if err := json . Unmarshal ( resp , & r ) ; err != nil {
return nil , err
}
2019-02-01 14:26:40 -05:00
2016-10-07 10:39:28 -04:00
return & r , nil
}
2019-02-01 14:26:40 -05:00
type ListAutoScalePoliciesResponse struct {
Count int ` json:"count" `
AutoScalePolicies [ ] * AutoScalePolicy ` json:"autoscalepolicy" `
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05: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" `
2019-02-01 14:26:40 -05:00
Project string ` json:"project" `
Projectid string ` json:"projectid" `
Quiettime int ` json:"quiettime" `
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
type ListAutoScaleVmGroupsParams struct {
2016-10-07 10:39:28 -04:00
p map [ string ] interface { }
}
2019-02-01 14:26:40 -05:00
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 ) )
}
2019-02-01 14:26:40 -05:00
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 ) )
}
2019-02-01 14:26:40 -05: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 [ "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 )
}
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
func ( p * ListAutoScaleVmGroupsParams ) SetDomainid ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "domainid" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * ListAutoScaleVmGroupsParams ) SetFordisplay ( v bool ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "fordisplay" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * ListAutoScaleVmGroupsParams ) SetId ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "id" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * ListAutoScaleVmGroupsParams ) SetIsrecursive ( v bool ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "isrecursive" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * ListAutoScaleVmGroupsParams ) SetKeyword ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "keyword" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * ListAutoScaleVmGroupsParams ) SetLbruleid ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "lbruleid" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
func ( p * ListAutoScaleVmGroupsParams ) SetPolicyid ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "policyid" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
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
2019-02-01 14:26:40 -05:00
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!
2019-02-01 14:26:40 -05:00
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
2019-02-01 14:26:40 -05:00
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
}
}
2019-02-01 14:26:40 -05:00
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 {
2019-02-01 14:26:40 -05:00
return l . AutoScaleVmGroups [ 0 ] , l . Count , nil
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05: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
}
2019-02-01 14:26:40 -05: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
}
2019-02-01 14:26:40 -05:00
var r ListAutoScaleVmGroupsResponse
2016-10-07 10:39:28 -04:00
if err := json . Unmarshal ( resp , & r ) ; err != nil {
return nil , err
}
2019-02-01 14:26:40 -05:00
2016-10-07 10:39:28 -04:00
return & r , nil
}
2019-02-01 14:26:40 -05:00
type ListAutoScaleVmGroupsResponse struct {
Count int ` json:"count" `
AutoScaleVmGroups [ ] * AutoScaleVmGroup ` json:"autoscalevmgroup" `
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05: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" `
2019-02-01 14:26:40 -05:00
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
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
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 {
2019-02-01 14:26:40 -05:00
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" `
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
type ListConditionsParams struct {
2016-10-07 10:39:28 -04:00
p map [ string ] interface { }
}
2019-02-01 14:26:40 -05:00
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 ) )
}
2019-02-01 14:26:40 -05: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 ) )
}
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
}
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
func ( p * ListConditionsParams ) SetCounterid ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "counterid" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * ListConditionsParams ) SetDomainid ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "domainid" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
// 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
2019-02-01 14:26:40 -05:00
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!
2019-02-01 14:26:40 -05:00
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
2019-02-01 14:26:40 -05:00
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
}
}
2019-02-01 14:26:40 -05:00
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 {
2019-02-01 14:26:40 -05:00
return l . Conditions [ 0 ] , l . Count , nil
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05: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
}
2019-02-01 14:26:40 -05: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
}
2019-02-01 14:26:40 -05:00
var r ListConditionsResponse
2016-10-07 10:39:28 -04:00
if err := json . Unmarshal ( resp , & r ) ; err != nil {
return nil , err
}
2019-02-01 14:26:40 -05:00
2016-10-07 10:39:28 -04:00
return & r , nil
}
2019-02-01 14:26:40 -05:00
type ListConditionsResponse struct {
Count int ` json:"count" `
Conditions [ ] * Condition ` json:"condition" `
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05: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" `
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
type ListCountersParams struct {
2016-10-07 10:39:28 -04:00
p map [ string ] interface { }
}
2019-02-01 14:26:40 -05:00
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 ) )
}
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
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
2019-02-01 14:26:40 -05:00
func ( s * AutoScaleService ) NewListCountersParams ( ) * ListCountersParams {
p := & ListCountersParams { }
2016-10-07 10:39:28 -04:00
p . p = make ( map [ string ] interface { } )
return p
}
2019-02-01 14:26:40 -05:00
// 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 {
2019-02-01 14:26:40 -05:00
return "" , - 1 , err
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05: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
}
2019-02-01 14:26:40 -05: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
}
}
2019-02-01 14:26:40 -05: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
2019-02-01 14:26:40 -05: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
2019-02-01 14:26:40 -05:00
r , count , err := s . GetCounterByID ( id , opts ... )
if err != nil {
return nil , count , err
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
return r , count , nil
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05: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
2019-02-01 14:26:40 -05:00
p . p [ "id" ] = id
2016-10-07 10:39:28 -04:00
2019-02-01 14:26:40 -05: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
}
2019-02-01 14:26:40 -05: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
}
2019-02-01 14:26:40 -05: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
}
2019-02-01 14:26:40 -05: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
}
2019-02-01 14:26:40 -05: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
}
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
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
}
}
2019-02-01 14:26:40 -05:00
2016-10-07 10:39:28 -04:00
return & r , nil
}
type UpdateAutoScalePolicyResponse struct {
2019-02-01 14:26:40 -05:00
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" `
2019-02-01 14:26:40 -05:00
Project string ` json:"project" `
Projectid string ` json:"projectid" `
Quiettime int ` json:"quiettime" `
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
type UpdateAutoScaleVmGroupParams struct {
2016-10-07 10:39:28 -04:00
p map [ string ] interface { }
}
2019-02-01 14:26:40 -05:00
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 ) )
}
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
func ( p * UpdateAutoScaleVmGroupParams ) SetCustomid ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "customid" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * UpdateAutoScaleVmGroupParams ) SetFordisplay ( v bool ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "fordisplay" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * UpdateAutoScaleVmGroupParams ) SetId ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "id" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * UpdateAutoScaleVmGroupParams ) SetInterval ( v int ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "interval" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * UpdateAutoScaleVmGroupParams ) SetMaxmembers ( v int ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "maxmembers" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * UpdateAutoScaleVmGroupParams ) SetMinmembers ( v int ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "minmembers" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * UpdateAutoScaleVmGroupParams ) SetScaledownpolicyids ( v [ ] string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "scaledownpolicyids" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
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
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
// 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
}
2019-02-01 14:26:40 -05:00
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
}
}
2019-02-01 14:26:40 -05:00
2016-10-07 10:39:28 -04:00
return & r , nil
}
2019-02-01 14:26:40 -05:00
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" `
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
type UpdateAutoScaleVmProfileParams struct {
2016-10-07 10:39:28 -04:00
p map [ string ] interface { }
}
2019-02-01 14:26:40 -05:00
func ( p * UpdateAutoScaleVmProfileParams ) toURLValues ( ) url . Values {
2016-10-07 10:39:28 -04:00
u := url . Values { }
if p . p == nil {
return u
}
2019-02-01 14:26:40 -05:00
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 ) )
}
2019-02-01 14:26:40 -05:00
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 ) )
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "templateid" ] ; found {
u . Set ( "templateid" , v . ( string ) )
2016-10-07 10:39:28 -04:00
}
return u
}
2019-02-01 14:26:40 -05:00
func ( p * UpdateAutoScaleVmProfileParams ) SetAutoscaleuserid ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "autoscaleuserid" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
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 { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "counterparam" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * UpdateAutoScaleVmProfileParams ) SetCustomid ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "customid" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * UpdateAutoScaleVmProfileParams ) SetDestroyvmgraceperiod ( v int ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "destroyvmgraceperiod" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * UpdateAutoScaleVmProfileParams ) SetFordisplay ( v bool ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "fordisplay" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * UpdateAutoScaleVmProfileParams ) SetId ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "id" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * UpdateAutoScaleVmProfileParams ) SetTemplateid ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "templateid" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
// 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
2019-02-01 14:26:40 -05:00
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
}
2019-02-01 14:26:40 -05:00
// 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
}
2019-02-01 14:26:40 -05:00
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
}
}
2019-02-01 14:26:40 -05:00
2016-10-07 10:39:28 -04:00
return & r , nil
}
2019-02-01 14:26:40 -05:00
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" `
2019-02-01 14:26:40 -05:00
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
}