Skip to content
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

godep: os beta enrollment #63

Merged
merged 5 commits into from
May 15, 2024
Merged
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
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")
}