#!/bin/bash
################################################################################
#
# Graphs REST Tutorial
#
# This script backs the Network Graphs Solver REST tutorial on the doc site
#
# A local Kinetica instance will handle calls to /create/graph and /solve/graph
# for a D.C.-based graph
#
# NOTE:
#       Running the script requires that the 'dc_roads' dataset be ingested
#       into the same Kinetica instance this script will be run against. This
#       dataset can be downloaded from the documentation site and imported via
#       GAdmin.
#
# EXAMPLE:
#       ./graphs_rest.sh localhost
#
################################################################################

THIS_SCRIPT=$(basename ${BASH_SOURCE[0]})
THIS_SCRIPT_LOG=${THIS_SCRIPT%.*}.log
THIS_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
HOSTNAME="${1:-localhost}"

echo
echo GRAPHS REST TUTORIAL OUTPUT
echo ===========================
echo

echo CREATE GRAPH
echo ------------
echo 

curl -sS -X POST --header "Content-Type: application/json" \
-d @create_graph.json http://${HOSTNAME}:9191/create/graph
echo
echo

echo SOLVE GRAPH
echo -----------
echo

echo "SHORTEST PATH"
echo "*************"
echo

curl -sS -X POST --header "Content-Type: application/json" \
-d @solve_graph_shortest_path.json http://${HOSTNAME}:9191/solve/graph
echo
echo

echo "MULTIPLE ROUTING"
echo "****************"
echo

curl -sS -X POST --header "Content-Type: application/json" \
-d @solve_graph_multiple_routing.json http://${HOSTNAME}:9191/solve/graph

