"""ActionBatchInsight 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,
)


class ActionBatchInsight:
    """ActionBatchInsight class."""

    def __init__(self) -> None:
        pass

    def create_organization_insight_monitored_media_server(
        self,
        *,
        organization_id: str,
        name: str,
        address: str,
        best_effort_monitoring_enabled: bool | None = None,
    ) -> CreateOrganizationActionBatchActionsItem:
        """Add a media server to be monitored for this organization.

        [API documentation: createOrganizationInsightMonitoredMediaServer](https://developer.cisco.com/meraki/api-v1/#!create-organization-insight-monitored-media-server)

        Args:
            organization_id: Organization ID.
            name: The name of the VoIP provider.
            address: The IP address (IPv4 only) or hostname of the media server to monitor.
            best_effort_monitoring_enabled: Indicates that if the media server doesn't respond to
                ICMP pings, the nearest hop will be used in its stead.

        """
        organization_id = urllib.parse.quote(str(organization_id), safe="")
        path = f"/organizations/{organization_id}/insight/monitoredMediaServers"

        payload: dict[str, Any] = {}
        if name is not None:
            payload["name"] = name
        if address is not None:
            payload["address"] = address
        if best_effort_monitoring_enabled is not None:
            payload["bestEffortMonitoringEnabled"] = best_effort_monitoring_enabled

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

    def update_organization_insight_monitored_media_server(
        self,
        *,
        organization_id: str,
        monitored_media_server_id: str,
        name: str | None = None,
        address: str | None = None,
        best_effort_monitoring_enabled: bool | None = None,
    ) -> CreateOrganizationActionBatchActionsItem:
        """Update a monitored media server for this organization.

        [API documentation: updateOrganizationInsightMonitoredMediaServer](https://developer.cisco.com/meraki/api-v1/#!update-organization-insight-monitored-media-server)

        Args:
            organization_id: Organization ID.
            monitored_media_server_id: Monitored media server ID.
            name: The name of the VoIP provider.
            address: The IP address (IPv4 only) or hostname of the media server to monitor.
            best_effort_monitoring_enabled: Indicates that if the media server doesn't respond to
                ICMP pings, the nearest hop will be used in its stead.

        """
        organization_id = urllib.parse.quote(str(organization_id), safe="")
        monitored_media_server_id = urllib.parse.quote(str(monitored_media_server_id), safe="")
        path = f"/organizations/{organization_id}/insight/monitoredMediaServers/{monitored_media_server_id}"

        payload: dict[str, Any] = {}
        if name is not None:
            payload["name"] = name
        if address is not None:
            payload["address"] = address
        if best_effort_monitoring_enabled is not None:
            payload["bestEffortMonitoringEnabled"] = best_effort_monitoring_enabled

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

    def delete_organization_insight_monitored_media_server(
        self, *, organization_id: str, monitored_media_server_id: str
    ) -> CreateOrganizationActionBatchActionsItem:
        """Delete a monitored media server from this organization.

        [API documentation: deleteOrganizationInsightMonitoredMediaServer](https://developer.cisco.com/meraki/api-v1/#!delete-organization-insight-monitored-media-server)

        Args:
            organization_id: Organization ID.
            monitored_media_server_id: Monitored media server ID.

        """
        organization_id = urllib.parse.quote(str(organization_id), safe="")
        monitored_media_server_id = urllib.parse.quote(str(monitored_media_server_id), safe="")
        path = f"/organizations/{organization_id}/insight/monitoredMediaServers/{monitored_media_server_id}"

        return CreateOrganizationActionBatchActionsItem(
            resource=path,
            operation="destroy",
        )
