# Commands to build TAPI v2.1.3 Server:

# Acknowledgements and References:
# [Ref-1]: https://github.com/OpenNetworkingFoundation/TAPI
# [Ref-2]: https://github.com/OpenNetworkingFoundation/TAPI/tree/v2.1.3/YANG
# [Ref-3]: https://github.com/OpenNetworkingFoundation/TAPI/tree/develop/RI

cd ~/tfs-ctrl/hackfest/tapi
wget https://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/3.0.35/swagger-codegen-cli-3.0.35.jar
wget -O tapi-connectivity.yaml https://github.com/OpenNetworkingFoundation/TAPI/raw/v2.1.3/OAS/tapi-connectivity%402020-06-16.yaml
java -jar swagger-codegen-cli-3.0.35.jar generate --input-spec tapi-connectivity.yaml \
    --lang python-flask --output server --disable-examples --config codegen-config.json
pip install connexion==2.14.1
cd ~/tfs-ctrl/hackfest/tapi/server
# Rename methods in "tapi_server/controllers/tapi_path_computation_controller.py" as follows:
#   operations_tapi_path_computationcompute_p2_p_path_post => operations_tapi_path_computationcompute_p_2_p_path_post
#   operations_tapi_path_computationdelete_p2_p_path_post => operations_tapi_path_computationdelete_p_2_p_path_post
#   operations_tapi_path_computationoptimize_p2_ppath_post => operations_tapi_path_computationoptimize_p_2_ppath_post
# Implement database based on Reference Implementation [Ref-3]
python3 -m tapi_server

RUN TAPI CLIENT (In a new window):
curl -X GET -H "Content-Type: application/json" http://127.0.0.1:8080/restconf/data/tapi-common:context/
curl -X GET -H "Content-Type: application/json" http://127.0.0.1:8080/restconf/data/tapi-common:context/service-interface-point=sip-pe1-uni1/
curl -X GET -H "Content-Type: application/json" http://127.0.0.1:8080/restconf/data/tapi-common:context/tapi-topology:topology-context/
curl -X GET -H "Content-Type: application/json" http://127.0.0.1:8080/restconf/data/tapi-common:context/tapi-topology:topology-context/topology=topo-nwk/
curl -X GET -H "Content-Type: application/json" http://127.0.0.1:8080/restconf/data/tapi-common:context/tapi-topology:topology-context/topology=topo-nwk/node=node-odu-pi-4/
curl -X GET -H "Content-Type: application/json" http://127.0.0.1:8080/restconf/data/tapi-common:context/tapi-topology:topology-context/topology=topo-nwk/node=node-odu-pi-4/owned-node-edge-point=nep-pi4-odu4-nni1/
curl -X GET -H "Content-Type: application/json" http://127.0.0.1:8080/restconf/data/tapi-common:context/tapi-topology:topology-context/topology=topo-nwk/node=node-odu-pi-4/owned-node-edge-point=nep-pi4-odu4-nni1/tapi-connectivity:cep-list/
curl -X GET -H "Content-Type: application/json" http://127.0.0.1:8080/restconf/data/tapi-common:context/tapi-topology:topology-context/topology=topo-nwk/link=link-pe1-odu4-nni1-pi4-odu4-nni2/


curl -X POST -H "Content-Type: application/json" \
    http://127.0.0.1:8080/restconf/data/tapi-common:context/tapi-connectivity:connectivity-context/connectivity-service/ \
    -d @/home/tfs/tfs-ctrl/hackfest/tapi/client/cs1.json

curl -X GET -H "Content-Type: application/json" http://127.0.0.1:8080/restconf/data/tapi-common:context/tapi-connectivity:connectivity-context/
curl -X GET -H "Content-Type: application/json" http://127.0.0.1:8080/restconf/data/tapi-common:context/tapi-connectivity:connectivity-context/connectivity-service=cs1/
curl -X GET -H "Content-Type: application/json" http://127.0.0.1:8080/restconf/data/tapi-common:context/tapi-connectivity:connectivity-context/connection=cs1/

curl -X DELETE -H "Content-Type: application/json" http://127.0.0.1:8080/restconf/data/tapi-common:context/tapi-connectivity:connectivity-context/connectivity-service=cs1/


Not testable since there is no path computation 
curl -X GET -H "Content-Type: application/json" http://127.0.0.1:8080/restconf/data/tapi-common:context/tapi-topology:topology-context/topology=topo-nwk/node=node-odu-pi-4/owned-node-edge-point=nep-pi4-odu4-nni1/tapi-connectivity:cep-list/connection-end-point={cep-uuid}/
