Skip to content

Commit a914924

Browse files
committed
Intune API support & typings updates
1 parent c777594 commit a914924

File tree

35 files changed

+936
-87
lines changed

35 files changed

+936
-87
lines changed

examples/data/Financial Sample.csv

Lines changed: 701 additions & 0 deletions
Large diffs are not rendered by default.

examples/directory/applications/add_cert.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
88
"""
99

1010
from office365.graph_client import GraphClient
11-
from tests import test_client_id, test_tenant
12-
from tests.graph_case import acquire_token_by_username_password
11+
from tests import test_client_id, test_password, test_tenant, test_username
1312

1413
cert_path = "../../selfsigncert.pem"
1514

16-
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+
)
1718
target_app = client.applications.get_by_app_id(test_client_id)
1819
with open(cert_path, "rb") as f:
1920
cert_data = f.read()
Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
"""
22
Manage an Azure AD application using Microsoft Graph
33
4-
https://learn.microsoft.com/en-us/graph/tutorial-applications-basics?tabs=http
4+
https://learn.microsoft.com/en-us/graph/tutorial-applications-basics
55
66
You can address an application or a service principal by its ID or by its appId, where ID is referred to
77
as Object ID and appId is referred to as Application (client) ID on the Azure portal.
88
"""
99
from office365.graph_client import GraphClient
10-
from tests import test_client_credentials
11-
from tests.graph_case import acquire_token_by_client_credentials
12-
13-
client = GraphClient(acquire_token_by_client_credentials)
14-
app = (
15-
client.applications.get_by_app_id(test_client_credentials.clientId)
16-
.get()
17-
.execute_query()
10+
from tests import (
11+
test_client_id,
12+
test_client_secret,
13+
test_tenant,
1814
)
15+
16+
client = GraphClient.with_client_secret(test_tenant, test_client_id, test_client_secret)
17+
app = client.applications.get_by_app_id(test_client_id).get().execute_query()
1918
print(app)
Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
"""
22
Assign manager
33
4-
https://learn.microsoft.com/en-us/graph/api/user-post-manager?view=graph-rest-1.0&tabs=http
4+
https://learn.microsoft.com/en-us/graph/api/user-post-manager?view=graph-rest-1.0
55
"""
66
from office365.graph_client import GraphClient
7-
from tests import test_user_principal_name
8-
from tests.graph_case import acquire_token_by_username_password
7+
from tests import (
8+
test_client_id,
9+
test_password,
10+
test_tenant,
11+
test_user_principal_name,
12+
test_username,
13+
)
914

10-
client = GraphClient(acquire_token_by_username_password)
11-
user = client.users.get_by_principal_name(test_user_principal_name)
12-
manager = client.me.assign_manager(user).get().execute_query()
15+
client = GraphClient.with_username_and_password(
16+
test_tenant, test_client_id, test_username, test_password
17+
)
18+
manager = client.users.get_by_principal_name(test_user_principal_name)
19+
client.me.assign_manager(manager).get().execute_query()
1320
print("User manager has been assigned")

examples/directory/users/export_personal_data.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
https://learn.microsoft.com/en-us/graph/api/user-exportpersonaldata?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
result = client.me.export_personal_data("storageLocation-value").execute_query()
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"""
2+
Retrieve a list of licenseDetails objects for enterprise users.
3+
4+
https://learn.microsoft.com/en-us/graph/api/user-list-licensedetails?view=graph-rest-1.0
5+
"""
6+
from office365.graph_client import GraphClient
7+
from tests import (
8+
test_client_id,
9+
test_password,
10+
test_tenant,
11+
test_username,
12+
)
13+
14+
client = GraphClient.with_username_and_password(
15+
test_tenant, test_client_id, test_username, test_password
16+
)
17+
result = client.me.license_details.get().execute_query()
18+
for details in result:
19+
print(details)

examples/onedrive/files/upload.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
Demonstrates how to upload a small file
33
4-
https://learn.microsoft.com/en-us/graph/api/driveitem-put-content?view=graph-rest-1.0&tabs=http
4+
https://learn.microsoft.com/en-us/graph/api/driveitem-put-content?view=graph-rest-1.0
55
"""
66

77
from office365.graph_client import GraphClient

examples/onedrive/folders/export.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,14 @@
99

1010
from office365.graph_client import GraphClient
1111
from office365.onedrive.driveitems.driveItem import DriveItem
12-
from tests import test_user_principal_name
13-
from tests.graph_case import acquire_token_by_client_credentials
12+
from tests import (
13+
test_client_id,
14+
test_client_secret,
15+
test_tenant,
16+
test_user_principal_name,
17+
)
1418

15-
client = GraphClient(acquire_token_by_client_credentials)
19+
client = GraphClient.with_client_secret(test_tenant, test_client_id, test_client_secret)
1620
drive = client.users[test_user_principal_name].drive
1721
with tempfile.TemporaryDirectory() as local_path:
1822
drive_items = drive.root.children.get().execute_query()

examples/onedrive/sites/get_all.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
https://learn.microsoft.com/en-us/graph/api/site-getallsites?view=graph-rest-1.0
55
"""
66
from office365.graph_client import GraphClient
7-
from tests.graph_case import acquire_token_by_client_credentials
7+
from tests import test_client_id, test_client_secret, test_tenant
88

9-
client = GraphClient(acquire_token_by_client_credentials)
9+
client = GraphClient.with_client_secret(test_tenant, test_client_id, test_client_secret)
1010
sites = client.sites.get_all_sites().execute_query()
1111
print("{0} sites was found".format(len(sites)))

examples/outlook/messages/send.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,17 @@
55
"""
66

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

11-
client = GraphClient(acquire_token_by_username_password)
16+
client = GraphClient.with_username_and_password(
17+
test_tenant, test_client_id, test_username, test_password
18+
)
1219
client.me.send_mail(
1320
subject="Meet for lunch?",
1421
body="The new cafeteria is open.",

0 commit comments

Comments
 (0)