# Management organization

An Authing user pool can create multiple organizations. This module is used to manage the Authing organization, and can perform operations such as adding, deleting, modifying, adding and deleting mobile nodes, and importing organizations.

# Create an organization

OrgManagementClient().create(createOrgParam)

Creating an organization will create an organization with only one node. If you want to import a complete organization tree, please use the importByJson method.

# Parameters

  • createOrgParam <CreateOrgParam>
  • createOrgParam.name <string> Organization name, which will be the name of the root node of the organization
  • createOrgParam.code <string> The only sign of the root node, which must be a legal English character
  • createOrgParam.description <string> Root node description

# Example

Org org = managementClient.org().create(new CreateOrgParam("name1", "org1", "desc1")).execute();

# Delete organization

OrgManagementClient().deleteById(id)

Delete organization tree

# Parameters

  • id <string> Organization ID

# Example

CommonMessage message = managementClient.org().deleteById("id").execute();

# Get the list of user pool organizations

OrgManagementClient().list(orgsParam)

Get the list of user pool organizations

# Parameters

  • orgsParam <OrgsParam>
  • orgsParam.page <number> Default value: 1
  • orgsParam.limit <number> Default value: 10
  • orgsParam.sortBy <SortByEnum> sorting rules.

# Example

PaginatedOrgs orgs = managementClient.org().list(new OrgsParam(1, 10, SortByEnum.CREATEDAT_DESC)).execute();

# Add node

OrgManagementClient().addNode(addNodeParam)

Add a node in the organization

# Parameters

  • addNodeParam <AddNodeParam>
  • addNodeParam.orgId <string> Organization ID
  • addNodeParam.parentNodeId <string> parent node ID
  • addNodeParam.name <string> node name
  • addNodeParam.code <string> unique identifier of the node
  • addNodeParam.description <string> node description information

# Example

AddNodeParam param = new AddNodeParam("orgId", "orgName")
        .withParentNodeId("parentId");
Org org2 = managementClient.org().addNode(param).execute();

# Modify node

OrgManagementClient().updateNode(updateNodeParam)

Modify node data

# Parameters

  • updateNodeParam <UpdateNodeParam>
  • updateNodeParam.id <string> node unique identifier
  • updateNodeParam.name <string> node name
  • updateNodeParam.description <string> node description information

# Example

UpdateNodeParam param = new UpdateNodeParam(0, "");
param.setId("id");
param.setName("name");
param.setDescription("description");
Node node = managementClient.org().updateNode(param).execute();

# Get organization details

OrgManagementClient().findById(id)

Get organization details through organization ID

# Parameters

  • id <string> Organization ID

# Example

Org org = managementClient.org().findById("id").execute();

# Delete node

OrgManagementClient().deleteNode(deleteNodeParam)

Delete a node in the organization tree

# Parameters

  • deleteNodeParam <DeleteNodeParam>
  • deleteNodeParam.orgId <string> Organization ID
  • deleteNodeParam.nodeId <string> node ID

# Example

CommonMessage commonMessage = managementClient.org().deleteNode(new DeleteNodeParam("orgId", "nodeId")).execute();

# Mobile Node

OrgManagementClient().moveNode(orgId, nodeId, targetParentId)

Move an organization node. When moving a node, you need to specify the node's new parent node. Note that you cannot move a node to its own child nodes.

# Parameters

  • orgId <string> Organization ID
  • nodeId <string> ID of the node to be moved
  • targetParentId <string> target parent node ID

# Example

Org org = managementClient.org().moveNode("orgId", "nodeId", "targetParentId").execute();

# Determine whether it is the root node

OrgManagementClient().isRootNode(nodeId, orgId)

Determine whether a node is the root node of the organization tree

# Parameters

  • nodeId <string> Organization ID
  • orgId <string> Organization ID

# Example

Boolean flag = managementClient.org().isRootNode("nodeId", "orgId").execute();

# Get the list of child nodes

OrgManagementClient().listChildren(orgId, nodeId)

Query the list of child nodes of a node

# Parameters

  • orgId <string> Organization ID
  • nodeId <string> Organization ID

# Example

List<Node> nodes = managementClient.org().listChildren("orgId", "nodeId").execute();

# Fuzzy search organization node

OrgManagementClient().searchNodes(searchNodesParam)

Fuzzy search organization node by node name

# Parameters

  • searchNodesParam.keyword <string> Organization name keyword

# Example

List<Node> list = orgManagementClient.searchNodes(new SearchNodesParam("test")).execute();

# Get the root node

OrgManagementClient().rootNode(rootNodeParam)

Get the root node of an organization

# Parameters

  • rootNodeParam <RootNodeParam>
  • rootNodeParam.orgId <string> Organization ID

# Example

Node node = managementClient.org().rootNode(new RootNodeParam(0, "orgId")).execute();

# Import via JSON

OrgManagementClient().importByJson(json)

Import organization through a JSON tree structure

# Parameters

  • json <Object> Tree structure in JSON format, please refer to the sample code for the detailed format.

# Example


json examples:

{
  name:'Beijing Extraordinary Technology Co., Ltd.',
  code:'feifan',
  children: [
     {
         code:'operation',
         name:'Operation',
         description:'Commercialization Department'
     },
     {
        code:'dev',
        name:'R&D',
        description:'R&D department',
        children: [
          {
            code:'backend',
            name:'Backend',
            description:'Back-end R&D department'
          }
        ]
     }
  ]
}

Map map1 = new HashMap<>();
map1.put("name","ceshi11");
map1.put("code","ceshi11");

Map map2 = new HashMap<>();
map2.put("name","ceshi12");
map2.put("code","ceshi12");

Map map = new HashMap<>();
map.put("name","ceshi1");
map.put("code","ceshi1");
map.put("children",Arrays.asList(map1,map2));

Gson gson = new Gson();
String jsonStr = gson.toJson(map);
Node nodes = managementClient.org().importByJson(jsonStr).execute();

# Add members

OrgManagementClient().addMembers(nodeId, userIds)

Node add members

# Parameters

  • nodeId <string> node ID
  • userIds <string[]> list of user IDs

# Example

Node node = managementClient.org().addMembers("nodeId", Arrays.asList("userId")).execute();

# Get node members

OrgManagementClient().listMembers(nodeByIdWithMembersParam)

Get node members, you can get users directly added to the node, or users of the node's child nodes.

# Parameters

  • nodeByIdWithMembersParam <NodeByIdWithMembersParam>
  • nodeByIdWithMembersParam.page <number> Default value: 1
  • nodeByIdWithMembersParam.limit <number> Default value: 10
  • nodeByIdWithMembersParam.sortBy <SortByEnum> sorting rules
  • nodeByIdWithMembersParam.includeChildrenNodes <boolean> Whether to get the members of all child nodes Default value: false
  • nodeByIdWithMembersParam.id <string> node ID

# Example

Node node = managementClient.org().listMembers(new NodeByIdWithMembersParam("id")).execute();

# Delete member

OrgManagementClient().removeMembers(nodeId, userIds)

Delete node member

# Parameters

  • nodeId <string> node ID
  • userIds <string[]> list of user IDs

# Example

Node node = managementClient.org().removeMembers("nodeId", Arrays.asList("userId")).execute();