Support for XApp configuration update (new retry)
[ric-plt/appmgr.git] / scripts / appmgrcli
index ac00485..22f0677 100755 (executable)
@@ -125,6 +125,9 @@ case $1 in
   (health|heal)
     cmd=health
     ;;
+  (config|upload)
+    cmd=config
+    ;;
   (help)
     usage
     exit 0
@@ -167,6 +170,7 @@ rest() {
   if [ "x$3" != "x" ]; then
     data="--data $3"
   fi
+
   if curl --silent --show-error --connect-timeout 20 --header "Content-Type: application/json" -X $1 -o $resultfile "http://${host}:${port}$2" $data 2> $errfile ;then
     status=0
   else
@@ -188,6 +192,7 @@ base=/ric/v1
 base_xapps=$base/xapps
 base_health=$base/health
 base_subs=$base/subscriptions
+base_config=$base/config
 
 do_deploy() {
   if [ "x$1" != "x" ]; then
@@ -333,6 +338,40 @@ do_subscriptions() {
   esac
 }
 
+do_config() {
+  local urlpath
+  urlpath=$base_config
+  case $1 in
+    (get|list)
+      if [ "x$2" != "x" ]; then
+        urlpath="$urlpath/$2"
+      fi
+      if rest GET $urlpath; then
+        json_reformat < $resultfile
+      else
+        status=1
+      fi
+    ;;
+    (add|update)
+      if rest POST $urlpath "@$2" ; then
+        cat $resultfile
+      else
+        status=1
+    fi
+    ;;
+    (del|delete|remove|rem)
+      if rest DELETE $urlpath "@$2" ; then
+        cat $resultfile
+      else
+        status=1
+    fi
+    ;;
+    (*)
+      echo "$myname: unrecognized config subcommand $1"
+      status=1
+  esac
+}
+
 case $cmd in
   (deploy)
     do_deploy "$2"
@@ -346,6 +385,9 @@ case $cmd in
   (subscriptions)
     do_subscriptions "$2" "$3" "$4" "$5" "$6" "$7"
     ;;
+  (config)
+    do_config "$2" "$3"
+    ;;
   (health)
     if rest GET $base_health ; then
       echo OK