@@ -215,7 +215,7 @@ func GetProcessDefinitionXMLByTenant(ctx context.Context, key, tenantId string)
215215// StartProcessDefinition instantiates a given process definition. Process variables and business
216216// key may be supplied in the request body.
217217func StartProcessDefinition (ctx context.Context , id string , trigger * ProcessInstanceTrigger ) (* ProcessInstance , error ) {
218- var reader * bytes .Reader
218+ var reader io .Reader
219219
220220 var uri string
221221 var payload []byte
@@ -249,7 +249,7 @@ exec:
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.
251251func StartProcessDefinitionByKey (ctx context.Context , key string , trigger * ProcessInstanceTrigger ) (* ProcessInstance , error ) {
252- var reader * bytes .Reader
252+ var reader io .Reader
253253
254254 var uri string
255255 var payload []byte
@@ -283,7 +283,7 @@ exec:
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
285285func StartProcessDefinitionByTenant (ctx context.Context , key , tenantId string , trigger * ProcessInstanceTrigger ) (* ProcessInstance , error ) {
286- var reader * bytes .Reader
286+ var reader io .Reader
287287
288288 var uri string
289289 var payload []byte
@@ -314,6 +314,30 @@ exec:
314314 return result , nil
315315}
316316
317+ // GetProcessInstances queries for process instances that fulfill given parameters. Parameters may be
318+ // static as well as dynamic runtime properties of process instances. The size of the result set can
319+ // be retrieved by using the GetProcessInstancesCount method.
320+ func GetProcessInstances (ctx context.Context , tenantId string ) ([]* ProcessInstance , error ) {
321+ var uri string
322+ var err error
323+
324+ result := make ([]* ProcessInstance , 0 )
325+
326+ uri = fmt .Sprintf ("%s/%s/process-instance?tenantIdIn=%s" , url , path , tenantId )
327+ err = client .send (ctx , uri , http .MethodGet , "application/json" , nil , & result )
328+
329+ if err != nil {
330+ return nil , err
331+ }
332+
333+ return result , err
334+ }
335+
336+ // GetProcessInstancesCount ...
337+ func GetProcessInstancesCount (ctx context.Context ) {
338+
339+ }
340+
317341// GetTasks queries for tasks that fulfill a given filter. The size of the result set can be retrieved
318342// by using the GetTasksCount method.
319343func GetTasks (ctx context.Context , processInstanceId string ) ([]* Task , error ) {
@@ -424,17 +448,27 @@ func UnclaimTask(ctx context.Context, id string) error {
424448
425449// CompleteTask completes a task and updates process variables.
426450func CompleteTask (ctx context.Context , id string , variables map [string ]* Variable ) error {
451+ var reader io.Reader
452+
427453 var uri string
454+ var payload []byte
428455 var err error
429456
430- payload , err := json .Marshal (& map [string ]interface {}{"variables" : variables })
457+ if variables == nil {
458+ goto exec
459+ }
460+
461+ payload , err = json .Marshal (& map [string ]interface {}{"variables" : variables })
431462
432463 if err != nil {
433464 return err
434465 }
435466
467+ reader = bytes .NewReader (payload )
468+
469+ exec:
436470 uri = fmt .Sprintf ("%s/%s/task/%s/complete" , url , path , id )
437- err = client .send (ctx , uri , http .MethodPost , "application/json" , bytes . NewReader ( payload ) , nil )
471+ err = client .send (ctx , uri , http .MethodPost , "application/json" , reader , nil )
438472
439473 return err
440474}
@@ -444,21 +478,54 @@ func CompleteTask(ctx context.Context, id string, variables map[string]*Variable
444478// can be sent back to the owner. Can only be executed when the task has been delegated. The assignee
445479// will be set to the owner, who performed the delegation.
446480func ResolveTask (ctx context.Context , id string , variables map [string ]* Variable ) error {
481+ var reader io.Reader
482+
447483 var uri string
484+ var payload []byte
448485 var err error
449486
450- payload , err := json .Marshal (& map [string ]interface {}{"variables" : variables })
487+ if variables == nil {
488+ goto exec
489+ }
490+
491+ payload , err = json .Marshal (& map [string ]interface {}{"variables" : variables })
451492
452493 if err != nil {
453494 return err
454495 }
455496
497+ reader = bytes .NewReader (payload )
498+
499+ exec:
456500 uri = fmt .Sprintf ("%s/%s/task/%s/resolve" , url , path , id )
457- err = client .send (ctx , uri , http .MethodPost , "application/json" , bytes . NewReader ( payload ) , nil )
501+ err = client .send (ctx , uri , http .MethodPost , "application/json" , reader , nil )
458502
459503 return err
460504}
461505
506+ // GetTenants query for a list of tenants using a list of parameters. The size of the result
507+ // set can be retrieved by using the GetTenantsCount method.
508+ func GetTenants (ctx context.Context ) ([]* Tenant , error ) {
509+ var uri string
510+ var err error
511+
512+ result := make ([]* Tenant , 0 )
513+
514+ uri = fmt .Sprintf ("%s/%s/tenant" , url , path )
515+ err = client .send (ctx , uri , http .MethodGet , "application/json" , nil , & result )
516+
517+ if err != nil {
518+ return nil , err
519+ }
520+
521+ return result , err
522+ }
523+
524+ // GetTenantsCount ...
525+ func GetTenantsCount (ctx context.Context ) {
526+
527+ }
528+
462529// GetTenant retrieves a Tenant.
463530func GetTenant (ctx context.Context , id string ) (* Tenant , error ) {
464531 var uri string
0 commit comments