Role bindings API

The /role-bindings API endpoint

/role-bindings (GET)

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

EXAMPLE

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

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

API Specification

/role-bindings (GET)
description Returns the list of role bindings.
example url http://hostname:8080/api/core/v2/namespaces/default/role-bindings
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"
      }
    ]
  }
]

/role-bindings (POST)

/role-bindings (POST)
description Create a Sensu role binding.
example URL http://hostname:8080/api/core/v2/role-bindings/default/role-bindings
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 /role-bindings/:role-binding API endpoint

/role-bindings/:role-binding (GET)

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

EXAMPLE

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

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

API Specification

/role-bindings/:role-binding (GET)
description Returns a role binding.
example url http://hostname:8080/api/core/v2/namespaces/default/role-bindings/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"
    }
  ]
}

/role-bindings/:role-binding (PUT)

API Specification

/role-bindings/:role-binding (PUT)
description Create or update a Sensu role binding.
example URL http://hostname:8080/api/core/v2/namespaces/default/role-bindings/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)

/role-bindings/:role-binding (DELETE)

API Specification

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