API 範例:公用虛擬伺服器設定檔
以下資訊顯示了用於配置使用預設設定檔的公用虛擬伺服器的 Rest API 範例。
如需更健全的 API 範例,請參閱下列資源:
佈建具有建立物件的公用虛擬伺服器
這 SoftLayer_Virtual_Guest/createObject API 服務是設定使用預設設定檔的公用虛擬伺服器的最簡單方法。
不適用於暫時性虛擬伺服器。
若要使用 REST 設定公用虛擬伺服器,需要將 POST 請求提交到https://softlayer.github.io/reference/services/SoftLayer_Virtual_Guest/createObject/請求正文中包含以下 JSON。
下列 JSON 要求內文是一般範例。
JSON 要求內文 1
{
"parameters":[
{
"hostname": "public-01-dal10",
"domain": "softlayer.local",
"datacenter": {
"name": "dal10"
},
"operatingSystemReferenceCode": "CENTOS_LATEST",
"networkComponents": [
{
"maxSpeed": 100
}
],
"hourlyBillingFlag": false,
"supplementalCreateObjectOptions": {
"flavorKeyName": "B1_1X2X25"
}
}
]
}
佈建具有下訂單物件的公用虛擬伺服器
配置使用預設設定檔的公共虛擬伺服器是透過使用 SoftLayer_Product_Order/placeOrder API服務。
不適用於暫時性虛擬伺服器。
若要使用 REST 設定公用虛擬伺服器,需要將 POST 請求提交到 下訂單請求正文中包含以下 JSON。
價格不需要項目說明。 包含它們只是為了顯示正在提交的產品選項。
下列 JSON 要求內文是一般範例。
JSON 要求內文 2
{
"parameters": [
{
"location": "449600",
"packageId": 835,
"presetId": 554,
"prices": [
{
"id": 45466,
"item": {
"description": "CentOS 7.x - Minimal Install (64 bit)"
}
},
{
"id": 2202,
"item": {
"description": "25 GB (SAN)"
}
},
{
"id": 905,
"item": {
"description": "Reboot / Remote Console"
}
},
{
"id": 273,
"item": {
"description": "100 Mbps Public & Private Network Uplinks"
}
},
{
"id": 50367,
"item": {
"description": "250 GB Bandwidth"
}
},
{
"id": 21,
"item": {
"description": "1 IP Address"
}
},
{
"id": 55,
"item": {
"description": "Host Ping"
}
},
{
"id": 57,
"item": {
"description": "Email and Ticket"
}
},
{
"id": 58,
"item": {
"description": "Automated Notification"
}
},
{
"id": 420,
"item": {
"description": "Unlimited SSL VPN Users & 1 PPTP VPN User per account"
}
}
],
"quantity": 1,
"useHourlyPricing": false,
"virtualGuests": [
{
"domain": "softlayer.local",
"hostname": "public-01-dal10"
}
],
"complexType": "SoftLayer_Container_Product_Order_Virtual_Guest"
}
]
}
升級公用虛擬伺服器
升級公共虛擬伺服器是透過使用 SoftLayer_Product_Order/placeOrder API服務。
不適用於暫時性虛擬伺服器。
若要使用 REST 設定公用虛擬伺服器,需要將 POST 請求提交到 下訂單請求正文中包含以下 JSON。
價格不需要項目說明。 包含它們只是為了顯示正在提交的產品選項。
下列 JSON 要求內文是一般範例。
JSON 要求內文 3
{
"parameters":[
{
"complexType": "SoftLayer_Container_Product_Order_Virtual_Guest_Upgrade",
"presetId": 494,
"prices": [
{
"id":"274",
"item": {
"description": "1 Gbps Public & Private Network Uplinks"
},
"categories": [
{
"categoryCode": "port_speed"
}
]
}
],
"properties": [
{
"name": "MAINTENANCE_WINDOW",
"value": "2017-07-20T13:48:31-05:00"
}
],
"virtualGuests": [
{
"id": 36189167
}
]
}
]
}
佈建具有「建立物件」的暫時性虛擬伺服器
這 SoftLayer_Virtual_Guest/createObject API 服務是配置臨時虛擬伺服器最簡單的方法。
若要使用 REST 設定臨時虛擬伺服器,需要將 POST 請求提交到 創建對象請求正文中包含以下 JSON。
下列 JSON 要求內文是一般範例。
JSON 要求內文 4
{
"parameters":[
{
"hostname": "sample-transient-public",
"domain": "softlayer.local",
"datacenter": {
"name": "dal10"
},
"operatingSystemReferenceCode": "CENTOS_LATEST",
"networkComponents": [
{
"maxSpeed": 100
}
],
"supplementalCreateObjectOptions": {
"flavorKeyName": "B1_1X2X25"
},
"transientGuestFlag": true
}
]
}