Please refer to this Apigee Community Article for more information about this project.
You can deploy both API proxies (mock and shop) and the environment configuration (config folder containing cache, kvm, target server) using maven, a pom.xml file is provided in the root directory of each of them.
Node.js and NPM (Node package manager) need to be installed to be able to deploy the API proxies and run the integration tests using cucumber-js.
- Maven
- Node.js
- NPM
-
Run the following command in the
configdirectory. Make sure to replace with your own credentials and Apigee organization/environment details.$ mvn install \ -Dapigee.config.options=update \ -Dapigee.username={email} \ -Dapigee.password={password} \ -Dapigee.org={org_name} \ -Dapigee.env={env_name} -
You can inspect the
edge.jsonfile to see how the Cache, KVM and Target Server are defined. For mode details on how to use theapigee-config-maven-pluginplease refer to the official repo.
-
Create a target server called "movies" that points to OMDb API server
$ curl -v -X POST -u {email}:{password} -H "Content-Type: application/json" -d '{ "name" : "movies", "host" : "{org_name}-{env_name}.apigee.net", "port" : 80 }' "https://api.enterprise.apigee.com/v1/organizations/{org_name}/environments/{env_name}/targetservers"`
-
Create a KeyValueMap named "movies" with an entry named "targetBasepath" that stores the basepath to hit on the target server
$ curl -v -X POST -u {email}:{password} -H "Content-Type: application/json" -d '{ "name" : "movies", "entry" : [ { "name" : "targetBasepath", "value" : "/mock" } ] }' "https://api.enterprise.apigee.com/v1/organizations/{org_name}/environments/{env_name}/keyvaluemaps"
-
Create a cache called "movies" where we would be caching the value of the key value map created for a better performance.
$ curl -v -X POST -u {email}:{password} -H "Content-Type: application/json" -d '{ "name" : "movies" }' "https://api.enterprise.apigee.com/v1/organizations/{org_name}/environments/{env_name}/caches"
Make sure you have created the Cache, KVM and Target Server before continuing on this step. Refer to environment setup.
Once the environment setup has been completed. Deploy the following proxies in order (steps are identical):
- mock
- shop
$ mvn install \
-Dapigee.username={email} \
-Dapigee.password={password} \
-Dapigee.org={org_name} \
-Dapigee.env={env_name}NOTE: Make sure that the mock API proxy is deployed first.
Whenever you deploy the API proxy the integration tests will be run. If you would like to just run the tests without deploying, use the following command:
$ mvn install \
-Dapigee.org={org_name} \
-Dapigee.env={env_name} \
-DskipDeploymentIf we would like to change the target server to be the real/implemented API proxy follow the steps below.
- To update the target server, edit and update the
edge.jsonfile in theconfigdirectory. Find the targetServer config and update thehostvalue to the real endpoint. You can usewww.omdbapi.com, but you will need your own API Key. Head to wwww.omdbapi.com to get your own key."targetServers": [ { "name": "movies", "host": "www.omdbapi.com", "isEnabled": true, "port": 80 } ]
- To update the targetBasepath in the KVM, edit and update the
edge.jsonfile in theconfigdirectory. Find the kvm config and update thevaluefor thetargetBasepath. You can use/if you are usingwww.omdbapi.com. You will need your own API Key. Head to wwww.omdbapi.com to get your own key."kvms": [ { "name": "movies", "entry": [ { "name": "targetBasepath", "value": "/" } ] } ]
-
Update target server "movies"
$ curl -v -X PUT -u {email}:{password} -H "Content-Type: application/json" -d '{ "name" : "movies", "host" : "www.omdbapi.com", "port" : 80 }' "https://api.enterprise.apigee.com/v1/organizations/{org_name}/environments/{env_name}/targetservers"
-
Update entry "targetBasepath" in key value map "movies"
$ curl -v -X POST -u {email}:{password} -H "Content-Type: application/json" -d '{ "name" : "targetBasepath", "value" : "/" }' "https://api.enterprise.apigee.com/v1/organizations/{org_name}/environments/{env_name}/keyvaluemaps/movies/entries/targetBasepath"
-
Invalidate the cache entries
$ curl -v -X POST -u {email}:{password} "https://api.enterprise.apigee.com/v1/organizations/{org_name}/environments/{env_name}/caches/movies/entries?action=clear