def update_document_sharing_info(
            self, resource_address, user_role_assignments,
            validate_existing_permissions, additive_mode,
            send_server_managed_notification, custom_message,
            include_anonymous_links_in_notification, propagate_acl):
        """
        This method allows a caller with the 'ManagePermission' permission to update sharing information about a
        document to enable document sharing with a set of users. It returns an array of
        UserSharingResult (section 3.2.5.190) elements where each element contains the sharing status for each user.

        :param str resource_address: A URL that points to a securable object, which can be a document, folder or the
            root folder of a document library.
        :param list[UserRoleAssignment] user_role_assignments:An array of recipients and assigned roles on the securable
            object pointed to by the resourceAddress parameter.
        :param bool validate_existing_permissions: A Boolean flag indicating how to honor a requested permission
            for a user. If this value is "true", the protocol server will not grant the requested permission if a user
            already has sufficient permissions, and if this value is "false", the protocol server will grant the
            requested permission whether or not a user already has the same or more permissions.
            This parameter is applicable only when the parameter additiveMode is set to true.
        :param bool additive_mode: A Boolean flag indicating whether the permission setting uses the additive or strict
            mode. If this value is "true", the permission setting uses the additive mode, which means that the
            specified permission will be added to the user's current list of permissions if it is not there already,
            and if this value is "false", the permission setting uses the strict mode, which means that the specified
            permission will replace the user's current permissions.
        :param bool send_server_managed_notification: A Boolean flag to indicate whether or not to generate an email
            notification to each recipient in the "userRoleAssignments" array after the document update is completed
            successfully. If this value is "true", the protocol server will send an email notification if an email
            server is configured, and if the value is "false", no email notification will be sent.
        :param str custom_message: A custom message to be included in the email notification.
        :param bool include_anonymous_links_in_notification: A Boolean flag that indicates whether or not to include
            anonymous access links in the email notification to each recipient in the userRoleAssignments array after
            the document update is completed successfully. If the value is "true", the protocol server will include
            an anonymous access link in the email notification, and if the value is "false", no link will be included.
        :param bool propagate_acl: A flag to determine if permissions SHOULD be pushed to items with unique permission.
        """
        result = ClientResult(self.context,
                              ClientValueCollection(UserSharingResult))
        payload = {
            "resourceAddress":
            resource_address,
            "userRoleAssignments":
            ClientValueCollection(UserRoleAssignment, user_role_assignments),
            "validateExistingPermissions":
            validate_existing_permissions,
            "additiveMode":
            additive_mode,
            "sendServerManagedNotification":
            send_server_managed_notification,
            "customMessage":
            custom_message,
            "includeAnonymousLinksInNotification":
            include_anonymous_links_in_notification,
            "propagateAcl":
            propagate_acl
        }
        qry = ServiceOperationQuery(self, "UpdateDocumentSharingInfo", None,
                                    payload, None, result)
        qry.static = True
        self.context.add_query(qry)
        return result
 def get_search_results(context,
                        search_pattern,
                        provider_id=None,
                        hierarchy_node_id=None,
                        entity_types=None):
     """
     :type context: office365.sharepoint.client_context.ClientContext
     :type search_pattern: str
     :type provider_id: str
     :type hierarchy_node_id: str
     :type entity_types: str
     """
     result = ClientResult(context)
     payload = {
         "searchPattern": search_pattern,
         "providerID": provider_id,
         "hierarchyNodeID": hierarchy_node_id,
         "entityTypes": entity_types
     }
     svc = ClientPeoplePickerWebServiceInterface(context)
     qry = ServiceOperationQuery(svc, "GetSearchResults", None, payload,
                                 None, result)
     qry.static = True
     context.add_query(qry)
     return result
    def client_people_picker_resolve_user(context,
                                          query_string,
                                          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 str query_string: Specifies the value to be used in the principal query.
        :param office365.sharepoint.client_context.ClientContext context:

        """
        result = ClientResult(context)
        svc = ClientPeoplePickerWebServiceInterface(context)
        query_params = ClientPeoplePickerQueryParameters(
            query_string=query_string)
        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
예제 #4
0
    def search_principals_using_context_web(context,
                                            s_input,
                                            sources,
                                            scopes,
                                            max_count,
                                            group_name=None):
        """
        Returns the collection of principals that partially or uniquely matches the specified search criteria in the
        context of the current Web site

        :param str s_input: Specifies the value to be used when searching for a principal.
        :param str sources: Specifies the source to be used when searching for a principal.
        :param int scopes: Specifies the type to be used when searching for a principal.
        :param int max_count: Specifies the maximum number of principals to be returned.
        :param str or None group_name:  Specifies the name of a site collection group in the site collection that
            contains the current Web site. The collection of users in this site collection group is used when searching
            for a principal.
        :type context: office365.sharepoint.client_context.ClientContext
        """
        result = ClientResult(context, StringCollection())
        utility = Utility(context)
        params = {
            "input": s_input,
            "sources": sources,
            "scopes": scopes,
            "maxCount": max_count,
            "groupName": group_name
        }
        qry = ServiceOperationQuery(utility, "SearchPrincipalsUsingContextWeb",
                                    params, None, None, result)
        qry.static = True
        context.add_query(qry)
        return result
예제 #5
0
 def content_service(context):
     """
     :param office365.sharepoint.client_context.ClientContext context: SharePoint context
     """
     return_type = SPWebService(context)
     qry = ServiceOperationQuery(return_type, "ContentService", None, None,
                                 None, return_type)
     qry.static = True
     context.add_query(qry)
     return return_type
 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_blocked_file_extensions(context):
     """
     :type context: office365.sharepoint.client_context.ClientContext
     """
     binding_type = ServerSettings(context)
     return_type = ClientResult(context, StringCollection())
     qry = ServiceOperationQuery(binding_type, "GetBlockedFileExtensions", None, None, None, return_type)
     qry.static = True
     context.add_query(qry)
     return return_type
 def create(context, request_url):
     """
     :type context: ClientContext
     :type request_url: str
     """
     remote_web = RemoteWeb(context)
     qry = ServiceOperationQuery(context, None, [request_url], None, None, remote_web)
     qry.static = True
     context.add_query(qry)
     return remote_web
예제 #9
0
 def lookup(context, request_uri):
     """
     :type context
     :type request_uri str
     """
     return_type = WebApplication(context)
     payload = {"requestUri": request_uri}
     qry = ServiceOperationQuery(return_type, "Lookup", None, payload, None, return_type)
     qry.static = True
     context.add_query(qry)
     return return_type
예제 #10
0
    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
예제 #11
0
    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
예제 #12
0
    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
예제 #13
0
    def send_email(context, properties):
        """
        This method is a static method.

        :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)
        return utility
    def get_role_definition(self, role):
        """This 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)
        self.context.web.role_definitions.add_child(role_def)
        qry = ServiceOperationQuery(self, "GetRoleDefinition", [role], None,
                                    None, role_def)
        qry.static = True
        self.context.add_query(qry)
        return role_def
예제 #15
0
    def get_trending_tags(context):
        """Gets a collection of the 20 (or fewer) most popular hash tags over the past week.
        The returned collection is sorted in descending order of frequency of use.

        :type context: office365.sharepoint.client_context.ClientContext
        """
        return_type = HashTagCollection(context)
        manager = PeopleManager(context)
        qry = ServiceOperationQuery(manager, "GetTrendingTags", None, None,
                                    None, return_type)
        qry.static = True
        context.add_query(qry)
        return return_type
예제 #16
0
    def exists(context, url):
        """Determine whether site exists

        :type context: office365.sharepoint.client_context.ClientContext
        :type url: str
        """
        result = ClientResult(context)
        payload = {"url": url}
        qry = ServiceOperationQuery(context.site, "Exists", None, payload,
                                    None, result)
        qry.static = True
        context.add_query(qry)
        return result
예제 #17
0
    def get_user_permission_levels(context):
        """
        Retrieves a collection of permission levels of the current user on the web.

        :type context: office365.sharepoint.client_context.ClientContext
        """
        result = ClientResult(context, StringCollection())
        utility = Utility(context)
        qry = ServiceOperationQuery(utility, "GetUserPermissionLevels", None,
                                    None, None, result)
        qry.static = True
        context.add_query(qry)
        return result
예제 #18
0
 def get_members(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
     """
     if return_type is None:
         return_type = BaseEntityCollection(context, User)
     helper = SPHelper(context)
     qry = ServiceOperationQuery(helper, "GetMembers", [group_id], None, None, return_type)
     qry.static = True
     context.add_query(qry)
     return return_type
