apiclient

package
v1.5.3-rc6 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2023 License: MIT Imports: 27 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	InsecureSkipVerify = false
	Cert               *tls.Certificate
	CaCertPool         *x509.CertPool
)

Functions

func CheckResponse

func CheckResponse(r *http.Response) error

Types

type APIKeyTransport

type APIKeyTransport struct {
	APIKey string
	// Transport is the underlying HTTP transport to use when making requests.
	// It will default to http.DefaultTransport if nil.
	Transport     http.RoundTripper
	URL           *url.URL
	VersionPrefix string
	UserAgent     string
}

func (*APIKeyTransport) Client

func (t *APIKeyTransport) Client() *http.Client

func (*APIKeyTransport) RoundTrip

func (t *APIKeyTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements the RoundTripper interface.

type AddOpts

type AddOpts struct {
}

type AlertsDeleteOpts

type AlertsDeleteOpts struct {
	ScopeEquals          *string `url:"scope,omitempty"`
	ValueEquals          *string `url:"value,omitempty"`
	ScenarioEquals       *string `url:"scenario,omitempty"`
	IPEquals             *string `url:"ip,omitempty"`
	RangeEquals          *string `url:"range,omitempty"`
	Since                *string `url:"since,omitempty"`
	Until                *string `url:"until,omitempty"`
	OriginEquals         *string `url:"origin,omitempty"`
	ActiveDecisionEquals *bool   `url:"has_active_decision,omitempty"`
	SourceEquals         *string `url:"alert_source,omitempty"`
	Contains             *bool   `url:"contains,omitempty"`
	Limit                *int    `url:"limit,omitempty"`
	ListOpts
}

type AlertsListOpts

type AlertsListOpts struct {
	ScopeEquals          *string `url:"scope,omitempty"`
	ValueEquals          *string `url:"value,omitempty"`
	ScenarioEquals       *string `url:"scenario,omitempty"`
	IPEquals             *string `url:"ip,omitempty"`
	RangeEquals          *string `url:"range,omitempty"`
	OriginEquals         *string `url:"origin,omitempty"`
	Since                *string `url:"since,omitempty"`
	TypeEquals           *string `url:"decision_type,omitempty"`
	Until                *string `url:"until,omitempty"`
	IncludeSimulated     *bool   `url:"simulated,omitempty"`
	ActiveDecisionEquals *bool   `url:"has_active_decision,omitempty"`
	IncludeCAPI          *bool   `url:"include_capi,omitempty"`
	Limit                *int    `url:"limit,omitempty"`
	Contains             *bool   `url:"contains,omitempty"`
	ListOpts
}

type AlertsService

type AlertsService service

func (*AlertsService) Add

func (*AlertsService) Delete

to demo query arguments

func (*AlertsService) DeleteOne added in v1.4.2

func (s *AlertsService) DeleteOne(ctx context.Context, alert_id string) (*models.DeleteAlertsResponse, *Response, error)

func (*AlertsService) GetByID

func (s *AlertsService) GetByID(ctx context.Context, alertID int) (*models.Alert, *Response, error)

func (*AlertsService) List

to demo query arguments

type ApiClient

type ApiClient struct {

	/*config stuff*/
	BaseURL   *url.URL
	PapiURL   *url.URL
	URLPrefix string
	UserAgent string
	/*exposed Services*/
	Decisions      *DecisionsService
	DecisionDelete *DecisionDeleteService
	Alerts         *AlertsService
	Auth           *AuthService
	Metrics        *MetricsService
	Signal         *SignalService
	HeartBeat      *HeartBeatService
	// contains filtered or unexported fields
}

func NewClient

func NewClient(config *Config) (*ApiClient, error)

func NewDefaultClient

func NewDefaultClient(URL *url.URL, prefix string, userAgent string, client *http.Client) (*ApiClient, error)

func RegisterClient

func RegisterClient(config *Config, client *http.Client) (*ApiClient, error)

func (*ApiClient) Do

func (c *ApiClient) Do(ctx context.Context, req *http.Request, v interface{}) (*Response, error)

func (*ApiClient) GetClient added in v1.5.0

func (a *ApiClient) GetClient() *http.Client

func (*ApiClient) NewRequest

func (c *ApiClient) NewRequest(method, url string, body interface{}) (*http.Request, error)

type AuthService

type AuthService service

func (*AuthService) AuthenticateWatcher

func (*AuthService) EnrollWatcher added in v1.1.0

func (s *AuthService) EnrollWatcher(ctx context.Context, enrollKey string, name string, tags []string, overwrite bool) (*Response, error)

func (*AuthService) RegisterWatcher

func (s *AuthService) RegisterWatcher(ctx context.Context, registration models.WatcherRegistrationRequest) (*Response, error)

func (*AuthService) UnregisterWatcher

func (s *AuthService) UnregisterWatcher(ctx context.Context) (*Response, error)

type Config

type Config struct {
	MachineID      string
	Password       strfmt.Password
	Scenarios      []string
	URL            *url.URL
	PapiURL        *url.URL
	VersionPrefix  string
	UserAgent      string
	UpdateScenario func() ([]string, error)
}

type DecisionDeleteService added in v1.5.0

type DecisionDeleteService service

func (*DecisionDeleteService) Add added in v1.5.0

func (d *DecisionDeleteService) Add(ctx context.Context, deletedDecisions *models.DecisionsDeleteRequest) (interface{}, *Response, error)

DecisionDeleteService purposely reuses AddSignalsRequestItemDecisions model

type DecisionsDeleteOpts

type DecisionsDeleteOpts struct {
	ScopeEquals  *string `url:"scope,omitempty"`
	ValueEquals  *string `url:"value,omitempty"`
	TypeEquals   *string `url:"type,omitempty"`
	IPEquals     *string `url:"ip,omitempty"`
	RangeEquals  *string `url:"range,omitempty"`
	Contains     *bool   `url:"contains,omitempty"`
	OriginEquals *string `url:"origin,omitempty"`
	//
	ScenarioEquals *string `url:"scenario,omitempty"`
	ListOpts
}

type DecisionsListOpts

type DecisionsListOpts struct {
	ScopeEquals *string `url:"scope,omitempty"`
	ValueEquals *string `url:"value,omitempty"`
	TypeEquals  *string `url:"type,omitempty"`
	IPEquals    *string `url:"ip,omitempty"`
	RangeEquals *string `url:"range,omitempty"`
	Contains    *bool   `url:"contains,omitempty"`
	ListOpts
}

type DecisionsService

type DecisionsService service

func (*DecisionsService) Delete

func (*DecisionsService) DeleteOne

func (s *DecisionsService) DeleteOne(ctx context.Context, decision_id string) (*models.DeleteDecisionResponse, *Response, error)

func (*DecisionsService) FetchV2Decisions added in v1.5.0

func (s *DecisionsService) FetchV2Decisions(ctx context.Context, url string) (*models.DecisionsStreamResponse, *Response, error)

func (*DecisionsService) FetchV3Decisions added in v1.5.0

func (s *DecisionsService) FetchV3Decisions(ctx context.Context, url string) (*models.DecisionsStreamResponse, *Response, error)

func (*DecisionsService) GetDecisionsFromBlocklist added in v1.5.0

func (s *DecisionsService) GetDecisionsFromBlocklist(ctx context.Context, blocklist *modelscapi.BlocklistLink, lastPullTimestamp *string) ([]*models.Decision, bool, error)

func (*DecisionsService) GetDecisionsFromGroups added in v1.5.0

func (s *DecisionsService) GetDecisionsFromGroups(decisionsGroups []*modelscapi.GetDecisionsStreamResponseNewItem) []*models.Decision

func (*DecisionsService) GetStream

func (*DecisionsService) GetStreamV3 added in v1.5.0

func (*DecisionsService) List

to demo query arguments

func (*DecisionsService) StopStream

func (s *DecisionsService) StopStream(ctx context.Context) (*Response, error)

type DecisionsStreamOpts added in v1.3.3

type DecisionsStreamOpts struct {
	Startup                bool   `url:"startup,omitempty"`
	Scopes                 string `url:"scopes,omitempty"`
	ScenariosContaining    string `url:"scenarios_containing,omitempty"`
	ScenariosNotContaining string `url:"scenarios_not_containing,omitempty"`
	Origins                string `url:"origins,omitempty"`
}

type DeleteOpts

type DeleteOpts struct {
}

type ErrorResponse

type ErrorResponse struct {
	models.ErrorResponse
}

func (*ErrorResponse) Error

func (e *ErrorResponse) Error() string

type HeartBeatService added in v1.4.0

type HeartBeatService service

func (*HeartBeatService) Ping added in v1.4.0

func (h *HeartBeatService) Ping(ctx context.Context) (bool, *Response, error)

func (*HeartBeatService) StartHeartBeat added in v1.4.0

func (h *HeartBeatService) StartHeartBeat(ctx context.Context, t *tomb.Tomb)

type JWTTransport

type JWTTransport struct {
	MachineID     *string
	Password      *strfmt.Password
	Token         string
	Expiration    time.Time
	Scenarios     []string
	URL           *url.URL
	VersionPrefix string
	UserAgent     string
	// Transport is the underlying HTTP transport to use when making requests.
	// It will default to http.DefaultTransport if nil.
	Transport      http.RoundTripper
	UpdateScenario func() ([]string, error)
	// contains filtered or unexported fields
}

func (*JWTTransport) Client

func (t *JWTTransport) Client() *http.Client

func (*JWTTransport) ResetToken added in v1.5.0

func (t *JWTTransport) ResetToken()

func (*JWTTransport) RoundTrip

func (t *JWTTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements the RoundTripper interface.

type ListOpts

type ListOpts struct {
}

type MetricsService

type MetricsService service

func (*MetricsService) Add

func (s *MetricsService) Add(ctx context.Context, metrics *models.Metrics) (interface{}, *Response, error)

type Response

type Response struct {
	Response *http.Response
}

type SignalService

type SignalService service

func (*SignalService) Add

func (s *SignalService) Add(ctx context.Context, signals *models.AddSignalsRequest) (interface{}, *Response, error)

Jump to

Keyboard shortcuts

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