Setup new Apigee Environment using mgmt API calls - Simple

API calls to create an new env `ENV_NAME`:

1. > curl -v -u <user>:<pass> -X POST -H "Content-Type:application/xml" http://management_server_IP:8080/v1/organizations/<orgname>/environments -d '<Environment name="ENV_NAME"/>'

2. to list available env: > curl -v -u <user>:<pass> -X GET http://management_server_IP:8080/v1/organizations/<orgname>/environments

3. The next call associates the environment with a Message Processor. Make this call for each Message Processor that you want to associate with the environment: > curl -v -u <user>:<pass> -X POST -H "Content-Type:application/x-www-form-urlencoded" http://management_server_IP:8080/v1/organizations/<orgname>/environments/ENV_NAME/servers -d "action=add&uuid=<uuid of MPs>"

4. to list MPs acsscosiated with env at: > curl -v -u <user>:<pass> http://management_server_IP:8080/v1/organizations/<orgname>/environments/at/servers

5. Enabling Analytics for env ENV_NAME: -> to get existing data curl -v -u <user>:<pass> http://management_server_IP:8080/v1/organizations/<orgname>/environments/ENV_NAME/ -> curl -v -u <user>:<pass> http://management_server_IP:8080/v1/servers?pod=analytics

6. prepare input JSON data:/home/admin/sample.json (associate postgres of ENV_NAME and QPIDx&QPIDy of ENV_NAME)

{

"properties" : {

"useSampling" : "100",

"samplingThreshold" : "100000",

"samplingTables" : "10=ten;1=one;",

"samplingAlgo" : "reservoir_sampler",

"samplingInterval" : "300000",

"aggregationinterval" : "300000"

},

"servers" : {

"postgres-server" : [ "uuid of PGRS" ],

"qpid-server" : [ "uuid of Qpid"]

}

}

> curl -v -u <user>:<pass> -X POST -H "Content-Type:application/json" http://management_server_IP:8080/v1/organizations/<orgname>/environments/ENV_NAME/analytics/admin -d "@sample.json"

The postgres-servers property contains a comma-separated list of the Postgres UUIDs, and the qpid-server property contains the Qpid UUIDs. If you need to obtain these UUIDs, use the following commands.

For Qpid, run the following command: curl -u sysAdminEmail:password http://management_server_IP/v1/servers?pod=central for PGRS: curl -u sysAdminEmail:passwor http://management_server_IP/v1/servers?pod=analytics

7. to cross verify > curl -v -u <user>:<pass> http://management_server_IP:8080/v1/organizations/<orgname>/environments/ENV_NAME/

8. to create VH `default` on new env ENV_NAME:

> curl -v -u <user>:<pass> -X POST -H "Content-Type:application/xml" http://management_server_IP:8080/v1/organizations/<orgname>/environments/ENV_NAME/virtualhosts -d '<VirtualHost name="default"> <HostAliases> <HostAlias>myorg-test.apigee.net<</HostAlias> </HostAliases> <Interfaces/> <Port><port></Port> </VirtualHost>'

to get VH list: > curl -v -u <user>:<pass> http://management_server_IP:8080/v1/organizations/<orgname>/environments/ENV_NAME/virtualhosts/

To Test and verify, You can create your own custom Hello World Sample API Proxy:

- You can have 2 policies such as for ex: helloResponse.js and setHeaders.js

helloRespsone.js:

//Parse the respose from the target.

var res = "Hello Welcome to Apigee AT-DevPortal"

//Set the response variable.

context.proxyResponse.content = JSON.stringify(res);

setHeaders.js

context.setVariable("response.header.X-Apigee-Target", context.getVariable("target.name"));

context.setVariable("response.header.X-Apigee-ApiProxyName", context.getVariable("apiproxy.name"));

context.setVariable("response.header.X-Apigee-ProxyName", context.getVariable("proxy.name"));

context.setVariable("response.header.X-Apigee-ProxyBasePath", context.getVariable("proxy.basepath"));

context.setVariable("response.header.X-Apigee-ProxyPathSuffix", context.getVariable("proxy.pathsuffix"));

context.setVariable("response.header.X-Apigee-ProxyUrl", context.getVariable("proxy.url"));

7035-helloworld-v1.png

Version history
Last update:
‎06-22-2018 08:17 PM
Updated by: