diff --git a/docs/data-sources/metric.md b/docs/data-sources/metric.md index 35829f91..5bce8325 100644 --- a/docs/data-sources/metric.md +++ b/docs/data-sources/metric.md @@ -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. diff --git a/docs/resources/metric.md b/docs/resources/metric.md index d98ff105..08e44821 100644 --- a/docs/resources/metric.md +++ b/docs/resources/metric.md @@ -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. diff --git a/launchdarkly/metrics_helper.go b/launchdarkly/metrics_helper.go index 61e0a1f9..a129fd87 100644 --- a/launchdarkly/metrics_helper.go +++ b/launchdarkly/metrics_helper.go @@ -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 { @@ -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) diff --git a/launchdarkly/resource_launchdarkly_metric.go b/launchdarkly/resource_launchdarkly_metric.go index eee882ee..a3f309c7 100644 --- a/launchdarkly/resource_launchdarkly_metric.go +++ b/launchdarkly/resource_launchdarkly_metric.go @@ -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, @@ -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 { @@ -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), @@ -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)