Skip to content

Commit 7f39971

Browse files
authored
feat: add reclaim functionality for volume purchasing locations (#791)
* fix: refactor Jamf Protect functions * feat: add reclaim functionality for volume purchasing locations
1 parent e837322 commit 7f39971

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

sdk/jamfpro/jamfproapi_volume_purchasing_locations.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ func (c *Client) CreateVolumePurchasingLocation(request *VolumePurchasingLocatio
140140
defer resp.Body.Close()
141141
}
142142

143+
err = c.ReclaimVolumePurchasingLocationByID(responseLocation.ID)
144+
if err != nil {
145+
return nil, fmt.Errorf("failed to reclaim volume purchasing location: %v", err)
146+
}
147+
143148
return &responseLocation, nil
144149
}
145150

@@ -157,6 +162,11 @@ func (c *Client) UpdateVolumePurchasingLocationByID(id string, request *VolumePu
157162
defer resp.Body.Close()
158163
}
159164

165+
err = c.ReclaimVolumePurchasingLocationByID(responseLocation.ID)
166+
if err != nil {
167+
return nil, fmt.Errorf("failed to reclaim volume purchasing location: %v", err)
168+
}
169+
160170
return &responseLocation, nil
161171
}
162172

@@ -175,6 +185,27 @@ func (c *Client) DeleteVolumePurchasingLocationByID(id string) error {
175185
return nil
176186
}
177187

188+
// ReclaimVolumePurchasingLocationByID reclaims a specific volume purchasing location by its ID
189+
func (c *Client) ReclaimVolumePurchasingLocationByID(id string) error {
190+
endpoint := fmt.Sprintf("%s/%s/reclaim", uriVolumePurchasingLocations, id)
191+
192+
resp, _ := c.HTTP.DoRequest("POST", endpoint, nil, nil)
193+
194+
if resp == nil {
195+
return fmt.Errorf("failed to reclaim volume purchasing location: received nil response")
196+
}
197+
198+
if resp.Body != nil {
199+
defer resp.Body.Close()
200+
}
201+
202+
if resp.StatusCode != 202 {
203+
return fmt.Errorf("failed to reclaim volume purchasing location: unexpected status code %d", resp.StatusCode)
204+
}
205+
206+
return nil
207+
}
208+
178209
// QUERY do we need the stuff below here?
179210

180211
// GetVolumePurchasingContentForLocationByID retrieves the content for a specific volume purchasing location by its ID.

0 commit comments

Comments
 (0)