Datastore API

Get all datastore providers

The /provider API endpoint provides HTTP GET access to Sensu datastore data.

Example

The following example demonstrates a request to the /provider API endpoint, resulting in a JSON map that contains a list of Sensu datastore providers.

curl -X GET \
http://127.0.0.1:8080/api/enterprise/store/v1/provider
-H "Authorization: Bearer $SENSU_ACCESS_TOKEN" \

HTTP/1.1 200 OK
[
  {
    "type": "PostgresConfig",
    "api_version": "store/v1",
    "metadata": {},
    "spec": {
      "dsn": "postgresql://user:secret@host:port/otherdbname",
      "pool_size": 20
    }
  },
  {
    "type": "PostgresConfig",
    "api_version": "store/v1",
    "metadata": {},
    "spec": {
      "dsn": "postgresql://user:secret@host:port/dbname",
      "pool_size": 20
    }
  }
]

API Specification

/provider (GET)
description Returns the list of datastore providers.
example url http://hostname:8080/api/enterprise/store/v1/provider
response type Map
response codes
  • Success: 200 (OK)
  • Error: 500 (Internal Server Error)
output
[
  {
    "type": "PostgresConfig",
    "api_version": "store/v1",
    "metadata": {},
    "spec": {
      "dsn": "postgresql://user:secret@host:port/otherdbname",
      "pool_size": 20
    }
  },
  {
    "type": "PostgresConfig",
    "api_version": "store/v1",
    "metadata": {},
    "spec": {
      "dsn": "postgresql://user:secret@host:port/dbname",
      "pool_size": 20
    }
  }
]

Get a specific datastore provider

The /provider/:provider API endpoint provides HTTP PUT access to retrieve a Sensu datastore provider.

Example

curl -X GET \
-H "Authorization: Bearer $SENSU_ACCESS_TOKEN" \
http://127.0.0.1:8080/api/enterprise/store/v1/provider/my-postgres

HTTP/1.1 200 OK
{
  "type": "PostgresConfig",
  "api_version": "store/v1",
  "metadata": {
    "name": "my-postgres"
  },
  "spec": {
    "dsn": "postgresql://user:secret@host:port/dbname",
    "pool_size": 20
  }
}

API Specification

/provider/:provider (GET)
description Returns the specified datastore provider.
example url http://hostname:8080/api/enterprise/store/v1/provider/my-postgres
url parameters Required: my-postgres (name of provider to retrieve).
response codes
  • Success: 200 (OK)
  • Missing: 404 (Not Found)
  • Error: 500 (Internal Server Error)
output
{
  "type": "PostgresConfig",
  "api_version": "store/v1",
  "metadata": {
    "name": "my-postgres"
  },
  "spec": {
    "dsn": "postgresql://user:secret@host:port/dbname",
    "pool_size": 20
  }
}

Create or update a datastore provider

The /provider/:provider API endpoint provides HTTP PUT access to create or update a Sensu datastore provider.

Example

curl -X PUT \
http://127.0.0.1:8080/api/enterprise/store/v1/provider/my-postgres \
-H "Authorization: Bearer $SENSU_ACCESS_TOKEN" \
-d '{
  "type": "PostgresConfig",
  "api_version": "store/v1",
  "metadata": {
    "name": "my-postgres"
  },
  "spec": {
    "dsn": "postgresql://user:secret@host:port/dbname",
    "pool_size": 20
  }
}'

HTTP/1.1 200 OK

API Specification

/provider/:provider (PUT)
description Creates a datastore provider.
example url http://hostname:8080/api/enterprise/store/v1/provider/my-postgres
url parameters Required: my-postgres (name to use for provider).
payload
{
  "type": "PostgresConfig",
  "api_version": "store/v1",
  "metadata": {
    "name": "my-postgres"
  },
  "spec": {
    "dsn": "postgresql://user:secret@host:port/dbname",
    "pool_size": 20
  }
}
response codes
  • Success: 200 (OK)
  • Missing: 404 (Not Found)
  • Error: 500 (Internal Server Error)

Delete a datastore provider

The /provider/:provider API endpoint provides HTTP DELETE access to remove a Sensu datastore provider.

Example

The following example shows a request to the /provider/:provider API endpoint to remove the Sensu datastore provider with the ID my-postgres, resulting in a successful HTTP 204 No Content response.

curl -X DELETE \
-H "Authorization: Bearer $SENSU_ACCESS_TOKEN" \
http://127.0.0.1:8080/api/enterprise/store/v1/provider/my-postgres

HTTP/1.1 204 No Content

API Specification

/provider/:provider (DELETE)
description Removes the specified datastore provider.
example url http://hostname:8080/api/enterprise/store/v1/provider/my-postgres
url parameters Required: my-postgres (name of provider to delete).
response codes
  • Success: 204 (No Content)
  • Missing: 404 (Not Found)
  • Error: 500 (Internal Server Error)