{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/viridi-parente/main/json-schema/viridi-parente-device-schema.json",
  "title": "Device",
  "x-generated": "2026-10-20",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/viridi-parente-device-controller-api-openapi.yml#/components/schemas/Device",
  "properties": {
    "id": {
      "$ref": "#/$defs/DeviceId",
      "description": "JSON object with the Device Id. Specify this field to update the Device. Referencing non-existing Device Id will cause error. Omit this field to create new Device."
    },
    "createdTime": {
      "type": "integer",
      "format": "int64",
      "description": "Timestamp of the device creation, in milliseconds",
      "readOnly": true
    },
    "tenantId": {
      "$ref": "#/$defs/TenantId",
      "description": "JSON object with Tenant Id. Use 'assignDeviceToTenant' to change the Tenant Id.",
      "readOnly": true
    },
    "customerId": {
      "$ref": "#/$defs/CustomerId",
      "description": "JSON object with Customer Id. Use 'assignDeviceToCustomer' to change the Customer Id.",
      "readOnly": true
    },
    "name": {
      "type": "string",
      "description": "Unique Device Name in scope of Tenant"
    },
    "type": {
      "type": "string",
      "description": "Device Profile Name"
    },
    "label": {
      "type": "string",
      "description": "Label that may be used in widgets"
    },
    "deviceProfileId": {
      "$ref": "#/$defs/DeviceProfileId",
      "description": "JSON object with Device Profile Id."
    },
    "firmwareId": {
      "$ref": "#/$defs/OtaPackageId",
      "description": "JSON object with Ota Package Id."
    },
    "softwareId": {
      "$ref": "#/$defs/OtaPackageId",
      "description": "JSON object with Ota Package Id."
    },
    "additionalInfo": {
      "$ref": "#/$defs/JsonNode",
      "description": "Additional parameters of the device"
    },
    "deviceData": {
      "$ref": "#/$defs/DeviceData",
      "description": "JSON object with content specific to type of transport in the device profile."
    }
  },
  "required": [
    "deviceProfileId",
    "name"
  ],
  "$defs": {
    "CoapDeviceTransportConfiguration": {
      "allOf": [
        {
          "$ref": "#/$defs/DeviceTransportConfiguration"
        },
        {
          "type": "object",
          "properties": {
            "powerMode": {
              "type": "string",
              "enum": [
                "PSM",
                "DRX",
                "E_DRX"
              ]
            },
            "psmActivityTimer": {
              "type": "integer",
              "format": "int64"
            },
            "edrxCycle": {
              "type": "integer",
              "format": "int64"
            },
            "pagingTransmissionWindow": {
              "type": "integer",
              "format": "int64"
            }
          }
        }
      ]
    },
    "CustomerId": {
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid",
          "description": "ID of the entity, time-based UUID v1"
        },
        "entityType": {
          "type": "string",
          "description": "string",
          "enum": [
            "CUSTOMER"
          ]
        }
      },
      "required": [
        "entityType",
        "id"
      ]
    },
    "DefaultDeviceConfiguration": {
      "allOf": [
        {
          "$ref": "#/$defs/DeviceConfiguration"
        }
      ]
    },
    "DefaultDeviceTransportConfiguration": {
      "allOf": [
        {
          "$ref": "#/$defs/DeviceTransportConfiguration"
        }
      ]
    },
    "DeviceConfiguration": {
      "properties": {
        "type": {
          "type": "string"
        }
      },
      "required": [
        "type"
      ]
    },
    "DeviceData": {
      "properties": {
        "configuration": {
          "description": "Device configuration for device profile type. DEFAULT is only supported value for now",
          "oneOf": [
            {
              "$ref": "#/$defs/DefaultDeviceConfiguration"
            }
          ]
        },
        "transportConfiguration": {
          "description": "Device transport configuration used to connect the device",
          "oneOf": [
            {
              "$ref": "#/$defs/CoapDeviceTransportConfiguration"
            },
            {
              "$ref": "#/$defs/DefaultDeviceTransportConfiguration"
            },
            {
              "$ref": "#/$defs/Lwm2mDeviceTransportConfiguration"
            },
            {
              "$ref": "#/$defs/MqttDeviceTransportConfiguration"
            },
            {
              "$ref": "#/$defs/SnmpDeviceTransportConfiguration"
            }
          ]
        }
      }
    },
    "DeviceId": {
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid",
          "description": "ID of the entity, time-based UUID v1"
        },
        "entityType": {
          "type": "string",
          "description": "string",
          "enum": [
            "DEVICE"
          ]
        }
      },
      "required": [
        "entityType",
        "id"
      ]
    },
    "DeviceProfileId": {
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid",
          "description": "ID of the entity, time-based UUID v1"
        },
        "entityType": {
          "type": "string",
          "description": "string",
          "enum": [
            "DEVICE_PROFILE"
          ]
        }
      },
      "required": [
        "entityType",
        "id"
      ]
    },
    "DeviceTransportConfiguration": {
      "properties": {
        "type": {
          "type": "string"
        }
      },
      "required": [
        "type"
      ]
    },
    "JsonNode": {
      "description": "A value representing the any type (object or primitive)"
    },
    "Lwm2mDeviceTransportConfiguration": {
      "allOf": [
        {
          "$ref": "#/$defs/DeviceTransportConfiguration"
        },
        {
          "type": "object",
          "properties": {
            "powerMode": {
              "type": "string",
              "enum": [
                "PSM",
                "DRX",
                "E_DRX"
              ]
            },
            "psmActivityTimer": {
              "type": "integer",
              "format": "int64"
            },
            "edrxCycle": {
              "type": "integer",
              "format": "int64"
            },
            "pagingTransmissionWindow": {
              "type": "integer",
              "format": "int64"
            }
          }
        }
      ]
    },
    "MqttDeviceTransportConfiguration": {
      "allOf": [
        {
          "$ref": "#/$defs/DeviceTransportConfiguration"
        }
      ]
    },
    "OtaPackageId": {
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid",
          "description": "ID of the entity, time-based UUID v1"
        },
        "entityType": {
          "type": "string",
          "description": "string",
          "enum": [
            "OTA_PACKAGE"
          ]
        }
      },
      "required": [
        "entityType",
        "id"
      ]
    },
    "SnmpDeviceTransportConfiguration": {
      "allOf": [
        {
          "$ref": "#/$defs/DeviceTransportConfiguration"
        },
        {
          "type": "object",
          "properties": {
            "host": {
              "type": "string"
            },
            "port": {
              "type": "integer",
              "format": "int32"
            },
            "protocolVersion": {
              "type": "string",
              "enum": [
                "V1",
                "V2C",
                "V3"
              ]
            },
            "community": {
              "type": "string"
            },
            "username": {
              "type": "string"
            },
            "securityName": {
              "type": "string"
            },
            "contextName": {
              "type": "string"
            },
            "authenticationProtocol": {
              "type": "string",
              "enum": [
                "SHA_1",
                "SHA_224",
                "SHA_256",
                "SHA_384",
                "SHA_512",
                "MD5"
              ]
            },
            "authenticationPassphrase": {
              "type": "string"
            },
            "privacyProtocol": {
              "type": "string",
              "enum": [
                "DES",
                "AES_128",
                "AES_192",
                "AES_256"
              ]
            },
            "privacyPassphrase": {
              "type": "string"
            },
            "engineId": {
              "type": "string"
            }
          }
        }
      ]
    },
    "TenantId": {
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid",
          "description": "ID of the entity, time-based UUID v1"
        },
        "entityType": {
          "type": "string",
          "description": "string",
          "enum": [
            "TENANT"
          ]
        }
      },
      "required": [
        "entityType",
        "id"
      ]
    }
  }
}