ninjarmm

package module
v0.2.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2024 License: MIT Imports: 11 Imported by: 0

README

Table of contents:

Description

This is a Go client for the NinjaRMM API for EU region.

Login is required the first time you launch the client and information is stored internally in the package. The package automatically refresh the token when it's expired.

To get a valid Client ID and Client Secret you can read the Ninja Documentation API.

Version

NinjaAPI v2.0.9-draft

Installation

go get github.com/provectio/go-ninjarmm@latest

Then you can import the package in your code:

import "github.com/provectio/go-ninjarmm"

Examples

Login

You need call this function only one time. After, for each request, the package automatically refresh the token when it's expired whit same client-id, client-secret and scope from the first call.

err := ninjarmm.Login("<client-id>", "<client-secret>", "monitoring management control")
if err != nil {
  panic(err)
}

Find devices

search := "my-hostname"
limit := 10

devices, err := ninjarmm.FindDevices(search, limit)
if err != nil {
  panic(err)
}

for _, device := range devices {
  fmt.Println(device)
}

Create organization

newOrg := ninjarmm.OrganizationDetailed{
  Name: "My new organization",
  Description: "My description",
  NodeApprovalMode: ninjarmm.ApprovalModeAutomatic,
  Tags: []string{"tag1", "tag2"},
  Fields: map[string]interface{}{
    "my_custom_field": "my custom value",
  },
  Locations: []ninjarmm.Location{
    {
      Name: "My location",
      Description: "My location description",
      Address: "My address",
      Tags: []string{"tag1", "tag2"},
      Fields: map[string]interface{}{
        "my_custom_field": "my custom value",
      },
    },
  },
  Policies: ninjarmm.OrganizationPolicyItem{
    NodeRoleID: 0,
    PolicyID: 0,
  }
}

org, err := ninjarmm.CreateOrganization(newOrg, 0)
if err != nil {
  panic(err)
}

fmt.Println(org)

Authors

Feel free to contribute to this project by creating a pull request or issue.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Login

func Login(options ...string) (err error)

Login to the NinjaRMM API with valid `cliendID`, `clientSecret` and `scope`.

See https://eu.ninjarmm.com/apidocs-beta/authorization/create-applications/machine-to-machine-apps to create your client ID and secret.

Usage:

err := Login("clientID", "clientSecret", "monitoring management control")
if err != nil {
	panic(err)
}

func SetDeviceCustomFields added in v0.0.8

func SetDeviceCustomFields(deviceID int, customFields CustomFields) (err error)

func SetLocationCustomFields added in v0.1.0

func SetLocationCustomFields(organizationID, locationID int, customFields CustomFields) (err error)

Update location custom field values

See https://app.ninjarmm.com/apidocs-beta/core-resources/operations/updateNodeAttributeValues_2

func SetOrganizationCustomFields added in v0.0.6

func SetOrganizationCustomFields(organizationID int, customFields CustomFields) (err error)

Update a set of custom fields for an organization

See https://eu.ninjarmm.com/apidocs-beta/core-resources/operations/updateNodeAttributeValues_1

func UpdateLocation added in v0.1.0

func UpdateLocation(organizationID, locationID int, location Location) (err error)

Change location name, address, description, custom data

See https://app.ninjarmm.com/apidocs-beta/core-resources/operations/updateLocation

func UpdateOrganization added in v0.0.7

func UpdateOrganization(organization Organization) (err error)

Update an organization

See https://eu.ninjarmm.com/apidocs-beta/core-resources/operations/updateOrganization

func UpdateOrganizationDocument added in v0.0.8

func UpdateOrganizationDocument(organizationID int, document Document) (err error)

func UpdateOrganizationPolicies added in v0.1.7

func UpdateOrganizationPolicies(organizationID int, policies []OrganizationPolicyItem) (affectedDevicesIDs []int, err error)

Change organization policy mappings

See https://eu.ninjarmm.com/apidocs-beta/core-resources/operations/updateNodeRolePolicyAssignmentForOrganization

Types

type Activity added in v0.0.6

type Activity struct {
	ID              int         `json:"id"`
	ActivityTime    Time        `json:"activityTime"`
	DeviceID        int         `json:"deviceId"`
	SeriesUID       string      `json:"seriesUid"`
	StatusCode      string      `json:"statusCode"`
	Status          string      `json:"status"`
	SourceConfigUID string      `json:"sourceConfigUid"`
	SourceName      string      `json:"sourceName"`
	Subject         string      `json:"subject"`
	UserID          int         `json:"userId"`
	Message         string      `json:"message"`
	Type            string      `json:"type"`
	Data            interface{} `json:"data"`

	Severity       `json:"severity"`
	Priority       `json:"priority"`
	ActivityType   `json:"activityType"`
	ActivityResult `json:"activityResult"`
}

type ActivityLog added in v0.0.6

type ActivityLog struct {
	LastActivityID int        `json:"lastActivityId"`
	Activities     []Activity `json:"activities"`
}

func GetActivityLog added in v0.0.6

func GetActivityLog(options ActivityLogOptions) (activityLog ActivityLog, err error)

Get activity log in reverse chronological order

See https://eu.ninjarmm.com/apidocs-beta/core-resources/operations/getActivities

type ActivityLogOptions added in v0.0.6

type ActivityLogOptions struct {
	// Return activities recorded after to specified date
	AfterDate string `url:"after,omitempty"`

	// Return activities recorded prior to specified date
	BeforeDate string `url:"before,omitempty"`

	// Activity Class (System/Device) filter (allowed: SYSTEM, DEVICE, USER or ALL) (default: ALL)
	Class string `url:"class,omitempty"`

	// Device filter (See https://eu.ninjarmm.com/apidocs-beta/core-resources/articles/devices/device-filters)
	DeviceFilter string `url:"df,omitempty"`

	// Language tag
	Language string `url:"lang,omitempty"`

	// Return activities recorded that are older than specified activity ID
	NewerThanActivityID int `url:"newerThan,omitempty"`

	// Return activities recorded that are newer than specified activity ID
	OlderThanActivityID int `url:"olderThan,omitempty"`

	// Limit number of activities to return (10 >= v <= 1000) (default: 200)
	PageSize int `url:"pageSize,omitempty"`

	// Return activities related to alert (series)
	SeriesUID string `url:"seriesUid,omitempty"`

	// Directed to a specific script
	SourceConfigUID string `url:"sourceConfigUid,omitempty"`

	// Return activities with status(es)
	Status string `url:"status,omitempty"`

	// Return activities of type
	Type string `url:"type,omitempty"`

	// Time Zone
	TimeZone string `url:"tz,omitempty"`

	// Return activities for user(s)
	User string `url:"user,omitempty"`
}

type ActivityResult added in v0.0.6

type ActivityResult string
const (
	ActivityResultSuccess     ActivityResult = "SUCCESS"
	ActivityResultFailure     ActivityResult = "FAILURE"
	ActivityResultUnsupported ActivityResult = "UNSUPPORTED"
	ActivityResultUncompleted ActivityResult = "UNCOMPLETED"
)

type ActivityType added in v0.0.6

