def move(self, name, parent_reference=None):
     """To move a DriveItem to a new parent item, your app requests to update the parentReference of the DriveItem
     to move. """
     from office365.graphClient import ReplaceMethodQuery
     result = ClientResult(None)
     qry = ReplaceMethodQuery(self,
                              "move",
                              None,
                              {
                                  "name": name,
                                  "parentReference": parent_reference
                              },
                              None,
                              result
                              )
     self.context.add_query(qry)
     return result
    def set_as_home_site(context, site_url, return_value=None):
        """

        :param ClientResult return_value:
        :param office365.sharepoint.client_context.ClientContext context:
        :param str site_url:
        """

        if return_value is None:
            return_value = ClientResult(context)
        sph = SPHSite(context)
        params = {"siteUrl": site_url}
        qry = ServiceOperationQuery(sph, "SetSPHSite", params, None, None,
                                    return_value)
        qry.static = True
        context.add_query(qry)
        return return_value
Пример #3
0
    def get_tenant_cdn_policies(self, cdn_type):
        """
        Get the public or private Policies applied on your SharePoint Online Tenant.

        Requires Tenant administrator permissions.


        :param int cdn_type: Specifies the CDN type. The valid values are: public or private.
        """
        payload = {
            "cdnType": cdn_type,
        }
        return_type = ClientResult(self.context, ClientValueCollection(str))
        qry = ServiceOperationQuery(self, "GetTenantCdnPolicies", None,
                                    payload, None, return_type)
        self.context.add_query(qry)
        return return_type
    def get_publishing_navigation_provider_type(
            self, mapProviderName="SPNavigationProvider"):
        """
        Gets a publishing navigation provider type when publishing feature is turned on for the site (2).
        If navigation provider is not found on the site MUST return InvalidSiteMapProvider type.

        :param str mapProviderName: The server will use "SPNavigationProvider" as provider name
            if mapProviderName is not specified.
        :return:
        """
        result = ClientResult(None)
        params = {"mapProviderName": mapProviderName}
        qry = ServiceOperationQuery(self,
                                    "GetPublishingNavigationProviderType",
                                    params, None, None, result)
        self.context.add_query(qry)
        return result
Пример #5
0
    def get_tenant_cdn_enabled(self, cdn_type):
        """
        Returns whether Public content delivery network (CDN) or Private CDN is enabled on the tenant level.

        You must have the SharePoint Admin role or Global Administrator role and be a site collection administrator
        to run the operation.

        :param int cdn_type: Specifies the CDN type. The valid values are: public or private.
        """
        payload = {
            "cdnType": cdn_type,
        }
        return_type = ClientResult(self.context)
        qry = ServiceOperationQuery(self, "GetTenantCdnEnabled", None, payload,
                                    None, return_type)
        self.context.add_query(qry)
        return return_type
Пример #6
0
    def get_status(self, site_url):
        """When executing this method server SHOULD return a SharePoint site status in the format
        of a SPSiteCreationRespnse according to the parameter passed in the url.

        :param str site_url: URL of the site to return status for
        """
        response = ClientResult(self.context, SPSiteCreationResponse())
        qry = ServiceOperationQuery(self, "Status", None, {'url': site_url},
                                    None, response)
        self.context.add_query(qry)

        def _construct_status_request(request):
            request.method = HttpMethod.Get
            request.url += "?url='{0}'".format(site_url)

        self.context.before_execute(_construct_status_request)
        return response
Пример #7
0
    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
Пример #8
0
    def query(self, search_request):
        """The operation is used to retrieve search results by using the HTTP protocol with the GET method.

        :type search_request: office365.sharepoint.search.searchRequest.SearchRequest
        """
        result = ClientResult(self.context, SearchResult())
        qry = ServiceOperationQuery(self, "query", search_request.to_json(),
                                    None, "query", result)
        self.context.add_query(qry)

        def _construct_request(request):
            """
            :type request: office365.runtime.http.request_options.RequestOptions
            """
            request.method = HttpMethod.Get

        self.context.before_execute(_construct_request)
        return result
    def remove_items_from_shared_with_me_view(self, item_urls):
        """
        Removes an item so that it no longer shows in the current user's 'Shared With Me' view. However, this
            does not remove the user's actual permissions to the item. Up to 200 items can be provided in a single call.
            Returns a list of results indicating whether the items were successfully removed. The length of this array
            will match the length of the itemUrls array that was provided.

        :param list[str] item_urls: A list of absolute URLs of the items to be removed from the view.
            These items might belong to any site or site collection in the tenant.
        """
        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
