Commit f0d0400d authored by Alexis Reigel's avatar Alexis Reigel

add Ci::Runner.offline scope to API

parent 00647b31
...@@ -15,7 +15,7 @@ GET /runners?scope=active ...@@ -15,7 +15,7 @@ GET /runners?scope=active
| Attribute | Type | Required | Description | | Attribute | Type | Required | Description |
|-----------|---------|----------|---------------------| |-----------|---------|----------|---------------------|
| `scope` | string | no | The scope of specific runners to show, one of: `active`, `paused`, `online`; showing all runners if none provided | | `scope` | string | no | The scope of specific runners to show, one of: `active`, `paused`, `online`, `offline`; showing all runners if none provided |
``` ```
curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/runners" curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/runners"
...@@ -60,7 +60,7 @@ GET /runners/all?scope=online ...@@ -60,7 +60,7 @@ GET /runners/all?scope=online
| Attribute | Type | Required | Description | | 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 | | `scope` | string | no | The scope of runners to show, one of: `specific`, `shared`, `active`, `paused`, `online`, `offline`; showing all runners if none provided |
``` ```
curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/runners/all" curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/runners/all"
......
...@@ -9,12 +9,12 @@ module API ...@@ -9,12 +9,12 @@ module API
success Entities::Runner success Entities::Runner
end end
params do params do
optional :scope, type: String, values: %w[active paused online], optional :scope, type: String, values: %w[active paused online offline],
desc: 'The scope of specific runners to show' desc: 'The scope of specific runners to show'
use :pagination use :pagination
end end
get do get do
runners = filter_runners(current_user.ci_owned_runners, params[:scope], without: %w(specific shared)) runners = filter_runners(current_user.ci_owned_runners, params[:scope], only: Ci::Runner::AVAILABLE_STATUSES)
present paginate(runners), with: Entities::Runner present paginate(runners), with: Entities::Runner
end end
...@@ -22,7 +22,7 @@ module API ...@@ -22,7 +22,7 @@ module API
success Entities::Runner success Entities::Runner
end end
params do params do
optional :scope, type: String, values: %w[active paused online specific shared], optional :scope, type: String, values: %w[active paused online offline specific shared],
desc: 'The scope of specific runners to show' desc: 'The scope of specific runners to show'
use :pagination use :pagination
end end
...@@ -114,7 +114,7 @@ module API ...@@ -114,7 +114,7 @@ module API
success Entities::Runner success Entities::Runner
end end
params do params do
optional :scope, type: String, values: %w[active paused online specific shared], optional :scope, type: String, values: %w[active paused online offline specific shared],
desc: 'The scope of specific runners to show' desc: 'The scope of specific runners to show'
use :pagination use :pagination
end end
...@@ -158,15 +158,12 @@ module API ...@@ -158,15 +158,12 @@ module API
end end
helpers do helpers do
def filter_runners(runners, scope, options = {}) def filter_runners(runners, scope, only: nil)
return runners unless scope.present? return runners unless scope.present?
available_scopes = ::Ci::Runner::AVAILABLE_SCOPES available_scopes = only || ::Ci::Runner::AVAILABLE_SCOPES
if options[:without]
available_scopes = available_scopes - options[:without]
end
if (available_scopes & [scope]).empty? unless available_scopes.include?(scope)
render_api_error!('Scope contains invalid value', 400) render_api_error!('Scope contains invalid value', 400)
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