session

package
v0.11.4 Latest Latest
Warning

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

Go to latest
Published: May 18, 2021 License: MIT Imports: 45 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ResourceTypeApp         = "app"
	ResourceTypeGenericLink = "genericlink"
	ResourceTypeDataset     = "dataset"
	ResourceTypeDataAsset   = "dataasset"
)

Currently known resource types

View Source
const (
	EventWsReconnectStarted = "eventws.reconnect.started"
	EventWsReconnectEnded   = "eventws.reconnect.ended"
)

Fake "events" for event websocket

View Source
const (
	// DefaultTimeout per request timeout
	DefaultTimeout = 300 * time.Second
)
View Source
const (
	GeneratedPropertiesPath = "/qUndoExclude/generated"
)

Variables

View Source
var (
	GlobalObjectHandler objectHandlerMap
)
View Source
var (
	// LogFeatureFlags logs feature flags unless previously logged
	LogFeatureFlags = &sync.Once{}
)

Functions

func CheckResponseStatus

func CheckResponseStatus(request *RestRequest, statusCodes []int) error

CheckResponseStatus validates that a response has acceptable

func DefaultClient

func DefaultClient(allowUntrusted bool, state *State) (*http.Client, error)

DefaultClient creates client instance with default client settings

func GetAndAddObjectAsync added in v0.5.3

func GetAndAddObjectAsync(sessionState *State, actionState *action.State, name string)

GetAndAddObjectAsync get and add object to object handling

func GetAndAddObjectSync added in v0.5.7

func GetAndAddObjectSync(sessionState *State, actionState *action.State, name string)

GetAndAddObjectSync get and add object to object handling

func GetApproriateNrOfBins added in v0.5.3

func GetApproriateNrOfBins(hypercube *enigmahandlers.HyperCube) int

Logic as written in client.js as of sense april 2018:

getApproriateNrOfBins: function (t) {
	var e = t.qHyperCube.qMeasureInfo.length || 1,
	n = 4 + 2 * (e - 1);
	return t.qHyperCube.qDimensionInfo.length > 1 && (e = Math.max(1, Math.min(h.maxNumberOfLines, t.qHyperCube.qDimensionInfo[1].qStateCounts.qLocked + t.qHyperCube.qDimensionInfo[1].qStateCounts.qOption + t.qHyperCube.qDimensionInfo[1].qStateCounts.qSelected)), n = 4),
	Math.ceil(2e3 / (e * n))
},

func GetFullContinuousRange added in v0.5.3

func GetFullContinuousRange(hypercube *enigmahandlers.HyperCube) (enigma.Float64, enigma.Float64, error)

Logic as written in client.js as of sense april 2018:

getFullContinuousRange: function (t) {
	var e = t.qHyperCube.qDimensionInfo[0].qMin,
	n = t.qHyperCube.qDimensionInfo[0].qMax;
	return n < e || "NaN" === n ? e = n = "NaN" : e === n && (e -= .5, n += .5), {
		min: e,
		max: n
	}
},

func GetObjectLayout added in v0.5.3

func GetObjectLayout(sessionState *State, actionState *action.State, obj *enigmahandlers.Object) error

func GetObjectProperties added in v0.5.3

func GetObjectProperties(sessionState *State, actionState *action.State, obj *enigmahandlers.Object) error

func ReadAll added in v0.6.21

func ReadAll(r io.Reader) ([]byte, error)

func SetChildList added in v0.5.3

func SetChildList(rawLayout json.RawMessage, obj *enigmahandlers.Object) error

func SetChildren added in v0.5.3

func SetChildren(rawLayout json.RawMessage, obj *enigmahandlers.Object) error

func SetHyperCube added in v0.5.3

func SetHyperCube(rawLayout json.RawMessage, obj *enigmahandlers.Object, path helpers.DataPath) error

func SetListObject added in v0.5.3

func SetListObject(rawLayout json.RawMessage, obj *enigmahandlers.Object, path helpers.DataPath) error

func SetObjectData added in v0.5.3

func SetObjectData(sessionState *State, actionState *action.State, rawLayout json.RawMessage, objectDef *senseobjdef.ObjectDef,
	obj *enigmahandlers.Object, enigmaObject *enigma.GenericObject) error

SetObjectData sets data to obj from layout and data requests according to objectDef

func SetObjectDataAndEvents added in v0.5.3

func SetObjectDataAndEvents(sessionState *State, actionState *action.State, obj *enigmahandlers.Object, genObj *enigma.GenericObject)

func UpdateListObjectDataAsync added in v0.5.3

func UpdateListObjectDataAsync(sessionState *State, actionState *action.State, gob *enigma.GenericObject,
	obj *enigmahandlers.Object, requestDef senseobjdef.GetDataRequests)

UpdateListObjectDataAsync send get listobject data and update saved list object

func UpdateObjectHyperCubeBinnedDataAsync added in v0.5.3

func UpdateObjectHyperCubeBinnedDataAsync(sessionState *State, actionState *action.State, gob *enigma.GenericObject,
	obj *enigmahandlers.Object, requestDef senseobjdef.GetDataRequests)

UpdateObjectHyperCubeBinnedDataAsync send get hypercube binned data request and update saved hypercube

func UpdateObjectHyperCubeContinuousDataAsync added in v0.5.3

func UpdateObjectHyperCubeContinuousDataAsync(sessionState *State, actionState *action.State, gob *enigma.GenericObject,
	obj *enigmahandlers.Object, requestDef senseobjdef.GetDataRequests)

UpdateObjectHyperCubeContinuousDataAsync send get continous data request

func UpdateObjectHyperCubeDataAsync added in v0.5.3

func UpdateObjectHyperCubeDataAsync(sessionState *State, actionState *action.State, gob *enigma.GenericObject,
	obj *enigmahandlers.Object, requestDef senseobjdef.GetDataRequests, columns bool)

UpdateObjectHyperCubeDataAsync send get straight hypercube data and update saved hypercube

func UpdateObjectHyperCubeReducedDataAsync added in v0.5.3

func UpdateObjectHyperCubeReducedDataAsync(sessionState *State, actionState *action.State, gob *enigma.GenericObject,
	obj *enigmahandlers.Object, requestDef senseobjdef.GetDataRequests)

