tosca

Is there a REST API to get subfolders of the workspace in Tosca?


I am trying to build a UI based in Angular to retrieve all existing execution lists of Tosca. However, I could not find a REST API that can give the list of folders within a workspace in Tosca. Has anyone tried this route?


Solution

  • You can use the Search task on the projectto find all ExecutionLists. Example:

    {rest_url}/ToscaCommander/{workspace_name}/object/project/task/Search
    

    as a post request with the xml payload:

    <Parameters xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
        <Parameter>
            <Name>tqlString</Name>
            <Type i:nil="true"/>
            <Value>->SUBPARTS:TCFolder[Name=?"Execution"]=>SUBPARTS:ExecutionList</Value>
        </Parameter>
    </Parameters>
    

    This will give you a list of object ids of the ExecustionLists contained in the Execution folder of the project. You can fetch the objects one by one with this request afterwards:

    {rest_url}/ToscaCommander/{workspace_name}/object/{object_id}

    Credits for this solution go to the development team of ToscaCommander - they provided it.

    P.S.: as an answer for your comment:

    1. Yes, there is a json equivalent of the body - but you do not need it. Anyway, here is the equivalent:

      [{ "Name":"tqlString", "Value":"->SUBPARTS:TCFolder[Name=?\"Execution\"]=>SUBPARTS:ExecutionList" }]

    2. If you want to get a json response (regardless of the request's payload's format) make sure your web.config sets AutomaticFormatSelectionEnabled to true (which should be the case). Then, in your requests, set the accept header accordingly:

      Accept: application/json