6.10 Notification, Notifier

Notification and Notifier definitions and definition examples are shown below. For details of Notification and Notifier, see “Designing notifications”.

The YAML definitions of Notification are as follows.

(Table) Notification definitions

Label Default value Required Description
apiVersion: 1.0 Yes API version
kind: Yes Specify "notification" for Notification.
type: No Only "resource" can be specified for Notification.
name: Yes Internal name of the Notification definition. Specify the directory name for this YAML definition.
label: Yes YAML file display name
includes: No List the related YAML files for use in this YAML file.
- kind: Yes Type of YAML file to be loaded
  name: Yes Internal name of YAML file to be loaded
description: No Detailed description of this YAML file
event: Yes Event conditions for notification
  resource: Yes Event resources
The following can be specified as resources.
  • schedule
  • workitem
  • workflow
  type: Yes Event types
  • update: Specify when the target resource is generated/updated
  • delete: Specify when the target resource is deleted
  • time: Specify when you want to evaluate the target resource periodically
If the event resource is a work item, time cannot be used. In the case of workflow, if you specify a time, the target resource will be an uncompleted workflow.
conditions: No Describe the conditions for notification.
- No If there are multiple conditions, they will be judged using an "or" condition. Conditions for lower levels are judged using an "and" condition.
- resource: Yes Specify the field that judges the condition with the object specified in the event condition (event part) of the notification as the starting point.
In addition, the object field uses the notation .Context for the current value of the data being judged, and .PrevContext for the value before the change.
If the event type (type) is "update", the current value can be obtained with ".Context" and the value before the change can be obtained with ".PrevContext".
If the event type (type) is "delete", the value before deletion can be obtained with ".PrevContext", and ".Context" cannot be used.
Example:
"{{ .GetValue ".Context.workflow.name" }}"
"{{ .GetValue ".PrevContext.status" }}"
  <operator>: Yes Specify the operator and operand of the condition with <key>: <value>.
<key>
Specify the operator. The following types are available.
  • eq, ne (==, !=)
  • gt, ge (>, >=)
  • lt, le (<, <=)
  • in, notIn, wildcard, regex
  • remaining
    Can be specified only when the type is "time". In this case, specify a value between -10080 (7 days later) and 10080 (7 days earlier) as the fraction.
    Specify the date/time field as the resource, and determine whether it is value minutes ago.
<value>
Specify the operand.
Example:
"eq: WorkflowNameAAA"
notifications: Yes List of notification objects to be sent
- message: Yes Notification object message to be sent
title: Yes Message title
It is also possible to embed fields starting from the object specified in the event condition (event part) of the notification. Note that only the current value (.Context) can be used. The value before the change (.PrevContext) cannot be used
Example:
"There is an request for {{ .GetValue ".Context.activity" }}."
body: Yes Body of the message.
It is also possible to embed fields starting from the object specified in the event condition (event part) of the notification.
Example:
"There is an request for {{ .GetValue ".Context.workflow.name" }}."
referTo: No Message reference.
It is also possible to embed fields starting from the object specified in the event condition (event part) of the notification.
When listing the URL for Ops I, check in advance that the user set as the recipient of the notification has access rights for the URL listed.
Example:
URL for Ops I /sys_request/workflow_list/workflow_detail/{{ .GetValue ".Context.workflow.id" }}
severity: Information No Notification severity
The following values can be used.
  • Critical
  • Warning
  • Information
destinations: Yes List of message recipients
The contents of a message object can be sent to multiple recipients.
- type: Yes Recipient type
Select from the following.
  • user (to Ops I user)
  • group (to Ops I group)
  • groupMember (to members of an Ops I group)
  value: Yes Recipient value
It is also possible to embed fields starting from the object specified in the event condition (event part) of the notification. Note that only the current value (.Context) can be used. The value before the change (.PrevContext) cannot be used.
Example:
"{{ .GetValue ".Context.assignedGroup"}}"
  notifiers: No Specify the means of notifying the recipient. Specify the name of the Notifier in an array.
If not specified, only the default system notification is implemented.

The object fields that can be used within the Notification definition are as follows.

(Table) Object fields that can be used in Notification

