-
Notifications
You must be signed in to change notification settings - Fork 5
/
jamfproapi_package.go
74 lines (55 loc) · 1.88 KB
/
jamfproapi_package.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
// jamfproapi_package.go
// Jamf Pro Api - Package
// api reference: https://developer.jamf.com/jamf-pro/reference/get_v1-jamf-package
// Jamf Pro API requires the structs to support a JSON data structure.
package jamfpro
import "fmt"
const uriPackageV1 = "/api/v1/jamf-package"
const uriPackageV2 = "/api/v2/jamf-package"
// Structs
// List
// V1
type ResponsePackageListV1 struct {
Results []ResponsePackageInfoShared
}
type ResponsePackageInfoShared struct {
ID string `json:"id"`
Filename string `json:"filename"`
Version string `json:"version"`
Created string `json:"created"`
Url string `json:"url"`
}
// V2
// List
type ResponsePackageV2 struct {
DisplayName string `json:"displayName"`
ReleaseHistoryUrl string `json:"releaseHistoryUrl"`
Artifacts []ResponsePackageInfoShared
}
// CRUD
// GetPackageInfoByApplicationV1 Returns a list of package info from the v1 api
func (c *Client) GetPackageInfoByApplicationV1(application string) (*ResponsePackageListV1, error) {
endpoint := fmt.Sprintf("%s?application=%s", uriPackageV1, application)
var out ResponsePackageListV1
resp, err := c.HTTP.DoRequest("GET", endpoint, nil, &out)
if err != nil {
return nil, fmt.Errorf(errMsgFailedGetByString, "jamf package", "application name", application, err)
}
if resp != nil {
defer resp.Body.Close()
}
return &out, nil
}
// GetPackageInfoByApplicationV1 Returns a list of package info from the v2 api with more info
func (c *Client) GetPackageInfoByApplicationV2(application string) (*ResponsePackageV2, error) {
endpoint := fmt.Sprintf("%s?application=%s", uriPackageV2, application)
var out ResponsePackageV2
resp, err := c.HTTP.DoRequest("GET", endpoint, nil, &out)
if err != nil {
return nil, fmt.Errorf(errMsgFailedGetByString, "jamf package", "application name", application, err)
}
if resp != nil {
defer resp.Body.Close()
}
return &out, nil
}