type ActivityType string
const (
	ActivityTypeActionSet         ActivityType = "ACTIONSET"
	ActivityTypeAction            ActivityType = "ACTION"
	ActivityTypeCondition         ActivityType = "CONDITION"
	ActvityTypeConditionActionSet ActivityType = ActivityTypeCondition + "_ACTIONSET"
	ActivityTypeConditionAction   ActivityType = ActivityTypeCondition + "_ACTION"
	ActivityTypeAntivirus         ActivityType = "ANTIVIRUS"
	ActivityTypePatchManagement   ActivityType = "PATCH_MANAGEMENT"
	ActivityTypeTeamViewer        ActivityType = "TEAMVIEWER"
	ActivityTypeMonitor           ActivityType = "MONITOR"
	ActivityTypeSystem            ActivityType = "SYSTEM"
	ActivityTypeComment           ActivityType = "COMMENT"
	ActivityTypeShadowProtect     ActivityType = "SHADOWPROTECT"
	ActivityTypeImageManager      ActivityType = "IMAGEMANAGER"
	ActivityTypeHelpRequest       ActivityType = "HELP_REQUEST"
	ActivityTypeSoftwarePatch     ActivityType = "SOFTWARE_PATCH_MANAGEMENT"
	ActivityTypeSplashtop         ActivityType = "SPLASHTOP"
	ActivityTypeCloudBerry        ActivityType = "CLOUDBERRY"
	ActivityTypeCloudBerryBackup  ActivityType = ActivityTypeCloudBerry + "_BACKUP"
	ActivityTypeScheduledTask     ActivityType = "SCHEDULED_TASK"
	ActivityTypeRDP               ActivityType = "RDP"
	ActivityTypeScripting         ActivityType = "SCRIPTING"
	ActivityTypeSecurity          ActivityType = "SECURITY"
	ActivityTypeRemoteTools       ActivityType = "REMOTE_TOOLS"
	ActivityTypeVirtualization    ActivityType = "VIRTUALIZATION"
	ActivityTypePSA               ActivityType = "PSA"
	ActivityTypeMDM               ActivityType = "MDM"
	ActivityTypeNinjaRemote       ActivityType = "NINJA_REMOTE"
	ActivityTypeNinjaQuickConnect ActivityType = "NINJA_QUICK_CONNECT"
	ActivityTypeNinjaDiscovery    ActivityType = "NINJA_NETWORK_DISCOVERY"
)

type Alert added in v0.0.7

type Alert struct {
	UID              string      `json:"uid"`              // Alert UID (activity series UID)
	DeviceID         int         `json:"deviceId"`         // Device identifier
	Message          string      `json:"message"`          // Alert message
	CreateTime       Time        `json:"createTime"`       // Alert creation timestamp
	UpdateTime       Time        `json:"updateTime"`       // Alert last updated
	SourceType       AlertOrigin `json:"sourceType"`       // Alert origin
	SourceConfigUID  string      `json:"sourceConfigUid"`  // Source configuration/policy element reference
	SourceName       string      `json:"sourceName"`       // Source configuration/policy element name
	Subject          string      `json:"subject"`          // Alert subject
	UserID           int         `json:"userId"`           // User identifier
	PSATicketID      int         `json:"psaTicketId"`      // related PSA ticket identifier
	TicketTemplateID int         `json:"ticketTemplateId"` // related ticket template identifier
	Data             any         `json:"data"`             // Alert data

}

func ListAlerts added in v0.0.7

func ListAlerts(filter string, sourceType AlertOrigin, lang string, tz string) (alerts []Alert, err error)

List all alerts with some filters

See https://eu.ninjarmm.com/apidocs-beta/core-resources/operations/getAlerts

func ListAlertsDevice added in v0.0.7

func ListAlertsDevice(devideID int, lang string, tz string) (alerts []Alert, err error)

List all alerts for a given device ID

See https://eu.ninjarmm.com/apidocs-beta/core-resources/operations/getDeviceAlerts

type AlertOrigin added in v0.0.7

