Cluster roles API

The /clusterroles API endpoint

/clusterroles (GET)

The /clusterroles API endpoint provides HTTP GET access to cluster role data.

EXAMPLE

The following example demonstrates a request to the /clusterroles API, resulting in a JSON Array containing cluster role definitions.

curl http://127.0.0.1:8080/api/core/v2/clusterroles -H "Authorization: Bearer $SENSU_TOKEN"

HTTP/1.1 200 OK
[
  {
    "rules": [
      {
        "verbs": [
          "*"
        ],
        "resources": [
          "assets",
          "checks",
          "entities",
          "extensions",
          "events",
          "filters",
          "handlers",
          "hooks",
          "mutators",
          "silenced",
          "roles",
          "rolebindings"
        ],
        "resource_names": null
      },
      {
        "verbs": [
          "get",
          "list"
        ],
        "resources": [
          "namespaces"
        ],
        "resource_names": null
      }
    ],
    "metadata": {
      "name": "admin"
    }
  },
  {
    "rules": [
      {
        "verbs": [
          "*"
        ],
        "resources": [
          "*"
        ],
        "resource_names": null
      }
    ],
    "metadata": {
      "name": "cluster-admin"
    }
  }
]

API Specification

/clusterroles (GET)
description Returns the list of cluster roles.
example url http://hostname:8080/api/core/v2/clusterroles
response type Array
response codes
  • Success: 200 (OK)
  • Error: 500 (Internal Server Error)
output
[
  {
    "rules": [
      {
        "verbs": [
          "*"
        ],
        "resources": [
          "*"
        ],
        "resource_names": null
      }
    ],
    "metadata": {
      "name": "cluster-admin"
    }
  }
]

/clusterroles (POST)

/clusterroles (POST)
description Create a Sensu cluster role.
example URL http://hostname:8080/api/core/v2/clusterroles
payload
{
  "metadata": {
    "name": "global-event-reader"
  },
  "rules": [
    {
      "verbs": [
        "get",
        "list"
      ],
      "resources": [
        "events"
      ],
      "resource_names": null
    }
  ]
}
response codes
  • Success: 200 (OK)
  • Malformed: 400 (Bad Request)
  • Error: 500 (Internal Server Error)

The /clusterroles/:clusterrole API endpoint

/clusterroles/:clusterrole (GET)

The /clusterroles/:clusterrole API endpoint provides HTTP GET access to cluster role data for specific :clusterrole definitions, by cluster role name.

EXAMPLE

In the following example, querying the /clusterroles/:clusterrole API returns a JSON Map containing the requested :clusterrole definition (in this example: for the :clusterrole named global-event-reader).

curl http://127.0.0.1:8080/api/core/v2/clusterroles/global-event-reader -H "Authorization: Bearer $SENSU_TOKEN"

HTTP/1.1 200 OK
{
  "metadata": {
    "name": "global-event-reader"
  },
  "rules": [
    {
      "verbs": [
        "get",
        "list"
      ],
      "resources": [
        "events"
      ],
      "resource_names": null
    }
  ]
}

API Specification

/clusterroles/:clusterrole (GET)
description Returns a cluster role.
example url http://hostname:8080/api/core/v2/clusterroles/global-event-reader
response type Map
response codes
  • Success: 200 (OK)
  • Missing: 404 (Not Found)
  • Error: 500 (Internal Server Error)
output
{
  "metadata": {
    "name": "global-event-reader"
  },
  "rules": [
    {
      "verbs": [
        "get",
        "list"
      ],
      "resources": [
        "events"
      ],
      "resource_names": null
    }
  ]
}

/clusterroles/:clusterrole (PUT)

API Specification

/clusterroles/:clusterrole (PUT)
description Create or update a Sensu cluster role.
example URL http://hostname:8080/api/core/v2/clusterroles/global-event-reader
payload
{
  "metadata": {
    "name": "global-event-reader"
  },
  "rules": [
    {
      "verbs": [
        "get",
        "list"
      ],
      "resources": [
        "events"
      ],
      "resource_names": null
    }
  ]
}
response codes
  • Success: 201 (Created)
  • Malformed: 400 (Bad Request)
  • Error: 500 (Internal Server Error)

/clusterroles/:clusterrole (DELETE)

The /clusterroles/:clusterrole API endpoint provides HTTP DELETE access to delete a cluster role from Sensu given the cluster role name.

EXAMPLE

The following example shows a request to delete the cluster role global-event-reader, resulting in a successful HTTP 204 No Content response.

curl -X DELETE \
-H "Authorization: Bearer $SENSU_TOKEN" \
http://127.0.0.1:8080/api/core/v2/clusterroles/global-event-reader

HTTP/1.1 204 No Content

API Specification

/clusterroles/:clusterrole (DELETE)
description Removes a cluster role from Sensu given the cluster role name.
example url http://hostname:8080/api/core/v2/clusterroles/global-event-reader
response codes
  • Success: 202 (Accepted)
  • Missing: 404 (Not Found)
  • Error: 500 (Internal Server Error)