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) GetHostGroupsByHostNamesAndAppType(hostNames []string, appType string) (*GWHostGroups, error)
- func (client *GWClient) GetServicesByAgent(agentID string) (*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
- type ReqDetails
Constants ¶
const ( DSEntrypointReload = "/dalekservices/connectors/reload/:agentID" DSEntrypointValidateToken = "/dalekservices/validate-token" )
Define entrypoints for DSOperations
const ( HdrCompressed = "compressed" 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, p []byte) (context.Context, []byte, error) { buf := &bytes.Buffer{} gw := gzip.NewWriter(buf) _, err := gw.Write(p) _ = gw.Close() return ctx, buf.Bytes(), 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, }
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 `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) GetHostGroupsByHostNamesAndAppType ¶
func (client *GWClient) GetHostGroupsByHostNamesAndAppType(hostNames []string, appType string) (*GWHostGroups, error)
GetHostGroupsByHostNamesAndAppType calls API
func (*GWClient) GetServicesByAgent ¶
func (client *GWClient) GetServicesByAgent(agentID string) (*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 `yaml:"id"` // HostName accepts value for combined "host:port" // used as `url.URL{HostName}` HostName string `yaml:"hostName"` UserName string `yaml:"userName"` Password string `yaml:"password"` Enabled bool `yaml:"enabled"` IsChild bool `yaml:"isChild"` DisplayName string `yaml:"displayName"` MergeHosts bool `yaml:"mergeHosts"` LocalConnection bool `yaml:"localConnection"` DeferOwnership string `yaml:"deferOwnership"` PrefixResourceNames bool `yaml:"prefixResourceNames"` ResourceNamePrefix string `yaml:"resourceNamePrefix"` SendAllInventory bool `yaml:"sendAllInventory"` IsDynamicInventory bool `yaml:"-"` HTTPEncode bool `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" GWEntrypointSendResourceWithMetricsDynamic 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 { HostName string `json:"hostName"` } `json:"services"` }
GWServices defines collection
type Req ¶
type Req struct { Err error Form map[string]string Headers map[string]string Method string Payload []byte Response []byte Status int URL string // contains filtered or unexported fields }
Req defines request context
func (Req) Details ¶
func (q Req) Details() ReqDetails
func (*Req) SendWithContext ¶
SendWithContext sends request