getItems method

Future<PagedList<ItemResponse>> getItems(
  1. String parentPath, {
  2. String? nameFilter,
  3. String? kindFilter,
  4. int? pageSize,
  5. String? cursor,
  6. bool includeDeprecated = false,
})
inherited

Lists items within a space with optional filtering.

parentPath is the space path to list items from. nameFilter filters items by name pattern (supports wildcards). kindFilter filters items by kind. pageSize optional page size for pagination. cursor optional cursor for pagination. includeDeprecated whether to include deprecated items.

Implementation

Future<PagedList<ItemResponse>> getItems(
  String parentPath, {
  String? nameFilter,
  String? kindFilter,
  int? pageSize,
  String? cursor,
  bool includeDeprecated = false,
}) async {
  final request = GetItemsRequest()
    ..parentPath = parentPath
    ..itemNameFilter = nameFilter ?? ''
    ..kindFilter = kindFilter ?? ''
    ..includeDeprecated = includeDeprecated;

  if (pageSize != null || cursor != null) {
    request.pagination = PaginationRequest()
      ..pageSize = pageSize ?? 100
      ..cursor = cursor ?? '';
  }

  final response = await stub.getItems(request, options: callOptions);

  return PagedList(
    response.items,
    nextCursor: response.hasPagination() ? response.pagination.nextCursor : null,
    totalCount: response.hasPagination() ? response.pagination.totalCount : null,
  );
}