取得動態定價
作為想要以程式方式取得定價的賣家、經銷商或用戶,您可能希望動態取得定價,以便您可以報價真實價格並對服務或軟體的成本進行成本預測。 為此,您可以利用全域目錄 API 來取得動態定價。 要使用API,您需要有正確的 身份驗證。
確定產品和區域可用性
透過此範例,您將了解如何識別產品和可用區域。 為此,您將對 GC 進行 API 呼叫以列出所有產品,篩選結果以識別所需的產品,並進行 API 呼叫以取得提供該產品的區域。 請注意,您確定的是特定計劃可用的區域,而不是服務是否在所有區域均可用的區域。
若要列出所有供應品,請使用下列指令:
curl --request GET
--url `https://globalcatalog.cloud.ibm.com/api/v1?q=kind:service`
--header `accept: application/json`
在回應中,您可以識別Power Systems Virtual Server群組的服務 ID:abd259f0-9990-11e8-acc8-b9f54a8f1661。
因此,您可以執行以下命令來取得Power Systems Virtual Server群組的計劃 ID。
curl -X 'GET'
--url 'https://globalcatalog.cloud.ibm.com/api/v1/abd259f0-9990-11e8-acc8-b9f54a8f1661/plan?_offset=0&_limit=50'
-H 'accept: application/json'
以下是您剛剛執行的命令的回應範例。 資源數組列出了服務中的所有計劃。 數組中的每個條目都是一個計劃。 計劃對像中的重要欄位是 id 欄位。 在以下回應中,您將看到 f165dd34-3a40-423b-9d95-e90a23f724dd 是 ID。
{
"offset": 0,
"limit": 50,
"count": 2,
"resource_count": 2,
"first": "https://globalcatalog.cloud.ibm.com/api/v1/abd259f0-9990-11e8-acc8-b9f54a8f1661/plan?languages=en-US%2Cen%3Bq%3D0.9",
"resources": [
{
"_id": "f165dd34-3a40-423b-9d95-e90a23f724dd",
"_rev": "5-3709538cdcff35d2917d56c3cafb1fac",
"active": true,
"catalog_crn": "crn:v1:bluemix:public:globalcatalog::::plan:f165dd34-3a40-423b-9d95-e90a23f724dd",
"children_url": "https://globalcatalog.cloud.ibm.com/api/v1/f165dd34-3a40-423b-9d95-e90a23f724dd/%2A",
"complete": true,
"created": "2019-06-14T22:52:18.378Z",
"disabled": false,
"geo_tags": [
"che01",
"dal10",
"dal12",
"eu-de-1",
"eu-de-2",
"lon04",
"lon06",
"mad02",
"mad04",
"mon01",
"osa21",
"sao01",
"sao04",
"syd04",
"syd05",
"tok04",
"tor01",
"wdc06",
"wdc07",
"us-east",
"us-south"
],
"id": "f165dd34-3a40-423b-9d95-e90a23f724dd",
"images": {
"feature_image": "https://cache.globalcatalog.cloud.ibm.com/api/v1/abd259f0-9990-11e8-acc8-b9f54a8f1661/artifacts/cache/66c89a2644c2ac54745d6ab9ecf4da8e-public/IBM_Power_CloudCatalog%202.svg",
"image": "https://cache.globalcatalog.cloud.ibm.com/api/v1/abd259f0-9990-11e8-acc8-b9f54a8f1661/artifacts/cache/66c89a2644c2ac54745d6ab9ecf4da8e-public/IBM_Power_CloudCatalog%202.svg",
"medium_image": "https://cache.globalcatalog.cloud.ibm.com/api/v1/abd259f0-9990-11e8-acc8-b9f54a8f1661/artifacts/cache/66c89a2644c2ac54745d6ab9ecf4da8e-public/IBM_Power_CloudCatalog%202.svg",
"small_image": "https://cache.globalcatalog.cloud.ibm.com/api/v1/abd259f0-9990-11e8-acc8-b9f54a8f1661/artifacts/cache/66c89a2644c2ac54745d6ab9ecf4da8e-public/IBM_Power_CloudCatalog%202.svg"
},
"kind": "plan",
"metadata": {
"compliance": [
"minisd"
],
"original_name": "power-virtual-server-project",
"other": {
"pricing_schema_url": "https://power-iaas.cloud.ibm.com/cost-estimator"
},
"plan": {
"allow_internal_users": true,
"async_provisioning_supported": true,
"async_unprovisioning_supported": true,
"bindable": false,
"reservable": false,
"service_check_enabled": false,
"single_scope_instance": "",
"test_check_interval": 0
},
"pricing": {
"metrics": null,
"origin": "pricing_catalog",
"starting_price": {},
"type": "Paid",
"url": "https://globalcatalog.cloud.ibm.com/api/v1/f165dd34-3a40-423b-9d95-e90a23f724dd/pricing"
},
"rc_compatible": true,
"service": {
"async_provisioning_supported": true,
"async_unprovisioning_supported": true,
"bindable": false,
"custom_create_page_hybrid_enabled": false,
"extension": null,
"iam_compatible": true,
"parameters": [],
"plan_updateable": true,
"rc_provisionable": true,
"service_check_enabled": false,
"service_key_supported": false,
"state": "",
"test_check_interval": 0,
"type": "",
"unique_api_key": false,
"user_defined_service": null
},
"ui": {
"strings": {
"en": {
"bullets": [
{
"description": "Enables provisioning of Power Virtual Server LPARs in the chosen region."
}
]
}
}
}
},
"name": "power-virtual-server-group",
"overview_ui": {
"en": {
"description": "A Power Systems Virtual Server group for the specified IBM Cloud region.",
"display_name": "Power Systems Virtual Server Group",
"long_description": "A Power Systems Virtual Server group for the specified IBM Cloud region."
}
},
"parent_id": "abd259f0-9990-11e8-acc8-b9f54a8f1661",
"parent_url": "https://globalcatalog.cloud.ibm.com/api/v1/abd259f0-9990-11e8-acc8-b9f54a8f1661",
"pricing_tags": [
"allow_internal_users",
"paid",
"paid_only"
],
"provider": {
"email": "pil@us.ibm.com",
"name": "IBM"
},
"tags": [
"apidocs_enabled",
"beryllium",
"freesia",
"ibm_created",
"rc_compatible"
],
"updated": "2024-03-15T13:14:09.574263813-04:00",
"url": "https://globalcatalog.cloud.ibm.com/api/v1/f165dd34-3a40-423b-9d95-e90a23f724dd?languages=en-US%2Cen%3Bq%3D0.9",
"visibility": {
"restrictions": "public"
}
},
{
"_id": "1112d6a9-71d6-4968-956b-eb3edbf0225b",
"_rev": "22-c4780dfb7c2ca400029754649383507e",
"active": true,
"catalog_crn": "crn:v1:bluemix:public:globalcatalog::::plan:1112d6a9-71d6-4968-956b-eb3edbf0225b",
"children_url": "https://globalcatalog.cloud.ibm.com/api/v1/1112d6a9-71d6-4968-956b-eb3edbf0225b/%2A",
"complete": true,
"created": "2024-02-14T11:00:24.476151306-05:00",
"disabled": false,
"geo_tags": [
"satcon_dal",
"satcon_fra",
"satcon_mad",
"satcon_osa",
"satcon_sao",
"satcon_syd",
"satcon_tok",
"satcon_tor",
"satcon_wdc"
],
"id": "1112d6a9-71d6-4968-956b-eb3edbf0225b",
"images": {
"feature_image": "https://cache.globalcatalog.cloud.ibm.com/api/v1/abd259f0-9990-11e8-acc8-b9f54a8f1661/artifacts/cache/66c89a2644c2ac54745d6ab9ecf4da8e-public/IBM_Power_CloudCatalog%202.svg",
"image": "https://cache.globalcatalog.cloud.ibm.com/api/v1/abd259f0-9990-11e8-acc8-b9f54a8f1661/artifacts/cache/66c89a2644c2ac54745d6ab9ecf4da8e-public/IBM_Power_CloudCatalog%202.svg",
"medium_image": "https://cache.globalcatalog.cloud.ibm.com/api/v1/abd259f0-9990-11e8-acc8-b9f54a8f1661/artifacts/cache/66c89a2644c2ac54745d6ab9ecf4da8e-public/IBM_Power_CloudCatalog%202.svg",
"small_image": "https://cache.globalcatalog.cloud.ibm.com/api/v1/abd259f0-9990-11e8-acc8-b9f54a8f1661/artifacts/cache/66c89a2644c2ac54745d6ab9ecf4da8e-public/IBM_Power_CloudCatalog%202.svg"
},
"kind": "plan",
"metadata": {
"compliance": [
"minisd"
],
"original_name": "power-virtual-server-private-group",
"plan": {
"allow_internal_users": true,
"async_provisioning_supported": false,
"async_unprovisioning_supported": false,
"bindable": false,
"reservable": false,
"service_check_enabled": false,
"single_scope_instance": "",
"test_check_interval": 0
},
"pricing": {
"metrics": null,
"origin": "pricing_catalog",
"starting_price": {},
"type": "free",
"url": "https://globalcatalog.cloud.ibm.com/api/v1/1112d6a9-71d6-4968-956b-eb3edbf0225b/pricing"
},
"rc_compatible": true,
"service": {
"async_provisioning_supported": false,
"async_unprovisioning_supported": false,
"bindable": false,
"custom_create_page_hybrid_enabled": false,
"extension": null,
"iam_compatible": true,
"parameters": [],
"plan_updateable": false,
"rc_provisionable": true,
"service_check_enabled": false,
"service_key_supported": false,
"state": "",
"test_check_interval": 0,
"type": "",
"unique_api_key": false,
"user_defined_service": null
},
"sla": {
"dr": {
"dr": true
}
},
"ui": {
"strings": {
"en": {
"bullets": [
{
"description": "Enables use of Power Virtual Server Private Cloud resources in the chosen satellite location."
}
]
}
}
}
},
"name": "power-virtual-server-private-group",
"overview_ui": {
"en": {
"description": "A Power Systems Virtual Server Private Cloud group for the specified IBM Cloud Satellite location.",
"display_name": "Power Virtual Server Private Cloud Group",
"long_description": "A Power Systems Virtual Server Private Cloud group for the specified IBM Cloud Satellite location."
}
},
"parent_id": "abd259f0-9990-11e8-acc8-b9f54a8f1661",
"parent_url": "https://globalcatalog.cloud.ibm.com/api/v1/abd259f0-9990-11e8-acc8-b9f54a8f1661",
"pricing_tags": [
"free",
"allow_internal_users"
],
"provider": {
"email": "pil@us.ibm.com",
"name": "IBM"
},
"tags": [
"rc_compatible",
"apidocs_enabled",
"compute",
"virtualservers",
"ibm_created",
"satellite_enabled"
],
"updated": "2024-06-20T10:12:47.969618989-04:00",
"url": "https://globalcatalog.cloud.ibm.com/api/v1/1112d6a9-71d6-4968-956b-eb3edbf0225b?languages=en-US%2Cen%3Bq%3D0.9",
"visibility": {
"restrictions": "public"
}
}
]
}
確定給定區域的有效計劃
在以下範例中,您將了解如何尋找特定區域的有效計劃。為此,您將進行 API 呼叫來檢索指定區域中產品的有效計劃列表,然後解釋 API 回應以了解可用計劃。 有關更多信息,請參閱 API 文件:獲取計劃的定價部署。
curl --request GET
--url 'https://globalcatalog.cloud.ibm.com/api/v1/{id}/pricing/deployment'
--header 'accept: application/json'
在該範例中,在 ID 位置輸入您使用上一個步驟找到的計劃 ID。
curl --request GET
--url 'https://globalcatalog.cloud.ibm.com/api/v1/f165dd34-3a40-423b-9d95-e90a23f724dd/pricing/deployment'
--header 'accept: application/json'
以下是僅列出第一個指標的範例回應:
{
"offset":0,
"limit":50,
"count":5,
"resource_count":5,
"resources":[
{
"deployment_id":"f165dd34-3a40-423b-9d95-e90a23f724dd:eu-de-114101",
"deployment_location":"eu-de-1",
"deployment_region":"eu-de-1",
"origin":"pricing_catalog",
"type":"Paid",
"i18n":{
},
"starting_price":{
},
"effective_from":"2024-11-01T00:00:00Z",
"effective_until":"9999-09-30T00:00:00Z",
"metrics":[
{
"part_ref":"",
"metric_id":"ibm-i-rds",
"tier_model":"Linear Tier",
"resource_display_name":"APPLICATION_INSTANCES",
"charge_unit_display_name":"IBM i RDS License/user-hour",
"charge_unit_name":"IBMIRDS_APPLICATION_INSTANCES",
"charge_unit":"Application Instance",
"charge_unit_quantity":1,
"amounts":[
{
"country":"USA",
"currency":"USD",
"prices":[
{
"quantity_tier":1,
"price":0.1808
}
]
},
{
"country":"USD",
"currency":"USD",
"prices":[
{
"quantity_tier":1,
"price":0.1808
}
]
},
{
"country":"CAN",
"currency":"CAD",
"prices":[
{
"quantity_tier":1,
"price":0.24962151999999999
}
]
},
{
"country":"AUS",
"currency":"AUD",
"prices":[
{
"quantity_tier":1,
"price":0.2696696184
}
]
},
{
"country":"ISA",
"currency":"USD",
"prices":[
{
"quantity_tier":1,
"price":0.1808
}
]
},
"usage_cap_qty":0,
"display_cap":0,
"effective_from":"2024-11-01T00:00:00Z",
"effective_until":"9999-12-31T00:00:00Z",
"additional_properties":{
"included_quantities":{
"account":0,
"instance":0
}
}
},
回應中的資源物件是可用計畫的部署或位置的清單。 在這種情況下,該計劃在全球範圍內可用。 還有其他情況是部署特定於某個區域,例如 us-south、us-east 等。
對於全球部署方案的情況,可以使用下列API查詢特定區域的定價:
curl --request GET
--url 'https://globalcatalog.cloud.ibm.com/api/v1/{id}:global/pricing?deployment_region={ region_id}'
--header 'accept: application/json'
使用您在上一個步驟中找到的計劃 ID:
curl --request GET
--url 'https://globalcatalog.cloud.ibm.com/api/v1/f165dd34-3a40-423b-9d95-e90a23f724dd:global/pricing?deployment_region={ region_id}'
--header 'accept: application/json'
Cloud Object Storage標準計畫是全球部署並具有特定區域定價的計畫的範例。 計劃 ID 為 744bfc56-d12c-4866-88d5-dac9139e0e5d。 該計劃有 eu-de 的特定區域。 此 region_id 必須與上一個回應中 deployment_locations 數組中 deployment_region 的值之一相符。
還有具有全球定價的全球計劃,不使用 deployment_regions 覆蓋變數。
以下是使用 API 端點和 eu-de deployment_region 的範例。
https://globalcatalog.cloud.ibm.com/api/v1/744bfc56-d12c-4866-88d5-dac9139e0e5d:global/pricing?deployment_region=eu-de
這是回應範例:
{
"deployment_id": "744bfc56-d12c-4866-88d5-dac9139e0e5d:global",
"deployment_location": "global",
"deployment_region": "eu-de",
"origin": "pricing_catalog",
"type": "paygo",
"url": "https://globalcatalog.cloud.ibm.com/api/v1/744bfc56-d12c-4866-88d5-dac9139e0e5d:global/pricing?deployment_region=eu-de",
"i18n": {},
"starting_price": {},
"effective_from": "2024-09-01T00:00:00Z",
"effective_until": "9999-12-31T00:00:00Z",
"metrics": [
{
"part_ref": "",
"metric_id": "COSVLTBCALL",
"tier_model": "Granular Tier",
"resource_display_name": "Vault Class B calls",
"charge_unit_display_name": "API_CALLS",
"charge_unit_name": "VAULT_CLASS_B_CALLS",
"charge_unit": "API_CALLS",
"charge_unit_quantity": 10000,
"amounts": [
{
"country": "USA",
"currency": "USD",
"prices": [
{
"quantity_tier": 1,
"price": 0.01045
}
]
}
],
"usage_cap_qty": 0,
"display_cap": 0,
"effective_from": "2024-09-01T00:00:00Z",
"effective_until": "9999-12-31T00:00:00Z",
"additional_properties": {}
}
]
}
對於計劃部署不是全域的情況,可以使用下列 API 查詢特定部署位置的定價:
curl --request GET
--url 'https://globalcatalog.cloud.ibm.com/api/v1/{id}/pricing'
--header 'accept: application/json'
使用上一個步驟中的計劃 ID:
curl --request GET
--url 'https://globalcatalog.cloud.ibm.com/api/v1/f165dd34-3a40-423b-9d95-e90a23f724dd/pricing'
--header 'accept: application/json'
{id} 是部署的 deployment_id 的 ID。 您可以使用前面討論的 API 找到部署位置和關聯的 deployment_id。
讓我們使用計劃 ID: databases-for-postgresql-standard 來說明此場景。 Databases for PostgreSQL中的計劃,服務 id: databases-for-postgresql。
該計劃的部署位置之一在 au-syd 中可用,該位置的 deployment_id 是 databases-for-postgresql-standard:au-syd。
API 呼叫將是這樣的:https://globalcatalog.cloud.ibm.com/api/v1/databases-for-postgresql-standard:au-syd。
以下是 API 呼叫的回應:
{
"deployment_id": "databases-for-postgresql-standard:au-syd",
"deployment_location": "au-syd",
"deployment_region": "au-syd",
"origin": "pricing_catalog",
"type": "paygo",
"url": "https://globalcatalog.cloud.ibm.com/api/v1/databases-for-postgresql-standard:au-syd/pricing",
"i18n": {},
"starting_price": {},
"effective_from": "2024-09-01T00:00:00Z",
"effective_until": "9999-12-31T00:00:00Z",
"metrics": [
{
"part_ref": "",
"metric_id": "databases-for-postgresql-cpu",
"tier_model": "Linear Tier",
"resource_display_name": "Databases for PostgreSQL CPU",
"charge_unit_display_name": "CPU",
"charge_unit_name": "VIRTUAL_PROCESSOR_CORES",
"charge_unit": "Virtual Processor Core-Hour",
"charge_unit_quantity": 1,
"amounts": [
{
"country": "USA",
"currency": "USD",
"prices": [
{
"quantity_tier": 1,
"price": 32.342
}
]
}
],
"usage_cap_qty": 0,
"display_cap": 0,
"effective_from": "2024-09-01T00:00:00Z",
"effective_until": "9999-12-31T00:00:00Z"
}
]
}
確定給定計劃或區域的有效指標
以下資訊可協助您確定特定計劃和地區的有效指標。 指標是確定定價使用情況的資源或操作的規範。 您可以進行 API 呼叫以列出指定區域中給定計劃的有效指標,然後解析回應以取得有關指標的詳細資訊。
以下範例顯示了對Power Systems Virtual Server群組服務的 API 呼叫。 正如我們之前發現的,ID 是 f165dd34-3a40-423b-9d95-e90a23f724dd。
curl --request GET
--url 'https://globalcatalog.cloud.ibm.com/api/v1/f165dd34-3a40-423b-9d95-e90a23f724dd/pricing/deployment'
--header 'accept: application/json'
以下是回應範例:
{
"offset": 0,
"limit": 1,
"count": 21,
"resource_count": 1,
"resources": [
{
"deployment_id": "f165dd34-3a40-423b-9d95-e90a23f724dd:che0142579",
"deployment_location": "che01",
"deployment_region": "che01",
"origin": "pricing_catalog",
"type": "Paid",
"i18n": {},
"starting_price": {},
"effective_from": "2024-07-01T00:00:00Z",
"effective_until": "9999-09-30T00:00:00Z",
"metrics": [
{
"part_ref": "",
"metric_id": "tier3-storage",
"tier_model": "Linear Tier",
"resource_display_name": "HDD Storage Gigabyte-Hours",
"charge_unit_display_name": "HDD Storage Gigabyte-Hour",
"charge_unit_name": "TIER_THREE_STORAGE_GIGABYTE_HOURS",
"charge_unit": "HDD Storage Gigabyte-Hour",
"charge_unit_quantity": 1,
"amounts": [
{
"country": "USA",
"currency": "USD",
"prices": [
{
"quantity_tier": 1,
"price": 0.000171798
}
]
}
],
"usage_cap_qty": 0,
"display_cap": 0,
"effective_from": "2024-07-01T00:00:00Z",
"effective_until": "9999-12-31T00:00:00Z"
}
]
}
]
}
檢查資源數組的部署。 每個部署都有 deployment_location 字段,該字段指的是可用計劃的特定位置或區域。
下表顯示了回應正文欄位及其描述。 有關更多信息,請參閱 全域目錄 API 文件。
| JSON字段 | 說明 |
|---|---|
deployment_id |
此定價來自的部署物件 ID。 |
deployment_location |
此定價來自的部署位置。 例如 che01。 |
deployment_region |
這是部署計劃用於檢索全球部署的計劃定價的區域。 本範例中為 che01。 |
origin |
定價數據來自哪裡。 對於本例,它是 pricing_catalog,由全域目錄 UI 中的定價來源指定。 |
type |
計劃類型。 有效值為 free、trial、paygo、paid、bluemix-subscription 和 ibm-subscription。 如需相關資訊,請參閱帳戶類型。 |
url |
工件的 url。 這是您可以用來獲取定價的 URL。 |
starting_price |
特定於計劃的起始價格資訊。 |
effective_from |
可用定價的開始日期。 |
effective_until |
可用定價的結束日期。 |
metrics |
確定定價使用情況的資源或操作的規格。 |
part_ref |
IBM為度量所指派的部件參考號。 |
metric_id |
公制 ID 或零件號。 |
tier_model |
分級定價模型[1]。 可能的值為 Simple Tier、Graduated Tier、Linear Tier 或 Block (Step) Tier。 對於本例,它是 Linear Tier。 有關詳細信息,請參閱
如何收費。 |
resource_display_name |
資源的顯示名稱。 這就是指標在目錄中的顯示方式。 |
charge_unit_display_name |
計費單位的顯示名稱。 charge_unit 的單位友善顯示名稱。 |
charge_unit_name |
收費單位的指定名稱。 這是用於衡量指標使用情況的 ID。 |
charge_unit |
這是可充電裝置。 對於本例,它是 HDD Storage Gigabyte-Hour。 |
charge_unit_quantity |
收費單位數量。 在範例回應中,收費單位為 1,這表示您需要按使用的每 GB 付費。 |
amounts |
按國家/地區和貨幣劃分的每個指標的定價。 |
country |
該物件的價格適用的國家。 |
currency |
價格的貨幣。 |
quantity_tier |
該價格在該層的使用水準。 |
price |
此等級的每單位價格。 |
included_quanitities |
可用的自由物件總數。 |
解釋定價 API 結果
在下表中,我們展示了線性層級定價的範例。 對於線性層,總金額是每個資源的單價與使用數量相乘的結果。
下表說明您要對根據累進層級定價模型的方案支付多少錢:
| 項目數量 | 費用計算 | 總價 |
|---|---|---|
| 500 | 500× 0.000171798 = .0859 | 0.0859 美元 |
| 2000 | 2000 x 0.000171798 =.344 | 0.344 美元 |
| 10000 | 10000× 0.000171798 = 1.72 | 1.72美元 |
-
對於分層定價,您會根據運行時間和服務消耗量來支付費用。 然而,分級收費增加了更多的定價水平,通常為較高消費層的產品提供折扣價。 分層定價提供簡單、漸進、線性或塊狀定價。 ↩︎