https://github.com/thefrontside/okapi.rb
Ruby client to communicate with an OKAPI cluster
https://github.com/thefrontside/okapi.rb
Last synced: 9 months ago
JSON representation
Ruby client to communicate with an OKAPI cluster
- Host: GitHub
- URL: https://github.com/thefrontside/okapi.rb
- Owner: thefrontside
- License: mit
- Created: 2017-09-25T15:03:58.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2018-01-17T16:05:45.000Z (over 8 years ago)
- Last Synced: 2025-09-27T21:28:59.303Z (9 months ago)
- Language: Ruby
- Size: 577 KB
- Stars: 0
- Watchers: 9
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Okapi
[](https://badge.fury.io/rb/okapi)
[](https://travis-ci.org/thefrontside/okapi.rb)
Ruby bindings and command line utility for the [Okapi][1] API gateway.
## Synopsis
To make calls to an Okapi gateway from Ruby, instantiate an instance
of the `Okapi::Client` class by passing in the URL, Tenant, and
auth_token to use for requests.
``` ruby
require 'okapi'
okapi = Okapi::Client.new('https://okapi.frontside.io', "fs", "")
okapi.get("/_/proxy/modules") //=> [{id: 'mod-kb-ebsco'}, {id: 'mod-config'}]
```
The `okapi` client has methods corresponding to the major `REST`ful
verbs: `okap.get`, `okapi.post`, `okapi.put`, `okapi.delete`
By default, even if you provided them to the constructor, the client
does not send tenant and auth information with the request. This is
because the gateway will reject requests that provide this information
when it is not needed. For example, an authorization request that
provides an auth token will result in an error, so you don't want to
send it.
To send tenant, use the `tenant` property on the client
to access an `Okapi::Client` that _will_ send tenant information.
``` ruby
okapi.tentant.post('/authn/login', username: 'admin', password: 'password')
```
To send both tenant _and_ authorization information with a request,
use the `user` property of the okapi client which will give you a
client that _will_ send both these bits of information with the
request:
``` ruby
okapi.user.get('/eholdings/configuration')
```
## Command Line
The okapi gem comes with a command line utility to help you easily
interact with an Okapi gateway from your shell.

## Installation
Add this line to your application's Gemfile:
```ruby
gem 'okapi'
```
And then execute:
$ bundle
Or install it yourself as:
$ gem install okapi
## Development
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/rspec spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
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).
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/thefrontside/okapi.rb
## License
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
[1]: https://github.com/folio-org/okapi