events

package
v0.0.0-...-81c02da Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2023 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Overview

Package events have the functionality of - Create Event Subscription - Delete Event Subscription - Get Event Subscription - Post Event Subscription to destination - Post TestEvent (SubmitTestEvent) and corresponding unit test cases

Package events have the functionality of - Create Event Subscription - Delete Event Subscription - Get Event Subscription - Post Event Subscription to destination - Post TestEvent (SubmitTestEvent) and corresponding unit test cases

Package events have the functionality of - Create Event Subscription - Delete Event Subscription - Get Event Subscription - Post Event Subscription to destination - Post TestEvent (SubmitTestEvent) and corresponding unit test cases

Package events have the functionality of - Create Event Subscription - Delete Event Subscription - Get Event Subscription - Post Event Subscription to destination - Post TestEvent (SubmitTestEvent) and corresponding unit test cases

Package events have the functionality of - Create Event Subscription - Delete Event Subscription - Get Event Subscription - Post Event Subscription to destination - Post TestEvent (SubmitTestEvent) and corresponding unit test cases

Package events have the functionality of - Create Event Subscription - Delete Event Subscription - Get Event Subscription - Post Event Subscription to destination - Post TestEvent (SubmitTestEvent) and corresponding unit test cases

Package events have the functionality of - Create Event Subscription - Delete Event Subscription - Get Event Subscription - Post Event Subscription to destination and corresponding unit test cases

Index

Constants

This section is empty.

Variables

View Source
var (
	// UpdateTaskService function  pointer for calling the files
	UpdateTaskService = services.UpdateTask
	// IOUtilReadAllFunc function  pointer for calling the files
	IOUtilReadAllFunc = ioutil.ReadAll
)
View Source
var (
	//GetIPFromHostNameFunc ...
	GetIPFromHostNameFunc = common.GetIPFromHostName
	//DecryptWithPrivateKeyFunc ...
	DecryptWithPrivateKeyFunc = common.DecryptWithPrivateKey
)
View Source
var (
	// SendEventFunc function  pointer for calling the files
	SendEventFunc = sendEvent
	//ServiceDiscoveryFunc func pointer for calling the files
	ServiceDiscoveryFunc = services.ODIMService.Client
)
View Source
var (
	//JSONUnmarshal function  pointer for calling the files
	JSONUnmarshal = json.Unmarshal
	//RequestParamsCaseValidatorFunc function  pointer for calling the files
	RequestParamsCaseValidatorFunc = common.RequestParamsCaseValidator
)
View Source
var FillInSubTaskID = ""

FillInSubTaskID is used as a nil value for subtask id as for some tasks subtask is not created and the function expects a subtask id in the parameters

Functions

func UpdateTaskData

func UpdateTaskData(ctx context.Context, taskData common.TaskData) error

UpdateTaskData update the task with the given data

Types

type DB

type DB struct {
	GetSessionUserName               func(ctx context.Context, sessionToken string) (string, error)
	GetEvtSubscriptions              func(string) ([]evmodel.SubscriptionResource, error)
	SaveEventSubscription            func(evmodel.SubscriptionResource) error
	GetPluginData                    func(string) (*common.Plugin, *errors.Error)
	GetDeviceSubscriptions           func(string) (*common.DeviceSubscription, error)
	GetTarget                        func(string) (*common.Target, error)
	GetAllKeysFromTable              func(string) ([]string, error)
	GetAllFabrics                    func() ([]string, error)
	GetAllMatchingDetails            func(string, string, common.DbType) ([]string, *errors.Error)
	UpdateDeviceSubscriptionLocation func(common.DeviceSubscription) error
	GetFabricData                    func(string) (evmodel.Fabric, error)
	DeleteEvtSubscription            func(string) error
	DeleteDeviceSubscription         func(hostIP string) error
	UpdateEventSubscription          func(evmodel.SubscriptionResource) error
	SaveUndeliveredEvents            func(string, []byte) error
	SaveDeviceSubscription           func(common.DeviceSubscription) error
	GetUndeliveredEvents             func(string) (string, error)
	DeleteUndeliveredEvents          func(string) error
	GetUndeliveredEventsFlag         func(string) (bool, error)
	SetUndeliveredEventsFlag         func(string) error
	DeleteUndeliveredEventsFlag      func(string) error
	GetAggregateData                 func(string) (evmodel.Aggregate, error)
	SaveAggregateSubscription        func(aggregateId string, hostIP []string) error
	GetAggregateHosts                func(aggregateIP string) ([]string, error)
	UpdateAggregateHosts             func(aggregateId string, hostIP []string) error
	GetAggregateList                 func(hostIP string) ([]string, error)
	GetUndeliveredEventsKeyList      func(string, string, common.DbType, int) ([]string, int, *errors.Error)
}

