class ATS::AMP4E::API
Constants
- HEADERS
Attributes
bearer_token[R]
client_id[R]
client_secret[R]
host[R]
http[R]
port[R]
scheme[R]
Public Class Methods
new(configuration:, debug: false)
click to toggle source
# File lib/ats/amp4e/api.rb, line 13 def initialize(configuration:, debug: false) @http = Net::Hippie::Client.new(headers: HEADERS, verify_mode: debug ? OpenSSL::SSL::VERIFY_NONE : nil) @configuration = configuration @port = configuration[:port] @scheme = configuration[:scheme] @host = configuration[:host] @bearer_token = configuration[:bearer_token] @client_id = configuration[:client_id] @client_secret = configuration[:client_secret] end
Public Instance Methods
computers()
click to toggle source
# File lib/ats/amp4e/api.rb, line 24 def computers ATS::AMP4E::Computers.new(self) end
events()
click to toggle source
# File lib/ats/amp4e/api.rb, line 28 def events ATS::AMP4E::Events.new(self) end
get(url, params: {}, version: 1)
click to toggle source
# File lib/ats/amp4e/api.rb, line 40 def get(url, params: {}, version: 1) http.get(build_uri(url, version: version), headers: headers, body: params) do |request, response| JSON.parse(response.body, symbolize_names: true) end end
groups()
click to toggle source
# File lib/ats/amp4e/api.rb, line 32 def groups ATS::AMP4E::Groups.new(self) end
policies()
click to toggle source
# File lib/ats/amp4e/api.rb, line 36 def policies ATS::AMP4E::Policies.new(self) end
Private Instance Methods
build_uri(relative_url, version:)
click to toggle source
# File lib/ats/amp4e/api.rb, line 48 def build_uri(relative_url, version:) URI::Generic.build(host: host, port: port, scheme: scheme, path: "/v#{version}/#{relative_url}") end
headers()
click to toggle source
# File lib/ats/amp4e/api.rb, line 52 def headers if bearer_token { AUTHORIZATION: "Bearer #{bearer_token}" } else { AUTHORIZATION: "Basic #{Base64.strict_encode64("#{client_id}:#{client_secret}")}" } end end