3scale-api 1.1.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/3scale/api/client.rb +24 -4
- data/lib/3scale/api/http_client.rb +20 -4
- data/lib/3scale/api/version.rb +1 -1
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 889c02fde022e3dfac63c698c05a631904181e7c5bb8b65f7a73378ede62bcd7
|
4
|
+
data.tar.gz: 10756f304d8b25f242416c2cdd3d6ae5141ef73c94103aab6cc9e7674cfcd450
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c029b7cafa5e81c612c2240f30c428d9be066ae9ad3d5b30f4efd1873b98c7600d5a446af4d1069978f32297ba96ffd34ba46d03afdfe34e6b79bfd40a3b66ea
|
7
|
+
data.tar.gz: 964b8e3168761498f2789b2f0466d2d52c68273972495e1dffa977c98f7257ac643af7a0600a7b5aab85ba37440cb1e3e337bdfc654bfd4f6b6cb20ce9ac7088
|
data/lib/3scale/api/client.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
module ThreeScale
|
2
2
|
module API
|
3
|
+
MAX_BACKENDS_PER_PAGE = 500
|
4
|
+
MAX_SERVICES_PER_PAGE = 500
|
5
|
+
|
3
6
|
class Client
|
4
7
|
attr_reader :http_client
|
5
8
|
|
@@ -19,8 +22,8 @@ module ThreeScale
|
|
19
22
|
|
20
23
|
# @api public
|
21
24
|
# @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)
|
24
27
|
extract(collection: 'services', entity: 'service', from: response)
|
25
28
|
end
|
26
29
|
|
@@ -41,6 +44,14 @@ module ThreeScale
|
|
41
44
|
extract(collection: 'applications', entity: 'application', from: response)
|
42
45
|
end
|
43
46
|
|
47
|
+
# @api public
|
48
|
+
# @param [Fixnum] account_id Account ID
|
49
|
+
# @return [Array<Hash>]
|
50
|
+
def list_applications_by_account(account_id)
|
51
|
+
response = http_client.get("/admin/api/accounts/#{account_id}/applications")
|
52
|
+
extract(collection: 'applications', entity: 'application', from: response)
|
53
|
+
end
|
54
|
+
|
44
55
|
# @api public
|
45
56
|
# @return [Hash]
|
46
57
|
# @param [Fixnum] id Application ID
|
@@ -200,6 +211,15 @@ module ThreeScale
|
|
200
211
|
extract(entity: 'proxy', from: response)
|
201
212
|
end
|
202
213
|
|
214
|
+
# @api public
|
215
|
+
# @return [Hash]
|
216
|
+
# @param [Fixnum] service_id Service ID
|
217
|
+
def proxy_deploy(service_id)
|
218
|
+
response = http_client.post("/admin/api/services/#{service_id}/proxy/deploy",
|
219
|
+
body: nil)
|
220
|
+
extract(entity: 'proxy', from: response)
|
221
|
+
end
|
222
|
+
|
203
223
|
# @api public
|
204
224
|
# @return [Array<Hash>]
|
205
225
|
# @param [Fixnum] service_id Service ID
|
@@ -828,8 +848,8 @@ module ThreeScale
|
|
828
848
|
|
829
849
|
# @api public
|
830
850
|
# @return [List]
|
831
|
-
def list_backends
|
832
|
-
response = http_client.get('/admin/api/backend_apis')
|
851
|
+
def list_backends(params = nil)
|
852
|
+
response = http_client.get('/admin/api/backend_apis', params: params)
|
833
853
|
extract(collection: 'backend_apis', entity: 'backend_api', from: response)
|
834
854
|
end
|
835
855
|
|
@@ -68,16 +68,22 @@ module ThreeScale
|
|
68
68
|
|
69
69
|
class NotFoundError < ResponseError; end
|
70
70
|
|
71
|
+
class UnknownFormatError < StandardError; end
|
72
|
+
|
71
73
|
def forbidden!(response)
|
72
|
-
raise ForbiddenError.new(response)
|
74
|
+
raise ForbiddenError.new(response, format_response(response))
|
73
75
|
end
|
74
76
|
|
75
77
|
def notfound!(response)
|
76
|
-
raise NotFoundError.new(response)
|
78
|
+
raise NotFoundError.new(response, format_response(response))
|
77
79
|
end
|
78
80
|
|
79
81
|
def unexpected!(response)
|
80
|
-
raise UnexpectedResponseError.new(response, response
|
82
|
+
raise UnexpectedResponseError.new(response, format_response(response))
|
83
|
+
end
|
84
|
+
|
85
|
+
def unknownformat!
|
86
|
+
raise UnknownFormatError, "unknown format #{format}"
|
81
87
|
end
|
82
88
|
|
83
89
|
def serialize(body)
|
@@ -91,7 +97,7 @@ module ThreeScale
|
|
91
97
|
def parser
|
92
98
|
case format
|
93
99
|
when :json then JSONParser
|
94
|
-
else
|
100
|
+
else unknownformat!
|
95
101
|
end
|
96
102
|
end
|
97
103
|
|
@@ -108,6 +114,16 @@ module ThreeScale
|
|
108
114
|
path
|
109
115
|
end
|
110
116
|
|
117
|
+
def format_response(response)
|
118
|
+
body = response.body if text_based?(response)
|
119
|
+
"#{response.inspect} body=#{body}"
|
120
|
+
end
|
121
|
+
|
122
|
+
def text_based?(response)
|
123
|
+
response.content_type =~ /^text/ ||
|
124
|
+
response.content_type =~ /^application/ && !['application/octet-stream', 'application/pdf'].include?(response.content_type)
|
125
|
+
end
|
126
|
+
|
111
127
|
module JSONParser
|
112
128
|
module_function
|
113
129
|
|
data/lib/3scale/api/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: 3scale-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Miguel Soriano
|
8
8
|
- Eguzki Astiz Lezaun
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-11-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -69,7 +69,7 @@ dependencies:
|
|
69
69
|
version: '3.4'
|
70
70
|
description: 'API Client to access your 3scale APIs: Account Management API'
|
71
71
|
email:
|
72
|
-
-
|
72
|
+
- msoriano@redhat.com
|
73
73
|
- eastizle@redhat.com
|
74
74
|
executables: []
|
75
75
|
extensions: []
|
@@ -94,15 +94,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
94
94
|
requirements:
|
95
95
|
- - ">="
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version: '
|
97
|
+
version: '2.6'
|
98
98
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
100
|
- - ">="
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: '0'
|
103
103
|
requirements: []
|
104
|
-
|
105
|
-
rubygems_version: 2.7.6
|
104
|
+
rubygems_version: 3.0.3
|
106
105
|
signing_key:
|
107
106
|
specification_version: 4
|
108
107
|
summary: API Client for 3scale APIs
|