platform

package
v1.15.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 6, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("not found")

ErrNotFound is returned when a resource name cannot be resolved to an ID.

Callers should prefer the SDK's built-in resolver methods directly:

blueprints.New(c).ResolveBlueprintIDByName(ctx, name)
compliancebenchmarks.New(c).ResolveBenchmarkIDByName(ctx, name)
compliancebenchmarks.New(c).ResolveBaselineIDByName(ctx, name)
devicegroups.New(c).ResolveDeviceGroupIDByName(ctx, name)
devices.New(c).ResolveDeviceIDByName(ctx, name)
devices.New(c).ResolveDeviceIDBySerialNumber(ctx, serial)

The SDK constructs subpackage clients cheaply (just a transport pointer), so per-call instantiation is fine. ErrNotFound stays here for use in platform.IsNotFound assertions across the codebase.

Functions

func ConfirmAction added in v1.15.0

func ConfirmAction(action, target string, yes bool) error

ConfirmAction prompts the user to confirm a destructive action. Returns nil on confirmation, an error otherwise. When stdin is not a terminal (e.g. CI), requires the --yes flag (yes==true) and returns an error if it isn't set.

Generated platform commands call this for destructive actions (delete, erase, etc.) before performing the request.

func IsNotFound

func IsNotFound(err error) bool

IsNotFound reports whether err is or wraps ErrNotFound.

func PrintList

func PrintList[T any](out registry.OutputFormatter, items []T) error

PrintList outputs a list of items through the CLI formatter.

func PrintOne

func PrintOne[T any](out registry.OutputFormatter, item T) error

PrintOne outputs a single item through the CLI formatter.

func ReadBody added in v1.15.0

func ReadBody(file string, sets []string) (any, error)

ReadBody assembles a JSON-marshallable request body from --file (JSON file path) and --set overrides ("key=value", "nested.key=value"). When file is empty an empty object is the starting point. Set values are JSON-decoded when they look like JSON (true/false/null/number/[]/{}/"...") and treated as strings otherwise. Dot-separated keys descend into nested maps.

Generated platform commands call this for POST/PATCH bodies. Returns nil when there's nothing to send (no file, no overrides) so callers can decide whether the op accepts an empty body or should error.

func RequirePlatformClient added in v1.15.0

func RequirePlatformClient(client *jamfplatform.Client) error

RequirePlatformClient returns a descriptive error when client is nil. Generated platform commands call this at the top of RunE so users get clear setup guidance instead of a nil-pointer panic.

func ResolveIDByName added in v1.15.0

func ResolveIDByName(ctx context.Context, client *jamfplatform.Client, listPath string, name string) (string, error)

ResolveIDByName finds a resource ID by its human-readable name on a Platform list endpoint. Walks pages when the response is paginated. Generated commands call this when the user supplies --name instead of a positional ID.

The list response can take several shapes:

  • {"results": [...], "totalCount": N} — paginated (blueprints, devices)
  • {"<resource>": [...]} — non-paginated single-array (baselines)
  • [...] — bare array

listPath is the full path including /api/{service}/v{n}/tenant/{tenantId}/<collection> with {tenantId} pre-substituted by the caller. Items are matched by checking "name", "title", and "displayName" properties in that order. The ID is read from "id" (and falls back to "blueprintId", "groupId", "deviceId" for resources that use a non-standard ID field).

func SelectTableColumns added in v1.15.0

func SelectTableColumns(data []byte, columns []TableColumn, format string) []byte

SelectTableColumns transforms a JSON array to include only the configured columns. For JSON/YAML/raw output formats, the input is returned unchanged so full fidelity is preserved.

Types

type TableColumn added in v1.15.0

type TableColumn struct {
	Field string // dot-notation JSON path (e.g. "deploymentState.state")
	Label string // output key/header
}

TableColumn defines a column selection for list table output.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL