All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.quarkiverse.openfga.client.AssertionsClient Maven / Gradle / Ivy

There is a newer version: 2.1.0
Show newest version
package io.quarkiverse.openfga.client;

import java.util.List;

import io.quarkiverse.openfga.client.api.API;
import io.quarkiverse.openfga.client.model.Assertion;
import io.quarkiverse.openfga.client.model.dto.ReadAssertionsResponse;
import io.quarkiverse.openfga.client.model.dto.WriteAssertionsRequest;
import io.smallrye.mutiny.Uni;

public class AssertionsClient {

    private final API api;
    private final Uni storeId;
    private final String authorizationModelId;

    public AssertionsClient(API api, Uni storeId, String authorizationModelId) {
        this.api = api;
        this.storeId = storeId;
        this.authorizationModelId = authorizationModelId;
    }

    public Uni> list() {
        return storeId.flatMap(storeId -> api.readAssertions(storeId, authorizationModelId))
                .map(ReadAssertionsResponse::getAssertions);
    }

    public Uni update(List assertions) {
        return storeId
                .flatMap(storeId -> api.writeAssertions(storeId, authorizationModelId, new WriteAssertionsRequest(assertions)));
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy