123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634 |
- //
- // Copyright 2016, Sander van Harmelen
- //
- // 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"
- "net/url"
- "strconv"
- )
- type UpdateConfigurationParams struct {
- p map[string]interface{}
- }
- func (p *UpdateConfigurationParams) toURLValues() url.Values {
- u := url.Values{}
- if p.p == nil {
- return u
- }
- if v, found := p.p["accountid"]; found {
- u.Set("accountid", v.(string))
- }
- if v, found := p.p["clusterid"]; found {
- u.Set("clusterid", v.(string))
- }
- if v, found := p.p["name"]; found {
- u.Set("name", v.(string))
- }
- if v, found := p.p["storageid"]; found {
- u.Set("storageid", v.(string))
- }
- if v, found := p.p["value"]; found {
- u.Set("value", v.(string))
- }
- if v, found := p.p["zoneid"]; found {
- u.Set("zoneid", v.(string))
- }
- return u
- }
- func (p *UpdateConfigurationParams) SetAccountid(v string) {
- if p.p == nil {
- p.p = make(map[string]interface{})
- }
- p.p["accountid"] = v
- return
- }
- func (p *UpdateConfigurationParams) SetClusterid(v string) {
- if p.p == nil {
- p.p = make(map[string]interface{})
- }
- p.p["clusterid"] = v
- return
- }
- func (p *UpdateConfigurationParams) SetName(v string) {
- if p.p == nil {
- p.p = make(map[string]interface{})
- }
- p.p["name"] = v
- return
- }
- func (p *UpdateConfigurationParams) SetStorageid(v string) {
- if p.p == nil {
- p.p = make(map[string]interface{})
- }
- p.p["storageid"] = v
- return
- }
- func (p *UpdateConfigurationParams) SetValue(v string) {
- if p.p == nil {
- p.p = make(map[string]interface{})
- }
- p.p["value"] = v
- return
- }
- func (p *UpdateConfigurationParams) 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 UpdateConfigurationParams instance,
- // as then you are sure you have configured all required params
- func (s *ConfigurationService) NewUpdateConfigurationParams(name string) *UpdateConfigurationParams {
- p := &UpdateConfigurationParams{}
- p.p = make(map[string]interface{})
- p.p["name"] = name
- return p
- }
- // Updates a configuration.
- func (s *ConfigurationService) UpdateConfiguration(p *UpdateConfigurationParams) (*UpdateConfigurationResponse, error) {
- resp, err := s.cs.newRequest("updateConfiguration", p.toURLValues())
- if err != nil {
- return nil, err
- }
- var r UpdateConfigurationResponse
- if err := json.Unmarshal(resp, &r); err != nil {
- return nil, err
- }
- return &r, nil
- }
- type UpdateConfigurationResponse struct {
- Category string `json:"category,omitempty"`
- Description string `json:"description,omitempty"`
- Id int64 `json:"id,omitempty"`
- Name string `json:"name,omitempty"`
- Scope string `json:"scope,omitempty"`
- Value string `json:"value,omitempty"`
- }
- type ListConfigurationsParams struct {
- p map[string]interface{}
- }
- func (p *ListConfigurationsParams) toURLValues() url.Values {
- u := url.Values{}
- if p.p == nil {
- return u
- }
- if v, found := p.p["accountid"]; found {
- u.Set("accountid", v.(string))
- }
- if v, found := p.p["category"]; found {
- u.Set("category", v.(string))
- }
- if v, found := p.p["clusterid"]; found {
- u.Set("clusterid", 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["storageid"]; found {
- u.Set("storageid", v.(string))
- }
- if v, found := p.p["zoneid"]; found {
- u.Set("zoneid", v.(string))
- }
- return u
- }
- func (p *ListConfigurationsParams) SetAccountid(v string) {
- if p.p == nil {
- p.p = make(map[string]interface{})
- }
- p.p["accountid"] = v
- return
- }
- func (p *ListConfigurationsParams) SetCategory(v string) {
- if p.p == nil {
- p.p = make(map[string]interface{})
- }
- p.p["category"] = v
- return
- }
- func (p *ListConfigurationsParams) SetClusterid(v string) {
- if p.p == nil {
- p.p = make(map[string]interface{})
- }
- p.p["clusterid"] = v
- return
- }
- func (p *ListConfigurationsParams) SetKeyword(v string) {
- if p.p == nil {
- p.p = make(map[string]interface{})
- }
- p.p["keyword"] = v
- return
- }
- func (p *ListConfigurationsParams) SetName(v string) {
- if p.p == nil {
- p.p = make(map[string]interface{})
- }
- p.p["name"] = v
- return
- }
- func (p *ListConfigurationsParams) SetPage(v int) {
- if p.p == nil {
- p.p = make(map[string]interface{})
- }
- p.p["page"] = v
- return
- }
- func (p *ListConfigurationsParams) SetPagesize(v int) {
- if p.p == nil {
- p.p = make(map[string]interface{})
- }
- p.p["pagesize"] = v
- return
- }
- func (p *ListConfigurationsParams) SetStorageid(v string) {
- if p.p == nil {
- p.p = make(map[string]interface{})
- }
- p.p["storageid"] = v
- return
- }
- func (p *ListConfigurationsParams) 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 ListConfigurationsParams instance,
- // as then you are sure you have configured all required params
- func (s *ConfigurationService) NewListConfigurationsParams() *ListConfigurationsParams {
- p := &ListConfigurationsParams{}
- p.p = make(map[string]interface{})
- return p
- }
- // Lists all configurations.
- func (s *ConfigurationService) ListConfigurations(p *ListConfigurationsParams) (*ListConfigurationsResponse, error) {
- resp, err := s.cs.newRequest("listConfigurations", p.toURLValues())
- if err != nil {
- return nil, err
- }
- var r ListConfigurationsResponse
- if err := json.Unmarshal(resp, &r); err != nil {
- return nil, err
- }
- return &r, nil
- }
- type ListConfigurationsResponse struct {
- Count int `json:"count"`
- Configurations []*Configuration `json:"configuration"`
- }
- type Configuration struct {
- Category string `json:"category,omitempty"`
- Description string `json:"description,omitempty"`
- Id int64 `json:"id,omitempty"`
- Name string `json:"name,omitempty"`
- Scope string `json:"scope,omitempty"`
- Value string `json:"value,omitempty"`
- }
- type ListCapabilitiesParams struct {
- p map[string]interface{}
- }
- func (p *ListCapabilitiesParams) toURLValues() url.Values {
- u := url.Values{}
- if p.p == nil {
- return u
- }
- return u
- }
- // You should always use this function to get a new ListCapabilitiesParams instance,
- // as then you are sure you have configured all required params
- func (s *ConfigurationService) NewListCapabilitiesParams() *ListCapabilitiesParams {
- p := &ListCapabilitiesParams{}
- p.p = make(map[string]interface{})
- return p
- }
- // Lists capabilities
- func (s *ConfigurationService) ListCapabilities(p *ListCapabilitiesParams) (*ListCapabilitiesResponse, error) {
- resp, err := s.cs.newRequest("listCapabilities", p.toURLValues())
- if err != nil {
- return nil, err
- }
- var r ListCapabilitiesResponse
- if err := json.Unmarshal(resp, &r); err != nil {
- return nil, err
- }
- return &r, nil
- }
- type ListCapabilitiesResponse struct {
- Count int `json:"count"`
- Capabilities []*Capability `json:"capability"`
- }
- type Capability struct {
- Allowusercreateprojects bool `json:"allowusercreateprojects,omitempty"`
- Allowuserexpungerecovervm bool `json:"allowuserexpungerecovervm,omitempty"`
- Allowuserviewdestroyedvm bool `json:"allowuserviewdestroyedvm,omitempty"`
- Apilimitinterval int `json:"apilimitinterval,omitempty"`
- Apilimitmax int `json:"apilimitmax,omitempty"`
- Cloudstackversion string `json:"cloudstackversion,omitempty"`
- Customdiskofferingmaxsize int64 `json:"customdiskofferingmaxsize,omitempty"`
- Customdiskofferingminsize int64 `json:"customdiskofferingminsize,omitempty"`
- Kvmsnapshotenabled bool `json:"kvmsnapshotenabled,omitempty"`
- Projectinviterequired bool `json:"projectinviterequired,omitempty"`
- Regionsecondaryenabled bool `json:"regionsecondaryenabled,omitempty"`
- Securitygroupsenabled bool `json:"securitygroupsenabled,omitempty"`
- SupportELB string `json:"supportELB,omitempty"`
- Userpublictemplateenabled bool `json:"userpublictemplateenabled,omitempty"`
- }
- type ListDeploymentPlannersParams struct {
- p map[string]interface{}
- }
- func (p *ListDeploymentPlannersParams) toURLValues() url.Values {
- u := url.Values{}
- if p.p == nil {
- return u
- }
- if v, found := p.p["keyword"]; found {
- u.Set("keyword", 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)
- }
- return u
- }
- func (p *ListDeploymentPlannersParams) SetKeyword(v string) {
- if p.p == nil {
- p.p = make(map[string]interface{})
- }
- p.p["keyword"] = v
- return
- }
- func (p *ListDeploymentPlannersParams) SetPage(v int) {
- if p.p == nil {
- p.p = make(map[string]interface{})
- }
- p.p["page"] = v
- return
- }
- func (p *ListDeploymentPlannersParams) SetPagesize(v int) {
- if p.p == nil {
- p.p = make(map[string]interface{})
- }
- p.p["pagesize"] = v
- return
- }
- // You should always use this function to get a new ListDeploymentPlannersParams instance,
- // as then you are sure you have configured all required params
- func (s *ConfigurationService) NewListDeploymentPlannersParams() *ListDeploymentPlannersParams {
- p := &ListDeploymentPlannersParams{}
- p.p = make(map[string]interface{})
- return p
- }
- // Lists all DeploymentPlanners available.
- func (s *ConfigurationService) ListDeploymentPlanners(p *ListDeploymentPlannersParams) (*ListDeploymentPlannersResponse, error) {
- resp, err := s.cs.newRequest("listDeploymentPlanners", p.toURLValues())
- if err != nil {
- return nil, err
- }
- var r ListDeploymentPlannersResponse
- if err := json.Unmarshal(resp, &r); err != nil {
- return nil, err
- }
- return &r, nil
- }
- type ListDeploymentPlannersResponse struct {
- Count int `json:"count"`
- DeploymentPlanners []*DeploymentPlanner `json:"deploymentplanner"`
- }
- type DeploymentPlanner struct {
- Name string `json:"name,omitempty"`
- }
- type ListLdapConfigurationsParams struct {
- p map[string]interface{}
- }
- func (p *ListLdapConfigurationsParams) toURLValues() url.Values {
- u := url.Values{}
- if p.p == nil {
- return u
- }
- if v, found := p.p["hostname"]; found {
- u.Set("hostname", v.(string))
- }
- if v, found := p.p["keyword"]; found {
- u.Set("keyword", 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["port"]; found {
- vv := strconv.Itoa(v.(int))
- u.Set("port", vv)
- }
- return u
- }
- func (p *ListLdapConfigurationsParams) SetHostname(v string) {
- if p.p == nil {
- p.p = make(map[string]interface{})
- }
- p.p["hostname"] = v
- return
- }
- func (p *ListLdapConfigurationsParams) SetKeyword(v string) {
- if p.p == nil {
- p.p = make(map[string]interface{})
- }
- p.p["keyword"] = v
- return
- }
- func (p *ListLdapConfigurationsParams) SetPage(v int) {
- if p.p == nil {
- p.p = make(map[string]interface{})
- }
- p.p["page"] = v
- return
- }
- func (p *ListLdapConfigurationsParams) SetPagesize(v int) {
- if p.p == nil {
- p.p = make(map[string]interface{})
- }
- p.p["pagesize"] = v
- return
- }
- func (p *ListLdapConfigurationsParams) SetPort(v int) {
- if p.p == nil {
- p.p = make(map[string]interface{})
- }
- p.p["port"] = v
- return
- }
- // You should always use this function to get a new ListLdapConfigurationsParams instance,
- // as then you are sure you have configured all required params
- func (s *ConfigurationService) NewListLdapConfigurationsParams() *ListLdapConfigurationsParams {
- p := &ListLdapConfigurationsParams{}
- p.p = make(map[string]interface{})
- return p
- }
- // Lists all LDAP configurations
- func (s *ConfigurationService) ListLdapConfigurations(p *ListLdapConfigurationsParams) (*ListLdapConfigurationsResponse, error) {
- resp, err := s.cs.newRequest("listLdapConfigurations", p.toURLValues())
- if err != nil {
- return nil, err
- }
- var r ListLdapConfigurationsResponse
- if err := json.Unmarshal(resp, &r); err != nil {
- return nil, err
- }
- return &r, nil
- }
- type ListLdapConfigurationsResponse struct {
- Count int `json:"count"`
- LdapConfigurations []*LdapConfiguration `json:"ldapconfiguration"`
- }
- type LdapConfiguration struct {
- Hostname string `json:"hostname,omitempty"`
- Port int `json:"port,omitempty"`
- }
- type AddLdapConfigurationParams struct {
- p map[string]interface{}
- }
- func (p *AddLdapConfigurationParams) toURLValues() url.Values {
- u := url.Values{}
- if p.p == nil {
- return u
- }
- if v, found := p.p["hostname"]; found {
- u.Set("hostname", v.(string))
- }
- if v, found := p.p["port"]; found {
- vv := strconv.Itoa(v.(int))
- u.Set("port", vv)
- }
- return u
- }
- func (p *AddLdapConfigurationParams) SetHostname(v string) {
- if p.p == nil {
- p.p = make(map[string]interface{})
- }
- p.p["hostname"] = v
- return
- }
- func (p *AddLdapConfigurationParams) SetPort(v int) {
- if p.p == nil {
- p.p = make(map[string]interface{})
- }
- p.p["port"] = v
- return
- }
- // You should always use this function to get a new AddLdapConfigurationParams instance,
- // as then you are sure you have configured all required params
- func (s *ConfigurationService) NewAddLdapConfigurationParams(hostname string, port int) *AddLdapConfigurationParams {
- p := &AddLdapConfigurationParams{}
- p.p = make(map[string]interface{})
- p.p["hostname"] = hostname
- p.p["port"] = port
- return p
- }
- // Add a new Ldap Configuration
- func (s *ConfigurationService) AddLdapConfiguration(p *AddLdapConfigurationParams) (*AddLdapConfigurationResponse, error) {
- resp, err := s.cs.newRequest("addLdapConfiguration", p.toURLValues())
- if err != nil {
- return nil, err
- }
- var r AddLdapConfigurationResponse
- if err := json.Unmarshal(resp, &r); err != nil {
- return nil, err
- }
- return &r, nil
- }
- type AddLdapConfigurationResponse struct {
- Hostname string `json:"hostname,omitempty"`
- Port int `json:"port,omitempty"`
- }
- type DeleteLdapConfigurationParams struct {
- p map[string]interface{}
- }
- func (p *DeleteLdapConfigurationParams) toURLValues() url.Values {
- u := url.Values{}
- if p.p == nil {
- return u
- }
- if v, found := p.p["hostname"]; found {
- u.Set("hostname", v.(string))
- }
- return u
- }
- func (p *DeleteLdapConfigurationParams) SetHostname(v string) {
- if p.p == nil {
- p.p = make(map[string]interface{})
- }
- p.p["hostname"] = v
- return
- }
- // You should always use this function to get a new DeleteLdapConfigurationParams instance,
- // as then you are sure you have configured all required params
- func (s *ConfigurationService) NewDeleteLdapConfigurationParams(hostname string) *DeleteLdapConfigurationParams {
- p := &DeleteLdapConfigurationParams{}
- p.p = make(map[string]interface{})
- p.p["hostname"] = hostname
- return p
- }
- // Remove an Ldap Configuration
- func (s *ConfigurationService) DeleteLdapConfiguration(p *DeleteLdapConfigurationParams) (*DeleteLdapConfigurationResponse, error) {
- resp, err := s.cs.newRequest("deleteLdapConfiguration", p.toURLValues())
- if err != nil {
- return nil, err
- }
- var r DeleteLdapConfigurationResponse
- if err := json.Unmarshal(resp, &r); err != nil {
- return nil, err
- }
- return &r, nil
- }
- type DeleteLdapConfigurationResponse struct {
- Hostname string `json:"hostname,omitempty"`
- Port int `json:"port,omitempty"`
- }
|