Search code examples
ibm-cloud-infrastructure

SoftLayer Account not considering the Object Mask


Problem: I'm trying to hit the API and use an Object Mask for SoftLayer_Account#getVirtualGuests, but it seems to be ignored.

What I've tried:

Calling SoftLayer_Virtual_Guest.getObject with header

<SoftLayer_Virtual_GuestObjectMask>
  <mask>
    <datacenter xsi:nil="true" />
    <bandwidthAllotmentDetail><allocation xsi:nil="true" /></bandwidthAllotmentDetail>
  </mask>
</SoftLayer_Virtual_GuestObjectMask>

Works perfectly, but when I call SoftLayer_Account.getVirtualGuests with header

<SoftLayer_AccountObjectMask>
  <mask>
    <datacenter xsi:nil="true" />
    <bandwidthAllotmentDetail><allocation xsi:nil="true" /></bandwidthAllotmentDetail>
  </mask>
</SoftLayer_AccountObjectMask>

it doesn't work, as I've seen on https://sldn.softlayer.com/article/object-masks article, when calling SoftLayer_Account::getHardware you need to set the root property for a particular type, but according to the example I can't figure out how to call using SOAP.

If an example could be provided on how to use Object Mask and Object Filter for SoftLayer_Account.getVirtualGuests I can handle on my side.

Thank you


Solution

  • Please, try the following example using SOAP request:

    <soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v3="http://api.service.softlayer.com/soap/v3/">
      <soapenv:Header>
        <authenticate xsi:type="v3:authenticate">
          <username xsi:type="xsd:string">?</username>
          <apiKey xsi:type="xsd:string">?</apiKey>
        </authenticate>
        <v3:SoftLayer_ObjectMask xsi:type="v3:SoftLayer_ObjectMask">
          <mask xsi:type="xsd:string">mask[id,datacenter,bandwidthAllotmentDetail]</mask>
        </v3:SoftLayer_ObjectMask>
        <SoftLayer_AccountObjectFilter xsi:type="v3:SoftLayer_AccountObjectFilter"/>
        <SoftLayer_AccountObjectMask xsi:type="v3:SoftLayer_AccountObjectMask">
          <mask xsi:type="v3:SoftLayer_Account"/>
        </SoftLayer_AccountObjectMask>
      </soapenv:Header>
      <soapenv:Body>
        <v3:getVirtualGuests soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
      </soapenv:Body>
    </soapenv:Envelope>
    

    If you want to combine object Masks and object Filters, please see:

    <soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v3="http://api.service.softlayer.com/soap/v3/">
      <soapenv:Header>
        <authenticate xsi:type="v3:authenticate">
          <username xsi:type="xsd:string">?</username>
          <apiKey xsi:type="xsd:string">?</apiKey>
        </authenticate>
        <v3:SoftLayer_ObjectMask xsi:type="v3:SoftLayer_ObjectMask">
          <mask xsi:type="xsd:string">filteredMask[id,datacenter,bandwidthAllotmentDetail]</mask>
        </v3:SoftLayer_ObjectMask>
        <v3:SoftLayer_AccountObjectFilter xsi:type="v3:SoftLayer_AccountObjectFilter">
          <virtualGuests>
            <datacenter>
              <name>
                <operation>dal06</operation>
              </name>
            </datacenter>
          </virtualGuests>
        </v3:SoftLayer_AccountObjectFilter>
        <SoftLayer_AccountObjectMask xsi:type="v3:SoftLayer_AccountObjectMask">
          <mask xsi:type="v3:SoftLayer_Account"/>    
        </SoftLayer_AccountObjectMask>
      </soapenv:Header>
      <soapenv:Body>
        <v3:getVirtualGuests soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
      </soapenv:Body>
    </soapenv:Envelope>