-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #86 from logicmonitor/DEV-164489-TestLocationAndSt…
…ageFix TestLocation And EscalationChain Stage Fix
- Loading branch information
Showing
13 changed files
with
511 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,19 +4,34 @@ resource "logicmonitor_escalation_chain" "my_escalation_chain"{ | |
destinations = [ | ||
{ | ||
period = [{ | ||
week_days = 2 | ||
week_days = [2,3] | ||
timezone = "UTC" | ||
start_minutes = 10 | ||
end_minutes = 15 | ||
}] | ||
stages = [ | ||
[ | ||
{ | ||
type = "Admin" | ||
addr = "[email protected]" | ||
method = "EMAIL" | ||
contact = "78362637" | ||
}, | ||
{ | ||
type = "Admin" | ||
addr = "[email protected]" | ||
method = "EMAIL" | ||
contact = "78362637" | ||
}], | ||
stages = [{ | ||
type = "Admin" | ||
addr = "[email protected]" | ||
method = "EMAIL" | ||
contact = "78362637" | ||
[{ | ||
type = "Admin" | ||
addr = "[email protected]" | ||
method = "EMAIL" | ||
contact = "78362637" | ||
}] | ||
type = "timebased" | ||
} | ||
] | ||
type = "timebased" | ||
} | ||
] | ||
name = "Escalation Chain Test" | ||
description = "escalation chain test" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package schemata | ||
|
||
import ( | ||
"terraform-provider-logicmonitor/models" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
func WebsiteCollectorInfoSchema() map[string]*schema.Schema { | ||
return map[string]*schema.Schema{ | ||
"collector_group_id": { | ||
Type: schema.TypeInt, | ||
Computed: true, | ||
}, | ||
|
||
"collector_group_name": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
|
||
"description": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
|
||
"hostname": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
|
||
"id": { | ||
Type: schema.TypeInt, | ||
Computed: true, | ||
}, | ||
|
||
"status": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
|
||
} | ||
} | ||
|
||
func SetWebsiteCollectorInfoSubResourceData(m []*models.WebsiteCollectorInfo) (d []*map[string]interface{}) { | ||
for _, websiteCollectorInfo := range m { | ||
if websiteCollectorInfo != nil { | ||
properties := make(map[string]interface{}) | ||
properties["collector_group_id"] = websiteCollectorInfo.CollectorGroupID | ||
properties["collector_group_name"] = websiteCollectorInfo.CollectorGroupName | ||
properties["description"] = websiteCollectorInfo.Description | ||
properties["hostname"] = websiteCollectorInfo.Hostname | ||
properties["id"] = websiteCollectorInfo.ID | ||
properties["status"] = websiteCollectorInfo.Status | ||
d = append(d, &properties) | ||
} | ||
} | ||
return | ||
} | ||
|
||
func WebsiteCollectorInfoModel(d map[string]interface{}) *models.WebsiteCollectorInfo { | ||
// assume that the incoming map only contains the relevant resource data | ||
|
||
return &models.WebsiteCollectorInfo { | ||
} | ||
} | ||
|
||
func GetWebsiteCollectorInfoPropertyFields() (t []string) { | ||
return []string{ | ||
"id", | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package schemata | ||
|
||
import ( | ||
"terraform-provider-logicmonitor/logicmonitor/utils" | ||
"terraform-provider-logicmonitor/models" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
func WebsiteLocationSchema() map[string]*schema.Schema { | ||
return map[string]*schema.Schema{ | ||
"all": { | ||
Type: schema.TypeBool, | ||
Optional: true, | ||
}, | ||
|
||
"collector_ids": { | ||
Type: schema.TypeList, //GoType: []int32 | ||
Elem: &schema.Schema{ | ||
Type: schema.TypeInt, | ||
}, | ||
ConfigMode: schema.SchemaConfigModeAttr, | ||
Optional: true, | ||
}, | ||
|
||
"collectors": { | ||
Type: schema.TypeList, //GoType: []*WebsiteCollectorInfo | ||
Elem: &schema.Resource{ | ||
Schema: WebsiteCollectorInfoSchema(), | ||
}, | ||
ConfigMode: schema.SchemaConfigModeAttr, | ||
Optional: true, | ||
}, | ||
|
||
"smg_ids": { | ||
Type: schema.TypeList, //GoType: []int32 | ||
Elem: &schema.Schema{ | ||
Type: schema.TypeInt, | ||
}, | ||
ConfigMode: schema.SchemaConfigModeAttr, | ||
Optional: true, | ||
}, | ||
|
||
} | ||
} | ||
|
||
func SetWebsiteLocationSubResourceData(m []*models.WebsiteLocation) (d []*map[string]interface{}) { | ||
for _, websiteLocation := range m { | ||
if websiteLocation != nil { | ||
properties := make(map[string]interface{}) | ||
properties["all"] = websiteLocation.All | ||
properties["collector_ids"] = websiteLocation.CollectorIds | ||
properties["collectors"] = SetWebsiteCollectorInfoSubResourceData(websiteLocation.Collectors) | ||
properties["smg_ids"] = websiteLocation.SmgIds | ||
d = append(d, &properties) | ||
} | ||
} | ||
return | ||
} | ||
|
||
func WebsiteLocationModel(d map[string]interface{}) *models.WebsiteLocation { | ||
// assume that the incoming map only contains the relevant resource data | ||
all := d["all"].(bool) | ||
collectorIds := utils.ConvertSetToInt32Slice(d["collectorIds"].([]interface{})) | ||
collectors := d["collectors"].([]*models.WebsiteCollectorInfo) | ||
smgIds := utils.ConvertSetToInt32Slice(d["smgIds"].([]interface{})) | ||
|
||
return &models.WebsiteLocation { | ||
All: all, | ||
CollectorIds: collectorIds, | ||
Collectors: collectors, | ||
SmgIds: smgIds, | ||
} | ||
} | ||
|
||
func GetWebsiteLocationPropertyFields() (t []string) { | ||
return []string{ | ||
"all", | ||
"collector_ids", | ||
"collectors", | ||
"smg_ids", | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.