Replacing a Specified Role

Function

This API is used to replace a specified Role.

URL

PUT /apis/rbac.authorization.k8s.io/v1/namespaces/{namespace}/roles/{name}

Table 1 describes the parameters of this API.

Table 1 Parameter description

Parameter

Mandatory

Description

name

Yes

Name of the Role.

namespace

Yes

Object name and auth scope, such as for teams and projects.

pretty

No

If 'true', then the output is pretty printed.

body

Yes

-

Request

Request parameters:

For the description about request parameters, see Table 2.

For the description about the Content-Type field, see Patch Request Method Operation Description.

Example request:

{
	"metadata": {
		"name": "pod-reader",
		"namespace": "default",
		"selfLink": "/apis/rbac.authorization.k8s.io/v1/namespaces/default/roles/secret-reader",
		"uid": "6320bedb-f220-11e8-b449-fa163ec24e06",
		"resourceVersion": "56532",
		"creationTimestamp": "2018-11-27T08:42:35Z"
	},
	"rules": [{
		"verbs": ["get","watch"],
		"apiGroups": [""],
		"resources": ["pods"]
	}]
}

Response

Response parameters:

For the description about response parameters, see Table 2.

Example response:

{
	"kind": "Role",
	"apiVersion": "rbac.authorization.k8s.io/v1",
	"metadata": {
		"name": "pod-reader",
		"namespace": "default",
		"selfLink": "/apis/rbac.authorization.k8s.io/v1/namespaces/default/roles/secret-reader",
		"uid": "6320bedb-f220-11e8-b449-fa163ec24e06",
		"resourceVersion": "56532",
		"creationTimestamp": "2018-11-27T08:42:35Z"
	},
	"rules": [{
		"verbs": ["get","watch"],
		"apiGroups": [""],
		"resources": ["pods"]
	}]
}

Status Code

Table 2 describes the status codes of this API.

Table 2 Status codes

Status Code

Description

200

OK

201

Created