fleet-memory/hindsight-clients/go/model_update_webhook_request.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

311 lines
8.9 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 UpdateWebhookRequest type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &UpdateWebhookRequest{}
// UpdateWebhookRequest Request model for updating a webhook. Only provided fields are updated.
type UpdateWebhookRequest struct {
Url NullableString `json:"url,omitempty"`
Secret NullableString `json:"secret,omitempty"`
EventTypes []string `json:"event_types,omitempty"`
Enabled NullableBool `json:"enabled,omitempty"`
HttpConfig NullableWebhookHttpConfig `json:"http_config,omitempty"`
}
// NewUpdateWebhookRequest instantiates a new UpdateWebhookRequest 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 NewUpdateWebhookRequest() *UpdateWebhookRequest {
this := UpdateWebhookRequest{}
return &this
}
// NewUpdateWebhookRequestWithDefaults instantiates a new UpdateWebhookRequest 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 NewUpdateWebhookRequestWithDefaults() *UpdateWebhookRequest {
this := UpdateWebhookRequest{}
return &this
}
// GetUrl returns the Url field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *UpdateWebhookRequest) GetUrl() string {
if o == nil || IsNil(o.Url.Get()) {
var ret string
return ret
}
return *o.Url.Get()
}
// GetUrlOk returns a tuple with the Url field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *UpdateWebhookRequest) GetUrlOk() (*string, bool) {
if o == nil {
return nil, false
}
return o.Url.Get(), o.Url.IsSet()
}
// HasUrl returns a boolean if a field has been set.
func (o *UpdateWebhookRequest) HasUrl() bool {
if o != nil && o.Url.IsSet() {
return true
}
return false
}
// SetUrl gets a reference to the given NullableString and assigns it to the Url field.
func (o *UpdateWebhookRequest) SetUrl(v string) {
o.Url.Set(&v)
}
// SetUrlNil sets the value for Url to be an explicit nil
func (o *UpdateWebhookRequest) SetUrlNil() {
o.Url.Set(nil)
}
// UnsetUrl ensures that no value is present for Url, not even an explicit nil
func (o *UpdateWebhookRequest) UnsetUrl() {
o.Url.Unset()
}
// GetSecret returns the Secret field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *UpdateWebhookRequest) GetSecret() string {
if o == nil || IsNil(o.Secret.Get()) {
var ret string
return ret
}
return *o.Secret.Get()
}
// GetSecretOk returns a tuple with the Secret field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *UpdateWebhookRequest) GetSecretOk() (*string, bool) {
if o == nil {
return nil, false
}
return o.Secret.Get(), o.Secret.IsSet()
}
// HasSecret returns a boolean if a field has been set.
func (o *UpdateWebhookRequest) HasSecret() bool {
if o != nil && o.Secret.IsSet() {
return true
}
return false
}
// SetSecret gets a reference to the given NullableString and assigns it to the Secret field.
func (o *UpdateWebhookRequest) SetSecret(v string) {
o.Secret.Set(&v)
}
// SetSecretNil sets the value for Secret to be an explicit nil
func (o *UpdateWebhookRequest) SetSecretNil() {
o.Secret.Set(nil)
}
// UnsetSecret ensures that no value is present for Secret, not even an explicit nil
func (o *UpdateWebhookRequest) UnsetSecret() {
o.Secret.Unset()
}
// GetEventTypes returns the EventTypes field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *UpdateWebhookRequest) GetEventTypes() []string {
if o == nil {
var ret []string
return ret
}
return o.EventTypes
}
// GetEventTypesOk returns a tuple with the EventTypes field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *UpdateWebhookRequest) GetEventTypesOk() ([]string, bool) {
if o == nil || IsNil(o.EventTypes) {
return nil, false
}
return o.EventTypes, true
}
// HasEventTypes returns a boolean if a field has been set.
func (o *UpdateWebhookRequest) HasEventTypes() bool {
if o != nil && !IsNil(o.EventTypes) {
return true
}
return false
}
// SetEventTypes gets a reference to the given []string and assigns it to the EventTypes field.
func (o *UpdateWebhookRequest) SetEventTypes(v []string) {
o.EventTypes = v
}
// GetEnabled returns the Enabled field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *UpdateWebhookRequest) GetEnabled() bool {
if o == nil || IsNil(o.Enabled.Get()) {
var ret bool
return ret
}
return *o.Enabled.Get()
}
// GetEnabledOk returns a tuple with the Enabled field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *UpdateWebhookRequest) GetEnabledOk() (*bool, bool) {
if o == nil {
return nil, false
}
return o.Enabled.Get(), o.Enabled.IsSet()
}
// HasEnabled returns a boolean if a field has been set.
func (o *UpdateWebhookRequest) HasEnabled() bool {
if o != nil && o.Enabled.IsSet() {
return true
}
return false
}
// SetEnabled gets a reference to the given NullableBool and assigns it to the Enabled field.
func (o *UpdateWebhookRequest) SetEnabled(v bool) {
o.Enabled.Set(&v)
}
// SetEnabledNil sets the value for Enabled to be an explicit nil
func (o *UpdateWebhookRequest) SetEnabledNil() {
o.Enabled.Set(nil)
}
// UnsetEnabled ensures that no value is present for Enabled, not even an explicit nil
func (o *UpdateWebhookRequest) UnsetEnabled() {
o.Enabled.Unset()
}
// GetHttpConfig returns the HttpConfig field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *UpdateWebhookRequest) GetHttpConfig() WebhookHttpConfig {
if o == nil || IsNil(o.HttpConfig.Get()) {
var ret WebhookHttpConfig
return ret
}
return *o.HttpConfig.Get()
}
// GetHttpConfigOk returns a tuple with the HttpConfig field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *UpdateWebhookRequest) GetHttpConfigOk() (*WebhookHttpConfig, bool) {
if o == nil {
return nil, false
}
return o.HttpConfig.Get(), o.HttpConfig.IsSet()
}
// HasHttpConfig returns a boolean if a field has been set.
func (o *UpdateWebhookRequest) HasHttpConfig() bool {
if o != nil && o.HttpConfig.IsSet() {
return true
}
return false
}
// SetHttpConfig gets a reference to the given NullableWebhookHttpConfig and assigns it to the HttpConfig field.
func (o *UpdateWebhookRequest) SetHttpConfig(v WebhookHttpConfig) {
o.HttpConfig.Set(&v)
}
// SetHttpConfigNil sets the value for HttpConfig to be an explicit nil
func (o *UpdateWebhookRequest) SetHttpConfigNil() {
o.HttpConfig.Set(nil)
}
// UnsetHttpConfig ensures that no value is present for HttpConfig, not even an explicit nil
func (o *UpdateWebhookRequest) UnsetHttpConfig() {
o.HttpConfig.Unset()
}
func (o UpdateWebhookRequest) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o UpdateWebhookRequest) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
if o.Url.IsSet() {
toSerialize["url"] = o.Url.Get()
}
if o.Secret.IsSet() {
toSerialize["secret"] = o.Secret.Get()
}
if o.EventTypes != nil {
toSerialize["event_types"] = o.EventTypes
}
if o.Enabled.IsSet() {
toSerialize["enabled"] = o.Enabled.Get()
}
if o.HttpConfig.IsSet() {
toSerialize["http_config"] = o.HttpConfig.Get()
}
return toSerialize, nil
}
type NullableUpdateWebhookRequest struct {
value *UpdateWebhookRequest
isSet bool
}
func (v NullableUpdateWebhookRequest) Get() *UpdateWebhookRequest {
return v.value
}
func (v *NullableUpdateWebhookRequest) Set(val *UpdateWebhookRequest) {
v.value = val
v.isSet = true
}
func (v NullableUpdateWebhookRequest) IsSet() bool {
return v.isSet
}
func (v *NullableUpdateWebhookRequest) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableUpdateWebhookRequest(val *UpdateWebhookRequest) *NullableUpdateWebhookRequest {
return &NullableUpdateWebhookRequest{value: val, isSet: true}
}
func (v NullableUpdateWebhookRequest) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableUpdateWebhookRequest) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}