🔍 Code Extractor

class RecycleBinQueryInformation

Maturity: 36

A data class that encapsulates query parameters for retrieving items from a SharePoint recycle bin, including filtering, sorting, and pagination options.

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/recyclebin/query_information.py
Lines:
4 - 31
Complexity:
simple

Purpose

RecycleBinQueryInformation is used to configure and execute queries against SharePoint recycle bins. It allows filtering by item state (first-stage or second-stage recycle bin), sorting by specific columns, limiting results, paginating through large result sets, and optionally filtering to show only items deleted by the current user. This class inherits from ClientValue, making it compatible with the Office365 REST API client framework for serialization and transmission to SharePoint services.

Source Code

class RecycleBinQueryInformation(ClientValue):
    def __init__(
        self,
        is_ascending,
        item_state,
        order_by,
        paging_info,
        row_limit,
        show_only_my_items,
    ):
        """
        Represents information for the recycle bin query.

        :param bool show_only_my_items: Gets or sets a Boolean value that specifies whether to get items deleted by
            other users.
        :param int row_limit: Gets or sets a limit for the number of items returned in the query per page.
        :param str paging_info: Gets or sets a string used to get the next set of rows in the page.
        :param int order_by: Gets or sets the column by which to order the Recycle Bin query.
        :param int item_state: Gets or sets the Recycle Bin state of items to return in the query.
        :param bool is_ascending: Gets or sets a Boolean value that specifies whether to sort in ascending order.
        """
        super(RecycleBinQueryInformation, self).__init__()
        self.IsAscending = is_ascending
        self.ItemState = item_state
        self.OrderBy = order_by
        self.PagingInfo = paging_info
        self.RowLimit = row_limit
        self.ShowOnlyMyItems = show_only_my_items

Parameters

Name Type Default Kind
bases ClientValue -

Parameter Details

is_ascending: Boolean flag that determines the sort order of query results. When True, results are sorted in ascending order; when False, results are sorted in descending order based on the column specified in order_by.

item_state: Integer value specifying which recycle bin stage to query. Typically represents first-stage recycle bin (items deleted by users) or second-stage recycle bin (items deleted from first-stage). The exact integer values correspond to SharePoint's RecycleBinItemState enumeration.

order_by: Integer value representing the column by which to sort the recycle bin query results. This corresponds to SharePoint's RecycleBinOrderBy enumeration, which includes options like DeletedDate, DeletedBy, Title, etc.

paging_info: String token used for pagination to retrieve subsequent pages of results. This is typically obtained from the previous query response and passed to the next query to continue where the last page ended. Can be None or empty string for the first page.

row_limit: Integer specifying the maximum number of items to return per page in the query results. Controls pagination size and helps manage large result sets by limiting the number of items retrieved in a single request.

show_only_my_items: Boolean flag that filters results to show only items deleted by the current authenticated user when True. When False, returns items deleted by all users (subject to permissions).

Return Value

Instantiation returns a RecycleBinQueryInformation object that encapsulates all query parameters. This object is typically passed to SharePoint API methods that query the recycle bin, where it gets serialized into the appropriate request format. The class itself doesn't have methods that return values; it serves as a data container.

Class Interface

Methods

__init__(self, is_ascending, item_state, order_by, paging_info, row_limit, show_only_my_items)

Purpose: Initializes a new RecycleBinQueryInformation instance with all required query parameters

Parameters:

  • is_ascending: Boolean flag for sort order (True for ascending, False for descending)
  • item_state: Integer representing the recycle bin stage to query
  • order_by: Integer representing the column to sort by
  • paging_info: String token for pagination continuation
  • row_limit: Integer maximum number of items per page
  • show_only_my_items: Boolean flag to filter by current user's deleted items

Returns: A new RecycleBinQueryInformation instance

Attributes

Name Type Description Scope
IsAscending bool Stores whether the query results should be sorted in ascending order instance
ItemState int Stores the recycle bin state filter (first-stage or second-stage) instance
OrderBy int Stores the column identifier to use for sorting results instance
PagingInfo str Stores the pagination token for retrieving subsequent pages of results instance
RowLimit int Stores the maximum number of items to return per page instance
ShowOnlyMyItems bool Stores whether to filter results to only items deleted by the current user instance

Dependencies

  • office365

Required Imports

from office365.runtime.client_value import ClientValue

Usage Example

from office365.runtime.client_value import ClientValue
from office365.sharepoint.recycleBin.query_information import RecycleBinQueryInformation

# Create a query to get the first 50 items from the recycle bin
# sorted by deletion date in descending order, showing all users' deleted items
query_info = RecycleBinQueryInformation(
    is_ascending=False,
    item_state=1,  # First-stage recycle bin
    order_by=0,  # Order by DeletedDate
    paging_info='',  # Empty for first page
    row_limit=50,
    show_only_my_items=False
)

# Use with SharePoint context to query recycle bin
# ctx = ClientContext(site_url).with_credentials(credentials)
# recycle_bin_items = ctx.web.recycle_bin.get_by_query_info(query_info)
# ctx.execute_query()

# For pagination, use the paging info from previous response
query_info_page2 = RecycleBinQueryInformation(
    is_ascending=False,
    item_state=1,
    order_by=0,
    paging_info='Paged=TRUE&p_ID=100',  # Token from previous response
    row_limit=50,
    show_only_my_items=False
)

Best Practices

  • Always set an appropriate row_limit to avoid retrieving too many items in a single request, which can impact performance
  • Use empty string or None for paging_info on the first query, then use the paging token from the response for subsequent pages
  • The item_state and order_by parameters should use the appropriate enumeration values defined by SharePoint's API (typically 0, 1, 2, etc.)
  • When show_only_my_items is True, ensure the authenticated user context is properly set up
  • This class is immutable after instantiation - create a new instance if you need to modify query parameters
  • The class inherits from ClientValue, which means it will be automatically serialized when used with Office365 API calls
  • Verify that the authenticated user has sufficient permissions to access the recycle bin before executing queries

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class RecycleBinItem 67.9% similar

    Represents a Recycle Bin item in the Recycle Bin of a site or a site collection.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/recyclebin/item.py
  • class RecycleBinItemCollection 64.2% similar

    Represents a collection of View resources.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/recyclebin/item_collection.py
  • class QueryRoutingInfo 60.6% similar

    A data class representing query routing information for SharePoint search operations, containing query state and search endpoints.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/search/query/routing_info.py
  • class SearchQuery 58.0% similar

    Represents a search query object that encapsulates search terms and optional query templates for SharePoint/Office365 search operations.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/search/query.py
  • class QueryConfiguration 57.5% similar

    A data class representing query configuration for a SharePoint local farm, encapsulating query context, parameters, routing information, and search endpoints.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/search/query/configuration.py
← Back to Browse