Role bindings API

The /rolebindings API endpoint

/rolebindings (GET)

The /rolebindings API endpoint provides HTTP GET access to role binding data.

EXAMPLE

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

curl http://127.0.0.1:8080/api/core/v2/namespaces/default/rolebindings -H "Authorization: Bearer TOKEN"

HTTP/1.1 200 OK
[
  {
    "name": "alice-binder",
    "namespace": "default",
    "roleRef": {
      "type": "Role",
      "name": "event-reader"
    },
    "subjects": [
      {
        "type": "User",
        "name": "alice"
      }
    ]
  }
]

API Specification

/rolebindings (GET)
description Returns the list of role bindings.
example url http://hostname:8080/api/core/v2/namespaces/default/rolebindings
response type Array
response codes
  • Success: 200 (OK)
  • Error: 500 (Internal Server Error)
output
[
  {
    "name": "alice-binder",
    "namespace": "default",
    "roleRef": {
      "type": "Role",
      "name": "event-reader"
    },
    "subjects": [
      {
        "type": "User",
        "name": "alice"
      }
    ]
  }
]

/rolebindings (POST)

/rolebindings (POST)
description Create a Sensu role binding.
example URL http://hostname:8080/api/core/v2/namespaces/default/rolebindings
payload
{
  "name": "alice-binder",
  "namespace": "default",
  "roleRef": {
    "type": "Role",
    "name": "event-reader"
  },
  "subjects": [
    {
      "type": "User",
      "name": "alice"
    }
  ]
}
response codes
  • Success: 200 (OK)
  • Malformed: 400 (Bad Request)
  • Error: 500 (Internal Server Error)

The /rolebindings/:rolebinding API endpoint

/rolebindings/:rolebinding (GET)

The /rolebindings/:rolebinding API endpoint provides HTTP GET access to role binding data for specific :rolebinding definitions, by role binding name.

EXAMPLE

In the following example, querying the /rolebindings/:rolebinding API returns a JSON Map containing the requested :rolebinding definition (in this example: for the :rolebinding named alice).

curl -s http://127.0.0.1:8080/api/core/v2/namespaces/default/rolebindings/alice -H "Authorization: Bearer TOKEN"
{
  "name": "alice-binder",
  "namespace": "default",
  "roleRef": {
    "type": "Role",
    "name": "event-reader"
  },
  "subjects": [
    {
      "type": "User",
      "name": "alice"
    }
  ]
}

API Specification

/rolebindings/:rolebinding (GET)
description Returns a role binding.
example url http://hostname:8080/api/core/v2/namespaces/default/rolebindings/alice
response type Map
response codes
  • Success: 200 (OK)
  • Missing: 404 (Not Found)
  • Error: 500 (Internal Server Error)
output
{
  "name": "alice-binder",
  "namespace": "default",
  "roleRef": {
    "type": "Role",
    "name": "event-reader"
  },
  "subjects": [
    {
      "type": "User",
      "name": "alice"
    }
  ]
}

/rolebindings/:rolebinding (PUT)

API Specification

/rolebindings/:rolebinding (PUT)
description Create or update a Sensu role binding.
example URL http://hostname:8080/api/core/v2/namespaces/default/rolebindings/alice-binder
payload
{
  "name": "alice-binder",
  "namespace": "default",
  "roleRef": {
    "type": "Role",
    "name": "event-reader"
  },
  "subjects": [
    {
      "type": "User",
      "name": "alice"
    }
  ]
}
response codes
  • Success: 201 (Created)
  • Malformed: 400 (Bad Request)
  • Error: 500 (Internal Server Error)

/rolebindings/:rolebinding (DELETE)

API Specification

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