Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pagination, filtering and sort to more API endpoints #12186

Merged
merged 13 commits into from
Mar 9, 2022

Commits on Mar 3, 2022

  1. api: split paginator components

    As more endpoints started using the API response paginator, new patterns
    started to emerge that required either more flexible configuration or a
    lot of re-used code.
    
    This commit splits the paginator into three logical components:
    
    - The Paginator is reponsible for splitting the values of an iterator
      into chunks of the requested size.
    - The Tokenizer returns a page token that is used to uniquely identify
      elements of the iterator.
    - The Filter is used to decide if a given element should be added to the
      page or skipped altogether.
    
    The Paginator implementation has returned, more or less, to its initial
    clean design and implementation.
    
    Additional logic and flow customization can be provided by implementing
    the Tokenizer and Filter interfaces.
    
    One Tokenizer implementation is provided (StructsTokenizer) which can be
    configured to emit tokens using common fields found in structs, such as
    ID, Namespace, and CreateIndex.
    
    The go-bexpr Evaluator implements the Filter interface, so it can be
    used directly. Another implementation provided is the NamespaceFilter,
    which can be used to apply filtering logic based on the namespaces the
    ACL token used for the request is allowed to access.
    lgfa29 committed Mar 3, 2022
    Configuration menu
    Copy the full SHA
    1a5d07c View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    d5a0d7f View commit details
    Browse the repository at this point in the history
  3. api: add filter and pagination to /v1/volumes

    It's currently not possible to provide consistent sorting by CreateIndex
    to this endpoint because it requires a Namespace and ID to be able to
    uniquely identify a volume.
    
    This reduces the type of go-memdb indexes that can be created where the
    raft CreateIndex would be in a position that would allow sorting with
    prefix match.
    lgfa29 committed Mar 3, 2022
    Configuration menu
    Copy the full SHA
    7069e67 View commit details
    Browse the repository at this point in the history
  4. api: add filter and pagination to /v1/jobs

    It's currently not possible to provide consistent sorting by CreateIndex
    to this endpoint because it requires a Namespace and ID to be able to
    uniquely identify a job.
    
    This reduces the type of go-memdb indexes that can be created where the
    raft CreateIndex would be in a position that would allow sorting with
    prefix match.
    lgfa29 committed Mar 3, 2022
    Configuration menu
    Copy the full SHA
    b624798 View commit details
    Browse the repository at this point in the history
  5. api: add filter, pagination, and sorting to /v1/allocations

    Co-authored-by: Seth Hoenig <seth.a.hoenig@gmail.com>
    lgfa29 and shoenig committed Mar 3, 2022
    Configuration menu
    Copy the full SHA
    ef098d7 View commit details
    Browse the repository at this point in the history
  6. api: refactor allocations list endpoint

    Refactor the allocations list endpoint to merge the listAllNamespaces
    special case into the normal List function.
    
    Co-authored-by: Seth Hoenig <seth.a.hoenig@gmail.com>
    lgfa29 and shoenig committed Mar 3, 2022
    Configuration menu
    Copy the full SHA
    194c407 View commit details
    Browse the repository at this point in the history
  7. api: refactor jobs list endpoint

    Refactor the jobs list endpoint to merge the listAllNamespaces special
    case into the normal List function.
    lgfa29 committed Mar 3, 2022
    Configuration menu
    Copy the full SHA
    cac9ec4 View commit details
    Browse the repository at this point in the history
  8. api: rename ascending query param to reverse

    Using reverse provides a more generic intention that the results should
    be returned in the reverse of the default order instead of assuming any
    particular order.
    lgfa29 committed Mar 3, 2022
    Configuration menu
    Copy the full SHA
    8582efb View commit details
    Browse the repository at this point in the history
  9. changelog: add entry for #12186

    lgfa29 committed Mar 3, 2022
    Configuration menu
    Copy the full SHA
    e181fd6 View commit details
    Browse the repository at this point in the history

Commits on Mar 7, 2022

  1. remove unused code

    lgfa29 committed Mar 7, 2022
    Configuration menu
    Copy the full SHA
    e79ecf8 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    837884c View commit details
    Browse the repository at this point in the history

Commits on Mar 8, 2022

  1. fix typo

    lgfa29 committed Mar 8, 2022
    Configuration menu
    Copy the full SHA
    f7392b8 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    cb8c6d0 View commit details
    Browse the repository at this point in the history