Skip to content

Create a tree data resource

This document is automatically generated based on https://github.com/authing/authing-docs-factory based on https://api-explorer.genauth.ai V3 API, and is consistent with API parameters and return results. If this document description is incorrect, please refer to V3 API.

When you only need to create a tree type data resource, you can use this API. We have fixed the data resource type, and you do not need to pass in the type character field. Note: struct should be passed in according to the tree type data resource structure, please refer to the example.

Method name

ManagementClient.createDataResourceByTree

Request parameters

NameTypeRequiredDefault valueDescriptionSample value
actionsstring[]Yes-Data resource permission operation list Array length limit: 50.["read","get"]
struct<a DataResourceTreeStructs[]Yes-Tree data resource node Array length limit: 50.
resourceCodestringyes-Data resource Code, unique in the permission spacedataResourceTestCode
resourceNamestringyes-Data resource name, unique in the permission spaceSample data resource name
namespaceCodestringyes-Permission space where the data policy is locatedcode1
descriptionstringno-Data resource descriptionSample data resource description

Sample code

ts
import { ManagementClient, Models } from "authing-node-sdk";

// Initialize ManagementClient
const managementClient = new ManagementClient({
  // Need to be replaced with your GenAuth Access Key ID
  accessKeyId: "GEN_AUTH_ACCESS_KEY_ID",
  // Need to be replaced with your GenAuth Access Key Secret
  accessKeySecret: "GEN_AUTH_ACCESS_KEY_SECRET",
  // If it is a private deployment customer, you need to set GenAuth Service domain name
  // host: 'https://api.your-authing-service.com'
});

(async () => {
  const result = await managementClient.createDataResourceByTree({
    namespaceCode: "examplePermissionNamespace",
    resourceCode: "treeResourceCode",
    resourceName: "Example tree data resource",
    struct: [
      {
        code: "tree1",
        name: "Tree node 1",
        value: "Tree node 1 description",
        children: [
          {
            code: "tree11",
            name: "Tree node 11",
            value: "Tree node 11 description",
          },
        ],
      },
      {
        code: "tree2",
        name: "Tree node 2",
        value: "Tree node 2 description",
      },
    ],
    description: "Example tree data resource description",
    actions: ["get", "read"],
  });

  console.log(JSON.stringify(result, null, 2));
})();

Request response

Type: CreateTreeDataResourceResponseDto

NameTypeDescription
statusCodenumberBusiness status code, which can be used to determine whether the operation is successful. 200 means success.
messagestringDescription
apiCodenumberSegmented error code, which can be used to get the specific error type (successful request does not return). For a detailed list of error codes, see: API Code List
requestIdstringRequest ID. Returned when the request fails.
data<a CreateTreeDataResourceRespDtoResponse data

Sample result:

json
{
  "statusCode": 200,
  "message": "Operation successful",
  "requestId": "934108e5-9fbf-4d24-8da1-c330328abd6c",
  "data": {
    "resourceName": "Sample data resource name",
    "resourceCode": "dataResourceTestCode",
    "type": "TREE",
    "description": "Sample data resource description",
    "struct": {
      "code": "123",
      "name": "Data resource",
      "value": "Sample data resource node",
      "children": "[{\"code\":\"code1\",\"name\":\"child node 1\",\"value\":\"child node value\",\"children\":[{\"code\":\"code2\",\"name\":\"child node 2\",\"value\":\"child node 2 value\"}]}]"
    },
    "actions": "[\"read\",\"get\"]"
  }
}

Data Structure

DataResourceTreeStructs

NameTypeIs it requiredDescriptionSample value
codestringYesData resource node Code, unique in the same level123
namestringYesData resource node name, unique in the same levelData resource
valuestringNoData resource node ValueSample data resource node
childrenarrayNoChild nodes of data resource node, child node level supports up to five levels[{"code":"code1","name":"child node 1","value":"child node value","children":[{"code":"code2","name":"child node 2","value":"child node 2 value"}]}]

CreateTreeDataResourceRespDto

NameTypeIs it requiredDescriptionSample value
resourceNamestringyesData resource name, unique in the permission spaceSample data resource name
resourceCodestringyesData resource Code, unique in the permission spacedataResourceTestCode
typestringyesData resource type, currently supports tree structure (TREE), string (STRING), array (ARRAY)TREE
descriptionstringnoData resource descriptionSample data resource description
structarrayyesTree data resource node nested type: <a DataResourceTreeStructs. Array length limit: 50.
actionsarrayYesData resource permission operation list Array length limit: 50.["read","get"]

DataResourceTreeStructs

NameTypeIs it requiredDescriptionSample value
codestringyesData resource node Code, unique in the same level123
namestringyesData resource node name, unique in the same levelData resource
valuestringnoData resource node ValueSample data resource node
childrenarraynoChild nodes of data resource node, child node level supports up to five levels[{"code":"code1","name":"child node 1","value":"child node value","children":[{"code":"code2","name":"child node 2","value":"child node 2 value"}]}]

Agent infrastructure for identity, memory, and web action.