获取动态定价
作为卖家、转售商或希望以编程方式获取定价的用户,您可能希望动态获取定价,这样您就可以报出真实的价格,并对服务或软件的成本进行预测。 为此,您可以利用全球目录 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
的特定区域。 This region_id
and must match with one of the values of deployment_region
in the deployment_locations
array in the previous response.
还有不使用 "deployment_regions
覆盖变量的全局定价计划。
下面是一个示例,使用的是带有 "eu-de
"deployment_region
的 API 端点。
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 ,由全局目录用户界面中的定价源指定。 |
type |
计划类型。 有效值为 "free "、"trial "、"paygo "、"paid "、"bluemix-subscription "和 "ibm-subscription "。 有关更多信息,请参阅
帐户类型。 |
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,这意味着每使用 1 千兆字节就要收费。 |
amounts |
按国家和货币划分的单位定价。 |
country |
此对象价格适用的国家。 |
currency |
价格货币。 |
quantity_tier |
该级别中该价格的使用水平。 |
price |
该层级的单位价格。 |
included_quanitities |
可用的空闲对象总数。 |
解释 API 的定价结果
在下表中,我们举例说明了线性分层定价的情况。 对于线性层级,总金额是每种资源的单价与使用数量相乘的结果。
下表说明了使用基于累进层定价模型的套餐要支付的费用:
项数 | 费用计算 | 总价 |
---|---|---|
500 | 500 × 0.000171798 = .0859 | 0.0859 美元 |
2000 | 2000 x0.000171798= .344 | 0.344 美元 |
10000 | 10000 x0.000171798=1.72 | 1.72美元 |
-
对于阶梯式定价,您需要根据运行时间和服务消耗量付费。 不过,分级收费增加了更多的定价级别,通常为较高消费级别的产品提供折扣价。 分级定价有简单、渐进、线性或区块定价。 ↩︎