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: 

https://<TSPShostname>:<port>/tsws/10.0/api/unifiedadmin/ 

Example

https://tsps105:443/tsws/10.0/api/unifiedadmin/BlackoutPolicy/create

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:

content-type application/json

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, Example-use-case-scenarios-to-create-a-monitoring-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":{  
     "tenant":{  
        "name":"*"
     },
     "owner":"admin",
     "type":"blackout",
     "precedence":900,
     "enabled":false,
     "shared":false,
     "agentSelectionCriteria":"agentTag EQUALS \"WinAgent\"",
     "timeframes":[  
        {  
           "name":"timeframe01",
           "id":"a2d7004d-2c61-432f-b5f1-88c318936c43"
        }
      ],
     "associatedUserGroup":"Administrators",
     "name":"BlackoutPolicy01",
     "description":"This is sample blackout policy",
     "scope":"completeAgent",
     "blackoutStartStopEvents":true,
     "blackoutTypes":[  
        "data",
        "events",
        "recoveryActions"
      ]
  }
}

The policy ID is generated through Infrastructure Management and cannot be created through the create API.

Response information for the create API

A sample JSON response is as follows:

{  
  "responseTimeStamp":"2016-05-12T23:48:13",
  "statusCode":"200",
  "statusMsg":"OK",
  "response":[  
     {  
        "resourceId":"1dbc6511-1093-4667-8fa2-974c7a250b78",
        "resourceName":"BlackoutPolicy02",
        "resourceURI":null,
        "statusCode":"200",
        "statusMsg":"OK"
     }
   ]
}

Related topics

Managing-policies-using-web-services

Performing-infrastructure-monitoring-functions-with-web-services

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*