schema

package
v0.0.0-...-59d4d0b Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const DeviceManagementGenerateHash = "b838baacf2e790db729b6ca3f52724adc8bfb96d"
View Source
const KeyANY = "ANY"

KeyANY is a special *PayloadKey.Key to represent a generic map[string]any instead of a struct

Variables

This section is empty.

Functions

func FromValue

func FromValue[T any](v *T) T

FromValue is a helper to get pointer values. If the pointer is nil, a zero value will be returned instead. e.g. FromValue[int64](NewValue[int64](10)) == 10 and FromValue[int64](nil) == 0

func NewValue

func NewValue[T any](v T) *T

NewValue is a helper function to get a pointer to a literal. e.g. NewValue[int64](10)

Types

type GlobalNamer

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

GlobalNamer namespaces schema and key names the minimum amount to achieve globally unique names among the registered schemas

func NewGlobalNamer

func NewGlobalNamer() *GlobalNamer

func (*GlobalNamer) KeyName

func (n *GlobalNamer) KeyName(key *PayloadKey) string

KeyName returns a unique name for the given key, amongst the registered schemas

func (*GlobalNamer) Register

func (n *GlobalNamer) Register(schemas ...*Schema)

func (*GlobalNamer) SchemaName

func (n *GlobalNamer) SchemaName(s *Schema) string

SchemaName returns a unique name for the given schema, amongst the registered schemas

type OS

type OS struct {
	// OS version where feature was introduced.
	Introduced string `yaml:"introduced,omitempty"`
	// OS version where feature was deprecated.
	Deprecated string `yaml:"deprecated,omitempty"`
	// OS version where feature was removed.
	Removed string `yaml:"removed,omitempty"`
	// The MDM protocol access rights required on the device to execute the command.
	AccessRights string `yaml:"accessrights,omitempty"`
	// Indicates whether multiple copies of the payload can be installed
	Multiple bool `yaml:"multiple,omitempty"`
	// Indicates whether the command or profile is supported on the device channel. If this key is present it overrides the the `devicechannel` key in the top-level payload !!(payload) key.
	DeviceChannel bool `yaml:"devicechannel,omitempty"`
	// indicates whether the command or profile is supported on the user channel. If this key is present it overrides the the `userchannel` key in the top-level payload !!(payload) key.
	UserChannel bool `yaml:"userchannel,omitempty"`
	// Indicates whether the command or profile can only be executed on supervised devices. If this key is present it overrides the the `supervised` key in the top-level payload !!(payload) key.
	Supervised bool `yaml:"supervised,omitempty"`
	// If True, the command can only be executed on devices provisioned in DEP.
	RequiresDEP bool `yaml:"requiresdep,omitempty"`
	// If True, the command can only be executed on devices with user approved MDM enrollment.
	UserApprovedMDM bool `yaml:"userapprovedmdm,omitempty"`
	// If True, the profile can be installed manually by a user on the device.
	AllowManualInstall bool `yaml:"allowmanualinstall,omitempty"`
	// Array of allowed enrollment types.
	AllowedEnrollments []string `yaml:"allowed-enrollments,omitempty"`
	// Array of allowed scopes.
	AllowedScopes []string `yaml:"allowed-scopes,omitempty"`
	// Additional behavior specific to shared iPad devices.
	SharediPad *SharediPad `yaml:"sharedipad,omitempty"`
	// Additional behavior when user enrollment is in effect. If this key is not present, then the corresponding payload or payload key can be used both with or without user enrollment in effect, without any changes to normal behavior.
	UserEnrollment *UserEnrollment `yaml:"userenrollment,omitempty"`
	// If true, indicates that the skip key's corresponding Setup pane is always skipped. If false, indicates that the skip key's corresponding Setup pane may be shown, depending on exactly when during the setup flow it occurs.
	AlwaysSkippable bool `yaml:"always-skippable,omitempty"`
}

Supported range on this OS.

type Payload

