Skip to content

Commit

Permalink
feat: add DictModel.items(). (#257)
Browse files Browse the repository at this point in the history
  • Loading branch information
pederhan authored Nov 26, 2024
1 parent 4a3c043 commit 8b8ed4c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions zabbix_cli/pyzabbix/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from typing import TYPE_CHECKING
from typing import Any
from typing import Dict
from typing import Iterable
from typing import List
from typing import MutableMapping
from typing import Optional
Expand Down Expand Up @@ -409,11 +410,12 @@ class DictModel(ZabbixAPIBaseModel):

model_config = ConfigDict(extra="allow")

def items(self) -> Iterable[tuple[str, Any]]:
return self.model_dump(mode="python").items()

def __cols_rows__(self) -> ColsRowsType:
cols = ["Key", "Value"]
rows: RowsType = [
[key, str(value)] for key, value in self.model_dump().items() if value
]
rows: RowsType = [[key, str(value)] for key, value in self.items() if value]
return cols, rows


Expand Down

0 comments on commit 8b8ed4c

Please sign in to comment.