Skip to content

Commit 92d1607

Browse files
author
Pedro Montiel
committed
feedback from vishal
1 parent e6319aa commit 92d1607

7 files changed

+39
-37
lines changed

sumologic/resource_sumologic_cse_insights_resolution.go

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ import (
77
"strconv"
88
)
99

10+
const Resolved string = "Resolved"
11+
const FalsePositive string = "FalsePositive"
12+
const NoAction string = "NoAction"
13+
const Duplicate string = "Duplicate"
14+
1015
func resourceSumologicCSEInsightsResolution() *schema.Resource {
1116
return &schema.Resource{
1217
Create: resourceSumologicCSEInsightsResolutionCreate,
@@ -32,7 +37,7 @@ func resourceSumologicCSEInsightsResolution() *schema.Resource {
3237
Type: schema.TypeString,
3338
Optional: true,
3439
ForceNew: false,
35-
ValidateFunc: validation.StringInSlice([]string{"Resolved", "False Positive", "No Action", "Duplicate"}, false),
40+
ValidateFunc: validation.StringInSlice([]string{Resolved, FalsePositive, NoAction, Duplicate}, false),
3641
},
3742
},
3843
}
@@ -42,11 +47,11 @@ func resourceSumologicCSEInsightsResolutionRead(d *schema.ResourceData, meta int
4247
c := meta.(*Client)
4348

4449
var CSEInsightsResolutionGet *CSEInsightsResolutionGet
45-
id, _ := strconv.Atoi(d.Id())
50+
id := d.Id()
4651

4752
CSEInsightsResolutionGet, err := c.GetCSEInsightsResolution(id)
4853
if err != nil {
49-
log.Printf("[WARN] CSE Insights Resolution not found when looking by id: %d, err: %v", id, err)
54+
log.Printf("[WARN] CSE Insights Resolution not found when looking by id: %s, err: %v", id, err)
5055

5156
}
5257

@@ -69,13 +74,13 @@ func parentIdToParentName(parentId int) string {
6974

7075
if parentId > 0 {
7176
if parentId == 1 {
72-
parentName = "Resolved"
77+
parentName = Resolved
7378
} else if parentId == 2 {
74-
parentName = "False Positive"
79+
parentName = FalsePositive
7580
} else if parentId == 3 {
76-
parentName = "No Action"
81+
parentName = NoAction
7782
} else if parentId == 4 {
78-
parentName = "Duplicate"
83+
parentName = Duplicate
7984
}
8085
}
8186
return parentName
@@ -85,24 +90,23 @@ func parentNameToParentId(parentName string) int {
8590

8691
parentId := -1
8792

88-
if parentName != "" {
89-
if parentName == "Resolved" {
90-
parentId = 1
91-
} else if parentName == "False Positive" {
92-
parentId = 2
93-
} else if parentName == "No Action" {
94-
parentId = 3
95-
} else if parentName == "Duplicate" {
96-
parentId = 4
97-
}
93+
if parentName == Resolved {
94+
parentId = 1
95+
} else if parentName == FalsePositive {
96+
parentId = 2
97+
} else if parentName == NoAction {
98+
parentId = 3
99+
} else if parentName == Duplicate {
100+
parentId = 4
98101
}
102+
99103
return parentId
100104
}
101105

102106
func resourceSumologicCSEInsightsResolutionDelete(d *schema.ResourceData, meta interface{}) error {
103107
c := meta.(*Client)
104108

105-
id, _ := strconv.Atoi(d.Id())
109+
id := d.Id()
106110
return c.DeleteCSEInsightsResolution(id)
107111

108112
}

sumologic/resource_sumologic_cse_insights_resolution_test.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package sumologic
22

33
import (
44
"fmt"
5-
"strconv"
65
"testing"
76

87
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
@@ -44,10 +43,7 @@ func testAccCSEInsightsResolutionDestroy(s *terraform.State) error {
4443
return fmt.Errorf("CSE Insights Resolution destruction check: CSE Insights Resolution ID is not set")
4544
}
4645

47-
id, err := strconv.Atoi(rs.Primary.ID)
48-
if err != nil {
49-
return fmt.Errorf("cse insight resolution check: id should be int; got %s", rs.Primary.ID)
50-
}
46+
id := rs.Primary.ID
5147

5248
s, err := client.GetCSEInsightsResolution(id)
5349
if err != nil {
@@ -81,10 +77,7 @@ func testCheckCSEInsightsResolutionExists(n string, insightResolution *CSEInsigh
8177
return fmt.Errorf("insight Resolution ID is not set")
8278
}
8379

84-
id, err := strconv.Atoi(rs.Primary.ID)
85-
if err != nil {
86-
return fmt.Errorf("insight Resolution id should be int; got %s", rs.Primary.ID)
87-
}
80+
id := rs.Primary.ID
8881

8982
c := testAccProvider.Meta().(*Client)
9083
insightResolutionResp, err := c.GetCSEInsightsResolution(id)

sumologic/resource_sumologic_cse_insights_status.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ func resourceSumologicCSEInsightsStatus() *schema.Resource {
2626
Required: true,
2727
ForceNew: false,
2828
},
29+
"display_name": {
30+
Type: schema.TypeString,
31+
Computed: true,
32+
},
2933
},
3034
}
3135
}
@@ -50,6 +54,7 @@ func resourceSumologicCSEInsightsStatusRead(d *schema.ResourceData, meta interfa
5054

5155
d.Set("name", CSEInsightsStatusGet.Name)
5256
d.Set("description", CSEInsightsStatusGet.Description)
57+
d.Set("display_name", CSEInsightsStatusGet.DisplayName)
5358

5459
return nil
5560
}

sumologic/sumologic_cse_insights_resolution.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"fmt"
66
)
77

8-
func (s *Client) GetCSEInsightsResolution(id int) (*CSEInsightsResolutionGet, error) {
9-
data, _, err := s.Get(fmt.Sprintf("sec/v1/insight-resolutions/%d", id))
8+
func (s *Client) GetCSEInsightsResolution(id string) (*CSEInsightsResolutionGet, error) {
9+
data, _, err := s.Get(fmt.Sprintf("sec/v1/insight-resolutions/%s", id))
1010
if err != nil {
1111
return nil, err
1212
}
@@ -24,8 +24,8 @@ func (s *Client) GetCSEInsightsResolution(id int) (*CSEInsightsResolutionGet, er
2424
return &response.CSEInsightsResolutionGet, nil
2525
}
2626

27-
func (s *Client) DeleteCSEInsightsResolution(id int) error {
28-
_, err := s.Delete(fmt.Sprintf("sec/v1/insight-resolutions/%d", id))
27+
func (s *Client) DeleteCSEInsightsResolution(id string) error {
28+
_, err := s.Delete(fmt.Sprintf("sec/v1/insight-resolutions/%s", id))
2929

3030
return err
3131
}

website/docs/r/cse_insights_configuration.html.markdown

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ Provides the Sumologic CSE Insights Configuration for the whole organization. Th
1111
## Example Usage
1212
```hcl
1313
resource "sumologic_cse_insights_configuration" "insights_configuration" {
14-
lookback_days = 13
15-
threshold = 12
14+
lookback_days = 13.0
15+
threshold = 12.0
1616
}
1717
```
1818

website/docs/r/cse_insights_resolution.html.markdown

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
layout: "sumologic"
33
page_title: "SumoLogic: sumologic_cse_insights_resolution"
44
description: |-
5-
Provides a CSE Insights Resolution
5+
Provides a Sumologic CSE Insights Resolution. When an insight gets closed, a resolution indicates why it got closed.
66
---
77

88
# sumologic_cse_insights_resolution
9-
Provides a CSE Insights Resolution.
9+
Provides a Sumologic CSE Insights Resolution. When an insight gets closed, a resolution indicates why it got closed.
1010

1111
## Example Usage
1212
```hcl

website/docs/r/cse_insights_status.html.markdown

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
layout: "sumologic"
33
page_title: "SumoLogic: sumologic_cse_insights_status"
44
description: |-
5-
Provides a CSE Insights Status
5+
Provides a Sumologic CSE Insights Status
66
---
77

88
# sumologic_cse_insights_status
9-
Provides a CSE Insights Status.
9+
Provides a Sumologic CSE Insights Status.
1010

1111
## Example Usage
1212
```hcl

0 commit comments

Comments
 (0)