type AlertOrigin string
const (
	AlertOriginAll                                    AlertOrigin = "" // Use for no filters alerts list
	AlertOriginAgentOffline                           AlertOrigin = "AGENT_OFFLINE"
	AlertOriginAgentCPU                               AlertOrigin = "CONDITION_AGENT_CPU"
	AlertOriginAgentMemory                            AlertOrigin = "CONDITION_AGENT_MEMORY"
	AlertOriginAgentNetwork                           AlertOrigin = "CONDITION_AGENT_NETWORK"
	AlertOriginAgentDiskIO                            AlertOrigin = "CONDITION_AGENT_DISK_IO"
	AlertOriginAgentDiskFreeSpace                     AlertOrigin = "CONDITION_AGENT_DISK_FREE_SPACE"
	AlertOriginAgentDiskUsage                         AlertOrigin = "CONDITION_AGENT_DISK_USAGE"
	AlertOriginAgentCVSSScore                         AlertOrigin = "CONDITION_AGENT_CVSS_SCORE"
	AlertOriginAgentPatchLastInstalled                AlertOrigin = "CONDITION_AGENT_PATCH_LAST_INSTALLED"
	AlertOriginNMSCPU                                 AlertOrigin = "CONDITION_NMS_CPU"
	AlertOriginNMSMemory                              AlertOrigin = "CONDITION_NMS_MEMORY"
	AlertOriginNMSNetworkTrafficBits                  AlertOrigin = "CONDITION_NMS_NETWORK_TRAFFIC_BITS"
	AlertOriginNMSNetworkTrafficPercent               AlertOrigin = "CONDITION_NMS_NETWORK_TRAFFIC_PERCENT"
	AlertOriginNMSNetworkStatus                       AlertOrigin = "CONDITION_NMS_NETWORK_STATUS"
	AlertOriginNMSNetworkStatusChange                 AlertOrigin = "CONDITION_NMS_NETWORK_STATUS_CHANGE"
	AlertOriginPing                                   AlertOrigin = "CONDITION_PING"
	AlertOriginPingLatency                            AlertOrigin = "CONDITION_PING_LATENCY"
	AlertOriginPingPacketLoss                         AlertOrigin = "CONDITION_PING_PACKET_LOSS"
	AlertOriginPingResponse                           AlertOrigin = "CONDITION_PING_RESPONSE"
	AlertOriginSystemUptime                           AlertOrigin = "CONDITION_SYSTEM_UPTIME"
	AlertOriginSmartStatusDegraded                    AlertOrigin = "CONDITION_SMART_STATUS_DEGRATED"
	AlertOriginRaidHealthStatus                       AlertOrigin = "CONDITION_RAID_HEALTH_STATUS"
	AlertOriginScriptResult                           AlertOrigin = "CONDITION_SCRIPT_RESULT"
	AlertOriginHTTP                                   AlertOrigin = "CONDITION_HTTP"
	AlertOriginHTTPResponse                           AlertOrigin = "CONDITION_HTTP_RESPONSE"
	AlertOriginPort                                   AlertOrigin = "CONDITION_PORT"
	AlertOriginPortScan                               AlertOrigin = "CONDITION_PORT_SCAN"
	AlertOriginSyslog                                 AlertOrigin = "CONDITION_SYSLOG"
	AlertOriginConfigurationFile                      AlertOrigin = "CONDITION_CONFIGURATION_FILE"
	AlertOriginSNMPTrap                               AlertOrigin = "CONDITION_SNMPTRAP"
	AlertOriginCriticalEvent                          AlertOrigin = "CONDITION_CRITICAL_EVENT"
	AlertOriginDNS                                    AlertOrigin = "CONDITION_DNS"
	AlertOriginEmail                                  AlertOrigin = "CONDITION_EMAIL"
	AlertOriginCustomSNMP                             AlertOrigin = "CONDITION_CUSTOM_SNMP"
	AlertOriginShadowProtectBackupJobCreate           AlertOrigin = "SHADOWPROTECT_BACKUPJOB_CREATE"
	AlertOriginShadowProtectBackupJobUpdate           AlertOrigin = "SHADOWPROTECT_BACKUPJOB_UPDATE"
	AlertOriginShadowProtectBackupJobDelete           AlertOrigin = "SHADOWPROTECT_BACKUPJOB_DELETE"
	AlertOriginShadowProtectBackupJobExecute          AlertOrigin = "SHADOWPROTECT_BACKUPJOB_EXECUTE"
	AlertOriginImageManagerManagedFolderCreate        AlertOrigin = "IMAGEMANAGER_MANAGEDFOLDER_CREATE"
	AlertOriginImageManagerManagedFolderUpdate        AlertOrigin = "IMAGEMANAGER_MANAGEDFOLDER_UPDATE"
	AlertOriginImageManagerManagedFolderDelete        AlertOrigin = "IMAGEMANAGER_MANAGEDFOLDER_DELETE"
	AlertOriginImageManagerManagedFolderExecute       AlertOrigin = "IMAGEMANAGER_MANAGEDFOLDER_EXECUTE"
	AlertOriginTeamViewerConnection                   AlertOrigin = "TEAMVIEWER_CONNECTION"
	AlertOriginRetrieveAgentLogs                      AlertOrigin = "RETRIEVE_AGENT_LOGS"
	AlertOriginScheduledTask                          AlertOrigin = "SCHEDULED_TASK"
	AlertOriginWindowsEventLogTriggered               AlertOrigin = "CONDITION_WINDOWS_EVENT_LOG_TRIGGERED"
	AlertOriginWindowsServiceStateChanged             AlertOrigin = "CONDITION_WINDOWS_SERVICE_STATE_CHANGED"
	AlertOriginUIMessageActionReboot                  AlertOrigin = "UI_MESSAGE_ACTION_REBOOT"
	AlertOriginUIMessageBDInstallationIssues          AlertOrigin = "UI_MESSAGE_BD_INSTALLATION_ISSUES"
	AlertOriginGravityZoneUIMessageInstallationIssues AlertOrigin = "GRAVITYZONE_UI_MESSAGE_INSTALLATION_ISSUES"
	AlertOriginAVQuarantineThreat                     AlertOrigin = "AV_QUARANTINE_THREAT"
	AlertOriginAVRestoreThreat                        AlertOrigin = "AV_RESTORE_THREAT"
	AlertOriginAVDeleteThreat                         AlertOrigin = "AV_DELETE_THREAT"
	AlertOriginAVRemoveThreat                         AlertOrigin = "AV_REMOVE_THREAT"
	AlertOriginBitdefenderRestoreThreat               AlertOrigin = "BITDEFENDER_RESTORE_THREAT"
	AlertOriginBitdefenderDeleteThreat                AlertOrigin = "BITDEFENDER_DELETE_THREAT"
	AlertOriginConditionBitlockerStatus               AlertOrigin = "CONDITION_BITLOCKER_STATUS"
	AlertOriginConditionFilevaultStatus               AlertOrigin = "CONDITION_FILEVAULT_STATUS"
	AlertOriginConditionLinuxProcess                  AlertOrigin = "CONDITION_LINUX_PROCESS"
	AlertOriginConditionLinuxDaemon                   AlertOrigin = "CONDITION_LINUX_Daemon"
	AlertOriginConditionLinuxProcessResource          AlertOrigin = "CONDITION_LINUX_PROCESS_RESOURCE"
	AlertOriginConditionLinuxProcessResourceCPU       AlertOrigin = "CONDITION_LINUX_PROCESS_RESOURCE_CPU"
	AlertOriginConditionLinuxProcessResourceMemory    AlertOrigin = "CONDITION_LINUX_PROCESS_RESOURCE_MEMORY"
	AlertOriginConditionLinuxDiskFreeSpace            AlertOrigin = "CONDITION_LINUX_DISK_FREE_SPACE"
	AlertOriginConditionLinuxDiskUsage                AlertOrigin = "CONDITION_LINUX_DISK_USAGE"
	AlertOriginConditionVMAggregateCPUUsage           AlertOrigin = "CONDITION_VM_AGGREGATE_CPU_USAGE"
	AlertOriginConditionVMDiskUsage                   AlertOrigin = "CONDITION_VM_DISK_USAGE"
	AlertOriginConditionVMHostDatastore               AlertOrigin = "CONDITION_VM_HOST_DATASTORE"
	AlertOriginConditionVMHostUptime                  AlertOrigin = "CONDITION_VM_HOST_UPTIME"
	AlertOriginConditionVMHostDeviceDown              AlertOrigin = "CONDITION_VM_HOST_DEVICE_DOWN"
	AlertOriginConditionVMHostBadSensors              AlertOrigin = "CONDITION_VM_HOST_BAD_SENSORS"
	AlertOriginConditionVMHostSensorHealth            AlertOrigin = "CONDITION_VM_HOST_SENSOR_HEALTH"
	AlertOriginConditionVMGuestGuestOperationalMode   AlertOrigin = "CONDITION_VM_GUEST_GUEST_OPERATIONAL_MODE"
	AlertOriginConditionVMGuestSnapshotSize           AlertOrigin = "CONDITION_VM_GUEST_SNAPSHOT_SIZE"
	AlertOriginConditionVMGuestSnapshotLifespan       AlertOrigin = "CONDITION_VM_GUEST_SNAPSHOT_LIFESPAN"
	AlertOriginConditionVMGuestToolsNotRunning        AlertOrigin = "CONDITION_VM_GUEST_TOOLS_NOT_RUNNING"
	AlertOriginConditionHVGuestCheckpointSize         AlertOrigin = "CONDITION_HV_GUEST_CHECKPOINT_SIZE"
	AlertOriginConditionHVGuestCheckpointLifespan     AlertOrigin = "CONDITION_HV_GUEST_CHECKPOINT_LIFESPAN"
	AlertOriginConditionSoftware                      AlertOrigin = "CONDITION_SOFTWARE"
	AlertOriginConditionWindowsProcessState           AlertOrigin = "CONDITION_WINDOWS_PROCESS_STATE"
	AlertOriginConditionWindowsProcessResourceCPU     AlertOrigin = "CONDITION_WINDOWS_PROCESS_RESOURCE_CPU"
	AlertOriginConditionWindowsProcessResourceMemory  AlertOrigin = "CONDITION_WINDOWS_PROCESS_RESOURCE_MEMORY"
	AlertOriginConditionMacProcessState               AlertOrigin = "CONDITION_MAC_PROCESS_STATE"
	AlertOriginConditionMacProcessResourceCPU         AlertOrigin = "CONDITION_MAC_PROCESS_RESOURCE_CPU"
	AlertOriginConditionMacProcessResourceMemory      AlertOrigin = "CONDITION_MAC_PROCESS_RESOURCE_MEMORY"
	AlertOriginConditionMacDeamon                     AlertOrigin = "CONDITION_MAC_DEAMON"
	AlertOriginConditionCustomField                   AlertOrigin = "CONDITION_CUSTOM_FIELD"
	AlertOriginConditionPendingReboot                 AlertOrigin = "CONDITION_PENDING_REBOOT"
)

type ApprovalMode

type ApprovalMode string
const (
	ApprovalModeAutomatic ApprovalMode = "AUTOMATIC"
	ApprovalModeManual    ApprovalMode = "MANUAL"
	ApprovalModeRefect    ApprovalMode = "REJECT"
)

type ApprovalStatus

type ApprovalStatus string
const (
	ApprovalStatusPending  ApprovalStatus = "PENDING"
	ApprovalStatusApproved ApprovalStatus = "APPROVED"
)

type BoardCondition added in v0.1.9

type BoardCondition struct {
	Field    string `json:"field"`
	Operator string `json:"operator"`
	Value    string `json:"value"`
}

type BoardConditions added in v0.1.9

type BoardConditions struct {
	Any []BoardCondition `json:"any"`
	All []BoardCondition `json:"all"`
}

type BoardMetadata added in v0.1.9

