fleet-memory/hindsight-clients/go/model_webhook_http_config.go
Nicolò Boschi abbf874d84
feat: webhook system with retain.completed event, UI, and docs (#487)
* doc: update cookbook

* fix(cookbook): preserve tag keys during sync, strip local .md links

- Fix extract_tags_from_readme/notebook to return dict[str,str] preserving
  sdk/topic keys instead of bare values, preventing topics like
  "Customer Service" from being misclassified as SDK
- Add strip_local_md_links() to remove relative .md references that
  would cause broken link errors in Docusaurus build

* ci: run test-doc-examples independently without waiting for test-rust-cli

Build the CLI directly in the job instead of downloading the artifact,
so test-doc-examples can start at the beginning in parallel with all other jobs.

* feat: webhook system with task-owned retry, retain.completed event, and UI

- New webhook system: register per-bank webhooks with HMAC signing, configurable
  HTTP method/timeout/headers/params (http_config JSONB), and PATCH support
- Webhook deliveries run as async_operations (webhook_delivery type) with
  task-owned retry via RetryTaskAt exception and exponential backoff
  (60s / 5m / 30m / 2h / 8h, max 6 attempts)
- New retain.completed event fires per-document for both sync and async retain
- Delivery debug info (status code, response body) stored in result_metadata
- Control plane UI: webhooks tab per bank with create/edit/delete and a
  deliveries table with cursor pagination and expandable response details
- 28 webhook tests covering HMAC signing, delivery retries, CRUD endpoints,
  PATCH update, and retain.completed queuing
- Docs page at developer/api/webhooks documenting event payloads and delivery
- OpenAPI spec and all client SDKs (Python, TypeScript, Rust, Go) regenerated

* fix: update tests for task-owned retry model and guard _webhook_manager attribute

- test_worker.py: test_executor_exception_triggers_retry now raises RetryTaskAt
  (plain exceptions are immediate failures in the new system); rename
  test_executor_exception_marks_failed_after_max_retries to
  test_executor_exception_marks_failed_immediately to reflect new semantics
- test_batch_api.py: remove max_retries kwarg from WorkerPoller constructor
- memory_engine.py: use getattr for _webhook_manager in _fire_retain_webhook
  to avoid AttributeError when engine is created without __init__ (tests)

* fix: remove max_retries from benchmark WorkerPoller call

* fix(webhooks): transactional outbox, observations_deleted tracking, sidebar

- Queue webhook delivery rows atomically with the primary operation using the
  transactional outbox pattern — prevents lost events on process crash:
  - Retain (sync + async): outbox_callback passed into orchestrator.retain_batch
    and called inside the DB transaction, replacing the post-commit fire call
  - Consolidation: new _mark_operation_completed_and_fire_webhook combines the
    status UPDATE and webhook INSERT in one transaction
  - Added fire_event_with_conn() to WebhookManager for in-connection delivery

- Track observations_deleted count in consolidation stats and expose it in the
  consolidation.completed webhook payload (was always None)

- Add Webhooks page to docs sidebar

- Document at-least-once delivery guarantee with operation_id dedup guidance

* fix(ui): add retain.completed to available webhook event types

* feat(ui): add delete confirmation dialog for webhooks

* fix(webhooks): include operation_id in task_payload so delivery is marked completed

The task_payload JSON was missing the operation_id field, causing execute_task
to see operation_id=None and skip _mark_operation_completed — leaving every
delivery row stuck in 'pending' forever.

Added a test that inserts a real async_operations row and verifies the status
transitions to 'completed' after a successful execute_task call.

* style: fix prettier formatting in webhooks-view
2026-03-04 14:17:01 +01:00

246 lines
6.5 KiB
Go

/*
Hindsight HTTP API
HTTP API for Hindsight
API version: 0.4.15
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hindsight
import (
"encoding/json"
)
// checks if the WebhookHttpConfig type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &WebhookHttpConfig{}
// WebhookHttpConfig HTTP delivery configuration for a webhook.
type WebhookHttpConfig struct {
// HTTP method: GET or POST
Method *string `json:"method,omitempty"`
// HTTP request timeout in seconds
TimeoutSeconds *int32 `json:"timeout_seconds,omitempty"`
// Custom HTTP headers
Headers map[string]string `json:"headers,omitempty"`
// Custom HTTP query parameters
Params map[string]string `json:"params,omitempty"`
}
// NewWebhookHttpConfig instantiates a new WebhookHttpConfig object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewWebhookHttpConfig() *WebhookHttpConfig {
this := WebhookHttpConfig{}
var method string = "POST"
this.Method = &method
var timeoutSeconds int32 = 30
this.TimeoutSeconds = &timeoutSeconds
return &this
}
// NewWebhookHttpConfigWithDefaults instantiates a new WebhookHttpConfig object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewWebhookHttpConfigWithDefaults() *WebhookHttpConfig {
this := WebhookHttpConfig{}
var method string = "POST"
this.Method = &method
var timeoutSeconds int32 = 30
this.TimeoutSeconds = &timeoutSeconds
return &this
}
// GetMethod returns the Method field value if set, zero value otherwise.
func (o *WebhookHttpConfig) GetMethod() string {
if o == nil || IsNil(o.Method) {
var ret string
return ret
}
return *o.Method
}
// GetMethodOk returns a tuple with the Method field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *WebhookHttpConfig) GetMethodOk() (*string, bool) {
if o == nil || IsNil(o.Method) {
return nil, false
}
return o.Method, true
}
// HasMethod returns a boolean if a field has been set.
func (o *WebhookHttpConfig) HasMethod() bool {
if o != nil && !IsNil(o.Method) {
return true
}
return false
}
// SetMethod gets a reference to the given string and assigns it to the Method field.
func (o *WebhookHttpConfig) SetMethod(v string) {
o.Method = &v
}
// GetTimeoutSeconds returns the TimeoutSeconds field value if set, zero value otherwise.
func (o *WebhookHttpConfig) GetTimeoutSeconds() int32 {
if o == nil || IsNil(o.TimeoutSeconds) {
var ret int32
return ret
}
return *o.TimeoutSeconds
}
// GetTimeoutSecondsOk returns a tuple with the TimeoutSeconds field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *WebhookHttpConfig) GetTimeoutSecondsOk() (*int32, bool) {
if o == nil || IsNil(o.TimeoutSeconds) {
return nil, false
}
return o.TimeoutSeconds, true
}
// HasTimeoutSeconds returns a boolean if a field has been set.
func (o *WebhookHttpConfig) HasTimeoutSeconds() bool {
if o != nil && !IsNil(o.TimeoutSeconds) {
return true
}
return false
}
// SetTimeoutSeconds gets a reference to the given int32 and assigns it to the TimeoutSeconds field.
func (o *WebhookHttpConfig) SetTimeoutSeconds(v int32) {
o.TimeoutSeconds = &v
}
// GetHeaders returns the Headers field value if set, zero value otherwise.
func (o *WebhookHttpConfig) GetHeaders() map[string]string {
if o == nil || IsNil(o.Headers) {
var ret map[string]string
return ret
}
return o.Headers
}
// GetHeadersOk returns a tuple with the Headers field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *WebhookHttpConfig) GetHeadersOk() (map[string]string, bool) {
if o == nil || IsNil(o.Headers) {
return map[string]string{}, false
}
return o.Headers, true
}
// HasHeaders returns a boolean if a field has been set.
func (o *WebhookHttpConfig) HasHeaders() bool {
if o != nil && !IsNil(o.Headers) {
return true
}
return false
}
// SetHeaders gets a reference to the given map[string]string and assigns it to the Headers field.
func (o *WebhookHttpConfig) SetHeaders(v map[string]string) {
o.Headers = v
}
// GetParams returns the Params field value if set, zero value otherwise.
func (o *WebhookHttpConfig) GetParams() map[string]string {
if o == nil || IsNil(o.Params) {
var ret map[string]string
return ret
}
return o.Params
}
// GetParamsOk returns a tuple with the Params field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *WebhookHttpConfig) GetParamsOk() (map[string]string, bool) {
if o == nil || IsNil(o.Params) {
return map[string]string{}, false
}
return o.Params, true
}
// HasParams returns a boolean if a field has been set.
func (o *WebhookHttpConfig) HasParams() bool {
if o != nil && !IsNil(o.Params) {
return true
}
return false
}
// SetParams gets a reference to the given map[string]string and assigns it to the Params field.
func (o *WebhookHttpConfig) SetParams(v map[string]string) {
o.Params = v
}
func (o WebhookHttpConfig) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o WebhookHttpConfig) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
if !IsNil(o.Method) {
toSerialize["method"] = o.Method
}
if !IsNil(o.TimeoutSeconds) {
toSerialize["timeout_seconds"] = o.TimeoutSeconds
}
if !IsNil(o.Headers) {
toSerialize["headers"] = o.Headers
}
if !IsNil(o.Params) {
toSerialize["params"] = o.Params
}
return toSerialize, nil
}
type NullableWebhookHttpConfig struct {
value *WebhookHttpConfig
isSet bool
}
func (v NullableWebhookHttpConfig) Get() *WebhookHttpConfig {
return v.value
}
func (v *NullableWebhookHttpConfig) Set(val *WebhookHttpConfig) {
v.value = val
v.isSet = true
}
func (v NullableWebhookHttpConfig) IsSet() bool {
return v.isSet
}
func (v *NullableWebhookHttpConfig) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableWebhookHttpConfig(val *WebhookHttpConfig) *NullableWebhookHttpConfig {
return &NullableWebhookHttpConfig{value: val, isSet: true}
}
func (v NullableWebhookHttpConfig) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableWebhookHttpConfig) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}