Using Object Masks in the SoftLayer API
Most of the data types modeled in the SoftLayer API contain relational properties that tie one data type to another. For instance, a SoftLayer_Account has links to its domains, support tickets, hardware, users, and much more. By default, calling the SoftLayer_Account service's getObject method won't retrieve relational and count properties. In order to retrieve this information, you would have to call getUsers, getTickets, and other methods. Making multiple API calls can significantly slow down an API-based application's response time, especially if the application retrieves a large amount of information at once. An alternative to making multiple method calls is to define an object mask in your method's header to retrieve all the information you need with a single call. Defining an object mask can result in a very noticeable increase in overall API responsiveness. While object masks are optional, they are the only way to retrieve a data type's count properties.
Structure
An object mask is an object of the type
Creating an Object Mask
Languages that support SOAP usually have built-in mechanisms to add headers to a SOAP call (i.e. the SoapHeader PHP class). When building manual SOAP calls, format your request XML similar to the following (assuming you're retrieving the structure above from the SoftLayer_Account service):<SoftLayer_AccountObjectMask xsi:type="v3:SoftLayer_AccountObjectMask"> <mask xsi:type="slt:SoftLayer_Account" xmlns:slt="http://api.service.softlayer.com/soap/v3/SLTypes/"> <domains> <resourceRecords /> </domains> <openTickets> <assignedUser /> <attachedHardware /> <updates /> </openTickets> <userCount /> </mask> </SoftLayer_AccountObjectMask>
<struct> <member> <name>SoftLayer_AccountObjectMask</name> <value> <struct> <member> <name>mask</name> <value> <struct> <member> <name>domains</name> <value> <struct> <member> <name>resourceRecords</name> <value> <array> <data/> </array> </value> </member> </struct> </value> </member> <member> <name>openTickets</name> <value> <struct> <member> <name>assignedUser</name> <value> <array> <data/> </array> </value> </member> <member> <name>attachedHardware</name> <value> <array> <data/> </array> </value> </member> <member> <name>updates</name> <value> <array> <data/> </array> </value> </member> </struct> </value> </member> <member> <name>userCount</name> <value> <array> <data/> </array> </value> </member> </struct> </value> </member> </struct> </value> </member> </struct>