classic

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const CodegenHeader = "// Code generated by jamf-cli generator (classic). DO NOT EDIT."

CodegenHeader is the marker line at the top of every classic API generated file. Must match the first line of classicResourceTemplate and classicRegistryTemplate.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClassicFileField added in v1.11.0

type ClassicFileField struct {
	Flag                       string // CLI flag name, e.g. "mobileconfig-file"
	XMLPath                    string // Slash-delimited path under the resource root, e.g. "general/payloads"
	Encoding                   string // "xml-cdata" | "raw"
	Desc                       string // Flag description shown in --help
	NameFallback               string // "none" | "keep-ext" | "strip-ext"
	PreservePayloadIdentifiers bool   // If true, fetch existing payloads on update and call profileconvert.InjectIdentifiers
	FetchMergePut              bool   // If true, apply must fetch existing record, overlay only the file field, and PUT
}

ClassicFileField declares a resource field whose value is sourced from a local file via a dedicated CLI flag on create/update/apply. The file contents are injected as children of a named XML parent before the body is sent. Encoding controls how the file contents are embedded: "xml-cdata" wraps them in a CDATA section (for mobileconfig), "raw" inserts the XML subtree as-is (for AppConfig plists).

type ClassicResource

type ClassicResource struct {
	Name            string // e.g., "policies"
	Path            string // URL segment under /JSSResource/: "policies"
	CLIName         string // e.g., "classic-policies"
	GoName          string // e.g., "ClassicPolicies"
	Singular        string // JSON root key for a single object: "policy"
	Description     string
	Operations      []string // ["list", "get", "create", "update", "delete"]
	Lookups         []string // ["id", "name", "serialnumber", "macaddress", "udid"]
	HasScope        bool     // true if the resource supports scope operations
	IDPath          string   // path segment between base path and ID value; defaults to "id" (e.g. "groupid" → /accounts/groupid/{id})
	IsConfigProfile bool     // true for macOS and mobile device configuration profile resources
	FileFields      []ClassicFileField
	// ListSubset marks a list operation as sharing the list endpoint with a
	// sibling resource: GET /JSSResource/{path} returns both, and the generated
	// list command extracts only the named sub-element before formatting.
	// Used for /accounts (returns users + groups combined under <accounts>).
	// Empty for normal list endpoints.
	ListSubset string
}

ClassicResource represents a Classic API resource parsed from the YAML manifest.

func ParseManifest

func ParseManifest(path string) ([]ClassicResource, error)

ParseManifest reads the Classic API YAML manifest and returns a sorted slice of ClassicResource structs with all defaults applied.

func (*ClassicResource) ExtraLookups

func (r *ClassicResource) ExtraLookups() []string

ExtraLookups returns lookups beyond "id" (e.g., name, serialnumber, macaddress, udid).

func (*ClassicResource) HasLookup

func (r *ClassicResource) HasLookup(lookup string) bool

HasLookup returns true if the resource supports the given lookup type.

func (*ClassicResource) HasOperation

func (r *ClassicResource) HasOperation(op string) bool

HasOperation returns true if the resource supports the given operation.

type Generator

type Generator struct {
	// contains filtered or unexported fields
}

Generator generates Go command files from ClassicResource definitions.

func NewGenerator

func NewGenerator(outputDir string) *Generator

NewGenerator creates a new Classic API code generator.

func (*Generator) Generate

func (g *Generator) Generate(resource ClassicResource) (string, error)

Generate writes a Go command file for a single Classic API resource.

func (*Generator) GenerateRegistry

func (g *Generator) GenerateRegistry(resources []ClassicResource) (string, error)

GenerateRegistry writes the classic_registry.go file that registers all Classic commands.

Jump to

Keyboard shortcuts

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