-
Notifications
You must be signed in to change notification settings - Fork 2
feat(schemas): Add SDK API request and response schemas #155
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #155 +/- ##
==========================================
+ Coverage 95.48% 95.67% +0.19%
==========================================
Files 83 85 +2
Lines 2767 2891 +124
==========================================
+ Hits 2642 2766 +124
Misses 125 125 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
b9c7f52 to
6921024
Compare
emyller
left a comment
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.
Added a few edit suggestions. None blocking.
| priority: int | None | ||
| """The priority of this segment feature override. Lower numbers indicate stronger priority. If null or not set, the weakest priority is assumed.""" |
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.
👌
| property_: str | ||
| """The property (context key) this condition applies to. May be `None` for the `PERCENTAGE_SPLIT` operator. | ||
|
|
||
| Named `property_` for legacy reasons. | ||
| """ |
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.
Maybe worth introducing a new attribute context_key and have property_ aliasing to it for backwards compatibility?
|
|
||
|
|
||
| class Segment(TypedDict): | ||
| """Represents a Flagsmith segment. Carries rules, feature overrides, and segment rules.""" |
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.
| """Represents a Flagsmith segment. Carries rules, feature overrides, and segment rules.""" | |
| """Represents a dynamic group of identities matching the set of `rules`, which will be applied all overrides from `feature_states`.""" |
|
|
||
|
|
||
| class Project(TypedDict): | ||
| """Represents data about a Flagsmith project. For SDKs, this is mainly used to convey segment data.""" |
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.
| """Represents data about a Flagsmith project. For SDKs, this is mainly used to convey segment data.""" | |
| """Represents a Flagsmith project. For SDKs, this is mainly used to convey segment data.""" |
|
|
||
|
|
||
| class MultivariateFeatureStateValue(TypedDict): | ||
| """Represents a multivariate feature state value.""" |
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.
| """Represents a multivariate feature state value.""" | |
| """Represents a feature override that will apply to identities falling into the specified percentage of matched identities.""" |
| mv_fs_value_uuid: UUIDStr | None | ||
| """The UUID for this multivariate feature state value. Should be used for multivariate bucketing if `id` is null.""" | ||
| percentage_allocation: float | ||
| """The percentage allocation for this multivariate feature state value. Should be between or equal to 0 and 100.""" |
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.
| """The percentage allocation for this multivariate feature state value. Should be between or equal to 0 and 100.""" | |
| """The percentage allocation for this multivariate feature state value. Should be between or equal to 0 and 100; total percentage allocation of grouped `MultivariateFeatureStateValue` must not exceed 100.""" |
| class MultivariateFeatureOption(TypedDict): | ||
| """Represents a single multivariate feature option in the Flagsmith UI.""" | ||
|
|
||
| value: str | ||
| """The feature state value that should be served when this option's parent multivariate feature state is selected by the engine.""" |
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.
This is out of scope, but is worth a note: I think this entity makes no sense in the API. I understand this represents the data model, but it also makes the API schema slightly harder to grasp as it adds hierarchy with no value.
|
|
||
|
|
||
| class FeatureState(TypedDict): | ||
| """Used to define the state of a feature for an environment, segment overrides, and identity overrides.""" |
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.
| """Used to define the state of a feature for an environment, segment overrides, and identity overrides.""" | |
| """A feature override for an environment, a segment, or an identity.""" |
|
|
||
|
|
||
| class SegmentRule(TypedDict): | ||
| """Represents a rule within a segment used by Flagsmith engine.""" |
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.
| """Represents a rule within a segment used by Flagsmith engine.""" | |
| """Represents a group of logic conditions to match identities with; root segment rules may contain sub rules.""" |
Contributes to Flagsmith/flagsmith#6341.
In this PR, we add types representing the SDK API request and response bodies to be used as
The types are accompanied by docstrings carrying user-facing API documentation.