diff --git a/internal/services/eventgrid/eventgrid_domain_data_source.go b/internal/services/eventgrid/eventgrid_domain_data_source.go index d84260a744546..59cf02d48121c 100644 --- a/internal/services/eventgrid/eventgrid_domain_data_source.go +++ b/internal/services/eventgrid/eventgrid_domain_data_source.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" "github.com/hashicorp/go-azure-helpers/resourcemanager/location" "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" "github.com/hashicorp/go-azure-sdk/resource-manager/eventgrid/2022-06-15/domains" @@ -138,6 +139,8 @@ func dataSourceEventGridDomain() *pluginsdk.Resource { }, "tags": commonschema.TagsDataSource(), + + "identity": commonschema.SystemOrUserAssignedIdentityComputed(), }, } } @@ -202,6 +205,14 @@ func dataSourceEventGridDomainRead(d *pluginsdk.ResourceData, meta interface{}) if err := d.Set("inbound_ip_rule", inboundIPRules); err != nil { return fmt.Errorf("setting `inbound_ip_rule` in %s: %+v", id, err) } + + flattenedIdentity, err := identity.FlattenSystemAndUserAssignedMap(model.Identity) + if err != nil { + return fmt.Errorf("flattening `identity`: %+v", err) + } + if err := d.Set("identity", flattenedIdentity); err != nil { + return fmt.Errorf("setting `identity`: %+v", err) + } } if err := tags.FlattenAndSet(d, model.Tags); err != nil { diff --git a/internal/services/eventgrid/eventgrid_domain_data_source_test.go b/internal/services/eventgrid/eventgrid_domain_data_source_test.go index 50923b8ae5ee3..9fc6dc2975040 100644 --- a/internal/services/eventgrid/eventgrid_domain_data_source_test.go +++ b/internal/services/eventgrid/eventgrid_domain_data_source_test.go @@ -35,6 +35,43 @@ func TestAccEventGridDomainDataSource_basic(t *testing.T) { check.That(data.ResourceName).Key("inbound_ip_rule.1.ip_mask").Exists(), check.That(data.ResourceName).Key("inbound_ip_rule.0.action").Exists(), check.That(data.ResourceName).Key("inbound_ip_rule.1.action").Exists(), + check.That(data.ResourceName).Key("identity.#").HasValue("0"), + ), + }, + }) +} + +func TestAccEventGridDomainDataSource_systemAssignedIdentity(t *testing.T) { + data := acceptance.BuildTestData(t, "data.azurerm_eventgrid_domain", "test") + r := EventGridDomainDataSource{} + + data.DataSourceTest(t, []acceptance.TestStep{ + { + Config: r.basicWithSystemManagedIdentity(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).Key("identity.#").HasValue("1"), + check.That(data.ResourceName).Key("identity.0.type").HasValue("SystemAssigned"), + check.That(data.ResourceName).Key("identity.0.identity_ids.#").HasValue("0"), + check.That(data.ResourceName).Key("identity.0.principal_id").Exists(), + check.That(data.ResourceName).Key("identity.0.tenant_id").Exists(), + ), + }, + }) +} + +func TestAccEventGridDomainDataSource_userAssignedIdentity(t *testing.T) { + data := acceptance.BuildTestData(t, "data.azurerm_eventgrid_domain", "test") + r := EventGridDomainDataSource{} + + data.DataSourceTest(t, []acceptance.TestStep{ + { + Config: r.basicWithUserAssignedManagedIdentity(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).Key("identity.#").HasValue("1"), + check.That(data.ResourceName).Key("identity.0.type").HasValue("UserAssigned"), + check.That(data.ResourceName).Key("identity.0.identity_ids.#").HasValue("1"), + check.That(data.ResourceName).Key("identity.0.principal_id").IsEmpty(), + check.That(data.ResourceName).Key("identity.0.tenant_id").IsEmpty(), ), }, }) @@ -50,3 +87,25 @@ data "azurerm_eventgrid_domain" "test" { } `, EventGridDomainResource{}.complete(data)) } + +func (EventGridDomainDataSource) basicWithSystemManagedIdentity(data acceptance.TestData) string { + return fmt.Sprintf(` +%s + +data "azurerm_eventgrid_domain" "test" { + name = azurerm_eventgrid_domain.test.name + resource_group_name = azurerm_resource_group.test.name +} +`, EventGridDomainResource{}.basicWithSystemManagedIdentity(data)) +} + +func (EventGridDomainDataSource) basicWithUserAssignedManagedIdentity(data acceptance.TestData) string { + return fmt.Sprintf(` +%s + +data "azurerm_eventgrid_domain" "test" { + name = azurerm_eventgrid_domain.test.name + resource_group_name = azurerm_resource_group.test.name +} +`, EventGridDomainResource{}.basicWithUserAssignedManagedIdentity(data)) +} diff --git a/internal/services/newrelic/client/client.go b/internal/services/newrelic/client/client.go index b2fbe97f90a15..bf85de87d9e05 100644 --- a/internal/services/newrelic/client/client.go +++ b/internal/services/newrelic/client/client.go @@ -4,23 +4,35 @@ package client import ( + "fmt" + "github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/monitors" + "github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules" "github.com/hashicorp/terraform-provider-azurerm/internal/common" ) type Client struct { MonitorsClient *monitors.MonitorsClient + TagRulesClient *tagrules.TagRulesClient } func NewClient(o *common.ClientOptions) (*Client, error) { - monitorsClient, err := monitors.NewMonitorsClientWithBaseURI(o.Environment.ResourceManager) if err != nil { - return nil, err + return nil, fmt.Errorf("building Monitors client: %+v", err) } + o.Configure(monitorsClient.Client, o.Authorizers.ResourceManager) + tagRulesClient, err := tagrules.NewTagRulesClientWithBaseURI(o.Environment.ResourceManager) + if err != nil { + return nil, fmt.Errorf("building TagRules client: %+v", err) + } + + o.Configure(tagRulesClient.Client, o.Authorizers.ResourceManager) + return &Client{ MonitorsClient: monitorsClient, + TagRulesClient: tagRulesClient, }, nil } diff --git a/internal/services/newrelic/new_relic_tag_rule_resource.go b/internal/services/newrelic/new_relic_tag_rule_resource.go new file mode 100644 index 0000000000000..e106d6416fee4 --- /dev/null +++ b/internal/services/newrelic/new_relic_tag_rule_resource.go @@ -0,0 +1,427 @@ +package newrelic + +import ( + "context" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/monitors" + "github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules" + "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" +) + +type NewRelicTagRuleModel struct { + NewRelicMonitorId string `tfschema:"monitor_id"` + AadLogEnabled bool `tfschema:"azure_active_directory_log_enabled"` + ActivityLogEnabled bool `tfschema:"activity_log_enabled"` + LogTagFilter []FilteringTagModel `tfschema:"log_tag_filter"` + MetricEnabled bool `tfschema:"metric_enabled"` + MetricTagFilter []FilteringTagModel `tfschema:"metric_tag_filter"` + SubscriptionLogEnabled bool `tfschema:"subscription_log_enabled"` +} + +type FilteringTagModel struct { + Action tagrules.TagAction `tfschema:"action"` + Name string `tfschema:"name"` + Value string `tfschema:"value"` +} + +type NewRelicTagRuleResource struct{} + +var _ sdk.ResourceWithUpdate = NewRelicTagRuleResource{} + +func (r NewRelicTagRuleResource) ResourceType() string { + return "azurerm_new_relic_tag_rule" +} + +func (r NewRelicTagRuleResource) ModelObject() interface{} { + return &NewRelicTagRuleModel{} +} + +func (r NewRelicTagRuleResource) IDValidationFunc() pluginsdk.SchemaValidateFunc { + return tagrules.ValidateTagRuleID +} + +func (r NewRelicTagRuleResource) Arguments() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{ + "monitor_id": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: monitors.ValidateMonitorID, + }, + + "azure_active_directory_log_enabled": { + Type: pluginsdk.TypeBool, + Optional: true, + Default: false, + }, + + "activity_log_enabled": { + Type: pluginsdk.TypeBool, + Optional: true, + Default: false, + }, + + "log_tag_filter": { + Type: pluginsdk.TypeList, + Optional: true, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "action": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + string(tagrules.TagActionExclude), + string(tagrules.TagActionInclude), + }, false), + }, + + "value": { + Type: pluginsdk.TypeString, + Required: true, + }, + }, + }, + }, + + "metric_enabled": { + Type: pluginsdk.TypeBool, + Optional: true, + Default: false, + }, + + "metric_tag_filter": { + Type: pluginsdk.TypeList, + Optional: true, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "action": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + string(tagrules.TagActionExclude), + string(tagrules.TagActionInclude), + }, false), + }, + + "value": { + Type: pluginsdk.TypeString, + Required: true, + }, + }, + }, + }, + + "subscription_log_enabled": { + Type: pluginsdk.TypeBool, + Optional: true, + Default: false, + }, + } +} + +func (r NewRelicTagRuleResource) Attributes() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{} +} + +func (r NewRelicTagRuleResource) Create() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + var model NewRelicTagRuleModel + if err := metadata.Decode(&model); err != nil { + return fmt.Errorf("decoding: %+v", err) + } + + client := metadata.Client.NewRelic.TagRulesClient + monitorId, err := monitors.ParseMonitorID(model.NewRelicMonitorId) + if err != nil { + return err + } + + id := tagrules.NewTagRuleID(monitorId.SubscriptionId, monitorId.ResourceGroupName, monitorId.MonitorName, "default") + existing, err := client.Get(ctx, id) + if err != nil && !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("checking for existing %s: %+v", id, err) + } + + if !response.WasNotFound(existing.HttpResponse) { + return metadata.ResourceRequiresImport(r.ResourceType(), id) + } + + logRules := tagrules.LogRules{ + FilteringTags: expandFilteringTagModelArray(model.LogTagFilter), + SendAadLogs: pointer.To(tagrules.SendAadLogsStatusDisabled), + SendActivityLogs: pointer.To(tagrules.SendActivityLogsStatusDisabled), + SendSubscriptionLogs: pointer.To(tagrules.SendSubscriptionLogsStatusDisabled), + } + + email, err := r.getEmail(ctx, metadata.Client.NewRelic.MonitorsClient, monitorId) + if err != nil { + return err + } + + metricRules := tagrules.MetricRules{ + FilteringTags: expandFilteringTagModelArray(model.MetricTagFilter), + SendMetrics: pointer.To(tagrules.SendMetricsStatusDisabled), + UserEmail: &email, + } + + if model.AadLogEnabled { + logRules.SendAadLogs = pointer.To(tagrules.SendAadLogsStatusEnabled) + } + + if model.ActivityLogEnabled { + logRules.SendActivityLogs = pointer.To(tagrules.SendActivityLogsStatusEnabled) + } + + if model.SubscriptionLogEnabled { + logRules.SendSubscriptionLogs = pointer.To(tagrules.SendSubscriptionLogsStatusEnabled) + } + + if model.MetricEnabled { + metricRules.SendMetrics = pointer.To(tagrules.SendMetricsStatusEnabled) + } + + properties := &tagrules.TagRule{ + Properties: tagrules.MonitoringTagRulesProperties{ + LogRules: &logRules, + MetricRules: &metricRules, + }, + } + + if err := client.CreateOrUpdateThenPoll(ctx, id, *properties); err != nil { + return fmt.Errorf("creating %s: %+v", id, err) + } + + metadata.SetID(id) + return nil + }, + } +} + +func (r NewRelicTagRuleResource) Update() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.NewRelic.TagRulesClient + + id, err := tagrules.ParseTagRuleID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + resp, err := client.Get(ctx, *id) + if err != nil { + return fmt.Errorf("retrieving %s: %+v", *id, err) + } + + properties := resp.Model + if properties == nil { + return fmt.Errorf("retrieving %s: properties was nil", id) + } + + if properties.Properties.LogRules == nil { + return fmt.Errorf("retrieving %s: log rules was nil", id) + } + + if properties.Properties.MetricRules == nil { + return fmt.Errorf("retrieving %s: metric rules was nil", id) + } + + var model NewRelicTagRuleModel + if err := metadata.Decode(&model); err != nil { + return fmt.Errorf("decoding: %+v", err) + } + + monitorId, err := monitors.ParseMonitorID(model.NewRelicMonitorId) + if err != nil { + return err + } + + email, err := r.getEmail(ctx, metadata.Client.NewRelic.MonitorsClient, monitorId) + if err != nil { + return err + } + + properties.Properties.MetricRules.UserEmail = &email + + if metadata.ResourceData.HasChange("azure_active_directory_log_enabled") { + if model.AadLogEnabled { + properties.Properties.LogRules.SendAadLogs = pointer.To(tagrules.SendAadLogsStatusEnabled) + } else { + properties.Properties.LogRules.SendAadLogs = pointer.To(tagrules.SendAadLogsStatusDisabled) + } + } + + if metadata.ResourceData.HasChange("activity_log_enabled") { + if model.ActivityLogEnabled { + properties.Properties.LogRules.SendActivityLogs = pointer.To(tagrules.SendActivityLogsStatusEnabled) + } else { + properties.Properties.LogRules.SendActivityLogs = pointer.To(tagrules.SendActivityLogsStatusDisabled) + } + } + + if metadata.ResourceData.HasChange("log_tag_filter") { + properties.Properties.LogRules.FilteringTags = expandFilteringTagModelArray(model.LogTagFilter) + } + + if metadata.ResourceData.HasChange("metric_enabled") { + if model.MetricEnabled { + properties.Properties.MetricRules.SendMetrics = pointer.To(tagrules.SendMetricsStatusEnabled) + } else { + properties.Properties.MetricRules.SendMetrics = pointer.To(tagrules.SendMetricsStatusDisabled) + } + } + + if metadata.ResourceData.HasChange("metric_tag_filter") { + properties.Properties.MetricRules.FilteringTags = expandFilteringTagModelArray(model.MetricTagFilter) + } + + if metadata.ResourceData.HasChange("subscription_log_enabled") { + if model.SubscriptionLogEnabled { + properties.Properties.LogRules.SendSubscriptionLogs = pointer.To(tagrules.SendSubscriptionLogsStatusEnabled) + } else { + properties.Properties.LogRules.SendSubscriptionLogs = pointer.To(tagrules.SendSubscriptionLogsStatusDisabled) + } + } + + if err := client.CreateOrUpdateThenPoll(ctx, *id, *properties); err != nil { + return fmt.Errorf("updating %s: %+v", *id, err) + } + + return nil + }, + } +} + +func (r NewRelicTagRuleResource) Read() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 5 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.NewRelic.TagRulesClient + + id, err := tagrules.ParseTagRuleID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + resp, err := client.Get(ctx, *id) + if err != nil { + if response.WasNotFound(resp.HttpResponse) { + return metadata.MarkAsGone(id) + } + + return fmt.Errorf("retrieving %s: %+v", *id, err) + } + + state := NewRelicTagRuleModel{ + NewRelicMonitorId: monitors.NewMonitorID(id.SubscriptionId, id.ResourceGroupName, id.MonitorName).ID(), + } + + if model := resp.Model; model != nil { + properties := &model.Properties + if properties.LogRules != nil { + state.AadLogEnabled = properties.LogRules.SendAadLogs != nil && *properties.LogRules.SendAadLogs == tagrules.SendAadLogsStatusEnabled + state.ActivityLogEnabled = properties.LogRules.SendActivityLogs != nil && *properties.LogRules.SendActivityLogs == tagrules.SendActivityLogsStatusEnabled + state.LogTagFilter = flattenFilteringTagModelArray(properties.LogRules.FilteringTags) + state.SubscriptionLogEnabled = properties.LogRules.SendSubscriptionLogs != nil && *properties.LogRules.SendSubscriptionLogs == tagrules.SendSubscriptionLogsStatusEnabled + } + + if properties.MetricRules != nil { + state.MetricEnabled = properties.MetricRules.SendMetrics != nil && *properties.MetricRules.SendMetrics == tagrules.SendMetricsStatusEnabled + state.MetricTagFilter = flattenFilteringTagModelArray(properties.MetricRules.FilteringTags) + } + } + + return metadata.Encode(&state) + }, + } +} + +func (r NewRelicTagRuleResource) Delete() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.NewRelic.TagRulesClient + + id, err := tagrules.ParseTagRuleID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + if err := client.DeleteThenPoll(ctx, *id); err != nil { + return fmt.Errorf("deleting %s: %+v", id, err) + } + + return nil + }, + } +} + +func (r NewRelicTagRuleResource) getEmail(ctx context.Context, monitorClient *monitors.MonitorsClient, monitorId *monitors.MonitorId) (string, error) { + monitor, err := monitorClient.Get(ctx, *monitorId) + if err != nil { + return "", fmt.Errorf("getting monitor: %+v", err) + } + + if monitor.Model == nil || monitor.Model.Properties.UserInfo == nil || monitor.Model.Properties.UserInfo.EmailAddress == nil || *monitor.Model.Properties.UserInfo.EmailAddress == "" { + return "", fmt.Errorf("failed to get user email address from monitor") + } + + return *monitor.Model.Properties.UserInfo.EmailAddress, nil +} + +func expandFilteringTagModelArray(inputList []FilteringTagModel) *[]tagrules.FilteringTag { + var outputList []tagrules.FilteringTag + for _, v := range inputList { + input := v + output := tagrules.FilteringTag{ + Action: &input.Action, + } + + if input.Name != "" { + output.Name = &input.Name + } + + if input.Value != "" { + output.Value = &input.Value + } + outputList = append(outputList, output) + } + return &outputList +} + +func flattenFilteringTagModelArray(inputList *[]tagrules.FilteringTag) []FilteringTagModel { + outputList := make([]FilteringTagModel, 0) + if inputList == nil { + return outputList + } + + for _, input := range *inputList { + outputList = append(outputList, FilteringTagModel{ + Action: pointer.From(input.Action), + Name: pointer.From(input.Name), + Value: pointer.From(input.Value), + }) + } + + return outputList +} diff --git a/internal/services/newrelic/new_relic_tag_rule_resource_test.go b/internal/services/newrelic/new_relic_tag_rule_resource_test.go new file mode 100644 index 0000000000000..84911ca81f953 --- /dev/null +++ b/internal/services/newrelic/new_relic_tag_rule_resource_test.go @@ -0,0 +1,243 @@ +package newrelic_test + +import ( + "context" + "fmt" + "testing" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" + "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/utils" +) + +type NewRelicTagRuleResource struct{} + +func TestAccNewRelicTagRule_basic(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_new_relic_tag_rule", "test") + r := NewRelicTagRuleResource{} + email := "27362230-e2d8-4c73-9ee3-fdef83459ca3@example.com" + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data, email), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + +func TestAccNewRelicTagRule_requiresImport(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_new_relic_tag_rule", "test") + r := NewRelicTagRuleResource{} + email := "85b5febd-127d-4633-9c25-bcfea555af46@example.com" + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data, email), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + { + Config: r.requiresImport(data, email), + ExpectError: acceptance.RequiresImportError(data.ResourceType), + }, + }) +} + +func TestAccNewRelicTagRule_complete(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_new_relic_tag_rule", "test") + r := NewRelicTagRuleResource{} + email := "672d9312-65a7-484c-870d-94584850a423@example.com" + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.complete(data, email), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + +func TestAccNewRelicTagRule_update(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_new_relic_tag_rule", "test") + r := NewRelicTagRuleResource{} + email := "f0ff47c3-3aed-45b0-b239-260d9625045a@example.com" + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.complete(data, email), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + { + Config: r.update(data, email), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + +func (r NewRelicTagRuleResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { + id, err := tagrules.ParseTagRuleID(state.ID) + if err != nil { + return nil, err + } + + client := clients.NewRelic.TagRulesClient + resp, err := client.Get(ctx, *id) + if err != nil { + if response.WasNotFound(resp.HttpResponse) { + return utils.Bool(false), nil + } + return nil, fmt.Errorf("retrieving %s: %+v", id, err) + } + return utils.Bool(resp.Model != nil), nil +} + +func (r NewRelicTagRuleResource) template(data acceptance.TestData, email string) string { + year, month, day := time.Now().Add(time.Hour * 72).Date() + effectiveDate := time.Date(year, month, day, 0, 0, 0, 0, time.UTC).Format(time.RFC3339) + + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctest-rg-%[1]d" + location = "%[2]s" +} + +resource "azurerm_new_relic_monitor" "test" { + name = "acctest-nrm-%[1]d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + + plan { + effective_date = "%[3]s" + } + + user { + email = "%[4]s" + first_name = "first" + last_name = "last" + phone_number = "123456" + } +} +`, data.RandomInteger, data.Locations.Primary, effectiveDate, email) +} + +func (r NewRelicTagRuleResource) basic(data acceptance.TestData, email string) string { + template := r.template(data, email) + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + %s + +resource "azurerm_new_relic_tag_rule" "test" { + monitor_id = azurerm_new_relic_monitor.test.id +} +`, template) +} + +func (r NewRelicTagRuleResource) requiresImport(data acceptance.TestData, email string) string { + config := r.basic(data, email) + return fmt.Sprintf(` + %s + +resource "azurerm_new_relic_tag_rule" "import" { + monitor_id = azurerm_new_relic_tag_rule.test.monitor_id +} +`, config) +} + +func (r NewRelicTagRuleResource) complete(data acceptance.TestData, email string) string { + template := r.template(data, email) + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + %s + +resource "azurerm_new_relic_tag_rule" "test" { + monitor_id = azurerm_new_relic_monitor.test.id + azure_active_directory_log_enabled = true + activity_log_enabled = true + metric_enabled = true + subscription_log_enabled = true + + log_tag_filter { + name = "log1" + action = "Include" + value = "log1" + } + + log_tag_filter { + name = "log2" + action = "Exclude" + value = "" + } + + metric_tag_filter { + name = "metric1" + action = "Include" + value = "metric1" + } + + metric_tag_filter { + name = "metric2" + action = "Exclude" + value = "" + } +} +`, template) +} + +func (r NewRelicTagRuleResource) update(data acceptance.TestData, email string) string { + template := r.template(data, email) + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + %s + +resource "azurerm_new_relic_tag_rule" "test" { + monitor_id = azurerm_new_relic_monitor.test.id + azure_active_directory_log_enabled = false + activity_log_enabled = false + metric_enabled = false + subscription_log_enabled = false + + log_tag_filter { + name = "log2" + action = "Exclude" + value = "" + } + + log_tag_filter { + name = "log1" + action = "Include" + value = "log1" + } + + metric_tag_filter { + name = "metric1" + action = "Exclude" + value = "" + } + + metric_tag_filter { + name = "metric2" + action = "Include" + value = "metric1" + } +} +`, template) +} diff --git a/internal/services/newrelic/registration.go b/internal/services/newrelic/registration.go index 46b5bb9cd8d67..824a2f9f343a5 100644 --- a/internal/services/newrelic/registration.go +++ b/internal/services/newrelic/registration.go @@ -27,6 +27,7 @@ func (r Registration) DataSources() []sdk.DataSource { func (r Registration) Resources() []sdk.Resource { return []sdk.Resource{ NewRelicMonitorResource{}, + NewRelicTagRuleResource{}, } } diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/README.md new file mode 100644 index 0000000000000..0691d3a676450 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/README.md @@ -0,0 +1,103 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules` Documentation + +The `tagrules` SDK allows for interaction with the Azure Resource Manager Service `newrelic` (API Version `2022-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules" +``` + + +### Client Initialization + +```go +client := tagrules.NewTagRulesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `TagRulesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := tagrules.NewTagRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorValue", "tagRuleValue") + +payload := tagrules.TagRule{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `TagRulesClient.Delete` + +```go +ctx := context.TODO() +id := tagrules.NewTagRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorValue", "tagRuleValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `TagRulesClient.Get` + +```go +ctx := context.TODO() +id := tagrules.NewTagRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorValue", "tagRuleValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `TagRulesClient.ListByNewRelicMonitorResource` + +```go +ctx := context.TODO() +id := tagrules.NewMonitorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorValue") + +// alternatively `client.ListByNewRelicMonitorResource(ctx, id)` can be used to do batched pagination +items, err := client.ListByNewRelicMonitorResourceComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `TagRulesClient.Update` + +```go +ctx := context.TODO() +id := tagrules.NewTagRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorValue", "tagRuleValue") + +payload := tagrules.TagRuleUpdate{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/client.go new file mode 100644 index 0000000000000..e35a62f311620 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/client.go @@ -0,0 +1,26 @@ +package tagrules + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagRulesClient struct { + Client *resourcemanager.Client +} + +func NewTagRulesClientWithBaseURI(sdkApi sdkEnv.Api) (*TagRulesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "tagrules", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating TagRulesClient: %+v", err) + } + + return &TagRulesClient{ + Client: client, + }, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/constants.go new file mode 100644 index 0000000000000..c8fd2d9e8a4ae --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/constants.go @@ -0,0 +1,277 @@ +package tagrules + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleted ProvisioningState = "Deleted" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateNotSpecified ProvisioningState = "NotSpecified" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateCreating), + string(ProvisioningStateDeleted), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateNotSpecified), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "creating": ProvisioningStateCreating, + "deleted": ProvisioningStateDeleted, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "notspecified": ProvisioningStateNotSpecified, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type SendAadLogsStatus string + +const ( + SendAadLogsStatusDisabled SendAadLogsStatus = "Disabled" + SendAadLogsStatusEnabled SendAadLogsStatus = "Enabled" +) + +func PossibleValuesForSendAadLogsStatus() []string { + return []string{ + string(SendAadLogsStatusDisabled), + string(SendAadLogsStatusEnabled), + } +} + +func (s *SendAadLogsStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSendAadLogsStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSendAadLogsStatus(input string) (*SendAadLogsStatus, error) { + vals := map[string]SendAadLogsStatus{ + "disabled": SendAadLogsStatusDisabled, + "enabled": SendAadLogsStatusEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SendAadLogsStatus(input) + return &out, nil +} + +type SendActivityLogsStatus string + +const ( + SendActivityLogsStatusDisabled SendActivityLogsStatus = "Disabled" + SendActivityLogsStatusEnabled SendActivityLogsStatus = "Enabled" +) + +func PossibleValuesForSendActivityLogsStatus() []string { + return []string{ + string(SendActivityLogsStatusDisabled), + string(SendActivityLogsStatusEnabled), + } +} + +func (s *SendActivityLogsStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSendActivityLogsStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSendActivityLogsStatus(input string) (*SendActivityLogsStatus, error) { + vals := map[string]SendActivityLogsStatus{ + "disabled": SendActivityLogsStatusDisabled, + "enabled": SendActivityLogsStatusEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SendActivityLogsStatus(input) + return &out, nil +} + +type SendMetricsStatus string + +const ( + SendMetricsStatusDisabled SendMetricsStatus = "Disabled" + SendMetricsStatusEnabled SendMetricsStatus = "Enabled" +) + +func PossibleValuesForSendMetricsStatus() []string { + return []string{ + string(SendMetricsStatusDisabled), + string(SendMetricsStatusEnabled), + } +} + +func (s *SendMetricsStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSendMetricsStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSendMetricsStatus(input string) (*SendMetricsStatus, error) { + vals := map[string]SendMetricsStatus{ + "disabled": SendMetricsStatusDisabled, + "enabled": SendMetricsStatusEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SendMetricsStatus(input) + return &out, nil +} + +type SendSubscriptionLogsStatus string + +const ( + SendSubscriptionLogsStatusDisabled SendSubscriptionLogsStatus = "Disabled" + SendSubscriptionLogsStatusEnabled SendSubscriptionLogsStatus = "Enabled" +) + +func PossibleValuesForSendSubscriptionLogsStatus() []string { + return []string{ + string(SendSubscriptionLogsStatusDisabled), + string(SendSubscriptionLogsStatusEnabled), + } +} + +func (s *SendSubscriptionLogsStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSendSubscriptionLogsStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSendSubscriptionLogsStatus(input string) (*SendSubscriptionLogsStatus, error) { + vals := map[string]SendSubscriptionLogsStatus{ + "disabled": SendSubscriptionLogsStatusDisabled, + "enabled": SendSubscriptionLogsStatusEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SendSubscriptionLogsStatus(input) + return &out, nil +} + +type TagAction string + +const ( + TagActionExclude TagAction = "Exclude" + TagActionInclude TagAction = "Include" +) + +func PossibleValuesForTagAction() []string { + return []string{ + string(TagActionExclude), + string(TagActionInclude), + } +} + +func (s *TagAction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTagAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTagAction(input string) (*TagAction, error) { + vals := map[string]TagAction{ + "exclude": TagActionExclude, + "include": TagActionInclude, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TagAction(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/id_monitor.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/id_monitor.go new file mode 100644 index 0000000000000..91def2f39e15c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/id_monitor.go @@ -0,0 +1,127 @@ +package tagrules + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = MonitorId{} + +// MonitorId is a struct representing the Resource ID for a Monitor +type MonitorId struct { + SubscriptionId string + ResourceGroupName string + MonitorName string +} + +// NewMonitorID returns a new MonitorId struct +func NewMonitorID(subscriptionId string, resourceGroupName string, monitorName string) MonitorId { + return MonitorId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + MonitorName: monitorName, + } +} + +// ParseMonitorID parses 'input' into a MonitorId +func ParseMonitorID(input string) (*MonitorId, error) { + parser := resourceids.NewParserFromResourceIdType(MonitorId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := MonitorId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", *parsed) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", *parsed) + } + + if id.MonitorName, ok = parsed.Parsed["monitorName"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "monitorName", *parsed) + } + + return &id, nil +} + +// ParseMonitorIDInsensitively parses 'input' case-insensitively into a MonitorId +// note: this method should only be used for API response data and not user input +func ParseMonitorIDInsensitively(input string) (*MonitorId, error) { + parser := resourceids.NewParserFromResourceIdType(MonitorId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := MonitorId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", *parsed) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", *parsed) + } + + if id.MonitorName, ok = parsed.Parsed["monitorName"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "monitorName", *parsed) + } + + return &id, nil +} + +// ValidateMonitorID checks that 'input' can be parsed as a Monitor ID +func ValidateMonitorID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseMonitorID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Monitor ID +func (id MonitorId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/NewRelic.Observability/monitors/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.MonitorName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Monitor ID +func (id MonitorId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticNewRelicObservability", "NewRelic.Observability", "NewRelic.Observability"), + resourceids.StaticSegment("staticMonitors", "monitors", "monitors"), + resourceids.UserSpecifiedSegment("monitorName", "monitorValue"), + } +} + +// String returns a human-readable description of this Monitor ID +func (id MonitorId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Monitor Name: %q", id.MonitorName), + } + return fmt.Sprintf("Monitor (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/id_tagrule.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/id_tagrule.go new file mode 100644 index 0000000000000..0f89ab5c649b4 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/id_tagrule.go @@ -0,0 +1,140 @@ +package tagrules + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = TagRuleId{} + +// TagRuleId is a struct representing the Resource ID for a Tag Rule +type TagRuleId struct { + SubscriptionId string + ResourceGroupName string + MonitorName string + TagRuleName string +} + +// NewTagRuleID returns a new TagRuleId struct +func NewTagRuleID(subscriptionId string, resourceGroupName string, monitorName string, tagRuleName string) TagRuleId { + return TagRuleId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + MonitorName: monitorName, + TagRuleName: tagRuleName, + } +} + +// ParseTagRuleID parses 'input' into a TagRuleId +func ParseTagRuleID(input string) (*TagRuleId, error) { + parser := resourceids.NewParserFromResourceIdType(TagRuleId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := TagRuleId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", *parsed) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", *parsed) + } + + if id.MonitorName, ok = parsed.Parsed["monitorName"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "monitorName", *parsed) + } + + if id.TagRuleName, ok = parsed.Parsed["tagRuleName"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "tagRuleName", *parsed) + } + + return &id, nil +} + +// ParseTagRuleIDInsensitively parses 'input' case-insensitively into a TagRuleId +// note: this method should only be used for API response data and not user input +func ParseTagRuleIDInsensitively(input string) (*TagRuleId, error) { + parser := resourceids.NewParserFromResourceIdType(TagRuleId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := TagRuleId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", *parsed) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", *parsed) + } + + if id.MonitorName, ok = parsed.Parsed["monitorName"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "monitorName", *parsed) + } + + if id.TagRuleName, ok = parsed.Parsed["tagRuleName"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "tagRuleName", *parsed) + } + + return &id, nil +} + +// ValidateTagRuleID checks that 'input' can be parsed as a Tag Rule ID +func ValidateTagRuleID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseTagRuleID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Tag Rule ID +func (id TagRuleId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/NewRelic.Observability/monitors/%s/tagRules/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.MonitorName, id.TagRuleName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Tag Rule ID +func (id TagRuleId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticNewRelicObservability", "NewRelic.Observability", "NewRelic.Observability"), + resourceids.StaticSegment("staticMonitors", "monitors", "monitors"), + resourceids.UserSpecifiedSegment("monitorName", "monitorValue"), + resourceids.StaticSegment("staticTagRules", "tagRules", "tagRules"), + resourceids.UserSpecifiedSegment("tagRuleName", "tagRuleValue"), + } +} + +// String returns a human-readable description of this Tag Rule ID +func (id TagRuleId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Monitor Name: %q", id.MonitorName), + fmt.Sprintf("Tag Rule Name: %q", id.TagRuleName), + } + return fmt.Sprintf("Tag Rule (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/method_createorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/method_createorupdate.go new file mode 100644 index 0000000000000..0a114c6602f57 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/method_createorupdate.go @@ -0,0 +1,74 @@ +package tagrules + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CreateOrUpdate ... +func (c TagRulesClient) CreateOrUpdate(ctx context.Context, id TagRuleId, input TagRule) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c TagRulesClient) CreateOrUpdateThenPoll(ctx context.Context, id TagRuleId, input TagRule) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/method_delete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/method_delete.go new file mode 100644 index 0000000000000..4161493d1b977 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/method_delete.go @@ -0,0 +1,71 @@ +package tagrules + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c TagRulesClient) Delete(ctx context.Context, id TagRuleId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c TagRulesClient) DeleteThenPoll(ctx context.Context, id TagRuleId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/method_get.go new file mode 100644 index 0000000000000..48b6368423a09 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/method_get.go @@ -0,0 +1,51 @@ +package tagrules + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TagRule +} + +// Get ... +func (c TagRulesClient) Get(ctx context.Context, id TagRuleId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/method_listbynewrelicmonitorresource.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/method_listbynewrelicmonitorresource.go new file mode 100644 index 0000000000000..f785b30da5b7c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/method_listbynewrelicmonitorresource.go @@ -0,0 +1,89 @@ +package tagrules + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByNewRelicMonitorResourceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TagRule +} + +type ListByNewRelicMonitorResourceCompleteResult struct { + Items []TagRule +} + +// ListByNewRelicMonitorResource ... +func (c TagRulesClient) ListByNewRelicMonitorResource(ctx context.Context, id MonitorId) (result ListByNewRelicMonitorResourceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/tagRules", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]TagRule `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByNewRelicMonitorResourceComplete retrieves all the results into a single object +func (c TagRulesClient) ListByNewRelicMonitorResourceComplete(ctx context.Context, id MonitorId) (ListByNewRelicMonitorResourceCompleteResult, error) { + return c.ListByNewRelicMonitorResourceCompleteMatchingPredicate(ctx, id, TagRuleOperationPredicate{}) +} + +// ListByNewRelicMonitorResourceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c TagRulesClient) ListByNewRelicMonitorResourceCompleteMatchingPredicate(ctx context.Context, id MonitorId, predicate TagRuleOperationPredicate) (result ListByNewRelicMonitorResourceCompleteResult, err error) { + items := make([]TagRule, 0) + + resp, err := c.ListByNewRelicMonitorResource(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByNewRelicMonitorResourceCompleteResult{ + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/method_update.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/method_update.go new file mode 100644 index 0000000000000..5f8ada856f1b9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/method_update.go @@ -0,0 +1,55 @@ +package tagrules + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TagRule +} + +// Update ... +func (c TagRulesClient) Update(ctx context.Context, id TagRuleId, input TagRuleUpdate) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/model_filteringtag.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/model_filteringtag.go new file mode 100644 index 0000000000000..13b1c7f0b877f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/model_filteringtag.go @@ -0,0 +1,10 @@ +package tagrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FilteringTag struct { + Action *TagAction `json:"action,omitempty"` + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/model_logrules.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/model_logrules.go new file mode 100644 index 0000000000000..1bd42a848b5be --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/model_logrules.go @@ -0,0 +1,11 @@ +package tagrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LogRules struct { + FilteringTags *[]FilteringTag `json:"filteringTags,omitempty"` + SendAadLogs *SendAadLogsStatus `json:"sendAadLogs,omitempty"` + SendActivityLogs *SendActivityLogsStatus `json:"sendActivityLogs,omitempty"` + SendSubscriptionLogs *SendSubscriptionLogsStatus `json:"sendSubscriptionLogs,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/model_metricrules.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/model_metricrules.go new file mode 100644 index 0000000000000..75e75e9aeb192 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/model_metricrules.go @@ -0,0 +1,10 @@ +package tagrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MetricRules struct { + FilteringTags *[]FilteringTag `json:"filteringTags,omitempty"` + SendMetrics *SendMetricsStatus `json:"sendMetrics,omitempty"` + UserEmail *string `json:"userEmail,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/model_monitoringtagrulesproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/model_monitoringtagrulesproperties.go new file mode 100644 index 0000000000000..8900c72ac040c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/model_monitoringtagrulesproperties.go @@ -0,0 +1,10 @@ +package tagrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MonitoringTagRulesProperties struct { + LogRules *LogRules `json:"logRules,omitempty"` + MetricRules *MetricRules `json:"metricRules,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/model_tagrule.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/model_tagrule.go new file mode 100644 index 0000000000000..be251a10a4d2c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/model_tagrule.go @@ -0,0 +1,16 @@ +package tagrules + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagRule struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties MonitoringTagRulesProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/model_tagruleupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/model_tagruleupdate.go new file mode 100644 index 0000000000000..75517f3f96d2c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/model_tagruleupdate.go @@ -0,0 +1,8 @@ +package tagrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagRuleUpdate struct { + Properties *TagRuleUpdateProperties `json:"properties,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/model_tagruleupdateproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/model_tagruleupdateproperties.go new file mode 100644 index 0000000000000..57895124c7556 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/model_tagruleupdateproperties.go @@ -0,0 +1,9 @@ +package tagrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagRuleUpdateProperties struct { + LogRules *LogRules `json:"logRules,omitempty"` + MetricRules *MetricRules `json:"metricRules,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/predicates.go new file mode 100644 index 0000000000000..b8e7c533c9f0e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/predicates.go @@ -0,0 +1,27 @@ +package tagrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagRuleOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p TagRuleOperationPredicate) Matches(input TagRule) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/version.go new file mode 100644 index 0000000000000..c7df0f2437ea6 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules/version.go @@ -0,0 +1,12 @@ +package tagrules + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2022-07-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/tagrules/%s", defaultApiVersion) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 596706960dff6..354c5ccb22562 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -737,6 +737,7 @@ github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-04-01/webapplica github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-04-01/webcategories github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/monitors +github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/tagrules github.com/hashicorp/go-azure-sdk/resource-manager/nginx/2022-08-01 github.com/hashicorp/go-azure-sdk/resource-manager/nginx/2022-08-01/nginxcertificate github.com/hashicorp/go-azure-sdk/resource-manager/nginx/2022-08-01/nginxconfiguration diff --git a/website/docs/d/eventgrid_domain.html.markdown b/website/docs/d/eventgrid_domain.html.markdown index 08bd714a9ff0c..d1aac45cb5262 100644 --- a/website/docs/d/eventgrid_domain.html.markdown +++ b/website/docs/d/eventgrid_domain.html.markdown @@ -58,6 +58,8 @@ The following attributes are exported: * `tags` - A mapping of tags assigned to the EventGrid Domain. +* `identity` - An `identity` block as documented below. + --- A `input_mapping_fields` supports the following: @@ -92,6 +94,18 @@ A `inbound_ip_rule` block supports the following: * `action` - The action to take when the rule is matched. Possible values are `Allow`. +--- + +An `identity` block exports the following: + +* `type` - The type of Managed Service Identity that is configured on this EventGrid Domain. + +* `principal_id` - The Principal ID of the System Assigned Managed Service Identity. + +* `tenant_id` - The Tenant ID of the System Assigned Managed Service Identity. + +* `identity_ids` - The list of User Assigned Managed Identity IDs assigned to this EventGrid Domain. + ## Timeouts The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/language/resources/syntax#operation-timeouts) for certain actions: diff --git a/website/docs/r/new_relic_tag_rule.html.markdown b/website/docs/r/new_relic_tag_rule.html.markdown new file mode 100644 index 0000000000000..4c8583ab6dd52 --- /dev/null +++ b/website/docs/r/new_relic_tag_rule.html.markdown @@ -0,0 +1,118 @@ +--- +subcategory: "New Relic" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_new_relic_tag_rule" +description: |- + Manages an Azure Native New Relic Tag Rule. +--- + +# azurerm_new_relic_tag_rule + +Manages an Azure Native New Relic Tag Rule. + +## Example Usage + +```hcl +resource "azurerm_resource_group" "example" { + name = "example-resources" + location = "East US" +} + +resource "azurerm_new_relic_monitor" "example" { + name = "example-nrm" + resource_group_name = azurerm_resource_group.example.name + location = azurerm_resource_group.example.location + + plan { + effective_date = "2023-06-06T00:00:00Z" + } + + user { + email = "user@example.com" + first_name = "Example" + last_name = "User" + phone_number = "+12313803556" + } +} + +resource "azurerm_new_relic_tag_rule" "example" { + monitor_id = azurerm_new_relic_monitor.example.id + azure_active_directory_log_enabled = true + activity_log_enabled = true + metric_enabled = true + subscription_log_enabled = true + + log_tag_filter { + name = "key" + action = "Include" + value = "value" + } + + metric_tag_filter { + name = "key" + action = "Exclude" + value = "value" + } +} +``` + +## Arguments Reference + +The following arguments are supported: + +* `monitor_id` - (Required) Specifies the ID of the New Relic Monitor this Tag Rule should be created within. Changing this forces a new Azure Native New Relic Tag Rule to be created. + +* `azure_active_directory_log_enabled` - (Optional) Whether Azure Active Directory logs should be sent for the Monitor resource. Defaults to `false`. + +* `activity_log_enabled` - (Optional) Whether activity logs from Azure resources should be sent for the Monitor resource. Defaults to `false`. + +* `log_tag_filter` - (Optional) A `log_tag_filter` block as defined below. + +* `metric_enabled` - (Optional) Whether metrics should be sent for the Monitor resource. Defaults to `false`. + +* `metric_tag_filter` - (Optional) A `metric_tag_filter` block as defined below. + +* `subscription_log_enabled` - (Optional) Whether subscription logs should be sent for the Monitor resource. Defaults to `false`. + +--- + +A `log_tag_filter` block supports the following: + +* `name` - (Required) Specifies the name (also known as the key) of the tag. + +* `action` - (Required) Valid actions for a filtering tag. Possible values are `Exclude` and `Include`. Exclusion takes priority over inclusion. + +* `value` - (Required) Specifies the value of the tag. + +--- + +A `metric_tag_filter` block supports the following: + +* `name` - (Required) Specifies the name (also known as the key) of the tag. + +* `action` - (Required) Valid actions for a filtering tag. Possible values are `Exclude` and `Include`. Exclusion takes priority over inclusion. + +* `value` - (Required) Specifies the value of the tag. + +## Attributes Reference + +In addition to the Arguments listed above - the following Attributes are exported: + +* `id` - The ID of the Azure Native New Relic Tag Rule. + +## Timeouts + +The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: + +* `create` - (Defaults to 30 minutes) Used when creating the Azure Native New Relic Tag Rule. +* `read` - (Defaults to 5 minutes) Used when retrieving the Azure Native New Relic Tag Rule. +* `update` - (Defaults to 30 minutes) Used when updating the Azure Native New Relic Tag Rule. +* `delete` - (Defaults to 30 minutes) Used when deleting the Azure Native New Relic Tag Rule. + +## Import + +Azure Native New Relic Tag Rule can be imported using the `resource id`, e.g. + +```shell +terraform import azurerm_new_relic_tag_rule.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/NewRelic.Observability/monitors/monitor1/tagRules/ruleSet1 +```