Documentation
¶
Index ¶
- Constants
- Variables
- func AllowOutput()
- func ArkVersion() string
- func ConvertToCamelCase(data interface{}, schema *reflect.Type) interface{}
- func ConvertToSnakeCase(data interface{}, schema *reflect.Type) interface{}
- func DeserializeJSONSnake(response io.ReadCloser) (interface{}, error)
- func DeserializeJSONSnakeSchema(response io.ReadCloser, schema *reflect.Type) (interface{}, error)
- func DisableCertificateVerification()
- func DisableColor()
- func DisableInteractive()
- func DisableVerboseLogging()
- func DisallowOutput()
- func EnableCertificateVerification()
- func EnableColor()
- func EnableInteractive()
- func EnableVerboseLogging(logLevel string)
- func ExpandFolder(folder string) string
- func IsAllowingOutput() bool
- func IsColoring() bool
- func IsConnectionRefused(err error) bool
- func IsInteractive() bool
- func IsVerifyingCertificates() bool
- func LogLevelFromEnv() int
- func MarshalCookies(cookieJar *cookiejar.Jar) ([]byte, error)
- func RandomIPAddress() string
- func RandomNumberString(n int) string
- func RandomPassword(n int) string
- func RandomString(n int) string
- func RetryCall(fn func() error, tries int, delay int, maxDelay *int, backoff int, ...) error
- func SerializeJSONCamel(item interface{}) (map[string]interface{}, error)
- func SerializeJSONCamelSchema(item interface{}, schema *reflect.Type) (map[string]interface{}, error)
- func SerializeResponseToJSON(response io.ReadCloser) string
- func SetArkVersion(version string)
- func SetLoggerStyle(loggerStyle string)
- func SetTrustedCertificate(cert string)
- func StrToLogLevel(logLevelStr string) int
- func TrustedCertificate() string
- func UnmarshalCookies(cookies []byte, cookieJar *cookiejar.Jar) error
- func UserAgent() string
- type ArkClient
- func (ac *ArkClient) Delete(ctx context.Context, route string, body interface{}) (*http.Response, error)
- func (ac *ArkClient) Get(ctx context.Context, route string, params map[string]string) (*http.Response, error)
- func (ac *ArkClient) GetCookieJar() *cookiejar.Jar
- func (ac *ArkClient) GetCookies() map[string]string
- func (ac *ArkClient) GetHeaders() map[string]string
- func (ac *ArkClient) GetToken() string
- func (ac *ArkClient) GetTokenType() string
- func (ac *ArkClient) Options(ctx context.Context, route string) (*http.Response, error)
- func (ac *ArkClient) Patch(ctx context.Context, route string, body interface{}) (*http.Response, error)
- func (ac *ArkClient) Post(ctx context.Context, route string, body interface{}) (*http.Response, error)
- func (ac *ArkClient) Put(ctx context.Context, route string, body interface{}) (*http.Response, error)
- func (ac *ArkClient) SetCookie(key string, value string)
- func (ac *ArkClient) SetCookies(cookies map[string]string)
- func (ac *ArkClient) SetHeader(key string, value string)
- func (ac *ArkClient) SetHeaders(headers map[string]string)
- func (ac *ArkClient) UpdateCookies(cookies map[string]string)
- func (ac *ArkClient) UpdateHeaders(headers map[string]string)
- func (ac *ArkClient) UpdateToken(token string, tokenType string)
- type ArkKeyring
- func (a *ArkKeyring) GetKeyring(enforceBasicKeyring bool) (*common.BasicKeyring, error)
- func (a *ArkKeyring) LoadToken(profile *models.ArkProfile, postfix string, enforceBasicKeyring bool) (*auth.ArkToken, error)
- func (a *ArkKeyring) SaveToken(profile *models.ArkProfile, token *auth.ArkToken, postfix string, ...) error
- type ArkLogger
- func (l *ArkLogger) Debug(msg string, v ...interface{})
- func (l *ArkLogger) Error(msg string, v ...interface{})
- func (l *ArkLogger) Fatal(msg string, v ...interface{})
- func (l *ArkLogger) Info(msg string, v ...interface{})
- func (l *ArkLogger) LogLevel() int
- func (l *ArkLogger) SetVerbose(value bool)
- func (l *ArkLogger) Warning(msg string, v ...interface{})
- type ArkPage
Constants ¶
const ( ArkBasicKeyringOverrideEnvVar = "ARK_BASIC_KEYRING" DBusSessionEnvVar = "DBUS_SESSION_BUS_ADDRESS" DefaultExpirationGraceDeltaSeconds = 60 MaxKeyringRecordTimeHours = 12 )
Env vars and definitions
const ( Debug = 4 Info = 3 Warning = 2 Error = 1 Critical = 0 Unknown = -1 )
Log Levels for ArkLogger
const ( LoggerStyle = "LOGGER_STYLE" LogLevel = "LOG_LEVEL" LoggerStyleDefault = "default" )
Logger Environment Variables
const (
ArkDisableCertificateVerificationEnvVar = "ARK_DISABLE_CERTIFICATE_VERIFICATION"
)
ArkDisableCertificateVerificationEnvVar Environment variable for disabling certificate validation
Variables ¶
var GlobalLogger = GetLogger("ark-sdk", -1)
GlobalLogger is the global logger instance for the Ark SDK.
Functions ¶
func ArkVersion ¶ added in v1.3.0
func ArkVersion() string
ArkVersion returns the current version of the Ark SDK.
func ConvertToCamelCase ¶ added in v1.3.0
ConvertToCamelCase converts a map with snake_case keys to camelCase keys.
func ConvertToSnakeCase ¶ added in v1.3.0
ConvertToSnakeCase converts a map with camelCase keys to snake_case keys.
func DeserializeJSONSnake ¶
func DeserializeJSONSnake(response io.ReadCloser) (interface{}, error)
DeserializeJSONSnake takes an io.ReadCloser response and deserializes it into a map with snake_case keys.
func DeserializeJSONSnakeSchema ¶ added in v1.3.0
func DeserializeJSONSnakeSchema(response io.ReadCloser, schema *reflect.Type) (interface{}, error)
DeserializeJSONSnakeSchema takes an io.ReadCloser response and deserializes it into a map with snake_case keys.
func DisableCertificateVerification ¶
func DisableCertificateVerification()
DisableCertificateVerification disables certificate verification.
func DisableVerboseLogging ¶
func DisableVerboseLogging()
DisableVerboseLogging disables verbose logging.
func EnableCertificateVerification ¶
func EnableCertificateVerification()
EnableCertificateVerification enables certificate verification.
func EnableVerboseLogging ¶
func EnableVerboseLogging(logLevel string)
EnableVerboseLogging enables verbose logging with the specified log level.
func ExpandFolder ¶
ExpandFolder expands the given folder path by replacing environment variables and user home directory.
func IsAllowingOutput ¶
func IsAllowingOutput() bool
IsAllowingOutput checks if output is allowed to be displayed.
func IsConnectionRefused ¶
IsConnectionRefused checks if the error is a connection refused error.
func IsVerifyingCertificates ¶
func IsVerifyingCertificates() bool
IsVerifyingCertificates checks if certificate verification is enabled.
func LogLevelFromEnv ¶
func LogLevelFromEnv() int
LogLevelFromEnv retrieves the log level from the environment variable.
func MarshalCookies ¶
MarshalCookies marshals the cookies into a JSON byte array.
func RandomIPAddress ¶
func RandomIPAddress() string
RandomIPAddress generates a random IPv4 address.
func RandomNumberString ¶
RandomNumberString generates a random string of digits of length n.
func RandomPassword ¶
RandomPassword generates a random password of length n.
func RandomString ¶
RandomString generates a random string of length n.
func RetryCall ¶
func RetryCall( fn func() error, tries int, delay int, maxDelay *int, backoff int, jitter interface{}, logger func(error, int), ) error
RetryCall retries a function call based on the provided parameters.
func SerializeJSONCamel ¶
SerializeJSONCamel takes an interface and serializes it into a map with camelCase keys.
func SerializeJSONCamelSchema ¶ added in v1.3.0
func SerializeJSONCamelSchema(item interface{}, schema *reflect.Type) (map[string]interface{}, error)
SerializeJSONCamelSchema takes an interface and serializes it into a map with camelCase keys.
func SerializeResponseToJSON ¶
func SerializeResponseToJSON(response io.ReadCloser) string
SerializeResponseToJSON takes an io.ReadCloser response and serializes it to a JSON string.
func SetArkVersion ¶ added in v1.3.0
func SetArkVersion(version string)
SetArkVersion sets the version of the Ark SDK.
func SetLoggerStyle ¶
func SetLoggerStyle(loggerStyle string)
SetLoggerStyle sets the logger style based on the provided string.
func SetTrustedCertificate ¶
func SetTrustedCertificate(cert string)
SetTrustedCertificate sets the trusted certificate for verification.
func StrToLogLevel ¶
StrToLogLevel converts a string representation of a log level to its integer value.
func TrustedCertificate ¶
func TrustedCertificate() string
TrustedCertificate returns the trusted certificate for verification.
func UnmarshalCookies ¶
UnmarshalCookies unmarshals the JSON byte array into the cookies map.
Types ¶
type ArkClient ¶
type ArkClient struct {
BaseURL string
// contains filtered or unexported fields
}
ArkClient is a struct that represents a client for the Ark service.
func NewArkClient ¶
func NewArkClient(baseURL string, token string, tokenType string, authHeaderName string, cookieJar *cookiejar.Jar, refreshCallback func(*ArkClient) error) *ArkClient
NewArkClient creates a new instance of ArkClient with the specified parameters.
func NewSimpleArkClient ¶
NewSimpleArkClient creates a new instance of ArkClient with the specified base URL.
func (*ArkClient) Delete ¶
func (ac *ArkClient) Delete(ctx context.Context, route string, body interface{}) (*http.Response, error)
Delete performs a DELETE request to the specified route.
func (*ArkClient) Get ¶
func (ac *ArkClient) Get(ctx context.Context, route string, params map[string]string) (*http.Response, error)
Get performs a GET request to the specified route with the provided parameters.
func (*ArkClient) GetCookieJar ¶
GetCookieJar returns the cookie jar for the ArkClient.
func (*ArkClient) GetCookies ¶
GetCookies returns the cookies for the ArkClient.
func (*ArkClient) GetHeaders ¶
GetHeaders returns the headers for the ArkClient.
func (*ArkClient) GetTokenType ¶
GetTokenType returns the token type for the ArkClient.
func (*ArkClient) Patch ¶
func (ac *ArkClient) Patch(ctx context.Context, route string, body interface{}) (*http.Response, error)
Patch performs a PATCH request to the specified route with the provided body.
func (*ArkClient) Post ¶
func (ac *ArkClient) Post(ctx context.Context, route string, body interface{}) (*http.Response, error)
Post performs a POST request to the specified route with the provided body.
func (*ArkClient) Put ¶
func (ac *ArkClient) Put(ctx context.Context, route string, body interface{}) (*http.Response, error)
Put performs a PUT request to the specified route with the provided body.
func (*ArkClient) SetCookies ¶
SetCookies sets multiple cookies for the ArkClient.
func (*ArkClient) SetHeaders ¶
SetHeaders sets multiple headers for the ArkClient.
func (*ArkClient) UpdateCookies ¶
UpdateCookies updates the cookies for the ArkClient with the provided cookies.
func (*ArkClient) UpdateHeaders ¶
UpdateHeaders updates the headers for the ArkClient with the provided headers.
func (*ArkClient) UpdateToken ¶
UpdateToken updates the token and token type for the ArkClient.
type ArkKeyring ¶
type ArkKeyring struct {
// contains filtered or unexported fields
}
ArkKeyring is a struct that represents a keyring for storing and retrieving tokens.
func NewArkKeyring ¶
func NewArkKeyring(serviceName string) *ArkKeyring
NewArkKeyring creates a new instance of ArkKeyring.
func (*ArkKeyring) GetKeyring ¶
func (a *ArkKeyring) GetKeyring(enforceBasicKeyring bool) (*common.BasicKeyring, error)
GetKeyring returns a keyring instance based on the operating system and environment.
func (*ArkKeyring) LoadToken ¶
func (a *ArkKeyring) LoadToken(profile *models.ArkProfile, postfix string, enforceBasicKeyring bool) (*auth.ArkToken, error)
LoadToken loads the token from the keyring for the specified profile and postfix.
func (*ArkKeyring) SaveToken ¶
func (a *ArkKeyring) SaveToken(profile *models.ArkProfile, token *auth.ArkToken, postfix string, enforceBasicKeyring bool) error
SaveToken saves the token to the keyring for the specified profile and postfix.
type ArkLogger ¶
ArkLogger is a custom logger for the Ark SDK.
func GetLogger ¶
GetLogger creates a new instance of ArkLogger with the specified application name and log level.
func NewArkLogger ¶
NewArkLogger creates a new instance of ArkLogger with the specified parameters.
func (*ArkLogger) Debug ¶
Debug logs a debug message if the logger is verbose and the log level is set to Debug or higher.
func (*ArkLogger) Error ¶
Error logs an error message if the logger is verbose and the log level is set to Error or higher.
func (*ArkLogger) Fatal ¶
Fatal logs a fatal message if the logger is verbose and the log level is set to Critical or higher, then exits the program.
func (*ArkLogger) Info ¶
Info logs an info message if the logger is verbose and the log level is set to Info or higher.
func (*ArkLogger) SetVerbose ¶
SetVerbose sets the verbosity of the logger.