Protected Branches API - Examples for updating protected branch isn't too clear
Link the doc and describe what is wrong with it.
https://docs.gitlab.com/ee/api/protected_branches.html#update-a-protected-branch
I'm unsure how to use this part of the API. I'm able to get the list of protected branches:
[
[0] {
"id" => 1113,
"name" => "master",
"push_access_levels" => [
[0] {
"id" => 1293,
"access_level" => 0,
"access_level_description" => "No one",
"user_id" => nil,
"group_id" => nil
}
],
"merge_access_levels" => [
[0] {
"id" => 1302,
"access_level" => 40,
"access_level_description" => "Maintainers",
"user_id" => nil,
"group_id" => nil
}
],
"allow_force_push" => false,
"unprotect_access_levels" => [],
"code_owner_approval_required" => false
}
]
I'm trying to set the 'merge_access_levels' value to 'No one' (which is access_level 0 as far as I can see), but when I send in the request via Ruby's HTTParty:
ENDPOINT_ROOT = "https://<private_gitlab_domain>/api/v4/projects/<project_id>/protected_branches/master"
API_TOKEN = ENV['GITLAB_API_TOKEN']
OPTIONS = {
'Content-Type' => 'application/json',
'PRIVATE-TOKEN' => API_TOKEN
}.freeze
data = {
merge_access_levels: [
{
id: 1302,
access_level: 0
}
]
}
HTTParty.put(ENDPOINT_ROOT, query: data, headers: OPTIONS)
I feel like this is a rather simple case, and the docs aren't too clear on how to modify existing rules. Some updates to the page to clear that up would be awesome.