type Payload struct {
	// Type of the profile payload.
	PayloadType string `yaml:"payloadtype,omitempty"`
	// Type of the MDM command.
	RequestType string `yaml:"requesttype,omitempty"`
	// Type of the declaration payload.
	DeclarationType string `yaml:"declarationtype,omitempty"`
	// Type of the status payload.
	StatusItemType string `yaml:"statusitemtype,omitempty"`
	// Type of the credential asset data.
	CredentialType string `yaml:"credentialtype,omitempty"`
	// Identifies the range of supported OS versions that support the entire payload.
	SupportedOS *SupportedOS `yaml:"supportedOS,omitempty"`
	// Indicates how multiple configurations of the same type are applied. If set to 'single', then only one configuration will be applied. If set to 'multiple', then each configuration is applied separately. If set to 'combined', then all configurations are combined into a single effective configuration.
	Apply PayloadApply `yaml:"apply,omitempty"`
	// Description of the payload.
	Content string `yaml:"content,omitempty"`
}

Overall properties of the payload.

type PayloadApply

type PayloadApply string

Indicates how multiple configurations of the same type are applied. If set to 'single', then only one configuration will be applied. If set to 'multiple', then each configuration is applied separately. If set to 'combined', then all configurations are combined into a single effective configuration.

const (
	PayloadApplySingle   PayloadApply = "single"
	PayloadApplyMultiple PayloadApply = "multiple"
	PayloadApplyCombined PayloadApply = "combined"
)

type PayloadKey

type PayloadKey struct {
	// The name of the key.
	Key string `yaml:"key"`
	// The title of the key.
	Title string `yaml:"title,omitempty"`
	// Identifies the range of supported OS versions that support the entire payload.
	SupportedOS *SupportedOS `yaml:"supportedOS,omitempty"`
	// The type of key. The value `<any>` may be used to indicate that any of the standard values can be used without any expectation that the value will be validated.
	Type PayloadKeyType `yaml:"type"`
	// Indicates the expected format of the string value of the key, supporting additional validation of the value.
	SubType PayloadKeySubType `yaml:"subtype,omitempty"`
	// Indicates the set of allowed asset types.
	AssetTypes []string `yaml:"assettypes,omitempty"`
	// Whether the key is required or optional.
	Presence PayloadKeyPresence `yaml:"presence,omitempty"`
	// List of allowed values for this key.
	Rangelist []yamlschema.IntegerNumberString `yaml:"rangelist,omitempty"`
	// Bounds for the value of this key.
	Range *Range `yaml:"range,omitempty"`
	// The default value (if any) for the key.
	Default yamlschema.IntegerNumberString `yaml:"default,omitempty"`
	// The format for the value expressed as a regular expression.
	Format string `yaml:"format,omitempty"`
	// Cardinality for this value.
	Repetition *Repetition `yaml:"repetition,omitempty"`
	// For a configuration that will be combined, indicates how this key is combined with ones from other configurations.
	// * boolean-or - multiple <boolean> values are combined using a logical OR operation
	// * boolean-and - multiple <boolean> values are combined using a logical AND operation
	// * number-min - multiple <integer> or <real> values are combined by using the smallest value
	// * number-max - multiple <integer> or <real> values are combined by using the largest value
	// * enum-lowest - multiple <string> values with a rangelist are combined by using the value whose position is lowest in the range list
	// * enum-highest - multiple <string> values with a rangelist are combined by using the value whose position is highest in the range list
	// * first - multiple values are combined by using the first value that is processed
	// * array-append - multiple <array> values are combined by concatenating the values in each array into a new array
	// * set-union - multiple <array> values are combined by returning the unique union of all values in each array
	// * set-intersection - multiple <array> values are combined by returning the unique intersection of all values in each array
	CombineType PayloadKeyCombineType `yaml:"combinetype,omitempty"`
	// Description of the payload key.
	Content string `yaml:"content,omitempty"`
	// A name that uniquely represents the structured subkey object. This is used when structured subkeys are referenced multiple times.
	SubKeyType string `yaml:"subkeytype,omitempty"`
	// An array of payload keys.
	SubKeys []*PayloadKey `yaml:"subkeys,omitempty"`
}

A single payload key.

type PayloadKeyCombineType

type PayloadKeyCombineType string

