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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
81ced6f5
Commit
81ced6f5
authored
Feb 02, 2016
by
Tomasz Maczukin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split `/runners` entrypoint to `/runners` and `/runners/all`
parent
b56ee397
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
108 additions
and
22 deletions
+108
-22
doc/api/runners.md
doc/api/runners.md
+53
-2
lib/api/runners.rb
lib/api/runners.rb
+12
-9
spec/requests/api/runners_spec.rb
spec/requests/api/runners_spec.rb
+43
-11
No files found.
doc/api/runners.md
View file @
81ced6f5
# Runners API
# Runners API
## List runners
## List
owned
runners
Get a list of
runners
.
Get a list of
specific runners available for user
.
```
```
GET /runners
GET /runners
...
@@ -37,6 +37,57 @@ Example response:
...
@@ -37,6 +37,57 @@ Example response:
]
]
```
```
## List all runners
Get a list of all runners (specific and shared). Access restricted to users with
`admin`
privileges.
```
GET /runners/all
```
| Attribute | Type | Required | Description |
|-----------|---------|----------|---------------------|
|
`scope`
| string | no | The scope of runners to show, one of:
`specific`
,
`shared`
,
`active`
,
`paused`
,
`online`
; showing all runners if none provided |
```
curl -H "PRIVATE_TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/runners/all"
```
Example response:
```
json
[
{
"active"
:
true
,
"description"
:
"shared-runner-1"
,
"id"
:
1
,
"is_shared"
:
true
,
"name"
:
null
},
{
"active"
:
true
,
"description"
:
"shared-runner-2"
,
"id"
:
3
,
"is_shared"
:
true
,
"name"
:
null
},
{
"active"
:
true
,
"description"
:
"test-1-20150125"
,
"id"
:
6
,
"is_shared"
:
false
,
"name"
:
null
},
{
"active"
:
true
,
"description"
:
"test-2-20150125"
,
"id"
:
8
,
"is_shared"
:
false
,
"name"
:
null
}
]
```
## Get runner's details
## Get runner's details
Get details of a runner.
Get details of a runner.
...
...
lib/api/runners.rb
View file @
81ced6f5
...
@@ -4,19 +4,22 @@ module API
...
@@ -4,19 +4,22 @@ module API
before
{
authenticate!
}
before
{
authenticate!
}
resource
:runners
do
resource
:runners
do
# Get
available shared runners
# Get
runners available for user
#
#
# Example Request:
# Example Request:
# GET /runners
# GET /runners
get
do
get
do
runners
=
runners
=
filter_runners
(
current_user
.
ci_authorized_runners
,
params
[
:scope
])
if
current_user
.
is_admin?
present
paginate
(
runners
),
with:
Entities
::
Runner
Ci
::
Runner
.
all
end
else
current_user
.
ci_authorized_runners
# Get all runners - shared and specific
end
#
# Example Request:
runners
=
filter_runners
(
runners
,
params
[
:scope
])
# GET /runners/all
get
'all'
do
authenticated_as_admin!
runners
=
filter_runners
(
Ci
::
Runner
.
all
,
params
[
:scope
])
present
paginate
(
runners
),
with:
Entities
::
Runner
present
paginate
(
runners
),
with:
Entities
::
Runner
end
end
...
...
spec/requests/api/runners_spec.rb
View file @
81ced6f5
...
@@ -23,9 +23,44 @@ describe API::API, api: true do
...
@@ -23,9 +23,44 @@ describe API::API, api: true do
describe
'GET /runners'
do
describe
'GET /runners'
do
context
'authorized user'
do
context
'authorized user'
do
context
'authorized user with admin privileges'
do
it
'should return user available runners'
do
get
api
(
'/runners'
,
user
)
shared
=
false
||
json_response
.
map
{
|
r
|
r
[
'is_shared'
]
}.
inject
{
|
sum
,
shr
|
sum
||
shr
}
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
shared
).
to
be_falsey
end
it
'should filter runners by scope'
do
get
api
(
'/runners?scope=specific'
,
user
)
shared
=
false
||
json_response
.
map
{
|
r
|
r
[
'is_shared'
]
}.
inject
{
|
sum
,
shr
|
sum
||
shr
}
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
shared
).
to
be_falsey
end
it
'should avoid filtering if scope is invalid'
do
get
api
(
'/runners?scope=unknown'
,
user
)
expect
(
response
.
status
).
to
eq
(
400
)
end
end
context
'unauthorized user'
do
it
'should not return runners'
do
get
api
(
'/runners'
)
expect
(
response
.
status
).
to
eq
(
401
)
end
end
end
describe
'GET /runners/all'
do
context
'authorized user'
do
context
'with admin privileges'
do
it
'should return all runners'
do
it
'should return all runners'
do
get
api
(
'/runners'
,
admin
)
get
api
(
'/runners
/all
'
,
admin
)
shared
=
false
||
json_response
.
map
{
|
r
|
r
[
'is_shared'
]
}.
inject
{
|
sum
,
shr
|
sum
||
shr
}
shared
=
false
||
json_response
.
map
{
|
r
|
r
[
'is_shared'
]
}.
inject
{
|
sum
,
shr
|
sum
||
shr
}
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
...
@@ -34,19 +69,16 @@ describe API::API, api: true do
...
@@ -34,19 +69,16 @@ describe API::API, api: true do
end
end
end
end
context
'authorized user without admin privileges'
do
context
'without admin privileges'
do
it
'should return user available runners'
do
it
'should not return runners list'
do
get
api
(
'/runners'
,
user
)
get
api
(
'/runners/all'
,
user
)
shared
=
false
||
json_response
.
map
{
|
r
|
r
[
'is_shared'
]
}.
inject
{
|
sum
,
shr
|
sum
||
shr
}
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
403
)
expect
(
json_response
).
to
be_an
Array
expect
(
shared
).
to
be_falsey
end
end
end
end
it
'should filter runners by scope'
do
it
'should filter runners by scope'
do
get
api
(
'/runners?scope=specific'
,
user
)
get
api
(
'/runners?scope=specific'
,
admin
)
shared
=
false
||
json_response
.
map
{
|
r
|
r
[
'is_shared'
]
}.
inject
{
|
sum
,
shr
|
sum
||
shr
}
shared
=
false
||
json_response
.
map
{
|
r
|
r
[
'is_shared'
]
}.
inject
{
|
sum
,
shr
|
sum
||
shr
}
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
...
@@ -55,7 +87,7 @@ describe API::API, api: true do
...
@@ -55,7 +87,7 @@ describe API::API, api: true do
end
end
it
'should avoid filtering if scope is invalid'
do
it
'should avoid filtering if scope is invalid'
do
get
api
(
'/runners?scope=unknown'
,
user
)
get
api
(
'/runners?scope=unknown'
,
admin
)
expect
(
response
.
status
).
to
eq
(
400
)
expect
(
response
.
status
).
to
eq
(
400
)
end
end
end
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