forked from deploymenttheory/go-api-sdk-jamfpro
/
reenrollment.go
65 lines (50 loc) · 1.95 KB
/
reenrollment.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
53
54
55
56
57
58
59
60
61
62
63
64
65
package jamfpro
import (
"fmt"
)
const uriAPIReEnrollment = "/api/v1/reenrollment"
type ResponseReEnrollment struct {
IsFlushPolicyHistoryEnabled bool `json:"isFlushPolicyHistoryEnabled"`
IsFlushLocationInformationEnabled bool `json:"isFlushLocationInformationEnabled"`
IsFlushLocationInformationHistoryEnabled bool `json:"isFlushLocationInformationHistoryEnabled"`
IsFlushExtensionAttributesEnabled bool `json:"isFlushExtensionAttributesEnabled"`
FlushMDMQueue string `json:"flushMDMQueue"`
}
type ReEnrollmentHistoryResult struct {
ID int `json:"id"`
Username string `json:"username"`
Date string `json:"date"`
Note string `json:"note"`
Details string `json:"details"`
}
type ResponseReEnrollmentHistory struct {
TotalCount int `json:"totalCount"`
Results []ReEnrollmentHistoryResult `json:"results"`
}
func (c *Client) GetReEnrollment() (*ResponseReEnrollment, error) {
uri := uriAPIReEnrollment
var out ResponseReEnrollment
err := c.DoRequest("GET", uri, nil, nil, &out)
if err != nil {
return nil, fmt.Errorf("failed to get re-enrollment data: %v", err)
}
return &out, nil
}
func (c *Client) UpdateReEnrollment(d *ResponseReEnrollment) (*ResponseReEnrollment, error) {
uri := uriAPIReEnrollment
updatedReEnrollment := &ResponseReEnrollment{}
err := c.DoRequest("PUT", uri, d, nil, updatedReEnrollment)
if err != nil {
return nil, fmt.Errorf("failed to update re-enrollment data: %v", err)
}
return updatedReEnrollment, nil
}
func (c *Client) GetReEnrollmentHistory(page, pageSize int, sort string) (*ResponseReEnrollmentHistory, error) {
uri := fmt.Sprintf("%s/history?page=%d&page-size=%d&sort=%s", uriAPIReEnrollment, page, pageSize, sort)
var out ResponseReEnrollmentHistory
err := c.DoRequest("GET", uri, nil, nil, &out)
if err != nil {
return nil, fmt.Errorf("failed to get re-enrollment history: %v", err)
}
return &out, nil
}