Documentation
¶
Overview ¶
Package ab is the Apple Business API client: ES256 client-assertion auth + typed read methods. Auth OMITS the JWT `kid` (verified live: a kid -> invalid_client).
Index ¶
- type APIError
- type Client
- func (c *Client) APIWrite(method, path string, payload any) (int, []byte, error)
- func (c *Client) AddBlueprintMembers(bpID, rel, memberType string, ids []string) error
- func (c *Client) AuditEvents(start, end string) ([]Resource, error)
- func (c *Client) BlueprintRelationship(id, rel string) ([]Resource, error)
- func (c *Client) CreateConfiguration(name, xml string, platforms []string) (id, updated string, err error)
- func (c *Client) DeleteConfiguration(id string) error
- func (c *Client) FetchBlueprints(configNameByID map[string]string) ([]LiveBlueprint, error)
- func (c *Client) FetchCustomSettingDetail(id string) (LiveConfig, error)
- func (c *Client) FetchCustomSettings() ([]LiveConfig, error)
- func (c *Client) FetchCustomSettingsMetadata(progress func(string)) ([]LiveConfig, error)
- func (c *Client) FetchCustomSettingsWithProgress(progress func(string)) ([]LiveConfig, error)
- func (c *Client) GetBlueprint(id string) (*Resource, error)
- func (c *Client) GetConfiguration(id string) (*Resource, error)
- func (c *Client) ListApps() ([]Resource, error)
- func (c *Client) ListBlueprints() ([]Resource, error)
- func (c *Client) ListConfigurations() ([]Resource, error)
- func (c *Client) ListDevices() ([]Resource, error)
- func (c *Client) ListMDMServers() ([]Resource, error)
- func (c *Client) ListPackages() ([]Resource, error)
- func (c *Client) ListUserGroups() ([]Resource, error)
- func (c *Client) ListUsers() ([]Resource, error)
- func (c *Client) Raw(method, path string, body io.Reader) (int, []byte, error)
- func (c *Client) RemoveBlueprintMembers(bpID, rel, memberType string, ids []string) error
- func (c *Client) ResolveApp(nameOrID string) (*Resource, error)
- func (c *Client) ResolveBlueprint(nameOrID string) (*Resource, error)
- func (c *Client) ResolveConfig(nameOrID string) (*Resource, error)
- func (c *Client) TokenSource() *TokenSource
- func (c *Client) UpdateConfiguration(id, name, xml string) (updated string, err error)
- type LiveBlueprint
- type LiveConfig
- type Resource
- type TokenSource
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a thin Apple Business API client (read methods for Phase 0).
func (*Client) APIWrite ¶
APIWrite issues an authenticated non-GET request with a JSON body (used by the gated `api` passthrough). A nil payload sends no body. It retries 401 (re-mint) and 429, never 5xx (a write may have partially applied).
func (*Client) AddBlueprintMembers ¶
AddBlueprintMembers / RemoveBlueprintMembers converge a blueprint relation via explicit per-member ops (correct whether Apple merges or replaces). Gated in the engine — not used by autonomous config-only apply.
func (*Client) AuditEvents ¶
AuditEvents returns audit events between the start and end timestamps (ISO 8601).
func (*Client) BlueprintRelationship ¶
BlueprintRelationship returns linkage IDs for a blueprint member relation.
func (*Client) CreateConfiguration ¶
func (c *Client) CreateConfiguration(name, xml string, platforms []string) (id, updated string, err error)
CreateConfiguration POSTs a CUSTOM_SETTING config with the raw .mobileconfig XML. It returns the new config's ID and its server-assigned updatedDateTime (parsed from the 201 body) so the caller can record an exact baseline with no extra GET.
func (*Client) DeleteConfiguration ¶
DeleteConfiguration deletes a configuration by id.
func (*Client) FetchBlueprints ¶
func (c *Client) FetchBlueprints(configNameByID map[string]string) ([]LiveBlueprint, error)
FetchBlueprints lists all blueprints and resolves each one's attached configuration IDs to names via configNameByID. One list call plus one relationship call per blueprint (blueprints are few — cheaper than a GET/config).
func (*Client) FetchCustomSettingDetail ¶ added in v0.4.9
func (c *Client) FetchCustomSettingDetail(id string) (LiveConfig, error)
FetchCustomSettingDetail returns one CUSTOM_SETTING configuration with profile XML.
func (*Client) FetchCustomSettings ¶
func (c *Client) FetchCustomSettings() ([]LiveConfig, error)
FetchCustomSettings returns all CUSTOM_SETTING configs with their raw XML. Uses one list call with fields[] (incl. customSettingsValues) to avoid a GET per config; falls back to a per-config GET only if the list came back sparse.
func (*Client) FetchCustomSettingsMetadata ¶ added in v0.4.9
func (c *Client) FetchCustomSettingsMetadata(progress func(string)) ([]LiveConfig, error)
FetchCustomSettingsMetadata returns CUSTOM_SETTING configurations without requesting profile XML.
func (*Client) FetchCustomSettingsWithProgress ¶ added in v0.4.4
func (c *Client) FetchCustomSettingsWithProgress(progress func(string)) ([]LiveConfig, error)
FetchCustomSettingsWithProgress returns live CUSTOM_SETTING configurations while reporting long-running list and per-profile detail fetch progress through progress.
func (*Client) GetBlueprint ¶
GetBlueprint fetches a single blueprint by ID.
func (*Client) GetConfiguration ¶
GetConfiguration fetches a single configuration by ID.
func (*Client) ListBlueprints ¶
ListBlueprints returns all blueprints.
func (*Client) ListConfigurations ¶
ListConfigurations returns all configurations (every type; only CUSTOM_SETTING is writable).
func (*Client) ListDevices ¶
ListDevices returns the organization's devices (orgDevices).
func (*Client) ListMDMServers ¶
ListMDMServers returns the organization's MDM servers (read-only).
func (*Client) ListPackages ¶
ListPackages returns the organization's packages (custom apps/pkgs; read-only). The endpoint is gated by the built-in-device-management permission, so it may 403 for an account without it.
func (*Client) ListUserGroups ¶
ListUserGroups returns the organization's user groups (read-only).
func (*Client) ListUsers ¶
ListUsers returns the organization's users (read-only; identity is not API-writable).
func (*Client) Raw ¶
Raw issues an authenticated request. For replayable (nil-body) requests it re-mints once on 401 and backs off on 429/5xx (respecting Retry-After).
func (*Client) RemoveBlueprintMembers ¶
RemoveBlueprintMembers detaches members (per-member DELETE) from a blueprint relation.
func (*Client) ResolveApp ¶ added in v0.2.0
ResolveApp finds an owned app by id, bundleId, or name. id/bundleId are unique so they win immediately; name may collide, so a name that matches >1 app is an error (caller should use the id/bundleId). App ids are numeric adamIds, not UUIDs, so looksLikeID never matches — always list and match here.
func (*Client) ResolveBlueprint ¶
ResolveBlueprint finds a blueprint by id (UUID) or by its `name` attribute.
func (*Client) ResolveConfig ¶
ResolveConfig finds a configuration by id (UUID) or by its `name` attribute.
func (*Client) TokenSource ¶
func (c *Client) TokenSource() *TokenSource
TokenSource exposes the underlying bearer-token source (for whoami/health checks).
type LiveBlueprint ¶
type LiveBlueprint struct {
Name string
ID string
Configs []string // attached config names, sorted; an unresolved id passes through as-is
}
LiveBlueprint is a blueprint with the NAMES of its attached configurations.
type LiveConfig ¶
LiveConfig is a CUSTOM_SETTING configuration with its raw profile XML.
func (LiveConfig) ContentHash ¶ added in v0.4.9
func (l LiveConfig) ContentHash() string
ContentHash returns the known normalized profile hash, deriving it from XML when present.
type Resource ¶
type Resource struct {
Type string `json:"type"`
ID string `json:"id"`
Attributes json.RawMessage `json:"attributes"`
}
Resource is a JSON:API resource object.
type TokenSource ¶
type TokenSource struct {
// contains filtered or unexported fields
}
TokenSource mints and caches a bearer token from an ES256 client assertion.
func NewTokenSource ¶
func NewTokenSource(cfg *config.Config, hc *http.Client) *TokenSource
NewTokenSource caches the bearer in a stable, per-credential file (see tokenCachePath).
func (*TokenSource) Expiry ¶
func (ts *TokenSource) Expiry() time.Time
Expiry returns the cached token expiry (after a successful Token()).
func (*TokenSource) Invalidate ¶
func (ts *TokenSource) Invalidate()
Invalidate forces a re-mint on the next Token() (e.g., after a 401).
func (*TokenSource) Token ¶
func (ts *TokenSource) Token() (string, error)
Token returns a valid bearer, minting/refreshing if <60s remain.