Object Field Description
workflow createdOn Workflow creation date and time
workflow updatedOn Workflow update date and time
workflow createdBy Workflow creator
workflow id Workflow ID
workflow name Workflow name
workflow schedule Immediate schedule object
workflow Optional Any schedule object that belongs
workflow title Workflow title
workflow status Workflow status
workflow customer Customer
schedule id Schedule ID
schedule workflow Workflow object tied to a schedule
schedule activity Activity tied to a schedule
schedule parent Schedule object of the parent schedule
schedule assignedTo User object of the user to be assigned to
This field must be specified when notifying the agent for each step in the workflow or the agent for a schedule that is not linked to a calendar.
schedule assignedGroup Group object of the group to be assigned to
schedule assignedUsers List of user objects to be assigned
This field must be specified when using the agent for the work item (multiple people can be specified) to send notifications.
If multiple items are specified, use a comma (,) to separate them.
When using in/notIn for the operator, the following evaluation is performed.
  • Whether the value specified in "value" matches/does not match any of the users in assignedUsers
  • Treats the values of "value" as being separated by commas, and checks whether any of the values of "value" match any of the values in assignedUsers
schedule status Schedule status
For the value, see “Detailed API reference information > Standard API functions > Schemas > dtos.ScheduleDTO > status” in the “JP1 Cloud Service/Operations Integration API Reference”.
schedule workflowStatus Status of the workflow activity tied to a schedule
For the value, see “Detailed API reference information > Standard API functions > Schemas > dtos.ScheduleDTO > workflowStatus” in the “JP1 Cloud Service/Operations Integration API Reference”.
schedule plannedStart Planned start date and time of the schedule
schedule plannedEnd Planned end date and time of the schedule
schedule calendar The calendar to which the work items linked to the schedule belong
schedule title Schedule title
schedule scheduleType Schedule type
The following values are set.
  • daily: Recurring work (daily)
  • weekly: Recurring work (weekly)
  • monthly: Recurring work (monthly)
  • yearly: Recurring work (yearly)
  • oneTime: Single work
  • on-demand: Schedule created at the start of a workflow
schedule workitem Related work item objects
schedule canceled Schedule deletion and restoration
schedule changedFromWorkItemDefinition Flag indicating changes since the work item was created
user id User ID
user name Username
user email User e-mail address
user number Phone number
group id Group ID
group name Group name
group email Group e-mail address
calendar id Calendar ID
calendar name Calendar name
calendar assignedGroups List of group objects to be assigned
If multiple items are specified, use a comma (,) to separate them.
When using in/notIn for the operator, the following evaluation is performed.
  • Whether the value specified in "value" matches/does not match any of the groups in assignedGroups
  • Treats the values of "value" as being separated by commas, and checks whether any of the values of "value" match any of the values in assignedGroups
workitem id Work item ID
workitem calendar Calendar object
workitem name Work item name
workitem createdOn Work item creation date and time
workitem createdBy Work item creator
workitem updatedOn Work item update date and time
workitem updatedBy Work item updater
workitem workflowExecUser Workflow executor
workitem assignedUsers List of user objects to be assigned
This field must be specified when using the agent for the work item (multiple people can be specified) to send notifications.
If multiple items are specified, use a comma (,) to separate them.
When using in/notIn for the operator, the following evaluation is performed.
  • Whether the value specified in "value" matches/does not match any of the users in assignedUsers
  • Treats the values of "value" as being separated by commas, and checks whether any of the values of "value" match any of the values in assignedUsers
workitem assignedGroup Group object of the group to be assigned to
workitem plannedStart Planned start time of the work item
workitem duration Planned duration of work item (minutes)
workitem scheduleType Schedule type
The following values are set.
  • daily: Recurring work (daily)
  • weekly: Recurring work (weekly)
  • monthly: Recurring work (monthly)
  • yearly: Recurring work (yearly)
  • oneTime: Single work
workitem recurrenceNum Number of work item repetitions
workitem startDate Start date of the work item
workitem endDate End date of the work item

The YAML definitions of Notifier are as follows.

(Table) Notifier definitions