예제 #19
0
 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
예제 #20
0
    def get_list_item_sharing_information(context,
                                          list_id,
                                          item_id,
                                          exclude_current_user=True,
                                          exclude_site_admin=True,
                                          exclude_security_groups=True,
                                          retrieve_anonymous_links=False,
                                          retrieve_user_info_details=False,
                                          check_for_access_requests=False,
                                          return_type=None):
        """
        Retrieves information about the sharing state for a given list.

        :param bool check_for_access_requests: Specifies whether the returned sharing state information will contain a URL
        to a location which describes any access requests present in the site (2), if such a URL is available.
        :param bool retrieve_user_info_details: Specifies whether the returned sharing state information will contain
        basic or detailed information about the users with permissions to the list item.
        :param bool retrieve_anonymous_links: Specifies whether the returned sharing state information will contain
        information about a URL that allows an anonymous user to access the list item.
        :param bool exclude_security_groups: Specifies whether the returned sharing state information will exclude
        information about security groups which have permissions to the list item.
        :param bool exclude_site_admin:  Specifies whether the returned sharing state information will exclude
        information about users who are site collection administrators of the site collection which contains the list.
        :param bool exclude_current_user: Specifies whether the returned sharing state information will exclude
        information about the user making the request.
        :param int item_id: The list item identifier for the list item for which the sharing state is requested.
        :param str list_id: The list identifier for the list which contains the list item for which
        the sharing state is requested.
        :param office365.sharepoint.client_context.ClientContext context: SharePoint client context
        :param BaseEntity return_type: Return type
        :return: ObjectSharingInformation
        """
        binding_type = ObjectSharingInformation(context)
        payload = {
            "listID": list_id,
            "itemID": item_id,
            "excludeCurrentUser": exclude_current_user,
            "excludeSiteAdmin": exclude_site_admin,
            "excludeSecurityGroups": exclude_security_groups,
            "retrieveAnonymousLinks": retrieve_anonymous_links,
            "retrieveUserInfoDetails": retrieve_user_info_details,
            "checkForAccessRequests": check_for_access_requests
        }
        if not return_type:
            return_type = binding_type
        qry = ServiceOperationQuery(binding_type,
                                    "GetListItemSharingInformation", None,
                                    payload, None, return_type)
        qry.static = True
        context.add_query(qry)
        return return_type
