Skip to content

Commit 410733a

Browse files
authored
Merge pull request #92 from 3scale/backend_list_paginated
Service and backend list endpoints support queryparams
2 parents 9cb5824 + 1cdcd51 commit 410733a

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

lib/3scale/api/client.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
module ThreeScale
22
module API
3+
MAX_BACKENDS_PER_PAGE = 500
4+
MAX_SERVICES_PER_PAGE = 500
5+
36
class Client
47
attr_reader :http_client
58

@@ -19,8 +22,8 @@ def show_service(id)
1922

2023
# @api public
2124
# @return [Array<Hash>]
22-
def list_services
23-
response = http_client.get('/admin/api/services')
25+
def list_services(params = nil)
26+
response = http_client.get('/admin/api/services', params: params)
2427
extract(collection: 'services', entity: 'service', from: response)
2528
end
2629

@@ -828,8 +831,8 @@ def show_provider
828831

829832
# @api public
830833
# @return [List]
831-
def list_backends
832-
response = http_client.get('/admin/api/backend_apis')
834+
def list_backends(params = nil)
835+
response = http_client.get('/admin/api/backend_apis', params: params)
833836
extract(collection: 'backend_apis', entity: 'backend_api', from: response)
834837
end
835838

spec/api/client_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
context '#list_services' do
1616
it do
17-
expect(http_client).to receive(:get).with('/admin/api/services').and_return('services' => [])
17+
expect(http_client).to receive(:get).with('/admin/api/services', params: nil).and_return('services' => [])
1818
expect(client.list_services).to eq([])
1919
end
2020
end
@@ -1124,7 +1124,7 @@
11241124
let(:resp_body) { { 'backend_apis' => backend_apis.map { |b| { 'backend_api' => b } } } }
11251125

11261126
it do
1127-
expect(http_client).to receive(:get).with('/admin/api/backend_apis').and_return(resp_body)
1127+
expect(http_client).to receive(:get).with('/admin/api/backend_apis', params: nil).and_return(resp_body)
11281128
expect(client.list_backends).to match_array(backend_apis)
11291129
end
11301130
end

0 commit comments

Comments
 (0)