Environment Setup
- To run the examples of this workshop, it is neccessary to have the following tools installed on your laptop.
- Docker or Docker-machine
- LINUX users need to install Docker
- Windows and OSx user need to install Docker-machine.
- Docker or Docker-machine
- This README assumes that the followers may use Windows or OSx. Therefore,
- The example docker commands are mostly provided according to Windows and OSx.
- LINUX users can skip commands related to
docker-machine
, which are marked asdmr
.
- Add a host entry to the host machine (
dmr
)docker-machine start
- will start the docker machine if you are usingwindows
orOSx
.docker-machine ip
- will display the IP address of the docker machine.- Open the
hosts
file of the host machine, and add an entry as<ip-address> docker.machine
. - You may also need to run
docker-machine env
andeval "$(docker-machine env default)"
onOSx
environments.
- Download WSO2 product binary packages
- WSO2 API Manager 1.10.0 -
wso2am-1.10.0.zip
- WSO2 Data Analytics Server 3.0.1 -
wso2das-3.0.1.zip
- WSO2 API Manager 1.10.0 -
- Add these 2 binary packs to the
packs
directory.
The Microservice (REST API)
- Start the Microservice container
docker-compose up -d mres
- will create the container image and boot it up.docker ps
- lists the running container information.- Observe the NAME value ( res.apimdemo.com ) of the containers.
- Try the Swagger definition
- Try API resources
Supporting server instances
- Start the databse container
docker-compose up -d dbs
- will create the database container image and boot it up.- Wait for a few seconds until the database server becomes ready to be used.
- Start the Analytics container
docker-compose up -d das
- will create the analytics profile container image and boot it up.
WSO2 API Manager (API-M)
- Start the API-M container
docker-compose up -d apim
- will create the API-M container image and boot it up.docker ps
- lists the running containers information.- Observe the NAME values ( api.apimdemo.com, das.apimdemo.com ) of the containers.
- To view API-M server logs, execute the command
docker exec -it api.apimdemo.com tailf wso2/wso2am-1.10.0/repository/logs/wso2carbon.log
- To get into the API-M container filesystem, execute the command
docker exec -it api.apimdemo.com bash
- Open API-M user interfaces (user=admin, password=admin).
- API-M Admin Console https://docker.machine:9443/carbon
- API-M Publisher https://docker.machine:9443/publisher
- API-M Store https://docker.machine:9443/store
- Publish the API using the Swagger definition of the Microservice.
- Create an API on API-M publisher.
- Import swagger definition from
apim-feature-demo/mres/swagger.json
of the repository. - Provide a proper resource path (i.e.
/uefa
) - Use image from
apim-feature-demo/mres/euro-2016.png
as thumbnail. - Go to the next page and add the URL
http://res.apimdemo.com:8080
as the Managed API URL. - Select a few throttling tiers and publish the API.
- Subscribe to the API via the API-M Store.
- Try the API with Swagger based API Console on the API-M Store UI.
- With resource
GET /matches/{tournementID}/results
use the input parameterEUL2016
. - With resource
GET /matches/{tournementID}/results/{recordId}
use the input parametersEUL2016
and a number beteen 1 and 8 such as4
. - If you get an error, it may be due to the browser not accepting your certificate. Should that be the case, open https://docker.machine:8243/uefa/1.0 on a separate tab and accept the certificate to resolve the issue.
- With resource
- Or, use a REST client like POSTMAN
https://docker.machine:8243/uefa/1.0/matches/EUL2016/results
https://docker.machine:8243/uefa/1.0/matches/EUL2016/results/8
When You are done...
- Run
docker stop $(docker ps -a -q)
to stop all containers. - Run
docker-machine stop
to stop the machine.