Commit b3f779af authored by Toon Claes's avatar Toon Claes

Make it possible to edit Geo primary through API

Upon a customer request make it possible to edit the Geo primary node
through the API.

Technically there is no reason to disallow it, since admins are also
able to modify nodes on the Admin panel.

Closes https://gitlab.com/gitlab-org/gitlab-ee/issues/9454
parent 6706a00c
......@@ -70,7 +70,7 @@ Example response:
## Edit a Geo node
Updates an existing Geo secondary node. The primary node cannot be edited.
Updates settings of an existing Geo node.
_This can only be run against a primary Geo node._
......@@ -92,8 +92,8 @@ Example response:
```json
{
"id": 1,
"url": "https://primary.example.com/",
"primary": true,
"url": "https://secondary.example.com/",
"primary": false,
"enabled": true,
"current": true,
"files_max_capacity": 10,
......
---
title: Make it possible to edit Geo primary through API
merge_request: 9328
author:
type: changed
......@@ -138,7 +138,7 @@ module API
#
# Example request:
# PUT /geo_nodes/:id
desc 'Edit an existing Geo secondary node' do
desc 'Update an existing Geo node' do
success EE::API::Entities::GeoNode
end
params do
......@@ -153,9 +153,7 @@ module API
update_params = declared_params(include_missing: false)
if geo_node.primary?
forbidden!('Primary node cannot be edited')
elsif geo_node.update(update_params)
if geo_node.update(update_params)
present geo_node, with: EE::API::Entities::GeoNode
else
render_validation_error!(geo_node)
......
......@@ -223,6 +223,18 @@ describe API::GeoNodes, :geo, :prometheus, api: true do
expect(response).to match_response_schema('public_api/v4/geo_node', dir: 'ee')
expect(json_response).to include(params)
end
it 'can update primary' do
params = {
url: 'https://updated.example.com/'
}.stringify_keys
put api("/geo_nodes/#{primary.id}", admin), params: params
expect(response).to have_gitlab_http_status(200)
expect(response).to match_response_schema('public_api/v4/geo_node', dir: 'ee')
expect(json_response).to include(params)
end
end
describe 'DELETE /geo_nodes/:id' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment