Skip to content

Commit dd92579

Browse files
committed
introduced admin namespace with new types
1 parent 92fb43a commit dd92579

27 files changed

+299
-75
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
Gets Term by id
3+
"""
4+
5+
from office365.sharepoint.client_context import ClientContext
6+
from tests import test_client_credentials, test_team_site_url
7+
8+
ctx = ClientContext(test_team_site_url).with_credentials(test_client_credentials)
9+
term_guid = "f9a6dae9-633c-474b-b35e-b235cf2b9e73"
10+
taxonomy_list = ctx.web.lists.get_by_title("TaxonomyHiddenList")
11+
result = (
12+
taxonomy_list.items.first("IdForTerm eq '{0}'".format(term_guid))
13+
.get()
14+
.execute_query()
15+
)
16+
print(result.properties.get("Title"))

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="sharepoint",
29+
default="graph",
3030
)
3131
parser.add_argument(
3232
"-p",
3333
"--path",
3434
dest="path",
35-
default="./metadata/SharePoint.xml",
35+
default="./metadata/Graph.xml",
3636
help="Import metadata endpoint",
3737
)
3838

generator/metadata/Graph.xml

+5
Original file line numberDiff line numberDiff line change
@@ -39197,6 +39197,11 @@ within the time frame of their original request."/>
3919739197
<Parameter Name="value" Type="Collection(graph.site)"/>
3919839198
<ReturnType Type="Collection(graph.site)"/>
3919939199
</Action>
39200+
<Action Name="remove" IsBound="true">
39201+
<Parameter Name="bindingParameter" Type="Collection(graph.conversationMember)"/>
39202+
<Parameter Name="values" Type="Collection(graph.conversationMember)"/>
39203+
<ReturnType Type="Collection(graph.actionResultPart)"/>
39204+
</Action>
3920039205
<Function Name="getAllSites" IsBound="true">
3920139206
<Parameter Name="bindingParameter" Type="Collection(graph.site)"/>
3920239207
<ReturnType Type="Collection(graph.site)"/>

office365/admin/__init__.py

Whitespace-only changes.

office365/admin/admin.py

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
from office365.admin.microsoft365_apps import AdminMicrosoft365Apps
2+
from office365.admin.people_settings import PeopleAdminSettings
3+
from office365.admin.report_settings import AdminReportSettings
4+
from office365.admin.sharepoint import Sharepoint
5+
from office365.entity import Entity
6+
from office365.intune.servicecommunications.announcement import ServiceAnnouncement
7+
from office365.runtime.paths.resource_path import ResourcePath
8+
9+
10+
class Admin(Entity):
11+
"""Entity that acts as a container for administrator functionality."""
12+
13+
@property
14+
def microsoft365_apps(self):
15+
"""A container for the Microsoft 365 apps admin functionality."""
16+
return self.properties.get(
17+
"microsoft365Apps",
18+
AdminMicrosoft365Apps(
19+
self.context, ResourcePath("microsoft365Apps", self.resource_path)
20+
),
21+
)
22+
23+
@property
24+
def sharepoint(self):
25+
"""A container for administrative resources to manage tenant-level settings for SharePoint and OneDrive."""
26+
return self.properties.get(
27+
"sharepoint",
28+
Sharepoint(self.context, ResourcePath("sharepoint", self.resource_path)),
29+
)
30+
31+
@property
32+
def service_announcement(self):
33+
"""A container for service communications resources. Read-only."""
34+
return self.properties.get(
35+
"serviceAnnouncement",
36+
ServiceAnnouncement(
37+
self.context, ResourcePath("serviceAnnouncement", self.resource_path)
38+
),
39+
)
40+
41+
@property
42+
def report_settings(self):
43+
"""A container for administrative resources to manage reports."""
44+
return self.properties.get(
45+
"reportSettings",
46+
AdminReportSettings(
47+
self.context, ResourcePath("reportSettings", self.resource_path)
48+
),
49+
)
50+
51+
@property
52+
def people(self):
53+
"""Represents a setting to control people-related admin settings in the tenant."""
54+
return self.properties.get(
55+
"people",
56+
PeopleAdminSettings(
57+
self.context, ResourcePath("people", self.resource_path)
58+
),
59+
)
60+
61+
def get_property(self, name, default_value=None):
62+
if default_value is None:
63+
property_mapping = {
64+
"microsoft365Apps": self.microsoft365_apps,
65+
"serviceAnnouncement": self.service_announcement,
66+
"reportSettings": self.report_settings,
67+
}
68+
default_value = property_mapping.get(name, None)
69+
return super(Admin, self).get_property(name, default_value)

office365/admin/microsoft365_apps.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from office365.entity import Entity
2+
3+
4+
class AdminMicrosoft365Apps(Entity):
5+
"""Represents an entity that acts as a container for administrator functionality for Microsoft 365 applications."""

office365/admin/people_settings.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from office365.entity import Entity
2+
3+
4+
class PeopleAdminSettings(Entity):
5+
"""Represents a setting to control people-related admin settings in the tenant."""

office365/admin/report_settings.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from office365.entity import Entity
2+
3+
4+
class AdminReportSettings(Entity):
5+
"""Represents the tenant-level settings for Microsoft 365 reports."""

office365/onedrive/sharepoint.py renamed to office365/admin/sharepoint.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
from office365.admin.sharepoint_settings import SharepointSettings
12
from office365.entity import Entity
2-
from office365.onedrive.sharepoint_settings import SharepointSettings
33
from office365.runtime.paths.resource_path import ResourcePath
44

55

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from office365.directory.identitygovernance.privilegedaccess.schedule_instance import (
2+
PrivilegedAccessScheduleInstance,
3+
)
4+
5+
6+
class PrivilegedAccessGroupAssignmentScheduleInstance(PrivilegedAccessScheduleInstance):
7+
"""Represents an instance of a provisioned membership or ownership assignment in PIM for groups."""

office365/directory/rolemanagement/resource_action.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@
33

44

55
class ResourceAction(ClientValue):
6-
""" """
6+
"""Set of allowed and not allowed actions for a resource."""
77

8-
def __init__(self):
9-
self.allowedResourceActions = StringCollection()
10-
self.notAllowedResourceActions = StringCollection()
8+
def __init__(self, allowed=None, not_allowed=None):
9+
"""
10+
:param list[str] allowed: Allowed Actions
11+
:param list[str] not_allowed: Not Allowed Actions.
12+
"""
13+
self.allowedResourceActions = StringCollection(allowed)
14+
self.notAllowedResourceActions = StringCollection(not_allowed)

office365/directory/rolemanagement/role_permission.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
class RolePermission(ClientValue):
7-
""" """
7+
"""Contains the set of ResourceActions determining the allowed and not allowed permissions for each role."""
88

9-
def __init__(self, resourceActions=None):
10-
self.resourceActions = ClientValueCollection(ResourceAction, resourceActions)
9+
def __init__(self, resource_actions=None):
10+
self.resourceActions = ClientValueCollection(ResourceAction, resource_actions)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
from office365.directory.security.alerts.alert import Alert
2+
from office365.entity_collection import EntityCollection
3+
from office365.runtime.http.request_options import RequestOptions
4+
5+
6+
class AlertCollection(EntityCollection[Alert]):
7+
"""Service Principal's collection"""
8+
9+
def __init__(self, context, resource_path=None):
10+
super(AlertCollection, self).__init__(context, Alert, resource_path)
11+
12+
def add(
13+
self,
14+
title,
15+
description=None,
16+
severity=None,
17+
category=None,
18+
status=None,
19+
source=None,
20+
vendor_information=None,
21+
):
22+
"""
23+
Creates an alert object.
24+
:param str title:
25+
:param str description:
26+
:param str severity:
27+
:param str category:
28+
:param str status:
29+
:param str source:
30+
:param str vendor_information:
31+
"""
32+
33+
def _construct_request(request):
34+
# type: (RequestOptions) -> None
35+
request.set_header("Content-Type", "application/json")
36+
37+
return (
38+
super(AlertCollection, self)
39+
.add(
40+
title=title,
41+
description=description,
42+
severity=severity,
43+
category=category,
44+
status=status,
45+
source=source,
46+
vendorInformation=vendor_information,
47+
)
48+
.before_execute(_construct_request)
49+
)

office365/directory/security/scorecontrol/__init__.py

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from office365.entity import Entity
2+
3+
4+
class SecureScoreControlProfile(Entity):
5+
"""Represents a tenant's secure score per control data. By default, it returns all controls
6+
for a tenant and can explicitly pull individual controls."""

office365/directory/security/security.py

+17-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
from office365.directory.security.alerts.alert import Alert
2+
from office365.directory.security.alerts.collection import AlertCollection
23
from office365.directory.security.attacksimulations.root import AttackSimulationRoot
34
from office365.directory.security.cases.root import CasesRoot
45
from office365.directory.security.hunting_query_results import HuntingQueryResults
56
from office365.directory.security.incidents.incident import Incident
7+
from office365.directory.security.scorecontrol.profile import SecureScoreControlProfile
68
from office365.directory.security.threatintelligence.threat_intelligence import (
79
ThreatIntelligence,
810
)
@@ -35,12 +37,10 @@ def run_hunting_query(self, query):
3537

3638
@property
3739
def alerts(self):
38-
# type: () -> EntityCollection[Alert]
40+
# type: () -> AlertCollection
3941
return self.properties.get(
4042
"alerts",
41-
EntityCollection(
42-
self.context, Alert, ResourcePath("alerts", self.resource_path)
43-
),
43+
AlertCollection(self.context, ResourcePath("alerts", self.resource_path)),
4444
)
4545

4646
@property
@@ -83,6 +83,18 @@ def incidents(self):
8383
),
8484
)
8585

86+
@property
87+
def secure_score_control_profiles(self):
88+
""""""
89+
return self.properties.get(
90+
"secureScoreControlProfiles",
91+
EntityCollection(
92+
self.context,
93+
SecureScoreControlProfile,
94+
ResourcePath("secureScoreControlProfiles", self.resource_path),
95+
),
96+
)
97+
8698
@property
8799
def triggers(self):
88100
""""""
@@ -106,6 +118,7 @@ def get_property(self, name, default_value=None):
106118
property_mapping = {
107119
"alerts_v2": self.alerts_v2,
108120
"attackSimulation": self.attack_simulation,
121+
"secureScoreControlProfiles": self.secure_score_control_profiles,
109122
"threatIntelligence": self.threat_intelligence,
110123
}
111124
default_value = property_mapping.get(name, None)

office365/directory/tenant_relationship.py

-23
This file was deleted.

office365/directory/tenantinformation/__init__.py

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from office365.entity import Entity
2+
3+
4+
class MultiTenantOrganization(Entity):
5+
"""
6+
Defines an organization with more than one instance of Microsoft Entra ID. A multitenant organization enables
7+
multiple tenants to collaborate like a single entity.
8+
9+
There can only be one multitenant organization per active tenant. It is not possible to be part of multiple
10+
multitenant organizations.
11+
"""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
from office365.directory.tenantinformation.information import TenantInformation
2+
from office365.directory.tenantinformation.multi_organization import (
3+
MultiTenantOrganization,
4+
)
5+
from office365.entity import Entity
6+
from office365.runtime.client_result import ClientResult
7+
from office365.runtime.paths.resource_path import ResourcePath
8+
from office365.runtime.queries.function import FunctionQuery
9+
10+
11+
class TenantRelationship(Entity):
12+
"""Represent the various type of tenant relationships."""
13+
14+
def find_tenant_information_by_domain_name(self, domain_name):
15+
"""Given a domain name, search for a tenant and read its tenantInformation. You can use this API to
16+
validate tenant information and use their tenantId to configure cross-tenant access settings between you
17+
and the tenant.
18+
19+
:param str domain_name: Primary domain name of an Azure AD tenant.
20+
"""
21+
return_type = ClientResult(self.context, TenantInformation())
22+
params = {"domainName": domain_name}
23+
qry = FunctionQuery(
24+
self, "findTenantInformationByDomainName", params, return_type
25+
)
26+
self.context.add_query(qry)
27+
return return_type
28+
29+
def find_tenant_information_by_tenant_id(self, tenant_id):
30+
"""Given a tenant ID, search for a tenant and read its tenantInformation. You can use this API to validate
31+
tenant information and use the tenantId to configure cross-tenant cross-tenant access settings between you
32+
and the tenant.
33+
34+
:param str tenant_id: Unique tenant identifier of a Microsoft Entra tenant.
35+
"""
36+
return_type = ClientResult(self.context, TenantInformation())
37+
params = {"tenantId": tenant_id}
38+
qry = FunctionQuery(
39+
self, "findTenantInformationByTenantId", params, return_type
40+
)
41+
self.context.add_query(qry)
42+
return return_type
43+
44+
@property
45+
def multi_tenant_organization(self):
46+
"""Represents a setting to control people-related admin settings in the tenant."""
47+
return self.properties.get(
48+
"multiTenantOrganization",
49+
MultiTenantOrganization(
50+
self.context,
51+
ResourcePath("multiTenantOrganization", self.resource_path),
52+
),
53+
)
54+
55+
def get_property(self, name, default_value=None):
56+
if default_value is None:
57+
property_mapping = {
58+
"multiTenantOrganization": self.multi_tenant_organization,
59+
}
60+
default_value = property_mapping.get(name, None)
61+
return super(TenantRelationship, self).get_property(name, default_value)

0 commit comments

Comments
 (0)