Configuring a blackout event with REST API

You can use the blackout RESTful API for retrieving the blackout status and performing or releasing a blackout event for a connection profile.

Procedure

  1. From the console, click the APIs icon or go to http[s]://<server>/dbapi/api/index_enterprise.html.
    The REST API document displays.
  2. Browse the API document. Choose the API you want to use and refer to the example in the right side pane.
  3. To view the definition of Retrieve blackout status API, go to Connection Profile > Retrieve blackout status or go to <http://<server>>/dbapi/api/index_enterprise.html#tag/Connection-profile or <http://<server>>/dbapi/api/index_enterprise.html#tag/Connection-Profile.
  4. To enable or disable blackout for a connection , go to Connection Profile > Perform or release blackout or go to http://<server>/dbapi/api/index_enterprise.html#operation/BlackoutDBProfile.
  5. Call the API and check the response.
  6. To set the blackout status of a connection profile to blackout status, call the following Restful API:
    method: PUT
    end point: /dbprofiles/blackout/{profilename}
    Authorization: <Bearer token>
    payload : {"blackout":"true"}
    To release the blackout status of a connection profile:
    payload : {"blackout":"false"}

Example

To set a blackout event for a Connection Profile, use the following script:
#!/bin/bash

echo -n "Enter the DIC Username: "
read DICUSERID

echo -n "Enter the DIC Password: "
read -s DICPASSWD
echo ""

echo -n "Enter the hostname / ip address for DIC: "
read DICHOST

TOKEN=$(curl --silent --insecure -X POST \
  https://$DICHOST:11081/dbapi/v4/auth/tokens \
  -H 'content-type: application/json' \
  -d '{"userid":"'$DICUSERID'","password":"'$DICPASSWD'"}' \
  | jq -r '.token'
)
#echo $TOKEN

echo -n "Enter the DB Profile name to set blackout status: "
read DBPROFILE_NAME

echo -n "Enter the name of the DB Profile you want to set the blackout status (true/false): "
read BLACKOUT

# Set Blackout for dbprofile
BLACKOUTSTATUS=$(curl --silent --insecure -X PUT \
      https://$DICHOST:11081/dbapi/v4/dbprofiles/blackout/$DBPROFILE_NAME \
        -H 'authorization: Bearer '$TOKEN \
        -H 'content-type: application/json' \
        -d '{"blackout":"'$BLACKOUT'"}'
        )

echo "New Blackout Status is: "
echo $BLACKOUTSTATUS | jq '.'
echo
To get a blackout event for a Connection Profile, use the following script:
#!/bin/bash

echo -n "Enter the DIC Username: "
read DICUSERID

echo -n "Enter the DIC Password: "
read -s DICPASSWD
echo ""

echo -n "Enter the hostname / ip address for DIC: "
read DICHOST

TOKEN=$(curl --silent --insecure -X POST \
  https://$DICHOST:11081/dbapi/v4/auth/tokens \
  -H 'content-type: application/json' \
  -d '{"userid":"'$DICUSERID'","password":"'$DICPASSWD'"}' \
  | jq -r '.token'
)
#echo $TOKEN

echo -n "Enter the name of the DB Profile you want to get the blackout status: "
read DBPROFILE_NAME

# get blackout status for profile
BLACKSTATUS=$(curl --silent --insecure -X GET \
  https://$DICHOST:11081/dbapi/v4/dbprofiles/blackout/$DBPROFILE_NAME \
  -H 'authorization: Bearer '$TOKEN \
  -H 'content-type: application/json' 
)

echo "blackout status result"
echo $BLACKSTATUS | jq '.'
echo
Note: The Blackout feature supports different scheduling options such as specific durations and recurring periods, and it sends notifications through email and SNMP.
To blackout a Connection Profile (blackoutTestConn), use the following script:
curl --location --request PUT 'http://9.30.194.50:11080/dbapi/v4/dbprofiles/blackout/blackoutTestConn' \
--header 'Authorization: Bearer eyJraWQiOiJXVEkxNjAzNjcxMTE3MjkxREc2LTZxVjlkOUN4dVpsVjUzWVhkb0dncGRsSmxjZlRsRldIYXk5ckpYbFBrQm1naWhPZ2c3VjZEczFBdWY2dDQxR0tlSUpEQnErcjg0T0RTSW1jSDVjZm1pTGhlam9rZ2lXMXNVazQtelpmcENRMkROeGV2dk0zQndWQUdyalFhRWpydkw0Sk9uYipnK081bjNLUW1zUGxvYnhBellEd2FaZS1VaytMWmYrS1pnSEp6eVg4aWkrKlJwNlYrVjJxS3cqVnphQm5wM0w5Q1kwYWZHRHVWQUNTd2N6dm1nV0FTbVRqQVNEQUtmbis1TWM5IiwidHlwIjoiSldUIiwiYWxnIjoiUlMyNTYifQ.eyJpc3MiOiJodHRwczovL2xvY2FsaG9zdDoxMTA4MSIsImdlbmVyYXRlVGltZXN0YW1wIjoiMTYwMzY3NjEzMzM5MCIsImV4cCI6MTYwMzcwNDkzMywiZXhwaXJlZFRpbWUiOiIxNjAzNzA0OTMzMzkwIiwidXNlcm5hbWUiOiJhZG1pbjEifQ.alDGEtHSMhJRpP-w6SQrr4SVdP9OPQGkVuLyUA55BxMKVM2qVXhOk-gTiR1eFixTLoIdxsNhFkBBQOSTwVRqyVMgwKhUrOOCnPTDfHTXlFUdTveLHjGflmWB9TYZF2Ie9yw9Fc9w_Ia5mmdO1st6Nom3czFqQIkczLIcrS-qfxK3RE7xsW4nEdfZybYp67rwE5jNZLr6ZSWmr3M5P3oHzsgFHvcem73wmuJs0C27fFeyM5Exf53X7ke69gRHYgIX3aw9iBlDitSYjidfAjhI6Ns7GGlGW2FZYIet5XXE2bvcDwuLV-bflJYeHAM4Ii4xx-EAiNoiZyRq5fMNesFOmA' \
--header 'Content-Type: application/json' \
--data-raw '{"blackout":"true"}'