Skip to content

Add query to the docs, plus minor corrections to docs in query #1162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions O365/utils/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def get_filter_by_attribute(self, attribute: str) -> Optional[str]:
"""
Returns a filter value by attribute name. It will match the attribute to the start of each filter attribute
and return the first found.

:param attribute: the attribute you want to search
:return: The value applied to that attribute or None
"""
Expand Down Expand Up @@ -592,11 +593,14 @@ def iterable_operation(self, operation: str, collection: str, filter_instance: Q
""" Performs the provided filter operation on a collection by iterating over it.

For example:
q.iterable(
operation='any',
collection='email_addresses',
filter_instance=q.equals('address', 'george@best.com')
)

.. code-block:: python

q.iterable(
operation='any',
collection='email_addresses',
filter_instance=q.equals('address', 'george@best.com')
)

will transform to a filter such as:
emailAddresses/any(a:a/address eq 'george@best.com')
Expand Down Expand Up @@ -733,7 +737,7 @@ def select(self, *attributes: str) -> SelectFilter:
"""
Returns a 'select' query param
This is useful to return a limited set of attributes from a resource or return attributes that are not
returned by default by the resource.
returned by default by the resource.

:param attributes: a tuple of attribute names to select
:return: a SelectFilter instance that can render the OData select operation
Expand All @@ -750,8 +754,8 @@ def expand(self, relationship: str, select: Optional[SelectFilter] = None) -> Ex
"""
Returns an 'expand' query param
Important: If the 'expand' is a relationship (e.g. "event" or "attachments"), then the ApiComponent using
this query should know how to handle the relationship (e.g. Message knows how to handle attachments,
and event (if it's an EventMessage).
this query should know how to handle the relationship (e.g. Message knows how to handle attachments,
and event (if it's an EventMessage).
Important: When using expand on multi-value relationships a max of 20 items will be returned.

:param relationship: a relationship that will be expanded
Expand Down
8 changes: 7 additions & 1 deletion O365/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1308,7 +1308,13 @@ def close_group(self):
return self

def get_filter_by_attribute(self, attribute):
""" Returns a filter word applied to an attribute """
"""
Returns a filter value by attribute name. It will match the attribute to the start of each filter attribute
and return the first found.

:param attribute: the attribute you want to search
:return: The value applied to that attribute or None
"""

attribute = attribute.lower()

Expand Down
1 change: 1 addition & 0 deletions docs/source/api/utils.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ Utils
:caption: Contents:

utils/attachment
utils/query
utils/token
utils/utils
10 changes: 10 additions & 0 deletions docs/source/api/utils/query.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Query
-----

.. include:: ../global.rst

.. automodule:: O365.utils.query
:members:
:undoc-members:
:show-inheritance:
:member-order: groupwise
1 change: 1 addition & 0 deletions docs/source/usage/utils.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ Utils
:maxdepth: 2
:caption: Contents:

utils/query
utils/token
utils/utils
7 changes: 7 additions & 0 deletions docs/source/usage/utils/query.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Query
=====

Query Builder
-------------