Loading
Add write API to gitlab-policy-store gem
What does this MR do and why?
Extend the gitlab-policy-store gem with write-side operations:
The policy repository contract now defines:
#create(attributes)- creates and returns a Policy#find(id)- retrieves a Policy or raises NotFound#delete(id)- removes a Policy or raises NotFound#list(organization_id:)- returns policies for an org
Part 2 of the Policy Store v2 MR split (see &22937)
References
Related to #606968
How to set up and validate locally
Example usage in Rails console
# Create a policy
policy = Gitlab::PolicyStore.create(
organization_id: 1,
name: "My policy",
trigger_id: "merge_request"
)
# Find by ID
Gitlab::PolicyStore.find(policy.id)
# List policies for an organization
Gitlab::PolicyStore.list(organization_id: 1)
# Delete a policy
Gitlab::PolicyStore.delete(policy.id)MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Edited by Andy Schoenen