kandji 0.1.0 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b139dcc224da457e0570035886561f9a16445dcceb5eb87cd777f673897c0ad5
4
- data.tar.gz: 290e44ba2e0e871ef2d9a8d33958e355208bbd65a5752b56f561bd1a757c7d03
3
+ metadata.gz: ef89f9d9191ba3e53f9657c7e1610650c6374b88dbe49277af4d4a646e5b55cc
4
+ data.tar.gz: 4b5fe631e5683c689d187f81954cd5543d39ff77edbcd5ce1b9a7dadf4cf6d64
5
5
  SHA512:
6
- metadata.gz: 122742faf6495903b7174a671c781dc9ec310f83b6763c073e1d65defc2a7f239b861edc69fb42530bc1ef4b3bae6a506a0d0ab933b560d428a5e68269a6ba38
7
- data.tar.gz: 7471b5ddfd673a942f19369aa8be1ff3cf55fb5b222ee2bbbbd1cd89af24e2d541f65c6228fc7b0dc6c86f66303a6f55b6042664f411123b008aabe739a5c75c
6
+ metadata.gz: 0fb6a21eb2be362a8170f76192d71b8cbf8e249bad2bd8ae2a913d1e20b9b4acad2f6b34c960b57a955db4c834f04036878197b21a225dfe35ac6227adc62b43
7
+ data.tar.gz: 67500f6a1f3ff5c1d0e65da05c2c9a32d14cd3b69e39e8748671c9b7e9ed0deed855950f0648d2b9dce01c12034d84ac9aeb994291d8d5587d585561586d529b
data/CHANGELOG.md CHANGED
@@ -1,11 +1,21 @@
1
- ## [Unreleased]
1
+ ## [0.1.2]
2
+ - Implement endpoints:
3
+ - Devices.where_user_activation_lock_enabled
4
+ - Devices.where_filevault_recovery_key_missing
5
+
6
+ ## [0.1.1]
2
7
 
3
- - Setup configuration
4
8
  - Implement endpoints:
5
- - Devices.all
6
- - Devices.find(device_id)
7
- - Device::Applications.all
9
+ - Devices::Activities.all
10
+ - Logs.all
11
+ - Users.all
12
+ - Users.find(id)
8
13
 
9
14
  ## [0.1.0] - 2025-05-06
10
15
 
11
16
  - Initial release
17
+ - Setup configuration
18
+ - Implement endpoints:
19
+ - Devices.all
20
+ - Devices.find(device_id)
21
+ - Device::Applications.all
data/README.md CHANGED
@@ -1,28 +1,36 @@
1
1
  # Kandji
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
4
-
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/kandji`. To experiment with that code, run `bin/console` for an interactive prompt.
6
-
7
3
  ## Installation
8
4
 
9
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
-
11
5
  Install the gem and add to the application's Gemfile by executing:
12
6
 
13
7
  ```bash
14
- bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
8
+ bundle add kandji
15
9
  ```
16
10
 
17
11
  If bundler is not being used to manage dependencies, install the gem by executing:
18
12
 
19
13
  ```bash
