File size: 3,845 Bytes
9373c61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5cfe5c4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
package com.dalab.policyengine.service;

import java.util.List;
import java.util.UUID;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

import com.dalab.policyengine.dto.EventAnalyticsDTO;
import com.dalab.policyengine.dto.EventStreamDTO;
import com.dalab.policyengine.dto.EventSubscriptionInputDTO;
import com.dalab.policyengine.dto.EventSubscriptionOutputDTO;
import com.dalab.policyengine.model.EventSubscriptionStatus;
import com.dalab.policyengine.model.EventType;

/**

 * Service interface for Event Subscription management and event streaming.

 * Provides operations for creating, managing, and processing event subscriptions.

 */
public interface IEventSubscriptionService {

    // Subscription Management

    /**

     * Create a new event subscription for the authenticated user

     */
    EventSubscriptionOutputDTO createSubscription(EventSubscriptionInputDTO inputDTO, UUID creatorUserId);

    /**

     * Update an existing event subscription

     */
    EventSubscriptionOutputDTO updateSubscription(UUID subscriptionId, EventSubscriptionInputDTO inputDTO, UUID updaterUserId);

    /**

     * Get event subscription by ID

     */
    EventSubscriptionOutputDTO getSubscriptionById(UUID subscriptionId);

    /**

     * Get all event subscriptions for a user with pagination

     */
    Page<EventSubscriptionOutputDTO> getSubscriptionsForUser(UUID userId, Pageable pageable, String status, String nameContains);

    /**

     * Get all event subscriptions (admin only) with pagination

     */
    Page<EventSubscriptionOutputDTO> getAllSubscriptions(Pageable pageable, String status, String nameContains);

    /**

     * Delete an event subscription

     */
    void deleteSubscription(UUID subscriptionId);

    /**

     * Update subscription status (enable/disable/pause)

     */
    EventSubscriptionOutputDTO updateSubscriptionStatus(UUID subscriptionId, EventSubscriptionStatus status, UUID updaterUserId);

    // Event Streaming and Processing

    /**

     * Get real-time event stream for a user's subscriptions

     * This would typically be used with WebSocket or Server-Sent Events

     */
    List<EventStreamDTO> getEventStreamForUser(UUID userId, Integer limit);

    /**

     * Get event stream for all subscriptions (admin only)

     */
    List<EventStreamDTO> getAllEventStream(Integer limit);

    /**

     * Process an incoming event and match it against active subscriptions

     */
    void processIncomingEvent(EventStreamDTO eventDTO);

    /**

     * Get historical events for a subscription

     */
    Page<EventStreamDTO> getHistoricalEventsForSubscription(UUID subscriptionId, Pageable pageable);

    // Analytics and Metrics

    /**

     * Get event analytics for a user's subscriptions

     */
    EventAnalyticsDTO getEventAnalyticsForUser(UUID userId);

    /**

     * Get system-wide event analytics (admin only)

     */
    EventAnalyticsDTO getSystemEventAnalytics();

    /**

     * Get event analytics for a specific time range

     */
    EventAnalyticsDTO getEventAnalyticsForTimeRange(UUID userId, java.time.Instant fromTime, java.time.Instant toTime);

    // Utility Methods

    /**

     * Test event rules against sample data

     */
    boolean testEventRule(String ruleCondition, EventStreamDTO sampleEvent);

    /**

     * Get available event types for subscription configuration

     */
    List<EventType> getAvailableEventTypes();

    /**

     * Get available source services for subscription configuration

     */
    List<String> getAvailableSourceServices();

    /**

     * Validate subscription configuration

     */
    void validateSubscriptionConfiguration(EventSubscriptionInputDTO inputDTO);
}