3scale-api 0.1.5 → 0.1.6
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 +5 -5
- data/README.md +20 -1
- data/lib/3scale/api.rb +3 -2
- data/lib/3scale/api/client.rb +10 -0
- data/lib/3scale/api/http_client.rb +3 -1
- data/lib/3scale/api/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e3ae48b0911ac65f9a45bd02e2a378e234b2235dd9ebfd92f44cb97f6f62225f
|
4
|
+
data.tar.gz: 0fac2326c5a08a52ae7a25aabd510a4d2da1a5a4ed4f2431f88f561a2e6e7eff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b424f617c927c6ec4e5e41d45cbbd15274bc460744b13d632a1a26163691669368148147838a50b4bc9e5c8f12ebaaa151779ba037cad688d6ce359bfc5c2ecc
|
7
|
+
data.tar.gz: 1ba5fb1af0f06f9a8b83f02fc31dba8ee6abc829d34556520db4ed29a374e461d53106923c57074f2db3a93e0ceda2c022c1148eb1cce4cab2e93086420a7b0f
|
data/README.md
CHANGED
@@ -44,11 +44,30 @@ Design decisions:
|
|
44
44
|
|
45
45
|
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
46
46
|
|
47
|
+
## Testing
|
48
|
+
|
47
49
|
To run tests run `rake` or `rspec`.
|
48
50
|
|
51
|
+
There are two kinds of tests: unit (see [spec/api](spec/api)) and integration (see [spec/integration](spec/integration)).
|
52
|
+
|
53
|
+
For running the integration tests you will need to have a real 3scale account, you can set the details of the account via environment variables. The easiest way to set everything up is it to have a `.env` file in the root of the project with the following environment variables (set your own values):
|
54
|
+
|
55
|
+
```
|
56
|
+
ENDPOINT=https://your-domain-admin.3scale.net
|
57
|
+
PROVIDER_KEY=abc123
|
58
|
+
SERVICE_ID=12345
|
59
|
+
METRIC_ID=12345 # should be a numeric value, not the system name
|
60
|
+
APPLICATION_PLAN_ID=12345
|
61
|
+
VERIFY_SSL=true (by default true)
|
62
|
+
```
|
63
|
+
|
64
|
+
**Note:** for the tests to pass the following requirements need to be met:
|
65
|
+
- authorization mode of the service should be *API key*
|
66
|
+
- there should be at least 1 method for the 'hits' metric
|
67
|
+
- the field `billing_address` should be added to the Account model in **Settings > Fields Definitions**
|
68
|
+
|
49
69
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
50
70
|
|
51
71
|
## Contributing
|
52
72
|
|
53
73
|
Bug reports and pull requests are welcome on GitHub at https://github.com/3scale/3scale-api-ruby.
|
54
|
-
|
data/lib/3scale/api.rb
CHANGED
@@ -5,9 +5,10 @@ module ThreeScale
|
|
5
5
|
autoload :Client, '3scale/api/client'
|
6
6
|
autoload :HttpClient, '3scale/api/http_client'
|
7
7
|
|
8
|
-
def self.new(endpoint:, provider_key:)
|
8
|
+
def self.new(endpoint:, provider_key:, verify_ssl: true)
|
9
9
|
http_client = HttpClient.new(endpoint: endpoint,
|
10
|
-
provider_key: provider_key
|
10
|
+
provider_key: provider_key,
|
11
|
+
verify_ssl: verify_ssl)
|
11
12
|
Client.new(http_client)
|
12
13
|
end
|
13
14
|
end
|
data/lib/3scale/api/client.rb
CHANGED
@@ -101,6 +101,16 @@ module ThreeScale
|
|
101
101
|
extract(entity: 'service', from: response)
|
102
102
|
end
|
103
103
|
|
104
|
+
# @api public
|
105
|
+
# @return [Hash]
|
106
|
+
# @param [Fixnum] service_id Service ID
|
107
|
+
# @param [Hash] attributes Service Attributes
|
108
|
+
# @option attributes [String] :name Service Name
|
109
|
+
def update_service(service_id, attributes)
|
110
|
+
response = http_client.put("/admin/api/services/#{service_id}", body: { service: attributes })
|
111
|
+
extract(entity: 'service', from: response)
|
112
|
+
end
|
113
|
+
|
104
114
|
# @api public
|
105
115
|
# @return [Hash]
|
106
116
|
# @param [Fixnum] service_id Service ID
|
@@ -1,18 +1,20 @@
|
|
1
1
|
require 'json'
|
2
2
|
require 'uri'
|
3
3
|
require 'net/http'
|
4
|
+
require 'openssl'
|
4
5
|
|
5
6
|
module ThreeScale
|
6
7
|
module API
|
7
8
|
class HttpClient
|
8
9
|
attr_reader :endpoint, :admin_domain, :provider_key, :headers, :format
|
9
10
|
|
10
|
-
def initialize(endpoint:, provider_key:, format: :json)
|
11
|
+
def initialize(endpoint:, provider_key:, format: :json, verify_ssl: true)
|
11
12
|
@endpoint = URI(endpoint).freeze
|
12
13
|
@admin_domain = @endpoint.host.freeze
|
13
14
|
@provider_key = provider_key.freeze
|
14
15
|
@http = Net::HTTP.new(admin_domain, @endpoint.port)
|
15
16
|
@http.use_ssl = @endpoint.is_a?(URI::HTTPS)
|
17
|
+
@http.verify_mode = OpenSSL::SSL::VERIFY_NONE unless verify_ssl
|
16
18
|
|
17
19
|
@headers = {
|
18
20
|
'Accept' => "application/#{format}",
|
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.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michal Cichra
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -99,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
99
99
|
version: '0'
|
100
100
|
requirements: []
|
101
101
|
rubyforge_project:
|
102
|
-
rubygems_version: 2.6
|
102
|
+
rubygems_version: 2.7.6
|
103
103
|
signing_key:
|
104
104
|
specification_version: 4
|
105
105
|
summary: API Client for 3scale APIs
|