-
Notifications
You must be signed in to change notification settings - Fork 5
/
list_subaccount_destinations.go
49 lines (41 loc) · 1.22 KB
/
list_subaccount_destinations.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package clients
import (
models "cf-html5-apps-repo-cli-plugin/clients/models"
"cf-html5-apps-repo-cli-plugin/log"
"encoding/json"
"io/ioutil"
"net/http"
)
// ListSubaccountDestinations list destination service subaccount destinations
func ListSubaccountDestinations(serviceURL string, accessToken string) (models.DestinationListDestinationsResponse, error) {
var destinations models.DestinationListDestinationsResponse
var request *http.Request
var response *http.Response
var err error
var destinationsURL string
var body []byte
destinationsURL = serviceURL + "/destination-configuration/v1/subaccountDestinations/"
log.Tracef("Making request to: %s\n", destinationsURL)
client := &http.Client{}
request, err = http.NewRequest("GET", destinationsURL, nil)
if err != nil {
return destinations, err
}
request.Header.Add("Authorization", "Bearer "+accessToken)
response, err = client.Do(request)
if err != nil {
return destinations, err
}
// Get response body
defer response.Body.Close()
body, err = ioutil.ReadAll(response.Body)
if err != nil {
return destinations, err
}
// Parse response JSON
err = json.Unmarshal(body, &destinations)
if err != nil {
return destinations, err
}
return destinations, nil
}