-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexecutions.go
52 lines (46 loc) · 964 Bytes
/
executions.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
50
51
52
package main
import (
"encoding/json"
"fmt"
"log"
"net/http"
)
func getReplicationExecutionsByPolicyId(server, user, password, apiVersion string, policyId int) []ReplicationExecution {
page := 0
pageSize := 50
baseUrl := fmt.Sprintf("%v/api/%vreplication/executions",
server,
apiVersion,
)
var replications, aux []ReplicationExecution
var res *http.Response
var body, url string
for {
page++
url = fmt.Sprintf("%v?page=%v&page_size=%v&policy_id=%v",
baseUrl,
page,
pageSize,
policyId,
)
res, body = client(
ClientPrt{
Url: url,
Method: "GET",
ContentType: "application/json",
User: user,
Password: password,
},
)
if res.StatusCode < 399 && res.StatusCode > 100 {
json.Unmarshal([]byte(body), &aux)
if len(aux) == 0 {
break
}
replications = append(replications, aux...)
} else {
log.Fatal("Error getting replications")
}
}
return replications
}