3scale_api 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/3scale_api/3scale/api.rb +32 -0
- data/lib/3scale_api/version.rb +1 -1
- data/spec/3scale_api_spec.rb +35 -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: 8b5621d5247c1a95bdd119289a847dcaa2c789a0
|
4
|
+
data.tar.gz: bcd9a3b112e0906219963d9ff0e4251d1fe291f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8df7de521e42f9118cdef182195d29dd75cc4988aec883fb2bcdf789f7877d9ac9ac7615e5c2bc13ee528d42d3983bd1b33050211184eae8c5c25ff2ecdb85b
|
7
|
+
data.tar.gz: 79fda93210f3332290888f6d3019ad4b71164b99d12bb742321579f1eeac5b4151c5c9be122633718b05b544872e5b93a88bef46171630e29ff05995ded33b52
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# 3scale - API
|
2
2
|
|
3
3
|
[![Join the chat at https://gitter.im/IDTLabs/threescale_api](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/IDTLabs/threescale_api?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
4
|
-
[![Gem Version](https://badge.fury.io/rb/
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/3scale_api.svg)](http://badge.fury.io/rb/3scale_api)
|
5
5
|
|
6
6
|
This gem will allow developers to interact with 3Scale's APIs.
|
7
7
|
|
@@ -86,5 +86,37 @@ module Threescale
|
|
86
86
|
results
|
87
87
|
end
|
88
88
|
|
89
|
+
def get_service_plans
|
90
|
+
results = Array.new
|
91
|
+
response = @conn.get "/admin/api/application_plans.xml", {:provider_key => @provider_key }
|
92
|
+
xml = Nokogiri::XML(response.body)
|
93
|
+
plans = xml.xpath("//plans/plan")
|
94
|
+
plans = plans.map do |plan|
|
95
|
+
{
|
96
|
+
:name => plan.css("name").text,
|
97
|
+
:service_plan_id => plan.css("service_id").text
|
98
|
+
}
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def get_services
|
103
|
+
results = Array.new
|
104
|
+
response = @conn.get "/admin/api/services.xml", {:provider_key => @provider_key }
|
105
|
+
xml = Nokogiri::XML(response.body)
|
106
|
+
p xml
|
107
|
+
services = xml.xpath("//services/service")
|
108
|
+
services.map do |service|
|
109
|
+
{
|
110
|
+
:name => service.css("name").first.text,
|
111
|
+
:service_id => service.css("id").first.text
|
112
|
+
}
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def create_account(name, service_id)
|
117
|
+
response = @conn.post "/admin/api/services/#{service_id}/application_plans.xml", {:provider_key => @provider_key,
|
118
|
+
:name => name}
|
119
|
+
response.status == 201
|
120
|
+
end
|
89
121
|
end
|
90
122
|
end
|
data/lib/3scale_api/version.rb
CHANGED
data/spec/3scale_api_spec.rb
CHANGED
@@ -5,6 +5,7 @@ describe "3scaleApi" do
|
|
5
5
|
ENV["THREESCALE_URL"] = nil
|
6
6
|
ENV["THREESCALE_PROVIDER_KEY"] = nil
|
7
7
|
end
|
8
|
+
|
8
9
|
describe "Instantiate 3scale object" do
|
9
10
|
it "should raise an error when there is no env variables and you instantiate" do
|
10
11
|
lambda do
|
@@ -31,11 +32,13 @@ describe "3scaleApi" do
|
|
31
32
|
end.should_not raise_error
|
32
33
|
end
|
33
34
|
end
|
35
|
+
|
34
36
|
describe "API methods" do
|
35
37
|
before(:all) do
|
36
38
|
ENV["THREESCALE_URL"] = "http://test-url.test"
|
37
39
|
@threescale = Threescale::API.new 'provider-key'
|
38
40
|
end
|
41
|
+
|
39
42
|
describe "get_application_keys" do
|
40
43
|
it "should call /admin/api/accounts/{account_id}/applications/{application_id}/keys.xml" do
|
41
44
|
stub_request(
|
@@ -50,6 +53,7 @@ describe "3scaleApi" do
|
|
50
53
|
@threescale.get_application_keys 'account-id', 'application-id'
|
51
54
|
end
|
52
55
|
end
|
56
|
+
|
53
57
|
describe "get_application_list" do
|
54
58
|
it "should call /admin/api/accounts/{account_id}/applications.xml" do
|
55
59
|
stub_request(
|
@@ -99,6 +103,7 @@ describe "3scaleApi" do
|
|
99
103
|
@threescale.generate_application_key 'account-id', 'application-id'
|
100
104
|
end
|
101
105
|
end
|
106
|
+
|
102
107
|
describe "create_application" do
|
103
108
|
it "should call /admin/api/accounts/{account_id}/applications.xml" do
|
104
109
|
stub_request(
|
@@ -120,5 +125,34 @@ describe "3scaleApi" do
|
|
120
125
|
@threescale.create_application 'account-id', 'plan-id', 'name', 'description'
|
121
126
|
end
|
122
127
|
end
|
128
|
+
|
129
|
+
describe "get_service_plans" do
|
130
|
+
it "should call /admin/api/application_plans.xml" do
|
131
|
+
stub_request(:get, "http://test-url.test/admin/api/application_plans.xml?provider_key=provider-key").
|
132
|
+
with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Faraday v0.9.1'}).
|
133
|
+
to_return(:status => 200, :body => "", :headers => {})
|
134
|
+
|
135
|
+
@threescale.get_service_plans
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
describe "get_services" do
|
140
|
+
it "should call /admin/api/services.xml" do
|
141
|
+
stub_request(:get, "http://test-url.test/admin/api/services.xml?provider_key=provider-key").
|
142
|
+
with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Faraday v0.9.1'}).
|
143
|
+
to_return(:status => 200, :body => "", :headers => {})
|
144
|
+
@threescale.get_services
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
describe "create_account" do
|
149
|
+
it "should call /admin/api/accounts/{account_id}/applications.xml" do
|
150
|
+
stub_request(:post, "http://test-url.test/admin/api/services/service-id/application_plans.xml").
|
151
|
+
with(:body => {"name"=>"name", "provider_key"=>"provider-key"},
|
152
|
+
:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type'=>'application/x-www-form-urlencoded', 'User-Agent'=>'Faraday v0.9.1'}).
|
153
|
+
to_return(:status => 200, :body => "", :headers => {})
|
154
|
+
@threescale.create_account "name", "service-id"
|
155
|
+
end
|
156
|
+
end
|
123
157
|
end
|
124
|
-
end
|
158
|
+
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: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robbie Holmes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: This gem is to be used to interact with 3Scale's API.
|
14
14
|
email:
|