0
votes

SoftLayer API: How can I get all invoices for one specific order ?

e.g. I placed three orders: one monthly virutal server with orderId1, one hourly bare metal server with orderId2, one monthly baremetal server with orderId3.

SoftLayer_Billing_Order-> getInitialInvoice() can return me my initial invoice of one order.

SoftLayer_Account->getInvoices can return me all of my invoices. Each SoftLayer_Billing_Invoice includes details of all my three orders.

I'm trying to find the API that can return me invoices for only one order.

e.g get the amount from each billing cycle for a device using the orderId as input parameter

Is there a way to do this?

Thanks.

1

1 Answers

0
votes

This a python script using filters

import SoftLayer
# For nice debug output:
from pprint import pprint as pp

API_USERNAME = 'set me'
API_KEY = 'set me'


filterInstance = {
  'invoices': {
    'items': {
      'billingItem': {
        'orderItem': {
          'order': {
            'id': {
              'operation': 2901586
            }
          }
        }
      }
    }
  }
}

# Creates a new connection to the API service.
client = SoftLayer.Client(
    username=API_USERNAME,
    api_key=API_KEY
)

try:
    result = client['SoftLayer_Account'].getInvoices( filter = filterInstance)
    pp(result)

except SoftLayer.SoftLayerAPIError as e:
    pp('Failed ...  faultCode=%s, faultString=%s'
        % (e.faultCode, e.faultString))

I hope it help you.