Script Management API

/api/space/script-management/scripts/{script-id}

The following operations are supported on this resource:

GET /api/space/script-management/scripts/{script-id} (v1)


This API finds a script on Junos Space and returns details about the script.

Access Control

The following capabilities are required to access this API:
"ViewScriptsCap"


Example Usage

GET /api/space/script-management/scripts/{script-id}


Parameters

NameTypeURI TypeDescriptionRequired
scriptidintPathThe ID of the script to get from Junos Space Y

Content Types

  • Produces content types:
    application/vnd.net.juniper.space.script-management.script+xml;version=1
    application/vnd.net.juniper.space.script-management.script+json;version=1


  • Sample Output XML:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <script>
          <id>1114117</id>
          <scriptName>cpu-usage-60.slax</scriptName>
          <type>TYPE_EVENT</type>
          <format>FORMAT_SLAX</format>
          <lastestRevision>1.1</lastestRevision>
          <comments>Script is imported for the first time</comments>
          <scriptSize>7520</scriptSize>
          <collection href="/api/space/script-management/scripts/1114117/results" rel="script verification results"/>
          <contents href="/api/space/script-management/scripts/1114117/contents" rel="script contents"/>
    </script>


  • Sample Output JSON:
    script:
    {
          id: 1114117
          scriptName: cpu-usage-60.slax
          type: TYPE_EVENT
          format: FORMAT_SLAX
          lastestRevision: 1.1
          comments: Script is imported for the first time
          scriptSize: 7520
          collection:
          {
          @href:/api/space/script-management/scripts/1114117/results
          @rel:script verification results
          }
          contents:
          {
          @href:/api/space/script-management/scripts/1114117/contents
          @rel:script contents
          }
    }



PUT /api/space/script-management/scripts/{script-id} (v1)


This API modifies the script contents. If the script type is provided in the input, the script type will be updated with the new script type. If the script type is not provided in the input, the original script type is preserved.

Access Control

The following capabilities are required to access this API:
"ModifyScriptCap"


Example Usage

PUT /api/space/script-management/scripts/{script-id}


Parameters

NameTypeURI TypeDescriptionRequired
scriptidintPathThe ID of the script to be updated on Junos Space Y

Data Notification

This API supports data notification.

See the following links for information about enabling data notifications changes to be received for this service:

  • Data Notification Usage.


Content Types

  • Consumes content types:
    application/vnd.net.juniper.space.script-management.script+xml;version=1;charset=UTF-8
    application/vnd.net.juniper.space.script-management.script+json;version=1;charset=UTF-8


  • Produces content types:
    application/vnd.net.juniper.space.script-management.script+xml;version=1
    application/vnd.net.juniper.space.script-management.script+json;version=1


  • Sample Input XML:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <script>
          <comments>Script is updated</comments>
          <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 $mtu;
              ")";
              }
              }
              }
              }
              }
              }
          ]]></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>
          <lastestRevision>1.1</lastestRevision>
          <scriptSize>7520</scriptSize>
          <completionStatus>UPDATE_SUCCESS</completionStatus>
    </script>


  • Sample Input JSON:
    {"script":
    {"comments":"Script is updated","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 need to be escaped in the contents of the script. This change is needed for the JAX-B unmarshaler to correctly unmarshal the script.



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



DELETE /api/space/script-management/scripts/{script-id} (v1)


This API deletes a device script from Junos Space.

Access Control

The following capabilities are required to access this API:
"DeleteScriptCap"


Example Usage

Since this API makes an asynchronous method call, the user must specify a queue parameter with this API.

DELETE /api/space/script-management/scripts/{script-id}?queue-url=<queue-url>&schedule-time=<schedule-time>

Note: It is assumed that the queue denoted by <queue-url> has, already, been created.



Parameters

NameTypeURI TypeDescriptionRequired
scriptidintPathThe ID of the script to be delete from Junos Space. Y
queue-urlURLQueryA fully qualified queue URL, where job progress notifications will be sent (See Asynchronous API Usage)Y
schedule-timecron-like-expressionQuerySchedule this API in the future, by specifying a cron-like-expression (See Job Scheduling)N

Data Notification

This API supports data notification.

See the following links for information about enabling data notifications changes to be received for this service:

  • Data Notification Usage.


Content Types