type BoardMetadata struct {
	Columns                 []string `json:"columns"`
	SortBy                  []SortBy `json:"sortBy"`
	Attributes              any      `json:"attributes"`
	Filters                 any      `json:"filters"`
	LastCursorID            int      `json:"lastCursorId"`
	AllRequiredColumns      []string `json:"allRequiredColumns"`
	AllColumns              []string `json:"allColumns"`
	ColumnNamesForExporting []string `json:"columnNamesForExporting"`
}

type BoardTicket added in v0.1.9

type BoardTicket struct {
	AssignedAppUser    string                        `json:"assignedAppUser"`
	CreateTime         Time                          `json:"createTime"`
	Description        string                        `json:"description"`
	Device             string                        `json:"device"`
	ID                 int                           `json:"id"`
	Organization       string                        `json:"organization"`
	Status             BoardTicketStatus             `json:"status"`
	Summary            string                        `json:"summary"`
	Tags               []string                      `json:"tags"`
	TicketForm         string                        `json:"ticketForm"`
	TotalTimeTracked   int                           `json:"totalTimeTracked"`
	TriggeredCondition BoardTicketTriggeredCondition `json:"triggeredCondition"`
	Priority           `json:"priority"`
	Severity           `json:"severity"`
}

type BoardTicketStatus added in v0.1.9

type BoardTicketStatus struct {
	StatusID    int    `json:"statusId"`
	DisplayName string `json:"displayName"`
	ParentID    int    `json:"parentId"`
}

type BoardTicketTriggeredCondition added in v0.1.9

type BoardTicketTriggeredCondition struct {
	UID        string `json:"uid"`
	Message    string `json:"message"`
	CreateTime Time   `json:"createTime"`
}

type BoardTickets added in v0.1.9

type BoardTickets struct {
	Data     []BoardTicket `json:"data"`
	Metadata BoardMetadata `json:"metadata"`
}

func ListTicketsByBoard added in v0.1.9

func ListTicketsByBoard(boardID int, options ListTicketsOptions) (tickets BoardTickets, err error)

Run a board. Returns list of tickets matching the board condition and filters. Allows pagination

See https://eu.ninjarmm.com/apidocs-beta/core-resources/operations/getTicketsByBoard

type Chassis

type Chassis string
const (
	ChassisDesktop Chassis = "DESKTOP"
	ChassisLaptop  Chassis = "LAPTOP"
	ChassisMobile  Chassis = "MOBILE"
	ChassisUnknown Chassis = "UNKNOWN"
)

type ComputerSystem added in v0.1.6

type ComputerSystem struct {
	Name                string `json:"name"`
	Manufacturer        string `json:"manufacturer"`
	Model               string `json:"model"`
	BiosSerialNumber    string `json:"biosSerialNumber"`
	SerialNumber        string `json:"serialNumber"`
	Domain              string `json:"domain"`
	DomainRole          string `json:"domainRole"`
	NumberOfProcessors  int    `json:"numberOfProcessors"`
	TotalPhysicalMemory int    `json:"totalPhysicalMemory"`
	VirtualMachine      bool   `json:"virtualMachine"`
	ChassisType         string `json:"chassisType"`
	DeviceID            int    `json:"deviceId"`
	Timestamp           Time   `json:"timestamp"`
}

type ComputerSystemReport added in v0.1.6

type ComputerSystemReport struct {
	Cursor  ReportCursor     `json:"cursor"`
	Results []ComputerSystem `json:"results"`
}

func QueryComputerSystems added in v0.1.6

func QueryComputerSystems(filter string, pageSize int) (report ComputerSystemReport, err error)

Query computer systems device informations

See https://eu.ninjarmm.com/apidocs-beta/core-resources/operations/getComputerSystems

type Contact added in v0.1.9

type Contact struct {
	ID          int    `json:"id"`
	ClientID    int    `json:"clientId"`
	ClientName  string `json:"clientName"`
	UID         string `json:"uid"`
	FirstName   string `json:"firstName"`
	LastName    string `json:"lastName"`
	Email       string `json:"email"`
	Phone       string `json:"phone"`
	JobTitle    string `json:"jobTitle"`
	DisplayName string `json:"displayName"`
	CreateTime  Time   `json:"createTime"`
	UpdateTime  Time   `json:"updateTime"`
}

func ListContacts added in v0.1.9

func ListContacts() (contacts []Contact, err error)

Returns list of contacts

See https://eu.ninjarmm.com/apidocs-beta/core-resources/operations/getContacts

type CustomFields added in v0.0.6

type CustomFields map[string]interface{}

Shortcuts for map[string]interface{}

func GetDeviceCustomFields added in v0.0.8

func GetDeviceCustomFields(deviceID int) (customFields CustomFields, err error)

Return device custom fields

See https://eu.ninjarmm.com/apidocs-beta/core-resources/operations/getNodeCustomFields

func GetLocationCustomFields added in v0.1.0

func GetLocationCustomFields(organizationID, locationID int) (customFields CustomFields, err error)

Returns location custom fields

See https://app.ninjarmm.com/apidocs-beta/core-resources/operations/getNodeCustomFields_1

func GetOrganizationCustomFields added in v0.0.6

func GetOrganizationCustomFields(organizationID int) (customFields CustomFields, err error)

Getting custom fields for an organization

See https://eu.ninjarmm.com/apidocs-beta/core-resources/operations/getNodeCustomFields_2

func (CustomFields) BoolField added in v0.1.1

func (c CustomFields) BoolField(key string) bool

BoolField returns a parsed boolean value from the custom field.

func (CustomFields) Delete added in v0.1.4

func (c CustomFields) Delete(key string)

Delete deletes a custom field.

func (CustomFields) FloatField added in v0.1.1

func (c CustomFields) FloatField(key string) float64

FloatField returns a parsed float64 value from the custom field.

func (CustomFields) Get added in v0.1.1

func (c CustomFields) Get(key string) interface{}

Get returns the interface{} value from the custom field. Same as InterfaceField.

func (CustomFields) IntField added in v0.1.1

func (c CustomFields) IntField(key string) int

IntField returns a parsed int value from the custom field.

func (CustomFields) InterfaceField added in v0.1.1

func (c CustomFields) InterfaceField(key string) interface{}

InterfaceField returns the interface{} value from the custom field. Same as Get.

func (CustomFields) Set added in v0.1.1

func (c CustomFields) Set(key string, value interface{})

Set sets a custom field. Don't forget to call make(CustomFields) before using this function.

You can reset the field by setting his value to nil.

Example:

customFields := make(ninjarmm.CustomFields)
customFields.Set("myField", "myValue")

func (CustomFields) StringField added in v0.1.1

func (c CustomFields) StringField(key string) string

StringField returns a string value from the custom field.

type Device

type Device struct {
	ID             int            `json:"id"`
	ParentDeviceID int            `json:"parentDeviceId"`
	OrganizationID int            `json:"organizationId"`
	LocationID     int            `json:"locationId"`
	NodeClass      NodeClass      `json:"nodeClass"`
	NodeRoleID     int            `json:"nodeRoleId"`
	RolePolicyID   int            `json:"rolePolicyId"`
	PolicyID       int            `json:"policyId"`
	ApprovalStatus ApprovalStatus `json:"approvalStatus"`
	Offline        bool           `json:"offline"`
	DisplayName    string         `json:"displayName"`
	SystemName     string         `json:"systemName"`
	DNSName        string         `json:"dnsName"`
	NETBIOSName    string         `json:"netbiosName"`
	Created        Time           `json:"created"`
	LastContact    Time           `json:"lastContact"`
	LastUpdate     Time           `json:"lastUpdate"`
	UserData       CustomFields   `json:"userData"`
	Tags           []string       `json:"tags"`   // seems not implemented yet
	Fields         CustomFields   `json:"fields"` // seems not implemented yet
	Maintenance    struct {
		Status MaintenanceStatus `json:"status"`
		Start  Time              `json:"start"`
		End    Time              `json:"end"`
	} `json:"maintenance"`
	References struct {
		Organization Organization `json:"organization"`
		Location     Location     `json:"location"`
		RolePolicy   Policy       `json:"rolePolicy"`
		Policy       Policy       `json:"policy"`
		Role         DeviceRole   `json:"role"`
	} `json:"references"`

	// Only in detailed mode
	IPAddress []string `json:"ipAddress,omitempty"`
	PublicIP  string   `json:"publicIp,omitempty"`
	Notes     []struct {
		Text string `json:"text"`
	} `json:"notes,omitempty"`
	DeviceType string `json:"deviceType,omitempty"`
}