20
- gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
14
+ gem install kandji
21
15
  ```
22
16
 
23
17
  ## Usage
24
18
 
25
- TODO: Write usage instructions here
19
+ First you will have to confige the gem. You need to setup an API key on Kandji. Once you've retrieved that, you are ready:
20
+
21
+ ```ruby
22
+ Kandji.configure do |config|
23
+ config.api_token = 'your-api-token'
24
+ config.organization_url = 'your-kanjdi-api-url'
25
+ end
26
+ ```
27
+
28
+ Then once you have the client setup, you can call the API. Some examples:
29
+
30
+ ```ruby
31
+ Kandji::Applications.all
32
+ Kandji::Users.find(user_id)
33
+ ```
26
34
 
27
35
  ## Development
28
36
 
@@ -32,7 +40,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
32
40
 
33
41
  ## Contributing
34
42
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/kandji. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/kandji/blob/main/CODE_OF_CONDUCT.md).
43
+ Bug reports and pull requests are welcome on GitHub at https://github.com/monarchmoney/kandji. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/monarchmoney/kandji/blob/main/CODE_OF_CONDUCT.md).
36
44
 
37
45
  ## License
38
46
 
@@ -40,4 +48,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
40
48
 
41
49
  ## Code of Conduct
42
50
 
43
- Everyone interacting in the Kandji project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/kandji/blob/main/CODE_OF_CONDUCT.md).
51
+ Everyone interacting in the Kandji project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/monarchmoney/kandji/blob/main/CODE_OF_CONDUCT.md).
data/lib/kandji/client.rb CHANGED
@@ -19,14 +19,30 @@ module Kandji
19
19
 
20
20
  all_results = []
21
21
  while (response = get(path, params))
22
- all_results.concat(response)
23
- break if response.size < params[:limit]
22
+ # The Kandji API can return different structures, so we handle both cases
23
+ result = response.is_a?(Array) ? response : response["data"]
24
+ all_results.concat(result)
25
+ break if result.size < params[:limit]
24
26
 
25
27
  params[:offset] += params[:limit]
26
28
  end
27
29
  all_results
28
30
  end
29
31
 
32
+ def self.paginated_cursor_get(path, params = {})
33
+ params[:limit] = params[:limit] || 500
34
+ url = build_url(path, params)
35
+
36
+ all_results = []
37
+ loop do
38
+ response = JSON.parse(RestClient.get(url, headers))
39
+ all_results.concat(response["results"])
40
+ url = response["next"]
41
+ break unless url
42
+ end
43
+ all_results
44
+ end
45
+
30
46
  def self.build_url(path, params)
31
47
  url = "#{Kandji.organization_url}/api/#{API_VERSION}/#{path}"
32
48
  url += "?#{URI.encode_www_form(params)}" unless params.empty?
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kandji
4
+ module Device
5
+ class Activities < Client
6
+ def self.all(device_id)
7
+ paginated_get("devices/#{device_id}/activity")
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kandji
4
+ class Devices < Client
5
+ def self.all(params = {})
6
+ paginated_get("devices", params)
7
+ end
8
+
9
+ def self.where_user_activation_lock_enabled
10
+ filter = { user_activation_lock_status: { eq: true } }
11
+ params = { filter: filter.to_json }
12
+
13
+ paginated_get("prism/activation_lock", params)
14
+ end
15
+
16
+ def self.where_filevault_recovery_key_missing
17
+ filter = { key_escrowed: { eq: false } }
18
+ params = { filter: filter.to_json }
19
+
20
+ paginated_get("prism/filevault", params)
21
+ end
22
+
23
+ def self.find(id)
24
+ get("devices/#{id}")
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kandji
4
+ class Logs < Client
5
+ def self.all(params = {})
6
+ paginated_cursor_get("audit/events", params)
7
+ end
8
+ end
9
+ end
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kandji
4
- class Devices < Client
4
+ class Users < Client
5
5
  def self.all(params = {})
6
- paginated_get("devices", params)
6
+ paginated_cursor_get("users", params)
7
7
  end
8
8
 
9
9
  def self.find(id)
10
- get("devices/#{id}")
10
+ get("users/#{id}")
11
11
  end
12
12
  end
13
13
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kandji
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.2"
5
5
  end
data/lib/kandji.rb CHANGED
@@ -3,7 +3,11 @@
3
3
  require_relative "kandji/version"
4
4
  require_relative "kandji/configuration"
5
5
  require_relative "kandji/client"
6
- require_relative "kandji/api"
6
+ require_relative "kandji/devices"
7
+ require_relative "kandji/device/applications"
8
+ require_relative "kandji/logs"
9
+ require_relative "kandji/device/activities"
10
+ require_relative "kandji/users"
7
11
 
8
12
  module Kandji
9
13
  extend Configuration
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kandji
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lien Van Den Steen
@@ -52,11 +52,13 @@ files:
52
52
  - README.md
53
53
  - Rakefile
54
54
  - lib/kandji.rb
55
- - lib/kandji/api.rb
56
- - lib/kandji/api/device/applications.rb
57
- - lib/kandji/api/devices.rb
58
55
  - lib/kandji/client.rb
59
56
  - lib/kandji/configuration.rb
57
+ - lib/kandji/device/activities.rb
58
+ - lib/kandji/device/applications.rb
59
+ - lib/kandji/devices.rb
60
+ - lib/kandji/logs.rb
61
+ - lib/kandji/users.rb
60
62
  - lib/kandji/version.rb
61
63
  - sig/kandji.rbs
62
64
  homepage: https://github.com/monarchmoney/kandji
data/lib/kandji/api.rb DELETED
@@ -1,4 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "api/devices"
4
- require_relative "api/device/applications"
File without changes