Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
1635a79
New resources: azurerm_dynatrace_monitors, azurerm_dynatrace_tag_rules
jiaweitao001 Sep 13, 2022
66c631f
Adding documentation
jiaweitao001 Sep 14, 2022
1c6897a
Add subcategory
jiaweitao001 Sep 14, 2022
aa1919a
Renaming parameters
jiaweitao001 Sep 16, 2022
e29c604
change variable names
jiaweitao001 Oct 8, 2022
bc52244
Fix acc tests
jiaweitao001 Oct 21, 2022
c5455db
Renaming variables
jiaweitao001 Oct 25, 2022
84f445b
fix schema
jiaweitao001 Nov 2, 2022
8d4567a
fix imports
jiaweitao001 Nov 2, 2022
e9f9e06
retrigger teamcity run
jiaweitao001 Dec 1, 2022
42fa5e5
rebase dynatrace
jiaweitao001 May 22, 2023
fed7c15
Update API
jiaweitao001 Oct 23, 2023
70e0c18
New Resource: azurerm_dynatrace_monitors
jiaweitao001 Nov 7, 2023
9a5a1ab
sort imports
jiaweitao001 Nov 7, 2023
d09c64d
Fix imports
jiaweitao001 Nov 7, 2023
4f1df1a
Fix lint
jiaweitao001 Nov 7, 2023
d4f2622
Fix gencheck
jiaweitao001 Nov 7, 2023
8fc8047
Fix gofmt
jiaweitao001 Nov 7, 2023
d08fce5
Remove redundant condition
jiaweitao001 Nov 7, 2023
ab0f662
Address PR comments
jiaweitao001 Dec 1, 2023
e0d4364
Update docs
jiaweitao001 Dec 4, 2023
2221a67
Update expand/flatten identity helper
jiaweitao001 Dec 4, 2023
dca6838
Add prechecks
jiaweitao001 Dec 6, 2023
fa5a7b4
remove effective date, testing
jiaweitao001 Aug 20, 2024
fabb928
modified tests, replace pointers
jiaweitao001 Sep 19, 2024
ad57c54
modified docs
jiaweitao001 Sep 19, 2024
0fa9382
upgrade vendor
jiaweitao001 Sep 19, 2024
5a9bf21
fix go gen
jiaweitao001 Sep 19, 2024
abce79a
skip tests
jiaweitao001 Sep 19, 2024
1b73d35
inclined some functions, changed docs
jiaweitao001 Oct 24, 2024
c31798c
fix imports
jiaweitao001 Oct 24, 2024
eed639b
update vendors
jiaweitao001 Oct 24, 2024
927c7f4
inlined values, add tracking issue
jiaweitao001 Oct 29, 2024
c076a2d
Format code to follow guidance
jiaweitao001 Nov 7, 2024
05005d6
format acc test
jiaweitao001 Nov 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Renaming parameters
  • Loading branch information
