Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ tasklist:
client-secret:
```

Configure defaults that influence the client behaviour:
Configure defaults that influence the client behavior:

```yaml
tasklist:
Expand All @@ -107,6 +107,8 @@ tasklist:
load-truncated-variables: true
return-variables: true
use-zeebe-user-tasks: true
tenant-ids:
- <default>
```

### Plain Java
Expand All @@ -131,6 +133,7 @@ URL tasklistUrl = URI.create("http://localhost:8082").toURL();
boolean returnVariables = false;
boolean loadTruncatedVariables = false;
boolean useZeebeUserTasks = true;
List<String> tenantIds = List.of("<default>");
// if you are using zeebe user tasks, you require a zeebe client as well
ZeebeClient zeebeClient = zeebeClient();
// bootstrapping
Expand All @@ -142,14 +145,16 @@ CamundaTasklistClientConfiguration configuration =
authentication,
tasklistUrl,
zeebeClient,
new DefaultProperties(returnVariables, loadTruncatedVariables, useZeebeUserTasks));
new DefaultProperties(
returnVariables, loadTruncatedVariables, useZeebeUserTasks, tenantIds));

CamundaTaskListClient client = new CamundaTaskListClient(configuration);
```

Build a Camunda Tasklist client with identity authentication:

```java
// properties you need to provide
// properties you need to provide
String clientId = "";
String clientSecret = "";
String audience = "tasklist-api";
Expand All @@ -162,6 +167,7 @@ URL authUrl =
boolean returnVariables = false;
boolean loadTruncatedVariables = false;
boolean useZeebeUserTasks = true;
List<String> tenantIds = List.of("<default>");
// if you are using zeebe user tasks, you require a zeebe client as well
ZeebeClient zeebeClient = zeebeClient();
// bootstrapping
Expand All @@ -176,21 +182,23 @@ CamundaTasklistClientConfiguration configuration =
authentication,
tasklistUrl,
zeebeClient,
new DefaultProperties(returnVariables, loadTruncatedVariables, useZeebeUserTasks));
new DefaultProperties(
returnVariables, loadTruncatedVariables, useZeebeUserTasks, tenantIds));
CamundaTaskListClient client = new CamundaTaskListClient(configuration);
```

Build a Camunda Tasklist client for Saas:

```java
// properties you need to provide
// properties you need to provide
String region = "";
String clusterId = "";
String clientId = "";
String clientSecret = "";
boolean returnVariables = false;
boolean loadTruncatedVariables = false;
boolean useZeebeUserTasks = true;
List<String> tenantIds = List.of("<default>");
// if you are using zeebe user tasks, you require a zeebe client as well
ZeebeClient zeebeClient = zeebeClient();
// bootstrapping
Expand All @@ -208,7 +216,8 @@ CamundaTasklistClientConfiguration configuration =
authentication,
tasklistUrl,
zeebeClient,
new DefaultProperties(returnVariables, loadTruncatedVariables, useZeebeUserTasks));
new DefaultProperties(
returnVariables, loadTruncatedVariables, useZeebeUserTasks, tenantIds));
CamundaTaskListClient client = new CamundaTaskListClient(configuration);
```

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.camunda.tasklist.bootstrapping;

import static io.camunda.tasklist.CamundaTasklistClientConfiguration.*;

import io.camunda.tasklist.CamundaTaskListClient;
import io.camunda.tasklist.CamundaTasklistClientConfiguration;
import io.camunda.tasklist.CamundaTasklistClientConfiguration.DefaultProperties;
Expand All @@ -22,7 +24,7 @@ public CamundaTaskListClient create() {
Duration.ofMinutes(10))),
URI.create("http://localhost:8082").toURL(),
null,
new DefaultProperties(true, true, false)));
new DefaultProperties(true, true, false, DEFAULT_TENANT_IDS)));
} catch (MalformedURLException e) {
throw new RuntimeException("Error while bootstrapping tasklist client", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.net.URI;
import java.net.URL;
import java.time.Duration;
import java.util.List;

public interface TasklistClientBootstrapper {
static ZeebeClient zeebeClient() {
Expand All @@ -33,6 +34,7 @@ public CamundaTaskListClient createTasklistClient() throws MalformedURLException
boolean returnVariables = false;
boolean loadTruncatedVariables = false;
boolean useZeebeUserTasks = true;
List<String> tenantIds = List.of("<default>");
// if you are using zeebe user tasks, you require a zeebe client as well
ZeebeClient zeebeClient = zeebeClient();
// bootstrapping
Expand All @@ -44,7 +46,9 @@ public CamundaTaskListClient createTasklistClient() throws MalformedURLException
authentication,
tasklistUrl,
zeebeClient,
new DefaultProperties(returnVariables, loadTruncatedVariables, useZeebeUserTasks));
new DefaultProperties(
returnVariables, loadTruncatedVariables, useZeebeUserTasks, tenantIds));

CamundaTaskListClient client = new CamundaTaskListClient(configuration);
return client;
}
Expand All @@ -66,6 +70,7 @@ public CamundaTaskListClient createTasklistClient() throws MalformedURLException
boolean returnVariables = false;
boolean loadTruncatedVariables = false;
boolean useZeebeUserTasks = true;
List<String> tenantIds = List.of("<default>");
// if you are using zeebe user tasks, you require a zeebe client as well
ZeebeClient zeebeClient = zeebeClient();
// bootstrapping
Expand All @@ -80,7 +85,8 @@ public CamundaTaskListClient createTasklistClient() throws MalformedURLException
authentication,
tasklistUrl,
zeebeClient,
new DefaultProperties(returnVariables, loadTruncatedVariables, useZeebeUserTasks));
new DefaultProperties(
returnVariables, loadTruncatedVariables, useZeebeUserTasks, tenantIds));
CamundaTaskListClient client = new CamundaTaskListClient(configuration);
return client;
}
Expand All @@ -97,6 +103,7 @@ public CamundaTaskListClient createTasklistClient() throws MalformedURLException
boolean returnVariables = false;
boolean loadTruncatedVariables = false;
boolean useZeebeUserTasks = true;
List<String> tenantIds = List.of("<default>");
// if you are using zeebe user tasks, you require a zeebe client as well
ZeebeClient zeebeClient = zeebeClient();
// bootstrapping
Expand All @@ -114,7 +121,8 @@ public CamundaTaskListClient createTasklistClient() throws MalformedURLException
authentication,
tasklistUrl,
zeebeClient,
new DefaultProperties(returnVariables, loadTruncatedVariables, useZeebeUserTasks));
new DefaultProperties(
returnVariables, loadTruncatedVariables, useZeebeUserTasks, tenantIds));
CamundaTaskListClient client = new CamundaTaskListClient(configuration);
return client;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ public CamundaTaskListClient(
new DefaultProperties(
properties.isDefaultShouldReturnVariables(),
properties.isDefaultShouldLoadTruncatedVariables(),
properties.isUseZeebeUserTasks())));
properties.isUseZeebeUserTasks(),
properties.getTenantIds())));
}

