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(ctx context.Context, client hcapi2.Client, cmd *cobra.Command, idOrName string) (interface{}, *hcloud.Response, error) { return client.Location().Get(ctx, idOrName) }, PrintText: func(ctx context.Context, client hcapi2.Client, cmd *cobra.Command, resource interface{}) error { location := resource.(*hcloud.Location) fmt.Printf("ID:\t\t%d\n", location.ID) fmt.Printf("Name:\t\t%s\n", location.Name) fmt.Printf("Description:\t%s\n", location.Description) fmt.Printf("Network Zone:\t%s\n", location.NetworkZone) fmt.Printf("Country:\t%s\n", location.Country) fmt.Printf("City:\t\t%s\n", location.City) fmt.Printf("Latitude:\t%f\n", location.Latitude) fmt.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(ctx context.Context, client hcapi2.Client, _ *pflag.FlagSet, listOpts hcloud.ListOpts, sorts []string) ([]interface{}, error) { opts := hcloud.LocationListOpts{ListOpts: listOpts} if len(sorts) > 0 { opts.Sort = sorts } locations, _, err := client.Location().List(ctx, 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{}) }, JSONSchema: func(resources []interface{}) interface{} { locationSchemas := make([]schema.Location, 0, len(resources)) for _, resource := range resources { location := resource.(*hcloud.Location) locationSchemas = append(locationSchemas, util.LocationToSchema(*location)) } return locationSchemas }, }
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.