Roles

View as Markdown

Roles

A role is a collection of permissions that will be applicable to all the users who are assigned this role.

create

The create method adds a new role in your stack.

NameTypeDescription
data (required)Dict

Data required to create a new role

data = {
	"role": {
		"name": "testRole",
		"description": "This is a test role.",
		"rules": [
			{
				"module": "branch_alias",
				"branch_aliases": [
					"deploy"
				],
				"acl": {
					"read": true
				}
			},
			{
				"module": "content_type",
				"content_types": [
					"$all"
				],
				"acl": {
					"read": true,
					"sub_acl": {
						"read": true
					}
				}
			},
			{
				"module": "asset",
				"assets": [
					"$all"
				],
				"acl": {
					"read": true,
					"update": true,
					"publish": true,
					"delete": true
				}
			},
			{
				"module": "environment",
				"environments": [
					"$all"
				],
				"acl": {
					"read": true
				}
			},
			{
				"module": "taxonomy",
				"taxonomies": [
					"taxonomy_UID"
				],
				"terms": [
					"taxonomy_UID.term_UID"
				],
				"content_types": [
					{
						"uid": "$all",
						"acl": {}
					}
				]
			}
		]
	}
}
import contentstack_management 
client = contentstack_management.Client(authtoken='authtoken')
response = client.stack('api_key').roles().create(data).json()

delete

The delete method removes an existing role from a particular stack of your organization.

NameTypeDescription
role_uid (required)str

UID of the role

import contentstack_management 
client = contentstack_management.Client(authtoken='authtoken')
response = response = client.stack('api_key').roles('role_uid').delete().json()

fetch

The fetch method retrieves the details of a specific role from the stack.

NameTypeDescription
role_uid (required)str

UID of the role

import contentstack_management 
client = contentstack_management.Client(authtoken='authtoken')
response = client.stack('api_key').roles('role_uid').fetch().json()

find

The find method retrieves the details of all the environments in a particular stack.

import contentstack_management
client = contentstack_management.Client(authtoken='authtoken')
response = client.stack("api_key").roles().find().json()

update

The update method allows you to make changes in the existing role of your stack.

NameTypeDescription
data (required)Dict

The updated information for the role

data = {

       "role":{

           "name":"sampleRole",

           "description":"This is a test role.",

           "rules":[

           {

               "module":"branch",

               "branches":[

               "main"

               ],

               "acl":{

               "read":true

               }

           },

           {

               "module":"branch_alias",

               "branch_aliases":[

               "deploy"

               ],

               "acl":{

               "read":true

               }

           },

           {

               "module":"content_type",

               "content_types":[

               "$all"

               ],

               "acl":{

               "read":true,

               "sub_acl":{

                   "read":true

               }

               }

           },

           {

               "module":"asset",

               "assets":[

               "$all"

               ],

               "acl":{

               "read":true,

               "update":true,

               "publish":true,

               "delete":true

               }

           },

           {

               "module":"folder",

               "folders":[

               "$all"

               ],

               "acl":{

               "read":true,

               "update":true,

               "publish":true,

               "delete":true,

               "sub_acl":{

                   "read":true,

                   "update":true,

                   "publish":true,

                   "delete":true

               }

               }

           },

           {

               "module":"environment",

               "environments":[

               "$all"

               ],

               "acl":{

               "read":true

               }

           },

           {

               "module":"locale",

               "locales":[

               "$all"

               ],

               "acl":{

               "read":true

               }

           }

           ],

           "uid":"blt5a570885da41c710"

       }

       }

import contentstack_management 

client = contentstack_management.client(authtoken='your_authtoken')

response = client.stack('api_key').roles("role_uid").update(data).json()