Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
230 changes: 213 additions & 17 deletions docs/openapi/monitoring-api.json

Large diffs are not rendered by default.

495 changes: 466 additions & 29 deletions internal/generated/types.go

Large diffs are not rendered by default.

14 changes: 9 additions & 5 deletions internal/provider/resources/alert_channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func (r *AlertChannelResource) buildConfig(model *AlertChannelResourceModel) (js
}
case generated.AlertChannelDtoChannelTypeEmail:
cfg = generated.EmailChannelConfig{
ChannelType: generated.Email,
ChannelType: generated.EmailChannelConfigChannelTypeEmail,
Recipients: emailsFromStringList(model.Recipients),
}
case generated.AlertChannelDtoChannelTypePagerduty:
Expand Down Expand Up @@ -228,9 +228,11 @@ func (r *AlertChannelResource) Create(ctx context.Context, req resource.CreateRe
return
}

managedByTF := generated.CreateAlertChannelRequestManagedByTERRAFORM
body := generated.CreateAlertChannelRequest{
Name: plan.Name.ValueString(),
Config: configUnion,
Name: plan.Name.ValueString(),
Config: configUnion,
ManagedBy: &managedByTF,
}

ch, err := api.Create[generated.AlertChannelDto](ctx, r.client, api.PathAlertChannels, body)
Expand Down Expand Up @@ -306,9 +308,11 @@ func (r *AlertChannelResource) Update(ctx context.Context, req resource.UpdateRe
return
}

managedByTF := generated.UpdateAlertChannelRequestManagedByTERRAFORM
body := generated.UpdateAlertChannelRequest{
Name: plan.Name.ValueString(),
Config: configUnion,
Name: plan.Name.ValueString(),
Config: configUnion,
ManagedBy: &managedByTF,
}

ch, err := api.Update[generated.AlertChannelDto](ctx, r.client, api.AlertChannelPath(state.ID.ValueString()), body)
Expand Down
7 changes: 4 additions & 3 deletions internal/provider/resources/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,8 @@ func (r *MonitorResource) Schema(_ context.Context, _ resource.SchemaRequest, re
Description: "Incident severity: down or degraded",
Validators: []validator.String{
stringvalidator.OneOf(
string(generated.Down),
string(generated.Degraded),
string(generated.TriggerRuleSeverityDown),
string(generated.TriggerRuleSeverityDegraded),
),
},
},
Expand Down Expand Up @@ -828,11 +828,12 @@ func (r *MonitorResource) buildCreateRequest(ctx context.Context, plan *MonitorR
return nil, err
}

