Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Device Disown endpoint to godep #43

Merged
merged 2 commits into from
Mar 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions godep/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ func IsCursorExpired(err error) bool {
return httpErrorContains(err, http.StatusBadRequest, "EXPIRED_CURSOR")
}

// DeviceListRequest corresponds to the Apple API "DeviceListRequest" structure.
// See https://developer.apple.com/documentation/devicemanagement/devicelistrequest
type DeviceListRequest struct {
Devices []string `json:"devices"`
}

// DeviceListResponse corresponds to the Apple API "DeviceListResponse" structure.
// See https://developer.apple.com/documentation/devicemanagement/devicelistresponse
type DeviceListResponse struct {
Expand All @@ -124,11 +130,24 @@ type DeviceListResponse struct {
// details on a set of devices.
// See https://developer.apple.com/documentation/devicemanagement/get_device_details
func (c *Client) DeviceDetails(ctx context.Context, name string, serials ...string) (*DeviceListResponse, error) {
req := struct {
Devices []string `json:"devices"`
}{
Devices: serials,
}
req := DeviceListRequest{Devices: serials}
resp := new(DeviceListResponse)
return resp, c.do(ctx, name, http.MethodPost, "/devices", req, resp)
}

// DeviceStatusResponse corresponds to the Apple API "DeviceStatusRepoonse" structure.
// See https://developer.apple.com/documentation/devicemanagement/devicestatusresponse
type DeviceStatusResponse struct {
Devices map[string]string `json:"devices"`
}

// DisownDevices uses the Apple "Disown Devices" API endpoint to disclaim
// ownership of device serial numbers.
// WARNING: This will permanantly remove devices from the ABM/ASM/ABE instance.
jessepeterson marked this conversation as resolved.
Show resolved Hide resolved
// Use with caution.
// See https://developer.apple.com/documentation/devicemanagement/disown_devices
func (c *Client) DisownDevices(ctx context.Context, name string, serials ...string) (*DeviceStatusResponse, error) {
req := DeviceListRequest{Devices: serials}
resp := new(DeviceStatusResponse)
return resp, c.do(ctx, name, http.MethodPost, "/devices/disown", req, resp)
}