fix(modules/matrix): set access_token and device_id properties

This commit is contained in:
Jadyn Emma Jaeger 2022-08-24 13:43:40 +02:00
parent 70d9a47129
commit 537e65ef87
No known key found for this signature in database
GPG key ID: 632410170049FDDA

View file

@ -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()