UpdateObjectHyperCubeReducedDataAsync send get hypercube reduced data request and update saved hypercube

func UpdateObjectHyperCubeStackDataAsync added in v0.5.3

func UpdateObjectHyperCubeStackDataAsync(sessionState *State, actionState *action.State, gob *enigma.GenericObject,
	obj *enigmahandlers.Object, requestDef senseobjdef.GetDataRequests)

UpdateObjectHyperCubeStackDataAsync send get stacked hypercube data and update saved hypercube

func UpdateObjectHyperCubeTreeDataAsync added in v0.6.26

func UpdateObjectHyperCubeTreeDataAsync(sessionState *State, actionState *action.State, gob *enigma.GenericObject,
	obj *enigmahandlers.Object, requestDef senseobjdef.GetDataRequests)

UpdateObjectHyperCubeTreeDataAsync send get hypercube tree data request and update saved data

func WarnOrError

func WarnOrError(actionState *action.State, logEntry *logger.LogEntry, failOnError bool, err error)

WarnOrError add error to action or log warning

Types

type AppSelection

type AppSelection struct {
	AppSelectionCore
	// contains filtered or unexported fields
}

AppSelection contains the selected app for the current session

func NewAppSelection

func NewAppSelection(appMode AppSelectionModeEnum, app string, list []string) (*AppSelection, error)

NewAppSelection creates new instance of AppSelection

func (*AppSelection) Select

func (appSelection *AppSelection) Select(sessionState *State) (*ArtifactEntry, error)

Select new app

func (*AppSelection) UnmarshalJSON

func (appSelection *AppSelection) UnmarshalJSON(arg []byte) error

UnmarshalJSON unmarshal AppSelection

func (*AppSelection) Validate

func (appSelection *AppSelection) Validate() error

Validate AppSelection settings

type AppSelectionCore

type AppSelectionCore struct {
	// AppMode app selection mode
	AppMode AppSelectionModeEnum `json:"appmode" displayname:"App selection mode" doc-key:"appselection.appmode"`
	// App name or GUID depending on AppMode
	App SyncedTemplate `json:"app,omitempty" displayname:"App" doc-key:"appselection.app"`
	// AppList of app names or GUID's, depending on AppMode
	AppList []string `json:"list,omitempty" displayname:"App selection list" doc-key:"appselection.list"`
	// Filename of file containing app names, one app per line
	Filename helpers.RowFile `json:"filename,omitempty" displayname:"App selection filename" displayelement:"file" doc-key:"appselection.filename"`
}

AppSelectionCore app selection settings shared between multiple actions

type AppSelectionModeEnum

type AppSelectionModeEnum int

AppSelectionModeEnum from where to get app to open, defaults to "current"

const (
	AppModeCurrent AppSelectionModeEnum = iota
	AppModeGUID
	AppModeName
	AppModeRandom
	AppModeRandomNameFromList
	AppModeRandomGUIDFromList
	AppModeRandomNameFromFile
	AppModeRandomGUIDFromFile
	AppModeRound
	AppModeRoundNameFromList
	AppModeRoundGUIDFromList
	AppModeRoundNameFromFile
	AppModeRoundGUIDFromFile
)

AppSelectionModeEnum from where to get app to open, defaults to "current"

func (AppSelectionModeEnum) GetEnumMap

func (mode AppSelectionModeEnum) GetEnumMap() *enummap.EnumMap

GetEnumMap for app selection mode

func (AppSelectionModeEnum) MarshalJSON

func (mode AppSelectionModeEnum) MarshalJSON() ([]byte, error)

MarshalJSON marshal AppSelectionModeEnum

func (AppSelectionModeEnum) String

func (mode AppSelectionModeEnum) String() string

String implements stringer interface

func (*AppSelectionModeEnum) UnmarshalJSON

func (mode *AppSelectionModeEnum) UnmarshalJSON(arg []byte) error

UnmarshalJSON unmarshal AppSelectionModeEnum

type ArtifactEntry

type ArtifactEntry struct {
	Name         string      `json:"name"`
	ID           string      `json:"resourceId"`
	ItemID       string      `json:"ID,omitempty"`
	ResourceType string      `json:"resourceType"`
	Data         interface{} `json:"-"`
}

ArtifactEntry is the entry for most, but not all, item types in artifact map

func (*ArtifactEntry) Copy

func (entry *ArtifactEntry) Copy() *ArtifactEntry

Copy of ArtifactEntry

type ArtifactKey added in v0.6.19

type ArtifactKey struct {
	Title string
	Type  string
}

ArtifactKey used to find item using title

type ArtifactList added in v0.6.19

type ArtifactList struct {
	// contains filtered or unexported fields
}

ArtifactList all items, spaces and collections

func (*ArtifactList) Len added in v0.6.19

func (d *ArtifactList) Len() int

func (ArtifactList) Less added in v0.6.19

func (d ArtifactList) Less(i, j int) bool

func (ArtifactList) MarshalJSON added in v0.6.19

func (d ArtifactList) MarshalJSON() ([]byte, error)

MarshalJSON marshal artifact list to JSON

func (ArtifactList) Swap added in v0.6.19

func (d ArtifactList) Swap(i, j int)

type ArtifactMap

type ArtifactMap struct {
	NonEphemeralResourceTypes []string
	// contains filtered or unexported fields
}

ArtifactMap is the map between app names and GUIDs

func NewArtifactMap added in v0.6.19

func NewArtifactMap() *ArtifactMap

NewArtifactMap returns an empty ArtifactMap

func (*ArtifactMap) Append added in v0.6.19

func (am *ArtifactMap) Append(resourceType string, entry *ArtifactEntry)

Append locks ArtifactMap and appends entry to artifact list

func (*ArtifactMap) ClearArtifactMap added in v0.6.19

func (am *ArtifactMap) ClearArtifactMap()

ClearArtifactMap Empty Apps from ArtifactMap

func (*ArtifactMap) Count added in v0.6.19

func (am *ArtifactMap) Count(resourceType string) int

Count of specified resource type list

func (*ArtifactMap) DeleteApp

func (am *ArtifactMap) DeleteApp(appGUID string)

DeleteApp deletes an app from the ArtifactMap

func (*ArtifactMap) DeleteItem added in v0.6.19

func (am *ArtifactMap) DeleteItem(resourceType, lookfor string, id bool)