Пример #10
0
    def create(self, group_name):
        """Provision a new team along with a group.

        :type group_name: str
        :rtype: ClientResult
        """

        grp_properties = GroupProfile(group_name)
        grp_properties.securityEnabled = False
        grp_properties.mailEnabled = True
        grp_properties.groupTypes = ["Unified"]
        target_group = self.context.groups.add(grp_properties)
        result = ClientResult(Team(self.context))

        def _group_created(resp):
            result.value = target_group.add_team()
        self.context.after_execute(_group_created)
        return result
Пример #11
0
    def start_upload(self, upload_id, content):
        """Starts a new chunk upload session and uploads the first fragment.

        :param bytes content: File content
        :param str upload_id: Upload session id
        """
        result = ClientResult(None)
        qry = ServiceOperationQuery(self,
                                    "startUpload",
                                    {
                                        "uploadID": upload_id
                                    },
                                    content,
                                    None,
                                    result
                                    )
        self.context.add_query(qry)
        return result
Пример #12
0
    def preview(self, page, zoom=None):
        """
        This action allows you to obtain a short-lived embeddable URL for an item in order
        to render a temporary preview.

        :param str or int page: Optional. Page number of document to start at, if applicable.
            Specified as string for future use cases around file types such as ZIP.
        :param int zoom: Optional. Zoom level to start at, if applicable.

        """
        payload = {
            "page": page,
            "zoom": zoom
        }
        result = ClientResult(self.context, ItemPreviewInfo())
        qry = ServiceOperationQuery(self, "preview", None, payload, None, result)
        self.context.add_query(qry)
        return result
Пример #13
0
 def expand_groups_to_principals(context, inputs, max_count=None, return_type=None):
     """
     :type context: office365.sharepoint.client_context.ClientContext
     :type inputs: list[str]
     :type max_count: int
     :type return_type: ClientResult
     """
     utility = Utility(context)
     payload = {
         "inputs": inputs,
         "maxCount": max_count
     }
     if return_type is None:
         return_type = ClientResult(context, ClientValueCollection(PrincipalInfo))
     qry = ServiceOperationQuery(utility, "ExpandGroupsToPrincipals", None, payload, None, return_type)
     qry.static = True
     context.add_query(qry)
     return return_type
Пример #14
0
    def share_link(self, link_kind, expiration=None):
        """Creates a tokenized sharing link for a list item based on the specified parameters and optionally
        sends an email to the people that are listed in the specified parameters.

        :param int link_kind: The kind of the tokenized sharing link to be created/updated or retrieved.
        :param datetime or None expiration: A date/time string for which the format conforms to the ISO 8601:2004(E)
            complete representation for calendar date and time of day and which represents the time and date of expiry
            for the tokenized sharing link. Both the minutes and hour value MUST be specified for the difference
            between the local and UTC time. Midnight is represented as 00:00:00. A null value indicates no expiry.
            This value is only applicable to tokenized sharing links that are anonymous access links.
        """
        result = ClientResult(self.context, ShareLinkResponse())
        payload = ShareLinkRequest(settings=ShareLinkSettings(
            link_kind=link_kind, expiration=expiration))
        qry = ServiceOperationQuery(self, "ShareLink", None, payload,
                                    "request", result)
        self.context.add_query(qry)
        return result
Пример #15
0
    def save_page_as_draft(self, title, canvas_content=None, banner_image_url=None, topic_header=None):
        """
        Updates the Site Page with the provided pageStream content and checks in a minor version if the page library
        has minor versions enabled.

        :param str title: The title of Site Page. At least Title property needs to be provided
        :param str canvas_content:
        :param str banner_image_url:
        :param str topic_header:
        """
        payload = SitePageFieldsData(title=title,
                                     canvas_content=canvas_content,
                                     banner_image_url=banner_image_url,
                                     topic_header=topic_header)
        result = ClientResult(self.context)
        qry = ServiceOperationQuery(self, "SavePageAsDraft", None, payload, "pageStream", result)
        self.context.add_query(qry)
        return result
Пример #16
0
 def is_member_of(context, principal_name, group_id, result=None):
     """
     :param str principal_name: User principal name
     :param str group_id: Group id
     :param office365.sharepoint.client_context.ClientContext context: SharePoint context
     :param ClientResult or None result: Client result
     """
     helper = SPHelper(context)
     if result is None:
         result = ClientResult(context)
     payload = {
         "principalName": principal_name,
         "groupId": group_id
     }
     qry = ServiceOperationQuery(helper, "IsMemberOf", None, payload, None, result)
     qry.static = True
     context.add_query(qry)
     return result
