Skip to content

Conversation

varkart
Copy link

@varkart varkart commented Aug 7, 2025

Add name filter support to ListStores

  • Add name parameter to ClientListStoresOptions
  • Extend OpenFgaApi.listStores() method signatures
  • Update OpenFgaClient to pass name parameter
  • Add comprehensive unit and integration tests
  • Maintain full backward compatibility

Resolves #157

Description

What problem is being solved?

The OpenFGA API supports filtering stores by name (introduced in openfga/api#211), but the Java SDK doesn't expose
this functionality. Users currently cannot filter stores by name when calling listStores(), requiring them to
retrieve all stores and filter client-side.

How is it being solved?

Added optional name parameter support to the existing ListStores functionality by:

  • Extending the ClientListStoresOptions class with a name field
  • Adding overloaded methods to OpenFgaApi.listStores() that accept the name parameter
  • Updating OpenFgaClient to pass the name parameter from options to the API
  • Using the existing pathWithParams utility to properly construct query parameters

What changes are made to solve it?

  1. ClientListStoresOptions.java: Added name field with fluent setter/getter methods
  2. OpenFgaApi.java: Added overloaded listStores methods accepting name parameter while maintaining backward
    compatibility
  3. OpenFgaClient.java: Updated to pass getName() from options to the API call
  4. Comprehensive test coverage: Added unit tests for name filtering scenarios and integration tests for both API
    and Client levels

Usage examples:

// Filter by name only
ClientListStoresOptions options = new ClientListStoresOptions().name("my-store");
ClientListStoresResponse response = client.listStores(options).get();

// Combine with pagination
ClientListStoresOptions options = new ClientListStoresOptions()
    .name("my-store")
    .pageSize(10)
    .continuationToken("token");

References

Review Checklist

  • I have clicked on ["allow edits by maintainers"](https://docs.github.com/en/pull-requests/collaborating-with-p
    ull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork).
  • I have added documentation for new/changed functionality in this PR or in a PR to
    openfga.dev [Provide a link to any relevant PRs in the references section
    above]
  • The correct base branch is being used, if not main
  • I have added tests to validate that the change in functionality is working as expected

Summary by CodeRabbit

  • New Features

    • Added the ability to filter stores by name when listing stores.
  • Tests

    • Introduced new integration and unit tests to verify store listing with name filtering and ensure correct behavior with various query parameters.

@varkart varkart requested a review from a team as a code owner August 7, 2025 03:49
Copy link

linux-foundation-easycla bot commented Aug 7, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

Copy link
Contributor

coderabbitai bot commented Aug 7, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes add support for filtering stores by name in the listStores methods of the Java SDK. This includes updates to method signatures in OpenFgaApi and OpenFgaClient, enhancements to the client options class, and new or updated integration and unit tests to verify the name filtering functionality.

Changes

Cohort / File(s) Change Summary
API: Add name filter to listStores
src/main/java/dev/openfga/sdk/api/OpenFgaApi.java
Extended all listStores overloads to support an optional name filter parameter; updated private method and delegation logic.
Client: Pass name filter in listStores
src/main/java/dev/openfga/sdk/api/client/OpenFgaClient.java
Modified listStores(ClientListStoresOptions) to pass the new name parameter to the API.
Options: Add name field
src/main/java/dev/openfga/sdk/api/configuration/ClientListStoresOptions.java
Added name field with getter and fluent setter to support specifying the store name filter.
Integration Tests: API
src/test-integration/java/dev/openfga/sdk/api/OpenFgaApiIntegrationTest.java
Added test for listStores with name filter, creating stores and asserting correct filtering.
Integration Tests: Client
src/test-integration/java/dev/openfga/sdk/api/client/OpenFgaClientIntegrationTest.java
Added test for listStores with name filter using options, asserting correct filtering.
Unit Tests: Client
src/test/java/dev/openfga/sdk/api/client/OpenFgaClientTest.java
Added tests for listStores with name filter and with all parameters, verifying query parameter handling.

Sequence Diagram(s)

sequenceDiagram
    participant Client as OpenFgaClient
    participant Api as OpenFgaApi
    participant Server as OpenFGA Server

    Client->>Api: listStores(pageSize, continuationToken, name, override)
    Api->>Server: GET /stores?page_size=...&continuation_token=...&name=...
    Server-->>Api: ListStoresResponse (filtered by name)
    Api-->>Client: ApiResponse<ListStoresResponse>
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Assessment against linked issues

Objective Addressed Explanation
Add support for name filter in OpenFgaApi and OpenFgaClient listStores methods (#157)
Allow passing name in ClientListStoresOptions for filtering (#157)
Add tests verifying store filtering by name in API and client (#157)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes found.

Possibly related issues

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@jimmyjames
Copy link
Contributor

hi @varkart, thanks for the PR!

Generally looking good, a couple things we need:

@varkart varkart force-pushed the main branch 2 times, most recently from c54882a to d6211f3 Compare September 2, 2025 12:07
@varkart
Copy link
Author

varkart commented Sep 2, 2025

hi @varkart, thanks for the PR!

Generally looking good, a couple things we need:

hi @jimmyjames
I fixed the IT, could you plz review again.
I did verify the filter and added tests accordingly; and it was working as expected.
What do you mean my manual testing ?

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 80.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 35.21%. Comparing base (ff7aa69) to head (d6211f3).
⚠️ Report is 15 commits behind head on main.

Files with missing lines Patch % Lines
src/main/java/dev/openfga/sdk/api/OpenFgaApi.java 60.00% 2 Missing ⚠️

❌ Your project status has failed because the head coverage (35.21%) is below the target coverage (80.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #195      +/-   ##
============================================
+ Coverage     33.73%   35.21%   +1.47%     
- Complexity     1005     1073      +68     
============================================
  Files           182      187       +5     
  Lines          6900     7093     +193     
  Branches        778      803      +25     
============================================
+ Hits           2328     2498     +170     
- Misses         4467     4485      +18     
- Partials        105      110       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

- Add name parameter to ClientListStoresOptions with fluent API
- Extend OpenFgaApi.listStores() method signatures with backward compatibility
- Update OpenFgaClient to pass name parameter from options to API
- Add comprehensive unit and integration tests
- Update OpenFGA container version for test compatibility
- Maintain full backward compatibility

Resolves openfga#157
  - Add name parameter to ClientListStoresOptions
  - Extend OpenFgaApi.listStores() method signatures
  - Update OpenFgaClient to pass name parameter
  - Add comprehensive unit and integration tests
  - Maintain full backward compatibility

  Resolves openfga#157
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support passing name filter to ListStores
3 participants