DeleteItem from artifact map

func (*ArtifactMap) DeleteItemUsingID added in v0.6.19

func (am *ArtifactMap) DeleteItemUsingID(id, resourceType string)

DeleteItemUsingID with resource type and ID

func (*ArtifactMap) FillAppsUsingDocListEntries

func (am *ArtifactMap) FillAppsUsingDocListEntries(docListEntries []*enigma.DocListEntry) error

FillAppsUsingDocListEntries should be used to fillAppMap app map in QSEoW

func (*ArtifactMap) FillAppsUsingStream added in v0.10.0

func (am *ArtifactMap) FillAppsUsingStream(stream structs.Stream) error

FillAppsUsingStream

func (*ArtifactMap) FillArtifacts added in v0.6.19

func (am *ArtifactMap) FillArtifacts(item *ItemData) error

FillArtifacts puts the app name (key) and the app ID (value) in the ArtifactMap

func (*ArtifactMap) First added in v0.6.19

func (am *ArtifactMap) First(resourceType string) *ArtifactEntry

First entry of resource type

func (*ArtifactMap) GetAppID

func (am *ArtifactMap) GetAppID(appName string) (string, error)

GetAppID returns the app ID given the app Title. When multiple apps have the same Title, this will return the ID of the last app in the order of the struct passed to the Fill function.

func (*ArtifactMap) GetAppItemID added in v0.6.19

func (am *ArtifactMap) GetAppItemID(appName string) (string, error)

GetAppItemID returns the item ID given the app Title. When multiple apps have the same Title, this will return the ID of the last app in the order of the struct passed to the Fill function.

func (*ArtifactMap) GetRandomApp

func (am *ArtifactMap) GetRandomApp(sessionState *State) (ArtifactEntry, error)

GetRandomApp returns a random app for the map, chosen by a uniform distribution

func (*ArtifactMap) GetRoundRobin

func (am *ArtifactMap) GetRoundRobin(sessionState *State) (ArtifactEntry, error)

GetRoundRobin returns a app round robin for the map

func (*ArtifactMap) JSON added in v0.6.19

func (am *ArtifactMap) JSON() ([]byte, error)

JSON locks artifact map and marshals json

func (*ArtifactMap) LogMap

func (am *ArtifactMap) LogMap(entry *logger.LogEntry) error

LogMap log entire map as debug logging

func (*ArtifactMap) Lookup added in v0.9.0

func (am *ArtifactMap) Lookup(resourcetype, lookup string, id bool) (*ArtifactEntry, error)

Lookup resource type with using lookup (name or ID, defined by id flag)

func (*ArtifactMap) LookupAppGUID

func (am *ArtifactMap) LookupAppGUID(guid string) (*ArtifactEntry, error)

LookupAppGUID lookup app using GUID

func (*ArtifactMap) LookupAppTitle

func (am *ArtifactMap) LookupAppTitle(title string) (*ArtifactEntry, error)

LookupAppTitle lookup app using title

func (*ArtifactMap) Sort added in v0.6.19

func (am *ArtifactMap) Sort(resourceType string)

Sort entries of resource type

type AutoChartHandler added in v0.5.3

type AutoChartHandler struct {
	DefaultHandler
}

func (*AutoChartHandler) Instance added in v0.5.3

func (handler *AutoChartHandler) Instance(id string) ObjectHandlerInstance

type AutoChartInstance added in v0.5.3

type AutoChartInstance struct {
	DefaultHandlerInstance
	ObjectDef *senseobjdef.ObjectDef
}

func (*AutoChartInstance) GetObjectDefinition added in v0.5.4

func (instance *AutoChartInstance) GetObjectDefinition(objectType string) (string, senseobjdef.SelectType, senseobjdef.DataDefType, error)

func (*AutoChartInstance) SetObjectAndEvents added in v0.5.3

func (instance *AutoChartInstance) SetObjectAndEvents(sessionState *State, actionState *action.State, obj *enigmahandlers.Object, genObj *enigma.GenericObject)

GetObject implement ObjectHandler interface

func (*AutoChartInstance) SetObjectDefData added in v0.5.4

func (instance *AutoChartInstance) SetObjectDefData(objDefData []senseobjdef.Data)

type ConnectionSettings

type ConnectionSettings interface {
	AllowUntrusted() bool
}

ConnectionSettings interface

type ContainerChild added in v0.6.10

type ContainerChild struct {
	RefID             string              `json:"refId"`
	Label             string              `json:"label"`
	IsMaster          bool                `json:"isMaster"`
	ExternalReference *ContainerExternal  `json:"externalReference"`
	Type              string              `json:"type"`
	Condition         *helpers.StringBool `json:"condition"`
}

type ContainerChildItem added in v0.6.10

type ContainerChildItem struct {
	Info enigma.NxInfo          `json:"qInfo"`
	Meta interface{}            `json:"qMeta"`
	Data ContainerChildItemData `json:"qData"`
}

type ContainerChildItemData added in v0.6.10

type ContainerChildItemData struct {
	Title            string `json:"title"`
	Visualization    string `json:"visualization"`
	ContainerChildId string `json:"containerChildId"`
	ExtendsId        string `json:"qExtendsId"`
	ShowCondition    string `json:"showCondition"`
}

type ContainerChildList added in v0.6.10

type ContainerChildList struct {
	Items []ContainerChildItem `json:"qItems"`
}

type ContainerChildReference added in v0.6.10

type ContainerChildReference struct {
	RefID    string
	ObjID    string
	External bool
	Show     bool
}

type ContainerExternal added in v0.6.10

type ContainerExternal struct {
	MasterID string `json:"masterId"`
	App      string `json:"app"`
	ViewID   string `json:"viewId"`
}

type ContainerHandler added in v0.6.10

type ContainerHandler struct{}

func (*ContainerHandler) Instance added in v0.6.10

func (handler *ContainerHandler) Instance(id string) ObjectHandlerInstance

Instance implements ObjectHandler interface

type ContainerHandlerInstance added in v0.6.10

type ContainerHandlerInstance struct {
	ID       string
	ActiveID string
	// contains filtered or unexported fields
}

func (*ContainerHandlerInstance) ActiveChildReference added in v0.6.17

func (handler *ContainerHandlerInstance) ActiveChildReference() *ContainerChildReference

ActiveChildReference returns reference to currently active child or nil

func (*ContainerHandlerInstance) ChildWithID added in v0.6.17

func (handler *ContainerHandlerInstance) ChildWithID(id string) *ContainerChildReference

ChildWithID returns child reference to child with defined object ID

func (*ContainerHandlerInstance) Children added in v0.6.10

func (handler *ContainerHandlerInstance) Children() []ContainerChildReference

Children returns copy of children

func (*ContainerHandlerInstance) FirstShowableChild added in v0.6.17

func (handler *ContainerHandlerInstance) FirstShowableChild() (*ContainerChildReference, bool)

FirstShowableChild gets reference to first object from container which fulfills conditions, true if already active object

func (*ContainerHandlerInstance) GetObjectDefinition added in v0.6.10

func (handler *ContainerHandlerInstance) GetObjectDefinition(objectType string) (string, senseobjdef.SelectType, senseobjdef.DataDefType, error)

GetObjectDefinition implements ObjectHandlerInstance interface

func (*ContainerHandlerInstance) SetObjectAndEvents added in v0.6.10

func (handler *ContainerHandlerInstance) SetObjectAndEvents(sessionState *State, actionState *action.State, obj *enigmahandlers.Object, genObj *enigma.GenericObject)

SetObjectAndEvents implements ObjectHandlerInstance interface

func (*ContainerHandlerInstance) SwitchActiveChild added in v0.6.17

func (handler *ContainerHandlerInstance) SwitchActiveChild(sessionState *State, actionState *action.State, child *ContainerChildReference) error

SwitchActiveChild to referenced child

func (*ContainerHandlerInstance) UpdateChildren added in v0.6.17

func (handler *ContainerHandlerInstance) UpdateChildren(layout *ContainerLayout) error

UpdateChildren of the container

type ContainerLayout added in v0.6.10

type ContainerLayout struct {
	Children  []ContainerChild   `json:"children"`
	ChildList ContainerChildList `json:"qChildList"`
}

func GetContainerLayout added in v0.6.17

func GetContainerLayout(sessionState *State, actionState *action.State, containerObject *enigma.GenericObject) *ContainerLayout

GetContainerLayout returns unmarshaled container layout, errors reported on action state

type DefaultHandler added in v0.5.3

type DefaultHandler struct{}

func (*DefaultHandler) Instance added in v0.5.3

func (handler *DefaultHandler) Instance(id string) ObjectHandlerInstance

type DefaultHandlerInstance added in v0.5.3

type DefaultHandlerInstance struct {
	Id string
}

func (*DefaultHandlerInstance) GetObjectDefinition added in v0.5.3

func (instance *DefaultHandlerInstance) GetObjectDefinition(objectType string) (string, senseobjdef.SelectType, senseobjdef.DataDefType, error)

func (*DefaultHandlerInstance) SetObjectAndEvents added in v0.5.3

func (instance *DefaultHandlerInstance) SetObjectAndEvents(sessionState *State, actionState *action.State, obj *enigmahandlers.Object, genObj *enigma.GenericObject)

GetObject implement ObjectHandler interface

type DefaultRandomizer added in v0.4.11

type DefaultRandomizer struct {
	*randomizer.Randomizer
	// contains filtered or unexported fields
}

func (*DefaultRandomizer) Reset added in v0.4.11

func (rnd *DefaultRandomizer) Reset(instance, session uint64, onlyInstanceSeed bool)

Reset child randomizer with new seed

type DuplicateKeyError

type DuplicateKeyError string

DuplicateKeyError is returned in case of adding an already existing key id

func (DuplicateKeyError) Error

func (err DuplicateKeyError) Error() string

Error id already exist in map

type Event

type Event struct {
	// F is function to be executed on event
	F func(ctx context.Context, actionState *action.State) error
	// NoFailOnError -
	// False (Default) - Report error and abort action
	// True - Log warning instead of failing and error reporting
	NoFailOnError bool
	// Close executed on de-registering event
	Close func()
}

Event encapsulates an event channel and a function to be executed on events

type EventMetricsLogger added in v0.6.0

type EventMetricsLogger struct {
	LogEntry *logger.LogEntry
}

func (*EventMetricsLogger) SocketOpenMetric added in v0.6.0

func (lgr *EventMetricsLogger) SocketOpenMetric(url *neturl.URL, duration time.Duration)

type FeatureAllocationError added in v0.6.23

type FeatureAllocationError struct{}

FeatureAllocationError returned when feature map is expected to be allocated but is not

func (FeatureAllocationError) Error added in v0.6.23

func (err FeatureAllocationError) Error() string

type FeatureFlagNotFoundError added in v0.6.23

type FeatureFlagNotFoundError string

FeatureFlagNotFoundError returned when feature flag was not found

func (FeatureFlagNotFoundError) Error added in v0.6.23

func (err FeatureFlagNotFoundError) Error() string

type Features added in v0.6.23

type Features struct {
	// contains filtered or unexported fields
}

Features maps feature flags and values

func (*Features) IsFeatureEnabled added in v0.6.23

func (features *Features) IsFeatureEnabled(feature string) (bool, error)

IsFeatureEnabled check if feature flag is enabled

func (*Features) IsFeatureEnabledDefault added in v0.6.23

func (features *Features) IsFeatureEnabledDefault(feature string, d bool) bool

IsFeatureEnabledDefault check if feature flag is enabled, if not existing return default value

func (*Features) UpdateCapabilities added in v0.10.0

func (features *Features) UpdateCapabilities(rest *RestHandler, host string, actionState *action.State, logEntry *logger.LogEntry)

UpdateCapabilities request capabilities from server and updates feature map

func (*Features) UpdateFeatureMap added in v0.6.23

func (features *Features) UpdateFeatureMap(rest *RestHandler, host string, actionState *action.State, logEntry *logger.LogEntry)

UpdateFeatureMap request features from server and updates feature map

type HeaderJar

type HeaderJar struct {
	// contains filtered or unexported fields
}

HeaderJar map between hosts and headers

func NewHeaderJar

func NewHeaderJar() *HeaderJar

NewHeaderJar returns an empty HeaderJar

func (*HeaderJar) GetHeader

func (hj *HeaderJar) GetHeader(host string) http.Header

