list

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyFilterMode     = errors.New("a filter mode must be set")
	ErrEmptyFilterOperator = errors.New("a filter operator must be set")
	ErrEmptyFilterValues   = errors.New("at least one value must be set")
)

Functions

This section is empty.

Types

type Filter

type Filter struct {
	Key      []string       `json:"key"`
	Values   []any          `json:"values"`
	Operator FilterOperator `json:"operator"`
	Mode     FilterMode     `json:"mode"`
}

func (Filter) IsValid

func (filter Filter) IsValid() error

IsValid returns any error related to missing Filter content.

func (Filter) MarshalJSON

func (filter Filter) MarshalJSON() ([]byte, error)

MarshalJSON checks for Filter missing content and returns its json representation.

func (Filter) ToGraphQL

func (filter Filter) ToGraphQL() (string, error)

ToGraphQL returns the appropriate representation of a Filter for direct use in a 'customAttributes' field. In the GraphQL query, the field names and typed values are not quoted, but strings are.

type FilterGroup

type FilterGroup struct {
	Mode         FilterMode    `json:"mode"`
	Filters      []Filter      `json:"filters"`
	FilterGroups []FilterGroup `json:"filterGroups"`
}

func (FilterGroup) IsValid

func (filterGroup FilterGroup) IsValid() error

IsValid returns any error related to missing FilterGroup content.

func (FilterGroup) MarshalJSON

func (filterGroup FilterGroup) MarshalJSON() ([]byte, error)

MarshalJSON checks for FilterGroup missing content and returns its json representation.

func (FilterGroup) ToGraphQL

func (filterGroup FilterGroup) ToGraphQL() (string, error)

ToGraphQL returns the appropriate representation of a FilterGroup for direct use in a 'customAttributes' field.

type FilterMode

type FilterMode string

FilterMode defines the various filter combination modes available.

const (
	FilterModeAnd FilterMode = "and"
	FilterModeOr  FilterMode = "or"
)

type FilterOperator

type FilterOperator string

FilterOperator defines the various filtering operators available.

const (
	FilterOperatorEq            FilterOperator = "eq"
	FilterOperatorNotEq         FilterOperator = "not_eq"
	FilterOperatorLt            FilterOperator = "lt"
	FilterOperatorLte           FilterOperator = "lte"
	FilterOperatorGt            FilterOperator = "gt"
	FilterOperatorGte           FilterOperator = "gte"
	FilterOperatorMatch         FilterOperator = "match"
	FilterOperatorWildcard      FilterOperator = "wildcard"
	FilterOperatorContains      FilterOperator = "contains"
	FilterOperatorNotContains   FilterOperator = "not_contains"
	FilterOperatorEndsWith      FilterOperator = "ends_with"
	FilterOperatorNotEndsWith   FilterOperator = "not_ends_with"
	FilterOperatorStartsWith    FilterOperator = "starts_with"
	FilterOperatorNotStartsWith FilterOperator = "not_starts_with"
	FilterOperatorScript        FilterOperator = "script"
	FilterOperatorNil           FilterOperator = "nil"
	FilterOperatorNotNil        FilterOperator = "not_nil"
	FilterOperatorSearch        FilterOperator = "search"
)

type Option

type Option func(*QueryVars)

Option is a function that configures a QueryVars object.

func WithAfter

func WithAfter(after string) Option

func WithCategory

func WithCategory(category string) Option

func WithConfidences

func WithConfidences(confidences []int) Option

func WithElementWithTargetTypes

func WithElementWithTargetTypes(elementWithTargetTypes []string) Option

func WithEndDate

func WithEndDate(endDate *time.Time) Option

func WithFilters

func WithFilters(filters FilterGroup) Option

func WithFirst

func WithFirst(first int) Option

func WithFirstSeenStart

func WithFirstSeenStart(firstSeenStart *time.Time) Option

func WithFirstSeenStop

func WithFirstSeenStop(firstSeenStop *time.Time) Option

func WithFromIDList

func WithFromIDList(fromIDList []string) Option

func WithFromOrToIDList

func WithFromOrToIDList(fromOrToIDList []string) Option

func WithFromRole

func WithFromRole(fromRole string) Option

func WithFromTypes

func WithFromTypes(fromTypes []string) Option

func WithIncludeParents

