Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
154 changes: 82 additions & 72 deletions internal/services/automation/automation_runbook_resource.go

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"fmt"
"testing"

"github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook"
"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/automation/parse"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/utils"
)
Expand Down Expand Up @@ -145,17 +145,17 @@ func TestAccAutomationRunbook_withJobSchedule(t *testing.T) {
}

func (t AutomationRunbookResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) {
id, err := parse.RunbookID(state.ID)
id, err := runbook.ParseRunbookID(state.ID)
if err != nil {
return nil, err
}

resp, err := clients.Automation.RunbookClient.Get(ctx, id.ResourceGroup, id.AutomationAccountName, id.Name)
resp, err := clients.Automation.RunbookClient.Get(ctx, *id)
if err != nil {
return nil, fmt.Errorf("retrieving Automation Runbook '%s' (resource group: '%s') does not exist", id.Name, id.ResourceGroup)
return nil, fmt.Errorf("retrieving Automation Runbook '%s' (resource group: '%s') does not exist", id.RunbookName, id.ResourceGroupName)
}

return utils.Bool(resp.RunbookProperties != nil), nil
return utils.Bool(resp.Model != nil), nil
}

func (AutomationRunbookResource) PSWorkflow(data acceptance.TestData) string {
Expand Down
10 changes: 8 additions & 2 deletions internal/services/automation/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package client

import (
"github.com/Azure/azure-sdk-for-go/services/preview/automation/mgmt/2020-01-13-preview/automation"
"github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook"
"github.com/hashicorp/go-azure-sdk/resource-manager/automation/2021-06-22/automationaccount"
"github.com/hashicorp/go-azure-sdk/resource-manager/automation/2021-06-22/hybridrunbookworker"
"github.com/hashicorp/go-azure-sdk/resource-manager/automation/2021-06-22/hybridrunbookworkergroup"
Expand All @@ -19,7 +20,8 @@ type Client struct {
DscNodeConfigurationClient *automation.DscNodeConfigurationClient
JobScheduleClient *automation.JobScheduleClient
ModuleClient *automation.ModuleClient
RunbookClient *automation.RunbookClient
RunbookClient *runbook.RunbookClient
RunbookClientHack *automation.RunbookClient
RunbookDraftClient *automation.RunbookDraftClient
RunBookWgClient *hybridrunbookworkergroup.HybridRunbookWorkerGroupClient
RunbookWorkerClient *hybridrunbookworker.HybridRunbookWorkerClient
Expand Down Expand Up @@ -62,7 +64,10 @@ func NewClient(o *common.ClientOptions) *Client {
moduleClient := automation.NewModuleClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&moduleClient.Client, o.ResourceManagerAuthorizer)

runbookClient := automation.NewRunbookClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
runbookClient2 := automation.NewRunbookClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&runbookClient2.Client, o.ResourceManagerAuthorizer)

runbookClient := runbook.NewRunbookClientWithBaseURI(o.ResourceManagerEndpoint)
o.ConfigureClient(&runbookClient.Client, o.ResourceManagerAuthorizer)

runbookDraftClient := automation.NewRunbookDraftClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
Expand Down Expand Up @@ -104,6 +109,7 @@ func NewClient(o *common.ClientOptions) *Client {
JobScheduleClient: &jobScheduleClient,
ModuleClient: &moduleClient,
RunbookClient: &runbookClient,
RunbookClientHack: &runbookClient2,
RunbookDraftClient: &runbookDraftClient,
RunBookWgClient: &runbookWgClient,
RunbookWorkerClient: &runbookWorkerClient,
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.

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

Loading