Layer 7 API Management

Expand all | Collapse all

RESTMAN call to create a folder in another

Jump to Best Answer
  • 1.  RESTMAN call to create a folder in another

    Posted 06-30-2017 06:38 AM

    Hi,

     

    I am attempting to write an ansible module to help me setup CA from ansible.

    As a part of that I want to create a folder tree using the RESTMAN API.

     

    restman command - CA API Gateway - 8.3 - CA Technologies Documentation 

     

    The following request body creates a folder:

     

    <l7:Folder folderId="0000000000000000ffffffffffffec76" xmlns:l7="http://ns.l7tech.com/2010/04/gateway-management">
        <l7:Name>Folder Name</l7:Name>
    </l7:Folder

     

    But how can I specify the the parent folder (or even better an entire path) where I want the folder to be created:

     



  • 2.  Re: RESTMAN call to create a folder in another

    Posted 07-03-2017 04:34 AM

    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/&/&amp;/')
          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

    .....

    .....

     

     



  • 3.  Re: RESTMAN call to create a folder in another
    Best Answer

    Posted 07-07-2017 12:07 PM

    ' folderId="0000000000000000ffffffffffffec76" ' is the parent folder in the request body you posted as an example here. So you would need to know the Id of the parent folder when creating a new folder, and use the Id of the parent folder as the value entered in folderId="".



  • 4.  Re: RESTMAN call to create a folder in another

    Posted 07-13-2017 03:44 AM

    If you want to import a GMU export of MigrationChild3 into an arbitrary folder, the GMU can do this during import.
    You can use the flag --destFolder, during which is a relatively new GMU feature.

    So if you export /Migration/MigrationChild1/MigrationChild2/MigrationChild3, you can import this using:
     --destFolder /Migration/MigrationChild1/MigrationChild2

    The GMU will auto create these root folders, and import MigrationChild3 and all its containing policies there.
    Offcourse, this requires use of the GMU, and won't work with Restman natively.