Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var CreateCmd = &cobra.Command{ Use: "create <mailbox-resource-id>", Short: "Create calendar", Long: "Create a calendar owned by the mailbox. The number of calendars a mailbox can own is limited; when the limit is reached the request fails with `400` and code `ERR_CALENDAR_LIMIT_REACHED`.", Example: " hostinger-mail calendars create my-mailbox-resource-id --displayname Work", 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().CreateCalendarWithBodyWithResponse(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> <calendar-uuid>", Short: "Delete calendar", Long: "Delete a calendar owned by the mailbox together with all its events, or remove a calendar shared with the mailbox from its list. This cannot be undone. A calendar that cannot be deleted is rejected with `403` and code `ERR_CALENDAR_NOT_DELETABLE`.", Example: " hostinger-mail calendars delete my-mailbox-resource-id 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d", ValidArgsFunction: utils.CompleteArgs( nil, &utils.ArgSource{ Value: "uuid", Fetch: func(ctx context.Context, args []string) ([]byte, int, error) { r, err := api.CompletionRequest().ListCalendarsWithResponse(ctx, args[0], nil) if err != nil { return nil, 0, err } return r.Body, r.StatusCode(), nil }, }, ), RunE: func(cmd *cobra.Command, args []string) error { args = utils.PromptedArgs(cmd, args) if err := utils.Confirm(cmd, "Delete calendar", args); err != nil { return err } call := func(ctx context.Context) ([]byte, int, error) { r, err := api.Request().DeleteCalendarWithResponse(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> <calendar-uuid>", Short: "Get calendar", Long: "Retrieve one calendar of a mailbox: its name, description, color, whether it is the default calendar and whether it is shown in the calendar view. It does not return events; use `listCalendarEvents` for those.", Example: " hostinger-mail calendars get my-mailbox-resource-id 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d", ValidArgsFunction: utils.CompleteArgs( nil, &utils.ArgSource{ Value: "uuid", Fetch: func(ctx context.Context, args []string) ([]byte, int, error) { r, err := api.CompletionRequest().ListCalendarsWithResponse(ctx, args[0], nil) if err != nil { return nil, 0, err } return r.Body, r.StatusCode(), nil }, }, ), 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().GetCalendarWithResponse(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: "calendars", Short: "Calendars commands", Args: cobra.ArbitraryArgs, RunE: utils.GroupRunE, }
View Source
var ListCmd = &cobra.Command{ Use: "list <mailbox-resource-id>", Short: "List calendars", Long: "List the calendars of a mailbox: its own calendars and the calendars shared with it, in display order. Call it first to get the `calendarUuid` every calendar event operation needs: the `uuid` of each calendar. The calendar with `default` true is where new events go unless another one is named. `visible` false means the calendar is hidden in the calendar view; its events still exist.", Example: " hostinger-mail calendars 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().ListCalendarsWithResponse(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> <calendar-uuid>", Short: "Update calendar", Long: "Update the name, description, color and visibility of a calendar. Name, description and color replace the stored values: an omitted `description` is cleared and an omitted `color` resets to the default color. An omitted `visible` keeps the current value.", Example: " hostinger-mail calendars update my-mailbox-resource-id 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d --displayname Work", ValidArgsFunction: utils.CompleteArgs( nil, &utils.ArgSource{ Value: "uuid", Fetch: func(ctx context.Context, args []string) ([]byte, int, error) { r, err := api.CompletionRequest().ListCalendarsWithResponse(ctx, args[0], nil) if err != nil { return nil, 0, err } return r.Body, r.StatusCode(), nil }, }, ), 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().UpdateCalendarWithBodyWithResponse(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.