location

package
v1.56.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DescribeCmd = base.DescribeCmd[*hcloud.Location]{
	ResourceNameSingular: "Location",
	ShortDescription:     "Describe a Location",
	NameSuggestions:      func(c hcapi2.Client) func() []string { return c.Location().Names },
	Fetch: func(s state.State, _ *cobra.Command, idOrName string) (*hcloud.Location, any, error) {
		l, _, err := s.Client().Location().Get(s, idOrName)
		if err != nil {
			return nil, nil, err
		}
		return l, hcloud.SchemaFromLocation(l), nil
	},
	PrintText: func(_ state.State, _ *cobra.Command, out io.Writer, location *hcloud.Location) error {
		fmt.Fprint(out, DescribeLocation(location))
		return nil
	},
}

DescribeCmd defines a command for describing a location.

View Source
var ListCmd = base.ListCmd[*hcloud.Location, schema.Location]{
	ResourceNamePlural: "Locations",
	JSONKeyGetByName:   "locations",
	DefaultColumns:     []string{"id", "name", "description", "network_zone", "country", "city"},
	SortOption:         config.OptionSortLocation,

	Fetch: func(s state.State, _ *pflag.FlagSet, listOpts hcloud.ListOpts, sorts []string) ([]*hcloud.Location, error) {
		opts := hcloud.LocationListOpts{ListOpts: listOpts}
		if len(sorts) > 0 {
			opts.Sort = sorts
		}
		return s.Client().Location().AllWithOpts(s, opts)
	},

	OutputTable: func(t *output.Table[*hcloud.Location], _ hcapi2.Client) {
		t.
			AddAllowedFields(&hcloud.Location{})
	},

	Schema: hcloud.SchemaFromLocation,
}

Functions

func DescribeLocation added in v1.56.0

func DescribeLocation(location *hcloud.Location) string

func NewCommand

func NewCommand(s state.State) *cobra.Command

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL