PageRenderTime 79ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/vendor/github.com/xanzy/go-cloudstack/cloudstack/cloudstack.go

https://gitlab.com/unofficial-mirrors/kubernetes
Go | 936 lines | 708 code | 171 blank | 57 comment | 47 complexity | 6eb33b2aee0dba799557b9444dee13c1 MD5 | raw file
  1. //
  2. // Copyright 2016, Sander van Harmelen
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. package cloudstack
  17. import (
  18. "bytes"
  19. "crypto/hmac"
  20. "crypto/sha1"
  21. "crypto/tls"
  22. "encoding/base64"
  23. "encoding/json"
  24. "errors"
  25. "fmt"
  26. "io/ioutil"
  27. "net/http"
  28. "net/url"
  29. "regexp"
  30. "sort"
  31. "strings"
  32. "time"
  33. )
  34. // UnlimitedResourceID is a special ID to define an unlimited resource
  35. const UnlimitedResourceID = "-1"
  36. var idRegex = regexp.MustCompile(`^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|-1)$`)
  37. // IsID return true if the passed ID is either a UUID or a UnlimitedResourceID
  38. func IsID(id string) bool {
  39. return idRegex.MatchString(id)
  40. }
  41. // OptionFunc can be passed to the courtesy helper functions to set additional parameters
  42. type OptionFunc func(*CloudStackClient, interface{}) error
  43. type CSError struct {
  44. ErrorCode int `json:"errorcode"`
  45. CSErrorCode int `json:"cserrorcode"`
  46. ErrorText string `json:"errortext"`
  47. }
  48. func (e *CSError) Error() error {
  49. return fmt.Errorf("CloudStack API error %d (CSExceptionErrorCode: %d): %s", e.ErrorCode, e.CSErrorCode, e.ErrorText)
  50. }
  51. type CloudStackClient struct {
  52. HTTPGETOnly bool // If `true` only use HTTP GET calls
  53. client *http.Client // The http client for communicating
  54. baseURL string // The base URL of the API
  55. apiKey string // Api key
  56. secret string // Secret key
  57. async bool // Wait for async calls to finish
  58. timeout int64 // Max waiting timeout in seconds for async jobs to finish; defaults to 300 seconds
  59. APIDiscovery *APIDiscoveryService
  60. Account *AccountService
  61. Address *AddressService
  62. AffinityGroup *AffinityGroupService
  63. Alert *AlertService
  64. Asyncjob *AsyncjobService
  65. Authentication *AuthenticationService
  66. AutoScale *AutoScaleService
  67. Baremetal *BaremetalService
  68. Certificate *CertificateService
  69. CloudIdentifier *CloudIdentifierService
  70. Cluster *ClusterService
  71. Configuration *ConfigurationService
  72. DiskOffering *DiskOfferingService
  73. Domain *DomainService
  74. Event *EventService
  75. Firewall *FirewallService
  76. GuestOS *GuestOSService
  77. Host *HostService
  78. Hypervisor *HypervisorService
  79. ISO *ISOService
  80. ImageStore *ImageStoreService
  81. InternalLB *InternalLBService
  82. LDAP *LDAPService
  83. Limit *LimitService
  84. LoadBalancer *LoadBalancerService
  85. NAT *NATService
  86. NetworkACL *NetworkACLService
  87. NetworkDevice *NetworkDeviceService
  88. NetworkOffering *NetworkOfferingService
  89. Network *NetworkService
  90. Nic *NicService
  91. NiciraNVP *NiciraNVPService
  92. OvsElement *OvsElementService
  93. Pod *PodService
  94. Pool *PoolService
  95. PortableIP *PortableIPService
  96. Project *ProjectService
  97. Quota *QuotaService
  98. Region *RegionService
  99. Resourcemetadata *ResourcemetadataService
  100. Resourcetags *ResourcetagsService
  101. Router *RouterService
  102. SSH *SSHService
  103. SecurityGroup *SecurityGroupService
  104. ServiceOffering *ServiceOfferingService
  105. Snapshot *SnapshotService
  106. StoragePool *StoragePoolService
  107. StratosphereSSP *StratosphereSSPService
  108. Swift *SwiftService
  109. SystemCapacity *SystemCapacityService
  110. SystemVM *SystemVMService
  111. Template *TemplateService
  112. UCS *UCSService
  113. Usage *UsageService
  114. User *UserService
  115. VLAN *VLANService
  116. VMGroup *VMGroupService
  117. VPC *VPCService
  118. VPN *VPNService
  119. VirtualMachine *VirtualMachineService
  120. Volume *VolumeService
  121. Zone *ZoneService
  122. }
  123. // Creates a new client for communicating with CloudStack
  124. func newClient(apiurl string, apikey string, secret string, async bool, verifyssl bool) *CloudStackClient {
  125. cs := &CloudStackClient{
  126. client: &http.Client{
  127. Transport: &http.Transport{
  128. Proxy: http.ProxyFromEnvironment,
  129. TLSClientConfig: &tls.Config{InsecureSkipVerify: !verifyssl}, // If verifyssl is true, skipping the verify should be false and vice versa
  130. },
  131. Timeout: time.Duration(60 * time.Second),
  132. },
  133. baseURL: apiurl,
  134. apiKey: apikey,
  135. secret: secret,
  136. async: async,
  137. timeout: 300,
  138. }
  139. cs.APIDiscovery = NewAPIDiscoveryService(cs)
  140. cs.Account = NewAccountService(cs)
  141. cs.Address = NewAddressService(cs)
  142. cs.AffinityGroup = NewAffinityGroupService(cs)
  143. cs.Alert = NewAlertService(cs)
  144. cs.Asyncjob = NewAsyncjobService(cs)
  145. cs.Authentication = NewAuthenticationService(cs)
  146. cs.AutoScale = NewAutoScaleService(cs)
  147. cs.Baremetal = NewBaremetalService(cs)
  148. cs.Certificate = NewCertificateService(cs)
  149. cs.CloudIdentifier = NewCloudIdentifierService(cs)
  150. cs.Cluster = NewClusterService(cs)
  151. cs.Configuration = NewConfigurationService(cs)
  152. cs.DiskOffering = NewDiskOfferingService(cs)
  153. cs.Domain = NewDomainService(cs)
  154. cs.Event = NewEventService(cs)
  155. cs.Firewall = NewFirewallService(cs)
  156. cs.GuestOS = NewGuestOSService(cs)
  157. cs.Host = NewHostService(cs)
  158. cs.Hypervisor = NewHypervisorService(cs)
  159. cs.ISO = NewISOService(cs)
  160. cs.ImageStore = NewImageStoreService(cs)
  161. cs.InternalLB = NewInternalLBService(cs)
  162. cs.LDAP = NewLDAPService(cs)
  163. cs.Limit = NewLimitService(cs)
  164. cs.LoadBalancer = NewLoadBalancerService(cs)
  165. cs.NAT = NewNATService(cs)
  166. cs.NetworkACL = NewNetworkACLService(cs)
  167. cs.NetworkDevice = NewNetworkDeviceService(cs)
  168. cs.NetworkOffering = NewNetworkOfferingService(cs)
  169. cs.Network = NewNetworkService(cs)
  170. cs.Nic = NewNicService(cs)
  171. cs.NiciraNVP = NewNiciraNVPService(cs)
  172. cs.OvsElement = NewOvsElementService(cs)
  173. cs.Pod = NewPodService(cs)
  174. cs.Pool = NewPoolService(cs)
  175. cs.PortableIP = NewPortableIPService(cs)
  176. cs.Project = NewProjectService(cs)
  177. cs.Quota = NewQuotaService(cs)
  178. cs.Region = NewRegionService(cs)
  179. cs.Resourcemetadata = NewResourcemetadataService(cs)
  180. cs.Resourcetags = NewResourcetagsService(cs)
  181. cs.Router = NewRouterService(cs)
  182. cs.SSH = NewSSHService(cs)
  183. cs.SecurityGroup = NewSecurityGroupService(cs)
  184. cs.ServiceOffering = NewServiceOfferingService(cs)
  185. cs.Snapshot = NewSnapshotService(cs)
  186. cs.StoragePool = NewStoragePoolService(cs)
  187. cs.StratosphereSSP = NewStratosphereSSPService(cs)
  188. cs.Swift = NewSwiftService(cs)
  189. cs.SystemCapacity = NewSystemCapacityService(cs)
  190. cs.SystemVM = NewSystemVMService(cs)
  191. cs.Template = NewTemplateService(cs)
  192. cs.UCS = NewUCSService(cs)
  193. cs.Usage = NewUsageService(cs)
  194. cs.User = NewUserService(cs)
  195. cs.VLAN = NewVLANService(cs)
  196. cs.VMGroup = NewVMGroupService(cs)
  197. cs.VPC = NewVPCService(cs)
  198. cs.VPN = NewVPNService(cs)
  199. cs.VirtualMachine = NewVirtualMachineService(cs)
  200. cs.Volume = NewVolumeService(cs)
  201. cs.Zone = NewZoneService(cs)
  202. return cs
  203. }
  204. // Default non-async client. So for async calls you need to implement and check the async job result yourself. When using
  205. // HTTPS with a self-signed certificate to connect to your CloudStack API, you would probably want to set 'verifyssl' to
  206. // false so the call ignores the SSL errors/warnings.
  207. func NewClient(apiurl string, apikey string, secret string, verifyssl bool) *CloudStackClient {
  208. cs := newClient(apiurl, apikey, secret, false, verifyssl)
  209. return cs
  210. }
  211. // For sync API calls this client behaves exactly the same as a standard client call, but for async API calls
  212. // this client will wait until the async job is finished or until the configured AsyncTimeout is reached. When the async
  213. // job finishes successfully it will return actual object received from the API and nil, but when the timout is
  214. // reached it will return the initial object containing the async job ID for the running job and a warning.
  215. func NewAsyncClient(apiurl string, apikey string, secret string, verifyssl bool) *CloudStackClient {
  216. cs := newClient(apiurl, apikey, secret, true, verifyssl)
  217. return cs
  218. }
  219. // When using the async client an api call will wait for the async call to finish before returning. The default is to poll for 300 seconds
  220. // seconds, to check if the async job is finished.
  221. func (cs *CloudStackClient) AsyncTimeout(timeoutInSeconds int64) {
  222. cs.timeout = timeoutInSeconds
  223. }
  224. var AsyncTimeoutErr = errors.New("Timeout while waiting for async job to finish")
  225. // A helper function that you can use to get the result of a running async job. If the job is not finished within the configured
  226. // timeout, the async job returns a AsyncTimeoutErr.
  227. func (cs *CloudStackClient) GetAsyncJobResult(jobid string, timeout int64) (json.RawMessage, error) {
  228. var timer time.Duration
  229. currentTime := time.Now().Unix()
  230. for {
  231. p := cs.Asyncjob.NewQueryAsyncJobResultParams(jobid)
  232. r, err := cs.Asyncjob.QueryAsyncJobResult(p)
  233. if err != nil {
  234. return nil, err
  235. }
  236. // Status 1 means the job is finished successfully
  237. if r.Jobstatus == 1 {
  238. return r.Jobresult, nil
  239. }
  240. // When the status is 2, the job has failed
  241. if r.Jobstatus == 2 {
  242. if r.Jobresulttype == "text" {
  243. return nil, fmt.Errorf(string(r.Jobresult))
  244. } else {
  245. return nil, fmt.Errorf("Undefined error: %s", string(r.Jobresult))
  246. }
  247. }
  248. if time.Now().Unix()-currentTime > timeout {
  249. return nil, AsyncTimeoutErr
  250. }
  251. // Add an (extremely simple) exponential backoff like feature to prevent
  252. // flooding the CloudStack API
  253. if timer < 15 {
  254. timer++
  255. }
  256. time.Sleep(timer * time.Second)
  257. }
  258. }
  259. // Execute the request against a CS API. Will return the raw JSON data returned by the API and nil if
  260. // no error occured. If the API returns an error the result will be nil and the HTTP error code and CS
  261. // error details. If a processing (code) error occurs the result will be nil and the generated error
  262. func (cs *CloudStackClient) newRequest(api string, params url.Values) (json.RawMessage, error) {
  263. params.Set("apiKey", cs.apiKey)
  264. params.Set("command", api)
  265. params.Set("response", "json")
  266. // Generate signature for API call
  267. // * Serialize parameters, URL encoding only values and sort them by key, done by encodeValues
  268. // * Convert the entire argument string to lowercase
  269. // * Replace all instances of '+' to '%20'
  270. // * Calculate HMAC SHA1 of argument string with CloudStack secret
  271. // * URL encode the string and convert to base64
  272. s := encodeValues(params)
  273. s2 := strings.ToLower(s)
  274. s3 := strings.Replace(s2, "+", "%20", -1)
  275. mac := hmac.New(sha1.New, []byte(cs.secret))
  276. mac.Write([]byte(s3))
  277. signature := base64.StdEncoding.EncodeToString(mac.Sum(nil))
  278. var err error
  279. var resp *http.Response
  280. if !cs.HTTPGETOnly && (api == "deployVirtualMachine" || api == "updateVirtualMachine") {
  281. // The deployVirtualMachine API should be called using a POST call
  282. // so we don't have to worry about the userdata size
  283. // Add the unescaped signature to the POST params
  284. params.Set("signature", signature)
  285. // Make a POST call
  286. resp, err = cs.client.PostForm(cs.baseURL, params)
  287. } else {
  288. // Create the final URL before we issue the request
  289. url := cs.baseURL + "?" + s + "&signature=" + url.QueryEscape(signature)
  290. // Make a GET call
  291. resp, err = cs.client.Get(url)
  292. }
  293. if err != nil {
  294. return nil, err
  295. }
  296. defer resp.Body.Close()
  297. b, err := ioutil.ReadAll(resp.Body)
  298. if err != nil {
  299. return nil, err
  300. }
  301. // Need to get the raw value to make the result play nice
  302. b, err = getRawValue(b)
  303. if err != nil {
  304. return nil, err
  305. }
  306. if resp.StatusCode != 200 {
  307. var e CSError
  308. if err := json.Unmarshal(b, &e); err != nil {
  309. return nil, err
  310. }
  311. return nil, e.Error()
  312. }
  313. return b, nil
  314. }
  315. // Custom version of net/url Encode that only URL escapes values
  316. // Unmodified portions here remain under BSD license of The Go Authors: https://go.googlesource.com/go/+/master/LICENSE
  317. func encodeValues(v url.Values) string {
  318. if v == nil {
  319. return ""
  320. }
  321. var buf bytes.Buffer
  322. keys := make([]string, 0, len(v))
  323. for k := range v {
  324. keys = append(keys, k)
  325. }
  326. sort.Strings(keys)
  327. for _, k := range keys {
  328. vs := v[k]
  329. prefix := k + "="
  330. for _, v := range vs {
  331. if buf.Len() > 0 {
  332. buf.WriteByte('&')
  333. }
  334. buf.WriteString(prefix)
  335. buf.WriteString(url.QueryEscape(v))
  336. }
  337. }
  338. return buf.String()
  339. }
  340. // Generic function to get the first raw value from a response as json.RawMessage
  341. func getRawValue(b json.RawMessage) (json.RawMessage, error) {
  342. var m map[string]json.RawMessage
  343. if err := json.Unmarshal(b, &m); err != nil {
  344. return nil, err
  345. }
  346. for _, v := range m {
  347. return v, nil
  348. }
  349. return nil, fmt.Errorf("Unable to extract the raw value from:\n\n%s\n\n", string(b))
  350. }
  351. // ProjectIDSetter is an interface that every type that can set a project ID must implement
  352. type ProjectIDSetter interface {
  353. SetProjectid(string)
  354. }
  355. // WithProject takes either a project name or ID and sets the `projectid` parameter
  356. func WithProject(project string) OptionFunc {
  357. return func(cs *CloudStackClient, p interface{}) error {
  358. ps, ok := p.(ProjectIDSetter)
  359. if !ok || project == "" {
  360. return nil
  361. }
  362. if !IsID(project) {
  363. id, _, err := cs.Project.GetProjectID(project)
  364. if err != nil {
  365. return err
  366. }
  367. project = id
  368. }
  369. ps.SetProjectid(project)
  370. return nil
  371. }
  372. }
  373. // VPCIDSetter is an interface that every type that can set a vpc ID must implement
  374. type VPCIDSetter interface {
  375. SetVpcid(string)
  376. }
  377. // WithVPCID takes a vpc ID and sets the `vpcid` parameter
  378. func WithVPCID(id string) OptionFunc {
  379. return func(cs *CloudStackClient, p interface{}) error {
  380. vs, ok := p.(VPCIDSetter)
  381. if !ok || id == "" {
  382. return nil
  383. }
  384. vs.SetVpcid(id)
  385. return nil
  386. }
  387. }
  388. type APIDiscoveryService struct {
  389. cs *CloudStackClient
  390. }
  391. func NewAPIDiscoveryService(cs *CloudStackClient) *APIDiscoveryService {
  392. return &APIDiscoveryService{cs: cs}
  393. }
  394. type AccountService struct {
  395. cs *CloudStackClient
  396. }
  397. func NewAccountService(cs *CloudStackClient) *AccountService {
  398. return &AccountService{cs: cs}
  399. }
  400. type AddressService struct {
  401. cs *CloudStackClient
  402. }
  403. func NewAddressService(cs *CloudStackClient) *AddressService {
  404. return &AddressService{cs: cs}
  405. }
  406. type AffinityGroupService struct {
  407. cs *CloudStackClient
  408. }
  409. func NewAffinityGroupService(cs *CloudStackClient) *AffinityGroupService {
  410. return &AffinityGroupService{cs: cs}
  411. }
  412. type AlertService struct {
  413. cs *CloudStackClient
  414. }
  415. func NewAlertService(cs *CloudStackClient) *AlertService {
  416. return &AlertService{cs: cs}
  417. }
  418. type AsyncjobService struct {
  419. cs *CloudStackClient
  420. }
  421. func NewAsyncjobService(cs *CloudStackClient) *AsyncjobService {
  422. return &AsyncjobService{cs: cs}
  423. }
  424. type AuthenticationService struct {
  425. cs *CloudStackClient
  426. }
  427. func NewAuthenticationService(cs *CloudStackClient) *AuthenticationService {
  428. return &AuthenticationService{cs: cs}
  429. }
  430. type AutoScaleService struct {
  431. cs *CloudStackClient
  432. }
  433. func NewAutoScaleService(cs *CloudStackClient) *AutoScaleService {
  434. return &AutoScaleService{cs: cs}
  435. }
  436. type BaremetalService struct {
  437. cs *CloudStackClient
  438. }
  439. func NewBaremetalService(cs *CloudStackClient) *BaremetalService {
  440. return &BaremetalService{cs: cs}
  441. }
  442. type CertificateService struct {
  443. cs *CloudStackClient
  444. }
  445. func NewCertificateService(cs *CloudStackClient) *CertificateService {
  446. return &CertificateService{cs: cs}
  447. }
  448. type CloudIdentifierService struct {
  449. cs *CloudStackClient
  450. }
  451. func NewCloudIdentifierService(cs *CloudStackClient) *CloudIdentifierService {
  452. return &CloudIdentifierService{cs: cs}
  453. }
  454. type ClusterService struct {
  455. cs *CloudStackClient
  456. }
  457. func NewClusterService(cs *CloudStackClient) *ClusterService {
  458. return &ClusterService{cs: cs}
  459. }
  460. type ConfigurationService struct {
  461. cs *CloudStackClient
  462. }
  463. func NewConfigurationService(cs *CloudStackClient) *ConfigurationService {
  464. return &ConfigurationService{cs: cs}
  465. }
  466. type DiskOfferingService struct {
  467. cs *CloudStackClient
  468. }
  469. func NewDiskOfferingService(cs *CloudStackClient) *DiskOfferingService {
  470. return &DiskOfferingService{cs: cs}
  471. }
  472. type DomainService struct {
  473. cs *CloudStackClient
  474. }
  475. func NewDomainService(cs *CloudStackClient) *DomainService {
  476. return &DomainService{cs: cs}
  477. }
  478. type EventService struct {
  479. cs *CloudStackClient
  480. }
  481. func NewEventService(cs *CloudStackClient) *EventService {
  482. return &EventService{cs: cs}
  483. }
  484. type FirewallService struct {
  485. cs *CloudStackClient
  486. }
  487. func NewFirewallService(cs *CloudStackClient) *FirewallService {
  488. return &FirewallService{cs: cs}
  489. }
  490. type GuestOSService struct {
  491. cs *CloudStackClient
  492. }
  493. func NewGuestOSService(cs *CloudStackClient) *GuestOSService {
  494. return &GuestOSService{cs: cs}
  495. }
  496. type HostService struct {
  497. cs *CloudStackClient
  498. }
  499. func NewHostService(cs *CloudStackClient) *HostService {
  500. return &HostService{cs: cs}
  501. }
  502. type HypervisorService struct {
  503. cs *CloudStackClient
  504. }
  505. func NewHypervisorService(cs *CloudStackClient) *HypervisorService {
  506. return &HypervisorService{cs: cs}
  507. }
  508. type ISOService struct {
  509. cs *CloudStackClient
  510. }
  511. func NewISOService(cs *CloudStackClient) *ISOService {
  512. return &ISOService{cs: cs}
  513. }
  514. type ImageStoreService struct {
  515. cs *CloudStackClient
  516. }
  517. func NewImageStoreService(cs *CloudStackClient) *ImageStoreService {
  518. return &ImageStoreService{cs: cs}
  519. }
  520. type InternalLBService struct {
  521. cs *CloudStackClient
  522. }
  523. func NewInternalLBService(cs *CloudStackClient) *InternalLBService {
  524. return &InternalLBService{cs: cs}
  525. }
  526. type LDAPService struct {
  527. cs *CloudStackClient
  528. }
  529. func NewLDAPService(cs *CloudStackClient) *LDAPService {
  530. return &LDAPService{cs: cs}
  531. }
  532. type LimitService struct {
  533. cs *CloudStackClient
  534. }
  535. func NewLimitService(cs *CloudStackClient) *LimitService {
  536. return &LimitService{cs: cs}
  537. }
  538. type LoadBalancerService struct {
  539. cs *CloudStackClient
  540. }
  541. func NewLoadBalancerService(cs *CloudStackClient) *LoadBalancerService {
  542. return &LoadBalancerService{cs: cs}
  543. }
  544. type NATService struct {
  545. cs *CloudStackClient
  546. }
  547. func NewNATService(cs *CloudStackClient) *NATService {
  548. return &NATService{cs: cs}
  549. }
  550. type NetworkACLService struct {
  551. cs *CloudStackClient
  552. }
  553. func NewNetworkACLService(cs *CloudStackClient) *NetworkACLService {
  554. return &NetworkACLService{cs: cs}
  555. }
  556. type NetworkDeviceService struct {
  557. cs *CloudStackClient
  558. }
  559. func NewNetworkDeviceService(cs *CloudStackClient) *NetworkDeviceService {
  560. return &NetworkDeviceService{cs: cs}
  561. }
  562. type NetworkOfferingService struct {
  563. cs *CloudStackClient
  564. }
  565. func NewNetworkOfferingService(cs *CloudStackClient) *NetworkOfferingService {
  566. return &NetworkOfferingService{cs: cs}
  567. }
  568. type NetworkService struct {
  569. cs *CloudStackClient
  570. }
  571. func NewNetworkService(cs *CloudStackClient) *NetworkService {
  572. return &NetworkService{cs: cs}
  573. }
  574. type NicService struct {
  575. cs *CloudStackClient
  576. }
  577. func NewNicService(cs *CloudStackClient) *NicService {
  578. return &NicService{cs: cs}
  579. }
  580. type NiciraNVPService struct {
  581. cs *CloudStackClient
  582. }
  583. func NewNiciraNVPService(cs *CloudStackClient) *NiciraNVPService {
  584. return &NiciraNVPService{cs: cs}
  585. }
  586. type OvsElementService struct {
  587. cs *CloudStackClient
  588. }
  589. func NewOvsElementService(cs *CloudStackClient) *OvsElementService {
  590. return &OvsElementService{cs: cs}
  591. }
  592. type PodService struct {
  593. cs *CloudStackClient
  594. }
  595. func NewPodService(cs *CloudStackClient) *PodService {
  596. return &PodService{cs: cs}
  597. }
  598. type PoolService struct {
  599. cs *CloudStackClient
  600. }
  601. func NewPoolService(cs *CloudStackClient) *PoolService {
  602. return &PoolService{cs: cs}
  603. }
  604. type PortableIPService struct {
  605. cs *CloudStackClient
  606. }
  607. func NewPortableIPService(cs *CloudStackClient) *PortableIPService {
  608. return &PortableIPService{cs: cs}
  609. }
  610. type ProjectService struct {
  611. cs *CloudStackClient
  612. }
  613. func NewProjectService(cs *CloudStackClient) *ProjectService {
  614. return &ProjectService{cs: cs}
  615. }
  616. type QuotaService struct {
  617. cs *CloudStackClient
  618. }
  619. func NewQuotaService(cs *CloudStackClient) *QuotaService {
  620. return &QuotaService{cs: cs}
  621. }
  622. type RegionService struct {
  623. cs *CloudStackClient
  624. }
  625. func NewRegionService(cs *CloudStackClient) *RegionService {
  626. return &RegionService{cs: cs}
  627. }
  628. type ResourcemetadataService struct {
  629. cs *CloudStackClient
  630. }
  631. func NewResourcemetadataService(cs *CloudStackClient) *ResourcemetadataService {
  632. return &ResourcemetadataService{cs: cs}
  633. }
  634. type ResourcetagsService struct {
  635. cs *CloudStackClient
  636. }
  637. func NewResourcetagsService(cs *CloudStackClient) *ResourcetagsService {
  638. return &ResourcetagsService{cs: cs}
  639. }
  640. type RouterService struct {
  641. cs *CloudStackClient
  642. }
  643. func NewRouterService(cs *CloudStackClient) *RouterService {
  644. return &RouterService{cs: cs}
  645. }
  646. type SSHService struct {
  647. cs *CloudStackClient
  648. }
  649. func NewSSHService(cs *CloudStackClient) *SSHService {
  650. return &SSHService{cs: cs}
  651. }
  652. type SecurityGroupService struct {
  653. cs *CloudStackClient
  654. }
  655. func NewSecurityGroupService(cs *CloudStackClient) *SecurityGroupService {
  656. return &SecurityGroupService{cs: cs}
  657. }
  658. type ServiceOfferingService struct {
  659. cs *CloudStackClient
  660. }
  661. func NewServiceOfferingService(cs *CloudStackClient) *ServiceOfferingService {
  662. return &ServiceOfferingService{cs: cs}
  663. }
  664. type SnapshotService struct {
  665. cs *CloudStackClient
  666. }
  667. func NewSnapshotService(cs *CloudStackClient) *SnapshotService {
  668. return &SnapshotService{cs: cs}
  669. }
  670. type StoragePoolService struct {
  671. cs *CloudStackClient
  672. }
  673. func NewStoragePoolService(cs *CloudStackClient) *StoragePoolService {
  674. return &StoragePoolService{cs: cs}
  675. }
  676. type StratosphereSSPService struct {
  677. cs *CloudStackClient
  678. }
  679. func NewStratosphereSSPService(cs *CloudStackClient) *StratosphereSSPService {
  680. return &StratosphereSSPService{cs: cs}
  681. }
  682. type SwiftService struct {
  683. cs *CloudStackClient
  684. }
  685. func NewSwiftService(cs *CloudStackClient) *SwiftService {
  686. return &SwiftService{cs: cs}
  687. }
  688. type SystemCapacityService struct {
  689. cs *CloudStackClient
  690. }
  691. func NewSystemCapacityService(cs *CloudStackClient) *SystemCapacityService {
  692. return &SystemCapacityService{cs: cs}
  693. }
  694. type SystemVMService struct {
  695. cs *CloudStackClient
  696. }
  697. func NewSystemVMService(cs *CloudStackClient) *SystemVMService {
  698. return &SystemVMService{cs: cs}
  699. }
  700. type TemplateService struct {
  701. cs *CloudStackClient
  702. }
  703. func NewTemplateService(cs *CloudStackClient) *TemplateService {
  704. return &TemplateService{cs: cs}
  705. }
  706. type UCSService struct {
  707. cs *CloudStackClient
  708. }
  709. func NewUCSService(cs *CloudStackClient) *UCSService {
  710. return &UCSService{cs: cs}
  711. }
  712. type UsageService struct {
  713. cs *CloudStackClient
  714. }
  715. func NewUsageService(cs *CloudStackClient) *UsageService {
  716. return &UsageService{cs: cs}
  717. }
  718. type UserService struct {
  719. cs *CloudStackClient
  720. }
  721. func NewUserService(cs *CloudStackClient) *UserService {
  722. return &UserService{cs: cs}
  723. }
  724. type VLANService struct {
  725. cs *CloudStackClient
  726. }
  727. func NewVLANService(cs *CloudStackClient) *VLANService {
  728. return &VLANService{cs: cs}
  729. }
  730. type VMGroupService struct {
  731. cs *CloudStackClient
  732. }
  733. func NewVMGroupService(cs *CloudStackClient) *VMGroupService {
  734. return &VMGroupService{cs: cs}
  735. }
  736. type VPCService struct {
  737. cs *CloudStackClient
  738. }
  739. func NewVPCService(cs *CloudStackClient) *VPCService {
  740. return &VPCService{cs: cs}
  741. }
  742. type VPNService struct {
  743. cs *CloudStackClient
  744. }
  745. func NewVPNService(cs *CloudStackClient) *VPNService {
  746. return &VPNService{cs: cs}
  747. }
  748. type VirtualMachineService struct {
  749. cs *CloudStackClient
  750. }
  751. func NewVirtualMachineService(cs *CloudStackClient) *VirtualMachineService {
  752. return &VirtualMachineService{cs: cs}
  753. }
  754. type VolumeService struct {
  755. cs *CloudStackClient
  756. }
  757. func NewVolumeService(cs *CloudStackClient) *VolumeService {
  758. return &VolumeService{cs: cs}
  759. }
  760. type ZoneService struct {
  761. cs *CloudStackClient
  762. }
  763. func NewZoneService(cs *CloudStackClient) *ZoneService {
  764. return &ZoneService{cs: cs}
  765. }