mirror of
https://github.com/famedly/ansible-collection-matrix
synced 2025-03-04 14:47:18 +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
|
__metaclass__ = type
|
||||||
|
|
||||||
import traceback
|
import traceback
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||||
|
|
||||||
|
@ -125,10 +126,7 @@ class AnsibleNioModule:
|
||||||
login_response = await self.client.login(
|
login_response = await self.client.login(
|
||||||
password=self.module.params.get("password")
|
password=self.module.params.get("password")
|
||||||
)
|
)
|
||||||
if isinstance(login_response, LoginResponse):
|
if not isinstance(login_response, LoginResponse):
|
||||||
self.access_token = login_response.access_token
|
|
||||||
self.device_id = login_response.device_id
|
|
||||||
else:
|
|
||||||
result = {
|
result = {
|
||||||
"msg": login_response.message,
|
"msg": login_response.message,
|
||||||
"http_status_code": login_response.status_code,
|
"http_status_code": login_response.status_code,
|
||||||
|
@ -138,6 +136,14 @@ class AnsibleNioModule:
|
||||||
self.client = AsyncClient(self.module.params.get("hs_url"))
|
self.client = AsyncClient(self.module.params.get("hs_url"))
|
||||||
self.client.access_token = self.module.params.get("token")
|
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):
|
async def matrix_logout(self):
|
||||||
if self.client.logged_in:
|
if self.client.logged_in:
|
||||||
request = await self.client.logout()
|
request = await self.client.logout()
|
||||||
|
|
Loading…
Add table
Reference in a new issue