Skip to content

Commit 2e9d224

Browse files
committed
Add DeleteWorkunitByID exported function
1 parent a5c9403 commit 2e9d224

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

WorkunitExec.ecl

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,65 @@ EXPORT WorkunitExec := MODULE
584584
RETURN queryResults(rProtected);
585585
END;
586586

587+
/**
588+
* Delete an existing workunit from a cluster.
589+
*
590+
* @param workunitID The WUID of the workunit containing the
591+
* result; REQUIRED
592+
* @param espURL The full URL for accessing the esp process
593+
* running on the HPCC Systems cluster (this
594+
* is typically the same URL as used to access
595+
* ECL Watch); set to an empty string to use
596+
* the URL of the current esp process;
597+
* OPTIONAL, defaults to an empty string
598+
* @param username The user name to use when connecting
599+
* to the cluster; OPTIONAL, defaults to
600+
* an empty string
601+
* @param userPW The username password to use when
602+
* connecting to the cluster; OPTIONAL,
603+
* defaults to an empty string
604+
* @param timeoutInSeconds The number of seconds to wait for the
605+
* executed job to complete; use zero (0) to
606+
* wait forever; OPTIONAL, defaults to 60
607+
*
608+
* @return TRUE if the workunit was successfully deleted, FALSE otherwise.
609+
*/
610+
EXPORT DeleteWorkunitByID(STRING workunitID,
611+
STRING espURL = '',
612+
STRING username = '',
613+
STRING userPW = '',
614+
UNSIGNED2 timeoutInSeconds = 0) := FUNCTION
615+
myESPURL := CreateESPURL(espURL);
616+
auth := CreateAuthHeaderValue(username, userPW);
617+
618+
WUIDListLayout := RECORD
619+
STRING item;
620+
END;
621+
622+
QueryResultsLayout := RECORD
623+
STRING rWUID {XPATH('Wuid')};
624+
STRING rAction {XPATH('Action')};
625+
BOOLEAN rResult {XPATH('Result')};
626+
END;
627+
628+
queryResults := SOAPCALL
629+
(
630+
myESPURL,
631+
'WUDelete',
632+
{
633+
DATASET(WUIDListLayout) pWuids {XPATH('Wuids')} := DATASET([workunitID], WUIDListLayout);
634+
UNSIGNED4 pBlockTillFinishTimer {XPATH('BlockTillFinishTimer')} := 1; // IF(timeoutInSeconds = 0, 0, 1);
635+
},
636+
DATASET(QueryResultsLayout),
637+
XPATH('WUDeleteResponse/ActionResults/WUActionResult'),
638+
HTTPHEADER('Authorization', auth),
639+
TIMEOUT(60), ONFAIL(SKIP)
640+
);
641+
642+
// If the results are missing then the call succeeded
643+
RETURN IF(EXISTS(queryResults), queryResults[1].rResult, TRUE);
644+
END;
645+
587646
/**
588647
* Record structure used to represent the results of a published
589648
* workunit.

0 commit comments

Comments
 (0)