Christian Will
Christian Will

Reputation: 1695

How can I apply a filter using Softlayer's ticket API?

I tried to receive a full list of tickets with the following code snipped:

client = SoftLayer.create_client_from_env(username="xxx", api_key="xxx")
client['Account'].getTickets(mask='id')

Even so I mask the output to only return 'id' it fails in one of my Softlayer accounts with SoftLayerAPIError: SoftLayerAPIError(SOAP-ENV:Server): Internal Error. I have over 1.4 millions tickets (including closed) in that account.

Next I tried to apply a filter:

tickets = client.call('Account', 'getTickets',
                      filter={'id': { 'operation': 48076123 }}
# or
tickets = client.call('Account', 'getTickets',
                      filter={'id': { 'operation': '>48076123' }}

But it always returns the complete list of tickets and fails the same way on the accounts with a high number of tickets. I need to create a history of all tickets.

Is there are way to limit the query or create a window over the results? Any help is appreciated.

Upvotes: 2

Views: 168

Answers (1)

your objectMask should be

client['Account'].getTickets(mask="mask[id]")

your fitler should be:

tickets = client.call('Account', 'getTickets', filter={"tickets":{"id":{"operation":48076123}}}

and also you can limmit the result using the pagination

client.call('Account', 'getTickets', limit=10, offset=0)

see https://github.com/softlayer/softlayer-python/blob/master/docs/api/client.rst for more information

Upvotes: 2

Related Questions