Skip to content

Commit d40b6b5

Browse files
committed
changing on_missing and on_duplicate to string value instead of Enum for proper JSON values
1 parent c53dab7 commit d40b6b5

File tree

4 files changed

+2750
-2883
lines changed

4 files changed

+2750
-2883
lines changed

docs/openapiv2/apidocs.swagger.json

Lines changed: 17 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

openfga/v1/openfga_service.proto

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,9 @@ service OpenFGAService {
155155
"relationship exists between an object and an user.\n"
156156
"In the body, `writes` adds new tuples and `deletes` removes existing tuples. When deleting a tuple, any `condition` specified with it is ignored.\n"
157157
"The API is not idempotent by default: if, later on, you try to add the same tuple key (even if the `condition` is different), or if you try to delete a non-existing tuple, it will throw an error.\n"
158-
"To allow writes when an identical tuple already exists in the database, set `\"on_duplicate\": \"ON_DUPLICATE_IGNORE\"` on the `writes` object.\n"
159-
"To allow deletes when a tuple was already removed from the database, set `\"on_missing\": \"ON_MISSING_IGNORE\"` on the `deletes` object.\n"
158+
"To allow writes when an identical tuple already exists in the database, set `\"on_duplicate\": \"ignore\"` on the `writes` object.\n"
159+
"To allow deletes when a tuple was already removed from the database, set `\"on_missing\": \"ignore\"` on the `deletes` object.\n"
160+
"If a Write request contains both idempotent (ignore) and non-idempotent (error) operations, the most restrictive action (error) will take precedence. If a condition fails for a sub-request with an error flag, the entire transaction will be rolled back. This gives developers explicit control over the atomicity of the requests.\n"
160161
"The API will not allow you to write tuples such as `document:2021-budget#viewer@document:2021-budget#viewer`, because they are implicit.\n"
161162
"An `authorization_model_id` may be specified in the body. If it is, it will be used to assert that each written tuple (not deleted) "
162163
"is valid for the model specified. If it is not specified, the latest authorization model ID will be used.\n"
@@ -174,7 +175,7 @@ service OpenFGAService {
174175
" \"object\": \"document:2021-budget\"\n"
175176
" }\n"
176177
" ],\n"
177-
" \"on_duplicate\": \"ON_DUPLICATE_ERROR\"\n"
178+
" \"on_duplicate\": \"ignore\"\n"
178179
" },\n"
179180
" \"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\"\n"
180181
"}\n"
@@ -192,7 +193,7 @@ service OpenFGAService {
192193
" \"object\": \"document:2021-budget\"\n"
193194
" }\n"
194195
" ],\n"
195-
" \"on_missing\": \"ON_MISSING_ERROR\"\n"
196+
" \"on_missing\": \"ignore\"\n"
196197
" }\n"
197198
"}\n"
198199
"```\n"
@@ -1245,48 +1246,44 @@ message ReadResponse {
12451246
];
12461247
}
12471248

1248-
enum OnDuplicate {
1249-
ON_DUPLICATE_UNSPECIFIED = 0; // If set to 'ON_DUPLICATE_UNSPECIFIED' OR not set, the API will behave as if it was set to 'ON_DUPLICATE_ERROR'.
1250-
ON_DUPLICATE_ERROR = 1; // Return an error if a tuple already exists.
1251-
ON_DUPLICATE_IGNORE = 2; // Treat identical writes as no-ops if all attributes (including the RelationshipCondition) match.
1252-
}
1253-
12541249
message WriteRequestWrites {
12551250
repeated TupleKey tuple_keys = 1 [
12561251
json_name = "tuple_keys",
12571252
(google.api.field_behavior) = REQUIRED,
12581253
(validate.rules).repeated.min_items = 1,
12591254
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {min_items: 1}
12601255
];
1261-
OnDuplicate on_duplicate = 2 [
1256+
string on_duplicate = 2 [
12621257
json_name = "on_duplicate",
1263-
(validate.rules).enum.defined_only = true,
12641258
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
1265-
example: "\"ON_DUPLICATE_ERROR\""
1266-
description: "If 'ON_DUPLICATE_ERROR', the API returns an error if an identical tuple already exists. If 'ON_DUPLICATE_IGNORE', identical writes are treated as no-ops (matching on user, relation, object, and RelationshipCondition)."
1259+
enum: [
1260+
"error", // Return an error if a tuple already exists.
1261+
"ignore" // Treat identical writes as no-ops if all attributes (including the RelationshipCondition) match.
1262+
]
1263+
default: "error"
1264+
example: "\"ignore\""
1265+
description: "On 'error' ( or unspecified ), the API returns an error if an identical tuple already exists. On 'ignore', identical writes are treated as no-ops (matching on user, relation, object, and RelationshipCondition)."
12671266
}
12681267
];
12691268
}
12701269

1271-
enum OnMissing {
1272-
ON_MISSING_UNSPECIFIED = 0; // If set to 'ON_MISSING_UNSPECIFIED' or not set, the API behaves as if it were set to 'ON_MISSING_ERROR'.
1273-
ON_MISSING_ERROR = 1; // Return an error if a tuple does not exist.
1274-
ON_MISSING_IGNORE = 2; // Do not return an error if a tuple does not exist.
1275-
}
1276-
12771270
message WriteRequestDeletes {
12781271
repeated TupleKeyWithoutCondition tuple_keys = 1 [
12791272
json_name = "tuple_keys",
12801273
(google.api.field_behavior) = REQUIRED,
12811274
(validate.rules).repeated.min_items = 1,
12821275
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {min_items: 1}
12831276
];
1284-
OnMissing on_missing = 2 [
1277+
string on_missing = 2 [
12851278
json_name = "on_missing",
1286-
(validate.rules).enum.defined_only = true,
12871279
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
1288-
example: "\"ON_MISSING_ERROR\""
1289-
description: "If 'ON_MISSING_ERROR', the API returns an error when deleting a tuple that does not exist. If 'ON_MISSING_IGNORE', deletes of non-existent tuples are treated as no-ops."
1280+
enum: [
1281+
"error", // Return an error if a tuple does not exist.
1282+
"ignore" // Do not return an error if a tuple does not exist.
1283+
]
1284+
default: "error"
1285+
example: "\"ignore\""
1286+
description: "On 'error', the API returns an error when deleting a tuple that does not exist. On 'ignore', deletes of non-existent tuples are treated as no-ops."
12901287
}
12911288
];
12921289
}

0 commit comments

Comments
 (0)