Skip to content

Rest: databag templates api

Svyatoslav Reyentenko edited this page Mar 20, 2013 · 11 revisions

Databag template impose some structure for the databags and environment configurations created on their base. New object retain a link to template, hence cannot be modified in an arbirtrary ways. Databag template contains following fields:

Field Type Mandatory Description
id String Y Free form template identifier. Must be unique across the Genesis installation
scope String Y Template scope. May be one of following:
  • system For system scope
  • project For project scope
  • environments For the environment configuration scope
name String Y Databag template name for the better UI recognition
databag-name String N Default name for the newly created databag
default-tags List of strings N Default set of tags for the newly created databags
properties Map of property definitions N Property definition for newly created databag (see below)

Property Definition Format

Predefined properties are the map where key is databag variable name, and value is a structure with the following fields:

Field Type Mandatory Description
default String Y Default value for a property. UI use it to codepopulate new variable value
required Boolean N If set to true, databag must include that key on creation and on update.
validation Map of validation rules N Validation rules for the property. Format is {"message":"rule"} Following rules are supported currently:
  • required - Property must have a value
  • int_nonnegative - Property must be a string recodesenting an integer starting from 0 to a Integer.MAX_VALUE
  • int_positive - Property must be a string recodesenting an integer starting from 1 to a Integer.MAX_VALUE
  • port - Property must be a string recodesenting an integer starting from 1 to a 32767
  • boolean - Property must have value 'true' or 'false'
  • email - Property must have valid email format
  • host - Property must have valid hostname format
  • url - Property must have valid url format

Databag template example

{
  "id": "1-system",
  "name": "System level template",
  "scope": "system",
  "default-tags": ["foo", "bar"],
  "databag-name": "tdb",
  "properties": {
    "validated": {"description": "This is a long key", "default": 1234,  "validation": {"Must be integer value >= 0": "int_nonnegative"}},
    "required": {"description": "This is an other key", "default": "aaa", "required": true}
  }
}

REST API

List scopes

Path: /rest/dbtempates
Type: GET

Example response:

{
   "links" : [
      {
         "rel" : "self",
         "href" : "http://localhost:8081/rest/dbtemplates",
         "methods" : [
            "get"
         ],
         "type" : "application/vnd.griddynamics.genesis.DatabagTemplate+json"
      }
   ],
   "items" : [
      {
         "rel" : "collection",
         "href" : "http://localhost:8081/rest/dbtemplates/environment",
         "methods" : [
            "get"
         ],
         "type" : "application/vnd.griddynamics.genesis.DatabagTemplate+json"
      },
      {
         "rel" : "collection",
         "href" : "http://localhost:8081/rest/dbtemplates/project",
         "methods" : [
            "get"
         ],
         "type" : "application/vnd.griddynamics.genesis.DatabagTemplate+json"
      },
      {
         "rel" : "collection",
         "href" : "http://localhost:8081/rest/dbtemplates/system",
         "methods" : [
            "get"
         ],
         "type" : "application/vnd.griddynamics.genesis.DatabagTemplate+json"
      }
   ]
}

List databag templates in scope

Path: /rest/dbtemplates/(scope)
Type: GET Path variables

Variable Mandatory Description
scope Y Template scope

Example response:

{
   "items" : [
      {
         "defaultName" : "email",
         "name" : "System wide email settings",
         "id" : "system-email",
         "links" : [],
         "properties" : [
            {
               "required" : false,
               "value" : "",
               "name" : "genesisUrl"
            }
         ],
         "tags" : [
            ""
         ],
         "scope" : "system"
      }
     ],
    "links" : [
      {
         "rel" : "self",
         "href" : "http://localhost:8081/rest/dbtemplates/system",
         "methods" : [
            "get"
         ],
         "type" : "application/vnd.griddynamics.genesis.DatabagTemplate+json"
      }
   ]
}

Read databag template

Path: /rest/dbtemplates/(scope)/(templateId)
Type: GET Path variables

Variable Mandatory Description
scope Y Template scope
templateId Y Template id

Example response

{
   "defaultName" : "email",
   "name" : "System wide email settings",
   "id" : "system-email",
   "links" : [
      {
         "rel" : "self",
         "href" : "http://localhost:8081/rest/dbtemplates/system/system-email",
         "methods" : [
            "get"
         ],
         "type" : "application/vnd.griddynamics.genesis.DatabagTemplate+json"
      }
   ],
   "properties" : [
      {
         "required" : false,
         "value" : "",
         "name" : "genesisUrl"
      }
   ],
   "tags" : [
      ""
   ],
   "scope" : "system"
}
Clone this wiki locally