func FindDevices

func FindDevices(search string, limit int) (devices []Device, err error)

Find devices by search string

See https://eu.ninjarmm.com/apidocs-beta/core-resources/operations/search

func GetDevice added in v0.0.8

func GetDevice(deviceID int) (device Device, err error)

Get device by ID

See https://eu.ninjarmm.com/apidocs-beta/core-resources/operations/getDevice

func ListDevices

func ListDevices(filter string, detailed bool, after, pageSize int) (devices []Device, err error)

List all devices with some filters

See https://eu.ninjarmm.com/apidocs-beta/core-resources/operations/getDevices

For filter see https://eu.ninjarmm.com/apidocs-beta/core-resources/articles/devices/device-filters

func ListOrganizationDevices added in v0.1.0

func ListOrganizationDevices(organizationID int) (devices []Device, err error)

Returns list of devices for organization

See https://app.ninjarmm.com/apidocs-beta/core-resources/operations/getOrganizationDevices

func (*Device) GetCustomFields added in v0.1.4

func (device *Device) GetCustomFields() (err error)

Populate device custom fields

See https://eu.ninjarmm.com/apidocs-beta/core-resources/operations/getNodeCustomFields

type DeviceRole

type DeviceRole struct {
	ID          int          `json:"id"`
	Name        string       `json:"name"`
	Description string       `json:"description"`
	NodeClass   NodeClass    `json:"nodeClass"`
	Custom      bool         `json:"custom"`
	ChassisType Chassis      `json:"chassisType"`
	Created     Time         `json:"created"`
	Tags        []string     `json:"tags"`
	Fields      CustomFields `json:"fields"`
}

func ListDeviceRoles

func ListDeviceRoles() (deviceRoles []DeviceRole, err error)

List all device roles

See https://eu.ninjarmm.com/apidocs-beta/core-resources/operations/getNodeRoles

type DiskVolumes added in v0.2.1

type DiskVolumes struct {
	Name            string `json:"name"`
	DriveLetter     string `json:"driveLetter"`
	Label           string `json:"label"`
	DeviceType      string `json:"deviceType"`
	FileSystem      string `json:"fileSystem"`
	AutoMount       bool   `json:"autoMount"`
	Compressed      bool   `json:"compressed"`
	Capacity        int    `json:"capacity"`
	FreeSpace       int    `json:"freeSpace"`
	SerialNumber    string `json:"serialNumber"`
	BitLockerStatus struct {
		ConversionStatus         string `json:"conversionStatus"`
		EncryptionMethod         string `json:"encryptionMethod"`
		ProtectionStatus         string `json:"protectionStatus"`
		LockStatus               string `json:"lockStatus"`
		InitializedForProtection bool   `json:"initializedForProtection"`
	} `json:"bitLockerStatus"`
	DeviceId  int `json:"deviceId"`
	Timestamp int `json:"timestamp"`
}

type DiskVolumesReport added in v0.2.1

type DiskVolumesReport struct {
	Cursor  ReportCursor  `json:"cursor"`
	Results []DiskVolumes `json:"results"`
}

func QueryDiskVolumesReport added in v0.2.1

func QueryDiskVolumesReport(filter string, pageSize int) (report DiskVolumesReport, err error)

type Document added in v0.0.8

type Document struct {
	ClientDocumentID          int             `json:"clientDocumentId,omitempty"`
	ClientDocumentName        string          `json:"clientDocumentName"`
	ClientDocumentDescription string          `json:"clientDocumentDescription"`
	ClientDocumentUpdateTime  int             `json:"clientDocumentUpdateTime"`
	AttributeValues           []DocumentValue `json:"attributeValues,omitempty"`
}

func GetOrganizationDocuments added in v0.0.8

func GetOrganizationDocuments(organizationID int) (documents []Document, err error)

type DocumentValue added in v0.0.8

type DocumentValue struct {
	Value           interface{} `json:"value"`
	ValueUpdateTime int         `json:"valueUpdateTime"`
	AttributeName   string      `json:"attributeName"`
}

type Filters added in v0.1.9

type Filters struct {
	Field    string `json:"field"`
	Operator string `json:"operator"`
	Value    string `json:"value"`
}

type InvitationStatus added in v0.0.2

type InvitationStatus string
const (
	InvitationStatusPending    InvitationStatus = "PENDING"
	InvitationStatusRegistered InvitationStatus = "REGISTERED"
	InvitationStatusExpired    InvitationStatus = "EXPIRED"
)

type ListTicketsOptions added in v0.1.9

type ListTicketsOptions struct {
	SortBy         []SortBy         `json:"sortBy,omitempty"`
	Filters        []BoardCondition `json:"filters,omitempty"`
	PageSize       int              `json:"pageSize,omitempty"`
	SearchCriteria string           `json:"searchCriteria,omitempty"`
	IncludeColumns []string         `json:"includeColumns,omitempty"`
	LastCursorID   int              `json:"lastCursorId,omitempty"`
}

type Location

type Location struct {
	ID             int          `json:"id,omitempty"`
	Name           string       `json:"name,omitempty"`
	Address        string       `json:"address,omitempty"`
	Description    string       `json:"description,omitempty"`
	UserData       CustomFields `json:"userData,omitempty"`
	Tags           []string     `json:"tags,omitempty"`           // seems not implemented yet
	Fields         CustomFields `json:"fields,omitempty"`         // seems not implemented yet
	OrganizationID int          `json:"organizationId,omitempty"` // only when list all locations
}

func CreateLocation added in v0.1.0

func CreateLocation(organizationID int, location Location) (createdLocation Location, err error)

Creates new location for organization

See https://app.ninjarmm.com/apidocs-beta/core-resources/operations/createLocationForOrganization

func ListLocations

func ListLocations(after, pageSize int) (locations []Location, err error)

Returns flat list of all locations for all organizations

See https://eu.ninjarmm.com/apidocs-beta/core-resources/operations/getLocations

func ListOrganizationLocations added in v0.1.0

func ListOrganizationLocations(organizationID int) (locations []Location, err error)

Returns list of locations for organization

See https://app.ninjarmm.com/apidocs-beta/core-resources/operations/getOrganizationLocations

func (*Location) GetCustomFields added in v0.1.4

func (location *Location) GetCustomFields() (err error)

Populate location custom fields

See https://app.ninjarmm.com/apidocs-beta/core-resources/operations/getNodeCustomFields_1

type MaintenanceStatus

type MaintenanceStatus string
const (
	MaintenanceStatusFailed       MaintenanceStatus = "FAILED"
	MaintenanceStatusPending      MaintenanceStatus = "PENDING"
	MaintenanceStatusInMaintenace MaintenanceStatus = "IN_MAINTENANCE"
)

type NewTicket added in v0.1.9

