Class: NinjaOne::Client
- Includes:
- Organizations, System
- Defined in:
- lib/ninjaone/client.rb,
lib/ninjaone/client/system.rb,
lib/ninjaone/client/organizations.rb
Overview
All methods are grouped in separate modules for better organization and follow the structure provided in the official API documentation.
The ‘NinjaOne::Client` class acts as a wrapper for the NinjaOne REST API. This class inherits from the `NinjaOne::API` class and includes modules that group the API methods according to the structure in the NinjaOne API documentation.
Defined Under Namespace
Modules: Organizations, System
Class Method Summary collapse
-
.api_endpoint(method, singular_method = nil, path = method.to_s.tr('_', '-')) ⇒ Object
Dynamically defines methods for interacting with NinjaOne API resources.
Instance Method Summary collapse
-
#api_url(path) ⇒ String
Constructs the full API URL for a given path.
Methods included from Organizations
api_endpoint_suffix, #organization_backup_usage_by_location
Methods included from System
Methods inherited from API
Methods included from Authentication
Constructor Details
This class inherits a constructor from NinjaOne::API
Class Method Details
.api_endpoint(method, singular_method = nil, path = method.to_s.tr('_', '-')) ⇒ 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
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ninjaone/client.rb', line 27 def self.api_endpoint(method, singular_method = nil, path = method.to_s.tr('_', '-')) # Define method to fetch all records send(:define_method, method) do |params = {}| get_paged(api_url(path), params) end # Define method to fetch a single record by ID if singular_method send(:define_method, singular_method) do |id, params = {}| get(api_url("#{singular_method}/#{id}"), params) end end end |
Instance Method Details
#api_url(path) ⇒ String
Constructs the full API URL for a given path.
54 55 56 |
# File 'lib/ninjaone/client.rb', line 54 def api_url(path) "/v2/#{path}" end |