Skip to content

Commit 83d16e8

Browse files
committed
Update docs for change to query builder
1 parent ee25b05 commit 83d16e8

File tree

5 files changed

+17
-14
lines changed

5 files changed

+17
-14
lines changed

docs/source/usage/addressbook.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,16 @@ Without admin consent you can only access a few properties of each user such as
6464
To search the Global Address List (Users API):
6565

6666
.. code-block:: python
67-
67+
6868
global_address_list = account.directory()
6969
7070
# for backwards compatibility only this also works and returns a Directory object:
7171
# global_address_list = account.address_book(address_book='gal')
7272
7373
# start a new query:
74-
q = global_address_list.new_query('display_name')
75-
q.startswith('George Best')
74+
builder = global_address_list.new_query()
75+
query = builder.select('display_name')
76+
query = query & builder.startswith('subject', 'George Best')
7677
7778
for user in global_address_list.get_users(query=q):
7879
print(user)

docs/source/usage/calendar.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,13 @@ Working with Calendar instances:
4646
4747
calendar = schedule.get_calendar(calendar_name='Birthdays')
4848
49+
builder = calendar.new_query()
4950
calendar.name = 'Football players birthdays'
5051
calendar.update()
5152
5253
53-
start_q = calendar.new_query('start').greater_equal(dt.datetime(2018, 5, 20))
54-
end_q = calendar.new_query('start').less_equal(dt.datetime(2018, 5, 24))
54+
start_q = builder.greater_equal('start', dt.datetime(2018, 5, 20))
55+
end_q = builder.greater_equal('start', dt.datetime(2018, 5, 24))
5556
5657
birthdays = calendar.get_events(
5758
include_recurring=True, # include_recurring=True will include repeated events on the result set.

docs/source/usage/mailbox.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ MailboxSettings.ReadWrite mailbox_settings To read and
8787
.. .. code-block:: python
8888
8989
.. # All child folders whose name startswith 'Top'
90-
.. mail_folders = mailbox.get_folders(query=mailbox.new_query('displayName').startswith('Top'))
90+
.. builder = mailbox.new_query()
91+
.. mail_folders = mailbox.get_folders(query=builder.startswith('displayName', 'Top'))
9192
9293
Mailbox and Messages
9394
""""""""""""""""""""
@@ -152,8 +153,9 @@ Creating a draft message is as easy as this:
152153
**Working with saved emails is also easy**
153154

154155
.. code-block:: python
155-
156-
query = mailbox.new_query().on_attribute('subject').contains('george best') # see Query object in Utils
156+
157+
builder = mailbox.new_query()
158+
query = builder.chain_or(builder.contains('subject', 'george best'), builder.startswith('subject', 'quotes') # see Query object in Utils
157159
messages = mailbox.get_messages(limit=25, query=query)
158160
159161
message = messages[0] # get the first one

docs/source/usage/utils/query.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ For example:
1212

1313
.. code-block:: python
1414
15-
from O365.utils import QueryBuilder
16-
builder = QueryBuilder(protocol=account.protocol)
15+
builder = mailbox.new_query()
1716
1817
query = builder.chain_or(builder.contains('subject', 'george best'), builder.startswith('subject', 'quotes')
1918
@@ -27,7 +26,7 @@ For example:
2726
# contains(subject, 'george best') or startswith(subject, 'quotes') and createdDateTime gt '2018-03-21T00:00:00Z'
2827
# 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
2928
30-
# To use Query objetcs just pass it to the query parameter:
29+
# To use Query objects just pass it to the query parameter:
3130
filtered_messages = mailbox.get_messages(query=query)
3231
3332
You can also specify specific data to be retrieved with "select":

docs/source/usage/utils/utils.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ For example:
4949

5050
.. code-block:: python
5151
52-
query = mailbox.new_query() # you can use the shorthand: mailbox.q()
52+
builder = mailbox.new_query() # you can use the shorthand: mailbox.q()
5353
54-
query = query.on_attribute('subject').contains('george best').chain('or').startswith('quotes')
54+
query = builder.chain_or(builder.contains('subject', 'george best'), builder.startswith('subject', 'quotes')
5555
5656
# 'created_date_time' will automatically be converted to the protocol casing.
5757
# For example when using MS Graph this will become 'createdDateTime'.
5858
59-
query = query.chain('and').on_attribute('created_date_time').greater(datetime(2018, 3, 21))
59+
query = query & builder.greater('created_date_time', datetime(2018, 3, 21))
6060
6161
print(query)
6262

0 commit comments

Comments
 (0)