'''
List planned events.
The script retrieves all the planned events
'''
import SoftLayer.API
from pprint import pprint as pp
import datetime
# Gets the current date.
now = datetime.datetime.now()
now = now.strftime("%m/%d/%Y")
client = SoftLayer.create_client_from_env()
eventService = client['SoftLayer_Notification_Occurrence_Event']
objectMask = "mask[updateCount, statusCode, notificationOccurrenceEventType[keyName], impactedUsers[user[id], acknowledgedFlag]]"
objectFilterEndDate = {
"endDate": {
"operation": "greaterThanDate",
"options": [{"name": "date", "value": [now]}]},
"notificationOccurrenceEventType": {"keyName": {"operation": "PLANNED"}},
"statusCode": {
"keyName": {
"operation": "in",
"options": [
{"name": "data", "value": ["ACTIVE", "COMPLETED", "PUBLISHED"]}
]
}
}
}
objectFilterNoEndDate = {
"endDate": {"operation": 'is null'},
"notificationOccurrenceEventType": {"keyName": {"operation": "PLANNED"}},
"statusCode": {
"keyName": {
"operation": "in",
"options": [
{"name": "data", "value": ["ACTIVE", "COMPLETED", "PUBLISHED"]}
]
}
}
}
try:
resultEndDate = eventService.getAllObjects(mask=objectMask, filter=objectFilterEndDate)
resultNoEndDate = eventService.getAllObjects(mask=objectMask, filter=objectFilterNoEndDate)
pp(resultEndDate)
pp(resultNoEndDate)
except SoftLayer.SoftLayerAPIError as e:
print("Unable to list the planned events. "
% (e.faultCode, e.faultString))
If this article contains any error, or leaves any of your questions unanswered, please help us out by
opening up a github issue.
Open an issue