|
| 1 | +from office365.runtime.client_result import ClientResult |
| 2 | +from office365.runtime.client_value_collection import ClientValueCollection |
| 3 | +from office365.runtime.queries.service_operation_query import ServiceOperationQuery |
| 4 | +from office365.runtime.resource_path import ResourcePath |
| 5 | +from office365.sharepoint.base_entity import BaseEntity |
| 6 | + |
| 7 | + |
| 8 | +class Utility(BaseEntity): |
| 9 | + |
| 10 | + def __init__(self, context): |
| 11 | + super().__init__(context, ResourcePath("SP.Utilities.Utility")) |
| 12 | + |
| 13 | + @staticmethod |
| 14 | + def get_current_user_email_addresses(context): |
| 15 | + """ |
| 16 | +
|
| 17 | + :type context: office365.sharepoint.client_context.ClientContext |
| 18 | + """ |
| 19 | + result = ClientResult(str) |
| 20 | + utility = Utility(context) |
| 21 | + qry = ServiceOperationQuery(utility, "GetCurrentUserEmailAddresses", None, None, None, result) |
| 22 | + qry.static = True |
| 23 | + context.add_query(qry) |
| 24 | + return result |
| 25 | + |
| 26 | + @staticmethod |
| 27 | + def get_user_permission_levels(context): |
| 28 | + """ |
| 29 | + :type context: office365.sharepoint.client_context.ClientContext |
| 30 | + """ |
| 31 | + result = ClientResult(ClientValueCollection(str)) |
| 32 | + utility = Utility(context) |
| 33 | + qry = ServiceOperationQuery(utility, "GetUserPermissionLevels", None, None, None, result) |
| 34 | + qry.static = True |
| 35 | + context.add_query(qry) |
| 36 | + return result |
| 37 | + |
| 38 | + @staticmethod |
| 39 | + def search_principals_using_context_web(context, s_input, sources, scopes, maxCount, groupName=None): |
| 40 | + """ |
| 41 | + :type s_input: str |
| 42 | + :type sources: int |
| 43 | + :type scopes: int |
| 44 | + :type maxCount: int |
| 45 | + :type groupName: str or None |
| 46 | + :type context: office365.sharepoint.client_context.ClientContext |
| 47 | + """ |
| 48 | + result = ClientResult(ClientValueCollection(str)) |
| 49 | + utility = Utility(context) |
| 50 | + params = { |
| 51 | + "input": s_input, |
| 52 | + "sources": sources, |
| 53 | + "scopes": scopes, |
| 54 | + "maxCount": maxCount, |
| 55 | + "groupName": groupName |
| 56 | + } |
| 57 | + qry = ServiceOperationQuery(utility, "SearchPrincipalsUsingContextWeb", params, None, None, result) |
| 58 | + qry.static = True |
| 59 | + context.add_query(qry) |
| 60 | + return result |
| 61 | + |
| 62 | + @staticmethod |
| 63 | + def send_email(context, properties): |
| 64 | + """ |
| 65 | + :type context: office365.sharepoint.client_context.ClientContext |
| 66 | + :type properties: office365.sharepoint.utilities.email_properties.EmailProperties |
| 67 | + """ |
| 68 | + utility = Utility(context) |
| 69 | + qry = ServiceOperationQuery(utility, "SendEmail", None, properties, "properties") |
| 70 | + qry.static = True |
| 71 | + context.add_query(qry) |
| 72 | + |
| 73 | + @property |
| 74 | + def entity_type_name(self): |
| 75 | + return "SP.Utilities.Utility" |
0 commit comments