DB struct to inject the contact DB function into the handlers

type External

type External struct {
	ContactClient   func(context.Context, string, string, string, string, interface{}, map[string]string) (*http.Response, error)
	Auth            func(context.Context, string, []string, []string) (response.RPC, error)
	CreateTask      func(context.Context, string) (string, error)
	UpdateTask      func(context.Context, common.TaskData) error
	CreateChildTask func(context.Context, string, string) (string, error)
}

External struct to inject the contact external function into the handlers

type ExternalInterfaces

type ExternalInterfaces struct {
	External
	DB
}

ExternalInterfaces struct to inject the pmb client function into the handlers

func (*ExternalInterfaces) CreateDefaultEventSubscription

func (e *ExternalInterfaces) CreateDefaultEventSubscription(ctx context.Context, originResources, eventTypes, messageIDs, resourceTypes []string, protocol string) errResponse.RPC

CreateDefaultEventSubscription is creates the subscription with event types which will be required to rediscover the inventory after computer system restarts ,This will triggered from aggregation service whenever a computer system is added

func (*ExternalInterfaces) CreateEventSubscription

func (e *ExternalInterfaces) CreateEventSubscription(ctx context.Context, taskID string, sessionUserName string, req *eventsproto.EventSubRequest) errResponse.RPC

CreateEventSubscription is a API to create event subscription

func (*ExternalInterfaces) CreateSubTask

func (e *ExternalInterfaces) CreateSubTask(ctx context.Context, reqSessionToken string, parentTask string) string

CreateSubTask creates a child task for a task calling RPC to task service and returns the subtask ID

func (*ExternalInterfaces) DeleteAggregateSubscriptions

func (e *ExternalInterfaces) DeleteAggregateSubscriptions(ctx context.Context, req *eventsproto.EventUpdateRequest, isRemove bool) error

DeleteAggregateSubscriptions it will add subscription for newly Added system in aggregate

func (*ExternalInterfaces) DeleteEventSubscriptions

func (e *ExternalInterfaces) DeleteEventSubscriptions(ctx context.Context, req *eventsproto.EventRequest) response.RPC

DeleteEventSubscriptions delete subscription data against given URL

func (*ExternalInterfaces) DeleteEventSubscriptionsDetails

func (e *ExternalInterfaces) DeleteEventSubscriptionsDetails(ctx context.Context, req *eventsproto.EventRequest) response.RPC

DeleteEventSubscriptionsDetails delete subscription data against given subscription id

func (*ExternalInterfaces) DeleteFabricsSubscription

func (e *ExternalInterfaces) DeleteFabricsSubscription(ctx context.Context, originResource string, plugin *common.Plugin) (response.RPC, error)

DeleteFabricsSubscription will delete fabric subscription

func (*ExternalInterfaces) DeleteSubscriptions

func (e *ExternalInterfaces) DeleteSubscriptions(ctx context.Context, originResource, token string, plugin *common.Plugin, target *common.Target) (errResponse.RPC, error)

DeleteSubscriptions will delete subscription from device

func (*ExternalInterfaces) GetAggregateSubscriptionList

func (e *ExternalInterfaces) GetAggregateSubscriptionList(ctx context.Context, host, aggregateID string, isRemove bool) (data []evmodel.SubscriptionResource)