GetHeader returns the header for the given host

func (*HeaderJar) SetHeader

func (hj *HeaderJar) SetHeader(host string, header http.Header)

SetHeader set header for a particular host

type IConnection

type IConnection interface {
	// Disconnect connection
	Disconnect() error

	// SetSense : set current sense environment
	SetSense(*enigmahandlers.SenseUplink)
	// Sense : connection to sense environment
	Sense() *enigmahandlers.SenseUplink
}

IConnection interface for current

type IDMap

type IDMap struct {
	// contains filtered or unexported fields
}

IDMap should be used as a lookup table for Id defined in the script and id of object created. We should never define the id to be sent to engine as this might cause collision errors, instead this lookup table is used with the key id connecting object together for in-script purposes.

func (*IDMap) Add

func (idm *IDMap) Add(key, id string, logEntry *logger.LogEntry) error

Add new key to id map

func (*IDMap) Get

func (idm *IDMap) Get(key string) string

Get Id value for key, if key not found return key itself

func (*IDMap) IsDuplicateKey

func (idm *IDMap) IsDuplicateKey(key string) error

IsDuplicateKey returns already in case of duplicate key

type ItemData added in v0.6.19

type ItemData struct {
	Data []ArtifactEntry `json:"data"`
}

ItemData struct to unmarshal list app response

type NoActiveDocError added in v0.5.7

type NoActiveDocError struct {
	Msg string
	Err error
}

func (NoActiveDocError) Error added in v0.5.7

func (err NoActiveDocError) Error() string

Error implements error interface

type ObjectHandler added in v0.5.3

type ObjectHandler interface {
	Instance(id string) ObjectHandlerInstance
}

type ObjectHandlerInstance added in v0.5.3

type ObjectHandlerInstance interface {
	SetObjectAndEvents(sessionState *State, actionState *action.State, obj *enigmahandlers.Object, genObj *enigma.GenericObject)
	GetObjectDefinition(objectType string) (string, senseobjdef.SelectType, senseobjdef.DataDefType, error)
}

type ReconnectInfo added in v0.5.7

type ReconnectInfo struct {
	// contains filtered or unexported fields
}

type ReconnectSettings added in v0.5.7

type ReconnectSettings struct {
	// Reconnect set to true to attempt reconnecting websocket on disconnect
	Reconnect bool `json:"reconnect" doc-key:"reconnectsettings.reconnect" displayname:"Reconnect on disconnected websocket"`
	// Backoff pattern for reconnect, if empty defaults to defaultReconnectBackoff
	Backoff []float64 `json:"backoff" doc-key:"reconnectsettings.backoff" displayname:"Reconnect backoff pattern"`
}

ReconnectSettings settings for re-connecting websocket on unexpected disconnect

type ReqOptions

type ReqOptions struct {
	// ExpectedStatusCode of response, empty list accepts everything (used e.g. for separate checking status)
	ExpectedStatusCode []int
	// FailOnError set to true for request to add an error to actionState, otherwise a warning is logged.
	FailOnError bool
	// ContentType defaults to application/json
	ContentType string
	// NoVirtualProxy disables the automatic adding of virtualproxy to request when a virtualproxy is defined.
	// This is useful e.g. when sending requests towards non sense environments as part of custom actions.
	NoVirtualProxy bool
}

ReqOptions options controlling handling of requests

func DefaultReqOptions

func DefaultReqOptions() *ReqOptions

DefaultReqOptions sets expected status code to 200 and fails on error

type RestHandler

type RestHandler struct {
	Client *http.Client
	// contains filtered or unexported fields
}

RestHandler handles waiting for pending requests and responses

func NewRestHandler

func NewRestHandler(ctx context.Context, size int, trafficLogger enigma.TrafficLogger, headerjar *HeaderJar, virtualProxy string, timeout time.Duration) *RestHandler

NewRestHandler new instance of RestHandler

func (*RestHandler) DecPending

func (handler *RestHandler) DecPending(request *RestRequest)

DecPending increase finished requests

func (*RestHandler) DeleteAsync added in v0.7.0

func (handler *RestHandler) DeleteAsync(url string, actionState *action.State, logEntry *logger.LogEntry, options *ReqOptions) *RestRequest

DeleteAsync send async DELETE request with options, using options=nil default options are used

func (*RestHandler) DeleteAsyncWithCallback added in v0.7.0

func (handler *RestHandler) DeleteAsyncWithCallback(url string, actionState *action.State, logEntry *logger.LogEntry, headers map[string]string, options *ReqOptions, callback func(err error, req *RestRequest)) *RestRequest

DeleteAsyncWithCallback send async DELETE request with options and callback, using options=nil default options are used

func (*RestHandler) DeleteAsyncWithHeaders added in v0.7.0

func (handler *RestHandler) DeleteAsyncWithHeaders(url string, actionState *action.State, logEntry *logger.LogEntry, headers map[string]string, options *ReqOptions) *RestRequest

DeleteAsyncWithHeaders send async DELETE request with options and headers, using options=nil default options are used

func (*RestHandler) GetAsync

func (handler *RestHandler) GetAsync(url string, actionState *action.State, logEntry *logger.LogEntry, options *ReqOptions) *RestRequest

GetAsync send async GET request with options, using options=nil default options are used

func (*RestHandler) GetAsyncWithCallback

func (handler *RestHandler) GetAsyncWithCallback(url string, actionState *action.State, logEntry *logger.LogEntry, options *ReqOptions, callback func(err error, req *RestRequest)) *RestRequest

GetAsyncWithCallback send async GET request with options and callback, with options=nil default options are used

func (*RestHandler) GetSync

func (handler *RestHandler) GetSync(url string, actionState *action.State, logEntry *logger.LogEntry, options *ReqOptions) (*RestRequest, error)

GetSync sends synchronous GET request with options, using options=nil default options are used

func (*RestHandler) GetSyncWithCallback

func (handler *RestHandler) GetSyncWithCallback(url string, actionState *action.State, logEntry *logger.LogEntry, options *ReqOptions, callback func(err error, req *RestRequest)) (*RestRequest, error)

GetSyncWithCallback sends synchronous GET request with options and callback, using options=nil default options are used

func (*RestHandler) GetWithHeadersAsync added in v0.5.8

