Documentation
¶
Index ¶
- Constants
- Variables
- func BuildQueryParams(params map[string]string) string
- func SendRequest(httpMethod string, requestURL string, headers map[string]string, ...) (int, []byte, error)
- func SendRequestWithContext(ctx context.Context, httpMethod string, requestURL string, ...) (int, []byte, error)
- type CtxKey
- type DSClient
- type DSConnection
- type GWClient
- func (client *GWClient) AuthenticatePassword(username, password string) (string, error)
- func (client *GWClient) ClearInDowntime(ctx context.Context, payload []byte) ([]byte, error)
- func (client *GWClient) Connect() error
- func (client *GWClient) Disconnect() error
- func (client *GWClient) GetHostGroupsByAppTypeAndHostNames(appType string, hostNames []string, gwHostGroups *GWHostGroups) error
- func (client *GWClient) GetServicesByAgent(agentID string, gwServices *GWServices) error
- func (client *GWClient) SendEvents(ctx context.Context, payload []byte) ([]byte, error)
- func (client *GWClient) SendEventsAck(ctx context.Context, payload []byte) ([]byte, error)
- func (client *GWClient) SendEventsUnack(ctx context.Context, payload []byte) ([]byte, error)
- func (client *GWClient) SendResourcesWithMetrics(ctx context.Context, payload []byte) ([]byte, error)
- func (client *GWClient) SetInDowntime(ctx context.Context, payload []byte) ([]byte, error)
- func (client *GWClient) SynchronizeInventory(ctx context.Context, payload []byte) ([]byte, error)
- func (client *GWClient) ValidateToken(appName, apiToken string) error
- type GWConnection
- type GWEntrypoint
- type GWHostGroups
- type GWServices
- type Req
Constants ¶
const ( DSEntrypointReload = "/dalekservices/connectors/reload/:agentID" DSEntrypointValidateToken = "/dalekservices/validate-token" )
Define entrypoints for DSOperations
const ( HdrCompressed = "compressed" HdrPayloadLen = "payloadLen" HdrPayloadType = "payloadType" HdrSpanSpanID = "spanSpanID" HdrSpanTraceID = "spanTraceID" HdrSpanTraceFlags = "spanTraceFlags" HdrTodoTracerCtx = "todoTracerCtx" )
const ( EnvHttpClientTimeout = "TCG_HTTP_CLIENT_TIMEOUT" EnvTlsClientInsecure = "TCG_TLS_CLIENT_INSECURE" )
const EnvHttpClientTimeoutGW = "TCG_HTTP_CLIENT_TIMEOUT_GW"
Variables ¶
var CtxHeaders = CtxKey("headers")
var GZIP = func(ctx context.Context, w io.Writer, p []byte) (context.Context, error) { gw := gzip.NewWriter(w) _, err := gw.Write(p) _ = gw.Close() return ctx, err }
var HookRequestContext = func(ctx context.Context, req *http.Request) (context.Context, *http.Request) {
return ctx, req
}
var HttpClient = &http.Client{ Timeout: func(env string) time.Duration { if s, ok := os.LookupEnv(env); ok { if v, err := time.ParseDuration(s); err == nil { return v } } return time.Duration(5 * time.Second) }(EnvHttpClientTimeout), Transport: HttpClientTransport, }
var HttpClientGW = func() *http.Client { c := new(http.Client) *c = *HttpClient c.Timeout = func() time.Duration { if s, ok := os.LookupEnv(EnvHttpClientTimeoutGW); ok { if v, err := time.ParseDuration(s); err == nil { return v } } if s, ok := os.LookupEnv(EnvHttpClientTimeout); ok { if v, err := time.ParseDuration(s); err == nil { return v } } return time.Second * 40 }() return c }()
Functions ¶
func BuildQueryParams ¶
BuildQueryParams makes the query parameters string
Types ¶
type DSClient ¶
type DSClient struct {
DSConnection
}
DSClient implements DS API operations
func (*DSClient) ValidateToken ¶
ValidateToken calls API
type DSConnection ¶
type DSConnection struct { // HostName accepts value for combined "host:port" // used as `url.URL{HostName}` HostName string `env:"HOSTNAME" yaml:"hostName"` }
DSConnection defines DalekServices Connection configuration
type GWClient ¶
type GWClient struct { AppName string AppType string GWConnection // contains filtered or unexported fields }
GWClient implements GW API operations
func (*GWClient) AuthenticatePassword ¶
AuthenticatePassword calls API and returns token
func (*GWClient) ClearInDowntime ¶
ClearInDowntime calls API
func (*GWClient) GetHostGroupsByAppTypeAndHostNames ¶
func (client *GWClient) GetHostGroupsByAppTypeAndHostNames(appType string, hostNames []string, gwHostGroups *GWHostGroups) error
GetHostGroupsByAppTypeAndHostNames calls API
func (*GWClient) GetServicesByAgent ¶
func (client *GWClient) GetServicesByAgent(agentID string, gwServices *GWServices) error
GetServicesByAgent calls API
func (*GWClient) SendEvents ¶
SendEvents calls API
func (*GWClient) SendEventsAck ¶
SendEventsAck calls API
func (*GWClient) SendEventsUnack ¶
SendEventsUnack calls API
func (*GWClient) SendResourcesWithMetrics ¶
func (client *GWClient) SendResourcesWithMetrics(ctx context.Context, payload []byte) ([]byte, error)
SendResourcesWithMetrics calls API
func (*GWClient) SetInDowntime ¶
SetInDowntime calls API
func (*GWClient) SynchronizeInventory ¶
SynchronizeInventory calls API
func (*GWClient) ValidateToken ¶
ValidateToken calls API
type GWConnection ¶
type GWConnection struct { ID int `env:"ID" yaml:"id"` // HostName accepts value for combined "host:port" // used as `url.URL{HostName}` HostName string `env:"HOSTNAME" yaml:"hostName"` UserName string `env:"USERNAME" yaml:"userName"` Password string `env:"PASSWORD" yaml:"password"` Enabled bool `env:"ENABLED" yaml:"enabled"` IsChild bool `env:"ISCHILD" yaml:"isChild"` DisplayName string `env:"DISPLAYNAME" yaml:"displayName"` MergeHosts bool `env:"MERGEHOSTS" yaml:"mergeHosts"` LocalConnection bool `env:"LOCALCONNECTION" yaml:"localConnection"` DeferOwnership string `env:"DEFEROWNERSHIP" yaml:"deferOwnership"` PrefixResourceNames bool `env:"PREFIXRESOURCENAMES" yaml:"prefixResourceNames"` ResourceNamePrefix string `env:"RESOURCENAMEPREFIX" yaml:"resourceNamePrefix"` SendAllInventory bool `env:"SENDALLINVENTORY" yaml:"sendAllInventory"` IsDynamicInventory bool `env:"ISDYNAMICINVENTORY" yaml:"-"` HTTPEncode bool `env:"HTTPENCODE" yaml:"-"` }
GWConnection defines Groundwork Connection configuration
type GWEntrypoint ¶
type GWEntrypoint string
GWEntrypoint defines entrypoint
const ( GWEntrypointAuthenticatePassword GWEntrypoint = "/api/users/authenticatePassword" GWEntrypointConnect GWEntrypoint = "/api/auth/login" GWEntrypointDisconnect GWEntrypoint = "/api/auth/logout" GWEntrypointClearInDowntime GWEntrypoint = "/api/biz/clearindowntime" GWEntrypointSetInDowntime GWEntrypoint = "/api/biz/setindowntime" GWEntrypointSendEvents GWEntrypoint = "/api/events" GWEntrypointSendEventsAck GWEntrypoint = "/api/events/ack" GWEntrypointSendEventsUnack GWEntrypoint = "/api/events/unack" GWEntrypointSendResourceWithMetrics GWEntrypoint = "/api/monitoring" GWEntrypointSendResourceWithMetricsDyn GWEntrypoint = "/api/monitoring?dynamic=true" GWEntrypointSynchronizeInventory GWEntrypoint = "/api/synchronizer" GWEntrypointServices GWEntrypoint = "/api/services" GWEntrypointHostgroups GWEntrypoint = "/api/hostgroups" GWEntrypointValidateToken GWEntrypoint = "/api/auth/validatetoken" )
GWEntrypoint
type GWHostGroups ¶
type GWHostGroups struct { HostGroups []struct { Name string `json:"name"` Hosts []struct { HostName string `json:"hostName"` } `json:"hosts"` } `json:"hostGroups"` }
GWHostGroups defines collection
type GWServices ¶
type GWServices struct { Services []struct { Description string `json:"description"` HostName string `json:"hostName"` } `json:"services"` }
GWServices defines collection