GetAggregateSubscriptionList return list of subscription corresponding to host

func (*ExternalInterfaces) GetEventSubscriptionsCollection

func (e *ExternalInterfaces) GetEventSubscriptionsCollection(ctx context.Context, req *eventsproto.EventRequest) response.RPC

GetEventSubscriptionsCollection collects all subscription details

func (*ExternalInterfaces) GetEventSubscriptionsDetails

func (e *ExternalInterfaces) GetEventSubscriptionsDetails(ctx context.Context, req *eventsproto.EventRequest) response.RPC

GetEventSubscriptionsDetails collects subscription data against given subscription id

func (*ExternalInterfaces) IsAggregateHaveSubscription

func (e *ExternalInterfaces) IsAggregateHaveSubscription(ctx context.Context, req *eventsproto.EventUpdateRequest) bool

IsAggregateHaveSubscription validate any subscription contain aggregate id, return status

func (*ExternalInterfaces) IsEventsSubscribed

func (e *ExternalInterfaces) IsEventsSubscribed(ctx context.Context, token, origin string, subscription *model.EventDestination, plugin *common.Plugin, target *common.Target, collectionFlag bool, collectionName string, isAggregate bool, aggregateID string, isRemove bool) (errResponse.RPC, error)

IsEventsSubscribed is to check events already subscribed. if event already subscribed then will do search the subscription details in db against host IP if data found then delete the entry in db and get the event types and also delete the subscription on device also subscription: New Subscription subscriptionDetails : subscription details stored in db for the particular device

func (*ExternalInterfaces) LoadSubscriptionData

func (e *ExternalInterfaces) LoadSubscriptionData(ctx context.Context) error

LoadSubscriptionData method calls whenever service is started Here we load Subscription, DeviceSubscription, AggregateToHost table data into cache memory

func (*ExternalInterfaces) PluginCall

PluginCall method is to call to given url and method and validate the response and return

func (*ExternalInterfaces) PublishEventsToDestination

func (e *ExternalInterfaces) PublishEventsToDestination(ctx context.Context, data interface{}) bool

PublishEventsToDestination This method sends the event/alert to subscriber's destination Takes:

data of type interface{}

Returns:

bool: return false if any error occurred during execution, else returns true

func (*ExternalInterfaces) SaveSubscription

func (e *ExternalInterfaces) SaveSubscription(ctx context.Context, sessionUserName, subscriptionID string,
	hosts []string, successfulSubscriptionList []model.Link, postRequest model.EventDestination) (int32, string, []interface{}, error)

SaveSubscription function save subscription in db

func (*ExternalInterfaces) SaveSubscriptionOnDevice

func (e *ExternalInterfaces) SaveSubscriptionOnDevice(ctx context.Context, origin string, target *common.Target,
	plugin *common.Plugin, contactRequest evcommon.PluginContactRequest,
	subscriptionPost model.EventDestination, subTaskID string) (string, evresponse.EventResponse)

SaveSubscriptionOnDevice method update subscription on device

func (*ExternalInterfaces) SubmitTestEvent

SubmitTestEvent is a helper method to handle the submit test event request.

func (*ExternalInterfaces) UpdateEventSubscriptions

func (e *ExternalInterfaces) UpdateEventSubscriptions(ctx context.Context, req *eventsproto.EventUpdateRequest, isRemove bool) (string, evresponse.EventResponse)

UpdateEventSubscriptions it will add subscription for newly Added system in aggregate

func (*ExternalInterfaces) UpdateSubscriptionLocation

func (e *ExternalInterfaces) UpdateSubscriptionLocation(ctx context.Context, location, host string) bool

UpdateSubscriptionLocation method location and host takes as input and update subscription location in DeviceSubscription table to corresponding host

func (*ExternalInterfaces) ValidateRequest

func (e *ExternalInterfaces) ValidateRequest(ctx context.Context, req *eventsproto.EventSubRequest,
	postRequest model.EventDestination) (int32, string, []interface{}, error)

ValidateRequest input request for create subscription

Jump to

Keyboard shortcuts

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