Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DescribeCmd = base.DescribeCmd{ ResourceNameSingular: "serverType", ShortDescription: "Describe a server type", JSONKeyGetByID: "server_type", JSONKeyGetByName: "server_types", NameSuggestions: func(c hcapi2.Client) func() []string { return c.ServerType().Names }, Fetch: func(s state.State, _ *cobra.Command, idOrName string) (interface{}, interface{}, error) { st, _, err := s.Client().ServerType().Get(s, idOrName) if err != nil { return nil, nil, err } return st, hcloud.SchemaFromServerType(st), nil }, PrintText: func(s state.State, cmd *cobra.Command, resource interface{}) error { serverType := resource.(*hcloud.ServerType) cmd.Printf("ID:\t\t\t%d\n", serverType.ID) cmd.Printf("Name:\t\t\t%s\n", serverType.Name) cmd.Printf("Description:\t\t%s\n", serverType.Description) cmd.Printf("Cores:\t\t\t%d\n", serverType.Cores) cmd.Printf("CPU Type:\t\t%s\n", serverType.CPUType) cmd.Printf("Architecture:\t\t%s\n", serverType.Architecture) cmd.Printf("Memory:\t\t\t%.1f GB\n", serverType.Memory) cmd.Printf("Disk:\t\t\t%d GB\n", serverType.Disk) cmd.Printf("Storage Type:\t\t%s\n", serverType.StorageType) cmd.Print(util.DescribeDeprecation(serverType)) pricings, err := fullPricingInfo(s, serverType) if err != nil { cmd.PrintErrf("failed to get prices for server type: %v", err) } if pricings != nil { cmd.Printf("Pricings per Location:\n") for _, price := range pricings { cmd.Printf(" - Location:\t\t%s\n", price.Location.Name) cmd.Printf(" Hourly:\t\t%s\n", util.GrossPrice(price.Hourly)) cmd.Printf(" Monthly:\t\t%s\n", util.GrossPrice(price.Monthly)) cmd.Printf(" Included Traffic:\t%s\n", humanize.IBytes(price.IncludedTraffic)) cmd.Printf(" Additional Traffic:\t%s per TB\n", util.GrossPrice(price.PerTBTraffic)) cmd.Printf("\n") } } return nil }, }
View Source
var ListCmd = base.ListCmd{ ResourceNamePlural: "Server Types", JSONKeyGetByName: "server_types", DefaultColumns: []string{"id", "name", "cores", "cpu_type", "architecture", "memory", "disk", "storage_type"}, SortOption: nil, Fetch: func(s state.State, _ *pflag.FlagSet, listOpts hcloud.ListOpts, sorts []string) ([]interface{}, error) { opts := hcloud.ServerTypeListOpts{ListOpts: listOpts} if len(sorts) > 0 { opts.Sort = sorts } servers, err := s.Client().ServerType().AllWithOpts(s, opts) var resources []interface{} for _, r := range servers { resources = append(resources, r) } return resources, err }, OutputTable: func(t *output.Table, _ hcapi2.Client) { t. AddAllowedFields(hcloud.ServerType{}). AddFieldAlias("storagetype", "storage type"). AddFieldFn("memory", output.FieldFn(func(obj interface{}) string { serverType := obj.(*hcloud.ServerType) return fmt.Sprintf("%.1f GB", serverType.Memory) })). AddFieldFn("disk", output.FieldFn(func(obj interface{}) string { serverType := obj.(*hcloud.ServerType) return fmt.Sprintf("%d GB", serverType.Disk) })). AddFieldFn("traffic", func(interface{}) string { return "-" }). AddFieldFn("deprecated", func(obj interface{}) string { serverType := obj.(*hcloud.ServerType) if !serverType.IsDeprecated() { return "-" } return util.Datetime(serverType.UnavailableAfter()) }) }, Schema: func(resources []interface{}) interface{} { serverTypeSchemas := make([]schema.ServerType, 0, len(resources)) for _, resource := range resources { serverType := resource.(*hcloud.ServerType) serverTypeSchemas = append(serverTypeSchemas, hcloud.SchemaFromServerType(serverType)) } return serverTypeSchemas }, }
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.