Documentation
¶
Index ¶
- Variables
- func BackupFilterNames() []string
- func BoundedParallelFetch[T any, R any](ctx context.Context, items []T, concurrency int, ...) ([]R, []error)
- func DeduplicateSlug(slug string, seen map[string]bool) string
- func FetchAllPaginated(ctx context.Context, client registry.HTTPClient, basePath string, pageSize int) ([]map[string]any, error)
- func FetchClassicList(ctx context.Context, client registry.HTTPClient, path, wrapperKey string) ([]any, error)
- func FetchClassicListSubset(ctx context.Context, client registry.HTTPClient, path, subset string) ([]map[string]any, error)
- func FetchJSON(ctx context.Context, client registry.HTTPClient, path string) (map[string]any, error)
- func FormatError(err error) bool
- func NewRootCmd(version, commit, date string) *cobra.Command
- func ResolveAuthForProfile(cfg *config.Config, params AuthParams) (string, auth.Provider, error)
- func SlugifyName(name string) string
- func StripServerFields(obj map[string]any) map[string]any
- type AuthParams
- type BackupResource
- type FetchResult
- type ResolvedBackupResource
Constants ¶
This section is empty.
Variables ¶
var BackupResources = []BackupResource{ {Key: "classic-policies", FilterName: "policies", SubDir: "policies"}, {Key: "classic-macos-config-profiles", FilterName: "profiles", SubDir: "profiles/macos"}, {Key: "classic-mobile-config-profiles", FilterName: "profiles", SubDir: "profiles/ios"}, {Key: "scripts", FilterName: "scripts", SubDir: "scripts"}, {Key: "computer-extension-attributes", FilterName: "extension-attributes", SubDir: "extension-attributes/computer"}, {Key: "mobile-device-extension-attributes", FilterName: "extension-attributes", SubDir: "extension-attributes/mobile"}, {Key: "classic-user-ext-attrs", FilterName: "extension-attributes", SubDir: "extension-attributes/user"}, {Key: "smart-computer-groups", FilterName: "smart-groups", SubDir: "smart-groups/computers"}, {Key: "static-computer-groups", FilterName: "static-groups", SubDir: "static-groups/computers"}, {Key: "mobile-device-groups-smart-groups", FilterName: "smart-groups", SubDir: "smart-groups/mobile"}, {Key: "mobile-device-groups-static-groups", FilterName: "static-groups", SubDir: "static-groups/mobile"}, {Key: "categories", FilterName: "categories", SubDir: "categories"}, {Key: "buildings", FilterName: "buildings", SubDir: "buildings"}, {Key: "departments", FilterName: "departments", SubDir: "departments"}, {Key: "sites", FilterName: "sites", SubDir: "sites", ListOnly: true}, {Key: "classic-packages", FilterName: "packages", SubDir: "packages"}, {Key: "classic-printers", FilterName: "printers", SubDir: "printers"}, {Key: "classic-dock-items", FilterName: "dock-items", SubDir: "dock-items"}, {Key: "classic-network-segments", FilterName: "network-segments", SubDir: "network-segments"}, {Key: "classic-restricted-software", FilterName: "restricted-software", SubDir: "restricted-software"}, {Key: "classic-disk-encryption-configs", FilterName: "disk-encryption", SubDir: "disk-encryption"}, {Key: "classic-patch-titles", FilterName: "patch-titles", SubDir: "patch-titles"}, {Key: "classic-account-users", FilterName: "accounts", SubDir: "accounts/users"}, {Key: "classic-account-groups", FilterName: "accounts", SubDir: "accounts/groups"}, }
BackupResources is the curated set of resources included in `backup` and `diff`. Endpoint paths live in generated/backup_registry.go; this file only decides which resources are in scope and how they lay out on disk.
Grouping follows a logical config-object order: policies/profiles first, then scripts/EAs/groups, then supporting objects, then administration.
Functions ¶
func BackupFilterNames ¶ added in v1.11.0
func BackupFilterNames() []string
BackupFilterNames returns the unique set of FilterName values (sorted) — used for CLI help text and completion hints.
func BoundedParallelFetch ¶
func BoundedParallelFetch[T any, R any](ctx context.Context, items []T, concurrency int, fn func(context.Context, T) (R, error)) ([]R, []error)
BoundedParallelFetch runs fn for each item with bounded concurrency. Returns all results (in input order) and any errors collected.
func DeduplicateSlug ¶
DeduplicateSlug appends a numeric suffix if slug already exists in the set. Returns the unique slug and adds it to the set.
func FetchAllPaginated ¶
func FetchAllPaginated(ctx context.Context, client registry.HTTPClient, basePath string, pageSize int) ([]map[string]any, error)
FetchAllPaginated fetches all items from a modern API endpoint. It auto-detects the response format:
- Paginated: `{"totalCount": N, "results": [...]}` — fetches all pages
- Array: `[{...}, {...}]` — returns the full array directly
Some Jamf Pro endpoints (e.g. /v1/sites, /v1/computer-groups, /v2/patch-software-title-configurations) return plain arrays even when pagination params are provided. This function handles both transparently.
func FetchClassicList ¶
func FetchClassicList(ctx context.Context, client registry.HTTPClient, path, wrapperKey string) ([]any, error)
FetchClassicList performs a GET on a Classic API list endpoint and returns the unwrapped array. Classic API returns XML; JSON is handled as a fallback.
func FetchClassicListSubset ¶ added in v1.11.0
func FetchClassicListSubset(ctx context.Context, client registry.HTTPClient, path, subset string) ([]map[string]any, error)
FetchClassicListSubset performs a GET on a Classic API endpoint that hosts multiple sibling collections under a single root (currently only /JSSResource/accounts, which nests <users> and <groups> inside <accounts>) and returns the items belonging to the named subset. The runtime mirror of the list_subset manifest opt-in handled by the classic generator in PR 152.
func FetchJSON ¶
func FetchJSON(ctx context.Context, client registry.HTTPClient, path string) (map[string]any, error)
FetchJSON performs a GET request and returns the parsed JSON object. Exported version of the overview.go fetchJSON helper.
func FormatError ¶
FormatError writes a structured JSON error to stdout when the output format is "json". Returns true if the error was handled, false otherwise (caller should fall back to plain stderr).
func NewRootCmd ¶
func ResolveAuthForProfile ¶
ResolveAuthForProfile determines the server URL and auth provider for a specific profile name using the given config. Unlike resolveAuth, it does not read or mutate package-level variables, making it safe to call multiple times for different profiles (e.g., in the diff command).
func SlugifyName ¶
SlugifyName converts a display name to a filesystem-safe slug. "Deploy Chrome - v1.2" → "deploy-chrome-v1-2"
Types ¶
type AuthParams ¶
type AuthParams struct {
Profile string
ServerURL string
Token string
TokenFile string
TokenStdin bool
ClientID string
ClientSecret string
TenantID string
}
AuthParams holds all auth-related inputs for profile resolution. Enables callers (like diff) to resolve multiple profiles independently.
type BackupResource ¶ added in v1.11.0
type BackupResource struct {
Key string // lookup in generated.BackupEndpoints
FilterName string // --resources filter token
SubDir string // output subdirectory under --output
// ListOnly bypasses the per-ID detail fetch — each list item is written
// directly to disk as its own file. Used for resources whose list response
// is already the complete record (e.g. sites: {id, name}).
ListOnly bool
}
BackupResource is a curated entry in the backup/diff resource set. Each entry names a generated CLI command (Key) whose list+get endpoints are resolved at runtime from generated.BackupEndpoints. FilterName is the user-facing token accepted by --resources (e.g. "profiles" covers both macOS and iOS profiles); SubDir is the output directory under the backup root.
Rule of thumb: prefer a modern-API resource over its classic counterpart when both exist (modern responses are richer and paginated). Only fall back to classic when there is no modern equivalent.
type FetchResult ¶
FetchResult holds either a result or an error from a parallel fetch.
type ResolvedBackupResource ¶ added in v1.11.0
type ResolvedBackupResource struct {
BackupResource
generated.BackupEndpoint
}
ResolvedBackupResource couples a curated entry with its generated endpoint metadata. Runtime code iterates the resolved form so it doesn't need to cross-reference two slices at every step.
func ResolveBackupResources ¶ added in v1.11.0
func ResolveBackupResources(filter []string) ([]ResolvedBackupResource, error)
ResolveBackupResources joins the curated BackupResources against the generated endpoint registry, optionally filtering by user-supplied resource names (matched against FilterName). An unknown filter name produces an empty result; a filter name that matches zero curated entries is reported by the caller.
An entry whose Key is missing from generated.BackupEndpoints is a programming error — a regenerated registry and a stale curation list have diverged — and surfaces via an error so tests catch the drift at build time.
Source Files
¶
- aliases.go
- completion.go
- config.go
- groups.go
- multi.go
- platform.go
- platform_auth.go
- pro.go
- pro_audit.go
- pro_auth.go
- pro_backup.go
- pro_blueprints.go
- pro_bulk.go
- pro_bulk_commands.go
- pro_bulk_groups.go
- pro_bulk_policies.go
- pro_command_flush.go
- pro_compliance_benchmarks.go
- pro_ddm_reports.go
- pro_device.go
- pro_device_actions.go
- pro_device_resolve.go
- pro_diff.go
- pro_group_tools.go
- pro_helpers.go
- pro_overview.go
- pro_packages_upload.go
- pro_platform_device_groups.go
- pro_platform_devices.go
- pro_platform_helpers.go
- pro_report.go
- pro_report_compliance.go
- pro_report_ea.go
- pro_report_inventory.go
- pro_report_mdm.go
- pro_report_patch.go
- pro_report_platform.go
- pro_report_policy.go
- pro_report_security.go
- pro_report_software.go
- pro_report_updates.go
- pro_resources.go
- pro_setup.go
- protect.go
- protect_action_configs.go
- protect_alerts.go
- protect_analytic_sets.go
- protect_analytics.go
- protect_api_clients.go
- protect_audit_logs.go
- protect_auth.go
- protect_computers.go
- protect_exception_sets.go
- protect_groups.go
- protect_helpers.go
- protect_insights.go
- protect_org.go
- protect_overview.go
- protect_permissions.go
- protect_plans.go
- protect_prevent_lists.go
- protect_roles.go
- protect_rscs.go
- protect_setup.go
- protect_telemetry.go
- protect_ulf.go
- protect_users.go
- root.go
- school.go
- school_apps.go
- school_classes.go
- school_dep_devices.go
- school_device_groups.go
- school_devices.go
- school_groups.go
- school_ibeacons.go
- school_locations.go
- school_overview.go
- school_profiles.go
- school_setup.go
- school_users.go