managedByTF := generated.CreateMonitorRequestManagedByTERRAFORM
req := &generated.CreateMonitorRequest{
Name: plan.Name.ValueString(),
Type: monitorType,
Config: configUnion,
ManagedBy: generated.CreateMonitorRequestManagedByTERRAFORM,
ManagedBy: &managedByTF,
FrequencySeconds: int32PtrOrNil(plan.FrequencySeconds),
Enabled: boolPtrOrNil(plan.Enabled),
Regions: stringSliceToPtr(plan.Regions),
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/resources/monitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ func TestBuildCreateRequest_PopulatesEveryRequiredField(t *testing.T) {
if body.Type != "HTTP" {
t.Errorf("Type = %q", body.Type)
}
if body.ManagedBy != "TERRAFORM" {
t.Errorf("ManagedBy = %q, want TERRAFORM (provider must self-identify so a future round-trip survives a manual dashboard edit detection)", body.ManagedBy)
if body.ManagedBy == nil || *body.ManagedBy != "TERRAFORM" {
t.Errorf("ManagedBy = %v, want TERRAFORM (provider must self-identify so a future round-trip survives a manual dashboard edit detection)", body.ManagedBy)
}
if body.FrequencySeconds == nil || *body.FrequencySeconds != 60 {
t.Errorf("FrequencySeconds = %v, want 60", body.FrequencySeconds)
Expand Down
4 changes: 4 additions & 0 deletions internal/provider/resources/resource_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ func (r *ResourceGroupResource) buildRequest(ctx context.Context, plan *Resource
if diags.HasError() {
return generated.CreateResourceGroupRequest{}, diags
}
managedByTF := generated.CreateResourceGroupRequestManagedByTERRAFORM
return generated.CreateResourceGroupRequest{
Name: plan.Name.ValueString(),
Description: stringPtrOrNil(plan.Description),
Expand All @@ -195,6 +196,7 @@ func (r *ResourceGroupResource) buildRequest(ctx context.Context, plan *Resource
SuppressMemberAlerts: boolPtrOrNil(plan.SuppressMemberAlerts),
ConfirmationDelaySeconds: int32PtrOrNil(plan.ConfirmationDelaySeconds),
RecoveryCooldownMinutes: int32PtrOrNil(plan.RecoveryCooldownMinutes),
ManagedBy: &managedByTF,
}, diags
}

Expand All @@ -219,6 +221,7 @@ func (r *ResourceGroupResource) buildUpdateRequest(ctx context.Context, plan *Re
if diags.HasError() {
return generated.UpdateResourceGroupRequest{}, diags
}
managedByTF := generated.UpdateResourceGroupRequestManagedByTERRAFORM
return generated.UpdateResourceGroupRequest{
Name: plan.Name.ValueString(),
Description: stringPtrOrNil(plan.Description),
Expand All @@ -236,6 +239,7 @@ func (r *ResourceGroupResource) buildUpdateRequest(ctx context.Context, plan *Re
SuppressMemberAlerts: boolPtrOrNil(plan.SuppressMemberAlerts),
ConfirmationDelaySeconds: int32PtrOrNil(plan.ConfirmationDelaySeconds),
RecoveryCooldownMinutes: int32PtrOrNil(plan.RecoveryCooldownMinutes),
ManagedBy: &managedByTF,
}, diags
}

Expand Down
22 changes: 16 additions & 6 deletions internal/provider/resources/schema_dto_audit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,17 @@ func TestSchemaVsDTO_Audit(t *testing.T) {
"channel_type": "type",
},
allowed: map[string]string{
"config": "Discriminated union spread across per-channel-type schema blocks (slack, discord, email, …); the union is built by the provider's buildConfig().",
"config": "Discriminated union spread across per-channel-type schema blocks (slack, discord, email, …); the union is built by the provider's buildConfig().",
"managed_by": "Hardcoded to TERRAFORM by the provider; not a user-facing knob.",
},
},
{
name: "alert_channel_update",
resource: &AlertChannelResource{},
dto: generated.UpdateAlertChannelRequest{},
allowed: map[string]string{
"config": "See alert_channel_create note: discriminated union exploded into per-type blocks.",
"config": "See alert_channel_create note: discriminated union exploded into per-type blocks.",
"managed_by": "Hardcoded to TERRAFORM by the provider; not a user-facing knob.",
},
},
{
Expand Down Expand Up @@ -213,13 +215,17 @@ func TestSchemaVsDTO_Audit(t *testing.T) {
name: "resource_group_create",
resource: &ResourceGroupResource{},
dto: generated.CreateResourceGroupRequest{},
allowed: map[string]string{},
allowed: map[string]string{
"managed_by": "Hardcoded to TERRAFORM by the provider; not a user-facing knob.",
},
},
{
name: "resource_group_update",
resource: &ResourceGroupResource{},
dto: generated.UpdateResourceGroupRequest{},
allowed: map[string]string{},
allowed: map[string]string{
"managed_by": "Hardcoded to TERRAFORM by the provider; not a user-facing knob.",
},
},
{
name: "resource_group_membership_create",
Expand Down Expand Up @@ -257,13 +263,17 @@ func TestSchemaVsDTO_Audit(t *testing.T) {
name: "status_page_create",
resource: &StatusPageResource{},
dto: generated.CreateStatusPageRequest{},
allowed: map[string]string{},
allowed: map[string]string{
"managed_by": "Hardcoded to TERRAFORM by the provider; not a user-facing knob.",
},
},
{
name: "status_page_update",
resource: &StatusPageResource{},
dto: generated.UpdateStatusPageRequest{},
allowed: map[string]string{},
allowed: map[string]string{
"managed_by": "Hardcoded to TERRAFORM by the provider; not a user-facing knob.",
},
},
{
name: "status_page_component_create",
Expand Down
4 changes: 4 additions & 0 deletions internal/provider/resources/status_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ func (r *StatusPageResource) Create(ctx context.Context, req resource.CreateRequ
return
}

managedByTF := generated.CreateStatusPageRequestManagedByTERRAFORM
body := generated.CreateStatusPageRequest{
Name: plan.Name.ValueString(),
Slug: plan.Slug.ValueString(),
Expand All @@ -241,6 +242,7 @@ func (r *StatusPageResource) Create(ctx context.Context, req resource.CreateRequ
Enabled: boolPtrOrNil(plan.Enabled),
IncidentMode: incidentModeCreatePtr(plan.IncidentMode),
Branding: branding,
ManagedBy: &managedByTF,
}

page, err := api.Create[generated.StatusPageDto](ctx, r.client, api.PathStatusPages, body)
Expand Down Expand Up @@ -300,6 +302,7 @@ func (r *StatusPageResource) Update(ctx context.Context, req resource.UpdateRequ
}

name := plan.Name.ValueString()
managedByTF := generated.UpdateStatusPageRequestManagedByTERRAFORM
body := generated.UpdateStatusPageRequest{
Name: &name,
// Description follows the API's "null preserves, empty string clears"
Expand All @@ -310,6 +313,7 @@ func (r *StatusPageResource) Update(ctx context.Context, req resource.UpdateRequ
Visibility: visibilityUpdatePtr(plan.Visibility),
Enabled: boolPtrOrNil(plan.Enabled),
IncidentMode: incidentModeUpdatePtr(plan.IncidentMode),
ManagedBy: &managedByTF,
// Branding is non-pointer in the Update DTO so it must always be sent.
// brandingForUpdate handles three cases:
// - plan.Branding fully populated (UseStateForUnknown filled blanks
Expand Down
Loading