Skip to content

Commit 127d050

Browse files
committed
Added deleteUserData method to Harness Client
1 parent c5e7da2 commit 127d050

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

example/src/main/java/HarnessClientExample.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,15 @@ public static void main(String[] args) {
6161
HarnessClient client = new HarnessClient(engineId, serverHost, serverPort, optionalCreds);
6262

6363
runGetUserData(client, "u1");
64+
// runDeleteUserData(client, "u1");
6465
}
6566

6667

6768
private static void runGetUserData(HarnessClient client, String userId) {
68-
client.getEvents(userId).thenApply(x -> { System.out.println(x); return new Object(); });
69+
client.deleteEvents(userId).thenAccept(System.out::println);
70+
}
71+
72+
private static void runDeleteUserData(HarnessClient client, String userId) {
73+
client.deleteEvents(userId).thenAccept(System.out::println);
6974
}
7075
}

src/main/java/com/actionml/HarnessClient.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,17 @@ public CompletionStage<Pair<Integer, List<String>>> getEvents(String userId) {
5555
);
5656
}
5757

58+
public CompletionStage<Integer> deleteEvents(String userId) {
59+
return withAuth().thenCompose(optionalToken ->
60+
Source.single(this.uri.addPathSegment(userId))
61+
.map(this::createDelete)
62+
.zipWithIndex()
63+
.map(pair -> pair.copy(pair.first(), (Long) pair.second()))
64+
.via(this.poolClientFlow)
65+
.mapAsync(1, this::extractResponse)
66+
.runFold(0, (a, i) -> i.second().status().intValue(), this.materializer)
67+
);
68+
}
69+
5870

5971
}

0 commit comments

Comments
 (0)