'''Server======Methods described in this section relate to the server API.These methods can be accessed at ``Nessus.server``... rst-class:: hide-signature.. autoclass:: ServerAPI :members:'''fromtypingimportList,Dict,Optionalfromtyping_extensionsimportLiteralfromrestfly.utilsimportdict_cleanfromtenable.base.endpointimportAPIEndpoint
[docs]defproperties(self)->Dict:''' Retrieves the Tenable Nessus server properties. Returns: Dict: The various properties for this server. Example: >>> nessus.server.properties() '''returnself._get('properties')
[docs]defstatus(self)->Dict:''' Retrieves the current server status. Returns: Dict: The server status Example: >>> nessus.server.status() '''returnself._get('status')
[docs]defrestart(self,reason:Optional[str]=None,soft:Optional[bool]=None,unlink:Optional[bool]=None,when_idle:Optional[bool]=None)->None:''' Initiates a restart of this Tenable Nessus service Args: reason (str, optional): What is the reason for the restart to occur? soft (bool, optional): Should we only restart the web service (soft restart) or restart the whole Tenable Nessus service? unlink (bool, optional): Should the scanner be unlinked from it's upstream controller before restarting? when_idle (bool, optional): Should the scanner restart once there are no running scans? Example: >>> nessus.server.restart(reason='Time to restart', ... when_idle=True, ... soft=True ... ) '''ifsoftisnotNone:soft=str(soft).lower()ifunlinkisnotNone:unlink=str(unlink).lower()ifwhen_idleisnotNone:when_idle=str(when_idle).lower()returnself._get('restart',params=dict_clean({'reason':reason,'soft':soft,'unlink':unlink,'when_idle':when_idle}))