from __future__ import annotations

from collections.abc import Mapping
from typing import Any, TypeVar

from attrs import define as _attrs_define
from attrs import field as _attrs_field

from ..models.e_agent_status import EAgentStatus
from ..models.e_discovered_computer_state import EDiscoveredComputerState
from ..models.e_discovered_entity_filters_order_column import EDiscoveredEntityFiltersOrderColumn
from ..models.e_driver_status import EDriverStatus
from ..types import UNSET, Unset

T = TypeVar("T", bound="DiscoveredEntityFilters")


@_attrs_define
class DiscoveredEntityFilters:
    """
    Attributes:
        skip (int | Unset): Number of discovered entities to skip.
        limit (int | Unset): Maximum number of discovered entities to return.
        order_column (EDiscoveredEntityFiltersOrderColumn | Unset): Sorts discovered entities by one of the parameters.
        order_asc (bool | Unset): Sorts discovered entities in ascending order by the `orderColumn` parameter.
        name_filter (str | Unset): Filters discovered entities by the `nameFilter` pattern. The pattern can match any
            parameter. To substitute one or more characters, use the asterisk (*) character at the beginning and/or at the
            end.
        ip_address_filter (str | Unset): Filters discovered entities by the `ipAddressFilter` pattern.
        state_filter (EDiscoveredComputerState | Unset): State of the discovered computer.
        agent_status_filter (EAgentStatus | Unset): Status of the Veeam Agent on a discovered computer.
        driver_status_filter (EDriverStatus | Unset): Status of the driver on a discovered computer.
    """

    skip: int | Unset = UNSET
    limit: int | Unset = UNSET
    order_column: EDiscoveredEntityFiltersOrderColumn | Unset = UNSET
    order_asc: bool | Unset = UNSET
    name_filter: str | Unset = UNSET
    ip_address_filter: str | Unset = UNSET
    state_filter: EDiscoveredComputerState | Unset = UNSET
    agent_status_filter: EAgentStatus | Unset = UNSET
    driver_status_filter: EDriverStatus | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

    def to_dict(self) -> dict[str, Any]:
        skip = self.skip

        limit = self.limit

        order_column: str | Unset = UNSET
        if not isinstance(self.order_column, Unset):
            order_column = self.order_column.value

        order_asc = self.order_asc

        name_filter = self.name_filter

        ip_address_filter = self.ip_address_filter

        state_filter: str | Unset = UNSET
        if not isinstance(self.state_filter, Unset):
            state_filter = self.state_filter.value

        agent_status_filter: str | Unset = UNSET
        if not isinstance(self.agent_status_filter, Unset):
            agent_status_filter = self.agent_status_filter.value

        driver_status_filter: str | Unset = UNSET
        if not isinstance(self.driver_status_filter, Unset):
            driver_status_filter = self.driver_status_filter.value

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if skip is not UNSET:
            field_dict["skip"] = skip
        if limit is not UNSET:
            field_dict["limit"] = limit
        if order_column is not UNSET:
            field_dict["orderColumn"] = order_column
        if order_asc is not UNSET:
            field_dict["orderAsc"] = order_asc
        if name_filter is not UNSET:
            field_dict["nameFilter"] = name_filter
        if ip_address_filter is not UNSET:
            field_dict["ipAddressFilter"] = ip_address_filter
        if state_filter is not UNSET:
            field_dict["stateFilter"] = state_filter
        if agent_status_filter is not UNSET:
            field_dict["agentStatusFilter"] = agent_status_filter
        if driver_status_filter is not UNSET:
            field_dict["driverStatusFilter"] = driver_status_filter

        return field_dict

    @classmethod
    def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
        d = dict(src_dict)
        skip = d.pop("skip", UNSET)

        limit = d.pop("limit", UNSET)

        _order_column = d.pop("orderColumn", UNSET)
        order_column: EDiscoveredEntityFiltersOrderColumn | Unset
        if isinstance(_order_column, Unset):
            order_column = UNSET
        else:
            order_column = EDiscoveredEntityFiltersOrderColumn(_order_column)

        order_asc = d.pop("orderAsc", UNSET)

        name_filter = d.pop("nameFilter", UNSET)

        ip_address_filter = d.pop("ipAddressFilter", UNSET)

        _state_filter = d.pop("stateFilter", UNSET)
        state_filter: EDiscoveredComputerState | Unset
        if isinstance(_state_filter, Unset):
            state_filter = UNSET
        else:
            state_filter = EDiscoveredComputerState(_state_filter)

        _agent_status_filter = d.pop("agentStatusFilter", UNSET)
        agent_status_filter: EAgentStatus | Unset
        if isinstance(_agent_status_filter, Unset):
            agent_status_filter = UNSET
        else:
            agent_status_filter = EAgentStatus(_agent_status_filter)

        _driver_status_filter = d.pop("driverStatusFilter", UNSET)
        driver_status_filter: EDriverStatus | Unset
        if isinstance(_driver_status_filter, Unset):
            driver_status_filter = UNSET
        else:
            driver_status_filter = EDriverStatus(_driver_status_filter)

        discovered_entity_filters = cls(
            skip=skip,
            limit=limit,
            order_column=order_column,
            order_asc=order_asc,
            name_filter=name_filter,
            ip_address_filter=ip_address_filter,
            state_filter=state_filter,
            agent_status_filter=agent_status_filter,
            driver_status_filter=driver_status_filter,
        )

        discovered_entity_filters.additional_properties = d
        return discovered_entity_filters

    @property
    def additional_keys(self) -> list[str]:
        return list(self.additional_properties.keys())

    def __getitem__(self, key: str) -> Any:
        return self.additional_properties[key]

    def __setitem__(self, key: str, value: Any) -> None:
        self.additional_properties[key] = value

    def __delitem__(self, key: str) -> None:
        del self.additional_properties[key]

    def __contains__(self, key: str) -> bool:
        return key in self.additional_properties
