From a02af72641932ab81c424bed8e0aa47045b009f4 Mon Sep 17 00:00:00 2001 From: Sebastian Rose Date: Thu, 8 Feb 2024 20:21:22 +0100 Subject: [PATCH] #299 - java noop --- .../template/client-ClientWriteResponse.java.mustache | 8 ++++++++ .../java/template/client-OpenFgaClient.java.mustache | 10 ++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/config/clients/java/template/client-ClientWriteResponse.java.mustache b/config/clients/java/template/client-ClientWriteResponse.java.mustache index 1883f647..f7c3ac5c 100644 --- a/config/clients/java/template/client-ClientWriteResponse.java.mustache +++ b/config/clients/java/template/client-ClientWriteResponse.java.mustache @@ -10,12 +10,20 @@ public class ClientWriteResponse { private final Map> headers; private final String rawResponse; + public static ClientWriteResponse EMPTY = new ClientWriteResponse(); + public ClientWriteResponse(ApiResponse apiResponse) { this.statusCode = apiResponse.getStatusCode(); this.headers = apiResponse.getHeaders(); this.rawResponse = apiResponse.getRawResponse(); } + private ClientWriteResponse() { + this.statusCode = 0; + this.headers = Map.empty(); + this.rawResponse = ""; + } + public int getStatusCode() { return statusCode; } diff --git a/config/clients/java/template/client-OpenFgaClient.java.mustache b/config/clients/java/template/client-OpenFgaClient.java.mustache index 928f7606..5950897e 100644 --- a/config/clients/java/template/client-OpenFgaClient.java.mustache +++ b/config/clients/java/template/client-OpenFgaClient.java.mustache @@ -357,15 +357,21 @@ public class OpenFgaClient { WriteRequest body = new WriteRequest(); var writeTuples = request.getWrites(); - if (writeTuples != null && !writeTuples.isEmpty()) { + var writesRequested = writeTuples != null && !writeTuples.isEmpty() + if (writesRequested) { body.writes(ClientTupleKey.asWriteRequestWrites(writeTuples)); } var deleteTuples = request.getDeletes(); - if (deleteTuples != null && !deleteTuples.isEmpty()) { + var deletesRequested = deleteTuples != null && !deleteTuples.isEmpty(); + if (deletesRequested) { body.deletes(ClientTupleKeyWithoutCondition.asWriteRequestDeletes(deleteTuples)); } + if (!writesRequested && !deletesRequested) { + return completedFuture(ClientWriteResponse.EMPTY); + } + if (options != null && !isNullOrWhitespace(options.getAuthorizationModelId())) { body.authorizationModelId(options.getAuthorizationModelId()); } else {