-
Notifications
You must be signed in to change notification settings - Fork 676
feat(api): add support for project feature flags and feature flag user lists #3366
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
Open
amimas
wants to merge
16
commits into
python-gitlab:main
Choose a base branch
from
amimas:issue-3350
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+958
−10
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
bfc0637
feat(api): add support for project feature flags
amimas 3e2385a
refactor(api): use JsonAttribute for feature flag strategies
amimas 9a9322d
feat(api): add support for project feature flag user lists
amimas 0915bfc
test(api): validate feature flag strategy and scope deletion
amimas 02e5535
feat(api): enable feature flag renaming via save()
amimas 07d98be
docs(api): add documentation for project feature flags
amimas 7e287d2
docs: clarify development feature flag documentation
amimas 522c25e
test(api): add unit tests for feature flags and types
amimas 8d21b07
fix(docs): correct title overline length
amimas 977ab5c
refactor(test): use shared project fixture in unit tests
amimas 7d93a4f
refactor(docs): update URL of GitLab API documentation
amimas e132683
refactor(test): do not overwrite fixture within test logic
amimas ba5b539
refactor(types): rename transform_in_post to transform_in_body and im…
amimas 39abc47
fix(cli): handle invalid JSON input in CLI options gracefully
amimas 21b980a
feat(cli): add support for renaming project feature flags
amimas 6726189
refactor: enhance request body validation in unit test and update method
amimas 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| ############################### | ||
| Project Feature Flag User Lists | ||
| ############################### | ||
|
|
||
| Reference | ||
| --------- | ||
|
|
||
| * v4 API: | ||
|
|
||
| + :class:`gitlab.v4.objects.ProjectFeatureFlagUserList` | ||
| + :class:`gitlab.v4.objects.ProjectFeatureFlagUserListManager` | ||
| + :attr:`gitlab.v4.objects.Project.feature_flags_user_lists` | ||
|
|
||
| * GitLab API: https://docs.gitlab.com/api/feature_flag_user_lists | ||
|
|
||
| Examples | ||
| -------- | ||
|
|
||
| List user lists:: | ||
|
|
||
| user_lists = project.feature_flags_user_lists.list() | ||
|
|
||
| Get a user list:: | ||
|
|
||
| user_list = project.feature_flags_user_lists.get(list_iid) | ||
|
|
||
| Create a user list:: | ||
|
|
||
| user_list = project.feature_flags_user_lists.create({ | ||
| 'name': 'my_user_list', | ||
| 'user_xids': 'user1,user2,user3' | ||
| }) | ||
|
|
||
| Update a user list:: | ||
|
|
||
| user_list.name = 'updated_list_name' | ||
| user_list.user_xids = 'user1,user2' | ||
| user_list.save() | ||
|
|
||
| Delete a user list:: | ||
|
|
||
| user_list.delete() | ||
|
|
||
| Search for a user list:: | ||
|
|
||
| user_lists = project.feature_flags_user_lists.list(search='my_list') | ||
|
|
||
| See also | ||
| -------- | ||
|
|
||
| * :doc:`project_feature_flags` |
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,63 @@ | ||
| ##################### | ||
| Project Feature Flags | ||
| ##################### | ||
|
|
||
| Reference | ||
| --------- | ||
|
|
||
| * v4 API: | ||
|
|
||
| + :class:`gitlab.v4.objects.ProjectFeatureFlag` | ||
| + :class:`gitlab.v4.objects.ProjectFeatureFlagManager` | ||
| + :attr:`gitlab.v4.objects.Project.feature_flags` | ||
|
|
||
| * GitLab API: https://docs.gitlab.com/api/feature_flags | ||
|
|
||
| Examples | ||
| -------- | ||
|
|
||
| List feature flags:: | ||
|
|
||
| flags = project.feature_flags.list() | ||
|
|
||
| Get a feature flag:: | ||
|
|
||
| flag = project.feature_flags.get('my_feature_flag') | ||
|
|
||
| Create a feature flag:: | ||
|
|
||
| flag = project.feature_flags.create({'name': 'my_feature_flag', 'version': 'new_version_flag'}) | ||
|
|
||
| Create a feature flag with strategies:: | ||
|
|
||
| flag = project.feature_flags.create({ | ||
| 'name': 'my_complex_flag', | ||
| 'version': 'new_version_flag', | ||
| 'strategies': [{ | ||
| 'name': 'userWithId', | ||
| 'parameters': {'userIds': 'user1,user2'} | ||
| }] | ||
| }) | ||
|
|
||
| Update a feature flag:: | ||
|
|
||
| flag.description = 'Updated description' | ||
| flag.save() | ||
|
|
||
| Rename a feature flag:: | ||
|
|
||
| # You can rename a flag by changing its name attribute and calling save() | ||
| flag.name = 'new_flag_name' | ||
| flag.save() | ||
|
|
||
| # Alternatively, you can use the manager's update method | ||
| project.feature_flags.update('old_flag_name', {'name': 'new_flag_name'}) | ||
|
|
||
| Delete a feature flag:: | ||
|
|
||
| flag.delete() | ||
|
|
||
| See also | ||
| -------- | ||
|
|
||
| * :doc:`project_feature_flag_user_lists` | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| """ | ||
| GitLab API: | ||
| https://docs.gitlab.com/api/feature_flag_user_lists | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from gitlab import types | ||
| from gitlab.base import RESTObject | ||
| from gitlab.mixins import CRUDMixin, ObjectDeleteMixin, SaveMixin | ||
| from gitlab.types import RequiredOptional | ||
|
|
||
| __all__ = ["ProjectFeatureFlagUserList", "ProjectFeatureFlagUserListManager"] | ||
|
|
||
|
|
||
| class ProjectFeatureFlagUserList(SaveMixin, ObjectDeleteMixin, RESTObject): | ||
| _id_attr = "iid" | ||
|
|
||
|
|
||
| class ProjectFeatureFlagUserListManager(CRUDMixin[ProjectFeatureFlagUserList]): | ||
| _path = "/projects/{project_id}/feature_flags_user_lists" | ||
| _obj_cls = ProjectFeatureFlagUserList | ||
| _from_parent_attrs = {"project_id": "id"} | ||
| _create_attrs = RequiredOptional(required=("name", "user_xids")) | ||
| _update_attrs = RequiredOptional(optional=("name", "user_xids")) | ||
| _list_filters = ("search",) | ||
| _types = {"user_xids": types.CommaSeparatedStringAttribute} |
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.