例如:“categoryCode”:“guest_disk1”或“categoryCode”:“gateway_resource_group”。如何识别此资源属于哪个父服务器?或者如何区分同一类别的2个资源。就像我们使用主机名识别2台服务器一样。我不想使用“id”作为标识符。我尝试使用parentId和parent,但我总是将它取为所有资源的null。
答案 0 :(得分:1)
如果“ParentId”
为null,请参阅resourceTableId
属性,它将包含您需要的item_id
(resourceTableId:与之关联的SoftLayer服务的唯一标识符)发票项目.ref:SoftLayer_Billing_Invoice_Item),
例如,在执行此请求时:
https://[username]:[apikey]@api.softlayer.com/rest/v3/SoftLayer_Account/getNextInvoiceTopLevelBillingItems?objectFilter={ "nextInvoiceTopLevelBillingItems": { "orderItem": { "order": { "id": { "operation": 5874669 } } } } }&objectMask=mask[id,categoryCode, item, parentId,orderItem[item],invoiceItems[id,resourceTableId,categoryCode,description,billingItemId],children[parentId,categoryCode,orderItem[id,description,order.id]]]
Method: GET
Where `”5874669”` is the orderId
我的回答是:
[
{
"categoryCode": "guest_core",
"id": 70751841,
"parentId": null,
"children": [
{
"categoryCode": "ram",
"parentId": 70751841,
"orderItem": {
"description": "8 GB",
"id": 92196283,
"order": {
"id": 5874669
}
}
},
{
"categoryCode": "remote_management",
"parentId": 70751841,
"orderItem": {
"description": "Reboot / Remote Console",
"id": 92196285,
"order": {
"id": 5874669
}
}
},
{
"categoryCode": "port_speed",
"parentId": 70751841,
"orderItem": {
"description": "100 Mbps Public & Private Network Uplinks",
"id": 92196287,
"order": {
"id": 5874669
}
}
},
{
"categoryCode": "public_port",
"parentId": 70751841,
"orderItem": {
"description": "100 Mbps Public Uplink",
"id": 92196289,
"order": {
"id": 5874669
}
}
},
{
"categoryCode": "service_port",
"parentId": 70751841,
"orderItem": {
"description": "100 Mbps Private Uplink",
"id": 92196291,
"order": {
"id": 5874669
}
}
},
{
"categoryCode": "bandwidth",
"parentId": 70751841,
"orderItem": {
"description": "0 GB Bandwidth",
"id": 92196293,
"order": {
"id": 5874669
}
}
},
{
"categoryCode": "pri_ip_addresses",
"parentId": 70751841,
"orderItem": {
"description": "1 IP Address",
"id": 92196295,
"order": {
"id": 5874669
}
}
},
{
"categoryCode": "guest_disk0",
"parentId": 70751841,
"orderItem": {
"description": "25 GB (SAN)",
"id": 92196297,
"order": {
"id": 5874669
}
}
},
{
"categoryCode": "os",
"parentId": 70751841,
"orderItem": {
"description": "Ubuntu Linux 14.04 LTS Trusty Tahr - Minimal Install (64 bit)",
"id": 92196299,
"order": {
"id": 5874669
}
}
},
{
"categoryCode": "monitoring",
"parentId": 70751841,
"orderItem": {
"description": "Host Ping",
"id": 92196301,
"order": {
"id": 5874669
}
}
},
{
"categoryCode": "notification",
"parentId": 70751841,
"orderItem": {
"description": "Email and Ticket",
"id": 92196303,
"order": {
"id": 5874669
}
}
},
{
"categoryCode": "response",
"parentId": 70751841,
"orderItem": {
"description": "Automated Notification",
"id": 92196305,
"order": {
"id": 5874669
}
}
},
{
"categoryCode": "vpn_management",
"parentId": 70751841,
"orderItem": {
"description": "Unlimited SSL VPN Users & 1 PPTP VPN User per account",
"id": 92196307,
"order": {
"id": 5874669
}
}
},
{
"categoryCode": "vulnerability_scanner",
"parentId": 70751841,
"orderItem": {
"description": "Nessus Vulnerability Assessment & Reporting",
"id": 92196309,
"order": {
"id": 5874669
}
}
}
],
"invoiceItems": [
{
"billingItemId": 70751841,
"categoryCode": "guest_core",
"description": "4 x 2.0 GHz Cores",
"id": 229216475,
"resourceTableId": 13102629
},
{
"billingItemId": 70751841,
"categoryCode": "guest_core",
"description": "4 x 2.0 GHz Cores",
"id": 236371529,
"resourceTableId": 13102629
},
{
"billingItemId": 70751841,
"categoryCode": "guest_core",
"description": "4 x 2.0 GHz Cores",
"id": 254309359,
"resourceTableId": 13102629
},
{
"billingItemId": 70751841,
"categoryCode": "guest_core",
"description": "4 x 2.0 GHz Cores",
"id": 227147491,
"resourceTableId": null
},
{
"billingItemId": 70751841,
"categoryCode": "guest_core",
"description": "4 x 2.0 GHz Cores",
"id": 245530073,
"resourceTableId": 13102629
},
{
"billingItemId": 70751841,
"categoryCode": "guest_core",
"description": "4 x 2.0 GHz Cores",
"id": 263996519,
"resourceTableId": 13102629
},
{
"billingItemId": 70751841,
"categoryCode": "guest_core",
"description": "4 x 2.0 GHz Cores",
"id": 284422451,
"resourceTableId": 13102629
},
{
"billingItemId": 70751841,
"categoryCode": "guest_core",
"description": "4 x 2.0 GHz Cores",
"id": 274920353,
"resourceTableId": 13102629
}
],
"item": {
"capacity": "4",
"description": "4 x 2.0 GHz Cores",
"id": 859,
"itemTaxCategoryId": 166,
"keyName": "GUEST_CORES_4",
"softwareDescriptionId": null,
"units": "CORE",
"upgradeItemId": null,
"itemCategory": {
"categoryCode": "guest_core",
"id": 80,
"name": "Computing Instance",
"quantityLimit": 20
},
"totalPhysicalCoreCount": 4
},
"orderItem": {
"categoryCode": "guest_core",
"description": "4 x 2.0 GHz Cores",
"domainName": "mesos.maceacs.com",
"hostName": "2-master-1712",
"hourlyRecurringFee": "0",
"id": 92196281,
"itemId": 859,
"itemPriceId": "52135",
"laborAfterTaxAmount": "0",
"laborFee": "0",
"laborFeeTaxRate": "0",
"laborTaxAmount": "0",
"oneTimeAfterTaxAmount": "0",
"oneTimeFee": "0",
"oneTimeFeeTaxRate": "0",
"oneTimeTaxAmount": "0",
"parentId": null,
"promoCodeId": null,
"quantity": null,
"recurringAfterTaxAmount": "0",
"recurringFee": "0",
"recurringTaxAmount": "0",
"setupAfterTaxAmount": "0",
"setupFee": "0",
"setupFeeDeferralMonths": 12,
"setupFeeTaxRate": "0",
"setupTaxAmount": "0",
"item": {
"capacity": "4",
"description": "4 x 2.0 GHz Cores",
"id": 859,
"itemTaxCategoryId": 166,
"keyName": "GUEST_CORES_4",
"softwareDescriptionId": null,
"units": "CORE",
"upgradeItemId": null,
"itemCategory": {
"categoryCode": "guest_core",
"id": 80,
"name": "Computing Instance",
"quantityLimit": 20
},
"totalPhysicalCoreCount": 4
},
"order": {
"id": 5874669
}
}
}
]
在此响应中显示与orderId关联的所有项目。
在第一部分中:
[
{
"categoryCode": "guest_core",
"id": 70751841,
"parentId": null,
"children": [
{
"categoryCode": "ram",
"parentId": 70751841,
"orderItem": {
"description": "8 GB",
"id": 92196283,
"order": {
"id": 5874669
}
}
},
....
我们注意到这个"categoryCode": "guest_core"
没有'parentId'(“parentId”:null)。这意味着此商品是此订单的父商品。
但是如何识别这个项目的ID?
好吧,在invoiceItems
部分有一个名为'resourceTableId'的属性,这是父项的id。我的意思是:"resourceTableId"= 13102629
是id
Virtual Guest
"invoiceItems": [
{
"billingItemId": 70751841,
"categoryCode": "guest_core",
"description": "4 x 2.0 GHz Cores",
"id": 229216475,
"resourceTableId": 13102629
},
在Children section
中会显示与我的订单相关联的其他项目,我们可以在其中注意到他们有parentId = null。