Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bdd8835a07 | |||
| 858994eef1 | |||
| 4dd86376c9 | |||
| b438f31f89 | |||
| 54736f440a | |||
| 1f202279c9 | |||
| 98a65cdea8 | |||
| 77f520aa31 | |||
| e2f6da1b5f | |||
| f8a72a792f | |||
| 794664e3f1 |
38
README.md
38
README.md
@ -25,6 +25,44 @@ Flags:
|
|||||||
-v, --verbose verbose logging
|
-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
|
## Building
|
||||||
|
|
||||||
make
|
make
|
||||||
|
|
||||||
|
## Installing
|
||||||
|
|
||||||
|
```shell
|
||||||
|
curl -sSL https://git.mortons.site/verint.com/tps-cli/raw/branch/main/install.sh | bash
|
||||||
|
```
|
||||||
|
|||||||
10
cmd/list.go
10
cmd/list.go
@ -15,6 +15,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var filter string
|
var filter string
|
||||||
|
var notrunc bool
|
||||||
|
|
||||||
// listCmd represents the list command
|
// listCmd represents the list command
|
||||||
var listCmd = &cobra.Command{
|
var listCmd = &cobra.Command{
|
||||||
@ -43,7 +44,11 @@ var listCmd = &cobra.Command{
|
|||||||
t.SetOutputMirror(os.Stdout)
|
t.SetOutputMirror(os.Stdout)
|
||||||
t.AppendHeader(table.Row{"Property Name", "Value", "Last Modified By", "Last Modified Date"})
|
t.AppendHeader(table.Row{"Property Name", "Value", "Last Modified By", "Last Modified Date"})
|
||||||
for _, p := range collection.Member {
|
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()
|
t.Render()
|
||||||
|
|
||||||
@ -67,5 +72,6 @@ func init() {
|
|||||||
|
|
||||||
// Cobra supports local flags which will only run when this command
|
// Cobra supports local flags which will only run when this command
|
||||||
// is called directly, e.g.:
|
// 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(¬runc, "notrunc", "", false, "Prevent truncation of values")
|
||||||
}
|
}
|
||||||
|
|||||||
71
install.sh
Executable file
71
install.sh
Executable 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
|
||||||
@ -7,7 +7,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"golang.org/x/oauth2"
|
"golang.org/x/oauth2"
|
||||||
@ -31,12 +30,12 @@ func GetAccessToken(c *Config) (string, error) {
|
|||||||
Endpoint: oauth2.Endpoint{
|
Endpoint: oauth2.Endpoint{
|
||||||
TokenURL: "https://" + c.Hostname + "/oidc-token-service/" + c.ClientID + "/token",
|
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()
|
log.WithFields(log.Fields{"conf": fmt.Sprintf("%+v", conf)}).Debug()
|
||||||
token, err := conf.PasswordCredentialsToken(context.TODO(), c.Username, c.Password)
|
token, err := conf.PasswordCredentialsToken(context.TODO(), c.Username, c.Password)
|
||||||
if err != nil {
|
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
|
return "", err
|
||||||
}
|
}
|
||||||
log.WithFields(log.Fields{"token": fmt.Sprintf("%+v", token.AccessToken)}).Debug()
|
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)
|
log.Fatal(err)
|
||||||
return 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
|
return nil
|
||||||
@ -162,7 +162,7 @@ func DeleteProperty(c *Config, p []properties.PropertyDelete) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debug(string(response))
|
log.Debug("client.DeleteProperty: response is " + string(response))
|
||||||
|
|
||||||
rp := []properties.PropertyDelete{}
|
rp := []properties.PropertyDelete{}
|
||||||
|
|
||||||
@ -172,8 +172,8 @@ func DeleteProperty(c *Config, p []properties.PropertyDelete) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasPrefix("2", res.Status) {
|
if rp[0].Status >= 400 {
|
||||||
log.Error(rp[0].Status + rp[0].Description)
|
log.Error(fmt.Sprint(rp[0].Status) + ":" + rp[0].Description)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@ -5,7 +5,7 @@ type Property struct {
|
|||||||
Name string `json:"vcfg:name"`
|
Name string `json:"vcfg:name"`
|
||||||
Value string `json:"vcfg:value"`
|
Value string `json:"vcfg:value"`
|
||||||
ID string `json:"vcfg:id,omitempty"`
|
ID string `json:"vcfg:id,omitempty"`
|
||||||
Status string `json:"vcfg:status,omitempty"`
|
Status int `json:"vcfg:status,omitempty"`
|
||||||
Prefix string `json:"vcfg:prefix,omitempty"`
|
Prefix string `json:"vcfg:prefix,omitempty"`
|
||||||
LastModifiedBy string `json:"vcfg:lastModifiedBy,omitempty"`
|
LastModifiedBy string `json:"vcfg:lastModifiedBy,omitempty"`
|
||||||
LastModifiedDate string `json:"vcfg:lastModifiedDate,omitempty"`
|
LastModifiedDate string `json:"vcfg:lastModifiedDate,omitempty"`
|
||||||
@ -20,13 +20,13 @@ type PropertyUpdateOrCreate struct {
|
|||||||
Type string `json:"@type"`
|
Type string `json:"@type"`
|
||||||
Name string `json:"vcfg:name"`
|
Name string `json:"vcfg:name"`
|
||||||
Value string `json:"vcfg:value"`
|
Value string `json:"vcfg:value"`
|
||||||
Status string `json:"vcfg:status"`
|
Status int `json:"vcfg:status"`
|
||||||
Description string `json:"vcfg:description"`
|
Description string `json:"vcfg:description"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type PropertyDelete struct {
|
type PropertyDelete struct {
|
||||||
Type string `json:"@type"`
|
Type string `json:"@type"`
|
||||||
Name string `json:"vcfg:name"`
|
Name string `json:"vcfg:name"`
|
||||||
Status string `json:"vcfg:status"`
|
Status int `json:"vcfg:status"`
|
||||||
Description string `json:"vcfg:description"`
|
Description string `json:"vcfg:description"`
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user