Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var AttachmentCmd = &cobra.Command{ Use: "attachment <mailbox-resource-id> <folder> <uid> <attachment-id>", Short: "Download message attachment", Long: "Download a message attachment as `application/octet-stream`.", Example: " hostinger-mail messages attachment my-mailbox-resource-id my-folder 1234567 my-attachment-id", 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().GetMessageAttachmentWithResponse(ctx, args[0], args[1], utils.StringToInt(args[2]), args[3]) 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 DeleteAllCmd = &cobra.Command{ Use: "delete-all <mailbox-resource-id> <folder>", Short: "Delete all messages", Long: "Permanently delete every message in a folder (empty the folder).", Example: " hostinger-mail messages delete-all my-mailbox-resource-id my-folder", ValidArgsFunction: cobra.NoFileCompletions, RunE: func(cmd *cobra.Command, args []string) error { args = utils.PromptedArgs(cmd, args) if err := utils.Confirm(cmd, "Delete all messages", args); err != nil { return err } call := func(ctx context.Context) ([]byte, int, error) { r, err := api.Request().DeleteAllMessagesWithResponse(ctx, args[0], 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 DeleteBulkCmd = &cobra.Command{ Use: "delete-bulk <mailbox-resource-id> <folder>", Short: "Delete messages", Long: "Permanently delete multiple messages from a folder.", Example: " hostinger-mail messages delete-bulk my-mailbox-resource-id my-folder --uids 42,43,44", ValidArgsFunction: cobra.NoFileCompletions, RunE: func(cmd *cobra.Command, args []string) error { args = utils.PromptedArgs(cmd, args) body, err := deleteBulkBody(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().DeleteMessagesWithBodyWithResponse(ctx, args[0], 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) }, }
View Source
var DeleteCmd = &cobra.Command{ Use: "delete <mailbox-resource-id> <folder> <uid>", Short: "Delete message", Long: "Permanently delete a single message.", Example: " hostinger-mail messages delete my-mailbox-resource-id my-folder 1234567", ValidArgsFunction: cobra.NoFileCompletions, RunE: func(cmd *cobra.Command, args []string) error { args = utils.PromptedArgs(cmd, args) if err := utils.Confirm(cmd, "Delete message", args); err != nil { return err } call := func(ctx context.Context) ([]byte, int, error) { r, err := api.Request().DeleteMessageWithResponse(ctx, args[0], args[1], utils.StringToInt(args[2])) 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> <folder> <uid>", Short: "Get message", Long: "Retrieve a single message by UID.", Example: " hostinger-mail messages get my-mailbox-resource-id my-folder 1234567", 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().GetMessageWithResponse(ctx, args[0], args[1], utils.StringToInt(args[2])) 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: "messages", Short: "Messages commands", Args: cobra.ArbitraryArgs, RunE: utils.GroupRunE, }
View Source
var ListCmd = &cobra.Command{ Use: "list <mailbox-resource-id> <folder>", Short: "List messages", Long: "List messages in a folder. Use POST /search for filtering. Sort fields: uid, date, size (prefix with `-` for descending). Default `-uid`.", Example: " hostinger-mail messages list my-mailbox-resource-id my-folder", ValidArgsFunction: cobra.NoFileCompletions, RunE: func(cmd *cobra.Command, args []string) error { args = utils.PromptedArgs(cmd, args) params := listParams(cmd) call := func(ctx context.Context) ([]byte, int, error) { r, err := api.Request().ListMessagesWithResponse(ctx, args[0], args[1], 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 MoveBulkCmd = &cobra.Command{ Use: "move-bulk <mailbox-resource-id> <folder>", Short: "Move messages", Long: "Move multiple messages from a source folder to a target folder.", Example: " hostinger-mail messages move-bulk my-mailbox-resource-id my-folder --targetfolder INBOX.Sent --uids 42,43,44", ValidArgsFunction: cobra.NoFileCompletions, RunE: func(cmd *cobra.Command, args []string) error { args = utils.PromptedArgs(cmd, args) body, err := moveBulkBody(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().MoveMessagesWithBodyWithResponse(ctx, args[0], 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) }, }
View Source
var MoveCmd = &cobra.Command{ Use: "move <mailbox-resource-id> <folder> <uid>", Short: "Move message", Long: "Move a single message to a target folder.", Example: " hostinger-mail messages move my-mailbox-resource-id my-folder 1234567 --targetfolder INBOX.Sent", ValidArgsFunction: cobra.NoFileCompletions, RunE: func(cmd *cobra.Command, args []string) error { args = utils.PromptedArgs(cmd, args) body, err := moveBody(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().MoveMessageWithBodyWithResponse(ctx, args[0], args[1], utils.StringToInt(args[2]), "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 PatchCmd = &cobra.Command{ Use: "patch <mailbox-resource-id> <folder> <uid>", Short: "Update message flags", Long: "Add and/or remove flags on a single message. Returns the updated message.", Example: " hostinger-mail messages patch my-mailbox-resource-id my-folder 1234567", ValidArgsFunction: cobra.NoFileCompletions, RunE: func(cmd *cobra.Command, args []string) error { args = utils.PromptedArgs(cmd, args) body, err := patchBody(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().PatchMessageWithBodyWithResponse(ctx, args[0], args[1], utils.StringToInt(args[2]), "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 SearchCmd = &cobra.Command{ Use: "search <mailbox-resource-id> <folder>", Short: "Search messages", Long: "Search messages in a folder. Filters in body; pagination and sort via query (`page`, `perPage`, `sort`).", Example: " hostinger-mail messages search my-mailbox-resource-id my-folder", ValidArgsFunction: cobra.NoFileCompletions, RunE: func(cmd *cobra.Command, args []string) error { args = utils.PromptedArgs(cmd, args) params := searchParams(cmd) body, err := searchBody(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().SearchMessagesWithBodyWithResponse(ctx, args[0], args[1], params, "application/json", bytes.NewReader(payload)) 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 SourceCmd = &cobra.Command{ Use: "source <mailbox-resource-id> <folder> <uid>", Short: "Get message source", Long: "Retrieve raw RFC822 source of a message as `message/rfc822` attachment.", Example: " hostinger-mail messages source my-mailbox-resource-id my-folder 1234567", 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().GetMessageSourceWithResponse(ctx, args[0], args[1], utils.StringToInt(args[2])) 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 TextCmd = &cobra.Command{ Use: "text <mailbox-resource-id> <folder> <uid>", Short: "Get message text content", Long: "Retrieve rendered text (plain + HTML) of a message. Marks message as `\\Seen`.", Example: " hostinger-mail messages text my-mailbox-resource-id my-folder 1234567", 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().GetMessageTextWithResponse(ctx, args[0], args[1], utils.StringToInt(args[2])) 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 UpdateFlagsCmd = &cobra.Command{ Use: "update-flags <mailbox-resource-id> <folder>", Short: "Update flags on multiple messages", Long: "Add and/or remove flags on multiple messages. Returns 200 when all UIDs succeed, 207 with per-UID outcome when some fail.", Example: " hostinger-mail messages update-flags my-mailbox-resource-id my-folder --uids 42,43,44", ValidArgsFunction: cobra.NoFileCompletions, RunE: func(cmd *cobra.Command, args []string) error { args = utils.PromptedArgs(cmd, args) body, err := updateFlagsBody(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().UpdateMessageFlagsWithBodyWithResponse(ctx, args[0], 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.