Search code examples
pythonrestibm-cloudibm-cloud-infrastructure

How to retrieve objects from the sotlayer saved quote using Python API


I'm trying to retrieve the objects/items (server name, host name, domain name, location, etc...) that are stored under the saved quote for a particular Softlayer account. Can someone help how to retrieve the objects within a quote? I could find a REST API (Python) to retrieve quote details (quote ID, status, etc..) but couldn't find a way to fetch objects within a quote.

Thanks!

Best regards,

Khelan Patel


Solution

  • If you are trying to retrieve the same order information structure you sent when placing the quote then you need to use the method getRecalculatedOrderContainer, it should returns the packageId, presetId, location, item prices, etc., but as far as I know, the hostname, domain, sshKeys, provisionScripts, vlans aren't in the quote since those values could change over the time whether the user requires new values before placing the order or to avoid errors from system due to availability of resources like vlans and subnets.

    https://[username]:[apikey]api.softlayer.com/rest/v3/SoftLayer_Billing_Order_Quote/[quoteID]/getRecalculatedOrderContainer
    Method: GET
    

    Now if you want to retrieve orderId, items, etc, then you need to use object-mask feature whether you are using the methods Account::getQuotes or SoftLayer_Billing_Order_Quote::getObject they both returns the datatype SoftLayer_Billing_Order_Quote in a list or as a single object.

    Account::getQuotes

    https://[username]:[apikey]@api.softlayer.com/rest/v3/SoftLayer_Account/getQuotes?objectMask=mask[id,name,order[id,status,items[id,description,domainName,hostName,location]]]
    
    Method: GET
    

    SoftLayer_Billing_Order_Quote::getObject

    https://[username]:[apikey]@api.softlayer.com/rest/v3/SoftLayer_Billing_Order_Quote/[quoteID]/getObject?objectMask=mask[id,name,order[id,status,items[id,description,location]]]
    
    Method: GET
    

    References:

    https://softlayer.github.io/reference/services/SoftLayer_Account/getQuotes/

    https://softlayer.github.io/reference/services/SoftLayer_Billing_Order_Quote/

    https://softlayer.github.io/reference/datatypes/SoftLayer_Billing_Order_Quote/