Module: NinjaOne::Client::Organizations
- Included in:
- NinjaOne::Client
- Defined in:
- lib/ninjaone/client/organizations.rb
Overview
Contains Organizations API calls for Ninja One.
Class Method Summary collapse
-
.api_endpoint_suffix(method, suffix) ⇒ Object
Dynamically defines methods for interacting with NinjaOne API resources.
Instance Method Summary collapse
-
#organization_backup_usage_by_location(id, location_id, params = {}) ⇒ Object
Returns a location backup usage.
Class Method Details
.api_endpoint_suffix(method, suffix) ⇒ Object
Dynamically defines methods for interacting with NinjaOne API resources.
Depending on the arguments, this will define methods to:
-
Fetch all records for a resource
-
Fetch a specific record by ID
24 25 26 27 28 29 30 31 |
# File 'lib/ninjaone/client/organizations.rb', line 24 def self.api_endpoint_suffix(method, suffix) # Define method to fetch a single record by ID name = "#{method}_#{suffix.gsub(/[-\/]/,'_')}" send(:define_method, name) do |id, params = {}| get(api_url("#{method}/#{id}/#{suffix}"), params) end end |
Instance Method Details
#organization_backup_usage_by_location(id, location_id, params = {}) ⇒ Object
Returns a location backup usage
40 41 42 43 44 45 |
# File 'lib/ninjaone/client/organizations.rb', line 40 def organization_backup_usage_by_location(id, location_id, params={}) get(api_url("organization/#{id}/locations/#{location_id}/backup/usage"), params) rescue Faraday::ServerError # it looks like a server error is thrown when no backup is available; fake it by returning anempty array [] end |