GlobalParameters#

API for getting and deleting GlobalParameters.

Get all GlobalParameters#

  • URL: /api/globalparams
  • Method: GET

Success Response#

  • Code: 200 OK
  • Content:
    {
      "data": {
        "WNEDzeyC": {
          "id": "WNEDzeyC",
          "isGlobal": true,
          "label": "param_0",
          "props": {
            "defaultIndex": 0,
            "items": []
          },
          "type": "Selector",
          "index": 0,
          "access": "rw",
          "source": "API"
        },
        "CURRENT": {
          "id": "CURRENT",
          "label": "CURRENT",
          "props": {
            "defaultIndex": 1,
            "items": [
              "DATA",
              "DEMO Welcome",
              "DEMO Newsroom",
              "DEMO Traffic",
              "DEMO Webcams",
              "DEMO Button"
            ]
          },
          "type": "Selector",
          "index": 1,
          "val": "DEMO Welcome",
          "access": "rw",
          "isGlobal": true,
          "source": "hedgehog"
        }
      },
      "edition": "full",
      "ts": 1578589080698,
      "version": "v1.2.0"
    }
    

Sample Call#

curl --request GET \
  --url 'http://localhost:3000/api/globalparams'

Post new GlobalParameters#

  • URL: /api/globalparams
  • Method: POST
  • Body Props:
{
  "data": "<ARRAY OF PARAM_DATA>",
  "edition": "<EDITION>",
  "id": "<VIEW_ID>",
  "ts": "<TS>",
  "version": "<VERSION>"
}

Success Response#

  • Code: 200 OK
  • Content:
    {
      "data": [
        {
          "id": "NEW_GLOBAL_PARAM",
          "props": {
            "defaultVal": false
          },
          "type": "Boolean",
          "access": "rw",
          "label": "globalparam_1"
        }
      ],
      "edition": "full",
      "ts": 1578589377669,
      "version": "v1.2.0"
    }
    

