-
Notifications
You must be signed in to change notification settings - Fork 63
feat(python-sdk): add support for write conflict settings #643
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
a1f451d
feat: generator changes for idempotency py sdk
SoulPancake 07a87d8
fix: default args for on missing and on deletes test fix
SoulPancake 8014c8f
feat: remove setUp script for test
SoulPancake 050476d
fix: lint issues remove unused imports
SoulPancake a910647
feat: add README and changelog changes
SoulPancake 3b64c2e
fix: ruff lint error
SoulPancake 8395a2a
fix: revert mf change
SoulPancake 1385edb
fix: use correct open API ref
SoulPancake 9d4ed8b
feat: readme and changelog changes reverse sync from sdk
SoulPancake ab6718a
feat: client file reverse sync
SoulPancake ceb366c
fix: client tests mustache template reverse sync
SoulPancake b82b67c
feat: apply committable copilot suggestions
SoulPancake 410dd85
fix: revert changelog issue #
SoulPancake e444a15
feat: use packageName template instead of HC
SoulPancake 99d9301
feat: address copilot comment, backward compatible
SoulPancake File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
config/clients/python/template/src/client/models/write_conflict_opts.py.mustache
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| {{>partial_header}} | ||
|
|
||
| from enum import Enum | ||
|
|
||
|
|
||
| class ClientWriteRequestOnDuplicateWrites(str, Enum): | ||
| ERROR = "error" | ||
| IGNORE = "ignore" | ||
|
|
||
|
|
||
| class ClientWriteRequestOnMissingDeletes(str, Enum): | ||
| ERROR = "error" | ||
| IGNORE = "ignore" | ||
|
|
||
|
|
||
| class ConflictOptions: | ||
| """ | ||
| OpenFGA client write conflict options | ||
| """ | ||
|
|
||
| def __init__( | ||
| self, | ||
| on_duplicate_writes: ClientWriteRequestOnDuplicateWrites | None = None, | ||
| on_missing_deletes: ClientWriteRequestOnMissingDeletes | None = None, | ||
| ) -> None: | ||
| self._on_duplicate_writes = on_duplicate_writes | ||
| self._on_missing_deletes = on_missing_deletes | ||
|
|
||
| @property | ||
| def on_duplicate_writes(self) -> ClientWriteRequestOnDuplicateWrites | None: | ||
| """ | ||
| Return on_duplicate_writes | ||
| """ | ||
| return self._on_duplicate_writes | ||
|
|
||
| @on_duplicate_writes.setter | ||
| def on_duplicate_writes( | ||
| self, | ||
| value: ClientWriteRequestOnDuplicateWrites | None, | ||
| ) -> None: | ||
| """ | ||
| Set on_duplicate_writes | ||
| """ | ||
| self._on_duplicate_writes = value | ||
|
|
||
| @property | ||
| def on_missing_deletes(self) -> ClientWriteRequestOnMissingDeletes | None: | ||
| """ | ||
| Return on_missing_deletes | ||
| """ | ||
| return self._on_missing_deletes | ||
|
|
||
| @on_missing_deletes.setter | ||
| def on_missing_deletes( | ||
| self, | ||
| value: ClientWriteRequestOnMissingDeletes | None, | ||
| ) -> None: | ||
| """ | ||
| Set on_missing_deletes | ||
| """ | ||
| self._on_missing_deletes = value |
71 changes: 71 additions & 0 deletions
71
config/clients/python/template/src/client/models/write_options.py.mustache
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| {{>partial_header}} | ||
|
|
||
| from {{packageName}}.client.models.write_conflict_opts import ConflictOptions | ||
| from {{packageName}}.client.models.write_transaction_opts import WriteTransactionOpts | ||
|
|
||
|
|
||
| class ClientWriteOptions: | ||
| """ | ||
| OpenFGA client write options | ||
| """ | ||
|
|
||
| def __init__( | ||
| self, | ||
| authorization_model_id: str | None = None, | ||
| transaction: WriteTransactionOpts | None = None, | ||
| conflict: ConflictOptions | None = None, | ||
| ) -> None: | ||
| self._authorization_model_id = authorization_model_id | ||
| self._transaction = transaction | ||
| self._conflict = conflict | ||
|
|
||
| @property | ||
| def authorization_model_id(self) -> str | None: | ||
| """ | ||
| Return authorization_model_id | ||
| """ | ||
| return self._authorization_model_id | ||
|
|
||
| @authorization_model_id.setter | ||
| def authorization_model_id( | ||
| self, | ||
| value: str | None, | ||
| ) -> None: | ||
| """ | ||
| Set authorization_model_id | ||
| """ | ||
| self._authorization_model_id = value | ||
|
|
||
| @property | ||
| def transaction(self) -> WriteTransactionOpts | None: | ||
| """ | ||
| Return transaction | ||
| """ | ||
| return self._transaction | ||
|
|
||
| @transaction.setter | ||
| def transaction( | ||
| self, | ||
| value: WriteTransactionOpts | None, | ||
| ) -> None: | ||
| """ | ||
| Set transaction | ||
| """ | ||
| self._transaction = value | ||
|
|
||
| @property | ||
| def conflict(self) -> ConflictOptions | None: | ||
| """ | ||
| Return conflict | ||
| """ | ||
| return self._conflict | ||
|
|
||
| @conflict.setter | ||
| def conflict( | ||
| self, | ||
| value: ConflictOptions | None, | ||
| ) -> None: | ||
| """ | ||
| Set conflict | ||
| """ | ||
| self._conflict = value |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.