func (handler *RestHandler) GetWithHeadersAsync(url string, actionState *action.State, logEntry *logger.LogEntry, headers map[string]string, options *ReqOptions, callback func(err error, req *RestRequest)) *RestRequest

GetWithHeadersAsync send async GET request with headers and options, using options=nil default options are used

func (*RestHandler) IncPending

func (handler *RestHandler) IncPending()

IncPending increase pending requests

func (*RestHandler) PatchAsync added in v0.6.26

func (handler *RestHandler) PatchAsync(url string, actionState *action.State, logEntry *logger.LogEntry, content []byte, options *ReqOptions) *RestRequest

PatchAsync send async PATCH request with options, using options=nil default options are used

func (*RestHandler) PatchAsyncWithCallback added in v0.6.26

func (handler *RestHandler) PatchAsyncWithCallback(url string, actionState *action.State, logEntry *logger.LogEntry, content []byte, headers map[string]string, options *ReqOptions, callback func(err error, req *RestRequest)) *RestRequest

PatchAsyncWithCallback send async PATCH request with options and callback, using options=nil default options are used

func (*RestHandler) PatchWithHeadersAsync added in v0.6.26

func (handler *RestHandler) PatchWithHeadersAsync(url string, actionState *action.State, logEntry *logger.LogEntry, content []byte, headers map[string]string, options *ReqOptions) *RestRequest

PatchWithHeadersAsync send async PATCH request with options and headers, using options=nil default options are used

func (*RestHandler) PostAsync

func (handler *RestHandler) PostAsync(url string, actionState *action.State, logEntry *logger.LogEntry, content []byte, options *ReqOptions) *RestRequest

PostAsync send async POST request with options, using options=nil default options are used

func (*RestHandler) PostAsyncWithCallback

func (handler *RestHandler) PostAsyncWithCallback(url string, actionState *action.State, logEntry *logger.LogEntry, content []byte, headers map[string]string, options *ReqOptions, callback func(err error, req *RestRequest)) *RestRequest

PostAsyncWithCallback send async POST request with options and callback, using options=nil default options are used

func (*RestHandler) PostWithHeadersAsync added in v0.5.8

func (handler *RestHandler) PostWithHeadersAsync(url string, actionState *action.State, logEntry *logger.LogEntry, content []byte, headers map[string]string, options *ReqOptions) *RestRequest

PostWithHeadersAsync send async POST request with options and headers, using options=nil default options are used

func (*RestHandler) PutAsync added in v0.6.26

func (handler *RestHandler) PutAsync(url string, actionState *action.State, logEntry *logger.LogEntry, content []byte, options *ReqOptions) *RestRequest

PutAsync send async PUT request with options, using options=nil default options are used

func (*RestHandler) PutAsyncWithCallback added in v0.6.26

func (handler *RestHandler) PutAsyncWithCallback(url string, actionState *action.State, logEntry *logger.LogEntry, content []byte, headers map[string]string, options *ReqOptions, callback func(err error, req *RestRequest)) *RestRequest

PutAsyncWithCallback send async PUT request with options and callback, using options=nil default options are used

func (*RestHandler) PutWithHeadersAsync added in v0.6.26

func (handler *RestHandler) PutWithHeadersAsync(url string, actionState *action.State, logEntry *logger.LogEntry, content []byte, headers map[string]string, options *ReqOptions) *RestRequest

PutWithHeadersAsync send async PUT request with options and headers, using options=nil default options are used

func (*RestHandler) QueueRequest

func (handler *RestHandler) QueueRequest(actionState *action.State, failOnError bool,
	request *RestRequest, logEntry *logger.LogEntry)

QueueRequest Async request

func (*RestHandler) QueueRequestWithCallback

func (handler *RestHandler) QueueRequestWithCallback(actionState *action.State, failOnError bool,
	request *RestRequest, logEntry *logger.LogEntry, callback func(err error, req *RestRequest))

QueueRequestWithCallback Async request with callback, set warnOnError to log warning instead of registering error for request

func (*RestHandler) SetClient

func (handler *RestHandler) SetClient(client *http.Client)

SetClient set HTTP client for this RestHandler

func (*RestHandler) WaitForPending

func (handler *RestHandler) WaitForPending()

WaitForPending uses double locking of mutex to wait until mutex is unlocked by loop listening for pending req/resp

type RestMethod

type RestMethod int

RestMethod method with which to execute request

const (
	// GET RestMethod
	GET RestMethod = iota
	// POST RestMethod
	POST
	// DELETE RestMethod
	DELETE
	// PUT RestMethod
	PUT
	// PATCH RestMethod
	PATCH
)

RestMethod values

func (RestMethod) MarshalJSON

func (method RestMethod) MarshalJSON() ([]byte, error)

MarshalJSON marshal RestMethod

func (RestMethod) String

func (method RestMethod) String() string

String implements fmt.Stringer interface

func (*RestMethod) UnmarshalJSON

func (method *RestMethod) UnmarshalJSON(arg []byte) error

UnmarshalJSON unmarshal RestMethod

type RestRequest

type RestRequest struct {
	Method        RestMethod
	ContentType   string
	Content       []byte
	ContentReader io.Reader
	Destination   string

	ResponseBody       []byte
	ResponseStatus     string
	ResponseStatusCode int
	ResponseHeaders    http.Header
	ExtraHeaders       map[string]string
	NoVirtualProxy     bool
	// contains filtered or unexported fields
}

RestRequest represents a REST request and its response

type SessionVariableTypeEnum added in v0.11.0

type SessionVariableTypeEnum int
const (
	SessionVariableTypeUnknown SessionVariableTypeEnum = iota
	SessionVariableTypeString
	SessionVariableTypeInt
	SessionVariableTypeArray
)

SessionVariableTypeEnum enumerations

func (SessionVariableTypeEnum) GetEnumMap added in v0.11.0

func (typ SessionVariableTypeEnum) GetEnumMap() *enummap.EnumMap

GetEnumMap return sessionVariableTypeEnumMap to GUI

func (SessionVariableTypeEnum) MarshalJSON added in v0.11.0

func (typ SessionVariableTypeEnum) MarshalJSON() ([]byte, error)

MarshalJSON SessionVariableTypeEnum type

func (SessionVariableTypeEnum) String added in v0.11.0

