Extract from our createFolder framework function, not shown here are getFolderId which obviously returns the Id of the folder given in parm (urlencoded), and callPUTService/callPOSTService functions which actually are encapsulating curl calls.
"folderName" can be a complete path, function will create folder under it's parent.
if "folderId" is defined, it will create the folder with the specified id.
To actually create your structure:
createFolder "/Migration"
createFolder "/Migration/MigrationChild1"
createFolder "/Migration/MigrationChild1/MigrationChild2"
createFolder "/Migration/MigrationChild1/MigrationChild2/MigrationChild3"
if [ -n "${folderName}" ]; then
folderName=$(echo ${folderName} | sed 's/&/\&/')
local parentDir=$(dirname "${folderName}")
parentDir=$(basename "$(echo ${parentDir} | sed 's/&/\&/')")
[ "$parentDir" == "/" ] && parentDir="Root Node"
local pfolderId=$(getFolderId "${parentDir}")
if [ -n "${pfolderId}" ]; then
local realFolderName=$(basename "${folderName}")
realFolderName=$(echo ${realFolderName} |sed 's/&/&/')
local xml="\
<l7:Folder folderId='${pfolderId}' xmlns:l7='http://ns.l7tech.com/2010/04/gateway-management'> \
<l7:Name>${realFolderName}</l7:Name> \
</l7:Folder>"
if [ "${folderId}" != "" ]; then
callPUTService "/folders/${folderId}" "${xml}"
else
callPOSTService "/folders" "${xml}"
fi
.....
.....