Skip to content

Commit c413586

Browse files
committed
directory & teams new types and methods
1 parent b59e027 commit c413586

File tree

35 files changed

+643
-137
lines changed

35 files changed

+643
-137
lines changed

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/Graph.xml",
35+
default="./metadata/SharePoint.xml",
3636
help="Import metadata endpoint",
3737
)
3838

generator/metadata/Graph.xml

+112-3
Large diffs are not rendered by default.

generator/metadata/SharePoint.xml

+195-105
Large diffs are not rendered by default.

office365/communications/calls/participant.py

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
InvitationParticipantInfo,
55
)
66
from office365.communications.calls.participant_info import ParticipantInfo
7+
from office365.communications.onlinemeetings.restricted import OnlineMeetingRestricted
78
from office365.communications.operations.invite_participants import (
89
InviteParticipantsOperation,
910
)
@@ -73,3 +74,8 @@ def metadata(self):
7374
# type: () -> Optional[str]
7475
"""A blob of data provided by the participant in the roster."""
7576
return self.properties.get("metadata", None)
77+
78+
@property
79+
def restricted_experience(self):
80+
"""Information about the reason or reasons media content from a participant is restricted."""
81+
return self.properties.get("restrictedExperience", OnlineMeetingRestricted())
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from office365.runtime.client_value import ClientValue
2+
3+
4+
class OnlineMeetingRestricted(ClientValue):
5+
"""Indicates the reason or reasons media content from a participant is restricted."""

office365/directory/applications/collection.py

+11
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ class ApplicationCollection(DeltaCollection[Application]):
99
def __init__(self, context, resource_path=None):
1010
super(ApplicationCollection, self).__init__(context, Application, resource_path)
1111

12+
def add(self, display_name, **kwargs):
13+
"""
14+
Create a new application object.
15+
:param str display_name: Display name of the application.
16+
"""
17+
props = {
18+
"displayName": display_name,
19+
**kwargs,
20+
}
21+
return super(ApplicationCollection, self).add(**props)
22+
1223
def get_by_app_id(self, app_id):
1324
# type: (str) -> Application
1425
"""Retrieves application by Application client identifier

office365/directory/identitygovernance/appconsent/request.py

+9
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,12 @@ def user_consent_requests(self):
5656
self.context, ResourcePath("userConsentRequests", self.resource_path)
5757
),
5858
)
59+
60+
def get_property(self, name, default_value=None):
61+
if default_value is None:
62+
property_mapping = {
63+
"pendingScopes": self.pending_scopes,
64+
"userConsentRequests": self.user_consent_requests,
65+
}
66+
default_value = property_mapping.get(name, None)
67+
return super(AppConsentRequest, self).get_property(name, default_value)

office365/directory/protection/information.py

+19-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from office365.directory.protection.threatassessment.request import (
1+
from office365.directory.protection.threatassessment.requests.request import (
22
ThreatAssessmentRequest,
33
)
44
from office365.entity import Entity
@@ -11,6 +11,23 @@
1111
class InformationProtection(Entity):
1212
"""Exposes methods that you can use to get Microsoft Purview Information Protection labels and label policies."""
1313

14+
def create_url_assessment(self, url, expected_assessment, category):
15+
"""Create a new threat assessment request."""
16+
from office365.directory.protection.threatassessment.requests.url import (
17+
UrlAssessmentRequest,
18+
)
19+
20+
return_type = UrlAssessmentRequest(self.context)
21+
return_type.set_property("url", url)
22+
return_type.set_property("expectedAssessment", expected_assessment)
23+
return_type.set_property("category", category)
24+
self.threat_assessment_requests.add_child(return_type)
25+
qry = CreateEntityQuery(
26+
self.threat_assessment_requests, return_type, return_type
27+
)
28+
self.context.add_query(qry)
29+
return return_type
30+
1431
def create_mail_assessment(
1532
self, message, recipient=None, expected_assessment="block", category="spam"
1633
):
@@ -22,7 +39,7 @@ def create_mail_assessment(
2239
:param str category:
2340
"""
2441