For a configuration that will be combined, indicates how this key is combined with ones from other configurations. * boolean-or - multiple <boolean> values are combined using a logical OR operation * boolean-and - multiple <boolean> values are combined using a logical AND operation * number-min - multiple <integer> or <real> values are combined by using the smallest value * number-max - multiple <integer> or <real> values are combined by using the largest value * enum-lowest - multiple <string> values with a rangelist are combined by using the value whose position is lowest in the range list * enum-highest - multiple <string> values with a rangelist are combined by using the value whose position is highest in the range list * first - multiple values are combined by using the first value that is processed * array-append - multiple <array> values are combined by concatenating the values in each array into a new array * set-union - multiple <array> values are combined by returning the unique union of all values in each array * set-intersection - multiple <array> values are combined by returning the unique intersection of all values in each array

const (
	PayloadKeyCombineTypeBooleanOr       PayloadKeyCombineType = "boolean-or"
	PayloadKeyCombineTypeBooleanAnd      PayloadKeyCombineType = "boolean-and"
	PayloadKeyCombineTypeNumberMin       PayloadKeyCombineType = "number-min"
	PayloadKeyCombineTypeNumberMax       PayloadKeyCombineType = "number-max"
	PayloadKeyCombineTypeEnumLowest      PayloadKeyCombineType = "enum-lowest"
	PayloadKeyCombineTypeEnumHighest     PayloadKeyCombineType = "enum-highest"
	PayloadKeyCombineTypeFirst           PayloadKeyCombineType = "first"
	PayloadKeyCombineTypeArrayAppend     PayloadKeyCombineType = "array-append"
	PayloadKeyCombineTypeSetUnion        PayloadKeyCombineType = "set-union"
	PayloadKeyCombineTypeSetIntersection PayloadKeyCombineType = "set-intersection"
)

type PayloadKeyPresence

type PayloadKeyPresence string

Whether the key is required or optional.

const (
	PayloadKeyPresenceRequired PayloadKeyPresence = "required"
	PayloadKeyPresenceOptional PayloadKeyPresence = "optional"
)

type PayloadKeySubType

type PayloadKeySubType string

Indicates the expected format of the string value of the key, supporting additional validation of the value.

const (
	PayloadKeySubTypeURL      PayloadKeySubType = "<url>"
	PayloadKeySubTypeHostname PayloadKeySubType = "<hostname>"
	PayloadKeySubTypeEmail    PayloadKeySubType = "<email>"
)

type PayloadKeyType

type PayloadKeyType string

The type of key. The value `<any>` may be used to indicate that any of the standard values can be used without any expectation that the value will be validated.

const (
	PayloadKeyTypeString     PayloadKeyType = "<string>"
	PayloadKeyTypeInteger    PayloadKeyType = "<integer>"
	PayloadKeyTypeReal       PayloadKeyType = "<real>"
	PayloadKeyTypeBoolean    PayloadKeyType = "<boolean>"
	PayloadKeyTypeDate       PayloadKeyType = "<date>"
	PayloadKeyTypeData       PayloadKeyType = "<data>"
	PayloadKeyTypeArray      PayloadKeyType = "<array>"
	PayloadKeyTypeDictionary PayloadKeyType = "<dictionary>"
	PayloadKeyTypeAny        PayloadKeyType = "<any>"
)

type Range

type Range struct {
	// Lower bound.
	Min yamlschema.IntegerNumber `yaml:"min,omitempty"`
	// Upper bound.
	Max yamlschema.IntegerNumber `yaml:"max,omitempty"`
}

Bounds for the value of this key.

type Repetition

type Repetition struct {
	// Lower bound.
	Min int64 `yaml:"min"`
	// Upper bound.
	Max int64 `yaml:"max"`
}

Cardinality for this value.

type Schema

type Schema struct {
	// Title for this schema object.
	Title string `yaml:"title"`
	// Description of this schema object.
	Description string `yaml:"description,omitempty"`
	// Overall properties of the payload.
	Payload *Payload `yaml:"payload,omitempty"`
	// An array of payload keys.
	PayloadKeys []*PayloadKey `yaml:"payloadkeys,omitempty"`
	// An array of payload keys.
	ResponseKeys []*PayloadKey `yaml:"responsekeys,omitempty"`
}

