/api/space/script-management/scripts

The following operations are supported on this resource:

  • GET - Get all scripts
  • POST - Add or import a script
GET /scriptsVersion 3

Get all scripts.

Sample Usage

GET /scripts


  • Sample Output XML:
    <scripts total="Integer" uri="/api/space/script-management/scripts">
         <script href="/api/space/script-management/scripts/{id}" uri="/api/space/script-management/scripts/{id}">
               <id>Integer</id>
               <scriptName>String</scriptName>
               <category>String</category>
               <domain-name>String</domain-name>
               <domain-id>Integer</domain-id>
         </script>
    </scripts>

  • Sample Output JSON:
    {
       "scripts" : {
         "@total" : "Integer" ,
         "@uri" : "/api/space/script-management/scripts" ,
         "script" : {
           "@href" : "/api/space/script-management/scripts/{id}" ,
           "@uri" : "/api/space/script-management/scripts/{id}" ,
           "id" : "Integer" ,
           "scriptName" : "String" ,
           "category" : "String" ,
           "domain-name" : "String" ,
           "domain-id" : "Integer"
         }
       }
    }

  • Access Control

    The following capabilities are required to access this API: ViewScriptsCap

    POST /scriptsVersion 1

    This API is used to add or import script contents to the platform. The script type is always determined from the contents of the script and the field script type is never evaluated (even if there is a value present in the input).

    Sample Usage

    POST /scripts


  • Sample Input XML:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <script>
          <scriptName>cpu-usage-60.slax</ scriptName>
          <scriptContents><![CDATA[

    Version 1.0;
    ns junos = "http://xml.juniper.net/junos/*\/junos";
    ns xnm = "http://xml.juniper.net/xnm/1.1/xnm";
    ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0";
    ns ext = "http://xmlsoft.org/XSLT/namespace";

    import "../import/junos.xsl";

    \/*
    * This commit script checks that any interfaces with "CORE" or "core"
    * in the description is configured with an MTU of 4484.
    * The search criteria and MTU should be changed to fit the environment
    * and requirements.
    *\/


    match configuration { for-each (interfaces/interface) { var $int = name; var $unit = unit/name; var $desc = unit/description; var $mtu = mtu; if (contains($desc, "CORE") || contains($desc, "core")) { if (not ($mtu == 4484)) { <xnm:warning> { <message> { expr "MTU on backbone interface"; expr $int; expr "."; expr $unit; expr " is not set to 4484"; expr " ("; expr $mtu; expr ")"; } } } } }


          ]]></scriptContents>
    </script>


    Note : The actual script provided is inside a CDATA tag.


  • Sample Output XML:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <script>
          <id>1114117</id>
          <scriptName>slax-event1.slax</ scriptName>
          <type>TYPE_EVENT</type>
          <category>sample</category>
          <lastestRevision>1.1</lastestRevision>
          <scriptSize>7520</scriptSize>
          <completionStatus>IMPORT_SUCCESS</ completionStatus>
    </script>

  • Sample Input JSON:


    {"script":
    {"scriptName":"slax-event1.slax","scriptContents":"Version 1.0;
    ns junos = \"http:\/\/xml.juniper.net\/junos\/*\/junos\";
    ns xnm = \"http:\/\/xml.juniper.net\/xnm\/1.1\/xnm\";
    ns jcs = \"http:\/\/xml.juniper.net\/junos\/commit-scripts\/1.0\";
    ns ext = \"http:\/\/xmlsoft.org\/XSLT\/namespace\";import \"..\/import\/junos.xsl\";

    /** This commit script checks that any interfaces with \"CORE\" or \"core\"
    * in the description is configured with an MTU of 4484.
    * The search criteria and MTU should be changed to fit the environment
    * and requirements.
    *\/
    match configuration { for-each (interfaces\/interface) { var $int = name; var $unit = unit\/name; var $desc = unit\/description; var $mtu = mtu; if (contains($desc, \"CORE\") || contains($desc, \"core\")) { if (not ($mtu == 4484)) { <xnm:warning> { <message> { expr \"MTU on backbone interface\"; expr $int; expr \".\"; expr $unit; expr \" is not set to 4484\"; expr \" (\"; expr $mtu;expr \")\"; } } } } } } "} }


    Note : The actual script provided starts from
    "Version 1.0;ns junos = ........... expr $mtu; expr \")\"; } } } } }}"

    Note that all special characters, new lines, tabs, and so on must be
    escaped in the contents of the script. This change is needed to correctly
    unmarshal script content by the JAX-B unmarshaler.

  • Sample Output JSON:
    script:
    {
          id: 1114117
          scriptName: slax-event1.slax
          type: TYPE_EVENT
          category: sample
          lastestRevision: 1.1
          scriptSize: 7520
          completionStatus: IMPORT_SUCCESS
    }

  • Access Control

    The following capabilities are required to access this API: ImportScriptsCap

    Data Notification

    This API supports data notification.