marklogic / ml-gradle

Gradle plugin for automating everything involving MarkLogic

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: com.marklogic.gradle.task.qconsole.DeleteWorkspacesTask

lingtao-sa opened this issue · comments

I would like to request to have a DeleteWorkspacesTask under qconsole.

I need to set up a workflow to auto archive and clean up qconsole workspace once my each project completes.

You could do that fairly easily with a custom task that extends ServerEvalTask.

Below is an example. You would either need to replace YOUR-USERNAME-GOES-HERE with your username, or a reference to a project variable for the username.

task deleteWorkspaces(type: com.marklogic.gradle.task.ServerEvalTask) {
    doFirst(){ println "deleting workspaces"}
    xquery = '''declare namespace qconsole="http://marklogic.com/appservices/qconsole";
xdmp:invoke-function(function() {
  cts:uris("/workspaces/", (), cts:element-value-query(xs:QName("qconsole:userid"),
    xdmp:user("YOUR-USERNAME-GOES-HERE") => string()
  )) ! xdmp:document-delete(.)
}, map:entry("database", xdmp:database("App-Services")))
'''
}

@lingtao-sa What inputs would you expect for this task? Like how would mlDeleteWorkspaces know which workspaces to delete and which ones to keep?

I'm also wondering how much time this would save. I understand your use case, and I'd identify the workspaces I want to delete by their name. And I'd likely have to go to qconsole to see what the name of each workspace is that I want to delete. But once I'm doing that in qconsole, I'm a few seconds away from deleting each workspace that I want to delete. It seems like it would take me more time and more copying/pasting to grab each workspace name and toss them into a call to mlDeleteWorkspaces.

Of course, if I'm having to do this to more than 1 MarkLogic installation, it'd be a pain to do it via qconsole for each ML instance. But that use case seems rare - I'm rarely creating the same workspace in more than one ML instance.

Closing due to lack of response.