Пример #17
0
    def create_post(self, target_id=None, creation_data=None):
        """
        The CreatePost method creates a post in the current user's feed, in the specified user's feed, or in
        the specified thread. This method returns a new or a modified thread.

        :param str or None target_id: Optional, specifies the target of the post. If this parameter is null, the post is
            created as a root post in the current user's feed. If this parameter is set to a site (2) URL or a site
            (2) actor identification, the post is created as a root post in the specified site (2) feed.
            If this parameter is set to a thread identification, the post is created as a reply post in the specified
            thread.
        :param SocialPostCreationData creation_data: Specifies the text and details of the post.
        """
        return_type = ClientResult(self.context, SocialThread())
        payload = {"targetId": target_id, "creationData": creation_data}
        qry = ServiceOperationQuery(self, "CreatePost", None, payload, None,
                                    return_type)
        self.context.add_query(qry)
        return return_type
Пример #18
0
    def get_url_by_id_for_web(context, site_id, stop_redirect, web_id):
        """Gets Site Url By Id

        :type context: office365.sharepoint.client_context.ClientContext
        :type site_id: str
        :type stop_redirect: bool
        :type web_id: str
        """
        result = ClientResult(context)
        payload = {
            "id": site_id,
            "stopRedirect": stop_redirect,
            "webId": web_id
        }
        qry = ServiceOperationQuery(context.site, "GetUrlById", None, payload, None, result)
        qry.static = True
        context.add_query(qry)
        return result
Пример #19
0
    def log_custom_app_error(context, error):
        """
        Logs an error from a SharePoint Add-in. The return value indicates the success or failure of this operation.
        These errors are of interest to administrators who monitor such apps (2).

        :type context: office365.sharepoint.client_context.ClientContext
        :param str error: Error string to log
        """
        utility = Utility(context)
        payload = {
            "error": error,
        }
        return_type = ClientResult(context)
        qry = ServiceOperationQuery(utility, "LogCustomAppError", None,
                                    payload, None, return_type)
        qry.static = True
        context.add_query(qry)
        return return_type
Пример #20
0
    def get_site_design_metadata(context, _id, store=None):
        """
        Gets information about a specific site script.

        :param office365.sharepoint.client_context.ClientContext context: SharePoint context
        :param str _id:
        :param str store:
        """
        return_type = ClientResult(context, SiteDesignMetadata())
        utility = SiteScriptUtility(context)
        payload = {
            "id": _id,
            "store": store
        }
        qry = ServiceOperationQuery(utility, "GetSiteDesignMetadata", None, payload, None, return_type)
        qry.static = True
        context.add_query(qry)
        return return_type
Пример #21
0
    def get_document_libraries(context, web_full_url):
        """
        Returns the document libraries of a SharePoint site, specifically a list of objects that represents
        document library information. Document libraries that are private—picture library, catalog library,
        asset library, application list, form template or libraries—for whom the user does not have permission to view
        the items are not included.

        :param office365.sharepoint.client_context.ClientContext context: SharePoint context
        :param str web_full_url: The URL of the web.
        """
        result = ClientResult(context, ClientValueCollection(DocumentLibraryInformation))
        payload = {
            "webFullUrl": web_full_url
        }
        qry = ServiceOperationQuery(context.web, "GetDocumentLibraries", None, payload, None, result)
        qry.static = True
        context.add_query(qry)
        return result
Пример #22
0
    def create_file_attachment(self, name, description, file_data):
        """
        Creates a file attachment for a future post.

        :param str name: The name of the file.
        :param str description: An optional description of the file.
        :param str or bytes file_data: A stream for reading the file data.
        """
        return_type = ClientResult(self.context, SocialAttachment())
        payload = {
            "name": name,
            "description": description,
            "fileData": file_data
        }
        qry = ServiceOperationQuery(self, "CreateFileAttachment", None,
                                    payload, None, return_type)
        self.context.add_query(qry)
        return return_type
Пример #23
0
    def get_recent_notebooks(self, include_personal_notebooks=True):
        """Get a list of recentNotebook instances that have been accessed by the signed-in user.

        :param bool include_personal_notebooks: Include notebooks owned by the user. Set to true to include notebooks
            owned by the user; otherwise, set to false. If you don't include the includePersonalNotebooks parameter,
            your request will return a 400 error response.
        """

        result = ClientResult(self.context, ClientValueCollection(RecentNotebook))
        params = {"includePersonalNotebooks": include_personal_notebooks}
        qry = ServiceOperationQuery(self, "getRecentNotebooks", params, None, None, result)
        self.context.add_query(qry)

        def _construct_request(request):
            request.method = HttpMethod.Get

        self.context.before_execute(_construct_request)
        return result
Пример #24
0
    def get_list_data_as_stream(context, list_full_url, parameters=None):
        """
        Returns list data from the specified list url and for the specified query parameters.

        :param office365.sharepoint.client_context.ClientContext context: Client context
        :param str list_full_url: The absolute URL of the list.
        :param RenderListDataParameters parameters: The parameters to be used.
        """
        result = ClientResult(context)
        payload = {
            "listFullUrl": list_full_url,
            "parameters": parameters,
        }
        target_list = context.web.get_list(list_full_url)
        qry = ServiceOperationQuery(target_list, "GetListDataAsStream", None,
                                    payload, None, result)
        context.add_query(qry)
        return result
    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.

        :type item: office365.graph.onedrive.driveItemUploadableProperties.DriveItemUploadableProperties
        """
        result = ClientResult(UploadSession())
        qry = ServiceOperationQuery(self,
                                    "createUploadSession",
                                    None,
                                    {
                                        "item": item
                                    },
                                    None,
                                    result
                                    )
        self.context.add_query(qry)
        return result
Пример #26
0
    def create_session(self):
        """
        Create a new workbook session.

        Excel APIs can be called in one of two modes:
            Persistent session - All changes made to the workbook are persisted (saved). This is the usual mode of
                operation.
            Non-persistent session - Changes made by the API are not saved to the source location. Instead, the Excel
                backend server keeps a temporary copy of the file that reflects the changes made during that particular
                API session. When the Excel session expires, the changes are lost. This mode is useful for apps that
                need to do analysis or obtain the results of a calculation or a chart image, but not affect the
                document state.
        """
        return_type = ClientResult(self.context, WorkbookSessionInfo())
        qry = ServiceOperationQuery(self, "createSession", None, None, None,
                                    return_type)
        self.context.add_query(qry)
        return return_type
Пример #27
0
 def add_microservice_work_item(context, payload, minutes, properties):
     """
     :param office365.sharepoint.client_context.ClientContext context:
     :param str or byte payload:
     :param int minutes:
     :param MicroServiceWorkItemProperties properties:
     """
     return_type = ClientResult(context)
     payload = {
         "payLoad": payload,
         "minutes": minutes,
         "properties": properties
     }
     manager = MicroServiceManager(context)
     qry = ServiceOperationQuery(manager, "AddMicroserviceWorkItem", None,
                                 payload, None, return_type)
     qry.static = True
     context.add_query(qry)
     return return_type
Пример #28
0
    def find_meeting_times(self):
        """
        Suggest meeting times and locations based on organizer and attendee availability, and time or location
        constraints specified as parameters.

        If findMeetingTimes cannot return any meeting suggestions, the response would indicate a reason in the
        emptySuggestionsReason property. Based on this value, you can better adjust the parameters
        and call findMeetingTimes again.

        The algorithm used to suggest meeting times and locations undergoes fine-tuning from time to time.
        In scenarios like test environments where the input parameters and calendar data remain static, expect
        that the suggested results may differ over time.

        """
        result = ClientResult(self.context, MeetingTimeSuggestionsResult())
        qry = ServiceOperationQuery(self, "findMeetingTimes", None, None, None,
                                    result)
        self.context.add_query(qry)
        return result
Пример #29
0
    def create_group_for_site(self, display_name, alias, is_public=None, optional_params=None):
        """
        Create a modern site

        :param str display_name:
        :param str alias:
        :param bool or None is_public:
        :param office365.sharepoint.portal.group_creation_params.GroupCreationParams or None optional_params:
        """
        payload = {
            "displayName": display_name,
            "alias": alias,
            "isPublic": is_public,
            "optionalParams": optional_params
        }
        return_type = ClientResult(self.context, GroupSiteInfo())
        qry = ServiceOperationQuery(self, "CreateGroupForSite", None, payload, None, return_type)
        self.context.add_query(qry)
        return return_type
Пример #30
0
    def copy_folder(context, srcUrl, destUrl, options):
        """

        :param office365.sharepoint.utilities.move_copy_options.MoveCopyOptions options:
        :param str srcUrl:
        :param str destUrl:
        :param office365.sharepoint.client_context.ClientContext context: client context
        """
        result = ClientResult(context)
        util = MoveCopyUtil(context)
        payload = {
            "srcUrl": srcUrl,
            "destUrl": destUrl,
            "options": options
        }
        qry = ServiceOperationQuery(util, "CopyFolder", None, payload, None, result)
        qry.static = True
        context.add_query(qry)
        return result