@@ -214,18 +214,18 @@ func GetProcessDefinitionXMLByTenant(ctx context.Context, key, tenantId string)
214214
215215// StartProcessDefinition instantiates a given process definition. Process variables and business
216216// key may be supplied in the request body.
217- func StartProcessDefinition (ctx context.Context , id string , trigger * ProcessInstanceTrigger ) (* ProcessInstance , error ) {
217+ func StartProcessDefinition (ctx context.Context , id string , data * ProcessDefinitionStart ) (* ProcessInstance , error ) {
218218 var reader io.Reader
219219
220220 var uri string
221221 var payload []byte
222222 var err error
223223
224- if trigger == nil {
224+ if data == nil {
225225 goto exec
226226 }
227227
228- payload , err = json .Marshal (trigger )
228+ payload , err = json .Marshal (data )
229229
230230 if err != nil {
231231 return nil , err
@@ -248,18 +248,18 @@ exec:
248248
249249// StartProcessDefinitionByKey instantiates a given process definition. Process variables and business
250250// key may be supplied in the request body. Starts the latest version of the process definition which belongs to no tenant.
251- func StartProcessDefinitionByKey (ctx context.Context , key string , trigger * ProcessInstanceTrigger ) (* ProcessInstance , error ) {
251+ func StartProcessDefinitionByKey (ctx context.Context , key string , data * ProcessDefinitionStart ) (* ProcessInstance , error ) {
252252 var reader io.Reader
253253
254254 var uri string
255255 var payload []byte
256256 var err error
257257
258- if trigger == nil {
258+ if data == nil {
259259 goto exec
260260 }
261261
262- payload , err = json .Marshal (trigger )
262+ payload , err = json .Marshal (data )
263263
264264 if err != nil {
265265 return nil , err
@@ -282,18 +282,18 @@ exec:
282282
283283// StartProcessDefinitionByTenant instantiates a given process definition. Process variables and business
284284// key may be supplied in the request body. Starts the latest version of the process definition for tenant
285- func StartProcessDefinitionByTenant (ctx context.Context , key , tenantId string , trigger * ProcessInstanceTrigger ) (* ProcessInstance , error ) {
285+ func StartProcessDefinitionByTenant (ctx context.Context , key , tenantId string , data * ProcessDefinitionStart ) (* ProcessInstance , error ) {
286286 var reader io.Reader
287287
288288 var uri string
289289 var payload []byte
290290 var err error
291291
292- if trigger == nil {
292+ if data == nil {
293293 goto exec
294294 }
295295
296- payload , err = json .Marshal (trigger )
296+ payload , err = json .Marshal (data )
297297
298298 if err != nil {
299299 return nil , err
@@ -314,6 +314,98 @@ exec:
314314 return result , nil
315315}
316316
317+ // ActivateProcessDefinition activates a given process definition by id.
318+ func ActivateProcessDefinition (ctx context.Context , id , date string , includeProcessInstances bool ) error {
319+ var uri string
320+ var err error
321+
322+ data := make (map [string ]interface {})
323+
324+ data ["suspended" ] = false
325+ data ["includeProcessInstances" ] = includeProcessInstances
326+ data ["executionDate" ] = date
327+
328+ payload , err := json .Marshal (data )
329+
330+ if err != nil {
331+ return err
332+ }
333+
334+ uri = fmt .Sprintf ("%s/%s/process-definition/%s/suspended" , url , path , id )
335+ err = client .send (ctx , uri , http .MethodPut , "application/json" , bytes .NewReader (payload ), nil )
336+
337+ return err
338+ }
339+
340+ // SuspendProcessDefinition suspends a given process definition by id.
341+ func SuspendProcessDefinition (ctx context.Context , id , date string , includeProcessInstances bool ) error {
342+ var uri string
343+ var err error
344+
345+ data := make (map [string ]interface {})
346+
347+ data ["suspended" ] = true
348+ data ["includeProcessInstances" ] = includeProcessInstances
349+ data ["executionDate" ] = date
350+
351+ payload , err := json .Marshal (data )
352+
353+ if err != nil {
354+ return err
355+ }
356+
357+ uri = fmt .Sprintf ("%s/%s/process-definition/%s/suspended" , url , path , id )
358+ err = client .send (ctx , uri , http .MethodPut , "application/json" , bytes .NewReader (payload ), nil )
359+
360+ return err
361+ }
362+
363+ // RestartProcessDefinition restarts process instances that were canceled or terminated
364+ // synchronously. Can also restart completed process instances. It will create a new
365+ // instance using the original instance information. To execute the restart asynchronously,
366+ // use the RestartProcessDefinitionAsync method.
367+ func RestartProcessDefinition (ctx context.Context , id string , data * ProcessDefinitionRestart ) error {
368+ var uri string
369+ var err error
370+
371+ payload , err := json .Marshal (data )
372+
373+ if err != nil {
374+ return err
375+ }
376+
377+ uri = fmt .Sprintf ("%s/%s/process-definition/%s/restart" , url , path , id )
378+ err = client .send (ctx , uri , http .MethodPost , "application/json" , bytes .NewReader (payload ), nil )
379+
380+ return err
381+ }
382+
383+ // RestartProcessDefinitionAsync restarts process instances that were canceled or terminated
384+ // asynchronously. Can also restart completed process instances. It will create a new
385+ // instance using the original instance information. To execute the restart synchronously,
386+ // use the RestartProcessDefinition method.
387+ func RestartProcessDefinitionAsync (ctx context.Context , id string , data * ProcessDefinitionRestart ) (* Batch , error ) {
388+ var uri string
389+ var err error
390+
391+ payload , err := json .Marshal (data )
392+
393+ if err != nil {
394+ return nil , err
395+ }
396+
397+ result := new (Batch )
398+
399+ uri = fmt .Sprintf ("%s/%s/process-definition/%s/restart-async" , url , path , id )
400+ err = client .send (ctx , uri , http .MethodPost , "application/json" , bytes .NewReader (payload ), result )
401+
402+ if err != nil {
403+ return nil , err
404+ }
405+
406+ return result , err
407+ }
408+
317409// GetProcessInstances queries for process instances that fulfill given parameters. Parameters may be
318410// static as well as dynamic runtime properties of process instances. The size of the result set can
319411// be retrieved by using the GetProcessInstancesCount method.
@@ -338,6 +430,35 @@ func GetProcessInstancesCount(ctx context.Context) {
338430
339431}
340432
433+ // GetUserOperations queries for user operation log entries that fulfill the given parameters. The
434+ // size of the result set can be retrieved by using the GetUserOperationsCount method.
435+ // Note that the properties of operation log entries are interpreted as restrictions on the
436+ // entities they apply to. That means, if a single process instance is updated, the field
437+ // processInstanceId is populated. If a single operation updates all process instances of the
438+ // same process definition, the field processInstanceId is null (a null restriction is viewed
439+ // as a wildcard, i.e., matches a process instance with any id) and the field processDefinitionId
440+ // is populated. This way, which entities were changed by a user operation can easily be reconstructed.
441+ func GetUserOperations (ctx context.Context , taskId string ) ([]* UserOperationLog , error ) {
442+ var uri string
443+ var err error
444+
445+ result := make ([]* UserOperationLog , 0 )
446+
447+ uri = fmt .Sprintf ("%s/%s/history/user-operation?taskId=%s" , url , path , taskId )
448+ err = client .send (ctx , uri , http .MethodGet , "application/json" , nil , & result )
449+
450+ if err != nil {
451+ return nil , err
452+ }
453+
454+ return result , err
455+ }
456+
457+ // GetUserOperationsCount ...
458+ func GetUserOperationsCount (ctx context.Context ) {
459+
460+ }
461+
341462// GetTasks queries for tasks that fulfill a given filter. The size of the result set can be retrieved
342463// by using the GetTasksCount method.
343464func GetTasks (ctx context.Context , processInstanceId string ) ([]* Task , error ) {
@@ -464,8 +585,11 @@ func UnclaimTask(ctx context.Context, id string) error {
464585 return err
465586}
466587
467- // CompleteTask completes a task and updates process variables.
468- func CompleteTask (ctx context.Context , id string , variables map [string ]* Variable ) error {
588+ // ResolveTask resolves a task and updates execution variables.
589+ // Resolving a task marks that the assignee is done with the task delegated to them, and that it
590+ // can be sent back to the owner. Can only be executed when the task has been delegated. The assignee
591+ // will be set to the owner, who performed the delegation.
592+ func ResolveTask (ctx context.Context , id string , variables map [string ]* Variable ) error {
469593 var reader io.Reader
470594
471595 var uri string
@@ -485,17 +609,14 @@ func CompleteTask(ctx context.Context, id string, variables map[string]*Variable
485609 reader = bytes .NewReader (payload )
486610
487611exec:
488- uri = fmt .Sprintf ("%s/%s/task/%s/complete " , url , path , id )
612+ uri = fmt .Sprintf ("%s/%s/task/%s/resolve " , url , path , id )
489613 err = client .send (ctx , uri , http .MethodPost , "application/json" , reader , nil )
490614
491615 return err
492616}
493617
494- // ResolveTask resolves a task and updates execution variables.
495- // Resolving a task marks that the assignee is done with the task delegated to them, and that it
496- // can be sent back to the owner. Can only be executed when the task has been delegated. The assignee
497- // will be set to the owner, who performed the delegation.
498- func ResolveTask (ctx context.Context , id string , variables map [string ]* Variable ) error {
618+ // CompleteTask completes a task and updates process variables.
619+ func CompleteTask (ctx context.Context , id string , variables map [string ]* Variable ) error {
499620 var reader io.Reader
500621
501622 var uri string
@@ -515,12 +636,69 @@ func ResolveTask(ctx context.Context, id string, variables map[string]*Variable)
515636 reader = bytes .NewReader (payload )
516637
517638exec:
518- uri = fmt .Sprintf ("%s/%s/task/%s/resolve " , url , path , id )
639+ uri = fmt .Sprintf ("%s/%s/task/%s/complete " , url , path , id )
519640 err = client .send (ctx , uri , http .MethodPost , "application/json" , reader , nil )
520641
521642 return err
522643}
523644
645+ // GetTaskComments gets the comments for a task by id.
646+ func GetTaskComments (ctx context.Context , id string ) ([]* Comment , error ) {
647+ var uri string
648+ var err error
649+
650+ result := make ([]* Comment , 0 )
651+
652+ uri = fmt .Sprintf ("%s/%s/task/%s/comment" , url , path , id )
653+ err = client .send (ctx , uri , http .MethodGet , "application/json" , nil , & result )
654+
655+ if err != nil {
656+ return nil , err
657+ }
658+
659+ return result , err
660+ }
661+
662+ // GetTaskComment retrieves a task comment by task id and comment id.
663+ func GetTaskComment (ctx context.Context , id , commentId string ) (* Comment , error ) {
664+ var uri string
665+ var err error
666+
667+ result := new (Comment )
668+
669+ uri = fmt .Sprintf ("%s/%s/task/%s/comment/%s" , url , path , id , commentId )
670+ err = client .send (ctx , uri , http .MethodGet , "application/json" , nil , & result )
671+
672+ if err != nil {
673+ return nil , err
674+ }
675+
676+ return result , err
677+ }
678+
679+ // CreateTaskComment creates a comment for a task by id.
680+ func CreateTaskComment (ctx context.Context , id , message string ) (* Comment , error ) {
681+ var uri string
682+ var err error
683+
684+ payload , err := json .Marshal (& map [string ]string {"message" : message })
685+
686+ if err != nil {
687+ return nil , err
688+ }
689+
690+ result := new (Comment )
691+
692+ uri = fmt .Sprintf ("%s/%s/task/%s/comment/create" , url , path , id )
693+ err = client .send (ctx , uri , http .MethodPost , "application/json" , bytes .NewReader (payload ), result )
694+
695+ if err != nil {
696+ return nil , err
697+ }
698+
699+ return result , err
700+ }
701+
524702// GetTenants query for a list of tenants using a list of parameters. The size of the result
525703// set can be retrieved by using the GetTenantsCount method.
526704func GetTenants (ctx context.Context ) ([]* Tenant , error ) {
@@ -577,3 +755,31 @@ func CreateTenant(ctx context.Context, tenant *Tenant) error {
577755
578756 return err
579757}
758+
759+ // UpdateTenant updates a given Tenant.
760+ func UpdateTenant (ctx context.Context , id string , tenant * Tenant ) error {
761+ var uri string
762+ var err error
763+
764+ payload , err := json .Marshal (tenant )
765+
766+ if err != nil {
767+ return err
768+ }
769+
770+ uri = fmt .Sprintf ("%s/%s/tenant/%s" , url , path , id )
771+ err = client .send (ctx , uri , http .MethodPut , "application/json" , bytes .NewReader (payload ), nil )
772+
773+ return err
774+ }
775+
776+ // DeleteTenant deletes a tenant by id.
777+ func DeleteTenant (ctx context.Context , id string ) error {
778+ var uri string
779+ var err error
780+
781+ uri = fmt .Sprintf ("%s/%s/tenant/%s" , url , path , id )
782+ err = client .send (ctx , uri , http .MethodDelete , "application/json" , nil , nil )
783+
784+ return err
785+ }
0 commit comments