-
Notifications
You must be signed in to change notification settings - Fork 5
/
jamfproapi_mobile_device_prestages.go
203 lines (170 loc) · 9.44 KB
/
jamfproapi_mobile_device_prestages.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
// jamfproapi_mobile_device_prestages.go
// Jamf Pro Api - Mobile Device Prestages
// api reference: https://developer.jamf.com/jamf-pro/reference/get_v2-mobile-device-prestages
// Jamf Pro API requires the structs to support a JSON data structure.
package jamfpro
import (
"fmt"
"github.com/mitchellh/mapstructure"
)
const uriMobileDevicePrestages = "/api/v2/mobile-device-prestages"
// Structs
// List
type ResponseMobileDevicePrestagesList struct {
TotalCount int `json:"totalCount"`
Results []ResourceMobileDevicePrestage `json:"results"`
}
// Response
type ResponseMobileDevicePrestageCreate struct {
ID string `json:"id"`
Href string `json:"href"`
}
// Resource
type ResourceMobileDevicePrestage struct {
DisplayName string `json:"displayName"`
Mandatory bool `json:"mandatory"`
MdmRemovable bool `json:"mdmRemovable"`
SupportPhoneNumber string `json:"supportPhoneNumber"`
SupportEmailAddress string `json:"supportEmailAddress"`
Department string `json:"department"`
DefaultPrestage bool `json:"defaultPrestage"`
EnrollmentSiteID string `json:"enrollmentSiteId"`
KeepExistingSiteMembership bool `json:"keepExistingSiteMembership"`
KeepExistingLocationInformation bool `json:"keepExistingLocationInformation"`
RequireAuthentication bool `json:"requireAuthentication"`
AuthenticationPrompt string `json:"authenticationPrompt"`
PreventActivationLock bool `json:"preventActivationLock"`
EnableDeviceBasedActivationLock bool `json:"enableDeviceBasedActivationLock"`
DeviceEnrollmentProgramInstanceID string `json:"deviceEnrollmentProgramInstanceId"`
SkipSetupItems MobileDevicePrestageSubsetSkipSetupItems `json:"skipSetupItems"`
LocationInformation MobileDevicePrestageSubsetLocationInformation `json:"locationInformation"`
PurchasingInformation MobileDevicePrestageSubsetLocationInformation `json:"purchasingInformation"`
AnchorCertificates []string `json:"anchorCertificates"`
EnrollmentCustomizationID string `json:"enrollmentCustomizationId"`
Language string `json:"language"`
Region string `json:"region"`
AutoAdvanceSetup bool `json:"autoAdvanceSetup"`
AllowPairing bool `json:"allowPairing"`
MultiUser bool `json:"multiUser"`
Supervised bool `json:"supervised"`
MaximumSharedAccounts int `json:"maximumSharedAccounts"`
ConfigureDeviceBeforeSetupAssistant bool `json:"configureDeviceBeforeSetupAssistant"`
Names MobileDevicePrestageSubsetNames `json:"names"`
SendTimezone bool `json:"sendTimezone"`
Timezone string `json:"timezone"`
StorageQuotaSizeMegabytes int `json:"storageQuotaSizeMegabytes"`
UseStorageQuotaSize bool `json:"useStorageQuotaSize"`
TemporarySessionOnly bool `json:"temporarySessionOnly"`
EnforceTemporarySessionTimeout bool `json:"enforceTemporarySessionTimeout"`
TemporarySessionTimeout int `json:"temporarySessionTimeout"`
EnforceUserSessionTimeout bool `json:"enforceUserSessionTimeout"`
UserSessionTimeout int `json:"userSessionTimeout"`
ID string `json:"id"`
ProfileUuid string `json:"profileUuid"`
SiteId string `json:"siteId"`
VersionLock int `json:"versionLock"`
}
// Subsets
type MobileDevicePrestageSubsetSkipSetupItems struct {
Location bool `json:"Location"`
Privacy bool `json:"Privacy"`
}
type MobileDevicePrestageSubsetLocationInformation struct {
Username string `json:"username"`
Realname string `json:"realname"`
Phone string `json:"phone"`
Email string `json:"email"`
Room string `json:"room"`
Position string `json:"position"`
DepartmentId string `json:"departmentId"`
BuildingId string `json:"buildingId"`
ID string `json:"id"`
VersionLock int `json:"versionLock"`
}
type MobileDevicePrestageSubsetPurchasingInformation struct {
ID string `json:"id"`
Leased bool `json:"leased"`
Purchased bool `json:"purchased"`
AppleCareId string `json:"appleCareId"`
PoNumber string `json:"poNumber"`
Vendor string `json:"vendor"`
PurchasePrice string `json:"purchasePrice"`
LifeExpectancy int `json:"lifeExpectancy"`
PurchasingAccount string `json:"purchasingAccount"`
PurchasingContact string `json:"purchasingContact"`
LeaseDate string `json:"leaseDate"`
PoDate string `json:"poDate"`
WarrantyDate string `json:"warrantyDate"`
VersionLock int `json:"versionLock"`
}
type MobileDevicePrestageSubsetNames struct {
AssignNamesUsing string `json:"assignNamesUsing"`
PrestageDeviceNames []MobileDevicePrestageSubsetNamesName `json:"prestageDeviceNames"`
DeviceNamePrefix string `json:"deviceNamePrefix"`
DeviceNameSuffix string `json:"deviceNameSuffix"`
SingleDeviceName string
}
type MobileDevicePrestageSubsetNamesName struct {
ID string `json:"id"`
DeviceName string `json:"deviceName"`
Used bool `json:"used"`
}
// CRUD
// GetMobileDevicePrestages retrieves a list of all mobile prestages
func (c *Client) GetMobileDevicePrestages(sort_filter string) (*ResponseMobileDevicePrestagesList, error) {
endpoint := uriMobileDevicePrestages
resp, err := c.DoPaginatedGet(endpoint, standardPageSize, startingPageNumber, sort_filter)
if err != nil {
return nil, fmt.Errorf(errMsgFailedPaginatedGet, "mobile device prestages", err)
}
var out ResponseMobileDevicePrestagesList
out.TotalCount = resp.Size
for _, value := range resp.Results {
var newObj ResourceMobileDevicePrestage
err := mapstructure.Decode(value, &newObj)
if err != nil {
return nil, fmt.Errorf(errMsgFailedMapstruct, "mobile device prestage", err)
}
out.Results = append(out.Results, newObj)
}
return &out, nil
}
// GetMobileDevicePrestageByID retrieves a single mobile prestage from the supplied ID
func (c *Client) GetMobileDevicePrestageByID(id string) (*ResourceMobileDevicePrestage, error) {
endpoint := fmt.Sprintf("%s/%s", uriMobileDevicePrestages, id)
var out ResourceMobileDevicePrestage
resp, err := c.HTTP.DoRequest("GET", endpoint, nil, &out)
if err != nil {
return nil, fmt.Errorf(errMsgFailedGetByID, "mobile device prestage", id, err)
}
if resp != nil && resp.Body != nil {
defer resp.Body.Close()
}
return &out, nil
}
// CreateMobileDevicePrestage creates a new mobile prestage and returns the id
func (c *Client) CreateMobileDevicePrestage(newPrestage ResourceMobileDevicePrestage) (*ResponseMobileDevicePrestageCreate, error) {
endpoint := uriMobileDevicePrestages
var out ResponseMobileDevicePrestageCreate
resp, err := c.HTTP.DoRequest("POST", endpoint, newPrestage, &out)
if err != nil {
return nil, fmt.Errorf(errMsgFailedCreate, "mobile device prestage", err)
}
if resp != nil {
defer resp.Body.Close()
}
return &out, nil
}
// DeleteMobileDevicePrestageByID a mobile prestage at the given id
func (c *Client) DeleteMobileDevicePrestageByID(id string) error {
endpoint := fmt.Sprintf("%s/%s", uriMobileDevicePrestages, id)
resp, err := c.HTTP.DoRequest("DELETE", endpoint, nil, nil)
if err != nil {
return fmt.Errorf(errMsgFailedDeleteByID, "mobile device prestage", id, err)
}
if resp != nil {
defer resp.Body.Close()
}
return nil
}
// QUERY Which other endpoints required here? I think something to do with the scopes & syncs but strugging to make sense of it.