Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Commit

Permalink
Merge pull request #850 from cisco-open/tenantlevelapi
Browse files Browse the repository at this point in the history
add support for tenant level user to make API calls for mtt aaa
  • Loading branch information
nikhilkp93 authored Nov 6, 2024
2 parents b4916c5 + a7f74c0 commit 91e941f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
28 changes: 11 additions & 17 deletions catalystwan/api/mtt_aaa_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ def __init__(self, session: ManagerSession) -> None:
def __str__(self) -> str:
return str(self.session)

@property
def tenant_id(self):
return self.session.get_tenant_id()

def aaa_exists(self) -> bool:
return True if self.session.get_data(self.url_path) else False

Expand All @@ -67,7 +63,7 @@ def get_aaa(self) -> TenantAAA:
:param aaa:
:return:
"""
logger.debug(f"AAA config {self.tenant_id}.")
logger.debug("AAA config")
tenant_aaa = self.session.get_data(self.url_path)
# return tenant_aaa
return create_dataclass(TenantAAA, tenant_aaa)
Expand All @@ -79,8 +75,8 @@ def del_aaa(self):
:return:
"""
if not self.aaa_exists():
raise AAAConfigNotPresent(f"No AAA config present for Tenant id={self.tenant_id}")
logger.debug(f"Delete AAA config on tenant_id={self.tenant_id}.")
raise AAAConfigNotPresent("No AAA config present for Tenant")
logger.debug("Delete AAA config on tenant")
return self.session.delete(self.url_path)

@status_ok
Expand All @@ -101,7 +97,6 @@ class TenantRadiusAPI:
def __init__(self, session: ManagerSession) -> None:
self.session = session
self.url_path = "/dataservice/admin/radius"
self.tenant_id = self.session.get_tenant_id()

def __str__(self) -> str:
return str(self.session)
Expand All @@ -113,7 +108,7 @@ def add_radius(self, radius_server: TenantRadiusServer):
:param radius_server:
:return:
"""
logger.debug(f"Add RADIUS config tenant_id={self.tenant_id}.")
logger.debug("Add RADIUS config")
data = asdict(radius_server) # type: ignore
return self.session.post(url=self.url_path, json=data)

Expand All @@ -124,7 +119,7 @@ def put_radius(self, radius_server: TenantRadiusServer):
:param radius_server:
:return:
"""
logger.debug(f"Update RADIUS config tenant_id={self.tenant_id}.")
logger.debug("Update RADIUS config")
data = asdict(radius_server) # type: ignore
return self.session.put(url=self.url_path, json=data)

Expand All @@ -135,15 +130,15 @@ def delete_radius(self):
:param radius_server:
:return: True|False
"""
logger.debug(f"Delete RADIUS config tenant_id={self.tenant_id}.")
logger.debug("Delete RADIUS config")
return self.session.delete(self.url_path)

def get_radius(self) -> TenantRadiusServer:
"""
Retrieve Radius server
:return: TenantRadiusServer
"""
logger.debug(f"RADIUS config tenant_id={self.tenant_id}.")
logger.debug("RADIUS config")
data = self.session.get_data(self.url_path)
return create_dataclass(TenantRadiusServer, data)

Expand All @@ -156,7 +151,6 @@ class TenantTacacsAPI:
def __init__(self, session: ManagerSession) -> None:
self.session = session
self.url_path = "/dataservice/admin/tacacs"
self.tenant_id = self.session.get_tenant_id()

def __str__(self) -> str:
return str(self.session)
Expand All @@ -168,7 +162,7 @@ def add_tacacs(self, tacacs_server: TenantTacacsServer):
:param tacacs_server:
:return:
"""
logger.debug(f"TACACS config tenant_id={self.tenant_id}.")
logger.debug("TACACS config")
data = asdict(tacacs_server) # type: ignore
return self.session.post(url=self.url_path, json=data)

Expand All @@ -179,7 +173,7 @@ def put_tacacs(self, tacacs_server: TenantTacacsServer):
:param tacacs_server:
:return:
"""
logger.debug(f"Update TACACS config tenant_id={self.tenant_id}.")
logger.debug("Update TACACS config")
data = asdict(tacacs_server) # type: ignore
return self.session.put(url=self.url_path, json=data)

Expand All @@ -190,14 +184,14 @@ def delete_tacacs(self):
:param tacacs_server:
:return: True|False
"""
logger.debug(f"Delete TACACS config tenant_id={self.tenant_id}.")
logger.debug("Delete TACACS config")
return self.session.delete(self.url_path)

def get_tacacs(self) -> TenantTacacsServer:
"""
Retrieves Tacacs server
:return: TenantTacacsServer
"""
logger.debug(f"TACACS config tenant_id={self.tenant_id}.")
logger.debug("TACACS config")
data = self.session.get_data(self.url_path)
return create_dataclass(TenantTacacsServer, data)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "catalystwan"
version = "0.36.0"
version = "0.36.1"
description = "Cisco Catalyst WAN SDK for Python"
authors = ["kagorski <[email protected]>"]
readme = "README.md"
Expand Down

0 comments on commit 91e941f

Please sign in to comment.