Documentation ¶
Index ¶
- func AddVarNamesToQuery(query string, varNames ...interface{}) string
- func ExecuteQuery(cli HTTPClient, serverURL string, graphqlReq *Request, out interface{}) error
- func ExecuteQueryContext(ctx context.Context, qc *QueryConfig) error
- func ExecuteQueryContextWithTenant(ctx context.Context, qc *QueryConfig) (string, error)
- func ExecuteQueryEscapeHTML(cli HTTPClient, serverURL string, graphqlReq *Request, escapeHTML bool, ...) error
- func ExecuteQueryWithTenant(cli HTTPClient, serverURL string, graphqlReq *Request, out interface{}) (string, error)
- func NewMockSubServer(t *testing.T, expectedQuery string, expectedVars map[string]interface{}, ...) *httptest.Server
- func SubscriptionSendKAMessages(s *Subscription)
- type Error
- type HTTPClient
- type KeepAliveMessage
- type Message
- type QueryConfig
- type Request
- type RequestOption
- type Response
- type ResponseFields
- type Subscription
- type SubscriptionOption
- func SubscriptionWithHeader(header http.Header) SubscriptionOption
- func SubscriptionWithLog(l log.Logger) SubscriptionOption
- func SubscriptionWithTenant(tenantID string) SubscriptionOption
- func SubscriptionWithToken(token string) SubscriptionOption
- func SubscriptionWithVars(vars map[string]interface{}) SubscriptionOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddVarNamesToQuery ¶
AddVarNamesToQuery accepts a query or mutation definition and will populate the definition with the variables passed. The definitions use the notation: $%[1]s, $%[2]s, etc... to avoid passing the same variables multiple times in the varNames field(s). When wanting to reference a variable several times inside a format string, the variables can be reference by position using %[n] where n is the index of the parameter (1 based).
func ExecuteQuery ¶
func ExecuteQuery(cli HTTPClient, serverURL string, graphqlReq *Request, out interface{}) error
ExecuteQuery is shorthand for ExecuteQueryContext with the given args. Look to ExecuteQueryContext for more details.
func ExecuteQueryContext ¶
func ExecuteQueryContext(ctx context.Context, qc *QueryConfig) error
ExecuteQueryContext takes a context for HTTP request control and the given QueryConfig. It executes the graphql request against the proveded HTTPClient, returning an error or unmarshalling into QueryConfig.Output if provided. HClient, ServerURL, and Request are required in QueryConfig.
func ExecuteQueryContextWithTenant ¶
func ExecuteQueryContextWithTenant(ctx context.Context, qc *QueryConfig) (string, error)
func ExecuteQueryEscapeHTML ¶
func ExecuteQueryEscapeHTML(cli HTTPClient, serverURL string, graphqlReq *Request, escapeHTML bool, out interface{}) error
ExecuteQueryEscapeHTML is shorthand for ExecuteQueryContext with the given args. Look to ExecuteQueryContext for more details.
func ExecuteQueryWithTenant ¶
func ExecuteQueryWithTenant(cli HTTPClient, serverURL string, graphqlReq *Request, out interface{}) (string, error)
func NewMockSubServer ¶
func SubscriptionSendKAMessages ¶
func SubscriptionSendKAMessages(s *Subscription)
Types ¶
type Error ¶
type Error struct { Message string `json:"message"` Locations []map[string]int `json:"locations"` Path []string `json:"path"` }
Error is the response type for graphql errors from our gateway
type HTTPClient ¶
HTTPClient is any client that can perform HTTP requests. It is often but not always github.com/secureworks/taegis-sdk-go/client
type KeepAliveMessage ¶
type KeepAliveMessage struct{}
type QueryConfig ¶
type QueryConfig struct { ServerURL string HClient HTTPClient Request *Request Header http.Header //DEPRECATED - DO NOT USE. Use graphql.RequestOptions instead EscapeHTML bool LimitRead int64 Output interface{} // contains filtered or unexported fields }
QueryConfig takes all necessary or optional params for this package's Execute functions.
type Request ¶
type Request struct { Query string `json:"query"` Variables map[string]interface{} `json:"variables"` Header http.Header // contains filtered or unexported fields }
Request is the standard graphql request format to send to an API This should NOT be instantiated directly, you should use the NewRequest method to make sure your getting everything you need set
func NewRequest ¶
func NewRequest(query string, opts ...RequestOption) *Request
NewRequest creates a default graphql request with empty vars The Request struct should NOT be created directly - it should use this method so we can make sure everything is set on your graphql request
type RequestOption ¶
type RequestOption func(r *Request)
RequestOption are for the services to use to provide a token *per* request instead of one for the overall client
func RequestWithHeader ¶
func RequestWithHeader(header http.Header) RequestOption
RequestWithHeader adds a set of headers to the request, any headers that are already present, will be skipped
func RequestWithLogger ¶
func RequestWithLogger(logger log.Logger) RequestOption
RequestWithLogger adds a logger for possibly more verbose output
func RequestWithTenant ¶
func RequestWithTenant(tenantID string) RequestOption
RequestWithTenant adds a tenant id to the individual request, overriding one set by client.Options
func RequestWithToken ¶
func RequestWithToken(token string) RequestOption
RequestWithToken adds a bearer token to the individual request, overriding one set by client.Options
type Response ¶
type Response struct { Data interface{} `json:"data"` Error []Error `json:"errors"` }
type ResponseFields ¶
type ResponseFields string
ResponseFields is used to define what graphql response fields we want back from the server
type Subscription ¶
type Subscription struct {
// contains filtered or unexported fields
}
func NewSubscription ¶
func NewSubscription(ctx context.Context, u *url.URL, query string, responseCreator func() interface{}, opts ...SubscriptionOption) (*Subscription, error)
func (*Subscription) Messages ¶
func (s *Subscription) Messages() <-chan *Message
type SubscriptionOption ¶
type SubscriptionOption func(s *Subscription)
func SubscriptionWithHeader ¶
func SubscriptionWithHeader(header http.Header) SubscriptionOption
func SubscriptionWithLog ¶
func SubscriptionWithLog(l log.Logger) SubscriptionOption
func SubscriptionWithTenant ¶
func SubscriptionWithTenant(tenantID string) SubscriptionOption
func SubscriptionWithToken ¶
func SubscriptionWithToken(token string) SubscriptionOption
func SubscriptionWithVars ¶
func SubscriptionWithVars(vars map[string]interface{}) SubscriptionOption