Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
1d18d63e
Commit
1d18d63e
authored
Dec 02, 2017
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change endpoint to avoid passing an ID
parent
a23fa7c8
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
36 deletions
+31
-36
doc/api/geo_nodes.md
doc/api/geo_nodes.md
+3
-3
lib/api/geo_nodes.rb
lib/api/geo_nodes.rb
+21
-26
spec/requests/api/geo_nodes_spec.rb
spec/requests/api/geo_nodes_spec.rb
+7
-7
No files found.
doc/api/geo_nodes.md
View file @
1d18d63e
...
...
@@ -140,11 +140,11 @@ Example response:
}
```
## Retrieve project sync failures ocurred on
a specific node (only available for the current node)
## Retrieve project sync failures ocurred on
the current node
```
GET /geo_nodes/
:id/
failures
GET /geo_nodes/failures
```
| Attribute | Type | Required | Description |
...
...
@@ -154,7 +154,7 @@ GET /geo_nodes/:id/failures
This endpoint uses
[
Pagination
](
README.md#pagination
)
.
```
bash
curl
--header
"PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK"
https://gitlab.example.com/api/v4/geo_nodes/
2/
failures
curl
--header
"PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK"
https://gitlab.example.com/api/v4/geo_nodes/failures
```
Example response:
...
...
lib/api/geo_nodes.rb
View file @
1d18d63e
...
...
@@ -33,6 +33,27 @@ module API
present
paginate
(
status
),
with:
GeoNodeStatusEntity
end
# Get project registry failures for the current Geo node
#
# Example request:
# GET /geo_nodes/failures
desc
'Get project registry failures for the current Geo node'
do
success
::
GeoProjectRegistryEntity
end
params
do
optional
:type
,
type:
String
,
values:
%w[wiki repository]
,
desc:
'Type of failure (repository/wiki)'
use
:pagination
end
get
'/failures'
do
geo_node
=
Gitlab
::
Geo
.
current_node
not_found
(
'Geo node not found'
)
unless
geo_node
project_registries
=
paginate
(
geo_node
.
filtered_project_registries
(
params
[
:type
]))
present
project_registries
,
with:
::
GeoProjectRegistryEntity
end
# Get all Geo node information
#
# Example request:
...
...
@@ -77,32 +98,6 @@ module API
present
status
,
with:
::
GeoNodeStatusEntity
end
# Get project registry failures for the current Geo node
#
# Example request:
# GET /geo_nodes/:id/failures
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
,
values:
%w[wiki repository]
,
desc:
'Type of failure (repository/wiki)'
use
:pagination
end
get
':id/failures'
do
unless
Gitlab
::
Geo
.
current_node
.
id
==
params
[
:id
]
forbidden!
(
'Geo node is not the current node.'
)
end
geo_node
=
Gitlab
::
Geo
.
current_node
not_found
(
'Geo node not found'
)
unless
geo_node
project_registries
=
paginate
(
geo_node
.
filtered_project_registries
(
params
[
:type
]))
present
project_registries
,
with:
::
GeoProjectRegistryEntity
end
end
end
end
spec/requests/api/geo_nodes_spec.rb
View file @
1d18d63e
...
...
@@ -87,7 +87,7 @@ describe API::GeoNodes, :geo, api: true do
end
end
describe
'GET /geo_nodes/
:id/
failures/:type'
do
describe
'GET /geo_nodes/failures/:type'
do
it
'fetches the current node failures'
do
create
(
:geo_project_registry
,
:sync_failed
)
create
(
:geo_project_registry
,
:sync_failed
)
...
...
@@ -95,7 +95,7 @@ describe API::GeoNodes, :geo, api: true do
stub_current_geo_node
(
secondary
)
expect
(
Gitlab
::
Geo
).
to
receive
(
:current_node
).
and_return
(
secondary
)
get
api
(
"/geo_nodes/
#{
secondary
.
id
}
/
failures"
,
admin
)
get
api
(
"/geo_nodes/failures"
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
match_response_schema
(
'geo_project_registry'
)
...
...
@@ -107,7 +107,7 @@ describe API::GeoNodes, :geo, api: true do
stub_current_geo_node
(
secondary
)
expect
(
Gitlab
::
Geo
).
to
receive
(
:current_node
).
and_return
(
secondary
)
get
api
(
"/geo_nodes/
#{
secondary
.
id
}
/
failures"
,
admin
)
get
api
(
"/geo_nodes/failures"
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
json_response
.
count
).
to
be_zero
...
...
@@ -121,7 +121,7 @@ describe API::GeoNodes, :geo, api: true do
stub_current_geo_node
(
secondary
)
expect
(
Gitlab
::
Geo
).
to
receive
(
:current_node
).
and_return
(
secondary
)
get
api
(
"/geo_nodes/
#{
secondary
.
id
}
/
failures?type=wiki"
,
admin
)
get
api
(
"/geo_nodes/failures?type=wiki"
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
json_response
.
count
).
to
eq
(
1
)
...
...
@@ -137,7 +137,7 @@ describe API::GeoNodes, :geo, api: true do
stub_current_geo_node
(
secondary
)
expect
(
Gitlab
::
Geo
).
to
receive
(
:current_node
).
and_return
(
secondary
)
get
api
(
"/geo_nodes/
#{
secondary
.
id
}
/
failures?type=repository"
,
admin
)
get
api
(
"/geo_nodes/failures?type=repository"
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
json_response
.
count
).
to
eq
(
1
)
...
...
@@ -149,14 +149,14 @@ describe API::GeoNodes, :geo, api: true do
it
'returns a bad request'
do
create
(
:geo_project_registry
,
:repository_sync_failed
)
get
api
(
"/geo_nodes/
#{
secondary
.
id
}
/
failures?type=nonexistent"
,
admin
)
get
api
(
"/geo_nodes/failures?type=nonexistent"
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
400
)
end
end
it
'denies access if not admin'
do
get
api
(
"/geo_nodes/
#{
secondary
.
id
}
/
failures"
,
user
)
get
api
(
"/geo_nodes/failures"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment