Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DescribeCmd = base.DescribeCmd{ ResourceNameSingular: "location", ShortDescription: "Describe a location", JSONKeyGetByID: "location", JSONKeyGetByName: "locations", NameSuggestions: func(c hcapi2.Client) func() []string { return c.Location().Names }, Fetch: func(s state.State, cmd *cobra.Command, idOrName string) (interface{}, interface{}, error) { l, _, err := s.Client().Location().Get(s, idOrName) if err != nil { return nil, nil, err } return l, hcloud.SchemaFromLocation(l), nil }, PrintText: func(s state.State, cmd *cobra.Command, resource interface{}) error { location := resource.(*hcloud.Location) cmd.Printf("ID:\t\t%d\n", location.ID) cmd.Printf("Name:\t\t%s\n", location.Name) cmd.Printf("Description:\t%s\n", location.Description) cmd.Printf("Network Zone:\t%s\n", location.NetworkZone) cmd.Printf("Country:\t%s\n", location.Country) cmd.Printf("City:\t\t%s\n", location.City) cmd.Printf("Latitude:\t%f\n", location.Latitude) cmd.Printf("Longitude:\t%f\n", location.Longitude) return nil }, }
DescribeCmd defines a command for describing a location.
View Source
var ListCmd = base.ListCmd{ ResourceNamePlural: "locations", JSONKeyGetByName: "locations", DefaultColumns: []string{"id", "name", "description", "network_zone", "country", "city"}, Fetch: func(s state.State, _ *pflag.FlagSet, listOpts hcloud.ListOpts, sorts []string) ([]interface{}, error) { opts := hcloud.LocationListOpts{ListOpts: listOpts} if len(sorts) > 0 { opts.Sort = sorts } locations, err := s.Client().Location().AllWithOpts(s, opts) var resources []interface{} for _, n := range locations { resources = append(resources, n) } return resources, err }, OutputTable: func(_ hcapi2.Client) *output.Table { return output.NewTable(). AddAllowedFields(hcloud.Location{}) }, Schema: func(resources []interface{}) interface{} { locationSchemas := make([]schema.Location, 0, len(resources)) for _, resource := range resources { location := resource.(*hcloud.Location) locationSchemas = append(locationSchemas, hcloud.SchemaFromLocation(location)) } return locationSchemas }, }
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.