Skip to content

MScottBlake/kandji-bash-sdk

Repository files navigation

Kandji API Bash client

Overview

This is a Bash client script for accessing Kandji API service.

The script uses cURL underneath for making all REST calls.

Usage

# Make sure the script has executable rights
$ chmod u+x kandji

# Print the list of operations available on the service
$ ./kandji -h

# Print the service description
$ ./kandji --about

# Print detailed information about specific operation
$ ./kandji <operationId> -h

# Make GET request
./kandji --host http://<hostname>:<port> --accept xml <operationId> <queryParam1>=<value1> <header_key1>:<header_value2>

# Make GET request using arbitrary curl options (must be passed before <operationId>) to an SSL service using username:password
kandji -k -sS --tlsv1.2 --host https://<hostname> -u <user>:<password> --accept xml <operationId> <queryParam1>=<value1> <header_key1>:<header_value2>

# Make POST request
$ echo '<body_content>' | kandji --host <hostname> --content-type json <operationId> -

# Make POST request with simple JSON content, e.g.:
# {
#   "key1": "value1",
#   "key2": "value2",
#   "key3": 23
# }
$ echo '<body_content>' | kandji --host <hostname> --content-type json <operationId> key1==value1 key2=value2 key3:=23 -

# Make POST request with form data
$ kandji --host <hostname> <operationId> key1:=value1 key2:=value2 key3:=23

# Preview the cURL command without actually executing it
$ kandji --host http://<hostname>:<port> --dry-run <operationid>

Docker image

You can easily create a Docker image containing a preconfigured environment for using the REST Bash client including working autocompletion and short welcome message with basic instructions, using the generated Dockerfile:

docker build -t my-rest-client .
docker run -it my-rest-client

By default you will be logged into a Zsh environment which has much more advanced auto completion, but you can switch to Bash, where basic autocompletion is also available.

Shell completion

Bash

The generated bash-completion script can be either directly loaded to the current Bash session using:

source kandji.bash-completion

Alternatively, the script can be copied to the /etc/bash-completion.d (or on OSX with Homebrew to /usr/local/etc/bash-completion.d):

sudo cp kandji.bash-completion /etc/bash-completion.d/kandji

OS X

On OSX you might need to install bash-completion using Homebrew:

brew install bash-completion

and add the following to the ~/.bashrc:

if [ -f $(brew --prefix)/etc/bash_completion ]; then
  . $(brew --prefix)/etc/bash_completion
fi

Zsh

In Zsh, the generated _kandji Zsh completion file must be copied to one of the folders under $FPATH variable.

Documentation for API Endpoints

All URIs are relative to **

