Team management can be done using REST API.
API reference: Swagger UI
Authentication requires the token of a corporate admin:
Use the following request template to create teams
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/vnd.api+json' --header 'Authorization: <Auth_Token>' -d '{"team": {"name": "<TEAM_NAME>", "roles": ["admin"]}}' 'https://<NAO_CLOUD>/api/v2/teams'
The following request creates the team “Test Team”
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/vnd.api+json' --header 'Authorization: e1XYDn4fAY2Gs2VgMbqVgNv4-HxU9A' -d '{ \
"team": {"name": "Test Team", "roles": ["admin"]} \
}' 'https://www.nao-cloud.com/api/v2/teams'
Response:
{
"data": {
"id": "392",
"type": "team",
"attributes": {
"id": 392,
"name": "Test Team",
"user_id": 4840,
"roles_mask": 1,
"roles": [
"admin"
],
"ldap_group": null
},
"relationships": {
"users": {
"data": [
{
"id": "4840",
"type": "user"
}
]
},
"sites": {
"data": []
}
}
},
"links": {
"self": "https://www.nao-cloud.com/api/v2/teams"
}
}
The response of the request contains the ID of the created team. The ID of the teams is required to add site and user to the teams. The IDs are also displayed in the Corporate Account page:
Use the following request template to add sites to teams
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/vnd.api+json' --header 'Authorization: <Auth_Token>' -d '{"site_team_association": {"site_id": <SITE_ID>}' 'https://<NAO_CLOUD>/api/v2/teams/<TEAM_ID>/site_team_associations'
The following request add site “Test Site 1“ to team “Test Team”
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: e1XYDn4fAY2Gs2VgMbqVgNv4-HxU9A' -d '{ \
"site_team_association": { \
"site_id": "11416"} \
}' 'https://www.nao-cloud.com/api/v2/teams/392/site_team_associations'
The response:
{
"data": {
"id": "1093",
"type": "site_team_association",
"attributes": {
"id": 1093,
"site_id": 11416,
"team_id": 392
},
"relationships": {
"site": {
"data": {
"id": "11416",
"type": "site"
}
},
"team": {
"data": {
"id": "392",
"type": "team"
}
}
}
},
"links": {
"self": "https://www.nao-cloud.com/api/v2/teams/392/site_team_associations"
}
}
The results also show up on the page of the team:
curl -X DELETE --header 'Content-Type: application/json' --header 'Accept: application/vnd.api+json' --header 'Authorization: <Auth_Token>' 'https://<NAO_CLOUD>/api/v2/teams/<TEAM_ID>/site_team_associations/<SITE_ID>'
Use the following request template to add users to teams
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/vnd.api+json' --header 'Authorization: <Auth_Token>' -d '{"user_team_association": {"email": "<EMAIL>"}}' 'http://localhost:3000/api/v2/teams/<TEAM_ID>/user_team_associations
The following request add user “Member“ to team “Test team”
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/vnd.api+json' --header 'Authorization: e1XYDn4fAY2Gs2VgMbqVgNv4-HxU9A' -d '{ \
"user_team_association": { \
"email":"polestarusa-test3%40naocloud.com"} \
}' 'https://www.nao-cloud.com/api/v2/teams/392/user_team_associations'
Response
{
"data": {
"id": "1002",
"type": "user_team_association",
"attributes": {
"id": 1002,
"user_id": 4841,
"roles_mask": null,
"admin": null,
"team_id": 392,
"email": "polestarusa-test3@naocloud.com"
},
"relationships": {
"user": {
"data": {
"id": "4841",
"type": "user"
}
},
"team": {
"data": {
"id": "392",
"type": "team"
}
}
}
},
"links": {
"self": "https://www.nao-cloud.com/api/v2/teams/392/user_team_associations"
}
}
Result in the page of the team:
The user email is passed as path parameter, thus @ character must be replaced by %40
curl -X DELETE --header 'Accept: application/vnd.api+json' --header 'Authorization: <AUTH_TOKEN>' 'https://staging.nao-cloud.com/api/v2/teams/<TEAM_ID>/user_team_associations/<EMAIL>'