Skip to content

Commit 39c31d4

Browse files
committed
Introduced support for M365 Backup Storage service
1 parent d65ef80 commit 39c31d4

File tree

20 files changed

+366
-55
lines changed

20 files changed

+366
-55
lines changed

examples/directory/applications/get_delegated_permissions.py renamed to examples/directory/applications/get_delegated_perms.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@
55
"""
66

77
from office365.graph_client import GraphClient
8-
from tests import test_client_id, test_password, test_tenant, test_username
8+
from tests import (
9+
test_client_id,
10+
test_password,
11+
test_tenant,
12+
test_username,
13+
)
914

1015
client = GraphClient.with_username_and_password(
1116
test_tenant, test_client_id, test_username, test_password

examples/directory/applications/grant_delegated_perms.py

+2-11
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,7 @@
2121

2222

2323
resource = client.service_principals.get_by_name("Microsoft Graph")
24-
app_role = "User.Read.All"
24+
# app_role = "User.Read.All"
25+
app_role = "BackupRestore-Control.Read.All"
2526
user = client.users.get_by_principal_name(test_user_principal_name)
2627
resource.grant_delegated(test_client_id, user, app_role).execute_query()
27-
28-
29-
# Confirm and print permission grants
30-
result = (
31-
client.oauth2_permission_grants.filter("clientId eq '{0}'".format(test_client_id))
32-
.get()
33-
.execute_query()
34-
)
35-
for grant in result:
36-
print(grant)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
"""
2+
Determines whether the delegated permissions is defined by the Microsoft Graph service principal in the tenant.
3+
4+
https://learn.microsoft.com/en-us/graph/permissions-grant-via-msgraph?tabs=http&pivots=grant-delegated-permissions
5+
"""
6+
7+
from office365.graph_client import GraphClient
8+
from tests import (
9+
test_admin_principal_name,
10+
test_client_id,
11+
test_password,
12+
test_tenant,
13+
test_user_principal_name,
14+
test_username,
15+
)
16+
17+
# client = GraphClient.with_username_and_password(
18+
# test_tenant, test_client_id, test_username, test_password
19+
# )
20+
client = GraphClient.with_token_interactive(
21+
test_tenant, test_client_id, test_admin_principal_name
22+
)
23+
24+
resource = client.service_principals.get_by_name("Microsoft Graph")
25+
# app_role = "User.Read.All"
26+
app_role = "BackupRestore-Control.Read.All"
27+
user = client.users.get_by_principal_name(test_admin_principal_name)
28+
client_app = client.applications.get_by_app_id(test_client_id)
29+
# result = resource.get_delegated(client_app, user, app_role).execute_query()
30+
result = resource.get_delegated(test_client_id, user, app_role).execute_query()
31+
if len(result) == 0:
32+
print("Delegated permission '{0}' is not set".format(app_role))
33+
else:
34+
print(result.value)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""
2+
How to grant and revoke delegated permissions for an app using Microsoft Graph.
3+
Delegated permissions, also called scopes or OAuth2 permissions, allow an app to call an API
4+
on behalf of a signed-in user.
5+
6+
7+
https://learn.microsoft.com/en-us/graph/permissions-grant-via-msgraph?tabs=http&pivots=grant-delegated-permissions
8+
"""
9+
10+
from office365.graph_client import GraphClient
11+
from tests import (
12+
test_admin_principal_name,
13+
test_client_id,
14+
test_tenant,
15+
test_user_principal_name,
16+
)
17+
18+
client = GraphClient.with_token_interactive(
19+
test_tenant, test_client_id, test_admin_principal_name
20+
)
21+
22+
23+
resource = client.service_principals.get_by_name("Microsoft Graph")
24+
user = client.users.get_by_principal_name(test_user_principal_name)
25+
result = resource.get_delegated(test_client_id, user).execute_query()
26+
27+
for grant in result:
28+
print(grant)

examples/onedrive/lists/list_in_site.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
client = GraphClient.with_client_secret(test_tenant, test_client_id, test_client_secret)
1111
lists = client.sites.root.lists.get().execute_query()
1212
for lst in lists:
13-
print(lst.display_name)
13+
print(lst)

generator/import_metadata.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ def export_to_file(path, content):
2626
"--endpoint",
2727
dest="endpoint",
2828
help="Import metadata endpoint",
29-
default="graph",
29+
default="sharepoint",
3030
)
3131
parser.add_argument(
3232
"-p",
3333
"--path",
3434
dest="path",
35-
default="./metadata/MicrosoftGraph.xml",
35+
default="./metadata/SharePoint.xml",
3636
help="Import metadata endpoint",
3737
)
3838

