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

Commit

Permalink
tenant level user cannot access provider API
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilkp93 committed Nov 4, 2024
1 parent 015398d commit f6dfcf5
Showing 1 changed file with 35 additions and 11 deletions.
46 changes: 35 additions & 11 deletions catalystwan/api/mtt_aaa_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ def __str__(self) -> str:
def aaa_exists(self) -> bool:
return True if self.session.get_data(self.url_path) else False

@property
def tenant_org_name(self):
"""
Get the tenant org name
:return:
"""
return self.endpoints.configuration_settings.get_organizations().first().org

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

@status_ok
Expand All @@ -101,14 +109,22 @@ def __init__(self, session: ManagerSession) -> None:
def __str__(self) -> str:
return str(self.session)

@property
def tenant_org_name(self):
"""
Get the tenant org name
:return:
"""
return self.endpoints.configuration_settings.get_organizations().first().org

@status_ok
def add_radius(self, radius_server: TenantRadiusServer):
"""
Create RADIUS for tenant
:param radius_server:
:return:
"""
logger.debug("Add RADIUS config")
logger.debug("Add RADIUS config {self.tenant_org_name}")
data = asdict(radius_server) # type: ignore
return self.session.post(url=self.url_path, json=data)

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

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

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

Expand All @@ -155,14 +171,22 @@ def __init__(self, session: ManagerSession) -> None:
def __str__(self) -> str:
return str(self.session)

@property
def tenant_org_name(self):
"""
Get the tenant org name
:return:
"""
return self.endpoints.configuration_settings.get_organizations().first().org

@status_ok
def add_tacacs(self, tacacs_server: TenantTacacsServer):
"""
Create TACACS for tenant
:param tacacs_server:
:return:
"""
logger.debug("TACACS config")
logger.debug("TACACS config {self.tenant_org_name}")
data = asdict(tacacs_server) # type: ignore
return self.session.post(url=self.url_path, json=data)

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

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

def get_tacacs(self) -> TenantTacacsServer:
"""
Retrieves Tacacs server
:return: TenantTacacsServer
"""
logger.debug("TACACS config")
logger.debug("TACACS config {self.tenant_org_name}")
data = self.session.get_data(self.url_path)
return create_dataclass(TenantTacacsServer, data)

0 comments on commit f6dfcf5

Please sign in to comment.