@@ -750,78 +750,9 @@ response = await fga_client.write(body, options)
750750
751751###### Conflict Options for Write Operations
752752
753- With OpenFGA [ v1.10.0] ( https://github.com/openfga/openfga/releases/tag/v1.10.0 ) and later, support for write conflict options to handle duplicate writes and missing deletes gracefully has been added .
753+ OpenFGA v1.10.0+ supports conflict options for write operations to handle duplicate writes and missing deletes gracefully.
754754
755- ** Example: Ignoring duplicate writes**
756-
757- ``` python
758- # from openfga_sdk import OpenFgaClient
759- # from openfga_sdk.client.models import ClientTuple, ClientWriteRequest
760- # from openfga_sdk.client.models.write_conflict_opts import (
761- # ClientWriteRequestOnDuplicateWrites,
762- # ConflictOptions,
763- # )
764-
765- # Initialize the fga_client
766- # fga_client = OpenFgaClient(configuration)
767-
768- options = {
769- " authorization_model_id" : " 01GXSA8YR785C4FYS3C0RTG7B1" ,
770- " conflict" : ConflictOptions(
771- on_duplicate_writes = ClientWriteRequestOnDuplicateWrites.IGNORE , // or ERROR to retain default behaviour
772- on_missing_deletes = ClientWriteRequestOnMissingDeletes.IGNORE // or ERROR to retain default behaviour
773- )
774- }
775-
776- body = ClientWriteRequest(
777- writes = [
778- ClientTuple(
779- user = " user:81684243-9356-4421-8fbf-a4f8d36aa31b" ,
780- relation = " viewer" ,
781- object = " document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a" ,
782- ),
783- ],
784- )
785-
786- # This will succeed even if the tuple already exists
787- response = await fga_client.write(body, options)
788- ```
789-
790- ** Example: Ignoring missing deletes**
791-
792- ``` python
793- # from openfga_sdk import OpenFgaClient
794- # from openfga_sdk.client.models import ClientTuple, ClientWriteRequest
795- # from openfga_sdk.client.models.write_conflict_opts import (
796- # ClientWriteRequestOnMissingDeletes,
797- # ConflictOptions,
798- # )
799-
800- # Initialize the fga_client
801- # fga_client = OpenFgaClient(configuration)
802-
803- options = {
804- " authorization_model_id" : " 01GXSA8YR785C4FYS3C0RTG7B1" ,
805- " conflict" : ConflictOptions(
806- on_missing_deletes = ClientWriteRequestOnMissingDeletes.IGNORE
807- )
808- }
809-
810- body = ClientWriteRequest(
811- deletes = [
812- ClientTuple(
813- user = " user:81684243-9356-4421-8fbf-a4f8d36aa31b" ,
814- relation = " writer" ,
815- object = " document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a" ,
816- ),
817- ],
818- )
819-
820- # This will succeed even if the tuple doesn't exist
821- response = await fga_client.write(body, options)
822- ```
823-
824- ** Example: Using both conflict options together**
755+ ** Example: Ignore duplicate writes and missing deletes**
825756
826757``` python
827758# from openfga_sdk import OpenFgaClient
@@ -832,14 +763,11 @@ response = await fga_client.write(body, options)
832763# ConflictOptions,
833764# )
834765
835- # Initialize the fga_client
836- # fga_client = OpenFgaClient(configuration)
837-
838766options = {
839767 " authorization_model_id" : " 01GXSA8YR785C4FYS3C0RTG7B1" ,
840768 " conflict" : ConflictOptions(
841- on_duplicate_writes = ClientWriteRequestOnDuplicateWrites.IGNORE ,
842- on_missing_deletes = ClientWriteRequestOnMissingDeletes.IGNORE ,
769+ on_duplicate_writes = ClientWriteRequestOnDuplicateWrites.IGNORE , # Available options: ERROR, IGNORE
770+ on_missing_deletes = ClientWriteRequestOnMissingDeletes.IGNORE , # Available options: ERROR, IGNORE
843771 )
844772}
845773
@@ -860,11 +788,10 @@ body = ClientWriteRequest(
860788 ],
861789)
862790
863- # Both operations will succeed regardless of tuple existence
864791response = await fga_client.write(body, options)
865792```
866793
867- For a complete working example, see the [ conflict-options example ] ( https://github.com/openfga/python-sdk/tree/main/example/conflict-options ) .
794+
868795
869796#### Relationship Queries
870797
0 commit comments