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 -s http://127.0.0.1:8080/api/core/v2/clusterroles -H "Authorization: Bearer TOKEN"
[
  {
    "name": "global-event-reader",
    "rules": [
      {
        "verbs": [
          "get",
          "list"
        ],
        "resources": [
          "events"
        ],
        "resource_names": [
          ""
        ]
      }
    ]
  }
]

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
[
  {
    "name": "global-event-reader",
    "rules": [
      {
        "verbs": [
          "get",
          "list"
        ],
        "resources": [
          "events"
        ],
        "resource_names": [
          ""
        ]
      }
    ]
  }
]

/clusterroles (POST)

/clusterroles (POST)
description Create a Sensu cluster role.
example URL http://hostname:8080/api/core/v2/clusterroles
payload
{
  "name": "global-event-reader",
  "rules": [
    {
      "verbs": [
        "get",
        "list"
      ],
      "resources": [
        "events"
      ],
      "resource_names": [
        ""
      ]
    }
  ]
}
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 -s http://127.0.0.1:8080/api/core/v2/clusterroles/global-event-reader -H "Authorization: Bearer TOKEN"
{
  "name": "global-event-reader",
  "rules": [
    {
      "verbs": [
        "get",
        "list"
      ],
      "resources": [
        "events"
      ],
      "resource_names": [
        ""
      ]
    }
  ]
}

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
{
  "name": "global-event-reader",
  "rules": [
    {
      "verbs": [
        "get",
        "list"
      ],
      "resources": [
        "events"
      ],
      "resource_names": [
        ""
      ]
    }
  ]
}

/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
{
  "name": "global-event-reader",
  "rules": [
    {
      "verbs": [
        "get",
        "list"
      ],
      "resources": [
        "events"
      ],
      "resource_names": [
        ""
      ]
    }
  ]
}
response codes
  • Success: 201 (Created)
  • Malformed: 400 (Bad Request)
  • Error: 500 (Internal Server Error)

/clusterroles/:clusterrole (DELETE)

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)