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

feat: create the --simple-json flag for tuple read #168

Merged
merged 1 commit into from
Oct 9, 2023
Merged

feat: create the --simple-json flag for tuple read #168

merged 1 commit into from
Oct 9, 2023

Conversation

gabrielbussolo
Copy link
Contributor

@gabrielbussolo gabrielbussolo commented Sep 27, 2023

aims to close #111

I made the read function to return a "complete" version and a "simple" version of the JSON that can be imported by tuple write and tuple delete with the flag --file.

Description

now if its informed the --simple-json flag the response is this:

./dist/fga tuple read --store-id 01HB3AZ6RAAGHJQ9HKXV9C89SE --simple-json
[
  {
    "object":"document:Z",
    "relation":"reader",
    "user":"user:gabriel"
  },
  {
    "object":"document:Z",
    "relation":"reader",
    "user":"user:anne"
  },
  {
    "object":"document:Z",
    "relation":"reader",
    "user":"user:jones"
  }
]

without the flag:

./dist/fga tuple read --store-id 01HB3AZ6RAAGHJQ9HKXV9C89SE              
{
  "tuples": [
    {
      "key": {
        "object":"document:Z",
        "relation":"reader",
        "user":"user:gabriel"
      },
      "timestamp":"2023-09-27T10:58:46.209655Z"
    },
    {
      "key": {
        "object":"document:Z",
        "relation":"reader",
        "user":"user:anne"
      },
      "timestamp":"2023-09-27T10:58:46.208397Z"
    },
    {
      "key": {
        "object":"document:Z",
        "relation":"reader",
        "user":"user:jones"
      },
      "timestamp":"2023-09-27T10:58:46.209576Z"
    }
  ]
}

now its possible to use like:

 ./dist/fga tuple read --store-id 01HB3AZ6RAAGHJQ9HKXV9C89SE --simple-json > tuple-simple.json
 ./dist/fga tuple delete --store-id 01HB3AZ6RAAGHJQ9HKXV9C89SE --file tuple-simple.json
{
  "successful": [
    {
      "object":"document:Z",
      "relation":"reader",
      "user":"user:gabriel"
    },
    {
      "object":"document:Z",
      "relation":"reader",
      "user":"user:anne"
    },
    {
      "object":"document:Z",
      "relation":"reader",
      "user":"user:jones"
    }
  ],
  "failed":null
}

References

Review Checklist

  • I have clicked on "allow edits by maintainers".
  • 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

@gabrielbussolo gabrielbussolo requested a review from a team as a code owner September 27, 2023 15:02
@rhamzeh rhamzeh added this pull request to the merge queue Oct 9, 2023
Merged via the queue into openfga:main with commit 4adc839 Oct 9, 2023
@gabrielbussolo gabrielbussolo deleted the 111-provide-an-option-in-tuple-read-that-outputs-the-format-used-in-tuple-import branch October 11, 2023 13:04
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.

Provide an option in tuple read that outputs the format used in tuple import
2 participants