func New

func New(data []byte) (*Schema, error)

func NewFromFile

func NewFromFile(path string) (*Schema, error)

func (*Schema) Iter

func (s *Schema) Iter(f func(parent, key *PayloadKey))

type SharediPad

type SharediPad struct {
	// Indicates whether a payload or payload key can used with or without shared iPad in effect. If set to 'allowed', then the payload or payload key can be used both with or without shared iPad in effect. If set to 'required', then the payload or payload key can only be used if shared iPad is in effect. If set to 'forbidden', then the payload or payload key cannot be used if shared iPad is in effect. If set to 'ignored', then the payload or payload key can be used, but is ignored if shared iPad is in effect.
	Mode SharediPadMode `yaml:"mode,omitempty"`
	// Defines if the payload can be installed on the device MDM channel.
	DeviceChannel bool `yaml:"devicechannel,omitempty"`
	// Defines if the payload can be installed on the user MDM channel.
	UserChannel bool `yaml:"userchannel,omitempty"`
	// Array of allowed scopes.
	AllowedScopes []string `yaml:"allowed-scopes,omitempty"`
}

Additional behavior specific to shared iPad devices.

type SharediPadMode

type SharediPadMode string

Indicates whether a payload or payload key can used with or without shared iPad in effect. If set to 'allowed', then the payload or payload key can be used both with or without shared iPad in effect. If set to 'required', then the payload or payload key can only be used if shared iPad is in effect. If set to 'forbidden', then the payload or payload key cannot be used if shared iPad is in effect. If set to 'ignored', then the payload or payload key can be used, but is ignored if shared iPad is in effect.

const (
	SharediPadModeAllowed   SharediPadMode = "allowed"
	SharediPadModeRequired  SharediPadMode = "required"
	SharediPadModeForbidden SharediPadMode = "forbidden"
	SharediPadModeIgnored   SharediPadMode = "ignored"
)

type SupportedOS

type SupportedOS struct {
	// Supported range on this OS.
	IOS *OS `yaml:"iOS,omitempty"`
	// Supported range on this OS.
	MacOS *OS `yaml:"macOS,omitempty"`
	// Supported range on this OS.
	TVOS *OS `yaml:"tvOS,omitempty"`
	// Supported range on this OS.
	WatchOS *OS `yaml:"watchOS,omitempty"`
}

Identifies the range of supported OS versions that support the entire payload.

type UserEnrollment

type UserEnrollment struct {
	// Indicates how a payload or payload key can only be used if user enrollment is in effect. If set to 'allowed', then the payload or payload key can be used both with or without user enrollment in effect. If set to 'required', then the payload or payload key can only be used if user enrollment is in effect. If set to 'forbidden', then the payload or payload key cannot be used if user enrollment is in effect. If set to 'ignored', then the payload or payload key can be used, but is ignored if user enrollment is in effect.
	Mode UserEnrollmentMode `yaml:"mode,omitempty"`
	// Describes any special behavior for the payload or payload key if user enrollment is in effect.
	Behavior string `yaml:"behavior,omitempty"`
}

Additional behavior when user enrollment is in effect. If this key is not present, then the corresponding payload or payload key can be used both with or without user enrollment in effect, without any changes to normal behavior.

type UserEnrollmentMode

type UserEnrollmentMode string

Indicates how a payload or payload key can only be used if user enrollment is in effect. If set to 'allowed', then the payload or payload key can be used both with or without user enrollment in effect. If set to 'required', then the payload or payload key can only be used if user enrollment is in effect. If set to 'forbidden', then the payload or payload key cannot be used if user enrollment is in effect. If set to 'ignored', then the payload or payload key can be used, but is ignored if user enrollment is in effect.

const (
	UserEnrollmentModeAllowed   UserEnrollmentMode = "allowed"
	UserEnrollmentModeRequired  UserEnrollmentMode = "required"
	UserEnrollmentModeForbidden UserEnrollmentMode = "forbidden"
	UserEnrollmentModeIgnored   UserEnrollmentMode = "ignored"
)

Jump to

Keyboard shortcuts

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