Documentation
¶
Index ¶
- Constants
- func ApplyGetDetailPaths(resources []*Resource)
- func ApplyListDetailPaths(resources []*Resource)
- func ApplyLookupFields(resources []*Resource)
- func ApplyNameFieldOverrides(resources []*Resource)
- func ApplyNameOverrides(resources []*Resource)
- func ApplyTableColumns(resources []*Resource)
- type Generator
- type LookupField
- type Operation
- type Parameter
- type Property
- type RequestBody
- type Resource
- type Response
- type ScalarField
- type Schema
- type TableColumn
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 ¶
func ApplyGetDetailPaths ¶
func ApplyGetDetailPaths(resources []*Resource)
ApplyGetDetailPaths configures "get" commands to use a richer detail endpoint. For resources whose get has a section parameter (e.g. computers-inventory), the detail path is stored in GetDetailPath and used as the default — specifying --section overrides back to the original path. For resources without section filtering (e.g. mobile-devices), the get path is swapped outright. Must be called after ApplyNameOverrides.
func ApplyListDetailPaths ¶
func ApplyListDetailPaths(resources []*Resource)
ApplyListDetailPaths swaps the "list" operation's path to a richer detail endpoint and injects a section query parameter. Must be called after ApplyNameOverrides and before ApplyTableColumns.
func ApplyLookupFields ¶
func ApplyLookupFields(resources []*Resource)
ApplyLookupFields sets LookupFields on resources that have alternate identifier fields defined in resourceLookupFields. Must be called after DeduplicateVersioned so resource names are in their final canonical form.
func ApplyNameFieldOverrides ¶
func ApplyNameFieldOverrides(resources []*Resource)
ApplyNameFieldOverrides corrects NameField and IDField values that the auto-detection heuristics got wrong. Must be called after ApplyNameOverrides so resource names are in their final canonical form.
func ApplyNameOverrides ¶
func ApplyNameOverrides(resources []*Resource)
ApplyNameOverrides corrects resource names that auto-pluralization got wrong. Must be called after DeduplicateVersioned.
func ApplyTableColumns ¶
func ApplyTableColumns(resources []*Resource)
ApplyTableColumns sets TableColumns and DefaultSections on resources that have preferred column configuration. Must be called after ApplyNameOverrides.
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 LookupField ¶
type LookupField struct {
Flag string // CLI flag name (e.g. "serial")
RSQLField string // RSQL filter field path (e.g. "hardware.serialNumber")
Desc string // Flag description shown in --help
}
LookupField represents an alternate identifier that can be used to resolve a resource ID instead of the primary name field (e.g. serial number for computers).
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
SchemaRef string // name of the referenced component schema for object/array types (e.g. "ComputerGeneralUpdate")
Nested *Schema // resolved nested schema for object types (may be nil)
}
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
IsMergePatch bool // true when content type is application/merge-patch+json
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")
IDField string // Response field for ID extraction in name resolution (default "id", some use "templateId", "groupId", etc.)
IsSingleton bool // True for settings-style resources: single object, GET+PUT, no {id} in any path
LookupFields []LookupField // Alternate identifier fields for patch-by-name / delete-by-name (e.g. serial number)
NameLookupPath string // Override list path for name resolution (when the standard list endpoint ignores RSQL)
NameLookupIDField string // Override ID field extracted from NameLookupPath response (when it differs from IDField)
HasVersionLock bool // True when PUT/POST request body includes versionLock (optimistic locking for prestages)
TableColumns []TableColumn // Preferred columns for list table output (when set, overrides generic column selection)
DefaultSections []string // Default --section values for list (when set, fetches these sections for table output)
GetDetailPath string // When set, "get" uses this path by default (returns all sections). If the get op has a section param, --section overrides back to the original 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.
type Response ¶
type Response struct {
StatusCode string
Description string
Schema *Schema
IsBinary bool // true for image/* content types, text/csv, or format:binary schemas
}
Response represents an API response
type ScalarField ¶
type ScalarField struct {
Path string // dot-notation path, e.g. "general.managed"
Type string // scalar type: "string", "integer", "boolean", "number"
}
ScalarField represents a patchable scalar field in dot-notation (e.g. "general.managed").
type TableColumn ¶
type TableColumn struct {
Field string // JSON field path (e.g., "general.name") — may use dot-notation for nested fields
Label string // Display label (e.g., "name") — used as the column header
}
TableColumn defines a preferred column for list table output.