Filip Krzywka | ccdbec8 | 2018-12-12 08:14:57 +0100 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | # ============LICENSE_START======================================================= |
| 3 | # dcaegen2-collectors-veshv |
| 4 | # ================================================================================ |
| 5 | # Copyright (C) 2018 NOKIA |
| 6 | # ================================================================================ |
| 7 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | # you may not use this file except in compliance with the License. |
| 9 | # You may obtain a copy of the License at |
| 10 | # |
| 11 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | # |
| 13 | # Unless required by applicable law or agreed to in writing, software |
| 14 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | # See the License for the specific language governing permissions and |
| 17 | # limitations under the License. |
| 18 | # ============LICENSE_END========================================================= |
| 19 | |
| 20 | set -euo pipefail |
| 21 | |
| 22 | |
| 23 | usage() { |
| 24 | echo "Resets dcae-app-simulator consumed messages count" |
| 25 | echo "Usage: $0 [-h|--help] [-v|--verbose]" |
| 26 | exit 1 |
| 27 | } |
| 28 | |
| 29 | optspec=":vh-:" # catch v, h and - |
| 30 | while getopts "$optspec" arg; do |
| 31 | case "${arg}" in |
| 32 | -) # handle longopts |
| 33 | case "${OPTARG}" in |
| 34 | verbose) |
| 35 | VERBOSE=True |
| 36 | ;; |
| 37 | help) |
| 38 | usage |
| 39 | ;; |
| 40 | *) |
| 41 | echo "Unknown option --${OPTARG}" >&2 |
| 42 | usage |
| 43 | ;; |
| 44 | esac |
| 45 | ;; |
| 46 | v) |
| 47 | VERBOSE=True |
| 48 | ;; |
| 49 | h) |
| 50 | usage |
| 51 | ;; |
| 52 | *) |
| 53 | echo "Unknown option -${OPTARG}" >&2 |
| 54 | usage |
| 55 | ;; |
| 56 | esac |
| 57 | done |
| 58 | shift $((OPTIND-1)) |
| 59 | |
Filip Krzywka | 5180f3f | 2019-01-08 07:53:25 +0100 | [diff] [blame] | 60 | DEVELOPMENT_BIN_DIRECTORY=$(realpath $(dirname "$0")) |
| 61 | source ${DEVELOPMENT_BIN_DIRECTORY}/constants.sh |
| 62 | |
Filip Krzywka | ccdbec8 | 2018-12-12 08:14:57 +0100 | [diff] [blame] | 63 | if [ -n "${VERBOSE+x}" ]; then |
Filip Krzywka | 5180f3f | 2019-01-08 07:53:25 +0100 | [diff] [blame] | 64 | echo "Requesting DCAE app running on port ${DCAE_APP_PORT} to reset messages count" |
Filip Krzywka | ccdbec8 | 2018-12-12 08:14:57 +0100 | [diff] [blame] | 65 | fi |
| 66 | |
Filip Krzywka | 5180f3f | 2019-01-08 07:53:25 +0100 | [diff] [blame] | 67 | curl --request DELETE ${DCAE_APP_ADDRESS}/messages |
Filip Krzywka | ccdbec8 | 2018-12-12 08:14:57 +0100 | [diff] [blame] | 68 | echo |