utils

package
v0.0.0-...-5726bf6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 21, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const ConfigDirName = ".wso2micli"
View Source
const Context = "management"
View Source
const Count = "COUNT"
View Source
const CronExpression = "CRON EXPRESSION"
View Source
const DefaultEnvironmentName = "default"
View Source
const DefaultHost = "localhost"
View Source
const DefaultHttpRequestTimeout = 100000
View Source
const DefaultPort = "9164"
View Source
const DefaultRESTAPIBase = HTTPSProtocol + DefaultHost + ":" + DefaultPort + "/" + Context + "/"
View Source
const DefaultRemoteName = "default"
View Source
const DefaultTokenValidityPeriod = "3600"

Other

View Source
const DefaultValue = "DEFAULT VALUE"
View Source
const Description = "DESCRIPTION"
View Source
const HTTPProtocol = "http://"

DO NOT CHANGE THESE MANUALLY Default Server Address

View Source
const HTTPSProtocol = "https://"
View Source
const HeaderAccept = "Accept"
View Source
const HeaderAuthorization = "Authorization"

Headers and Header Values

View Source
const HeaderConnection = "Connection"
View Source
const HeaderConsumes = "Consumes"
View Source
const HeaderContentEncoding = "Content-Encoding"
View Source
const HeaderContentType = "Content-Type"
View Source
const HeaderProduces = "Produces"
View Source
const HeaderTransferEncoding = "transfer-encoding"
View Source
const HeaderValueApplicationJSON = "application/json"
View Source
const HeaderValueApplicationZip = "application/zip"
View Source
const HeaderValueAuthPrefixBasic = "Basic"
View Source
const HeaderValueAuthPrefixBearer = "Bearer"
View Source
const HeaderValueChunked = "chunked"
View Source
const HeaderValueGZIP = "gzip"
View Source
const HeaderValueKeepAlive = "keep-alive"
View Source
const HeaderValueMultiPartFormData = "multipart/form-data"
View Source
const HeaderValueXWWWFormUrlEncoded = "application/x-www-form-urlencoded"
View Source
const HelpCommand = "help"
View Source
const Interval = "INTERVAL"
View Source
const IsActive = "Active"
View Source
const IsMandatory = "MANDATORY"
View Source
const LogPrefixError = "[ERROR] "
View Source
const LogPrefixInfo = "[INFO] "

Logging Prefixes

View Source
const LogPrefixWarning = "[WARN] "
View Source
const LoginResource = "login"
View Source
const LogoutResource = "logout"
View Source
const Method = "METHOD"
View Source
const Name = "NAME"
View Source
const Package = "PACKAGE"
View Source
const PrefixAPIs = "apis"
View Source
const PrefixCarbonApps = "applications"
View Source
const PrefixConnectors = "connectors"
View Source
const PrefixDataServices = "data-services"
View Source
const PrefixEndpoints = "endpoints"
View Source
const PrefixInboundEndpoints = "inbound-endpoints"
View Source
const PrefixLocalEntries = "local-entries"
View Source
const PrefixLogging = "logging"
View Source
const PrefixLogs = "logs"
View Source
const PrefixMessageProcessors = "message-processors"
View Source
const PrefixMessageStores = "message-stores"
View Source
const PrefixProxyServices = "proxy-services"
View Source
const PrefixSequences = "sequences"
View Source
const PrefixServer = "server"
View Source
const PrefixServices = "services"
View Source
const PrefixTasks = "tasks"
View Source
const PrefixTemplates = "templates"
View Source
const PrefixTransactions = "transactions"
View Source
const PrefixUsers = "users"
View Source
const ProjectName = "mi"
View Source
const RemoteConfigFileName = "mi_cli_remote_config.yaml"
View Source
const SampleMainConfigFileName = "main_config.yaml.sample"
View Source
const ServerResource = "server"
View Source
const ShowCommand = "show"
View Source
const Size = "SIZE"
View Source
const Stats = "STATS"
View Source
const Status = "STATUS"
View Source
const Tracing = "TRACING"
View Source
const TransactionCountCmd = "count"
View Source
const TransactionReportCmd = "report"
View Source
const TriggerType = "TRIGGER TYPE"
View Source
const Type = "TYPE"
View Source
const Url = "URL"
View Source
const UserId = "USER_ID"
View Source
const Version = "VERSION"
View Source
const Wsdl11 = "WSDL 1.1"
View Source
const Wsdl20 = "WSDL 2.0"

