From e8b538dde7a087bde8df48f02b1ccf90577e2ff5 Mon Sep 17 00:00:00 2001 From: Rahul Date: Thu, 2 Nov 2023 18:08:46 +0530 Subject: [PATCH 1/2] add methods to get and clear notifications on workspace & project levels --- aryaxai/common/xai_uris.py | 2 ++ aryaxai/core/project.py | 31 +++++++++++++++++++++++++++++++ aryaxai/core/workspace.py | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+) diff --git a/aryaxai/common/xai_uris.py b/aryaxai/common/xai_uris.py index c4fbd94..8e7728d 100644 --- a/aryaxai/common/xai_uris.py +++ b/aryaxai/common/xai_uris.py @@ -8,6 +8,8 @@ # User GET_WORKSPACES_URI = f"{API_VERSION}/users/workspaces" CREATE_WORKSPACE_URI = f"{API_VERSION}/users/create_workspace" +GET_NOTIFICATIONS_URI = f"{API_VERSION}/users/notifications" +CLEAR_NOTIFICATIONS_URI = f"{API_VERSION}/users/clear-notifications" # Workspace UPDATE_WORKSPACE_URI = f"{API_VERSION}/users/workspace_config_update" diff --git a/aryaxai/core/project.py b/aryaxai/core/project.py index 091a0e2..60d378d 100644 --- a/aryaxai/core/project.py +++ b/aryaxai/core/project.py @@ -34,6 +34,7 @@ ALL_DATA_FILE_URI, AVAILABLE_TAGS_URI, CASE_INFO_URI, + CLEAR_NOTIFICATIONS_URI, CREATE_TRIGGER_URI, DATA_DRFIT_DIAGNOSIS_URI, DELETE_CASE_URI, @@ -48,6 +49,7 @@ GET_LABELS_URI, GET_MODEL_PERFORMANCE_URI, GET_MODELS_URI, + GET_NOTIFICATIONS_URI, GET_PROJECT_CONFIG, MODEL_PARAMETERS_URI, MODEL_SUMMARY_URI, @@ -1625,6 +1627,35 @@ def delete_cases( raise Exception(res["details"]) return res["details"] + + def get_notifications(self) -> pd.DataFrame: + """get user project notifications + + :return: DataFrame + """ + url = f"{GET_NOTIFICATIONS_URI}?project_name={self.project_name}" + + res = self.__api_client.get(url) + + if not res["success"]: + raise Exception("Error while getting project notifications.") + + return pd.DataFrame(res["details"]) + + def clear_notifications(self) -> str: + """clear user project notifications + + :raises Exception: _description_ + :return: str + """ + url = f"{CLEAR_NOTIFICATIONS_URI}?project_name={self.project_name}" + + res = self.__api_client.post(url) + + if not res['success']: + raise Exception('Error while clearing project notifications.') + + return res['details'] def __print__(self) -> str: return f"Project(user_project_name='{self.user_project_name}', created_by='{self.created_by}')" diff --git a/aryaxai/core/workspace.py b/aryaxai/core/workspace.py index edd8a0c..8e6b69f 100644 --- a/aryaxai/core/workspace.py +++ b/aryaxai/core/workspace.py @@ -1,3 +1,4 @@ +import pandas as pd from pydantic import BaseModel from typing import List from aryaxai.client.client import APIClient @@ -6,6 +7,8 @@ CREATE_PROJECT_URI, GET_WORKSPACES_URI, UPDATE_WORKSPACE_URI, + GET_NOTIFICATIONS_URI, + CLEAR_NOTIFICATIONS_URI ) from aryaxai.core.project import Project @@ -158,6 +161,35 @@ def create_project(self, project_name: str) -> Project: project = Project(api_client=self.__api_client, **res["details"]) return project + + def get_notifications(self) -> pd.DataFrame: + """get user project notifications + + :return: DataFrame + """ + url = f"{GET_NOTIFICATIONS_URI}?workspace_name={self.workspace_name}" + + res = self.__api_client.get(url) + + if not res["success"]: + raise Exception("Error while getting project notifications.") + + return pd.DataFrame(res["details"]) + + def clear_notifications(self) -> str: + """clear user project notifications + + :raises Exception: _description_ + :return: str + """ + url = f"{CLEAR_NOTIFICATIONS_URI}?workspace_name={self.workspace_name}" + + res = self.__api_client.post(url) + + if not res['success']: + raise Exception('Error while clearing project notifications.') + + return res['details'] def __print__(self) -> str: return f"Workspace(user_workspace_name='{self.user_workspace_name}', created_by='{self.created_by}', created_at='{self.created_at}')" From a078996ef69206cfb8d02bfbe94b0b2cfee1d55d Mon Sep 17 00:00:00 2001 From: Rahul Date: Fri, 3 Nov 2023 13:45:50 +0530 Subject: [PATCH 2/2] add notification methods at xai/user level --- aryaxai/core/workspace.py | 8 ++++---- aryaxai/core/xai.py | 28 +++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/aryaxai/core/workspace.py b/aryaxai/core/workspace.py index 8e6b69f..71e5757 100644 --- a/aryaxai/core/workspace.py +++ b/aryaxai/core/workspace.py @@ -163,7 +163,7 @@ def create_project(self, project_name: str) -> Project: return project def get_notifications(self) -> pd.DataFrame: - """get user project notifications + """get user workspace notifications :return: DataFrame """ @@ -172,12 +172,12 @@ def get_notifications(self) -> pd.DataFrame: res = self.__api_client.get(url) if not res["success"]: - raise Exception("Error while getting project notifications.") + raise Exception("Error while getting workspace notifications.") return pd.DataFrame(res["details"]) def clear_notifications(self) -> str: - """clear user project notifications + """clear user workspace notifications :raises Exception: _description_ :return: str @@ -187,7 +187,7 @@ def clear_notifications(self) -> str: res = self.__api_client.post(url) if not res['success']: - raise Exception('Error while clearing project notifications.') + raise Exception('Error while clearing workspace notifications.') return res['details'] diff --git a/aryaxai/core/xai.py b/aryaxai/core/xai.py index 4e99df2..e6564ea 100644 --- a/aryaxai/core/xai.py +++ b/aryaxai/core/xai.py @@ -1,9 +1,10 @@ import os +import pandas as pd from pydantic import BaseModel from aryaxai.client.client import APIClient from aryaxai.common.environment import Environment -from aryaxai.common.xai_uris import CREATE_WORKSPACE_URI, LOGIN_URI, GET_WORKSPACES_URI +from aryaxai.common.xai_uris import CLEAR_NOTIFICATIONS_URI, CREATE_WORKSPACE_URI, GET_NOTIFICATIONS_URI, LOGIN_URI, GET_WORKSPACES_URI import getpass from typing import List @@ -97,3 +98,28 @@ def create_workspace(self, workspace_name: str) -> Workspace: workspace = Workspace(api_client=self.__api_client, **res["workspace_details"]) return workspace + + def get_notifications(self) -> pd.DataFrame: + """get user notifications + + :return: DataFrame + """ + res = self.__api_client.get(GET_NOTIFICATIONS_URI) + + if not res["success"]: + raise Exception("Error while getting user notifications.") + + return pd.DataFrame(res["details"]) + + def clear_notifications(self) -> str: + """clear user notifications + + :raises Exception: _description_ + :return: str + """ + res = self.__api_client.post(CLEAR_NOTIFICATIONS_URI) + + if not res['success']: + raise Exception('Error while clearing user notifications.') + + return res['details'] \ No newline at end of file