HTTP Node Tree Creation Walkthrough
This walkthrough builds a node tree with the PowerTSM HTTP API: it creates a node attribute, assigns child nodes, modifies a node and verifies the resulting structure. It only demonstrates the creation of a node tree; see Working with Nodes for the basic information about nodes.
Create an Attribute
Section titled “Create an Attribute”First, an attribute has to be created that the nodes will be attached to:
Request
POST /repositories/TSM_SQLSERVER/attributesRequest Body
{ "name": "TestNodeTree", "description": "", "type": { "identifier": 13, "storageInformation": { "repositoryName": "TSM_SQLSERVER" } }}13 is the ID of the attribute type Node. See Basic Attribute Types for more information.
The response of this request will look like this:
Response
{ "identifier": 1014, "storageInformation": { "repositoryName": "TSM_SQLSERVER" }, "value": { "name": "TestNodeTree", "description": "", "type": { "identifier": 13, "storageInformation": { "repositoryName": "TSM_SQLSERVER" } } }}Note the identifier of the root is 1014.
Assign Child Nodes
Section titled “Assign Child Nodes”Request
POST /repositories/TSM_SQLSERVER/attributes/TestNodeTree/nodesSend this request with GET to see the ID(s) of the node(s).
Create a Node without Parents
Section titled “Create a Node without Parents”This node is only assigned to the root, which is the attribute TestNodeTree:
Request Body
[ { "name" : "ChildNodeA", "root": { "identifier" : 1014, "storageInformation": { "repositoryName": "TSM_SQLSERVER" } }, "parent": null }]Response
[ { "$successful": "true", "value": { "identifier": 10, "storageInformation": { "repositoryName": "TSM_SQLSERVER" }, "value": { "root": { "identifier": 1014, "storageInformation": { "repositoryName": "TSM_SQLSERVER" } }, "name": "ChildNodeA", "parent": null, "children": {} } } }]Note that the id of the created node is 10.
Create a Node as a Child of Another Node
Section titled “Create a Node as a Child of Another Node”This creates a child of ChildNodeA:
Request
POST /repositories/TSM_SQLSERVER/attributes/TestNodeTree/nodesRequest Body
[ { "name" : "ChildNodeA.1", "root": { "identifier" : 1014, "storageInformation": { "repositoryName": "TSM_SQLSERVER" } }, "parent": { "identifier" : 10, "storageInformation": { "repositoryName": "TSM_SQLSERVER" } } }]To follow the example, do this three times, one more time with the node name ChildNodeA.2 and ChildNodeA.3 respectively.
The response provides the information that, for this example, the ChildNodeA.1 has the id 11 and ChildNodeA.2 has the id 12.
Another Way to Add Children
Section titled “Another Way to Add Children”This second variant achieves the same result. It creates a child node of the node ChildNodeA.1:
Request
POST /repositories/TSM_SQLSERVER/attributes/TestNodeTree/nodes/id:10/children/id:11/childrenNote that this body does not need to be enclosed in []. The parent id must be the same as the last id in the request path (in this case 11):
Request Body
{ "name" : "ChildNodeA.1.1", "root": { "identifier" : 1014, "storageInformation": { "repositoryName": "TSM_SQLSERVER" } }, "parent": { "identifier" : 11, "storageInformation": { "repositoryName": "TSM_SQLSERVER" } }}The structure now looks like this:
TestNodeTree (id:1014)└─ ChildNodeA (id:10) ├─ ChildNodeA.1 (id:11) │ └─ ChildNodeA.1.1 (id:14) ├─ ChildNodeA.2 (id:12) └─ ChildNodeA.3 (id:13)Modify a Node
Section titled “Modify a Node”Request
PUT /repositories/TSM_SQLSERVER/attributes/TestNodeTree/nodes/id:10/children/id:11/children/id:14The body renames the node to ChildNodeA.2.1_modified and sets its parent id to 12, which is the id of ChildNodeA.2:
Request Body
{ "name" : "ChildNodeA.2.1_modified", "root": { "identifier" : 1014, "storageInformation": { "repositoryName": "TSM_SQLSERVER" } }, "parent": { "identifier" : 12, "storageInformation": { "repositoryName": "TSM_SQLSERVER" } }}Verify the Structure
Section titled “Verify the Structure”The following request delivers the full content of the node attribute:
GET /repositories/TSM_SQLSERVER/attributes/TestNodeTree/nodesFrom there it is visible that the first child of the attribute is ChildNodeA with the id 10.
To only see details on that node the following request is used:
GET /repositories/TSM_SQLSERVER/attributes/TestNodeTree/nodes/id:10This also shows the ids of the children of ChildNodeA. To see further details of the children, the /children endpoint is used:
GET /repositories/TSM_SQLSERVER/attributes/TestNodeTree/nodes/id:10/childrenEach of the children can be navigated to by simply appending their id from there. To see ChildNodeA.1, which is a child of ChildNodeA:
GET /repositories/TSM_SQLSERVER/attributes/TestNodeTree/nodes/id:10/children/id:11