python - Softlayer api: How to check that a VSI has been created an cancelation request on "Anniversary Date"? -


for newly created vsi, can cancel on "anniversary date". api billing_item.cancelitem can helps accomplish it. in website/devicelist of softlayer, canceldevice button unable. enter image description here

my question how check vsi has been created cancelation request on "anniversary date" or not api ? ohter word, want api status of vsi has been submit cancelation request or not.

you need see "cancelationdate" property of vsi's billing item if value of property "null" means vsi has not been cancelled. in case vsi has been cancelled in "anniversary date" value of property equals date when machine going canceled

see example below "cancelationdate" property of particular vsi:

import softlayer  username = 'set me' api_key = 'set me'  vsiid = 123  client = softlayer.client(username=username, api_key=api_key) vsiservice = client['softlayer_virtual_guest']  objectmask = "mask[id, cancellationdate]"  try:     result = vsiservice.getbillingitem(mask=objectmask, id=vsiid)     print(result) except softlayer.softlayerapierror e:     print("unable retrieve vsi's billing item. " % (e.faultcode, e.faultstring))     exit(1) 

list vsis , billingitems

import softlayer  username = 'set me' api_key = 'set me'  client = softlayer.client(username=username, api_key=api_key) vsiservice = client['softlayer_account']  objectmask = "mask[id,hostname, billingitem[cancellationdate]]"  try:     result = vsiservice.getvirtualguests(mask=objectmask)     print(result) except softlayer.softlayerapierror e:     print("unable retrieve vsi's billing item. " % (e.faultcode, e.faultstring))     exit(1) 

Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - IE9 error '$'is not defined -