Skip to content

feat: add reclaim functionality for volume purchasing locations #791

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
31 changes: 31 additions & 0 deletions sdk/jamfpro/jamfproapi_volume_purchasing_locations.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ func (c *Client) CreateVolumePurchasingLocation(request *VolumePurchasingLocatio
defer resp.Body.Close()
}

err = c.ReclaimVolumePurchasingLocationByID(responseLocation.ID)
if err != nil {
return nil, fmt.Errorf("failed to reclaim volume purchasing location: %v", err)
}

return &responseLocation, nil
}

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

err = c.ReclaimVolumePurchasingLocationByID(responseLocation.ID)
if err != nil {
return nil, fmt.Errorf("failed to reclaim volume purchasing location: %v", err)
}

return &responseLocation, nil
}

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

// ReclaimVolumePurchasingLocationByID reclaims a specific volume purchasing location by its ID
func (c *Client) ReclaimVolumePurchasingLocationByID(id string) error {
endpoint := fmt.Sprintf("%s/%s/reclaim", uriVolumePurchasingLocations, id)

resp, _ := c.HTTP.DoRequest("POST", endpoint, nil, nil)

if resp == nil {
return fmt.Errorf("failed to reclaim volume purchasing location: received nil response")
}

if resp.Body != nil {
defer resp.Body.Close()
}

if resp.StatusCode != 202 {
return fmt.Errorf("failed to reclaim volume purchasing location: unexpected status code %d", resp.StatusCode)
}

return nil
}

// QUERY do we need the stuff below here?

// GetVolumePurchasingContentForLocationByID retrieves the content for a specific volume purchasing location by its ID.
Expand Down
Loading