Label Default value Required Description
apiVersion: 1.0 Yes API version
kind: Yes Specify "notifier" for Notifier
type: No Only "container" can be specified for Notifier
name: Yes Internal name of the Notifier definition. Specify the directory name for this YAML file.
label: Yes YAML file display name
includes: No List the related YAML files for use in this YAML file.
- kind: Yes Type of YAML file to be loaded
  name: Yes Internal name of YAML file to be loaded
description: No Detailed description of this YAML file
protocol: Yes Protocol used for the notification method
The following protocols can be used.
  • smtp
property: Yes smtp properties
credential: Yes Authentication information for the SMTP server.
Fixed "default"
url: Yes SMTP server address
Fixed "email-smtp.ap-northeast-1.amazonaws.com"
port: Yes SMTP server port.
Fixed "587"
to: Yes Specify the address to which the e-mail is to be sent. The specified email address will be specified in the Bcc header of the notification email and sent.
It is also possible to embed fields of objects that can be used in Notifier, using the current value (.Context) as a starting point. See "(Table) Object fields that can be used in Notifier" for object fields that can be used in Notifier.
Example:
{{ .Context.receiver.email }}
from: No The SMTP sender address.
Fixed "noreply.opsi@itg.hitachi.co.jp"
subject: No The e-mail title.
It is also possible to embed fields of objects that can be used in Notifier, using the current value (.Context) as a starting point. See "(Table) Object fields that can be used in Notifier" for object fields that can be used in Notifier.
Example:
{{ .Context.message.title }}
message: No The e-mail body.
It is also possible to embed fields of objects that can be used in Notifier, using the current value (.Context) as a starting point. See "(Table) Object fields that can be used in Notifier" for object fields that can be used in Notifier.
Example:
{{ .Context.message.body }}
conditions: No If the conditions of this definition are met, notifications will be sent using this Notifier.
- No If there are multiple conditions, they will be judged using an "or" condition. Conditions for lower levels are judged using an "and" condition.
- resource: Yes Prerequisites
It is also possible to embed fields of objects that can be used in Notifier, using the current value (.Context) as a starting point. See "(Table) Object fields that can be used in Notifier" for object fields that can be used in Notifier.
Example:
{{ .Context.receiver.email }}
  <operator>: Yes Specify the operator and operand of the condition with <key>: <value>.
<key>
Specify the operator. The following types are available.
  • eq, ne (==, !=)
  • gt, ge (>, >=)
  • lt, le (<, <=)
  • in, notIn, wildcard, regex
<value>
  Specify the operand.
  Example:
  regex: ^∗@hitachi.com$

The object fields that can be used within the Notifier definition are as follows.

(Table) Object fields that can be used in Notifier

Object Field Description
message title Message title
message severity Message severity
message body Message content
message referTo Message reference
receiver email Destination e-mail address

<Definition example> Notification

apiVersion: 1.0
kind: notification

## Meta data
type: resource
name: lend_reject_notification
label: lend_reject_notification
description: A YAML definition that sends a rejection notice to the requester.

## Notification contents
event:
  resource: schedule
  type: update
conditions:
  -
    - resource: '{{ .GetValue ".Context.activity" }}'
      eq: create_vm_wf_04

    - resource: '{{ .GetValue ".Context.workflowStatus" }}'
      eq: pending

    - resource: '{{ .GetValue ".PrevContext.workflowStatus" }}'
      eq: succeeded

notifications:
  - message:
      title: VM lending rejection notice
      body: |
             A notice of rejection for the VM lending has been received. Please check the information provided and take the appropriate action.
              Date and time of application:{{ .GetValue ".Context.createdOn" }}
              Requester:{{ .GetValue ".Context.createdBy" }}
      referTo: URL of Ops I/sys_request/workflow_list/workflow_detail/{{ .GetValue ".Context.workflow" }}
      severity: Information
    destinations:
      - type: user
        value: '{{ .GetValue ".Context.createdBy" }}'

<Definition example> Notifier

apiVersion: 1.0
kind: notifier

## Meta data
type: resource
name: email
label: Normal case
description: Normal case

protocol: smtp
property:
  credential: default
  url: email-smtp.ap-northeast-1.amazonaws.com
  port: 587
  to: '{{ .Context.receiver.email }}'
  from: noreply.opsi@itg.hitachi.co.jp
  subject: '{{ .Context.message.title }}'
  message: |
    {{ .Context.message.body }}