"""ActionBatchCellularGateway 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,
    CreateOrganizationCellularGatewayEsimsServiceProvidersAccountServiceProvider,
    CreateOrganizationCellularGatewayEsimsSwapSwapsItem,
    UpdateDeviceCellularGatewayLanFixedIpAssignmentsItem,
    UpdateDeviceCellularGatewayLanReservedIpRangesItem,
    UpdateDeviceCellularGatewayPortForwardingRulesRulesItem,
    UpdateNetworkCellularGatewayConnectivityMonitoringDestinationsDestinationsItem,
    UpdateNetworkCellularGatewayUplinkBandwidthLimits,
)


class ActionBatchCellularGateway:
    """ActionBatchCellularGateway class."""

    def __init__(self) -> None:
        pass

    def update_device_cellular_gateway_lan(
        self,
        serial: str,
        *,
        reserved_ip_ranges: list[UpdateDeviceCellularGatewayLanReservedIpRangesItem] | None = None,
        fixed_ip_assignments: list[UpdateDeviceCellularGatewayLanFixedIpAssignmentsItem]
        | None = None,
    ) -> CreateOrganizationActionBatchActionsItem:
        """Update the LAN Settings for a single MG.

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

        Args:
            serial: Serial.
            reserved_ip_ranges: list of all reserved IP ranges for a single MG.
            fixed_ip_assignments: list of all fixed IP assignments for a single MG.

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

        payload: dict[str, Any] = {}
        if reserved_ip_ranges is not None:
            payload["reservedIpRanges"] = [
                item.model_dump(by_alias=True, exclude_none=True) for item in reserved_ip_ranges
            ]
        if fixed_ip_assignments is not None:
            payload["fixedIpAssignments"] = [
                item.model_dump(by_alias=True, exclude_none=True) for item in fixed_ip_assignments
            ]

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

    def update_device_cellular_gateway_port_forwarding_rules(
        self,
        serial: str,
        *,
        rules: list[UpdateDeviceCellularGatewayPortForwardingRulesRulesItem] | None = None,
    ) -> CreateOrganizationActionBatchActionsItem:
        """Updates the port forwarding rules for a single MG.

        [API documentation: updateDeviceCellularGatewayPortForwardingRules](https://developer.cisco.com/meraki/api-v1/#!update-device-cellular-gateway-port-forwarding-rules)

        Args:
            serial: Serial.
            rules: An array of port forwarding params.

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

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

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

    def update_network_cellular_gateway_connectivity_monitoring_destinations(
        self,
        network_id: str,
        *,
        destinations: list[
            UpdateNetworkCellularGatewayConnectivityMonitoringDestinationsDestinationsItem
        ]
        | None = None,
    ) -> CreateOrganizationActionBatchActionsItem:
        """Update the connectivity testing destinations for an MG network.

        [API documentation: updateNetworkCellularGatewayConnectivityMonitoringDestinations](https://developer.cisco.com/meraki/api-v1/#!update-network-cellular-gateway-connectivity-monitoring-destinations)

        Args:
            network_id: Network ID.
            destinations: The list of connectivity monitoring destinations.

        """
        network_id = urllib.parse.quote(str(network_id), safe="")
        path = f"/networks/{network_id}/cellularGateway/connectivityMonitoringDestinations"

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

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

    def update_network_cellular_gateway_dhcp(
        self,
        network_id: str,
        *,
        dhcp_lease_time: str | None = None,
        dns_nameservers: str | None = None,
        dns_custom_nameservers: list[str] | None = None,
    ) -> CreateOrganizationActionBatchActionsItem:
        """Update common DHCP settings of MGs.

        [API documentation: updateNetworkCellularGatewayDhcp](https://developer.cisco.com/meraki/api-v1/#!update-network-cellular-gateway-dhcp)

        Args:
            network_id: Network ID.
            dhcp_lease_time: DHCP Lease time for all MG of the network. Possible values are '30
                minutes', '1 hour', '4 hours', '12 hours', '1 day' or '1 week'.
            dns_nameservers: DNS name servers mode for all MG of the network. Possible values are:
                'upstream_dns', 'google_dns', 'opendns', 'custom'.
            dns_custom_nameservers: list of fixed IPs representing the the DNS Name servers when the
                mode is 'custom'.

        """
        network_id = urllib.parse.quote(str(network_id), safe="")
        path = f"/networks/{network_id}/cellularGateway/dhcp"

        payload: dict[str, Any] = {}
        if dhcp_lease_time is not None:
            payload["dhcpLeaseTime"] = dhcp_lease_time
        if dns_nameservers is not None:
            payload["dnsNameservers"] = dns_nameservers
        if dns_custom_nameservers is not None:
            payload["dnsCustomNameservers"] = dns_custom_nameservers

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

    def update_network_cellular_gateway_subnet_pool(
        self, network_id: str, *, mask: int | None = None, cidr: str | None = None
    ) -> CreateOrganizationActionBatchActionsItem:
        """Update the subnet pool and mask configuration for MGs in the network.

        [API documentation: updateNetworkCellularGatewaySubnetPool](https://developer.cisco.com/meraki/api-v1/#!update-network-cellular-gateway-subnet-pool)

        Args:
            network_id: Network ID.
            mask: Mask used for the subnet of all MGs in this network.
            cidr: CIDR of the pool of subnets. Each MG in this network will automatically pick a
                subnet from this pool.

        """
        network_id = urllib.parse.quote(str(network_id), safe="")
        path = f"/networks/{network_id}/cellularGateway/subnetPool"

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

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

    def update_network_cellular_gateway_uplink(
        self,
        network_id: str,
        *,
        bandwidth_limits: UpdateNetworkCellularGatewayUplinkBandwidthLimits | None = None,
    ) -> CreateOrganizationActionBatchActionsItem:
        """Updates the uplink settings for your MG network.

        [API documentation: updateNetworkCellularGatewayUplink](https://developer.cisco.com/meraki/api-v1/#!update-network-cellular-gateway-uplink)

        Args:
            network_id: Network ID.
            bandwidth_limits: The bandwidth settings for the 'cellular' uplink.

        """
        network_id = urllib.parse.quote(str(network_id), safe="")
        path = f"/networks/{network_id}/cellularGateway/uplink"

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

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

    def update_organization_cellular_gateway_esims_inventory(
        self, *, organization_id: str, id: str, status: str | None = None
    ) -> CreateOrganizationActionBatchActionsItem:
        """Toggle the status of an eSIM.

        [API documentation: updateOrganizationCellularGatewayEsimsInventory](https://developer.cisco.com/meraki/api-v1/#!update-organization-cellular-gateway-esims-inventory)

        Args:
            organization_id: Organization ID.
            id: ID.
            status: Status the eSIM will be updated to.

        """
        organization_id = urllib.parse.quote(str(organization_id), safe="")
        id = urllib.parse.quote(str(id), safe="")
        path = f"/organizations/{organization_id}/cellularGateway/esims/inventory/{id}"

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

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

    def create_organization_cellular_gateway_esims_service_providers_account(
        self,
        *,
        organization_id: str,
        account_id: str,
        api_key: str,
        service_provider: CreateOrganizationCellularGatewayEsimsServiceProvidersAccountServiceProvider,
        title: str,
        username: str,
    ) -> CreateOrganizationActionBatchActionsItem:
        """Add a service provider account.

        [API documentation: createOrganizationCellularGatewayEsimsServiceProvidersAccount](https://developer.cisco.com/meraki/api-v1/#!create-organization-cellular-gateway-esims-service-providers-account)

        Args:
            organization_id: Organization ID.
            account_id: Service provider account ID.
            api_key: Service provider account API key.
            service_provider: Service Provider information.
            title: Service provider account name.
            username: Service provider account username.

        """
        organization_id = urllib.parse.quote(str(organization_id), safe="")
        path = f"/organizations/{organization_id}/cellularGateway/esims/serviceProviders/accounts"

        payload: dict[str, Any] = {}
        if account_id is not None:
            payload["accountId"] = account_id
        if api_key is not None:
            payload["apiKey"] = api_key
        if service_provider is not None:
            payload["serviceProvider"] = service_provider.model_dump(
                by_alias=True, exclude_none=True
            )
        if title is not None:
            payload["title"] = title
        if username is not None:
            payload["username"] = username

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

    def update_organization_cellular_gateway_esims_service_providers_account(
        self,
        *,
        organization_id: str,
        account_id: str,
        title: str | None = None,
        api_key: str | None = None,
    ) -> CreateOrganizationActionBatchActionsItem:
        """Edit service provider account info stored in Meraki's database.

        [API documentation: updateOrganizationCellularGatewayEsimsServiceProvidersAccount](https://developer.cisco.com/meraki/api-v1/#!update-organization-cellular-gateway-esims-service-providers-account)

        Args:
            organization_id: Organization ID.
            account_id: Account ID.
            title: Service provider account name used on the Meraki UI.
            api_key: Service provider account API key.

        """
        organization_id = urllib.parse.quote(str(organization_id), safe="")
        account_id = urllib.parse.quote(str(account_id), safe="")
        path = f"/organizations/{organization_id}/cellularGateway/esims/serviceProviders/accounts/{account_id}"

        payload: dict[str, Any] = {}
        if title is not None:
            payload["title"] = title
        if api_key is not None:
            payload["apiKey"] = api_key

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

    def delete_organization_cellular_gateway_esims_service_providers_account(
        self, *, organization_id: str, account_id: str
    ) -> CreateOrganizationActionBatchActionsItem:
        """Remove a service provider account's integration with the Dashboard.

        [API documentation: deleteOrganizationCellularGatewayEsimsServiceProvidersAccount](https://developer.cisco.com/meraki/api-v1/#!delete-organization-cellular-gateway-esims-service-providers-account)

        Args:
            organization_id: Organization ID.
            account_id: Account ID.

        """
        organization_id = urllib.parse.quote(str(organization_id), safe="")
        account_id = urllib.parse.quote(str(account_id), safe="")
        path = f"/organizations/{organization_id}/cellularGateway/esims/serviceProviders/accounts/{account_id}"

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

    def create_organization_cellular_gateway_esims_swap(
        self,
        *,
        organization_id: str,
        swaps: list[CreateOrganizationCellularGatewayEsimsSwapSwapsItem],
    ) -> CreateOrganizationActionBatchActionsItem:
        """Swap which profile an eSIM uses.

        [API documentation: createOrganizationCellularGatewayEsimsSwap](https://developer.cisco.com/meraki/api-v1/#!create-organization-cellular-gateway-esims-swap)

        Args:
            organization_id: Organization ID.
            swaps: Each object represents a swap for one eSIM.

        """
        organization_id = urllib.parse.quote(str(organization_id), safe="")
        path = f"/organizations/{organization_id}/cellularGateway/esims/swap"

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

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

    def update_organization_cellular_gateway_esims_swap(
        self, *, id: str, organization_id: str
    ) -> CreateOrganizationActionBatchActionsItem:
        """Get the status of a profile swap.

        [API documentation: updateOrganizationCellularGatewayEsimsSwap](https://developer.cisco.com/meraki/api-v1/#!update-organization-cellular-gateway-esims-swap)

        Args:
            id: eSIM EID.
            organization_id: Organization ID.

        """
        id = urllib.parse.quote(str(id), safe="")
        organization_id = urllib.parse.quote(str(organization_id), safe="")
        path = f"/organizations/{organization_id}/cellularGateway/esims/swap/{id}"

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