Skip to content

Commit 45eb9d7

Browse files
committed
Add archived field to launchdarkly_metrics resources
Signed-off-by: Siddharth Asthana <sasthana@launchdarkly.com>
1 parent 15a0ef3 commit 45eb9d7

File tree

4 files changed

+13
-0
lines changed

4 files changed

+13
-0
lines changed

docs/data-sources/metric.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ data "launchdarkly_metric" "example" {
3737
### Read-Only
3838

3939
- `analysis_type` (String) The method for analyzing metric events. Available choices are `mean` and `percentile`.
40+
- `archived` (Boolean) Whether the metric is archived.
4041
- `description` (String) The description of the metric's purpose.
4142
- `event_key` (String) The event key for your metric (if custom metric)
4243
- `id` (String) The ID of this resource.

docs/resources/metric.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ resource "launchdarkly_metric" "example" {
4646
### Optional
4747

4848
- `analysis_type` (String) The method for analyzing metric events. Available choices are `mean` and `percentile`.
49+
- `archived` (Boolean) Whether the metric is archived.
4950
- `description` (String) The description of the metric's purpose.
5051
- `event_key` (String) The event key for your metric (if custom metric)
5152
- `include_units_without_events` (Boolean) Include units that did not send any events and set their value to 0.

launchdarkly/metrics_helper.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,12 @@ func baseMetricSchema(isDataSource bool) map[string]*schema.Schema {
151151
Computed: true,
152152
Description: "Version of the metric",
153153
},
154+
ARCHIVED: {
155+
Type: schema.TypeBool,
156+
Optional: !isDataSource,
157+
Computed: true,
158+
Description: "Whether the metric is archived.",
159+
},
154160
}
155161

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

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

launchdarkly/resource_launchdarkly_metric.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ func resourceMetricCreate(ctx context.Context, d *schema.ResourceData, metaRaw i
203203
analysisType := d.Get(ANALYSIS_TYPE).(string)
204204
includeUnitsWithoutEvents := d.Get(INCLUDE_UNITS_WITHOUT_EVENTS).(bool)
205205
eventDefaultDisabled := !includeUnitsWithoutEvents
206+
// archived := d.Get(ARCHIVED).(bool) // Uncomment when API client is updated with archived field
206207

207208
metric := ldapi.MetricPost{
208209
Name: &name,
@@ -220,6 +221,7 @@ func resourceMetricCreate(ctx context.Context, d *schema.ResourceData, metaRaw i
220221
UnitAggregationType: &unitAggregationType,
221222
AnalysisType: &analysisType,
222223
EventDefault: &ldapi.MetricEventDefaultRep{Disabled: &eventDefaultDisabled},
224+
// Archived: &archived, // Uncomment when API client is updated with archived field
223225
}
224226
percentileValueData, hasPercentile := d.GetOk(PERCENTILE_VALUE)
225227
if hasPercentile {
@@ -310,6 +312,7 @@ func resourceMetricUpdate(ctx context.Context, d *schema.ResourceData, metaRaw i
310312
unitAggregationType := d.Get(UNIT_AGGREGATION_TYPE).(string)
311313
analysisType := d.Get(ANALYSIS_TYPE).(string)
312314
includeUnitsWithoutEvents := d.Get(INCLUDE_UNITS_WITHOUT_EVENTS).(bool)
315+
// archived := d.Get(ARCHIVED).(bool) // Uncomment when API client is updated with archived field
313316

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

330334
percentileValueData, ok := d.GetOk(PERCENTILE_VALUE)

0 commit comments

Comments
 (0)