Skip to content

Commit

Permalink
IDview
Browse files Browse the repository at this point in the history
Signed-off-by: Madhuri Upadhye <[email protected]>
  • Loading branch information
madhuriupadhye committed Jan 16, 2025
1 parent ebd77c8 commit ee485c4
Showing 1 changed file with 79 additions and 0 deletions.
79 changes: 79 additions & 0 deletions sssd_test_framework/roles/ipa.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,8 @@ def test_example(client: Client, ipa: IPA):
"""
return IPASudoRule(self, name)

def idview(self, name:str) -> IPAIdView:
return IPAIdView(self, name)

class IPAObject(BaseObject[IPAHost, IPA]):
"""
Expand Down Expand Up @@ -1597,3 +1599,80 @@ def __get_info(self, info: str | NFSExport | IPAAutomountMap | None) -> str | No
return info.name

return info

class IPAIdView(IPAObject):
"""
IPA id view management.
"""

def __init__(self, role:IPA, name:str) -> None:
super().__init__(role, name, command_group="idview")

def add(self,
*,
description: str | None = None,
) -> IPAIdView:
"""
Create new IPA ID view.
:return: Self.
:rtype: IPAIdView
"""
attrs: CLIBuilderArgs = {
"desc": (self.cli.option.VALUE, description),
}

self._add(attrs)
return self

def find(self) -> IPAIdView:
"""
Search IPA ID view.
:return: Self.
:rtype: IPAIdView
"""
self.get(self.cli.option.VALUE)
#self.__getattribute__(__name=self.cli.option.VALUE)
#self._exec("find", self.cli.args(attrs))
return self

def modify(
self,
*,
description: str | None = None,
) -> IPAIdView:
"""
Modify existing IPA ID view.
Parameters that are not set are ignored.
:param description: Description, defaults to None
:type description: str | None, optional
:return: Self.
:rtype: IPAIdView
"""
attrs: CLIBuilderArgs = {
"desc": (self.cli.option.VALUE, description),
}

self._modify(attrs)
return self

def apply(self, *, hosts: list[str] | None = None, hostgroups: str | None = None) -> IPAIdView:
"""
:param hosts:
:return:
"""
if not hosts and not hostgroups:
raise ValueError(
"Either 'hosts' or 'hostgroups' must be provided.")

attrs: CLIBuilderArgs = {}
if hosts:
attrs["hosts"] = (self.cli.option.VALUE, hosts)
if hostgroups:
attrs["hostgroups"] = (self.cli.option.VALUE, hostgroups)

self._exec("apply", self.cli.args(attrs))
return self

0 comments on commit ee485c4

Please sign in to comment.