Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Navigation
Guide That Contains This Content
[+] Expand All
[-] Collapse All

    Creating an Advanced Incident Filter

    Creating an advanced incident filter involves the following APIs:

    Encoding PERL File of an Incident Filter

    Use this API to encode Perl file containing the filter logic of an advanced incident filter in Junos Space Service Now.

    URI

    https://[host]/api/juniper/servicenow/incident-filter-management/encodePerlFile -F "fileName=@filename.pl" (HTTP method = POST)

    URI Parameters

    Element

    Type

    Required

    Description

    filename

    String

    Yes

    Name of the Perl script file (*.pl)

    Consumes

    None

    Request Elements

    None

    Produces

    multipart/form-data

    Sample Output

    XkgJHNoZWxs ... IAkKfQoKCg==

    Creating the Advanced Incident Filter

    Use the createAdvancedFilter API to create the advanced incident filter. You must input the encoded perl script obtained by using the Encoding PERL File of an Incident Filter API.

    URI

    https://[host]/api/juniper/servicenow/incident-filter-management/createAdvancedFilter (HTTP method = POST)

    URI Parameters

    None

    Consumes

    • application/vnd.juniper.servicenow.incident-filter-management.filter +xml;version=1;charset=UTF-8
    • application/vnd.juniper.servicenow.incident-filter-management.filter +json;version=1;charset=UTF-8

    Request Elements

    Element

    Type

    Description

    name

    String

    Name of the advanced incident filter

    action

    String

    Action to be taken on JMBs that match the filter condition and terms

    Possible values:

    • Create Incident
    • Do Not Create Incident

    advancedFilterAttribute

    advancedFilterAttribute

    Defines the advanced filter terms and conditions

    perlFileContent

    String

    Perl script providing the logic for filtering JMBs in encoded form

    You can obtain the encoded Perl script by using the Encode Perl script API

    perlFileName

    String

    Name of the Perl file

    Produces

    • application/vnd.juniper.servicenow.incident-filter-management.filter+xml;version=1
    • application/vnd.juniper.servicenow.incident-filter-management.filter+json;version=1

    Response Elements

    Element

    Type

    Description

    uri

    String

    URI of the advanced filter

    id

    Integer

    ID of the advanced filter

    name

    String

    Name of the advanced filter

    type

    String

    Type of advanced filter

    Possible value—Advanced

    action

    String

    Action to be taken on JMBs that match the filter condition and terms

    Possible values:

    • Create Incident
    • Do Not Create Incident

    createdBy

    String

    User who created the filter

    priority

    Integer

    Order in which the filter is applied to a JMB

    status

    String

    Status of the filter

    Possible values:

    • Enabled—Filter can be applied to a JMB
    • Disabled—Filter cannot be applied to a JMB

    advancedFilterAttribute

    advancedFilterAttribute

    Defines terms and conditions of the advanced filter

    inputParams

    String

    Attributes used in the filter for filtering a JMB

    perlFileContent

    String

    Encoded Perl script providing the logic for filtering JMBs

    You can decode the Perl script by using the decodePerlFile API

    perlFileName

    String

    Name of the Perl file

    method

    String

    Methods applicable to the advanced filter

    Sample Input

    Sample XML Input

    <filter>
    <name>adv_filter_1_REST</name>
    <action>DoNotCreateIncident</action>
    <advancedFilterAttribute>
    <perlFileContent>IyEvdXNy ... 7Cn0KCg==</perlFileContent>
    <perlFileName>test.pl</perlFileName>
    </advancedFilterAttribute>
    </filter>
    

    Sample JSON Input

    {
       "filter": {
          "name": "adv_filter_1_REST",
          "action": "DoNotCreateIncident",
          "advancedFilterAttribute": {
             "perlFileContent": "IyEvdXNy ... 7Cn0KCg==" ,
             "perlFileName": "test.pl"
          }
       }
    }
    

    Sample Output

    Sample XML Output

    <?xml version="1.0" encoding="UTF-8"?>
    <filter uri="/api/juniper/servicenow/incident-filter-management/createAdvancedFilter">
       <id>6815744</id>
       <name>adv_filter_1_REST</name>
       <type>Advanced</type>
       <action>DoNotCreateIncident</action>
       <createdBy>super</createdBy>
       <priority>5</priority>
       <status>Enabled</status>
       <advancedFilterAttribute>
          <inputParams>eventType:deviceHostName:problemSynopsis:problemDescription:osPlatform: entity:junosVersion:eventTime</inputParams>
          <perlFileContent>IyEvdXNy ... 7Cn0KCg==</perlFileContent>
          <perlFileName>test.pl</perlFileName>
       </advancedFilterAttribute>
       <method href="/api/juniper/servicenow/incident-filter-management/incidentFilters/6815744/modify" />
       <method href="/api/juniper/servicenow/incident-filter-management/incidentFilters/6815744/enable" />
       <method href="/api/juniper/servicenow/incident-filter-management/incidentFilters/6815744/disable" />
    </filter>
    

    Sample JSON Output

    {
      "filter": {
        "@uri": "/api/juniper/servicenow/incident-filter-management/createAdvancedFilter",
        "id": 705646,
        "domainId": 2,
        "name": "adv_filter_1_REST",
        "type": "Advanced",
        "action": "DoNotCreateIncident",
        "createdBy": "super",
        "priority": 4,
        "status": "Enabled",
        "advancedFilterAttribute": {
          "inputParams": "eventType:deviceHostName:problemSynopsis:problemDescription:osPlatform: entity:junosVersion:eventTime:deviceId",
          "perlFileContent": "IyEvdXNy ... 7Cn0KCg==",
          "perlFileName": "test.pl"
        },
        "method": [
          {
            "@href": "/api/juniper/servicenow/incident-filter-management/incidentFilters/705646/modify"
          },
          {
            "@href": "/api/juniper/servicenow/incident-filter-management/incidentFilters/705646/enable"
          },
          {
            "@href": "/api/juniper/servicenow/incident-filter-management/incidentFilters/705646/disable"
          }
        ]
      }
    }
    

    Decoding Perl File

    Use this API to decode Perl file of advanced incident filters in Junos Space Service Now.

    URI

    https://[host]/api/juniper/servicenow/incident-filter-management/decodePerlFile (HTTP method = POST)

    URI Parameters

    None

    Consumes

    multipart/form-data

    Produces

    multipart/form-data

    Sample Input

    XkgJHNoZWxsID0g ... JIAkKfQoKCg==

    Sample Output

    #!/usr/bin/perl
    # Copyright 2009-2011 Juniper Networks, Inc. All rights reserved.
    use CGI;
    use CGI::Carp qw ( fatalsToBrowser warningsToBrowser );
    use warnings;
    use File::Copy;
    use lib ("/usr/nma/lib");
    use NmaUtil;
    use NmaUpgradeUtil;
    use NmaDb;
    
    $| = 1;  ## turn autoflush on
    $ENV{"PATH"}="/bin:/sbin:/usr/bin:/usr/sbin";
    $<=$>;
    

    Modified: 2017-07-19