-->

SoftLayer API: Price is not been adjusted based on

2019-09-02 16:40发布

问题:

We are under developing SL Portal, and for now, we've found that, from SL control page, when we try to order, the price of Netscaler is always same even for the all the different data centers. However when we retrieve the price through API then the price wasn't same.

Please what's the right price for each data centers, and when making the new portal site, what do we have to follow ?

Thanks.

回答1:

The portal displays the standard prices, The standard prices are the one which locationGroupId field is "null" or empty.

If you are interested in display the exactly price for a datacenter, you should display the price which value in "pricingLocationGroup": "locations": "regions": "description" is the same as the selected datacenter. Look at the price below in this case this price should be displayed for the datacenter "SYD01 - Sydney" and "MEL01 - Melbourne"

{
    "id": 83961,
    "locationGroupId": 545,
    "item": {
        "description": "Citrix NetScaler VPX 10.1 1000Mbps Standard",
        "id": 4423,
        "keyName": "CITRIX_NETSCALER_VPX_10_1_1000MBPS_STANDARD"
    } -
    "pricingLocationGroup": {
        "description": "Location Group 6"
        "id": 545,
        "locationGroupTypeId": 82,
        "name": "Location Group 6",
        "securityLevelId": null,
        "locations": [2]
          0:  {
               "id": 449612
               "longName": "Sydney 1"
               "name": "syd01"
               "regions": [1]
                0:  {
                     "description": "SYD01 - Sydney"
                     "keyname": "SYDNEY"
                     "sortOrder": 78
                    }-
                -
              }-
          1:  {
              "id": 449596
              "longName": "Melbourne 1"
              "name": "mel01"
              "regions": [1]
                0:  {
                 "description": "MEL01 - Melbourne"
                  "keyname": "MELBOURNE"
                  "sortOrder": 48
                }-

          }
    }

If you are not interested in display the exactly price for the datacenter you can use the standard price

Regards



回答2:

The reason why you see the same item prices is because of the prices selected by Control Portal are “Standard prices” probably. A “Standard price” means that it can be used to order the item for any location.

But, ... How do we know if a price is a “Standard price” or not?

The following request helps us to get prices according to location/datacenter.

REST example:

https://[username]:[apikey]@api.softlayer.com/rest/v3/SoftLayer_Product_Package/192/getItemPrices?objectMask=mask[id,locationGroupId,item[id,keyName,description],pricingLocationGroup[locations[id, name, longName]]]

Method: GET

Where:

Package used for NetScaler is = 192.

A price id with a locationGroupId = null is considered as "A standard price" and the API will internally switch the prices for the customer. But it is recommend to execute first the “verifyOrder” in order to see if the wanted order is ok (the fee can vary).

For better information, please review:

http://sldn.softlayer.com/blog/cmporter/Location-based-Pricing-and-You

This is an order request using standard prices:

https://[username]:[apikey]@api.softlayer.com/rest/v3/SoftLayer_Product_Order/verifyOrder.json

Method: POST

Json Payload:
=========================
{
  "parameters": [
    {
      "location": 138124,  // "DALLAS05"
      "packageId": 192,
      "complexType": "SoftLayer_Container_Product_Order_Network_Application_Delivery_Controller",
      "prices": [
        {
          "id": 22315 // "Citrix NetScaler VPX 10.1 10Mbps Standard"
        },
        {
          "id": 17238 // 2 Static Public IP Addresses
        }
      ],
      "quantity": 1
    }
  ]
}

=========================

Note: Remove the comments in order to get the request working.

The above request can work with different datacenters.

Also, we can use price ids that are not standard prices.

For example, we want to get :

  • Item: “Citrix NetScaler VPX 10.1 10Mbps Standard”
  • Location: “Singapore 1”

The item price id that fits well is (SoftLayer_Product_Package::getItemPrices):

 …
    {
    "id": 51173
    "locationGroupId": 509
    "item": {
    "description": "Citrix NetScaler VPX 10.1 10Mbps Standard"
    "id": 4425
    "keyName": "CITRIX_NETSCALER_VPX_10_1_10MBPS_STANDARD"
    }-
    "pricingLocationGroup": {
    "description": "Location Group 5"
    "id": 509
    "locationGroupTypeId": 82
    "name": "Location Group 5"
    "securityLevelId": null
    "locations": [3]
    0:  {
    "id": 352494
    "longName": "Hong Kong 2"
    "name": "hkg02"
    }-
    1:  {
    "id": 449604
    "longName": "Tokyo 2"
    "name": "tok02"
    }-
    2:  {
    "id": 224092
    "longName": "Singapore 1"
    "name": "sng01"
    }-
    -
    }-
    } …

Where: The locations allowed for this price are: Hong kong 2,Tokio 2 and Singapore 1.

Our order will change something like this:

{
  "parameters": [
    {
      "location": 224092, // Singapore 1
      "packageId": 192,
      "complexType": "SoftLayer_Container_Product_Order_Network_Application_Delivery_Controller",
      "prices": [
        {
          "id": 51173
        },
        {
          "id": 17238
        }
      ],
      "quantity": 1
    }
  ]
}

References:

http://sldn.softlayer.com/reference/services/SoftLayer_Product_Package/getItemPrices http://sldn.softlayer.com/reference/services/SoftLayer_Product_Package/getAllObjects http://sldn.softlayer.com/reference/services/SoftLayer_Product_Package http://sldn.softlayer.com/blog/cmporter/Location-based-Pricing-and-You http://sldn.softlayer.com/reference/services/SoftLayer_Location/getDatacenters

I hope this information help you.