Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Localtabgroup
Localtab
activetrue
titleCLI

Adding domain mappings via the CLI

Overview
CLI commandadd-domain-mapping
DescriptionAdd domain mappings for the subscribed cartridge.
Command format
Code Block
add-domain-mappings <APPLICATION-ID> -p <JSON_FILE_PATH>
Info

The path to the JSON file that defines the domain mapping needs to be defined as the  <JSON_FILE_PATH>  value.

Parameter definition
Short optionLong optionDescriptionRequiredExample value
N/AN/AID of the application.Yes

single-cartridge-app

-p

--resource-path

Folder path where the JSON file that defines the domain mappings is stored.Yes
<wso2am-1.9.1-cartridge-4.1.1>/samples<ANY_PATH>/domainmappings.json
Example

Add the domain mappings defined in the <wso2am-1.9.1-cartridge-4.1.1>/samples<TEST>/domainmappings.json file to the application with the ID: wso2am-190-application

Code Block
add-domain-mappings wso2am-190-application -p <wso2am-1.9.1-cartridge-4.1.1>/samples<TEST_PATH>/domainmappings.json
Sample output
Code Block
 
Localtab
titleREST API

Adding domain mappings via the REST API

Overview
DescriptionAdd one or more domain mappings for a cluster.
Resource Path

/applications/{applicationId}/domainMappings

HTTP MethodPOST
Request/Response Format

application/json

Command format
Code Block
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/applications/{applicationId}/domainMappings
Info
  • The path to the JSON file that defines the application needs to be defined as the <JSON_PAYLOAD> value.
  • By default, <USERNAME>:<PASSWORD> is admin:admin.
  • By default, <PRIVATE_PAAS_HOST> is localhost. However, if you are using a public IP, the respective IP address or domain needs to be specified.
  • By default, <PRIVATE_PAAS_HTTPS_PORT> has been set to 9443. However, if the port offset has been incremented by n, the default port value needs to be incremented by n.
Example

Add the domain mappings defined in the <wso2am-1.9.1-cartridge-4.1.1>/samples/<TEST_PATH>/domainmappings.json file and add this domain mapping to the application with the ID: wso2am-190-application. 

Code Block
cd <wso2am-1.9.1-cartridge-4.1.1>/samples/<TEST_PATH>
curl -X POST -H "Content-Type: application/json" -d @'domain-mappings.json' -k -v -u admin:admin https://localhost:9443/api/applications/wso2am-190-application/domainMappings
Sample output
Code Block
 

You will come across the following HTTP status codes while adding an application:

HTTP status code

200, 500

See the descriptions of the HTTP status codes here.

Location header URL

https://<STRATOS_HOST>:<STRATOS_HTTPS_PORT>/api/applications/<APPLICATION_ID>/domainMappings

  

...

Sample domain mapping JSON

title
Excerpt
Panel
Sample application JSON
Code Block
{
  "domainMappings": [
    {
      "cartridgeAlias": "tomcat",
      "domainName": "abc.com",
      "contextPath": "/abc/app"
    }
  ]
}

 

...