0

I want to order File Endurance Storage using REST, before ordering I am trying to verify it using the below API

https://[USERID]:[APIKEY]@api.softlayer.com/rest/v3/SoftLayer_Product_Order/verifyOrder

with payload below. Even though the ID 46296 is a storage space one, it is giving the error:

"Order is missing the following category: Storage Space."

Please tell me if I am doing anything wrong.

{
  "parameters": 
   [
    {
      "packageId": 240,
      "location": 449494,
      "osFormatType": 
      {
        "id": 12,
        "keyName": "LINUX"
      },
      "complexType": "SoftLayer_Container_Product_Order_Network_PerformanceStorage_Iscsi",
      "prices": 
      [
        {
          "id": 45114   
        },
        {
          "id": 46296   
        },
        {
          "id":  45064 
        },

        {
          "id": 45074
        }
      ],
      "quantity": 1
    }
   ]
}

1 Answers1

0

Take a look the category for the price:

Price: 46296 Description: "300 GB Storage Space" Category: "storage_snapshot_space"

It means that this storage item is only available for Snapshot, in this case you need to use a item with "Storage Space" (categoryCode: performance_storage_space) as category, you can try the following REST request to get available Storage Space:

https:/$user:$apiKey@api.softlayer.com/rest/v3/SoftLayer_Product_Package/240/getItemPrices?objectFilter={"itemPrices":{"categories":{"categoryCode":{"operation":"performance_storage_space"}},"locationGroupId":{"operation":"is null"}}}&objectMask=mask[categories]

Method: Get

Replace: $user and $apiKey with your own information.

Here some good forums references related to this:


Updated


If you would like to order a File Storage - Endurance, you need to use this container:

SoftLayer_Container_Product_Order_Network_Storage_Enterprise

Regarding to use: endurance_storage_space for getting the Storage Space for Endurance, that category doesn't exists, that's the reason why are you getting an empty response, you need to use: performance_storage_space which is valid for Endurance and Performance.

Another thing to keep in mind, for File Storage - Endurance, it's not necessary to set "osFormatType"

So, with the priceId: 45124, you template should looks like this (Try this please):

https://$user:$apiKey@api.softlayer.com/rest/v3/SoftLayer_Product_Order/verifyOrder

Method: Post

{
  "parameters": 
   [
    {
      "packageId": 240,
      "location": 449494,
      "complexType": "SoftLayer_Container_Product_Order_Network_Storage_Enterprise",
      "prices": 
      [
        {
          "id": 45114   
        },
        {
          "id": 45124   
        },
        {
          "id":  45064 
        },

        {
          "id": 45074
        }
      ],
      "quantity": 1
    }
   ]
}

Updated 2


How to retrieve Storage through orderId

The SoftLayer_Product_Order::placeOrder method returns an orderId, the Id that you mentioned (You saw in Portal) is the storageId.

Unfortunately, it's not possible that SoftLayer_Product_Order::placeOrder method returns the storageId, due to the storage should be already provisioned in order to have a storageId assigned, but you can get the storageId, username, mountAddress through orderId using the following call:

https://$user:$apiKey@api.softlayer.com/rest/v3/SoftLayer_Account/getNetworkStorage?objectFilter={"networkStorage":{"billingItem":{"orderItem":{"order":{"id":{"operation":6049481}}}}}}&objectMask=mask[fileNetworkMountAddress,allowedHardware,allowedIpAddresses,allowedSubnets,allowedVirtualGuests]

Method: Get

Replace: $user and $apiKey with your own information. Also you need to replace: 6049481 with your orderId returned for placeOrder method

Regarding to call allow storage API, I'm not sure about this, but in the request that I provided before, I added an mask to retrieve allowedVirtualGuests, hardware, ipAddresses and subnets

Or maybe you are referring to:


How to allow access from Virtual Guests through Storage

https://$user:$apiKey@api.softlayer.com/rest/v3/SoftLayer_Network_Storage/7064355/allowAccessFromVirtualGUest

Method: Post

{  
   "parameters":[  
      {  
         "id":29245009
      }
   ]
}

Replace: $user and $apiKey with your own information. Also replace: 7064355 with the storageId and 29245009 with the vsiId

Also, you can allow access for:

Hardware:

Ip Address:

Subnets:

I hope it helps, let me know if you need further assistance or any doubt


Updated 3


How to send ObjectFilter using cURL

To send an objectFilter using curl, it's necessary to encoded it, due to the special characters that it handles, as I see, there are some customers who have success using curl like this way (skipping the special characters), see the forum below:

A workaround that works fine for me and I can recommend, would be to encode the objectFilter and objectMask like this:

curl -k "https://$user:$apiKey@api.softlayer.com/rest/v3/SoftLayer_Account/getNetworkStorage?objectMask=fileNetworkMountAddress%3BallowedHardware%3BallowedIpAddresses%3BallowedSubnets%3BallowedVirtualGuests&objectFilter=%7B%22networkStorage%22%3A%7B%22billingItem%22%3A%7B%22orderItem%22%3A%7B%22order%22%3A%7B%22id%22%3A%7B%22operation%22%3A4353509%7D%7D%7D%7D%7D%7D"

