storageboxtype

package
v1.55.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DescribeCmd = base.DescribeCmd[*hcloud.StorageBoxType]{
	ResourceNameSingular: "Storage Box Type",
	ShortDescription:     "Describe a Storage Box Type",
	NameSuggestions:      func(c hcapi2.Client) func() []string { return c.StorageBoxType().Names },
	Fetch: func(s state.State, _ *cobra.Command, idOrName string) (*hcloud.StorageBoxType, any, error) {
		st, _, err := s.Client().StorageBoxType().Get(s, idOrName)
		if err != nil {
			return nil, nil, err
		}
		return st, hcloud.SchemaFromStorageBoxType(st), nil
	},
	PrintText: func(s state.State, cmd *cobra.Command, storageBoxType *hcloud.StorageBoxType) error {
		cmd.Printf("ID:\t\t\t\t%d\n", storageBoxType.ID)
		cmd.Printf("Name:\t\t\t\t%s\n", storageBoxType.Name)
		cmd.Printf("Description:\t\t\t%s\n", storageBoxType.Description)
		cmd.Printf("Size:\t\t\t\t%s\n", humanize.IBytes(uint64(storageBoxType.Size)))
		if storageBoxType.SnapshotLimit != nil {
			cmd.Printf("Snapshot Limit:\t\t\t%d\n", *storageBoxType.SnapshotLimit)
		}
		if storageBoxType.AutomaticSnapshotLimit != nil {
			cmd.Printf("Automatic Snapshot Limit:\t%d\n", *storageBoxType.AutomaticSnapshotLimit)
		}
		cmd.Printf("Subaccounts Limit:\t\t%d\n", storageBoxType.SubaccountsLimit)
		cmd.Print(util.DescribeDeprecation(storageBoxType))

		err := loadCurrencyFromAPI(s, storageBoxType)
		if err != nil {
			cmd.PrintErrf("failed to get currency for Storage Box Type prices: %v", err)
		}

		cmd.Printf("Pricings per Location:\n")
		for _, price := range storageBoxType.Pricings {
			cmd.Printf("  - Location:\t%s\n", price.Location)
			cmd.Printf("    Hourly:\t%s\n", util.GrossPrice(price.PriceHourly))
			cmd.Printf("    Monthly:\t%s\n", util.GrossPrice(price.PriceMonthly))
			cmd.Printf("    Setup Fee:\t%s\n", util.GrossPrice(price.SetupFee))
			cmd.Printf("\n")
		}

		return nil
	},
	Experimental: experimental.StorageBoxes,
}
View Source
var ListCmd = base.ListCmd[*hcloud.StorageBoxType, schema.StorageBoxType]{
	ResourceNamePlural: "Storage Box Types",
	JSONKeyGetByName:   "storage_box_types",
	DefaultColumns:     []string{"id", "name", "description", "size", "snapshot_limit", "automatic_snapshot_limit", "subaccounts_limit"},
	SortOption:         nil,

	Fetch: func(s state.State, _ *pflag.FlagSet, listOpts hcloud.ListOpts, _ []string) ([]*hcloud.StorageBoxType, error) {
		opts := hcloud.StorageBoxTypeListOpts{ListOpts: listOpts}
		return s.Client().StorageBoxType().AllWithOpts(s, opts)
	},

	OutputTable: func(t *output.Table, _ hcapi2.Client) {
		t.
			AddAllowedFields(hcloud.StorageBoxType{}).
			AddFieldFn("size", func(obj interface{}) string {
				storageBoxType := obj.(*hcloud.StorageBoxType)
				return humanize.IBytes(uint64(storageBoxType.Size))
			}).
			AddFieldFn("deprecated", func(obj interface{}) string {
				storageBoxType := obj.(*hcloud.StorageBoxType)
				if !storageBoxType.IsDeprecated() {
					return "-"
				}
				return util.Datetime(storageBoxType.UnavailableAfter())
			}).
			AddFieldFn("snapshot_limit", func(obj interface{}) string {
				storageBoxType := obj.(*hcloud.StorageBoxType)
				if storageBoxType.SnapshotLimit == nil {
					return "-"
				}
				return strconv.Itoa(*storageBoxType.SnapshotLimit)
			}).
			AddFieldFn("automatic_snapshot_limit", func(obj interface{}) string {
				storageBoxType := obj.(*hcloud.StorageBoxType)
				if storageBoxType.AutomaticSnapshotLimit == nil {
					return "-"
				}
				return strconv.Itoa(*storageBoxType.AutomaticSnapshotLimit)
			})
	},

	Schema:       hcloud.SchemaFromStorageBoxType,
	Experimental: experimental.StorageBoxes,
}

Functions

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