Skip to content

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

  1. Navigate to kxs-core/meta/enum.yaml to look up the required metadata for a new enumeration. The following example shows enum.yaml for 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
    ...
    
  2. If it doesn't already exist, create the standard config/enum/ directory for enumerations in your custom package.

  3. Create a YAML file named after your new enumeration; for example, flightStatus.yaml.
  4. For your m-meta parameters, enter enum.yaml followed by your enumeration type (byteEnum, shortEnum, intEnum, or symbEnum).
  5. Enter a description for the new enumeration and populate the file with the expected YAML. See an example of the flightStatus.yaml below:

    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
    
  6. Save your changes.

  7. Move the file to the appropriate config/enum override directory.

Override an existing enumeration

  1. If it doesn't already exist, create the standard config/enum/ directory for enumerations in your custom package.
  2. Create a new YAML file named after the existing enumeration. For example, flightStatus.yaml.
  3. 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.yaml override:

    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
    
  4. Save your changes.

  5. 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

  1. Navigate to kxs-core/meta/flags.yaml to look up the required metadata for a new flag. The following example shows kxs-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
    ...
    
  2. Create a YAML file named after your new flag; for example, myNewFlag.yaml.

  3. For your m-meta parameters, enter flags.yaml followed by your flag type (intFlags or byteFlags).
  4. 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
    
  5. Save your changes.

  6. Move the YAML file to the appropriate /config/flags override directory.

Override an existing flag

  1. Create a new YAML file named after the existing flag file. For example, myNewFlag.yaml.
  2. 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.yaml override:

    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
    
  3. Save your changes.

  4. Move the YAML file to the appropriate override directory.

Next steps