"""CellularGateway API endpoints.

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

"""

from __future__ import annotations

import urllib.parse
from typing import TYPE_CHECKING, Any, Literal

from meraki_client.schemas import (
    CreateOrganizationCellularGatewayEsimsServiceProvidersAccountResponse,
    CreateOrganizationCellularGatewayEsimsServiceProvidersAccountServiceProvider,
    CreateOrganizationCellularGatewayEsimsSwapResponse,
    CreateOrganizationCellularGatewayEsimsSwapSwapsItem,
    GetDeviceCellularGatewayLanResponse,
    GetDeviceCellularGatewayPortForwardingRulesResponse,
    GetNetworkCellularGatewayConnectivityMonitoringDestinationsResponse,
    GetNetworkCellularGatewayDhcpResponse,
    GetNetworkCellularGatewaySubnetPoolResponse,
    GetNetworkCellularGatewayUplinkResponse,
    GetOrganizationCellularGatewayEsimsInventoryResponseItemsItem,
    GetOrganizationCellularGatewayEsimsServiceProvidersAccountsCommunicationPlansResponseItemsItem,
    GetOrganizationCellularGatewayEsimsServiceProvidersAccountsRatePlansResponseItemsItem,
    GetOrganizationCellularGatewayEsimsServiceProvidersAccountsResponseItem,
    GetOrganizationCellularGatewayEsimsServiceProvidersResponseItemsItem,
    GetOrganizationCellularGatewayUplinkStatusesResponseItem,
    UpdateDeviceCellularGatewayLanFixedIpAssignmentsItem,
    UpdateDeviceCellularGatewayLanReservedIpRangesItem,
    UpdateDeviceCellularGatewayLanResponse,
    UpdateDeviceCellularGatewayPortForwardingRulesResponse,
    UpdateDeviceCellularGatewayPortForwardingRulesRulesItem,
    UpdateNetworkCellularGatewayConnectivityMonitoringDestinationsDestinationsItem,
    UpdateNetworkCellularGatewayConnectivityMonitoringDestinationsResponse,
    UpdateNetworkCellularGatewayDhcpResponse,
    UpdateNetworkCellularGatewaySubnetPoolResponse,
    UpdateNetworkCellularGatewayUplinkBandwidthLimits,
    UpdateNetworkCellularGatewayUplinkResponse,
    UpdateOrganizationCellularGatewayEsimsInventoryResponse,
    UpdateOrganizationCellularGatewayEsimsServiceProvidersAccountResponse,
    UpdateOrganizationCellularGatewayEsimsSwapResponse,
)

if TYPE_CHECKING:
    from meraki_client._session import PaginatedResponse, Session