Variables

View Source
var HomeDirectory = os.Getenv("HOME")
View Source
var IsVerbose bool
View Source
var PathSeparator_ = string(os.PathSeparator)

Functions

func AllowInsecureSSLConnection

func AllowInsecureSSLConnection()

func CloseFile

func CloseFile(f *os.File)

func ContainsString

func ContainsString(slice []string, element string) bool

ContainsString returns true iff slice contains element

func CreateKeyValuePairs

func CreateKeyValuePairs(mapData map[string]string) string

func EnableVerboseMode

func EnableVerboseMode()

func GetCmdFlags

func GetCmdFlags(cmd string) string

func GetCmdUsage

func GetCmdUsage(program, cmd, subcmd, arg string) string

func GetCmdUsageForArgsOnly

func GetCmdUsageForArgsOnly(program, cmd, subcmd string, args []string) string

Create a usage command for a command that always get invoked with its arguments.

func GetCmdUsageForNonArguments

func GetCmdUsageForNonArguments(program, cmd, subcmd string) string

func GetCmdUsageMultipleArgs

func GetCmdUsageMultipleArgs(program, cmd, subcmd string, args []string) string

func GetConfigFilePath

func GetConfigFilePath(configFileName string) string

func GetFileContent

func GetFileContent(filePath string) string

func GetRESTAPIBase

func GetRESTAPIBase() string

func GetRemoteConfigFilePath

func GetRemoteConfigFilePath() string

func GetSecurityDirectoryPath

func GetSecurityDirectoryPath() string

func GetTableWriter

func GetTableWriter() *tablewriter.Table

func GetUrlAndParams

func GetUrlAndParams(urlPrefix, key, value string) (string, map[string]string)

func GetkeyStoreInfoFileLocation

func GetkeyStoreInfoFileLocation() string

func HandleErrorAndExit

func HandleErrorAndExit(msg string, err error)

func InitRemoteConfigData

func InitRemoteConfigData()

func InvokeDELETERequest

func InvokeDELETERequest(url string, headers map[string]string) (*resty.Response, error)

Invoke http-delete request using go-resty

func InvokeGETRequest

func InvokeGETRequest(url string, headers map[string]string, params map[string]string) (*resty.Response, error)

Invoke http-get request using go-resty

func InvokePOSTRequest

func InvokePOSTRequest(url string, headers map[string]string, body map[string]string) (*resty.Response, error)

Invoke http-post request using go-resty

func InvokeUPDATERequest

func InvokeUPDATERequest(url string, headers map[string]string, body map[string]string) (*resty.Response, error)

Invoke http-put request using go-resty

func IsFileExist

func IsFileExist(path string) bool

Check whether the file exists.

func IsValidConsoleInput

func IsValidConsoleInput(inputs map[string]string) bool

func Logf

func Logf(format string, a ...interface{})

func Logln

func Logln(a ...interface{})

func MakeDirectoryIfNotExists

func MakeDirectoryIfNotExists(path string) error

func NormalizeFilePath

func NormalizeFilePath(path string) string

func PrintItemList

func PrintItemList(itemList IterableStringArray, columnData []string, emptyWarning string)

func PrintList

func PrintList(list []string)

func PromptForPassword

func PromptForPassword() string

func PromptForUsername

func PromptForUsername() string

func PutQueryParamsToMap

func PutQueryParamsToMap(paramMap map[string]string, key string, value string) map[string]string

func SetProperties

func SetProperties(variables map[string]string, fileName string)

func UnmarshalData

func UnmarshalData(url string, headers map[string]string, params map[string]string,
	model interface{}) (interface{}, error)

Unmarshal Data from the response to the respective struct @param url: url of rest api @param headers: HTTP headers @param model: struct object @param params: parameters for the HTTP call @return struct object @return error

func UnmarshalJsonToStringMap

func UnmarshalJsonToStringMap(body []byte) map[string]string

func UnmarshalLogFileData

func UnmarshalLogFileData(url string, headers map[string]string, params map[string]string, filename string)

func UpdateMIEndpoint

func UpdateMIEndpoint(endpointName string, intendedState string) (interface{}, error)

func UpdateMILogger

func UpdateMILogger(loggerName, loggingLevel, logClass string) (interface{}, error)

func UpdateMIMessageProcessor

func UpdateMIMessageProcessor(messageProcessorName, messageProcessorStateValue string) (interface{}, error)

func UpdateMIProxySerice

func UpdateMIProxySerice(proxyServiceName string, intendedState string) (interface{}, error)

func WhereAmI

func WhereAmI(depthList ...int) string

return a string containing the file name, function name and the line number of a specified entry on the call stack

func WriteLinesToCSVFile

func WriteLinesToCSVFile(lines [][]string, targetPath string)

Given an 2-D string array and a target filePath, write the content of the array as csv values to the file.

Types

type IterableStringArray

type IterableStringArray interface {
	GetCount() int32
	GetDataIterator() <-chan []string
}

type KeyStore

type KeyStore struct {
	Location string
	Type     string
	Alias    string
	Password string
}
var KeyStoreData KeyStore

func (*KeyStore) SetKeyStore

func (keyStore *KeyStore) SetKeyStore(file string, storeType string, alias string, password string) error

type Logger

type Logger struct {
	LoggerName    string `json:"loggerName"`
	ComponentName string `json:"componentName"`
	LogLevel      string `json:"level"`
}

type LoginResponse

type LoginResponse struct {
	AccessToken string `yaml:"AccessToken"`
}

type LogoutResponse

type LogoutResponse struct {
}

type Remote

type Remote struct {
	Url         string `yaml:"remote_address"`
	Port        string `yaml:"remote_port"`
	AccessToken string `yaml:"access_token"`
}

type RemoteConfig

type RemoteConfig struct {
	Remotes       Remotes `yaml:"remotes"`
	CurrentRemote string  `yaml:"current_remote"`
}
var RemoteConfigData RemoteConfig

func (*RemoteConfig) AddRemote

func (remoteConfig *RemoteConfig) AddRemote(name string, host string, port string) error

func (*RemoteConfig) Load

func (remoteConfig *RemoteConfig) Load(filePath string)

func (*RemoteConfig) Persist

func (remoteConfig *RemoteConfig) Persist(filePath string)

func (*RemoteConfig) RemoveRemote

func (remoteConfig *RemoteConfig) RemoveRemote(name string) error

func (*RemoteConfig) Reset

func (remoteConfig *RemoteConfig) Reset()

func (*RemoteConfig) SelectRemote

func (remoteConfig *RemoteConfig) SelectRemote(name string) error

func (*RemoteConfig) UpdateCurrentRemoteToken

func (remoteConfig *RemoteConfig) UpdateCurrentRemoteToken(accessToken string) error

update the access token of the current remote

func (*RemoteConfig) UpdateRemote

func (remoteConfig *RemoteConfig) UpdateRemote(name string, host string, port string) error

type RemoteInfo

type RemoteInfo struct {
	ProductVersion     string `json:"productVersion"`
	RepositoryLocation string `json:"repositoryLocation"`
	WorkDirectory      string `json:"workDirectory"`
	CarbonHome         string `json:"carbonHome"`
	ProductName        string `json:"productName"`
	JavaHome           string `json:"javaHome"`
}

type RemoteSummary

type RemoteSummary struct {
	Name     string `json:"name"`
	Version  string `json:"version"`
	Location string `json:"location"`
}

type Remotes

type Remotes map[string]Remote

type Service

type Service struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Type        string `json:"type"`
	Status      string `json:"status"`
	TryItURL    string `json:"tryItUrl"`
}

Directories

Path Synopsis
* Copyright (c) 2020, WSO2 Inc.
* Copyright (c) 2020, WSO2 Inc.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL