Created
June 14, 2012 18:01
-
-
Save eric/2931838 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Simple Boundary client | |
# | |
class BoundaryClient | |
def initialize(orgid, apikey) | |
@orgid = orgid | |
@apikey = apikey | |
end | |
def connection | |
@connection ||= Faraday::Connection.new("https://api.boundary.com/#{@orgid}/") do |b| | |
b.use FaradayMiddleware::EncodeJson | |
b.adapter Faraday.default_adapter | |
b.use Faraday::Response::RaiseError | |
b.use FaradayMiddleware::ParseJson | |
b.use FaradayMiddleware::Mashify | |
end.tap do |c| | |
c.basic_auth @apikey, '' | |
end | |
end | |
def conversations | |
connection.get('conversations').body.values.map { |c| Hashie::Mash.new(c) } | |
end | |
def conversation_for_name(name) | |
conversations.detect { |c| c[:name] == name } | |
end | |
def update_conversation(data) | |
connection.put("conversations/#{data[:id]}", data).body | |
end | |
def port_aliases | |
connection.get("aliases/ports").body | |
end | |
def update_port_aliases(aliases) | |
connection.put("aliases/ports", aliases) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment