Skip to content

Commit da77d79

Browse files
committed
fix: struct reorg
1 parent e6c73b8 commit da77d79

File tree

2 files changed

+72
-60
lines changed

2 files changed

+72
-60
lines changed

axm/services/devicemanagement/crud.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ type (
1414
//
1515
// Apple Business Manager API docs:
1616
// https://developer.apple.com/documentation/applebusinessmanagerapi/get-mdm-servers
17-
GetDeviceManagementServices(ctx context.Context, opts *RequestQueryOptions) (*MDMServersResponse, error)
17+
GetDeviceManagementServices(ctx context.Context, opts *RequestQueryOptions) (*ResponseMDMServers, error)
1818

1919
// GetMDMServerDeviceLinkages retrieves a list of device IDs assigned to an MDM server
2020
//
2121
// Apple Business Manager API docs:
2222
// https://developer.apple.com/documentation/applebusinessmanagerapi/get-all-device-ids-for-a-mdmserver
23-
GetMDMServerDeviceLinkages(ctx context.Context, mdmServerID string, opts *RequestQueryOptions) (*MDMServerDevicesLinkagesResponse, error)
23+
GetMDMServerDeviceLinkages(ctx context.Context, mdmServerID string, opts *RequestQueryOptions) (*ResponseMDMServerDevicesLinkages, error)
2424

2525
// GetAssignedDeviceManagementServiceIDForADevice retrieves the assigned device management service ID linkage for a device
2626
//
2727
// Apple Business Manager API docs:
2828
// https://developer.apple.com/documentation/applebusinessmanagerapi/get-the-assigned-server-id-for-an-orgdevice
29-
GetAssignedDeviceManagementServiceIDForADevice(ctx context.Context, deviceID string) (*OrgDeviceAssignedServerLinkageResponse, error)
29+
GetAssignedDeviceManagementServiceIDForADevice(ctx context.Context, deviceID string) (*ResponseOrgDeviceAssignedServerLinkage, error)
3030

3131
// GetAssignedDeviceManagementServiceInformationByDeviceID retrieves the assigned device management service information for a device
3232
//
@@ -38,13 +38,13 @@ type (
3838
//
3939
// Apple Business Manager API docs:
4040
// https://developer.apple.com/documentation/applebusinessmanagerapi/create-an-orgdeviceactivity
41-
AssignDevicesToServer(ctx context.Context, mdmServerID string, deviceIDs []string) (*OrgDeviceActivityResponse, error)
41+
AssignDevicesToServer(ctx context.Context, mdmServerID string, deviceIDs []string) (*ResponseOrgDeviceActivity, error)
4242

4343
// UnassignDevicesFromServer unassigns devices from an MDM server
4444
//
4545
// Apple Business Manager API docs:
4646
// https://developer.apple.com/documentation/applebusinessmanagerapi/create-an-orgdeviceactivity
47-
UnassignDevicesFromServer(ctx context.Context, mdmServerID string, deviceIDs []string) (*OrgDeviceActivityResponse, error)
47+
UnassignDevicesFromServer(ctx context.Context, mdmServerID string, deviceIDs []string) (*ResponseOrgDeviceActivity, error)
4848
}
4949

5050
// DeviceManagementService handles communication with the device management
@@ -68,7 +68,7 @@ func NewService(client interfaces.HTTPClient) *DeviceManagementService {
6868
// GetDeviceManagementServices retrieves a list of device management services (MDM servers) in an organization
6969
// URL: GET https://api-business.apple.com/v1/mdmServers
7070
// https://developer.apple.com/documentation/applebusinessmanagerapi/get-mdm-servers
71-
func (s *DeviceManagementService) GetDeviceManagementServices(ctx context.Context, opts *RequestQueryOptions) (*MDMServersResponse, error) {
71+
func (s *DeviceManagementService) GetDeviceManagementServices(ctx context.Context, opts *RequestQueryOptions) (*ResponseMDMServers, error) {
7272
if opts == nil {
7373
opts = &RequestQueryOptions{}
7474
}
@@ -93,7 +93,7 @@ func (s *DeviceManagementService) GetDeviceManagementServices(ctx context.Contex
9393
"Content-Type": "application/json",
9494
}
9595

96-
var result MDMServersResponse
96+
var result ResponseMDMServers
9797
err := s.client.GetPaginated(ctx, endpoint, queryParams.Build(), headers, &result)
9898
if err != nil {
9999
return nil, err
@@ -105,7 +105,7 @@ func (s *DeviceManagementService) GetDeviceManagementServices(ctx context.Contex
105105
// GetMDMServerDeviceLinkages retrieves a list of device IDs assigned to an MDM server
106106
// URL: GET https://api-business.apple.com/v1/mdmServers/{id}/relationships/devices
107107
// https://developer.apple.com/documentation/applebusinessmanagerapi/get-all-device-ids-for-a-mdmserver
108-
func (s *DeviceManagementService) GetMDMServerDeviceLinkages(ctx context.Context, mdmServerID string, opts *RequestQueryOptions) (*MDMServerDevicesLinkagesResponse, error) {
108+
func (s *DeviceManagementService) GetMDMServerDeviceLinkages(ctx context.Context, mdmServerID string, opts *RequestQueryOptions) (*ResponseMDMServerDevicesLinkages, error) {
109109
if mdmServerID == "" {
110110
return nil, fmt.Errorf("MDM server ID is required")
111111
}
@@ -130,7 +130,7 @@ func (s *DeviceManagementService) GetMDMServerDeviceLinkages(ctx context.Context
130130
queryParams.AddInt("limit", opts.Limit)
131131
}
132132

133-
var result MDMServerDevicesLinkagesResponse
133+
var result ResponseMDMServerDevicesLinkages
134134

135135
err := s.client.GetPaginated(ctx, endpoint, queryParams.Build(), headers, &result)
136136
if err != nil {
@@ -143,7 +143,7 @@ func (s *DeviceManagementService) GetMDMServerDeviceLinkages(ctx context.Context
143143
// GetAssignedDeviceManagementServiceIDForADevice retrieves the assigned device management service ID linkage for a device
144144
// URL: GET https://api-business.apple.com/v1/orgDevices/{id}/relationships/assignedServer
145145
// https://developer.apple.com/documentation/applebusinessmanagerapi/get-the-assigned-server-id-for-an-orgdevice
146-
func (s *DeviceManagementService) GetAssignedDeviceManagementServiceIDForADevice(ctx context.Context, deviceID string) (*OrgDeviceAssignedServerLinkageResponse, error) {
146+
func (s *DeviceManagementService) GetAssignedDeviceManagementServiceIDForADevice(ctx context.Context, deviceID string) (*ResponseOrgDeviceAssignedServerLinkage, error) {
147147
if deviceID == "" {
148148
return nil, fmt.Errorf("device ID is required")
149149
}
@@ -155,7 +155,7 @@ func (s *DeviceManagementService) GetAssignedDeviceManagementServiceIDForADevice
155155
"Content-Type": "application/json",
156156
}
157157

158-
var result OrgDeviceAssignedServerLinkageResponse
158+
var result ResponseOrgDeviceAssignedServerLinkage
159159
err := s.client.Get(ctx, endpoint, nil, headers, &result)
160160
if err != nil {
161161
return nil, err
@@ -201,7 +201,7 @@ func (s *DeviceManagementService) GetAssignedDeviceManagementServiceInformationB
201201
// AssignDevicesToServer assigns devices to an MDM server
202202
// URL: POST https://api-business.apple.com/v1/orgDeviceActivities
203203
// https://developer.apple.com/documentation/applebusinessmanagerapi/create-an-orgdeviceactivity
204-
func (s *DeviceManagementService) AssignDevicesToServer(ctx context.Context, mdmServerID string, deviceIDs []string) (*OrgDeviceActivityResponse, error) {
204+
func (s *DeviceManagementService) AssignDevicesToServer(ctx context.Context, mdmServerID string, deviceIDs []string) (*ResponseOrgDeviceActivity, error) {
205205
if mdmServerID == "" {
206206
return nil, fmt.Errorf("MDM server ID is required")
207207
}
@@ -244,7 +244,7 @@ func (s *DeviceManagementService) AssignDevicesToServer(ctx context.Context, mdm
244244
"Content-Type": "application/json",
245245
}
246246

247-
var result OrgDeviceActivityResponse
247+
var result ResponseOrgDeviceActivity
248248

249249
err := s.client.Post(ctx, endpoint, request, headers, &result)
250250
if err != nil {
@@ -257,7 +257,7 @@ func (s *DeviceManagementService) AssignDevicesToServer(ctx context.Context, mdm
257257
// UnassignDevicesFromServer unassigns devices from an MDM server
258258
// URL: POST https://api-business.apple.com/v1/orgDeviceActivities
259259
// https://developer.apple.com/documentation/applebusinessmanagerapi/create-an-orgdeviceactivity
260-
func (s *DeviceManagementService) UnassignDevicesFromServer(ctx context.Context, mdmServerID string, deviceIDs []string) (*OrgDeviceActivityResponse, error) {
260+
func (s *DeviceManagementService) UnassignDevicesFromServer(ctx context.Context, mdmServerID string, deviceIDs []string) (*ResponseOrgDeviceActivity, error) {
261261
if mdmServerID == "" {
262262
return nil, fmt.Errorf("MDM server ID is required")
263263
}
@@ -300,7 +300,7 @@ func (s *DeviceManagementService) UnassignDevicesFromServer(ctx context.Context,
300300
"Content-Type": "application/json",
301301
}
302302

303-
var result OrgDeviceActivityResponse
303+
var result ResponseOrgDeviceActivity
304304
err := s.client.Post(ctx, endpoint, request, headers, &result)
305305
if err != nil {
306306
return nil, err

axm/services/devicemanagement/models.go

Lines changed: 57 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,7 @@ package devicemanagement
22

33
import "time"
44

5-
// Shared types for pagination and links
6-
type Meta struct {
7-
Paging *Paging `json:"paging,omitempty"`
8-
}
9-
10-
type Paging struct {
11-
Total int `json:"total,omitempty"`
12-
Limit int `json:"limit,omitempty"`
13-
NextCursor string `json:"nextCursor,omitempty"`
14-
}
15-
16-
type Links struct {
17-
Self string `json:"self,omitempty"`
18-
First string `json:"first,omitempty"`
19-
Next string `json:"next,omitempty"`
20-
Prev string `json:"prev,omitempty"`
21-
Last string `json:"last,omitempty"`
22-
}
5+
// ====== MDM SERVER TYPES ======
236

247
// MDMServer represents an MDM server in the Apple Business Manager system
258
type MDMServer struct {
@@ -53,21 +36,26 @@ type MDMServerDevicesLinks struct {
5336
Self string `json:"self,omitempty"`
5437
}
5538

56-
// MDMServersResponse represents the response for getting MDM servers
57-
type MDMServersResponse struct {
39+
// ResponseMDMServers represents the response for getting MDM servers
40+
type ResponseMDMServers struct {
5841
Data []MDMServer `json:"data"`
5942
Meta *Meta `json:"meta,omitempty"`
6043
Links *Links `json:"links,omitempty"`
6144
}
6245

63-
// RequestQueryOptions represents the query parameters for getting MDM servers
64-
type RequestQueryOptions struct {
65-
// Field selection - fields to return for mdmServers
66-
// Possible values: serverName, serverType, createdDateTime, updatedDateTime, devices
67-
Fields []string `json:"fields,omitempty"`
46+
// MDMServerResponse represents the response for getting a single MDM server
47+
type MDMServerResponse struct {
48+
Data MDMServer `json:"data"`
49+
Links *Links `json:"links,omitempty"`
50+
}
6851

69-
// Limit the number of included related resources to return (max 1000)
70-
Limit int `json:"limit,omitempty"`
52+
// ====== DEVICE LINKAGE TYPES ======
53+
54+
// ResponseMDMServerDevicesLinkages represents the response for getting device linkages for an MDM server
55+
type ResponseMDMServerDevicesLinkages struct {
56+
Data []MDMServerDeviceLinkage `json:"data"`
57+
Links *Links `json:"links,omitempty"`
58+
Meta *Meta `json:"meta,omitempty"`
7159
}
7260

7361
// MDMServerDeviceLinkage represents a device linkage in the MDM server relationships
@@ -76,11 +64,10 @@ type MDMServerDeviceLinkage struct {
7664
ID string `json:"id"` // Device ID
7765
}
7866

79-
// MDMServerDevicesLinkagesResponse represents the response for getting device linkages for an MDM server
80-
type MDMServerDevicesLinkagesResponse struct {
81-
Data []MDMServerDeviceLinkage `json:"data"`
82-
Links *Links `json:"links,omitempty"`
83-
Meta *Meta `json:"meta,omitempty"`
67+
// ResponseOrgDeviceAssignedServerLinkage represents the response for getting assigned server linkage
68+
type ResponseOrgDeviceAssignedServerLinkage struct {
69+
Data OrgDeviceAssignedServerLinkage `json:"data"`
70+
Links *AssignedServerLinks `json:"links,omitempty"`
8471
}
8572

8673
// OrgDeviceAssignedServerLinkage represents the linkage between a device and its assigned server
@@ -89,23 +76,13 @@ type OrgDeviceAssignedServerLinkage struct {
8976
ID string `json:"id"` // MDM Server ID
9077
}
9178

92-
// OrgDeviceAssignedServerLinkageResponse represents the response for getting assigned server linkage
93-
type OrgDeviceAssignedServerLinkageResponse struct {
94-
Data OrgDeviceAssignedServerLinkage `json:"data"`
95-
Links *AssignedServerLinks `json:"links,omitempty"`
96-
}
97-
9879
// AssignedServerLinks contains linkage navigation links
9980
type AssignedServerLinks struct {
10081
Self string `json:"self,omitempty"`
10182
Related string `json:"related,omitempty"`
10283
}
10384

104-
// MDMServerResponse represents the response for getting a single MDM server
105-
type MDMServerResponse struct {
106-
Data MDMServer `json:"data"`
107-
Links *Links `json:"links,omitempty"`
108-
}
85+
// ====== DEVICE ACTIVITY TYPES ======
10986

11087
// OrgDeviceActivity represents a device activity (assign/unassign operations)
11188
type OrgDeviceActivity struct {
@@ -128,12 +105,14 @@ type OrgDeviceActivityLinks struct {
128105
Self string `json:"self,omitempty"`
129106
}
130107

131-
// OrgDeviceActivityResponse represents the response for creating an org device activity
132-
type OrgDeviceActivityResponse struct {
108+
// ResponseOrgDeviceActivity represents the response for creating an org device activity
109+
type ResponseOrgDeviceActivity struct {
133110
Data OrgDeviceActivity `json:"data"`
134111
Links *Links `json:"links,omitempty"`
135112
}
136113

114+
// ====== DEVICE ACTIVITY REQUEST TYPES ======
115+
137116
// OrgDeviceActivityCreateRequest represents the request for creating a device activity
138117
type OrgDeviceActivityCreateRequest struct {
139118
Data OrgDeviceActivityData `json:"data"`
@@ -178,3 +157,36 @@ type OrgDeviceActivityDeviceLinkage struct {
178157
Type string `json:"type"` // Should be "orgDevices"
179158
ID string `json:"id"` // Device ID
180159
}
160+
161+
// ====== SHARED TYPES ======
162+
163+
// Meta represents pagination metadata
164+
type Meta struct {
165+
Paging *Paging `json:"paging,omitempty"`
166+
}
167+
168+
// Paging contains pagination information
169+
type Paging struct {
170+
Total int `json:"total,omitempty"`
171+
Limit int `json:"limit,omitempty"`
172+
NextCursor string `json:"nextCursor,omitempty"`
173+
}
174+
175+
// Links contains navigation links for API responses
176+
type Links struct {
177+
Self string `json:"self,omitempty"`
178+
First string `json:"first,omitempty"`
179+
Next string `json:"next,omitempty"`
180+
Prev string `json:"prev,omitempty"`
181+
Last string `json:"last,omitempty"`
182+
}
183+
184+
// RequestQueryOptions represents the query parameters for getting MDM servers
185+
type RequestQueryOptions struct {
186+
// Field selection - fields to return for mdmServers
187+
// Possible values: serverName, serverType, createdDateTime, updatedDateTime, devices
188+
Fields []string `json:"fields,omitempty"`
189+
190+
// Limit the number of included related resources to return (max 1000)
191+
Limit int `json:"limit,omitempty"`
192+
}

0 commit comments

Comments
 (0)