DX Unified Infrastructure Management

  • 1.  Where can i get help related to REST API?

    Posted Jun 28, 2017 06:15 AM

    Hi,

     

    Where can i get help related to REST API? I'm not getting any help on this from any forum/CA?

     

    CA UIM

     

    Thanks



  • 2.  Re: Where can i get help related to REST API?

    Posted Jun 28, 2017 08:06 AM

    RESTful Web Services - CA Unified Infrastructure Management Probes - CA Technologies Documentation 

     

    If you are using VB, you can send a message with:

     

    Set restReq = CreateObject("MSXML2.ServerXMLHTTP")
    restReq.open "POST", url, false, username, password
    restReq.setRequestHeader "Content-Type", "application/xml"
    restReq.send data

     

    A quick search using Google of "MSXML2.ServerXMLHTTP" will give you loads of examples.

     

    -Gairn



  • 3.  Re: Where can i get help related to REST API?

    Posted Jun 28, 2017 08:43 AM

    Thanks Garin.

    But I'm not finding much details on pulling data's from CA UIM using REST API like, if the Target is something like this "Gi0/0/3.851(GigabitEthernet0/0/3.851)" how should i send the target in the rest call? i tried url encode/decode but nothing works.. also how can i get all the Items under one origin. Also based on User Tags?  like this i have multiple questions but not getting any response.



  • 4.  Re: Where can i get help related to REST API?
    Best Answer

    Posted Jun 28, 2017 10:11 AM

    Hi,

     

    What do you want exactly ? If you are pulling data (basically just dump the http request body to look how you have to play with the JSON or the XML Object).

     

    I think the call references have everything you need : 

    Call Reference - CA Unified Infrastructure Management Probes - CA Technologies Documentation 

     

    And if you want to put data (for callback2 for example), i think you have a JSON model and XML Model (i dont know much for the JSON One). But for XML i already created a JS code to create the XML Objet with an ES6 Map.

     

    class PDS {

        constructor(esMap) {
            this._inner = "";
            esMap != null && esMap.forEach( (v,k) => this.push(k,v) );
        }

        push(key,element) {
            if(key == null || element == null) return;

            if(typeof element === 'string') {
                this._inner+=`<nimString key="${key}">${element}</nimString>`;
            }
            else if(typeof element === 'number') {
                this._inner+=`<nimInt key="${key}">${element}</nimInt>`;
            }
            else if(element instanceof PDS) {
                this._inner+=element.toString(key);
            }
        }

        toString(key) {
            return key != null ? `
    <nimPds key="${key}">${this._inner}</nimPds>` : `<nimPds>${this._inner}</nimPds>`;
        }
    }

    const userId = "fraxken";
    const values = new Map([
        ["check_name","DeltaError"],
        ["description","File system /"],
        ["disk","/dev/root"],
        ["drive","/"],
        ["filesys","/"],
        ["filesystemtype","ext3"],
        ["unit","MB"],
        ["value","244.0"],
        ["value_limit","5"],
    ]);

    const udata = new Map([
        ["level",3],
        ["subsys","1.1.1.1"],
        ["message","DeltaError: Disk usage change on /, changed by 244.0 MB"],
        ["token", "as#system.cdm.disk_usage_changed_by_value"]
    ]);

    const postraw_data = new Map([
        ["tz_offset", 18000],
        ["nimts", Math.floor(Date.now()/1000)],
        ["pri", 3],
        ["subject", "alarm"],
        ["prid", "cdm"],
        ["source", "127.0.0.1"],
        ["robot", "keepcode-xa01"],
        ["domain","AREA51"],
        ["origin","error404"],
        ["user_tag_1", userId],
        ["suppression", "y000000000#disk///delta///"+userId],
        ["supp_key", "disk///delta///"+userId],
        ["dev_id", "DA6BED5555D47C791B670C5A943101A7E"],
        ["met_id", "M34DE72C2F392D29583C18467759199E7"]
    ]);

    udata.set('values', new PDS(values));
    postraw_data.set('udata', new PDS(udata));

    console.log(new PDS(postraw_data).toString());

     

    And the XML Output : 

     

    <nimPds>
        <nimInt key="tz_offset">18000</nimInt>
        <nimInt key="nimts">1498658616</nimInt>
        <nimInt key="pri">3</nimInt>
        <nimString key="subject">alarm</nimString>
        <nimString key="prid">cdm</nimString>
        <nimString key="source">127.0.0.1</nimString>
        <nimString key="robot">keepcode-xa01</nimString>
        <nimString key="domain">AREA51</nimString>
        <nimString key="origin">error404</nimString>
        <nimString key="user_tag_1">fraxken</nimString>
        <nimString key="suppression">y000000000#disk///delta///fraxken</nimString>
        <nimString key="supp_key">disk///delta///fraxken</nimString>
        <nimString key="dev_id">DA6BED5555D47C791B670C5A943101A7E</nimString>
        <nimString key="met_id">M34DE72C2F392D29583C18467759199E7</nimString>
        <nimPds key="udata">
            <nimInt key="level">3</nimInt>
            <nimString key="subsys">1.1.1.1</nimString>
            <nimString key="message">DeltaError: Disk usage change on /, changed by 244.0 MB</nimString>
            <nimString key="token">as#system.cdm.disk_usage_changed_by_value</nimString>
            <nimPds key="values">
                <nimString key="check_name">DeltaError</nimString>
                <nimString key="description">File system /</nimString>
                <nimString key="disk">/dev/root</nimString>
                <nimString key="drive">/</nimString>
                <nimString key="filesys">/</nimString>
                <nimString key="filesystemtype">ext3</nimString>
                <nimString key="unit">MB</nimString>
                <nimString key="value">244.0</nimString>
                <nimString key="value_limit">5</nimString>
            </nimPds>
        </nimPds>
    </nimPds>

     

     

    Best Regards,

    Thomas