CloudIdentifierService.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 GetCloudIdentifierParams struct {
  22. p map[string]interface{}
  23. }
  24. func (p *GetCloudIdentifierParams) toURLValues() url.Values {
  25. u := url.Values{}
  26. if p.p == nil {
  27. return u
  28. }
  29. if v, found := p.p["userid"]; found {
  30. u.Set("userid", v.(string))
  31. }
  32. return u
  33. }
  34. func (p *GetCloudIdentifierParams) SetUserid(v string) {
  35. if p.p == nil {
  36. p.p = make(map[string]interface{})
  37. }
  38. p.p["userid"] = v
  39. return
  40. }
  41. // You should always use this function to get a new GetCloudIdentifierParams instance,
  42. // as then you are sure you have configured all required params
  43. func (s *CloudIdentifierService) NewGetCloudIdentifierParams(userid string) *GetCloudIdentifierParams {
  44. p := &GetCloudIdentifierParams{}
  45. p.p = make(map[string]interface{})
  46. p.p["userid"] = userid
  47. return p
  48. }
  49. // Retrieves a cloud identifier.
  50. func (s *CloudIdentifierService) GetCloudIdentifier(p *GetCloudIdentifierParams) (*GetCloudIdentifierResponse, error) {
  51. resp, err := s.cs.newRequest("getCloudIdentifier", p.toURLValues())
  52. if err != nil {
  53. return nil, err
  54. }
  55. var r GetCloudIdentifierResponse
  56. if err := json.Unmarshal(resp, &r); err != nil {
  57. return nil, err
  58. }
  59. return &r, nil
  60. }
  61. type GetCloudIdentifierResponse struct {
  62. Cloudidentifier string `json:"cloudidentifier,omitempty"`
  63. Signature string `json:"signature,omitempty"`
  64. Userid string `json:"userid,omitempty"`
  65. }