Commit 901fbda6 authored by Toon Claes's avatar Toon Claes

Make it possible to query scope as scope[]=

Since issues also accepts the query parameter iids[]=, also make it
possible query scope like that.
parent f3724006
......@@ -14,7 +14,7 @@ GET /projects/:id/jobs
| `scope` | string **or** array of strings | no | The scope of jobs to show, one or array of: `created`, `pending`, `running`, `failed`, `success`, `canceled`, `skipped`; showing all jobs if none provided |
```
curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" 'https://gitlab.example.com/api/v4/projects/1/jobs?scope%5B0%5D=pending&scope%5B1%5D=running'
curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" 'https://gitlab.example.com/api/v4/projects/1/jobs?scope[]=pending&scope[]=running'
```
Example of response
......@@ -123,14 +123,14 @@ Get a list of jobs for a pipeline.
GET /projects/:id/pipeline/:pipeline_id/jobs
```
| Attribute | Type | Required | Description |
|--------------|--------------------------------|----------|----------------------|
| `id` | integer | yes | The ID of a project |
| `pipelin_id` | integer | yes | The ID of a pipeline |
| `scope` | string **or** array of strings | no | The scope of jobs to show, one or array of: `created`, `pending`, `running`, `failed`, `success`, `canceled`, `skipped`; showing all jobs if none provided |
| Attribute | Type | Required | Description |
|---------------|--------------------------------|----------|----------------------|
| `id` | integer | yes | The ID of a project |
| `pipeline_id` | integer | yes | The ID of a pipeline |
| `scope` | string **or** array of strings | no | The scope of jobs to show, one or array of: `created`, `pending`, `running`, `failed`, `success`, `canceled`, `skipped`; showing all jobs if none provided |
```
curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" 'https://gitlab.example.com/api/v4/projects/1/pipelines/6/jobs?scope%5B0%5D=pending&scope%5B1%5D=running'
curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" 'https://gitlab.example.com/api/v4/projects/1/pipelines/6/jobs?scope[]=pending&scope[]=running'
```
Example of response
......
......@@ -18,6 +18,8 @@ module API
[scope]
when Hashie::Mash
scope.values
when Hashie::Array
scope
else
['unknown']
end
......
......@@ -51,7 +51,7 @@ describe API::Jobs, api: true do
end
context 'filter project with array of scope elements' do
let(:query) { { 'scope[0]' => 'pending', 'scope[1]' => 'running' } }
let(:query) { { scope: %w(pending running) } }
it do
expect(response).to have_http_status(200)
......@@ -60,7 +60,7 @@ describe API::Jobs, api: true do
end
context 'respond 400 when scope contains invalid state' do
let(:query) { { 'scope[0]' => 'unknown', 'scope[1]' => 'running' } }
let(:query) { { scope: %w(unknown running) } }
it { expect(response).to have_http_status(400) }
end
......@@ -114,7 +114,7 @@ describe API::Jobs, api: true do
end
context 'filter jobs with array of scope elements' do
let(:query) { { 'scope[0]' => 'pending', 'scope[1]' => 'running' } }
let(:query) { { scope: %w(pending running) } }
it do
expect(response).to have_http_status(200)
......@@ -123,7 +123,7 @@ describe API::Jobs, api: true do
end
context 'respond 400 when scope contains invalid state' do
let(:query) { { 'scope[0]' => 'unknown', 'scope[1]' => 'running' } }
let(:query) { { scope: %w(unknown running) } }
it { expect(response).to have_http_status(400) }
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