Skip to content

Commit 586ea7b

Browse files
authored
Merge pull request #1173 from RogerSelwyn/query-docs
Added docs for query builder Update docs build to use uv
2 parents 18bb4a7 + 27d0a7d commit 586ea7b

File tree

5 files changed

+62
-8
lines changed

5 files changed

+62
-8
lines changed

.github/workflows/build_pages.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,18 @@ jobs:
1414
- name: "Set up Python"
1515
uses: actions/setup-python@v5
1616
with:
17-
python-version: "3.12"
18-
cache: "pip"
17+
python-version-file: "pyproject.toml"
1918

20-
- name: "Install requirements"
21-
run: python3 -m pip install -r requirements-pages.txt
19+
- name: Install uv
20+
uses: astral-sh/setup-uv@v1
21+
with:
22+
version: "latest"
23+
24+
- name: Install dependencies
25+
run: uv sync
2226

2327
- name: "Build pages"
24-
run: sphinx-build -b html -c ./docs/source/ ./docs/source/ ./docs/latest/
28+
run: uv run sphinx-build -b html -c ./docs/source/ ./docs/source/ ./docs/latest/
2529

2630
- name: "Pull any updates"
2731
shell: bash

O365/excel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1954,7 +1954,7 @@ def update_cells(self, address, rows):
19541954
direct endpoint API for tableless row updates.
19551955
:param str|Range address: the address to resolve to a range which can be used for updating cells.
19561956
:param list[list[str]] rows: list of rows to push to this range. If updating a single cell, pass a list
1957-
containing a single row (list) containing a single cell worth of data.
1957+
containing a single row (list) containing a single cell worth of data.
19581958
"""
19591959
if isinstance(address, str):
19601960
address = self.get_range(address)

docs/source/usage/sharepoint.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ Sites.Read.All sharepoint To only read
1111
Sites.ReadWrite.All sharepoint_dl To read and save sites, lists and items
1212
========================= ======================================= =======================================
1313

14-
Note that using the *.All scopes is way less secure than granting permissions to specific sites and using
15-
Sites.Selected scope.
14+
Note that using the :code:`.All` scopes is way less secure than granting permissions to specific sites and using
15+
:code:`Sites.Selected scope`.
1616

1717
Assuming an authenticated account, create a Sharepoint instance, and connect
1818
to a Sharepoint site.

docs/source/usage/utils/query.rst

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,53 @@
11
Query
22
=====
33

4+
.. _query_builder:
5+
46
Query Builder
57
-------------
68

9+
A query can be created for every ``ApiComponent`` (such as ``MailBox``). The ``Query`` can be used to handle the filtering, sorting, selecting, expanding and search very easily.
10+
11+
For example:
12+
13+
.. code-block:: python
14+
15+
from O365.utils import QueryBuilder
16+
builder = QueryBuilder(protocol=account.protocol)
17+
18+
query = builder.chain_or(builder.contains('subject', 'george best'), builder.startswith('subject', 'quotes')
19+
20+
# 'created_date_time' will automatically be converted to the protocol casing.
21+
# For example when using MS Graph this will become 'createdDateTime'.
22+
23+
query = query & builder.greater('created_date_time', datetime(2018, 3, 21))
24+
25+
print(query)
26+
27+
# contains(subject, 'george best') or startswith(subject, 'quotes') and createdDateTime gt '2018-03-21T00:00:00Z'
28+
# note you can pass naive datetimes and those will be converted to you local timezone and then send to the api as UTC in iso8601 format
29+
30+
# To use Query objetcs just pass it to the query parameter:
31+
filtered_messages = mailbox.get_messages(query=query)
32+
33+
You can also specify specific data to be retrieved with "select":
34+
35+
.. code-block:: python
36+
37+
# select only some properties for the retrieved messages:
38+
query = builder.select('subject', 'to_recipients', 'created_date_time)
39+
40+
messages_with_selected_properties = mailbox.get_messages(query=query)
41+
42+
You can also search content. As said in the graph docs:
43+
44+
You can currently search only message and person collections. A $search request returns up to 250 results. You cannot use $filter or $orderby in a search request.
45+
46+
If you do a search on messages and specify only a value without specific message properties, the search is carried out on the default search properties of from, subject, and body.
47+
48+
.. code-block:: python
49+
50+
# searching is the easy part ;)
51+
query = builder.search('george best is da boss')
52+
messages = mailbox.get_messages(query=query)
753

docs/source/usage/utils/utils.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ For example:
3939
4040
Query helper
4141
------------
42+
.. note::
43+
44+
This method of creating queries is now deprecated, queries shoould now be created using the ExperimentalQuery methods - :ref:`query_builder`
45+
4246
Every ``ApiComponent`` (such as ``MailBox``) implements a new_query method that will return a ``Query`` instance. This ``Query`` instance can handle the filtering, sorting, selecting, expanding and search very easily.
4347

4448
For example:

0 commit comments

Comments
 (0)