def get_object_sharing_settings(context, object_url, group_id, use_simplified_roles): """Given a path to an object in SharePoint, this will generate a sharing settings object which contains necessary information for rendering sharing information.. :param office365.sharepoint.client_context.ClientContext context: SharePoint client :param str object_url: A URL with one of two possible formats. The two possible URL formats are: 1) The URL of the site, with the path of the object in SharePoint represented as query string parameters, forSharing set to 1 if sharing, and mbypass set to 1 to bypass any mobile logic e.g. http://contoso.com/?forSharing=1&mbypass=1&List=%7BCF908473%2D72D4%2D449D%2D8A53%2D4BD01EC54B84%7D& obj={CF908473-72D4-449D-8A53-4BD01EC54B84},1,DOCUMENT 2) The URL of the SharePoint object (web, list, item) intended for sharing e.g. http://contoso.com/Documents/SampleFile.docx :param int group_id: The id value of the permissions group if adding to a group, 0 otherwise. :param bool use_simplified_roles: A Boolean value indicating whether to use the SharePoint simplified roles (Edit, View) or not. """ result = ObjectSharingSettings(context) payload = { "objectUrl": object_url, "groupId": group_id, "useSimplifiedRoles": use_simplified_roles } qry = ServiceOperationQuery(context.web, "GetObjectSharingSettings", None, payload, None, result) qry.static = True context.add_query(qry) return result
def update_document_sharing_info( self, resourceAddress, userRoleAssignments, validateExistingPermissions, additiveMode, sendServerManagedNotification, customMessage, includeAnonymousLinksInNotification, propagateAcl): """ :param str resourceAddress: :param ClientValueCollection userRoleAssignments: :param bool validateExistingPermissions: :param bool additiveMode: :param bool sendServerManagedNotification: :param str customMessage: :param bool includeAnonymousLinksInNotification: :param bool propagateAcl: """ result = ClientResult(self.context, ClientValueCollection(UserSharingResult)) payload = { "resourceAddress": resourceAddress, "userRoleAssignments": userRoleAssignments, "validateExistingPermissions": validateExistingPermissions, "additiveMode": additiveMode, "sendServerManagedNotification": sendServerManagedNotification, "customMessage": customMessage, "includeAnonymousLinksInNotification": includeAnonymousLinksInNotification, "propagateAcl": propagateAcl } qry = ServiceOperationQuery(self, "UpdateDocumentSharingInfo", None, payload, None, result) qry.static = True self.context.add_query(qry) return result
def client_people_picker_resolve_user(context, query_params, on_resolved=None): """ Resolves the principals to a string of JSON representing users in people picker format. :param (str) -> None on_resolved: resolved event :param ClientPeoplePickerQueryParameters query_params: Specifies the properties of a principal query. :param office365.sharepoint.client_context.ClientContext context: """ result = ClientResult(str) svc = ClientPeoplePickerWebServiceInterface(context) qry = ServiceOperationQuery(svc, "ClientPeoplePickerResolveUser", None, query_params, "queryParams", result) qry.static = True context.add_query(qry) def _process_result(resp): result.value = "[{0}]".format(result.value) if callable(on_resolved): on_resolved(result.value) context.after_execute(_process_result) return result
def create(context, requestUrl): remote_web = RemoteWeb(context) qry = ServiceOperationQuery(context, None, [requestUrl], None, None, remote_web) qry.static = True context.add_query(qry) return remote_web
def get_search_results(context, searchPattern, providerID=None, hierarchyNodeID=None, entityTypes=None): """ :type context: office365.sharepoint.client_context.ClientContext :type searchPattern: str :type providerID: str :type hierarchyNodeID: str :type entityTypes: str """ result = ClientResult(str) payload = { "searchPattern": searchPattern, "providerID": providerID, "hierarchyNodeID": hierarchyNodeID, "entityTypes": entityTypes } svc = ClientPeoplePickerWebServiceInterface(context) qry = ServiceOperationQuery(svc, "GetSearchResults", None, payload, None, result) qry.static = True context.add_query(qry) return result
def search_principals_using_context_web(context, s_input, sources, scopes, maxCount, groupName=None): """ :type s_input: str :type sources: int :type scopes: int :type maxCount: int :type groupName: str or None :type context: office365.sharepoint.client_context.ClientContext """ result = ClientResult(ClientValueCollection(str)) utility = Utility(context) params = { "input": s_input, "sources": sources, "scopes": scopes, "maxCount": maxCount, "groupName": groupName } qry = ServiceOperationQuery(utility, "SearchPrincipalsUsingContextWeb", params, None, None, result) qry.static = True context.add_query(qry) return result
def send_email(context, properties): """ :type context: office365.sharepoint.client_context.ClientContext :type properties: office365.sharepoint.utilities.email_properties.EmailProperties """ utility = Utility(context) qry = ServiceOperationQuery(utility, "SendEmail", None, properties, "properties") qry.static = True context.add_query(qry)
def get_profile_loader(context): """ :type: office365.sharepoint.client_context.ClientContext context """ result = ProfileLoader(context) qry = ServiceOperationQuery(result, "GetProfileLoader", None, None, None, result) qry.static = True context.add_query(qry) return result
def get_user_permission_levels(context): """ :type context: office365.sharepoint.client_context.ClientContext """ result = ClientResult(context, ClientValueCollection(str)) utility = Utility(context) qry = ServiceOperationQuery(utility, "GetUserPermissionLevels", None, None, None, result) qry.static = True context.add_query(qry) return result
def get_context_web_theme_data(context): """ :type context: office365.sharepoint.client_context.ClientContext """ result = ClientResult(context) qry = ServiceOperationQuery(context.web, "GetContextWebThemeData", None, None, None, result) qry.static = True context.add_query(qry) return result
def get_blocked_file_extensions(context): """ :type context: office365.sharepoint.client_context.ClientContext """ binding_type = ServerSettings(context) return_type = ClientResult(context, ClientValueCollection(str)) qry = ServiceOperationQuery(binding_type, "GetBlockedFileExtensions", None, None, None, return_type) qry.static = True context.add_query(qry) return return_type
def current(context): """ :type context: ClientContext :return: TenantSettings """ settings = TenantSettings(context) qry = ServiceOperationQuery(settings, "Current", None, None, None, settings) qry.static = True context.add_query(qry) return settings
def get_sharing_link_kind(context, fileUrl): """ :param office365.sharepoint.client_context.ClientContext context: :param str fileUrl: """ result = ClientResult(context) qry = ServiceOperationQuery(context.web, "GetSharingLinkKind", None, {"fileUrl": fileUrl}, None, result) qry.static = True context.add_query(qry) return result
def is_sharepoint_online(context): """ :type context: office365.sharepoint.client_context.ClientContext """ binding_type = ServerSettings(context) return_type = ClientResult(context) qry = ServiceOperationQuery(binding_type, "IsSharePointOnline", None, None, None, return_type) qry.static = True context.add_query(qry) return return_type
def get_current_user_email_addresses(context): """ :type context: office365.sharepoint.client_context.ClientContext """ result = ClientResult(context) utility = Utility(context) qry = ServiceOperationQuery(utility, "GetCurrentUserEmailAddresses", None, None, None, result) qry.static = True context.add_query(qry) return result
def get_role_definition(self, role): """his method returns a role definition in the current web that is associated with a given Role (section 3.2.5.188) value. :param int role: A Role value for which to obtain the associated role definition object. """ role_def = RoleDefinition(self.context) qry = ServiceOperationQuery(self, "GetRoleDefinition", [role], None, None, role_def) qry.static = True self.context.add_query(qry) return role_def
def file_picker_tab_options(context): """ :param office365.sharepoint.client_context.ClientContext context: Client context """ result = ClientResult(context, FilePickerOptions()) svc = SitePageService(context) qry = ServiceOperationQuery(svc, "FilePickerTabOptions", None, None, None, result) qry.static = True context.add_query(qry) return result
def org_assets(context): """ :param office365.sharepoint.client_context.ClientContext context: Client context """ result = ClientResult(context, OrgAssets()) svc = SitePageService(context) qry = ServiceOperationQuery(svc, "OrgAssets", None, None, None, result) qry.static = True context.add_query(qry) return result
def create_wiki_page_in_context_web(context, parameters): """ :type context: office365.sharepoint.client_context.ClientContext :type parameters: office365.sharepoint.pages.wiki_page_creation_information.WikiPageCreationInformation """ return_file = File(context) utility = Utility(context) qry = ServiceOperationQuery(utility, "CreateWikiPageInContextWeb", None, parameters, "parameters", return_file) qry.static = True context.add_query(qry) return return_file
def delete_site_design(context, _id): """ Deletes a site design. :type _id: str :param office365.sharepoint.client_context.ClientContext context: SharePoint client """ utility = SiteScriptUtility(context) qry = ServiceOperationQuery(utility, "DeleteSiteDesign", [_id]) qry.static = True context.add_query(qry) return utility
def exists(context, url): """Determine whether site exists :type context: office365.sharepoint.client_context.ClientContext :type url: str """ result = ClientResult(bool) payload = {"url": url} qry = ServiceOperationQuery(context.site, "Exists", None, payload, None, result) qry.static = True context.add_query(qry) return result
def remove_items_from_shared_with_me_view(self, item_urls): """ :type item_urls: list[str] """ result = ClientResult( self.context, ClientValueCollection(SharedWithMeViewItemRemovalResult)) qry = ServiceOperationQuery(self, "RemoveItemsFromSharedWithMeView", [item_urls], None, None, result) qry.static = True self.context.add_query(qry) return result
def get_context_web_information(context): """ Returns an object that specifies metadata about the site :type context: office365.sharepoint.client_context.ClientContext """ result = ClientResult(context, ContextWebInformation()) qry = ServiceOperationQuery(context.web, "GetContextWebInformation", None, None, None, result) qry.static = True context.add_query(qry) return result
def get_url_by_id(context, site_id, stop_redirect=False): """Gets Site Url By Id :type context: office365.sharepoint.client_context.ClientContext :type site_id: str :type stop_redirect: bool """ result = ClientResult(str) payload = {"id": site_id, "stopRedirect": stop_redirect} qry = ServiceOperationQuery(context.site, "GetUrlById", None, payload, None, result) qry.static = True context.add_query(qry) return result
def check_site_availability(context, site_url): """ :param str site_url: Site Url :param office365.sharepoint.client_context.ClientContext context: SharePoint context """ helper = SPHelper(context) result = ClientResult(context) qry = ServiceOperationQuery(helper, "CheckSiteAvailability", None, {"siteUrl": site_url}, None, result) qry.static = True context.add_query(qry) return result
def get_owners(context, group_id, return_type=None): """ :param str group_id: Group identifier :param office365.sharepoint.client_context.ClientContext context: SharePoint context :param BaseEntityCollection or None return_type: Returns members """ helper = SPHelper(context) if return_type is None: return_type = BaseEntityCollection(context, User) qry = ServiceOperationQuery(helper, "GetOwners", [group_id], None, None, return_type) qry.static = True context.add_query(qry) return return_type
def get_web_url_from_page_url(context, page_full_url): """Gets Web from page url :type context: office365.sharepoint.client_context.ClientContext :type page_full_url: str """ result = ClientResult(context) payload = {"pageFullUrl": page_full_url} qry = ServiceOperationQuery(context.web, "GetWebUrlFromPageUrl", None, payload, None, result) qry.static = True context.add_query(qry) return result
def compute_file_name(context, title): """ :param office365.sharepoint.client_context.ClientContext context: Client context :param str title: The title of the page. """ return_type = ClientResult(context) svc = SitePageService(context) params = {"title": title} qry = ServiceOperationQuery(svc, "ComputeFileName", params, None, None, return_type) qry.static = True context.add_query(qry) return return_type
def create_organization_sharing_link(context, url, is_edit_link): """ :param office365.sharepoint.client_context.ClientContext context: :param str url: :param bool is_edit_link: """ result = ClientResult(context) params = {"url": url, "isEditLink": is_edit_link} qry = ServiceOperationQuery(context.web, "CreateOrganizationSharingLink", None, params, None, result) qry.static = True context.add_query(qry) return result
def can_create_promoted_page(context): """ Checks if the current user has permission to create a site page on the site pages document library. MUST return true if the user has permission to create a site page, otherwise MUST return false. :param office365.sharepoint.client_context.ClientContext context: SharePoint context """ return_type = ClientResult(context) svc = SitePageService(context) qry = ServiceOperationQuery(svc, "CanCreatePromotedPage", None, None, None, return_type) qry.static = True context.add_query(qry) return return_type