okapi 1.0.2 → 2.0.0
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/.github/PULL_REQUEST_TEMPLATE.md +15 -0
- data/CHANGELOG.md +13 -0
- data/README.md +46 -3
- data/lib/okapi.rb +0 -13
- data/lib/okapi/cli.rb +6 -6
- data/lib/okapi/settings.rb +9 -3
- data/lib/okapi/version.rb +1 -1
- data/okapi-command-line.gif +0 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4c67e307310800684dc4dce031fa1bf8e347c02
|
4
|
+
data.tar.gz: a2c5c7394da03e8911c71843319bf059a32043e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43fe63985ed25721da900a18759a6e01afc9f499fe4a84a2b0d4d49c312d708dd0d29e67d60f108fd1792a59f3e0931a461a4645ecebef41848cd8d1862e8881
|
7
|
+
data.tar.gz: f843858ccd1b8a1d51d2ddb43faec1a9745b3363dcc994f6c1d9e9af80270e480993d334d2778e51a4e345d21816a1d673872cf0549bb562817bf348834643f1
|
@@ -0,0 +1,15 @@
|
|
1
|
+
## Purpose
|
2
|
+
_Describe the purpose of the pull request. Include background information if necessary._
|
3
|
+
|
4
|
+
## Approach
|
5
|
+
_How does this change fulfill the purpose?_
|
6
|
+
|
7
|
+
#### TODOS and Open Questions
|
8
|
+
- [ ] Use GitHub checklists. When solved, check the box and explain the answer.
|
9
|
+
|
10
|
+
## Learning
|
11
|
+
_Describe the research stage. Add links to blog posts, patterns, libraries or addons used to solve this problem._
|
12
|
+
|
13
|
+
## Screenshots
|
14
|
+
_A picture is worth a thousand words. If you can get your meaning
|
15
|
+
across with a GIF, then let's see those sweet visuals!_
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,19 @@ All notable changes to this project will be documented in this file.
|
|
3
3
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
5
5
|
|
6
|
+
## [2.0.0] - 2018-01-16
|
7
|
+
|
8
|
+
## Added
|
9
|
+
- PR template
|
10
|
+
|
11
|
+
## Changed
|
12
|
+
- README to reflect the actual, encouraged API based on simple Restful
|
13
|
+
verbs.
|
14
|
+
|
15
|
+
## Removed
|
16
|
+
- `modules` method from `Okapi::Client` and `modules:index` command
|
17
|
+
from the CLI.
|
18
|
+
|
6
19
|
## [1.0.2] - 2017-11-01
|
7
20
|
|
8
21
|
### Changed
|
data/README.md
CHANGED
@@ -1,13 +1,54 @@
|
|
1
1
|
# Okapi
|
2
|
-
|
2
|
+
[](https://badge.fury.io/rb/okapi)
|
3
3
|
[](https://travis-ci.org/thefrontside/okapi.rb)
|
4
4
|
|
5
|
+
Ruby bindings and command line utility for the [Okapi][1] API gateway.
|
6
|
+
|
7
|
+
## Synopsis
|
8
|
+
|
9
|
+
To make calls to an Okapi gateway from Ruby, instantiate an instance
|
10
|
+
of the `Okapi::Client` class by passing in the URL, Tenant, and
|
11
|
+
auth_token to use for requests.
|
12
|
+
|
13
|
+
``` ruby
|
14
|
+
require 'okapi'
|
15
|
+
okapi = Okapi::Client.new('https://okapi.frontside.io', "fs", "<MY-AUTH-TOKEN>")
|
16
|
+
okapi.get("/_/proxy/modules") //=> [{id: 'mod-kb-ebsco'}, {id: 'mod-config'}]
|
17
|
+
```
|
18
|
+
|
19
|
+
The `okapi` client has methods corresponding to the major `REST`ful
|
20
|
+
verbs: `okap.get`, `okapi.post`, `okapi.put`, `okapi.delete`
|
21
|
+
|
22
|
+
By default, even if you provided them to the constructor, the client
|
23
|
+
does not send tenant and auth information with the request. This is
|
24
|
+
because the gateway will reject requests that provide this information
|
25
|
+
when it is not needed. For example, an authorization request that
|
26
|
+
provides an auth token will result in an error, so you don't want to
|
27
|
+
send it.
|
28
|
+
|
29
|
+
To send tenant, use the `tenant` property on the client
|
30
|
+
to access an `Okapi::Client` that _will_ send tenant information.
|
31
|
+
|
5
32
|
``` ruby
|
33
|
+
okapi.tentant.post('/authn/login', username: 'admin', password: 'password')
|
34
|
+
```
|
35
|
+
|
36
|
+
To send both tenant _and_ authorization information with a request,
|
37
|
+
use the `user` property of the okapi client which will give you a
|
38
|
+
client that _will_ send both these bits of information with the
|
39
|
+
request:
|
6
40
|
|
7
|
-
|
8
|
-
|
41
|
+
``` ruby
|
42
|
+
okapi.user.get('/eholdings/configuration')
|
9
43
|
```
|
10
44
|
|
45
|
+
## Command Line
|
46
|
+
|
47
|
+
The okapi gem comes with a command line utility to help you easily
|
48
|
+
interact with an Okapi gateway from your shell.
|
49
|
+
|
50
|
+

|
11
52
|
|
12
53
|
## Installation
|
13
54
|
|
@@ -39,3 +80,5 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/thefro
|
|
39
80
|
## License
|
40
81
|
|
41
82
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
83
|
+
|
84
|
+
[1]: https://github.com/folio-org/okapi
|
data/lib/okapi.rb
CHANGED
@@ -16,19 +16,6 @@ module Okapi
|
|
16
16
|
Settings.new(@url, @tenant, @token)
|
17
17
|
end
|
18
18
|
|
19
|
-
def modules
|
20
|
-
endpoint = "#{settings.url}/_/proxy/modules"
|
21
|
-
open(endpoint) do |response|
|
22
|
-
JSON.parse(response.read)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def has_interface?(interface_name)
|
27
|
-
get("/_/proxy/tenants/#{settings.tenant}/interfaces/#{interface_name}") do |json|
|
28
|
-
json.length > 0
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
19
|
def url
|
33
20
|
settings.url
|
34
21
|
end
|
data/lib/okapi/cli.rb
CHANGED
@@ -44,6 +44,12 @@ module Okapi
|
|
44
44
|
|
45
45
|
subcommand "login", "authenticate to okapi and store credentials" do
|
46
46
|
def model
|
47
|
+
# We know that we're going to use these values
|
48
|
+
# so go ahead and pull them so that if they aren't
|
49
|
+
# set, they will throw a configuration error
|
50
|
+
client.settings.url
|
51
|
+
client.settings.tenant
|
52
|
+
|
47
53
|
username = console.ask("username: ")
|
48
54
|
password = console.ask("password: ") { |q| q.echo = "*" }
|
49
55
|
client.tenant.post("/authn/login", username: username, password: password) do |json, response|
|
@@ -94,12 +100,6 @@ module Okapi
|
|
94
100
|
end
|
95
101
|
end
|
96
102
|
|
97
|
-
subcommand "modules:index", "show a listing of all installed modules" do
|
98
|
-
def model
|
99
|
-
client.modules
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
103
|
def client
|
104
104
|
variables.load!
|
105
105
|
anonymous = Okapi::Client.new(url, tenant, token)
|
data/lib/okapi/settings.rb
CHANGED
@@ -7,10 +7,12 @@ module Okapi
|
|
7
7
|
end
|
8
8
|
def url
|
9
9
|
get_var!(:url, <<~EOM) do |url|
|
10
|
-
|
10
|
+
This operation requires the url of your Okapi gateway, but it couldn't be found.
|
11
11
|
|
12
12
|
You can fix this by setting either the `OKAPI_URL` environment variable, or
|
13
13
|
using the `--url` option if you're using the command line.
|
14
|
+
|
15
|
+
To store a default url, run `okapi config:set OKAPI_URL=<URL>`
|
14
16
|
EOM
|
15
17
|
URI(url)
|
16
18
|
end
|
@@ -18,21 +20,25 @@ EOM
|
|
18
20
|
|
19
21
|
def tenant
|
20
22
|
get_var!(:tenant, <<~EOM)
|
21
|
-
|
23
|
+
This operation requires a tenant id, but it couldn't be found.
|
22
24
|
|
23
25
|
You can fix this by setting either the `OKAPI_TENANT` environment variable, or
|
24
26
|
using the `--tenant` option if you're using the command line.
|
27
|
+
|
28
|
+
To store a default tenant, run `okapi config:set OKAPI_TENANT=<TENANT>`
|
25
29
|
EOM
|
26
30
|
end
|
27
31
|
|
28
32
|
def token
|
29
33
|
get_var!(:token, <<~EOM)
|
30
|
-
|
34
|
+
This operation requires you to be logged in, and already authenticated with
|
31
35
|
your Okapi cluster.
|
32
36
|
|
33
37
|
You can fix this by obtaining an authenication token, and then using it by
|
34
38
|
either setting the `OKAPI_TOKEN` environment variable or using the
|
35
39
|
`--token` option from the command line.
|
40
|
+
|
41
|
+
To log in with a username and password, run the command `okapi login`.
|
36
42
|
EOM
|
37
43
|
end
|
38
44
|
|
data/lib/okapi/version.rb
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: okapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Frontside Engineering
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clamp
|
@@ -132,6 +132,7 @@ executables:
|
|
132
132
|
extensions: []
|
133
133
|
extra_rdoc_files: []
|
134
134
|
files:
|
135
|
+
- ".github/PULL_REQUEST_TEMPLATE.md"
|
135
136
|
- ".gitignore"
|
136
137
|
- ".rspec"
|
137
138
|
- ".travis.yml"
|
@@ -148,6 +149,7 @@ files:
|
|
148
149
|
- lib/okapi/cli/config.rb
|
149
150
|
- lib/okapi/settings.rb
|
150
151
|
- lib/okapi/version.rb
|
152
|
+
- okapi-command-line.gif
|
151
153
|
- okapi.gemspec
|
152
154
|
homepage: https://github.com/thefrontside/okapi.rb
|
153
155
|
licenses:
|