From 2aef5d906202a93ee5a2b2f95f47620a5db620ce Mon Sep 17 00:00:00 2001 From: Nikhil Date: Thu, 31 Oct 2024 15:43:01 -0700 Subject: [PATCH 01/17] add support for tenant level API calls for mtt aaa --- catalystwan/api/mtt_aaa_api.py | 141 +++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) diff --git a/catalystwan/api/mtt_aaa_api.py b/catalystwan/api/mtt_aaa_api.py index c219c02b..54edf7ed 100644 --- a/catalystwan/api/mtt_aaa_api.py +++ b/catalystwan/api/mtt_aaa_api.py @@ -147,6 +147,76 @@ def get_radius(self) -> TenantRadiusServer: data = self.session.get_data(self.url_path) return create_dataclass(TenantRadiusServer, data) +class TenantLevelRadiusAPI: + """ + Class to configure tenant remote AAA RADIUS servers as tenant level users. + """ + + def __init__(self, session: ManagerSession) -> None: + self.session = session + self.url_path = "/dataservice/admin/radius" + + def __str__(self) -> str: + return str(self.session) + + @status_ok + def add_radius(self, radius_server: TenantRadiusServer): + """ + Create RADIUS server for tenant. + :param radius_server: TenantRadiusServer object containing the server configuration. + :return: True if successful, False otherwise. + """ + logger.debug("Adding RADIUS server.") + data = asdict(radius_server) # type: ignore + try: + response = self.session.post(url=self.url_path, json=data) + response.raise_for_status() + return True + except Exception as e: + logger.error(f"Error adding RADIUS server: {e}") + return False + + @status_ok + def put_radius(self, radius_server: TenantRadiusServer): + """ + Edit RADIUS server for tenant. + :param radius_server: TenantRadiusServer object containing the server configuration. + :return: True if successful, False otherwise. + """ + logger.debug("Updating RADIUS server.") + data = asdict(radius_server) # type: ignore + try: + response = self.session.put(url=self.url_path, json=data) + response.raise_for_status() + return True + except Exception as e: + logger.error(f"Error updating RADIUS server: {e}") + return False + + @status_ok + def delete_radius(self): + """ + Delete RADIUS server for tenant. + :return: True if successful, False otherwise. + """ + logger.debug("Deleting RADIUS server.") + try: + response = self.session.delete(self.url_path) + response.raise_for_status() + return True + except Exception as e: + logger.error(f"Error deleting RADIUS server: {e}") + return False + + def get_radius(self) -> TenantRadiusServer: + """ + Retrieve RADIUS server configuration for tenant. + :return: TenantRadiusServer object containing the server configuration. + """ + logger.debug("Retrieving RADIUS server configuration.") + data = self.session.get_data(self.url_path) + return create_dataclass(TenantRadiusServer, data) + class TenantTacacsAPI: """ @@ -201,3 +271,74 @@ def get_tacacs(self) -> TenantTacacsServer: logger.debug(f"TACACS config tenant_id={self.tenant_id}.") data = self.session.get_data(self.url_path) return create_dataclass(TenantTacacsServer, data) + + +class TenantLevelTacacsAPI: + """ + Class to configure tenant remote AAA TACACS servers as tenant level user. + """ + + def __init__(self, session: ManagerSession) -> None: + self.session = session + self.url_path = "/dataservice/admin/tacacs" + + def __str__(self) -> str: + return str(self.session) + + @status_ok + def add_tacacs(self, tacacs_server: TenantTacacsServer): + """ + Create TACACS server for tenant. + :param tacacs_server: TenantTacacsServer object containing the server configuration. + :return: True if successful, False otherwise. + """ + logger.debug("Adding TACACS server.") + data = asdict(tacacs_server) # type: ignore + try: + response = self.session.post(url=self.url_path, json=data) + response.raise_for_status() + return True + except Exception as e: + logger.error(f"Error adding TACACS server: {e}") + return False + + @status_ok + def put_tacacs(self, tacacs_server: TenantTacacsServer): + """ + Update TACACS server for tenant. + :param tacacs_server: TenantTacacsServer object containing the server configuration. + :return: True if successful, False otherwise. + """ + logger.debug("Updating TACACS server.") + data = asdict(tacacs_server) # type: ignore + try: + response = self.session.put(url=self.url_path, json=data) + response.raise_for_status() + return True + except Exception as e: + logger.error(f"Error updating TACACS server: {e}") + return False + + @status_ok + def delete_tacacs(self): + """ + Delete TACACS server for tenant. + :return: True if successful, False otherwise. + """ + logger.debug("Deleting TACACS server.") + try: + response = self.session.delete(self.url_path) + response.raise_for_status() + return True + except Exception as e: + logger.error(f"Error deleting TACACS server: {e}") + return False + + def get_tacacs(self) -> TenantTacacsServer: + """ + Retrieve TACACS server configuration for tenant. + :return: TenantTacacsServer object containing the server configuration. + """ + logger.debug("Retrieving TACACS server configuration.") + data = self.session.get_data(self.url_path) + return create_dataclass(TenantTacacsServer, data) \ No newline at end of file From 9dfe58dd10241a7dd9cc1f2aa477710074520faa Mon Sep 17 00:00:00 2001 From: Nikhil Date: Thu, 31 Oct 2024 15:48:32 -0700 Subject: [PATCH 02/17] add support for tenant level API calls for mtt aaa --- catalystwan/api/mtt_aaa_api.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/catalystwan/api/mtt_aaa_api.py b/catalystwan/api/mtt_aaa_api.py index 54edf7ed..6a8c9698 100644 --- a/catalystwan/api/mtt_aaa_api.py +++ b/catalystwan/api/mtt_aaa_api.py @@ -147,6 +147,7 @@ def get_radius(self) -> TenantRadiusServer: data = self.session.get_data(self.url_path) return create_dataclass(TenantRadiusServer, data) + class TenantLevelRadiusAPI: """ Class to configure tenant remote AAA RADIUS servers as tenant level users. @@ -216,7 +217,7 @@ def get_radius(self) -> TenantRadiusServer: logger.debug("Retrieving RADIUS server configuration.") data = self.session.get_data(self.url_path) return create_dataclass(TenantRadiusServer, data) - + class TenantTacacsAPI: """ @@ -341,4 +342,4 @@ def get_tacacs(self) -> TenantTacacsServer: """ logger.debug("Retrieving TACACS server configuration.") data = self.session.get_data(self.url_path) - return create_dataclass(TenantTacacsServer, data) \ No newline at end of file + return create_dataclass(TenantTacacsServer, data) From da44485181eaff8612ef6a567152317ab54c50d6 Mon Sep 17 00:00:00 2001 From: Nikhil Date: Thu, 31 Oct 2024 15:51:05 -0700 Subject: [PATCH 03/17] add support for tenant level API calls for mtt aaa --- catalystwan/api/mtt_aaa_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/catalystwan/api/mtt_aaa_api.py b/catalystwan/api/mtt_aaa_api.py index 6a8c9698..12af8bf8 100644 --- a/catalystwan/api/mtt_aaa_api.py +++ b/catalystwan/api/mtt_aaa_api.py @@ -217,7 +217,7 @@ def get_radius(self) -> TenantRadiusServer: logger.debug("Retrieving RADIUS server configuration.") data = self.session.get_data(self.url_path) return create_dataclass(TenantRadiusServer, data) - + class TenantTacacsAPI: """ From 2497f691b6ffb8c3404d77046543f8e24d367f6e Mon Sep 17 00:00:00 2001 From: Nikhil Date: Fri, 1 Nov 2024 10:30:35 -0700 Subject: [PATCH 04/17] make changes to existing classes --- catalystwan/api/mtt_aaa_api.py | 160 ++------------------------------- 1 file changed, 8 insertions(+), 152 deletions(-) diff --git a/catalystwan/api/mtt_aaa_api.py b/catalystwan/api/mtt_aaa_api.py index 12af8bf8..e19cd934 100644 --- a/catalystwan/api/mtt_aaa_api.py +++ b/catalystwan/api/mtt_aaa_api.py @@ -101,7 +101,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) @@ -113,7 +112,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) @@ -124,7 +123,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) @@ -135,7 +134,7 @@ 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: @@ -143,78 +142,7 @@ def get_radius(self) -> TenantRadiusServer: Retrieve Radius server :return: TenantRadiusServer """ - logger.debug(f"RADIUS config tenant_id={self.tenant_id}.") - data = self.session.get_data(self.url_path) - return create_dataclass(TenantRadiusServer, data) - - -class TenantLevelRadiusAPI: - """ - Class to configure tenant remote AAA RADIUS servers as tenant level users. - """ - - def __init__(self, session: ManagerSession) -> None: - self.session = session - self.url_path = "/dataservice/admin/radius" - - def __str__(self) -> str: - return str(self.session) - - @status_ok - def add_radius(self, radius_server: TenantRadiusServer): - """ - Create RADIUS server for tenant. - :param radius_server: TenantRadiusServer object containing the server configuration. - :return: True if successful, False otherwise. - """ - logger.debug("Adding RADIUS server.") - data = asdict(radius_server) # type: ignore - try: - response = self.session.post(url=self.url_path, json=data) - response.raise_for_status() - return True - except Exception as e: - logger.error(f"Error adding RADIUS server: {e}") - return False - - @status_ok - def put_radius(self, radius_server: TenantRadiusServer): - """ - Edit RADIUS server for tenant. - :param radius_server: TenantRadiusServer object containing the server configuration. - :return: True if successful, False otherwise. - """ - logger.debug("Updating RADIUS server.") - data = asdict(radius_server) # type: ignore - try: - response = self.session.put(url=self.url_path, json=data) - response.raise_for_status() - return True - except Exception as e: - logger.error(f"Error updating RADIUS server: {e}") - return False - - @status_ok - def delete_radius(self): - """ - Delete RADIUS server for tenant. - :return: True if successful, False otherwise. - """ - logger.debug("Deleting RADIUS server.") - try: - response = self.session.delete(self.url_path) - response.raise_for_status() - return True - except Exception as e: - logger.error(f"Error deleting RADIUS server: {e}") - return False - - def get_radius(self) -> TenantRadiusServer: - """ - Retrieve RADIUS server configuration for tenant. - :return: TenantRadiusServer object containing the server configuration. - """ - logger.debug("Retrieving RADIUS server configuration.") + logger.debug("RADIUS config") data = self.session.get_data(self.url_path) return create_dataclass(TenantRadiusServer, data) @@ -227,7 +155,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) @@ -239,7 +166,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) @@ -250,7 +177,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) @@ -261,7 +188,7 @@ 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: @@ -269,77 +196,6 @@ def get_tacacs(self) -> TenantTacacsServer: Retrieves Tacacs server :return: TenantTacacsServer """ - logger.debug(f"TACACS config tenant_id={self.tenant_id}.") - data = self.session.get_data(self.url_path) - return create_dataclass(TenantTacacsServer, data) - - -class TenantLevelTacacsAPI: - """ - Class to configure tenant remote AAA TACACS servers as tenant level user. - """ - - def __init__(self, session: ManagerSession) -> None: - self.session = session - self.url_path = "/dataservice/admin/tacacs" - - def __str__(self) -> str: - return str(self.session) - - @status_ok - def add_tacacs(self, tacacs_server: TenantTacacsServer): - """ - Create TACACS server for tenant. - :param tacacs_server: TenantTacacsServer object containing the server configuration. - :return: True if successful, False otherwise. - """ - logger.debug("Adding TACACS server.") - data = asdict(tacacs_server) # type: ignore - try: - response = self.session.post(url=self.url_path, json=data) - response.raise_for_status() - return True - except Exception as e: - logger.error(f"Error adding TACACS server: {e}") - return False - - @status_ok - def put_tacacs(self, tacacs_server: TenantTacacsServer): - """ - Update TACACS server for tenant. - :param tacacs_server: TenantTacacsServer object containing the server configuration. - :return: True if successful, False otherwise. - """ - logger.debug("Updating TACACS server.") - data = asdict(tacacs_server) # type: ignore - try: - response = self.session.put(url=self.url_path, json=data) - response.raise_for_status() - return True - except Exception as e: - logger.error(f"Error updating TACACS server: {e}") - return False - - @status_ok - def delete_tacacs(self): - """ - Delete TACACS server for tenant. - :return: True if successful, False otherwise. - """ - logger.debug("Deleting TACACS server.") - try: - response = self.session.delete(self.url_path) - response.raise_for_status() - return True - except Exception as e: - logger.error(f"Error deleting TACACS server: {e}") - return False - - def get_tacacs(self) -> TenantTacacsServer: - """ - Retrieve TACACS server configuration for tenant. - :return: TenantTacacsServer object containing the server configuration. - """ - logger.debug("Retrieving TACACS server configuration.") + logger.debug("TACACS config") data = self.session.get_data(self.url_path) return create_dataclass(TenantTacacsServer, data) From fd591100ee13eefacd91ecf2ee6ed4fc9359d841 Mon Sep 17 00:00:00 2001 From: Nikhil Date: Mon, 4 Nov 2024 10:50:58 -0800 Subject: [PATCH 05/17] tenant level user cannot access provider API --- catalystwan/api/mtt_aaa_api.py | 1 + 1 file changed, 1 insertion(+) diff --git a/catalystwan/api/mtt_aaa_api.py b/catalystwan/api/mtt_aaa_api.py index e19cd934..0b910ad9 100644 --- a/catalystwan/api/mtt_aaa_api.py +++ b/catalystwan/api/mtt_aaa_api.py @@ -8,6 +8,7 @@ from catalystwan.dataclasses import TenantAAA, TenantRadiusServer, TenantTacacsServer from catalystwan.exceptions import CatalystwanException from catalystwan.utils.creation_tools import asdict, create_dataclass +from catalystwan.models.tenant import TenantExport if TYPE_CHECKING: from catalystwan.session import ManagerSession From 2d24139b9fdedf7168494863c14482c1036c9c00 Mon Sep 17 00:00:00 2001 From: Nikhil Date: Mon, 4 Nov 2024 10:57:50 -0800 Subject: [PATCH 06/17] tenant level user cannot access provider API --- catalystwan/api/mtt_aaa_api.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/catalystwan/api/mtt_aaa_api.py b/catalystwan/api/mtt_aaa_api.py index 0b910ad9..44de7696 100644 --- a/catalystwan/api/mtt_aaa_api.py +++ b/catalystwan/api/mtt_aaa_api.py @@ -8,7 +8,6 @@ from catalystwan.dataclasses import TenantAAA, TenantRadiusServer, TenantTacacsServer from catalystwan.exceptions import CatalystwanException from catalystwan.utils.creation_tools import asdict, create_dataclass -from catalystwan.models.tenant import TenantExport if TYPE_CHECKING: from catalystwan.session import ManagerSession @@ -40,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 @@ -68,7 +63,7 @@ def get_aaa(self) -> TenantAAA: :param aaa: :return: """ - logger.debug(f"AAA config {self.tenant_id}.") + logger.debug(f"AAA config .") tenant_aaa = self.session.get_data(self.url_path) # return tenant_aaa return create_dataclass(TenantAAA, tenant_aaa) @@ -80,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(f"No AAA config present for Tenant") + logger.debug(f"Delete AAA config on tenant.") return self.session.delete(self.url_path) @status_ok From 015398d5cfbab9f49d89ba081e3566e220e3b8b4 Mon Sep 17 00:00:00 2001 From: Nikhil Date: Mon, 4 Nov 2024 11:01:35 -0800 Subject: [PATCH 07/17] tenant level user cannot access provider API --- catalystwan/api/mtt_aaa_api.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/catalystwan/api/mtt_aaa_api.py b/catalystwan/api/mtt_aaa_api.py index 44de7696..42563404 100644 --- a/catalystwan/api/mtt_aaa_api.py +++ b/catalystwan/api/mtt_aaa_api.py @@ -63,7 +63,7 @@ def get_aaa(self) -> TenantAAA: :param aaa: :return: """ - logger.debug(f"AAA config .") + logger.debug("AAA config .") tenant_aaa = self.session.get_data(self.url_path) # return tenant_aaa return create_dataclass(TenantAAA, tenant_aaa) @@ -75,8 +75,8 @@ def del_aaa(self): :return: """ if not self.aaa_exists(): - raise AAAConfigNotPresent(f"No AAA config present for Tenant") - logger.debug(f"Delete AAA config on tenant.") + raise AAAConfigNotPresent("No AAA config present for Tenant") + logger.debug("Delete AAA config on tenant.") return self.session.delete(self.url_path) @status_ok From f6dfcf53147257fa9b5123647f6e3564abf55221 Mon Sep 17 00:00:00 2001 From: Nikhil Date: Mon, 4 Nov 2024 11:56:30 -0800 Subject: [PATCH 08/17] tenant level user cannot access provider API --- catalystwan/api/mtt_aaa_api.py | 46 ++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/catalystwan/api/mtt_aaa_api.py b/catalystwan/api/mtt_aaa_api.py index 42563404..cf9ccbcf 100644 --- a/catalystwan/api/mtt_aaa_api.py +++ b/catalystwan/api/mtt_aaa_api.py @@ -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): """ " @@ -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) @@ -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 @@ -101,6 +109,14 @@ 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): """ @@ -108,7 +124,7 @@ def add_radius(self, radius_server: TenantRadiusServer): :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) @@ -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) @@ -130,7 +146,7 @@ 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: @@ -138,7 +154,7 @@ 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) @@ -155,6 +171,14 @@ 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): """ @@ -162,7 +186,7 @@ def add_tacacs(self, tacacs_server: TenantTacacsServer): :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) @@ -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) @@ -184,7 +208,7 @@ 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: @@ -192,6 +216,6 @@ 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) From 9d319b58ccf99874df315417d89be1fb45d987de Mon Sep 17 00:00:00 2001 From: Nikhil Date: Mon, 4 Nov 2024 12:59:58 -0800 Subject: [PATCH 09/17] tenant level user cannot access provider API --- catalystwan/api/mtt_aaa_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/catalystwan/api/mtt_aaa_api.py b/catalystwan/api/mtt_aaa_api.py index cf9ccbcf..533f647b 100644 --- a/catalystwan/api/mtt_aaa_api.py +++ b/catalystwan/api/mtt_aaa_api.py @@ -146,7 +146,7 @@ def delete_radius(self): :param radius_server: :return: True|False """ - logger.debug("Delete RADIUS config {self.tenant_org_name}") + logger.debug("Delete RADIUS config {self.tenant_org_name}") return self.session.delete(self.url_path) def get_radius(self) -> TenantRadiusServer: From 027b75f08150f8596e8e309917e786b9206ec8bf Mon Sep 17 00:00:00 2001 From: renuka Date: Wed, 6 Nov 2024 08:54:00 -0800 Subject: [PATCH 10/17] Update catalystwan/api/mtt_aaa_api.py Co-authored-by: JimOverholt <115191247+JimOverholt@users.noreply.github.com> --- catalystwan/api/mtt_aaa_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/catalystwan/api/mtt_aaa_api.py b/catalystwan/api/mtt_aaa_api.py index 533f647b..9e1cf5b7 100644 --- a/catalystwan/api/mtt_aaa_api.py +++ b/catalystwan/api/mtt_aaa_api.py @@ -71,7 +71,7 @@ def get_aaa(self) -> TenantAAA: :param aaa: :return: """ - logger.debug("AAA config {self.tenant_org_name}") + logger.debug(f"AAA config {self.tenant_org_name}") tenant_aaa = self.session.get_data(self.url_path) # return tenant_aaa return create_dataclass(TenantAAA, tenant_aaa) From 66efca1389ecee746c074d9170036889ffb1c3e5 Mon Sep 17 00:00:00 2001 From: renuka Date: Wed, 6 Nov 2024 08:54:18 -0800 Subject: [PATCH 11/17] Update catalystwan/api/mtt_aaa_api.py Co-authored-by: JimOverholt <115191247+JimOverholt@users.noreply.github.com> --- catalystwan/api/mtt_aaa_api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/catalystwan/api/mtt_aaa_api.py b/catalystwan/api/mtt_aaa_api.py index 9e1cf5b7..968e01e6 100644 --- a/catalystwan/api/mtt_aaa_api.py +++ b/catalystwan/api/mtt_aaa_api.py @@ -83,8 +83,8 @@ def del_aaa(self): :return: """ if not self.aaa_exists(): - raise AAAConfigNotPresent("No AAA config present for Tenant {self.tenant_org_name}") - logger.debug("Delete AAA config on tenant {self.tenant_org_name}") + raise AAAConfigNotPresent(f"No AAA config present for Tenant {self.tenant_org_name}") + logger.debug(f"Delete AAA config on tenant {self.tenant_org_name}") return self.session.delete(self.url_path) @status_ok From 9b9a93317bff6c63d8d549654b74534cd6410187 Mon Sep 17 00:00:00 2001 From: renuka Date: Wed, 6 Nov 2024 08:54:29 -0800 Subject: [PATCH 12/17] Update catalystwan/api/mtt_aaa_api.py Co-authored-by: JimOverholt <115191247+JimOverholt@users.noreply.github.com> --- catalystwan/api/mtt_aaa_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/catalystwan/api/mtt_aaa_api.py b/catalystwan/api/mtt_aaa_api.py index 968e01e6..b5b9335e 100644 --- a/catalystwan/api/mtt_aaa_api.py +++ b/catalystwan/api/mtt_aaa_api.py @@ -197,7 +197,7 @@ def put_tacacs(self, tacacs_server: TenantTacacsServer): :param tacacs_server: :return: """ - logger.debug("Update TACACS config {self.tenant_org_name}") + logger.debug(f"Update TACACS config {self.tenant_org_name}") data = asdict(tacacs_server) # type: ignore return self.session.put(url=self.url_path, json=data) From d840b3f87cf4d5c5928e3d6ebee1fdb599fbd236 Mon Sep 17 00:00:00 2001 From: Nikhil Date: Wed, 6 Nov 2024 10:30:16 -0800 Subject: [PATCH 13/17] add missing f-strings --- catalystwan/api/mtt_aaa_api.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/catalystwan/api/mtt_aaa_api.py b/catalystwan/api/mtt_aaa_api.py index 533f647b..13051511 100644 --- a/catalystwan/api/mtt_aaa_api.py +++ b/catalystwan/api/mtt_aaa_api.py @@ -71,7 +71,7 @@ def get_aaa(self) -> TenantAAA: :param aaa: :return: """ - logger.debug("AAA config {self.tenant_org_name}") + logger.debug(f"AAA config {self.tenant_org_name}") tenant_aaa = self.session.get_data(self.url_path) # return tenant_aaa return create_dataclass(TenantAAA, tenant_aaa) @@ -83,8 +83,8 @@ def del_aaa(self): :return: """ if not self.aaa_exists(): - raise AAAConfigNotPresent("No AAA config present for Tenant {self.tenant_org_name}") - logger.debug("Delete AAA config on tenant {self.tenant_org_name}") + raise AAAConfigNotPresent(f"No AAA config present for Tenant {self.tenant_org_name}") + logger.debug(f"Delete AAA config on tenant {self.tenant_org_name}") return self.session.delete(self.url_path) @status_ok @@ -124,7 +124,7 @@ def add_radius(self, radius_server: TenantRadiusServer): :param radius_server: :return: """ - logger.debug("Add RADIUS config {self.tenant_org_name}") + logger.debug(f"Add RADIUS config {self.tenant_org_name}") data = asdict(radius_server) # type: ignore return self.session.post(url=self.url_path, json=data) @@ -135,7 +135,7 @@ def put_radius(self, radius_server: TenantRadiusServer): :param radius_server: :return: """ - logger.debug("Update RADIUS config {self.tenant_org_name}") + logger.debug(f"Update RADIUS config {self.tenant_org_name}") data = asdict(radius_server) # type: ignore return self.session.put(url=self.url_path, json=data) @@ -146,7 +146,7 @@ def delete_radius(self): :param radius_server: :return: True|False """ - logger.debug("Delete RADIUS config {self.tenant_org_name}") + logger.debug(f"Delete RADIUS config {self.tenant_org_name}") return self.session.delete(self.url_path) def get_radius(self) -> TenantRadiusServer: @@ -154,7 +154,7 @@ def get_radius(self) -> TenantRadiusServer: Retrieve Radius server :return: TenantRadiusServer """ - logger.debug("RADIUS config {self.tenant_org_name}") + logger.debug(f"RADIUS config {self.tenant_org_name}") data = self.session.get_data(self.url_path) return create_dataclass(TenantRadiusServer, data) @@ -186,7 +186,7 @@ def add_tacacs(self, tacacs_server: TenantTacacsServer): :param tacacs_server: :return: """ - logger.debug("TACACS config {self.tenant_org_name}") + logger.debug(f"TACACS config {self.tenant_org_name}") data = asdict(tacacs_server) # type: ignore return self.session.post(url=self.url_path, json=data) @@ -197,7 +197,7 @@ def put_tacacs(self, tacacs_server: TenantTacacsServer): :param tacacs_server: :return: """ - logger.debug("Update TACACS config {self.tenant_org_name}") + logger.debug(f"Update TACACS config {self.tenant_org_name}") data = asdict(tacacs_server) # type: ignore return self.session.put(url=self.url_path, json=data) @@ -208,7 +208,7 @@ def delete_tacacs(self): :param tacacs_server: :return: True|False """ - logger.debug("Delete TACACS config {self.tenant_org_name}") + logger.debug(f"Delete TACACS config {self.tenant_org_name}") return self.session.delete(self.url_path) def get_tacacs(self) -> TenantTacacsServer: @@ -216,6 +216,6 @@ def get_tacacs(self) -> TenantTacacsServer: Retrieves Tacacs server :return: TenantTacacsServer """ - logger.debug("TACACS config {self.tenant_org_name}") + logger.debug(f"TACACS config {self.tenant_org_name}") data = self.session.get_data(self.url_path) return create_dataclass(TenantTacacsServer, data) From 069ad165096b0e336c43751380bb45d0d246701b Mon Sep 17 00:00:00 2001 From: Nikhil Date: Wed, 6 Nov 2024 10:34:37 -0800 Subject: [PATCH 14/17] it is not responsibility of that api to grab data from additional endpoint --- catalystwan/api/mtt_aaa_api.py | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/catalystwan/api/mtt_aaa_api.py b/catalystwan/api/mtt_aaa_api.py index 13051511..5c73c150 100644 --- a/catalystwan/api/mtt_aaa_api.py +++ b/catalystwan/api/mtt_aaa_api.py @@ -42,14 +42,6 @@ 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): """ " @@ -71,7 +63,7 @@ def get_aaa(self) -> TenantAAA: :param aaa: :return: """ - logger.debug(f"AAA config {self.tenant_org_name}") + logger.debug("AAA config") tenant_aaa = self.session.get_data(self.url_path) # return tenant_aaa return create_dataclass(TenantAAA, tenant_aaa) @@ -83,8 +75,8 @@ def del_aaa(self): :return: """ if not self.aaa_exists(): - raise AAAConfigNotPresent(f"No AAA config present for Tenant {self.tenant_org_name}") - logger.debug(f"Delete AAA config on tenant {self.tenant_org_name}") + raise AAAConfigNotPresent("No AAA config present for Tenant") + logger.debug("Delete AAA config on tenant") return self.session.delete(self.url_path) @status_ok @@ -124,7 +116,7 @@ def add_radius(self, radius_server: TenantRadiusServer): :param radius_server: :return: """ - logger.debug(f"Add RADIUS config {self.tenant_org_name}") + logger.debug("Add RADIUS config") data = asdict(radius_server) # type: ignore return self.session.post(url=self.url_path, json=data) @@ -135,7 +127,7 @@ def put_radius(self, radius_server: TenantRadiusServer): :param radius_server: :return: """ - logger.debug(f"Update RADIUS config {self.tenant_org_name}") + logger.debug("Update RADIUS config") data = asdict(radius_server) # type: ignore return self.session.put(url=self.url_path, json=data) @@ -146,7 +138,7 @@ def delete_radius(self): :param radius_server: :return: True|False """ - logger.debug(f"Delete RADIUS config {self.tenant_org_name}") + logger.debug("Delete RADIUS config") return self.session.delete(self.url_path) def get_radius(self) -> TenantRadiusServer: @@ -154,7 +146,7 @@ def get_radius(self) -> TenantRadiusServer: Retrieve Radius server :return: TenantRadiusServer """ - logger.debug(f"RADIUS config {self.tenant_org_name}") + logger.debug("RADIUS config") data = self.session.get_data(self.url_path) return create_dataclass(TenantRadiusServer, data) @@ -186,7 +178,7 @@ def add_tacacs(self, tacacs_server: TenantTacacsServer): :param tacacs_server: :return: """ - logger.debug(f"TACACS config {self.tenant_org_name}") + logger.debug("TACACS config") data = asdict(tacacs_server) # type: ignore return self.session.post(url=self.url_path, json=data) @@ -197,7 +189,7 @@ def put_tacacs(self, tacacs_server: TenantTacacsServer): :param tacacs_server: :return: """ - logger.debug(f"Update TACACS config {self.tenant_org_name}") + logger.debug("Update TACACS config") data = asdict(tacacs_server) # type: ignore return self.session.put(url=self.url_path, json=data) @@ -208,7 +200,7 @@ def delete_tacacs(self): :param tacacs_server: :return: True|False """ - logger.debug(f"Delete TACACS config {self.tenant_org_name}") + logger.debug("Delete TACACS config") return self.session.delete(self.url_path) def get_tacacs(self) -> TenantTacacsServer: From 1b42b800e46abf14a8c7a5aed41393e6178cae8c Mon Sep 17 00:00:00 2001 From: Nikhil Date: Wed, 6 Nov 2024 10:36:13 -0800 Subject: [PATCH 15/17] version 0.36.1 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 739703f4..7e9dc326 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 "] readme = "README.md" From 2508eead16e2efb00a0c7053949b7242c9bcba84 Mon Sep 17 00:00:00 2001 From: Nikhil Date: Wed, 6 Nov 2024 10:41:27 -0800 Subject: [PATCH 16/17] version 0.36.1 --- catalystwan/api/mtt_aaa_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/catalystwan/api/mtt_aaa_api.py b/catalystwan/api/mtt_aaa_api.py index 5c73c150..ae0cca48 100644 --- a/catalystwan/api/mtt_aaa_api.py +++ b/catalystwan/api/mtt_aaa_api.py @@ -208,6 +208,6 @@ def get_tacacs(self) -> TenantTacacsServer: Retrieves Tacacs server :return: TenantTacacsServer """ - logger.debug(f"TACACS config {self.tenant_org_name}") + logger.debug("TACACS config") data = self.session.get_data(self.url_path) return create_dataclass(TenantTacacsServer, data) From a7f74c0b6e9a26f270afe5a410698eff84415b6e Mon Sep 17 00:00:00 2001 From: Nikhil Date: Wed, 6 Nov 2024 11:09:53 -0800 Subject: [PATCH 17/17] version 0.36.1 --- catalystwan/api/mtt_aaa_api.py | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/catalystwan/api/mtt_aaa_api.py b/catalystwan/api/mtt_aaa_api.py index ae0cca48..27709435 100644 --- a/catalystwan/api/mtt_aaa_api.py +++ b/catalystwan/api/mtt_aaa_api.py @@ -101,14 +101,6 @@ 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): """ @@ -163,14 +155,6 @@ 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): """