DX Unified Infrastructure Management

  • 1.  RESTful Web Services Alarm Example

    Posted Sep 20, 2016 02:16 PM

    Does anyone have an example of creating an alarm utilizing the RESTful Web Services API?  I just want to verify the entries at the top to get the alarms into UIM.  Not concerned as much about the fields.

    thanks



  • 2.  Re: RESTful Web Services Alarm Example

    Posted Sep 21, 2016 02:07 AM

    HI.
    I'm using Powershell. With this part of the script, it should work:
    ********************************************************************

    ********************************************************************

    $user = "USER"
    $pass= "PASSWORD"
    $uri = "https://my.ca.uim/rest/alarms/createAlarm"

     

    $Headers = @{Authorization = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("$($user):$($pass)"))};

     

    $json = @{
        assignedBy = "";
        assignedTo = "";
        custom1 = "";
        custom2 = "";
        custom3 = "";
        custom4 = "";
        custom5 = "";
        devId = "";
        domain = "";
        hostname = "";
        hub = "";
        level = $Level;
        message = $Message
        metId = "";
        nas = "";
        origin = "";
        prevLevel = "";
        probe = "";
        robot = "";
        severity = $Severity;
        source = $Source;
        subsystem = $Subsys;
        subsystemId = $Subsysid
        suppressionCount = "0";
        suppressionKey = $Suppkey;
        visible = "true"
                } | ConvertTo-Json

     

    Invoke-RestMethod -Uri $uri -Headers $headers -ContentType "application/json" -Method Post -Body $json

    ********************************************************************
    ********************************************************************

    I hope, this is what you looked for.
    Daniel



  • 3.  Re: RESTful Web Services Alarm Example

    Posted Sep 22, 2016 11:44 AM

    Daniel

    thanks for the reply.  The group that is working on using this API is asking if someone has a XML example for creating an alarm.  

     

    thanks again

    Rod



  • 4.  Re: RESTful Web Services Alarm Example
    Best Answer

    Posted Sep 23, 2016 02:26 AM

    Just change the json to xml:

    ********************************************************************
    ********************************************************************

     

    $user = "USER"
    $pass= "PASSWORD"
    $uri = "https://my.ca.uim/rest/alarms/createAlarm"

     

    $Headers = @{Authorization = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("$($user):$($pass)"))};

     

    $json = @"
    <?xml version="1.0" encoding="UTF-8"?>
        <alarm>
        <assignedBy></assignedBy>
        <assignedTo></assignedTo>
        <custom1></custom1>
        <custom2></custom2>
        <custom3></custom3>
        <custom4></custom4>
        <custom5></custom5>
        <devId></devId>
        <domain></domain>
        <hostname></hostname>
        <hub></hub>
        <level>3</level>
        <message>Testmessage</message>
        <metId></metId>
        <nas></nas>
        <origin></origin>
        <prevLevel>0</prevLevel>
        <probe></probe>
        <robot></robot>
        <severity>Minor</severity>
        <source>w2k8r2-x64-lc</source>
        <subsystem>Nimsoft</subsystem>
        <subsystemId>1</subsystemId>
        <suppressionCount>0</suppressionCount>
        <suppressionKey></suppressionKey>
        <visible>true</visible>
      </alarm>
    "@

     

    Invoke-RestMethod -Uri $uri -Headers $headers -ContentType "application/xml" -Method Post -Body $json

     

    ********************************************************************
    ********************************************************************