forked from vgrem/Office365-REST-Python-Client
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
typings improvements for Outlook & SharePoint API, new methods for Ma…
…ilFolder type, examples updates
- Loading branch information
Showing
52 changed files
with
407 additions
and
324 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
""" | ||
Empties the mail folder | ||
""" | ||
from office365.graph_client import GraphClient | ||
from tests import test_client_id, test_password, test_tenant, test_username | ||
|
||
client = GraphClient.with_username_and_password( | ||
test_tenant, test_client_id, test_username, test_password | ||
) | ||
client.me.mail_folders["Inbox"].empty().execute_query() | ||
print("Inbox has been emptied") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
""" | ||
List attachments | ||
https://learn.microsoft.com/en-us/graph/api/message-list-attachments?view=graph-rest-1.0 | ||
""" | ||
|
||
from office365.graph_client import GraphClient | ||
from tests import test_client_id, test_password, test_tenant, test_username | ||
|
||
client = GraphClient.with_username_and_password( | ||
test_tenant, test_client_id, test_username, test_password | ||
) | ||
messages = ( | ||
client.me.messages.filter("hasAttachments eq true") | ||
.expand(["attachments"]) | ||
.top(10) | ||
.get() | ||
.execute_query() | ||
) | ||
|
||
for message in messages: | ||
for attachment in message.attachments: | ||
print("Message: {0}, Attachment: {1}".format(message.subject, attachment.name)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
""" | ||
""" | ||
from office365.graph_client import GraphClient | ||
from tests import test_client_id, test_password, test_tenant, test_username | ||
|
||
client = GraphClient.with_username_and_password( | ||
test_tenant, test_client_id, test_username, test_password | ||
) | ||
client.me.mail_folders["Inbox"].mark_all_items_as_unread().execute_query() | ||
print("All messages marked as read") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
""" | ||
Mark message as read example | ||
https://learn.microsoft.com/en-us/graph/api/message-update?view=graph-rest-1.0&tabs=http | ||
https://learn.microsoft.com/en-us/graph/api/message-update?view=graph-rest-1.0 | ||
""" | ||
|
||
import sys | ||
|
||
from office365.graph_client import GraphClient | ||
from office365.outlook.mail.messages.message import Message | ||
from tests.graph_case import acquire_token_by_username_password | ||
|
||
client = GraphClient(acquire_token_by_username_password) | ||
messages = client.me.messages.top(1).get().execute_query() | ||
if len(messages) == 0: | ||
sys.exit("No messages found") | ||
first_message = messages[0] # type: Message | ||
sys.exit("No messages were found") | ||
first_message = messages[0] | ||
first_message.set_property("isRead", True).update().execute_query() | ||
print("Message {0} has been marked as read".format(first_message.subject)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,12 +5,12 @@ | |
""" | ||
|
||
from office365.graph_client import GraphClient | ||
from tests import test_user_principal_name | ||
from tests import test_user_principal_name_alt | ||
from tests.graph_case import acquire_token_by_username_password | ||
|
||
client = GraphClient(acquire_token_by_username_password) | ||
client.me.send_mail( | ||
subject="Meet for lunch?", | ||
body="The new cafeteria is open.", | ||
to_recipients=["[email protected]", test_user_principal_name], | ||
to_recipients=["[email protected]", test_user_principal_name_alt], | ||
).execute_query() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
""" | ||
Create a message with a file attachment and send the message | ||
https://learn.microsoft.com/en-us/graph/api/user-sendmail?view=graph-rest-1.0&tabs=http | ||
https://learn.microsoft.com/en-us/graph/api/user-sendmail?view=graph-rest-1.0 | ||
""" | ||
|
||
from office365.graph_client import GraphClient | ||
from tests import test_user_principal_name_alt | ||
from tests.graph_case import acquire_token_by_username_password | ||
|
||
client = GraphClient(acquire_token_by_username_password) | ||
client.me.send_mail( | ||
subject="Meet for lunch?", | ||
body="The new cafeteria is open.", | ||
to_recipients=["[email protected]"], | ||
to_recipients=["[email protected]", test_user_principal_name_alt], | ||
).add_file_attachment( | ||
"attachment.txt", "--Some content goes here--", "text/plain" | ||
).execute_query() | ||
print("Message has been sent") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
from office365.sharepoint.client_context import ClientContext | ||
from office365.sharepoint.marketplace.app_metadata import CorporateCatalogAppMetadata | ||
from tests import test_admin_credentials, test_admin_site_url | ||
|
||
admin_client = ClientContext(test_admin_site_url).with_credentials( | ||
test_admin_credentials | ||
) | ||
apps = admin_client.web.tenant_app_catalog.available_apps.get().execute_query() | ||
for app in apps: # type: CorporateCatalogAppMetadata | ||
for app in apps: | ||
print(app.title) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
""" | ||
Demonstrates how to retain the history for list items. | ||
""" | ||
from office365.sharepoint.client_context import ClientContext | ||
from tests import test_client_credentials, test_team_site_url | ||
|
||
ctx = ClientContext(test_team_site_url).with_credentials(test_client_credentials) | ||
items = ( | ||
ctx.web.lists.get_by_title("Site Pages") | ||
.items.get() | ||
.expand(["Versions"]) | ||
.top(10) | ||
.execute_query() | ||
) | ||
|
||
for item in items: | ||
for version in item.versions: | ||
print(version) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
""" | ||
Retrieves site users | ||
""" | ||
|
||
from office365.sharepoint.client_context import ClientContext | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
""" | ||
Get OneDrive quota max for a user | ||
""" | ||
from office365.sharepoint.client_context import ClientContext | ||
from tests import test_password, test_site_url, test_username | ||
|
||
ctx = ClientContext(test_site_url).with_user_credentials(test_username, test_password) | ||
result = ctx.people_manager.get_user_onedrive_quota_max(test_username).execute_query() | ||
print(result.value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.