{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Datto RMM Device Response Schema",
  "description": "JSON schema for the response when requesting an individual device from Datto RMM API v2",
  "type": "object",
  "properties": {
    "item": {
      "type": "object",
      "description": "The device object returned by the API",
      "properties": {
        "id": {
          "type": "number",
          "description": "Unique numeric identifier for the device"
        },
        "uid": {
          "type": "string",
          "description": "Unique string identifier for the device"
        },
        "siteId": {
          "type": "number",
          "description": "Numeric identifier of the site this device belongs to"
        },
        "siteUid": {
          "type": "string",
          "description": "String identifier of the site this device belongs to"
        },
        "siteName": {
          "type": "string",
          "description": "Name of the site this device belongs to"
        },
        "deviceType": {
          "type": "object",
          "description": "Device type classification",
          "properties": {
            "category": {
              "type": "string",
              "description": "Device category (e.g., 'Server', 'Workstation', 'Laptop')"
            },
            "type": {
              "type": "string",
              "description": "Specific device type"
            }
          },
          "required": ["category", "type"]
        },
        "hostname": {
          "type": "string",
          "description": "Device hostname"
        },
        "description": {
          "type": "string",
          "description": "Device description"
        },
        "intIpAddress": {
          "type": "string",
          "description": "Internal IP address"
        },
        "extIpAddress": {
          "type": "string",
          "description": "External IP address"
        },
        "macAddresses": {
          "type": "array",
          "description": "List of MAC addresses associated with the device",
          "items": {
            "type": "string"
          }
        },
        "domain": {
          "type": "string",
          "description": "Domain the device belongs to"
        },
        "manufacturer": {
          "type": "string",
          "description": "Device manufacturer (e.g., 'Dell', 'HP', 'Lenovo')"
        },
        "model": {
          "type": "string",
          "description": "Device model"
        },
        "serialNumber": {
          "type": "string",
          "description": "Device serial number"
        },
        "lastSeen": {
          "type": "number",
          "description": "Timestamp in milliseconds when device was last seen"
        },
        "lastLoggedInUser": {
          "type": "string",
          "description": "Username of the last logged in user"
        },
        "lastReboot": {
          "type": "number",
          "description": "Timestamp in milliseconds of last reboot"
        },
        "lastAuditDate": {
          "type": "number",
          "description": "Timestamp in milliseconds of last audit"
        },
        "creationDate": {
          "type": "number",
          "description": "Timestamp in milliseconds when device was created in RMM"
        },
        "online": {
          "type": "boolean",
          "description": "Whether the device is currently online"
        },
        "suspended": {
          "type": "boolean",
          "description": "Whether the device is suspended"
        },
        "deleted": {
          "type": "boolean",
          "description": "Whether the device is marked as deleted"
        },
        "rebootRequired": {
          "type": "boolean",
          "description": "Whether a reboot is required"
        },
        "a64Bit": {
          "type": "boolean",
          "description": "Whether the device is 64-bit architecture"
        },
        "operatingSystem": {
          "type": "string",
          "description": "Operating system name and version"
        },
        "cagVersion": {
          "type": "string",
          "description": "Version of the Datto RMM agent (CAG)"
        },
        "displayVersion": {
          "type": "string",
          "description": "Display version of the operating system"
        },
        "memory": {
          "type": "number",
          "description": "Total memory in MB"
        },
        "cpuCores": {
          "type": "number",
          "description": "Number of CPU cores"
        },
        "cpuName": {
          "type": "string",
          "description": "CPU model name"
        },
        "diskSize": {
          "type": "number",
          "description": "Total disk size in GB"
        },
        "antivirus": {
          "type": "object",
          "description": "Antivirus information",
          "properties": {
            "antivirusProduct": {
              "type": "string",
              "description": "Name of the antivirus product"
            },
            "antivirusStatus": {
              "type": "string",
              "description": "Status of the antivirus (e.g., 'Up to date', 'Out of date')"
            }
          },
          "required": ["antivirusProduct", "antivirusStatus"]
        },
        "patchManagement": {
          "type": "object",
          "description": "Patch management information",
          "properties": {
            "patchStatus": {
              "type": "string",
              "description": "Overall patch status"
            },
            "patchesApprovedPending": {
              "type": "number",
              "description": "Number of approved patches pending installation"
            },
            "patchesNotApproved": {
              "type": "number",
              "description": "Number of patches not yet approved"
            },
            "patchesInstalled": {
              "type": "number",
              "description": "Number of patches installed"
            }
          },
          "required": ["patchStatus", "patchesApprovedPending", "patchesNotApproved", "patchesInstalled"]
        },
        "softwareStatus": {
          "type": "string",
          "description": "Software status"
        },
        "portalUrl": {
          "type": "string",
          "description": "URL to the device in the Datto RMM portal"
        },
        "webRemoteUrl": {
          "type": "string",
          "description": "URL for web-based remote access"
        },
        "warrantyDate": {
          "type": ["string", "null"],
          "description": "Warranty expiration date"
        },
        "snmpEnabled": {
          "type": "boolean",
          "description": "Whether SNMP is enabled on the device"
        },
        "deviceClass": {
          "type": "string",
          "description": "Device class classification"
        },
        "udf": {
          "type": "object",
          "description": "User-defined fields (custom fields)",
          "additionalProperties": true
        }
      },
      "required": [
        "id",
        "uid",
        "siteId",
        "siteUid",
        "siteName",
        "deviceType",
        "hostname",
        "description",
        "intIpAddress",
        "extIpAddress",
        "domain",
        "lastSeen",
        "online",
        "suspended",
        "deleted",
        "operatingSystem"
      ]
    }
  },
  "required": ["item"]
}
