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
}
]
}