MCPcopy Index your code
hub / github.com/Flagsmith/flagsmith / EdgeIdentity

Class EdgeIdentity

api/edge_api/identities/models.py:29–314  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27
28
29class EdgeIdentity:
30 dynamo_wrapper = DynamoIdentityWrapper()
31
32 def __init__(self, engine_identity_model: IdentityModel):
33 self.engine_identity_model = engine_identity_model
34 self._reset_initial_state() # type: ignore[no-untyped-call]
35
36 @classmethod
37 def from_identity_document(cls, identity_document: dict) -> "EdgeIdentity": # type: ignore[type-arg]
38 return EdgeIdentity(IdentityModel.model_validate(identity_document))
39
40 @property
41 def environment_api_key(self) -> str:
42 return self.engine_identity_model.environment_api_key
43
44 @property
45 def feature_overrides(self) -> IdentityFeaturesList:
46 return self.engine_identity_model.identity_features
47
48 @property
49 def id(self) -> typing.Union[int, str]:
50 return self.engine_identity_model.django_id or str(
51 self.engine_identity_model.identity_uuid
52 )
53
54 @property
55 def identifier(self) -> str:
56 return self.engine_identity_model.identifier
57
58 @property
59 def identity_uuid(self) -> str:
60 return str(self.engine_identity_model.identity_uuid)
61
62 @property
63 def environment(self) -> Environment:
64 environment: Environment = Environment.objects.get(
65 api_key=self.environment_api_key
66 )
67 return environment
68
69 @property
70 def dashboard_alias(self) -> str | None:
71 return self.engine_identity_model.dashboard_alias
72
73 @dashboard_alias.setter
74 def dashboard_alias(self, dashboard_alias: str) -> None:
75 self.engine_identity_model.dashboard_alias = dashboard_alias
76
77 def add_feature_override(self, feature_state: FeatureStateModel) -> None:
78 self.engine_identity_model.identity_features.append(feature_state)
79
80 def get_all_feature_states(
81 self,
82 ) -> typing.Tuple[
83 typing.List[typing.Union[FeatureState, FeatureStateModel]], typing.Set[str]
84 ]:
85 """
86 Get all feature states for a flag engine identity model. The list returned by

Calls 1