Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var CreateCmd = &cobra.Command{ Use: "create <mailbox-resource-id>", Short: "Create folder", Long: "Create a new folder in the managed mailbox.", Example: " hostinger-mail folders create my-mailbox-resource-id --name Projects", ValidArgsFunction: cobra.NoFileCompletions, RunE: func(cmd *cobra.Command, args []string) error { args = utils.PromptedArgs(cmd, args) 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().CreateFolderWithBodyWithResponse(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> <folder>", Short: "Delete folder", Long: "Delete a folder and all of its subfolders.", Example: " hostinger-mail folders delete 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 folder", args); err != nil { return err } call := func(ctx context.Context) ([]byte, int, error) { r, err := api.Request().DeleteFolderWithResponse(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 GroupCmd = &cobra.Command{ Use: "folders", Short: "Folders commands", Args: cobra.ArbitraryArgs, RunE: utils.GroupRunE, }
View Source
var ListCmd = &cobra.Command{ Use: "list <mailbox-resource-id>", Short: "List folders", Long: "Retrieve a paginated list of folders in the managed mailbox.", Example: " hostinger-mail folders list my-mailbox-resource-id", 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().ListFoldersWithResponse(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 UpdateCmd = &cobra.Command{ Use: "update <mailbox-resource-id> <folder>", Short: "Update folder", Long: "Rename an existing folder.", Example: " hostinger-mail folders update my-mailbox-resource-id my-folder --name Archive", ValidArgsFunction: cobra.NoFileCompletions, RunE: func(cmd *cobra.Command, args []string) error { args = utils.PromptedArgs(cmd, args) 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().UpdateFolderWithBodyWithResponse(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.