Skip to content

Protected packages: REST API PATCH package protection rules

  • 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 PATCH package protection rules

Adds a PATCH route to the REST API to update a package protection rule for a given rule id.

This MR is part of #457512 and still behind a feature flag.

🛠 with at Siemens

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)

How to set up and validate locally

  1. Enable feature flag via rails c
Feature.enable(:packages_protected_packages)
  1. Create a package protection rule that we will patch 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-*"
)
  1. Find the global id of the package protection rule that we want to patch
Packages::Protection::Rule.where(package_name_pattern: "@gitlab-org/npm-package-new-enum-*").first.id
=> 32
  1. Now, you should be able to send a patch request 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' \
  --data '{
       "package_name_pattern": "new-package-name-pattern-*"
    }'
Edited by Nicholas

Merge request reports