Skip to content

Commit

Permalink
godep: os beta enrollment support (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
jessepeterson authored May 15, 2024
1 parent a3db510 commit f0b5dce
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions godep/beta.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package godep

import (
"context"
"net/http"
)

// SeedBuildToken corresponds to the Apple DEP API "SeedBuildToken" structure.
// See https://developer.apple.com/documentation/devicemanagement/seedbuildtoken
type SeedBuildToken struct {
Token string `json:"token"`
Title string `json:"title"`
OS string `json:"os"`
}

// GetSeedBuildTokenResponse corresponds to the Apple DEP API "GetSeedBuildTokenResponse" structure.
// See https://developer.apple.com/documentation/devicemanagement/getseedbuildtokenresponse
type GetSeedBuildTokenResponse struct {
BetaEnrollmentTokens []SeedBuildToken `json:"betaEnrollmentTokens,omitempty"`
SeedBuildTokens []SeedBuildToken `json:"seedBuildTokens,omitempty"`
}

// OSBetaEnrollmentTokens uses the Apple "Get Beta Enrollment Tokens" API endpoint to fetch the
// OS beta enrollment tokens. These are for later use during ADE
// enrollment of devices to force enrollment into beta software enrollment.
// See https://developer.apple.com/documentation/devicemanagement/get_beta_enrollment_tokens
func (c *Client) OSBetaEnrollmentTokens(ctx context.Context, name string) (*GetSeedBuildTokenResponse, error) {
resp := new(GetSeedBuildTokenResponse)
return resp, c.do(ctx, name, http.MethodGet, "/os-beta-enrollment/tokens", nil, resp)
}

// IsAppleSeedForITTurnedOff returns true if err indicates your organization doesn't allow beta access.
func IsAppleSeedForITTurnedOff(err error) bool {
return httpErrorContains(err, http.StatusForbidden, "APPLE_SEED_FOR_IT_TURNED_OFF")
}

0 comments on commit f0b5dce

Please sign in to comment.