25-
from office365.directory.protection.threatassessment.mail_request import (
42+
from office365.directory.protection.threatassessment.requests.mail import (
2643
MailAssessmentRequest,
2744
)
2845

office365/directory/protection/threatassessment/requests/__init__.py

Whitespace-only changes.

office365/directory/protection/threatassessment/email_file_request.py renamed to office365/directory/protection/threatassessment/requests/email_file.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import Optional
22

3-
from office365.directory.protection.threatassessment.request import (
3+
from office365.directory.protection.threatassessment.requests.request import (
44
ThreatAssessmentRequest,
55
)
66

@@ -18,3 +18,11 @@ def content_data(self):
1818
Base64 encoded .eml email file content. The file content can't fetch back because it isn't stored.
1919
"""
2020
return self.properties.get("contentData", None)
21+
22+
@property
23+
def file_name(self):
24+
# type: () -> Optional[str]
25+
"""
26+
Base64 encoded .eml email file content. The file content can't fetch back because it isn't stored.
27+
"""
28+
return self.properties.get("fileName", None)

office365/directory/protection/threatassessment/mail_request.py renamed to office365/directory/protection/threatassessment/requests/mail.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from office365.directory.protection.threatassessment.request import (
1+
from office365.directory.protection.threatassessment.requests.request import (
22
ThreatAssessmentRequest,
33
)
44

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from office365.directory.protection.threatassessment.requests.request import (
2+
ThreatAssessmentRequest,
3+
)
4+
5+
6+
class UrlAssessmentRequest(ThreatAssessmentRequest):
7+
"""
8+
Used to create and retrieve a URL threat assessment, derived from threatAssessmentRequest.
9+
"""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from office365.entity import Entity
2+
3+
4+
class AppScope(Entity):
5+
"""
6+
The scope of a role assignment determines the set of resources for which the principal has been granted access.
7+
An app scope is a scope defined and understood by a specific application, unlike directory scopes that are
8+
shared scopes stored in the directory and understood by multiple applications.
9+
10+
This may be in both the following principal and scope scenarios:
11+
12+
A single principal and a single scope
13+
Multiple principals and multiple scopes.
14+
"""

office365/directory/rolemanagement/application.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from office365.directory.identitygovernance.privilegedaccess.unified_role_assignment_schedule_request import (
22
UnifiedRoleAssignmentScheduleRequest,
33
)
4-
from office365.directory.rolemanagement.unified_role_assignment import (
4+
from office365.directory.rolemanagement.unifiedrole.assignment import (
55
UnifiedRoleAssignment,
66
)
7-
from office365.directory.rolemanagement.unified_role_definition import (
7+
from office365.directory.rolemanagement.unifiedrole.definition import (
88
UnifiedRoleDefinition,
99
)
1010
from office365.entity import Entity
@@ -31,6 +31,7 @@ def role_assignments(self):
3131
),
3232
)
3333

34+
@property
3435
def role_definitions(self):
3536
# type: () -> EntityCollection[UnifiedRoleDefinition]
3637
"""Resource representing the roles allowed by RBAC providers and the permissions assigned to the roles."""

office365/directory/rolemanagement/unifiedrole/__init__.py

Whitespace-only changes.

office365/directory/rolemanagement/unified_role_assignment.py renamed to office365/directory/rolemanagement/unifiedrole/assignment.py

+37-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from typing import Optional
22

3-
from office365.directory.rolemanagement.unified_role_definition import (
3+
from office365.directory.rolemanagement.app_scope import AppScope
4+
from office365.directory.rolemanagement.unifiedrole.definition import (
45
UnifiedRoleDefinition,
56
)
67
from office365.entity import Entity
@@ -30,6 +31,29 @@ def condition(self):
3031
""" """
3132
return self.properties.get("condition", None)
3233

34+
@property
35+
def principal_id(self):
36+
# type: () -> Optional[str]
37+
"""Identifier of the principal to which the assignment is granted. Supported principals are users,
38+
role-assignable groups, and service principals. Supports $filter (eq, in)."""
39+
return self.properties.get("principalId", None)
40+
41+
@property
42+
def role_definition_id(self):
43+
# type: () -> Optional[str]
44+
"""Identifier of the unifiedRoleDefinition the assignment is for. Read-only. Supports $filter (eq, in)."""
45+
return self.properties.get("roleDefinitionId", None)
46+
47+
@property
48+
def directory_scope_id(self):
49+
# type: () -> Optional[str]
50+
"""Identifier of the directory object representing the scope of the assignment.
51+
The scope of an assignment determines the set of resources for which the principal has been granted access.
52+
Directory scopes are shared scopes stored in the directory that are understood by multiple applications,
53+
unlike app scopes that are defined and understood by a resource application only. Supports $filter (eq, in).
54+
"""
55+
return self.properties.get("directoryScopeId", None)
56+
3357
@property
3458
def role_definition(self):
3559
"""
@@ -42,9 +66,21 @@ def role_definition(self):
4266
),
4367
)
4468

