Class: ATS::AMP4E::API
- Inherits:
-
Object
- Object
- ATS::AMP4E::API
- Defined in:
- lib/ats/amp4e/api.rb
Constant Summary collapse
- HEADERS =
{ 'Content-Type' => 'application/json', 'Accept' => 'application/json', 'User-Agent' => "RubyGems/ATS #{ATS::VERSION}", }.freeze
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
#http ⇒ Object
readonly
Returns the value of attribute http.
-
#profile ⇒ Object
readonly
Returns the value of attribute profile.
Instance Method Summary collapse
- #computers ⇒ Object
- #events ⇒ Object
- #get(url, params: {}, version: 1) ⇒ Object
- #groups ⇒ Object
-
#initialize(api: HttpAPI.new(headers: HEADERS), profile: :default, configuration: ATS.configuration) ⇒ API
constructor
A new instance of API.
- #policies ⇒ Object
Constructor Details
#initialize(api: HttpAPI.new(headers: HEADERS), profile: :default, configuration: ATS.configuration) ⇒ API
Returns a new instance of API.
12 13 14 15 16 17 18 19 20 |
# File 'lib/ats/amp4e/api.rb', line 12 def initialize( api: HttpAPI.new(headers: HEADERS), profile: :default, configuration: ATS.configuration ) @http = api @profile = profile.to_sym @configuration = configuration end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
10 11 12 |
# File 'lib/ats/amp4e/api.rb', line 10 def configuration @configuration end |
#http ⇒ Object (readonly)
Returns the value of attribute http.
10 11 12 |
# File 'lib/ats/amp4e/api.rb', line 10 def http @http end |
#profile ⇒ Object (readonly)
Returns the value of attribute profile.
10 11 12 |
# File 'lib/ats/amp4e/api.rb', line 10 def profile @profile end |
Instance Method Details
#computers ⇒ Object
22 23 24 |
# File 'lib/ats/amp4e/api.rb', line 22 def computers ATS::AMP4E::Computers.new(self) end |
#events ⇒ Object
26 27 28 |
# File 'lib/ats/amp4e/api.rb', line 26 def events ATS::AMP4E::Events.new(self) end |
#get(url, params: {}, version: 1) ⇒ Object
38 39 40 41 42 |
# File 'lib/ats/amp4e/api.rb', line 38 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 |