Skip to content

Commit

Permalink
add Device Disown endpoint to godep (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
jessepeterson authored Mar 13, 2024
1 parent e87b1e3 commit 155fd5d
Showing 1 changed file with 24 additions and 5 deletions.
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.
// 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)
}

0 comments on commit 155fd5d

Please sign in to comment.