3scale-api 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 66112b4ebc751f3c6cc73dcc8e7fc930b742e99a
4
- data.tar.gz: 1e5a1e28aa8b6fb259444c5452b560066af2fae8
3
+ metadata.gz: 77a476fabcd236f26e54791a002e225f68f71f01
4
+ data.tar.gz: f294b48f5dc30f7552bb2c5c8528894b83af0461
5
5
  SHA512:
6
- metadata.gz: 6fdc86d5919b12c4ce43140799959fa3b86af0d4ddbb3823612b68431c89bf8a07f2e9a81c00231f188b48cf6ba9ec548d07a35d5d3cac7fdc87d885279f08c5
7
- data.tar.gz: f41eb26a96ef6d1ad7227371451dde1637a6348302ccf93f7492334d1c2c176c3df45f8a506874889d989ec28dec6129afb43b93da772fb746863c0dba6e2ef2
6
+ metadata.gz: 8d1da34bab1586e5b83c719877cb6c509ae6c6b9d34af8b5a4e4537809ff2f7f53cbad219b68e8523e7208d08eec12b84e3631d1264d45958e74ca8579f7e52f
7
+ data.tar.gz: 85d66c30ac936ce983c14eb9e53e13333b31cba3074794359c9d174c80869991b0faa5afecd2d9c1d4659c418f270cdb4c2fad1f14a2a9aa6d6a359f28e725cd
@@ -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
@@ -1,5 +1,5 @@
1
1
  module ThreeScale
2
2
  module API
3
- VERSION = "0.1.1"
3
+ VERSION = '0.1.2'
4
4
  end
5
5
  end
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.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-14 00:00:00.000000000 Z
11
+ date: 2016-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler