Skip to content
Closed
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
1 change: 1 addition & 0 deletions docs/data-sources/metric.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ data "launchdarkly_metric" "example" {
### Read-Only

- `analysis_type` (String) The method for analyzing metric events. Available choices are `mean` and `percentile`.
- `archived` (Boolean) Whether the metric is archived.
- `description` (String) The description of the metric's purpose.
- `event_key` (String) The event key for your metric (if custom metric)
- `id` (String) The ID of this resource.
Expand Down
1 change: 1 addition & 0 deletions docs/resources/metric.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ resource "launchdarkly_metric" "example" {
### Optional

- `analysis_type` (String) The method for analyzing metric events. Available choices are `mean` and `percentile`.
- `archived` (Boolean) Whether the metric is archived.
- `description` (String) The description of the metric's purpose.
- `event_key` (String) The event key for your metric (if custom metric)
- `include_units_without_events` (Boolean) Include units that did not send any events and set their value to 0.
Expand Down
7 changes: 7 additions & 0 deletions launchdarkly/metrics_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@ func baseMetricSchema(isDataSource bool) map[string]*schema.Schema {
Computed: true,
Description: "Version of the metric",
},
ARCHIVED: {
Type: schema.TypeBool,
Optional: !isDataSource,
Computed: true,
Description: "Whether the metric is archived.",
},
}

if isDataSource {
Expand Down Expand Up @@ -210,6 +216,7 @@ func metricRead(ctx context.Context, d *schema.ResourceData, metaRaw interface{}
_ = d.Set(ANALYSIS_TYPE, metric.AnalysisType)
_ = d.Set(PERCENTILE_VALUE, metric.PercentileValue)
_ = d.Set(VERSION, metric.Version)
// _ = d.Set(ARCHIVED, metric.Archived) // Uncomment when API client is updated with archived field

d.SetId(projectKey + "/" + key)

Expand Down
4 changes: 4 additions & 0 deletions launchdarkly/resource_launchdarkly_metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ func resourceMetricCreate(ctx context.Context, d *schema.ResourceData, metaRaw i
analysisType := d.Get(ANALYSIS_TYPE).(string)
includeUnitsWithoutEvents := d.Get(INCLUDE_UNITS_WITHOUT_EVENTS).(bool)
eventDefaultDisabled := !includeUnitsWithoutEvents
// archived := d.Get(ARCHIVED).(bool) // Uncomment when API client is updated with archived field

metric := ldapi.MetricPost{
Name: &name,
Expand All @@ -220,6 +221,7 @@ func resourceMetricCreate(ctx context.Context, d *schema.ResourceData, metaRaw i
UnitAggregationType: &unitAggregationType,
AnalysisType: &analysisType,
EventDefault: &ldapi.MetricEventDefaultRep{Disabled: &eventDefaultDisabled},
// Archived: &archived, // Uncomment when API client is updated with archived field
}
percentileValueData, hasPercentile := d.GetOk(PERCENTILE_VALUE)
if hasPercentile {
Expand Down Expand Up @@ -310,6 +312,7 @@ func resourceMetricUpdate(ctx context.Context, d *schema.ResourceData, metaRaw i
unitAggregationType := d.Get(UNIT_AGGREGATION_TYPE).(string)
analysisType := d.Get(ANALYSIS_TYPE).(string)
includeUnitsWithoutEvents := d.Get(INCLUDE_UNITS_WITHOUT_EVENTS).(bool)
// archived := d.Get(ARCHIVED).(bool) // Uncomment when API client is updated with archived field

patch := []ldapi.PatchOperation{
patchReplace("/name", name),
Expand All @@ -325,6 +328,7 @@ func resourceMetricUpdate(ctx context.Context, d *schema.ResourceData, metaRaw i
patchReplace("/unitAggregationType", unitAggregationType),
patchReplace("/analysisType", analysisType),
patchReplace("/eventDefault/disabled", !includeUnitsWithoutEvents),
// patchReplace("/archived", archived), // Uncomment when API client is updated with archived field
}

percentileValueData, ok := d.GetOk(PERCENTILE_VALUE)
Expand Down
Loading