ninjaone 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +31 -31
- data/lib/ninjaone/client/backup.rb +2 -24
- data/lib/ninjaone/client/devices.rb +4 -39
- data/lib/ninjaone/client/organizations.rb +6 -29
- data/lib/ninjaone/client/system.rb +24 -22
- data/lib/ninjaone/client.rb +30 -15
- data/lib/ninjaone/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 69cf374dfc56664fdbbc61533fcffbc84cc8f378cc422641be286b5740d04d8f
|
|
4
|
+
data.tar.gz: e4f573f19bb88b7173a035622e65a86119ca20276806fa4df2ce40d2752adc29
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '0090ba275e371d7064dee5ca2f432eb239ef6d31aa0aba63849c740834cc0c2cb6456d4d7f588a99475cb9ffa1add1c1349973b61c6c34e5ae3a90ae95b2966f'
|
|
7
|
+
data.tar.gz: 7d07158ecb6ab23ea23587453dfdadaf35df8906c8f5fbefa0c51e220782a866955338ca4dd849e9b49142dfd6c0f428859f60fe8ead3b401c072354489d97e2
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
|
@@ -66,7 +66,7 @@ client.login
|
|
|
66
66
|
|
|
67
67
|
|Resource|API endpoint|
|
|
68
68
|
|:--|:--|
|
|
69
|
-
|
|
69
|
+
|`login`|https://app.ninjarmm.com/apidocs/?links.active=authorization|
|
|
70
70
|
|
|
71
71
|
### System
|
|
72
72
|
|
|
@@ -78,29 +78,29 @@ subscriptions = client.subscriptions
|
|
|
78
78
|
|
|
79
79
|
|Resource|API endpoint|
|
|
80
80
|
|:--|:--|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
81
|
+
|`contacts`, `contact(id)`|List contact and get contact details|
|
|
82
|
+
|`organizations`|list organizations|
|
|
83
|
+
|`policies`|list policies|
|
|
84
|
+
|`jobs`|list active jobs|
|
|
85
|
+
|`activities`|list activities|
|
|
86
|
+
|`alerts`|List active alerts (triggered conditions)|
|
|
87
|
+
|`automation_scripts`|List available automation scripts|
|
|
88
|
+
|`device_custom_fields`|List device custom fields|
|
|
89
|
+
|`devices`|List devices|
|
|
90
|
+
|`devices_detailed`|List devices(deatiled)|
|
|
91
|
+
|`notification_channels_enabled`|List enabled notification channels|
|
|
92
|
+
|`notification_channels`|List all notification channels|
|
|
93
|
+
|`notification_channels_detailed`|List all notification channels detailed|
|
|
94
|
+
|`groups`|List all groups (saved searches)|
|
|
95
|
+
|`locations`|List all locations|
|
|
96
|
+
|`roles`|List device roles|
|
|
97
|
+
|`tasks`|List scheduled tasks|
|
|
98
|
+
|`software_products`|List supported 3rd party software|
|
|
99
|
+
|`users`|List users|
|
|
100
|
+
|`search_devices(query_string)`|Find devices|
|
|
101
|
+
|`user_end_users`|End user list|
|
|
102
|
+
|`user_technicians`|Technicians list|
|
|
103
|
+
|`user_roles`|Get user roles|
|
|
104
104
|
|
|
105
105
|
### Organizations
|
|
106
106
|
|
|
@@ -114,13 +114,13 @@ org_devices = client.organization_devices(org.id)
|
|
|
114
114
|
|
|
115
115
|
|Resource|API endpoint|
|
|
116
116
|
|:--|:--|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
117
|
+
|`organizations`,`organization(id)`|List organizations or get one by id|
|
|
118
|
+
|`organization_locations(id)`|Organization locations|
|
|
119
|
+
|`organization_end_users(id)`|List users|
|
|
120
|
+
|`organization_custom_fields(id)`|Organization custom fields|
|
|
121
|
+
|`organization_devices(id)`|Organization devices|
|
|
122
|
+
|`organization_locations_backup_usage(id)`|Organization location backup usage|
|
|
123
|
+
|`organization_backup_usage_by_location(id, location_id)`|Organization locations backup usage|
|
|
124
124
|
|
|
125
125
|
### Backup
|
|
126
126
|
|
|
@@ -6,32 +6,10 @@ module NinjaOne
|
|
|
6
6
|
#
|
|
7
7
|
# @see https://app.ninjarmm.com/apidocs/?links.active=core#/Backup Ninja One Developer Documentation - Backup section
|
|
8
8
|
module Backup
|
|
9
|
-
# Dynamically defines methods for interacting with NinjaOne API resources.
|
|
10
|
-
#
|
|
11
|
-
# Depending on the arguments, this will define methods to:
|
|
12
|
-
# - Fetch all records for a resource
|
|
13
|
-
# - Fetch a specific record by ID
|
|
14
|
-
#
|
|
15
|
-
# @param method [Symbol] The method name for fetching all records.
|
|
16
|
-
# @param path [String] The API path for the resource. Defaults to the method name.
|
|
17
|
-
#
|
|
18
|
-
# @example Defining endpoints
|
|
19
|
-
# api_endpoint :companies, :company
|
|
20
|
-
# # Defines:
|
|
21
|
-
# # - `companies(params = {})` to fetch all companies.
|
|
22
|
-
# # - `company(id, params = {})` to fetch a single company by ID.
|
|
23
|
-
def self.backup_endpoint(method, path = method.to_s.tr('_', '-'))
|
|
24
|
-
# Define method to fetch all records
|
|
25
|
-
send(:define_method, method) do |params = {}|
|
|
26
|
-
results = get(api_url(path), params)
|
|
27
|
-
results.results
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
9
|
|
|
31
10
|
# Backup endpoints (GET)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
11
|
+
Client::define_endpoint('backup/jobs')
|
|
12
|
+
Client::define_endpoint('backup/integrity-check-jobs')
|
|
35
13
|
end
|
|
36
14
|
end
|
|
37
15
|
end
|
|
@@ -6,43 +6,8 @@ module NinjaOne
|
|
|
6
6
|
#
|
|
7
7
|
# @see https://app.ninjarmm.com/apidocs/?links.active=core#/Devices Ninja One Developer Documentation - Device section
|
|
8
8
|
module Devices
|
|
9
|
-
# Defines a device-specific API endpoint method dynamically.
|
|
10
|
-
#
|
|
11
|
-
# This helper creates instance methods in the form of:
|
|
12
|
-
# device_<method>(id, params = {})
|
|
13
|
-
#
|
|
14
|
-
# Example:
|
|
15
|
-
# device_endpoint(:jobs)
|
|
16
|
-
# # => defines #device_jobs(id, params = {})
|
|
17
|
-
#
|
|
18
|
-
# @param method [Symbol]
|
|
19
|
-
# The method name suffix to generate (e.g., :jobs, :alerts).
|
|
20
|
-
#
|
|
21
|
-
# @param path [String]
|
|
22
|
-
# The API path segment. Defaults to the method name with
|
|
23
|
-
# underscores replaced by hyphens.
|
|
24
|
-
#
|
|
25
|
-
# @return [void]
|
|
26
|
-
def self.device_endpoint(method, path = method.to_s.tr('_', '-'))
|
|
27
|
-
# Define method to fetch all records for device
|
|
28
|
-
send(:define_method, "device_#{method}") do |id, params = {}|
|
|
29
|
-
get(api_url("device/#{id}/#{path}"), params)
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
9
|
|
|
33
|
-
|
|
34
|
-
#
|
|
35
|
-
# @param id [Integer, String]
|
|
36
|
-
# The NinjaOne device ID.
|
|
37
|
-
#
|
|
38
|
-
# @param params [Hash, nil]
|
|
39
|
-
# Optional query parameters.
|
|
40
|
-
#
|
|
41
|
-
# @return [Hash]
|
|
42
|
-
# The device details returned by the API.
|
|
43
|
-
def device(id, params = nil)
|
|
44
|
-
get(api_url("device/#{id}"), params)
|
|
45
|
-
end
|
|
10
|
+
Client::define_endpoint(:device, '')
|
|
46
11
|
|
|
47
12
|
# Device-related GET endpoints.
|
|
48
13
|
#
|
|
@@ -54,10 +19,10 @@ module NinjaOne
|
|
|
54
19
|
# device_activities(123, since: '2026-01-01T00:00:00Z')
|
|
55
20
|
#
|
|
56
21
|
[:jobs, :activities, :alerts, :disks, :processors, :software, :volumes, :windows_services, :custom_fields,
|
|
57
|
-
:os_patch_installs, :software_patch_installs, :last_logged_on_user, :network_interfaces, :os_patches, :software_patches].each do |
|
|
58
|
-
|
|
22
|
+
:os_patch_installs, :software_patch_installs, :last_logged_on_user, :network_interfaces, :os_patches, :software_patches].each do |resource|
|
|
23
|
+
Client::define_endpoint(:device, resource.to_s.gsub('_','-'))
|
|
59
24
|
end
|
|
60
|
-
|
|
25
|
+
Client::define_endpoint(:device, 'policy/overrides')
|
|
61
26
|
end
|
|
62
27
|
end
|
|
63
28
|
end
|
|
@@ -6,41 +6,18 @@ module NinjaOne
|
|
|
6
6
|
#
|
|
7
7
|
# @see https://app.ninjarmm.com/apidocs/?links.active=core#/organization Ninja One Developer Documentation
|
|
8
8
|
module Organizations
|
|
9
|
-
# Dynamically defines methods for interacting with NinjaOne API resources.
|
|
10
|
-
#
|
|
11
|
-
# Depending on the arguments, this will define methods to:
|
|
12
|
-
# - Fetch all records for a resource
|
|
13
|
-
# - Fetch a specific record by ID
|
|
14
|
-
#
|
|
15
|
-
# @param method [Symbol] The method name for fetching all records.
|
|
16
|
-
# @param singular_method [Symbol, nil] The method name for fetching a single record by ID. Optional.
|
|
17
|
-
# @param path [String] The API path for the resource. Defaults to the method name.
|
|
18
|
-
#
|
|
19
|
-
# @example Defining endpoints
|
|
20
|
-
# api_endpoint :companies, :company
|
|
21
|
-
# # Defines:
|
|
22
|
-
# # - `companies(params = {})` to fetch all companies.
|
|
23
|
-
# # - `company(id, params = {})` to fetch a single company by ID.
|
|
24
|
-
def self.api_endpoint_suffix(method, suffix)
|
|
25
|
-
# Define method to fetch a single record by ID
|
|
26
|
-
name = "#{method}_#{suffix.gsub(/[-\/]/,'_')}"
|
|
27
9
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
api_endpoint_suffix(:organization, 'locations')
|
|
34
|
-
api_endpoint_suffix(:organization, 'end-users')
|
|
35
|
-
api_endpoint_suffix(:organization, 'custom-fields')
|
|
36
|
-
api_endpoint_suffix(:organization, 'devices')
|
|
37
|
-
api_endpoint_suffix(:organization, 'locations/backup/usage')
|
|
10
|
+
Client::define_endpoint(:organization, 'locations')
|
|
11
|
+
Client::define_endpoint(:organization, 'end-users')
|
|
12
|
+
Client::define_endpoint(:organization, 'custom-fields')
|
|
13
|
+
Client::define_endpoint(:organization, 'devices')
|
|
14
|
+
Client::define_endpoint(:organization, 'locations/backup/usage')
|
|
38
15
|
|
|
39
16
|
# Returns a location backup usage
|
|
40
17
|
def organization_backup_usage_by_location(id, location_id, params={})
|
|
41
18
|
get(api_url("organization/#{id}/locations/#{location_id}/backup/usage"), params)
|
|
42
19
|
rescue Faraday::ServerError
|
|
43
|
-
# it looks like a server error is thrown when no backup is available; fake it by returning
|
|
20
|
+
# it looks like a server error is thrown when no backup is available; fake it by returning an empty array
|
|
44
21
|
[]
|
|
45
22
|
end
|
|
46
23
|
end
|
|
@@ -7,28 +7,30 @@ module NinjaOne
|
|
|
7
7
|
# @see https://app.ninjarmm.com/apidocs/?links.active=core#/system Ninja One Developer Documentation
|
|
8
8
|
module System
|
|
9
9
|
|
|
10
|
-
Client::
|
|
11
|
-
Client::
|
|
12
|
-
Client::
|
|
13
|
-
Client::
|
|
14
|
-
Client::
|
|
15
|
-
Client::
|
|
16
|
-
Client::
|
|
17
|
-
Client::
|
|
18
|
-
Client::
|
|
19
|
-
Client::
|
|
20
|
-
Client::
|
|
21
|
-
Client::
|
|
22
|
-
Client::
|
|
23
|
-
Client::
|
|
24
|
-
Client::
|
|
25
|
-
Client::
|
|
26
|
-
Client::
|
|
27
|
-
Client::
|
|
28
|
-
Client::
|
|
29
|
-
Client::
|
|
30
|
-
Client::
|
|
31
|
-
Client::
|
|
10
|
+
Client::define_endpoint(:contacts)
|
|
11
|
+
Client::define_endpoint(:contact, '')
|
|
12
|
+
Client::define_endpoint(:organizations)
|
|
13
|
+
Client::define_endpoint(:organization, '')
|
|
14
|
+
Client::define_endpoint('organizations-detailed')
|
|
15
|
+
Client::define_endpoint(:policies)
|
|
16
|
+
Client::define_endpoint(:jobs)
|
|
17
|
+
Client::define_endpoint(:activities)
|
|
18
|
+
Client::define_endpoint(:alerts)
|
|
19
|
+
Client::define_endpoint('automation/scripts')
|
|
20
|
+
Client::define_endpoint(:devices)
|
|
21
|
+
Client::define_endpoint('devices-detailed')
|
|
22
|
+
Client::define_endpoint('notification-channels/enabled')
|
|
23
|
+
Client::define_endpoint('notification-channels')
|
|
24
|
+
Client::define_endpoint(:groups)
|
|
25
|
+
Client::define_endpoint(:locations)
|
|
26
|
+
Client::define_endpoint(:roles)
|
|
27
|
+
Client::define_endpoint(:tasks)
|
|
28
|
+
Client::define_endpoint('software-products')
|
|
29
|
+
Client::define_endpoint(:users)
|
|
30
|
+
Client::define_endpoint('user/end-users')
|
|
31
|
+
Client::define_endpoint('user/roles')
|
|
32
|
+
Client::define_endpoint('user/technicians')
|
|
33
|
+
Client::define_endpoint('devices/search')
|
|
32
34
|
|
|
33
35
|
def search_devices(query_string, options={})
|
|
34
36
|
devices_search(options.merge({q:query_string}))
|
data/lib/ninjaone/client.rb
CHANGED
|
@@ -9,34 +9,50 @@ module NinjaOne
|
|
|
9
9
|
# @note All methods are grouped in separate modules for better organization and follow the structure provided in the official API documentation.
|
|
10
10
|
# @see https://developers.skykick.com/Guides/Authentication
|
|
11
11
|
class Client < API
|
|
12
|
+
|
|
13
|
+
# Constructs url resource name from url path
|
|
14
|
+
#
|
|
15
|
+
# @param path [String] Resource name
|
|
16
|
+
# @return [String] translated from /- to _
|
|
17
|
+
def self.resource_to_name(path)
|
|
18
|
+
path.to_s.gsub(/[-\/]/,'_')
|
|
19
|
+
end
|
|
20
|
+
|
|
12
21
|
# Dynamically defines methods for interacting with NinjaOne API resources.
|
|
13
22
|
#
|
|
14
23
|
# Depending on the arguments, this will define methods to:
|
|
15
|
-
# - Fetch all records for
|
|
16
|
-
# - Fetch a specific record by ID
|
|
24
|
+
# - Fetch all records for the given scope
|
|
25
|
+
# - Fetch a resource specific record by ID
|
|
26
|
+
#
|
|
27
|
+
# @param scope [Symbol] The method name for fetching all records.
|
|
28
|
+
# @param resource [String] If given, fetches all records for scope by id. If empty string, it will load single scope record
|
|
17
29
|
#
|
|
18
|
-
#
|
|
19
|
-
# @param singular_method [Symbol, nil] The method name for fetching a single record by ID. Optional.
|
|
20
|
-
# @param path [String] The API path for the resource. Defaults to the method name.
|
|
30
|
+
# Paging is not supported.
|
|
21
31
|
#
|
|
22
32
|
# @example Defining endpoints
|
|
23
33
|
# api_endpoint :companies, :company
|
|
24
34
|
# # Defines:
|
|
25
35
|
# # - `companies(params = {})` to fetch all companies.
|
|
26
36
|
# # - `company(id, params = {})` to fetch a single company by ID.
|
|
27
|
-
def self.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
send(:define_method,
|
|
35
|
-
get(api_url(
|
|
37
|
+
def self.define_endpoint(scope, resource = nil)
|
|
38
|
+
if resource
|
|
39
|
+
name = self.resource_to_name(scope)
|
|
40
|
+
name = "#{name}_#{self.resource_to_name(resource)}" if resource && !resource.empty?
|
|
41
|
+
# change to nil if resource is empty so we ar eable to generate /scope/id/resource
|
|
42
|
+
# but also /scope/id without training /
|
|
43
|
+
resource = resource&.empty? ? nil : resource
|
|
44
|
+
send(:define_method, name) do |id, params = {}|
|
|
45
|
+
get(api_url([scope, id, resource].compact.join('/')), params)
|
|
46
|
+
end
|
|
47
|
+
else
|
|
48
|
+
name = self.resource_to_name(scope)
|
|
49
|
+
send(:define_method, name) do |params = {}|
|
|
50
|
+
get(api_url(scope), params)
|
|
36
51
|
end
|
|
37
52
|
end
|
|
38
53
|
end
|
|
39
54
|
|
|
55
|
+
|
|
40
56
|
# Dynamically require all files in the `client` directory.
|
|
41
57
|
# This will load additional API modules as separate files for better modularity and code organization.
|
|
42
58
|
Dir[File.expand_path('client/*.rb', __dir__)].each { |f| require f }
|
|
@@ -56,6 +72,5 @@ module NinjaOne
|
|
|
56
72
|
def api_url(path)
|
|
57
73
|
"/v2/#{path}"
|
|
58
74
|
end
|
|
59
|
-
|
|
60
75
|
end
|
|
61
76
|
end
|
data/lib/ninjaone/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ninjaone
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Janco Tanis
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-01-
|
|
10
|
+
date: 2026-01-16 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: faraday
|