Skip to content

Commit

Permalink
sentinel/automation_rule: switching to use github.com/hashicorp/go-az…
Browse files Browse the repository at this point in the history
…ure-sdk (#20726)
  • Loading branch information
mbfrahry authored Mar 3, 2023
1 parent b3c92a5 commit 9359077
Show file tree
Hide file tree
Showing 37 changed files with 2,515 additions and 268 deletions.
5 changes: 3 additions & 2 deletions internal/services/sentinel/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package client
import (
alertruletemplates "github.com/Azure/azure-sdk-for-go/services/preview/securityinsight/mgmt/2021-09-01-preview/securityinsight" // nolint: staticcheck
"github.com/hashicorp/go-azure-sdk/resource-manager/securityinsights/2022-10-01-preview/alertrules"
"github.com/hashicorp/go-azure-sdk/resource-manager/securityinsights/2022-10-01-preview/automationrules"
"github.com/hashicorp/go-azure-sdk/resource-manager/securityinsights/2022-11-01/sentinelonboardingstates"
"github.com/hashicorp/terraform-provider-azurerm/internal/common"
securityinsight "github.com/tombuildsstuff/kermit/sdk/securityinsights/2022-10-01-preview/securityinsights"
Expand All @@ -11,7 +12,7 @@ import (
type Client struct {
AlertRulesClient *alertrules.AlertRulesClient
AlertRuleTemplatesClient *alertruletemplates.AlertRuleTemplatesClient
AutomationRulesClient *securityinsight.AutomationRulesClient
AutomationRulesClient *automationrules.AutomationRulesClient
DataConnectorsClient *securityinsight.DataConnectorsClient
WatchlistsClient *securityinsight.WatchlistsClient
WatchlistItemsClient *securityinsight.WatchlistItemsClient
Expand All @@ -26,7 +27,7 @@ func NewClient(o *common.ClientOptions) *Client {
alertRuleTemplatesClient := alertruletemplates.NewAlertRuleTemplatesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&alertRuleTemplatesClient.Client, o.ResourceManagerAuthorizer)

automationRulesClient := securityinsight.NewAutomationRulesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
automationRulesClient := automationrules.NewAutomationRulesClientWithBaseURI(o.ResourceManagerEndpoint)
o.ConfigureClient(&automationRulesClient.Client, o.ResourceManagerAuthorizer)

dataConnectorsClient := securityinsight.NewDataConnectorsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
Expand Down
409 changes: 148 additions & 261 deletions internal/services/sentinel/sentinel_automation_rule_resource.go

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ import (
"time"

"github.com/google/uuid"
"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-sdk/resource-manager/securityinsights/2022-10-01-preview/automationrules"
"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/services/sentinel/parse"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/utils"
)
Expand All @@ -36,7 +37,7 @@ func TestAccSentinelAutomationRule_basic(t *testing.T) {
})
}

func TestAccSentinelAutomationRule_completeDperecatedCondition(t *testing.T) {
func TestAccSentinelAutomationRule_completeDeprecatedCondition(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_sentinel_automation_rule", "test")
r := SentinelAutomationRuleResource{uuid: uuid.New().String()}

Expand Down Expand Up @@ -153,13 +154,13 @@ func TestAccSentinelAutomationRule_requiresImport(t *testing.T) {
func (r SentinelAutomationRuleResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) {
client := clients.Sentinel.AutomationRulesClient

id, err := parse.AutomationRuleID(state.ID)
id, err := automationrules.ParseAutomationRuleID(state.ID)
if err != nil {
return nil, err
}

if resp, err := client.Get(ctx, id.ResourceGroup, id.WorkspaceName, id.Name); err != nil {
if utils.ResponseWasNotFound(resp.Response) {
if resp, err := client.Get(ctx, *id); err != nil {
if response.WasNotFound(resp.HttpResponse) {
return utils.Bool(false), nil
}
return nil, fmt.Errorf("retrieving %s: %+v", id, err)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9359077

Please sign in to comment.