Class Method HTTP request Description
AutomatedDeviceEnrollmentIntegrationsApi createAdeIntegration POST /api/v1/integrations/apple/ade/ Create ADE integration
AutomatedDeviceEnrollmentIntegrationsApi deleteAdeIntegration DELETE /api/v1/integrations/apple/ade/{ade_token_id} Delete ADE integration
AutomatedDeviceEnrollmentIntegrationsApi downloadAdePublicKey GET /api/v1/integrations/apple/ade/public_key/ Download ADE public key
AutomatedDeviceEnrollmentIntegrationsApi getAdeDevice GET /api/v1/integrations/apple/ade/devices/{device_id} Get ADE device
AutomatedDeviceEnrollmentIntegrationsApi getAdeIntegration GET /api/v1/integrations/apple/ade/{ade_token_id} Get ADE integration
AutomatedDeviceEnrollmentIntegrationsApi listAdeDevices GET /api/v1/integrations/apple/ade/devices List ADE devices
AutomatedDeviceEnrollmentIntegrationsApi listAdeIntegrations GET /api/v1/integrations/apple/ade List ADE integrations
AutomatedDeviceEnrollmentIntegrationsApi listDevicesAssociatedToAdeToken GET /api/v1/integrations/apple/ade/{ade_token_id}/devices List devices associated to ADE token
AutomatedDeviceEnrollmentIntegrationsApi renewAdeIntegration POST /api/v1/integrations/apple/ade/{ade_token_id}/renew Renew ADE integration
AutomatedDeviceEnrollmentIntegrationsApi updateAdeDevice PATCH /api/v1/integrations/apple/ade/devices/{device_id} Update ADE device
AutomatedDeviceEnrollmentIntegrationsApi updateAdeIntegration PATCH /api/v1/integrations/apple/ade/{ade_token_id} Update ADE integration
BlueprintsApi assignLibraryItem POST /api/v1/blueprints/{blueprint_id}/assign-library-item Assign Library Item
BlueprintsApi createBlueprint POST /api/v1/blueprints Create Blueprint
BlueprintsApi deleteBlueprint DELETE /api/v1/blueprints/{blueprint_id} Delete Blueprint
BlueprintsApi getBlueprint GET /api/v1/blueprints/{blueprint_id} Get Blueprint
BlueprintsApi getBlueprintTemplates GET /api/v1/blueprints/templates/ Get Blueprint Templates
BlueprintsApi getManualEnrollmentProfile GET /api/v1/blueprints/{blueprint_id}/ota-enrollment-profile Get Manual Enrollment Profile
BlueprintsApi listBlueprints GET /api/v1/blueprints List Blueprints
BlueprintsApi listLibraryItems GET /api/v1/blueprints/{blueprint_id}/list-library-items List Library Items
BlueprintsApi removeLibraryItem POST /api/v1/blueprints/{blueprint_id}/remove-library-item Remove Library Item
BlueprintsApi updateBlueprint PATCH /api/v1/blueprints/{blueprint_id} Update Blueprint
DeviceActionsApi clearPasscode POST /api/v1/devices/{device_id}/action/clearpasscode Clear Passcode
DeviceActionsApi deleteDevice DELETE /api/v1/devices/{device_id} Delete Device
DeviceActionsApi deleteUser POST /api/v1/devices/{device_id}/action/deleteuser Delete User
DeviceActionsApi eraseDevice POST /api/v1/devices/{device_id}/action/erase Erase Device
DeviceActionsApi getDeviceCommands GET /api/v1/devices/{device_id}/commands Get Device Commands
DeviceActionsApi lockDevice POST /api/v1/devices/{device_id}/action/lock Lock Device
DeviceActionsApi reinstallAgent POST /api/v1/devices/{device_id}/action/reinstallagent Reinstall Agent
DeviceActionsApi remoteDesktop POST /api/v1/devices/{device_id}/action/remotedesktop Remote Desktop
DeviceActionsApi renewMdmProfile POST /api/v1/devices/{device_id}/action/renewmdmprofile Renew MDM Profile
DeviceActionsApi restartDevice POST /api/v1/devices/{device_id}/action/restart Restart Device
DeviceActionsApi sendBlankpush POST /api/v1/devices/{device_id}/action/blankpush Send Blankpush
DeviceActionsApi setName POST /api/v1/devices/{device_id}/action/setname Set Name
DeviceActionsApi shutdown POST /api/v1/devices/{device_id}/action/shutdown Shutdown
DeviceActionsApi unlockAccount POST /api/v1/devices/{device_id}/action/unlockaccount Unlock Account
DeviceActionsApi updateInventory POST /api/v1/devices/{device_id}/action/updateinventory Update Inventory
DeviceInformationApi cancelLostMode DELETE /api/v1/devices/{device_id}/details/lostmode Cancel Lost Mode
DeviceInformationApi getDevice GET /api/v1/devices/{device_id} Get Device
DeviceInformationApi getDeviceActivity GET /api/v1/devices/{device_id}/activity Get Device Activity
DeviceInformationApi getDeviceApps GET /api/v1/devices/{device_id}/apps Get Device Apps
DeviceInformationApi getDeviceDetails GET /api/v1/devices/{device_id}/details Get Device Details
DeviceInformationApi getDeviceLibraryItems GET /api/v1/devices/{device_id}/library-items Get Device Library Items
DeviceInformationApi getDeviceLostModeDetails GET /api/v1/devices/{device_id}/details/lostmode Get Device Lost Mode details
DeviceInformationApi getDeviceParameters GET /api/v1/devices/{device_id}/parameters Get Device Parameters
DeviceInformationApi getDeviceStatus GET /api/v1/devices/{device_id}/status Get Device Status
DeviceInformationApi listDevices GET /api/v1/devices List Devices
DeviceInformationApi updateDevice PATCH /api/v1/devices/{device_id} Update Device
DeviceSecretsApi getActivationLockBypassCode GET /api/v1/devices/{device_id}/secrets/bypasscode Get Activation Lock Bypass Code
DeviceSecretsApi getFilevaultRecoveryKey GET /api/v1/devices/{device_id}/secrets/filevaultkey Get FileVault Recovery Key
DeviceSecretsApi getRecoveryLockPassword GET /api/v1/devices/{device_id}/secrets/recoverypassword Get Recovery Lock Password
DeviceSecretsApi getUnlockPin GET /api/v1/devices/{device_id}/secrets/unlockpin Get Unlock Pin
LibraryItemsApi getLibraryItemActivity GET /api/v1/library/library-items/{library_item_id}/activity Get Library Item Activity
LibraryItemsApi getLibraryItemStatuses GET /api/v1/library/library-items/{library_item_id}/status Get Library Item Statuses
PrismApi activationLock GET /api/v1/prism/activation_lock Activation lock
PrismApi applicationFirewall GET /api/v1/prism/application_firewall Application firewall
PrismApi applications GET /api/v1/prism/apps Applications
PrismApi certificates GET /api/v1/prism/certificates Certificates
PrismApi count GET /api/v1/prism/count Count
PrismApi desktopAndScreensaver GET /api/v1/prism/desktop_and_screensaver Desktop and Screensaver
PrismApi deviceInformation GET /api/v1/prism/device_information Device information
PrismApi filevault GET /api/v1/prism/filevault FileVault
PrismApi gatekeeperAndXprotect GET /api/v1/prism/gatekeeper_and_xprotect Gatekeeper and XProtect
PrismApi getCategoryExport GET /api/v1/prism/export/{export_id} Get category export
PrismApi installedProfiles GET /api/v1/prism/installed_profiles Installed profiles
PrismApi kernelExtensions GET /api/v1/prism/kernel_extensions Kernel Extensions
PrismApi launchAgentsAndDaemons GET /api/v1/prism/launch_agents_and_daemons Launch Agents and Daemons
PrismApi localUsers GET /api/v1/prism/local_users Local users
PrismApi requestCategoryExport POST /api/v1/prism/export Request category export
PrismApi startupSettings GET /api/v1/prism/startup_settings Startup settings
PrismApi systemExtensions GET /api/v1/prism/system_extensions System Extensions
PrismApi transparencyDatabase GET /api/v1/prism/transparency_database Transparency database
SettingsApi licensing GET /api/v1/settings/licensing Licensing
TagsApi createTag POST /api/v1/tags Create Tag
TagsApi deleteTag DELETE /api/v1/tags/{tag_id} Delete Tag
TagsApi getTags GET /api/v1/tags Get Tags
TagsApi updateTag PATCH /api/v1/tags/{tag_id} Update Tag
ThreatsApi getThreatDetails GET /api/v1/threat-details Get Threat Details
UsersApi deleteUser DELETE /api/v1/users/{user_id} Delete User
UsersApi getUser GET /api/v1/users/{user_id} Get User
UsersApi listUsers GET /api/v1/users List Users
VulnerabilitiesApi getVulnerabilityDescription GET /api/v1/vulnerability-management/vulnerabilities/{cve_id} Get Vulnerability Description
VulnerabilitiesApi listAffectedApps GET /api/v1/vulnerability-management/vulnerabilities/{cve_id}/applications List Affected Apps
VulnerabilitiesApi listAffectedDevices GET /api/v1/vulnerability-management/vulnerabilities/{cve_id}/devices List Affected Devices
VulnerabilitiesApi listDetections GET /api/v1/vulnerability-management/detections List Detections
VulnerabilitiesApi listVulnerabilities GET /api/v1/vulnerability-management/vulnerabilities List Vulnerabilities

Documentation For Models

Documentation For Authorization

bearer

  • Type: HTTP Bearer Token authentication (API Token)