Protected packages: REST API DELETE package protection rules
requested to merge gitlab-community/gitlab:457512-nwittstruck-protected-packages-rest-api-delete-packages-protection-rules into master
-
Please check this box if this contribution uses AI-generated content (including content generated by GitLab Duo features) as outlined in the GitLab DCO & CLA
What does this MR do and why?
Protected packages: REST API DELETE package protection rules
Adds a DELETE route to the REST API to delete package protection rules for a given rule id.
This is part of #457512 (closed) and still behind a feature flag.
Database Queries
The following query will be executed when an item is deleted:
Packages::Protection::Rule Destroy (0.7ms) DELETE FROM "packages_protection_rules" WHERE "packages_protection_rules"."id" = 3
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
MR Checklist ( @nwittstruck)
-
Changelog entry added, if necessary -
Documentation created/updated via this MR -
Documentation reviewed by technical writer or follow-up review issue created -
Tests added for this feature/bug -
Tested in all supported browsers -
Conforms to the code review guidelines -
Conforms to the merge request performance guidelines -
Conforms to the style guides -
Conforms to the javascript style guides -
Conforms to the database guides
How to set up and validate locally
- Enable feature flag via
rails c
Feature.enable(:packages_protected_packages)
- Create a package protection rule that we will delete in the next step
Packages::Protection::Rule.create(
project: Project.find(7),
package_type: :npm,
push_protected_up_to_access_level: Gitlab::Access::DEVELOPER,
package_name_pattern: "@gitlab-org/npm-package-new-enum-*"
)
- Find the global id of the package protection rule that we want to delete
Packages::Protection::Rule.where(package_name_pattern: "@gitlab-org/npm-package-new-enum-*").first.id
=> 32
- Now, you should be able to send mutation requests via the REST api
curl -k --request DELETE \
--url https://gdk.test:3443/api/v4/projects/7/packages/protection/rules/32 \
--header 'Authorization: Bearer ypCa3Dzb23o5nvsixwPA'
Edited by Nicholas Wittstruck