type NewTicket struct {
	ClientID          int                `json:"clientId"`             // REQUIRED / Client (Organization) identifier
	TicketFormID      int                `json:"ticketFormId"`         // REQUIRED / Ticket form identifier
	LocationID        int                `json:"locationId,omitempty"` // Location identifier
	NodeID            int                `json:"nodeId,omitempty"`     // Device identifier
	Subject           string             `json:"subject"`              // REQUIRED / Ticket subject (>= 0 characters <= 200 characters)
	Description       TicketDescription  `json:"description"`          // REQUIRED / Ticket description
	Status            string             `json:"status"`               // REQUIRED / Ticket status
	Type              TicketType         `json:"type,omitempty"`       // Allowed values: 'PROBLEM', 'QUESTION', 'INCIDENT' or 'TASK'
	Cc                TicketCcList       `json:"cc,omitempty"`
	AssignedAppUserID int                `json:"assignedAppUserId,omitempty"`
	RequesterUID      string             `json:"requesterUid,omitempty"`
	Severity          string             `json:"severity,omitempty"`
	Priority          string             `json:"priority,omitempty"`
	ParentTicketID    int                `json:"parentTicketId,omitempty"`
	Tags              []string           `json:"tags,omitempty"`
	Attributes        []TicketAttributes `json:"attributes,omitempty"`
}

NewTicket object that needs to be added to the store

func (NewTicket) Create added in v0.1.9

func (newTicket NewTicket) Create() (createdTicket Ticket, err error)

Create new ticket, does not accept files

See https://eu.ninjarmm.com/apidocs-beta/core-resources/operations/create

type NodeClass

type NodeClass string
const (
	NodeClassWindowsServer             NodeClass = "WINDOWS_SERVER"
	NodeClassWindowsWorkstation        NodeClass = "WINDOWS_WORKSTATION"
	NodeClassLinuxWorkstation          NodeClass = "LINUX_WORKSTATION"
	NodeClassMac                       NodeClass = "MAC"
	NodeClassAndroid                   NodeClass = "ANDROID"
	NodeClassAppleIos                  NodeClass = "APPLE_IOS"
	NodeClassAppleIpadOs               NodeClass = "APPLE_IPADOS"
	NodeClassVmwareVmHost              NodeClass = "VMWARE_VM_HOST"
	NodeClassVmwareVmGuest             NodeClass = "VMWARE_VM_GUEST"
	NodeClassHypervVmmHost             NodeClass = "HYPERV_VMM_HOST"
	NodeClassHypervVmmGuest            NodeClass = "HYPERV_VMM_GUEST"
	NodeClassLinuxServer               NodeClass = "LINUX_SERVER"
	NodeClassMacServer                 NodeClass = "MAC_SERVER"
	NodeClassCloudMonitorTarget        NodeClass = "CLOUD_MONITOR_TARGET"
	NodeClassNmsSwitch                 NodeClass = "NMS_SWITCH"
	NodeClassNmsRouter                 NodeClass = "NMS_ROUTER"
	NodeClassNmsFirewall               NodeClass = "NMS_FIREWALL"
	NodeClassNmsPrivateNetworkGateway  NodeClass = "NMS_PRIVATE_NETWORK_GATEWAY"
	NodeClassNmsPrinter                NodeClass = "NMS_PRINTER"
	NodeClassNmsScanner                NodeClass = "NMS_SCANNER"
	NodeClassNmsDialManager            NodeClass = "NMS_DIAL_MANAGER"
	NodeClassNmsWap                    NodeClass = "NMS_WAP"
	NodeClassNmsIpsla                  NodeClass = "NMS_IPSLA"
	NodeClassNmsComputer               NodeClass = "NMS_COMPUTER"
	NodeClassNmsVmHost                 NodeClass = "NMS_VM_HOST"
	NodeClassNmsAppliance              NodeClass = "NMS_APPLIANCE"
	NodeClassNmsOther                  NodeClass = "NMS_OTHER"
	NodeClassNmsServer                 NodeClass = "NMS_SERVER"
	NodeClassNmsPhone                  NodeClass = "NMS_PHONE"
	NodeClassNmsVirtualMachine         NodeClass = "NMS_VIRTUAL_MACHINE"
	NodeClassNmsNetworkManagementAgent NodeClass = "NMS_NETWORK_MANAGEMENT_AGENT"
)

type OperatingSystem added in v0.1.6

type OperatingSystem struct {
	Name                    string `json:"name"`
	Manufacturer            string `json:"manufacturer"`
	Architecture            string `json:"architecture"`
	LastBootTime            Time   `json:"lastBootTime"`
	BuildNumber             string `json:"buildNumber"`
	ReleaseID               string `json:"releaseId"`
	ServicePackMajorVersion int    `json:"servicePackMajorVersion"`
	ServicePackMinorVersion int    `json:"servicePackMinorVersion"`
	Locale                  string `json:"locale"`
	Language                string `json:"language"`
	NeedsReboot             bool   `json:"needsReboot"`
	DeviceID                int    `json:"deviceId"`
	Timestamp               Time   `json:"timestamp"`
}

type OperatingSystemReport added in v0.1.6

type OperatingSystemReport struct {
	Cursor  ReportCursor      `json:"cursor"`
	Results []OperatingSystem `json:"results"`
}

func QueryOperatingSystems added in v0.1.6

func QueryOperatingSystems(filter string, pageSize int) (report OperatingSystemReport, err error)

Query operating systems device informations

See https://eu.ninjarmm.com/apidocs-beta/core-resources/operations/getOperatingSystems

type Organization

type Organization struct {
	ID               int          `json:"id,omitempty"`
	Name             string       `json:"name,omitempty"`
	Description      string       `json:"description,omitempty"`
	UserData         CustomFields `json:"userData,omitempty"`
	NodeApprovalMode ApprovalMode `json:"nodeApprovalMode,omitempty"`
	Tags             []string     `json:"tags,omitempty"`   // seems not implemented yet
	Fields           CustomFields `json:"fields,omitempty"` // seems not implemented yet
}

func ListOrganizations

func ListOrganizations() (organizations []Organization, err error)

List all organizations

See https://eu.ninjarmm.com/apidocs-beta/core-resources/operations/getOrganizations

func (*Organization) GetCustomFields added in v0.1.4

func (organization *Organization) GetCustomFields() (err error)

Populate custom fields for an organization

See https://eu.ninjarmm.com/apidocs-beta/core-resources/operations/getNodeCustomField_2

func (Organization) Update added in v0.1.9

func (organization Organization) Update() (err error)

Update an organization

See https://eu.ninjarmm.com/apidocs-beta/core-resources/operations/updateOrganization

func (*Organization) UpdatePolicies added in v0.1.7

func (organization *Organization) UpdatePolicies(policies []OrganizationPolicyItem) (affectedDevicesIDs []int, err error)

Change organization policy mappings

See https://eu.ninjarmm.com/apidocs-beta/core-resources/operations/updateNodeRolePolicyAssignmentForOrganization

type OrganizationDetailed

type OrganizationDetailed struct {
	ID               int                            `json:"id,omitempty"`
	Name             string                         `json:"name,omitempty"`
	Description      string                         `json:"description,omitempty"`
	UserData         CustomFields                   `json:"userData,omitempty"`
	NodeApprovalMode ApprovalMode                   `json:"nodeApprovalMode,omitempty"`
	Tags             []string                       `json:"tags,omitempty"`   // seems not implemented yet
	Fields           CustomFields                   `json:"fields,omitempty"` // seems not implemented yet
	Locations        []Location                     `json:"locations,omitempty"`
	Policies         []OrganizationPolicyItem       `json:"policies,omitempty"`
	Settings         map[string]OrganizationSetting `json:"settings,omitempty"` // 'trayicon', 'splashtop', 'teamviewer', 'backup' and 'psa'
}

