mirror of
https://github.com/famedly/ansible-collection-matrix
synced 2024-12-12 12:22:26 +00:00
fix(modules/matrix): set access_token and device_id properties
This commit is contained in:
parent
70d9a47129
commit
537e65ef87
1 changed files with 10 additions and 4 deletions
|
@ -8,6 +8,7 @@ from __future__ import absolute_import, division, print_function
|
|||
__metaclass__ = type
|
||||
|
||||
import traceback
|
||||
from typing import Union
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||
|
||||
|
@ -125,10 +126,7 @@ class AnsibleNioModule:
|
|||
login_response = await self.client.login(
|
||||
password=self.module.params.get("password")
|
||||
)
|
||||
if isinstance(login_response, LoginResponse):
|
||||
self.access_token = login_response.access_token
|
||||
self.device_id = login_response.device_id
|
||||
else:
|
||||
if not isinstance(login_response, LoginResponse):
|
||||
result = {
|
||||
"msg": login_response.message,
|
||||
"http_status_code": login_response.status_code,
|
||||
|
@ -138,6 +136,14 @@ class AnsibleNioModule:
|
|||
self.client = AsyncClient(self.module.params.get("hs_url"))
|
||||
self.client.access_token = self.module.params.get("token")
|
||||
|
||||
@property
|
||||
def access_token(self) -> str:
|
||||
return self.client.access_token
|
||||
|
||||
@property
|
||||
def device_id(self) -> Union[str, None]:
|
||||
return self.client.device_id
|
||||
|
||||
async def matrix_logout(self):
|
||||
if self.client.logged_in:
|
||||
request = await self.client.logout()
|
||||
|
|
Loading…
Reference in a new issue