feat(api): add support for project feature flags and feature flag user lists#3366
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3366 +/- ##
=======================================
Coverage 95.75% 95.75%
=======================================
Files 98 100 +2
Lines 6054 6125 +71
=======================================
+ Hits 5797 5865 +68
- Misses 257 260 +3
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR adds support for managing Project Feature Flags and Feature Flag User Lists in python-gitlab, enabling users to interact with the GitLab Feature Flags API and Feature Flag User Lists API via both the Python API client and CLI.
Changes:
- Adds two new API object files (
feature_flags.pyandfeature_flag_user_lists.py) with customsave()logic inProjectFeatureFlagto support renaming via the original name in the URL - Introduces two new
GitlabAttributetypes:JsonAttribute(for parsing/sending JSON from the CLI) andCommaSeparatedStringAttribute(for transforming lists to CSV strings in POST/PUT bodies), plus atransform_in_posthook inutils._transform_types - Adds unit tests for the new attribute types and renaming logic, functional API tests, functional CLI tests, and updated/new documentation pages
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
gitlab/v4/objects/feature_flags.py |
New ProjectFeatureFlag and ProjectFeatureFlagManager with custom save/rename logic |
gitlab/v4/objects/feature_flag_user_lists.py |
New ProjectFeatureFlagUserList and ProjectFeatureFlagUserListManager |
gitlab/v4/objects/__init__.py |
Adds exports for the two new object modules |
gitlab/v4/objects/projects.py |
Attaches the two new managers to Project |
gitlab/types.py |
New JsonAttribute and CommaSeparatedStringAttribute types |
gitlab/utils.py |
Extended _transform_types with transform_in_post support |
tests/unit/test_types.py |
Unit tests for the two new attribute types |
tests/unit/objects/test_project_feature_flags.py |
Unit test for rename save behavior |
tests/unit/objects/test_project_feature_flag_user_lists.py |
Unit test for list→CSV transformation in POST body |
tests/functional/api/test_project_feature_flags.py |
Functional API tests (CRUD + rename + strategy/scope deletion) |
tests/functional/api/test_project_feature_flag_user_lists.py |
Functional API tests (CRUD + search) |
tests/functional/cli/test_cli_project_feature_flags.py |
Functional CLI tests (CRUD + strategy creation) |
tests/functional/cli/test_cli_project_feature_flag_user_lists.py |
Functional CLI tests (CRUD) |
docs/gl_objects/project_feature_flags.rst |
New documentation page for feature flags |
docs/gl_objects/project_feature_flag_user_lists.rst |
New documentation page for user lists |
docs/gl_objects/gitlab_features.rst |
Renamed/clarified admin-only GitLab dev features doc |
docs/gl_objects/projects.rst |
Added references to the two new documentation pages |
docs/api-objects.rst |
Updated ToC to reference renamed and new docs |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
|
/rerun-workflow "Test / functional (cli_func_v4)" |
|
/rerun-workflow "Test / functional (api_func_v4)" |
2adc015 to
977ab5c
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
JohnVillalovos
left a comment
There was a problem hiding this comment.
@amimas Thanks for the PR!
I left some comments/questions.
|
@JohnVillalovos - Thanks for reviewing this PR. I believe I've addressed all the feedbacks so far. Please take a look when you get a chance. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
docs/gl_objects/gitlab_features.rst:3
- The overline/underline for the RST title is shorter than the title text (32
#vs 33 characters), which can cause Sphinx/reStructuredText formatting warnings or misrendering. Extend the delimiter lines so they are at least as long as the title.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 18 out of 18 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Thank you @JohnVillalovos . Yes, please do squash & merge. Individual commits from this feature branch wouldn't be relevant in the |
6726189 to
d320a40
Compare
…r lists Add new API objects for managing project feature flags and feature flag user lists, including CRUD operations, CLI support, and renaming via save(). Introduce JsonAttribute type for handling JSON fields in request bodies (e.g., feature flag strategies). Closes python-gitlab#3350
d320a40 to
3b1293d
Compare
Changes
This change introduces support for managing Project Feature Flags and Feature Flag User Lists via the API and CLI.
It adds the
ProjectFeatureFlagandProjectFeatureFlagUserListobjects and their corresponding managers, which are exposed on theProjectobject asproject.feature_flagsandproject.feature_flags_user_lists.To support the specific data formats required by these GitLab APIs, this change also introduces:
JsonAttribute: A new attribute type to handle the strategies field, which is sent as a JSON object.CommaSeparatedStringAttribute: A new attribute type to handle the user_xids field, which is sent as a comma-separated string.Additionally, a custom
save()method has been implemented forProjectFeatureFlagto correctly handle renaming, as the flag's name is also its unique identifier.The implementation includes:
Documentation and testing
Please consider whether this PR needs documentation and tests. This is not required, but highly appreciated:
Documentation updates:
features.rsttogitlab_features.rstand updated its content to clearly distinguish that this API/feature is for admin-only GitLab Development Feature Flags - not for project-level feature flags.References:
Support for following API is being included in this PR
Documentation changed/clarified related to following existing feature in python-gitlab
closes #3350