Skip to content

Commit

Permalink
doc(model/write): add missing example to readme, correct help text ex…
Browse files Browse the repository at this point in the history
…ample
  • Loading branch information
ewanharris committed Apr 10, 2024
1 parent f62751c commit 24b9808
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,8 @@ fga model **write**
* `--format`: Authorization model input format. Can be "fga", "json", or "modular". Defaults to the file extension if provided (optional)

###### Example
* `fga model write --store-id=01H0H015178Y2V4CX10C2KGHF4 --file model.fga`
* `fga model write --store-id=01H0H015178Y2V4CX10C2KGHF4 --file=model.fga`
* `fga model write --store-id=01H0H015178Y2V4CX10C2KGHF4 --file=fga.mod`
* `fga model write --store-id=01H0H015178Y2V4CX10C2KGHF4 '{"type_definitions": [ { "type": "user" }, { "type": "document", "relations": { "can_view": { "this": {} } }, "metadata": { "relations": { "can_view": { "directly_related_user_types": [ { "type": "user" } ] }}}} ], "schema_version": "1.1"}' --format json`

###### Response
Expand Down
5 changes: 3 additions & 2 deletions cmd/model/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ var writeCmd = &cobra.Command{
Short: "Write Authorization Model",
Long: "Writes a new authorization model.",
Example: `fga model write --store-id=01H0H015178Y2V4CX10C2KGHF4 --file=model.json
fga model write --store-id=01H0H015178Y2V4CX10C2KGHF4 '{"type_definitions":[{"type":"user"},{"type":"document","relations":{"can_view":{"this":{}}},"metadata":{"relations":{"can_view":{"directly_related_user_types":[{"type":"user"}]}}}}],"schema_version":"1.1"}'`, //nolint:lll
fga model write --store-id=01H0H015178Y2V4CX10C2KGHF4 --file=fga.mod
fga model write --store-id=01H0H015178Y2V4CX10C2KGHF4 '{"type_definitions":[{"type":"user"},{"type":"document","relations":{"can_view":{"this":{}}},"metadata":{"relations":{"can_view":{"directly_related_user_types":[{"type":"user"}]}}}}],"schema_version":"1.1"}' --format=json`, //nolint:lll
Args: cobra.MaximumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
clientConfig := cmdutils.GetClientConfig(cmd)
Expand Down Expand Up @@ -97,7 +98,7 @@ var writeInputFormat = authorizationmodel.ModelFormatDefault
func init() {
writeCmd.Flags().String("store-id", "", "Store ID")
writeCmd.Flags().String("file", "", "File Name. The file should have the model in the JSON or DSL format")
writeCmd.Flags().Var(&writeInputFormat, "format", `Authorization model input format. Can be "fga" or "json"`)
writeCmd.Flags().Var(&writeInputFormat, "format", `Authorization model input format. Can be "fga", "json", or "modular"`) //nolint:lll

if err := writeCmd.MarkFlagRequired("store-id"); err != nil {
fmt.Printf("error setting flag as required - %v: %v\n", "cmd/models/write", err)
Expand Down

0 comments on commit 24b9808

Please sign in to comment.