REST Resources
-
/ -
/exec-deploy -
/exec-scripts -
/job-instances /{job-id} /script-mgmt-job-results -
/match-scripts-by-context -
/scripts -
/scripts /exec-deploy -
/scripts /exec-disable -
/scripts /exec-enable -
/scripts /exec-remove -
/scripts /exec-scripts -
/scripts /exec-verify -
/scripts /{script-id} -
/scripts /{script-id} /contents -
/scripts /{script-id} /parameters -
/scripts /{script-id} /results -
/scripts /{script-id} /view-associated-devices
/api/space/script-management/scripts/{script-id}
The following operations are supported on this resource:
GET /scripts/{script-id} | Version 1 |
This API finds a script on Junos Space and returns details about the script.
Sample Usage
GET /scripts/{script-id}
-
Parameters:
Name Type URI Type Description Required scriptid int Path The ID of the script to get from Junos Space Y
-
Accept Headers:
application/vnd.net.juniper.space.script-management.script+xml;version=1
application/vnd.net.juniper.space.script-management.script+json;version=1
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<script>
<id>1114117</id>
<scriptName>cpu-usage-60.slax</scriptName>
<category>sample</category>
<domain-name>Global</domain-name>
<domain-id>65537</domain-id>
<type>TYPE_EVENT</type>
<format>FORMAT_SLAX</format>
<lastestRevision>1.1</lastestRevision>
<comments>Script is imported for the first
time</comments>
<scriptSize>7520</scriptSize>
<domain href= "/api/space/domain-management/domains/65537" />
<collection
href="/api/space/script-management/scripts/1114117/results"/>
<contents
href="/api/space/script-management/scripts/1114117/contents"/>
<parameters
href= "/api/space/script-management/scripts/1015808/parameters" />
<view-associated-devices
href= "/api/space/script-management/scripts/1015808/view-associated-devices" />
</script>
{
"script": {
"id": "1114117" ,
"scriptName": "cpu-usage-60.slax" ,
"category": "sample" ,
"domain-name": "Global",
"domain-id": "65537",
"type": "TYPE_EVENT" ,
"format": "FORMAT_SLAX" ,
"lastestRevision": "1.1",
"comments": "Script is imported for the first time" ,
"scriptSize": "7520" ,
"domain": {
"@href": "/api/space/domain-management/domains/65537"
},
"collection": {
"@href":"/api/space/script-management/scripts/1114117/results"
} ,
"contents": {
"@href":"/api/space/script-management/scripts/1114117/contents"
} ,
"parameters": {
"@href": "/api/space/script-management/scripts/1015808/parameters"
},
"view-associated-devices": {
"@href": "/api/space/script-management/scripts/1015808/view-associated-devices"
}
}
}
Access Control
The following capabilities are required to access this API: ViewScriptsCap
PUT /scripts/{script-id} | Version 1 |
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.
Sample Usage
PUT /scripts/{script-id}
-
Parameters:
Name Type URI Type Description Required scriptid int Path The ID of the script to be updated on Junos Space Y
-
Content-Type Headers:
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 -
Accept Headers:
application/vnd.net.juniper.space.script-management.script+xml;version=1
application/vnd.net.juniper.space.script-management.script+json;version=1
<?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.
<?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>UPDATE_SUCCESS</completionStatus>
<collection href="/api/space/script-management/scripts/11173888/results"/>
<contents href="/api/space/script-management/scripts/11173888/contents"/>
<parameters href="/api/space/script-management/scripts/11173888/parameters"/>
<view-associated-devices href="/api/space/script-management/scripts/11173888/view-associated-devices"/>
</script>
{
"script": {
"comments":"Script is updated",
"scriptContents":"Version 1.2;\
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.
{
"script":
{
"id": "1114117",
"scriptName": "slax-event1.slax",
"type": "TYPE_EVENT",
"category": "sample",
"lastestRevision": "1.1",
"scriptSize": "7520",
"completionStatus": "UPDATE_SUCCESS" ,
"collection" : {
"href" : "/api/space/script-management/scripts/11173888/results"
},
"contents" : {
"href" : "/api/space/script-management/scripts/11173888/contents"
},
"parameters" : {
"href" : "/api/space/script-management/scripts/11173888/parameters"
},
"view-associated-devices" : {
"href" : "/api/space/script-management/scripts/11173888/view-associated-devices"
}
}
}
Access Control
The following capabilities are required to access this API: ModifyScriptCap
Data Notification
This API supports data notification.
DELETE /scripts/{script-id} | Version 1 |
This API deletes a device script from Junos Space.
Sample Usage
This API makes an asynchronous method call; so, you can optionally specify queue and schedule parameters:
DELETE /scripts/{script-id}?queue=<queue>&schedule=<schedule>
Note: The queue URL denoted by <queue> must have been created already.
-
Parameters:
Name Type URI Type Description Required scriptid int Path The ID of the script to be delete from Junos Space. Y queue Queue URL Query A fully qualified queue URL, where job progress notifications will be sent (See Asynchronous API Usage) N schedule cron-like-expression Query Schedule this API in the future, by specifying a cron-like-expression (See Job Scheduling) N
-
Accept Headers:
application/vnd.net.juniper.space.script-management.script+xml;version=1
application/vnd.net.juniper.space.script-management.script+json;version=1
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<task>
<id>786496</id>
</task>
{
"task": {
"id": "786496"
}
}
Access Control
The following capabilities are required to access this API: DeleteScriptCap
Data Notification
This API supports data notification.