Skip to content

Commit 6005d49

Browse files
committed
type hints for client query
1 parent 98d7a5d commit 6005d49

File tree

18 files changed

+132
-43
lines changed

18 files changed

+132
-43
lines changed

examples/reports/get_user_mfa_status.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
This method doesn't work for disabled users.
44
55
"""
6+
67
from office365.graph_client import GraphClient
78
from tests import test_client_id, test_client_secret, test_tenant
89

office365/directory/authentication/conditions/conditions.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55

66

77
class AuthenticationConditions(ClientValue):
8-
""""""
8+
"""The conditions on which an authenticationEventListener should trigger."""
99

1010
def __init__(self, applications=AuthenticationConditionsApplications()):
11+
"""
12+
:parm AuthenticationConditionsApplications applications: Applications which trigger a custom authentication
13+
extension.
14+
"""
1115
self.applications = applications

office365/directory/identitygovernance/accessreview/instance.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
from office365.directory.identitygovernance.accessreview.stages import AccessReviewStageCollection
1+
from office365.directory.identitygovernance.accessreview.stages import (
2+
AccessReviewStageCollection,
3+
)
24
from office365.entity import Entity
35
from office365.runtime.paths.resource_path import ResourcePath
46

office365/directory/identitygovernance/accessreview/stages.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ class AccessReviewStageCollection(EntityCollection[AccessReviewStage]):
66
"""AccessReviewStage collection"""
77

88
def __init__(self, context, resource_path=None):
9-
super(AccessReviewStageCollection, self).__init__(context, AccessReviewStage, resource_path)
9+
super(AccessReviewStageCollection, self).__init__(
10+
context, AccessReviewStage, resource_path
11+
)

office365/directory/rolemanagement/role.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def members(self):
4141

4242
@property
4343
def scoped_members(self):
44-
"""Members of this directory role that are scoped to administrative units. """
44+
"""Members of this directory role that are scoped to administrative units."""
4545

4646
return self.properties.get(
4747
"scopedMembers",

office365/reports/internal/queries/create_report_query.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010

1111
def create_report_query(report_root, report_name, period=None, return_stream=False):
12-
# type: (ReportRoot, str, str, bool) -> FunctionQuery
1312
"""
1413
Construct Report query
1514

