File: dpi_restriction_apps.py

package info (click to toggle)
python-aiounifi 79-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 660 kB
  • sloc: python: 11,124; sh: 5; makefile: 5
file content (32 lines) | stat: -rw-r--r-- 1,135 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""DPI Restrictions as part of a UniFi network."""

from ..models.api import TypedApiResponse
from ..models.dpi_restriction_app import (
    DPIRestrictionApp,
    DPIRestrictionAppEnableRequest,
    DpiRestrictionAppListRequest,
)
from ..models.message import MessageKey
from .api_handlers import APIHandler


class DPIRestrictionApps(APIHandler[DPIRestrictionApp]):
    """Represents DPI App configurations."""

    obj_id_key = "_id"
    item_cls = DPIRestrictionApp
    process_messages = (MessageKey.DPI_APP_ADDED, MessageKey.DPI_APP_UPDATED)
    remove_messages = (MessageKey.DPI_APP_REMOVED,)
    api_request = DpiRestrictionAppListRequest.create()

    async def enable(self, app_id: str) -> TypedApiResponse:
        """Enable DPI Restriction Group Apps."""
        return await self.controller.request(
            DPIRestrictionAppEnableRequest.create(app_id, enable=True)
        )

    async def disable(self, app_id: str) -> TypedApiResponse:
        """Disable DPI Restriction Group Apps."""
        return await self.controller.request(
            DPIRestrictionAppEnableRequest.create(app_id, enable=False)
        )