Create an action and get it afterwards

Table of contents

  1. Description
  2. @Example

Description

In this example you will create an action and get it after its been created.

Note: This can be applied to any other EntityType. You just need to follow the method signatures from here.

@Example

In order for this example to work you need to replace username, password, region and destination with ones specific for you.

import {
    AlertNotificationClient,
    EntityType,
    BasicAuthentication,
    RegionUtils,
    State
} from '@sap_oss/alert-notification-client';

const client = new AlertNotificationClient({
    authentication: new BasicAuthentication({
        username: '<your-technical-client-username>',
        password: '<your-technical-client-password'
    }),
    region: RegionUtils.EU10;
});

client.create(EntityType.Action, {
    name: 'to-my-email',
    type: 'EMAIL',
    description: 'send to my mail',
    state: State.ENABLED,
    properties: {
        destination: '<your-email>@<domain>.com'
    }
})
.then(action => {
    client.get(EntityType.Action, action.name)
        .then(action => console.log(action)) // Action you have created
        .catch(error => console.log(error));
})
.catch(error => console.log(error)); // Shouldn't happen if everything above is setup correctly