Teams
Teams
Teams streamline the process of assigning roles and permissions by grouping users together. Rather than assigning roles to individual users or at the stack level, you can assign roles directly to a team. This ensures that all users within a team share the same set of role permissions, making role management more efficient.
fetch
The fetch method retrieves details of a specific team.
| Name | Type | Description |
|---|---|---|
| includeUserDetails | boolean | If true, include detailed user information for team members; otherwise, include only user UIDs. |
import * as contentstack from '@contentstack/management'
const client = contentstack.client({ authtoken })
client.organization('organization_uid').teams('teamUid').fetch()
.then((team) => console.log(team)create
The create method creates a new team.
| Name | Type | Description |
|---|---|---|
| includeUserDetails | boolean | If true, include detailed user information for team members; otherwise, include only user UIDs. |
| team | object | Details required for team creation. |
import * as contentstack from '@contentstack/management'
const client = contentstack.client({ authtoken })
const team = {
name: 'name',
organizationUid: 'organization_uid',
users: [],
stackRoleMapping: [],
organizationRole: 'organizationRole'
}
client.organization('organizationUid').teams().create(team)
.then((response) => console.log(response))fetchAll
The fetchAll method retrieves the details of all teams.
| Name | Type | Description |
|---|---|---|
| includeUserDetails | boolean | If true, include detailed user information for team members; otherwise, include only user UIDs. |
| asc|desc | string | Sort in either ascending or descending order |
| typeahead | string | Used to match the given string in all teams name & return the matched result |
| skip | number | Skip the number of teams |
| limit | number | Limit the result to number of teams |
| user_uid | comma separated string | list of user UIDs to be filtered |
import * as contentstack from '@contentstack/management'
const client = contentstack.client({ authtoken })
client.organization('organizationUid').teams().fetchAll()
.then((teams) => console.log(teams))delete
The delete method deletes an existing team.
import * as contentstack from '@contentstack/management'
const client = contentstack.client({ authtoken })
client.organization('organization_uid').teams('teamUid').delete()
.then((response) => console.log(response)update
The update method involves adding and removing users from teams, assigning and removing stack roles within teams, updating team descriptions, and adjusting team organization roles.
| Name | Type | Description |
|---|---|---|
| includeUserDetails | boolean | If true, include detailed user information for team members; otherwise, include only user UIDs. |
import * as contentstack from '@contentstack/management'
const client = contentstack.client({ authtoken })
const updateData = {
name: 'updatedname',
users: [{
email: '[email protected]'
}],
organizationRole: 'blt09e5dfced326aaea',
stackRoleMapping: []
}
client.organization(s'organizationUid').teams('teamUid').update(updateData)
.then((response) => console.log(response))TeamUsers
The TeamUsers method retrieves the UIDs of the users.
import * as contentstack from '@contentstack/management'
const client = contentstack.client({ authtoken })
client.organization('organizationUid').teams('teamUid').teamUsers().fetchAll()
.then((response) => console.log(response))stackRoleMappings
The stackRoleMappings method retrieves the stack role mapping details.
import * as contentstack from '@contentstack/management'
const client = contentstack.client({ authtoken })
client.organization(s'organizationUid').teams('teamUid').stackRoleMappings().fetchAll()
.then((response) => console.log(response))