You need to replace in the request: $user and $apiKey with your username and apiKey. Also you need to replace the 4353509 value with the orderId that you get in placeOrder's receipt

Community
  • 1
  • 1
  • Hi Ruber, Thanks for the answer. What I needed is Endurance storage space, so I have given the category code as "endurance_storage_space" instead of what you suggested., "performance_storage_space" but it is giving me an empty array. Isn't what I am doing correct? Please suggest, the package ID I am giving, 240 seems to be corresponding to Endurance Storage only, but I don't know why am I getting empty array. – Krishna Kishore Bonagiri Mar 14 '17 at 09:47
  • Another thing I wanted to mention is, I have tried one price ID, 45124 that I got with "performance_storage_space" but I am getting this error : { "error": "Invalid container specified: SoftLayer_Container_Product_Order_Network_PerformanceStorage_Iscsi. The container specified for the package type (ADDITIONAL_SERVICES_ENTERPRISE_STORAGE) is not compatible.", "code": "SoftLayer_Exception_Order_InvalidContainer" } – Krishna Kishore Bonagiri Mar 14 '17 at 09:56
  • Krishna please review the **Updated** section in my answer, please let me know any doubt or comment – Ruber Cuellar Valenzuela Mar 14 '17 at 14:20
  • Thanks Ruber, it worked. I have another couple of questions: 1) The order id returned doesn't seem to be correct, when I checked in the Softlayer portal. So, won't we get the correct order id? 2) Are the package ids and price ids same across all data centres? – Krishna Kishore Bonagiri Mar 14 '17 at 17:06
  • How did you check the orderId in Portal? (In order to verify this and provide a right answer because **the productOrder method returns a "orderId" which should be the same in Portal**) – Ruber Cuellar Valenzuela Mar 14 '17 at 17:54
  • Regarding to the package and prices, **the package is the same for all datacenters but there are some differences between prices for each datacenter**, for that reason I provided a request to get standard prices (which are valid for any datacenter, in other words, if you will use a standard price for a datacenter which has a different price, the standard price will be accepted but the cost differentiated for that datacenter will be applied), in order to get more information see: [Location-based Pricing and You](http://sldn.softlayer.com/blog/cmporter/location-based-pricing-and-you) – Ruber Cuellar Valenzuela Mar 14 '17 at 17:55
  • If you have any doubt or need further assistance with this, don't hesitate to ask – Ruber Cuellar Valenzuela Mar 14 '17 at 17:56
  • I have gone to the "Storage-->File Storage" page, and clicked on the new devices added, but the ID shown in the link(of the new device) is not same as the order id I have received in the reply for placeOrder call. I think the id in that link is the order id, isn't that? If not, how can I get that? – Krishna Kishore Bonagiri Mar 15 '17 at 02:33
  • And, how can I get the storage device ID from the placeOrder call, that I am supposed to for getting the mount address, or allow storage API? I want to be able to do all this in my code. 1) place order 2) get the storage id, 3) get mount address 4) call allow storage API etc. – Krishna Kishore Bonagiri Mar 15 '17 at 02:35
  • Please see **Updated 2** in my answer, Sorry If I misunderstanding but I'm not sure about **call allow storage API**, would be great if you can clarify this – Ruber Cuellar Valenzuela Mar 15 '17 at 15:07
  • Hi Ruber, my question is basically about how to get the storage device ID that I need use for allow storage API. When I call placeOrder I would be getting the order ID only I think, but from this order ID, how can I get the ID that I need to use in allow storage API? – Krishna Kishore Bonagiri Mar 16 '17 at 00:55
  • Hi Ruber, I just want to remind you of this. Please answer my above question when you get a chance. – Krishna Kishore Bonagiri Mar 16 '17 at 23:42
  • Review the **How to retrieve Storage through orderId** section in muy answer, **Updated 2**, you need to follow that – Ruber Cuellar Valenzuela Mar 17 '17 at 00:09
  • Hi Ruber, the call below worked from Postman, but it is giving error from curl command, can you give a clue as to how to make it work using curl? The error is " curl: (3) [globbing] nested braces not supported at pos 181" . https://$user:$apiKey@api.softlayer.com/rest/v3/SoftLayer_Account/getNetworkStorage?objectFilter={"networkStorage":{"billingItem":{"orderItem":{"order":{"id":{"operation":6049481}}}}}}&objectMask=mask[fileNetworkMountAddress,allowedHardware,allowedIpAddresses,allowedSubnets,allowedVirtualGuests] – Krishna Kishore Bonagiri Mar 17 '17 at 15:11
  • See the **Updated 3** in my answer please – Ruber Cuellar Valenzuela Mar 17 '17 at 17:41