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

622 lines
18 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"
"bytes"
"fmt"
)
// checks if the WebhookDeliveryResponse type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &WebhookDeliveryResponse{}
// WebhookDeliveryResponse Response model for a webhook delivery record.
type WebhookDeliveryResponse struct {
Id string `json:"id"`
WebhookId NullableString `json:"webhook_id"`
Url string `json:"url"`
EventType string `json:"event_type"`
Status string `json:"status"`
Attempts int32 `json:"attempts"`
NextRetryAt NullableString `json:"next_retry_at,omitempty"`
LastError NullableString `json:"last_error,omitempty"`
LastResponseStatus NullableInt32 `json:"last_response_status,omitempty"`
LastResponseBody NullableString `json:"last_response_body,omitempty"`
LastAttemptAt NullableString `json:"last_attempt_at,omitempty"`
CreatedAt NullableString `json:"created_at,omitempty"`
UpdatedAt NullableString `json:"updated_at,omitempty"`
}
type _WebhookDeliveryResponse WebhookDeliveryResponse
// NewWebhookDeliveryResponse instantiates a new WebhookDeliveryResponse 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 NewWebhookDeliveryResponse(id string, webhookId NullableString, url string, eventType string, status string, attempts int32) *WebhookDeliveryResponse {
this := WebhookDeliveryResponse{}
this.Id = id
this.WebhookId = webhookId
this.Url = url
this.EventType = eventType
this.Status = status
this.Attempts = attempts
return &this
}
// NewWebhookDeliveryResponseWithDefaults instantiates a new WebhookDeliveryResponse 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 NewWebhookDeliveryResponseWithDefaults() *WebhookDeliveryResponse {
this := WebhookDeliveryResponse{}
return &this
}
// GetId returns the Id field value
func (o *WebhookDeliveryResponse) GetId() string {
if o == nil {
var ret string
return ret
}
return o.Id
}
// GetIdOk returns a tuple with the Id field value
// and a boolean to check if the value has been set.
func (o *WebhookDeliveryResponse) GetIdOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Id, true
}
// SetId sets field value
func (o *WebhookDeliveryResponse) SetId(v string) {
o.Id = v
}
// GetWebhookId returns the WebhookId field value
// If the value is explicit nil, the zero value for string will be returned
func (o *WebhookDeliveryResponse) GetWebhookId() string {
if o == nil || o.WebhookId.Get() == nil {
var ret string
return ret
}
return *o.WebhookId.Get()
}
// GetWebhookIdOk returns a tuple with the WebhookId field value
// 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 *WebhookDeliveryResponse) GetWebhookIdOk() (*string, bool) {
if o == nil {
return nil, false
}
return o.WebhookId.Get(), o.WebhookId.IsSet()
}
// SetWebhookId sets field value
func (o *WebhookDeliveryResponse) SetWebhookId(v string) {
o.WebhookId.Set(&v)
}
// GetUrl returns the Url field value
func (o *WebhookDeliveryResponse) GetUrl() string {
if o == nil {
var ret string
return ret
}
return o.Url
}
// GetUrlOk returns a tuple with the Url field value
// and a boolean to check if the value has been set.
func (o *WebhookDeliveryResponse) GetUrlOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Url, true
}
// SetUrl sets field value
func (o *WebhookDeliveryResponse) SetUrl(v string) {
o.Url = v
}
// GetEventType returns the EventType field value
func (o *WebhookDeliveryResponse) GetEventType() string {
if o == nil {
var ret string
return ret
}
return o.EventType
}
// GetEventTypeOk returns a tuple with the EventType field value
// and a boolean to check if the value has been set.
func (o *WebhookDeliveryResponse) GetEventTypeOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.EventType, true
}
// SetEventType sets field value
func (o *WebhookDeliveryResponse) SetEventType(v string) {
o.EventType = v
}
// GetStatus returns the Status field value
func (o *WebhookDeliveryResponse) GetStatus() string {
if o == nil {
var ret string
return ret
}
return o.Status
}
// GetStatusOk returns a tuple with the Status field value
// and a boolean to check if the value has been set.
func (o *WebhookDeliveryResponse) GetStatusOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Status, true
}
// SetStatus sets field value
func (o *WebhookDeliveryResponse) SetStatus(v string) {
o.Status = v
}
// GetAttempts returns the Attempts field value
func (o *WebhookDeliveryResponse) GetAttempts() int32 {
if o == nil {
var ret int32
return ret
}
return o.Attempts
}
// GetAttemptsOk returns a tuple with the Attempts field value
// and a boolean to check if the value has been set.
func (o *WebhookDeliveryResponse) GetAttemptsOk() (*int32, bool) {
if o == nil {
return nil, false
}
return &o.Attempts, true
}
// SetAttempts sets field value
func (o *WebhookDeliveryResponse) SetAttempts(v int32) {
o.Attempts = v
}
// GetNextRetryAt returns the NextRetryAt field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *WebhookDeliveryResponse) GetNextRetryAt() string {
if o == nil || IsNil(o.NextRetryAt.Get()) {
var ret string
return ret
}
return *o.NextRetryAt.Get()
}
// GetNextRetryAtOk returns a tuple with the NextRetryAt 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 *WebhookDeliveryResponse) GetNextRetryAtOk() (*string, bool) {
if o == nil {
return nil, false
}
return o.NextRetryAt.Get(), o.NextRetryAt.IsSet()
}
// HasNextRetryAt returns a boolean if a field has been set.
func (o *WebhookDeliveryResponse) HasNextRetryAt() bool {
if o != nil && o.NextRetryAt.IsSet() {
return true
}
return false
}
// SetNextRetryAt gets a reference to the given NullableString and assigns it to the NextRetryAt field.
func (o *WebhookDeliveryResponse) SetNextRetryAt(v string) {
o.NextRetryAt.Set(&v)
}
// SetNextRetryAtNil sets the value for NextRetryAt to be an explicit nil
func (o *WebhookDeliveryResponse) SetNextRetryAtNil() {
o.NextRetryAt.Set(nil)
}
// UnsetNextRetryAt ensures that no value is present for NextRetryAt, not even an explicit nil
func (o *WebhookDeliveryResponse) UnsetNextRetryAt() {
o.NextRetryAt.Unset()
}
// GetLastError returns the LastError field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *WebhookDeliveryResponse) GetLastError() string {
if o == nil || IsNil(o.LastError.Get()) {
var ret string
return ret
}
return *o.LastError.Get()
}
// GetLastErrorOk returns a tuple with the LastError 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 *WebhookDeliveryResponse) GetLastErrorOk() (*string, bool) {
if o == nil {
return nil, false
}
return o.LastError.Get(), o.LastError.IsSet()
}
// HasLastError returns a boolean if a field has been set.
func (o *WebhookDeliveryResponse) HasLastError() bool {
if o != nil && o.LastError.IsSet() {
return true
}
return false
}
// SetLastError gets a reference to the given NullableString and assigns it to the LastError field.
func (o *WebhookDeliveryResponse) SetLastError(v string) {
o.LastError.Set(&v)
}
// SetLastErrorNil sets the value for LastError to be an explicit nil
func (o *WebhookDeliveryResponse) SetLastErrorNil() {
o.LastError.Set(nil)
}
// UnsetLastError ensures that no value is present for LastError, not even an explicit nil
func (o *WebhookDeliveryResponse) UnsetLastError() {
o.LastError.Unset()
}
// GetLastResponseStatus returns the LastResponseStatus field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *WebhookDeliveryResponse) GetLastResponseStatus() int32 {
if o == nil || IsNil(o.LastResponseStatus.Get()) {
var ret int32
return ret
}
return *o.LastResponseStatus.Get()
}
// GetLastResponseStatusOk returns a tuple with the LastResponseStatus 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 *WebhookDeliveryResponse) GetLastResponseStatusOk() (*int32, bool) {
if o == nil {
return nil, false
}
return o.LastResponseStatus.Get(), o.LastResponseStatus.IsSet()
}
// HasLastResponseStatus returns a boolean if a field has been set.
func (o *WebhookDeliveryResponse) HasLastResponseStatus() bool {
if o != nil && o.LastResponseStatus.IsSet() {
return true
}
return false
}
// SetLastResponseStatus gets a reference to the given NullableInt32 and assigns it to the LastResponseStatus field.
func (o *WebhookDeliveryResponse) SetLastResponseStatus(v int32) {
o.LastResponseStatus.Set(&v)
}
// SetLastResponseStatusNil sets the value for LastResponseStatus to be an explicit nil
func (o *WebhookDeliveryResponse) SetLastResponseStatusNil() {
o.LastResponseStatus.Set(nil)
}
// UnsetLastResponseStatus ensures that no value is present for LastResponseStatus, not even an explicit nil
func (o *WebhookDeliveryResponse) UnsetLastResponseStatus() {
o.LastResponseStatus.Unset()
}
// GetLastResponseBody returns the LastResponseBody field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *WebhookDeliveryResponse) GetLastResponseBody() string {
if o == nil || IsNil(o.LastResponseBody.Get()) {
var ret string
return ret
}
return *o.LastResponseBody.Get()
}
// GetLastResponseBodyOk returns a tuple with the LastResponseBody 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 *WebhookDeliveryResponse) GetLastResponseBodyOk() (*string, bool) {
if o == nil {
return nil, false
}
return o.LastResponseBody.Get(), o.LastResponseBody.IsSet()
}
// HasLastResponseBody returns a boolean if a field has been set.
func (o *WebhookDeliveryResponse) HasLastResponseBody() bool {
if o != nil && o.LastResponseBody.IsSet() {
return true
}
return false
}
// SetLastResponseBody gets a reference to the given NullableString and assigns it to the LastResponseBody field.
func (o *WebhookDeliveryResponse) SetLastResponseBody(v string) {
o.LastResponseBody.Set(&v)
}
// SetLastResponseBodyNil sets the value for LastResponseBody to be an explicit nil
func (o *WebhookDeliveryResponse) SetLastResponseBodyNil() {
o.LastResponseBody.Set(nil)
}
// UnsetLastResponseBody ensures that no value is present for LastResponseBody, not even an explicit nil
func (o *WebhookDeliveryResponse) UnsetLastResponseBody() {
o.LastResponseBody.Unset()
}
// GetLastAttemptAt returns the LastAttemptAt field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *WebhookDeliveryResponse) GetLastAttemptAt() string {
if o == nil || IsNil(o.LastAttemptAt.Get()) {
var ret string
return ret
}
return *o.LastAttemptAt.Get()
}
// GetLastAttemptAtOk returns a tuple with the LastAttemptAt 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 *WebhookDeliveryResponse) GetLastAttemptAtOk() (*string, bool) {
if o == nil {
return nil, false
}
return o.LastAttemptAt.Get(), o.LastAttemptAt.IsSet()
}
// HasLastAttemptAt returns a boolean if a field has been set.
func (o *WebhookDeliveryResponse) HasLastAttemptAt() bool {
if o != nil && o.LastAttemptAt.IsSet() {
return true
}
return false
}
// SetLastAttemptAt gets a reference to the given NullableString and assigns it to the LastAttemptAt field.
func (o *WebhookDeliveryResponse) SetLastAttemptAt(v string) {
o.LastAttemptAt.Set(&v)
}
// SetLastAttemptAtNil sets the value for LastAttemptAt to be an explicit nil
func (o *WebhookDeliveryResponse) SetLastAttemptAtNil() {
o.LastAttemptAt.Set(nil)
}
// UnsetLastAttemptAt ensures that no value is present for LastAttemptAt, not even an explicit nil
func (o *WebhookDeliveryResponse) UnsetLastAttemptAt() {
o.LastAttemptAt.Unset()
}
// GetCreatedAt returns the CreatedAt field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *WebhookDeliveryResponse) GetCreatedAt() string {
if o == nil || IsNil(o.CreatedAt.Get()) {
var ret string
return ret
}
return *o.CreatedAt.Get()
}
// GetCreatedAtOk returns a tuple with the CreatedAt 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 *WebhookDeliveryResponse) GetCreatedAtOk() (*string, bool) {
if o == nil {
return nil, false
}
return o.CreatedAt.Get(), o.CreatedAt.IsSet()
}
// HasCreatedAt returns a boolean if a field has been set.
func (o *WebhookDeliveryResponse) HasCreatedAt() bool {
if o != nil && o.CreatedAt.IsSet() {
return true
}
return false
}
// SetCreatedAt gets a reference to the given NullableString and assigns it to the CreatedAt field.
func (o *WebhookDeliveryResponse) SetCreatedAt(v string) {
o.CreatedAt.Set(&v)
}
// SetCreatedAtNil sets the value for CreatedAt to be an explicit nil
func (o *WebhookDeliveryResponse) SetCreatedAtNil() {
o.CreatedAt.Set(nil)
}
// UnsetCreatedAt ensures that no value is present for CreatedAt, not even an explicit nil
func (o *WebhookDeliveryResponse) UnsetCreatedAt() {
o.CreatedAt.Unset()
}
// GetUpdatedAt returns the UpdatedAt field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *WebhookDeliveryResponse) GetUpdatedAt() string {
if o == nil || IsNil(o.UpdatedAt.Get()) {
var ret string
return ret
}
return *o.UpdatedAt.Get()
}
// GetUpdatedAtOk returns a tuple with the UpdatedAt 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 *WebhookDeliveryResponse) GetUpdatedAtOk() (*string, bool) {
if o == nil {
return nil, false
}
return o.UpdatedAt.Get(), o.UpdatedAt.IsSet()
}
// HasUpdatedAt returns a boolean if a field has been set.
func (o *WebhookDeliveryResponse) HasUpdatedAt() bool {
if o != nil && o.UpdatedAt.IsSet() {
return true
}
return false
}
// SetUpdatedAt gets a reference to the given NullableString and assigns it to the UpdatedAt field.
func (o *WebhookDeliveryResponse) SetUpdatedAt(v string) {
o.UpdatedAt.Set(&v)
}
// SetUpdatedAtNil sets the value for UpdatedAt to be an explicit nil
func (o *WebhookDeliveryResponse) SetUpdatedAtNil() {
o.UpdatedAt.Set(nil)
}
// UnsetUpdatedAt ensures that no value is present for UpdatedAt, not even an explicit nil
func (o *WebhookDeliveryResponse) UnsetUpdatedAt() {
o.UpdatedAt.Unset()
}
func (o WebhookDeliveryResponse) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o WebhookDeliveryResponse) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
toSerialize["id"] = o.Id
toSerialize["webhook_id"] = o.WebhookId.Get()
toSerialize["url"] = o.Url
toSerialize["event_type"] = o.EventType
toSerialize["status"] = o.Status
toSerialize["attempts"] = o.Attempts
if o.NextRetryAt.IsSet() {
toSerialize["next_retry_at"] = o.NextRetryAt.Get()
}
if o.LastError.IsSet() {
toSerialize["last_error"] = o.LastError.Get()
}
if o.LastResponseStatus.IsSet() {
toSerialize["last_response_status"] = o.LastResponseStatus.Get()
}
if o.LastResponseBody.IsSet() {
toSerialize["last_response_body"] = o.LastResponseBody.Get()
}
if o.LastAttemptAt.IsSet() {
toSerialize["last_attempt_at"] = o.LastAttemptAt.Get()
}
if o.CreatedAt.IsSet() {
toSerialize["created_at"] = o.CreatedAt.Get()
}
if o.UpdatedAt.IsSet() {
toSerialize["updated_at"] = o.UpdatedAt.Get()
}
return toSerialize, nil
}
func (o *WebhookDeliveryResponse) UnmarshalJSON(data []byte) (err error) {
// This validates that all required properties are included in the JSON object
// by unmarshalling the object into a generic map with string keys and checking
// that every required field exists as a key in the generic map.
requiredProperties := []string{
"id",
"webhook_id",
"url",
"event_type",
"status",
"attempts",
}
allProperties := make(map[string]interface{})
err = json.Unmarshal(data, &allProperties)
if err != nil {
return err;
}
for _, requiredProperty := range(requiredProperties) {
if _, exists := allProperties[requiredProperty]; !exists {
return fmt.Errorf("no value given for required property %v", requiredProperty)
}
}
varWebhookDeliveryResponse := _WebhookDeliveryResponse{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varWebhookDeliveryResponse)
if err != nil {
return err
}
*o = WebhookDeliveryResponse(varWebhookDeliveryResponse)
return err
}
type NullableWebhookDeliveryResponse struct {
value *WebhookDeliveryResponse
isSet bool
}
func (v NullableWebhookDeliveryResponse) Get() *WebhookDeliveryResponse {
return v.value
}
func (v *NullableWebhookDeliveryResponse) Set(val *WebhookDeliveryResponse) {
v.value = val
v.isSet = true
}
func (v NullableWebhookDeliveryResponse) IsSet() bool {
return v.isSet
}
func (v *NullableWebhookDeliveryResponse) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableWebhookDeliveryResponse(val *WebhookDeliveryResponse) *NullableWebhookDeliveryResponse {
return &NullableWebhookDeliveryResponse{value: val, isSet: true}
}
func (v NullableWebhookDeliveryResponse) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableWebhookDeliveryResponse) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}