Cisco Cisco Tidal Enterprise Scheduler 6.2 テクニカルリファレンス
![Cisco](https://files.manualsbrain.com/attachments/7380d0050044647c30f5c24bbbf5d0c0b6d9bb84/common/fit/150/50/faa183d287233c52228cfea3dbc2a127fe780f60564fcb0955d9c3d1cd23/brand_logo.png)
2-13
Cisco Tidal Enterprise Scheduler 6.2.1 REST API Reference Guide
6.2.1
Chapter 2 Using the TES REST API
Java Client REST API Examples
Java Client REST API Examples
This section provides four code examples that illustrate using the Java client REST API.
•
•
•
•
Code Example 1 – GET Request
The following Java client issues a GET request to the REST API. This is the equivalent of clicking on
the ApiObject link as described in the REST API From Browser section. This example retrieves all of
the jobs currently defined in the Scheduler environment. The username and password pair is Base64
encoded and passed to the server as the "Authorization" property.
the ApiObject link as described in the REST API From Browser section. This example retrieves all of
the jobs currently defined in the Scheduler environment. The username and password pair is Base64
encoded and passed to the server as the "Authorization" property.
An XML document containing a list of jobs is returned from this call.
public static void
postRequest()
throws
Exception
{
URL url =
new
URL("
http://www.companyscheduler.com:8080/api/tes-6.2/post
");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod(
"
GET
"
);
conn.setDoInput(
true
);
conn.setDoOutput(
true
);
String userNamePassword =
"myusername:mypassword"
;
userNamePassword =
new
String(org.apache.commons.codec.binary.Base64.encodeBase64(userNamePassword
.getBytes()));
conn.setRequestProperty(
"Authorization"
, userNamePassword);
conn.connect();
BufferedReader reader =
new
BufferedReader(
new
InputStreamReader(
conn.getInputStream()));
String resp = "";
String next =
null
;
while
((next = reader.readLine()) !=
null
)
resp += next;
System.
out
.println(resp);
}
Code Example 2 – POST Request
Code Example 2 shows a POST request issued to the TES REST API. The URL for issuing a POST
request is always the same: http://<hostname>:<port>/api/<DSP Name>/ post.
request is always the same: http://<hostname>:<port>/api/<DSP Name>/ post.
In the post request, the command to be executed is sent in an URL encoded string. In this particular
example, a POST request is sent to insert a job into the schedule. The <id> is the id of the job. Other
parameters include <startdate> - the requested runtime for the job; <vars> - local job variable overrides;
<params> - local job parameter overrides; and <deps> - the Y/N value for whether or not to override the
job's dependencies.
example, a POST request is sent to insert a job into the schedule. The <id> is the id of the job. Other
parameters include <startdate> - the requested runtime for the job; <vars> - local job variable overrides;
<params> - local job parameter overrides; and <deps> - the Y/N value for whether or not to override the
job's dependencies.
An XML document acknowledging the job insert is returned.