Commit 83d9d9b4 authored by James Lopez's avatar James Lopez

add API and spec

parent e31ff0ef
......@@ -77,6 +77,32 @@ module API
present status, with: ::GeoNodeStatusEntity
end
# Get project registry failures for the current Geo node
#
# Example request:
# GET /geo_nodes/:id/failures/:type
desc 'Get project registry failures for the current Geo node' do
success Entities::GeoNode
end
params do
requires :id, type: Integer, desc: 'The ID of the node'
optional :type, type: String, desc: 'Type of failure (repository/wiki)'
use :pagination
end
get ':id/failures/:type' do
unless Gitlab::Geo.current_node.id == params[:id]
forbidden!('Geo node is not the current node.')
end
geo_node = GeoNode.find(params[:id])
not_found('Geo node not found') unless geo_node
project_registries = geo_node.project_registries
present project_registries, with: ::ProjectRegistryEntity
end
end
end
end
......@@ -86,4 +86,25 @@ describe API::GeoNodes, :geo, api: true do
expect(response.status).to eq 403
end
end
describe 'GET /geo_nodes/:id/failures/:type' do
it 'fetches the current node failures' do
create(:geo_project_registry, :sync_failed)
create(:geo_project_registry, :sync_failed)
stub_current_geo_node(secondary)
expect(GeoNode).to receive(:find).and_return(secondary)
get api("/geo_nodes/#{secondary.id}/failures", admin)
expect(response.status).to eq 200
expect(response.body).to eq('')
end
it 'denies access if not admin' do
get api('/geo_nodes', user)
expect(response.failures).to eq 403
end
end
end
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