Skip to content

Commit b2915c8

Browse files
committed
brandcenter namespace new types & methods, introduced test decorator for checking app perms
1 parent 3667b2b commit b2915c8

File tree

51 files changed

+501
-79
lines changed

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

+501
-79
lines changed

examples/auth/with_adal.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,19 @@
66
"""
77

88
from office365.graph_client import GraphClient
9-
from tests import load_settings
9+
from tests import test_tenant_name, test_client_id, test_username, test_password
1010

1111

1212
def acquire_token():
1313
import adal # pylint: disable=E0401
1414

15-
settings = load_settings()
16-
authority_url = "https://login.microsoftonline.com/{0}".format(
17-
settings["default"]["tenant"]
18-
)
15+
authority_url = "https://login.microsoftonline.com/{0}".format(test_tenant_name)
1916
auth_ctx = adal.AuthenticationContext(authority_url)
2017
token = auth_ctx.acquire_token_with_username_password(
2118
"https://graph.microsoft.com",
22-
settings["user_credentials"]["username"],
23-
settings["user_credentials"]["password"],
24-
settings["client_credentials"]["client_id"],
19+
test_username,
20+
test_password,
21+
test_client_id,
2522
)
2623
return token
2724

examples/directory/applications/has_application_perms.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,10 @@
2020

2121

2222
resource = client.service_principals.get_by_name("Microsoft Graph")
23-
app_role = "ThreatAssessment.Read.All" # "Bookings.Read.All"
23+
app_role = "Place.Read.All" # "Bookings.Read.All"
2424
result = resource.get_application_permissions(test_client_id).execute_query()
25-
if (
26-
len([cur_app_role for cur_app_role in result.value if cur_app_role == app_role])
27-
== 0
28-
):
25+
#if app_role not in result.value:
26+
if not any(role.value == app_role for role in result.value):
2927
print("Application permission '{0}' is not granted".format(app_role))
3028
else:
3129
print(result.value)

examples/security/run_hunting_query.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616
test_client_id, test_client_secret
1717
)
1818
query = """
19-
DeviceProcessEvents | where InitiatingProcessFileName =~ \"powershell.exe\" | project Timestamp, FileName, \
20-
InitiatingProcessFileName | order by Timestamp desc | limit 2"""
19+
DeviceProcessEvents
20+
| where InitiatingProcessFileName =~ \"powershell.exe\"
21+
| project Timestamp, FileName, InitiatingProcessFileName
22+
| order by Timestamp desc | limit 2"""
23+
2124
result = client.security.run_hunting_query(query).execute_query()
2225
print(result.value)

generator/import_metadata.py

Lines changed: 2 additions & 2 deletions
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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from office365.entity import Entity
2+
3+
4+
class ProtectionRuleBase(Entity):
5+
"""Represents a protection rule specified by the client as part of a protection plan applied to
6+
Microsoft 365 data in an organization. Currently, only inclusion rules, which are rules that indicate
7+
that a protection policy should match the specified criteria, can be defined.
8+
9+
Currently, protection Rules are static in nature, meaning policy changes are applied only when the
10+
rule is executed, with no automatic/dynamic updates."""

office365/backuprestore/root.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,22 @@
44
)
55
from office365.entity import Entity
66
from office365.entity_collection import EntityCollection
7+
from office365.runtime.client_result import ClientResult
78
from office365.runtime.paths.resource_path import ResourcePath
9+
from office365.runtime.queries.service_operation import ServiceOperationQuery
810

911

1012
class BackupRestoreRoot(Entity):
1113
"""Represents the Microsoft 365 Backup Storage service in a tenant."""
1214

15+
def enable(self, app_owner_tenant_id):
16+
"""Enable the Microsoft 365 Backup Storage service for a tenant."""
17+
return_type = ClientResult(self.context, ServiceStatus())
18+
payload = {"appOwnerTenantId": app_owner_tenant_id}
19+
qry = ServiceOperationQuery(self, "enable", None, payload, None, return_type)
20+
self.context.add_query(qry)
21+
return return_type
22+
1323
@property
1424
def service_status(self):
1525
"""Represents the tenant-level status of the Backup Storage service."""

office365/booking/service.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import Optional
2+
13
from office365.entity import Entity
24

35

@@ -6,3 +8,9 @@ class BookingService(Entity):
68
Represents information about a particular service provided by a bookingBusiness, such as the service name,
79
price, and the staff that usually provides such service.
810
"""
11+
12+
@property
13+
def additional_information(self):
14+
# type: () -> Optional[str]
15+
"""Additional information that is sent to the customer when an appointment is confirmed."""
16+
return self.properties.get("additionalInformation", None)

office365/booking/solutions/root.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from office365.backuprestore.root import BackupRestoreRoot
22
from office365.booking.business.collection import BookingBusinessCollection
33
from office365.booking.currency import BookingCurrency
4+
from office365.communications.virtualevents.root import VirtualEventsRoot
45
from office365.entity import Entity
56
from office365.entity_collection import EntityCollection
67
from office365.runtime.paths.resource_path import ResourcePath
@@ -43,12 +44,25 @@ def backup_restore(self):
4344
),
4445
)
4546

47+
@property
48+
def virtual_events(self):
49+
# type: () -> VirtualEventsRoot
50+
"""A collection of virtual events."""
51+
return self.properties.get(
52+
"virtualEvents",
53+
VirtualEventsRoot(
54+
self.context,
55+
ResourcePath("virtualEvents", self.resource_path),
56+
),
57+
)
58+
4659
def get_property(self, name, default_value=None):
4760
if default_value is None:
4861
property_mapping = {
4962
"bookingBusinesses": self.booking_businesses,
5063
"bookingCurrencies": self.booking_currencies,
5164
"backupRestore": self.backup_restore,
65+
"virtualEvents": self.virtual_events,
5266
}
5367
default_value = property_mapping.get(name, None)
5468
return super(SolutionsRoot, self).get_property(name, default_value)

office365/booking/staff/member.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from office365.booking.staff.member_base import BookingStaffMemberBase
2+
3+
4+
class BookingStaffMember(BookingStaffMemberBase):
5+
"""Represents a staff member who provides services in a bookingBusiness.
6+
7+
Staff members can be part of the Microsoft 365 tenant where the booking business is configured,
8+
or they can use email services from other email providers."""

0 commit comments

Comments
 (0)