How to customize my request notification settings

If you have more than a 100 virtual machines hosted in our environment and need to update all at once, let's say by adding a custom note, you'll receive 1 email/message per request submission (PUT) and another email/message per request completion. This is 200 emails in your inbox. However, you can modify certain user settings via the /v2/user resource, and one of those is to decide what kind of emails to receive.

If you do not want to receive request notifications, you will need to update the notification setting none to true or if you want to receive only notification in case of an error, set the error setting to true. In this tutorial, we'll set request notifications allowed if an error happens, but this process can be applied to any of the options (all, completion, error, none, submission).

Prerequisites

  1. Valid access token

Step-by-step guide

  1. Request notification settings are available via the /v2/user/setting/notification/request resource and are displayed by making a GET request to the mentioned URI as follows:

    http https://vss-api.eis.utoronto.ca/v2/user/setting/notification/request "Authorization: Bearer $TK"
    curl -H "Authorization: Bearer $TK" -X GET https://vss-api.eis.utoronto.ca/v2/user/setting/notification/request
    Response Body
    {
        "_links": {
            "notification": "https://vss-api.eis.utoronto.ca/v2/user/setting/notification",
            "self": "https://vss-api.eis.utoronto.ca/v2/user/setting/notification/request"
        },
        "data": {
            "all": true,
            "completion": false,
            "error": false,
            "none": false,
            "submission": false
        },
        "meta": {
            "count": 5,
            "time": "0.00190s",
            "user": "jm"
        }
    }
  2. Updating request notification settings can be done by making a PUT request to /v2/user/setting/notification/request adding as payload the following JSON object:

    {"attribute": <attribute>
     "value": <boolean>}
  3. In this case, updating the request notifications to receive only requests with error status requires to set first all=false and then error=true as follows:

    # HTTPie
    http PUT https://vss-api.eis.utoronto.ca/v2/user/setting/notification/request "Authorization: Bearer $TK" attribute=all value:=false
    http PUT https://vss-api.eis.utoronto.ca/v2/user/setting/notification/request "Authorization: Bearer $TK" attribute=error value:=true
     
    # CURL
    curl -H "Authorization: Bearer $TK" -X POST -H "Content-Type: application/json" https://vss-api.eis.utoronto.ca/v2/user/setting/notification/request -d '{"attribute": "all", "value": false}'
    curl -H "Authorization: Bearer $TK" -X POST -H "Content-Type: application/json" https://vss-api.eis.utoronto.ca/v2/user/setting/notification/request -d '{"attribute": "error", "value": true}'

    An empty response with status 200 will be returned if the operation was successful

  4. To validate changes were successfully applied:

    http https://vss-api.eis.utoronto.ca/v2/user/setting/notification/request "Authorization: Bearer $TK"
    curl -H "Authorization: Bearer $TK" -X GET https://vss-api.eis.utoronto.ca/v2/user/setting/notification/request
    Response Body
    {
        "_links": {
            "notification": "https://vss-api.eis.utoronto.ca/v2/user/setting/notification",
            "self": "https://vss-api.eis.utoronto.ca/v2/user/setting/notification/request"
        },
        "data": {
            "all": false,
            "completion": false,
            "error": true,
            "none": false,
            "submission": false
        },
        "meta": {
            "count": 5,
            "time": "0.00188s",
            "user": "jm"
        }
    }