Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var CreateCmd = &cobra.Command{ Use: "create <mailbox-resource-id>", Short: "Create webhook", Long: "Create a webhook. The response includes the one-time `secret` — store it securely as it is never returned again.", Example: " hostinger-mail webhooks create my-mailbox-resource-id --events message.received --name 'New message notifier' --url https://example.com/webhooks/incoming", ValidArgsFunction: cobra.NoFileCompletions, RunE: func(cmd *cobra.Command, args []string) error { args = utils.PromptedArgs(cmd, args) if err := utils.EnumCheck(cmd, "status", []string{"active", "paused", "disabled"}); err != nil { return err } body, err := createBody(cmd) if err != nil { return err } payload, err := json.Marshal(body) if err != nil { return err } call := func(ctx context.Context) ([]byte, int, error) { r, err := api.Request().CreateWebhookWithBodyWithResponse(ctx, args[0], "application/json", bytes.NewReader(payload)) if err != nil { return nil, 0, err } return r.Body, r.StatusCode(), nil } respBody, status, err := call(cmd.Context()) if err != nil { return err } return output.Format(cmd, respBody, status) }, }
View Source
var DeleteCmd = &cobra.Command{ Use: "delete <mailbox-resource-id> <webhook>", Short: "Delete webhook", Long: "Delete a webhook.", Example: " hostinger-mail webhooks delete my-mailbox-resource-id 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d", ValidArgsFunction: cobra.NoFileCompletions, RunE: func(cmd *cobra.Command, args []string) error { args = utils.PromptedArgs(cmd, args) if err := utils.Confirm(cmd, "Delete webhook", args); err != nil { return err } call := func(ctx context.Context) ([]byte, int, error) { r, err := api.Request().DeleteWebhookWithResponse(ctx, args[0], uuid.MustParse(args[1])) if err != nil { return nil, 0, err } return r.Body, r.StatusCode(), nil } respBody, status, err := call(cmd.Context()) if err != nil { return err } return output.Format(cmd, respBody, status) }, }
View Source
var GetCmd = &cobra.Command{ Use: "get <mailbox-resource-id> <webhook>", Short: "Get webhook", Long: "Retrieve a single webhook by id.", Example: " hostinger-mail webhooks get my-mailbox-resource-id 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d", ValidArgsFunction: cobra.NoFileCompletions, RunE: func(cmd *cobra.Command, args []string) error { args = utils.PromptedArgs(cmd, args) call := func(ctx context.Context) ([]byte, int, error) { r, err := api.Request().GetWebhookWithResponse(ctx, args[0], uuid.MustParse(args[1])) if err != nil { return nil, 0, err } return r.Body, r.StatusCode(), nil } respBody, status, err := call(cmd.Context()) if err != nil { return err } return output.Format(cmd, respBody, status) }, }
View Source
var GroupCmd = &cobra.Command{ Use: "webhooks", Short: "Webhooks commands", Args: cobra.ArbitraryArgs, RunE: utils.GroupRunE, }
View Source
var ListCmd = &cobra.Command{ Use: "list <mailbox-resource-id>", Short: "List webhooks", Long: "List webhooks for a mailbox.", Example: " hostinger-mail webhooks list my-mailbox-resource-id", ValidArgsFunction: cobra.NoFileCompletions, RunE: func(cmd *cobra.Command, args []string) error { args = utils.PromptedArgs(cmd, args) if err := utils.EnumCheck(cmd, "status", []string{"active", "paused", "disabled"}); err != nil { return err } params := listParams(cmd) call := func(ctx context.Context) ([]byte, int, error) { r, err := api.Request().ListWebhooksWithResponse(ctx, args[0], params) if err != nil { return nil, 0, err } return r.Body, r.StatusCode(), nil } if all, _ := cmd.Flags().GetBool("all"); all { call = utils.AllPages(call, func(page int) { params.Page = &page }) } respBody, status, err := call(cmd.Context()) if err != nil { return err } return output.Format(cmd, respBody, status) }, }
View Source
var RegenerateSecretCmd = &cobra.Command{ Use: "regenerate-secret <mailbox-resource-id> <webhook>", Short: "Regenerate webhook secret", Long: "Regenerate the webhook secret. The previous secret is immediately invalidated. The new secret is returned once.", Example: " hostinger-mail webhooks regenerate-secret my-mailbox-resource-id 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d", ValidArgsFunction: cobra.NoFileCompletions, RunE: func(cmd *cobra.Command, args []string) error { args = utils.PromptedArgs(cmd, args) call := func(ctx context.Context) ([]byte, int, error) { r, err := api.Request().RegenerateWebhookSecretWithResponse(ctx, args[0], uuid.MustParse(args[1])) if err != nil { return nil, 0, err } return r.Body, r.StatusCode(), nil } respBody, status, err := call(cmd.Context()) if err != nil { return err } return output.Format(cmd, respBody, status) }, }
View Source
var TestCmd = &cobra.Command{ Use: "test <mailbox-resource-id> <webhook>", Short: "Test webhook", Long: "Send a test delivery to the webhook URL and return the upstream response.", Example: " hostinger-mail webhooks test my-mailbox-resource-id 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d", ValidArgsFunction: cobra.NoFileCompletions, RunE: func(cmd *cobra.Command, args []string) error { args = utils.PromptedArgs(cmd, args) call := func(ctx context.Context) ([]byte, int, error) { r, err := api.Request().TestWebhookWithResponse(ctx, args[0], uuid.MustParse(args[1])) if err != nil { return nil, 0, err } return r.Body, r.StatusCode(), nil } respBody, status, err := call(cmd.Context()) if err != nil { return err } return output.Format(cmd, respBody, status) }, }
View Source
var UpdateCmd = &cobra.Command{ Use: "update <mailbox-resource-id> <webhook>", Short: "Update webhook", Long: "Partially update a webhook.", Example: " hostinger-mail webhooks update my-mailbox-resource-id 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d", ValidArgsFunction: cobra.NoFileCompletions, RunE: func(cmd *cobra.Command, args []string) error { args = utils.PromptedArgs(cmd, args) if err := utils.EnumCheck(cmd, "status", []string{"active", "paused", "disabled"}); err != nil { return err } body, err := updateBody(cmd) if err != nil { return err } payload, err := json.Marshal(body) if err != nil { return err } call := func(ctx context.Context) ([]byte, int, error) { r, err := api.Request().UpdateWebhookWithBodyWithResponse(ctx, args[0], uuid.MustParse(args[1]), "application/json", bytes.NewReader(payload)) if err != nil { return nil, 0, err } return r.Body, r.StatusCode(), nil } respBody, status, err := call(cmd.Context()) if err != nil { return err } return output.Format(cmd, respBody, status) }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.