public CamundaTaskListClient(CamundaTasklistClientConfiguration configuration) {
Expand Down Expand Up @@ -457,6 +458,9 @@ public TaskList getTasks(TaskSearch search) throws TaskListException {
if (search.getWithVariables() == null) {
search.setWithVariables(defaultProperties.returnVariables());
}
if (search.getTenantIds() == null || search.getTenantIds().isEmpty()) {
search.setTenantIds(defaultProperties.tenantIds());
}
Pagination pagination = search.getPagination();
TaskSearchRequest request = ConverterUtils.toTaskSearchRequest(search);
if (pagination != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.camunda.tasklist;

import static io.camunda.tasklist.CamundaTasklistClientConfiguration.*;

import com.fasterxml.jackson.databind.ObjectMapper;
import io.camunda.tasklist.auth.Authentication;
import io.camunda.tasklist.auth.JwtAuthentication;
Expand All @@ -13,6 +15,7 @@

@Deprecated
public class CamundaTaskListClientBuilder {

private CamundaTaskListClientProperties properties = new CamundaTaskListClientProperties();
private ZeebeClient zeebeClient;

Expand All @@ -38,12 +41,16 @@ public CamundaTaskListClientBuilder zeebeClient(ZeebeClient zeebeClient) {
* @return the builder
*/
public CamundaTaskListClientBuilder shouldReturnVariables() {

properties.setDefaultShouldReturnVariables(true);

return this;
}

public CamundaTaskListClientBuilder shouldLoadTruncatedVariables() {

properties.setDefaultShouldLoadTruncatedVariables(true);

return this;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package io.camunda.tasklist;

import static io.camunda.tasklist.CamundaTasklistClientConfiguration.*;

import io.camunda.tasklist.auth.Authentication;
import java.util.ArrayList;
import java.util.List;

@Deprecated
public class CamundaTaskListClientProperties {
Expand All @@ -10,6 +14,7 @@ public class CamundaTaskListClientProperties {
private boolean defaultShouldReturnVariables;
private boolean defaultShouldLoadTruncatedVariables;
private boolean useZeebeUserTasks;
private List<String> tenantIds = new ArrayList<>(DEFAULT_TENANT_IDS);

public CamundaTaskListClientProperties() {}

Expand Down Expand Up @@ -65,4 +70,12 @@ public boolean isUseZeebeUserTasks() {
public void setUseZeebeUserTasks(boolean useZeebeUserTasks) {
this.useZeebeUserTasks = useZeebeUserTasks;
}

public List<String> getTenantIds() {
return tenantIds;
}

public void setTenantIds(List<String> tenantIds) {
this.tenantIds = tenantIds;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@
import io.camunda.tasklist.auth.Authentication;
import io.camunda.zeebe.client.ZeebeClient;
import java.net.URL;
import java.util.List;

public record CamundaTasklistClientConfiguration(
Authentication authentication,
URL baseUrl,
ZeebeClient zeebeClient,
DefaultProperties defaultProperties) {
public record DefaultProperties(
boolean returnVariables, boolean loadTruncatedVariables, boolean useZeebeUserTasks) {}
boolean returnVariables,
boolean loadTruncatedVariables,
boolean useZeebeUserTasks,
List<String> tenantIds) {}

public static List<String> DEFAULT_TENANT_IDS = List.of("<default>");
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package io.camunda.tasklist;

import static com.github.tomakehurst.wiremock.client.WireMock.*;
import static io.camunda.tasklist.CamundaTasklistClientConfiguration.*;
import static org.junit.jupiter.api.Assertions.*;

import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.tomakehurst.wiremock.junit5.WireMockTest;
import io.camunda.tasklist.CamundaTasklistClientConfiguration.DefaultProperties;
import io.camunda.tasklist.auth.Authentication;
import io.camunda.tasklist.auth.JwtAuthentication;
import io.camunda.tasklist.auth.JwtCredential;
Expand Down Expand Up @@ -45,7 +45,10 @@ private static URL baseUrl() {
public void shouldThrowIfZeebeClientNullAndUseZeebeUserTasks() {
CamundaTasklistClientConfiguration configuration =
new CamundaTasklistClientConfiguration(
new MockAuthentication(), baseUrl(), null, new DefaultProperties(false, false, true));
new MockAuthentication(),
baseUrl(),
null,
new DefaultProperties(false, false, true, DEFAULT_TENANT_IDS));
IllegalStateException assertionError =
assertThrows(IllegalStateException.class, () -> new CamundaTaskListClient(configuration));
assertEquals("ZeebeClient is required when using ZeebeUserTasks", assertionError.getMessage());
Expand All @@ -55,7 +58,10 @@ public void shouldThrowIfZeebeClientNullAndUseZeebeUserTasks() {
public void shouldNotThrowIfZeebeClientNullAndNotUseZeebeUserTasks() {
CamundaTasklistClientConfiguration configuration =
new CamundaTasklistClientConfiguration(
new MockAuthentication(), baseUrl(), null, new DefaultProperties(false, false, false));
new MockAuthentication(),
baseUrl(),
null,
new DefaultProperties(false, false, false, DEFAULT_TENANT_IDS));
CamundaTaskListClient client = new CamundaTaskListClient(configuration);
assertNotNull(client);
}
Expand All @@ -79,7 +85,7 @@ void shouldAuthenticateUsingSimpleAuth() throws MalformedURLException, TaskListE
"demo", "demo", URI.create(BASE_URL).toURL(), Duration.ofMinutes(10))),
baseUrl(),
null,
new DefaultProperties(false, false, false));
new DefaultProperties(false, false, false, DEFAULT_TENANT_IDS));
CamundaTaskListClient client = new CamundaTaskListClient(configuration);
assertNotNull(client);
TaskList tasks = client.getTasks(new TaskSearch());
Expand Down Expand Up @@ -113,7 +119,7 @@ void shouldAuthenticateUsingJwt() throws MalformedURLException, TaskListExceptio
new TokenResponseHttpClientResponseHandler(new ObjectMapper())),
baseUrl(),
null,
new DefaultProperties(false, false, false));
new DefaultProperties(false, false, false, DEFAULT_TENANT_IDS));
CamundaTaskListClient client = new CamundaTaskListClient(configuration);
assertNotNull(client);
TaskList tasks = client.getTasks(new TaskSearch());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public CamundaTasklistClientConfiguration tasklistClientConfiguration(
new DefaultProperties(
properties.defaults().returnVariables(),
properties.defaults().loadTruncatedVariables(),
properties.defaults().useZeebeUserTasks()));
properties.defaults().useZeebeUserTasks(),
properties.defaults().tenantIds()));
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.net.URL;
import java.time.Duration;
import java.util.List;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.bind.DefaultValue;

Expand Down Expand Up @@ -34,5 +35,6 @@ public enum Profile {
public record ClientDefaults(
@DefaultValue("true") boolean returnVariables,
@DefaultValue("true") boolean loadTruncatedVariables,
@DefaultValue("true") boolean useZeebeUserTasks) {}
@DefaultValue("true") boolean useZeebeUserTasks,
@DefaultValue("<default>") List<String> tenantIds) {}
}