id
int64
0
843k
repository_name
stringlengths
7
55
file_path
stringlengths
9
332
class_name
stringlengths
3
290
human_written_code
stringlengths
12
4.36M
class_skeleton
stringlengths
19
2.2M
total_program_units
int64
1
9.57k
total_doc_str
int64
0
4.2k
AvgCountLine
float64
0
7.89k
AvgCountLineBlank
float64
0
300
AvgCountLineCode
float64
0
7.89k
AvgCountLineComment
float64
0
7.89k
AvgCyclomatic
float64
0
130
CommentToCodeRatio
float64
0
176
CountClassBase
float64
0
48
CountClassCoupled
float64
0
589
CountClassCoupledModified
float64
0
581
CountClassDerived
float64
0
5.37k
CountDeclInstanceMethod
float64
0
4.2k
CountDeclInstanceVariable
float64
0
299
CountDeclMethod
float64
0
4.2k
CountDeclMethodAll
float64
0
4.2k
CountLine
float64
1
115k
CountLineBlank
float64
0
9.01k
CountLineCode
float64
0
94.4k
CountLineCodeDecl
float64
0
46.1k
CountLineCodeExe
float64
0
91.3k
CountLineComment
float64
0
27k
CountStmt
float64
1
93.2k
CountStmtDecl
float64
0
46.1k
CountStmtExe
float64
0
90.2k
MaxCyclomatic
float64
0
759
MaxInheritanceTree
float64
0
16
MaxNesting
float64
0
34
SumCyclomatic
float64
0
6k
141,148
Kane610/aiounifi
aiounifi/models/api.py
aiounifi.models.api.TypedApiResponse
class TypedApiResponse(TypedDict, total=False): """Common response.""" meta: dict[str, Any] data: list[dict[str, Any]]
class TypedApiResponse(TypedDict, total=False): '''Common response.''' pass
1
1
0
0
0
0
0
0.33
2
0
0
0
0
0
0
0
5
1
3
1
2
1
3
1
2
0
1
0
0
141,149
Kane610/aiounifi
aiounifi/models/client.py
aiounifi.models.client.ClientReconnectRequest
class ClientReconnectRequest(ApiRequest): """Request object for client reconnect.""" @classmethod def create(cls, mac: str) -> Self: """Create client reconnect request.""" return cls( method="post", path="/cmd/stamgr", data={ "cmd": "kick-sta", "mac": mac, }, )
class ClientReconnectRequest(ApiRequest): '''Request object for client reconnect.''' @classmethod def create(cls, mac: str) -> Self: '''Create client reconnect request.''' pass
3
2
10
0
9
1
1
0.18
1
1
0
0
0
0
1
3
14
1
11
3
8
2
3
2
1
1
1
0
1
141,150
Kane610/aiounifi
aiounifi/models/device.py
aiounifi.models.device.DeviceRestartRequest
class DeviceRestartRequest(ApiRequest): """Request object for device restart.""" @classmethod def create(cls, mac: str, soft: bool = True) -> Self: """Create device restart request. Hard is specifically for PoE switches and will additionally cycle PoE ports. """ return cls( method="post", path="/cmd/devmgr", data={ "cmd": "restart", "mac": mac, "reboot_type": "soft" if soft else "hard", }, )
class DeviceRestartRequest(ApiRequest): '''Request object for device restart.''' @classmethod def create(cls, mac: str, soft: bool = True) -> Self: '''Create device restart request. Hard is specifically for PoE switches and will additionally cycle PoE ports. ''' pass
3
2
14
1
10
3
2
0.33
1
2
0
0
0
0
1
3
18
2
12
3
9
4
3
2
1
2
1
0
2
141,151
Kane610/aiounifi
aiounifi/models/device.py
aiounifi.models.device.DeviceSetOutletRelayRequest
class DeviceSetOutletRelayRequest(ApiRequest): """Request object for outlet relay state.""" @classmethod def create(cls, device: Device, outlet_idx: int, state: bool) -> Self: """Create device outlet relay state request. True: outlet power output on. False: outlet power output off. """ existing_override = False for outlet_override in device.outlet_overrides: if outlet_idx == outlet_override["index"]: outlet_override["relay_state"] = state existing_override = True break if not existing_override: name = device.outlet_table[outlet_idx - 1].get("name", "") device.outlet_overrides.append( { "index": outlet_idx, "name": name, "relay_state": state, } ) return cls( method="put", path=f"/rest/device/{device.id}", data={"outlet_overrides": device.outlet_overrides}, )
class DeviceSetOutletRelayRequest(ApiRequest): '''Request object for outlet relay state.''' @classmethod def create(cls, device: Device, outlet_idx: int, state: bool) -> Self: '''Create device outlet relay state request. True: outlet power output on. False: outlet power output off. ''' pass
3
2
28
3
21
4
4
0.22
1
3
1
0
0
0
1
3
32
4
23
6
20
5
12
5
10
4
1
2
4
141,152
Kane610/aiounifi
aiounifi/models/device.py
aiounifi.models.device.DeviceSetOutletCycleEnabledRequest
class DeviceSetOutletCycleEnabledRequest(ApiRequest): """Request object for outlet cycle_enabled flag.""" @classmethod def create(cls, device: Device, outlet_idx: int, state: bool) -> Self: """Create device outlet outlet cycle_enabled flag request. True: UniFi Network will power cycle this outlet if the internet goes down. False: UniFi Network will not power cycle this outlet if the internet goes down. """ existing_override = False for outlet_override in device.outlet_overrides: if outlet_idx == outlet_override["index"]: outlet_override["cycle_enabled"] = state existing_override = True break if not existing_override: name = device.outlet_table[outlet_idx - 1].get("name", "") device.outlet_overrides.append( { "index": outlet_idx, "name": name, "cycle_enabled": state, } ) return cls( method="put", path=f"/rest/device/{device.id}", data={"outlet_overrides": device.outlet_overrides}, )
class DeviceSetOutletCycleEnabledRequest(ApiRequest): '''Request object for outlet cycle_enabled flag.''' @classmethod def create(cls, device: Device, outlet_idx: int, state: bool) -> Self: '''Create device outlet outlet cycle_enabled flag request. True: UniFi Network will power cycle this outlet if the internet goes down. False: UniFi Network will not power cycle this outlet if the internet goes down. ''' pass
3
2
28
3
21
4
4
0.22
1
3
1
0
0
0
1
3
32
4
23
6
20
5
12
5
10
4
1
2
4
141,153
Kane610/aiounifi
aiounifi/models/api.py
aiounifi.models.api.ApiRequestV2
class ApiRequestV2(ApiRequest): """Data class with required properties of a V2 API request.""" def full_path(self, site: str, is_unifi_os: bool) -> str: """Create url to work with a specific controller.""" if is_unifi_os: return f"/proxy/network/v2/api/site/{site}{self.path}" return f"/v2/api/site/{site}{self.path}" def decode(self, raw: bytes) -> TypedApiResponse: """Put data, received from the unifi controller, into a TypedApiResponse.""" data = orjson.loads(raw) if "errorCode" in data: raise ERRORS.get(data["message"], AiounifiException)(data) return TypedApiResponse( meta={"rc": "ok", "msg": ""}, data=data if isinstance(data, list) else [data], )
class ApiRequestV2(ApiRequest): '''Data class with required properties of a V2 API request.''' def full_path(self, site: str, is_unifi_os: bool) -> str: '''Create url to work with a specific controller.''' pass def decode(self, raw: bytes) -> TypedApiResponse: '''Put data, received from the unifi controller, into a TypedApiResponse.''' pass
3
3
8
1
6
1
3
0.23
1
6
2
8
2
0
2
4
20
4
13
4
10
3
10
4
7
3
1
1
5
141,154
Kane610/aiounifi
aiounifi/models/device.py
aiounifi.models.device.DeviceSetPoePortModeRequest
class DeviceSetPoePortModeRequest(ApiRequest): """Request object for setting port PoE mode.""" @classmethod def create( cls, device: Device, port_idx: int | None = None, mode: str | None = None, targets: list[tuple[int, str]] | None = None, ) -> Self: """Create device set port PoE mode request. Auto, 24v, passthrough, off. Make sure to not overwrite any existing configs. """ overrides: list[tuple[int, str]] = [] if port_idx is not None and mode is not None: overrides.append((port_idx, mode)) elif targets is not None: overrides = targets else: raise AttributeError port_overrides = deepcopy(device.port_overrides) for override in overrides: port_idx, mode = override existing_override = False for port_override in port_overrides: if port_idx == port_override.get("port_idx"): port_override["poe_mode"] = mode existing_override = True break if existing_override: continue port_override = {"port_idx": port_idx, "poe_mode": mode} if portconf_id := device.port_table[port_idx - 1].get("portconf_id"): port_override["portconf_id"] = portconf_id port_overrides.append(port_override) return cls( method="put", path=f"/rest/device/{device.id}", data={"port_overrides": port_overrides}, )
class DeviceSetPoePortModeRequest(ApiRequest): '''Request object for setting port PoE mode.''' @classmethod def create( cls, device: Device, port_idx: int | None = None, mode: str | None = None, targets: list[tuple[int, str]] | None = None, ) -> Self: '''Create device set port PoE mode request. Auto, 24v, passthrough, off. Make sure to not overwrite any existing configs. ''' pass
3
2
45
7
34
4
8
0.14
1
6
1
0
0
0
1
3
49
8
36
15
27
5
23
7
21
8
1
3
8
141,155
Kane610/aiounifi
aiounifi/models/device.py
aiounifi.models.device.DeviceState
class DeviceState(enum.IntEnum): """Enum for device states.""" DISCONNECTED = 0 CONNECTED = 1 PENDING = 2 FIRMWARE_MISMATCH = 3 UPGRADING = 4 PROVISIONING = 5 HEARTBEAT_MISSED = 6 ADOPTING = 7 DELETING = 8 INFORM_ERROR = 9 ADOPTION_FALIED = 10 ISOLATED = 11 UNKNOWN = -1 @classmethod def _missing_(cls, value: object) -> DeviceState: """Set default enum member if an unknown value is provided.""" LOGGER.warning("Unsupported device state %s %s", value, cls) return DeviceState.UNKNOWN
class DeviceState(enum.IntEnum): '''Enum for device states.''' @classmethod def _missing_(cls, value: object) -> DeviceState: '''Set default enum member if an unknown value is provided.''' pass
3
2
4
0
3
1
1
0.11
1
0
0
0
0
0
1
56
23
3
18
16
15
2
17
15
15
1
3
0
1
141,156
Kane610/aiounifi
aiounifi/models/device.py
aiounifi.models.device.DeviceUpgradeRequest
class DeviceUpgradeRequest(ApiRequest): """Request object for device upgrade.""" @classmethod def create(cls, mac: str) -> Self: """Create device upgrade request.""" return cls( method="post", path="/cmd/devmgr", data={ "cmd": "upgrade", "mac": mac, }, )
class DeviceUpgradeRequest(ApiRequest): '''Request object for device upgrade.''' @classmethod def create(cls, mac: str) -> Self: '''Create device upgrade request.''' pass
3
2
10
0
9
1
1
0.18
1
1
0
0
0
0
1
3
14
1
11
3
8
2
3
2
1
1
1
0
1
141,157
Kane610/aiounifi
aiounifi/models/device.py
aiounifi.models.device.HardwareCapability
class HardwareCapability(enum.IntFlag): """Enumeration representing hardware capabilities.""" LED_RING = 2
class HardwareCapability(enum.IntFlag): '''Enumeration representing hardware capabilities.''' pass
1
1
0
0
0
0
0
0.5
1
0
0
0
0
0
0
55
4
1
2
2
1
1
2
2
1
0
3
0
0
141,158
Kane610/aiounifi
aiounifi/models/device.py
aiounifi.models.device.TypedDevice
class TypedDevice(TypedDict): """Device type definition.""" _id: str _uptime: int adoptable_when_upgraded: bool adopted: bool antenna_table: list[TypedDeviceAntennaTable] architecture: str adoption_completed: int board_rev: NotRequired[int] bytes: int bytes_d: int bytes_r: int cfgversion: int config_network: TypedDeviceConfigNetwork connect_request_ip: str connect_request_port: str considered_lost_at: int country_code: int countrycode_table: list # type: ignore[type-arg] device_id: str dhcp_server_table: list # type: ignore[type-arg] disabled: NotRequired[bool] disconnection_reason: str displayable_version: str dot1x_portctrl_enabled: bool downlink_table: list # type: ignore[type-arg] element_ap_serial: str element_peer_mac: str element_uplink_ap_mac: str ethernet_overrides: list[TypedDeviceEthernetOverrides] ethernet_table: list[TypedDeviceEthernetTable] fan_level: int flowctrl_enabled: bool fw_caps: int gateway_mac: str general_temperature: NotRequired[int] guest_num_sta: int guest_wlan_num_sta: int guest_token: str has_eth1: bool has_fan: bool has_speaker: bool has_temperature: bool hash_id: str hide_ch_width: str hw_caps: int inform_ip: str inform_url: str internet: bool ip: NotRequired[str] isolated: bool jumboframe_enabled: bool kernel_version: str known_cfgversion: str last_seen: int last_uplink: TypedDeviceLastUplink lcm_brightness: int lcm_brightness_override: bool lcm_idle_timeout_override: bool lcm_night_mode_begins: str lcm_night_mode_enabled: bool lcm_night_mode_ends: str lcm_tracker_enabled: bool led_override: str led_override_color: str led_override_color_brightness: int license_state: str lldp_table: list[TypedDeviceLldpTable] locating: bool mac: str manufacturer_id: int meshv3_peer_mac: str model: str model_in_eol: bool model_in_lts: bool model_incompatible: bool name: str network_table: list[TypedDeviceNetworkTable] next_heartbeat_at: int next_interval: int num_desktop: int num_handheld: int num_mobile: int num_sta: int outdoor_mode_override: str outlet_ac_power_budget: str outlet_ac_power_consumption: str outlet_enabled: bool outlet_overrides: list[TypedDeviceOutletOverrides] outlet_table: list[TypedDeviceOutletTable] overheating: bool power_source_ctrl_enabled: bool prev_non_busy_state: int provisioned_at: int port_overrides: list[TypedDevicePortOverrides] port_table: NotRequired[list[TypedDevicePortTable]] radio_table: list[TypedDeviceRadioTable] radio_table_stats: list[TypedDeviceRadioTableStats] required_version: str rollupgrade: bool rx_bytes: int rx_bytes_d: int satisfaction: int scan_radio_table: list # type: ignore[type-arg] scanning: bool serial: str site_id: str spectrum_scanning: bool speedtest_status: TypedDeviceSpeedtestStatus | None ssh_session_table: list # type: ignore[type-arg] start_connected_millis: int start_disconnected_millis: int stat: dict # type: ignore[type-arg] state: int storage: list[TypedDeviceStorage] | None stp_priority: str stp_version: str switch_caps: TypedDeviceSwitchCaps sys_error_caps: int sys_stats: TypedDeviceSysStats syslog_key: str system_stats: TypedDeviceSystemStats temperatures: list[TypedDeviceTemperature] | None two_phase_adopt: bool tx_bytes: int tx_bytes_d: int type: str unsupported: bool unsupported_reason: int upgradable: bool upgrade_state: int upgrade_to_firmware: str uplink: TypedDeviceUplink uplink_depth: int uplink_table: list # type: ignore[type-arg] uptime: int uptime_stats: TypedDeviceUptimeStats | None user_num_sta: int user_wlan_num_sta: int usg_caps: int vap_table: list[dict] # type: ignore[type-arg] version: str vwireEnabled: bool vwire_table: list # type: ignore[type-arg] vwire_vap_table: list # type: ignore[type-arg] wifi_caps: int wlan_overrides: list[TypedDeviceWlanOverrides] wlangroup_id_na: str wlangroup_id_ng: str x_aes_gcm: bool x_authkey: str x_fingerprint: str x_has_ssh_hostkey: bool x_inform_authkey: str x_ssh_hostkey_fingerprint: str x_vwirekey: str
class TypedDevice(TypedDict): '''Device type definition.'''
1
1
0
0
0
0
0
0.07
1
0
0
0
0
0
0
0
158
1
156
1
155
11
156
1
155
0
1
0
0
141,159
Kane610/aiounifi
aiounifi/models/device.py
aiounifi.models.device.TypedDeviceAntennaTable
class TypedDeviceAntennaTable(TypedDict): """Device antenna table type definition.""" default: bool id: int name: str wifi0_gain: int wifi1_gain: int
class TypedDeviceAntennaTable(TypedDict): '''Device antenna table type definition.'''
1
1
0
0
0
0
0
0.17
1
0
0
0
0
0
0
0
8
1
6
1
5
1
6
1
5
0
1
0
0
141,160
Kane610/aiounifi
aiounifi/models/device.py
aiounifi.models.device.TypedDeviceConfigNetwork
class TypedDeviceConfigNetwork(TypedDict): """Device config network type definition.""" ip: str type: str
class TypedDeviceConfigNetwork(TypedDict): '''Device config network type definition.'''
1
1
0
0
0
0
0
0.33
1
0
0
0
0
0
0
0
5
1
3
1
2
1
3
1
2
0
1
0
0
141,161
Kane610/aiounifi
aiounifi/models/device.py
aiounifi.models.device.TypedDeviceEthernetOverrides
class TypedDeviceEthernetOverrides(TypedDict): """Device ethernet overrides type definition.""" ifname: str networkgroup: str
class TypedDeviceEthernetOverrides(TypedDict): '''Device ethernet overrides type definition.'''
1
1
0
0
0
0
0
0.33
1
0
0
0
0
0
0
0
5
1
3
1
2
1
3
1
2
0
1
0
0
141,162
Kane610/aiounifi
aiounifi/models/device.py
aiounifi.models.device.TypedDeviceEthernetTable
class TypedDeviceEthernetTable(TypedDict): """Device ethernet table type definition.""" mac: str name: str num_port: int
class TypedDeviceEthernetTable(TypedDict): '''Device ethernet table type definition.'''
1
1
0
0
0
0
0
0.25
1
0
0
0
0
0
0
0
6
1
4
1
3
1
4
1
3
0
1
0
0
141,163
Kane610/aiounifi
aiounifi/models/device.py
aiounifi.models.device.TypedDeviceLastUplink
class TypedDeviceLastUplink(TypedDict): """Device last uplink type definition.""" port_idx: int type: str uplink_mac: str uplink_device_name: str uplink_remote_port: int
class TypedDeviceLastUplink(TypedDict): '''Device last uplink type definition.'''
1
1
0
0
0
0
0
0.17
1
0
0
0
0
0
0
0
8
1
6
1
5
1
6
1
5
0
1
0
0
141,164
Kane610/aiounifi
aiounifi/models/device.py
aiounifi.models.device.TypedDeviceLldpTable
class TypedDeviceLldpTable(TypedDict): """Device LLDP table type definition.""" chassis_id: str chassis_id_subtype: str is_wired: bool local_port_idx: int local_port_name: str port_id: str
class TypedDeviceLldpTable(TypedDict): '''Device LLDP table type definition.'''
1
1
0
0
0
0
0
0.14
1
0
0
0
0
0
0
0
9
1
7
1
6
1
7
1
6
0
1
0
0
141,165
Kane610/aiounifi
aiounifi/models/device.py
aiounifi.models.device.TypedDeviceNetworkTable
class TypedDeviceNetworkTable(TypedDict): """Device network table type definition.""" _id: str attr_hidden_id: str attr_no_delete: bool dhcp_relay_enabled: bool dhcpd_dns_1: str dhcpd_dns_enabled: bool dhcpd_enabled: bool dhcpd_gateway_enabled: bool dhcpd_leasetime: int dhcpd_start: str dhcpd_stop: str dhcpd_time_offset_enabled: bool dhcpd_unifi_controller: str domain_name: str enabled: bool ip: str ip_subnet: str is_guest: bool is_nat: bool lte_lan_enabled: bool mac: str name: str networkgroup: str num_sta: int purpose: str rx_bytes: int rx_packets: int site_id: str tx_bytes: int tx_packets: int up: str vlan_enabled: bool
class TypedDeviceNetworkTable(TypedDict): '''Device network table type definition.'''
1
1
0
0
0
0
0
0.03
1
0
0
0
0
0
0
0
35
1
33
1
32
1
33
1
32
0
1
0
0
141,166
Kane610/aiounifi
aiounifi/models/device.py
aiounifi.models.device.DeviceSetLedStatus
class DeviceSetLedStatus(ApiRequest): """Request object for setting LED status of device.""" @classmethod def create( cls, device: Device, status: str = "on", brightness: int | None = None, color: str | None = None, ) -> Self: """Set LED status of device.""" data: dict[str, int | str] = {"led_override": status} if device.supports_led_ring: # Validate brightness parameter if brightness is not None: if not (0 <= brightness <= 100): raise AttributeError( "Brightness must be within the range [0, 100]." ) data["led_override_color_brightness"] = brightness # Validate color parameter if color is not None: if not re.match(r"^#(?:[0-9a-fA-F]{3}){1,2}$", color): raise AttributeError( "Color must be a valid hex color code (e.g., '#00FF00')." ) data["led_override_color"] = color return cls( method="put", path=f"/rest/device/{device.id}", data=data, )
class DeviceSetLedStatus(ApiRequest): '''Request object for setting LED status of device.''' @classmethod def create( cls, device: Device, status: str = "on", brightness: int | None = None, color: str | None = None, ) -> Self: '''Set LED status of device.''' pass
3
2
32
3
26
5
6
0.21
1
5
1
0
0
0
1
3
36
4
28
10
19
6
13
3
11
6
1
3
6
141,167
Kane610/aiounifi
aiounifi/models/api.py
aiounifi.models.api.ApiRequest
class ApiRequest: """Data class with required properties of a request.""" method: str path: str data: Mapping[str, Any] | None = None def full_path(self, site: str, is_unifi_os: bool) -> str: """Create url to work with a specific controller.""" if is_unifi_os: return f"/proxy/network/api/s/{site}{self.path}" return f"/api/s/{site}{self.path}" def decode(self, raw: bytes) -> TypedApiResponse: """Put data, received from the unifi controller, into a TypedApiResponse.""" data: TypedApiResponse = orjson.loads(raw) if "meta" in data and data["meta"]["rc"] == "error": raise ERRORS.get(data["meta"]["msg"], AiounifiException)(data) return data
class ApiRequest: '''Data class with required properties of a request.''' def full_path(self, site: str, is_unifi_os: bool) -> str: '''Create url to work with a specific controller.''' pass def decode(self, raw: bytes) -> TypedApiResponse: '''Put data, received from the unifi controller, into a TypedApiResponse.''' pass
3
3
7
1
5
1
2
0.23
0
5
2
27
2
0
2
2
21
5
13
5
10
3
13
5
10
2
0
1
4
141,168
Kane610/aiounifi
aiounifi/interfaces/traffic_rules.py
aiounifi.interfaces.traffic_rules.TrafficRules
class TrafficRules(APIHandler[TrafficRule]): """Represents TrafficRules configurations.""" obj_id_key = "_id" item_cls = TrafficRule api_request = TrafficRuleListRequest.create() async def enable(self, traffic_rule: TrafficRule) -> TypedApiResponse: """Enable traffic rule defined in controller.""" return await self.toggle(traffic_rule, state=True) async def disable(self, traffic_rule: TrafficRule) -> TypedApiResponse: """Disable traffic rule defined in controller.""" return await self.toggle(traffic_rule, state=False) async def toggle(self, traffic_rule: TrafficRule, state: bool) -> TypedApiResponse: """Set traffic rule - defined in controller - to the desired state.""" traffic_rule_dict = deepcopy(traffic_rule.raw) traffic_rule_response = await self.controller.request( TrafficRuleEnableRequest.create(traffic_rule_dict, enable=state) ) self.process_raw(traffic_rule_response.get("data", [])) return traffic_rule_response
class TrafficRules(APIHandler[TrafficRule]): '''Represents TrafficRules configurations.''' async def enable(self, traffic_rule: TrafficRule) -> TypedApiResponse: '''Enable traffic rule defined in controller.''' pass async def disable(self, traffic_rule: TrafficRule) -> TypedApiResponse: '''Disable traffic rule defined in controller.''' pass async def toggle(self, traffic_rule: TrafficRule, state: bool) -> TypedApiResponse: '''Set traffic rule - defined in controller - to the desired state.''' pass
4
4
5
0
4
1
1
0.27
1
4
3
0
3
0
3
40
23
4
15
9
11
4
13
9
9
1
6
0
3
141,169
Kane610/aiounifi
aiounifi/interfaces/vouchers.py
aiounifi.interfaces.vouchers.Vouchers
class Vouchers(APIHandler[Voucher]): """Represents Hotspot vouchers.""" obj_id_key = "_id" item_cls = Voucher api_request = VoucherListRequest.create() async def create(self, voucher: Voucher) -> TypedApiResponse: """Create voucher on controller.""" return await self.controller.request( VoucherCreateRequest.create( quota=voucher.quota, expire_number=int( voucher.duration.total_seconds() / 60 # Get minutes. ), usage_quota=voucher.qos_usage_quota, rate_max_up=voucher.qos_rate_max_up, rate_max_down=voucher.qos_rate_max_down, note=voucher.note, ) ) async def delete(self, voucher: Voucher) -> TypedApiResponse: """Delete voucher from controller.""" return await self.controller.request( VoucherDeleteRequest.create( obj_id=voucher.id, ) )
class Vouchers(APIHandler[Voucher]): '''Represents Hotspot vouchers.''' async def create(self, voucher: Voucher) -> TypedApiResponse: '''Create voucher on controller.''' pass async def delete(self, voucher: Voucher) -> TypedApiResponse: '''Delete voucher from controller.''' pass
3
3
11
0
10
2
1
0.17
1
5
4
0
2
0
2
39
29
3
23
6
20
4
8
6
5
1
6
0
2
141,170
Kane610/aiounifi
aiounifi/models/device.py
aiounifi.models.device.TypedDeviceOutletOverrides
class TypedDeviceOutletOverrides(TypedDict, total=False): """Device outlet overrides type definition.""" cycle_enabled: bool index: int has_relay: bool has_metering: bool name: str relay_state: bool
class TypedDeviceOutletOverrides(TypedDict, total=False): '''Device outlet overrides type definition.'''
1
1
0
0
0
0
0
0.14
2
0
0
0
0
0
0
0
9
1
7
1
6
1
7
1
6
0
1
0
0
141,171
Kane610/aiounifi
aiounifi/errors.py
aiounifi.errors.AiounifiException
class AiounifiException(Exception): """Base error for aiounifi."""
class AiounifiException(Exception): '''Base error for aiounifi.''' pass
1
1
0
0
0
0
0
1
1
0
0
8
0
0
0
10
2
0
1
1
0
1
1
1
0
0
3
0
0
141,172
Kane610/aiounifi
aiounifi/errors.py
aiounifi.errors.BadGateway
class BadGateway(RequestError): """Invalid response from the upstream server."""
class BadGateway(RequestError): '''Invalid response from the upstream server.''' pass
1
1
0
0
0
0
0
1
1
0
0
0
0
0
0
10
2
0
1
1
0
1
1
1
0
0
5
0
0
141,173
Kane610/aiounifi
aiounifi/errors.py
aiounifi.errors.Forbidden
class Forbidden(AiounifiException): """Forbidden request."""
class Forbidden(AiounifiException): '''Forbidden request.''' pass
1
1
0
0
0
0
0
1
1
0
0
0
0
0
0
10
2
0
1
1
0
1
1
1
0
0
4
0
0
141,174
Kane610/aiounifi
aiounifi/errors.py
aiounifi.errors.LoginRequired
class LoginRequired(AiounifiException): """User is logged out."""
class LoginRequired(AiounifiException): '''User is logged out.''' pass
1
1
0
0
0
0
0
1
1
0
0
0
0
0
0
10
2
0
1
1
0
1
1
1
0
0
4
0
0
141,175
Kane610/aiounifi
aiounifi/errors.py
aiounifi.errors.NoPermission
class NoPermission(AiounifiException): """Users permissions are read only."""
class NoPermission(AiounifiException): '''Users permissions are read only.''' pass
1
1
0
0
0
0
0
1
1
0
0
0
0
0
0
10
2
0
1
1
0
1
1
1
0
0
4
0
0
141,176
Kane610/aiounifi
aiounifi/errors.py
aiounifi.errors.RequestError
class RequestError(AiounifiException): """Unable to fulfill request. Raised when host or API cannot be reached. """
class RequestError(AiounifiException): '''Unable to fulfill request. Raised when host or API cannot be reached. ''' pass
1
1
0
0
0
0
0
3
1
0
0
2
0
0
0
10
5
1
1
1
0
3
1
1
0
0
4
0
0
141,177
Kane610/aiounifi
aiounifi/errors.py
aiounifi.errors.ResponseError
class ResponseError(AiounifiException): """Invalid response."""
class ResponseError(AiounifiException): '''Invalid response.''' pass
1
1
0
0
0
0
0
1
1
0
0
0
0
0
0
10
2
0
1
1
0
1
1
1
0
0
4
0
0
141,178
Kane610/aiounifi
aiounifi/errors.py
aiounifi.errors.ServiceUnavailable
class ServiceUnavailable(RequestError): """Service is unavailable. Common error if controller is restarting and behind a proxy. """
class ServiceUnavailable(RequestError): '''Service is unavailable. Common error if controller is restarting and behind a proxy. ''' pass
1
1
0
0
0
0
0
3
1
0
0
0
0
0
0
10
5
1
1
1
0
3
1
1
0
0
5
0
0
141,179
Kane610/aiounifi
aiounifi/errors.py
aiounifi.errors.TwoFaTokenRequired
class TwoFaTokenRequired(AiounifiException): """2 factor authentication token required."""
class TwoFaTokenRequired(AiounifiException): '''2 factor authentication token required.''' pass
1
1
0
0
0
0
0
1
1
0
0
0
0
0
0
10
2
0
1
1
0
1
1
1
0
0
4
0
0
141,180
Kane610/aiounifi
aiounifi/errors.py
aiounifi.errors.Unauthorized
class Unauthorized(AiounifiException): """Username is not authorized."""
class Unauthorized(AiounifiException): '''Username is not authorized.''' pass
1
1
0
0
0
0
0
1
1
0
0
0
0
0
0
10
2
0
1
1
0
1
1
1
0
0
4
0
0
141,181
Kane610/aiounifi
aiounifi/errors.py
aiounifi.errors.WebsocketError
class WebsocketError(AiounifiException): """Websocket error."""
class WebsocketError(AiounifiException): '''Websocket error.''' pass
1
1
0
0
0
0
0
1
1
0
0
0
0
0
0
10
2
0
1
1
0
1
1
1
0
0
4
0
0
141,182
Kane610/aiounifi
aiounifi/interfaces/wlans.py
aiounifi.interfaces.wlans.Wlans
class Wlans(APIHandler[Wlan]): """Represents WLAN configurations.""" obj_id_key = "_id" item_cls = Wlan process_messages = (MessageKey.WLAN_CONF_UPDATED,) api_request = WlanListRequest.create() async def enable(self, wlan: Wlan) -> TypedApiResponse: """Block client from controller.""" return await self.controller.request( WlanEnableRequest.create(wlan.id, enable=True) ) async def disable(self, wlan: Wlan) -> TypedApiResponse: """Unblock client from controller.""" return await self.controller.request( WlanEnableRequest.create(wlan.id, enable=False) ) def generate_wlan_qr_code(self, wlan: Wlan) -> bytes: """Generate QR code based on WLAN properties.""" return wlan_qr_code(wlan.name, wlan.x_passphrase)
class Wlans(APIHandler[Wlan]): '''Represents WLAN configurations.''' async def enable(self, wlan: Wlan) -> TypedApiResponse: '''Block client from controller.''' pass async def disable(self, wlan: Wlan) -> TypedApiResponse: '''Unblock client from controller.''' pass def generate_wlan_qr_code(self, wlan: Wlan) -> bytes: '''Generate QR code based on WLAN properties.''' pass
4
4
4
0
3
1
1
0.27
1
4
3
0
3
0
3
40
23
4
15
8
11
4
11
8
7
1
6
0
3
141,183
Kane610/aiounifi
aiounifi/interfaces/api_handlers.py
aiounifi.interfaces.api_handlers.APIHandler
class APIHandler(SubscriptionHandler, Generic[ApiItemT]): """Base class for a map of API Items.""" obj_id_key: str item_cls: type[ApiItemT] api_request: ApiRequest process_messages: tuple[MessageKey, ...] = () remove_messages: tuple[MessageKey, ...] = () def __init__(self, controller: Controller) -> None: """Initialize API handler.""" super().__init__() self.controller = controller self._items: dict[str, ApiItemT] = {} if message_filter := self.process_messages + self.remove_messages: controller.messages.subscribe(self.process_message, message_filter) @final async def update(self) -> None: """Refresh data.""" raw = await self.controller.request(self.api_request) self.process_raw(raw.get("data", [])) @final def process_raw(self, raw: list[dict[str, Any]]) -> None: """Process full raw response.""" for raw_item in raw: self.process_item(raw_item) @final def process_message(self, message: Message) -> None: """Process and forward websocket data.""" if message.meta.message in self.process_messages: self.process_item(message.data) elif message.meta.message in self.remove_messages: self.remove_item(message.data) @final def process_item(self, raw: dict[str, Any]) -> None: """Process item data.""" if self.obj_id_key not in raw: return obj_id: str obj_is_known = (obj_id := raw[self.obj_id_key]) in self._items self._items[obj_id] = self.item_cls(raw) self.signal_subscribers( ItemEvent.CHANGED if obj_is_known else ItemEvent.ADDED, obj_id, ) @final def remove_item(self, raw: dict[str, Any]) -> None: """Remove item.""" obj_id: str if (obj_id := raw[self.obj_id_key]) in self._items: self._items.pop(obj_id) self.signal_subscribers(ItemEvent.DELETED, obj_id) @final def items(self) -> ItemsView[str, ApiItemT]: """Return items dictionary.""" return self._items.items() @final def values(self) -> ValuesView[ApiItemT]: """Return items.""" return self._items.values() @final def get(self, obj_id: str, default: Any | None = None) -> ApiItemT | None: """Get item value based on key, return default if no match.""" return self._items.get(obj_id, default) @final def __contains__(self, obj_id: str) -> bool: """Validate membership of item ID.""" return obj_id in self._items @final def __getitem__(self, obj_id: str) -> ApiItemT: """Get item value based on key.""" return self._items[obj_id] @final def __iter__(self) -> Iterator[str]: """Allow iterate over items.""" return iter(self._items)
class APIHandler(SubscriptionHandler, Generic[ApiItemT]): '''Base class for a map of API Items.''' def __init__(self, controller: Controller) -> None: '''Initialize API handler.''' pass @final async def update(self) -> None: '''Refresh data.''' pass @final def process_raw(self, raw: list[dict[str, Any]]) -> None: '''Process full raw response.''' pass @final def process_message(self, message: Message) -> None: '''Process and forward websocket data.''' pass @final def process_item(self, raw: dict[str, Any]) -> None: '''Process item data.''' pass @final def remove_item(self, raw: dict[str, Any]) -> None: '''Remove item.''' pass @final def items(self) -> ItemsView[str, ApiItemT]: '''Return items dictionary.''' pass @final def values(self) -> ValuesView[ApiItemT]: '''Return items.''' pass @final def get(self, obj_id: str, default: Any | None = None) -> ApiItemT | None: '''Get item value based on key, return default if no match.''' pass @final def __contains__(self, obj_id: str) -> bool: '''Validate membership of item ID.''' pass @final def __getitem__(self, obj_id: str) -> ApiItemT: '''Get item value based on key.''' pass @final def __iter__(self) -> Iterator[str]: '''Allow iterate over items.''' pass
24
13
5
0
4
1
2
0.21
2
11
2
16
12
2
12
37
91
17
61
32
37
13
46
20
33
3
5
1
19
141,184
Kane610/aiounifi
aiounifi/interfaces/clients.py
aiounifi.interfaces.clients.Clients
class Clients(APIHandler[Client]): """Represents client network devices.""" obj_id_key = "mac" item_cls = Client process_messages = (MessageKey.CLIENT,) remove_messages = (MessageKey.CLIENT_REMOVED,) api_request = ClientListRequest.create() async def block(self, mac: str) -> TypedApiResponse: """Block client from controller.""" return await self.controller.request(ClientBlockRequest.create(mac, block=True)) async def unblock(self, mac: str) -> TypedApiResponse: """Unblock client from controller.""" return await self.controller.request( ClientBlockRequest.create(mac, block=False) ) async def reconnect(self, mac: str) -> TypedApiResponse: """Force a wireless client to reconnect to the network.""" return await self.controller.request(ClientReconnectRequest.create(mac)) async def remove_clients(self, macs: list[str]) -> TypedApiResponse: """Make controller forget provided clients.""" return await self.controller.request(ClientRemoveRequest.create(macs))
class Clients(APIHandler[Client]): '''Represents client network devices.''' async def block(self, mac: str) -> TypedApiResponse: '''Block client from controller.''' pass async def unblock(self, mac: str) -> TypedApiResponse: '''Unblock client from controller.''' pass async def reconnect(self, mac: str) -> TypedApiResponse: '''Force a wireless client to reconnect to the network.''' pass async def remove_clients(self, macs: list[str]) -> TypedApiResponse: '''Make controller forget provided clients.''' pass
5
5
4
0
3
1
1
0.31
1
6
4
0
4
0
4
41
26
5
16
10
11
5
14
10
9
1
6
0
4
141,185
Kane610/aiounifi
aiounifi/interfaces/clients_all.py
aiounifi.interfaces.clients_all.ClientsAll
class ClientsAll(APIHandler[Client]): """Represents all client network devices.""" obj_id_key = "mac" item_cls = Client api_request = AllClientListRequest.create()
class ClientsAll(APIHandler[Client]): '''Represents all client network devices.''' pass
1
1
0
0
0
0
0
0.25
1
0
0
0
0
0
0
37
6
1
4
4
3
1
4
4
3
0
6
0
0
141,186
Kane610/aiounifi
aiounifi/interfaces/devices.py
aiounifi.interfaces.devices.Devices
class Devices(APIHandler[Device]): """Represents network devices.""" obj_id_key = "mac" item_cls = Device process_messages = (MessageKey.DEVICE,) api_request = DeviceListRequest.create() async def upgrade(self, mac: str) -> TypedApiResponse: """Upgrade network device.""" return await self.controller.request(DeviceUpgradeRequest.create(mac))
class Devices(APIHandler[Device]): '''Represents network devices.''' async def upgrade(self, mac: str) -> TypedApiResponse: '''Upgrade network device.''' pass
2
2
3
0
2
1
1
0.29
1
3
2
0
1
0
1
38
11
2
7
6
5
2
7
6
5
1
6
0
1
141,187
Kane610/aiounifi
aiounifi/interfaces/dpi_restriction_apps.py
aiounifi.interfaces.dpi_restriction_apps.DPIRestrictionApps
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) )
class DPIRestrictionApps(APIHandler[DPIRestrictionApp]): '''Represents DPI App configurations.''' async def enable(self, app_id: str) -> TypedApiResponse: '''Enable DPI Restriction Group Apps.''' pass async def disable(self, app_id: str) -> TypedApiResponse: '''Disable DPI Restriction Group Apps.''' pass
3
3
5
0
4
1
1
0.21
1
3
2
0
2
0
2
39
20
3
14
8
11
3
10
8
7
1
6
0
2
141,188
Kane610/aiounifi
aiounifi/interfaces/dpi_restriction_groups.py
aiounifi.interfaces.dpi_restriction_groups.DPIRestrictionGroups
class DPIRestrictionGroups(APIHandler[DPIRestrictionGroup]): """Represents DPI Group configurations.""" obj_id_key = "_id" item_cls = DPIRestrictionGroup process_messages = (MessageKey.DPI_GROUP_ADDED, MessageKey.DPI_GROUP_UPDATED) remove_messages = (MessageKey.DPI_GROUP_REMOVED,) api_request = DpiRestrictionGroupListRequest.create()
class DPIRestrictionGroups(APIHandler[DPIRestrictionGroup]): '''Represents DPI Group configurations.''' pass
1
1
0
0
0
0
0
0.17
1
0
0
0
0
0
0
37
8
1
6
6
5
1
6
6
5
0
6
0
0
141,189
Kane610/aiounifi
aiounifi/interfaces/events.py
aiounifi.interfaces.events.EventHandler
class EventHandler: """Event handler class.""" def __init__(self, controller: Controller) -> None: """Initialize API items.""" self.controller = controller self._subscribers: list[SubscriptionType] = [] controller.messages.subscribe(self.handler, MessageKey.EVENT) def subscribe( self, callback: SubscriptionCallback, event_filter: tuple[EventKey, ...] | EventKey | None = None, ) -> UnsubscribeType: """Subscribe to events. "callback" - callback function to call when on event. Return function to unsubscribe. """ if isinstance(event_filter, EventKey): event_filter = (event_filter,) subscription = (callback, event_filter) self._subscribers.append(subscription) def unsubscribe() -> None: self._subscribers.remove(subscription) return unsubscribe def handler(self, message: Message) -> None: """Receive event from message handler and identifies where the event belong.""" event = Event(message.data) for callback, event_filter in self._subscribers: if event_filter is not None and event.key not in event_filter: continue callback(event) def __len__(self) -> int: """List number of event subscribers.""" return len(self._subscribers)
class EventHandler: '''Event handler class.''' def __init__(self, controller: Controller) -> None: '''Initialize API items.''' pass def subscribe( self, callback: SubscriptionCallback, event_filter: tuple[EventKey, ...] | EventKey | None = None, ) -> UnsubscribeType: '''Subscribe to events. "callback" - callback function to call when on event. Return function to unsubscribe. ''' pass def unsubscribe() -> None: pass def handler(self, message: Message) -> None: '''Receive event from message handler and identifies where the event belong.''' pass def __len__(self) -> int: '''List number of event subscribers.''' pass
6
5
8
1
5
1
2
0.32
0
7
4
0
4
2
4
4
43
10
25
15
15
8
21
11
15
3
0
2
8
141,190
Kane610/aiounifi
aiounifi/interfaces/messages.py
aiounifi.interfaces.messages.MessageHandler
class MessageHandler: """Message handler class.""" def __init__(self, controller: Controller) -> None: """Initialize message handler class.""" self.controller = controller self._subscribers: list[SubscriptionType] = [] self._subscribed_messages: set[MessageKey] = set() def subscribe( self, callback: SubscriptionCallback, message_filter: tuple[MessageKey, ...] | MessageKey | None = None, ) -> UnsubscribeType: """Subscribe to messages. "callback" - callback function to call when on event. Return function to unsubscribe. """ if isinstance(message_filter, MessageKey): message_filter = (message_filter,) if message_filter is not None: self._subscribed_messages.update(message_filter) subscription = (callback, message_filter) self._subscribers.append(subscription) def unsubscribe() -> None: self._subscribers.remove(subscription) return unsubscribe def new_data(self, raw_bytes: bytes) -> None: """Convert bytes data into parseable JSON data..""" try: self.handler(orjson.loads(raw_bytes)) except orjson.JSONDecodeError: LOGGER.debug("Bad JSON data '%s'", raw_bytes) def handler(self, raw: dict[str, Any]) -> None: """Process data and identify where the message belongs.""" if "meta" not in raw or "data" not in raw: return for raw_data in raw["data"]: data = Message.from_dict( { "meta": raw["meta"], "data": raw_data, } ) if data.meta.message not in self._subscribed_messages: break for callback, message_filter in self._subscribers: if ( message_filter is not None and data.meta.message not in message_filter ): continue callback(data) def __len__(self) -> int: """List number of message subscribers.""" return len(self._subscribers)
class MessageHandler: '''Message handler class.''' def __init__(self, controller: Controller) -> None: '''Initialize message handler class.''' pass def subscribe( self, callback: SubscriptionCallback, message_filter: tuple[MessageKey, ...] | MessageKey | None = None, ) -> UnsubscribeType: '''Subscribe to messages. "callback" - callback function to call when on event. Return function to unsubscribe. ''' pass def unsubscribe() -> None: pass def new_data(self, raw_bytes: bytes) -> None: '''Convert bytes data into parseable JSON data..''' pass def handler(self, raw: dict[str, Any]) -> None: '''Process data and identify where the message belongs.''' pass def __len__(self) -> int: '''List number of message subscribers.''' pass
7
6
10
1
8
1
2
0.2
0
10
2
0
5
3
5
5
66
12
45
18
34
9
33
14
26
6
0
3
14
141,191
Kane610/aiounifi
aiounifi/interfaces/outlets.py
aiounifi.interfaces.outlets.Outlets
class Outlets(APIHandler[Outlet]): """Represents network device ports.""" item_cls = Outlet def __init__(self, controller: Controller) -> None: """Initialize API handler.""" super().__init__(controller) controller.devices.subscribe(self.process_device) def process_device(self, event: ItemEvent, device_id: str) -> None: """Add, update, remove.""" if event in (ItemEvent.ADDED, ItemEvent.CHANGED): device = self.controller.devices[device_id] for raw_outlet in device.outlet_table: outlet = Outlet(raw_outlet) obj_id = f"{device_id}_{outlet.index}" self._items[obj_id] = outlet self.signal_subscribers(event, obj_id) return matched_obj_ids = [ obj_id for obj_id in self._items if obj_id.startswith(device_id) ] for obj_id in matched_obj_ids: self._items.pop(obj_id) self.signal_subscribers(event, obj_id)
class Outlets(APIHandler[Outlet]): '''Represents network device ports.''' def __init__(self, controller: Controller) -> None: '''Initialize API handler.''' pass def process_device(self, event: ItemEvent, device_id: str) -> None: '''Add, update, remove.''' pass
3
3
11
1
9
1
3
0.15
1
4
2
0
2
0
2
39
27
4
20
9
17
3
18
9
15
4
6
2
5
141,192
Kane610/aiounifi
aiounifi/interfaces/port_forwarding.py
aiounifi.interfaces.port_forwarding.PortForwarding
class PortForwarding(APIHandler[PortForward]): """Represents port forwarding.""" obj_id_key = "_id" item_cls = PortForward process_messages = (MessageKey.PORT_FORWARD_ADDED, MessageKey.PORT_FORWARD_UPDATED) remove_messages = (MessageKey.PORT_FORWARD_DELETED,) api_request = PortForwardListRequest.create()
class PortForwarding(APIHandler[PortForward]): '''Represents port forwarding.''' pass
1
1
0
0
0
0
0
0.17
1
0
0
0
0
0
0
37
8
1
6
6
5
1
6
6
5
0
6
0
0
141,193
Kane610/aiounifi
aiounifi/interfaces/ports.py
aiounifi.interfaces.ports.Ports
class Ports(APIHandler[Port]): """Represents network device ports.""" item_cls = Port def __init__(self, controller: Controller) -> None: """Initialize API handler.""" super().__init__(controller) controller.devices.subscribe(self.process_device) def process_device(self, event: ItemEvent, device_id: str) -> None: """Add, update, remove.""" if event in (ItemEvent.ADDED, ItemEvent.CHANGED): device = self.controller.devices[device_id] if "port_table" not in device.raw: return for raw_port in device.raw["port_table"]: port = Port(raw_port) if (port_idx := port.port_idx or port.ifname) is None: continue obj_id = f"{device_id}_{port_idx}" self._items[obj_id] = port self.signal_subscribers(event, obj_id) return matched_obj_ids = [ obj_id for obj_id in self._items if obj_id.startswith(device_id) ] for obj_id in matched_obj_ids: self._items.pop(obj_id) self.signal_subscribers(event, obj_id)
class Ports(APIHandler[Port]): '''Represents network device ports.''' def __init__(self, controller: Controller) -> None: '''Initialize API handler.''' pass def process_device(self, event: ItemEvent, device_id: str) -> None: '''Add, update, remove.''' pass
3
3
13
1
11
1
4
0.13
1
4
2
0
2
0
2
39
31
4
24
10
21
3
22
9
19
6
6
3
7
141,194
Kane610/aiounifi
aiounifi/interfaces/sites.py
aiounifi.interfaces.sites.Sites
class Sites(APIHandler[Site]): """Represent UniFi sites.""" obj_id_key = "_id" item_cls = Site api_request = SiteListRequest.create()
class Sites(APIHandler[Site]): '''Represent UniFi sites.''' pass
1
1
0
0
0
0
0
0.25
1
0
0
0
0
0
0
37
6
1
4
4
3
1
4
4
3
0
6
0
0
141,195
Kane610/aiounifi
aiounifi/interfaces/system_information.py
aiounifi.interfaces.system_information.SystemInformationHandler
class SystemInformationHandler(APIHandler[SystemInformation]): """Represents system information interface.""" obj_id_key = "anonymous_controller_id" item_cls = SystemInformation api_request = SystemInformationRequest.create()
class SystemInformationHandler(APIHandler[SystemInformation]): '''Represents system information interface.''' pass
1
1
0
0
0
0
0
0.25
1
0
0
0
0
0
0
37
6
1
4
4
3
1
4
4
3
0
6
0
0
141,196
Kane610/aiounifi
aiounifi/interfaces/traffic_routes.py
aiounifi.interfaces.traffic_routes.TrafficRoutes
class TrafficRoutes(APIHandler[TrafficRoute]): """Represents TrafficRoutes configurations.""" obj_id_key = "_id" item_cls = TrafficRoute api_request = TrafficRouteListRequest.create() async def enable(self, traffic_route: TrafficRoute) -> TypedApiResponse: """Enable traffic route defined in controller.""" return await self.save(traffic_route, state=True) async def disable(self, traffic_route: TrafficRoute) -> TypedApiResponse: """Disable traffic route defined in controller.""" return await self.save(traffic_route, state=False) async def save( self, traffic_route: TrafficRoute, state: bool | None = None ) -> TypedApiResponse: """Set traffic route - defined in controller - to the desired state.""" traffic_route_dict = deepcopy(traffic_route.raw) traffic_route_response = await self.controller.request( TrafficRouteSaveRequest.create(traffic_route_dict, enable=state) ) self.process_raw(traffic_route_response.get("data", [])) return traffic_route_response
class TrafficRoutes(APIHandler[TrafficRoute]): '''Represents TrafficRoutes configurations.''' async def enable(self, traffic_route: TrafficRoute) -> TypedApiResponse: '''Enable traffic route defined in controller.''' pass async def disable(self, traffic_route: TrafficRoute) -> TypedApiResponse: '''Disable traffic route defined in controller.''' pass async def save( self, traffic_route: TrafficRoute, state: bool | None = None ) -> TypedApiResponse: '''Set traffic route - defined in controller - to the desired state.''' pass
4
4
5
0
4
1
1
0.24
1
4
3
0
3
0
3
40
25
4
17
11
11
4
13
9
9
1
6
0
3
141,197
Kane610/aiounifi
aiounifi/interfaces/api_handlers.py
aiounifi.interfaces.api_handlers.ItemEvent
class ItemEvent(enum.Enum): """The event action of the item.""" ADDED = "added" CHANGED = "changed" DELETED = "deleted"
class ItemEvent(enum.Enum): '''The event action of the item.''' pass
1
1
0
0
0
0
0
0.25
1
0
0
0
0
0
0
49
6
1
4
4
3
1
4
4
3
0
4
0
0
141,198
Kane610/aiounifi
aiounifi/models/device.py
aiounifi.models.device.TypedDeviceOutletTable
class TypedDeviceOutletTable(TypedDict): """Device outlet table type definition.""" cycle_enabled: NotRequired[bool] index: int has_relay: NotRequired[bool] has_metering: NotRequired[bool] name: str outlet_caps: int outlet_voltage: NotRequired[str] outlet_current: NotRequired[str] outlet_power: NotRequired[str] outlet_power_factor: NotRequired[str] relay_state: bool
class TypedDeviceOutletTable(TypedDict): '''Device outlet table type definition.'''
1
1
0
0
0
0
0
0.08
1
0
0
0
0
0
0
0
14
1
12
1
11
1
12
1
11
0
1
0
0
141,199
Kane610/aiounifi
aiounifi/interfaces/connectivity.py
aiounifi.interfaces.connectivity.Connectivity
class Connectivity: """UniFi Network Application connectivity.""" def __init__(self, config: Configuration) -> None: """Session setup.""" self.config = config self.is_unifi_os = False self.headers: dict[str, str] = {} self.can_retry_login = False self.ws_message_received: datetime.datetime | None = None if config.ssl_context: LOGGER.warning("Using SSL context %s", config.ssl_context) async def check_unifi_os(self) -> None: """Check if controller is running UniFi OS.""" self.is_unifi_os = False response, _ = await self._request("get", self.config.url, allow_redirects=False) if response.status == HTTPStatus.OK: self.is_unifi_os = True self.config.session.cookie_jar.clear_domain(self.config.host) LOGGER.debug("Talking to UniFi OS device: %s", self.is_unifi_os) async def login(self) -> None: """Log in to controller.""" self.headers.clear() url = f"{self.config.url}/api{'/auth/login' if self.is_unifi_os else '/login'}" auth = { "username": self.config.username, "password": self.config.password, "rememberMe": True, } response, bytes_data = await self._request("post", url, json=auth) if response.content_type != "application/json": LOGGER.debug("Login Failed not JSON: '%s'", bytes_data) raise RequestError("Login Failed: Host starting up") data: TypedApiResponse = orjson.loads(bytes_data) if data.get("meta", {}).get("rc") == "error": LOGGER.error("Login failed '%s'", data) raise ERRORS.get(data["meta"]["msg"], AiounifiException) if (csrf_token := response.headers.get("x-csrf-token")) is not None: self.headers["x-csrf-token"] = csrf_token if (cookie := response.headers.get("Set-Cookie")) is not None: self.headers["Cookie"] = cookie self.can_retry_login = True LOGGER.debug("Logged in to UniFi %s", url) async def request(self, api_request: ApiRequest) -> TypedApiResponse: """Make a request to the API, retry login on failure.""" url = self.config.url + api_request.full_path( self.config.site, self.is_unifi_os ) data: TypedApiResponse = {} try: response, bytes_data = await self._request( api_request.method, url, api_request.data ) if response.content_type == "application/json": data = api_request.decode(bytes_data) except LoginRequired: if not self.can_retry_login: raise # Session likely expired, try again self.can_retry_login = False await self.login() return await self.request(api_request) return data async def _request( self, method: str, url: str, json: Mapping[str, Any] | None = None, allow_redirects: bool = True, ) -> tuple[aiohttp.ClientResponse, bytes]: """Make a request to the API.""" LOGGER.debug("sending (to %s) %s, %s, %s", url, method, json, allow_redirects) bytes_data = b"" try: async with self.config.session.request( method, url, json=json, ssl=self.config.ssl_context, headers=self.headers, allow_redirects=allow_redirects, ) as res: LOGGER.debug( "received (from %s) %s %s %s", url, res.status, res.content_type, res, ) if res.status == HTTPStatus.UNAUTHORIZED: raise LoginRequired(f"Call {url} received 401 Unauthorized") if res.status == HTTPStatus.FORBIDDEN: raise Forbidden(f"Call {url} received 403 Forbidden") if res.status == HTTPStatus.NOT_FOUND: raise ResponseError(f"Call {url} received 404 Not Found") if res.status == HTTPStatus.BAD_GATEWAY: raise BadGateway(f"Call {url} received 502 bad gateway") if res.status == HTTPStatus.SERVICE_UNAVAILABLE: raise ServiceUnavailable( f"Call {url} received 503 service unavailable" ) bytes_data = await res.read() except client_exceptions.ClientError as err: raise RequestError(f"Error requesting data from {url}: {err}") from None LOGGER.debug("data (from %s) %s", url, bytes_data) if res.status == HTTPStatus.TOO_MANY_REQUESTS: raise ResponseError(f"Call {url} received 429: {bytes_data!r}") return res, bytes_data async def websocket(self, callback: Callable[[bytes], None]) -> None: """Run websocket.""" url = f"wss://{self.config.host}:{self.config.port}" url += "/proxy/network" if self.is_unifi_os else "" url += f"/wss/s/{self.config.site}/events" try: async with self.config.session.ws_connect( url, headers=self.headers, ssl=self.config.ssl_context, heartbeat=15, compress=12, ) as websocket_connection: LOGGER.debug( "Connected to UniFi websocket %s, headers: %s, cookiejar: %s", url, self.headers, self.config.session.cookie_jar._cookies, # type: ignore[attr-defined] ) async for message in websocket_connection: self.ws_message_received = datetime.datetime.now(datetime.UTC) if message.type is aiohttp.WSMsgType.TEXT: LOGGER.debug("Websocket '%s'", message.data) callback(message.data) elif message.type is aiohttp.WSMsgType.CLOSED: LOGGER.warning( "Connection closed to UniFi websocket '%s'", message.data ) break elif message.type is aiohttp.WSMsgType.ERROR: LOGGER.error("UniFi websocket error: '%s'", message.data) raise WebsocketError(message.data) else: LOGGER.warning( "Unexpected websocket message type '%s' with data '%s'", message.type, message.data, ) except aiohttp.ClientConnectorError as err: LOGGER.error("Error connecting to UniFi websocket: '%s'", err) err.add_note("Error connecting to UniFi websocket") raise except aiohttp.WSServerHandshakeError as err: LOGGER.error( "Server handshake error connecting to UniFi websocket: '%s'", err ) err.add_note("Server handshake error connecting to UniFi websocket") raise except WebsocketError: raise except Exception as err: LOGGER.exception(err) raise WebsocketError from err
class Connectivity: '''UniFi Network Application connectivity.''' def __init__(self, config: Configuration) -> None: '''Session setup.''' pass async def check_unifi_os(self) -> None: '''Check if controller is running UniFi OS.''' pass async def login(self) -> None: '''Log in to controller.''' pass async def request(self, api_request: ApiRequest) -> TypedApiResponse: '''Make a request to the API, retry login on failure.''' pass async def _request( self, method: str, url: str, json: Mapping[str, Any] | None = None, allow_redirects: bool = True, ) -> tuple[aiohttp.ClientResponse, bytes]: '''Make a request to the API.''' pass async def websocket(self, callback: Callable[[bytes], None]) -> None: '''Run websocket.''' pass
7
7
32
6
25
1
5
0.06
0
25
11
0
6
5
6
6
200
40
152
35
139
9
101
23
94
10
0
4
32
141,200
Kane610/aiounifi
aiounifi/models/device.py
aiounifi.models.device.TypedDevicePortTable
class TypedDevicePortTable(TypedDict): """Device port table type definition.""" aggregated_by: bool attr_no_edit: bool autoneg: bool bytes_r: int dot1x_mode: str dot1x_status: str enable: bool flowctrl_rx: bool flowctrl_tx: bool full_duplex: bool ifname: NotRequired[str] is_uplink: bool jumbo: bool lldp_table: list[TypedDevicePortTableLldpTable] mac_table: list[TypedDevicePortTableMacTable] masked: bool media: str name: str op_mode: str poe_caps: int poe_class: str poe_current: str poe_enable: bool poe_good: bool poe_mode: str poe_power: str poe_voltage: str port_delta: TypedDevicePortTablePortDelta port_idx: NotRequired[int] port_poe: bool portconf_id: str rx_broadcast: int rx_bytes: int rx_bytes_r: int rx_dropped: int rx_errors: int rx_multicast: int rx_packets: int speed: int speed_caps: int stp_pathcost: int stp_state: str tx_broadcast: int tx_bytes: int tx_bytes_r: int tx_dropped: int tx_errors: int tx_multicast: int tx_packets: int up: NotRequired[bool]
class TypedDevicePortTable(TypedDict): '''Device port table type definition.'''
1
1
0
0
0
0
0
0.02
1
0
0
0
0
0
0
0
53
1
51
1
50
1
51
1
50
0
1
0
0
141,201
Kane610/aiounifi
aiounifi/models/traffic_rule.py
aiounifi.models.traffic_rule.IPAddress
class IPAddress(TypedDict): """IP Address for which traffic rule is applicable type definition.""" ip_or_subnet: str ip_version: str port_ranges: list[PortRange] ports: list[int]
class IPAddress(TypedDict): '''IP Address for which traffic rule is applicable type definition.'''
1
1
0
0
0
0
0
0.2
1
0
0
0
0
0
0
0
7
1
5
1
4
1
5
1
4
0
1
0
0
141,202
Kane610/aiounifi
aiounifi/models/traffic_rule.py
aiounifi.models.traffic_rule.BandwidthLimit
class BandwidthLimit(TypedDict): """Bandwidth limit type definition.""" download_limit_kbps: int enabled: bool upload_limit_kbps: int
class BandwidthLimit(TypedDict): '''Bandwidth limit type definition.'''
1
1
0
0
0
0
0
0.25
1
0
0
0
0
0
0
0
6
1
4
1
3
1
4
1
3
0
1
0
0
141,203
Kane610/aiounifi
aiounifi/models/traffic_route.py
aiounifi.models.traffic_route.TypedTrafficRoute
class TypedTrafficRoute(TypedDict): """Traffic route type definition.""" _id: str description: str domains: list[Domain] enabled: bool ip_addresses: list[IPAddress] ip_ranges: list[IPRange] matching_target: MatchingTarget network_id: str next_hop: str regions: list[str] target_devices: list[TargetDevice]
class TypedTrafficRoute(TypedDict): '''Traffic route type definition.'''
1
1
0
0
0
0
0
0.08
1
0
0
0
0
0
0
0
14
1
12
1
11
1
12
1
11
0
1
0
0
141,204
Kane610/aiounifi
aiounifi/models/traffic_route.py
aiounifi.models.traffic_route.TrafficRouteSaveRequest
class TrafficRouteSaveRequest(ApiRequestV2): """Request object for saving a traffic route. To modify a route, you must make sure the `raw` attribute of the TypedTrafficRoute is modified. The properties provide convient access for reading, however do not provide means of setting values. """ @classmethod def create( cls, traffic_route: TypedTrafficRoute, enable: bool | None = None ) -> Self: """Create traffic route save request.""" if enable is not None: traffic_route["enabled"] = enable return cls( method="put", path=f"/trafficroutes/{traffic_route['_id']}", data=traffic_route, )
class TrafficRouteSaveRequest(ApiRequestV2): '''Request object for saving a traffic route. To modify a route, you must make sure the `raw` attribute of the TypedTrafficRoute is modified. The properties provide convient access for reading, however do not provide means of setting values. ''' @classmethod def create( cls, traffic_route: TypedTrafficRoute, enable: bool | None = None ) -> Self: '''Create traffic route save request.''' pass
3
2
11
0
10
1
2
0.42
1
2
1
0
0
0
1
5
19
2
12
5
7
5
5
2
3
2
2
1
2
141,205
Kane610/aiounifi
aiounifi/models/traffic_route.py
aiounifi.models.traffic_route.TrafficRouteListRequest
class TrafficRouteListRequest(ApiRequestV2): """Request object for traffic route list.""" @classmethod def create(cls) -> Self: """Create traffic route request.""" return cls(method="get", path="/trafficroutes", data=None)
class TrafficRouteListRequest(ApiRequestV2): '''Request object for traffic route list.''' @classmethod def create(cls) -> Self: '''Create traffic route request.''' pass
3
2
3
0
2
1
1
0.5
1
0
0
0
0
0
1
5
7
1
4
3
1
2
3
2
1
1
2
0
1
141,206
Kane610/aiounifi
aiounifi/models/traffic_route.py
aiounifi.models.traffic_route.TrafficRoute
class TrafficRoute(ApiItem): """Represent a traffic route configuration.""" raw: TypedTrafficRoute @property def id(self) -> str: """ID of traffic route.""" return self.raw["_id"] @property def description(self) -> str: """Description given by user to traffic route.""" return self.raw["description"] @property def domains(self) -> list[Domain]: """What IP addresses are matched against by this traffic route. Note: Domain matching requires the client devices to use the UniFi gateway as the DNS server. """ return self.raw["domains"] @property def enabled(self) -> bool: """Is traffic route enabled.""" return self.raw["enabled"] @property def ip_addresses(self) -> list[IPAddress]: """What IP addresses are matched against by this traffic route.""" return self.raw["ip_addresses"] @property def ip_ranges(self) -> list[IPRange]: """What IP addresses are matched against by this traffic route.""" return self.raw["ip_ranges"] @property def matching_target(self) -> MatchingTarget: """What target is matched by this traffic route.""" return self.raw["matching_target"] @property def network_id(self) -> str: """Network ID that this rule applies to.""" return self.raw["network_id"] @property def next_hop(self) -> str: """Used for defining a static route.""" return self.raw["next_hop"] @property def regions(self) -> list[str]: """Regions that the rule applies to.""" return self.raw["regions"] @property def target_devices(self) -> list[TargetDevice]: """What target devices are affected by this traffic route.""" return self.raw["target_devices"]
class TrafficRoute(ApiItem): '''Represent a traffic route configuration.''' @property def id(self) -> str: '''ID of traffic route.''' pass @property def description(self) -> str: '''Description given by user to traffic route.''' pass @property def domains(self) -> list[Domain]: '''What IP addresses are matched against by this traffic route. Note: Domain matching requires the client devices to use the UniFi gateway as the DNS server. ''' pass @property def enabled(self) -> bool: '''Is traffic route enabled.''' pass @property def ip_addresses(self) -> list[IPAddress]: '''What IP addresses are matched against by this traffic route.''' pass @property def ip_ranges(self) -> list[IPRange]: '''What IP addresses are matched against by this traffic route.''' pass @property def matching_target(self) -> MatchingTarget: '''What target is matched by this traffic route.''' pass @property def network_id(self) -> str: '''Network ID that this rule applies to.''' pass @property def next_hop(self) -> str: '''Used for defining a static route.''' pass @property def regions(self) -> list[str]: '''Regions that the rule applies to.''' pass @property def target_devices(self) -> list[TargetDevice]: '''What target devices are affected by this traffic route.''' pass
23
12
3
0
2
1
1
0.4
1
8
5
0
11
0
11
32
62
13
35
23
12
14
24
12
12
1
5
0
11
141,207
Kane610/aiounifi
aiounifi/models/traffic_rule.py
aiounifi.models.traffic_rule.IPRange
class IPRange(TypedDict): """IP Range type definition.""" ip_start: str ip_stop: str ip_version: str
class IPRange(TypedDict): '''IP Range type definition.'''
1
1
0
0
0
0
0
0.25
1
0
0
0
0
0
0
0
6
1
4
1
3
1
4
1
3
0
1
0
0
141,208
Kane610/aiounifi
aiounifi/models/traffic_route.py
aiounifi.models.traffic_route.TargetDevice
class TargetDevice(TypedDict): """Target device to which the traffic route applies.""" client_mac: NotRequired[str] network_id: NotRequired[str] type: str
class TargetDevice(TypedDict): '''Target device to which the traffic route applies.''' pass
1
1
0
0
0
0
0
0.25
1
0
0
0
0
0
0
0
6
1
4
1
3
1
4
1
3
0
1
0
0
141,209
Kane610/aiounifi
aiounifi/models/traffic_route.py
aiounifi.models.traffic_route.IPAddress
class IPAddress(TypedDict): """IP Address for which traffic route is applicable type definition.""" ip_or_subnet: str ip_version: str port_ranges: list[PortRange] ports: list[int]
class IPAddress(TypedDict): '''IP Address for which traffic route is applicable type definition.'''
1
1
0
0
0
0
0
0.2
1
0
0
0
0
0
0
0
7
1
5
1
4
1
5
1
4
0
1
0
0
141,210
Kane610/aiounifi
aiounifi/models/traffic_route.py
aiounifi.models.traffic_route.Domain
class Domain(TypedDict): """A target domain for a traffic route.""" domain: str port_ranges: list[PortRange] ports: list[int]
class Domain(TypedDict): '''A target domain for a traffic route.''' pass
1
1
0
0
0
0
0
0.25
1
0
0
0
0
0
0
0
6
1
4
1
3
1
4
1
3
0
1
0
0
141,211
Kane610/aiounifi
aiounifi/models/system_information.py
aiounifi.models.system_information.TypedSystemInfo
class TypedSystemInfo(TypedDict): """System information type definition.""" anonymous_controller_id: str autobackup: bool build: str console_display_version: str data_retention_days: int data_retention_time_in_hours_for_5minutes_scale: int data_retention_time_in_hours_for_daily_scale: int data_retention_time_in_hours_for_hourly_scale: int data_retention_time_in_hours_for_monthly_scale: int data_retention_time_in_hours_for_others: int debug_device: str debug_mgmt: str debug_sdn: str debug_setting_preference: str debug_system: str default_site_device_auth_password_alert: bool facebook_wifi_registered: bool has_webrtc_support: bool hostname: str https_port: int image_maps_use_google_engine: bool inform_port: int ip_addrs: list[str] is_cloud_console: bool live_chat: str name: str override_inform_host: bool portal_http_port: int previous_version: str radius_disconnect_running: bool sso_app_id: str sso_app_sec: str store_enabled: str timezone: str ubnt_device_type: str udm_version: str unifi_go_enabled: bool unsupported_device_count: int unsupported_device_list: list[str] update_available: bool update_downloaded: bool uptime: int version: str
class TypedSystemInfo(TypedDict): '''System information type definition.'''
1
1
0
0
0
0
0
0.02
1
0
0
0
0
0
0
0
46
1
44
1
43
1
44
1
43
0
1
0
0
141,212
Kane610/aiounifi
aiounifi/models/system_information.py
aiounifi.models.system_information.SystemInformationRequest
class SystemInformationRequest(ApiRequest): """Request object for system information.""" @classmethod def create(cls) -> SystemInformationRequest: """Create system information request.""" return cls(method="get", path="/stat/sysinfo")
class SystemInformationRequest(ApiRequest): '''Request object for system information.''' @classmethod def create(cls) -> SystemInformationRequest: '''Create system information request.''' pass
3
2
3
0
2
1
1
0.5
1
0
0
0
0
0
1
3
7
1
4
3
1
2
3
2
1
1
1
0
1
141,213
Kane610/aiounifi
aiounifi/models/system_information.py
aiounifi.models.system_information.SystemInformation
class SystemInformation(ApiItem): """Represents a client network device.""" raw: TypedSystemInfo @property def anonymous_controller_id(self) -> str: """Anonymous controller ID.""" return self.raw["anonymous_controller_id"] @property def device_type(self) -> str: """Network host device type.""" return self.raw["ubnt_device_type"] @property def hostname(self) -> str: """Host name.""" return self.raw["hostname"] @property def ip_address(self) -> list[str]: """External IP address.""" return self.raw["ip_addrs"] @property def is_cloud_console(self) -> bool: """Cloud hosted console.""" return self.raw["is_cloud_console"] @property def name(self) -> str: """Name.""" return self.raw["name"] @property def previous_version(self) -> str: """Previous application version.""" return self.raw["previous_version"] @property def update_available(self) -> bool: """Application update available.""" return self.raw["update_available"] @property def uptime(self) -> int: """Application uptime.""" return self.raw["uptime"] @property def version(self) -> str: """Current application version.""" return self.raw["version"]
class SystemInformation(ApiItem): '''Represents a client network device.''' @property def anonymous_controller_id(self) -> str: '''Anonymous controller ID.''' pass @property def device_type(self) -> str: '''Network host device type.''' pass @property def hostname(self) -> str: '''Host name.''' pass @property def ip_address(self) -> list[str]: '''External IP address.''' pass @property def is_cloud_console(self) -> bool: '''Cloud hosted console.''' pass @property def name(self) -> str: '''Name.''' pass @property def previous_version(self) -> str: '''Previous application version.''' pass @property def update_available(self) -> bool: '''Application update available.''' pass @property def uptime(self) -> int: '''Application uptime.''' pass @property def version(self) -> str: '''Current application version.''' pass
21
11
3
0
2
1
1
0.34
1
4
0
0
10
0
10
31
54
11
32
21
11
11
22
11
11
1
5
0
10
141,214
Kane610/aiounifi
aiounifi/models/site.py
aiounifi.models.site.TypedSite
class TypedSite(TypedDict): """Site description.""" _id: str attr_hidden_id: str attr_no_delete: bool desc: str name: str role: str
class TypedSite(TypedDict): '''Site description.''' pass
1
1
0
0
0
0
0
0.14
1
0
0
0
0
0
0
0
9
1
7
1
6
1
7
1
6
0
1
0
0
141,215
Kane610/aiounifi
aiounifi/models/traffic_route.py
aiounifi.models.traffic_route.MatchingTarget
class MatchingTarget(StrEnum): """Possible matching targets for a traffic rule.""" DOMAIN = "DOMAIN" IP = "IP" INTERNET = "INTERNET" REGION = "REGION"
class MatchingTarget(StrEnum): '''Possible matching targets for a traffic rule.''' pass
1
1
0
0
0
0
0
0.2
1
0
0
0
0
0
0
68
7
1
5
5
4
1
5
5
4
0
3
0
0
141,216
Kane610/aiounifi
aiounifi/models/traffic_rule.py
aiounifi.models.traffic_rule.Schedule
class Schedule(TypedDict): """Schedule to enable/disable traffic rule type definition.""" date_end: str date_start: str mode: str repeat_on_days: list[str] time_all_day: bool time_range_end: str time_range_start: str
class Schedule(TypedDict): '''Schedule to enable/disable traffic rule type definition.'''
1
1
0
0
0
0
0
0.13
1
0
0
0
0
0
0
0
10
1
8
1
7
1
8
1
7
0
1
0
0
141,217
Kane610/aiounifi
aiounifi/models/traffic_rule.py
aiounifi.models.traffic_rule.TargetDevice
class TargetDevice(TypedDict): """Target device to which the traffic rule applies.""" client_mac: NotRequired[str] network_id: NotRequired[str] type: str
class TargetDevice(TypedDict): '''Target device to which the traffic rule applies.''' pass
1
1
0
0
0
0
0
0.25
1
0
0
0
0
0
0
0
6
1
4
1
3
1
4
1
3
0
1
0
0
141,218
Kane610/aiounifi
aiounifi/models/traffic_rule.py
aiounifi.models.traffic_rule.TrafficRule
class TrafficRule(ApiItem): """Represent a traffic rule configuration.""" raw: TypedTrafficRule @property def id(self) -> str: """ID of traffic rule.""" return self.raw["_id"] @property def description(self) -> str: """Description given by user to traffic rule.""" return self.raw["description"] @property def enabled(self) -> bool: """Is traffic rule enabled.""" return self.raw["enabled"] @property def action(self) -> str: """What action is defined by this traffic rule.""" return self.raw["action"] @property def matching_target(self) -> str: """What target is matched by this traffic rule.""" return self.raw["matching_target"] @property def target_devices(self) -> list[TargetDevice]: """What target devices are affected by this traffic rule.""" return self.raw["target_devices"]
class TrafficRule(ApiItem): '''Represent a traffic rule configuration.''' @property def id(self) -> str: '''ID of traffic rule.''' pass @property def description(self) -> str: '''Description given by user to traffic rule.''' pass @property def enabled(self) -> bool: '''Is traffic rule enabled.''' pass @property def action(self) -> str: '''What action is defined by this traffic rule.''' pass @property def matching_target(self) -> str: '''What target is matched by this traffic rule.''' pass @property def target_devices(self) -> list[TargetDevice]: '''What target devices are affected by this traffic rule.''' pass
13
7
3
0
2
1
1
0.35
1
4
1
0
6
0
6
27
34
7
20
13
7
7
14
7
7
1
5
0
6
141,219
Kane610/aiounifi
aiounifi/models/device.py
aiounifi.models.device.TypedDevicePortOverrides
class TypedDevicePortOverrides(TypedDict, total=False): """Device port overrides type definition.""" poe_mode: str port_idx: int portconf_id: str
class TypedDevicePortOverrides(TypedDict, total=False): '''Device port overrides type definition.'''
1
1
0
0
0
0
0
0.25
2
0
0
0
0
0
0
0
6
1
4
1
3
1
4
1
3
0
1
0
0
141,220
Kane610/aiounifi
aiounifi/models/wlan.py
aiounifi.models.wlan.WlanListRequest
class WlanListRequest(ApiRequest): """Request object for wlan list.""" @classmethod def create(cls) -> Self: """Create wlan list request.""" return cls(method="get", path="/rest/wlanconf")
class WlanListRequest(ApiRequest): '''Request object for wlan list.''' @classmethod def create(cls) -> Self: '''Create wlan list request.''' pass
3
2
3
0
2
1
1
0.5
1
0
0
0
0
0
1
3
7
1
4
3
1
2
3
2
1
1
1
0
1
141,221
Kane610/aiounifi
aiounifi/models/wlan.py
aiounifi.models.wlan.WlanEnableRequest
class WlanEnableRequest(ApiRequest): """Request object for wlan enable.""" @classmethod def create(cls, wlan_id: str, enable: bool) -> Self: """Create wlan enable request.""" return cls( method="put", path=f"/rest/wlanconf/{wlan_id}", data={"enabled": enable}, )
class WlanEnableRequest(ApiRequest): '''Request object for wlan enable.''' @classmethod def create(cls, wlan_id: str, enable: bool) -> Self: '''Create wlan enable request.''' pass
3
2
7
0
6
1
1
0.25
1
2
0
0
0
0
1
3
11
1
8
3
5
2
3
2
1
1
1
0
1
141,222
Kane610/aiounifi
aiounifi/models/wlan.py
aiounifi.models.wlan.WlanChangePasswordRequest
class WlanChangePasswordRequest(ApiRequest): """Request object for wlan password change.""" @classmethod def create(cls, wlan_id: str, password: str) -> Self: """Create wlan password change request.""" return cls( method="put", path=f"/rest/wlanconf/{wlan_id}", data={"x_passphrase": password}, )
class WlanChangePasswordRequest(ApiRequest): '''Request object for wlan password change.''' @classmethod def create(cls, wlan_id: str, password: str) -> Self: '''Create wlan password change request.''' pass
3
2
7
0
6
1
1
0.25
1
1
0
0
0
0
1
3
11
1
8
3
5
2
3
2
1
1
1
0
1
141,223
Kane610/aiounifi
aiounifi/models/wlan.py
aiounifi.models.wlan.Wlan
class Wlan(ApiItem): """Represent a WLAN configuration.""" raw: TypedWlan @property def id(self) -> str: """ID of WLAN.""" return self.raw["_id"] @property def bc_filter_enabled(self) -> bool: """Is BC filter enabled.""" return self.raw.get("bc_filter_enabled", False) @property def bc_filter_list(self) -> list[str]: """List of BC filters.""" return self.raw["bc_filter_list"] @property def dtim_mode(self) -> str: """DTIM mode.""" return self.raw["dtim_mode"] @property def dtim_na(self) -> int: """DTIM NA.""" return self.raw["dtim_na"] @property def dtim_ng(self) -> int: """DTIM NG.""" return self.raw["dtim_ng"] @property def enabled(self) -> bool: """Is WLAN enabled.""" return self.raw["enabled"] @property def group_rekey(self) -> int: """Group rekey.""" return self.raw["group_rekey"] @property def is_guest(self) -> bool | None: """Is WLAN a guest network.""" return self.raw.get("is_guest") @property def mac_filter_enabled(self) -> bool | None: """Is MAC filtering enabled.""" return self.raw.get("mac_filter_enabled") @property def mac_filter_list(self) -> list[str]: """List of MAC filters.""" return self.raw["mac_filter_list"] @property def mac_filter_policy(self) -> str: """MAC filter policy.""" return self.raw["mac_filter_policy"] @property def minrate_na_advertising_rates(self) -> bool: """Minrate NA advertising rates.""" return self.raw["minrate_na_advertising_rates"] @property def minrate_na_beacon_rate_kbps(self) -> int: """Minrate NA beacon rate kbps.""" return self.raw["minrate_na_beacon_rate_kbps"] @property def minrate_na_data_rate_kbps(self) -> int: """Minrate NA data rate kbps.""" return self.raw["minrate_na_data_rate_kbps"] @property def minrate_na_enabled(self) -> bool | None: """Is minrate NA enabled.""" return self.raw.get("minrate_na_enabled") @property def minrate_na_mgmt_rate_kbps(self) -> int: """Minrate NA management rate kbps.""" return self.raw["minrate_na_mgmt_rate_kbps"] @property def minrate_ng_advertising_rates(self) -> bool: """Minrate NG advertising rates.""" return self.raw["minrate_ng_advertising_rates"] @property def minrate_ng_beacon_rate_kbps(self) -> int: """Minrate NG beacon rate kbps.""" return self.raw["minrate_ng_beacon_rate_kbps"] @property def minrate_ng_cck_rates_enabled(self) -> bool | None: """Is minrate NG CCK rates enabled.""" return self.raw.get("minrate_ng_cck_rates_enabled") @property def minrate_ng_data_rate_kbps(self) -> int: """Minrate NG data rate kbps.""" return self.raw["minrate_ng_data_rate_kbps"] @property def minrate_ng_enabled(self) -> bool | None: """Is minrate NG enabled.""" return self.raw.get("minrate_ng_enabled") @property def minrate_ng_mgmt_rate_kbps(self) -> int: """Minrate NG management rate kbps.""" return self.raw["minrate_ng_mgmt_rate_kbps"] @property def name(self) -> str: """WLAN name.""" return self.raw["name"] @property def name_combine_enabled(self) -> bool | None: """If 2.5 and 5 GHz SSIDs should be combined.""" return self.raw.get("name_combine_enabled") @property def name_combine_suffix(self) -> str | None: """Suffix for 2.4GHz SSID if name is not combined.""" return self.raw.get("name_combine_suffix") @property def no2ghz_oui(self) -> bool: """No 2GHz OUI.""" return self.raw["no2ghz_oui"] @property def schedule(self) -> list[str]: """Schedule list.""" return self.raw["schedule"] @property def security(self) -> str: """Security.""" return self.raw["security"] @property def site_id(self) -> str: """WLAN site ID.""" return self.raw["site_id"] @property def usergroup_id(self) -> str: """WLAN user group ID.""" return self.raw["usergroup_id"] @property def wep_idx(self) -> int: """WEP index.""" return self.raw["wep_idx"] @property def wlangroup_id(self) -> str: """WLAN group ID.""" return self.raw["wlangroup_id"] @property def wpa_enc(self) -> str: """WPA encryption.""" return self.raw["wpa_enc"] @property def wpa_mode(self) -> str: """WPA mode.""" return self.raw["wpa_mode"] @property def x_iapp_key(self) -> str: """X iapp key.""" return self.raw["x_iapp_key"] @property def x_passphrase(self) -> str | None: """Passphrase.""" return self.raw.get("x_passphrase")
class Wlan(ApiItem): '''Represent a WLAN configuration.''' @property def id(self) -> str: '''ID of WLAN.''' pass @property def bc_filter_enabled(self) -> bool: '''Is BC filter enabled.''' pass @property def bc_filter_list(self) -> list[str]: '''List of BC filters.''' pass @property def dtim_mode(self) -> str: '''DTIM mode.''' pass @property def dtim_na(self) -> int: '''DTIM NA.''' pass @property def dtim_ng(self) -> int: '''DTIM NG.''' pass @property def enabled(self) -> bool: '''Is WLAN enabled.''' pass @property def group_rekey(self) -> int: '''Group rekey.''' pass @property def is_guest(self) -> bool | None: '''Is WLAN a guest network.''' pass @property def mac_filter_enabled(self) -> bool | None: '''Is MAC filtering enabled.''' pass @property def mac_filter_list(self) -> list[str]: '''List of MAC filters.''' pass @property def mac_filter_policy(self) -> str: '''MAC filter policy.''' pass @property def minrate_na_advertising_rates(self) -> bool: '''Minrate NA advertising rates.''' pass @property def minrate_na_beacon_rate_kbps(self) -> int: '''Minrate NA beacon rate kbps.''' pass @property def minrate_na_data_rate_kbps(self) -> int: '''Minrate NA data rate kbps.''' pass @property def minrate_na_enabled(self) -> bool | None: '''Is minrate NA enabled.''' pass @property def minrate_na_mgmt_rate_kbps(self) -> int: '''Minrate NA management rate kbps.''' pass @property def minrate_ng_advertising_rates(self) -> bool: '''Minrate NG advertising rates.''' pass @property def minrate_ng_beacon_rate_kbps(self) -> int: '''Minrate NG beacon rate kbps.''' pass @property def minrate_ng_cck_rates_enabled(self) -> bool | None: '''Is minrate NG CCK rates enabled.''' pass @property def minrate_ng_data_rate_kbps(self) -> int: '''Minrate NG data rate kbps.''' pass @property def minrate_ng_enabled(self) -> bool | None: '''Is minrate NG enabled.''' pass @property def minrate_ng_mgmt_rate_kbps(self) -> int: '''Minrate NG management rate kbps.''' pass @property def name(self) -> str: '''WLAN name.''' pass @property def name_combine_enabled(self) -> bool | None: '''If 2.5 and 5 GHz SSIDs should be combined.''' pass @property def name_combine_suffix(self) -> str | None: '''Suffix for 2.4GHz SSID if name is not combined.''' pass @property def no2ghz_oui(self) -> bool: '''No 2GHz OUI.''' pass @property def schedule(self) -> list[str]: '''Schedule list.''' pass @property def security(self) -> str: '''Security.''' pass @property def site_id(self) -> str: '''WLAN site ID.''' pass @property def usergroup_id(self) -> str: '''WLAN user group ID.''' pass @property def wep_idx(self) -> int: '''WEP index.''' pass @property def wlangroup_id(self) -> str: '''WLAN group ID.''' pass @property def wpa_enc(self) -> str: '''WPA encryption.''' pass @property def wpa_mode(self) -> str: '''WPA mode.''' pass @property def x_iapp_key(self) -> str: '''X iapp key.''' pass @property def x_passphrase(self) -> str | None: '''Passphrase.''' pass
75
38
3
0
2
1
1
0.34
1
4
0
0
37
0
37
58
189
38
113
75
38
38
76
38
38
1
5
0
37
141,224
Kane610/aiounifi
aiounifi/models/wlan.py
aiounifi.models.wlan.TypedWlan
class TypedWlan(TypedDict): """Wlan type definition.""" _id: str bc_filter_enabled: bool bc_filter_list: list[str] dtim_mode: str dtim_na: int dtim_ng: int enabled: bool group_rekey: int is_guest: NotRequired[bool] mac_filter_enabled: NotRequired[bool] mac_filter_list: list[str] mac_filter_policy: str minrate_na_advertising_rates: bool minrate_na_beacon_rate_kbps: int minrate_na_data_rate_kbps: int minrate_na_enabled: NotRequired[bool] minrate_na_mgmt_rate_kbps: int minrate_ng_advertising_rates: bool minrate_ng_beacon_rate_kbps: int minrate_ng_cck_rates_enabled: NotRequired[bool] minrate_ng_data_rate_kbps: int minrate_ng_enabled: NotRequired[bool] minrate_ng_mgmt_rate_kbps: int name: str name_combine_enabled: NotRequired[bool] name_combine_suffix: NotRequired[str] no2ghz_oui: bool schedule: list[str] security: str site_id: str usergroup_id: str wep_idx: int wlangroup_id: str wpa_enc: str wpa_mode: str x_iapp_key: str x_passphrase: NotRequired[str]
class TypedWlan(TypedDict): '''Wlan type definition.'''
1
1
0
0
0
0
0
0.03
1
0
0
0
0
0
0
0
40
1
38
1
37
1
38
1
37
0
1
0
0
141,225
Kane610/aiounifi
aiounifi/models/voucher.py
aiounifi.models.voucher.VoucherStatus
class VoucherStatus(StrEnum): """Voucher status.""" VALID_ONE = "VALID_ONE" VALID_MULTI = "VALID_MULTI" USED_MULTIPLE = "USED_MULTIPLE"
class VoucherStatus(StrEnum): '''Voucher status.''' pass
1
1
0
0
0
0
0
0.25
1
0
0
0
0
0
0
68
6
1
4
4
3
1
4
4
3
0
3
0
0
141,226
Kane610/aiounifi
aiounifi/models/voucher.py
aiounifi.models.voucher.VoucherListRequest
class VoucherListRequest(ApiRequest): """Request object for voucher list.""" @classmethod def create(cls) -> Self: """Create voucher list request.""" return cls( method="get", path="/stat/voucher", )
class VoucherListRequest(ApiRequest): '''Request object for voucher list.''' @classmethod def create(cls) -> Self: '''Create voucher list request.''' pass
3
2
6
0
5
1
1
0.29
1
0
0
0
0
0
1
3
10
1
7
3
4
2
3
2
1
1
1
0
1
141,227
Kane610/aiounifi
aiounifi/models/voucher.py
aiounifi.models.voucher.VoucherDeleteRequest
class VoucherDeleteRequest(ApiRequest): """Request object for voucher delete.""" @classmethod def create( cls, obj_id: str, ) -> Self: """Create voucher delete request.""" data = { "cmd": "delete-voucher", "_id": obj_id, } return cls( method="post", path="/cmd/hotspot", data=data, )
class VoucherDeleteRequest(ApiRequest): '''Request object for voucher delete.''' @classmethod def create( cls, obj_id: str, ) -> Self: '''Create voucher delete request.''' pass
3
2
14
0
13
1
1
0.13
1
1
0
0
0
0
1
3
18
1
15
7
9
2
4
3
2
1
1
0
1
141,228
Kane610/aiounifi
aiounifi/models/voucher.py
aiounifi.models.voucher.VoucherCreateRequest
class VoucherCreateRequest(ApiRequest): """Request object for voucher create.""" @classmethod def create( cls, expire_number: int, expire_unit: int = 1, number: int = 1, quota: int = 0, usage_quota: int | None = None, rate_max_up: int | None = None, rate_max_down: int | None = None, note: str | None = None, ) -> Self: """Create voucher create request. :param expire_number: expiration of voucher per expire_unit :param expire_unit: scale of expire_number, 1 = minute, 60 = hour, 3600 = day :param number: number of vouchers :param quota: number of using; 0 = unlimited :param usage_quota: quantity of bytes allowed in MB :param rate_max_up: up speed allowed in kbps :param rate_max_down: down speed allowed in kbps :param note: description """ data = { "cmd": "create-voucher", "n": number, "quota": quota, "expire_number": expire_number, "expire_unit": expire_unit, } if usage_quota: data["bytes"] = usage_quota if rate_max_up: data["up"] = rate_max_up if rate_max_down: data["down"] = rate_max_down if note: data["note"] = note return cls( method="post", path="/cmd/hotspot", data=data, )
class VoucherCreateRequest(ApiRequest): '''Request object for voucher create.''' @classmethod def create( cls, expire_number: int, expire_unit: int = 1, number: int = 1, quota: int = 0, usage_quota: int | None = None, rate_max_up: int | None = None, rate_max_down: int | None = None, note: str | None = None, ) -> Self: '''Create voucher create request. :param expire_number: expiration of voucher per expire_unit :param expire_unit: scale of expire_number, 1 = minute, 60 = hour, 3600 = day :param number: number of vouchers :param quota: number of using; 0 = unlimited :param usage_quota: quantity of bytes allowed in MB :param rate_max_up: up speed allowed in kbps :param rate_max_down: down speed allowed in kbps :param note: description ''' pass
3
2
43
2
31
10
5
0.33
1
2
0
0
0
0
1
3
47
3
33
14
20
11
12
3
10
5
1
1
5
141,229
Kane610/aiounifi
aiounifi/models/voucher.py
aiounifi.models.voucher.Voucher
class Voucher(ApiItem): """Represents a voucher.""" raw: TypedVoucher @property def id(self) -> str: """ID of voucher.""" return self.raw["_id"] @property def site_id(self) -> str: """Site ID.""" return self.raw["site_id"] @property def note(self) -> str: """Note given by creator to voucher.""" return self.raw.get("note") or "" @property def code(self) -> str: """Code of voucher in known format 00000-00000. To enter the code on the captive portal, the hyphen must be placed after the fifth digit. """ c = self.raw.get("code", "") # API returns the code without a hyphen. But this is necessary. Separate the API string after the fifth digit. return f"{c[:5]}-{c[5:]}" @property def quota(self) -> int: """Allowed uses (0 = unlimited) of voucher.""" return self.raw["quota"] @property def duration(self) -> timedelta: """Expiration of voucher.""" return timedelta(minutes=self.raw["duration"]) @property def qos_overwrite(self) -> bool: """Defaults for QoS overwritten by the use of this voucher.""" return self.raw.get("qos_overwrite", False) @property def qos_usage_quota(self) -> int: """Quantity of bytes (in MB) allowed when using this voucher.""" return int(self.raw.get("qos_usage_quota", 0)) @property def qos_rate_max_up(self) -> int: """Up speed (in kbps) allowed when using this voucher.""" return self.raw.get("qos_rate_max_up", 0) @property def qos_rate_max_down(self) -> int: """Down speed (in kbps) allowed when using this voucher.""" return self.raw.get("qos_rate_max_down", 0) @property def used(self) -> int: """Number of uses of this voucher.""" return self.raw["used"] @property def create_time(self) -> datetime: """Create datetime of voucher.""" return datetime.fromtimestamp(self.raw["create_time"]) @property def start_time(self) -> datetime | None: """Start datetime of first usage of voucher.""" if "start_time" in self.raw: return datetime.fromtimestamp(self.raw["start_time"]) return None @property def end_time(self) -> datetime | None: """End datetime of latest usage of voucher.""" if "end_time" in self.raw: return datetime.fromtimestamp(self.raw["end_time"]) return None @property def for_hotspot(self) -> bool: """For hotspot use.""" return self.raw.get("for_hotspot", False) @property def admin_name(self) -> str: """Creator name of voucher.""" return self.raw["admin_name"] @property def status(self) -> VoucherStatus: """Status of voucher.""" return self.raw["status"] @property def status_expires(self) -> timedelta | None: """Status expires in seconds.""" if (status_expiry := self.raw["status_expires"]) > 0: return timedelta(seconds=status_expiry) return None
class Voucher(ApiItem): '''Represents a voucher.''' @property def id(self) -> str: '''ID of voucher.''' pass @property def site_id(self) -> str: '''Site ID.''' pass @property def note(self) -> str: '''Note given by creator to voucher.''' pass @property def code(self) -> str: '''Code of voucher in known format 00000-00000. To enter the code on the captive portal, the hyphen must be placed after the fifth digit. ''' pass @property def quota(self) -> int: '''Allowed uses (0 = unlimited) of voucher.''' pass @property def duration(self) -> timedelta: '''Expiration of voucher.''' pass @property def qos_overwrite(self) -> bool: '''Defaults for QoS overwritten by the use of this voucher.''' pass @property def qos_usage_quota(self) -> int: '''Quantity of bytes (in MB) allowed when using this voucher.''' pass @property def qos_rate_max_up(self) -> int: '''Up speed (in kbps) allowed when using this voucher.''' pass @property def qos_rate_max_down(self) -> int: '''Down speed (in kbps) allowed when using this voucher.''' pass @property def used(self) -> int: '''Number of uses of this voucher.''' pass @property def create_time(self) -> datetime: '''Create datetime of voucher.''' pass @property def start_time(self) -> datetime | None: '''Start datetime of first usage of voucher.''' pass @property def end_time(self) -> datetime | None: '''End datetime of latest usage of voucher.''' pass @property def for_hotspot(self) -> bool: '''For hotspot use.''' pass @property def admin_name(self) -> str: '''Creator name of voucher.''' pass @property def status(self) -> VoucherStatus: '''Status of voucher.''' pass @property def status_expires(self) -> timedelta | None: '''Status expires in seconds.''' pass
37
19
4
0
2
1
1
0.35
1
6
1
0
18
0
18
39
105
20
63
39
26
22
45
20
26
2
5
1
21
141,230
Kane610/aiounifi
aiounifi/models/voucher.py
aiounifi.models.voucher.TypedVoucher
class TypedVoucher(TypedDict): """Voucher type definition.""" _id: str site_id: str note: NotRequired[str] code: str quota: int duration: float qos_overwrite: NotRequired[bool] qos_usage_quota: NotRequired[str] qos_rate_max_up: NotRequired[int] qos_rate_max_down: NotRequired[int] used: int create_time: float start_time: NotRequired[float] end_time: NotRequired[float] for_hotspot: NotRequired[bool] admin_name: str status: VoucherStatus status_expires: float
class TypedVoucher(TypedDict): '''Voucher type definition.'''
1
1
0
0
0
0
0
0.05
1
0
0
0
0
0
0
0
21
1
19
1
18
1
19
1
18
0
1
0
0
141,231
Kane610/aiounifi
aiounifi/models/traffic_rule.py
aiounifi.models.traffic_rule.TypedTrafficRule
class TypedTrafficRule(TypedDict): """Traffic rule type definition.""" _id: str action: str app_category_ids: list[str] app_ids: list[str] bandwidth_limit: BandwidthLimit description: str domains: list[str] enabled: bool ip_addresses: list[IPAddress] ip_ranges: list[IPRange] matching_target: str network_ids: list[str] regions: list[str] schedule: Schedule target_devices: list[TargetDevice]
class TypedTrafficRule(TypedDict): '''Traffic rule type definition.'''
1
1
0
0
0
0
0
0.06
1
0
0
0
0
0
0
0
18
1
16
1
15
1
16
1
15
0
1
0
0
141,232
Kane610/aiounifi
aiounifi/models/traffic_rule.py
aiounifi.models.traffic_rule.TrafficRuleListRequest
class TrafficRuleListRequest(ApiRequestV2): """Request object for traffic rule list.""" @classmethod def create(cls) -> Self: """Create traffic rule request.""" return cls(method="get", path="/trafficrules", data=None)
class TrafficRuleListRequest(ApiRequestV2): '''Request object for traffic rule list.''' @classmethod def create(cls) -> Self: '''Create traffic rule request.''' pass
3
2
3
0
2
1
1
0.5
1
0
0
0
0
0
1
5
7
1
4
3
1
2
3
2
1
1
2
0
1
141,233
Kane610/aiounifi
aiounifi/models/traffic_rule.py
aiounifi.models.traffic_rule.TrafficRuleEnableRequest
class TrafficRuleEnableRequest(ApiRequestV2): """Request object for traffic rule enable.""" @classmethod def create(cls, traffic_rule: TypedTrafficRule, enable: bool) -> Self: """Create traffic rule enable request.""" traffic_rule["enabled"] = enable return cls( method="put", path=f"/trafficrules/{traffic_rule['_id']}", data=traffic_rule, )
class TrafficRuleEnableRequest(ApiRequestV2): '''Request object for traffic rule enable.''' @classmethod def create(cls, traffic_rule: TypedTrafficRule, enable: bool) -> Self: '''Create traffic rule enable request.''' pass
3
2
8
0
7
1
1
0.22
1
2
1
0
0
0
1
5
12
1
9
3
6
2
4
2
2
1
2
0
1
141,234
Kane610/aiounifi
aiounifi/models/site.py
aiounifi.models.site.SiteListRequest
class SiteListRequest(ApiRequest): """Request object for site list.""" @classmethod def create(cls) -> Self: """Create site list request.""" return cls(method="get", path="/self/sites") def full_path(self, site: str, is_unifi_os: bool) -> str: """Url to list sites is global for controller.""" if is_unifi_os: return f"/proxy/network/api{self.path}" return f"/api{self.path}"
class SiteListRequest(ApiRequest): '''Request object for site list.''' @classmethod def create(cls) -> Self: '''Create site list request.''' pass def full_path(self, site: str, is_unifi_os: bool) -> str: '''Url to list sites is global for controller.''' pass
4
3
4
0
3
1
2
0.38
1
2
0
0
1
0
2
4
13
2
8
4
4
3
7
3
4
2
1
1
3
141,235
Kane610/aiounifi
aiounifi/models/site.py
aiounifi.models.site.Site
class Site(ApiItem): """Represents a network device.""" raw: TypedSite @property def site_id(self) -> str: """Site ID.""" return self.raw["_id"] @property def description(self) -> str: """Site description.""" return self.raw["desc"] @property def hidden_id(self) -> str: """Unknown.""" return self.raw["attr_hidden_id"] @property def name(self) -> str: """Site name.""" return self.raw["name"] @property def no_delete(self) -> bool: """Can not delete site.""" return self.raw["attr_no_delete"] @property def role(self) -> str: """User role.""" return self.raw["role"]
class Site(ApiItem): '''Represents a network device.''' @property def site_id(self) -> str: '''Site ID.''' pass @property def description(self) -> str: '''Site description.''' pass @property def hidden_id(self) -> str: '''Unknown.''' pass @property def name(self) -> str: '''Site name.''' pass @property def no_delete(self) -> bool: '''Can not delete site.''' pass @property def role(self) -> str: '''User role.''' pass
13
7
3
0
2
1
1
0.35
1
2
0
0
6
0
6
27
34
7
20
13
7
7
14
7
7
1
5
0
6
141,236
Kane610/aiounifi
aiounifi/models/traffic_rule.py
aiounifi.models.traffic_rule.PortRange
class PortRange(TypedDict): """Port range type definition.""" port_start: int port_stop: int
class PortRange(TypedDict): '''Port range type definition.'''
1
1
0
0
0
0
0
0.33
1
0
0
0
0
0
0
0
5
1
3
1
2
1
3
1
2
0
1
0
0
141,237
Kane610/aiounifi
aiounifi/models/port_forward.py
aiounifi.models.port_forward.PortForwardListRequest
class PortForwardListRequest(ApiRequest): """Request object for port forward list.""" @classmethod def create(cls) -> Self: """Create port forward list request.""" return cls(method="get", path="/rest/portforward")
class PortForwardListRequest(ApiRequest): '''Request object for port forward list.''' @classmethod def create(cls) -> Self: '''Create port forward list request.''' pass
3
2
3
0
2
1
1
0.5
1
0
0
0
0
0
1
3
7
1
4
3
1
2
3
2
1
1
1
0
1
141,238
Kane610/aiounifi
aiounifi/models/device.py
aiounifi.models.device.TypedDeviceUptimeStatsWan
class TypedDeviceUptimeStatsWan(TypedDict): """Device uptime stats wan type definition.""" monitors: list[TypedDeviceUptimeStatsWanMonitor]
class TypedDeviceUptimeStatsWan(TypedDict): '''Device uptime stats wan type definition.'''
1
1
0
0
0
0
0
0.5
1
0
0
0
0
0
0
0
4
1
2
1
1
1
2
1
1
0
1
0
0
141,239
Kane610/aiounifi
aiounifi/models/device.py
aiounifi.models.device.TypedDeviceUptimeStats
class TypedDeviceUptimeStats(TypedDict): """Device uptime stats type definition.""" WAN: TypedDeviceUptimeStatsWan WAN2: TypedDeviceUptimeStatsWan
class TypedDeviceUptimeStats(TypedDict): '''Device uptime stats type definition.'''
1
1
0
0
0
0
0
0.33
1
0
0
0
0
0
0
0
5
1
3
1
2
1
3
1
2
0
1
0
0
141,240
Kane610/aiounifi
aiounifi/models/device.py
aiounifi.models.device.TypedDeviceUplink
class TypedDeviceUplink(TypedDict): """Device uplink type definition.""" full_duplex: bool ip: str mac: str max_speed: int max_vlan: int media: str name: str netmask: str num_port: int rx_bytes: int rx_bytes_r: int rx_dropped: int rx_errors: int rx_multicast: int rx_packets: int speed: int tx_bytes: int tx_bytes_r: int tx_dropped: int tx_errors: int tx_packets: int type: str up: bool uplink_mac: str uplink_remote_port: int
class TypedDeviceUplink(TypedDict): '''Device uplink type definition.'''
1
1
0
0
0
0
0
0.04
1
0
0
0
0
0
0
0
28
1
26
1
25
1
26
1
25
0
1
0
0
141,241
Kane610/aiounifi
aiounifi/models/device.py
aiounifi.models.device.TypedDeviceTemperature
class TypedDeviceTemperature(TypedDict): """Device temperature type definition.""" name: str type: str value: float
class TypedDeviceTemperature(TypedDict): '''Device temperature type definition.'''
1
1
0
0
0
0
0
0.25
1
0
0
0
0
0
0
0
6
1
4
1
3
1
4
1
3
0
1
0
0
141,242
Kane610/aiounifi
aiounifi/models/device.py
aiounifi.models.device.TypedDeviceSystemStats
class TypedDeviceSystemStats(TypedDict): """Device system stats type definition.""" cpu: str mem: str uptime: str
class TypedDeviceSystemStats(TypedDict): '''Device system stats type definition.'''
1
1
0
0
0
0
0
0.25
1
0
0
0
0
0
0
0
6
1
4
1
3
1
4
1
3
0
1
0
0
141,243
Kane610/aiounifi
aiounifi/models/device.py
aiounifi.models.device.TypedDeviceSysStats
class TypedDeviceSysStats(TypedDict): """Device sys stats type definition.""" loadavg_1: str loadavg_15: str loadavg_5: str mem_buffer: int mem_total: int mem_used: int
class TypedDeviceSysStats(TypedDict): '''Device sys stats type definition.'''
1
1
0
0
0
0
0
0.14
1
0
0
0
0
0
0
0
9
1
7
1
6
1
7
1
6
0
1
0
0
141,244
Kane610/aiounifi
aiounifi/models/device.py
aiounifi.models.device.TypedDeviceSwitchCaps
class TypedDeviceSwitchCaps(TypedDict): """Device switch caps type definition.""" feature_caps: int max_aggregate_sessions: int max_mirror_sessions: int vlan_caps: int
class TypedDeviceSwitchCaps(TypedDict): '''Device switch caps type definition.'''
1
1
0
0
0
0
0
0.2
1
0
0
0
0
0
0
0
7
1
5
1
4
1
5
1
4
0
1
0
0
141,245
Kane610/aiounifi
aiounifi/models/device.py
aiounifi.models.device.TypedDeviceStorage
class TypedDeviceStorage(TypedDict): """Device storage type definition.""" mount_point: str name: str size: int type: str used: int
class TypedDeviceStorage(TypedDict): '''Device storage type definition.'''
1
1
0
0
0
0
0
0.17
1
0
0
0
0
0
0
0
8
1
6
1
5
1
6
1
5
0
1
0
0
141,246
Kane610/aiounifi
aiounifi/models/device.py
aiounifi.models.device.TypedDeviceSpeedtestStatus
class TypedDeviceSpeedtestStatus(TypedDict): """Device speedtest status type definition.""" latency: int rundate: int runtime: int status_download: int status_ping: int status_summary: int status_upload: int xput_download: float xput_upload: float
class TypedDeviceSpeedtestStatus(TypedDict): '''Device speedtest status type definition.'''
1
1
0
0
0
0
0
0.1
1
0
0
0
0
0
0
0
12
1
10
1
9
1
10
1
9
0
1
0
0
141,247
Kane610/aiounifi
aiounifi/models/device.py
aiounifi.models.device.TypedDeviceRadioTableStats
class TypedDeviceRadioTableStats(TypedDict): """Device radio table statistics type definition.""" ast_be_xmit: int ast_cst: int ast_txto: int channel: int cu_self_rx: int cu_self_tx: int cu_total: int extchannel: int gain: int guest_num_sta: int name: str num_sta: int radio: str satisfaction: int state: str tx_packets: str tx_power: str tx_retries: str user_num_sta: str
class TypedDeviceRadioTableStats(TypedDict): '''Device radio table statistics type definition.'''
1
1
0
0
0
0
0
0.05
1
0
0
0
0
0
0
0
22
1
20
1
19
1
20
1
19
0
1
0
0