Beispiel #1
0
 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
Beispiel #2
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(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 create_anonymous_link(context, url, is_edit_link):
        """Create an anonymous link which can be used to access a document without needing to authenticate.

        :param bool is_edit_link: If true, the link will allow the guest user edit privileges on the item.
        :param str url: The URL of the site, with the path of the object in SharePoint represented as query
        string parameters
        :param office365.sharepoint.client_context.ClientContext context: client context
        """
        result = ClientResult(bool)
        payload = {"url": context.base_url + url, "isEditLink": is_edit_link}
        qry = ServiceOperationQuery(context.web, "CreateAnonymousLink", None,
                                    payload, None, result)
        qry.static = True
        context.add_query(qry)
        return result
Beispiel #4
0
 def create(self, request):
     """Create a modern site"""
     response = SPSiteCreationResponse()
     qry = ServiceOperationQuery(self, "Create", None, request, "request",
                                 response)
     self.context.add_query(qry)
     return response
Beispiel #5
0
    def deny(self, comment):
        """Denies approval for a file that was submitted for content approval.

        :type comment: str
        """
        qry = ServiceOperationQuery(self, "deny", {"comment": comment})
        self.context.add_query(qry)
Beispiel #6
0
 def ensure_site_pages_library(self):
     """Gets a list that is the default location for wiki pages."""
     target_list = List(self.context)
     self.add_child(target_list)
     qry = ServiceOperationQuery(self, "ensureSitePagesLibrary", None, None, None, target_list)
     self.context.add_query(qry)
     return target_list
Beispiel #7
0
 def checkout(self):
     """Checks out the file from a document library based on the check-out type."""
     qry = ServiceOperationQuery(
         self,
         "checkout",
     )
     self.context.add_query(qry)
Beispiel #8
0
    def approve(self, comment):
        """Approves the file submitted for content approval with the specified comment.

        :type comment: str
        """
        qry = ServiceOperationQuery(self, "approve", {"comment": comment})
        self.context.add_query(qry)
Beispiel #9
0
 def checkin(self, comment, checkin_type):
     """Checks the file in to a document library based on the check-in type."""
     qry = ServiceOperationQuery(self, "checkin", {
         "comment": comment,
         "checkInType": checkin_type
     })
     self.context.add_query(qry)
Beispiel #10
0
 def create_upload_session(self, item):
     """Creates a temporary storage location where the bytes of the file will be saved until the complete file is
     uploaded. """
     result = ClientResult(UploadSession())
     qry = ServiceOperationQuery(self, "createUploadSession", None,
                                 {"item": item}, None, result)
     self.context.add_query(qry)
     return result
Beispiel #11
0
 def add(self, view_creation_information):
     view = View(self.context, None, self._parent_list)
     view._parent_collection = self
     qry = ServiceOperationQuery(self, "Add", None,
                                 view_creation_information, "parameters",
                                 view)
     self.context.add_query(qry)
     return view
Beispiel #12
0
 def add(self, user_id):
     """Add a user to the group."""
     payload = {
         "@odata.id":
         "https://graph.microsoft.com/v1.0/users/{0}".format(user_id)
     }
     qry = ServiceOperationQuery(self, "$ref", None, payload)
     self.context.add_query(qry)
Beispiel #13
0
 def ensure_site_assets_library(self):
     """Gets a list that is the default asset location for images or other files, which the users
     upload to their wiki pages."""
     target_list = List(self.context)
     self.add_child(target_list)
     qry = ServiceOperationQuery(self, "ensureSiteAssetsLibrary", None, None, None, target_list)
     self.context.add_query(qry)
     return target_list
Beispiel #14
0
 def start_upload(self, upload_id, content):
     """Starts a new chunk upload session and uploads the first fragment."""
     result = ClientResult(None)
     qry = ServiceOperationQuery(self, "startupload",
                                 {"uploadID": upload_id}, content, None,
                                 result)
     self.context.add_query(qry)
     return result
Beispiel #15
0
 def unpublish(self, comment):
     """Removes the file from content approval or unpublish a major version.
     :type comment: str
     """
     qry = ServiceOperationQuery(self, "unpublish", {
         "comment": comment,
     })
     self.context.add_query(qry)
Beispiel #16
0
 def publish(self, comment):
     """Submits the file for content approval with the specified comment.
     :type comment: str
     """
     qry = ServiceOperationQuery(self, "publish", {
         "comment": comment,
     })
     self.context.add_query(qry)
 def add_team(self):
     """Create a new team under a group."""
     team = Team(self.context)
     qry = ServiceOperationQuery(self, "team", None, team, None, team)
     self.context.add_query(qry)
     self.context.get_pending_request(
     ).beforeExecute += self._construct_create_team_request
     return team
 def does_user_have_permissions(self, permission_mask):
     """Returns whether the current user has the given set of permissions.
     :type permission_mask: BasePermissions
     """
     result = ClientResult(bool)
     qry = ServiceOperationQuery(self, "doesUserHavePermissions",
                                 permission_mask, None, None, result)
     self.context.add_query(qry)
     return result
 def get_user_effective_permissions(self, user_name):
     """Gets the effective permissions that the specified user has within the current application scope.
     :type user_name: str
     """
     result = ClientResult(BasePermissions())
     qry = ServiceOperationQuery(self, "GetUserEffectivePermissions",
                                 [user_name], None, None, result)
     self.context.add_query(qry)
     return result
Beispiel #20
0
 def get_changes(self, query):
     """Returns the collection of all changes from the change log that have occurred within the scope of the site,
     based on the specified query.
     :type query: ChangeQuery"""
     changes = ChangeCollection(self.context)
     qry = ServiceOperationQuery(self, "getChanges", None, query, "query",
                                 changes)
     self.context.add_query(qry)
     return changes
Beispiel #21
0
 def finish_upload(self, upload_id, file_offset, content):
     """Uploads the last file fragment and commits the file. The current file content is changed when this method
     completes. """
     qry = ServiceOperationQuery(self, "finishupload", {
         "uploadID": upload_id,
         "fileOffset": file_offset,
     }, content, None, self)
     self.context.add_query(qry)
     return self
Beispiel #22
0
 def continue_upload(self, upload_id, file_offset, content):
     """Continues the chunk upload session with an additional fragment. The current file content is not changed."""
     result = ClientResult(None)
     qry = ServiceOperationQuery(self, "continueupload", {
         "uploadID": upload_id,
         "fileOffset": file_offset,
     }, content, None, result)
     self.context.add_query(qry)
     return result
    def delete(self, site_url):
        """
        Deletes a SharePoint Team site

        :type site_url: str
        """
        payload = {"siteUrl": site_url}
        qry = ServiceOperationQuery(self, "Delete", None, payload)
        self.context.add_query(qry)
Beispiel #24
0
 def get_status(self, url):
     """Get the status of a SharePoint site"""
     response = SPSiteCreationResponse()
     qry = ServiceOperationQuery(self, "Status", None, {'url': url}, None,
                                 response)
     self.context.add_query(qry)
     self.context.get_pending_request(
     ).beforeExecute += self._construct_status_request
     return response
        def _get_items_inner(target_view):
            """

            :type target_view: View
            """
            caml_query = CamlQuery.parse(target_view.viewQuery)
            qry = ServiceOperationQuery(self._parent_list, "GetItems", None,
                                        caml_query, "query",
                                        self._parent_list.items)
            self.context.add_query(qry)
Beispiel #26
0
 def validate_update_listItem(self, form_values, new_document_update):
     """Validates and sets the values of the specified collection of fields for the list item."""
     qry = ServiceOperationQuery(self,
                                 "validateUpdateListItem",
                                 None,
                                 {
                                     "formValues": form_values,
                                     "bNewDocumentUpdate": new_document_update,
                                 })
     self.context.add_query(qry)
 def add_item(self, list_item_creation_information):
     """The recommended way to add a list item is to send a POST request to the ListItemCollection resource endpoint,
      as shown in ListItemCollection request examples.
      :type list_item_creation_information: ListItemCreationInformation"""
     item = ListItem(self.context, None, list_item_creation_information)
     self.items.add_child(item)
     item.ensure_type_name(self)
     qry = ServiceOperationQuery(self, "items", None, item, None, item)
     self.context.add_query(qry)
     return item
Beispiel #28
0
 def get_member_groups(self, security_enabled_only=True):
     """Return all the groups that the specified user, group, or directory object is a member of. This function is
     transitive. """
     result = ClientResult(None)
     payload = {
         "securityEnabledOnly": security_enabled_only
     }
     qry = ServiceOperationQuery(self, "getMemberGroups", None, payload, None, result)
     self.context.add_query(qry)
     return result
Beispiel #29
0
    def remove_site(self, site_url):
        """Deletes the site with the specified URL

        :param str site_url: A string representing the URL of the site.
        """
        result = SpoOperation(self.context)
        qry = ServiceOperationQuery(self, "removeSite", [site_url], None, None,
                                    result)
        self.context.add_query(qry)
        return result
 def get_status(self, group_id):
     """Get the status of a SharePoint site"""
     group_site_info = GroupSiteInfo()
     qry = ServiceOperationQuery(self, "GetSiteStatus", None,
                                 {'groupId': group_id}, None,
                                 group_site_info)
     self.context.add_query(qry)
     self.context.get_pending_request(
     ).beforeExecute += self._construct_status_request
     return group_site_info