NotificationHandler

The Notification service provides a toolkit to contact people via email (eventually SMS etc.) to trigger some actions.

The original motivation for this is due to some sites restricting the sending of email but it is useful for e.g. crash reports to get to their destination.

Another use-case is for users to request an email notification for the completion of their jobs. When output data files are uploaded to the Grid, an email could be sent by default with the metadata of the file.

It can also be used to set alarms to be promptly forwarded to those subscribing to them.

class DIRAC.FrameworkSystem.Service.NotificationHandler.NotificationHandler(handlerInitDict, trid)

Bases: DIRAC.Core.DISET.RequestHandler.RequestHandler

__init__(handlerInitDict, trid)

Constructor

Parameters
  • handlerInitDict (dictionary) – Information vars for the service

  • trid (object) – Transport to use

auth_ping = ['all']
auth_refreshConfiguration = ['CSAdministrator']
auth_whoami = ['all']
export_addNotificationForUser(user, message, lifetime=604800, deferToMail=True)

Create a group of users to be used as an assignee for an alarm

classmethod export_deleteAlarmsByAlarmId(alarmsIdList)

Delete alarms by alarmId

classmethod export_deleteAlarmsByAlarmKey(alarmsKeyList)

Delete alarms by alarmId

classmethod export_deleteAssigneeGroup(groupName)

Delete an assignee group

static export_echo(data)

This method is used for testing performance of the service

Parameters

data (str) – data to be sent back to the caller

Returns

S_OK, Value is the input data

classmethod export_getAlarmInfo(alarmId)

Get the extended info of an alarm

classmethod export_getAlarms(selectDict, sortList, startItem, maxItems)

Select existing alarms suitable for the Web monitoring

classmethod export_getAssigneeGroups()

Get all assignee groups and the users that belong to them

export_getAssigneeGroupsForUser(user)

Get all assignee groups and the users that belong to them

export_getNotifications(selectDict, sortList, startItem, maxItems)

Get all assignee groups and the users that belong to them

classmethod export_getUsersInAssigneeGroup(groupName)

Get users in assignee group

export_markNotificationsAsNotRead(user, notIds)

Delete an assignee group

export_markNotificationsAsRead(user, notIds)

Delete an assignee group

export_newAlarm(alarmDefinition)

Set a new alarm in the Notification database

export_ping()
static export_refreshConfiguration(fromMaster)

Force refreshing the configuration data

Parameters

fromMaster (bool) – flag to refresh from the master configuration service

export_removeNotificationsForUser(user, notIds)

Get users in assignee group

export_sendMail(address, subject, body, fromAddress, avoidSpam=False)

Send an email with supplied body to the specified address using the Mail utility.

Parameters
  • address (six.string_types) – recipient addresses

  • subject (six.string_types) – subject of letter

  • body (six.string_types) – body of letter

  • fromAddress (six.string_types) – sender address, if None, will be used default from CS

  • avoidSpam (bool) – Deprecated

Returns

S_OK(six.string_types)/S_ERROR() – six.string_types is status message

export_sendSMS(userName, body, fromAddress)

Send an SMS with supplied body to the specified DIRAC user using the Mail utility via an SMS switch.

Parameters
  • userName (six.string_types) – user name

  • body (six.string_types) – message

  • fromAddress (six.string_types) – sender address

Returns

S_OK()/S_ERROR()

classmethod export_setAssigneeGroup(groupName, userList)

Create a group of users to be used as an assignee for an alarm

export_updateAlarm(updateDefinition)

update an existing alarm in the Notification database

export_whoami()

A simple whoami, returns all credential dictionary, except certificate chain object.

classmethod getCSOption(optionName, defaultValue=False)

Get an option from the CS section of the services

Returns

Value for serviceSection/optionName in the CS being defaultValue the default

getRemoteAddress()

Get the address of the remote peer.

Returns

Address of remote peer.

getRemoteCredentials()

Get the credentials of the remote peer.

Returns

Credentials dictionary of remote peer.

initialize()

Initialize this instance of the handler (to be overwritten)

classmethod initializeHandler(serviceInfo)

Handler initialization

srv_disconnect(trid=None)
classmethod srv_disconnectClient(trid)
srv_getActionTuple()
classmethod srv_getCSOption(optionName, defaultValue=False)

Get an option from the CS section of the services

Returns

Value for serviceSection/optionName in the CS being defaultValue the default

srv_getClientSetup()
srv_getClientVO()
srv_getClientVersion()
srv_getFormattedRemoteCredentials()
classmethod srv_getMonitor()
srv_getRemoteAddress()

Get the address of the remote peer.

Returns

Address of remote peer.

srv_getRemoteCredentials()

Get the credentials of the remote peer.

Returns

Credentials dictionary of remote peer.

classmethod srv_getServiceName()
srv_getTransportID()
classmethod srv_getURL()
classmethod srv_msgCreate(msgName)
srv_msgReply(msgObj)
classmethod srv_msgSend(trid, msgObj)
transfer_bulkFromClient(bulkId, token, bulkSize, fileHelper)
transfer_bulkToClient(bulkId, token, fileHelper)
transfer_fromClient(fileId, token, fileSize, fileHelper)
transfer_listBulk(bulkId, token, fileHelper)
transfer_toClient(fileId, token, fileHelper)
types_addNotificationForUser = [(<class 'str'>,), (<class 'str'>,)]
types_deleteAlarmsByAlarmId = [(<class 'list'>, <class 'int'>)]
types_deleteAlarmsByAlarmKey = [((<class 'str'>,), <class 'list'>)]
types_deleteAssigneeGroup = [(<class 'str'>,)]
types_echo = [(<class 'str'>,)]
types_getAlarmInfo = [(<class 'int'>,)]
types_getAlarms = [<class 'dict'>, <class 'list'>, <class 'int'>, <class 'int'>]
types_getAssigneeGroups = []
types_getAssigneeGroupsForUser = [(<class 'str'>,)]
types_getNotifications = [<class 'dict'>, <class 'list'>, <class 'int'>, <class 'int'>]
types_getUsersInAssigneeGroup = [(<class 'str'>,)]
types_markNotificationsAsNotRead = [(<class 'str'>,), <class 'list'>]
types_markNotificationsAsRead = [(<class 'str'>,), <class 'list'>]
types_newAlarm = [<class 'dict'>]
types_ping = []
types_refreshConfiguration = [<class 'bool'>]
types_removeNotificationsForUser = [(<class 'str'>,), <class 'list'>]
types_sendMail = [(<class 'str'>,), (<class 'str'>,), (<class 'str'>,), (<class 'str'>,), <class 'bool'>]
types_sendSMS = [(<class 'str'>,), (<class 'str'>,), (<class 'str'>,)]
types_setAssigneeGroup = [(<class 'str'>,), <class 'list'>]
types_updateAlarm = [<class 'dict'>]
types_whoami = []