11package io .camunda .tasklist .example ;
22
33import com .fasterxml .jackson .databind .ObjectMapper ;
4+ import io .camunda .client .CamundaClient ;
45import io .camunda .tasklist .CamundaTaskListClient ;
56import io .camunda .tasklist .CamundaTasklistClientConfiguration ;
7+ import io .camunda .tasklist .CamundaTasklistClientConfiguration .ApiVersion ;
68import io .camunda .tasklist .CamundaTasklistClientConfiguration .DefaultProperties ;
79import io .camunda .tasklist .auth .JwtAuthentication ;
810import io .camunda .tasklist .auth .JwtCredential ;
911import io .camunda .tasklist .auth .SimpleAuthentication ;
1012import io .camunda .tasklist .auth .SimpleCredential ;
1113import io .camunda .tasklist .auth .TokenResponseHttpClientResponseHandler ;
12- import io .camunda .zeebe .client .ZeebeClient ;
1314import java .net .MalformedURLException ;
1415import java .net .URI ;
1516import java .net .URL ;
1617import java .time .Duration ;
1718
1819public interface TasklistClientBootstrapper {
19- static ZeebeClient zeebeClient () {
20- return ZeebeClient .newClientBuilder ().build ();
20+ static CamundaClient camundaClient () {
21+ return CamundaClient .newClientBuilder ().build ();
2122 }
2223
2324 CamundaTaskListClient createTasklistClient () throws MalformedURLException ;
@@ -27,23 +28,25 @@ class SimpleAuthTasklistClientBootstrapper implements TasklistClientBootstrapper
2728 @ Override
2829 public CamundaTaskListClient createTasklistClient () throws MalformedURLException {
2930 // properties you need to provide
31+ ApiVersion apiVersion = ApiVersion .v1 ;
3032 String username = "demo" ;
3133 String password = "demo" ;
3234 URL tasklistUrl = URI .create ("http://localhost:8082" ).toURL ();
3335 boolean returnVariables = false ;
3436 boolean loadTruncatedVariables = false ;
3537 boolean useZeebeUserTasks = true ;
36- // if you are using zeebe user tasks, you require a zeebe client as well
37- ZeebeClient zeebeClient = zeebeClient ();
38+ // if you are using camunda user tasks, you require a camunda client as well
39+ CamundaClient camundaClient = camundaClient ();
3840 // bootstrapping
3941 SimpleCredential credentials =
4042 new SimpleCredential (username , password , tasklistUrl , Duration .ofMinutes (10 ));
4143 SimpleAuthentication authentication = new SimpleAuthentication (credentials );
4244 CamundaTasklistClientConfiguration configuration =
4345 new CamundaTasklistClientConfiguration (
46+ apiVersion ,
4447 authentication ,
4548 tasklistUrl ,
46- zeebeClient ,
49+ camundaClient ,
4750 new DefaultProperties (returnVariables , loadTruncatedVariables , useZeebeUserTasks ));
4851 CamundaTaskListClient client = new CamundaTaskListClient (configuration );
4952 return client ;
@@ -54,6 +57,7 @@ class IdentityAuthTasklistClientBootstrapper implements TasklistClientBootstrapp
5457 @ Override
5558 public CamundaTaskListClient createTasklistClient () throws MalformedURLException {
5659 // properties you need to provide
60+ ApiVersion apiVersion = ApiVersion .v1 ;
5761 String clientId = "" ;
5862 String clientSecret = "" ;
5963 String audience = "tasklist-api" ;
@@ -66,8 +70,8 @@ public CamundaTaskListClient createTasklistClient() throws MalformedURLException
6670 boolean returnVariables = false ;
6771 boolean loadTruncatedVariables = false ;
6872 boolean useZeebeUserTasks = true ;
69- // if you are using zeebe user tasks, you require a zeebe client as well
70- ZeebeClient zeebeClient = zeebeClient ();
73+ // if you are using camunda user tasks, you require a camunda client as well
74+ CamundaClient camundaClient = camundaClient ();
7175 // bootstrapping
7276 JwtCredential credentials =
7377 new JwtCredential (clientId , clientSecret , audience , authUrl , scope );
@@ -77,9 +81,10 @@ public CamundaTaskListClient createTasklistClient() throws MalformedURLException
7781 JwtAuthentication authentication = new JwtAuthentication (credentials , clientResponseHandler );
7882 CamundaTasklistClientConfiguration configuration =
7983 new CamundaTasklistClientConfiguration (
84+ apiVersion ,
8085 authentication ,
8186 tasklistUrl ,
82- zeebeClient ,
87+ camundaClient ,
8388 new DefaultProperties (returnVariables , loadTruncatedVariables , useZeebeUserTasks ));
8489 CamundaTaskListClient client = new CamundaTaskListClient (configuration );
8590 return client ;
@@ -90,15 +95,16 @@ class SaasTasklistClientBootstrapper implements TasklistClientBootstrapper {
9095 @ Override
9196 public CamundaTaskListClient createTasklistClient () throws MalformedURLException {
9297 // properties you need to provide
98+ ApiVersion apiVersion = ApiVersion .v1 ;
9399 String region = "" ;
94100 String clusterId = "" ;
95101 String clientId = "" ;
96102 String clientSecret = "" ;
97103 boolean returnVariables = false ;
98104 boolean loadTruncatedVariables = false ;
99105 boolean useZeebeUserTasks = true ;
100- // if you are using zeebe user tasks, you require a zeebe client as well
101- ZeebeClient zeebeClient = zeebeClient ();
106+ // if you are using camunda user tasks, you require a camunda client as well
107+ CamundaClient camundaClient = camundaClient ();
102108 // bootstrapping
103109 URL tasklistUrl =
104110 URI .create ("https://" + region + ".tasklist.camunda.io/" + clusterId ).toURL ();
@@ -111,9 +117,10 @@ public CamundaTaskListClient createTasklistClient() throws MalformedURLException
111117 JwtAuthentication authentication = new JwtAuthentication (credentials , clientResponseHandler );
112118 CamundaTasklistClientConfiguration configuration =
113119 new CamundaTasklistClientConfiguration (
120+ apiVersion ,
114121 authentication ,
115122 tasklistUrl ,
116- zeebeClient ,
123+ camundaClient ,
117124 new DefaultProperties (returnVariables , loadTruncatedVariables , useZeebeUserTasks ));
118125 CamundaTaskListClient client = new CamundaTaskListClient (configuration );
119126 return client ;
0 commit comments