Cluster roles API

The /cluster-roles API endpoint

/cluster-roles (GET)

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

EXAMPLE

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

curl -s http://127.0.0.1:8080/api/core/v2/cluster-roles -H "Authorization: Bearer TOKEN"
[
  {
    "name": "global-event-reader",
    "rules": [
      {
        "verbs": [
          "get",
          "list"
        ],
        "resources": [
          "events"
        ],
        "resourceNames": [
          ""
        ]
      }
    ]
  }
]

API Specification

/cluster-roles (GET)
description Returns the list of cluster roles.
example url http://hostname:8080/api/core/v2/cluster-roles
response type Array
response codes
  • Success: 200 (OK)
  • Error: 500 (Internal Server Error)
output
[
  {
    "name": "global-event-reader",
    "rules": [
      {
        "verbs": [
          "get",
          "list"
        ],
        "resources": [
          "events"
        ],
        "resourceNames": [
          ""
        ]
      }
    ]
  }
]

/cluster-roles (POST)

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

The /cluster-roles/:cluster-role API endpoint

/cluster-roles/:cluster-role (GET)

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

EXAMPLE

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

curl -s http://127.0.0.1:8080/api/core/v2/cluster-roles/global-event-reader -H "Authorization: Bearer TOKEN"
{
  "name": "global-event-reader",
  "rules": [
    {
      "verbs": [
        "get",
        "list"
      ],
      "resources": [
        "events"
      ],
      "resourceNames": [
        ""
      ]
    }
  ]
}

API Specification

/cluster-roles/:cluster-role (GET)
description Returns a cluster role.
example url http://hostname:8080/api/core/v2/cluster-roles/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"
      ],
      "resourceNames": [
        ""
      ]
    }
  ]
}

/cluster-roles/:cluster-role (PUT)

API Specification

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

/cluster-roles/:cluster-role (DELETE)

API Specification

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