Providing you are a LUSID user with sufficient access control permissions, you can create a notification to send to Amazon SQS when an event you have subscribed to occurs.
For example, you could queue a SQS message when the LUSID PortfolioCreated event occurs.
Using the Notification REST API
Currently, you can create one notification per API call. Note you must have already subscribed to the event you want to attach the Amazon SQS notification to.
Before you can create a notification, you must perform a one-time setup of your AWS credentials in the LUSID Configuration Store. You need to create a configuration set containing the following:
A Key of
apiKeywith a Value containing your AWS access key ID.A Key of
apiSecretwith a Value containing your AWS secret access key.A Key of
queueUrlwith a Value containing your SQS queue URL. See how to upload credentials to the Configuration Store.
Call the CreateNotification API for your LUSID domain, passing in your API access token and:
The
scopeandcodeof the subscription to attach it to.A unique
notificationId.A
displayNameand, optionally,description.A
notificationTypecontaining:A
TypeofAmazonSqs.A
Bodycontaining the notification message. You can use attributes of the subscribed event in mustache templates to make the text more meaningful.An
ApiKeyRefcontaining the reference toapiKeyin the configuration set created earlier. For example, if you created a shared configuration set with scopeAWSand codeSQS, you might enterconfig://shared/AWS/SQS/apiKey.An
ApiSecretRefcontaining the reference toapiSecretin the configuration set created earlier. For example, if you created a shared configuration set with scopeAWSand codeSQS, you might enterconfig://shared/AWS/SQS/apiSecret.An
QueueUrlRefcontaining the reference toqueueUrlin the configuration set created earlier. For example, if you created a shared configuration set with scopeAWSand codeSQS, you might enterconfig://shared/AWS/SQS/queueUrl.
For example, to attach an Amazon SQS notification to a subscription with the scope PortfolioEvents and code PortfolioCreated you might send the following:
curl -X POST "https://<your-domain>.lusid.com/notification/api/subscriptions/PortfolioEvents/PortfolioCreated/notifications"
-H "Authorization: Bearer <your-API-access-token>"
-H "Content-Type: application/json"
-d '{
"notificationId": "SqsNotification1",
"displayName": "AwsSqsNotification",
"description": "Notification for AWS SQS",
"notificationType": {
"Type": "AmazonSqs",
"Body": "Portfolio created in scope {{Body.portfolioScope}} with code {{Body.portfolioCode}}",
"ApiKeyRef": "config://shared/AWS/SQS/apiKey",
"ApiSecretRef": "config://shared/AWS/SQS/apiSecret",
"QueueUrlRef": "config://shared/AWS/SQS/queueUrl"
}
}'The response is as follows. Note you can use the notificationId to reference the notification again in subsequent API calls:
{
"notificationId": "SqsNotification1",
"displayName": "AwsSqsNotification",
"description": "Notification for AWS SQS",
"notificationType": {
"type": "AmazonSqs",
"body": "Portfolio created in scope {{Body.portfolioScope}} with code {{Body.portfolioCode}}",
"apiKeyRef": "config://shared/AWS/SQS/apiKey",
"apiSecretRef": "config://shared/AWS/SQS/apiSecret",
"queueUrlRef": "config://shared/AWS/SQS/queueUrl"
},
"createdAt": "2023-08-03T09:41:52.6175307+00:00",
"userIdCreated": "00uji4twb3jDcHGjN2p8",
"modifiedAt": "2023-08-03T09:41:52.6175307+00:00",
"userIdModified": "00uji4twb3jDcHGjN2p8",
"href": "https://<your-domain>.lusid.com/notification/api/subscriptions/PortfolioEvents/PortfolioCreated/notifications/SqsNotification1"
}