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 --expunge option to event-type delete #100

Merged
merged 3 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions cmd/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,11 @@ Example Schema:
printer.CheckErr(err)
ep.Disabled = &disabledFlag
}
versionFlag, err := cmd.Flags().GetInt32(versionFlagName)
printer.CheckErr(err)
ep.Version = versionFlag

if cmd.Flags().Changed(versionFlagName) {
versionFlag, err := cmd.Flags().GetInt32(versionFlagName)
printer.CheckErr(err)
ep.Version.Set(&versionFlag)
}
svixClient := getSvixClientOrExit()
out, err := svixClient.Endpoint.Create(cmd.Context(), appID, &ep)
printer.CheckErr(err)
Expand All @@ -117,7 +118,7 @@ Example Schema:
},
}
create.Flags().String(urlFlagName, "", "")
create.Flags().Int32(versionFlagName, 1, "")
create.Flags().Int32(versionFlagName, 0, "")
create.Flags().StringArray(filterTypesFlagName, []string{}, "")
create.Flags().Int32(rateLimitFlagName, 0, "Rate Limit of the endpoint (optional)")
create.Flags().Bool(disabledFlagName, false, "")
Expand Down Expand Up @@ -189,7 +190,7 @@ Example Schema:
if cmd.Flags().Changed(versionFlagName) {
versionFlag, err := cmd.Flags().GetInt32(versionFlagName)
printer.CheckErr(err)
ep.Version = versionFlag
ep.Version.Set(&versionFlag)
}
if cmd.Flags().Changed(filterTypesFlagName) {
filterTypesFlag, err := cmd.Flags().GetStringArray(filterTypesFlagName)
Expand Down
11 changes: 9 additions & 2 deletions cmd/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,22 @@ Example Schema:
// parse args
eventID := args[0]

utils.Confirm(fmt.Sprintf("Are you sure you want to delete the the event with id: %s", eventID))
utils.Confirm(fmt.Sprintf("Are you sure you want to delete the event with id: %s", eventID))

svixClient := getSvixClientOrExit()
err := svixClient.EventType.Delete(cmd.Context(), eventID)
options := &svix.EventTypeDeleteOptions{}
expunge, _ := cmd.Flags().GetBool("expunge")
if cmd.Flags().Changed("expunge") {
options.Expunge = &expunge
}
err := svixClient.EventType.DeleteWithOptions(cmd.Context(), eventID, options)
printer.CheckErr(err)

fmt.Printf("Event Type \"%s\" Deleted!\n", eventID)
},
}

delete.Flags().Bool("expunge", false, "permanently delete instead of archiving")
etc.cmd.AddCommand(delete)

return etc
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ require (
github.com/spf13/afero v1.6.0 // indirect
github.com/spf13/cobra v1.3.0
github.com/spf13/viper v1.10.0
github.com/svix/svix-webhooks v1.7.0
github.com/svix/svix-webhooks v1.12.1-0.20230926011735-7bc1d38200ec
github.com/tidwall/pretty v1.1.1
)
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,12 @@ github.com/svix/svix-webhooks v0.75.0 h1:GH8myVTh6EDlVIHbyEXqs6bA8a/zSBH3JmZKRdD
github.com/svix/svix-webhooks v0.75.0/go.mod h1:vWwH7D6zMhF9pCLfgLlogcXGDmnGqIJeIT9AXorZTAQ=
github.com/svix/svix-webhooks v1.7.0 h1:rfJ9yGc1h9odbdoNW8+dkO4ZdgajPYXvTdLqJsLBcIo=
github.com/svix/svix-webhooks v1.7.0/go.mod h1:q3Z9c8NXqDRPZviI+zLMToAja+bjhTw929cMVhJirOI=
github.com/svix/svix-webhooks v1.12.1-0.20230925233234-3ab7663b4d56 h1:PQ68xHJkoZ8Y0O283S+QRg9X6vbUyWKvuQHauLaaC3U=
github.com/svix/svix-webhooks v1.12.1-0.20230925233234-3ab7663b4d56/go.mod h1:q3Z9c8NXqDRPZviI+zLMToAja+bjhTw929cMVhJirOI=
github.com/svix/svix-webhooks v1.12.1-0.20230925234853-e39398a6349d h1:0EDWjQWi6yyBwekvXhMxbmM7M/llfGeYCeiUQvVfe8g=
github.com/svix/svix-webhooks v1.12.1-0.20230925234853-e39398a6349d/go.mod h1:q3Z9c8NXqDRPZviI+zLMToAja+bjhTw929cMVhJirOI=
github.com/svix/svix-webhooks v1.12.1-0.20230926011735-7bc1d38200ec h1:q7YwrxoMXMHBhlrNqshcI+X+1zb5D8gNkNqsom3n+Dc=
github.com/svix/svix-webhooks v1.12.1-0.20230926011735-7bc1d38200ec/go.mod h1:q3Z9c8NXqDRPZviI+zLMToAja+bjhTw929cMVhJirOI=
github.com/tidwall/pretty v1.1.1 h1:nt6/Ot5LtZnJCWwEFlelOixPo0xhPFsuZlKyOL3Xfnc=
github.com/tidwall/pretty v1.1.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
Expand Down
Loading