Compare commits

..

No commits in common. "main" and "v0.1.0" have entirely different histories.
main ... v0.1.0

5 changed files with 13 additions and 128 deletions

View File

@ -25,44 +25,6 @@ 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,7 +15,6 @@ import (
)
var filter string
var notrunc bool
// listCmd represents the list command
var listCmd = &cobra.Command{
@ -44,11 +43,7 @@ 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 {
text := p.Value
if !notrunc {
text = truncateText(text, 80)
}
t.AppendRow([]interface{}{p.Name, text, p.LastModifiedBy, p.LastModifiedDate})
t.AppendRow([]interface{}{p.Name, truncateText(p.Value, 80), p.LastModifiedBy, p.LastModifiedDate})
}
t.Render()
@ -72,6 +67,5 @@ 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 --filter \"redaction\"")
listCmd.Flags().BoolVarP(&notrunc, "notrunc", "", false, "Prevent truncation of values")
listCmd.Flags().StringVarP(&filter, "filter", "f", "", "Filter properties using a query. For example --fitler \"redaction\"")
}

View File

@ -1,71 +0,0 @@
#!/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,6 +7,7 @@ import (
"fmt"
"io"
"net/http"
"strings"
log "github.com/sirupsen/logrus"
"golang.org/x/oauth2"
@ -30,12 +31,12 @@ func GetAccessToken(c *Config) (string, error) {
Endpoint: oauth2.Endpoint{
TokenURL: "https://" + c.Hostname + "/oidc-token-service/" + c.ClientID + "/token",
},
Scopes: []string{"em_api_access"},
Scopes: []string{"oidc", "tags", "context_entitlements", "content_entitlements", "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. Check configuration, username and password")
log.Error("Error retrieving AccessToken. Chech configuration, username and password")
return "", err
}
log.WithFields(log.Fields{"token": fmt.Sprintf("%+v", token.AccessToken)}).Debug()
@ -120,9 +121,8 @@ func UpdateProperty(c *Config, p []properties.PropertyUpdateOrCreate) error {
log.Fatal(err)
return err
}
if rp[0].Status >= 400 {
log.Error(fmt.Sprint(rp[0].Status) + ":" + rp[0].Description)
if strings.HasPrefix("2", res.Status) {
log.Error(rp[0].Status + rp[0].Description)
}
return nil
@ -162,7 +162,7 @@ func DeleteProperty(c *Config, p []properties.PropertyDelete) error {
return err
}
log.Debug("client.DeleteProperty: response is " + string(response))
log.Debug(string(response))
rp := []properties.PropertyDelete{}
@ -172,8 +172,8 @@ func DeleteProperty(c *Config, p []properties.PropertyDelete) error {
return err
}
if rp[0].Status >= 400 {
log.Error(fmt.Sprint(rp[0].Status) + ":" + rp[0].Description)
if strings.HasPrefix("2", res.Status) {
log.Error(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 int `json:"vcfg:status,omitempty"`
Status string `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 int `json:"vcfg:status"`
Status string `json:"vcfg:status"`
Description string `json:"vcfg:description"`
}
type PropertyDelete struct {
Type string `json:"@type"`
Name string `json:"vcfg:name"`
Status int `json:"vcfg:status"`
Status string `json:"vcfg:status"`
Description string `json:"vcfg:description"`
}