{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/eagle-eye-networks/main/json-schema/eagle-eye-networks-api-add-camera-schema.json",
  "title": "ApiAddCamera",
  "description": "Base schema to describe all new cameras to be created.\n",
  "x-generated": "2026-10-14",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/eagle-eye-networks-devices-openapi.yml#/components/schemas/ApiAddCamera",
  "oneOf": [
    {
      "$ref": "#/$defs/ApiBridgeCameraCreate"
    },
    {
      "$ref": "#/$defs/ApiRtspCameraCreate"
    },
    {
      "$ref": "#/$defs/ApiCameraDirectCreate"
    },
    {
      "$ref": "#/$defs/ApiAxisCameraDirectCreate"
    },
    {
      "$ref": "#/$defs/ApiChannelCameraCreate"
    }
  ],
  "properties": {
    "registrationStrategy": {
      "$ref": "#/$defs/ApiRegistrationStrategy"
    }
  },
  "required": [
    "registrationStrategy"
  ],
  "$defs": {
    "ApiAxisCameraDirectCreate": {
      "description": "Schema used to describe a new Axis camera to be created that directly connects to the cloud.\n",
      "allOf": [
        {
          "$ref": "#/$defs/ApiCameraDirectCreate"
        },
        {
          "type": "object",
          "properties": {
            "oak": {
              "$ref": "#/$defs/oak"
            },
            "serial": {
              "$ref": "#/$defs/serial"
            }
          },
          "required": [
            "oak",
            "serial"
          ]
        }
      ]
    },
    "ApiBaseCameraCreate": {
      "type": "object",
      "properties": {
        "name": {
          "$ref": "#/$defs/DeviceName"
        },
        "tags": {
          "$ref": "#/$defs/DeviceTags"
        },
        "locationId": {
          "$ref": "#/$defs/LocationId"
        },
        "devicePosition": {
          "$ref": "#/$defs/ApiDevicePosition"
        },
        "deviceAddress": {
          "$ref": "#/$defs/DeviceAddress"
        }
      }
    },
    "ApiBridgeCameraCreate": {
      "description": "Schema used to describe a new camera to be created that should be attached to a bridge.\n",
      "allOf": [
        {
          "$ref": "#/$defs/ApiBridgedCameraCreate"
        },
        {
          "type": "object",
          "properties": {
            "guid": {
              "$ref": "#/$defs/Guid"
            }
          },
          "required": [
            "name",
            "bridgeId",
            "guid"
          ]
        }
      ]
    },
    "ApiBridgedCameraCreate": {
      "description": "Base schema for cameras that are attached to a bridge, vs cameras that are connected directly to the cloud.\n",
      "allOf": [
        {
          "$ref": "#/$defs/ApiBaseCameraCreate"
        },
        {
          "type": "object",
          "properties": {
            "bridgeId": {
              "$ref": "#/$defs/BridgeId"
            },
            "credentials": {
              "$ref": "#/$defs/ApiDeviceCredentials"
            }
          }
        }
      ]
    },
    "ApiCameraDirectCreate": {
      "description": "Schema used to describe a new camera to be created that directly connects to the cloud.\n",
      "allOf": [
        {
          "$ref": "#/$defs/ApiBaseCameraCreate"
        },
        {
          "type": "object",
          "properties": {
            "macAddress": {
              "$ref": "#/$defs/MacAddress"
            }
          },
          "required": [
            "name",
            "macAddress"
          ]
        }
      ]
    },
    "ApiChannelCameraCreate": {
      "description": "Schema used to describe a new channel camera to be created that should be attached to a multi camera.\n",
      "properties": {
        "guid": {
          "$ref": "#/$defs/Guid"
        },
        "name": {
          "$ref": "#/$defs/DeviceName"
        },
        "tags": {
          "$ref": "#/$defs/DeviceTags"
        },
        "locationId": {
          "$ref": "#/$defs/LocationId"
        },
        "bridgeId": {
          "$ref": "#/$defs/BridgeId"
        }
      },
      "required": [
        "name",
        "bridgeId",
        "guid"
      ]
    },
    "ApiDeviceCredentials": {
      "type": "object",
      "x-jsoninclude-nonnull-annotation": true,
      "properties": {
        "username": {
          "type": "string",
          "description": "Username to use when authenticating with the device",
          "maxLength": 126
        },
        "password": {
          "type": "string",
          "description": "Password to use when authenticating with the device",
          "maxLength": 126
        }
      }
    },
    "ApiDevicePosition": {
      "type": "object",
      "x-jsoninclude-nonnull-annotation": true,
      "properties": {
        "latitude": {
          "description": "The latitude of the device. (WGS 84)",
          "type": [
            "number",
            "null"
          ],
          "format": "double",
          "minimum": -90,
          "maximum": 90
        },
        "longitude": {
          "description": "The longitude of the device. (WGS 84).",
          "type": [
            "number",
            "null"
          ],
          "format": "double",
          "minimum": -180,
          "maximum": 180
        },
        "azimuth": {
          "type": [
            "number",
            "null"
          ],
          "format": "double",
          "minimum": 0,
          "maximum": 360
        },
        "rangeInMeters": {
          "type": [
            "number",
            "null"
          ],
          "format": "double",
          "minimum": 0
        },
        "floor": {
          "type": [
            "integer",
            "null"
          ],
          "minimum": -30,
          "maximum": 300
        },
        "fieldOfView": {
          "description": "Field of view is the range of the observable world visible at any given time through camera viewfinder.",
          "type": [
            "number",
            "null"
          ],
          "format": "double",
          "minimum": 0,
          "maximum": 360
        }
      }
    },
    "ApiRegistrationStrategy": {
      "type": "string",
      "enum": [
        "bridge",
        "rtspUrl",
        "cameraDirect",
        "channel"
      ],
      "description": "Cameras can be added in multiple ways, and this field indicates how this specific camera should be added. Possible methods:\n * `bridge`: Associate a camera found with `GET /api/v3.0/availableDevices` with one of the bridges that found it.\n * `rtspUrl`: Define a camera by giving a RTSP URL to retrieve its live stream and the bridge that should connect to it.\n * `cameraDirect`: Register a camera by its MAC address regardless of its physical location and without needing a bridge.\n * `channel`: Associate a channel camera with its parent multi camera.\n"
    },
    "ApiRtspCameraCreate": {
      "description": "Schema used to describe a new virtual camera to be created that should be created based on an RTSP stream.\n",
      "allOf": [
        {
          "$ref": "#/$defs/ApiBridgedCameraCreate"
        },
        {
          "type": "object",
          "properties": {
            "rtspSettings": {
              "$ref": "#/$defs/RtspConnectionSettings"
            }
          },
          "required": [
            "name",
            "bridgeId",
            "rtspSettings"
          ]
        }
      ]
    },
    "BridgeId": {
      "type": "string",
      "pattern": "^(?:0[xX])?[0-9a-fA-F]{8}$",
      "description": "The bridge a camera is connected to. Keep in mind that some cameras are connected directly to the cloud, which is when this field will not be reported.\n"
    },
    "DeviceAddress": {
      "type": "object",
      "x-jsoninclude-nonnull-annotation": true,
      "description": "Address of the device.",
      "properties": {
        "name": {
          "type": [
            "string",
            "null"
          ]
        },
        "address": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "DeviceName": {
      "description": "User-defined name for the device.",
      "type": "string",
      "minLength": 1,
      "maxLength": 126
    },
    "DeviceTags": {
      "type": "array",
      "maxItems": 64,
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 64
      }
    },
    "Guid": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid"
    },
    "LocationId": {
      "description": "ID Of the location.",
      "minLength": 1,
      "type": [
        "string",
        "null"
      ]
    },
    "MacAddress": {
      "type": [
        "string",
        "null"
      ],
      "pattern": "^([A-F0-9]{2}:){5}[A-F0-9]{2}$"
    },
    "RtspConnectionSettings": {
      "type": "object",
      "allOf": [
        {
          "$ref": "#/$defs/RtspConnectionSettings"
        }
      ],
      "required": [
        "ipAddress",
        "videoResourceUrl"
      ]
    },
    "oak": {
      "description": "Owner Authentication Key",
      "type": "string",
      "pattern": "^[A-Z0-9]{12}$",
      "nullable": false
    },
    "serial": {
      "type": "string",
      "pattern": "^[A-F0-9]{12}$",
      "nullable": false
    }
  }
}