Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add batch-check proto definition #203

Merged
merged 18 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 156 additions & 0 deletions docs/openapiv2/apidocs.swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

76 changes: 76 additions & 0 deletions openfga/v1/openfga_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import "google/protobuf/struct.proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/wrappers.proto";
import "openfga/v1/authzmodel.proto";
import "openfga/v1/errors_ignore.proto";
import "openfga/v1/openfga.proto";
import "openfga/v1/openfga_service_consistency.proto";
import "protoc-gen-openapiv2/options/annotations.proto";
Expand Down Expand Up @@ -326,6 +327,28 @@ service OpenFGAService {
};
}

rpc BatchCheck(BatchCheckRequest) returns (BatchCheckResponse) {
option (google.api.http) = {
post: "/stores/{store_id}/batch-check"
body: "*"
};

option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "Send a list of `check` operations in a single request"
justincoh marked this conversation as resolved.
Show resolved Hide resolved
tags: ["Relationship Queries"]
operation_id: "BatchCheck"
description:
"The `BatchCheck` API functions nearly identically to `Check`, but instead of checking a single "
"user-object relationship BatchCheck accepts a list of relationships to check and returns a list containing a response "
"for each check it received.\n\n"
"Like `Check`, you can specify `contextual_tuples` and `context` with each individual tuple to be checked. Unlike check, however, "
"`BatchCheck` also accepts `contextual_tuples` and `context` at the request level. If `contextual_tuples` or `context` are received "
"at the request level, those contexts will taken into account when evaluating each check in the batch. If an individual check within the batch "
"has its own `contextual_tuples` or `context`, **they will override** the request-level values and the request-level values will not be considered for that check.\n\n"
"For more details on how `Check` functions, see the docs for `/check`."
};
}

rpc Expand(ExpandRequest) returns (ExpandResponse) {
option (google.api.http) = {
post: "/stores/{store_id}/expand"
Expand Down Expand Up @@ -1173,6 +1196,59 @@ message CheckResponse {
string resolution = 2;
}

message BatchCheckRequest {
string store_id = 1 [
json_name = "store_id",
(google.api.field_behavior) = REQUIRED,
(validate.rules).string = {pattern: "^[ABCDEFGHJKMNPQRSTVWXYZ0-9]{26}$"},
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {example: "\"01YCP46JKYM8FJCQ37NMBYHE5X\""}
];

repeated BatchCheckItem checks = 2 [(google.api.field_behavior) = REQUIRED];

openfga.v1.ContextualTupleKeys contextual_tuples = 3 [json_name = "contextual_tuples"];

google.protobuf.Struct context = 4;

string authorization_model_id = 5 [
json_name = "authorization_model_id",
(validate.rules).string = {
pattern: "^[ABCDEFGHJKMNPQRSTVWXYZ0-9]{26}$"
ignore_empty: true
},
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {example: "\"01G5JAVJ41T49E9TT3SKVS7X1J\""}
];

ConsistencyPreference consistency = 6 [(validate.rules).enum.defined_only = true];
justincoh marked this conversation as resolved.
Show resolved Hide resolved
}

message BatchCheckItem {
CheckRequestTupleKey tuple_key = 1 [(google.api.field_behavior) = REQUIRED];
justincoh marked this conversation as resolved.
Show resolved Hide resolved
openfga.v1.ContextualTupleKeys contextual_tuples = 2 [json_name = "contextual_tuples"];
google.protobuf.Struct context = 3;
}

message BatchCheckResponse {
repeated BatchCheckSingleResult result = 1;
}

message BatchCheckSingleResult {
BatchCheckItem check = 1;
oneof check_result {
bool allowed = 2;
justincoh marked this conversation as resolved.
Show resolved Hide resolved
CheckError error = 3;
}
google.protobuf.Int32Value query_duration_ms = 4;
justincoh marked this conversation as resolved.
Show resolved Hide resolved
}

message CheckError {
oneof code {
ErrorCode input_error = 1;
InternalErrorCode internal_error = 2;
}
string message = 3;
}

message ExpandRequest {
string store_id = 1 [
json_name = "store_id",
Expand Down
Loading
Loading