Running Daily Maintenance While Skipping the Scheduled Daily Maintenance (v1)
Use this API (v1) if you want to run daily maintenance while skipping the scheduled daily maintenance.
This topic describes the original version of this REST API. You can also use the simplified v2 version of the REST API. The v2 version contains all parameters in the payload and does not require URL encoding while calling the REST APIs. This makes the v2 API easier to use. The v2 version is backwards compatible.
Before using the REST resources, you must understand how to access the REST resources and other important concepts. See About the REST APIs. Using this REST API requires prerequisites. See Prerequisites.
This API is version v1.
Required Roles
Service Administrator
REST Resource
POST /interop/rest/{api_version}/services/maintenancewindow
Note:
Before using the REST resources, you must understand how to access the REST resources and other important concepts. See Implementation Best Practices for EPM Cloud REST APIs. Using this REST API requires prerequisites. See Prerequisites.
Request
The following table summarizes the request parameters.
Table 11-10 Parameters
Name | Description | Type | Required | Default |
---|---|---|---|---|
api_version |
Specific API version | Path | Yes | None |
skipNext |
Specifies if the set maintenance time should be used,
true or false |
String | Yes | false |
Response
Supported Media Types: application/json
Table 11-11 Parameters
Parameters | Description |
---|---|
details |
In case of errors, details are published with the error string |
status |
See Migration Status Codes |
links |
Detailed information about the link |
href |
Links to API call |
action |
The HTTP call type |
rel |
Possible value: self
|
data |
Parameters as key value pairs passed in the request |
- Java Code using
skipNext
:DailyMaintenanceWithSkipNextv1.java Main method: runDailyMaintenanceWithSkipNext() Helper method waitForCompletion
- Curl Code using
skipNext
:Main method: funcSetMaintenancewithSkipNext
- Groovy Code using
skipNext
:DailyMaintenanceWithSkipNextv1.groovy Main method: runDailyMaintenanceWithSkipNext()
Maintenance Window Time Sample Code
Example 11-7 Java Sample – SetMaintenanceDetails.java
Prerequisites: json.jar
Common Functions: See Common Helper Functions for Java
public class DailyMaintenanceWithSkipNextv1 {
private String userName ; // PBCS user name
private String password ; // PBCS user password
private String serverUrl ; // PBCS server URL
private String lcmVersion = "v1"; // Version of the PBCS API that you are
public void runDailyMaintenanceWithSkipNext(String comment) throws Exception {
Scanner in = null;
try {
String skipNext = "false";
JSONObject params = new JSONObject();
/*Parameter to Skip the next scheduled maintenance report to be run .
It is either true or false
If true the scheduled daily maintenance is run
If false the scheduled daily maintenance is skipped*/
params.put("skipNext", skipNext);
String urlString = String.format(
"%s/interop/rest/%s/services/maintenancewindow", serverUrl,
lcmVersion);
String response = executeRequest(urlString, "POST",
params.toString(), "application/json");
waitForCompletion(fetchPingUrlFromResponse(response, "Job Status"),"GET");
} catch (Exception e) {
} finally {
in.close();
}
}
private void waitForCompletion(String pingUrlString, String methodType)
throws Exception {
boolean completed = false;
while (!completed) {
try {
String pingResponse = executeRequest(pingUrlString, methodType,
null, "application/x-www-form-urlencoded");
JSONObject json = new JSONObject(pingResponse);
int status = json.getInt("status");
if (status == -1) {
try {
System.out.println("Please wait...");
Thread.sleep(20000);
} catch (InterruptedException e) {
completed = true;
throw e;
}
} else {
if (status > 0) {
System.out.println("Error occurred: "
+ json.getString("details"));
} else {
System.out.println("Completed");
}
completed = true;
}
} catch (Exception e) {
System.out.println(e.getMessage());
// services are down, waiting to come up
Thread.sleep(60000);
}
}
}
}
Example 11-8 cURL Sample – SetMaintenanceDetails.sh
Prerequisites: jq (http://stedolan.github.io/jq/download/linux64/jq)
Common Functions: See Common Helper Functions for cURL
#!/bin/sh
SERVER_URL=""
USERNAME=""
PASSWORD=""
API_VERSION=""
DOMAIN=""
funcSetMaintenancewithSkipNext () {
url=$SERVER_URL/interop/rest/v1/services/maintenancewindow
skipNext="false"
param="{\"skipNext\":\"$skipNext\"}"
funcExecuteRequest "POST" $url $param "application/json"
output=`cat response.txt`
status=`echo $output | jq '.status'`
if [ $status == -1 ]; then
echo "Started Daily Maintainence succesfully"
funcGetStatus "GET"
else
error=`echo $output | jq '.details'`
echo "Error occurred. " $error
fi
funcRemoveTempFiles "respHeader.txt" "response.txt"
}
Example 11-9 Groovy Sample – SetMaintenanceDetails.groovy
Prerequisites: json.jar
Common Functions: See CSS Common Helper Functions for Groovy
class DailyMaintenanceWithSkipNextv1 {
def userName // PBCS user name
def password // PBCS user password
def serverUrl // PBCS server URL
def lcmVersion = "v1"; // Version of the PBCS API that you are
void runDailyMaintenanceWithSkipNext() throws Exception {
def skipNext = "false"; //true or false based on requirement
JSONObject params = new JSONObject();
params.put("skipNext",skipNext);
String urlString = String.format("%s/interop/rest/%s/services/maintenancewindow", serverUrl, lcmVersion);
String response = executeRequest(urlString, "POST", params.toString(), "application/json");
waitForCompletion(fetchPingUrlFromResponse(response, "Job Status"));
}
}