-
Notifications
You must be signed in to change notification settings - Fork 5
/
jamfproapi_jamf_protect.go
78 lines (58 loc) · 2.12 KB
/
jamfproapi_jamf_protect.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
66
67
68
69
70
71
72
73
74
75
76
77
78
// jamfproapi_jamf_protect.go
// Jamf Pro Api - Jamf Protect
// api reference: https://developer.jamf.com/jamf-pro/reference/put_v1-jamf-protect
// Jamf Pro API requires the structs to support a JSON data structure.
package jamfpro
import (
"fmt"
)
const uriJamfProtect = "/api/v1/jamf-protect"
// Structs
type ResourceJamfProtectIntegrationSettings struct {
ID string `json:"id"`
APIClientID string `json:"apiClientId"`
APIClientName string `json:"apiClientName"`
RegistrationID string `json:"registrationId"`
ProtectURL string `json:"protectUrl"`
LastSyncTime string `json:"lastSyncTime"`
SyncStatus string `json:"syncStatus"`
AutoInstall bool `json:"autoInstall"`
}
// CRUD
func (c *Client) GetJamfProtectIntegrationSettings() (*ResourceJamfProtectIntegrationSettings, error) {
endpoint := uriJamfProtect
var out ResourceJamfProtectIntegrationSettings
resp, err := c.HTTP.DoRequest("GET", endpoint, nil, &out)
if err != nil {
return nil, fmt.Errorf(errMsgFailedGet, "jamf protect integration settings", err)
}
if resp != nil && resp.Body != nil {
defer resp.Body.Close()
}
return &out, nil
}
func (c *Client) UpdateJamfProtectIntegrationSettings(updatedSettings ResourceJamfProtectIntegrationSettings) (*ResourceJamfProtectIntegrationSettings, error) {
// TODO - Figure out if we can update everything here or just the bool
endpoint := uriJamfProtect
var out ResourceJamfProtectIntegrationSettings
resp, err := c.HTTP.DoRequest("PUT", endpoint, updatedSettings, &out)
if err != nil {
return nil, fmt.Errorf(errMsgFailedUpdate, "jamf protect integration settings", err)
}
if resp != nil && resp.Body != nil {
defer resp.Body.Close()
}
return &out, nil
}
func (c *Client) DeleteJamfProtectIntegration() error {
endpoint := uriJamfProtect
resp, err := c.HTTP.DoRequest("DELETE", endpoint, nil, nil)
if err != nil {
return fmt.Errorf(errMsgFailedDelete, "jamf protect integration", err)
}
if resp != nil && resp.Body != nil {
defer resp.Body.Close()
}
return nil
}
// QUERY are we bothered about the rest of the operations at this endpoint? - no i dont thinik so at this stage