func (typ SessionVariableTypeEnum) String() string

String implements Stringer interface

func (*SessionVariableTypeEnum) UnmarshalJSON added in v0.11.0

func (typ *SessionVariableTypeEnum) UnmarshalJSON(arg []byte) error

UnmarshalJSON SessionVariableTypeEnum type

func (*SessionVariableTypeEnum) Validate added in v0.11.1

func (typ *SessionVariableTypeEnum) Validate() error

Validate SessionVariableTypeEnum type

type SessionVariables

type SessionVariables struct {
	users.User
	Session    uint64
	Thread     uint64
	ScriptVars map[string]interface{}
	Local      interface{}
}

SessionVariables is used as a data carrier for session variables.

type State

type State struct {
	Cookies      http.CookieJar
	VirtualProxy string
	Connection   IConnection
	ArtifactMap  *ArtifactMap
	IDMap        IDMap
	HeaderJar    *HeaderJar
	Timeout      time.Duration
	User         *users.User
	OutputsDir   string
	CurrentApp   *ArtifactEntry
	CurrentUser  *structs.User
	Counters     *statistics.ExecutionCounters
	// CurrentActionState will contain the state of the latest action to be started
	CurrentActionState *action.State
	LogEntry           *logger.LogEntry
	EW                 statistics.ErrWarn
	Pending            pending.Handler
	Rest               *RestHandler
	RequestMetrics     *requestmetrics.RequestMetrics
	ReconnectSettings  ReconnectSettings
	Features           Features
	// contains filtered or unexported fields
}

State for user

func New

func New(ctx context.Context, outputsDir string, timeout time.Duration, user *users.User, session, instance uint64,
	virtualProxy string, onlyInstanceSeed bool, counters *statistics.ExecutionCounters) *State

New instance of session state

func NewWithRandomizer added in v0.4.11

func NewWithRandomizer(ctx context.Context, outputsDir string, timeout time.Duration, user *users.User, virtualProxy string,
	rnd helpers.Randomizer, counters *statistics.ExecutionCounters) *State

NewWithRandomizer instance of session state with custom randomizer

func (*State) AddCustomState added in v0.9.0

func (state *State) AddCustomState(key string, value interface{})

AddCustomState add custom data handler to state object

func (*State) AwaitReconnect added in v0.5.7

func (state *State) AwaitReconnect()

AwaitReconnect awaits any reconnect lock to be released

func (*State) BaseContext

func (state *State) BaseContext() context.Context

BaseContext for state. Normally shouldn't be used. Use ReqContext for for context on Sense actions, or methods handling the context such as QueueRequest and SendRequest

func (*State) Cancel

func (state *State) Cancel()

Cancel state context

func (*State) ClearObjectSubscriptions added in v0.6.10

func (state *State) ClearObjectSubscriptions()

ClearObjectSubscriptions and currently subscribed objects

func (*State) ClearSubscribedObjects added in v0.6.10

func (state *State) ClearSubscribedObjects(IDs []string) error

ClearSubscribedObjects unsubscribes from listed objects

func (*State) ContextChangeList

func (state *State) ContextChangeList() (context.Context, *enigma.ChangeLists)

ContextChangeList create changeList object and context to be used for synchronizing changes

func (*State) ContextWithTimeout

func (state *State) ContextWithTimeout(ctx context.Context) (context.Context, context.CancelFunc)

ContextWithTimeout new context based on ctx with default timeout

func (*State) CurrentSenseApp added in v0.5.7

func (state *State) CurrentSenseApp() (*senseobjects.App, error)

CurrentSenseApp returns currently set sense app or error if none found

func (state *State) CurrentSenseUplink() (*enigmahandlers.SenseUplink, error)

CurrentSenseUplink return currently set sense uplink or error if none found

func (*State) DeRegisterEvent

func (state *State) DeRegisterEvent(handle int)

DeRegisterEvent for handle

func (*State) DeRegisterEvents

func (state *State) DeRegisterEvents(handles []int)

DeRegisterEvents for handles in list

func (*State) DeregisterAllEvents

func (state *State) DeregisterAllEvents()

DeregisterAllEvents for session

func (*State) Disconnect

func (state *State) Disconnect()

Disconnect de-registers all events and disconnects current connection

func (*State) EventWebsocket added in v0.6.0

func (state *State) EventWebsocket() *eventws.EventWebsocket

EventWebsocket returns current established event websocket or nil

func (*State) GetActiveDoc added in v0.5.7

func (state *State) GetActiveDoc(actionState *action.State, upLink *enigmahandlers.SenseUplink) (*enigma.Doc, error)

GetActiveDoc get active doc from engine

func (*State) GetCustomState added in v0.9.0

func (state *State) GetCustomState(key string) (interface{}, bool)

GetCustomState data handler from state object

func (*State) GetObjectHandlerInstance added in v0.5.3

func (state *State) GetObjectHandlerInstance(id, typ string) ObjectHandlerInstance

GetObjectHandlerInstance for object ID and type

func (*State) GetReconnectError added in v0.5.7

func (state *State) GetReconnectError() error

GetReconnectError from latest finished reconnect attempt

func (*State) GetSessionVariable

func (state *State) GetSessionVariable(localData interface{}) SessionVariables

GetSessionVariable populates and returns session variables struct

func (*State) GetSheet added in v0.5.7

func (state *State) GetSheet(actionState *action.State, upLink *enigmahandlers.SenseUplink, id string) (*enigmahandlers.Object, *senseobjects.Sheet, error)

GetSheet get sheet and add to object list

func (*State) GetSheetList added in v0.5.7

func (state *State) GetSheetList(actionState *action.State, uplink *enigmahandlers.SenseUplink)

GetSheetList create and update sheetlist session object if not existing

func (*State) IsAbortTriggered

func (state *State) IsAbortTriggered() bool

IsAbortTriggered check if abort has been flagged

func (*State) IsSenseWebsocketDisconnected added in v0.6.0

func (state *State) IsSenseWebsocketDisconnected(err error) bool

IsSenseWebsocketDisconnected checks if error is caused by websocket disconnect

func (*State) QueueRequest

func (state *State) QueueRequest(f func(ctx context.Context) error, actionState *action.State, failOnError bool, errMsg string)

