@@ -21,6 +21,7 @@ type OrdersCommand struct {
2121 AccountManager managers.AccountManager
2222 Command * cobra.Command
2323 Limit int
24+ Upgrades bool
2425}
2526
2627func NewOrdersCommand (sl * metadata.SoftlayerCommand ) * OrdersCommand {
@@ -37,6 +38,7 @@ func NewOrdersCommand(sl *metadata.SoftlayerCommand) *OrdersCommand {
3738 },
3839 }
3940 cobraCmd .Flags ().IntVar (& thisCmd .Limit , "limit" , 100 , T ("How many results to get in one api call." ))
41+ cobraCmd .Flags ().BoolVar (& thisCmd .Upgrades , "upgrades" , false , T ("Show upgrades orders." ))
4042 thisCmd .Command = cobraCmd
4143 return thisCmd
4244}
@@ -51,6 +53,15 @@ func (cmd *OrdersCommand) Run(args []string) error {
5153 }
5254 PrintOrders (orders , cmd .UI , outputFormat )
5355
56+ if cmd .Upgrades {
57+ mask = "mask[id,maintenanceStartTimeUtc,statusId,createDate,ticketId]"
58+ upgrades , err := cmd .AccountManager .GetUpgradeRequests (mask , cmd .Limit )
59+ if err != nil {
60+ return errors .NewAPIError (T ("Failed to get Upgrade Requests." ), err .Error (), 2 )
61+ }
62+ PrintUpgrades (upgrades , cmd .UI , outputFormat )
63+ }
64+
5465 return nil
5566}
5667
@@ -84,3 +95,26 @@ func PrintOrders(orders []datatypes.Billing_Order, ui terminal.UI, outputFormat
8495
8596 utils .PrintTableWithTitle (ui , table , bufEvent , "Orders" , outputFormat )
8697}
98+
99+ func PrintUpgrades (upgrades []datatypes.Product_Upgrade_Request , ui terminal.UI , outputFormat string ) {
100+ bufEvent := new (bytes.Buffer )
101+ table := terminal .NewTable (bufEvent , []string {
102+ T ("Id" ),
103+ T ("Maintance Window" ),
104+ T ("Status" ),
105+ T ("Created Date" ),
106+ T ("Case" ),
107+ })
108+
109+ for _ , upgrade := range upgrades {
110+ table .Add (
111+ utils .FormatIntPointer (upgrade .Id ),
112+ utils .FormatSLTimePointer (upgrade .MaintenanceStartTimeUtc ),
113+ utils .FormatIntPointer (upgrade .StatusId ),
114+ utils .FormatSLTimePointer (upgrade .CreateDate ),
115+ utils .FormatIntPointer (upgrade .TicketId ),
116+ )
117+ }
118+
119+ utils .PrintTableWithTitle (ui , table , bufEvent , "Upgrade orders" , outputFormat )
120+ }
0 commit comments