MindsDB 25.8.3.0__py3-none-any.whl → 25.9.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of MindsDB might be problematic. Click here for more details.
- mindsdb/__about__.py +1 -1
- mindsdb/__main__.py +2 -44
- mindsdb/api/a2a/__init__.py +52 -0
- mindsdb/api/a2a/agent.py +11 -12
- mindsdb/api/a2a/common/server/server.py +17 -36
- mindsdb/api/a2a/common/server/task_manager.py +14 -28
- mindsdb/api/a2a/task_manager.py +20 -21
- mindsdb/api/a2a/utils.py +1 -1
- mindsdb/api/common/middleware.py +106 -0
- mindsdb/api/http/initialize.py +13 -15
- mindsdb/api/http/namespaces/auth.py +6 -14
- mindsdb/api/http/namespaces/config.py +0 -2
- mindsdb/api/http/namespaces/default.py +74 -106
- mindsdb/api/http/start.py +25 -44
- mindsdb/api/litellm/start.py +11 -10
- mindsdb/api/mcp/__init__.py +165 -0
- mindsdb/api/mysql/mysql_proxy/mysql_proxy.py +33 -64
- mindsdb/api/postgres/postgres_proxy/postgres_proxy.py +86 -85
- mindsdb/integrations/handlers/crate_handler/crate_handler.py +3 -7
- mindsdb/integrations/handlers/derby_handler/derby_handler.py +32 -34
- mindsdb/integrations/handlers/documentdb_handler/requirements.txt +1 -0
- mindsdb/integrations/handlers/dummy_data_handler/dummy_data_handler.py +12 -13
- mindsdb/integrations/handlers/google_books_handler/google_books_handler.py +45 -44
- mindsdb/integrations/handlers/google_calendar_handler/google_calendar_handler.py +101 -95
- mindsdb/integrations/handlers/google_content_shopping_handler/google_content_shopping_handler.py +129 -129
- mindsdb/integrations/handlers/google_fit_handler/google_fit_handler.py +59 -43
- mindsdb/integrations/handlers/google_search_handler/google_search_handler.py +38 -39
- mindsdb/integrations/handlers/informix_handler/informix_handler.py +5 -18
- mindsdb/integrations/handlers/maxdb_handler/maxdb_handler.py +22 -28
- mindsdb/integrations/handlers/monetdb_handler/monetdb_handler.py +3 -7
- mindsdb/integrations/handlers/mongodb_handler/mongodb_handler.py +53 -67
- mindsdb/integrations/handlers/mongodb_handler/requirements.txt +1 -0
- mindsdb/{api/mongo/utilities → integrations/handlers/mongodb_handler/utils}/mongodb_ast.py +43 -68
- mindsdb/{api/mongo/utilities → integrations/handlers/mongodb_handler/utils}/mongodb_parser.py +17 -25
- mindsdb/{api/mongo/utilities → integrations/handlers/mongodb_handler/utils}/mongodb_query.py +10 -16
- mindsdb/integrations/handlers/mongodb_handler/utils/mongodb_render.py +43 -69
- mindsdb/integrations/libs/base.py +1 -1
- mindsdb/interfaces/agents/constants.py +1 -0
- mindsdb/interfaces/knowledge_base/controller.py +3 -1
- mindsdb/utilities/config.py +3 -155
- mindsdb/utilities/log.py +0 -25
- mindsdb/utilities/starters.py +0 -39
- {mindsdb-25.8.3.0.dist-info → mindsdb-25.9.1.0.dist-info}/METADATA +263 -261
- {mindsdb-25.8.3.0.dist-info → mindsdb-25.9.1.0.dist-info}/RECORD +47 -91
- mindsdb/api/a2a/__main__.py +0 -144
- mindsdb/api/a2a/run_a2a.py +0 -86
- mindsdb/api/common/check_auth.py +0 -42
- mindsdb/api/http/gunicorn_wrapper.py +0 -17
- mindsdb/api/mcp/start.py +0 -205
- mindsdb/api/mongo/__init__.py +0 -0
- mindsdb/api/mongo/classes/__init__.py +0 -5
- mindsdb/api/mongo/classes/query_sql.py +0 -19
- mindsdb/api/mongo/classes/responder.py +0 -45
- mindsdb/api/mongo/classes/responder_collection.py +0 -34
- mindsdb/api/mongo/classes/scram.py +0 -86
- mindsdb/api/mongo/classes/session.py +0 -23
- mindsdb/api/mongo/functions/__init__.py +0 -19
- mindsdb/api/mongo/responders/__init__.py +0 -73
- mindsdb/api/mongo/responders/add_shard.py +0 -13
- mindsdb/api/mongo/responders/aggregate.py +0 -90
- mindsdb/api/mongo/responders/buildinfo.py +0 -17
- mindsdb/api/mongo/responders/coll_stats.py +0 -63
- mindsdb/api/mongo/responders/company_id.py +0 -25
- mindsdb/api/mongo/responders/connection_status.py +0 -22
- mindsdb/api/mongo/responders/count.py +0 -21
- mindsdb/api/mongo/responders/db_stats.py +0 -32
- mindsdb/api/mongo/responders/delete.py +0 -105
- mindsdb/api/mongo/responders/describe.py +0 -23
- mindsdb/api/mongo/responders/end_sessions.py +0 -13
- mindsdb/api/mongo/responders/find.py +0 -175
- mindsdb/api/mongo/responders/get_cmd_line_opts.py +0 -18
- mindsdb/api/mongo/responders/get_free_monitoring_status.py +0 -14
- mindsdb/api/mongo/responders/get_parameter.py +0 -23
- mindsdb/api/mongo/responders/getlog.py +0 -14
- mindsdb/api/mongo/responders/host_info.py +0 -28
- mindsdb/api/mongo/responders/insert.py +0 -270
- mindsdb/api/mongo/responders/is_master.py +0 -20
- mindsdb/api/mongo/responders/is_master_lower.py +0 -13
- mindsdb/api/mongo/responders/list_collections.py +0 -55
- mindsdb/api/mongo/responders/list_databases.py +0 -37
- mindsdb/api/mongo/responders/list_indexes.py +0 -22
- mindsdb/api/mongo/responders/ping.py +0 -13
- mindsdb/api/mongo/responders/recv_chunk_start.py +0 -13
- mindsdb/api/mongo/responders/replsetgetstatus.py +0 -13
- mindsdb/api/mongo/responders/sasl_continue.py +0 -34
- mindsdb/api/mongo/responders/sasl_start.py +0 -33
- mindsdb/api/mongo/responders/update_range_deletions.py +0 -12
- mindsdb/api/mongo/responders/whatsmyuri.py +0 -18
- mindsdb/api/mongo/server.py +0 -388
- mindsdb/api/mongo/start.py +0 -15
- mindsdb/api/mongo/utilities/__init__.py +0 -0
- {mindsdb-25.8.3.0.dist-info → mindsdb-25.9.1.0.dist-info}/WHEEL +0 -0
- {mindsdb-25.8.3.0.dist-info → mindsdb-25.9.1.0.dist-info}/licenses/LICENSE +0 -0
- {mindsdb-25.8.3.0.dist-info → mindsdb-25.9.1.0.dist-info}/top_level.txt +0 -0
|
@@ -19,9 +19,10 @@ logger = log.getLogger(__name__)
|
|
|
19
19
|
|
|
20
20
|
class GoogleBooksHandler(APIHandler):
|
|
21
21
|
"""
|
|
22
|
-
|
|
22
|
+
A class for handling connections and interactions with the Google Books API.
|
|
23
23
|
"""
|
|
24
|
-
|
|
24
|
+
|
|
25
|
+
name = "google_books"
|
|
25
26
|
|
|
26
27
|
def __init__(self, name: str, **kwargs):
|
|
27
28
|
"""
|
|
@@ -33,18 +34,18 @@ class GoogleBooksHandler(APIHandler):
|
|
|
33
34
|
super().__init__(name)
|
|
34
35
|
self.token = None
|
|
35
36
|
self.service = None
|
|
36
|
-
self.connection_data = kwargs.get(
|
|
37
|
-
self.credentials_file = self.connection_data.get(
|
|
37
|
+
self.connection_data = kwargs.get("connection_data", {})
|
|
38
|
+
self.credentials_file = self.connection_data.get("credentials", None)
|
|
38
39
|
self.credentials = None
|
|
39
|
-
self.scopes = [
|
|
40
|
+
self.scopes = ["https://www.googleapis.com/auth/books"]
|
|
40
41
|
self.is_connected = False
|
|
41
42
|
self.connection = None
|
|
42
43
|
bookshelves = BookshelvesTable(self)
|
|
43
44
|
self.bookshelves = bookshelves
|
|
44
|
-
self._register_table(
|
|
45
|
+
self._register_table("bookshelves", bookshelves)
|
|
45
46
|
volumes = VolumesTable(self)
|
|
46
47
|
self.volumes = volumes
|
|
47
|
-
self._register_table(
|
|
48
|
+
self._register_table("volumes", volumes)
|
|
48
49
|
|
|
49
50
|
def connect(self):
|
|
50
51
|
"""
|
|
@@ -58,18 +59,19 @@ class GoogleBooksHandler(APIHandler):
|
|
|
58
59
|
if self.is_connected is True:
|
|
59
60
|
return self.service
|
|
60
61
|
if self.credentials_file:
|
|
61
|
-
if os.path.exists(
|
|
62
|
-
self.credentials = Credentials.from_authorized_user_file(
|
|
62
|
+
if os.path.exists("token_books.json"):
|
|
63
|
+
self.credentials = Credentials.from_authorized_user_file("token_books.json", self.scopes)
|
|
63
64
|
if not self.credentials or not self.credentials.valid:
|
|
64
65
|
if self.credentials and self.credentials.expired and self.credentials.refresh_token:
|
|
65
66
|
self.credentials.refresh(Request())
|
|
66
67
|
else:
|
|
67
68
|
self.credentials = service_account.Credentials.from_service_account_file(
|
|
68
|
-
self.credentials_file, scopes=self.scopes
|
|
69
|
+
self.credentials_file, scopes=self.scopes
|
|
70
|
+
)
|
|
69
71
|
# Save the credentials for the next run
|
|
70
|
-
with open(
|
|
72
|
+
with open("token_books.json", "w") as token:
|
|
71
73
|
token.write(self.credentials.to_json())
|
|
72
|
-
self.service = build(
|
|
74
|
+
self.service = build("books", "v1", credentials=self.credentials)
|
|
73
75
|
return self.service
|
|
74
76
|
|
|
75
77
|
def check_connection(self) -> StatusResponse:
|
|
@@ -85,7 +87,7 @@ class GoogleBooksHandler(APIHandler):
|
|
|
85
87
|
self.connect()
|
|
86
88
|
response.success = True
|
|
87
89
|
except Exception as e:
|
|
88
|
-
logger.error(f
|
|
90
|
+
logger.error(f"Error connecting to Google Books API: {e}!")
|
|
89
91
|
response.error_message = e
|
|
90
92
|
|
|
91
93
|
self.is_connected = response.success
|
|
@@ -96,7 +98,7 @@ class GoogleBooksHandler(APIHandler):
|
|
|
96
98
|
Receive raw query and act upon it somehow.
|
|
97
99
|
Args:
|
|
98
100
|
query (Any): query in native format (str for sql databases,
|
|
99
|
-
|
|
101
|
+
api's json etc)
|
|
100
102
|
Returns:
|
|
101
103
|
HandlerResponse
|
|
102
104
|
"""
|
|
@@ -104,10 +106,7 @@ class GoogleBooksHandler(APIHandler):
|
|
|
104
106
|
|
|
105
107
|
df = self.call_application_api(method_name, params)
|
|
106
108
|
|
|
107
|
-
return Response(
|
|
108
|
-
RESPONSE_TYPE.TABLE,
|
|
109
|
-
data_frame=df
|
|
110
|
-
)
|
|
109
|
+
return Response(RESPONSE_TYPE.TABLE, data_frame=df)
|
|
111
110
|
|
|
112
111
|
def get_bookshelves(self, params: dict = None) -> DataFrame:
|
|
113
112
|
"""
|
|
@@ -120,35 +119,39 @@ class GoogleBooksHandler(APIHandler):
|
|
|
120
119
|
service = self.connect()
|
|
121
120
|
minShelf = None
|
|
122
121
|
maxShelf = None
|
|
123
|
-
if params[
|
|
124
|
-
shelf = int(params[
|
|
125
|
-
if params[
|
|
126
|
-
df =
|
|
127
|
-
|
|
122
|
+
if params["shelf"]:
|
|
123
|
+
shelf = int(params["shelf"])
|
|
124
|
+
if params["source"]:
|
|
125
|
+
df = (
|
|
126
|
+
service.mylibrary()
|
|
127
|
+
.bookshelves()
|
|
128
|
+
.get(shelf=shelf, userid=params["userid"], source=params["source"])
|
|
129
|
+
.execute()
|
|
130
|
+
)
|
|
128
131
|
else:
|
|
129
|
-
df = service.mylibrary().bookshelves().get(shelf=shelf, userid=params[
|
|
132
|
+
df = service.mylibrary().bookshelves().get(shelf=shelf, userid=params["userid"]).execute()
|
|
130
133
|
|
|
131
134
|
df = pd.DataFrame(df, columns=self.bookshelves.get_columns())
|
|
132
135
|
return df
|
|
133
|
-
elif not params[
|
|
134
|
-
minShelf = int(params[
|
|
135
|
-
maxShelf = int(params[
|
|
136
|
-
elif not params[
|
|
137
|
-
minShelf = int(params[
|
|
138
|
-
maxShelf = int(params[
|
|
139
|
-
elif params[
|
|
140
|
-
minShelf = int(params[
|
|
141
|
-
maxShelf = int(params[
|
|
136
|
+
elif not params["minShelf"] and params["maxShelf"]:
|
|
137
|
+
minShelf = int(params["maxShelf"]) - 10
|
|
138
|
+
maxShelf = int(params["maxShelf"])
|
|
139
|
+
elif not params["maxShelf"] and params["minShelf"]:
|
|
140
|
+
minShelf = int(params["minShelf"])
|
|
141
|
+
maxShelf = int(params["minShelf"]) + 10
|
|
142
|
+
elif params["maxShelf"] and params["minShelf"]:
|
|
143
|
+
minShelf = int(params["minShelf"])
|
|
144
|
+
maxShelf = int(params["maxShelf"])
|
|
142
145
|
|
|
143
146
|
args = {
|
|
144
|
-
key: value for key, value in params.items() if key not in [
|
|
147
|
+
key: value for key, value in params.items() if key not in ["minShelf", "maxShelf"] and value is not None
|
|
145
148
|
}
|
|
146
|
-
bookshelves = service.bookshelves().list(userid=params[
|
|
149
|
+
bookshelves = service.bookshelves().list(userid=params["userid"], **args).execute()
|
|
147
150
|
|
|
148
|
-
df = pd.DataFrame(bookshelves[
|
|
151
|
+
df = pd.DataFrame(bookshelves["items"], columns=self.bookshelves.get_columns())
|
|
149
152
|
if minShelf is not None or maxShelf is not None:
|
|
150
153
|
# Drop bookshelves that are not in the id range
|
|
151
|
-
df = df.drop(df[(df[
|
|
154
|
+
df = df.drop(df[(df["id"] < minShelf) | (df["id"] > maxShelf)].index)
|
|
152
155
|
|
|
153
156
|
return df
|
|
154
157
|
|
|
@@ -161,11 +164,9 @@ class GoogleBooksHandler(APIHandler):
|
|
|
161
164
|
DataFrame
|
|
162
165
|
"""
|
|
163
166
|
service = self.connect()
|
|
164
|
-
args = {
|
|
165
|
-
key: value for key, value in params.items() if value is not None
|
|
166
|
-
}
|
|
167
|
+
args = {key: value for key, value in params.items() if value is not None}
|
|
167
168
|
volumes = service.volumes().list(**args).execute()
|
|
168
|
-
df = pd.DataFrame(volumes[
|
|
169
|
+
df = pd.DataFrame(volumes["items"], columns=self.volumes.get_columns())
|
|
169
170
|
return df
|
|
170
171
|
|
|
171
172
|
def call_application_api(self, method_name: str = None, params: dict = None) -> DataFrame:
|
|
@@ -177,9 +178,9 @@ class GoogleBooksHandler(APIHandler):
|
|
|
177
178
|
Returns:
|
|
178
179
|
DataFrame
|
|
179
180
|
"""
|
|
180
|
-
if method_name ==
|
|
181
|
+
if method_name == "get_bookshelves":
|
|
181
182
|
return self.get_bookshelves(params)
|
|
182
|
-
elif method_name ==
|
|
183
|
+
elif method_name == "get_volumes":
|
|
183
184
|
return self.get_volumes(params)
|
|
184
185
|
else:
|
|
185
|
-
raise NotImplementedError(f
|
|
186
|
+
raise NotImplementedError(f"Unknown method {method_name}")
|
|
@@ -15,9 +15,9 @@ from mindsdb.integrations.utilities.handlers.auth_utilities.exceptions import Au
|
|
|
15
15
|
from .google_calendar_tables import GoogleCalendarEventsTable
|
|
16
16
|
|
|
17
17
|
DEFAULT_SCOPES = [
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
"https://www.googleapis.com/auth/calendar",
|
|
19
|
+
"https://www.googleapis.com/auth/calendar.events",
|
|
20
|
+
"https://www.googleapis.com/auth/calendar.readonly",
|
|
21
21
|
]
|
|
22
22
|
|
|
23
23
|
logger = log.getLogger(__name__)
|
|
@@ -25,12 +25,13 @@ logger = log.getLogger(__name__)
|
|
|
25
25
|
|
|
26
26
|
class GoogleCalendarHandler(APIHandler):
|
|
27
27
|
"""
|
|
28
|
-
|
|
28
|
+
A class for handling connections and interactions with the Google Calendar API.
|
|
29
29
|
"""
|
|
30
|
-
|
|
30
|
+
|
|
31
|
+
name = "google_calendar"
|
|
31
32
|
|
|
32
33
|
def __init__(self, name: str, **kwargs):
|
|
33
|
-
"""
|
|
34
|
+
"""constructor
|
|
34
35
|
Args:
|
|
35
36
|
name (str): the handler name
|
|
36
37
|
credentials_file (str): The path to the credentials file.
|
|
@@ -39,32 +40,32 @@ class GoogleCalendarHandler(APIHandler):
|
|
|
39
40
|
events (GoogleCalendarEventsTable): The `GoogleCalendarEventsTable` object for interacting with the events table.
|
|
40
41
|
"""
|
|
41
42
|
super().__init__(name)
|
|
42
|
-
self.connection_data = kwargs.get(
|
|
43
|
+
self.connection_data = kwargs.get("connection_data", {})
|
|
43
44
|
|
|
44
45
|
self.service = None
|
|
45
46
|
self.is_connected = False
|
|
46
47
|
|
|
47
|
-
self.handler_storage = kwargs[
|
|
48
|
+
self.handler_storage = kwargs["handler_storage"]
|
|
48
49
|
|
|
49
|
-
self.credentials_url = self.connection_data.get(
|
|
50
|
-
self.credentials_file = self.connection_data.get(
|
|
51
|
-
if self.connection_data.get(
|
|
52
|
-
self.credentials_file = self.connection_data.pop(
|
|
50
|
+
self.credentials_url = self.connection_data.get("credentials_url", None)
|
|
51
|
+
self.credentials_file = self.connection_data.get("credentials_file", None)
|
|
52
|
+
if self.connection_data.get("credentials"):
|
|
53
|
+
self.credentials_file = self.connection_data.pop("credentials")
|
|
53
54
|
if not self.credentials_file and not self.credentials_url:
|
|
54
55
|
# try to get from config
|
|
55
|
-
gcalendar_config = Config().get(
|
|
56
|
-
secret_file = gcalendar_config.get(
|
|
57
|
-
secret_url = gcalendar_config.get(
|
|
56
|
+
gcalendar_config = Config().get("handlers", {}).get("youtube", {})
|
|
57
|
+
secret_file = gcalendar_config.get("credentials_file")
|
|
58
|
+
secret_url = gcalendar_config.get("credentials_url")
|
|
58
59
|
if secret_file:
|
|
59
60
|
self.credentials_file = secret_file
|
|
60
61
|
elif secret_url:
|
|
61
62
|
self.credentials_url = secret_url
|
|
62
63
|
|
|
63
|
-
self.scopes = self.connection_data.get(
|
|
64
|
+
self.scopes = self.connection_data.get("scopes", DEFAULT_SCOPES)
|
|
64
65
|
|
|
65
66
|
events = GoogleCalendarEventsTable(self)
|
|
66
67
|
self.events = events
|
|
67
|
-
self._register_table(
|
|
68
|
+
self._register_table("events", events)
|
|
68
69
|
|
|
69
70
|
def connect(self):
|
|
70
71
|
"""
|
|
@@ -77,10 +78,16 @@ class GoogleCalendarHandler(APIHandler):
|
|
|
77
78
|
if self.is_connected is True:
|
|
78
79
|
return self.service
|
|
79
80
|
|
|
80
|
-
google_oauth2_manager = GoogleUserOAuth2Manager(
|
|
81
|
+
google_oauth2_manager = GoogleUserOAuth2Manager(
|
|
82
|
+
self.handler_storage,
|
|
83
|
+
self.scopes,
|
|
84
|
+
self.credentials_file,
|
|
85
|
+
self.credentials_url,
|
|
86
|
+
self.connection_data.get("code"),
|
|
87
|
+
)
|
|
81
88
|
creds = google_oauth2_manager.get_oauth2_credentials()
|
|
82
89
|
|
|
83
|
-
self.service = build(
|
|
90
|
+
self.service = build("calendar", "v3", credentials=creds)
|
|
84
91
|
return self.service
|
|
85
92
|
|
|
86
93
|
def check_connection(self) -> StatusResponse:
|
|
@@ -103,7 +110,7 @@ class GoogleCalendarHandler(APIHandler):
|
|
|
103
110
|
return response
|
|
104
111
|
|
|
105
112
|
except Exception as e:
|
|
106
|
-
logger.error(f
|
|
113
|
+
logger.error(f"Error connecting to Google Calendar API: {e}!")
|
|
107
114
|
response.error_message = e
|
|
108
115
|
|
|
109
116
|
self.is_connected = response.success
|
|
@@ -114,7 +121,7 @@ class GoogleCalendarHandler(APIHandler):
|
|
|
114
121
|
Receive raw query and act upon it somehow.
|
|
115
122
|
Args:
|
|
116
123
|
query (Any): query in native format (str for sql databases,
|
|
117
|
-
|
|
124
|
+
api's json etc)
|
|
118
125
|
Returns:
|
|
119
126
|
HandlerResponse
|
|
120
127
|
"""
|
|
@@ -122,10 +129,7 @@ class GoogleCalendarHandler(APIHandler):
|
|
|
122
129
|
|
|
123
130
|
df = self.call_application_api(method_name, params)
|
|
124
131
|
|
|
125
|
-
return Response(
|
|
126
|
-
RESPONSE_TYPE.TABLE,
|
|
127
|
-
data_frame=df
|
|
128
|
-
)
|
|
132
|
+
return Response(RESPONSE_TYPE.TABLE, data_frame=df)
|
|
129
133
|
|
|
130
134
|
def get_events(self, params: dict = None) -> pd.DataFrame:
|
|
131
135
|
"""
|
|
@@ -139,12 +143,12 @@ class GoogleCalendarHandler(APIHandler):
|
|
|
139
143
|
page_token = None
|
|
140
144
|
events = pd.DataFrame(columns=self.events.get_columns())
|
|
141
145
|
while True:
|
|
142
|
-
events_result = service.events().list(calendarId=
|
|
146
|
+
events_result = service.events().list(calendarId="primary", pageToken=page_token, **params).execute()
|
|
143
147
|
events = pd.concat(
|
|
144
|
-
[events, pd.DataFrame(events_result.get(
|
|
145
|
-
ignore_index=True
|
|
148
|
+
[events, pd.DataFrame(events_result.get("items", []), columns=self.events.get_columns())],
|
|
149
|
+
ignore_index=True,
|
|
146
150
|
)
|
|
147
|
-
page_token = events_result.get(
|
|
151
|
+
page_token = events_result.get("nextPageToken")
|
|
148
152
|
if not page_token:
|
|
149
153
|
break
|
|
150
154
|
return events
|
|
@@ -159,37 +163,38 @@ class GoogleCalendarHandler(APIHandler):
|
|
|
159
163
|
"""
|
|
160
164
|
service = self.connect()
|
|
161
165
|
# Check if 'attendees' is a string and split it into a list
|
|
162
|
-
if isinstance(params[
|
|
163
|
-
params[
|
|
166
|
+
if isinstance(params["attendees"], str):
|
|
167
|
+
params["attendees"] = params["attendees"].split(",")
|
|
164
168
|
|
|
165
169
|
event = {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
170
|
+
"summary": params["summary"],
|
|
171
|
+
"location": params["location"],
|
|
172
|
+
"description": params["description"],
|
|
173
|
+
"start": {
|
|
174
|
+
"dateTime": params["start"]["dateTime"],
|
|
175
|
+
"timeZone": params["start"]["timeZone"],
|
|
172
176
|
},
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
177
|
+
"end": {
|
|
178
|
+
"dateTime": params["end"]["dateTime"],
|
|
179
|
+
"timeZone": params["end"]["timeZone"],
|
|
176
180
|
},
|
|
177
|
-
|
|
178
|
-
|
|
181
|
+
"recurrence": ["RRULE:FREQ=DAILY;COUNT=1"],
|
|
182
|
+
"attendees": [
|
|
183
|
+
{"email": attendee["email"]}
|
|
184
|
+
for attendee in (
|
|
185
|
+
params["attendees"] if isinstance(params["attendees"], list) else [params["attendees"]]
|
|
186
|
+
)
|
|
179
187
|
],
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
{'method': 'email', 'minutes': 24 * 60},
|
|
186
|
-
{'method': 'popup', 'minutes': 10},
|
|
188
|
+
"reminders": {
|
|
189
|
+
"useDefault": False,
|
|
190
|
+
"overrides": [
|
|
191
|
+
{"method": "email", "minutes": 24 * 60},
|
|
192
|
+
{"method": "popup", "minutes": 10},
|
|
187
193
|
],
|
|
188
194
|
},
|
|
189
195
|
}
|
|
190
196
|
|
|
191
|
-
event = service.events().insert(calendarId=
|
|
192
|
-
body=event).execute()
|
|
197
|
+
event = service.events().insert(calendarId="primary", body=event).execute()
|
|
193
198
|
return pd.DataFrame([event], columns=self.events.get_columns())
|
|
194
199
|
|
|
195
200
|
def update_event(self, params: dict = None) -> pd.DataFrame:
|
|
@@ -201,37 +206,38 @@ class GoogleCalendarHandler(APIHandler):
|
|
|
201
206
|
DataFrame
|
|
202
207
|
"""
|
|
203
208
|
service = self.connect()
|
|
204
|
-
df = pd.DataFrame(columns=[
|
|
205
|
-
if params[
|
|
206
|
-
start_id = int(params[
|
|
209
|
+
df = pd.DataFrame(columns=["eventId", "status"])
|
|
210
|
+
if params["event_id"]:
|
|
211
|
+
start_id = int(params["event_id"])
|
|
207
212
|
end_id = start_id + 1
|
|
208
|
-
elif not params[
|
|
209
|
-
start_id = int(params[
|
|
210
|
-
elif not params[
|
|
211
|
-
end_id = int(params[
|
|
213
|
+
elif not params["start_id"]:
|
|
214
|
+
start_id = int(params["end_id"]) - 10
|
|
215
|
+
elif not params["end_id"]:
|
|
216
|
+
end_id = int(params["start_id"]) + 10
|
|
212
217
|
else:
|
|
213
|
-
start_id = int(params[
|
|
214
|
-
end_id = int(params[
|
|
218
|
+
start_id = int(params["start_id"])
|
|
219
|
+
end_id = int(params["end_id"])
|
|
215
220
|
|
|
216
221
|
for i in range(start_id, end_id):
|
|
217
|
-
event = service.events().get(calendarId=
|
|
218
|
-
if params[
|
|
219
|
-
event[
|
|
220
|
-
if params[
|
|
221
|
-
event[
|
|
222
|
-
if params[
|
|
223
|
-
event[
|
|
224
|
-
if params[
|
|
225
|
-
event[
|
|
226
|
-
event[
|
|
227
|
-
if params[
|
|
228
|
-
event[
|
|
229
|
-
event[
|
|
230
|
-
if params[
|
|
231
|
-
event[
|
|
232
|
-
updated_event = service.events().update(calendarId=
|
|
233
|
-
df = pd.concat(
|
|
234
|
-
|
|
222
|
+
event = service.events().get(calendarId="primary", eventId=i).execute()
|
|
223
|
+
if params["summary"]:
|
|
224
|
+
event["summary"] = params["summary"]
|
|
225
|
+
if params["location"]:
|
|
226
|
+
event["location"] = params["location"]
|
|
227
|
+
if params["description"]:
|
|
228
|
+
event["description"] = params["description"]
|
|
229
|
+
if params["start"]:
|
|
230
|
+
event["start"]["dateTime"] = params["start"]["dateTime"]
|
|
231
|
+
event["start"]["timeZone"] = params["start"]["timeZone"]
|
|
232
|
+
if params["end"]:
|
|
233
|
+
event["end"]["dateTime"] = params["end"]["dateTime"]
|
|
234
|
+
event["end"]["timeZone"] = params["end"]["timeZone"]
|
|
235
|
+
if params["attendees"]:
|
|
236
|
+
event["attendees"] = [{"email": attendee} for attendee in params["attendees"].split(",")]
|
|
237
|
+
updated_event = service.events().update(calendarId="primary", eventId=event["id"], body=event).execute()
|
|
238
|
+
df = pd.concat(
|
|
239
|
+
[df, pd.DataFrame([{"eventId": updated_event["id"], "status": "updated"}])], ignore_index=True
|
|
240
|
+
)
|
|
235
241
|
|
|
236
242
|
return df
|
|
237
243
|
|
|
@@ -244,21 +250,21 @@ class GoogleCalendarHandler(APIHandler):
|
|
|
244
250
|
DataFrame
|
|
245
251
|
"""
|
|
246
252
|
service = self.connect()
|
|
247
|
-
if params[
|
|
248
|
-
service.events().delete(calendarId=
|
|
249
|
-
return pd.DataFrame([{
|
|
253
|
+
if params["event_id"]:
|
|
254
|
+
service.events().delete(calendarId="primary", eventId=params["event_id"]).execute()
|
|
255
|
+
return pd.DataFrame([{"eventId": params["event_id"], "status": "deleted"}])
|
|
250
256
|
else:
|
|
251
|
-
df = pd.DataFrame(columns=[
|
|
252
|
-
if not params[
|
|
253
|
-
start_id = int(params[
|
|
254
|
-
elif not params[
|
|
255
|
-
end_id = int(params[
|
|
257
|
+
df = pd.DataFrame(columns=["eventId", "status"])
|
|
258
|
+
if not params["start_id"]:
|
|
259
|
+
start_id = int(params["end_id"]) - 10
|
|
260
|
+
elif not params["end_id"]:
|
|
261
|
+
end_id = int(params["start_id"]) + 10
|
|
256
262
|
else:
|
|
257
|
-
start_id = int(params[
|
|
258
|
-
end_id = int(params[
|
|
263
|
+
start_id = int(params["start_id"])
|
|
264
|
+
end_id = int(params["end_id"])
|
|
259
265
|
for i in range(start_id, end_id):
|
|
260
|
-
service.events().delete(calendarId=
|
|
261
|
-
df = pd.concat([df, pd.DataFrame([{
|
|
266
|
+
service.events().delete(calendarId="primary", eventId=str(i)).execute()
|
|
267
|
+
df = pd.concat([df, pd.DataFrame([{"eventId": str(i), "status": "deleted"}])], ignore_index=True)
|
|
262
268
|
return df
|
|
263
269
|
|
|
264
270
|
def call_application_api(self, method_name: str = None, params: dict = None) -> pd.DataFrame:
|
|
@@ -270,13 +276,13 @@ class GoogleCalendarHandler(APIHandler):
|
|
|
270
276
|
Returns:
|
|
271
277
|
DataFrame
|
|
272
278
|
"""
|
|
273
|
-
if method_name ==
|
|
279
|
+
if method_name == "get_events":
|
|
274
280
|
return self.get_events(params)
|
|
275
|
-
elif method_name ==
|
|
281
|
+
elif method_name == "create_event":
|
|
276
282
|
return self.create_event(params)
|
|
277
|
-
elif method_name ==
|
|
283
|
+
elif method_name == "update_event":
|
|
278
284
|
return self.update_event(params)
|
|
279
|
-
elif method_name ==
|
|
285
|
+
elif method_name == "delete_event":
|
|
280
286
|
return self.delete_event(params)
|
|
281
287
|
else:
|
|
282
|
-
raise NotImplementedError(f
|
|
288
|
+
raise NotImplementedError(f"Unknown method {method_name}")
|