universal-mcp-applications 0.1.22__py3-none-any.whl → 0.1.33__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 universal-mcp-applications might be problematic. Click here for more details.
- universal_mcp/applications/browser_use/app.py +14 -19
- universal_mcp/applications/google_docs/app.py +363 -289
- universal_mcp/applications/google_gemini/app.py +3 -3
- universal_mcp/applications/google_sheet/app.py +6 -2
- universal_mcp/applications/linkedin/README.md +18 -4
- universal_mcp/applications/linkedin/app.py +754 -153
- universal_mcp/applications/onedrive/README.md +24 -0
- universal_mcp/applications/onedrive/__init__.py +1 -0
- universal_mcp/applications/onedrive/app.py +338 -0
- universal_mcp/applications/outlook/app.py +281 -199
- universal_mcp/applications/reddit/app.py +30 -47
- universal_mcp/applications/scraper/README.md +7 -4
- universal_mcp/applications/scraper/app.py +310 -290
- universal_mcp/applications/sharepoint/README.md +16 -14
- universal_mcp/applications/sharepoint/app.py +267 -154
- universal_mcp/applications/slack/app.py +31 -0
- universal_mcp/applications/zenquotes/app.py +2 -2
- {universal_mcp_applications-0.1.22.dist-info → universal_mcp_applications-0.1.33.dist-info}/METADATA +2 -2
- {universal_mcp_applications-0.1.22.dist-info → universal_mcp_applications-0.1.33.dist-info}/RECORD +21 -21
- universal_mcp/applications/unipile/README.md +0 -28
- universal_mcp/applications/unipile/__init__.py +0 -1
- universal_mcp/applications/unipile/app.py +0 -1077
- {universal_mcp_applications-0.1.22.dist-info → universal_mcp_applications-0.1.33.dist-info}/WHEEL +0 -0
- {universal_mcp_applications-0.1.22.dist-info → universal_mcp_applications-0.1.33.dist-info}/licenses/LICENSE +0 -0
|
@@ -11,18 +11,18 @@ class GoogleDocsApp(APIApplication):
|
|
|
11
11
|
|
|
12
12
|
def create_document(self, title: str) -> dict[str, Any]:
|
|
13
13
|
"""
|
|
14
|
-
Creates a blank Google Document with a specified title
|
|
15
|
-
|
|
14
|
+
Creates a blank Google Document with a specified title by sending a POST request to the Google Docs API. The function returns a dictionary containing the new document's metadata, including the unique document ID required by other functions for subsequent modifications or retrieval. Note that you need to call other google_docs functions (e.g. `google_docs__insert_text`) to actually add content after creating the document.
|
|
15
|
+
|
|
16
16
|
Args:
|
|
17
|
-
title: The title for the new Google Document to be created
|
|
18
|
-
|
|
17
|
+
title: The title for the new Google Document to be created.
|
|
18
|
+
|
|
19
19
|
Returns:
|
|
20
|
-
A dictionary containing the Google Docs API
|
|
21
|
-
|
|
20
|
+
A dictionary containing the response from the Google Docs API with document details and metadata.
|
|
21
|
+
|
|
22
22
|
Raises:
|
|
23
|
-
HTTPError: If the API request fails due to network issues, authentication errors, or invalid parameters
|
|
24
|
-
RequestException: If there are connection errors or timeout issues during the API request
|
|
25
|
-
|
|
23
|
+
HTTPError: If the API request fails due to network issues, authentication errors, or invalid parameters.
|
|
24
|
+
RequestException: If there are connection errors or timeout issues during the API request.
|
|
25
|
+
|
|
26
26
|
Tags:
|
|
27
27
|
create, document, api, important, google-docs, http
|
|
28
28
|
"""
|
|
@@ -30,22 +30,26 @@ class GoogleDocsApp(APIApplication):
|
|
|
30
30
|
document_data = {"title": title}
|
|
31
31
|
response = self._post(url, data=document_data)
|
|
32
32
|
response.raise_for_status()
|
|
33
|
-
|
|
33
|
+
payload = response.json()
|
|
34
|
+
payload["Note"] = (
|
|
35
|
+
"You must load and call other google docs content functions (like google_docs__insert_text)"
|
|
36
|
+
)
|
|
37
|
+
return payload
|
|
34
38
|
|
|
35
39
|
def get_document(self, document_id: str) -> dict[str, Any]:
|
|
36
40
|
"""
|
|
37
|
-
Retrieves the complete
|
|
38
|
-
|
|
41
|
+
Retrieves the complete, raw JSON object for a Google Document by its ID. This function returns the full, unprocessed API response with all metadata and structural elements, distinguishing it from `get_document_content`, which parses this data to extract only the title and plain text.
|
|
42
|
+
|
|
39
43
|
Args:
|
|
40
|
-
document_id: The unique identifier of the
|
|
41
|
-
|
|
44
|
+
document_id: The unique identifier of the Google Document to retrieve.
|
|
45
|
+
|
|
42
46
|
Returns:
|
|
43
|
-
A dictionary containing the document data
|
|
44
|
-
|
|
47
|
+
A dictionary containing the complete document data as returned by the Google Docs API.
|
|
48
|
+
|
|
45
49
|
Raises:
|
|
46
|
-
HTTPError: If the API request fails or the document
|
|
47
|
-
JSONDecodeError: If the API response cannot be parsed
|
|
48
|
-
|
|
50
|
+
HTTPError: If the API request fails or the specified document cannot be found.
|
|
51
|
+
JSONDecodeError: If the API response is not valid JSON and cannot be parsed.
|
|
52
|
+
|
|
49
53
|
Tags:
|
|
50
54
|
retrieve, read, api, document, google-docs, important
|
|
51
55
|
"""
|
|
@@ -53,24 +57,191 @@ class GoogleDocsApp(APIApplication):
|
|
|
53
57
|
response = self._get(url)
|
|
54
58
|
return response.json()
|
|
55
59
|
|
|
56
|
-
def
|
|
57
|
-
self, document_id: str, content: str, index: int = 1
|
|
58
|
-
) -> dict[str, Any]:
|
|
60
|
+
def get_document_content(self, document_id: str) -> dict[str, Any]:
|
|
59
61
|
"""
|
|
60
|
-
|
|
62
|
+
Retrieves and converts a Google Docs document into Markdown-formatted content.
|
|
63
|
+
|
|
64
|
+
This method calls the Google Docs API via `get_document`, then parses the document structure
|
|
65
|
+
to extract paragraphs, headings, lists, tables, images, equations, footnotes, and horizontal rules.
|
|
66
|
+
The final result is a clean Markdown string that closely mirrors the layout and content of
|
|
67
|
+
the original document, including support for nested lists and multi-row tables.
|
|
61
68
|
|
|
62
69
|
Args:
|
|
63
|
-
document_id: The unique
|
|
64
|
-
content: The text content to be inserted into the document
|
|
65
|
-
index: The zero-based position in the document where the text should be inserted (default: 1)
|
|
70
|
+
document_id (str): The unique ID of the Google Document to retrieve.
|
|
66
71
|
|
|
67
72
|
Returns:
|
|
68
|
-
A dictionary
|
|
73
|
+
dict[str, Any]: A dictionary with the following keys:
|
|
74
|
+
- 'title' (str): The document's title.
|
|
75
|
+
- 'content' (str): The document content converted to Markdown.
|
|
76
|
+
Markdown Output Supports:
|
|
77
|
+
- Paragraphs and line breaks
|
|
78
|
+
- Headings (Heading 1-6)
|
|
79
|
+
- Bulleted and numbered lists (with nesting)
|
|
80
|
+
- Tables (converted to Markdown tables)
|
|
81
|
+
- Inline images (`` format)
|
|
82
|
+
- Equations (LaTeX-style `$...$`)
|
|
83
|
+
- Footnotes (`[^1]` references and notes at the end)
|
|
84
|
+
- Horizontal rules (`---`)
|
|
85
|
+
|
|
86
|
+
Tags:
|
|
87
|
+
google-docs, markdown, document-parsing, text-extraction, conversion, structured-data
|
|
88
|
+
"""
|
|
89
|
+
import re
|
|
90
|
+
|
|
91
|
+
response = self.get_document(document_id)
|
|
92
|
+
title = response.get("title", "")
|
|
93
|
+
body_content = response.get("body", {}).get("content", [])
|
|
94
|
+
inline_objects = response.get("inlineObjects", {})
|
|
95
|
+
lists = response.get("lists", {})
|
|
96
|
+
footnotes_data = response.get("footnotes", {})
|
|
97
|
+
|
|
98
|
+
text_chunks: list[str] = []
|
|
99
|
+
footnotes: dict[str, str] = {}
|
|
100
|
+
footnote_index: dict[str, int] = {}
|
|
101
|
+
current_list_counters: dict[str, int] = {}
|
|
102
|
+
|
|
103
|
+
def extract_text_from_paragraph(paragraph: dict) -> str:
|
|
104
|
+
"""Extracts paragraph text with inline formatting."""
|
|
105
|
+
text = ""
|
|
106
|
+
for elem in paragraph.get("elements", []):
|
|
107
|
+
if "textRun" in elem:
|
|
108
|
+
content = elem["textRun"].get("content", "")
|
|
109
|
+
text += content
|
|
110
|
+
elif "inlineObjectElement" in elem:
|
|
111
|
+
obj_id = elem["inlineObjectElement"]["inlineObjectId"]
|
|
112
|
+
obj = inline_objects.get(obj_id, {})
|
|
113
|
+
embed = obj.get("inlineObjectProperties", {}).get("embeddedObject", {})
|
|
114
|
+
image_source = embed.get("imageProperties", {}).get("contentUri", "")
|
|
115
|
+
if image_source:
|
|
116
|
+
text += f"\n\n\n\n"
|
|
117
|
+
return text
|
|
118
|
+
|
|
119
|
+
def extract_table(table: dict) -> str:
|
|
120
|
+
rows = []
|
|
121
|
+
for i, row in enumerate(table.get("tableRows", [])):
|
|
122
|
+
cells = []
|
|
123
|
+
for cell in row.get("tableCells", []):
|
|
124
|
+
cell_text = ""
|
|
125
|
+
for content in cell.get("content", []):
|
|
126
|
+
if "paragraph" in content:
|
|
127
|
+
cell_text += extract_text_from_paragraph(content["paragraph"]).strip()
|
|
128
|
+
cells.append(cell_text)
|
|
129
|
+
row_line = "| " + " | ".join(cells) + " |"
|
|
130
|
+
rows.append(row_line)
|
|
131
|
+
if i == 0:
|
|
132
|
+
rows.insert(1, "| " + " | ".join(["---"] * len(cells)) + " |")
|
|
133
|
+
return "\n".join(rows)
|
|
134
|
+
|
|
135
|
+
def extract_heading_style(paragraph: dict) -> str:
|
|
136
|
+
"""Returns appropriate Markdown heading level."""
|
|
137
|
+
style = paragraph.get("paragraphStyle", {})
|
|
138
|
+
heading = style.get("namedStyleType", "")
|
|
139
|
+
match = re.match(r"HEADING_(\d)", heading)
|
|
140
|
+
if match:
|
|
141
|
+
level = int(match.group(1))
|
|
142
|
+
return "#" * level
|
|
143
|
+
return ""
|
|
144
|
+
|
|
145
|
+
def extract_list_prefix(paragraph: dict) -> str:
|
|
146
|
+
"""Generates proper list prefix (numbered or bullet)."""
|
|
147
|
+
list_id = paragraph.get("bullet", {}).get("listId")
|
|
148
|
+
if not list_id:
|
|
149
|
+
return ""
|
|
150
|
+
glyph = paragraph["bullet"].get("glyph", None)
|
|
151
|
+
nesting = paragraph["bullet"].get("nestingLevel", 0)
|
|
152
|
+
list_info = lists.get(list_id, {})
|
|
153
|
+
list_type = list_info.get("listProperties", {}).get("nestingLevels", [{}])[nesting].get("glyphType")
|
|
154
|
+
|
|
155
|
+
indent = " " * nesting
|
|
156
|
+
if list_type and "DECIMAL" in list_type:
|
|
157
|
+
current_list_counters[list_id] = current_list_counters.get(list_id, 1)
|
|
158
|
+
prefix = f"{current_list_counters[list_id]}. "
|
|
159
|
+
current_list_counters[list_id] += 1
|
|
160
|
+
else:
|
|
161
|
+
prefix = "- "
|
|
162
|
+
return indent + prefix
|
|
163
|
+
|
|
164
|
+
def extract_equation(paragraph: dict) -> str:
|
|
165
|
+
return "\n\n$" + paragraph.get("equation", {}).get("equation", "") + "$\n\n"
|
|
166
|
+
|
|
167
|
+
def extract_footnote_ref(footnote_id: str) -> str:
|
|
168
|
+
if footnote_id not in footnote_index:
|
|
169
|
+
footnote_index[footnote_id] = len(footnotes) + 1
|
|
170
|
+
fn_content = footnotes_data.get(footnote_id, {}).get("content", [])
|
|
171
|
+
fn_text = ""
|
|
172
|
+
for item in fn_content:
|
|
173
|
+
if "paragraph" in item:
|
|
174
|
+
fn_text += extract_text_from_paragraph(item["paragraph"]).strip()
|
|
175
|
+
footnotes[footnote_id] = fn_text
|
|
176
|
+
return f"[^{footnote_index[footnote_id]}]"
|
|
177
|
+
|
|
178
|
+
for element in body_content:
|
|
179
|
+
if "paragraph" in element:
|
|
180
|
+
para = element["paragraph"]
|
|
181
|
+
if "equation" in para:
|
|
182
|
+
text_chunks.append(extract_equation(para))
|
|
183
|
+
continue
|
|
184
|
+
|
|
185
|
+
heading_md = extract_heading_style(para)
|
|
186
|
+
list_prefix = extract_list_prefix(para)
|
|
187
|
+
|
|
188
|
+
para_text = extract_text_from_paragraph(para).strip()
|
|
189
|
+
if para_text:
|
|
190
|
+
if heading_md:
|
|
191
|
+
text_chunks.append(f"{heading_md} {para_text}")
|
|
192
|
+
elif list_prefix:
|
|
193
|
+
text_chunks.append(f"{list_prefix}{para_text}")
|
|
194
|
+
else:
|
|
195
|
+
text_chunks.append(para_text)
|
|
196
|
+
|
|
197
|
+
elif "table" in element:
|
|
198
|
+
table_md = extract_table(element["table"])
|
|
199
|
+
text_chunks.append(table_md)
|
|
200
|
+
|
|
201
|
+
elif "horizontalRule" in element:
|
|
202
|
+
text_chunks.append("\n---\n")
|
|
203
|
+
|
|
204
|
+
elif "tableOfContents" in element:
|
|
205
|
+
text_chunks.append("<!-- Table of Contents -->")
|
|
206
|
+
|
|
207
|
+
# Handle footnote references (inline elements)
|
|
208
|
+
elif "footnoteReference" in element:
|
|
209
|
+
footnote_id = element["footnoteReference"]["footnoteId"]
|
|
210
|
+
ref = extract_footnote_ref(footnote_id)
|
|
211
|
+
text_chunks.append(ref)
|
|
212
|
+
|
|
213
|
+
# Append footnotes at the end
|
|
214
|
+
if footnotes:
|
|
215
|
+
text_chunks.append("\n## Footnotes\n")
|
|
216
|
+
for fid, index in sorted(footnote_index.items(), key=lambda x: x[1]):
|
|
217
|
+
text_chunks.append(f"[^{index}]: {footnotes[fid]}")
|
|
218
|
+
|
|
219
|
+
content = "\n\n".join(chunk.strip() for chunk in text_chunks if chunk.strip())
|
|
220
|
+
|
|
221
|
+
return {
|
|
222
|
+
"title": title,
|
|
223
|
+
"content": content
|
|
224
|
+
}
|
|
69
225
|
|
|
70
|
-
Raises:
|
|
71
|
-
HTTPError: When the API request fails, such as invalid document_id or insufficient permissions
|
|
72
|
-
RequestException: When there are network connectivity issues or API endpoint problems
|
|
73
226
|
|
|
227
|
+
def insert_text(
|
|
228
|
+
self, document_id: str, content: str, index: int = 1
|
|
229
|
+
) -> dict[str, Any]:
|
|
230
|
+
"""
|
|
231
|
+
Inserts a text string at a specified index within a Google Document using the batchUpdate API. Unlike functions that format existing text or delete content ranges, this method specifically adds new textual content to the document body.
|
|
232
|
+
|
|
233
|
+
Args:
|
|
234
|
+
document_id: The unique identifier of the Google Document to be updated.
|
|
235
|
+
content: The text content to be inserted into the document.
|
|
236
|
+
index: The zero-based position in the document where the text should be inserted (default is 1).
|
|
237
|
+
|
|
238
|
+
Returns:
|
|
239
|
+
A dictionary containing the Google Docs API response after performing the batch update operation.
|
|
240
|
+
|
|
241
|
+
Raises:
|
|
242
|
+
HTTPError: If the API request fails, for example due to invalid document_id or insufficient permissions.
|
|
243
|
+
RequestException: If there are network connectivity issues or problems contacting the API endpoint.
|
|
244
|
+
|
|
74
245
|
Tags:
|
|
75
246
|
update, insert, document, api, google-docs, batch, content-management, important
|
|
76
247
|
"""
|
|
@@ -98,56 +269,48 @@ class GoogleDocsApp(APIApplication):
|
|
|
98
269
|
background_color: dict[str, float] | None = None,
|
|
99
270
|
) -> dict[str, Any]:
|
|
100
271
|
"""
|
|
101
|
-
Applies character-level formatting
|
|
102
|
-
|
|
272
|
+
Applies character-level formatting (e.g., bold, italic, color, links) to a specified text range. This function modifies text attributes directly, distinguishing it from `update_paragraph_style` which handles block-level properties like alignment.
|
|
273
|
+
|
|
103
274
|
Args:
|
|
104
|
-
document_id: The unique identifier of the Google Document to
|
|
105
|
-
start_index: The zero-based start index of the text range to style
|
|
106
|
-
end_index: The zero-based end index of the text range to style
|
|
107
|
-
bold: Whether
|
|
108
|
-
italic: Whether
|
|
109
|
-
underline: Whether
|
|
110
|
-
font_size:
|
|
111
|
-
link_url: URL to
|
|
112
|
-
foreground_color: RGB color
|
|
113
|
-
background_color: RGB color
|
|
114
|
-
|
|
275
|
+
document_id: The unique identifier of the Google Document to update.
|
|
276
|
+
start_index: The zero-based start index of the text range to apply the style.
|
|
277
|
+
end_index: The zero-based end index (exclusive) of the text range to apply the style.
|
|
278
|
+
bold: Whether to apply bold formatting to the text.
|
|
279
|
+
italic: Whether to apply italic formatting to the text.
|
|
280
|
+
underline: Whether to apply underline formatting to the text.
|
|
281
|
+
font_size: Font size in points (e.g., 12.0 for 12pt) to apply to the text.
|
|
282
|
+
link_url: URL to apply as a hyperlink to the text.
|
|
283
|
+
foreground_color: RGB color dictionary with 'red', 'green', and 'blue' floats (0.0 to 1.0) for the text color.
|
|
284
|
+
background_color: RGB color dictionary with 'red', 'green', and 'blue' floats (0.0 to 1.0) for the text background color.
|
|
285
|
+
|
|
115
286
|
Returns:
|
|
116
|
-
A dictionary containing the Google Docs API response
|
|
117
|
-
|
|
287
|
+
A dictionary containing the Google Docs API response, or a message if no styling was applied.
|
|
288
|
+
|
|
118
289
|
Raises:
|
|
119
|
-
HTTPError:
|
|
120
|
-
RequestException:
|
|
121
|
-
|
|
290
|
+
HTTPError: If the Google Docs API request fails.
|
|
291
|
+
RequestException: If there are network connectivity issues during the API request.
|
|
292
|
+
|
|
122
293
|
Tags:
|
|
123
|
-
style, format, text, document, api, google-docs,
|
|
294
|
+
style, format, text, document, api, google-docs, important
|
|
124
295
|
"""
|
|
125
296
|
url = f"{self.base_api_url}/{document_id}:batchUpdate"
|
|
126
|
-
|
|
127
|
-
# Build the text style object with only common properties
|
|
128
297
|
text_style = {}
|
|
129
298
|
fields_to_update = []
|
|
130
|
-
|
|
131
299
|
if bold:
|
|
132
300
|
text_style["bold"] = True
|
|
133
301
|
fields_to_update.append("bold")
|
|
134
|
-
|
|
135
302
|
if italic:
|
|
136
303
|
text_style["italic"] = True
|
|
137
304
|
fields_to_update.append("italic")
|
|
138
|
-
|
|
139
305
|
if underline:
|
|
140
306
|
text_style["underline"] = True
|
|
141
307
|
fields_to_update.append("underline")
|
|
142
|
-
|
|
143
308
|
if font_size is not None:
|
|
144
309
|
text_style["fontSize"] = {"magnitude": font_size, "unit": "PT"}
|
|
145
310
|
fields_to_update.append("fontSize")
|
|
146
|
-
|
|
147
311
|
if link_url is not None:
|
|
148
312
|
text_style["link"] = {"url": link_url}
|
|
149
313
|
fields_to_update.append("link")
|
|
150
|
-
|
|
151
314
|
if foreground_color is not None:
|
|
152
315
|
text_style["foregroundColor"] = {
|
|
153
316
|
"color": {
|
|
@@ -159,7 +322,6 @@ class GoogleDocsApp(APIApplication):
|
|
|
159
322
|
}
|
|
160
323
|
}
|
|
161
324
|
fields_to_update.append("foregroundColor")
|
|
162
|
-
|
|
163
325
|
if background_color is not None:
|
|
164
326
|
text_style["backgroundColor"] = {
|
|
165
327
|
"color": {
|
|
@@ -171,11 +333,8 @@ class GoogleDocsApp(APIApplication):
|
|
|
171
333
|
}
|
|
172
334
|
}
|
|
173
335
|
fields_to_update.append("backgroundColor")
|
|
174
|
-
|
|
175
|
-
# If no styling requested, return early
|
|
176
336
|
if not text_style:
|
|
177
337
|
return {"message": "No styling applied"}
|
|
178
|
-
|
|
179
338
|
batch_update_data = {
|
|
180
339
|
"requests": [
|
|
181
340
|
{
|
|
@@ -187,7 +346,6 @@ class GoogleDocsApp(APIApplication):
|
|
|
187
346
|
}
|
|
188
347
|
]
|
|
189
348
|
}
|
|
190
|
-
|
|
191
349
|
response = self._post(url, data=batch_update_data)
|
|
192
350
|
return self._handle_response(response)
|
|
193
351
|
|
|
@@ -204,64 +362,51 @@ class GoogleDocsApp(APIApplication):
|
|
|
204
362
|
tab_id: str | None = None,
|
|
205
363
|
) -> dict[str, Any]:
|
|
206
364
|
"""
|
|
207
|
-
Applies paragraph-level formatting
|
|
208
|
-
|
|
365
|
+
Applies paragraph-level formatting like alignment, named styles (e.g., 'HEADING_1'), and text direction to a text range in a Google Doc. Distinct from `apply_text_style`, which handles character formatting, this method modifies properties for entire paragraphs using the batchUpdate API.
|
|
366
|
+
|
|
209
367
|
Args:
|
|
210
|
-
document_id: The unique identifier of the Google Document to
|
|
211
|
-
start_index: The zero-based start index of the paragraph range to style
|
|
212
|
-
end_index: The zero-based end index of the paragraph range to style (exclusive)
|
|
213
|
-
named_style_type: The named style type (e.g., 'NORMAL_TEXT', 'TITLE', 'HEADING_1'
|
|
214
|
-
alignment:
|
|
215
|
-
direction:
|
|
216
|
-
spacing_mode:
|
|
217
|
-
segment_id:
|
|
218
|
-
tab_id:
|
|
219
|
-
|
|
368
|
+
document_id: The unique identifier of the Google Document to update.
|
|
369
|
+
start_index: The zero-based start index of the paragraph range to style.
|
|
370
|
+
end_index: The zero-based end index of the paragraph range to style (exclusive).
|
|
371
|
+
named_style_type: The named style type to apply (e.g., 'NORMAL_TEXT', 'TITLE', 'HEADING_1').
|
|
372
|
+
alignment: Paragraph alignment option ('START', 'CENTER', 'END', 'JUSTIFIED').
|
|
373
|
+
direction: Content direction of the paragraph ('LEFT_TO_RIGHT', 'RIGHT_TO_LEFT').
|
|
374
|
+
spacing_mode: Spacing mode for the paragraph ('NEVER_COLLAPSE', 'COLLAPSE_LISTS').
|
|
375
|
+
segment_id: Optional segment ID for the text range.
|
|
376
|
+
tab_id: Optional tab ID for the text range.
|
|
377
|
+
|
|
220
378
|
Returns:
|
|
221
|
-
A dictionary containing the Google Docs
|
|
222
|
-
|
|
379
|
+
A dictionary containing the API response from the Google Docs batchUpdate request.
|
|
380
|
+
|
|
223
381
|
Raises:
|
|
224
|
-
HTTPError:
|
|
225
|
-
RequestException:
|
|
226
|
-
|
|
382
|
+
HTTPError: If the API request to update the document fails due to an HTTP error.
|
|
383
|
+
RequestException: If there are network connectivity issues during the API request.
|
|
384
|
+
|
|
227
385
|
Tags:
|
|
228
|
-
style, format, paragraph, document, api, google-docs, batch, content-management
|
|
386
|
+
style, format, paragraph, document, api, google-docs, batch, content-management, important
|
|
229
387
|
"""
|
|
230
388
|
url = f"{self.base_api_url}/{document_id}:batchUpdate"
|
|
231
|
-
|
|
232
|
-
# Build the paragraph style object with only specified properties
|
|
233
389
|
paragraph_style = {}
|
|
234
390
|
fields_to_update = []
|
|
235
|
-
|
|
236
391
|
if named_style_type is not None:
|
|
237
392
|
paragraph_style["namedStyleType"] = named_style_type
|
|
238
393
|
fields_to_update.append("namedStyleType")
|
|
239
|
-
|
|
240
394
|
if alignment is not None:
|
|
241
395
|
paragraph_style["alignment"] = alignment
|
|
242
396
|
fields_to_update.append("alignment")
|
|
243
|
-
|
|
244
397
|
if direction is not None:
|
|
245
398
|
paragraph_style["direction"] = direction
|
|
246
399
|
fields_to_update.append("direction")
|
|
247
|
-
|
|
248
400
|
if spacing_mode is not None:
|
|
249
401
|
paragraph_style["spacingMode"] = spacing_mode
|
|
250
402
|
fields_to_update.append("spacingMode")
|
|
251
|
-
|
|
252
|
-
# If no styling requested, return early
|
|
253
403
|
if not paragraph_style:
|
|
254
404
|
return {"message": "No paragraph styling applied"}
|
|
255
|
-
|
|
256
|
-
# Build the range object
|
|
257
405
|
range_obj: dict[str, Any] = {"startIndex": start_index, "endIndex": end_index}
|
|
258
|
-
|
|
259
|
-
# Add optional parameters if provided
|
|
260
406
|
if segment_id is not None:
|
|
261
407
|
range_obj["segmentId"] = segment_id
|
|
262
408
|
if tab_id is not None:
|
|
263
409
|
range_obj["tabId"] = tab_id
|
|
264
|
-
|
|
265
410
|
batch_update_data = {
|
|
266
411
|
"requests": [
|
|
267
412
|
{
|
|
@@ -273,7 +418,6 @@ class GoogleDocsApp(APIApplication):
|
|
|
273
418
|
}
|
|
274
419
|
]
|
|
275
420
|
}
|
|
276
|
-
|
|
277
421
|
response = self._post(url, data=batch_update_data)
|
|
278
422
|
return self._handle_response(response)
|
|
279
423
|
|
|
@@ -286,40 +430,34 @@ class GoogleDocsApp(APIApplication):
|
|
|
286
430
|
tab_id: str | None = None,
|
|
287
431
|
) -> dict[str, Any]:
|
|
288
432
|
"""
|
|
289
|
-
|
|
290
|
-
|
|
433
|
+
Removes content from a specified index range in a Google Document via the batchUpdate API. Unlike functions that delete entire elements (e.g., `delete_header`), this provides granular control by targeting content based on its precise start and end location, optionally within a specific segment or tab.
|
|
434
|
+
|
|
291
435
|
Args:
|
|
292
|
-
document_id: The unique identifier of the Google Document to be updated
|
|
293
|
-
start_index: The zero-based start index of the content range to delete
|
|
294
|
-
end_index: The zero-based end index of the content range to delete (exclusive)
|
|
295
|
-
segment_id:
|
|
296
|
-
tab_id:
|
|
297
|
-
|
|
436
|
+
document_id: The unique identifier of the Google Document to be updated.
|
|
437
|
+
start_index: The zero-based start index of the content range to delete.
|
|
438
|
+
end_index: The zero-based end index of the content range to delete (exclusive).
|
|
439
|
+
segment_id: Optional; the ID of the header, footer, or footnote segment containing the content.
|
|
440
|
+
tab_id: Optional; the ID of the tab containing the content to delete.
|
|
441
|
+
|
|
298
442
|
Returns:
|
|
299
|
-
A dictionary
|
|
300
|
-
|
|
443
|
+
A dictionary representing the Google Docs API response after performing the delete operation.
|
|
444
|
+
|
|
301
445
|
Raises:
|
|
302
|
-
HTTPError:
|
|
303
|
-
RequestException:
|
|
304
|
-
|
|
446
|
+
HTTPError: Raised when the API request fails due to issues such as invalid document ID or insufficient permissions.
|
|
447
|
+
RequestException: Raised when there are network connectivity issues or problems with the API endpoint.
|
|
448
|
+
|
|
305
449
|
Tags:
|
|
306
450
|
delete, remove, content, document, api, google-docs, batch, content-management, important
|
|
307
451
|
"""
|
|
308
452
|
url = f"{self.base_api_url}/{document_id}:batchUpdate"
|
|
309
|
-
|
|
310
|
-
# Build the delete content range request
|
|
311
453
|
delete_request: dict[str, Any] = {
|
|
312
454
|
"range": {"startIndex": start_index, "endIndex": end_index}
|
|
313
455
|
}
|
|
314
|
-
|
|
315
|
-
# Add optional parameters if provided
|
|
316
456
|
if segment_id is not None:
|
|
317
457
|
delete_request["range"]["segmentId"] = segment_id
|
|
318
458
|
if tab_id is not None:
|
|
319
459
|
delete_request["tabId"] = tab_id
|
|
320
|
-
|
|
321
460
|
batch_update_data = {"requests": [{"deleteContentRange": delete_request}]}
|
|
322
|
-
|
|
323
461
|
response = self._post(url, data=batch_update_data)
|
|
324
462
|
return self._handle_response(response)
|
|
325
463
|
|
|
@@ -333,39 +471,32 @@ class GoogleDocsApp(APIApplication):
|
|
|
333
471
|
tab_id: str = None,
|
|
334
472
|
) -> dict[str, Any]:
|
|
335
473
|
"""
|
|
336
|
-
Inserts a table with specified
|
|
337
|
-
|
|
474
|
+
Inserts a table with specified rows and columns at a given index in a Google Document using the batchUpdate API. It can optionally place the table within specific document segments, such as headers or footers, handling structural additions rather than text or style modifications.
|
|
475
|
+
|
|
338
476
|
Args:
|
|
339
|
-
document_id: The unique identifier of the Google Document to be updated
|
|
340
|
-
location_index: The zero-based index where the table should be inserted
|
|
341
|
-
rows: The number of rows
|
|
342
|
-
columns: The number of columns
|
|
343
|
-
segment_id:
|
|
344
|
-
tab_id:
|
|
345
|
-
|
|
477
|
+
document_id: The unique identifier of the Google Document to be updated.
|
|
478
|
+
location_index: The zero-based index within the document body or segment where the table should be inserted.
|
|
479
|
+
rows: The number of rows the inserted table should have.
|
|
480
|
+
columns: The number of columns the inserted table should have.
|
|
481
|
+
segment_id: Optional ID of the header, footer, or footnote segment where the table will be inserted (if applicable).
|
|
482
|
+
tab_id: Optional ID of the tab containing the insertion location.
|
|
483
|
+
|
|
346
484
|
Returns:
|
|
347
|
-
A dictionary containing the Google Docs API
|
|
348
|
-
|
|
485
|
+
A dictionary containing the response from the Google Docs API after performing the table insertion.
|
|
486
|
+
|
|
349
487
|
Raises:
|
|
350
|
-
HTTPError:
|
|
351
|
-
RequestException:
|
|
352
|
-
|
|
488
|
+
HTTPError: Raised when the API request fails due to reasons such as invalid document ID or insufficient permissions.
|
|
489
|
+
RequestException: Raised when there are network connectivity issues or problems reaching the API endpoint.
|
|
490
|
+
|
|
353
491
|
Tags:
|
|
354
|
-
table, insert, document, api, google-docs, batch, content-management
|
|
492
|
+
table, insert, document, api, google-docs, batch, content-management, important
|
|
355
493
|
"""
|
|
356
494
|
url = f"{self.base_api_url}/{document_id}:batchUpdate"
|
|
357
|
-
|
|
358
|
-
# Build the location object according to Google Docs API specification
|
|
359
495
|
location = {"index": location_index}
|
|
360
|
-
|
|
361
|
-
# Add segment_id if provided (empty string for document body, specific ID for header/footer/footnote)
|
|
362
496
|
if segment_id is not None:
|
|
363
497
|
location["segmentId"] = segment_id
|
|
364
|
-
|
|
365
|
-
# Add tab_id if provided
|
|
366
498
|
if tab_id is not None:
|
|
367
499
|
location["tabId"] = tab_id
|
|
368
|
-
|
|
369
500
|
batch_update_data = {
|
|
370
501
|
"requests": [
|
|
371
502
|
{
|
|
@@ -377,7 +508,6 @@ class GoogleDocsApp(APIApplication):
|
|
|
377
508
|
}
|
|
378
509
|
]
|
|
379
510
|
}
|
|
380
|
-
|
|
381
511
|
response = self._post(url, data=batch_update_data)
|
|
382
512
|
return self._handle_response(response)
|
|
383
513
|
|
|
@@ -390,31 +520,27 @@ class GoogleDocsApp(APIApplication):
|
|
|
390
520
|
section_break_tab_id: str = None,
|
|
391
521
|
) -> dict[str, Any]:
|
|
392
522
|
"""
|
|
393
|
-
Creates a footer of a specified type in a Google Document
|
|
394
|
-
|
|
523
|
+
Creates a footer of a specified type in a Google Document using the batch update API. This function, distinct from `create_header`, can optionally associate the new footer with a specific section break, enabling section-specific footers within the document.
|
|
524
|
+
|
|
395
525
|
Args:
|
|
396
|
-
document_id: The unique identifier of the Google Document to
|
|
397
|
-
footer_type: The type of footer to create
|
|
398
|
-
section_break_location_index:
|
|
399
|
-
section_break_segment_id:
|
|
400
|
-
section_break_tab_id:
|
|
401
|
-
|
|
526
|
+
document_id: The unique identifier of the Google Document to update.
|
|
527
|
+
footer_type: The type of footer to create, such as 'DEFAULT' or 'HEADER_FOOTER_TYPE_UNSPECIFIED'.
|
|
528
|
+
section_break_location_index: Optional index of the SectionBreak location to associate with the footer.
|
|
529
|
+
section_break_segment_id: Optional segment ID of the SectionBreak location.
|
|
530
|
+
section_break_tab_id: Optional tab ID of the SectionBreak location.
|
|
531
|
+
|
|
402
532
|
Returns:
|
|
403
|
-
A dictionary containing the Google Docs API response
|
|
404
|
-
|
|
533
|
+
A dictionary containing the Google Docs API response from the create footer operation.
|
|
534
|
+
|
|
405
535
|
Raises:
|
|
406
|
-
HTTPError:
|
|
407
|
-
RequestException:
|
|
408
|
-
|
|
536
|
+
HTTPError: Raised when the API request fails due to reasons like invalid document_id or insufficient permissions.
|
|
537
|
+
RequestException: Raised when there are network connectivity issues or problems with the API endpoint.
|
|
538
|
+
|
|
409
539
|
Tags:
|
|
410
|
-
footer, create, document, api, google-docs, batch, content-management
|
|
540
|
+
footer, create, document, api, google-docs, batch, content-management, important
|
|
411
541
|
"""
|
|
412
542
|
url = f"{self.base_api_url}/{document_id}:batchUpdate"
|
|
413
|
-
|
|
414
|
-
# Build the create footer request
|
|
415
543
|
create_footer_request = {"type": footer_type}
|
|
416
|
-
|
|
417
|
-
# Add section break location if provided
|
|
418
544
|
if section_break_location_index is not None:
|
|
419
545
|
section_break_location = {"index": section_break_location_index}
|
|
420
546
|
|
|
@@ -425,9 +551,7 @@ class GoogleDocsApp(APIApplication):
|
|
|
425
551
|
section_break_location["tabId"] = section_break_tab_id
|
|
426
552
|
|
|
427
553
|
create_footer_request["sectionBreakLocation"] = section_break_location
|
|
428
|
-
|
|
429
554
|
batch_update_data = {"requests": [{"createFooter": create_footer_request}]}
|
|
430
|
-
|
|
431
555
|
response = self._post(url, data=batch_update_data)
|
|
432
556
|
return self._handle_response(response)
|
|
433
557
|
|
|
@@ -442,32 +566,29 @@ class GoogleDocsApp(APIApplication):
|
|
|
442
566
|
end_of_segment_tab_id: str = None,
|
|
443
567
|
) -> dict[str, Any]:
|
|
444
568
|
"""
|
|
445
|
-
|
|
446
|
-
|
|
569
|
+
Inserts a numbered footnote reference into a Google Document using the batchUpdate API. The footnote can be placed at a precise index or at the end of a document segment, distinct from the `create_footer` function which adds standard page footers.
|
|
570
|
+
|
|
447
571
|
Args:
|
|
448
|
-
document_id: The unique identifier of the Google Document to be updated
|
|
449
|
-
location_index: The index
|
|
450
|
-
location_segment_id: The segment ID
|
|
451
|
-
location_tab_id: The tab ID for the location (optional)
|
|
452
|
-
end_of_segment_location:
|
|
453
|
-
end_of_segment_segment_id: The segment ID
|
|
454
|
-
end_of_segment_tab_id: The tab ID for end
|
|
455
|
-
|
|
572
|
+
document_id: The unique identifier of the Google Document to be updated.
|
|
573
|
+
location_index: The zero-based index within the document where the footnote reference will be inserted (optional if inserting at end of segment).
|
|
574
|
+
location_segment_id: The segment ID where the footnote reference should be inserted (optional, usually empty for the document body).
|
|
575
|
+
location_tab_id: The tab ID for the location within the segment (optional).
|
|
576
|
+
end_of_segment_location: If True, inserts the footnote reference at the end of a segment instead of a specific index (default is False).
|
|
577
|
+
end_of_segment_segment_id: The segment ID indicating where to insert the footnote at the end of a segment (optional).
|
|
578
|
+
end_of_segment_tab_id: The tab ID for the end-of-segment location (optional).
|
|
579
|
+
|
|
456
580
|
Returns:
|
|
457
|
-
A dictionary containing the Google Docs API
|
|
458
|
-
|
|
581
|
+
A dictionary containing the response from the Google Docs API after performing the footnote creation operation.
|
|
582
|
+
|
|
459
583
|
Raises:
|
|
460
|
-
HTTPError:
|
|
461
|
-
RequestException:
|
|
462
|
-
|
|
584
|
+
HTTPError: Raised when the API request fails, such as due to an invalid document ID or insufficient permissions.
|
|
585
|
+
RequestException: Raised when there are network connectivity issues or problems reaching the API endpoint.
|
|
586
|
+
|
|
463
587
|
Tags:
|
|
464
|
-
footnote, create, document, api, google-docs, batch, content-management
|
|
588
|
+
footnote, create, document, api, google-docs, batch, content-management, important
|
|
465
589
|
"""
|
|
466
590
|
url = f"{self.base_api_url}/{document_id}:batchUpdate"
|
|
467
|
-
|
|
468
|
-
# Build the create footnote request
|
|
469
591
|
create_footnote_request = {}
|
|
470
|
-
|
|
471
592
|
if end_of_segment_location:
|
|
472
593
|
# Use endOfSegmentLocation
|
|
473
594
|
end_of_segment_location_obj = {}
|
|
@@ -492,9 +613,7 @@ class GoogleDocsApp(APIApplication):
|
|
|
492
613
|
location["tabId"] = location_tab_id
|
|
493
614
|
|
|
494
615
|
create_footnote_request["location"] = location
|
|
495
|
-
|
|
496
616
|
batch_update_data = {"requests": [{"createFootnote": create_footnote_request}]}
|
|
497
|
-
|
|
498
617
|
response = self._post(url, data=batch_update_data)
|
|
499
618
|
return self._handle_response(response)
|
|
500
619
|
|
|
@@ -505,34 +624,28 @@ class GoogleDocsApp(APIApplication):
|
|
|
505
624
|
tab_id: str = None,
|
|
506
625
|
) -> dict[str, Any]:
|
|
507
626
|
"""
|
|
508
|
-
Deletes a specific footer from a Google Document using its unique ID via a
|
|
509
|
-
|
|
627
|
+
Deletes a specific footer from a Google Document using its unique ID via a batchUpdate API request. This operation removes the entire footer object, optionally within a specific tab, distinguishing it from functions that delete headers (`delete_header`) or general content (`delete_content_range`).
|
|
628
|
+
|
|
510
629
|
Args:
|
|
511
|
-
document_id: The unique identifier of the Google Document to be updated
|
|
512
|
-
footer_id: The
|
|
513
|
-
tab_id:
|
|
514
|
-
|
|
630
|
+
document_id: The unique identifier of the Google Document to be updated.
|
|
631
|
+
footer_id: The identifier of the footer to delete.
|
|
632
|
+
tab_id: Optional identifier of the tab containing the footer to delete.
|
|
633
|
+
|
|
515
634
|
Returns:
|
|
516
|
-
A dictionary containing the Google Docs API
|
|
517
|
-
|
|
635
|
+
A dictionary containing the response from the Google Docs API after performing the delete footer operation.
|
|
636
|
+
|
|
518
637
|
Raises:
|
|
519
|
-
HTTPError:
|
|
520
|
-
RequestException:
|
|
521
|
-
|
|
638
|
+
HTTPError: Raised when the API request fails due to reasons such as an invalid document ID or insufficient permissions.
|
|
639
|
+
RequestException: Raised for network-related issues or problems reaching the API endpoint.
|
|
640
|
+
|
|
522
641
|
Tags:
|
|
523
|
-
footer, delete, remove, document, api, google-docs, batch, content-management
|
|
642
|
+
footer, delete, remove, document, api, google-docs, batch, content-management, important
|
|
524
643
|
"""
|
|
525
644
|
url = f"{self.base_api_url}/{document_id}:batchUpdate"
|
|
526
|
-
|
|
527
|
-
# Build the delete footer request
|
|
528
645
|
delete_footer_request = {"footerId": footer_id}
|
|
529
|
-
|
|
530
|
-
# Add tab_id if provided
|
|
531
646
|
if tab_id is not None:
|
|
532
647
|
delete_footer_request["tabId"] = tab_id
|
|
533
|
-
|
|
534
648
|
batch_update_data = {"requests": [{"deleteFooter": delete_footer_request}]}
|
|
535
|
-
|
|
536
649
|
response = self._post(url, data=batch_update_data)
|
|
537
650
|
return self._handle_response(response)
|
|
538
651
|
|
|
@@ -545,31 +658,27 @@ class GoogleDocsApp(APIApplication):
|
|
|
545
658
|
section_break_tab_id: str = None,
|
|
546
659
|
) -> dict[str, Any]:
|
|
547
660
|
"""
|
|
548
|
-
Creates a header
|
|
549
|
-
|
|
661
|
+
Creates a header of a specified type in a Google Document using the batchUpdate API. This function can optionally associate the new header with a specific section break, distinguishing it from the `create_footer` method, which performs the equivalent action for footers.
|
|
662
|
+
|
|
550
663
|
Args:
|
|
551
|
-
document_id: The unique identifier of the Google Document to be updated
|
|
552
|
-
header_type: The type of header to create
|
|
553
|
-
section_break_location_index: The index of the
|
|
554
|
-
section_break_segment_id: The segment ID
|
|
555
|
-
section_break_tab_id: The tab ID
|
|
556
|
-
|
|
664
|
+
document_id: The unique identifier of the Google Document to be updated.
|
|
665
|
+
header_type: The type of header to create, e.g., 'DEFAULT' or 'HEADER_FOOTER_TYPE_UNSPECIFIED'.
|
|
666
|
+
section_break_location_index: The index position of the section break location within the document, if applicable.
|
|
667
|
+
section_break_segment_id: The segment ID associated with the section break location, if applicable.
|
|
668
|
+
section_break_tab_id: The tab ID associated with the section break location, if applicable.
|
|
669
|
+
|
|
557
670
|
Returns:
|
|
558
|
-
A dictionary containing the Google Docs API
|
|
559
|
-
|
|
671
|
+
A dictionary containing the response from the Google Docs API after the header creation request.
|
|
672
|
+
|
|
560
673
|
Raises:
|
|
561
|
-
HTTPError:
|
|
562
|
-
RequestException:
|
|
563
|
-
|
|
674
|
+
HTTPError: If the API request fails due to issues such as an invalid document ID or insufficient permissions.
|
|
675
|
+
RequestException: If there are network problems or issues reaching the API endpoint.
|
|
676
|
+
|
|
564
677
|
Tags:
|
|
565
678
|
header, create, document, api, google-docs, batch, content-management, important
|
|
566
679
|
"""
|
|
567
680
|
url = f"{self.base_api_url}/{document_id}:batchUpdate"
|
|
568
|
-
|
|
569
|
-
# Build the create header request
|
|
570
681
|
create_header_request = {"type": header_type}
|
|
571
|
-
|
|
572
|
-
# Add section break location if provided
|
|
573
682
|
if section_break_location_index is not None:
|
|
574
683
|
section_break_location = {"index": section_break_location_index}
|
|
575
684
|
|
|
@@ -580,9 +689,7 @@ class GoogleDocsApp(APIApplication):
|
|
|
580
689
|
section_break_location["tabId"] = section_break_tab_id
|
|
581
690
|
|
|
582
691
|
create_header_request["sectionBreakLocation"] = section_break_location
|
|
583
|
-
|
|
584
692
|
batch_update_data = {"requests": [{"createHeader": create_header_request}]}
|
|
585
|
-
|
|
586
693
|
response = self._post(url, data=batch_update_data)
|
|
587
694
|
return self._handle_response(response)
|
|
588
695
|
|
|
@@ -593,34 +700,28 @@ class GoogleDocsApp(APIApplication):
|
|
|
593
700
|
tab_id: str = None,
|
|
594
701
|
) -> dict[str, Any]:
|
|
595
702
|
"""
|
|
596
|
-
|
|
597
|
-
|
|
703
|
+
Deletes a specific header from a Google Document using its unique ID via a batchUpdate API request. This function, the counterpart to `create_header`, removes headers and can optionally target a header within a specific tab. It requires both the document and header IDs for the operation.
|
|
704
|
+
|
|
598
705
|
Args:
|
|
599
|
-
document_id: The unique identifier of the Google Document to be updated
|
|
600
|
-
header_id: The ID of the header to delete
|
|
601
|
-
tab_id:
|
|
602
|
-
|
|
706
|
+
document_id: The unique identifier of the Google Document to be updated.
|
|
707
|
+
header_id: The ID of the header to delete.
|
|
708
|
+
tab_id: Optional ID of the tab containing the header to delete.
|
|
709
|
+
|
|
603
710
|
Returns:
|
|
604
|
-
A dictionary containing the Google Docs API
|
|
605
|
-
|
|
711
|
+
A dictionary containing the response from the Google Docs API after performing the delete header operation.
|
|
712
|
+
|
|
606
713
|
Raises:
|
|
607
|
-
HTTPError:
|
|
608
|
-
RequestException:
|
|
609
|
-
|
|
714
|
+
HTTPError: Raised when the API request fails due to invalid document_id, insufficient permissions, or other HTTP errors.
|
|
715
|
+
RequestException: Raised when network connectivity issues or API endpoint problems occur during the request.
|
|
716
|
+
|
|
610
717
|
Tags:
|
|
611
|
-
header, delete, remove, document, api, google-docs, batch, content-management
|
|
718
|
+
header, delete, remove, document, api, google-docs, batch, content-management, important
|
|
612
719
|
"""
|
|
613
720
|
url = f"{self.base_api_url}/{document_id}:batchUpdate"
|
|
614
|
-
|
|
615
|
-
# Build the delete header request
|
|
616
721
|
delete_header_request = {"headerId": header_id}
|
|
617
|
-
|
|
618
|
-
# Add tab_id if provided
|
|
619
722
|
if tab_id is not None:
|
|
620
723
|
delete_header_request["tabId"] = tab_id
|
|
621
|
-
|
|
622
724
|
batch_update_data = {"requests": [{"deleteHeader": delete_header_request}]}
|
|
623
|
-
|
|
624
725
|
response = self._post(url, data=batch_update_data)
|
|
625
726
|
return self._handle_response(response)
|
|
626
727
|
|
|
@@ -634,53 +735,32 @@ class GoogleDocsApp(APIApplication):
|
|
|
634
735
|
tab_id: str = None,
|
|
635
736
|
) -> dict[str, Any]:
|
|
636
737
|
"""
|
|
637
|
-
Applies a predefined bulleted or numbered
|
|
638
|
-
|
|
738
|
+
Applies a predefined list style (bulleted or numbered) to paragraphs within a specified range using a chosen preset. Unlike `delete_paragraph_bullets`, which removes list formatting, this function creates it, distinguishing it from other text and paragraph styling methods in the class.
|
|
739
|
+
|
|
639
740
|
Args:
|
|
640
|
-
document_id: The unique identifier of the Google Document to be updated
|
|
641
|
-
start_index: The zero-based start index of the range to
|
|
642
|
-
end_index: The zero-based end index of the range to apply
|
|
643
|
-
bullet_preset:
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
- BULLET_CHECKBOX: CHECKBOX bullet glyphs for all nesting levels
|
|
648
|
-
- BULLET_ARROW_DIAMOND_DISC: ARROW, DIAMOND and DISC for first 3 nesting levels
|
|
649
|
-
- BULLET_STAR_CIRCLE_SQUARE: STAR, CIRCLE and SQUARE for first 3 nesting levels
|
|
650
|
-
- BULLET_ARROW3D_CIRCLE_SQUARE: ARROW3D, CIRCLE and SQUARE for first 3 nesting levels
|
|
651
|
-
- BULLET_LEFTTRIANGLE_DIAMOND_DISC: LEFTTRIANGLE, DIAMOND and DISC for first 3 nesting levels
|
|
652
|
-
- BULLET_DIAMONDX_HOLLOWDIAMOND_SQUARE: DIAMONDX, HOLLOWDIAMOND and SQUARE for first 3 nesting levels
|
|
653
|
-
- BULLET_DIAMOND_CIRCLE_SQUARE: DIAMOND, CIRCLE and SQUARE for first 3 nesting levels
|
|
654
|
-
- NUMBERED_DECIMAL_ALPHA_ROMAN: DECIMAL, ALPHA and ROMAN with periods
|
|
655
|
-
- NUMBERED_DECIMAL_ALPHA_ROMAN_PARENS: DECIMAL, ALPHA and ROMAN with parenthesis
|
|
656
|
-
- NUMBERED_DECIMAL_NESTED: DECIMAL with nested numbering (1., 1.1., 2., 2.2.)
|
|
657
|
-
- NUMBERED_UPPERALPHA_ALPHA_ROMAN: UPPERALPHA, ALPHA and ROMAN with periods
|
|
658
|
-
- NUMBERED_UPPERROMAN_UPPERALPHA_DECIMAL: UPPERROMAN, UPPERALPHA and DECIMAL with periods
|
|
659
|
-
- NUMBERED_ZERODECIMAL_ALPHA_ROMAN: ZERODECIMAL, ALPHA and ROMAN with periods
|
|
660
|
-
segment_id: The segment ID for the range (optional)
|
|
661
|
-
tab_id: The tab ID for the range (optional)
|
|
662
|
-
|
|
741
|
+
document_id: The unique identifier of the Google Document to be updated.
|
|
742
|
+
start_index: The zero-based start index of the text range to which the list style should be applied.
|
|
743
|
+
end_index: The zero-based end index (exclusive) of the text range to apply the list style.
|
|
744
|
+
bullet_preset: Specifies the bullet or numbering style preset to use (e.g., bulleted or numbered formats with specific glyphs).
|
|
745
|
+
segment_id: Optional segment ID within the document where the updates apply.
|
|
746
|
+
tab_id: Optional tab ID within the segment to narrow the update scope.
|
|
747
|
+
|
|
663
748
|
Returns:
|
|
664
|
-
A dictionary
|
|
665
|
-
|
|
749
|
+
A dictionary representing the Google Docs API response confirming the application of the bullet list style.
|
|
750
|
+
|
|
666
751
|
Raises:
|
|
667
|
-
HTTPError:
|
|
668
|
-
RequestException:
|
|
669
|
-
|
|
752
|
+
HTTPError: Raised when the API request to update the document fails (e.g., invalid document ID or insufficient permissions).
|
|
753
|
+
RequestException: Raised on network issues or problems reaching the API endpoint.
|
|
754
|
+
|
|
670
755
|
Tags:
|
|
671
|
-
bullets, list, paragraph, document, api, google-docs, batch, content-management
|
|
756
|
+
bullets, list, paragraph, document, api, google-docs, batch, content-management, important
|
|
672
757
|
"""
|
|
673
758
|
url = f"{self.base_api_url}/{document_id}:batchUpdate"
|
|
674
|
-
|
|
675
|
-
# Build the range object
|
|
676
759
|
range_obj = {"startIndex": start_index, "endIndex": end_index}
|
|
677
|
-
|
|
678
|
-
# Add optional parameters if provided
|
|
679
760
|
if segment_id is not None:
|
|
680
761
|
range_obj["segmentId"] = segment_id
|
|
681
762
|
if tab_id is not None:
|
|
682
763
|
range_obj["tabId"] = tab_id
|
|
683
|
-
|
|
684
764
|
batch_update_data = {
|
|
685
765
|
"requests": [
|
|
686
766
|
{
|
|
@@ -691,7 +771,6 @@ class GoogleDocsApp(APIApplication):
|
|
|
691
771
|
}
|
|
692
772
|
]
|
|
693
773
|
}
|
|
694
|
-
|
|
695
774
|
response = self._post(url, data=batch_update_data)
|
|
696
775
|
return self._handle_response(response)
|
|
697
776
|
|
|
@@ -704,47 +783,42 @@ class GoogleDocsApp(APIApplication):
|
|
|
704
783
|
tab_id: str = None,
|
|
705
784
|
) -> dict[str, Any]:
|
|
706
785
|
"""
|
|
707
|
-
Removes bullet points or numbering from paragraphs within a specified range in a Google Document. This
|
|
708
|
-
|
|
786
|
+
Removes bullet points or numbering from paragraphs within a specified index range in a Google Document. This reverts list formatting to normal text while preserving content, acting as the inverse operation to the `apply_list_style` function.
|
|
787
|
+
|
|
709
788
|
Args:
|
|
710
|
-
document_id: The unique identifier of the Google Document to be updated
|
|
711
|
-
start_index: The zero-based start index of the range to remove bullets from
|
|
712
|
-
end_index: The zero-based end index of the range to remove bullets from (exclusive)
|
|
713
|
-
segment_id:
|
|
714
|
-
tab_id:
|
|
715
|
-
|
|
789
|
+
document_id: The unique identifier of the Google Document to be updated.
|
|
790
|
+
start_index: The zero-based start index of the range to remove bullets from.
|
|
791
|
+
end_index: The zero-based end index of the range to remove bullets from (exclusive).
|
|
792
|
+
segment_id: Optional segment ID specifying a subset of the document where the range applies.
|
|
793
|
+
tab_id: Optional tab ID specifying a particular tab within the document where the range applies.
|
|
794
|
+
|
|
716
795
|
Returns:
|
|
717
|
-
A dictionary containing the Google Docs API response after performing the delete bullets operation
|
|
718
|
-
|
|
796
|
+
A dictionary containing the Google Docs API response after performing the delete bullets operation.
|
|
797
|
+
|
|
719
798
|
Raises:
|
|
720
|
-
HTTPError:
|
|
721
|
-
RequestException:
|
|
722
|
-
|
|
799
|
+
HTTPError: Raised when the API request fails due to invalid document ID, insufficient permissions, or other server-side errors.
|
|
800
|
+
RequestException: Raised when there are network connectivity issues or problems accessing the API endpoint.
|
|
801
|
+
|
|
723
802
|
Tags:
|
|
724
803
|
bullets, delete, remove, list, paragraph, document, api, google-docs, batch, content-management
|
|
725
804
|
"""
|
|
726
805
|
url = f"{self.base_api_url}/{document_id}:batchUpdate"
|
|
727
|
-
|
|
728
|
-
# Build the range object
|
|
729
806
|
range_obj = {"startIndex": start_index, "endIndex": end_index}
|
|
730
|
-
|
|
731
|
-
# Add optional parameters if provided
|
|
732
807
|
if segment_id is not None:
|
|
733
808
|
range_obj["segmentId"] = segment_id
|
|
734
809
|
if tab_id is not None:
|
|
735
810
|
range_obj["tabId"] = tab_id
|
|
736
|
-
|
|
737
811
|
batch_update_data = {
|
|
738
812
|
"requests": [{"deleteParagraphBullets": {"range": range_obj}}]
|
|
739
813
|
}
|
|
740
|
-
|
|
741
814
|
response = self._post(url, data=batch_update_data)
|
|
742
815
|
return self._handle_response(response)
|
|
743
816
|
|
|
744
817
|
def list_tools(self):
|
|
745
818
|
return [
|
|
746
819
|
self.create_document,
|
|
747
|
-
self.get_document,
|
|
820
|
+
# self.get_document,
|
|
821
|
+
self.get_document_content,
|
|
748
822
|
self.insert_text,
|
|
749
823
|
self.apply_text_style,
|
|
750
824
|
self.delete_content_range,
|