diff --git a/incident_trigger_subscription_models.go b/incident_trigger_subscription_models.go new file mode 100644 index 0000000..30e6993 --- /dev/null +++ b/incident_trigger_subscription_models.go @@ -0,0 +1,22 @@ +package flashduty + +// IncidentTriggerSubscriptionUpsertRequest creates or updates an incident trigger subscription. +// +// Enabled is pointer-backed because omitting it defaults to true, while a +// non-nil false explicitly disables the subscription. +type IncidentTriggerSubscriptionUpsertRequest struct { + // On-call channel IDs whose new incidents should trigger the consumer. + ChannelIDs []int64 `json:"channel_ids,omitempty" toon:"channel_ids,omitempty"` + // Consumer system. Use `fc_safari` for AI SRE automation rules. + Consumer string `json:"consumer,omitempty" toon:"consumer,omitempty"` + // Consumer-owned reference, such as an Automation rule ID. + ConsumerRef string `json:"consumer_ref,omitempty" toon:"consumer_ref,omitempty"` + // Whether the subscription is enabled. Defaults to true when omitted. + Enabled *bool `json:"enabled,omitempty" toon:"enabled,omitempty"` + // Incident severities to subscribe to. `Ok` is not valid. + Severities []string `json:"severities,omitempty" toon:"severities,omitempty"` + // Subscription source. Use `ai_sre_automation` for AI SRE automation rules. + Source string `json:"source,omitempty" toon:"source,omitempty"` + // Existing subscription ID. Omit to create or upsert by source, consumer, and consumer_ref. + SubscriptionID string `json:"subscription_id,omitempty" toon:"subscription_id,omitempty"` +} diff --git a/incident_trigger_subscription_test.go b/incident_trigger_subscription_test.go new file mode 100644 index 0000000..c3827b4 --- /dev/null +++ b/incident_trigger_subscription_test.go @@ -0,0 +1,29 @@ +package flashduty + +import ( + "encoding/json" + "strings" + "testing" +) + +func TestIncidentTriggerSubscriptionUpsertRequestPreservesDisabledValue(t *testing.T) { + var req IncidentTriggerSubscriptionUpsertRequest + if err := json.Unmarshal([]byte(`{ + "source":"ai_sre_automation", + "consumer":"fc_safari", + "consumer_ref":"auto_1", + "channel_ids":[2468013579], + "severities":["Critical"], + "enabled":false + }`), &req); err != nil { + t.Fatal(err) + } + payload, err := json.Marshal(&req) + if err != nil { + t.Fatal(err) + } + got := string(payload) + if !strings.Contains(got, `"enabled":false`) { + t.Fatalf("payload %s missing explicit enabled=false", got) + } +} diff --git a/internal/cmd/gen/main.go b/internal/cmd/gen/main.go index 45d64f2..f6bc38e 100644 --- a/internal/cmd/gen/main.go +++ b/internal/cmd/gen/main.go @@ -94,10 +94,11 @@ func run() error { schemas: asMap(asMap(spec["components"])["schemas"]), emptyTypes: map[string]bool{}, skip: map[string]bool{ - "SuccessEnvelope": true, - "ErrorResponse": true, - "DutyError": true, - "AutomationRuleUpdateRequest": true, // hand-written to preserve partial-update pointer semantics. + "SuccessEnvelope": true, + "ErrorResponse": true, + "DutyError": true, + "AutomationRuleUpdateRequest": true, // hand-written to preserve partial-update pointer semantics. + "IncidentTriggerSubscriptionUpsertRequest": true, // hand-written to preserve enabled=false. }, queued: map[string]bool{}, synth: map[string]any{}, diff --git a/models_gen.go b/models_gen.go index f21e6d1..7f780a6 100644 --- a/models_gen.go +++ b/models_gen.go @@ -3275,24 +3275,6 @@ type IncidentTriggerSubscriptionDeleteRequest struct { Source string `json:"source,omitempty" toon:"source,omitempty"` } -// IncidentTriggerSubscriptionUpsertRequest is generated from the Flashduty OpenAPI schema. -type IncidentTriggerSubscriptionUpsertRequest struct { - // On-call channel IDs whose new incidents should trigger the consumer. - ChannelIDs []int64 `json:"channel_ids,omitempty" toon:"channel_ids,omitempty"` - // Consumer system. Use `fc_safari` for AI SRE automation rules. - Consumer string `json:"consumer,omitempty" toon:"consumer,omitempty"` - // Consumer-owned reference, such as an Automation rule ID. - ConsumerRef string `json:"consumer_ref,omitempty" toon:"consumer_ref,omitempty"` - // Whether the subscription is enabled. Defaults to true when omitted. - Enabled bool `json:"enabled,omitempty" toon:"enabled,omitempty"` - // Incident severities to subscribe to. `Ok` is not valid. - Severities []string `json:"severities,omitempty" toon:"severities,omitempty"` - // Subscription source. Use `ai_sre_automation` for AI SRE automation rules. - Source string `json:"source,omitempty" toon:"source,omitempty"` - // Existing subscription ID. Omit to create or upsert by source, consumer, and consumer_ref. - SubscriptionID string `json:"subscription_id,omitempty" toon:"subscription_id,omitempty"` -} - // InhibitRuleItem is generated from the Flashduty OpenAPI schema. type InhibitRuleItem struct { AccountID int64 `json:"account_id" toon:"account_id"`