嗯,我沒有想法你的代碼,但我能夠做出verifyOrder工作訂購耐力卷
package main
import (
"fmt"
//"log"
"github.com/softlayer/softlayer-go/datatypes"
"github.com/softlayer/softlayer-go/services"
"github.com/softlayer/softlayer-go/session"
"github.com/softlayer/softlayer-go/sl"
)
func main() {
sess := session.New() // See above for details about creating a new session
// Get the Virtual_Guest service
service := services.GetProductOrderService(sess)
// Create a Virtual_Guest struct as a template
vOrderTemplate := datatypes.Container_Product_Order_Network_Storage_Enterprise{}
vOrderTemplate.Location = sl.String("154820")
vOrderTemplate.Quantity = sl.Int(1)
vOrderTemplate.PackageId = sl.Int(240)
price1 := datatypes.Product_Item_Price{}
price1.Id = sl.Int(45058)
price2 := datatypes.Product_Item_Price{}
price2.Id = sl.Int(45098)
price3 := datatypes.Product_Item_Price{}
price3.Id = sl.Int(45068)
price4 := datatypes.Product_Item_Price{}
price4.Id = sl.Int(45118)
price5 := datatypes.Product_Item_Price{}
price5.Id = sl.Int(46120)
prices := []datatypes.Product_Item_Price{price1,price2,price3,price4,price5}
vOrderTemplate.Prices = prices
vOrderTemplate.OsFormatType = &datatypes.Network_Storage_Iscsi_OS_Type{
Id: sl.Int(12),
KeyName: sl.String("LINUX"),
}
vOrd, err := service.VerifyOrder(&vOrderTemplate)
if err != nil {
fmt.Printf("%s\n", err)
return
} else {
fmt.Printf("\norder verified with Total Recurring Tax %d\n", *vOrd.TotalRecurringTax)
}
}
我是新與GO,很抱歉,如果代碼是不是很簡單:P ,此外,我不知道如何打印響應的所有屬性所以我只印一個property.As你可能在GO的專家,我相信你可以提高代碼。
請注意確保您在訂單中使用了正確的價格。
我在Go代碼基本上是喜歡這樣一個RESTful調用相同:
{
"parameters": [
{
"location": 154820, //Dallas 06
"packageId": 240,
"osFormatType": {
"id": 12,
"keyName": "LINUX"
},
"complexType": "SoftLayer_Container_Product_Order_Network_Storage_Enterprise",
"prices": [
{
"id": 45058 # Endurance Storage
},
{
"id": 45098 # Block Storage
},
{
"id": 45068 # 0.25 IOPS per GB
},
{
"id": 45118 # 20 GB Storage Space
},
{
"id": 46120 # 5 GB Storage Space - Snapshot
}
],
"quantity": 1
}
]
}
問候
安置自己的GO代碼,它是IMPOSIBLE幫你沒有代碼。目前看到調試日誌,看起來你只是發送錯誤的「ComplexType」屬性,即使你使用RESTFul調用,你也會得到相同的錯誤。 –