Documentation
¶
Index ¶
- type Cmd
- type DeleteCmd
- type DescribeCmd
- type LabelCmds
- func (lc *LabelCmds) AddCobraCommand(ctx context.Context, client hcapi2.Client, tokenEnsurer state.TokenEnsurer) *cobra.Command
- func (lc *LabelCmds) RemoveCobraCommand(ctx context.Context, client hcapi2.Client, tokenEnsurer state.TokenEnsurer) *cobra.Command
- func (lc *LabelCmds) RunAdd(ctx context.Context, client hcapi2.Client, cmd *cobra.Command, args []string) error
- func (lc *LabelCmds) RunRemove(ctx context.Context, client hcapi2.Client, cmd *cobra.Command, args []string) error
- type ListCmd
- type SetRdnsCmd
- type UpdateCmd
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cmd ¶
type Cmd struct {
BaseCobraCommand func(hcapi2.Client) *cobra.Command
Run func(context.Context, hcapi2.Client, state.ActionWaiter, *cobra.Command, []string) error
}
Cmd allows defining commands for generic resource-based commands
func (*Cmd) CobraCommand ¶
func (gc *Cmd) CobraCommand( ctx context.Context, client hcapi2.Client, tokenEnsurer state.TokenEnsurer, actionWaiter state.ActionWaiter, ) *cobra.Command
CobraCommand creates a command that can be registered with cobra.
type DeleteCmd ¶ added in v1.25.0
type DeleteCmd struct {
ResourceNameSingular string // e.g. "server"
ShortDescription string
NameSuggestions func(client hcapi2.Client) func() []string
AdditionalFlags func(*cobra.Command)
Fetch func(ctx context.Context, client hcapi2.Client, cmd *cobra.Command, idOrName string) (interface{}, *hcloud.Response, error)
Delete func(ctx context.Context, client hcapi2.Client, cmd *cobra.Command, resource interface{}) error
}
DeleteCmd allows defining commands for deleting a resource.
type DescribeCmd ¶
type DescribeCmd struct {
ResourceNameSingular string // e.g. "server"
ShortDescription string
// key in API response JSON to use for extracting object from response body for JSON output.
JSONKeyGetByID string // e.g. "server"
JSONKeyGetByName string // e.g. "servers"
NameSuggestions func(client hcapi2.Client) func() []string
AdditionalFlags func(*cobra.Command)
Fetch func(ctx context.Context, client hcapi2.Client, cmd *cobra.Command, idOrName string) (interface{}, *hcloud.Response, error)
PrintText func(ctx context.Context, client hcapi2.Client, cmd *cobra.Command, resource interface{}) error
}
DescribeCmd allows defining commands for describing a resource.
func (*DescribeCmd) CobraCommand ¶
func (dc *DescribeCmd) CobraCommand( ctx context.Context, client hcapi2.Client, tokenEnsurer state.TokenEnsurer, ) *cobra.Command
CobraCommand creates a command that can be registered with cobra.
type LabelCmds ¶
type LabelCmds struct {
ResourceNameSingular string
ShortDescriptionAdd string
ShortDescriptionRemove string
NameSuggestions func(client hcapi2.Client) func() []string
LabelKeySuggestions func(client hcapi2.Client) func(idOrName string) []string
FetchLabels func(ctx context.Context, client hcapi2.Client, idOrName string) (map[string]string, int, error)
SetLabels func(ctx context.Context, client hcapi2.Client, id int, labels map[string]string) error
}
LabelCmds allows defining commands for adding labels to resources.
func (*LabelCmds) AddCobraCommand ¶
func (lc *LabelCmds) AddCobraCommand( ctx context.Context, client hcapi2.Client, tokenEnsurer state.TokenEnsurer, ) *cobra.Command
AddCobraCommand creates a command that can be registered with cobra.
func (*LabelCmds) RemoveCobraCommand ¶
func (lc *LabelCmds) RemoveCobraCommand( ctx context.Context, client hcapi2.Client, tokenEnsurer state.TokenEnsurer, ) *cobra.Command
RemoveCobraCommand creates a command that can be registered with cobra.
type ListCmd ¶
type ListCmd struct {
ResourceNamePlural string // e.g. "servers"
DefaultColumns []string
Fetch func(context.Context, hcapi2.Client, *cobra.Command, hcloud.ListOpts) ([]interface{}, error)
AdditionalFlags func(*cobra.Command)
OutputTable func(client hcapi2.Client) *output.Table
JSONSchema func([]interface{}) interface{}
}
ListCmd allows defining commands for listing resources
type SetRdnsCmd ¶ added in v1.28.1
type SetRdnsCmd struct {
ResourceNameSingular string // e.g. "server"
ShortDescription string
NameSuggestions func(client hcapi2.Client) func() []string
AdditionalFlags func(*cobra.Command)
Fetch func(ctx context.Context, client hcapi2.Client, cmd *cobra.Command, idOrName string) (interface{}, *hcloud.Response, error)
GetDefaultIP func(resource interface{}) net.IP
}
SetRdnsCmd allows defining commands for setting the RDNS of a resource.
func (*SetRdnsCmd) CobraCommand ¶ added in v1.28.1
func (rc *SetRdnsCmd) CobraCommand( ctx context.Context, client hcapi2.Client, tokenEnsurer state.TokenEnsurer, actionWaiter state.ActionWaiter, ) *cobra.Command
CobraCommand creates a command that can be registered with cobra.
type UpdateCmd ¶ added in v1.25.0
type UpdateCmd struct {
ResourceNameSingular string // e.g. "server"
ShortDescription string
NameSuggestions func(client hcapi2.Client) func() []string
DefineFlags func(*cobra.Command)
Fetch func(ctx context.Context, client hcapi2.Client, cmd *cobra.Command, idOrName string) (interface{}, *hcloud.Response, error)
Update func(ctx context.Context, client hcapi2.Client, cmd *cobra.Command, resource interface{}, flags map[string]pflag.Value) error
}
UpdateCmd allows defining commands for updating a resource.