cart

package
v0.0.0-...-e5adc05 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2017 License: BSD-3-Clause Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = &cobra.Command{
	Use:   "cart",
	Short: "Cart commands: ovhcli order cart --help",
	Long:  `Cart commands: ovhcli order cart <command>`,
}

Cmd domain

View Source
var CmdCartDeleteItem = &cobra.Command{
	Use:   "deleteItem <itemId>",
	Short: "Delete item's info of a cart: ovhcli order cart deleteItem <itemId>",
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) != 1 {
			common.WrongUsage(cmd)
		}
		itemID := args[0]
		i, err := strconv.ParseInt(itemID, 10, 64)
		if err != nil {
			fmt.Println(err)
			os.Exit(2)
		}
		client, err := ovh.NewDefaultClient()
		common.Check(err)

		item, err := client.OrderDeleteCartItem(cartID, i)
		common.Check(err)

		common.FormatOutputDef(item)
	},
}

CmdCartDeleteItem delete item of a cart

View Source
var CmdCartInfoItem = &cobra.Command{
	Use:   "item <itemId>",
	Short: "Get item's info of a cart: ovhcli order cart item <itemId>",
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) != 1 {
			common.WrongUsage(cmd)
		}
		itemID := args[0]
		i, err := strconv.ParseInt(itemID, 10, 64)
		if err != nil {
			fmt.Println(err)
			os.Exit(2)
		}
		client, err := ovh.NewDefaultClient()
		common.Check(err)
		item, err := client.OrderCartItemInfo(cartID, i)
		common.Check(err)

		common.FormatOutputDef(item)
	},
}

CmdCartInfoItem get item info of a cart

View Source
var CmdCartItemConfigurationAdd = &cobra.Command{
	Use:   "addConfig <itemId>",
	Short: "Add config on an item: ovhcli order cart addConfig <itemId>",
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) != 1 {
			common.WrongUsage(cmd)
		}
		itemID := args[0]
		i, err := strconv.ParseInt(itemID, 10, 64)
		if err != nil {
			fmt.Println(err)
			os.Exit(2)
		}
		client, err := ovh.NewDefaultClient()
		common.Check(err)

		item, err := client.OrderCartAddConfiguration(cartID, i, label, value)
		common.Check(err)

		common.FormatOutputDef(item)
	},
}

CmdCartItemConfigurationAdd add configuration on an item

View Source
var CmdCartItemConfigurationInfo = &cobra.Command{
	Use:   "config <itemId> <configId>",
	Short: "Get config's info of a cart: ovhcli order cart config <itemId> <configId>",
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) != 2 {
			common.WrongUsage(cmd)
		}
		itemID := args[0]
		i, err := strconv.ParseInt(itemID, 10, 64)
		common.Check(err)

		configID := args[1]
		c, err := strconv.ParseInt(configID, 10, 64)
		common.Check(err)

		client, err := ovh.NewDefaultClient()
		common.Check(err)
		config, err := client.OrderCartConfigurationInfo(cartID, i, c)
		common.Check(err)

		common.FormatOutputDef(config)
	},
}

CmdCartItemConfigurationInfo get configuration info for an item

View Source
var CmdCartItemConfigurationRemove = &cobra.Command{
	Use:   "removeConfig <itemId> <configId>",
	Short: "Delete item's info of a cart: ovhcli order cart removeConfig <itemId> <configId>",
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) != 2 {
			common.WrongUsage(cmd)
		}
		itemID := args[0]
		i, err := strconv.ParseInt(itemID, 10, 64)
		common.Check(err)

		configID := args[1]
		c, err := strconv.ParseInt(configID, 10, 64)
		common.Check(err)

		client, err := ovh.NewDefaultClient()
		common.Check(err)

		config, err := client.OrderCartDeleteConfiguration(cartID, i, c)
		common.Check(err)

		common.FormatOutputDef(config)
	},
}

CmdCartItemConfigurationRemove remove config on an item

View Source
var CmdCartItemConfigurationsList = &cobra.Command{
	Use:   "listConfigs",
	Short: "List all configs of an item: ovhcli order cart listConfigs <itemId>",
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) != 1 {
			common.WrongUsage(cmd)
		}
		client, errc := ovh.NewDefaultClient()
		common.Check(errc)

		itemID := args[0]
		i, err := strconv.ParseInt(itemID, 10, 64)
		common.Check(err)

		configs, err := client.OrderCartConfigurationsList(cartID, i)
		common.Check(err)

		if configWithDetails {
			configs = getDetailledConfigurationsList(client, i, configs)
		}

		common.FormatOutputDef(configs)
	},
}

CmdCartItemConfigurationsList list all configurations for an item

View Source
var CmdCartItemRequiredConfigurations = &cobra.Command{
	Use:   "listRequiredConfigs <itemId>",
	Short: "List all required configurations for an item: ovhcli order cart listRequiredConfigs <itemId>",
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) != 1 {
			common.WrongUsage(cmd)
		}
		client, err := ovh.NewDefaultClient()

		common.Check(err)
		itemID := args[0]
		i, err := strconv.ParseInt(itemID, 10, 64)
		common.Check(err)

		configs, err := client.OrderCartRequiredConfigurations(cartID, i)
		common.Check(err)

		common.FormatOutputDef(configs)
	},
}

CmdCartItemRequiredConfigurations list all configurations for an item

View Source
var CmdCartListItems = &cobra.Command{
	Use:   "listItems",
	Short: "List all items of a cart: ovhcli order cart list",
	Run: func(cmd *cobra.Command, args []string) {
		client, err := ovh.NewDefaultClient()
		common.Check(err)

		items, err := client.OrderCartItemList(cartID)
		common.Check(err)

		if itemsWithDetails {
			items = getDetailledItemList(client, items)
		}

		common.FormatOutputDef(items)
	},
}

CmdCartListItems list all item of a cart

View Source
var CmdCartUpdateItem = &cobra.Command{
	Use:   "updateItem <itemId>",
	Short: "Update item's info of a cart: ovhcli order cart updateItem <itemId>",
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) != 1 {
			common.WrongUsage(cmd)
		}
		itemID := args[0]
		i, err := strconv.ParseInt(itemID, 10, 64)
		if err != nil {
			fmt.Println(err)
			os.Exit(2)
		}
		client, err := ovh.NewDefaultClient()
		common.Check(err)

		item, err := client.OrderUpdateCartItem(cartID, i, duration, quantity)
		common.Check(err)

		common.FormatOutputDef(item)
	},
}

CmdCartUpdateItem update item of a cart

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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