Role
Role
A role is a collection of permissions that will be applicable to all the users who are assigned this role.
create
The create role method adds a new role to your stack.
| Name | Type | Description |
|---|---|---|
| requestBody (required) | JSONObject | The body should be of a JSONObject type |
Example:
import contentstack;
Contentstack contentstack = new Contentstack.Builder().build();
Roles roles = contentstack.stack().roles();
Call<ResponseBody> response = roles.create(requestBody).execute();
if (response.isSuccessful()) {
System.out.println(response.body().string());
} else {
System.out.println(response.errorBody().string());
}addHeader
Sets header for the request.
| Name | Type | Description |
|---|---|---|
| key (required) | String | Header key for the request. |
| value (required) | Object | Header value for the request. |
import contentstack;
Contentstack contentstack = new Contentstack.Builder().build();
Roles roles = contentstack.stack().roles();
roles.addHeader("key", value);addParam
Sets header for the request.
| Name | Type | Description |
|---|---|---|
| key (required) | String | Query parameter key for the request. |
| value (required) | Object | Query parameter value for the request. |
import contentstack;
Contentstack contentstack = new Contentstack.Builder().build();
Roles roles = contentstack.stack().roles();
roles.addParam("key", value);delete
The "Delete role" call deletes an existing role from your stack.
import contentstack;
Contentstack contentstack = new Contentstack.Builder().build();
Roles roles = contentstack.stack().roles();
Call<ResponseBody> response = roles.delete().execute();
if (response.isSuccessful) {
System.out.println("Response" + response);
}fetch
The "Get a single role" request returns comprehensive information on a specific role.
import contentstack;
Contentstack contentstack = new Contentstack.Builder().build();
Roles roles = contentstack.stack().roles();
Call<ResponseBody> response = roles.fetch().execute();
if (response.isSuccessful) {
System.out.println("Response" + response);
}find
The "Get all roles" request returns comprehensive information about all roles created in a stack.
You can add queries to extend the functionality of this API request.
import contentstack;
Contentstack contentstack = new Contentstack.Builder().build();
Roles roles = contentstack.stack().roles();
Call<ResponseBody> response = roles.find().execute();
if (response.isSuccessful) {
System.out.println("Response" + response);
}update
The "Update role" request lets you modify an existing role of your stack. However, the pre-existing system roles cannot be modified.
| Name | Type | Description |
|---|---|---|
| requestBody (required) | JSONObject | The body should be of a JSONObject type. |
import contentstack;
Contentstack contentstack = new Contentstack.Builder().build();
Roles roles = contentstack.stack().roles();
Call<ResponseBody> response = roles.update(requestBody).execute();
if (response.isSuccessful) {
System.out.println("Response" + response);
}removeParam
Set header for the request.
| Name | Type | Description |
|---|---|---|
| key (required) | String | Removes query parameters using the key of the request. |
import contentstack;
Contentstack contentstack = new Contentstack.Builder().build();
Roles roles = contentstack.stack().roles();
roles.removeParam("key");