StratosphereSSPService.go 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. "encoding/json"
  19. "net/url"
  20. )
  21. type AddStratosphereSspParams struct {
  22. p map[string]interface{}
  23. }
  24. func (p *AddStratosphereSspParams) toURLValues() url.Values {
  25. u := url.Values{}
  26. if p.p == nil {
  27. return u
  28. }
  29. if v, found := p.p["name"]; found {
  30. u.Set("name", v.(string))
  31. }
  32. if v, found := p.p["password"]; found {
  33. u.Set("password", v.(string))
  34. }
  35. if v, found := p.p["tenantuuid"]; found {
  36. u.Set("tenantuuid", v.(string))
  37. }
  38. if v, found := p.p["url"]; found {
  39. u.Set("url", v.(string))
  40. }
  41. if v, found := p.p["username"]; found {
  42. u.Set("username", v.(string))
  43. }
  44. if v, found := p.p["zoneid"]; found {
  45. u.Set("zoneid", v.(string))
  46. }
  47. return u
  48. }
  49. func (p *AddStratosphereSspParams) SetName(v string) {
  50. if p.p == nil {
  51. p.p = make(map[string]interface{})
  52. }
  53. p.p["name"] = v
  54. return
  55. }
  56. func (p *AddStratosphereSspParams) SetPassword(v string) {
  57. if p.p == nil {
  58. p.p = make(map[string]interface{})
  59. }
  60. p.p["password"] = v
  61. return
  62. }
  63. func (p *AddStratosphereSspParams) SetTenantuuid(v string) {
  64. if p.p == nil {
  65. p.p = make(map[string]interface{})
  66. }
  67. p.p["tenantuuid"] = v
  68. return
  69. }
  70. func (p *AddStratosphereSspParams) SetUrl(v string) {
  71. if p.p == nil {
  72. p.p = make(map[string]interface{})
  73. }
  74. p.p["url"] = v
  75. return
  76. }
  77. func (p *AddStratosphereSspParams) SetUsername(v string) {
  78. if p.p == nil {
  79. p.p = make(map[string]interface{})
  80. }
  81. p.p["username"] = v
  82. return
  83. }
  84. func (p *AddStratosphereSspParams) SetZoneid(v string) {
  85. if p.p == nil {
  86. p.p = make(map[string]interface{})
  87. }
  88. p.p["zoneid"] = v
  89. return
  90. }
  91. // You should always use this function to get a new AddStratosphereSspParams instance,
  92. // as then you are sure you have configured all required params
  93. func (s *StratosphereSSPService) NewAddStratosphereSspParams(name string, url string, zoneid string) *AddStratosphereSspParams {
  94. p := &AddStratosphereSspParams{}
  95. p.p = make(map[string]interface{})
  96. p.p["name"] = name
  97. p.p["url"] = url
  98. p.p["zoneid"] = zoneid
  99. return p
  100. }
  101. // Adds stratosphere ssp server
  102. func (s *StratosphereSSPService) AddStratosphereSsp(p *AddStratosphereSspParams) (*AddStratosphereSspResponse, error) {
  103. resp, err := s.cs.newRequest("addStratosphereSsp", p.toURLValues())
  104. if err != nil {
  105. return nil, err
  106. }
  107. var r AddStratosphereSspResponse
  108. if err := json.Unmarshal(resp, &r); err != nil {
  109. return nil, err
  110. }
  111. return &r, nil
  112. }
  113. type AddStratosphereSspResponse struct {
  114. Hostid string `json:"hostid,omitempty"`
  115. Name string `json:"name,omitempty"`
  116. Url string `json:"url,omitempty"`
  117. Zoneid string `json:"zoneid,omitempty"`
  118. }