Error Response example#

  • Condition: If provided data is invalid, e.g. parameter type is unknown.
  • Code: 400 BAD REQUEST
  • Content:
    {
      "errors": [
        {
          "keyword": "type",
          "dataPath": ".data",
          "schemaPath": "param.json#//type",
          "params": {
            "type": "object"
          },
          "message": "should be object",
          "schema": "object",
          "parentSchema": {
            "$id": "http://treetop.de/disco/schemas/param.json",
            "dependencies": {
              "type": {
                "oneOf": [
                  {
                    "properties": {
                      "type": {
                        "enum": ["Boolean"]
                      },
                      "props": {
                        "$id": "Boolean",
                        "properties": {
                          "defaultVal": {
                            "default": false,
                            "description": "Default value",
                            "title": "Default Value",
                            "type": "boolean"
                          }
                        },
                        "required": ["defaultVal"],
                        "title": "Boolean Parameter",
                        "type": "object"
                      }
                    }
                  },
                  {
                    "properties": {
                      "type": {
                        "enum": ["Number"]
                      },
                      "props": {
                        "$id": "Number",
                        "properties": {
                          "defaultVal": {
                            "default": 0,
                            "description": "Displayed default value",
                            "title": "Default Value",
                            "type": "number"
                          },
                          "maximum": {
                            "description": "Value must be multiple of",
                            "title": "Maximum",
                            "type": "number"
                          },
                          "minimum": {
                            "description": "Minimal value",
                            "title": "Minimum",
                            "type": "number"
                          },
                          "multipleOf": {
                            "description": "Multiple of",
                            "title": "MultipleOf",
                            "type": "number",
                            "minimum": 0
                          }
                        },
                        "required": ["defaultVal"],
                        "title": "Number Parameter",
                        "type": "object"
                      }
                    }
                  },
                  {
                    "properties": {
                      "type": {
                        "enum": ["Selector"]
                      },
                      "props": {
                        "$id": "Selector",
                        "properties": {
                          "defaultIndex": {
                            "default": 0,
                            "description": "default index",
                            "minimum": 0,
                            "title": "Default Index",
                            "type": "number"
                          },
                          "items": {
                            "default": [],
                            "description": "Selector items",
                            "items": {
                              "type": "string"
                            },
                            "title": "Items",
                            "type": "array"
                          }
                        },
                        "required": ["items"],
                        "title": "Selector Parameter",
                        "type": "object"
                      }
                    }
                  },
                  {
                    "properties": {
                      "type": {
                        "enum": ["String"]
                      },
                      "props": {
                        "$id": "String",
                        "properties": {
                          "defaultVal": {
                            "default": "NO STRING",
                            "description": "displayed default value",
                            "title": "Default Value",
                            "type": "string"
                          },
                          "options": {
                            "description": "List of valid strings",
                            "items": {
                              "type": "string"
                            },
                            "title": "Options",
                            "type": "array"
                          },
                          "pattern": {
                            "description": "Regex pattern for validation",
                            "title": "Pattern",
                            "type": "string"
                          }
                        },
                        "required": ["defaultVal"],
                        "title": "String Parameter",
                        "type": "object"
                      }
                    }
                  }
                ]
              }
            },
            "properties": {
              "access": {
                "default": "rw",
                "enum": ["r", "rw"],
                "type": "string"
              },
              "id": {
                "description": "Unique ID",
                "title": "ID",
                "type": "string"
              },
              "label": {
                "description": "Displayed label",
                "title": "Label",
                "type": "string"
              },
              "type": {
                "description": "Param type",
                "enum": ["Boolean", "Number", "Selector", "String"],
                "title": "Type",
                "type": "string"
              }
            },
            "required": ["id", "type"],
            "title": "Parameter",
            "type": "object"
          },
          "data": [
            {
              "id": "HANS_3",
              "props": {
                "defaultVal": false
              },
              "type": "None",
              "access": "rw"
            }
          ]
        },
        {
          "keyword": "enum",
          "dataPath": ".data[0].type",
          "schemaPath": "param.json#//dependencies/type/oneOf/0/properties/type/enum",
          "params": {
            "allowedValues": ["Boolean"]
          },
          "message": "should be equal to one of the allowed values",
          "schema": ["Boolean"],
          "parentSchema": {
            "enum": ["Boolean"]
          },
          "data": "None"
        },
        {
          "keyword": "enum",
          "dataPath": ".data[0].type",
          "schemaPath": "param.json#//dependencies/type/oneOf/1/properties/type/enum",
          "params": {
            "allowedValues": ["Number"]
          },
          "message": "should be equal to one of the allowed values",
          "schema": ["Number"],
          "parentSchema": {
            "enum": ["Number"]
          },
          "data": "None"
        },
        {
          "keyword": "enum",
          "dataPath": ".data[0].type",
          "schemaPath": "param.json#//dependencies/type/oneOf/2/properties/type/enum",
          "params": {
            "allowedValues": ["Selector"]
          },
          "message": "should be equal to one of the allowed values",
          "schema": ["Selector"],
          "parentSchema": {
            "enum": ["Selector"]
          },
          "data": "None"
        },
        {
          "keyword": "enum",
          "dataPath": ".data[0].type",
          "schemaPath": "param.json#//dependencies/type/oneOf/3/properties/type/enum",
          "params": {
            "allowedValues": ["String"]
          },
          "message": "should be equal to one of the allowed values",
          "schema": ["String"],
          "parentSchema": {
            "enum": ["String"]
          },
          "data": "None"
        },
        {
          "keyword": "oneOf",
          "dataPath": ".data[0]",
          "schemaPath": "param.json#//dependencies/type/oneOf",
          "params": {
            "passingSchemas": null
          },
          "message": "should match exactly one schema in oneOf",
          "schema": [
            {
              "properties": {
                "type": {
                  "enum": ["Boolean"]
                },
                "props": {
                  "$id": "Boolean",
                  "properties": {
                    "defaultVal": {
                      "default": false,
                      "description": "Default value",
                      "title": "Default Value",
                      "type": "boolean"
                    }
                  },
                  "required": ["defaultVal"],
                  "title": "Boolean Parameter",
                  "type": "object"
                }
              }
            },
            {
              "properties": {
                "type": {
                  "enum": ["Number"]
                },
                "props": {
                  "$id": "Number",
                  "properties": {
                    "defaultVal": {
                      "default": 0,
                      "description": "Displayed default value",
                      "title": "Default Value",
                      "type": "number"
                    },
                    "maximum": {
                      "description": "Value must be multiple of",
                      "title": "Maximum",
                      "type": "number"
                    },
                    "minimum": {
                      "description": "Minimal value",
                      "title": "Minimum",
                      "type": "number"
                    },
                    "multipleOf": {
                      "description": "Multiple of",
                      "title": "MultipleOf",
                      "type": "number",
                      "minimum": 0
                    }
                  },
                  "required": ["defaultVal"],
                  "title": "Number Parameter",
                  "type": "object"
                }
              }
            },
            {
              "properties": {
                "type": {
                  "enum": ["Selector"]
                },
                "props": {
                  "$id": "Selector",
                  "properties": {
                    "defaultIndex": {
                      "default": 0,
                      "description": "default index",
                      "minimum": 0,
                      "title": "Default Index",
                      "type": "number"
                    },
                    "items": {
                      "default": [],
                      "description": "Selector items",
                      "items": {
                        "type": "string"
                      },
                      "title": "Items",
                      "type": "array"
                    }
                  },
                  "required": ["items"],
                  "title": "Selector Parameter",
                  "type": "object"
                }
              }
            },
            {
              "properties": {
                "type": {
                  "enum": ["String"]
                },
                "props": {
                  "$id": "String",
                  "properties": {
                    "defaultVal": {
                      "default": "NO STRING",
                      "description": "displayed default value",
                      "title": "Default Value",
                      "type": "string"
                    },
                    "options": {
                      "description": "List of valid strings",
                      "items": {
                        "type": "string"
                      },
                      "title": "Options",
                      "type": "array"
                    },
                    "pattern": {
                      "description": "Regex pattern for validation",
                      "title": "Pattern",
                      "type": "string"
                    }
                  },
                  "required": ["defaultVal"],
                  "title": "String Parameter",
                  "type": "object"
                }
              }
            }
          ],
          "parentSchema": {
            "oneOf": [
              {
                "properties": {
                  "type": {
                    "enum": ["Boolean"]
                  },
                  "props": {
                    "$id": "Boolean",
                    "properties": {
                      "defaultVal": {
                        "default": false,
                        "description": "Default value",
                        "title": "Default Value",
                        "type": "boolean"
                      }
                    },
                    "required": ["defaultVal"],
                    "title": "Boolean Parameter",
                    "type": "object"
                  }
                }
              },
              {
                "properties": {
                  "type": {
                    "enum": ["Number"]
                  },
                  "props": {
                    "$id": "Number",
                    "properties": {
                      "defaultVal": {
                        "default": 0,
                        "description": "Displayed default value",
                        "title": "Default Value",
                        "type": "number"
                      },
                      "maximum": {
                        "description": "Value must be multiple of",
                        "title": "Maximum",
                        "type": "number"
                      },
                      "minimum": {
                        "description": "Minimal value",
                        "title": "Minimum",
                        "type": "number"
                      },
                      "multipleOf": {
                        "description": "Multiple of",
                        "title": "MultipleOf",
                        "type": "number",
                        "minimum": 0
                      }
                    },
                    "required": ["defaultVal"],
                    "title": "Number Parameter",
                    "type": "object"
                  }
                }
              },
              {
                "properties": {
                  "type": {
                    "enum": ["Selector"]
                  },
                  "props": {
                    "$id": "Selector",
                    "properties": {
                      "defaultIndex": {
                        "default": 0,
                        "description": "default index",
                        "minimum": 0,
                        "title": "Default Index",
                        "type": "number"
                      },
                      "items": {
                        "default": [],
                        "description": "Selector items",
                        "items": {
                          "type": "string"
                        },
                        "title": "Items",
                        "type": "array"
                      }
                    },
                    "required": ["items"],
                    "title": "Selector Parameter",
                    "type": "object"
                  }
                }
              },
              {
                "properties": {
                  "type": {
                    "enum": ["String"]
                  },
                  "props": {
                    "$id": "String",
                    "properties": {
                      "defaultVal": {
                        "default": "NO STRING",
                        "description": "displayed default value",
                        "title": "Default Value",
                        "type": "string"
                      },
                      "options": {
                        "description": "List of valid strings",
                        "items": {
                          "type": "string"
                        },
                        "title": "Options",
                        "type": "array"
                      },
                      "pattern": {
                        "description": "Regex pattern for validation",
                        "title": "Pattern",
                        "type": "string"
                      }
                    },
                    "required": ["defaultVal"],
                    "title": "String Parameter",
                    "type": "object"
                  }
                }
              }
            ]
          },
          "data": {
            "id": "HANS_3",
            "props": {
              "defaultVal": false
            },
            "type": "None",
            "access": "rw"
          }
        },
        {
          "keyword": "oneOf",
          "dataPath": ".data",
          "schemaPath": "#/properties/data/oneOf",
          "params": {
            "passingSchemas": null
          },
          "message": "should match exactly one schema in oneOf",
          "schema": [
            {
              "$ref": "param.json#/"
            },
            {
              "items": {
                "$ref": "param.json#/"
              },
              "type": "array"
            }
          ],
          "parentSchema": {
            "oneOf": [
              {
                "$ref": "param.json#/"
              },
              {
                "items": {
                  "$ref": "param.json#/"
                },
                "type": "array"
              }
            ]
          },
          "data": [
            {
              "id": "HANS_3",
              "props": {
                "defaultVal": false
              },
              "type": "None",
              "access": "rw"
            }
          ]
        }
      ],
      "edition": "full",
      "ts": 1578589841120,
      "version": "v1.2.0"
    }
    

