You can add an application policy using the CLI tool, REST API or the Private PaaS Console as shown below:
Adding an application policy via the CLI
Overview
CLI command | add-application-policy |
Description | Add an application policy. |
Command format | add-application-policy -p <JSON_FILE_PATH> The path to the JSON file that defines the application policy needs to be defined as the |
Parameter definition
Short option | Long option | Description | Required | Example value |
---|---|---|---|---|
-p | --resource-path | Folder path where the JSON file that defines the application policy is stored. | yes | <PRIVATE_PAAS_CARTRIDGES>/wso2am/1.9.0/samples/ |
Example
Add the application policy defined in the <PRIVATE_PAAS_CARTRIDGES>/wso2am/1.9.0/samples/application-policies/mock/application-policy-1.json
file.
add-application-policy -p <PRIVATE_PAAS_CARTRIDGES>/wso2am/1.9.0/samples/cartridge-groups/wso2am-190/wso2am-190-group1.json
Sample output
Application policy added successfully: [application-policy] application-policy-1
Adding an application policy via the REST API
Overview
Description | Add an application policy definition. |
Resource Path | /applicationPolicies |
HTTP Method | POST |
Request/Response Format | application/json |
Command format | curl -X POST -H "Content-Type: application/json" -d @'<JSON_PAYLOAD>' -k -v -u <USERNAME>:<PASSWORD> https://<PRIVATE_PAAS_HOST>:<PRIVATE_PAAS_HTTPS_PORT>/api/applicationPolicies
|
Example
Add a cartridge group that has been defined in the <PRIVATE_PAAS_CARTRIDGES>/wso2am/1.9.0/samples/application-policies/mock/application-policy-1.json
file.
cd <PRIVATE_PAAS_CARTRIDGES>/wso2am/1.9.0/samples curl -X POST -H "Content-Type: application/json" -d @'application-policies/mock/application-policy-1.json' -k -v -u admin:admin https://localhost:9443/api/applicationPolicies
Sample output
> POST /api/applicationPolicies HTTP/1.1 > Host: localhost:9443 > Authorization: Basic YWRtaW46YWRtaW4= > User-Agent: curl/7.43.0 > Accept: */* > Content-Type: application/json > Content-Length: 160 > < HTTP/1.1 201 Created < Date: Wed, 07 Oct 2015 10:01:11 GMT < Location: https://localhost:9443/api/applicationPolicies/application-policy-1 < Content-Type: application/json < Transfer-Encoding: chunked < Server: WSO2 Carbon Server < {"status":"success","message":"Application policy added successfully: [application-policy] application-policy-1"}
You will come across the following HTTP status codes while adding an application policy:
HTTP status code | 201, 400, 409, 500 See the descriptions of the HTTP status codes here. |
Location header URL | https://<STRATOS_HOST>:<STRATOS_HTTPS_PORT>/api/applicationPolicies/<APPLICATION_POLICY_ID> |
Adding an application policy via the Private PaaS Console
Adding an application policy via the UI editor
Follow the instructions below to add an application policy:
- Click Configurations on the home page.
- Click Application Policies.
- Click ADD APPLICATION POLICY.
- Enter the required details. For property definitions, see Application policy property definitions.
- Click SAVE APPLICATION POLICY DEFINITION.
Adding an application policy via the JSON editor
Follow the instructions below to add an application policy:
- Click Configurations on the home page.
- Click Application Policies.
- Click ADD APPLICATION POLICY .
- Click on the editor control to switch to the JSON editor. The JSON code format to add an application policy will appear.
- Optionally, check the Auto correct with schema option to ensure that you do not accidentally delete any mandatory fields from the application policy definition JSON code.
- Code the application policy definition using JSON. For property definitions, see Application policy property definitions.
- Click SAVE APPLICATION POLICY DEFINITION.
Sample application policy JSON
{ "id": "application-policy-1", "algorithm": "one-after-another", "networkPartitions": [ "network-partition-mock" ], "properties": [ ] }