[TT-11966/TT-12064] implement OAS webhooks events#6258
Conversation
|
API Changes --- prev.txt 2024-05-07 14:32:20.760436472 +0000
+++ current.txt 2024-05-07 14:32:17.900402827 +0000
@@ -1806,9 +1806,11 @@
Method string `bson:"method" json:"method"`
}
-type TykEvent string // A type so we can ENUM event types easily, e.g. EventQuotaExceeded
+type TykEvent = event.Event
+ TykEvent is an alias maintained for backwards compatibility.
-type TykEventHandlerName string // A type for handler codes in API definitions
+type TykEventHandlerName = event.HandlerName
+ TykEventHandlerName is an alias maintained for backwards compatibility.
type UDGGlobalHeader struct {
Key string `bson:"key" json:"key"`
@@ -1947,6 +1949,29 @@
ProxyOnError bool `bson:"proxy_on_error" json:"proxy_on_error"`
}
+type WebHookHandlerConf struct {
+ // Disabled enables/disables this webhook.
+ Disabled bool `bson:"disabled" json:"disabled"`
+ // ID optional ID of the webhook, to be used in pro mode.
+ ID string `bson:"id" json:"id"`
+ // Name is the name of webhook.
+ Name string `bson:"name" json:"name"`
+ // The method to use for the webhook.
+ Method string `bson:"method" json:"method"`
+ // The target path on which to send the request.
+ TargetPath string `bson:"target_path" json:"target_path"`
+ // The template to load in order to format the request.
+ TemplatePath string `bson:"template_path" json:"template_path"`
+ // Headers to set when firing the webhook.
+ HeaderList map[string]string `bson:"header_map" json:"header_map"`
+ // The cool-down for the event so it does not trigger again (in seconds).
+ EventTimeout int64 `bson:"event_timeout" json:"event_timeout"`
+}
+ WebHookHandlerConf holds configuration related to webhook event handler.
+
+func (w *WebHookHandlerConf) Scan(in any) error
+ Scan scans WebHookHandlerConf from `any` in.
+
# Package: ./apidef/adapter
package adapter // import "github.com/TykTechnologies/tyk/apidef/adapter"
@@ -2908,6 +2933,43 @@
func (et *EnforceTimeout) Fill(meta apidef.HardTimeoutMeta)
Fill fills *EnforceTimeout from apidef.HardTimeoutMeta.
+type Event struct {
+ // Enabled enables the event handler.
+ Enabled bool `json:"enabled" bson:"enabled"`
+ // Type specifies the TykEvent that should trigger the event handler.
+ Type event.Event `json:"type" bson:"type"`
+ // Action specifies the action to be taken on the event trigger.
+ Action event.Action `json:"action" bson:"action"`
+ // ID is the ID of event handler in storage.
+ ID string `json:"id,omitempty" bson:"id,omitempty"`
+ // Name is the name of event handler
+ Name string `json:"name,omitempty" bson:"name,omitempty"`
+
+ Webhook WebhookEvent `bson:"-" json:"-"`
+}
+ Event holds information about individual event to be configured on the API.
+
+func (e *Event) GetWebhookConf() (map[string]interface{}, error)
+ GetWebhookConf converts Event.WebhookEvent to map[string]interface{}
+ with apidef.WebHookHandlerConf structure for classic API definition
+ compatibility.
+
+func (e *Event) MarshalJSON() ([]byte, error)
+ MarshalJSON marshals Event as per Tyk OAS API definition contract.
+
+func (e *Event) UnmarshalJSON(in []byte) error
+ UnmarshalJSON unmarshals Event as per Tyk OAS API definition contract.
+
+type Events []Event
+ Events holds the list of events to be processed for the API.
+
+func (e *Events) ExtractTo(api *apidef.APIDefinition)
+ ExtractTo extracts events to apidef.APIDefinition.
+
+func (e *Events) Fill(api apidef.APIDefinition)
+ Fill fills Events from classic API definition. Currently only webhook events
+ are supported.
+
type ExternalOAuth struct {
Enabled bool `bson:"enabled" json:"enabled"` // required
AuthSources `bson:",inline" json:",inline"`
@@ -3827,6 +3889,11 @@
//
// Tyk classic API definition: `detailed_tracing`
DetailedTracing *DetailedTracing `bson:"detailedTracing,omitempty" json:"detailedTracing,omitempty"`
+
+ // Events contains the configuration related to Tyk Events.
+ //
+ // Tyk classic API definition: `event_handlers`
+ Events Events `bson:"events,omitempty" json:"events,omitempty"`
}
Server contains the configuration that sets Tyk up to receive requests from
the client applications.
@@ -4345,6 +4412,15 @@
It is implemented to facilitate a smooth migration from deprecated fields
that were previously used to represent the same data.
+type WebhookEvent struct {
+ URL string `json:"url" bson:"url"`
+ Method string `json:"method" bson:"method"`
+ Timeout int64 `json:"timeout" bson:"timeout"`
+ BodyTemplate string `json:"bodyTemplate,omitempty" bson:"bodyTemplate,omitempty"`
+ Headers map[string]string `json:"headers,omitempty" bson:"headers,omitempty"`
+}
+ WebhookEvent stores the core information about a webhook event.
+
type XTykAPIGateway struct {
// Info contains the main metadata for the API definition.
Info Info `bson:"info" json:"info"` // required
@@ -5299,6 +5375,7 @@
func (c *Config) LoadIgnoredIPs()
func (c *Config) SetEventTriggers(eventTriggers map[apidef.TykEvent][]TykEventHandler)
+ SetEventTriggers sets events for backwards compatibility
func (c *Config) StoreAnalytics(ip string) bool
@@ -6793,26 +6870,40 @@
other types. This is a go <1.13 cludge.
const (
- EventQuotaExceeded apidef.TykEvent = "QuotaExceeded"
- EventRateLimitExceeded apidef.TykEvent = "RatelimitExceeded"
- EventAuthFailure apidef.TykEvent = "AuthFailure"
- EventKeyExpired apidef.TykEvent = "KeyExpired"
- EventVersionFailure apidef.TykEvent = "VersionFailure"
- EventOrgQuotaExceeded apidef.TykEvent = "OrgQuotaExceeded"
- EventOrgRateLimitExceeded apidef.TykEvent = "OrgRateLimitExceeded"
- EventTriggerExceeded apidef.TykEvent = "TriggerExceeded"
- EventBreakerTriggered apidef.TykEvent = "BreakerTriggered"
- EventBreakerTripped apidef.TykEvent = "BreakerTripped"
- EventBreakerReset apidef.TykEvent = "BreakerReset"
- EventHOSTDOWN apidef.TykEvent = "HostDown"
- EventHOSTUP apidef.TykEvent = "HostUp"
- EventTokenCreated apidef.TykEvent = "TokenCreated"
- EventTokenUpdated apidef.TykEvent = "TokenUpdated"
- EventTokenDeleted apidef.TykEvent = "TokenDeleted"
+ // EventQuotaExceeded is an alias maintained for backwards compatibility.
+ EventQuotaExceeded = event.QuotaExceeded
+ // EventRateLimitExceeded is an alias maintained for backwards compatibility.
+ EventRateLimitExceeded = event.RateLimitExceeded
+
+ // EventAuthFailure is an alias maintained for backwards compatibility.
+ EventAuthFailure = event.AuthFailure
+ // EventKeyExpired is an alias maintained for backwards compatibility.
+ EventKeyExpired = event.KeyExpired
+ // EventVersionFailure is an alias maintained for backwards compatibility.
+ EventVersionFailure = event.VersionFailure
+ // EventOrgQuotaExceeded is an alias maintained for backwards compatibility.
+ EventOrgQuotaExceeded = event.OrgQuotaExceeded
+ // EventOrgRateLimitExceeded is an alias maintained for backwards compatibility.
+ EventOrgRateLimitExceeded = event.OrgRateLimitExceeded
+ // EventTriggerExceeded is an alias maintained for backwards compatibility.
+ EventTriggerExceeded = event.TriggerExceeded
+ // EventBreakerTriggered is an alias maintained for backwards compatibility.
+ EventBreakerTriggered = event.BreakerTriggered
+ // EventBreakerTripped is an alias maintained for backwards compatibility.
+ EventBreakerTripped = event.BreakerTripped
+ // EventBreakerReset is an alias maintained for backwards compatibility.
+ EventBreakerReset = event.BreakerReset
+ // EventHOSTDOWN is an alias maintained for backwards compatibility.
+ EventHOSTDOWN = event.HostDown
+ // EventHOSTUP is an alias maintained for backwards compatibility.
+ EventHOSTUP = event.HostUp
+ // EventTokenCreated is an alias maintained for backwards compatibility.
+ EventTokenCreated = event.TokenCreated
+ // EventTokenUpdated is an alias maintained for backwards compatibility.
+ EventTokenUpdated = event.TokenUpdated
+ // EventTokenDeleted is an alias maintained for backwards compatibility.
+ EventTokenDeleted = event.TokenDeleted
)
- Register new event types here, the string is the code used to hook at the
- Api Deifnititon JSON/BSON level
-
const (
MsgAuthFieldMissing = "Authorization field missing"
MsgApiAccessDisallowed = "Access to this API has been disallowed"
@@ -6900,11 +6991,18 @@
const CoProcessDefaultKeyPrefix = "coprocess-data:"
CoProcessDefaultKeyPrefix is used as a key prefix for this CP.
-const EH_CoProcessHandler apidef.TykEventHandlerName = "cp_dynamic_handler"
- Constant for event system.
+const EH_CoProcessHandler = event.CoProcessHandler
+ EH_CoProcessHandler is used for event system, maintained here for backwards
+ compatibility.
-const EH_JSVMHandler apidef.TykEventHandlerName = "eh_dynamic_handler"
-const EH_LogHandler apidef.TykEventHandlerName = "eh_log_handler"
+const EH_JSVMHandler = event.JSVMHandler
+ EH_JSVMHandler is aliased for backwards compatibility.
+
+const (
+ // EH_LogHandler is an alias maintained for backwards compatibility.
+ // It is used to register log handler on an event.
+ EH_LogHandler = event.LogHandler
+)
The name for event handlers as defined in the API Definition JSON/BSON
format
@@ -10025,8 +10123,9 @@
WH_DELETE WebHookRequestMethod = "DELETE"
WH_PATCH WebHookRequestMethod = "PATCH"
- // Define the Event Handler name so we can register it
- EH_WebHook apidef.TykEventHandlerName = "eh_web_hook_handler"
+ // EH_WebHook is an alias maintained for backwards compatibility.
+ // it is the handler to register a webhook event.
+ EH_WebHook = event.WebHookHandler
)
type XPathExtractor struct {
BaseExtractor |
b3ffa99 to
0828b51
Compare
|
PR Description updated to latest commit (50963a1) |
PR Review 🔍
Code feedback:
|
PR Code Suggestions ✨
|
| } | ||
|
|
||
| // Decode decodes WebHookHandlerConf into map[string]interface{}. | ||
| func (w *WebHookHandlerConf) Decode(in map[string]interface{}) error { |
There was a problem hiding this comment.
Can we use strong types and not resort to interfaces? Could the argument just be any, or do we need the map[string] semantics?
There was a problem hiding this comment.
any could be used, but resorting to strong types wouldn't be possible atm since that's gonna increase the scope.
f3df037 to
a095659
Compare
a095659 to
42e5625
Compare
42e5625 to
d5438b6
Compare
💥 CI tests failed 🙈git-stateall okPlease look at the run or in the Checks tab. |
1 similar comment
💥 CI tests failed 🙈git-stateall okPlease look at the run or in the Checks tab. |
💥 CI tests failed 🙈git-stateall okPlease look at the run or in the Checks tab. |
💥 CI tests failed 🙈git-stateall okPlease look at the run or in the Checks tab. |
💥 CI tests failed 🙈git-stateall okPlease look at the run or in the Checks tab. |
💥 CI tests failed 🙈git-stateall okPlease look at the run or in the Checks tab. |
|
|
/release to release-5.3 |
|
Working on it! Note that it can take a few minutes. |
### **User description** - implement OAS webhooks events - implement webhook disabled flag - refactor code to support events <!-- Provide a general summary of your changes in the Title above --> ## Description <!-- Describe your changes in detail --> ## Related Issue Parent: https://tyktech.atlassian.net/browse/TT-11966 Subtask: https://tyktech.atlassian.net/browse/TT-12064 ## Motivation and Context <!-- Why is this change required? What problem does it solve? --> ## How This Has Been Tested <!-- Please describe in detail how you tested your changes --> <!-- Include details of your testing environment, and the tests --> <!-- you ran to see how your change affects other areas of the code, etc. --> <!-- This information is helpful for reviewers and QA. --> ## Screenshots (if appropriate) ## Types of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Refactoring or add test (improvements in base code or adds test coverage to functionality) ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply --> <!-- If there are no documentation updates required, mark the item as checked. --> <!-- Raise up any additional concerns not covered by the checklist. --> - [ ] I ensured that the documentation is up to date - [ ] I explained why this PR updates go.mod in detail with reasoning why it's required - [ ] I would like a code coverage CI quality gate exception and have explained why ___ ### **PR Type** enhancement, bug_fix ___ ### **Description** - Refactored event handling to use new `pkg/event` package, enhancing maintainability and clarity. - Introduced `WebHookHandlerConf` with a `Decode` method to facilitate webhook configuration. - Added methods in `apidef/oas/server.go` to handle event configurations, improving OAS support. - Updated all relevant tests to align with the new event handling approach. - Added new configurations and methods in `config.go` to utilize new event types, improving system configurability. ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement </strong></td><td><details><summary>6 files</summary><table> <tr> <td> <details> <summary><strong>api_definitions.go</strong><dd><code>Refactor Event Handling and Add Webhook Configuration</code> </dd></summary> <hr> apidef/api_definitions.go <li>Introduced new types and constants for event handling using the <br><code>pkg/event</code> package.<br> <li> Refactored <code>EventHandlerTriggerConfig</code> and <code>EventHandlerMetaConfig</code> to use <br>new event types.<br> <li> Added <code>WebHookHandlerConf</code> struct for webhook configuration.<br> <li> Added <code>Decode</code> method to <code>WebHookHandlerConf</code> for decoding configuration.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6258/files#diff-9961ccc89a48d32db5b47ba3006315ef52f6e5007fb4b09f8c5d6d299c669d67">+39/-4</a> </td> </tr> <tr> <td> <details> <summary><strong>migration.go</strong><dd><code>Implement Event Handler Disabling in Migration</code> </dd></summary> <hr> apidef/migration.go <li>Added method <code>setEventHandlersDisabledFlags</code> to disable event handlers <br>during migration.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6258/files#diff-e1d9b55a26f9d6225d56d6f0161959217308e5ad4d6934e7d7df4595d9c2a130">+12/-0</a> </td> </tr> <tr> <td> <details> <summary><strong>server.go</strong><dd><code>Add Event Configuration Handling in OAS Server</code> </dd></summary> <hr> apidef/oas/server.go <li>Added <code>Events</code> field to <code>Server</code> struct for event configuration.<br> <li> Implemented methods to fill and extract event configurations to/from <br><code>apidef.APIDefinition</code>.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6258/files#diff-21857c42e8659f7980014e277c3c758703f29e9e5c0c40553f2584cddb870808">+150/-0</a> </td> </tr> <tr> <td> <details> <summary><strong>config.go</strong><dd><code>Update Configurations to Use New Event Types</code> </dd></summary> <hr> config/config.go <li>Updated event-related configurations to use new event types from <br><code>pkg/event</code>.<br> <li> Added method <code>SetEventTriggers</code> for setting event triggers.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6258/files#diff-fe44f09c4d5977b5f5eaea29170b6a0748819c9d02271746a20d81a5f3efca17">+8/-5</a> </td> </tr> <tr> <td> <details> <summary><strong>event_system.go</strong><dd><code>Refactor Gateway Event System to Use New Event Types</code> </dd></summary> <hr> gateway/event_system.go <li>Refactored event system to use new event types and handler names from <br><code>pkg/event</code>.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6258/files#diff-d56e22d4f1b8d2e91bb643d30e678a3819691a18bfae8506b10e0af8dc279a0e">+45/-23</a> </td> </tr> <tr> <td> <details> <summary><strong>event.go</strong><dd><code>Introduce New Event Package with Constants and Types</code> </dd></summary> <hr> pkg/event/event.go <li>Introduced new package <code>pkg/event</code> with constants and types for event <br>handling.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6258/files#diff-f35b8976e8af7ef3dd90969c4b2b48f8cdb23e77e2a79a2be4fea7225938e13d">+62/-0</a> </td> </tr> </table></details></td></tr><tr><td><strong>Tests </strong></td><td><details><summary>5 files</summary><table> <tr> <td> <details> <summary><strong>migration_test.go</strong><dd><code>Update Migration Tests for Event Handler Flags</code> </dd></summary> <hr> apidef/migration_test.go - Updated tests to include checks for disabled event handlers. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6258/files#diff-d79d77f814074b9e483554e36687e22fda759045141c3b094b039428744ff94c">+28/-0</a> </td> </tr> <tr> <td> <details> <summary><strong>linter_test.go</strong><dd><code>Extend OAS Linter Tests for Event Handling</code> </dd></summary> <hr> apidef/oas/linter_test.go - Extended linting tests to include event settings verification. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6258/files#diff-b92239afd81e77a829fe7fe8410044dfd4dfda525d17dbf5f8811714a9c986d3">+9/-0</a> </td> </tr> <tr> <td> <details> <summary><strong>server_test.go</strong><dd><code>Comprehensive Tests for Event Configuration in OAS Server</code></dd></summary> <hr> apidef/oas/server_test.go <li>Added comprehensive tests for event configuration extraction and <br>filling.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6258/files#diff-a194795077946243b2b6d04b30be360dbafff8e5eb03e6212081e45d1c72573f">+213/-0</a> </td> </tr> <tr> <td> <details> <summary><strong>config_test.go</strong><dd><code>Update Configuration Tests for New Event Types</code> </dd></summary> <hr> config/config_test.go - Updated configuration tests to reflect new event types. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6258/files#diff-373f5578b8f362a364b50b0d01919a57da64c128547ca10d49df8ae422237c82">+2/-2</a> </td> </tr> <tr> <td> <details> <summary><strong>event_system_test.go</strong><dd><code>Update Event System Tests for New Event Types</code> </dd></summary> <hr> gateway/event_system_test.go <li>Updated event system tests to use new event types and handler names.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6258/files#diff-59fda3ebcb87e3c16f222e51988dfb18be9239c84caeef0137db04ffe9ab8f3c">+12/-10</a> </td> </tr> </table></details></td></tr></tr></tbody></table> ___ > 💡 **PR-Agent usage**: >Comment `/help` on the PR to get a list of all available PR-Agent tools and their descriptions (cherry picked from commit 700d49e)
|
@titpetric Succesfully merged PR |
|
Ignore, intended for 5.4, cherry pick issues with the bot @buger |
### **User description** - implement OAS webhooks events - implement webhook disabled flag - refactor code to support events <!-- Provide a general summary of your changes in the Title above --> ## Description <!-- Describe your changes in detail --> ## Related Issue Parent: https://tyktech.atlassian.net/browse/TT-11966 Subtask: https://tyktech.atlassian.net/browse/TT-12064 ## Motivation and Context <!-- Why is this change required? What problem does it solve? --> ## How This Has Been Tested <!-- Please describe in detail how you tested your changes --> <!-- Include details of your testing environment, and the tests --> <!-- you ran to see how your change affects other areas of the code, etc. --> <!-- This information is helpful for reviewers and QA. --> ## Screenshots (if appropriate) ## Types of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Refactoring or add test (improvements in base code or adds test coverage to functionality) ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply --> <!-- If there are no documentation updates required, mark the item as checked. --> <!-- Raise up any additional concerns not covered by the checklist. --> - [ ] I ensured that the documentation is up to date - [ ] I explained why this PR updates go.mod in detail with reasoning why it's required - [ ] I would like a code coverage CI quality gate exception and have explained why ___ ### **PR Type** enhancement, bug_fix ___ ### **Description** - Refactored event handling to use new `pkg/event` package, enhancing maintainability and clarity. - Introduced `WebHookHandlerConf` with a `Decode` method to facilitate webhook configuration. - Added methods in `apidef/oas/server.go` to handle event configurations, improving OAS support. - Updated all relevant tests to align with the new event handling approach. - Added new configurations and methods in `config.go` to utilize new event types, improving system configurability. ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement </strong></td><td><details><summary>6 files</summary><table> <tr> <td> <details> <summary><strong>api_definitions.go</strong><dd><code>Refactor Event Handling and Add Webhook Configuration</code> </dd></summary> <hr> apidef/api_definitions.go <li>Introduced new types and constants for event handling using the <br><code>pkg/event</code> package.<br> <li> Refactored <code>EventHandlerTriggerConfig</code> and <code>EventHandlerMetaConfig</code> to use <br>new event types.<br> <li> Added <code>WebHookHandlerConf</code> struct for webhook configuration.<br> <li> Added <code>Decode</code> method to <code>WebHookHandlerConf</code> for decoding configuration.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6258/files#diff-9961ccc89a48d32db5b47ba3006315ef52f6e5007fb4b09f8c5d6d299c669d67">+39/-4</a> </td> </tr> <tr> <td> <details> <summary><strong>migration.go</strong><dd><code>Implement Event Handler Disabling in Migration</code> </dd></summary> <hr> apidef/migration.go <li>Added method <code>setEventHandlersDisabledFlags</code> to disable event handlers <br>during migration.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6258/files#diff-e1d9b55a26f9d6225d56d6f0161959217308e5ad4d6934e7d7df4595d9c2a130">+12/-0</a> </td> </tr> <tr> <td> <details> <summary><strong>server.go</strong><dd><code>Add Event Configuration Handling in OAS Server</code> </dd></summary> <hr> apidef/oas/server.go <li>Added <code>Events</code> field to <code>Server</code> struct for event configuration.<br> <li> Implemented methods to fill and extract event configurations to/from <br><code>apidef.APIDefinition</code>.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6258/files#diff-21857c42e8659f7980014e277c3c758703f29e9e5c0c40553f2584cddb870808">+150/-0</a> </td> </tr> <tr> <td> <details> <summary><strong>config.go</strong><dd><code>Update Configurations to Use New Event Types</code> </dd></summary> <hr> config/config.go <li>Updated event-related configurations to use new event types from <br><code>pkg/event</code>.<br> <li> Added method <code>SetEventTriggers</code> for setting event triggers.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6258/files#diff-fe44f09c4d5977b5f5eaea29170b6a0748819c9d02271746a20d81a5f3efca17">+8/-5</a> </td> </tr> <tr> <td> <details> <summary><strong>event_system.go</strong><dd><code>Refactor Gateway Event System to Use New Event Types</code> </dd></summary> <hr> gateway/event_system.go <li>Refactored event system to use new event types and handler names from <br><code>pkg/event</code>.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6258/files#diff-d56e22d4f1b8d2e91bb643d30e678a3819691a18bfae8506b10e0af8dc279a0e">+45/-23</a> </td> </tr> <tr> <td> <details> <summary><strong>event.go</strong><dd><code>Introduce New Event Package with Constants and Types</code> </dd></summary> <hr> pkg/event/event.go <li>Introduced new package <code>pkg/event</code> with constants and types for event <br>handling.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6258/files#diff-f35b8976e8af7ef3dd90969c4b2b48f8cdb23e77e2a79a2be4fea7225938e13d">+62/-0</a> </td> </tr> </table></details></td></tr><tr><td><strong>Tests </strong></td><td><details><summary>5 files</summary><table> <tr> <td> <details> <summary><strong>migration_test.go</strong><dd><code>Update Migration Tests for Event Handler Flags</code> </dd></summary> <hr> apidef/migration_test.go - Updated tests to include checks for disabled event handlers. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6258/files#diff-d79d77f814074b9e483554e36687e22fda759045141c3b094b039428744ff94c">+28/-0</a> </td> </tr> <tr> <td> <details> <summary><strong>linter_test.go</strong><dd><code>Extend OAS Linter Tests for Event Handling</code> </dd></summary> <hr> apidef/oas/linter_test.go - Extended linting tests to include event settings verification. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6258/files#diff-b92239afd81e77a829fe7fe8410044dfd4dfda525d17dbf5f8811714a9c986d3">+9/-0</a> </td> </tr> <tr> <td> <details> <summary><strong>server_test.go</strong><dd><code>Comprehensive Tests for Event Configuration in OAS Server</code></dd></summary> <hr> apidef/oas/server_test.go <li>Added comprehensive tests for event configuration extraction and <br>filling.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6258/files#diff-a194795077946243b2b6d04b30be360dbafff8e5eb03e6212081e45d1c72573f">+213/-0</a> </td> </tr> <tr> <td> <details> <summary><strong>config_test.go</strong><dd><code>Update Configuration Tests for New Event Types</code> </dd></summary> <hr> config/config_test.go - Updated configuration tests to reflect new event types. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6258/files#diff-373f5578b8f362a364b50b0d01919a57da64c128547ca10d49df8ae422237c82">+2/-2</a> </td> </tr> <tr> <td> <details> <summary><strong>event_system_test.go</strong><dd><code>Update Event System Tests for New Event Types</code> </dd></summary> <hr> gateway/event_system_test.go <li>Updated event system tests to use new event types and handler names.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6258/files#diff-59fda3ebcb87e3c16f222e51988dfb18be9239c84caeef0137db04ffe9ab8f3c">+12/-10</a> </td> </tr> </table></details></td></tr></tr></tbody></table> ___ > 💡 **PR-Agent usage**: >Comment `/help` on the PR to get a list of all available PR-Agent tools and their descriptions



User description
Description
Related Issue
Parent: https://tyktech.atlassian.net/browse/TT-11966
Subtask: https://tyktech.atlassian.net/browse/TT-12064
Motivation and Context
How This Has Been Tested
Screenshots (if appropriate)
Types of changes
Checklist
PR Type
enhancement, bug_fix
Description
pkg/eventpackage, enhancing maintainability and clarity.WebHookHandlerConfwith aDecodemethod to facilitate webhook configuration.apidef/oas/server.goto handle event configurations, improving OAS support.config.goto utilize new event types, improving system configurability.Changes walkthrough 📝
6 files
api_definitions.go
Refactor Event Handling and Add Webhook Configurationapidef/api_definitions.go
pkg/eventpackage.EventHandlerTriggerConfigandEventHandlerMetaConfigto usenew event types.
WebHookHandlerConfstruct for webhook configuration.Decodemethod toWebHookHandlerConffor decoding configuration.migration.go
Implement Event Handler Disabling in Migrationapidef/migration.go
setEventHandlersDisabledFlagsto disable event handlersduring migration.
server.go
Add Event Configuration Handling in OAS Serverapidef/oas/server.go
Eventsfield toServerstruct for event configuration.apidef.APIDefinition.config.go
Update Configurations to Use New Event Typesconfig/config.go
pkg/event.SetEventTriggersfor setting event triggers.event_system.go
Refactor Gateway Event System to Use New Event Typesgateway/event_system.go
pkg/event.event.go
Introduce New Event Package with Constants and Typespkg/event/event.go
pkg/eventwith constants and types for eventhandling.
5 files
migration_test.go
Update Migration Tests for Event Handler Flagsapidef/migration_test.go
linter_test.go
Extend OAS Linter Tests for Event Handlingapidef/oas/linter_test.go
server_test.go
Comprehensive Tests for Event Configuration in OAS Serverapidef/oas/server_test.go
filling.
config_test.go
Update Configuration Tests for New Event Typesconfig/config_test.go
event_system_test.go
Update Event System Tests for New Event Typesgateway/event_system_test.go