Skip to content

Commit 615211c

Browse files
committed
Examples update & Planner API fixes
1 parent 124423a commit 615211c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+384
-103
lines changed

examples/directory/users/create_activity.py

Lines changed: 0 additions & 9 deletions
This file was deleted.

examples/informationprotection/create_mail_assessment.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
44
"""
55
from office365.graph_client import GraphClient
6-
from tests.graph_case import acquire_token_by_username_password
6+
from tests import test_client_id, test_password, test_tenant, test_username
77

8-
client = GraphClient(acquire_token_by_username_password)
8+
client = GraphClient.with_username_and_password(
9+
test_tenant, test_client_id, test_username, test_password
10+
)
911
messages = client.me.messages.get().filter("isDraft eq false").top(1).execute_query()
1012
result = client.information_protection.create_mail_assessment(
1113
messages[0]

examples/onedrive/bundles/create.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
https://learn.microsoft.com/en-us/graph/api/drive-post-bundles?view=graph-rest-1.0&tabs=http#example-1-create-a-bundle
55
"""
66
from office365.graph_client import GraphClient
7-
from tests.graph_case import acquire_token_by_username_password
7+
from tests import test_client_id, test_password, test_tenant, test_username
88

9-
client = GraphClient(acquire_token_by_username_password)
9+
client = GraphClient.with_username_and_password(
10+
test_tenant, test_client_id, test_username, test_password
11+
)
1012
file_item = client.me.drive.root.get_by_path("Sample.html").get().execute_query()
1113
bundle = client.me.drive.create_bundle(
1214
"Just some files", [file_item.id]

examples/onedrive/columns/create_text.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,18 @@
55
"""
66

77
from office365.graph_client import GraphClient
8-
from tests import create_unique_name
9-
from tests.graph_case import acquire_token_by_username_password
8+
from tests import (
9+
create_unique_name,
10+
test_client_id,
11+
test_password,
12+
test_tenant,
13+
test_username,
14+
)
1015

11-
client = GraphClient(acquire_token_by_username_password)
12-
lib = client.sites.root.lists["Docs"]
16+
client = GraphClient.with_username_and_password(
17+
test_tenant, test_client_id, test_username, test_password
18+
)
19+
lib = client.sites.root.lists["Documents"]
1320
column_name = create_unique_name("TextColumn")
1421
column = lib.columns.add_text(column_name).execute_query()
1522
print(column.display_name)

examples/onedrive/drives/list_shared_with_me.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
https://learn.microsoft.com/en-us/graph/api/drive-sharedwithme?view=graph-rest-1.0
55
"""
66
from office365.graph_client import GraphClient
7-
from tests.graph_case import acquire_token_by_username_password
7+
from tests import test_client_id, test_password, test_tenant, test_username
88

9-
client = GraphClient(acquire_token_by_username_password)
9+
client = GraphClient.with_username_and_password(
10+
test_tenant, test_client_id, test_username, test_password
11+
)
1012
drive_items = client.me.drive.shared_with_me().execute_query()
1113
for item in drive_items:
1214
print("Drive Item url: {0}".format(item.web_url))

examples/onedrive/excel/read_table.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
44
https://learn.microsoft.com/en-us/graph/api/resources/excel?view=graph-rest-1.0#get-list-of-table-rows
55
"""
6-
from examples.onedrive import upload_excel_sample
76
from office365.graph_client import GraphClient
8-
from tests.graph_case import acquire_token_by_username_password
7+
from tests import test_client_id, test_password, test_tenant, test_username
98

10-
client = GraphClient(acquire_token_by_username_password)
11-
drive_item = upload_excel_sample(client)
9+
client = GraphClient.with_username_and_password(
10+
test_tenant, test_client_id, test_username, test_password
11+
)
12+
drive_item = client.me.drive.root.get_by_path("Financial Sample.xlsx")
1213
table = (
1314
drive_item.workbook.worksheets["Sheet1"].tables["financials"].get().execute_query()
1415
)

examples/onedrive/files/copy_file.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
This example copies a file identified by {server relative path} into a folder identified with a {server relative path}.
33
The new copy of the file will be named Sample (copy).rtf.
44
5-
https://learn.microsoft.com/en-us/graph/api/driveitem-copy?view=graph-rest-1.0&tabs=http
5+
https://learn.microsoft.com/en-us/graph/api/driveitem-copy?view=graph-rest-1.0
66
"""
77
from office365.graph_client import GraphClient
8-
from tests.graph_case import acquire_token_by_username_password
8+
from tests import test_client_id, test_password, test_tenant, test_username
99

10-
client = GraphClient(acquire_token_by_username_password)
10+
client = GraphClient.with_username_and_password(
11+
test_tenant, test_client_id, test_username, test_password
12+
)
1113
source_path = "archive/Sample.rtf"
1214
new_name = "Sample (copy).rtf"
1315
target_path = "archive/2018"

examples/onedrive/files/download.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@
77
import tempfile
88

99
from office365.graph_client import GraphClient
10+
from tests import test_client_id, test_password, test_tenant, test_username
1011
from tests.graph_case import acquire_token_by_username_password
1112

12-
client = GraphClient(acquire_token_by_username_password)
13+
client = GraphClient.with_username_and_password(
14+
test_tenant, test_client_id, test_username, test_password
15+
)
1316
# 1. address file by path
1417
# remote_path = "archive/countries.json"
1518
remote_path = "archive/Financial Sample.xlsx"

examples/onedrive/files/download_large.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,17 @@
1010
import tempfile
1111

1212
from office365.graph_client import GraphClient
13-
from tests.graph_case import acquire_token_by_username_password
13+
from tests import test_client_id, test_password, test_tenant, test_username
1414

1515

1616
def print_progress(offset):
1717
# type: (int) -> None
1818
print("Downloaded '{0}' bytes...".format(offset))
1919

2020

21-
client = GraphClient(acquire_token_by_username_password)
21+
client = GraphClient.with_username_and_password(
22+
test_tenant, test_client_id, test_username, test_password
23+
)
2224
# # 1. address file by path and get file metadata
2325
file_item = (
2426
client.me.drive.root.get_by_path("archive/big_buck_bunny.mp4").get().execute_query()

examples/onedrive/files/get_by_abs_url.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,18 @@
22
Retrieves file by absolute url
33
"""
44
from office365.graph_client import GraphClient
5-
from tests import test_team_site_url
6-
from tests.graph_case import acquire_token_by_username_password
5+
from tests import (
6+
test_client_id,
7+
test_password,
8+
test_team_site_url,
9+
test_tenant,
10+
test_username,
11+
)
712

813
file_abs_url = "{0}/Shared Documents/Financial Sample.xlsx".format(test_team_site_url)
914

10-
client = GraphClient(acquire_token_by_username_password)
15+
client = GraphClient.with_username_and_password(
16+
test_tenant, test_client_id, test_username, test_password
17+
)
1118
file_item = client.shares.by_url(file_abs_url).drive_item.get().execute_query()
1219
print(file_item.web_url)

0 commit comments

Comments
 (0)