DATA - Class/Schema – cavaliba.com
Description: DataClass and Schema

`CTRL K`

Documentation
Data Features
DATA - Class/Schema

# DATA - Class/Schema

DataClass are top-level asset families : Devices, Applications, Laptops, Projects, Customers, Books, Facilities, Cooking Receipes, Invoices, etc.

Schemas describes fields/attributes for each DataClass. Schema can be modified at any time during the life of the system: add or remove fields, change constraints.

Field types can be basic : string, int, float, boolean, date, IP addresses, … or more complex structure : other objects, enumetate (static) lists, users and groups, computed fields, etc. Fields can be single or multi-valued.

Instances are individual assets.

Instances have relationships : a geographical sites is located in a region or country. A virtual machine is hosted on a physical server, etc.

JSON/YAML - Datamodels (Class and Schema) are best configured with JSON/YAML files uploaded to Cavaliba from UI, API or CLI command, with appropriate permissions.

Cavaliba Data Management dynamicaly provides :

- a Responsive Web UI for humans : create, view, edit assets
- a REST API for machines: same operations, single instance/field level, or massive bulk transfer
- a CLI command to import/export in batch from/to external systems
- a relationship framework, including inheritance / propagation of fields and objects between Instances
- a Role/Permission model to handle authorization at Class/Instance/Field level
- a Data storage at scale on standard relationnal databases (PostgreSQL, MariaDB, MySQL, …) with an Entity-Attribute-Value (EAV) dynamic datamodel.

## Global Fields for all DataClass

All DataClass share a small number of mandatory fields.

- keyname - primarykey - unique name of the DataClass ; no special chars ; must be unique

- displayname - a short string for humans

- page - string, page name in the Web UI displaying the list of available DataClasses

- order - int, display order in the Web UI

- icon - string, name of a FontAwsome Icon to display in UI

- handle_method - method to create a unique HTML friendly primary key for instances

- permissions… - a set of permissions to control authorizations on instances

## Schema Fields

Each DataClass Schema can have zero or more custom fields. These fields can be single-valued or multi-valued. They have a type from one of the available field types below.

Field name must be a valid slug string (unique, no special chararcter) within the DataClass schema.

Available field types:

- string
- int
- float
- date
- datetime
- time
- boolean
- ipv4
- text
- enumerate (static lists)
- schema (other DataClass)
- user group
- user

## YAML Example

This simple example create a DataClass to manage user Laptops.

    # Asset = User Laptops

    - classname: _schema
      keyname: laptop
      displayname: User Laptops
      is_enabled: yes
      icon: fa-laptop
      order: 200
      page: Data
      handle_method: md5

      serial:
            displayname: serial_number
            page: General
            order: 100
            dataformat: string

      name:
            displayname: hostname
            page: General
            order: 110
            dataformat: string

      os:
            displayname: Operating System
            page: General
            order: 120
            dataformat: enumerate
            dataformat_ext: enumerate_os

      site:
            displayname: Site
            dataformat: schema
            dataformat_ext: site
            order: 130
            page: General
            cardinal_min: 0
            cardinal_max: 1

      owner:
            displayname: User
            dataformat: user
            order: 140
            page: General
            cardinal_min: 0
            cardinal_max: 0

      purchase_date:
            displayname: Purchase date
            dataformat: date

      waranty_end_date:
            displayname: Waranty end date
            dataformat: date

      bitlocker:
            displayname: Bitlocker
            page: Security
            order: 500
            dataformat: boolean

## YAML Reference

    - classname: _schema
      _action: create/delete/update/enable/disable
      keyname: string
      displayname: string
      is_enabled: boolean
      handle_method: [keyname|uuid|external|md5]
      icon: icon_name
      order: int
      page: string
      p_admin:  PERMISSION_NAME
      p_read:   PERMISSION_NAME
      p_create: PERMISSION_NAME
      p_update: PERMISSION_NAME
      p_delete: PERMISSION_NAME
      p_import: PERMISSION_NAME
      p_export: PERMISSION_NAME

      field_name:
           _action: create/delete/update/enable/disable
           displayname: string
           dataformat: fieldtype
           dataformat_ext: extended_fieldtype
           cardinal_min: int
           cardinal_max: int
           default : string
       (...)

DATA - Pipeline