예제 #21
0
    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
예제 #22
0
    def get_site_design_stages(context, site_design_id):
        """
        Gets a list of site design stages.

        :param office365.sharepoint.client_context.ClientContext context: SharePoint context
        :param str site_design_id:
        """
        return_type = ClientResult(context)
        utility = SiteScriptUtility(context)
        qry = ServiceOperationQuery(utility, "GetSiteDesignStages",
                                    [site_design_id], None, None, return_type)
        qry.static = True
        context.add_query(qry)
        return return_type
예제 #23
0
    def update_site_design(context, update_info):
        """
        Updates a site design with new values.

        :param office365.sharepoint.client_context.ClientContext context: SharePoint context
        :param SiteDesignMetadata update_info:
        """
        return_type = ClientResult(context, SiteDesignMetadata())
        utility = SiteScriptUtility(context)
        qry = ServiceOperationQuery(utility, "UpdateSiteDesign", None,
                                    update_info, "updateInfo", return_type)
        qry.static = True
        context.add_query(qry)
        return return_type
예제 #24
0
    def create_site_design(context, info):
        """
        Creates a new site design available to users when they create a new site from the SharePoint start page.

        :param office365.sharepoint.client_context.ClientContext context: SharePoint context
        :param office365.sharepoint.sitedesigns.creation_info.SiteDesignCreationInfo info:
        """
        return_type = ClientResult(context, SiteDesignMetadata())
        utility = SiteScriptUtility(context)
        qry = ServiceOperationQuery(utility, "CreateSiteDesign", None, info,
                                    "info", return_type)
        qry.static = True
        context.add_query(qry)
        return return_type
    def get_global_installed_languages(context, compatibility_level):
        """
        Gets a list of installed languages that are compatible with a given version of SharePoint.

        :type context: office365.sharepoint.client_context.ClientContext
        :param int compatibility_level: The value of the major SharePoint version to query for installed languages.
        """
        binding_type = ServerSettings(context)
        return_type = LanguageCollection(context)
        qry = ServiceOperationQuery(binding_type, "GetGlobalInstalledLanguages", [compatibility_level],
                                    None, None, return_type)
        qry.static = True
        context.add_query(qry)
        return return_type
예제 #26
0
    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(context)
        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 create_from_key_group(context, key_group_identifier):
        """
        Create an instance of SP.AppPrincipalCredential that wraps a key group identifier.

        :type context: office365.sharepoint.client_context.ClientContext
        :param str key_group_identifier:  The key group identifier.
        """
        return_type = AppPrincipalCredential(context)
        payload = {"keyGroupIdentifier": key_group_identifier}
        qry = ServiceOperationQuery(return_type, "CreateFromKeyGroup", None,
                                    payload, None, return_type)
        qry.static = True
        context.add_query(qry)
        return return_type
예제 #28
0
    def can_current_user_share(context, doc_id):
        """Indicates whether the current user can share the document identified by docId.

        :param office365.sharepoint.client_context.ClientContext context: SharePoint client context
        :param str doc_id: Identifies the document that will be analyzed from a sharing perspective.
        """
        binding_type = ObjectSharingInformation(context)
        payload = {"docId": doc_id}
        result = ClientResult(context)
        qry = ServiceOperationQuery(binding_type, "CanCurrentUserShare", None,
                                    payload, None, result)
        qry.static = True
        context.add_query(qry)
        return result
예제 #29
0
    def get_current_user_email_addresses(context):
        """
        Returns the email addresses of the current user. If more than one email address exists for the current user,
        returns a list of email addresses separated by semicolons.

        :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_team_site_data(context, ignore_validation=True):
     """
     :param office365.sharepoint.client_context.ClientContext context: SharePoint client context
     :param bool ignore_validation:
     """
     manager = TeamChannelManager(context)
     payload = {
         "ignoreValidation": ignore_validation,
     }
     return_type = TeamSiteData(context)
     qry = ServiceOperationQuery(manager, "GetTeamSiteData", None, payload,
                                 None, return_type)
     qry.static = True
     context.add_query(qry)
     return return_type