QueueRequest Async request, add error to action state or log as warning depending on failOnError flag. This method adds timeout and ChangeList to ctx context and auto triggers changes. Thus ctx should not be used when having multiple request in a QueueRequest function, instead use SendRequest and SendRequestRaw internally in f. Changes can also be handled "manually" with the help of TriggerContextChanges.

func (*State) QueueRequestWithCallback

func (state *State) QueueRequestWithCallback(f func(ctx context.Context) error, actionState *action.State, failOnError bool, errMsg string, callback func(err error))

QueueRequestWithCallback Async request, add error to action state or log as warning depending on failOnError flag. This method adds timeout and ChangeList to ctx context and auto triggers changes. Thus ctx should not be used when having multiple request in a QueueRequest function, instead use SendRequest and SendRequestRaw internally in f. Changes can also be handled "manually" with the help of TriggerContextChanges.

func (*State) Randomizer

func (state *State) Randomizer() helpers.Randomizer

Randomizer get randomizer for session

func (*State) Reconnect added in v0.5.7

func (state *State) Reconnect() error

Reconnect attempts reconnecting to previously opened app

func (*State) RegisterEvent

func (state *State) RegisterEvent(handle int,
	event func(ctx context.Context, actionState *action.State) error,
	onClose func(), failOnError bool)

RegisterEvent register function to be executed on object change

func (*State) ReplaceSessionVariables

func (state *State) ReplaceSessionVariables(input *SyncedTemplate) (string, error)

ReplaceSessionVariables execute template and replace session variables, e.g. "my app ({{.UserName}})" -> "my app (user_1)"

func (*State) ReplaceSessionVariablesWithLocalData

func (state *State) ReplaceSessionVariablesWithLocalData(input *SyncedTemplate, localData interface{}) (string, error)

ReplaceSessionVariablesWithLocalData execute template and replace session variables, e.g. "my app ({{.UserName}})" -> "my app (user_1)", extra "local" data can be added in addition to the session variables

func (*State) ReqContext

func (state *State) ReqContext() (context.Context, *enigma.ChangeLists, context.CancelFunc)

ReqContext context to be used on request, includes timeout and changeList to be used for synchronizing changes. A request context is automatically added when using QueueRequest functions.

func (*State) Reset

func (state *State) Reset(ctx context.Context)

Reset session, to be used when an existing session state enters a new "sequence"

func (*State) SendRequest

func (state *State) SendRequest(actionState *action.State, f func(ctx context.Context) error) error

SendRequest and trigger any object changes synchronously

func (*State) SendRequestRaw

func (state *State) SendRequestRaw(actionState *action.State, f func(ctx context.Context) (json.RawMessage, error)) (json.RawMessage, error)

SendRequestRaw send request, trigger any object changes synchronously and return raw json response.

func (*State) SetLogEntry

func (state *State) SetLogEntry(entry *logger.LogEntry)

SetLogEntry set the log entry

func (*State) SetRandomizer

func (state *State) SetRandomizer(rnd helpers.Randomizer, force bool)

SetRandomizer set randomizer for session, will not be set if already has a randomizer on concurrent sets, first instance to acquire lock will "win". When setting to nil, it will be automatically forced. Set force flag to have randomizer set even when a randomizer exists.

func (*State) SetReconnectFunc added in v0.5.7

func (state *State) SetReconnectFunc(f func() (string, error))

SetReconnectFunc sets current app re-connect function

func (*State) SetVariableValue added in v0.11.0

func (state *State) SetVariableValue(variable string, value interface{})

SetVariableValue to session variable map

func (*State) SetupChangeChan added in v0.5.7

func (state *State) SetupChangeChan() error

SetupChangeChan start listening to enigma change channel

func (*State) SetupEventWebsocketAsync added in v0.6.0

func (state *State) SetupEventWebsocketAsync(actionState *action.State, nurl neturl.URL, allowuntrusted bool)

SetupEventWebsocketAsync setup event websocket and listener

func (*State) TrafficLogger

func (state *State) TrafficLogger() enigmahandlers.ITrafficLogger

TrafficLogger returns the current trafficLogger

func (*State) TriggerContextChanges

func (state *State) TriggerContextChanges(ctx context.Context, actionState *action.State)

TriggerContextChanges gets ChangeList from context and triggers changes

func (*State) TriggerEvents

func (state *State) TriggerEvents(actionState *action.State, chHandles, clHandles []int)

TriggerEvents from change and close lists

func (*State) UpdateFeatureMap added in v0.6.23

func (state *State) UpdateFeatureMap(host string, actionState *action.State)

UpdateFeatureMap request features from server and updates feature map

func (*State) WSFailed

func (state *State) WSFailed()

WSFailed Should be executed on websocket unexpectedly failing

func (*State) Wait

func (state *State) Wait(actionState *action.State) bool

Wait for all pending requests to finish, returns true if action state has been marked as failed

type SyncedTemplate

type SyncedTemplate struct {
	// contains filtered or unexported fields
}

Synced Template used for creating templates parsed once

func NewSyncedTemplate

func NewSyncedTemplate(t string) (*SyncedTemplate, error)

NewSyncedTemplate parses string and creates new instance of SyncedTemplate

func (*SyncedTemplate) Execute

func (syn *SyncedTemplate) Execute(writer io.Writer, data interface{}) error

Execute template

func (SyncedTemplate) MarshalJSON

func (syn SyncedTemplate) MarshalJSON() ([]byte, error)

MarshalJSON marshal template to json string

func (*SyncedTemplate) ReplaceWithoutSessionVariables

func (input *SyncedTemplate) ReplaceWithoutSessionVariables(data interface{}) (string, error)

ReplaceWithoutSessionVariables execute template without session variables - only use if we do not have a session

func (*SyncedTemplate) String

func (syn *SyncedTemplate) String() string

String return text pattern

func (SyncedTemplate) TreatAs

func (syn SyncedTemplate) TreatAs() string

func (*SyncedTemplate) UnmarshalJSON

func (syn *SyncedTemplate) UnmarshalJSON(arg []byte) error

UnmarshalJSON un-marshal from json string

type Transport

type Transport struct {
	*http.Transport
	*State
}

Transport http transport interceptor

func (*Transport) RoundTrip

func (transport *Transport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implement RoundTripper interface

Jump to

Keyboard shortcuts

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