3scale-api 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/3scale/api/client.rb +72 -0
- data/lib/3scale/api/http_client.rb +5 -1
- data/lib/3scale/api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77a476fabcd236f26e54791a002e225f68f71f01
|
4
|
+
data.tar.gz: f294b48f5dc30f7552bb2c5c8528894b83af0461
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d1da34bab1586e5b83c719877cb6c509ae6c6b9d34af8b5a4e4537809ff2f7f53cbad219b68e8523e7208d08eec12b84e3631d1264d45958e74ca8579f7e52f
|
7
|
+
data.tar.gz: 85d66c30ac936ce983c14eb9e53e13333b31cba3074794359c9d174c80869991b0faa5afecd2d9c1d4659c418f270cdb4c2fad1f14a2a9aa6d6a359f28e725cd
|
data/lib/3scale/api/client.rb
CHANGED
@@ -34,6 +34,78 @@ module ThreeScale
|
|
34
34
|
extract(entity: 'service', from: response)
|
35
35
|
end
|
36
36
|
|
37
|
+
# @api public
|
38
|
+
# @return [Hash]
|
39
|
+
# @param [Fixnum] service_id Service ID
|
40
|
+
def show_proxy(service_id)
|
41
|
+
response = http_client.get("/admin/api/services/#{service_id}/proxy")
|
42
|
+
extract(entity: 'proxy', from: response)
|
43
|
+
end
|
44
|
+
|
45
|
+
# @api public
|
46
|
+
# @return [Hash]
|
47
|
+
# @param [Fixnum] service_id Service ID
|
48
|
+
def update_proxy(service_id, attributes)
|
49
|
+
response = http_client.patch("/admin/api/services/#{service_id}/proxy",
|
50
|
+
body: { proxy: attributes })
|
51
|
+
extract(entity: 'proxy', from: response)
|
52
|
+
end
|
53
|
+
|
54
|
+
# @api public
|
55
|
+
# @return [Array<Hash>]
|
56
|
+
# @param [Fixnum] service_id Service ID
|
57
|
+
def list_mapping_rules(service_id)
|
58
|
+
response = http_client.get("/admin/api/services/#{service_id}/proxy/mapping_rules")
|
59
|
+
extract(entity: 'mapping_rule', collection: 'mapping_rules', from: response)
|
60
|
+
end
|
61
|
+
|
62
|
+
# @api public
|
63
|
+
# @return [Array<Hash>]
|
64
|
+
# @param [Fixnum] service_id Service ID
|
65
|
+
# @param [Fixnum] id Mapping Rule ID
|
66
|
+
def show_mapping_rule(service_id, id)
|
67
|
+
response = http_client.get("/admin/api/services/#{service_id}/proxy/mapping_rules/#{id}")
|
68
|
+
extract(entity: 'mapping_rule', from: response)
|
69
|
+
end
|
70
|
+
|
71
|
+
# @api public
|
72
|
+
# @return [Array<Hash>]
|
73
|
+
# @param [Fixnum] service_id Service ID
|
74
|
+
# @param [Hash] attributes Mapping Rule Attributes
|
75
|
+
# @option attributes [String] :http_method HTTP Method
|
76
|
+
# @option attributes [String] :pattern Pattern
|
77
|
+
# @option attributes [Fixnum] :delta Increase the metric by delta.
|
78
|
+
# @option attributes [Fixnum] :metric_id Metric ID
|
79
|
+
def create_mapping_rule(service_id, attributes)
|
80
|
+
response = http_client.post("/admin/api/services/#{service_id}/proxy/mapping_rules",
|
81
|
+
body: { mapping_rule: attributes })
|
82
|
+
extract(entity: 'mapping_rule', from: response)
|
83
|
+
end
|
84
|
+
|
85
|
+
# @api public
|
86
|
+
# @return [Array<Hash>]
|
87
|
+
# @param [Fixnum] service_id Service ID
|
88
|
+
# @param [Fixnum] id Mapping Rule ID
|
89
|
+
def delete_mapping_rule(service_id, id)
|
90
|
+
http_client.delete("/admin/api/services/#{service_id}/proxy/mapping_rules/#{id}")
|
91
|
+
true
|
92
|
+
end
|
93
|
+
|
94
|
+
# @api public
|
95
|
+
# @return [Array<Hash>]
|
96
|
+
# @param [Fixnum] service_id Service ID
|
97
|
+
# @param [Fixnum] id Mapping Rule ID
|
98
|
+
# @param [Hash] attributes Mapping Rule Attributes
|
99
|
+
# @option attributes [String] :http_method HTTP Method
|
100
|
+
# @option attributes [String] :pattern Pattern
|
101
|
+
# @option attributes [Fixnum] :delta Increase the metric by delta.
|
102
|
+
# @option attributes [Fixnum] :metric_id Metric ID
|
103
|
+
def update_mapping_rule(service_id, id, attributes)
|
104
|
+
response = http_client.patch("/admin/api/services/#{service_id}/mapping_rules/#{id}",
|
105
|
+
body: { mapping_rule: attributes })
|
106
|
+
extract(entity: 'mapping_rule', from: response)
|
107
|
+
end
|
108
|
+
|
37
109
|
# @api public
|
38
110
|
# @return [Array<Hash>]
|
39
111
|
# @param [Fixnum] service_id Service ID
|
@@ -34,6 +34,10 @@ module ThreeScale
|
|
34
34
|
parse @http.get("#{path}.#{format}", headers)
|
35
35
|
end
|
36
36
|
|
37
|
+
def patch(path, body: )
|
38
|
+
parse @http.patch("#{path}.#{format}", serialize(body), headers)
|
39
|
+
end
|
40
|
+
|
37
41
|
def post(path, body: )
|
38
42
|
parse @http.post("#{path}.#{format}", serialize(body), headers)
|
39
43
|
end
|
@@ -82,7 +86,7 @@ module ThreeScale
|
|
82
86
|
|
83
87
|
def decode(string)
|
84
88
|
case string
|
85
|
-
when ' '.freeze, ''.freeze then nil
|
89
|
+
when nil, ' '.freeze, ''.freeze then nil
|
86
90
|
else ::JSON.parse(string)
|
87
91
|
end
|
88
92
|
end
|
data/lib/3scale/api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: 3scale-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michal Cichra
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|