jiaweitao001 committed Oct 24, 2024
commit aa1919add9ca734e1ef7ccc4fb622202ce6b9919
30 changes: 17 additions & 13 deletions internal/services/dynatrace/dynatrace_monitors_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ type MonitorsResourceModel struct {
Name string `tfschema:"name"`
ResourceGroup string `tfschema:"resource_group_name"`
Location string `tfschema:"location"`
MonitoringStatus string `tfschema:"monitoring_status"`
MarketplaceSubscriptionStatus string `tfschema:"marketplace_subscription_status"`
MonitoringStatus bool `tfschema:"monitoring_enabled"`
MarketplaceSubscriptionStatus string `tfschema:"marketplace_subscription"`
IdentityType string `tfschema:"identity_type"`
PlanData []PlanData `tfschema:"plan_data"`
UserInfo []UserInfo `tfschema:"user_info"`
Expand All @@ -34,13 +34,13 @@ type MonitorsResourceModel struct {
type PlanData struct {
BillingCycle string `tfschema:"billing_cycle"`
EffectiveDate string `tfschema:"effective_date"`
PlanDetails string `tfschema:"plan_details"`
PlanDetails string `tfschema:"plan"`
UsageType string `tfschema:"usage_type"`
}

type UserInfo struct {
Country string `tfschema:"country"`
EmailAddress string `tfschema:"email_address"`
EmailAddress string `tfschema:"email"`
FirstName string `tfschema:"first_name"`
LastName string `tfschema:"last_name"`
PhoneNumber string `tfschema:"phone_number"`
Expand Down Expand Up @@ -70,17 +70,14 @@ func (r MonitorsResource) Arguments() map[string]*schema.Schema {
}, false),
},

"monitoring_status": {
Type: pluginsdk.TypeString,
"monitoring_enabled": {
Type: pluginsdk.TypeBool,
Optional: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{
"Enabled",
"Disabled",
}, false),
Default: true,
},

"marketplace_subscription_status": {
"marketplace_subscription": {
Type: pluginsdk.TypeString,
Optional: true,
ForceNew: true,
Expand Down Expand Up @@ -132,7 +129,10 @@ func (r MonitorsResource) Create() sdk.ResourceFunc {
}

marketplaceSubscriptionServiceStatus := monitors.MarketplaceSubscriptionStatus(model.MarketplaceSubscriptionStatus)
monitoringStatus := monitors.MonitoringStatus(model.MonitoringStatus)
monitoringStatus := monitors.MonitoringStatusEnabled
if !model.MonitoringStatus {
monitoringStatus = monitors.MonitoringStatusDisabled
}
monitorsProps := monitors.MonitorProperties{
MarketplaceSubscriptionStatus: &marketplaceSubscriptionServiceStatus,
MonitoringStatus: &monitoringStatus,
Expand Down Expand Up @@ -184,12 +184,16 @@ func (r MonitorsResource) Read() sdk.ResourceFunc {
props := model.Properties
identityProps := model.Identity
userInfo := metadata.ResourceData.Get("user_info").([]interface{})
monitoringStatus := true
if *props.MonitoringStatus == monitors.MonitoringStatusDisabled {
monitoringStatus = false
}

state := MonitorsResourceModel{
Name: id.MonitorName,
ResourceGroup: id.ResourceGroupName,
Location: model.Location,
MonitoringStatus: string(*props.MonitoringStatus),
MonitoringStatus: monitoringStatus,
MarketplaceSubscriptionStatus: string(*props.MarketplaceSubscriptionStatus),
IdentityType: string(identityProps.Type),
PlanData: FlattenDynatracePlanData(props.PlanData),
Expand Down
60 changes: 30 additions & 30 deletions internal/services/dynatrace/dynatrace_monitors_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,25 +90,25 @@ func (r MonitorsResource) basic(data acceptance.TestData) string {
%[1]s

resource "azurerm_dynatrace_monitors" "test" {
name = "acctestacc%[2]d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
identity_type = "SystemAssigned"
monitoring_status = "Enabled"
marketplace_subscription_status = "Active"
name = "acctestacc%[2]d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
identity_type = "SystemAssigned"
monitoring_status = "Enabled"
marketplace_subscription = "Active"

user_info {
first_name = "Alice"
last_name = "Bobab"
email_address = "alice@microsoft.com"
phone_number = "123456"
country = "westus"
first_name = "Alice"
last_name = "Bobab"
email = "alice@microsoft.com"
phone_number = "123456"
country = "westus"
}

plan_data {
usage_type = "COMMITTED"
billing_cycle = "MONTHLY"
plan_details = "azureportalintegration_privatepreview@TIDhjdtn7tfnxcy"
plan = "azureportalintegration_privatepreview@TIDhjdtn7tfnxcy"
effective_date = "2019-08-30T15:14:33Z"
}
}
Expand All @@ -121,25 +121,25 @@ func (r MonitorsResource) updated(data acceptance.TestData) string {
%[1]s

resource "azurerm_dynatrace_monitors" "test" {
name = "acctestacc%[2]d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
identity_type = "SystemAssigned"
monitoring_status = "Enabled"
marketplace_subscription_status = "Active"
name = "acctestacc%[2]d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
identity_type = "SystemAssigned"
monitoring_status = "Enabled"
marketplace_subscription = "Active"

user_info {
first_name = "Alice"
last_name = "Bobab"
email_address = "alice@microsoft.com"
phone_number = "123456"
country = "westus"
first_name = "Alice"
last_name = "Bobab"
email = "alice@microsoft.com"
phone_number = "123456"
country = "westus"
}

plan_data {
usage_type = "COMMITTED"
billing_cycle = "MONTHLY"
plan_details = "azureportalintegration_privatepreview@TIDhjdtn7tfnxcy"
plan = "azureportalintegration_privatepreview@TIDhjdtn7tfnxcy"
effective_date = "2019-08-30T15:14:33Z"
}

Expand All @@ -157,12 +157,12 @@ func (r MonitorsResource) requiresImport(data acceptance.TestData) string {
%s

resource "azurerm_dynatrace_monitors" "import" {
name = azurerm_dynatrace_monitors.test.name
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
identity_type = azurerm_dynatrace_monitors.test.identity_type
monitoring_status = azurerm_dynatrace_monitors.test.monitoring_status
marketplace_subscription_status = azurerm_dynatrace_monitors.test.marketplace_subscription_status
name = azurerm_dynatrace_monitors.test.name
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
identity_type = azurerm_dynatrace_monitors.test.identity_type
monitoring_status = azurerm_dynatrace_monitors.test.monitoring_status
marketplace_subscription = azurerm_dynatrace_monitors.test.marketplace_subscription_status
}
`, template)
}
Expand Down
6 changes: 3 additions & 3 deletions internal/services/dynatrace/dynatrace_tag_rules_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ type MetricRule struct {

type LogRule struct {
FilteringTags []FilteringTag `tfschema:"filtering_tag"`
SendAadLogs string `tfschema:"send_aad_logs"`
SendActivityLogs string `tfschema:"send_activity_logs"`
SendSubscriptionLogs string `tfschema:"send_subscription_logs"`
SendAadLogs string `tfschema:"send_aad_logs_enabled"`
SendActivityLogs string `tfschema:"send_activity_logs_enabled"`
SendSubscriptionLogs string `tfschema:"send_subscription_logs_enabled"`
}

type FilteringTag struct {
Expand Down
30 changes: 15 additions & 15 deletions internal/services/dynatrace/dynatrace_tag_rules_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ resource "azurerm_dynatrace_tag_rules" "test" {
value = "Prod"
action = "Include"
}
send_aad_logs = "Enabled"
send_activity_logs = "Enabled"
send_subscription_logs = "Enabled"
send_aad_logs_enabled = "Enabled"
send_activity_logs_enabled = "Enabled"
send_subscription_logs_enabled = "Enabled"
}

metric_rules {
Expand Down Expand Up @@ -117,25 +117,25 @@ resource "azurerm_resource_group" "test" {
}

resource "azurerm_dynatrace_monitors" "test" {
name = "acctestacc%[2]s"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
identity_type = "SystemAssigned"
monitoring_status = "Enabled"
marketplace_subscription_status = "Active"
name = "acctestacc%[2]s"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
identity_type = "SystemAssigned"
monitoring_status = "Enabled"
marketplace_subscription = "Active"

user_info {
first_name = "Alice"
last_name = "Bobab"
email_address = "alice@microsoft.com"
phone_number = "123456"
country = "westus"
first_name = "Alice"
last_name = "Bobab"
email = "alice@microsoft.com"
phone_number = "123456"
country = "westus"
}

plan_data {
usage_type = "COMMITTED"
billing_cycle = "MONTHLY"
plan_details = "azureportalintegration_privatepreview@TIDhjdtn7tfnxcy"
plan = "azureportalintegration_privatepreview@TIDhjdtn7tfnxcy"
effective_date = "2019-08-30T15:14:33Z"
}
}
Expand Down
12 changes: 6 additions & 6 deletions internal/services/dynatrace/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func SchemaPlanData() *pluginsdk.Schema {
ValidateFunc: validation.IsRFC3339Time,
},

"plan_details": {
"plan": {
Type: pluginsdk.TypeString,
Optional: true,
ValidateFunc: validation.StringIsNotEmpty,
Expand Down Expand Up @@ -64,7 +64,7 @@ func SchemaUserInfo() *pluginsdk.Schema {
ValidateFunc: validation.StringIsNotEmpty,
},

"email_address": {
"email": {
Type: pluginsdk.TypeString,
Optional: true,
ValidateFunc: validation.StringIsNotEmpty,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can propertly validate this is an email?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do.

Expand Down Expand Up @@ -133,7 +133,7 @@ func SchemaLogRule() *pluginsdk.Schema {
Schema: map[string]*schema.Schema{
"filtering_tag": SchemaFilteringTag(),

"send_aad_logs": {
"send_aad_logs_enabled": {
Type: pluginsdk.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{
Expand All @@ -142,7 +142,7 @@ func SchemaLogRule() *pluginsdk.Schema {
}, false),
},

"send_activity_logs": {
"send_activity_logs_enabled": {
Type: pluginsdk.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{
Expand All @@ -151,7 +151,7 @@ func SchemaLogRule() *pluginsdk.Schema {
}, false),
},

"send_subscription_logs": {
"send_subscription_logs_enabled": {
Type: pluginsdk.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{
Expand Down Expand Up @@ -295,7 +295,7 @@ func FlattenDynatraceUserInfo(input []interface{}) []UserInfo {
v := input[0].(map[string]interface{})

country := v["country"].(string)
emailAddress := v["email_address"].(string)
emailAddress := v["email"].(string)
firstName := v["first_name"].(string)
lastName := v["last_name"].(string)
phoneNumber := v["phone_number"].(string)
Expand Down
4 changes: 2 additions & 2 deletions website/docs/r/dynatrace_monitors.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ resource "azurerm_dynatrace_monitors" "example" {
plan_data {
usage_type = "COMMITTED"
billing_cycle = "MONTHLY"
plan_details = "azureportalintegration_privatepreview@TIDhjdtn7tfnxcy"
plan = "azureportalintegration_privatepreview@TIDhjdtn7tfnxcy"
effective_date = "2019-08-30T15:14:33Z"
}
}
Expand Down Expand Up @@ -74,7 +74,7 @@ A `plan_data` block supports the following:

* `effective_date` - (Optional) Date when plan was applied.

* `plan_details` - (Optional) Plan id as published by Dynatrace.
* `plan` - (Optional) Plan id as published by Dynatrace.

* `usage_type` - (Optional) Different usage type. Possible values are `PAYG`, `COMMITTED`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will change.


Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/dynatrace_tag_rules.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ resource "azurerm_dynatrace_monitors" "example" {
plan_data {
usage_type = "COMMITTED"
billing_cycle = "MONTHLY"
plan_details = "azureportalintegration_privatepreview@TIDhjdtn7tfnxcy"
plan = "azureportalintegration_privatepreview@TIDhjdtn7tfnxcy"
effective_date = "2019-08-30T15:14:33Z"
}
}
Expand Down