Add enumerations and flags¶
This page explains how to add new enumerations and flags to KXS, and how to override existing ones.
Enumerations¶
There are four types of enumerations in KXS: byte, short, integer, and symbol.
Add a new enumeration¶
-
Navigate to
kxs-core/meta/enum.yamlto look up the required metadata for a new enumeration. The following example showsenum.yamlfor a byte enumeration:byteEnum: description: m-type: string values: m-type: list m-required: true m-value: name: m-type: symbol m-description: Enum name m-required: true value: m-type: byte m-description: Enum value m-required: true description: m-type: string m-description: Enum description ... -
If it doesn't already exist, create the standard
config/enum/directory for enumerations in your custom package. - Create a YAML file named after your new enumeration; for example,
flightStatus.yaml. - For your
m-metaparameters, enterenum.yamlfollowed by your enumeration type (byteEnum,shortEnum,intEnum, orsymbEnum). -
Enter a description for the new enumeration and populate the file with the expected YAML. See an example of the
flightStatus.yamlbelow:flightStatus: m-meta: enum.yaml shortEnum description: Defines the valid flight statuses that apply to airline flights values: - name: UNKNOWN value: 0 description: Unknown - name: ON_TIME value: 1 description: On time - name: DELAYED value: 2 description: Delayed - name: CANCELLED value: 3 description: Cancelled -
Save your changes.
- Move the file to the appropriate
config/enumoverride directory.
Override an existing enumeration¶
- If it doesn't already exist, create the standard
config/enum/directory for enumerations in your custom package. - Create a new YAML file named after the existing enumeration. For example,
flightStatus.yaml. -
Populate the file with the expected YAML. The YAML that you create at this level overrides any YAML files at a lower level with identical paths. The following example shows the resulting
flightStatus.yamloverride:flightStatus: m-meta: enum.yaml shortEnum description: Defines the flight status override for package XYZ. values: - name: UNKNOWN value: 0 description: Unknown - name: ON_TIME value: 1 description: On time - name: SCHEDULED value: 4 description: Scheduled -
Save your changes.
- Move the YAML file to the appropriate override directory.
Flags¶
There are two types of flags in KXS: byte and integer.
Add a new flag¶
-
Navigate to
kxs-core/meta/flags.yamlto look up the required metadata for a new flag. The following example showskxs-core/meta/flags.yaml:byteFlags: description: m-type: string values: m-type: list m-required: true m-value: name: m-type: symbol m-description: Flag name m-required: true value: m-type: byte m-description: Flag value m-required: true description: m-type: string m-description: Flag description ... -
Create a YAML file named after your new flag; for example,
myNewFlag.yaml. - For your
m-metaparameters, enterflags.yamlfollowed by your flag type (intFlagsorbyteFlags). -
Enter a description for the new flag and populate the file with the expected YAML. The following example shows the resulting
myNewFlag.yaml:myNewFlag: m-meta: flags.yaml intFlags description: Defines my new flag for customer ABC. values: - name: NONE value: 000 description: No flags - name: ABC value: 001 description: Abc - name: DEF value: 002 description: Def - name: GHI value: 003 description: Ghi -
Save your changes.
- Move the YAML file to the appropriate
/config/flagsoverride directory.
Override an existing flag¶
- Create a new YAML file named after the existing flag file. For example,
myNewFlag.yaml. -
Populate the file with the expected YAML. The YAML that you create at this level overrides any YAML files at a lower level with identical paths. The following example shows the resulting
myNewFlag.yamloverride:myNewFlag: m-meta: flags.yaml intFlags description: Defines my new flag for customer ABC. values: - name: DEF value: 002 description: Def - name: GHI value: 003 description: Ghi -
Save your changes.
- Move the YAML file to the appropriate override directory.