'''Session=======Methods described in this section relate to the session API.These methods can be accessed at ``Nessus.session``... rst-class:: hide-signature.. autoclass:: SessionAPI :members:'''fromtypingimportDict,Optionalfromrestfly.utilsimportdict_cleanfromtenable.base.endpointimportAPIEndpoint
[docs]defget(self)->Dict:''' Returns the current user's session data Returns: Dict: The session details dictionary Example: >>> nessus.session.get() '''returnself._get()
[docs]defchpasswd(self,current_password,new_password)->None:''' Updated the current user's password. Args: current_password (str): The user's current password new_password (str): The new password for the user Example: >>> nessus.session.chpasswd('old_pass', 'new_pass') '''self._put('chpasswd',json={'password':new_password,'current_password':current_password})
[docs]defapi_keys(self)->Dict:''' Generates a new API key pair for the current user. The API Keys for the current session will also be updated if the auth mechanism is api keys Returns: Dict: The newly generated keypair for the user. Example: >>> nessus.session.api_keys() '''keys=self._put('keys')ifself._api._auth_mech=='keys':self._api._key_auth(keys['accessKey'],keys['secretKey'])returnkeys
[docs]defedit(self,name:Optional[str]=None,email:Optional[str]=None)->None:''' Updates the current user's settings. Args: name (str, optional): Updated name for the user email (str, optional): Updated email for the user Example: >>> nessus.session.edit(email='user@name.com') '''self._put(json=dict_clean({'name':name,'email':email}))