"""ActionBatchDevices 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 (
    CreateDeviceLiveToolsLedsBlinkCallback,
    CreateDeviceLiveToolsThroughputTestCallback,
    CreateOrganizationActionBatchActionsItem,
    UpdateDeviceManagementInterfaceWan1,
    UpdateDeviceManagementInterfaceWan2,
)


class ActionBatchDevices:
    """ActionBatchDevices class."""

    def __init__(self) -> None:
        pass

    def update_device(
        self,
        serial: str,
        *,
        name: str | None = None,
        tags: list[str] | None = None,
        lat: float | None = None,
        lng: float | None = None,
        address: str | None = None,
        notes: str | None = None,
        move_map_marker: bool | None = None,
        switch_profile_id: str | None = None,
        floor_plan_id: str | None = None,
    ) -> CreateOrganizationActionBatchActionsItem:
        """Update the attributes of a device.

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

        Args:
            serial: Serial.
            name: The name of a device.
            tags: The list of tags of a device.
            lat: The latitude of a device.
            lng: The longitude of a device.
            address: The address of a device.
            notes: The notes for the device. String. Limited to 255 characters.
            move_map_marker: Whether or not to set the latitude and longitude of a device based on
                the new address. Only applies when lat and lng are not specified.
            switch_profile_id: The ID of a switch template to bind to the device (for available
                switch templates, see the 'Switch Templates' endpoint). Use null to
                unbind the switch device from the current profile. For a device to be
                bindable to a switch template, it must (1) be a switch, and (2) belong
                to a network that is bound to a configuration template.
            floor_plan_id: The floor plan to associate to this device. null disassociates the device
                from the floorplan.

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

        payload: dict[str, Any] = {}
        if name is not None:
            payload["name"] = name
        if tags is not None:
            payload["tags"] = tags
        if lat is not None:
            payload["lat"] = lat
        if lng is not None:
            payload["lng"] = lng
        if address is not None:
            payload["address"] = address
        if notes is not None:
            payload["notes"] = notes
        if move_map_marker is not None:
            payload["moveMapMarker"] = move_map_marker
        if switch_profile_id is not None:
            payload["switchProfileId"] = switch_profile_id
        if floor_plan_id is not None:
            payload["floorPlanId"] = floor_plan_id

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

    def create_device_live_tools_leds_blink(
        self,
        *,
        serial: str,
        duration: int,
        callback: CreateDeviceLiveToolsLedsBlinkCallback | None = None,
    ) -> CreateOrganizationActionBatchActionsItem:
        """Enqueue a job to blink LEDs on a device.

        [API documentation: createDeviceLiveToolsLedsBlink](https://developer.cisco.com/meraki/api-v1/#!create-device-live-tools-leds-blink)

        Args:
            serial: Serial.
            duration: The duration in seconds to blink LEDs.
            callback: Details for the callback. Please include either an httpServerId OR url and
                sharedSecret.

        """
        serial = urllib.parse.quote(str(serial), safe="")
        path = f"/devices/{serial}/liveTools/leds/blink"

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

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

    def create_device_live_tools_throughput_test(
        self, serial: str, *, callback: CreateDeviceLiveToolsThroughputTestCallback | None = None
    ) -> CreateOrganizationActionBatchActionsItem:
        """Enqueue a job to test a device throughput, the test will run for 10 secs to test throughput.

        [API documentation: createDeviceLiveToolsThroughputTest](https://developer.cisco.com/meraki/api-v1/#!create-device-live-tools-throughput-test)

        Args:
            serial: Serial.
            callback: Details for the callback. Please include either an httpServerId OR url and
                sharedSecret.

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

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

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

    def update_device_management_interface(
        self,
        serial: str,
        *,
        wan1: UpdateDeviceManagementInterfaceWan1 | None = None,
        wan2: UpdateDeviceManagementInterfaceWan2 | None = None,
    ) -> CreateOrganizationActionBatchActionsItem:
        """Update the management interface settings for a device.

        [API documentation: updateDeviceManagementInterface](https://developer.cisco.com/meraki/api-v1/#!update-device-management-interface)

        Args:
            serial: Serial.
            wan1: WAN 1 settings.
            wan2: WAN 2 settings (only for MX devices).

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

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

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