-
Notifications
You must be signed in to change notification settings - Fork 375
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add a task for writing (edge) identity overrides (#3127)
- Loading branch information
Showing
24 changed files
with
872 additions
and
136 deletions.
There are no files selected for viewing
This file contains 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 was deleted.
Oops, something went wrong.
This file contains 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 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 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,15 @@ | ||
from typing import Any, Literal, TypedDict | ||
|
||
from typing_extensions import NotRequired | ||
|
||
ChangeType = Literal["+", "-", "~"] | ||
|
||
|
||
class FeatureStateChangeDetails(TypedDict): | ||
change_type: ChangeType | ||
old: NotRequired[dict[str, Any]] | ||
new: NotRequired[dict[str, Any]] | ||
|
||
|
||
class IdentityChangeset(TypedDict): | ||
feature_overrides: dict[str, FeatureStateChangeDetails] |
This file contains 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,40 @@ | ||
import typing | ||
|
||
from flag_engine.features.models import FeatureStateModel | ||
|
||
if typing.TYPE_CHECKING: | ||
from edge_api.identities.types import ChangeType, FeatureStateChangeDetails | ||
|
||
|
||
def generate_change_dict( | ||
change_type: "ChangeType", | ||
identity_id: int | str | None, | ||
new: FeatureStateModel | None = None, | ||
old: FeatureStateModel | None = None, | ||
) -> "FeatureStateChangeDetails": | ||
if not (new or old): | ||
raise ValueError("Must provide one of 'new' or 'old'") | ||
|
||
change_dict = {"change_type": change_type} | ||
if new: | ||
change_dict["new"] = _get_overridden_feature_state_dict( | ||
identity_id=identity_id, | ||
feature_state=new, | ||
) | ||
if old: | ||
change_dict["old"] = _get_overridden_feature_state_dict( | ||
identity_id=identity_id, | ||
feature_state=old, | ||
) | ||
|
||
return change_dict | ||
|
||
|
||
def _get_overridden_feature_state_dict( | ||
identity_id: int | str | None, | ||
feature_state: FeatureStateModel, | ||
) -> dict[str, typing.Any]: | ||
return { | ||
**feature_state.dict(), | ||
"feature_state_value": feature_state.get_value(identity_id), | ||
} |
This file contains 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,5 @@ | ||
ENVIRONMENTS_V2_PARTITION_KEY = "environment_id" | ||
ENVIRONMENTS_V2_SORT_KEY = "document_key" | ||
|
||
ENVIRONMENTS_V2_SECONDARY_INDEX = "environment_api_key-index" | ||
ENVIRONMENTS_V2_SECONDARY_INDEX_PARTITION_KEY = "environment_api_key" |
Oops, something went wrong.
2a9cd7c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
flagsmith-frontend-preview – ./frontend
flagsmith-frontend-production-native.vercel.app
flagsmith-frontend-preview-flagsmith.vercel.app
flagsmith-frontend-preview-git-main-flagsmith.vercel.app
2a9cd7c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
docs – ./docs
docs-flagsmith.vercel.app
docs-git-main-flagsmith.vercel.app
docs.flagsmith.com
docs.bullet-train.io
2a9cd7c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
flagsmith-frontend-staging – ./frontend
flagsmith-frontend-staging-git-main-flagsmith.vercel.app
flagsmith-staging-frontend.vercel.app
flagsmith-frontend-staging-flagsmith.vercel.app
staging.flagsmith.com