Closed y0urself closed 3 years ago
My idea is to use a different default value then None and allow to pass None to reset e.g. a target of a task
__UNDEFINED_VALUE = -1
def modify_task(
self,
task_id: str,
*,
name: Optional[str] = None,
config_id: Optional[str] = __UNDEFINED_VALUE,
target_id: Optional[str] = __UNDEFINED_VALUE,
scanner_id: Optional[str] = __UNDEFINED_VALUE,
alterable: Optional[bool] = None,
hosts_ordering: Optional[HostsOrdering] = None,
schedule_id: Optional[str] = __UNDEFINED_VALUE,
schedule_periods: Optional[int] = None,
comment: Optional[str] = None,
alert_ids: Optional[List[str]] = None,
observers: Optional[List[str]] = None,
preferences: Optional[dict] = None
) -> Any
if target_id is None:
cmd.add_element("target", attrs={"id": "0"}) # not sure about "0"
elif target_id and target_id != __UNDEFINED_VALUE:
cmd.add_element("target", attrs={"id": target_id})
This issue is not existing at all ... we support removals as Björn mentioned in his comment. Just pass the "0" as ID ...
It seems to be impossible to remove a certain field of an entity in the modify functions. See this Issue for more information ...
Expected behaviour
Remove the Field from the Entity.
Current behaviour
Treated as
None
, what leads to remain the Field untouched in that Entity.Steps to reproduce
gmp.modify_task(task_id=id, schedule_id="")
will be treated asNone
gmp.modify_task(task_id=id)
will be treated asNone
GVM versions
all?!
Environment
Operating system: all
Installation method / source: (packages, source installation) all