generator/metadata/MicrosoftGraph.xml

+17
Original file line numberDiff line numberDiff line change
@@ -16894,6 +16894,12 @@
1689416894
<Annotations Target="microsoft.graph.disconnect(microsoft.graph.remoteAssistancePartner)">
1689516895
<Annotation Term="Org.OData.Core.V1.Description" String="A request to remove the active TeamViewer connector"/>
1689616896
</Annotations>
16897+
<Annotations Target="microsoft.graph.endWorkingTime(microsoft.graph.workingTimeSchedule)">
16898+
<Annotation Term="Org.OData.Core.V1.Description" String="Triggers the policies associated with the end of working hours for user."/>
16899+
</Annotations>
16900+
<Annotations Target="microsoft.graph.startWorkingTime(microsoft.graph.workingTimeSchedule)">
16901+
<Annotation Term="Org.OData.Core.V1.Description" String="Triggers the policies associated with the start of working hours for user."/>
16902+
</Annotations>
1689716903
</Schema>
1689816904
<Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="microsoft.graph" Alias="graph">
1689916905
<EnumType Name="appliedConditionalAccessPolicyResult">
@@ -23017,6 +23023,7 @@
2301723023
<NavigationProperty Name="joinedTeams" Type="Collection(graph.team)" ContainsTarget="true"/>
2301823024
<NavigationProperty Name="permissionGrants" Type="Collection(graph.resourceSpecificPermissionGrant)" ContainsTarget="true"/>
2301923025
<NavigationProperty Name="teamwork" Type="graph.userTeamwork" ContainsTarget="true"/>
23026+
<NavigationProperty Name="solutions" Type="graph.userSolutionRoot" ContainsTarget="true"/>
2302023027
<NavigationProperty Name="todo" Type="graph.todo" ContainsTarget="true"/>
2302123028
<NavigationProperty Name="employeeExperience" Type="graph.employeeExperienceUser" ContainsTarget="true"/>
2302223029
</EntityType>
@@ -23446,6 +23453,9 @@
2344623453
<NavigationProperty Name="associatedTeams" Type="Collection(graph.associatedTeamInfo)" ContainsTarget="true"/>
2344723454
<NavigationProperty Name="installedApps" Type="Collection(graph.userScopeTeamsAppInstallation)" ContainsTarget="true"/>
2344823455
</EntityType>
23456+
<EntityType Name="userSolutionRoot" BaseType="graph.entity">
23457+
<NavigationProperty Name="workingTimeSchedule" Type="graph.workingTimeSchedule" ContainsTarget="true"/>
23458+
</EntityType>
2344923459
<EntityType Name="todo" BaseType="graph.entity">
2345023460
<NavigationProperty Name="lists" Type="Collection(graph.todoTaskList)" ContainsTarget="true"/>
2345123461
</EntityType>
@@ -34560,6 +34570,7 @@
3456034570
<Property Name="sharedTimeOff" Type="graph.timeOffItem"/>
3456134571
<Property Name="userId" Type="Edm.String"/>
3456234572
</EntityType>
34573+
<EntityType Name="workingTimeSchedule" BaseType="graph.entity"/>
3456334574
<EntityType Name="emailFileAssessmentRequest" BaseType="graph.threatAssessmentRequest">
3456434575
<Property Name="contentData" Type="Edm.String" Nullable="false"/>
3456534576
<Property Name="destinationRoutingReason" Type="graph.mailDestinationRoutingReason"/>
@@ -40310,6 +40321,12 @@
4031040321
<Parameter Name="startDateTime" Type="Edm.DateTimeOffset"/>
4031140322
<Parameter Name="endDateTime" Type="Edm.DateTimeOffset"/>
4031240323
</Action>
40324+
<Action Name="endWorkingTime" IsBound="true">
40325+
<Parameter Name="bindparameter" Type="graph.workingTimeSchedule" Nullable="false"/>
40326+
</Action>
40327+
<Action Name="startWorkingTime" IsBound="true">
40328+
<Parameter Name="bindparameter" Type="graph.workingTimeSchedule" Nullable="false"/>
40329+
</Action>
4031340330
<EntityContainer Name="GraphService">
4031440331
<EntitySet Name="directoryObjects" EntityType="microsoft.graph.directoryObject"/>
4031540332
<EntitySet Name="invitations" EntityType="microsoft.graph.invitation">

0 commit comments

Comments
 (0)