Creating a policy using web services
The create API uses the POST method to create a policy. You must provide authentication credentials by using the login API before creating a policy. For information about the authentication process, see Web services authentication. This topic provides the following information about the create API:
Examples and resources
URL to create a policy
The generic format of a URL for the create API is as follows:
http://<TSPShostname:80>/tsws/10.0/api/unifiedadmin/
Input parameters in the JSON format to create a policy
When you provide input parameters for any web service request, you must specify the content-type parameter in the header of the web service request as follows:
The input parameters vary according to the policy you create. For information about the input parameters, see Example-use-case-scenarios-to-create-a-blackout-policy and Example-use-case-scenarios-to-create-a-staging-policy.
Sample input parameters in the JSON format are as follows:
Sample input parameters for the create API to create a blackout policy
"blackoutPolicy": {
"blackoutStartStopEvents": false,
"blackoutTypes": [
"data"
],
"timeframe": {
"name": "timeframe123"
},
"agentSelectionCriteria": "agentVersion GREATER_OR_EQUALS \"10.0\"",
"precedence": 999,
"tenant": {
"name": "Calbro"
},
"enabled": true,
"name": "policy121_blackout",
"type": "blackout",
"description": "description",
"scope": "completeAgent"
}
}
Response information for the create API
A sample JSON response is as follows:
"response": [
{
"name": "policy121_blackout",
"statusCode": "200",
"statusMsg": "Successfully created policy",
"policyId": "id_1"
}
],
"statusCode": "200",
"statusMsg": "OK",
"responseTimeStamp": "2012-06-20T08:36:24",
}
Related topics
Managing-policies-using-web-services
Performing-Central-Monitoring-Administration-functions-with-web-services