class CellularGateway:
    """CellularGateway class."""

    def __init__(self, session: Session) -> None:
        self._session = session

    def get_device_cellular_gateway_lan(self, serial: str) -> GetDeviceCellularGatewayLanResponse:
        """Show the LAN Settings of a MG.

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

        Args:
            serial: Serial.

        Returns:
            Successful operation.

        Example API response:
            ```json
            {
              "deviceName": "name of the MG",
              "deviceLanIp": "192.168.0.33",
              "deviceSubnet": "192.168.0.32/27",
              "fixedIpAssignments": [
                {
                  "name": "server 1",
                  "ip": "192.168.0.10",
                  "mac": "0b:00:00:00:00:ac"
                }
              ],
              "reservedIpRanges": [
                {
                  "start": "192.168.1.0",
                  "end": "192.168.1.1",
                  "comment": "A reserved IP range"
                }
              ]
            }
            ```

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

        return self._session.get(
            scope="cellularGateway",
            operation_id="getDeviceCellularGatewayLan",
            path=path,
            response_schema=GetDeviceCellularGatewayLanResponse,
        )

    def update_device_cellular_gateway_lan(
        self,
        serial: str,
        *,
        reserved_ip_ranges: list[UpdateDeviceCellularGatewayLanReservedIpRangesItem] | None = None,
        fixed_ip_assignments: list[UpdateDeviceCellularGatewayLanFixedIpAssignmentsItem]
        | None = None,
    ) -> UpdateDeviceCellularGatewayLanResponse:
        """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.

        Returns:
            Successful operation.

        Example API response:
            ```json
            {
              "deviceName": "name of the MG",
              "deviceLanIp": "192.168.0.33",
              "deviceSubnet": "192.168.0.32/27",
              "fixedIpAssignments": [
                {
                  "name": "server 1",
                  "ip": "192.168.0.10",
                  "mac": "0b:00:00:00:00:ac"
                }
              ],
              "reservedIpRanges": [
                {
                  "start": "192.168.1.0",
                  "end": "192.168.1.1",
                  "comment": "A reserved IP range"
                }
              ]
            }
            ```

        """
        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 self._session.put(
            scope="cellularGateway",
            operation_id="updateDeviceCellularGatewayLan",
            path=path,
            json=payload,
            response_schema=UpdateDeviceCellularGatewayLanResponse,
        )

    def get_device_cellular_gateway_port_forwarding_rules(
        self, serial: str
    ) -> GetDeviceCellularGatewayPortForwardingRulesResponse:
        """Returns the port forwarding rules for a single MG.

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

        Args:
            serial: Serial.

        Returns:
            Successful operation.

        Example API response:
            ```json
            {
              "rules": [
                {
                  "name": "test",
                  "lanIp": "172.31.128.5",
                  "publicPort": "11-12",
                  "localPort": "4",
                  "allowedIps": [
                    "10.10.10.10",
                    "10.10.10.11"
                  ],
                  "protocol": "tcp",
                  "access": "any"
                }
              ]
            }
            ```

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

        return self._session.get(
            scope="cellularGateway",
            operation_id="getDeviceCellularGatewayPortForwardingRules",
            path=path,
            response_schema=GetDeviceCellularGatewayPortForwardingRulesResponse,
        )

    def update_device_cellular_gateway_port_forwarding_rules(
        self,
        serial: str,
        *,
        rules: list[UpdateDeviceCellularGatewayPortForwardingRulesRulesItem] | None = None,
    ) -> UpdateDeviceCellularGatewayPortForwardingRulesResponse:
        """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.

        Returns:
            Successful operation.

        Example API response:
            ```json
            {
              "rules": [
                {
                  "name": "test",
                  "lanIp": "172.31.128.5",
                  "publicPort": "11-12",
                  "localPort": "4",
                  "allowedIps": [
                    "10.10.10.10",
                    "10.10.10.11"
                  ],
                  "protocol": "tcp",
                  "access": "any"
                }
              ]
            }
            ```

        """
        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 self._session.put(
            scope="cellularGateway",
            operation_id="updateDeviceCellularGatewayPortForwardingRules",
            path=path,
            json=payload,
            response_schema=UpdateDeviceCellularGatewayPortForwardingRulesResponse,
        )

    def get_network_cellular_gateway_connectivity_monitoring_destinations(
        self, network_id: str
    ) -> GetNetworkCellularGatewayConnectivityMonitoringDestinationsResponse:
        """Return the connectivity testing destinations for an MG network.

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

        Args:
            network_id: Network ID.

        Returns:
            Successful operation.

        Example API response:
            ```json
            {
              "destinations": [
                {
                  "ip": "1.2.3.4",
                  "description": "Google",
                  "default": false
                }
              ]
            }
            ```

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

        return self._session.get(
            scope="cellularGateway",
            operation_id="getNetworkCellularGatewayConnectivityMonitoringDestinations",
            path=path,
            response_schema=GetNetworkCellularGatewayConnectivityMonitoringDestinationsResponse,
        )

    def update_network_cellular_gateway_connectivity_monitoring_destinations(
        self,
        network_id: str,
        *,
        destinations: list[
            UpdateNetworkCellularGatewayConnectivityMonitoringDestinationsDestinationsItem
        ]
        | None = None,
    ) -> UpdateNetworkCellularGatewayConnectivityMonitoringDestinationsResponse:
        """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.

        Returns:
            Successful operation.

        Example API response:
            ```json
            {
              "destinations": [
                {
                  "ip": "1.2.3.4",
                  "description": "Google",
                  "default": false
                }
              ]
            }
            ```

        """
        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 self._session.put(
            scope="cellularGateway",
            operation_id="updateNetworkCellularGatewayConnectivityMonitoringDestinations",
            path=path,
            json=payload,
            response_schema=UpdateNetworkCellularGatewayConnectivityMonitoringDestinationsResponse,
        )

    def get_network_cellular_gateway_dhcp(
        self, network_id: str
    ) -> GetNetworkCellularGatewayDhcpResponse:
        """List common DHCP settings of MGs.

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

        Args:
            network_id: Network ID.

        Returns:
            Successful operation.

        Example API response:
            ```json
            {
              "dhcpLeaseTime": "1 hour",
              "dnsNameservers": "custom",
              "dnsCustomNameservers": [
                "172.16.2.111",
                "172.16.2.30"
              ]
            }
            ```

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

        return self._session.get(
            scope="cellularGateway",
            operation_id="getNetworkCellularGatewayDhcp",
            path=path,
            response_schema=GetNetworkCellularGatewayDhcpResponse,
        )

    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,
    ) -> UpdateNetworkCellularGatewayDhcpResponse:
        """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'.

        Returns:
            Successful operation.

        Example API response:
            ```json
            {
              "dhcpLeaseTime": "1 hour",
              "dnsNameservers": "custom",
              "dnsCustomNameservers": [
                "172.16.2.111",
                "172.16.2.30"
              ]
            }
            ```

        """
        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 self._session.put(
            scope="cellularGateway",
            operation_id="updateNetworkCellularGatewayDhcp",
            path=path,
            json=payload,
            response_schema=UpdateNetworkCellularGatewayDhcpResponse,
        )

    def get_network_cellular_gateway_subnet_pool(
        self, network_id: str
    ) -> GetNetworkCellularGatewaySubnetPoolResponse:
        """Return the subnet pool and mask configured for MGs in the network.

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

        Args:
            network_id: Network ID.

        Returns:
            Successful operation.

        Example API response:
            ```json
            {
              "deploymentMode": "routed",
              "cidr": "192.168.0.0/16",
              "mask": 24,
              "subnets": [
                {
                  "serial": "AAAA-AAAA-AAAA",
                  "name": "my first MG",
                  "applianceIp": "192.168.0.1",
                  "subnet": "192.168.0.0/24"
                }
              ]
            }
            ```

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

        return self._session.get(
            scope="cellularGateway",
            operation_id="getNetworkCellularGatewaySubnetPool",
            path=path,
            response_schema=GetNetworkCellularGatewaySubnetPoolResponse,
        )

    def update_network_cellular_gateway_subnet_pool(
        self, network_id: str, *, mask: int | None = None, cidr: str | None = None
    ) -> UpdateNetworkCellularGatewaySubnetPoolResponse:
        """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.

        Returns:
            Successful operation.

        Example API response:
            ```json
            {
              "deploymentMode": "routed",
              "cidr": "192.168.0.0/16",
              "mask": 24,
              "subnets": [
                {
                  "serial": "AAAA-AAAA-AAAA",
                  "name": "my first MG",
                  "applianceIp": "192.168.0.1",
                  "subnet": "192.168.0.0/24"
                }
              ]
            }
            ```

        """
        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 self._session.put(
            scope="cellularGateway",
            operation_id="updateNetworkCellularGatewaySubnetPool",
            path=path,
            json=payload,
            response_schema=UpdateNetworkCellularGatewaySubnetPoolResponse,
        )

    def get_network_cellular_gateway_uplink(
        self, network_id: str
    ) -> GetNetworkCellularGatewayUplinkResponse:
        """Returns the uplink settings for your MG network.

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

        Args:
            network_id: Network ID.

        Returns:
            Successful operation.

        Example API response:
            ```json
            {
              "bandwidthLimits": {
                "limitUp": 51200,
                "limitDown": 51200
              }
            }
            ```

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

        return self._session.get(
            scope="cellularGateway",
            operation_id="getNetworkCellularGatewayUplink",
            path=path,
            response_schema=GetNetworkCellularGatewayUplinkResponse,
        )

    def update_network_cellular_gateway_uplink(
        self,
        network_id: str,
        *,
        bandwidth_limits: UpdateNetworkCellularGatewayUplinkBandwidthLimits | None = None,
    ) -> UpdateNetworkCellularGatewayUplinkResponse:
        """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.

        Returns:
            Successful operation.

        Example API response:
            ```json
            {
              "bandwidthLimits": {
                "limitUp": 51200,
                "limitDown": 51200
              }
            }
            ```

        """
        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 self._session.put(
            scope="cellularGateway",
            operation_id="updateNetworkCellularGatewayUplink",
            path=path,
            json=payload,
            response_schema=UpdateNetworkCellularGatewayUplinkResponse,
        )

    def get_organization_cellular_gateway_esims_inventory(
        self, organization_id: str, *, eids: list[str] | None = None
    ) -> PaginatedResponse[GetOrganizationCellularGatewayEsimsInventoryResponseItemsItem]:
        """The eSIM inventory of a given organization.

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

        Args:
            organization_id: Organization ID.
            eids: Optional parameter to filter the results by EID.

        Returns:
            Successful operation.

        Note:
            Returns a lazy PaginatedResponse
            that can be iterated or collected with `.collect()`.
            Page metadata is available on `.meta` and `.meta_pages`.

        Example API response:
            ```json
            {
              "items": [
                {
                  "device": {
                    "name": "My cellular gateway",
                    "model": "mg52",
                    "serial": "Q234-ABCD-5678",
                    "url": "https://n1.meraki.com//n//manage/nodes/new_list/000000000000",
                    "status": "online"
                  },
                  "active": true,
                  "eid": "89000000000000000000000000000000",
                  "lastUpdatedAt": "2023-02-01T00:00:00Z",
                  "network": {
                    "id": "N_24329156"
                  },
                  "profiles": [
                    {
                      "customApns": [
                        "internet"
                      ],
                      "iccid": "8900000000000000000",
                      "status": "activated",
                      "serviceProvider": {
                        "name": "ATT",
                        "plans": [
                          {
                            "name": "1 Cisco IoT SDO AT&T eSIM Test Plan downloadable",
                            "type": "communication"
                          }
                        ]
                      }
                    }
                  ]
                }
              ],
              "meta": {
                "counts": {
                  "items": {
                    "total": 1,
                    "remaining": 0
                  }
                }
              }
            }
            ```

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

        params: dict[str, Any] = {}
        if eids is not None:
            params["eids[]"] = eids

        return self._session.get_pages(
            scope="cellularGateway",
            operation_id="getOrganizationCellularGatewayEsimsInventory",
            path=path,
            params=params,
            item_schema=GetOrganizationCellularGatewayEsimsInventoryResponseItemsItem,
        )

    def update_organization_cellular_gateway_esims_inventory(
        self, *, organization_id: str, id: str, status: str | None = None
    ) -> UpdateOrganizationCellularGatewayEsimsInventoryResponse:
        """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.

        Returns:
            Successful operation.

        Example API response:
            ```json
            {
              "device": {
                "name": "My cellular gateway",
                "model": "mg52",
                "serial": "Q234-ABCD-5678",
                "url": "https://n1.meraki.com//n//manage/nodes/new_list/000000000000",
                "status": "online"
              },
              "active": true,
              "eid": "89000000000000000000000000000000",
              "lastUpdatedAt": "2023-02-01T00:00:00Z",
              "network": {
                "id": "N_24329156"
              },
              "profiles": [
                {
                  "customApns": [
                    "internet"
                  ],
                  "iccid": "8900000000000000000",
                  "status": "activated",
                  "serviceProvider": {
                    "name": "ATT",
                    "plans": [
                      {
                        "name": "1 Cisco IoT SDO AT&T eSIM Test Plan downloadable",
                        "type": "communication"
                      }
                    ]
                  }
                }
              ]
            }
            ```

        """
        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 self._session.put(
            scope="cellularGateway",
            operation_id="updateOrganizationCellularGatewayEsimsInventory",
            path=path,
            json=payload,
            response_schema=UpdateOrganizationCellularGatewayEsimsInventoryResponse,
        )

    def get_organization_cellular_gateway_esims_service_providers(
        self, organization_id: str
    ) -> PaginatedResponse[GetOrganizationCellularGatewayEsimsServiceProvidersResponseItemsItem]:
        """Service providers customers can add accounts for.

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

        Args:
            organization_id: Organization ID.

        Returns:
            Successful operation.

        Note:
            Returns a lazy PaginatedResponse
            that can be iterated or collected with `.collect()`.
            Page metadata is available on `.meta` and `.meta_pages`.

        Example API response:
            ```json
            {
              "items": [
                {
                  "name": "AT&T",
                  "logo": {
                    "url": "Logo URL"
                  },
                  "isBootstrap": false,
                  "terms": {
                    "content": "Legal jargon",
                    "name": "AT&T Terms and Conditions"
                  }
                }
              ],
              "meta": {
                "counts": {
                  "items": {
                    "total": 42,
                    "remaining": 0
                  }
                }
              }
            }
            ```

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

        return self._session.get_pages(
            scope="cellularGateway",
            operation_id="getOrganizationCellularGatewayEsimsServiceProviders",
            path=path,
            item_schema=GetOrganizationCellularGatewayEsimsServiceProvidersResponseItemsItem,
        )

    def get_organization_cellular_gateway_esims_service_providers_accounts(
        self, organization_id: str, *, account_ids: list[int] | None = None
    ) -> PaginatedResponse[GetOrganizationCellularGatewayEsimsServiceProvidersAccountsResponseItem]:
        """Inventory of service provider accounts tied to the organization.

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

        Args:
            organization_id: Organization ID.
            account_ids: Optional parameter to filter the results by service provider account IDs.

        Returns:
            Successful operation.

        Note:
            Returns a lazy PaginatedResponse
            that can be iterated or collected with `.collect()`.
            Page metadata is available on `.meta` and `.meta_pages`.

        Example API response:
            ```json
            [
              {
                "items": [
                  {
                    "accountId": "0987654321",
                    "lastUpdatedAt": "2023-08-21T00:00:00Z",
                    "serviceProvider": {
                      "name": "ATT",
                      "logo": {
                        "url": "serviceproviderlogo.url"
                      }
                    },
                    "title": "My AT&T account",
                    "username": "MerakiUser"
                  }
                ],
                "meta": {
                  "counts": {
                    "items": {
                      "total": 1,
                      "remaining": 0
                    }
                  }
                }
              }
            ]
            ```

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

        params: dict[str, Any] = {}
        if account_ids is not None:
            params["accountIds[]"] = account_ids

        return self._session.get_pages(
            scope="cellularGateway",
            operation_id="getOrganizationCellularGatewayEsimsServiceProvidersAccounts",
            path=path,
            params=params,
            item_schema=GetOrganizationCellularGatewayEsimsServiceProvidersAccountsResponseItem,
        )

    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,
    ) -> CreateOrganizationCellularGatewayEsimsServiceProvidersAccountResponse:
        """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.

        Returns:
            Successful operation.

        Example API response:
            ```json
            {
              "accountId": "0987654321",
              "lastUpdatedAt": "2023-08-21T00:00:00Z",
              "serviceProvider": {
                "name": "ATT",
                "logo": {
                  "url": "serviceproviderlogo.url"
                }
              },
              "title": "My AT&T account",
              "username": "MerakiUser"
            }
            ```

        """
        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 self._session.post(
            scope="cellularGateway",
            operation_id="createOrganizationCellularGatewayEsimsServiceProvidersAccount",
            path=path,
            json=payload,
            response_schema=CreateOrganizationCellularGatewayEsimsServiceProvidersAccountResponse,
        )

    def get_organization_cellular_gateway_esims_service_providers_accounts_communication_plans(
        self, *, organization_id: str, account_ids: list[str]
    ) -> PaginatedResponse[
        GetOrganizationCellularGatewayEsimsServiceProvidersAccountsCommunicationPlansResponseItemsItem
    ]:
        """The communication plans available for a given provider.

        [API documentation: getOrganizationCellularGatewayEsimsServiceProvidersAccountsCommunicationPlans](https://developer.cisco.com/meraki/api-v1/#!get-organization-cellular-gateway-esims-service-providers-accounts-communication-plans)

        Args:
            organization_id: Organization ID.
            account_ids: Account IDs that communication plans will be fetched for.

        Returns:
            Successful operation.

        Note:
            Returns a lazy PaginatedResponse
            that can be iterated or collected with `.collect()`.
            Page metadata is available on `.meta` and `.meta_pages`.

        Example API response:
            ```json
            {
              "items": [
                {
                  "accountId": "some account ID",
                  "apns": [
                    {
                      "name": "Some APN"
                    }
                  ],
                  "name": "A communication plan"
                }
              ],
              "meta": {
                "counts": {
                  "items": {
                    "total": 2,
                    "remaining": 0
                  }
                }
              }
            }
            ```

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

        params: dict[str, Any] = {}
        if account_ids is not None:
            params["accountIds[]"] = account_ids

        return self._session.get_pages(
            scope="cellularGateway",
            operation_id="getOrganizationCellularGatewayEsimsServiceProvidersAccountsCommunicationPlans",
            path=path,
            params=params,
            item_schema=GetOrganizationCellularGatewayEsimsServiceProvidersAccountsCommunicationPlansResponseItemsItem,
        )

    def get_organization_cellular_gateway_esims_service_providers_accounts_rate_plans(
        self, *, organization_id: str, account_ids: list[str]
    ) -> PaginatedResponse[
        GetOrganizationCellularGatewayEsimsServiceProvidersAccountsRatePlansResponseItemsItem
    ]:
        """The rate plans available for a given provider.

        [API documentation: getOrganizationCellularGatewayEsimsServiceProvidersAccountsRatePlans](https://developer.cisco.com/meraki/api-v1/#!get-organization-cellular-gateway-esims-service-providers-accounts-rate-plans)

        Args:
            organization_id: Organization ID.
            account_ids: Account IDs that rate plans will be fetched for.

        Returns:
            Successful operation.

        Note:
            Returns a lazy PaginatedResponse
            that can be iterated or collected with `.collect()`.
            Page metadata is available on `.meta` and `.meta_pages`.

        Example API response:
            ```json
            {
              "items": [
                {
                  "accountId": "account ID",
                  "name": "A rate plan"
                }
              ],
              "meta": {
                "counts": {
                  "items": {
                    "total": 2,
                    "remaining": 0
                  }
                }
              }
            }
            ```

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

        params: dict[str, Any] = {}
        if account_ids is not None:
            params["accountIds[]"] = account_ids

        return self._session.get_pages(
            scope="cellularGateway",
            operation_id="getOrganizationCellularGatewayEsimsServiceProvidersAccountsRatePlans",
            path=path,
            params=params,
            item_schema=GetOrganizationCellularGatewayEsimsServiceProvidersAccountsRatePlansResponseItemsItem,
        )

    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,
    ) -> UpdateOrganizationCellularGatewayEsimsServiceProvidersAccountResponse:
        """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.

        Returns:
            Successful operation.

        Example API response:
            ```json
            {
              "accountId": "0987654321",
              "lastUpdatedAt": "2023-08-21T00:00:00Z",
              "serviceProvider": {
                "name": "ATT",
                "logo": {
                  "url": "serviceproviderlogo.url"
                }
              },
              "title": "My AT&T account",
              "username": "MerakiUser"
            }
            ```

        """
        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 self._session.put(
            scope="cellularGateway",
            operation_id="updateOrganizationCellularGatewayEsimsServiceProvidersAccount",
            path=path,
            json=payload,
            response_schema=UpdateOrganizationCellularGatewayEsimsServiceProvidersAccountResponse,
        )

    def delete_organization_cellular_gateway_esims_service_providers_account(
        self, *, organization_id: str, account_id: str
    ) -> None:
        """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.

        Returns:
            Successful operation.

        """
        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 self._session.delete(
            scope="cellularGateway",
            operation_id="deleteOrganizationCellularGatewayEsimsServiceProvidersAccount",
            path=path,
        )

    def create_organization_cellular_gateway_esims_swap(
        self,
        *,
        organization_id: str,
        swaps: list[CreateOrganizationCellularGatewayEsimsSwapSwapsItem],
    ) -> CreateOrganizationCellularGatewayEsimsSwapResponse:
        """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.

        Returns:
            Successful operation.

        Example API response:
            ```json
            {
              "eid": "1234567890",
              "iccid": "9876543210",
              "status": "Completed"
            }
            ```

        """
        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 self._session.post(
            scope="cellularGateway",
            operation_id="createOrganizationCellularGatewayEsimsSwap",
            path=path,
            json=payload,
            response_schema=CreateOrganizationCellularGatewayEsimsSwapResponse,
        )

    def update_organization_cellular_gateway_esims_swap(
        self, *, id: str, organization_id: str
    ) -> UpdateOrganizationCellularGatewayEsimsSwapResponse:
        """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.

        Returns:
            Successful operation.

        Example API response:
            ```json
            {
              "eid": "1234567890",
              "iccid": "9876543210",
              "status": "Completed"
            }
            ```

        """
        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 self._session.put(
            scope="cellularGateway",
            operation_id="updateOrganizationCellularGatewayEsimsSwap",
            path=path,
            response_schema=UpdateOrganizationCellularGatewayEsimsSwapResponse,
        )

    def get_organization_cellular_gateway_uplink_statuses(
        self,
        organization_id: str,
        *,
        per_page: int | None = None,
        starting_after: str | None = None,
        ending_before: str | None = None,
        network_ids: list[str] | None = None,
        serials: list[str] | None = None,
        iccids: list[str] | None = None,
        total_pages: int | Literal["all"] = "all",
        direction: Literal["prev", "next"] = "next",
    ) -> PaginatedResponse[GetOrganizationCellularGatewayUplinkStatusesResponseItem]:
        """List the uplink status of every Meraki MG cellular gateway in the organization.

        [API documentation: getOrganizationCellularGatewayUplinkStatuses](https://developer.cisco.com/meraki/api-v1/#!get-organization-cellular-gateway-uplink-statuses)

        Args:
            organization_id: Organization ID.
            per_page: The number of entries per page returned. Acceptable range is 3 - 1000. Default
                is 1000.
            starting_after: A token used by the server to indicate the start of the page. Often this
                is a timestamp or an ID but it is not limited to those. This parameter
                should not be defined by client applications. The link for the first,
                last, prev, or next page in the HTTP Link header should define it.
            ending_before: A token used by the server to indicate the end of the page. Often this is
                a timestamp or an ID but it is not limited to those. This parameter
                should not be defined by client applications. The link for the first,
                last, prev, or next page in the HTTP Link header should define it.
            network_ids: A list of network IDs. The returned devices will be filtered to only
                include these networks.
            serials: A list of serial numbers. The returned devices will be filtered to only include
                these serials.
            iccids: A list of ICCIDs. The returned devices will be filtered to only include these
                ICCIDs.
            total_pages: use with per_page to get total results up to total_pages * per_page; -1 or
                "all" for all pages.
            direction: direction to paginate, either "next" (default) or "prev" page.

        Returns:
            Successful operation.

        Note:
            Returns a lazy PaginatedResponse
            that can be iterated or collected with `.collect()`.
            Page metadata is available on `.meta` and `.meta_pages`.

        Example API response:
            ```json
            [
              {
                "networkId": "N_24329156",
                "serial": "Q234-ABCD-5678",
                "model": "MG21",
                "lastReportedAt": "2018-02-11T00:00:00Z",
                "uplinks": [
                  {
                    "interface": "cellular",
                    "status": "ready",
                    "ip": "1.2.3.4",
                    "provider": "at&t",
                    "publicIp": "123.123.123.1",
                    "model": "integrated",
                    "signalStat": {
                      "rsrp": "-120",
                      "rsrq": "-13"
                    },
                    "mcc": "123",
                    "mnc": "123",
                    "roaming": {
                      "status": "home"
                    },
                    "connectionType": "4g",
                    "apn": "internet",
                    "gateway": "100.100.100.100",
                    "dns1": "111.111.111.111",
                    "dns2": "222.222.222.222",
                    "signalType": "4G",
                    "mtu": 1500,
                    "iccid": "123456789",
                    "imsi": "123456789012345",
                    "msisdn": "123456789012345"
                  }
                ]
              }
            ]
            ```

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

        params: dict[str, Any] = {}
        if per_page is not None:
            params["perPage"] = per_page
        if starting_after is not None:
            params["startingAfter"] = starting_after
        if ending_before is not None:
            params["endingBefore"] = ending_before
        if network_ids is not None:
            params["networkIds[]"] = network_ids
        if serials is not None:
            params["serials[]"] = serials
        if iccids is not None:
            params["iccids[]"] = iccids

        return self._session.get_pages(
            scope="cellularGateway",
            operation_id="getOrganizationCellularGatewayUplinkStatuses",
            path=path,
            params=params,
            total_pages=total_pages,
            direction=direction,
            item_schema=GetOrganizationCellularGatewayUplinkStatusesResponseItem,
        )