69+
@property
70+
def app_scope(self):
71+
"""
72+
Read-only property with details of the app specific scope when the assignment scope is app specific.
73+
Containment entity. Supports $expand for the entitlement provider only.
74+
"""
75+
return self.properties.get(
76+
"appScope",
77+
AppScope(self.context, ResourcePath("appScope", self.resource_path)),
78+
)
79+
4580
def get_property(self, name, default_value=None):
4681
if default_value is None:
4782
property_mapping = {
83+
"appScope": self.app_scope,
4884
"roleDefinition": self.role_definition,
4985
}
5086
default_value = property_mapping.get(name, None)

office365/directory/rolemanagement/unified_role_definition.py renamed to office365/directory/rolemanagement/unifiedrole/definition.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import Optional
22

3-
from office365.directory.rolemanagement.unified_role_permission import (
3+
from office365.directory.rolemanagement.unifiedrole.permission import (
44
UnifiedRolePermission,
55
)
66
from office365.entity import Entity
@@ -13,6 +13,9 @@ class UnifiedRoleDefinition(Entity):
1313
"""A role definition is a collection of permissions in Azure Active Directory (Azure AD) listing the operations
1414
that can be performed and the resources against which they can performed."""
1515

16+
def __str__(self):
17+
return self.display_name or self.entity_type_name
18+
1619
@property
1720
def display_name(self):
1821
# type: () -> Optional[str]
@@ -29,6 +32,7 @@ def is_built_in(self):
2932

3033
@property
3134
def role_permissions(self):
35+
# type: () -> ClientValueCollection[UnifiedRolePermission]
3236
"""
3337
List of permissions included in the role. Read-only when isBuiltIn is true. Required.
3438
"""
@@ -56,6 +60,7 @@ def get_property(self, name, default_value=None):
5660
if default_value is None:
5761
property_mapping = {
5862
"inheritsPermissionsFrom": self.inherits_permissions_from,
63+
"rolePermissions": self.role_permissions,
5964
}
6065
default_value = property_mapping.get(name, None)
6166
return super(UnifiedRoleDefinition, self).get_property(name, default_value)

office365/directory/users/activities/activity.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ def created_datetime(self):
5757
"""Set by the server. DateTime in UTC when the object was created on the server."""
5858
return self.properties.get("createdDateTime", datetime.min)
5959

60+
@property
61+
def expiration_datetime(self):
62+
"""Set by the server. DateTime in UTC when the object was created on the server."""
63+
return self.properties.get("expirationDateTime", datetime.min)
64+
6065
@property
6166
def history_items(self):
6267
"""NavigationProperty/Containment; navigation property to the associated activity."""
@@ -75,6 +80,10 @@ def history_items(self):
7580

7681
def get_property(self, name, default_value=None):
7782
if default_value is None:
78-
property_mapping = {"historyItems": self.history_items}
83+
property_mapping = {
84+
"createdDateTime": self.created_datetime,
85+
"expirationDateTime": self.expiration_datetime,
86+
"historyItems": self.history_items,
87+
}
7988
default_value = property_mapping.get(name, None)
8089
return super(UserActivity, self).get_property(name, default_value)

office365/directory/users/user.py

+41
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
from office365.directory.authentication.authentication import Authentication
1515
from office365.directory.extensions.extension import Extension
1616
from office365.directory.identities.object_identity import ObjectIdentity
17+
from office365.directory.identitygovernance.termsofuse.agreement_acceptance import (
18+
AgreementAcceptance,
19+
)
1720
from office365.directory.insights.office_graph import OfficeGraphInsights
1821
from office365.directory.licenses.assigned_license import AssignedLicense
1922
from office365.directory.licenses.assigned_plan import AssignedPlan
@@ -55,6 +58,7 @@
5558
from office365.outlook.mail.messages.message import Message
5659
from office365.outlook.mail.recipient import Recipient
5760
from office365.outlook.mail.tips.tips import MailTips
61+
from office365.outlook.person import Person
5862
from office365.outlook.user import OutlookUser
5963
from office365.planner.user import PlannerUser
6064
from office365.runtime.client_result import ClientResult
@@ -69,6 +73,7 @@
6973
from office365.runtime.types.collections import StringCollection
7074
from office365.teams.chats.collection import ChatCollection
7175
from office365.teams.collection import TeamCollection
76+
from office365.teams.teamwork.shiftmanagement.user_solution_root import UserSolutionRoot
7277
from office365.teams.teamwork.user import UserTeamwork
7378
from office365.teams.viva.employee_experience_user import EmployeeExperienceUser
7479
from office365.todo.todo import Todo
@@ -1025,6 +1030,17 @@ def outlook(self):
10251030
OutlookUser(self.context, ResourcePath("outlook", self.resource_path)),
10261031
)
10271032

1033+
@property
1034+
def people(self):
1035+
# type: () -> EntityCollection[Person]
1036+
"""People that are relevant to the user. Read-only. Nullable."""
1037+
return self.properties.get(
1038+
"people",
1039+
EntityCollection(
1040+
self.context, Person, ResourcePath("people", self.resource_path)
1041+
),
1042+
)
1043+
10281044
@property
10291045
def onenote(self):
10301046
# type: () -> Onenote
@@ -1050,6 +1066,20 @@ def planner(self):
10501066
PlannerUser(self.context, ResourcePath("planner", self.resource_path)),
10511067
)
10521068

1069+
@property
1070+
def agreement_acceptances(self):
1071+
"""
1072+
The user's terms of use acceptance statuses
1073+
"""
1074+
return self.properties.get(
1075+
"agreementAcceptances",
1076+
EntityCollection(
1077+
self.context,
1078+
AgreementAcceptance,
1079+
ResourcePath("agreementAcceptances", self.resource_path),
1080+
),
1081+
)
1082+
10531083
@property
10541084
def extensions(self):
10551085
# type: () -> EntityCollection[Extension]
@@ -1140,6 +1170,17 @@ def teamwork(self):
11401170
UserTeamwork(self.context, ResourcePath("teamwork", self.resource_path)),
11411171
)
11421172

1173+
@property
1174+
def solutions(self):
1175+
# type: () -> UserSolutionRoot
1176+
"""The identifier that relates the user to the working time schedule triggers. Read-Only. Nullable."""
1177+
return self.properties.get(
1178+
"solutions",
1179+
UserSolutionRoot(
1180+
self.context, ResourcePath("solutions", self.resource_path)
1181+
),
1182+
)
1183+
11431184
@property
11441185
def todo(self):
11451186
# type: () -> Todo

office365/entity_collection.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def create_typed_object(self, initial_properties=None, resource_path=None):
7373

7474
def set_property(self, key, value, persist_changes=False):
7575
# type: (str | int, dict, bool) -> Self
76-
if key == "__deltaLinkUrl":
76+
if key == self.context.pending_request().json_format.collection_delta:
7777
self._delta_request_url = value
7878
else:
7979
super(EntityCollection, self).set_property(key, value, persist_changes)

0 commit comments

Comments
 (0)