func CreateOrganization

func CreateOrganization(newOrganization OrganizationDetailed, model_id int) (createdOrganization OrganizationDetailed, err error)

Create an organization, optionally based on a template organization

See https://eu.ninjarmm.com/apidocs-beta/core-resources/operations/createOrganization

func GetOrganization added in v0.1.0

func GetOrganization(organizationID int) (organization OrganizationDetailed, err error)

Returns organization details (policy mappings, locations)

See https://app.ninjarmm.com/apidocs-beta/core-resources/operations/getOrganization

func ListOrganizationsDetailed

func ListOrganizationsDetailed() (organizations []OrganizationDetailed, err error)

List all organizations with detailed information

See https://eu.ninjarmm.com/apidocs-beta/core-resources/operations/getOrganizationsDetailed

func (*OrganizationDetailed) GetCustomFields added in v0.1.5

func (organization *OrganizationDetailed) GetCustomFields() (err error)

Populate custom fields for a detailed organization

See https://eu.ninjarmm.com/apidocs-beta/core-resources/operations/getNodeCustomField_2

func (*OrganizationDetailed) UpdatePolicies added in v0.1.7

func (organization *OrganizationDetailed) UpdatePolicies(policies []OrganizationPolicyItem) (affectedDevicesIDs []int, err error)

Change organization policy mappings

See https://eu.ninjarmm.com/apidocs-beta/core-resources/operations/updateNodeRolePolicyAssignmentForOrganization

type OrganizationPolicyItem

type OrganizationPolicyItem struct {
	NodeRoleID int `json:"nodeRoleId"`
	PolicyID   int `json:"policyId"`
}

type OrganizationSetting

type OrganizationSetting struct {
	Product string         `json:"product"`
	Enabled bool           `json:"enabled"`
	Targets []string       `json:"targets"`
	Options map[string]any `json:"options"`
}

type Policy

type Policy struct {
	ID               int          `json:"id"`
	ParentPolicyID   int          `json:"parentPolicyId"`
	Name             string       `json:"name"`
	Description      string       `json:"description"`
	NodeClass        NodeClass    `json:"nodeClass"`
	Updated          Time         `json:"updated"`
	NodeClassDefault bool         `json:"nodeClassDefault"`
	Tags             []string     `json:"tags"`
	Fields           CustomFields `json:"fields"`
}

func ListDevicePolicies

func ListDevicePolicies() (policies []Policy, err error)

List all device policies

See https://eu.ninjarmm.com/apidocs-beta/core-resources/operations/getPolicies

type Priority added in v0.0.6

type Priority string
const (
	PriorityNone   Priority = "NONE"
	PriorityLow    Priority = "LOW"
	PriorityMedium Priority = "MEDIUM"
	PriorityHigh   Priority = "HIGH"
)

type ProcessorInfo added in v0.1.11

type ProcessorInfo struct {
	Architecture  string `json:"architecture"`
	MaxClockSpeed int    `json:"maxClockSpeed"`
}

type ProcessorReport added in v0.1.11

type ProcessorReport struct {
	Cursor  ReportCursor    `json:"cursor"`
	Results []ProcessorInfo `json:"results"`
}

func QueryProcessorReport added in v0.1.11

func QueryProcessorReport(filter string, pageSize int) (report ProcessorReport, err error)

type ReportCursor added in v0.1.6

type ReportCursor struct {
	Name    string `json:"name"`
	Offset  int    `json:"offset"`
	Count   int    `json:"count"`
	Expires Time   `json:"expires"`
}

Global query cursor

type Severity added in v0.0.6

type Severity string
const (
	SeverityNone     Severity = "NONE"
	SeverityMinor    Severity = "MINOR"
	SeverityModerate Severity = "MODERATE"
	SeverityMajor    Severity = "MAJOR"
	SeverityCritical Severity = "CRITICAL"
)

type Software added in v0.2.3

type Software struct {
	Location    string `json:"location"`
	Name        string `json:"name"`
	Publisher   string `json:"publisher"`
	Size        int    `json:"size"`
	Version     string `json:"version"`
	ProductCode string `json:"productCode"`
	DeviceId    int    `json:"deviceId"`
}

type SoftwareInventoryReport added in v0.2.3

type SoftwareInventoryReport struct {
	Cursor  ReportCursor `json:"cursor"`
	Results []Software   `json:"results"`
}

func SoftwareInventory added in v0.2.3

func SoftwareInventory(filter string, pageSize int) (report SoftwareInventoryReport, err error)

type SortBy added in v0.1.9

type SortBy struct {
	Field     string `json:"field"`
	Direction string `json:"direction"` // 'ASC' or 'DESC'
}

type TechniciansTagged added in v0.1.9

type TechniciansTagged struct {
	ID          int    `json:"id"`
	Email       string `json:"email"`
	DisplayName string `json:"displayName"`
	Deleted     bool   `json:"deleted"`
	Permitted   bool   `json:"permitted"`
}

type Ticket added in v0.1.9

type Ticket struct {
	ID                int                `json:"id,omitempty"`
	Version           int                `json:"version,omitempty"`
	NodeID            int                `json:"nodeId,omitempty"`
	ClientID          int                `json:"clientId,omitempty"`
	LocationID        int                `json:"locationId,omitempty"`
	AssignedAppUserID int                `json:"assignedAppUserId,omitempty"`
	RequesterUID      string             `json:"requesterUid,omitempty"`
	Subject           string             `json:"subject,omitempty"`
	Status            TicketStatus       `json:"status,omitempty"`
	Type              TicketType         `json:"type,omitempty"`
	TicketFormID      int                `json:"ticketFormId,omitempty"`
	Source            string             `json:"source,omitempty"`
	Tags              []string           `json:"tags,omitempty"`
	CcList            TicketCcList       `json:"ccList,omitempty"`
	CreateTime        Time               `json:"createTime,omitempty"`
	Deleted           bool               `json:"deleted,omitempty"`
	AttributeValues   []TicketAttributes `json:"attributeValues,omitempty"`

	Priority `json:"priority,omitempty"`
	Severity `json:"severity,omitempty"`
}

func CreateTicket added in v0.1.9

func CreateTicket(newTicket NewTicket) (createdTicket Ticket, err error)

Create new ticket, does not accept files

See https://eu.ninjarmm.com/apidocs-beta/core-resources/operations/create

func GetTicket added in v0.1.9

func GetTicket(ticketID int) (ticket Ticket, err error)

Returns a ticket

See https://eu.ninjarmm.com/apidocs-beta/core-resources/operations/getTicketById

func UpdateTicket added in v0.1.9

func UpdateTicket(ticket Ticket) (updatedTicket Ticket, err error)

Change ticket fields. Does not accept comments or files

See https://eu.ninjarmm.com/apidocs-beta/core-resources/operations/update

func (Ticket) AddComment added in v0.1.9

func (ticket Ticket) AddComment(comment TicketComment) (err error)

[W.I.P] Add a new comment to a ticket, allows files

See https://eu.ninjarmm.com/apidocs-beta/core-resources/operations/createComment

func (Ticket) GetLog added in v0.1.9

func (ticket Ticket) GetLog() (log []TicketLog, err error)

Returns list of the ticket log entries for a ticket

See https://eu.ninjarmm.com/apidocs-beta/core-resources/operations/getTicketLogEntriesByTicketId

func (Ticket) Update added in v0.1.9

func (ticket Ticket) Update() (updatedTicket Ticket, err error)

Change ticket fields. Does not accept comments or files

See https://eu.ninjarmm.com/apidocs-beta/core-resources/operations/update

