Some workspaces require resources to run. Any resources associated with a workspace are placed with the workspace and are accessed through the repository object.
To List the Resources for a Workspace
To view the resources that exist for a workspace, the repository name and the workspace name are required.
httpRequest.open("GET", "/fmerest/repositories/"+repositoryName+"/"+workspaceName+"/resources.json?token="+token_, true);
httpRequest.onreadystatechange = function()
{
if (httpRequest.readyState == 4)
{
if (httpRequest.status == 200)
{
var reply = eval("(" + httpRequest.responseText + ")");
if (typeof(reply.serviceResponse.resources.resource) != 'undefined')
{
var resources = reply.serviceResponse.resources;
for (var i in resources)
{
println(resources[i].name);
}
}
else
{
println("No Resources Found");
}
}
else
{
println("Error");
}
}
}
httpRequest.send(null);
To Add Resources for a Workspace
Use FME Workbench to upload resources for a workspace.
To Remove Resources from a Workspace
To remove a resource from a workspace, the repository name, workspace name, and resource name are required. Alternatively, removing a workspace also removes all associated resources for the workspace.
httpRequest.open("DELETE", "/fmerest/repositories/"+repositoryName+"/"+workspaceName+"/resources/"+resourceName+".json?token="+token_, true);
httpRequest.onreadystatechange = function()
{
if (httpRequest.readyState == 4)
{
if (httpRequest.status == 200)
{
println("Resource removed");
}
else
{
println("Failed to remove resource");
}
}
}
httpRequest.send(null);