Sample Call#

curl --request POST \
  --url http://localhost:3000/api/globalparams \
  --header 'content-type: application/json' \
  --data '{
  "data": [
        {
            "id": "NEW_GLOBAL_PARAM",
      "props": {
        "defaultVal": false
      },
      "type": "Boolean",
      "access": "rw"
    }
    ],
  "edition": "full",
  "ts": 1560412080510,
  "version": "v1.2.0"
}'

Delete GlobalParameter by ID#

  • URL: /api/globalparams/:id
  • Method: DELETE

Success Response#

  • Code: 200 OK
  • Content:
    {
      "id": "gMdQhlit",
      "edition": "full",
      "ts": 1581417696147,
      "version": "v1.2.0"
    }
    

Error Response example#

  • Condition: If provided data is invalid, e.g. id does not exist.
  • Code: 400 BAD REQUEST
  • Content:
    {
      "errors": ["Cannot delete Global parameter with id UNKNOWN"],
      "edition": "full",
      "ts": 1567752680051,
      "version": "v1.2.0"
    }
    

Sample Call#

curl --request DELETE \
  --url http://localhost:3000/api/globalparams/CURRENT

Get GlobalParameter by ID#

  • URL: /api/globalparams/:id
  • Method: GET

Success Response#

  • Code: 200 OK
  • Content:
    {
      "data": {
        "id": "CURRENT",
        "label": "CURRENT",
        "props": {
          "defaultIndex": 1,
          "items": [
            "DATA",
            "DEMO Welcome",
            "DEMO Newsroom",
            "DEMO Traffic",
            "DEMO Webcams",
            "DEMO Button"
          ]
        },
        "type": "Selector",
        "index": 1,
        "val": "DEMO Welcome",
        "access": "rw",
        "isGlobal": true,
        "source": "hedgehog"
      },
      "edition": "full",
      "ts": 1579171224264,
      "version": "v1.2.0"
    }
    

Error Response example#

  • Condition: If provided data is invalid, e.g. id does not exist.
  • Code: 404 NOT FOUND
  • Content:
    {
      "errors": ["GlobalParameter with id UNKNOWN not found"],
      "edition": "full",
      "ts": 1579171275688,
      "version": "v1.2.0"
    }
    

Sample Call#

curl --request GET \
  --url http://localhost:3000/api/globalparams/CURRENT

Last update: March 4, 2020