-
Notifications
You must be signed in to change notification settings - Fork 33
/
softlayer_product_order.go
102 lines (82 loc) · 3.41 KB
/
softlayer_product_order.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package services
import (
"bytes"
"encoding/json"
"fmt"
datatypes "github.com/maximilien/softlayer-go/data_types"
softlayer "github.com/maximilien/softlayer-go/softlayer"
)
type softLayer_Product_Order_Service struct {
client softlayer.Client
}
func NewSoftLayer_Product_Order_Service(client softlayer.Client) *softLayer_Product_Order_Service {
return &softLayer_Product_Order_Service{
client: client,
}
}
func (slpo *softLayer_Product_Order_Service) GetName() string {
return "SoftLayer_Product_Order"
}
func (slpo *softLayer_Product_Order_Service) PlaceOrder(order datatypes.SoftLayer_Container_Product_Order) (datatypes.SoftLayer_Container_Product_Order_Receipt, error) {
parameters := datatypes.SoftLayer_Container_Product_Order_Parameters{
Parameters: []datatypes.SoftLayer_Container_Product_Order{
order,
},
}
requestBody, err := json.Marshal(parameters)
if err != nil {
return datatypes.SoftLayer_Container_Product_Order_Receipt{}, err
}
responseBytes, err := slpo.client.DoRawHttpRequest(fmt.Sprintf("%s/placeOrder.json", slpo.GetName()), "POST", bytes.NewBuffer(requestBody))
if err != nil {
return datatypes.SoftLayer_Container_Product_Order_Receipt{}, err
}
receipt := datatypes.SoftLayer_Container_Product_Order_Receipt{}
err = json.Unmarshal(responseBytes, &receipt)
if err != nil {
return datatypes.SoftLayer_Container_Product_Order_Receipt{}, err
}
return receipt, nil
}
func (slpo *softLayer_Product_Order_Service) PlaceContainerOrderNetworkPerformanceStorageIscsi(order datatypes.SoftLayer_Container_Product_Order_Network_PerformanceStorage_Iscsi) (datatypes.SoftLayer_Container_Product_Order_Receipt, error) {
parameters := datatypes.SoftLayer_Container_Product_Order_Network_PerformanceStorage_Iscsi_Parameters{
Parameters: []datatypes.SoftLayer_Container_Product_Order_Network_PerformanceStorage_Iscsi{
order,
},
}
requestBody, err := json.Marshal(parameters)
if err != nil {
return datatypes.SoftLayer_Container_Product_Order_Receipt{}, err
}
responseBytes, err := slpo.client.DoRawHttpRequest(fmt.Sprintf("%s/placeOrder.json", slpo.GetName()), "POST", bytes.NewBuffer(requestBody))
if err != nil {
return datatypes.SoftLayer_Container_Product_Order_Receipt{}, err
}
receipt := datatypes.SoftLayer_Container_Product_Order_Receipt{}
err = json.Unmarshal(responseBytes, &receipt)
if err != nil {
return datatypes.SoftLayer_Container_Product_Order_Receipt{}, err
}
return receipt, nil
}
func (slpo *softLayer_Product_Order_Service) PlaceContainerOrderVirtualGuestUpgrade(order datatypes.SoftLayer_Container_Product_Order_Virtual_Guest_Upgrade) (datatypes.SoftLayer_Container_Product_Order_Receipt, error) {
parameters := datatypes.SoftLayer_Container_Product_Order_Virtual_Guest_Upgrade_Parameters{
Parameters: []datatypes.SoftLayer_Container_Product_Order_Virtual_Guest_Upgrade{
order,
},
}
requestBody, err := json.Marshal(parameters)
if err != nil {
return datatypes.SoftLayer_Container_Product_Order_Receipt{}, err
}
responseBytes, err := slpo.client.DoRawHttpRequest(fmt.Sprintf("%s/placeOrder.json", slpo.GetName()), "POST", bytes.NewBuffer(requestBody))
if err != nil {
return datatypes.SoftLayer_Container_Product_Order_Receipt{}, err
}
receipt := datatypes.SoftLayer_Container_Product_Order_Receipt{}
err = json.Unmarshal(responseBytes, &receipt)
if err != nil {
return datatypes.SoftLayer_Container_Product_Order_Receipt{}, err
}
return receipt, nil
}