Skip to content

Commit 95d6339

Browse files
committed
Metrics Search Terraform Resource - field constraints
1 parent 7eb89b0 commit 95d6339

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

sumologic/resource_sumologic_metrics_search.go

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"log"
55

66
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
7+
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
78
)
89

910
func resourceSumologicMetricsSearch() *schema.Resource {
@@ -18,24 +19,29 @@ func resourceSumologicMetricsSearch() *schema.Resource {
1819

1920
Schema: map[string]*schema.Schema{
2021
"title": {
21-
Type: schema.TypeString,
22-
Required: true,
22+
Type: schema.TypeString,
23+
Required: true,
24+
ValidateFunc: validation.StringLenBetween(1, 255),
2325
},
2426
"description": {
25-
Type: schema.TypeString,
26-
Optional: true,
27+
Type: schema.TypeString,
28+
Required: true,
29+
ValidateFunc: validation.StringLenBetween(0, 8192),
2730
},
2831
"parent_id": {
2932
Type: schema.TypeString,
30-
Optional: true,
33+
Required: true,
3134
},
3235
"log_query": {
33-
Type: schema.TypeString,
34-
Optional: true,
36+
Type: schema.TypeString,
37+
Optional: true,
38+
ValidateFunc: validation.StringLenBetween(0, 1024),
3539
},
3640
"desired_quantization_in_secs": {
37-
Type: schema.TypeInt,
38-
Optional: true,
41+
Type: schema.TypeInt,
42+
Optional: true,
43+
Default: 0,
44+
ValidateFunc: validation.IntAtLeast(0),
3945
},
4046
"time_range": {
4147
Type: schema.TypeList,
@@ -51,7 +57,7 @@ func resourceSumologicMetricsSearch() *schema.Resource {
5157
},
5258
"metrics_queries": {
5359
Type: schema.TypeList,
54-
Optional: true,
60+
Required: true,
5561
Elem: &schema.Resource{
5662
Schema: map[string]*schema.Schema{
5763
"row_id": {

sumologic/resource_sumologic_metrics_search_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,4 @@ func testAccSumologicMetricsSearch(tfResourceName string, title string, descript
8888
`, tfResourceName, title, description, logQuery, desiredQuantizationInSecs,
8989
metricsSearchQuery[0].RowId, metricsSearchQuery[0].Query,
9090
literalRangeName)
91-
}
91+
}

website/docs/r/metrics_search.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ resource "sumologic_metrics_search" "example_metrics_search" {
3838
The following arguments are supported:
3939

4040
- `title` - (Required) Title of the search.
41-
- `description` - (Optional) Description of the search.
41+
- `description` - (Required) Description of the search.
4242
- `parent_id` - (Required) The identifier of the folder to create the log search in.
4343
- `log_query` - Log query to perform.
4444
- `metrics_queries` - (Required) Array of objects [MetricsSearchQuery](#schema-for-metrics_search_query). Metrics queries, up to the maximum of six.

0 commit comments

Comments
 (0)