Skip to content

Commit

Permalink
openfga#299 - java noop
Browse files Browse the repository at this point in the history
  • Loading branch information
srose committed Feb 8, 2024
1 parent 77f822b commit a02af72
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,20 @@ public class ClientWriteResponse {
private final Map<String, List<String>> headers;
private final String rawResponse;
public static ClientWriteResponse EMPTY = new ClientWriteResponse();
public ClientWriteResponse(ApiResponse<Object> 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;
}
Expand Down
10 changes: 8 additions & 2 deletions config/clients/java/template/client-OpenFgaClient.java.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit a02af72

Please sign in to comment.