Documentation
¶
Index ¶
Constants ¶
const CodegenHeader = "// Code generated by jamf-cli generator. DO NOT EDIT."
CodegenHeader is the marker line at the top of every modern API generated file. Must match the first line of resourceTemplate and registryTemplate.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator generates Go code from parsed resources
func NewGenerator ¶
NewGenerator creates a new code generator
type Operation ¶
type Operation struct {
Name string // e.g., "list", "get", "create"
Method string // HTTP method
Path string // API path
Summary string
Description string
Parameters []*Parameter
RequestBody *RequestBody
Responses map[string]*Response
IsAction bool // x-action: true
IsDestructive bool // Requires confirmation (delete, erase, etc.)
IsList bool // List operation with pagination support
APIVersion string // v1, v2, preview, etc.
Privileges []string // x-required-privileges
}
Operation represents an API operation (endpoint)
type Parameter ¶
type Parameter struct {
Name string
In string // "query", "path"
Description string
Required bool
Type string
Default any
IsArray bool
}
Parameter represents a query/path parameter
type Property ¶
type Property struct {
Name string
Type string
Description string
Example any
Nullable bool
ReadOnly bool
}
Property represents a schema property
type RequestBody ¶
type RequestBody struct {
Description string
Required bool
Schema *Schema
IsMultipart bool // true when content type is multipart/form-data
FileField string // schema property that holds the binary file (e.g. "file")
}
RequestBody represents a request body
type Resource ¶
type Resource struct {
Name string // e.g., "buildings"
NameSingular string // e.g., "building"
GoName string // e.g., "Buildings"
Description string
Operations []*Operation
Schemas map[string]*Schema
NameField string // Filter field for name lookups (default "name", some use "displayName")
IsSingleton bool // True for settings-style resources: single object, GET+PUT, no {id} in any path
}
Resource represents a parsed API resource (e.g., buildings, computers)
func DeduplicateVersioned ¶
DeduplicateVersioned consolidates multi-version resources so each resource group surfaces as a single command using the latest API version.
When multiple spec files cover the same resource at different API versions (e.g. MobileDevicePrestagesV2.yaml + MobileDevicePrestagesV3.yaml), the generator produces commands like "mobile-device-prestages-v-2s" and "mobile-device-prestages-v-3s". This function:
- Detects versioned resource names via the "-v-{N}s" suffix pattern
- For each version family, keeps only the highest version
- Renames the winning resource to the clean canonical name (no version suffix)
- Suppresses any non-versioned base resource that the versioned family supersedes
func ParseSpec ¶
ParseSpec parses an OpenAPI spec file and returns one or more Resources. Most specs produce a single resource, but specs with multiple sibling collection paths (e.g. /v1/foo/macos and /v1/foo/ios in the same file) produce one resource per family. Returns nil when the file should be skipped.