4 # ============LICENSE_START=======================================================
6 # ================================================================================
7 # Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
8 # Modifications Copyright (C) 2024 Nordix Foundation.
9 # ================================================================================
10 # Licensed under the Apache License, Version 2.0 (the "License");
11 # you may not use this file except in compliance with the License.
12 # You may obtain a copy of the License at
14 # http://www.apache.org/licenses/LICENSE-2.0
16 # Unless required by applicable law or agreed to in writing, software
17 # distributed under the License is distributed on an "AS IS" BASIS,
18 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 # See the License for the specific language governing permissions and
20 # limitations under the License.
21 # ============LICENSE_END=========================================================
25 echo -n "Usage: $(basename $0) "
26 echo -n "[(-d|--debug)] "
27 echo -n "(-h|--host) <bus-host> "
28 echo -n "[(-p|--port) <bus-port>] "
29 echo -n "(-k|--key) <api-key> "
30 echo -n "(-s|--secret) <api-secret> "
31 echo -n "(-P|--producer-key) <producer-key> "
32 echo -n "(-C|--consumer-key) <consumer-key> "
33 echo "(-t|--topic) <topic> "
38 # command line options parsing
58 -P|--producer-key) shift
59 URL_CONTEXT="producers"
63 -C|--consumer-key) shift
64 URL_CONTEXT="consumers"
75 if [ -z "${BUS_HOST}" ]; then
76 echo "An UEB/KAFKA server must be provided."
82 if [ -z "${API_KEY}" ]; then
83 echo "The API Key must be provided."
88 if [ -z "${API_SECRET}" ]; then
89 echo "The API Secret must be provided."
94 if [ -z "${TOPIC}" ]; then
95 echo "The Topic Name must be provided."
100 if [ -z "${PRODUCER_KEY}" ] && [ -z "${CONSUMER_KEY}" ]; then
101 echo "Either the Producer or Consumer options must be provided."
106 if [ -n "${PRODUCER_KEY}" ] && [ -n "${CONSUMER_KEY}" ]; then
107 echo "Only and only one of the Producer or Consumer options must be provided."
114 DATE_HASH=$(echo -n "${DATE}" | openssl sha1 -hmac "${API_SECRET}" -binary | openssl base64)
117 curl --silent -X PUT \
119 --header "X-CambriaDate: ${DATE}" \
120 --header "X-CambriaAuth: ${API_KEY}:${DATE_HASH}" \
121 --header "Content-Type: application/json" \
123 http://${BUS_HOST}:${BUS_PORT}/topics/${TOPIC}/${URL_CONTEXT}/${KEY}