"""ActionBatchCamera API endpoints.

This file is automatically @generated from the Meraki API specification.
Do not edit this file manually.

"""

import urllib.parse
from typing import Any

from meraki_client.schemas import (
    CreateOrganizationActionBatchActionsItem,
    UpdateDeviceCameraCustomAnalyticsParametersItem,
    UpdateDeviceCameraSenseAudioDetection,
    UpdateDeviceCameraWirelessProfilesIds,
)
from meraki_client.types import (
    UpdateDeviceCameraQualityAndRetentionMotionDetectorVersion,
    UpdateDeviceCameraQualityAndRetentionQuality,
    UpdateDeviceCameraQualityAndRetentionResolution,
)


class ActionBatchCamera:
    """ActionBatchCamera class."""

    def __init__(self) -> None:
        pass

    def update_device_camera_custom_analytics(
        self,
        serial: str,
        *,
        enabled: bool | None = None,
        artifact_id: str | None = None,
        parameters: list[UpdateDeviceCameraCustomAnalyticsParametersItem] | None = None,
    ) -> CreateOrganizationActionBatchActionsItem:
        """Update custom analytics settings for a camera.

        [API documentation: updateDeviceCameraCustomAnalytics](https://developer.cisco.com/meraki/api-v1/#!update-device-camera-custom-analytics)

        Args:
            serial: Serial.
            enabled: Enable custom analytics.
            artifact_id: The ID of the custom analytics artifact.
            parameters: Parameters for the custom analytics workload.

        """
        serial = urllib.parse.quote(str(serial), safe="")
        path = f"/devices/{serial}/camera/customAnalytics"

        payload: dict[str, Any] = {}
        if enabled is not None:
            payload["enabled"] = enabled
        if artifact_id is not None:
            payload["artifactId"] = artifact_id
        if parameters is not None:
            payload["parameters"] = [
                item.model_dump(by_alias=True, exclude_none=True) for item in parameters
            ]

        return CreateOrganizationActionBatchActionsItem(
            resource=path,
            operation="update",
            body=payload,
        )

    def update_device_camera_quality_and_retention(
        self,
        serial: str,
        *,
        profile_id: str | None = None,
        motion_based_retention_enabled: bool | None = None,
        audio_recording_enabled: bool | None = None,
        restricted_bandwidth_mode_enabled: bool | None = None,
        quality: UpdateDeviceCameraQualityAndRetentionQuality | None = None,
        resolution: UpdateDeviceCameraQualityAndRetentionResolution | None = None,
        motion_detector_version: UpdateDeviceCameraQualityAndRetentionMotionDetectorVersion
        | None = None,
    ) -> CreateOrganizationActionBatchActionsItem:
        """Update quality and retention settings for the given camera.

        [API documentation: updateDeviceCameraQualityAndRetention](https://developer.cisco.com/meraki/api-v1/#!update-device-camera-quality-and-retention)

        Args:
            serial: Serial.
            profile_id: The ID of a quality and retention profile to assign to the camera. The
                profile's settings will override all of the per-camera quality and
                retention settings. If the value of this parameter is null, any existing
                profile will be unassigned from the camera.
            motion_based_retention_enabled: Boolean indicating if motion-based retention is
                enabled(true) or disabled(false) on the camera.
            audio_recording_enabled: Boolean indicating if audio recording is enabled(true) or
                disabled(false) on the camera.
            restricted_bandwidth_mode_enabled: Boolean indicating if restricted bandwidth is
                enabled(true) or disabled(false) on the camera. This setting does not
                apply to MV2 cameras.
            quality: Quality of the camera. Can be one of 'Standard', 'High', 'Enhanced' or 'Ultra'.
                Not all qualities are supported by every camera model.
            resolution: Resolution of the camera. Can be one of '1280x720', '1920x1080',
                '1080x1080', '2112x2112', '2880x2880', '2688x1512' or '3840x2160'.Not
                all resolutions are supported by every camera model.
            motion_detector_version: The version of the motion detector that will be used by the
                camera. Only applies to Gen 2 cameras. Defaults to v2.

        """
        serial = urllib.parse.quote(str(serial), safe="")
        path = f"/devices/{serial}/camera/qualityAndRetention"

        payload: dict[str, Any] = {}
        if profile_id is not None:
            payload["profileId"] = profile_id
        if motion_based_retention_enabled is not None:
            payload["motionBasedRetentionEnabled"] = motion_based_retention_enabled
        if audio_recording_enabled is not None:
            payload["audioRecordingEnabled"] = audio_recording_enabled
        if restricted_bandwidth_mode_enabled is not None:
            payload["restrictedBandwidthModeEnabled"] = restricted_bandwidth_mode_enabled
        if quality is not None:
            payload["quality"] = quality
        if resolution is not None:
            payload["resolution"] = resolution
        if motion_detector_version is not None:
            payload["motionDetectorVersion"] = motion_detector_version

        return CreateOrganizationActionBatchActionsItem(
            resource=path,
            operation="update",
            body=payload,
        )

    def update_device_camera_sense(
        self,
        serial: str,
        *,
        sense_enabled: bool | None = None,
        mqtt_broker_id: str | None = None,
        audio_detection: UpdateDeviceCameraSenseAudioDetection | None = None,
        detection_model_id: str | None = None,
    ) -> CreateOrganizationActionBatchActionsItem:
        """Update sense settings for the given camera.

        [API documentation: updateDeviceCameraSense](https://developer.cisco.com/meraki/api-v1/#!update-device-camera-sense)

        Args:
            serial: Serial.
            sense_enabled: Boolean indicating if sense(license) is enabled(true) or disabled(false)
                on the camera.
            mqtt_broker_id: The ID of the MQTT broker to be enabled on the camera. A value of null
                will disable MQTT on the camera.
            audio_detection: The details of the audio detection config.
            detection_model_id: The ID of the object detection model.

        """
        serial = urllib.parse.quote(str(serial), safe="")
        path = f"/devices/{serial}/camera/sense"

        payload: dict[str, Any] = {}
        if sense_enabled is not None:
            payload["senseEnabled"] = sense_enabled
        if mqtt_broker_id is not None:
            payload["mqttBrokerId"] = mqtt_broker_id
        if audio_detection is not None:
            payload["audioDetection"] = audio_detection.model_dump(by_alias=True, exclude_none=True)
        if detection_model_id is not None:
            payload["detectionModelId"] = detection_model_id

        return CreateOrganizationActionBatchActionsItem(
            resource=path,
            operation="update",
            body=payload,
        )

    def update_device_camera_video_settings(
        self, serial: str, *, external_rtsp_enabled: bool | None = None
    ) -> CreateOrganizationActionBatchActionsItem:
        """Update video settings for the given camera.

        [API documentation: updateDeviceCameraVideoSettings](https://developer.cisco.com/meraki/api-v1/#!update-device-camera-video-settings)

        Args:
            serial: Serial.
            external_rtsp_enabled: Boolean indicating if external rtsp stream is exposed.

        """
        serial = urllib.parse.quote(str(serial), safe="")
        path = f"/devices/{serial}/camera/video/settings"

        payload: dict[str, Any] = {}
        if external_rtsp_enabled is not None:
            payload["externalRtspEnabled"] = external_rtsp_enabled

        return CreateOrganizationActionBatchActionsItem(
            resource=path,
            operation="update",
            body=payload,
        )

    def update_device_camera_wireless_profiles(
        self, *, serial: str, ids: UpdateDeviceCameraWirelessProfilesIds
    ) -> CreateOrganizationActionBatchActionsItem:
        """Assign wireless profiles to the given camera.

        [API documentation: updateDeviceCameraWirelessProfiles](https://developer.cisco.com/meraki/api-v1/#!update-device-camera-wireless-profiles)

        Args:
            serial: Serial.
            ids: The ids of the wireless profile to assign to the given camera.

        """
        serial = urllib.parse.quote(str(serial), safe="")
        path = f"/devices/{serial}/camera/wirelessProfiles"

        payload: dict[str, Any] = {}
        if ids is not None:
            payload["ids"] = ids.model_dump(by_alias=True, exclude_none=True)

        return CreateOrganizationActionBatchActionsItem(
            resource=path,
            operation="update",
            body=payload,
        )
