All Products
Search
Document Center

Drive and Photo Service:Manage groups

Last Updated:Nov 23, 2023

Drive and Photo Service allows you to manage groups on a default client provided by Drive and Photo Service. You can also call the API operations described in this topic to manage groups.

Basic concepts

  • A group can be considered a department of an enterprise. You can add users or other groups to a group.

  • The members of a group can be users or groups.

The following figure shows the structure of a sample enterprise.

image

Note
  • A user can be added to multiple groups. We recommend that you add a user to no more than ten groups. Otherwise, query performance may be compromised.

  • You can specify a parent group when you create a group. A group cannot be moved after it is created. If you do not specify a parent group when you create a group, the group you create serves as a root group.

  • A group can have a maximum of 10 levels.

Sample API calls

1. Create a group

If you want to create a root group, set the is_root parameter to true. If you do not want to create a root group, you must specify the parent_group_id parameter and set the is_root parameter to false.

Sample request

// Create a root group.
{
  "group_name": "Enterprise A", 
  "is_root": true
}

// Create an R&D department in Enterprise A.
{
  "group_name": "R&D department", 
  "is_root": false,
  "parent_group_id": "929bf1cec48d4eb28a6cca0af29f1b8f"
}

Sample success response

{
  "domain_id": "bj3231",
  "group_id": "929bf1cec48d4eb28a6cca0af29f1b8f",
  "group_name": "Enterprise A",
  "description": "",
  "created_at": 1677335855709,
  "updated_at": 1677335855709,
  "creator": "",
  "permission": null
}

2. List group members

If you want to list all root groups, do not specify the group_id parameter.

Sample request

{
  "group_id": "929bf1cec48d4eb28a6cca0af29f1b8f", 
  "limit": 100
}

Sample success response

{
  "group_items": [
    {
      "domain_id": "bj3231",
      "group_id": "ef6a45fa25f54aacae08a501269de4e4",
      "group_name": "R&D department",
      "description": "",
      "created_at": 1677336367210,
      "updated_at": 1677336367210,
      "creator": "",
      "permission": null
    }
  ],
  "user_items": [],
  "next_marker": ""

3. Add a user to a group

You can call this operation to add only users to groups. To add a group to a parent group, specify the parent_group_id parameter when you create the child group.

Sample request

{
  "group_id": "ef6a45fa25f54aacae08a501269de4e4",
  "member_id": "39df109b4f4f428db75898bbb0644fa5",
  "member_type": "user"
}

Sample response

204 NoContent

4. Remove a user from a group

You can call this operation to remove only users from groups. If you want to delete a group, you must remove all members from the group and then delete the group.

Sample request

{
  "group_id": "ef6a45fa25f54aacae08a501269de4e4",
  "member_id": "39df109b4f4f428db75898bbb0644fa5",
  "member_type": "user"
}

Sample response

204 NoContent

5. Delete a group

You can call this operation to delete only a group that has no members.

Sample request

{
  "group_id": "ef6a45fa25f54aacae08a501269de4e4"
}

Sample response

204 NoContent