[FEATURE] Support Filtering Results Via API Query Parameters

by ADMIN 61 views

Motivation

Filtering is a fundamental feature of any enterprise-grade API, allowing users to restrict which elements of a collection are returned according to their preferences. In this feature, we aim to enhance the "list" endpoints available in Notebooks 2.0 to honor filtering, with the default behavior of returning all results if no filtering information is provided by the user. This feature is crucial for providing a more user-friendly and efficient experience for API users.

Affected Endpoints

The following endpoints will be affected by this feature:

  • GET api/v1/workspaces
  • GET api/v1/workspaces/{namespace}
  • GET api/v1/workspacekinds

High Level Design/Mock-ups

While we have a clear understanding of the requirements for this feature, we do not have any high-level design or mock-ups to share at this time. Our focus will be on implementing the filtering functionality in a way that is consistent and efficient across all affected endpoints.

Acceptance Criteria

To ensure that this feature meets the required standards, we have established the following acceptance criteria:

Query Parameter Availability

  • Query parameter(s) will be available on the aforementioned endpoints to restrict results based on comparisons to a given attribute.
  • The query parameters will be implemented in a way that is consistent across all endpoints.

Error Handling

  • Attributes that do not support filtering (or unrecognized attributes) will return a 400 status response with helpful error text.
  • Endpoints that do not support filtering will return a 400 status response with helpful error text.

Filtering Implementation

  • The filtering implementation/syntax will be consistent across all endpoints.
  • The filtering implementation will be designed to handle various comparison operators (e.g., eq, ne, gt, lt, etc.).

Implementation Details

To implement this feature, we will follow these steps:

  1. Identify Supported Attributes: We will identify the attributes that support filtering and ensure that they are consistent across all endpoints.
  2. Implement Query Parameters: We will implement the query parameters on the affected endpoints to restrict results based on comparisons to a given attribute.
  3. Error Handling: We will implement error handling to return a 400 status response with helpful error text for attributes that do not support filtering or unrecognized attributes.
  4. Filtering Implementation: We will implement the filtering functionality in a way that is consistent across all endpoints, using various comparison operators (e.g., eq, ne, gt, lt, etc.).

Benefits

The implementation of this feature will provide several benefits, including:

  • Improved User Experience: By allowing users to restrict results based on their preferences, we can provide a more user-friendly and efficient experience for API users.
  • Increased Efficiency: By reducing the amount of data returned, we can improve the performance of the API and reduce the load on the system.
  • Enhanced Flexibility: By providing a consistent filtering implementation across all endpoints, we can enhance the flexibility of the API and make it easier for users to integrate with our system.

Conclusion

Q&A

Q: What is the motivation behind implementing filtering results via API query parameters?

A: The motivation behind implementing filtering results via API query parameters is to provide a more user-friendly and efficient experience for API users. By allowing users to restrict which elements of a collection are returned according to their preferences, we can improve the user experience and reduce the load on the system.

Q: Which endpoints will be affected by this feature?

A: The following endpoints will be affected by this feature:

  • GET api/v1/workspaces
  • GET api/v1/workspaces/{namespace}
  • GET api/v1/workspacekinds

Q: What is the default behavior of the API if no filtering information is provided by the user?

A: The default behavior of the API is to return all results if no filtering information is provided by the user.

Q: What happens if an attribute does not support filtering or is unrecognized?

A: If an attribute does not support filtering or is unrecognized, the API will return a 400 status response with helpful error text.

Q: What is the expected behavior of the API when filtering on a valid attribute that has no matches persisted in the system?

A: The API will return an empty list with a 200 response code if filtering on a valid attribute that has no matches persisted in the system.

Q: How will the filtering implementation be consistent across all endpoints?

A: The filtering implementation will be consistent across all endpoints by using a consistent syntax and implementation details.

Q: What are the benefits of implementing filtering results via API query parameters?

A: The benefits of implementing filtering results via API query parameters include:

  • Improved User Experience: By allowing users to restrict results based on their preferences, we can provide a more user-friendly and efficient experience for API users.
  • Increased Efficiency: By reducing the amount of data returned, we can improve the performance of the API and reduce the load on the system.
  • Enhanced Flexibility: By providing a consistent filtering implementation across all endpoints, we can enhance the flexibility of the API and make it easier for users to integrate with our system.

Q: What is the current status of the frontend integration with the API?

A: The frontend integration with the API is currently relying on a rendered table that has filtering capabilities. However, work is underway to integrate the API behavior with the frontend once the sorting, filtering, and paging functionality is present in the backend.

Q: What is the expected timeline for the frontend integration with the API?

A: The expected timeline for the frontend integration with the API is once the sorting, filtering, and paging functionality is present in the backend.

Q: How can users provide feedback on the implementation of filtering results via API query parameters?

A: Users can provide feedback on the implementation of filtering results via API query parameters by submitting a support ticket or contacting our support team directly.