func WithIncludeParents(includeParents bool) Option

func WithLastSeenStart

func WithLastSeenStart(lastSeenStart *time.Time) Option

func WithLastSeenStop

func WithLastSeenStop(lastSeenStop *time.Time) Option

func WithOrderBy

func WithOrderBy(orderBy string) Option

func WithOrderMode

func WithOrderMode(orderMode OrderingMode) Option

func WithRelationshipType

func WithRelationshipType(relationshipType []string) Option

func WithSearch

func WithSearch(search string) Option

func WithStartDate

func WithStartDate(startDate *time.Time) Option

func WithStartTimeStart

func WithStartTimeStart(startTimeStart *time.Time) Option

func WithStartTimeStop

func WithStartTimeStop(startTimeStop *time.Time) Option

func WithStix

func WithStix(stix bool) Option

func WithStopTimeStart

func WithStopTimeStart(stopTimeStart *time.Time) Option

func WithStopTimeStop

func WithStopTimeStop(stopTimeStop *time.Time) Option

func WithToIDList

func WithToIDList(toIDList []string) Option

func WithToRole

func WithToRole(toRole string) Option

func WithToStix

func WithToStix(toStix bool) Option

func WithToTypes

func WithToTypes(toTypes []string) Option

func WithType

func WithType(type_ string) Option

func WithTypes

func WithTypes(types []string) Option

type OrderingMode

type OrderingMode string

OrderingMode defines the various ordering modes available when retrieving multiple entities.

const (
	OrderModeAsc  OrderingMode = "asc"
	OrderModeDesc OrderingMode = "desc"
)

type QueryVars

type QueryVars struct {
	Filters   FilterGroup  `json:"filters"`
	Search    string       `json:"search,omitempty"`
	First     int          `json:"first,omitempty"`   // Number of entities per page
	After     string       `json:"after,omitempty"`   // EndCursor of previous page
	OrderBy   string       `json:"orderBy,omitempty"` // Specific to each entity
	OrderMode OrderingMode `json:"orderMode"`

	Category               string     `json:"category,omitempty"`
	Confidences            []int      `json:"confidences,omitempty"`
	ElementWithTargetTypes []string   `json:"elementWithTargetTypes,omitempty"`
	EndDate                *time.Time `json:"endDate,omitempty"`
	FirstSeenStart         *time.Time `json:"firstSeenStart,omitempty"`
	FirstSeenStop          *time.Time `json:"firstSeenStop,omitempty"`
	FromIDList             []string   `json:"fromId,omitempty"`
	FromOrToIDList         []string   `json:"fromOrToId,omitempty"`
	FromRole               string     `json:"fromRole,omitempty"`
	FromTypes              []string   `json:"fromTypes,omitempty"`
	IncludeParents         bool       `json:"includeParents,omitempty"`
	LastSeenStart          *time.Time `json:"lastSeenStart,omitempty"`
	LastSeenStop           *time.Time `json:"lastSeenStop,omitempty"`
	RelationshipType       []string   `json:"relationship_type,omitempty"`
	StartDate              *time.Time `json:"startDate,omitempty"`
	StartTimeStart         *time.Time `json:"startTimeStart,omitempty"`
	StartTimeStop          *time.Time `json:"startTimeStop,omitempty"`
	Stix                   bool       `json:"stix,omitempty"`
	StopTimeStart          *time.Time `json:"stopTimeStart,omitempty"`
	StopTimeStop           *time.Time `json:"stopTimeStop,omitempty"`
	ToIDList               []string   `json:"toId,omitempty"`
	ToRole                 string     `json:"toRole,omitempty"`
	ToStix                 bool       `json:"toStix,omitempty"`
	ToTypes                []string   `json:"toTypes,omitempty"`
	Type                   string     `json:"type,omitempty"`
	Types                  []string   `json:"types,omitempty"`
}

QueryVars is a list of parameters to configure a GraphQL List query. Configuration should be made via Option functions.

func NewQueryVars

func NewQueryVars() *QueryVars

NewQueryVars returns a QueryVars instance with default values applied.

func (*QueryVars) Mapping

func (queryVars *QueryVars) Mapping() (map[string]any, error)

Mapping converts the List Query Variables struct to a map[string]any.

Jump to

Keyboard shortcuts

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