Compare commits

...

11 Commits
v0.1.0 ... main

Author SHA1 Message Date
bdd8835a07 Fix trailing punctuation 2023-10-20 16:23:24 -05:00
858994eef1 remove path from example 2023-10-20 16:22:21 -05:00
4dd86376c9 install now always uses latest release and updated
README with installation instructions
2023-10-18 00:02:46 -05:00
b438f31f89 Adding install script. Fixes #4 2023-10-17 23:40:18 -05:00
54736f440a revert 1f202279c9f0d11bd5d148fd77fb102d669337d2
revert Adding install script.  Fixes #3
2023-10-17 23:39:37 -05:00
1f202279c9 Adding install script. Fixes #3 2023-10-17 23:37:40 -05:00
98a65cdea8 added notrunc flag 2023-10-16 21:49:53 -05:00
77f520aa31 status property is not a string 2023-09-07 15:09:00 -05:00
e2f6da1b5f reducing scope of token request 2023-05-02 16:55:05 -05:00
f8a72a792f split out example and result 2023-05-02 16:47:10 -05:00
794664e3f1 Added examples 2023-05-02 16:34:21 -05:00
5 changed files with 128 additions and 13 deletions

View File

@ -25,6 +25,44 @@ Flags:
-v, --verbose verbose logging
```
## Configuration
Any of the flag values can be set using a YAML configuration file. By default it will try and read the file $HOME/.tps.yaml.
### Example configuration (~/.tps.yaml)
```yaml
hostname: em5.verint.training
username: apiclient
password: apiclient12345
clientId: default
```
## Example usage
```shell
tps list -f conversation-service
```
```shell
Using config file: /Users/Peter.Morton/.tps.yaml
+--------------------------------------------------------------------------------------------+-----------+----------------------+-------------------------+
| PROPERTY NAME | VALUE | LAST MODIFIED BY | LAST MODIFIED DATE |
+--------------------------------------------------------------------------------------------+-----------+----------------------+-------------------------+
| conversation-service.initialised | true | conversation-service | 2022-04-08T19:16:08.226 |
| conversation-service.upload.default.max-number-of-customer-attachments | 10 | conversation-service | 2022-04-08T19:16:08.197 |
| conversation-service.upload.default.max-number-of-customer-attachments-bytes | 100000000 | conversation-service | 2022-04-08T19:16:08.224 |
| conversation-service.upload.default.number-of-customer-attachments-bytes-period-in-minutes | 10 | conversation-service | 2022-04-08T19:16:08.22 |
| conversation-service.upload.default.number-of-customer-attachments-period-in-minutes | 10 | conversation-service | 2022-04-08T19:16:08.214 |
+--------------------------------------------------------------------------------------------+-----------+----------------------+-------------------------+
```
## Building
make
## Installing
```shell
curl -sSL https://git.mortons.site/verint.com/tps-cli/raw/branch/main/install.sh | bash
```

View File

@ -15,6 +15,7 @@ import (
)
var filter string
var notrunc bool
// listCmd represents the list command
var listCmd = &cobra.Command{
@ -43,7 +44,11 @@ var listCmd = &cobra.Command{
t.SetOutputMirror(os.Stdout)
t.AppendHeader(table.Row{"Property Name", "Value", "Last Modified By", "Last Modified Date"})
for _, p := range collection.Member {
t.AppendRow([]interface{}{p.Name, truncateText(p.Value, 80), p.LastModifiedBy, p.LastModifiedDate})
text := p.Value
if !notrunc {
text = truncateText(text, 80)
}
t.AppendRow([]interface{}{p.Name, text, p.LastModifiedBy, p.LastModifiedDate})
}
t.Render()
@ -67,5 +72,6 @@ func init() {
// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
listCmd.Flags().StringVarP(&filter, "filter", "f", "", "Filter properties using a query. For example --fitler \"redaction\"")
listCmd.Flags().StringVarP(&filter, "filter", "f", "", "Filter properties using a query. For example --filter \"redaction\"")
listCmd.Flags().BoolVarP(&notrunc, "notrunc", "", false, "Prevent truncation of values")
}

71
install.sh Executable file
View File

@ -0,0 +1,71 @@
#!/usr/bin/env bash
# shellcheck disable=SC1090
set -e
OS="$(uname -s)"
ARCH="$(uname -m)"
VERSION=0.2.0
case $OS in
"Linux")
case $ARCH in
"x86_64")
ARCH=amd64
;;
"aarch64")
ARCH=arm64
;;
"armv6" | "armv7l")
ARCH=armv6l
;;
"armv8")
ARCH=arm64
;;
"i686")
ARCH=386
;;
.*386.*)
ARCH=386
;;
esac
PLATFORM="linux_$ARCH"
;;
"Darwin")
case $ARCH in
"x86_64")
ARCH=amd64
;;
"arm64")
ARCH=arm64
;;
esac
PLATFORM="darwin_$ARCH"
;;
esac
print_help() {
echo "Usage: bash goinstall.sh OPTIONS"
echo -e "\nOPTIONS:"
echo -e " --remove\tRemove currently installed version"
echo -e " --version\tSpecify a version number to install"
}
if [ -z "$PLATFORM" ]; then
echo "Your operating system is not supported by the script."
exit 1
fi
# get latest tag path
TAG_PATH="$(curl -s https://git.mortons.site/verint.com/tps-cli/releases/latest | sed -n 's/^<a.* href="\([^"]*\).*/\1/p')"
TAG_PATH="${TAG_PATH/tag/download}"
if hash wget 2>/dev/null; then
wget https://git.mortons.site${TAG_PATH}/tps_${PLATFORM} -O "tps"
else
curl -o "tps" https://git.mortons.site${TAG_PATH}/tps_${PLATFORM}
fi
chmod u+x tps

View File

@ -7,7 +7,6 @@ import (
"fmt"
"io"
"net/http"
"strings"
log "github.com/sirupsen/logrus"
"golang.org/x/oauth2"
@ -31,12 +30,12 @@ func GetAccessToken(c *Config) (string, error) {
Endpoint: oauth2.Endpoint{
TokenURL: "https://" + c.Hostname + "/oidc-token-service/" + c.ClientID + "/token",
},
Scopes: []string{"oidc", "tags", "context_entitlements", "content_entitlements", "em_api_access"},
Scopes: []string{"em_api_access"},
}
log.WithFields(log.Fields{"conf": fmt.Sprintf("%+v", conf)}).Debug()
token, err := conf.PasswordCredentialsToken(context.TODO(), c.Username, c.Password)
if err != nil {
log.Error("Error retrieving AccessToken. Chech configuration, username and password")
log.Error("Error retrieving AccessToken. Check configuration, username and password")
return "", err
}
log.WithFields(log.Fields{"token": fmt.Sprintf("%+v", token.AccessToken)}).Debug()
@ -121,8 +120,9 @@ func UpdateProperty(c *Config, p []properties.PropertyUpdateOrCreate) error {
log.Fatal(err)
return err
}
if strings.HasPrefix("2", res.Status) {
log.Error(rp[0].Status + rp[0].Description)
if rp[0].Status >= 400 {
log.Error(fmt.Sprint(rp[0].Status) + ":" + rp[0].Description)
}
return nil
@ -162,7 +162,7 @@ func DeleteProperty(c *Config, p []properties.PropertyDelete) error {
return err
}
log.Debug(string(response))
log.Debug("client.DeleteProperty: response is " + string(response))
rp := []properties.PropertyDelete{}
@ -172,8 +172,8 @@ func DeleteProperty(c *Config, p []properties.PropertyDelete) error {
return err
}
if strings.HasPrefix("2", res.Status) {
log.Error(rp[0].Status + rp[0].Description)
if rp[0].Status >= 400 {
log.Error(fmt.Sprint(rp[0].Status) + ":" + rp[0].Description)
}
return nil

View File

@ -5,7 +5,7 @@ type Property struct {
Name string `json:"vcfg:name"`
Value string `json:"vcfg:value"`
ID string `json:"vcfg:id,omitempty"`
Status string `json:"vcfg:status,omitempty"`
Status int `json:"vcfg:status,omitempty"`
Prefix string `json:"vcfg:prefix,omitempty"`
LastModifiedBy string `json:"vcfg:lastModifiedBy,omitempty"`
LastModifiedDate string `json:"vcfg:lastModifiedDate,omitempty"`
@ -20,13 +20,13 @@ type PropertyUpdateOrCreate struct {
Type string `json:"@type"`
Name string `json:"vcfg:name"`
Value string `json:"vcfg:value"`
Status string `json:"vcfg:status"`
Status int `json:"vcfg:status"`
Description string `json:"vcfg:description"`
}
type PropertyDelete struct {
Type string `json:"@type"`
Name string `json:"vcfg:name"`
Status string `json:"vcfg:status"`
Status int `json:"vcfg:status"`
Description string `json:"vcfg:description"`
}