type TicketAttributes added in v0.1.9

type TicketAttributes struct {
	ID          int `json:"id"`
	AttributeID int `json:"attributeId"`
	Value       any `json:"value"`
}

type TicketCcList added in v0.1.9

type TicketCcList struct {
	Uids   []string `json:"uids"`
	Emails []string `json:"emails"`
}

type TicketComment added in v0.1.9

type TicketComment struct {
	Comment TicketDescription `form:"comment"`
	Files   map[string][]byte `form:"files"`
}

W.I.P

type TicketDescription added in v0.1.9

type TicketDescription struct {
	Public               bool   `json:"public"` // REQUIRED
	Body                 string `json:"body"`
	HTMLBody             string `json:"htmlBody"`
	TimeTracked          int    `json:"timeTracked"`
	DuplicateInIncidents bool   `json:"duplicateInIncidents"`
}

type TicketLog added in v0.1.9

type TicketLog struct {
	ID                        int                 `json:"id"`
	AppUserContactUID         string              `json:"appUserContactUid"`
	AppUserContactID          int                 `json:"appUserContactId"`
	AppUserContactType        UserType            `json:"appUserContactType"`
	Type                      TicketLogType       `json:"type"`
	Body                      string              `json:"body"`
	HTMLBody                  string              `json:"htmlBody"`
	FullEmailBody             string              `json:"fullEmailBody"`
	PublicEntry               bool                `json:"publicEntry"`
	System                    bool                `json:"system"`
	CreateTime                Time                `json:"createTime"`
	ChangeDiff                any                 `json:"changeDiff"`
	ActivityID                int                 `json:"activityId"`
	TimeTracked               int                 `json:"timeTracked"`
	TechnicianTagged          []int               `json:"technicianTagged"`
	TechniciansTaggedMetadata []TechniciansTagged `json:"techniciansTaggedMetadata"`
	Automation                TicketLogAutomation `json:"automation"`
	BlockedByInvoice          bool                `json:"blockedByInvoice"`
	EmailResponse             bool                `json:"emailResponse"`
}

func GetTicketLog added in v0.1.9

func GetTicketLog(ticketID int) (log []TicketLog, err error)

Returns list of the ticket log entries for a ticket

See https://eu.ninjarmm.com/apidocs-beta/core-resources/operations/getTicketLogEntriesByTicketId

type TicketLogAutomation added in v0.1.9

type TicketLogAutomation struct {
	ID     int    `json:"id"`
	Name   string `json:"name"`
	System bool   `json:"system"`
	Type   string `json:"type"`
}

type TicketLogType added in v0.1.9

type TicketLogType string
const (
	TicketLogTypeComment     TicketLogType = "COMMENT"
	TicketLogTypeDescription TicketLogType = "DESCRIPTION"
	TicketLogTypeCondition   TicketLogType = "CONDITION"
	TicketLogTypeSave        TicketLogType = "SAVE"
	TicketLogTypeDelete      TicketLogType = "DELETE"
)

type TicketStatus added in v0.1.9

type TicketStatus struct {
	Name        string `json:"name,omitempty"`
	DisplayName string `json:"displayName,omitempty"`
	ParentID    int    `json:"parentId,omitempty"`
	StatusID    int    `json:"statusId,omitempty"`
}

type TicketType added in v0.1.9

type TicketType string
const (
	TicketTypeNone     TicketType = ""
	TicketTypeProblem  TicketType = "PROBLEM"
	TicketTypeQuestion TicketType = "QUESTION"
	TicketTypeIncident TicketType = "INCIDENT"
	TicketTypeTask     TicketType = "TASK"
)

type TicketingBoard added in v0.1.9

type TicketingBoard struct {
	ID          int             `json:"id"`
	UID         string          `json:"uid"`
	Name        string          `json:"name"`
	Description string          `json:"description"`
	Conditions  BoardConditions `json:"conditions"`
	CreateTime  int             `json:"createTime"`
	UpdateTime  int             `json:"updateTime"`
	System      bool            `json:"system"`
	Columns     []string        `json:"columns"`
	SortBy      map[string]any  `json:"sortBy"`
	TicketCount int             `json:"ticketCount"`
}

func ListTicketingBoards added in v0.1.9

func ListTicketingBoards() (boards []TicketingBoard, err error)

Returns list of ticketing boards

See https://eu.ninjarmm.com/apidocs-beta/core-resources/operations/getBoards

type Time

type Time time.Time

Better implementation of `double“ provided by NinjaAPI for time.Time.

func (Time) Add added in v0.0.6

func (j Time) Add(d time.Duration) Time

Add implements the time.Time.Add method for ninjarmm.Time.

func (Time) After added in v0.0.6

func (j Time) After(u time.Time) bool

After implements the time.Time.After method for ninjarmm.Time.

func (Time) AppendFormat added in v0.0.6

func (j Time) AppendFormat(b []byte, f string) []byte

AppendFormat implements the time.Time.AppendFormat method for ninjarmm.Time.

func (Time) Before added in v0.0.6

func (j Time) Before(u time.Time) bool

Before implements the time.Time.Before method for ninjarmm.Time.

func (Time) Clock added in v0.0.6

func (j Time) Clock() (int, int, int)

Clock implements the time.Time.Clock method for ninjarmm.Time.

func (Time) Date added in v0.0.6

func (j Time) Date() (int, time.Month, int)

Date implements the time.Time.Date method for ninjarmm.Time.

func (Time) Format

func (j Time) Format(s string) string

Format implements the fmt.Formatter interface for ninjarmm.Time.

func (Time) MarshalJSON

func (j Time) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for ninjarmm.Time.

func (Time) String

func (j Time) String() string

String implements the fmt.Stringer interface for ninjarmm.Time.

func (Time) Sub added in v0.0.6

func (j Time) Sub(u time.Time) time.Duration

Sub implements the time.Time.Sub method for ninjarmm.Time.

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(b []byte) (err error)

UnmarshalJSON implements the json.Unmarshaler interface for ninjarmm.Time.

type User

type User struct {
	ID               int              `json:"id"`
	Firstname        string           `json:"firstname"`
	Lastname         string           `json:"lastname"`
	Email            string           `json:"email"`
	Phone            string           `json:"phone"`
	Enabled          bool             `json:"enabled"`
	Administrator    bool             `json:"administrator"`
	PermitAllClients bool             `json:"permitAllClients"`
	NotifyAllClients bool             `json:"notifyAllClients"`
	MustChangePw     bool             `json:"mustChangePw"`
	MFAConfigured    bool             `json:"mfaConfigured"`
	UserType         UserType         `json:"userType"`         // 'TECHNICIAN' or 'END_USER'
	InvitationStatus InvitationStatus `json:"invitationStatus"` // 'PENDING' or 'REGISTERED' or 'EXPIRED'
	OrganizationID   int              `json:"organizationId"`   // For END_USER only
	DeviceIDs        []int            `json:"deviceIds"`
	Tags             []string         `json:"tags"`
	Fields           CustomFields     `json:"fields"`
}

func ListOrganizationUsers added in v0.0.6

func ListOrganizationUsers(organizationID int) (users []User, err error)

Returns list of end-users for organization

See https://eu.ninjarmm.com/apidocs-beta/core-resources/operations/getEndUsers

func ListUsers

func ListUsers(userType UserType) (users []User, err error)

List all users, can be filtered by user type

See https://eu.ninjarmm.com/apidocs-beta/core-resources/operations/getUsers

type UserType

type UserType string
const (
	UserTypeTechnician UserType = "TECHNICIAN"
	UserTypeEndUser    UserType = "END_USER"
	UserTypeContact    UserType = "CONTACT"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL