Skip to content

cagedtornado/centralconfig-webapi

Repository files navigation

centralconfig-webapi Build status

Easy centralized application configuration for .NET apps. This is an ASP.NET WebAPI and Entity Framework version of the centralconfig service. Suitable for IIS based deployments.

Quick start

API server information

API path Description
/ Redirects to the /UI path (and the web based user interface)
/config/get Gets a single configuration item
/config/set Sets (creates or updates) a configuration item
/config/remove Removes a configuration item
/config/getall Gets all configuration items
/config/getallforapp Get all configuration items for a single application (plus the default * application)
/applications/getall Get all applications

Requests

Most API operations expect a configitem object in the POST body that will be used to either filter (in a get operation), update or create (in a set operation), or remove an item (in a remove operation).

For example:

{
    "application" : "AccountingReports",
    "name": "ShowObscureFactoids",
    "value": "true"
}

Responses

All operations will return an object that contain the fields status, message, and data.

For Example:

{
  "status": 200,
  "message": "Config item found",
  "data": {
    "id": 6,
    "application": "AccountingReports",
    "machine": "",
    "name": "ShowFooterDates",
    "value": "true",
    "updated": "2016-08-11T14:49:38.1555535-04:00"
  }
}

/config/get

This operation retrieves a single configuration item. If it doesn't exist for the given application, it attemps to get it for the default application (*).

This is an HTTP POST request

Example request:
{
    "application" : "AccountingReports",
    "name" : "ShowFooterDates" 
}
Example response:
{
  "status": 200,
  "message": "Config item found",
  "data": {
    "id": 6,
    "application": "AccountingReports",
    "machine": "",
    "name": "ShowFooterDates",
    "value": "true",
    "updated": "2016-08-11T14:49:38.1555535-04:00"
  }
}

/config/set

This operation sets the value of a single configuration item

This is an HTTP POST request

Example request:
{
    "application" : "AccountingReports",
    "name" : "ShowHeaderValues",
    "value": "false"
}
Example response:
{
  "status": 200,
  "message": "Config item updated",
  "data": {
    "id": 10,
    "application": "AccountingReports",
    "machine": "",
    "name": "ShowHeaderValues",
    "value": "false",
    "updated": "2016-08-11T14:58:16.0132648-04:00"
  }
}

/config/remove

This operation removes a single configuration item

Example request:
{
    "application" : "AccountingReports",
    "name" : "ShowHeaderValues"
}
Example response:
{
  "status": 200,
  "message": "Config item removed",
  "data": {
    "id": 0,
    "application": "AccountingReports",
    "machine": "",
    "name": "ShowHeaderValues",
    "value": "",
    "updated": "0001-01-01T00:00:00Z"
  }
}

/config/getall

This operation retrieves all configuration items.

This is a GET request.

Example response:
{
  "status": 200,
  "message": "Config items found",
  "data": [
    {
      "id": 7,
      "application": "AccountingReports",
      "machine": "",
      "name": "Name",
      "value": "Accounting reporting system",
      "updated": "2016-08-11T14:50:17.3451641-04:00"
    },
    {
      "id": 6,
      "application": "AccountingReports",
      "machine": "",
      "name": "ShowFooterDates",
      "value": "true",
      "updated": "2016-08-11T14:49:38.1555535-04:00"
    },
    {
      "id": 8,
      "application": "ITSupportDesk",
      "machine": "",
      "name": "ShowEmailLinks",
      "value": "false",
      "updated": "2016-08-11T14:50:51.4152237-04:00"
    },
    {
      "id": 9,
      "application": "ITSupportDesk",
      "machine": "",
      "name": "SupportNumber",
      "value": "1 (415) 344-3200",
      "updated": "2016-08-11T14:52:53.4456194-04:00"
    }
  ]
}

/config/getallforapp

This operation retrieves all configuration items for a specified application

This is an HTTP POST operation

Example request:
{
    "application" : "AccountingReports"
}
Example response:
{
  "status": 200,
  "message": "Config items found",
  "data": [
    {
      "id": 7,
      "application": "AccountingReports",
      "machine": "",
      "name": "Name",
      "value": "Accounting reporting system",
      "updated": "2016-08-11T14:50:17.3451641-04:00"
    },
    {
      "id": 6,
      "application": "AccountingReports",
      "machine": "",
      "name": "ShowFooterDates",
      "value": "true",
      "updated": "2016-08-11T14:49:38.1555535-04:00"
    }
  ]
}

/applications/getall

This operation retrieves all applications

This is an HTTP GET operation.

Example response:
{
  "status": 200,
  "message": "Applications found",
  "data": [
    "AccountingReports",
    "AnotherApp",
    "DouglasAdams",
    "FormBuilder",
    "ITSupportDesk",
    "SomeOtherAppEntirely"
  ]
}