class BBC::Cosmos::Tools::Config::API

Public Class Methods

new(host, key_path) click to toggle source
# File lib/bbc/cosmos/tools/config/api.rb, line 11
def initialize(host, key_path)
  @connection = Faraday.new host, :ssl => {:client_key => client_key(key_path), :client_cert  => client_cert(key_path), :verify => false }
end

Public Instance Methods

client_cert(path) click to toggle source
# File lib/bbc/cosmos/tools/config/api.rb, line 19
def client_cert(path)
  OpenSSL::X509::Certificate.new(File.read path)
end
client_key(path) click to toggle source
# File lib/bbc/cosmos/tools/config/api.rb, line 15
def client_key(path)
  OpenSSL::PKey::RSA.new(File.read path)
end
content_type_from(type) click to toggle source
# File lib/bbc/cosmos/tools/config/api.rb, line 32
def content_type_from(type)
  @connection.headers[:content_type] = type
end
get(path) click to toggle source
# File lib/bbc/cosmos/tools/config/api.rb, line 23
def get(path)
  @connection.get path
end
put(path, payload, content_type = 'application/json') click to toggle source
# File lib/bbc/cosmos/tools/config/api.rb, line 27
def put(path, payload, content_type = 'application/json')
  content_type_from content_type
  @connection.put path, payload
end