office365/reports/root.py

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ def get_email_activity_user_detail(self, period):
8989
The supported values for {period_value} are: D7, D30, D90, and D180. These values follow the format
9090
Dn where n represents the number of days over which the report is aggregated. Required.
9191
"""
92-
qry = create_report_query(self, "getEmailActivityUserDetail", period, return_stream=True)
92+
qry = create_report_query(
93+
self, "getEmailActivityUserDetail", period, return_stream=True
94+
)
9395
self.context.add_query(qry)
9496
return qry.return_type
9597

@@ -105,18 +107,48 @@ def get_email_app_usage_apps_user_counts(self, period):
105107
self.context.add_query(qry)
106108
return qry.return_type
107109

110+
def get_email_app_usage_user_counts(self, period):
111+
"""
112+
Get the count of unique users that connected to Exchange Online using any email app.
113+
114+
:param str period: Specifies the length of time over which the report is aggregated.
115+
The supported values for {period_value} are: D7, D30, D90, and D180. These values follow the format
116+
Dn where n represents the number of days over which the report is aggregated. Required.
117+
"""
118+
qry = create_report_query(self, "getEmailAppUsageUserCounts", period, True)
119+
self.context.add_query(qry)
120+
return qry.return_type
121+
122+
def get_mailbox_usage_storage(self, period):
123+
"""
124+
Get the amount of storage used in your organization.
125+
126+
:param str period: Specifies the length of time over which the report is aggregated.
127+
The supported values for {period_value} are: D7, D30, D90, and D180. These values follow the format
128+
Dn where n represents the number of days over which the report is aggregated. Required.
129+
"""
130+
qry = create_report_query(self, "getMailboxUsageStorage", period, True)
131+
self.context.add_query(qry)
132+
return qry.return_type
133+
108134
def get_m365_app_user_counts(self, period=None):
109135
"""
110136
Get a report that provides the trend in the number of active users for each app (Outlook, Word, Excel,
111137
PowerPoint, OneNote, and Teams) in your organization.
112138
"""
113-
return_type = ClientResult(self.context, str())
139+
return_type = ClientResult(self.context, bytes())
114140
qry = FunctionQuery(
115141
self, "getM365AppUserCounts", {"period": period}, return_type
116142
)
117143
self.context.add_query(qry)
118144
return return_type
119145

146+
def get_office365_activation_counts(self):
147+
"""Get the count of Microsoft 365 activations on desktops and devices."""
148+
qry = create_report_query(self, "getOffice365ActivationCounts")
149+
self.context.add_query(qry)
150+
return qry.return_type
151+
120152
def get_office365_activations_user_counts(self):
121153
"""Get the count of Microsoft 365 activations on desktops and devices."""
122154
qry = create_report_query(self, "getOffice365ActivationsUserCounts")
@@ -283,6 +315,20 @@ def get_sharepoint_site_usage_site_counts(self, period):
283315
self.context.add_query(qry)
284316
return qry.return_type
285317

318+
def get_teams_team_counts(self, period):
319+
"""
320+
Get the number of teams of a particular type in an instance of Microsoft Teams.
321+
322+
:param str period: Specifies the length of time over which the report is aggregated.
323+
The supported values for {period_value} are: D7, D30, D90, and D180. These values follow the format
324+
Dn where n represents the number of days over which the report is aggregated. Required.
325+
"""
326+
qry = create_report_query(
327+
self, "getTeamsTeamCounts", period, return_stream=True
328+
)
329+
self.context.add_query(qry)
330+
return qry.return_type
331+
286332
@property
287333
def authentication_methods(self):
288334
"""Container for navigation properties for Azure AD authentication methods resources."""

office365/runtime/queries/client_query.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
class ClientQuery(object):
1+
from typing import TYPE_CHECKING, AnyStr, Dict, Generic, Optional, TypeVar, Union
2+
3+
if TYPE_CHECKING:
4+
from office365.runtime.client_object import ClientObject
5+
from office365.runtime.client_result import ClientResult
6+
from office365.runtime.client_runtime_context import ClientRuntimeContext
7+
from office365.runtime.client_value import ClientValue
8+
9+
T = TypeVar("T", bound=Union["ClientObject", "ClientResult"])
10+
11+
12+
class ClientQuery(Generic[T]):
213
"""Client query"""
314

415
def __init__(
@@ -9,15 +20,9 @@ def __init__(
920
parameters_name=None,
1021
return_type=None,
1122
):
23+
# type: (ClientRuntimeContext, Optional[ClientObject], Optional[ClientObject|ClientValue|Dict|AnyStr], Optional[str], Optional[T]) -> None
1224
"""
1325
Generic query
14-
15-
:type context: office365.runtime.client_runtime_context.ClientRuntimeContext
16-
:type binding_type: office365.runtime.client_object.ClientObject or None
17-
:type parameters_type: office365.runtime.client_object.ClientObject or ClientValue or dict or bytes or None
18-
:type parameters_name: str or None
19-
:type return_type: office365.runtime.client_object.ClientObject
20-
or office365.runtime.client_result.ClientResult or None
2126
"""
2227
self._context = context
2328
self._binding_type = binding_type

office365/runtime/queries/create_entity.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
from typing import Dict
1+
from typing import TYPE_CHECKING, Dict
22

3-
from office365.runtime.client_object import ClientObject
43
from office365.runtime.client_value import ClientValue
5-
from office365.runtime.queries.client_query import ClientQuery
4+
from office365.runtime.queries.client_query import ClientQuery, T
65

6+
if TYPE_CHECKING:
7+
from office365.runtime.client_object import ClientObject
78

8-
class CreateEntityQuery(ClientQuery):
9+
10+
class CreateEntityQuery(ClientQuery[T]):
911
def __init__(self, parent_entity, parameters, return_type=None):
10-
# type: (ClientObject, ClientObject|ClientValue|Dict, ClientObject) -> None
12+
# type: (ClientObject, ClientObject|ClientValue|Dict, T) -> None
1113
"""Create entity query"""
1214
super(CreateEntityQuery, self).__init__(
1315
parent_entity.context, parent_entity, parameters, None, return_type
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1+
from typing import TYPE_CHECKING
2+
13
from office365.runtime.queries.client_query import ClientQuery
24

5+
if TYPE_CHECKING:
6+
from office365.runtime.client_object import ClientObject
7+
38

49
class DeleteEntityQuery(ClientQuery):
510
def __init__(self, delete_type):
11+
# type: (ClientObject) -> None
612
"""
713
Delete entity query
8-
9-
:type delete_type: office365.runtime.client_object.ClientObject
1014
"""
1115
super(DeleteEntityQuery, self).__init__(delete_type.context, delete_type)

0 commit comments

Comments
 (0)