Commit 9c105f03 authored by Sander van Harmelen's avatar Sander van Harmelen

godep: add go-cloudstack dependency

parent 9f8625fb
......@@ -2124,6 +2124,11 @@
"Rev": "b5ee639d7aa4b8dbb48ab4f75dddc19f71b5c514"
},
{
"ImportPath": "github.com/xanzy/go-cloudstack/cloudstack",
"Comment": "v2.1.1-1-g1e2cbf6",
"Rev": "1e2cbf647e57fa90353612074fdfc42faf5073bf"
},
{
"ImportPath": "github.com/xiang90/probing",
"Rev": "6a0cc1ae81b4cc11db5e491e030e4b98fba79c19"
},
......
//
// 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"
)
type ListApisParams struct {
p map[string]interface{}
}
func (p *ListApisParams) toURLValues() url.Values {
u := url.Values{}
if p.p == nil {
return u
}
if v, found := p.p["name"]; found {
u.Set("name", v.(string))
}
return u
}
func (p *ListApisParams) SetName(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["name"] = v
return
}
// You should always use this function to get a new ListApisParams instance,
// as then you are sure you have configured all required params
func (s *APIDiscoveryService) NewListApisParams() *ListApisParams {
p := &ListApisParams{}
p.p = make(map[string]interface{})
return p
}
// lists all available apis on the server, provided by the Api Discovery plugin
func (s *APIDiscoveryService) ListApis(p *ListApisParams) (*ListApisResponse, error) {
resp, err := s.cs.newRequest("listApis", p.toURLValues())
if err != nil {
return nil, err
}
var r ListApisResponse
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
return &r, nil
}
type ListApisResponse struct {
Count int `json:"count"`
Apis []*Api `json:"api"`
}
type Api struct {
Description string `json:"description,omitempty"`
Isasync bool `json:"isasync,omitempty"`
Name string `json:"name,omitempty"`
Params []struct {
Description string `json:"description,omitempty"`
Length int `json:"length,omitempty"`
Name string `json:"name,omitempty"`
Related string `json:"related,omitempty"`
Required bool `json:"required,omitempty"`
Since string `json:"since,omitempty"`
Type string `json:"type,omitempty"`
} `json:"params,omitempty"`
Related string `json:"related,omitempty"`
Response []struct {
Description string `json:"description,omitempty"`
Name string `json:"name,omitempty"`
Response []string `json:"response,omitempty"`
Type string `json:"type,omitempty"`
} `json:"response,omitempty"`
Since string `json:"since,omitempty"`
Type string `json:"type,omitempty"`
}
//
// 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"
"time"
)
type QueryAsyncJobResultParams struct {
p map[string]interface{}
}
func (p *QueryAsyncJobResultParams) toURLValues() url.Values {
u := url.Values{}
if p.p == nil {
return u
}
if v, found := p.p["jobid"]; found {
u.Set("jobid", v.(string))
}
return u
}
func (p *QueryAsyncJobResultParams) SetJobid(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["jobid"] = v
return
}
// You should always use this function to get a new QueryAsyncJobResultParams instance,
// as then you are sure you have configured all required params
func (s *AsyncjobService) NewQueryAsyncJobResultParams(jobid string) *QueryAsyncJobResultParams {
p := &QueryAsyncJobResultParams{}
p.p = make(map[string]interface{})
p.p["jobid"] = jobid
return p
}
// Retrieves the current status of asynchronous job.
func (s *AsyncjobService) QueryAsyncJobResult(p *QueryAsyncJobResultParams) (*QueryAsyncJobResultResponse, error) {
var resp json.RawMessage
var err error
// We should be able to retry on failure as this call is idempotent
for i := 0; i < 3; i++ {
resp, err = s.cs.newRequest("queryAsyncJobResult", p.toURLValues())
if err == nil {
break
}
time.Sleep(500 * time.Millisecond)
}
if err != nil {
return nil, err
}
var r QueryAsyncJobResultResponse
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
return &r, nil
}
type QueryAsyncJobResultResponse struct {
Accountid string `json:"accountid,omitempty"`
Cmd string `json:"cmd,omitempty"`
Created string `json:"created,omitempty"`
Jobinstanceid string `json:"jobinstanceid,omitempty"`
Jobinstancetype string `json:"jobinstancetype,omitempty"`
Jobprocstatus int `json:"jobprocstatus,omitempty"`
Jobresult json.RawMessage `json:"jobresult,omitempty"`
Jobresultcode int `json:"jobresultcode,omitempty"`
Jobresulttype string `json:"jobresulttype,omitempty"`
Jobstatus int `json:"jobstatus,omitempty"`
Userid string `json:"userid,omitempty"`
}
type ListAsyncJobsParams struct {
p map[string]interface{}
}
func (p *ListAsyncJobsParams) 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["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["startdate"]; found {
u.Set("startdate", v.(string))
}
return u
}
func (p *ListAsyncJobsParams) SetAccount(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["account"] = v
return
}
func (p *ListAsyncJobsParams) SetDomainid(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["domainid"] = v
return
}
func (p *ListAsyncJobsParams) SetIsrecursive(v bool) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["isrecursive"] = v
return
}
func (p *ListAsyncJobsParams) SetKeyword(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["keyword"] = v
return
}
func (p *ListAsyncJobsParams) SetListall(v bool) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["listall"] = v
return
}
func (p *ListAsyncJobsParams) SetPage(v int) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["page"] = v
return
}
func (p *ListAsyncJobsParams) SetPagesize(v int) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["pagesize"] = v
return
}
func (p *ListAsyncJobsParams) SetStartdate(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["startdate"] = v
return
}
// You should always use this function to get a new ListAsyncJobsParams instance,
// as then you are sure you have configured all required params
func (s *AsyncjobService) NewListAsyncJobsParams() *ListAsyncJobsParams {
p := &ListAsyncJobsParams{}
p.p = make(map[string]interface{})
return p
}
// Lists all pending asynchronous jobs for the account.
func (s *AsyncjobService) ListAsyncJobs(p *ListAsyncJobsParams) (*ListAsyncJobsResponse, error) {
resp, err := s.cs.newRequest("listAsyncJobs", p.toURLValues())
if err != nil {
return nil, err
}
var r ListAsyncJobsResponse
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
return &r, nil
}
type ListAsyncJobsResponse struct {
Count int `json:"count"`
AsyncJobs []*AsyncJob `json:"asyncjobs"`
}
type AsyncJob struct {
Accountid string `json:"accountid,omitempty"`
Cmd string `json:"cmd,omitempty"`
Created string `json:"created,omitempty"`
Jobinstanceid string `json:"jobinstanceid,omitempty"`
Jobinstancetype string `json:"jobinstancetype,omitempty"`
Jobprocstatus int `json:"jobprocstatus,omitempty"`
Jobresult json.RawMessage `json:"jobresult,omitempty"`
Jobresultcode int `json:"jobresultcode,omitempty"`
Jobresulttype string `json:"jobresulttype,omitempty"`
Jobstatus int `json:"jobstatus,omitempty"`
Userid string `json:"userid,omitempty"`
}
//
// 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 LoginParams struct {
p map[string]interface{}
}
func (p *LoginParams) toURLValues() url.Values {
u := url.Values{}
if p.p == nil {
return u
}
if v, found := p.p["domain"]; found {
u.Set("domain", v.(string))
}
if v, found := p.p["domainId"]; found {
vv := strconv.FormatInt(v.(int64), 10)
u.Set("domainId", vv)
}
if v, found := p.p["password"]; found {
u.Set("password", v.(string))
}
if v, found := p.p["username"]; found {
u.Set("username", v.(string))
}
return u
}
func (p *LoginParams) SetDomain(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["domain"] = v
return
}
func (p *LoginParams) SetDomainId(v int64) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["domainId"] = v
return
}
func (p *LoginParams) SetPassword(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["password"] = v
return
}
func (p *LoginParams) SetUsername(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["username"] = v
return
}
// You should always use this function to get a new LoginParams instance,
// as then you are sure you have configured all required params
func (s *AuthenticationService) NewLoginParams(password string, username string) *LoginParams {
p := &LoginParams{}
p.p = make(map[string]interface{})
p.p["password"] = password
p.p["username"] = username
return p
}
// Logs a user into the CloudStack. A successful login attempt will generate a JSESSIONID cookie value that can be passed in subsequent Query command calls until the "logout" command has been issued or the session has expired.
func (s *AuthenticationService) Login(p *LoginParams) (*LoginResponse, error) {
resp, err := s.cs.newRequest("login", p.toURLValues())
if err != nil {
return nil, err
}
var r LoginResponse
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
return &r, nil
}
type LoginResponse struct {
Account string `json:"account,omitempty"`
Domainid string `json:"domainid,omitempty"`
Firstname string `json:"firstname,omitempty"`
Lastname string `json:"lastname,omitempty"`
Registered string `json:"registered,omitempty"`
Sessionkey string `json:"sessionkey,omitempty"`
Timeout int `json:"timeout,omitempty"`
Timezone string `json:"timezone,omitempty"`
Type string `json:"type,omitempty"`
Userid string `json:"userid,omitempty"`
Username string `json:"username,omitempty"`
}
type LogoutParams struct {
p map[string]interface{}
}
func (p *LogoutParams) toURLValues() url.Values {
u := url.Values{}
if p.p == nil {
return u
}
return u
}
// You should always use this function to get a new LogoutParams instance,
// as then you are sure you have configured all required params
func (s *AuthenticationService) NewLogoutParams() *LogoutParams {
p := &LogoutParams{}
p.p = make(map[string]interface{})
return p
}
// Logs out the user
func (s *AuthenticationService) Logout(p *LogoutParams) (*LogoutResponse, error) {
resp, err := s.cs.newRequest("logout", p.toURLValues())
if err != nil {
return nil, err
}
var r LogoutResponse
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
return &r, nil
}
type LogoutResponse struct {
Description string `json:"description,omitempty"`
}
//
// 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 UploadCustomCertificateParams struct {
p map[string]interface{}
}
func (p *UploadCustomCertificateParams) toURLValues() url.Values {
u := url.Values{}
if p.p == nil {
return u
}
if v, found := p.p["certificate"]; found {
u.Set("certificate", v.(string))
}
if v, found := p.p["domainsuffix"]; found {
u.Set("domainsuffix", v.(string))
}
if v, found := p.p["id"]; found {
vv := strconv.Itoa(v.(int))
u.Set("id", vv)
}
if v, found := p.p["name"]; found {
u.Set("name", v.(string))
}
if v, found := p.p["privatekey"]; found {
u.Set("privatekey", v.(string))
}
return u
}
func (p *UploadCustomCertificateParams) SetCertificate(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["certificate"] = v
return
}
func (p *UploadCustomCertificateParams) SetDomainsuffix(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["domainsuffix"] = v
return
}
func (p *UploadCustomCertificateParams) SetId(v int) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["id"] = v
return
}
func (p *UploadCustomCertificateParams) SetName(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["name"] = v
return
}
func (p *UploadCustomCertificateParams) SetPrivatekey(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["privatekey"] = v
return
}
// You should always use this function to get a new UploadCustomCertificateParams instance,
// as then you are sure you have configured all required params
func (s *CertificateService) NewUploadCustomCertificateParams(certificate string, domainsuffix string) *UploadCustomCertificateParams {
p := &UploadCustomCertificateParams{}
p.p = make(map[string]interface{})
p.p["certificate"] = certificate
p.p["domainsuffix"] = domainsuffix
return p
}
// Uploads a custom certificate for the console proxy VMs to use for SSL. Can be used to upload a single certificate signed by a known CA. Can also be used, through multiple calls, to upload a chain of certificates from CA to the custom certificate itself.
func (s *CertificateService) UploadCustomCertificate(p *UploadCustomCertificateParams) (*UploadCustomCertificateResponse, error) {
resp, err := s.cs.newRequest("uploadCustomCertificate", p.toURLValues())
if err != nil {
return nil, err
}
var r UploadCustomCertificateResponse
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
// If we have a async client, we need to wait for the async result
if s.cs.async {
b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
if err != nil {
if err == AsyncTimeoutErr {
return &r, err
}
return nil, err
}
b, err = getRawValue(b)
if err != nil {
return nil, err
}
if err := json.Unmarshal(b, &r); err != nil {
return nil, err
}
}
return &r, nil
}
type UploadCustomCertificateResponse struct {
JobID string `json:"jobid,omitempty"`
Message string `json:"message,omitempty"`
}
//
// 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"
)
type GetCloudIdentifierParams struct {
p map[string]interface{}
}
func (p *GetCloudIdentifierParams) toURLValues() url.Values {
u := url.Values{}
if p.p == nil {
return u
}
if v, found := p.p["userid"]; found {
u.Set("userid", v.(string))
}
return u
}
func (p *GetCloudIdentifierParams) SetUserid(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["userid"] = v
return
}
// You should always use this function to get a new GetCloudIdentifierParams instance,
// as then you are sure you have configured all required params
func (s *CloudIdentifierService) NewGetCloudIdentifierParams(userid string) *GetCloudIdentifierParams {
p := &GetCloudIdentifierParams{}
p.p = make(map[string]interface{})
p.p["userid"] = userid
return p
}
// Retrieves a cloud identifier.
func (s *CloudIdentifierService) GetCloudIdentifier(p *GetCloudIdentifierParams) (*GetCloudIdentifierResponse, error) {
resp, err := s.cs.newRequest("getCloudIdentifier", p.toURLValues())
if err != nil {
return nil, err
}
var r GetCloudIdentifierResponse
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
return &r, nil
}
type GetCloudIdentifierResponse struct {
Cloudidentifier string `json:"cloudidentifier,omitempty"`
Signature string `json:"signature,omitempty"`
Userid string `json:"userid,omitempty"`
}
//
// 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"
"fmt"
"net/url"
"strconv"
"strings"
)
type ListHypervisorsParams struct {
p map[string]interface{}
}
func (p *ListHypervisorsParams) toURLValues() url.Values {
u := url.Values{}
if p.p == nil {
return u
}
if v, found := p.p["zoneid"]; found {
u.Set("zoneid", v.(string))
}
return u
}
func (p *ListHypervisorsParams) 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 ListHypervisorsParams instance,
// as then you are sure you have configured all required params
func (s *HypervisorService) NewListHypervisorsParams() *ListHypervisorsParams {
p := &ListHypervisorsParams{}
p.p = make(map[string]interface{})
return p
}
// List hypervisors
func (s *HypervisorService) ListHypervisors(p *ListHypervisorsParams) (*ListHypervisorsResponse, error) {
resp, err := s.cs.newRequest("listHypervisors", p.toURLValues())
if err != nil {
return nil, err
}
var r ListHypervisorsResponse
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
return &r, nil
}
type ListHypervisorsResponse struct {
Count int `json:"count"`
Hypervisors []*Hypervisor `json:"hypervisor"`
}
type Hypervisor struct {
Name string `json:"name,omitempty"`
}
type UpdateHypervisorCapabilitiesParams struct {
p map[string]interface{}
}
func (p *UpdateHypervisorCapabilitiesParams) toURLValues() url.Values {
u := url.Values{}
if p.p == nil {
return u
}
if v, found := p.p["id"]; found {
u.Set("id", v.(string))
}
if v, found := p.p["maxguestslimit"]; found {
vv := strconv.FormatInt(v.(int64), 10)
u.Set("maxguestslimit", vv)
}
if v, found := p.p["securitygroupenabled"]; found {
vv := strconv.FormatBool(v.(bool))
u.Set("securitygroupenabled", vv)
}
return u
}
func (p *UpdateHypervisorCapabilitiesParams) SetId(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["id"] = v
return
}
func (p *UpdateHypervisorCapabilitiesParams) SetMaxguestslimit(v int64) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["maxguestslimit"] = v
return
}
func (p *UpdateHypervisorCapabilitiesParams) SetSecuritygroupenabled(v bool) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["securitygroupenabled"] = v
return
}
// You should always use this function to get a new UpdateHypervisorCapabilitiesParams instance,
// as then you are sure you have configured all required params
func (s *HypervisorService) NewUpdateHypervisorCapabilitiesParams() *UpdateHypervisorCapabilitiesParams {
p := &UpdateHypervisorCapabilitiesParams{}
p.p = make(map[string]interface{})
return p
}
// Updates a hypervisor capabilities.
func (s *HypervisorService) UpdateHypervisorCapabilities(p *UpdateHypervisorCapabilitiesParams) (*UpdateHypervisorCapabilitiesResponse, error) {
resp, err := s.cs.newRequest("updateHypervisorCapabilities", p.toURLValues())
if err != nil {
return nil, err
}
var r UpdateHypervisorCapabilitiesResponse
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
return &r, nil
}
type UpdateHypervisorCapabilitiesResponse struct {
Hypervisor string `json:"hypervisor,omitempty"`
Hypervisorversion string `json:"hypervisorversion,omitempty"`
Id string `json:"id,omitempty"`
Maxdatavolumeslimit int `json:"maxdatavolumeslimit,omitempty"`
Maxguestslimit int64 `json:"maxguestslimit,omitempty"`
Maxhostspercluster int `json:"maxhostspercluster,omitempty"`
Securitygroupenabled bool `json:"securitygroupenabled,omitempty"`
Storagemotionenabled bool `json:"storagemotionenabled,omitempty"`
}
type ListHypervisorCapabilitiesParams struct {
p map[string]interface{}
}
func (p *ListHypervisorCapabilitiesParams) toURLValues() url.Values {
u := url.Values{}
if p.p == nil {
return u
}
if v, found := p.p["hypervisor"]; found {
u.Set("hypervisor", v.(string))
}
if v, found := p.p["id"]; found {
u.Set("id", v.(string))
}
if v, found := p.p["keyword"]; found {
u.Set("keyword", v.(string))
}
if v, found := p.p["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 *ListHypervisorCapabilitiesParams) SetHypervisor(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["hypervisor"] = v
return
}
func (p *ListHypervisorCapabilitiesParams) SetId(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["id"] = v
return
}
func (p *ListHypervisorCapabilitiesParams) SetKeyword(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["keyword"] = v
return
}
func (p *ListHypervisorCapabilitiesParams) SetPage(v int) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["page"] = v
return
}
func (p *ListHypervisorCapabilitiesParams) 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 ListHypervisorCapabilitiesParams instance,
// as then you are sure you have configured all required params
func (s *HypervisorService) NewListHypervisorCapabilitiesParams() *ListHypervisorCapabilitiesParams {
p := &ListHypervisorCapabilitiesParams{}
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 *HypervisorService) GetHypervisorCapabilityByID(id string, opts ...OptionFunc) (*HypervisorCapability, int, error) {
p := &ListHypervisorCapabilitiesParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListHypervisorCapabilities(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.HypervisorCapabilities[0], l.Count, nil
}
return nil, l.Count, fmt.Errorf("There is more then one result for HypervisorCapability UUID: %s!", id)
}
// Lists all hypervisor capabilities.
func (s *HypervisorService) ListHypervisorCapabilities(p *ListHypervisorCapabilitiesParams) (*ListHypervisorCapabilitiesResponse, error) {
resp, err := s.cs.newRequest("listHypervisorCapabilities", p.toURLValues())
if err != nil {
return nil, err
}
var r ListHypervisorCapabilitiesResponse
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
return &r, nil
}
type ListHypervisorCapabilitiesResponse struct {
Count int `json:"count"`
HypervisorCapabilities []*HypervisorCapability `json:"hypervisorcapability"`
}
type HypervisorCapability struct {
Hypervisor string `json:"hypervisor,omitempty"`
Hypervisorversion string `json:"hypervisorversion,omitempty"`
Id string `json:"id,omitempty"`
Maxdatavolumeslimit int `json:"maxdatavolumeslimit,omitempty"`
Maxguestslimit int64 `json:"maxguestslimit,omitempty"`
Maxhostspercluster int `json:"maxhostspercluster,omitempty"`
Securitygroupenabled bool `json:"securitygroupenabled,omitempty"`
Storagemotionenabled bool `json:"storagemotionenabled,omitempty"`
}
//
// 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"
"fmt"
"net/url"
"strconv"
)
type LdapCreateAccountParams struct {
p map[string]interface{}
}
func (p *LdapCreateAccountParams) 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["accountdetails"]; found {
i := 0
for k, vv := range v.(map[string]string) {
u.Set(fmt.Sprintf("accountdetails[%d].key", i), k)
u.Set(fmt.Sprintf("accountdetails[%d].value", i), vv)
i++
}
}
if v, found := p.p["accountid"]; found {
u.Set("accountid", v.(string))
}
if v, found := p.p["accounttype"]; found {
vv := strconv.Itoa(v.(int))
u.Set("accounttype", vv)
}
if v, found := p.p["domainid"]; found {
u.Set("domainid", v.(string))
}
if v, found := p.p["networkdomain"]; found {
u.Set("networkdomain", v.(string))
}
if v, found := p.p["timezone"]; found {
u.Set("timezone", v.(string))
}
if v, found := p.p["userid"]; found {
u.Set("userid", v.(string))
}
if v, found := p.p["username"]; found {
u.Set("username", v.(string))
}
return u
}
func (p *LdapCreateAccountParams) SetAccount(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["account"] = v
return
}
func (p *LdapCreateAccountParams) SetAccountdetails(v map[string]string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["accountdetails"] = v
return
}
func (p *LdapCreateAccountParams) SetAccountid(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["accountid"] = v
return
}
func (p *LdapCreateAccountParams) SetAccounttype(v int) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["accounttype"] = v
return
}
func (p *LdapCreateAccountParams) SetDomainid(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["domainid"] = v
return
}
func (p *LdapCreateAccountParams) SetNetworkdomain(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["networkdomain"] = v
return
}
func (p *LdapCreateAccountParams) SetTimezone(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["timezone"] = v
return
}
func (p *LdapCreateAccountParams) SetUserid(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["userid"] = v
return
}
func (p *LdapCreateAccountParams) SetUsername(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["username"] = v
return
}
// You should always use this function to get a new LdapCreateAccountParams instance,
// as then you are sure you have configured all required params
func (s *LDAPService) NewLdapCreateAccountParams(accounttype int, username string) *LdapCreateAccountParams {
p := &LdapCreateAccountParams{}
p.p = make(map[string]interface{})
p.p["accounttype"] = accounttype
p.p["username"] = username
return p
}
// Creates an account from an LDAP user
func (s *LDAPService) LdapCreateAccount(p *LdapCreateAccountParams) (*LdapCreateAccountResponse, error) {
resp, err := s.cs.newRequest("ldapCreateAccount", p.toURLValues())
if err != nil {
return nil, err
}
var r LdapCreateAccountResponse
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
return &r, nil
}
type LdapCreateAccountResponse struct {
Accountdetails map[string]string `json:"accountdetails,omitempty"`
Accounttype int `json:"accounttype,omitempty"`
Cpuavailable string `json:"cpuavailable,omitempty"`
Cpulimit string `json:"cpulimit,omitempty"`
Cputotal int64 `json:"cputotal,omitempty"`
Defaultzoneid string `json:"defaultzoneid,omitempty"`
Domain string `json:"domain,omitempty"`
Domainid string `json:"domainid,omitempty"`
Groups []string `json:"groups,omitempty"`
Id string `json:"id,omitempty"`
Ipavailable string `json:"ipavailable,omitempty"`
Iplimit string `json:"iplimit,omitempty"`
Iptotal int64 `json:"iptotal,omitempty"`
Iscleanuprequired bool `json:"iscleanuprequired,omitempty"`
Isdefault bool `json:"isdefault,omitempty"`
Memoryavailable string `json:"memoryavailable,omitempty"`
Memorylimit string `json:"memorylimit,omitempty"`
Memorytotal int64 `json:"memorytotal,omitempty"`
Name string `json:"name,omitempty"`
Networkavailable string `json:"networkavailable,omitempty"`
Networkdomain string `json:"networkdomain,omitempty"`
Networklimit string `json:"networklimit,omitempty"`
Networktotal int64 `json:"networktotal,omitempty"`
Primarystorageavailable string `json:"primarystorageavailable,omitempty"`
Primarystoragelimit string `json:"primarystoragelimit,omitempty"`
Primarystoragetotal int64 `json:"primarystoragetotal,omitempty"`
Projectavailable string `json:"projectavailable,omitempty"`
Projectlimit string `json:"projectlimit,omitempty"`
Projecttotal int64 `json:"projecttotal,omitempty"`
Receivedbytes int64 `json:"receivedbytes,omitempty"`
Secondarystorageavailable string `json:"secondarystorageavailable,omitempty"`
Secondarystoragelimit string `json:"secondarystoragelimit,omitempty"`
Secondarystoragetotal int64 `json:"secondarystoragetotal,omitempty"`
Sentbytes int64 `json:"sentbytes,omitempty"`
Snapshotavailable string `json:"snapshotavailable,omitempty"`
Snapshotlimit string `json:"snapshotlimit,omitempty"`
Snapshottotal int64 `json:"snapshottotal,omitempty"`
State string `json:"state,omitempty"`
Templateavailable string `json:"templateavailable,omitempty"`
Templatelimit string `json:"templatelimit,omitempty"`
Templatetotal int64 `json:"templatetotal,omitempty"`
User []struct {
Account string `json:"account,omitempty"`
Accountid string `json:"accountid,omitempty"`
Accounttype int `json:"accounttype,omitempty"`
Apikey string `json:"apikey,omitempty"`
Created string `json:"created,omitempty"`
Domain string `json:"domain,omitempty"`
Domainid string `json:"domainid,omitempty"`
Email string `json:"email,omitempty"`
Firstname string `json:"firstname,omitempty"`
Id string `json:"id,omitempty"`
Iscallerchilddomain bool `json:"iscallerchilddomain,omitempty"`
Isdefault bool `json:"isdefault,omitempty"`
Lastname string `json:"lastname,omitempty"`
Secretkey string `json:"secretkey,omitempty"`
State string `json:"state,omitempty"`
Timezone string `json:"timezone,omitempty"`
Username string `json:"username,omitempty"`
} `json:"user,omitempty"`
Vmavailable string `json:"vmavailable,omitempty"`
Vmlimit string `json:"vmlimit,omitempty"`
Vmrunning int `json:"vmrunning,omitempty"`
Vmstopped int `json:"vmstopped,omitempty"`
Vmtotal int64 `json:"vmtotal,omitempty"`
Volumeavailable string `json:"volumeavailable,omitempty"`
Volumelimit string `json:"volumelimit,omitempty"`
Volumetotal int64 `json:"volumetotal,omitempty"`
Vpcavailable string `json:"vpcavailable,omitempty"`
Vpclimit string `json:"vpclimit,omitempty"`
Vpctotal int64 `json:"vpctotal,omitempty"`
}
This source diff could not be displayed because it is too large. You can view the blob instead.
//
// 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"
"fmt"
"net/url"
"strconv"
)
type AddNetworkDeviceParams struct {
p map[string]interface{}
}
func (p *AddNetworkDeviceParams) toURLValues() url.Values {
u := url.Values{}
if p.p == nil {
return u
}
if v, found := p.p["networkdeviceparameterlist"]; found {
i := 0
for k, vv := range v.(map[string]string) {
u.Set(fmt.Sprintf("networkdeviceparameterlist[%d].key", i), k)
u.Set(fmt.Sprintf("networkdeviceparameterlist[%d].value", i), vv)
i++
}
}
if v, found := p.p["networkdevicetype"]; found {
u.Set("networkdevicetype", v.(string))
}
return u
}
func (p *AddNetworkDeviceParams) SetNetworkdeviceparameterlist(v map[string]string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["networkdeviceparameterlist"] = v
return
}
func (p *AddNetworkDeviceParams) SetNetworkdevicetype(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["networkdevicetype"] = v
return
}
// You should always use this function to get a new AddNetworkDeviceParams instance,
// as then you are sure you have configured all required params
func (s *NetworkDeviceService) NewAddNetworkDeviceParams() *AddNetworkDeviceParams {
p := &AddNetworkDeviceParams{}
p.p = make(map[string]interface{})
return p
}
// Adds a network device of one of the following types: ExternalDhcp, ExternalFirewall, ExternalLoadBalancer, PxeServer
func (s *NetworkDeviceService) AddNetworkDevice(p *AddNetworkDeviceParams) (*AddNetworkDeviceResponse, error) {
resp, err := s.cs.newRequest("addNetworkDevice", p.toURLValues())
if err != nil {
return nil, err
}
var r AddNetworkDeviceResponse
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
return &r, nil
}
type AddNetworkDeviceResponse struct {
Id string `json:"id,omitempty"`
}
type ListNetworkDeviceParams struct {
p map[string]interface{}
}
func (p *ListNetworkDeviceParams) 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["networkdeviceparameterlist"]; found {
i := 0
for k, vv := range v.(map[string]string) {
u.Set(fmt.Sprintf("networkdeviceparameterlist[%d].key", i), k)
u.Set(fmt.Sprintf("networkdeviceparameterlist[%d].value", i), vv)
i++
}
}
if v, found := p.p["networkdevicetype"]; found {
u.Set("networkdevicetype", 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 *ListNetworkDeviceParams) SetKeyword(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["keyword"] = v
return
}
func (p *ListNetworkDeviceParams) SetNetworkdeviceparameterlist(v map[string]string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["networkdeviceparameterlist"] = v
return
}
func (p *ListNetworkDeviceParams) SetNetworkdevicetype(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["networkdevicetype"] = v
return
}
func (p *ListNetworkDeviceParams) SetPage(v int) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["page"] = v
return
}
func (p *ListNetworkDeviceParams) 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 ListNetworkDeviceParams instance,
// as then you are sure you have configured all required params
func (s *NetworkDeviceService) NewListNetworkDeviceParams() *ListNetworkDeviceParams {
p := &ListNetworkDeviceParams{}
p.p = make(map[string]interface{})
return p
}
// List network devices
func (s *NetworkDeviceService) ListNetworkDevice(p *ListNetworkDeviceParams) (*ListNetworkDeviceResponse, error) {
resp, err := s.cs.newRequest("listNetworkDevice", p.toURLValues())
if err != nil {
return nil, err
}
var r ListNetworkDeviceResponse
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
return &r, nil
}
type ListNetworkDeviceResponse struct {
Count int `json:"count"`
NetworkDevice []*NetworkDevice `json:"networkdevice"`
}
type NetworkDevice struct {
Id string `json:"id,omitempty"`
}
type DeleteNetworkDeviceParams struct {
p map[string]interface{}
}
func (p *DeleteNetworkDeviceParams) 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 *DeleteNetworkDeviceParams) 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 DeleteNetworkDeviceParams instance,
// as then you are sure you have configured all required params
func (s *NetworkDeviceService) NewDeleteNetworkDeviceParams(id string) *DeleteNetworkDeviceParams {
p := &DeleteNetworkDeviceParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
return p
}
// Deletes network device.
func (s *NetworkDeviceService) DeleteNetworkDevice(p *DeleteNetworkDeviceParams) (*DeleteNetworkDeviceResponse, error) {
resp, err := s.cs.newRequest("deleteNetworkDevice", p.toURLValues())
if err != nil {
return nil, err
}
var r DeleteNetworkDeviceResponse
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
return &r, nil
}
type DeleteNetworkDeviceResponse struct {
Displaytext string `json:"displaytext,omitempty"`
Success string `json:"success,omitempty"`
}
This source diff could not be displayed because it is too large. You can view the blob instead.
//
// 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 AddNiciraNvpDeviceParams struct {
p map[string]interface{}
}
func (p *AddNiciraNvpDeviceParams) 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["l3gatewayserviceuuid"]; found {
u.Set("l3gatewayserviceuuid", v.(string))
}
if v, found := p.p["password"]; found {
u.Set("password", v.(string))
}
if v, found := p.p["physicalnetworkid"]; found {
u.Set("physicalnetworkid", v.(string))
}
if v, found := p.p["transportzoneuuid"]; found {
u.Set("transportzoneuuid", v.(string))
}
if v, found := p.p["username"]; found {
u.Set("username", v.(string))
}
return u
}
func (p *AddNiciraNvpDeviceParams) SetHostname(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["hostname"] = v
return
}
func (p *AddNiciraNvpDeviceParams) SetL3gatewayserviceuuid(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["l3gatewayserviceuuid"] = v
return
}
func (p *AddNiciraNvpDeviceParams) SetPassword(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["password"] = v
return
}
func (p *AddNiciraNvpDeviceParams) SetPhysicalnetworkid(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["physicalnetworkid"] = v
return
}
func (p *AddNiciraNvpDeviceParams) SetTransportzoneuuid(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["transportzoneuuid"] = v
return
}
func (p *AddNiciraNvpDeviceParams) SetUsername(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["username"] = v
return
}
// You should always use this function to get a new AddNiciraNvpDeviceParams instance,
// as then you are sure you have configured all required params
func (s *NiciraNVPService) NewAddNiciraNvpDeviceParams(hostname string, password string, physicalnetworkid string, transportzoneuuid string, username string) *AddNiciraNvpDeviceParams {
p := &AddNiciraNvpDeviceParams{}
p.p = make(map[string]interface{})
p.p["hostname"] = hostname
p.p["password"] = password
p.p["physicalnetworkid"] = physicalnetworkid
p.p["transportzoneuuid"] = transportzoneuuid
p.p["username"] = username
return p
}
// Adds a Nicira NVP device
func (s *NiciraNVPService) AddNiciraNvpDevice(p *AddNiciraNvpDeviceParams) (*AddNiciraNvpDeviceResponse, error) {
resp, err := s.cs.newRequest("addNiciraNvpDevice", p.toURLValues())
if err != nil {
return nil, err
}
var r AddNiciraNvpDeviceResponse
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
// If we have a async client, we need to wait for the async result
if s.cs.async {
b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
if err != nil {
if err == AsyncTimeoutErr {
return &r, err
}
return nil, err
}
b, err = getRawValue(b)
if err != nil {
return nil, err
}
if err := json.Unmarshal(b, &r); err != nil {
return nil, err
}
}
return &r, nil
}
type AddNiciraNvpDeviceResponse struct {
JobID string `json:"jobid,omitempty"`
Hostname string `json:"hostname,omitempty"`
L3gatewayserviceuuid string `json:"l3gatewayserviceuuid,omitempty"`
Niciradevicename string `json:"niciradevicename,omitempty"`
Nvpdeviceid string `json:"nvpdeviceid,omitempty"`
Physicalnetworkid string `json:"physicalnetworkid,omitempty"`
Provider string `json:"provider,omitempty"`
Transportzoneuuid string `json:"transportzoneuuid,omitempty"`
}
type DeleteNiciraNvpDeviceParams struct {
p map[string]interface{}
}
func (p *DeleteNiciraNvpDeviceParams) toURLValues() url.Values {
u := url.Values{}
if p.p == nil {
return u
}
if v, found := p.p["nvpdeviceid"]; found {
u.Set("nvpdeviceid", v.(string))
}
return u
}
func (p *DeleteNiciraNvpDeviceParams) SetNvpdeviceid(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["nvpdeviceid"] = v
return
}
// You should always use this function to get a new DeleteNiciraNvpDeviceParams instance,
// as then you are sure you have configured all required params
func (s *NiciraNVPService) NewDeleteNiciraNvpDeviceParams(nvpdeviceid string) *DeleteNiciraNvpDeviceParams {
p := &DeleteNiciraNvpDeviceParams{}
p.p = make(map[string]interface{})
p.p["nvpdeviceid"] = nvpdeviceid
return p
}
// delete a nicira nvp device
func (s *NiciraNVPService) DeleteNiciraNvpDevice(p *DeleteNiciraNvpDeviceParams) (*DeleteNiciraNvpDeviceResponse, error) {
resp, err := s.cs.newRequest("deleteNiciraNvpDevice", p.toURLValues())
if err != nil {
return nil, err
}
var r DeleteNiciraNvpDeviceResponse
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
}
}
return &r, nil
}
type DeleteNiciraNvpDeviceResponse struct {
JobID string `json:"jobid,omitempty"`
Displaytext string `json:"displaytext,omitempty"`
Success bool `json:"success,omitempty"`
}
type ListNiciraNvpDevicesParams struct {
p map[string]interface{}
}
func (p *ListNiciraNvpDevicesParams) 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["nvpdeviceid"]; found {
u.Set("nvpdeviceid", 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["physicalnetworkid"]; found {
u.Set("physicalnetworkid", v.(string))
}
return u
}
func (p *ListNiciraNvpDevicesParams) SetKeyword(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["keyword"] = v
return
}
func (p *ListNiciraNvpDevicesParams) SetNvpdeviceid(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["nvpdeviceid"] = v
return
}
func (p *ListNiciraNvpDevicesParams) SetPage(v int) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["page"] = v
return
}
func (p *ListNiciraNvpDevicesParams) SetPagesize(v int) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["pagesize"] = v
return
}
func (p *ListNiciraNvpDevicesParams) SetPhysicalnetworkid(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["physicalnetworkid"] = v
return
}
// You should always use this function to get a new ListNiciraNvpDevicesParams instance,
// as then you are sure you have configured all required params
func (s *NiciraNVPService) NewListNiciraNvpDevicesParams() *ListNiciraNvpDevicesParams {
p := &ListNiciraNvpDevicesParams{}
p.p = make(map[string]interface{})
return p
}
// Lists Nicira NVP devices
func (s *NiciraNVPService) ListNiciraNvpDevices(p *ListNiciraNvpDevicesParams) (*ListNiciraNvpDevicesResponse, error) {
resp, err := s.cs.newRequest("listNiciraNvpDevices", p.toURLValues())
if err != nil {
return nil, err
}
var r ListNiciraNvpDevicesResponse
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
return &r, nil
}
type ListNiciraNvpDevicesResponse struct {
Count int `json:"count"`
NiciraNvpDevices []*NiciraNvpDevice `json:"niciranvpdevice"`
}
type NiciraNvpDevice struct {
Hostname string `json:"hostname,omitempty"`
L3gatewayserviceuuid string `json:"l3gatewayserviceuuid,omitempty"`
Niciradevicename string `json:"niciradevicename,omitempty"`
Nvpdeviceid string `json:"nvpdeviceid,omitempty"`
Physicalnetworkid string `json:"physicalnetworkid,omitempty"`
Provider string `json:"provider,omitempty"`
Transportzoneuuid string `json:"transportzoneuuid,omitempty"`
}
//
// 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"
"fmt"
"net/url"
"strconv"
"strings"
)
type ConfigureOvsElementParams struct {
p map[string]interface{}
}
func (p *ConfigureOvsElementParams) toURLValues() url.Values {
u := url.Values{}
if p.p == nil {
return u
}
if v, found := p.p["enabled"]; found {
vv := strconv.FormatBool(v.(bool))
u.Set("enabled", vv)
}
if v, found := p.p["id"]; found {
u.Set("id", v.(string))
}
return u
}
func (p *ConfigureOvsElementParams) SetEnabled(v bool) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["enabled"] = v
return
}
func (p *ConfigureOvsElementParams) 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 ConfigureOvsElementParams instance,
// as then you are sure you have configured all required params
func (s *OvsElementService) NewConfigureOvsElementParams(enabled bool, id string) *ConfigureOvsElementParams {
p := &ConfigureOvsElementParams{}
p.p = make(map[string]interface{})
p.p["enabled"] = enabled
p.p["id"] = id
return p
}
// Configures an ovs element.
func (s *OvsElementService) ConfigureOvsElement(p *ConfigureOvsElementParams) (*ConfigureOvsElementResponse, error) {
resp, err := s.cs.newRequest("configureOvsElement", p.toURLValues())
if err != nil {
return nil, err
}
var r ConfigureOvsElementResponse
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
// If we have a async client, we need to wait for the async result
if s.cs.async {
b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
if err != nil {
if err == AsyncTimeoutErr {
return &r, err
}
return nil, err
}
b, err = getRawValue(b)
if err != nil {
return nil, err
}
if err := json.Unmarshal(b, &r); err != nil {
return nil, err
}
}
return &r, nil
}
type ConfigureOvsElementResponse struct {
JobID string `json:"jobid,omitempty"`
Account string `json:"account,omitempty"`
Domain string `json:"domain,omitempty"`
Domainid string `json:"domainid,omitempty"`
Enabled bool `json:"enabled,omitempty"`
Id string `json:"id,omitempty"`
Nspid string `json:"nspid,omitempty"`
Project string `json:"project,omitempty"`
Projectid string `json:"projectid,omitempty"`
}
type ListOvsElementsParams struct {
p map[string]interface{}
}
func (p *ListOvsElementsParams) toURLValues() url.Values {
u := url.Values{}
if p.p == nil {
return u
}
if v, found := p.p["enabled"]; found {
vv := strconv.FormatBool(v.(bool))
u.Set("enabled", vv)
}
if v, found := p.p["id"]; found {
u.Set("id", v.(string))
}
if v, found := p.p["keyword"]; found {
u.Set("keyword", v.(string))
}
if v, found := p.p["nspid"]; found {
u.Set("nspid", 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 *ListOvsElementsParams) SetEnabled(v bool) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["enabled"] = v
return
}
func (p *ListOvsElementsParams) SetId(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["id"] = v
return
}
func (p *ListOvsElementsParams) SetKeyword(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["keyword"] = v
return
}
func (p *ListOvsElementsParams) SetNspid(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["nspid"] = v
return
}
func (p *ListOvsElementsParams) SetPage(v int) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["page"] = v
return
}
func (p *ListOvsElementsParams) 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 ListOvsElementsParams instance,
// as then you are sure you have configured all required params
func (s *OvsElementService) NewListOvsElementsParams() *ListOvsElementsParams {
p := &ListOvsElementsParams{}
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 *OvsElementService) GetOvsElementByID(id string, opts ...OptionFunc) (*OvsElement, int, error) {
p := &ListOvsElementsParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListOvsElements(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.OvsElements[0], l.Count, nil
}
return nil, l.Count, fmt.Errorf("There is more then one result for OvsElement UUID: %s!", id)
}
// Lists all available ovs elements.
func (s *OvsElementService) ListOvsElements(p *ListOvsElementsParams) (*ListOvsElementsResponse, error) {
resp, err := s.cs.newRequest("listOvsElements", p.toURLValues())
if err != nil {
return nil, err
}
var r ListOvsElementsResponse
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
return &r, nil
}
type ListOvsElementsResponse struct {
Count int `json:"count"`
OvsElements []*OvsElement `json:"ovselement"`
}
type OvsElement struct {
Account string `json:"account,omitempty"`
Domain string `json:"domain,omitempty"`
Domainid string `json:"domainid,omitempty"`
Enabled bool `json:"enabled,omitempty"`
Id string `json:"id,omitempty"`
Nspid string `json:"nspid,omitempty"`
Project string `json:"project,omitempty"`
Projectid string `json:"projectid,omitempty"`
}
//
// 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"
)
type QuotaIsEnabledParams struct {
p map[string]interface{}
}
func (p *QuotaIsEnabledParams) toURLValues() url.Values {
u := url.Values{}
if p.p == nil {
return u
}
return u
}
// You should always use this function to get a new QuotaIsEnabledParams instance,
// as then you are sure you have configured all required params
func (s *QuotaService) NewQuotaIsEnabledParams() *QuotaIsEnabledParams {
p := &QuotaIsEnabledParams{}
p.p = make(map[string]interface{})
return p
}
// Return true if the plugin is enabled
func (s *QuotaService) QuotaIsEnabled(p *QuotaIsEnabledParams) (*QuotaIsEnabledResponse, error) {
resp, err := s.cs.newRequest("quotaIsEnabled", p.toURLValues())
if err != nil {
return nil, err
}
var r QuotaIsEnabledResponse
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
return &r, nil
}
type QuotaIsEnabledResponse struct {
Isenabled bool `json:"isenabled,omitempty"`
}
//
// 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 AddRegionParams struct {
p map[string]interface{}
}
func (p *AddRegionParams) toURLValues() url.Values {
u := url.Values{}
if p.p == nil {
return u
}
if v, found := p.p["endpoint"]; found {
u.Set("endpoint", v.(string))
}
if v, found := p.p["id"]; found {
vv := strconv.Itoa(v.(int))
u.Set("id", vv)
}
if v, found := p.p["name"]; found {
u.Set("name", v.(string))
}
return u
}
func (p *AddRegionParams) SetEndpoint(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["endpoint"] = v
return
}
func (p *AddRegionParams) SetId(v int) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["id"] = v
return
}
func (p *AddRegionParams) SetName(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["name"] = v
return
}
// You should always use this function to get a new AddRegionParams instance,
// as then you are sure you have configured all required params
func (s *RegionService) NewAddRegionParams(endpoint string, id int, name string) *AddRegionParams {
p := &AddRegionParams{}
p.p = make(map[string]interface{})
p.p["endpoint"] = endpoint
p.p["id"] = id
p.p["name"] = name
return p
}
// Adds a Region
func (s *RegionService) AddRegion(p *AddRegionParams) (*AddRegionResponse, error) {
resp, err := s.cs.newRequest("addRegion", p.toURLValues())
if err != nil {
return nil, err
}
var r AddRegionResponse
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
return &r, nil
}
type AddRegionResponse struct {
Endpoint string `json:"endpoint,omitempty"`
Gslbserviceenabled bool `json:"gslbserviceenabled,omitempty"`
Id int `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Portableipserviceenabled bool `json:"portableipserviceenabled,omitempty"`
}
type UpdateRegionParams struct {
p map[string]interface{}
}
func (p *UpdateRegionParams) toURLValues() url.Values {
u := url.Values{}
if p.p == nil {
return u
}
if v, found := p.p["endpoint"]; found {
u.Set("endpoint", v.(string))
}
if v, found := p.p["id"]; found {
vv := strconv.Itoa(v.(int))
u.Set("id", vv)
}
if v, found := p.p["name"]; found {
u.Set("name", v.(string))
}
return u
}
func (p *UpdateRegionParams) SetEndpoint(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["endpoint"] = v
return
}
func (p *UpdateRegionParams) SetId(v int) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["id"] = v
return
}
func (p *UpdateRegionParams) SetName(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["name"] = v
return
}
// You should always use this function to get a new UpdateRegionParams instance,
// as then you are sure you have configured all required params
func (s *RegionService) NewUpdateRegionParams(id int) *UpdateRegionParams {
p := &UpdateRegionParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
return p
}
// Updates a region
func (s *RegionService) UpdateRegion(p *UpdateRegionParams) (*UpdateRegionResponse, error) {
resp, err := s.cs.newRequest("updateRegion", p.toURLValues())
if err != nil {
return nil, err
}
var r UpdateRegionResponse
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
return &r, nil
}
type UpdateRegionResponse struct {
Endpoint string `json:"endpoint,omitempty"`
Gslbserviceenabled bool `json:"gslbserviceenabled,omitempty"`
Id int `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Portableipserviceenabled bool `json:"portableipserviceenabled,omitempty"`
}
type RemoveRegionParams struct {
p map[string]interface{}
}
func (p *RemoveRegionParams) toURLValues() url.Values {
u := url.Values{}
if p.p == nil {
return u
}
if v, found := p.p["id"]; found {
vv := strconv.Itoa(v.(int))
u.Set("id", vv)
}
return u
}
func (p *RemoveRegionParams) SetId(v int) {
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 RemoveRegionParams instance,
// as then you are sure you have configured all required params
func (s *RegionService) NewRemoveRegionParams(id int) *RemoveRegionParams {
p := &RemoveRegionParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
return p
}
// Removes specified region
func (s *RegionService) RemoveRegion(p *RemoveRegionParams) (*RemoveRegionResponse, error) {
resp, err := s.cs.newRequest("removeRegion", p.toURLValues())
if err != nil {
return nil, err
}
var r RemoveRegionResponse
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
return &r, nil
}
type RemoveRegionResponse struct {
Displaytext string `json:"displaytext,omitempty"`
Success string `json:"success,omitempty"`
}
type ListRegionsParams struct {
p map[string]interface{}
}
func (p *ListRegionsParams) toURLValues() url.Values {
u := url.Values{}
if p.p == nil {
return u
}
if v, found := p.p["id"]; found {
vv := strconv.Itoa(v.(int))
u.Set("id", vv)
}
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)
}
return u
}
func (p *ListRegionsParams) SetId(v int) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["id"] = v
return
}
func (p *ListRegionsParams) SetKeyword(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["keyword"] = v
return
}
func (p *ListRegionsParams) SetName(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["name"] = v
return
}
func (p *ListRegionsParams) SetPage(v int) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["page"] = v
return
}
func (p *ListRegionsParams) 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 ListRegionsParams instance,
// as then you are sure you have configured all required params
func (s *RegionService) NewListRegionsParams() *ListRegionsParams {
p := &ListRegionsParams{}
p.p = make(map[string]interface{})
return p
}
// Lists Regions
func (s *RegionService) ListRegions(p *ListRegionsParams) (*ListRegionsResponse, error) {
resp, err := s.cs.newRequest("listRegions", p.toURLValues())
if err != nil {
return nil, err
}
var r ListRegionsResponse
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
return &r, nil
}
type ListRegionsResponse struct {
Count int `json:"count"`
Regions []*Region `json:"region"`
}
type Region struct {
Endpoint string `json:"endpoint,omitempty"`
Gslbserviceenabled bool `json:"gslbserviceenabled,omitempty"`
Id int `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Portableipserviceenabled bool `json:"portableipserviceenabled,omitempty"`
}
//
// 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 ListStorageProvidersParams struct {
p map[string]interface{}
}
func (p *ListStorageProvidersParams) 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)
}
if v, found := p.p["type"]; found {
u.Set("type", v.(string))
}
return u
}
func (p *ListStorageProvidersParams) SetKeyword(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["keyword"] = v
return
}
func (p *ListStorageProvidersParams) SetPage(v int) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["page"] = v
return
}
func (p *ListStorageProvidersParams) SetPagesize(v int) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["pagesize"] = v
return
}
func (p *ListStorageProvidersParams) SetType(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["storagePoolType"] = v
return
}
// You should always use this function to get a new ListStorageProvidersParams instance,
// as then you are sure you have configured all required params
func (s *StoragePoolService) NewListStorageProvidersParams(storagePoolType string) *ListStorageProvidersParams {
p := &ListStorageProvidersParams{}
p.p = make(map[string]interface{})
p.p["storagePoolType"] = storagePoolType
return p
}
// Lists storage providers.
func (s *StoragePoolService) ListStorageProviders(p *ListStorageProvidersParams) (*ListStorageProvidersResponse, error) {
resp, err := s.cs.newRequest("listStorageProviders", p.toURLValues())
if err != nil {
return nil, err
}
var r ListStorageProvidersResponse
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
return &r, nil
}
type ListStorageProvidersResponse struct {
Count int `json:"count"`
StorageProviders []*StorageProvider `json:"storageprovider"`
}
type StorageProvider struct {
Name string `json:"name,omitempty"`
Type string `json:"type,omitempty"`
}
type EnableStorageMaintenanceParams struct {
p map[string]interface{}
}
func (p *EnableStorageMaintenanceParams) 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 *EnableStorageMaintenanceParams) 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 EnableStorageMaintenanceParams instance,
// as then you are sure you have configured all required params
func (s *StoragePoolService) NewEnableStorageMaintenanceParams(id string) *EnableStorageMaintenanceParams {
p := &EnableStorageMaintenanceParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
return p
}
// Puts storage pool into maintenance state
func (s *StoragePoolService) EnableStorageMaintenance(p *EnableStorageMaintenanceParams) (*EnableStorageMaintenanceResponse, error) {
resp, err := s.cs.newRequest("enableStorageMaintenance", p.toURLValues())
if err != nil {
return nil, err
}
var r EnableStorageMaintenanceResponse
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
// If we have a async client, we need to wait for the async result
if s.cs.async {
b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
if err != nil {
if err == AsyncTimeoutErr {
return &r, err
}
return nil, err
}
b, err = getRawValue(b)
if err != nil {
return nil, err
}
if err := json.Unmarshal(b, &r); err != nil {
return nil, err
}
}
return &r, nil
}
type EnableStorageMaintenanceResponse struct {
JobID string `json:"jobid,omitempty"`
Capacityiops int64 `json:"capacityiops,omitempty"`
Clusterid string `json:"clusterid,omitempty"`
Clustername string `json:"clustername,omitempty"`
Created string `json:"created,omitempty"`
Disksizeallocated int64 `json:"disksizeallocated,omitempty"`
Disksizetotal int64 `json:"disksizetotal,omitempty"`
Disksizeused int64 `json:"disksizeused,omitempty"`
Hypervisor string `json:"hypervisor,omitempty"`
Id string `json:"id,omitempty"`
Ipaddress string `json:"ipaddress,omitempty"`
Name string `json:"name,omitempty"`
Overprovisionfactor string `json:"overprovisionfactor,omitempty"`
Path string `json:"path,omitempty"`
Podid string `json:"podid,omitempty"`
Podname string `json:"podname,omitempty"`
Scope string `json:"scope,omitempty"`
State string `json:"state,omitempty"`
Storagecapabilities map[string]string `json:"storagecapabilities,omitempty"`
Suitableformigration bool `json:"suitableformigration,omitempty"`
Tags string `json:"tags,omitempty"`
Type string `json:"type,omitempty"`
Zoneid string `json:"zoneid,omitempty"`
Zonename string `json:"zonename,omitempty"`
}
type CancelStorageMaintenanceParams struct {
p map[string]interface{}
}
func (p *CancelStorageMaintenanceParams) 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 *CancelStorageMaintenanceParams) 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 CancelStorageMaintenanceParams instance,
// as then you are sure you have configured all required params
func (s *StoragePoolService) NewCancelStorageMaintenanceParams(id string) *CancelStorageMaintenanceParams {
p := &CancelStorageMaintenanceParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
return p
}
// Cancels maintenance for primary storage
func (s *StoragePoolService) CancelStorageMaintenance(p *CancelStorageMaintenanceParams) (*CancelStorageMaintenanceResponse, error) {
resp, err := s.cs.newRequest("cancelStorageMaintenance", p.toURLValues())
if err != nil {
return nil, err
}
var r CancelStorageMaintenanceResponse
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
// If we have a async client, we need to wait for the async result
if s.cs.async {
b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
if err != nil {
if err == AsyncTimeoutErr {
return &r, err
}
return nil, err
}
b, err = getRawValue(b)
if err != nil {
return nil, err
}
if err := json.Unmarshal(b, &r); err != nil {
return nil, err
}
}
return &r, nil
}
type CancelStorageMaintenanceResponse struct {
JobID string `json:"jobid,omitempty"`
Capacityiops int64 `json:"capacityiops,omitempty"`
Clusterid string `json:"clusterid,omitempty"`
Clustername string `json:"clustername,omitempty"`
Created string `json:"created,omitempty"`
Disksizeallocated int64 `json:"disksizeallocated,omitempty"`
Disksizetotal int64 `json:"disksizetotal,omitempty"`
Disksizeused int64 `json:"disksizeused,omitempty"`
Hypervisor string `json:"hypervisor,omitempty"`
Id string `json:"id,omitempty"`
Ipaddress string `json:"ipaddress,omitempty"`
Name string `json:"name,omitempty"`
Overprovisionfactor string `json:"overprovisionfactor,omitempty"`
Path string `json:"path,omitempty"`
Podid string `json:"podid,omitempty"`
Podname string `json:"podname,omitempty"`
Scope string `json:"scope,omitempty"`
State string `json:"state,omitempty"`
Storagecapabilities map[string]string `json:"storagecapabilities,omitempty"`
Suitableformigration bool `json:"suitableformigration,omitempty"`
Tags string `json:"tags,omitempty"`
Type string `json:"type,omitempty"`
Zoneid string `json:"zoneid,omitempty"`
Zonename string `json:"zonename,omitempty"`
}
//
// 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"
)
type AddStratosphereSspParams struct {
p map[string]interface{}
}
func (p *AddStratosphereSspParams) toURLValues() url.Values {
u := url.Values{}
if p.p == nil {
return u
}
if v, found := p.p["name"]; found {
u.Set("name", v.(string))
}
if v, found := p.p["password"]; found {
u.Set("password", v.(string))
}
if v, found := p.p["tenantuuid"]; found {
u.Set("tenantuuid", v.(string))
}
if v, found := p.p["url"]; found {
u.Set("url", v.(string))
}
if v, found := p.p["username"]; found {
u.Set("username", v.(string))
}
if v, found := p.p["zoneid"]; found {
u.Set("zoneid", v.(string))
}
return u
}
func (p *AddStratosphereSspParams) SetName(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["name"] = v
return
}
func (p *AddStratosphereSspParams) SetPassword(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["password"] = v
return
}
func (p *AddStratosphereSspParams) SetTenantuuid(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["tenantuuid"] = v
return
}
func (p *AddStratosphereSspParams) SetUrl(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["url"] = v
return
}
func (p *AddStratosphereSspParams) SetUsername(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["username"] = v
return
}
func (p *AddStratosphereSspParams) 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 AddStratosphereSspParams instance,
// as then you are sure you have configured all required params
func (s *StratosphereSSPService) NewAddStratosphereSspParams(name string, url string, zoneid string) *AddStratosphereSspParams {
p := &AddStratosphereSspParams{}
p.p = make(map[string]interface{})
p.p["name"] = name
p.p["url"] = url
p.p["zoneid"] = zoneid
return p
}
// Adds stratosphere ssp server
func (s *StratosphereSSPService) AddStratosphereSsp(p *AddStratosphereSspParams) (*AddStratosphereSspResponse, error) {
resp, err := s.cs.newRequest("addStratosphereSsp", p.toURLValues())
if err != nil {
return nil, err
}
var r AddStratosphereSspResponse
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
return &r, nil
}
type AddStratosphereSspResponse struct {
Hostid string `json:"hostid,omitempty"`
Name string `json:"name,omitempty"`
Url string `json:"url,omitempty"`
Zoneid string `json:"zoneid,omitempty"`
}
//
// 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"
"fmt"
"net/url"
"strconv"
)
type AddSwiftParams struct {
p map[string]interface{}
}
func (p *AddSwiftParams) 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["key"]; found {
u.Set("key", v.(string))
}
if v, found := p.p["url"]; found {
u.Set("url", v.(string))
}
if v, found := p.p["username"]; found {
u.Set("username", v.(string))
}
return u
}
func (p *AddSwiftParams) SetAccount(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["account"] = v
return
}
func (p *AddSwiftParams) SetKey(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["key"] = v
return
}
func (p *AddSwiftParams) SetUrl(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["url"] = v
return
}
func (p *AddSwiftParams) SetUsername(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["username"] = v
return
}
// You should always use this function to get a new AddSwiftParams instance,
// as then you are sure you have configured all required params
func (s *SwiftService) NewAddSwiftParams(url string) *AddSwiftParams {
p := &AddSwiftParams{}
p.p = make(map[string]interface{})
p.p["url"] = url
return p
}
// Adds Swift.
func (s *SwiftService) AddSwift(p *AddSwiftParams) (*AddSwiftResponse, error) {
resp, err := s.cs.newRequest("addSwift", p.toURLValues())
if err != nil {
return nil, err
}
var r AddSwiftResponse
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
return &r, nil
}
type AddSwiftResponse struct {
Details []string `json:"details,omitempty"`
Id string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Protocol string `json:"protocol,omitempty"`
Providername string `json:"providername,omitempty"`
Scope string `json:"scope,omitempty"`
Url string `json:"url,omitempty"`
Zoneid string `json:"zoneid,omitempty"`
Zonename string `json:"zonename,omitempty"`
}
type ListSwiftsParams struct {
p map[string]interface{}
}
func (p *ListSwiftsParams) toURLValues() url.Values {
u := url.Values{}
if p.p == nil {
return u
}
if v, found := p.p["id"]; found {
vv := strconv.FormatInt(v.(int64), 10)
u.Set("id", vv)
}
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 *ListSwiftsParams) SetId(v int64) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["id"] = v
return
}
func (p *ListSwiftsParams) SetKeyword(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["keyword"] = v
return
}
func (p *ListSwiftsParams) SetPage(v int) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["page"] = v
return
}
func (p *ListSwiftsParams) 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 ListSwiftsParams instance,
// as then you are sure you have configured all required params
func (s *SwiftService) NewListSwiftsParams() *ListSwiftsParams {
p := &ListSwiftsParams{}
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 *SwiftService) GetSwiftID(keyword string, opts ...OptionFunc) (string, int, error) {
p := &ListSwiftsParams{}
p.p = make(map[string]interface{})
p.p["keyword"] = keyword
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", -1, err
}
}
l, err := s.ListSwifts(p)
if err != nil {
return "", -1, err
}
if l.Count == 0 {
return "", l.Count, fmt.Errorf("No match found for %s: %+v", keyword, l)
}
if l.Count == 1 {
return l.Swifts[0].Id, l.Count, nil
}
if l.Count > 1 {
for _, v := range l.Swifts {
if v.Name == keyword {
return v.Id, l.Count, nil
}
}
}
return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", keyword, l)
}
// List Swift.
func (s *SwiftService) ListSwifts(p *ListSwiftsParams) (*ListSwiftsResponse, error) {
resp, err := s.cs.newRequest("listSwifts", p.toURLValues())
if err != nil {
return nil, err
}
var r ListSwiftsResponse
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
return &r, nil
}
type ListSwiftsResponse struct {
Count int `json:"count"`
Swifts []*Swift `json:"swift"`
}
type Swift struct {
Details []string `json:"details,omitempty"`
Id string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Protocol string `json:"protocol,omitempty"`
Providername string `json:"providername,omitempty"`
Scope string `json:"scope,omitempty"`
Url string `json:"url,omitempty"`
Zoneid string `json:"zoneid,omitempty"`
Zonename string `json:"zonename,omitempty"`
}
//
// 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 ListCapacityParams struct {
p map[string]interface{}
}
func (p *ListCapacityParams) toURLValues() url.Values {
u := url.Values{}
if p.p == nil {
return u
}
if v, found := p.p["clusterid"]; found {
u.Set("clusterid", v.(string))
}
if v, found := p.p["fetchlatest"]; found {
vv := strconv.FormatBool(v.(bool))
u.Set("fetchlatest", vv)
}
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["podid"]; found {
u.Set("podid", v.(string))
}
if v, found := p.p["sortby"]; found {
u.Set("sortby", v.(string))
}
if v, found := p.p["type"]; found {
vv := strconv.Itoa(v.(int))
u.Set("type", vv)
}
if v, found := p.p["zoneid"]; found {
u.Set("zoneid", v.(string))
}
return u
}
func (p *ListCapacityParams) SetClusterid(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["clusterid"] = v
return
}
func (p *ListCapacityParams) SetFetchlatest(v bool) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["fetchlatest"] = v
return
}
func (p *ListCapacityParams) SetKeyword(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["keyword"] = v
return
}
func (p *ListCapacityParams) SetPage(v int) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["page"] = v
return
}
func (p *ListCapacityParams) SetPagesize(v int) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["pagesize"] = v
return
}
func (p *ListCapacityParams) SetPodid(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["podid"] = v
return
}
func (p *ListCapacityParams) SetSortby(v string) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["sortby"] = v
return
}
func (p *ListCapacityParams) SetType(v int) {
if p.p == nil {
p.p = make(map[string]interface{})
}
p.p["systemCapacityType"] = v
return
}
func (p *ListCapacityParams) 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 ListCapacityParams instance,
// as then you are sure you have configured all required params
func (s *SystemCapacityService) NewListCapacityParams() *ListCapacityParams {
p := &ListCapacityParams{}
p.p = make(map[string]interface{})
return p
}
// Lists all the system wide capacities.
func (s *SystemCapacityService) ListCapacity(p *ListCapacityParams) (*ListCapacityResponse, error) {
resp, err := s.cs.newRequest("listCapacity", p.toURLValues())
if err != nil {
return nil, err
}
var r ListCapacityResponse
if err := json.Unmarshal(resp, &r); err != nil {
return nil, err
}
return &r, nil
}
type ListCapacityResponse struct {
Count int `json:"count"`
Capacity []*Capacity `json:"capacity"`
}
type Capacity struct {
Capacitytotal int64 `json:"capacitytotal,omitempty"`
Capacityused int64 `json:"capacityused,omitempty"`
Clusterid string `json:"clusterid,omitempty"`
Clustername string `json:"clustername,omitempty"`
Percentused string `json:"percentused,omitempty"`
Podid string `json:"podid,omitempty"`
Podname string `json:"podname,omitempty"`
Type int `json:"type,omitempty"`
Zoneid string `json:"zoneid,omitempty"`
Zonename string `json:"zonename,omitempty"`
}
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment