예제 #1
0
    def get_item_by_id(self, item_id):
        """Returns the list item with the specified list item identifier.

        :type item_id: int
        """
        return ListItem(
            self.context,
            ResourcePathServiceOperation("getItemById", [item_id],
                                         self.resource_path))
예제 #2
0
    def get_list_item(self, str_url):
        """
        Returns the list item that is associated with the specified server-relative URL.

        :param str str_url: A string that contains the server-relative URL,
        for example, "/sites/MySite/Shared Documents/MyDocument.docx".
        :return: ListItem
        """
        return_item = ListItem(self.context, ResourcePathServiceOperation("GetListItem", [str_url], self.resource_path))
        return return_item
예제 #3
0
    def get_item_by_unique_id(self, uniqueId):
        """
        Returns the list item with the specified ID.

        :param str uniqueId:"""
        item = ListItem(
            self.context,
            ResourcePathServiceOperation("getItemByUniqueId", [uniqueId],
                                         self.resource_path))
        return item
예제 #4
0
    def get_item_by_unique_id(self, unique_id):
        """
        Returns the list item with the specified ID.

        :param str unique_id: The unique ID that is associated with the list item.

        """
        return ListItem(
            self.context,
            ServiceOperationPath("getItemByUniqueId", [unique_id],
                                 self.resource_path))
예제 #5
0
 def add_item_using_path(self, leaf_name, object_type, folder_url):
     """
     :type leaf_name: str
     :type object_type: int
     :type folder_url: str
     """
     from office365.sharepoint.types.resource_path import ResourcePath as SPResPath
     parameters = ListItemCreationInformationUsingPath(leaf_name, object_type, folder_path=SPResPath(folder_url))
     item = ListItem(self.context)
     qry = ServiceOperationQuery(self, "AddItemUsingPath", None, parameters, "parameters", item)
     self.context.add_query(qry)
     return item
예제 #6
0
    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 or dict"""
        item = ListItem(self.context, None, self)
        if isinstance(list_item_creation_information, dict):
            for k, v in list_item_creation_information.items():
                item.set_property(k, v, True)
            self.items.add_child(item)
            item.ensure_type_name(self)
            qry = ServiceOperationQuery(self, "items", None, item, None, item)
            self.context.add_query(qry)
        else:

            def _resolve_folder_url():
                list_item_creation_information.FolderUrl = self.context.base_url + self.root_folder.serverRelativeUrl
                add_item_qry = ServiceOperationQuery(
                    self, "addItem", None, list_item_creation_information,
                    "parameters", item)
                self.context.add_query(add_item_qry)

            self.root_folder.ensure_property("ServerRelativeUrl",
                                             _resolve_folder_url)
        return item
예제 #7
0
    def add_item_using_path(self, leaf_name, object_type, folder_url):
        """
        Adds a ListItem to an existing List.

        :param str leaf_name: Specifies the name of the list item that will be created. In the case of a
            document library, the name is equal to the filename of the list item.
        :param int object_type: Specifies the file system object type for the item that will be created.
            It MUST be either FileSystemObjectType.File or FileSystemObjectType.Folder.
        :param str ot None folder_url: Specifies the url of the folder of the new list item.
            The value MUST be either null or the decoded url value an empty string or a server-relative
            URL or an absolute URL. If the value is not null or the decoded url value not being empty string,
            the decoded url value MUST point to a location within the list.
        """
        parameters = ListItemCreationInformationUsingPath(
            leaf_name, object_type, folder_path=folder_url)
        return_type = ListItem(self.context)
        qry = ServiceOperationQuery(self, "AddItemUsingPath", None, parameters,
                                    "parameters", return_type)
        self.context.add_query(qry)
        return return_type
예제 #8
0
 def listItemAllFields(self):
     """Gets a value that specifies the list item fields values for the list item corresponding to the file."""
     if self.is_property_available('ListItemAllFields'):
         return self.properties['ListItemAllFields']
     else:
         return ListItem(self.context, ResourcePath("listItemAllFields", self.resource_path))
예제 #9
0
 def list_item_all_fields(self):
     """Specifies the list item fields (2) values for the list item corresponding to the folder."""
     return self.properties.get(
         "ListItemAllFields",
         ListItem(self.context,
                  ResourcePath("ListItemAllFields", self.resource_path)))
예제 #10
0
 def list_item_all_fields(self):
     """Specifies the list item fields (2) values for the list item corresponding to the folder."""
     if self.is_property_available('ListItemAllFields'):
         return self.properties["ListItemAllFields"]
     else:
         return ListItem(self.context, ResourcePath("ListItemAllFields", self.resource_path))
예제 #11
0
 def get_list_item(self, list_name, item_id):
     return ListItem(self,
                     ResourcePathServiceOperation(list_name, [item_id], None))
예제 #12
0
 def listItemAllFields(self):
     """Gets a value that specifies the list item fields values for the list item corresponding to the file."""
     return self.properties.get('ListItemAllFields',
                                ListItem(self.context, ResourcePath("listItemAllFields", self.resource_path)))