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 read latest authorization model API #135

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
58 changes: 58 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.

65 changes: 65 additions & 0 deletions openfga/v1/openfga_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,58 @@ service OpenFGAService {
};
}

rpc ReadLatestAuthorizationModel(ReadLatestAuthorizationModelRequest) returns (ReadLatestAuthorizationModelResponse) {
option (google.api.http) = {get: "/stores/{store_id}/latest-authorization-models"};
adriantam marked this conversation as resolved.
Show resolved Hide resolved

option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "Return latest authorization model"
tags: ["Authorization Models"]
operation_id: "ReadLatestAuthorizationModel"
description:
"The ReadLatestAuthorizationModel API returns the latest authorization model.\n"
"The response will return the authorization model.\n\n"
"## Example\n"
"The API will return:\n"
"```json\n"
"{\n"
" \"authorization_model\":{\n"
" \"id\":\"01G5JAVJ41T49E9TT3SKVS7X1J\",\n"
" \"type_definitions\":[\n"
" {\n"
" \"type\":\"user\"\n"
" },\n"
" {\n"
" \"type\":\"document\",\n"
" \"relations\":{\n"
" \"reader\":{\n"
" \"union\":{\n"
" \"child\":[\n"
" {\n"
" \"this\":{}\n"
" },\n"
" {\n"
" \"computedUserset\":{\n"
" \"object\":\"\",\n"
" \"relation\":\"writer\"\n"
" }\n"
" }\n"
" ]\n"
" }\n"
" },\n"
" \"writer\":{\n"
" \"this\":{}\n"
" }\n"
" }\n"
" }\n"
" ]\n"
" }\n"
"}\n"
"```\n"
"In the above example, there are 2 types (`user` and `document`). The `document` type "
"has 2 relations (`writer` and `reader`)."
miparnisari marked this conversation as resolved.
Show resolved Hide resolved
};
}

rpc WriteAuthorizationModel(WriteAuthorizationModelRequest) returns (WriteAuthorizationModelResponse) {
option (google.api.http) = {
post: "/stores/{store_id}/authorization-models"
Expand Down Expand Up @@ -1032,6 +1084,15 @@ message ExpandResponse {
openfga.v1.UsersetTree tree = 1;
}

message ReadLatestAuthorizationModelRequest {
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\""}
];
}

message ReadAuthorizationModelRequest {
string store_id = 1 [
json_name = "store_id",
Expand All @@ -1052,6 +1113,10 @@ message ReadAuthorizationModelResponse {
AuthorizationModel authorization_model = 1 [json_name = "authorization_model"];
}

message ReadLatestAuthorizationModelResponse {
AuthorizationModel authorization_model = 1 [json_name = "authorization_model"];
}

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