ninjaone 0.1.0 → 0.2.0
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 +38 -0
- data/lib/ninjaone/client/backup.rb +37 -0
- data/lib/ninjaone/client/devices.rb +63 -0
- data/lib/ninjaone/client.rb +2 -0
- data/lib/ninjaone/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d2d9edce18fc48c11d1eee0a7d87d4e3d23f3622c54d522495181f50f2004bb3
|
|
4
|
+
data.tar.gz: a99415651e31f4616c478871acc3539abdcc16d452f372a366cdc321be9ed939
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 13fe05ba9d907d7ebb217cdd79dd890e008a5805319e2de4bbcaba6a28d8f5a8f33cbed562f36797d081f823006553bbbdb4815a119a0678461b2b89bfaa5d5e
|
|
7
|
+
data.tar.gz: 4481305a4e29b2dc3e3043e05a383225790f0c745d10efcfbe5dc06368e34b5a3d0e7fed9c43c469dd27304276f6ed25f496cfafdce317c2b65c00ba36377bbb
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
|
@@ -122,6 +122,44 @@ org_devices = client.organization_devices(org.id)
|
|
|
122
122
|
|.organization_locations_backup_usage(id)|Organization location backup usage|
|
|
123
123
|
|.organization_backup_usage_by_location(id, location_id)|Organization locations backup usage|
|
|
124
124
|
|
|
125
|
+
### Backup
|
|
126
|
+
|
|
127
|
+
All apis related to backup
|
|
128
|
+
|
|
129
|
+
```ruby
|
|
130
|
+
# get failed jobs using status filter
|
|
131
|
+
failed_jobs = client.backup_jobs(sf:'status = FAILED')
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
|Resource|API endpoint|
|
|
135
|
+
|:--|:--|
|
|
136
|
+
|`backup_jobs(params)`|Returns list of backup jobs. Params is a hash for filtering the result|
|
|
137
|
+
|`backup_integrity_check_jobs(params)`|Returns a list of integrity check jobs|
|
|
138
|
+
|
|
139
|
+
### Devices
|
|
140
|
+
|
|
141
|
+
All apis related to devices.
|
|
142
|
+
|
|
143
|
+
| Resource | API endpoint |
|
|
144
|
+
|:--|:--|
|
|
145
|
+
| `device(id, params = {})` | Retrieves the details of a single device by its device ID. |
|
|
146
|
+
| `device_jobs(id, params = {})` | Retrieves all jobs associated with the specified device. |
|
|
147
|
+
| `device_activities(id, params = {})` | Retrieves activities for the specified device (e.g. filtered using `since`). |
|
|
148
|
+
| `device_alerts(id, params = {})` | Retrieves alerts related to the specified device. |
|
|
149
|
+
| `device_disks(id, params = {})` | Retrieves disk information for the specified device. |
|
|
150
|
+
| `device_processors(id, params = {})` | Retrieves processor information for the specified device. |
|
|
151
|
+
| `device_software(id, params = {})` | Retrieves installed software for the specified device. |
|
|
152
|
+
| `device_volumes(id, params = {})` | Retrieves volume information for the specified device. |
|
|
153
|
+
| `device_windows_services(id, params = {})` | Retrieves Windows services for the specified device. |
|
|
154
|
+
| `device_custom_fields(id, params = {})` | Retrieves custom fields associated with the specified device. |
|
|
155
|
+
| `device_os_patch_installs(id, params = {})` | Retrieves operating system patch installation records for the specified device. |
|
|
156
|
+
| `device_software_patch_installs(id, params = {})` | Retrieves software patch installation records for the specified device. |
|
|
157
|
+
| `device_last_logged_on_user(id, params = {})` | Retrieves information about the last logged-on user of the device. |
|
|
158
|
+
| `device_network_interfaces(id, params = {})` | Retrieves network interface information for the specified device. |
|
|
159
|
+
| `device_os_patches(id, params = {})` | Retrieves available or installed operating system patches for the device. |
|
|
160
|
+
| `device_software_patches(id, params = {})` | Retrieves available or installed software patches for the device. |
|
|
161
|
+
| `device_policy_overrides(id, params = {})` | Retrieves policy overrides applied to the specified device. |
|
|
162
|
+
|
|
125
163
|
|
|
126
164
|
## Contributing
|
|
127
165
|
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module NinjaOne
|
|
4
|
+
class Client
|
|
5
|
+
# Contains Backup-related API calls for Ninja One.
|
|
6
|
+
#
|
|
7
|
+
# @see https://app.ninjarmm.com/apidocs/?links.active=core#/Backup Ninja One Developer Documentation - Backup section
|
|
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
|
+
|
|
31
|
+
# Backup endpoints (GET)
|
|
32
|
+
backup_endpoint(:backup_jobs, 'backup/jobs')
|
|
33
|
+
backup_endpoint(:backup_integrity_check_jobs, 'backup/integrity-check-jobs')
|
|
34
|
+
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module NinjaOne
|
|
4
|
+
class Client
|
|
5
|
+
# Contains Device-related API calls for Ninja One.
|
|
6
|
+
#
|
|
7
|
+
# @see https://app.ninjarmm.com/apidocs/?links.active=core#/Devices Ninja One Developer Documentation - Device section
|
|
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
|
+
|
|
33
|
+
# Retrieves a single device by ID.
|
|
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
|
|
46
|
+
|
|
47
|
+
# Device-related GET endpoints.
|
|
48
|
+
#
|
|
49
|
+
# Each symbol below dynamically generates a method:
|
|
50
|
+
# device_<endpoint>(id, params = {})
|
|
51
|
+
#
|
|
52
|
+
# Example:
|
|
53
|
+
# device_jobs(123)
|
|
54
|
+
# device_activities(123, since: '2026-01-01T00:00:00Z')
|
|
55
|
+
#
|
|
56
|
+
[: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 |m|
|
|
58
|
+
device_endpoint(m)
|
|
59
|
+
end
|
|
60
|
+
device_endpoint(:policy_overrides, 'policy/overrides')
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
data/lib/ninjaone/client.rb
CHANGED
|
@@ -46,6 +46,8 @@ module NinjaOne
|
|
|
46
46
|
# such as managing backups and handling alerts.
|
|
47
47
|
include NinjaOne::Client::System
|
|
48
48
|
include NinjaOne::Client::Organizations
|
|
49
|
+
include NinjaOne::Client::Backup
|
|
50
|
+
include NinjaOne::Client::Devices
|
|
49
51
|
|
|
50
52
|
# Constructs the full API URL for a given path.
|
|
51
53
|
#
|
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.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Janco Tanis
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 2026-01-15 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: faraday
|
|
@@ -108,6 +108,8 @@ files:
|
|
|
108
108
|
- lib/ninjaone/api.rb
|
|
109
109
|
- lib/ninjaone/authentication.rb
|
|
110
110
|
- lib/ninjaone/client.rb
|
|
111
|
+
- lib/ninjaone/client/backup.rb
|
|
112
|
+
- lib/ninjaone/client/devices.rb
|
|
111
113
|
- lib/ninjaone/client/organizations.rb
|
|
112
114
|
- lib/ninjaone/client/system.rb
|
|
113
115
|
- lib/ninjaone/error.rb
|