== RESTCONF

=== YANG2SWAGGER

$ cd ~/tfs-ctrl/hackfest/restconf
(if needed)
$ wget https://github.com/bartoszm/yang2swagger/releases/download/1.1.11/swagger-generator-cli-1.1.11-executable.jar

Generate swagger files:
$ java -jar swagger-generator-cli-1.1.11-executable.jar -yang-dir ../yang/ -output topology.yaml topology
$ java -jar swagger-generator-cli-1.1.11-executable.jar -yang-dir ../yang/ -output connection.yaml connection



=== SERVER
$ cd ~/tfs-ctrl/hackfest/restconf
(if needed)
$ wget https://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/3.0.11/swagger-codegen-cli-3.0.11.jar -O swagger-codegen-cli.jar

Create the server:
$ mkdir ~/tfs-ctrl/hackfest/restconf/server
$ java -jar swagger-codegen-cli.jar generate -i connection.yaml -l python-flask -o server

Run the server:
$ cd ~/tfs-ctrl/hackfest/restconf/server
$ pip3 install -r requirements.txt
(Open ~/tfs-ctrl/hackfest/restconf/server/swagger_server/swagger/swagger.yaml and modify all: "name: connection_id" for "name: connection-id")
RUN AUTOGENERATED SERVER
$ python3 -m swagger_server

(you have the solution in ~/tfs-ctrl/hackfest/restconf/connectionserver )

RUN CURL AS CLIENT (In another window)
$ cd ~/tfs-ctrl/hackfest/restconf/
$ curl -X POST -H "Content-Type: application/yang-data+json" http://127.0.0.1:8080/data/connection/ -d@conn1.json
$ curl -X GET -H "Content-Type: application/yang-data+json" http://127.0.0.1:8080/data/connection=0/
$ curl -X DELETE -H "Content-Type: application/yang-data+json" http://127.0.0.1:8080/data/connection=0/


=== Exercise: RESTCONF TOPOLOGY ===
$ mkdir ~/tfs-ctrl/hackfest/restconf/topologyserver
$ java -jar swagger-codegen-cli.jar generate -i topology.yaml -l python-flask -o topologyserver
$ cd ~/tfs-ctrl/hackfest/restconf/topologyserver
(Open ~/tfs-ctrl/hackfest/restconf/topologyserver/swagger_server/swagger/swagger.yaml and modify all: "name: link_id" for "name: link-id", same for node and port)
$ python3 -m swagger_server

RUN CURL AS CLIENT (In another window)
$curl -X GET -H "Content-Type: application/yang-data+json" http://127.0.0.1:8080/data/topology/
