openfga/sdk-generator

Java SDK: support context and contextual tuples for ListRelations

Closed this issue · 0 comments

Checklist

  • I have looked into the README and have not found a suitable solution or answer.
  • I have looked into the documentation and have not found a suitable solution or answer.
  • I have searched the issues and have not found a suitable solution or answer.
  • I have searched the Slack Community and have not found a suitable solution or answer.
  • I agree to the terms within the OpenFGA Code of Conduct.

Description

ListRelations in the Java SDK OpenFgaClient does not support context or contextual tuples

Expectation

ListRelations: should pass context and contextual tuples to batchCheck

public CompletableFuture<ClientListRelationsResponse> listRelations(
ClientListRelationsRequest request, ClientListRelationsOptions listRelationsOptions)
throws FgaInvalidParameterException {
if (request.getRelations() == null || request.getRelations().isEmpty()) {
throw new FgaInvalidParameterException(
"At least 1 relation to check has to be provided when calling ListRelations");
}
var options = listRelationsOptions != null
? listRelationsOptions
: new ClientListRelationsOptions().maxParallelRequests(DEFAULT_MAX_METHOD_PARALLEL_REQS);
if (options.getAdditionalHeaders() == null) {
options.additionalHeaders(new HashMap<>());
}
options.getAdditionalHeaders().putIfAbsent(CLIENT_METHOD_HEADER, "ListRelations");
options.getAdditionalHeaders()
.putIfAbsent(CLIENT_BULK_REQUEST_ID_HEADER, randomUUID().toString());
var batchCheckRequests = request.getRelations().stream()
.map(relation -> new ClientCheckRequest()
.user(request.getUser())
.relation(relation)
._object(request.getObject()))
.collect(Collectors.toList());
return this.batchCheck(batchCheckRequests, options.asClientBatchCheckOptions())
.thenCompose(responses -> call(() -> ClientListRelationsResponse.fromBatchCheckResponses(responses)));
}

ClientListRelationsRequest: should add support for context https://github.com/openfga/sdk-generator/blob/d62eec2512d53134552c507c7fe44442be04c006/config/clients/java/template/client-ClientListRelationsRequest.java.mustache

Reproduction

.

SDK Checklist

  • JS SDK
  • Go SDK
  • .NET SDK
  • Python SDK
  • Java SDK

OpenFGA SDK version

v0.4.0

OpenFGA version

N/A

SDK Configuration

N/A

Logs

No response

References

Related to #331