diff --git a/internal/services/automation/automation_runbook_resource.go b/internal/services/automation/automation_runbook_resource.go index b1a5cbbc4bad..053c0309e026 100644 --- a/internal/services/automation/automation_runbook_resource.go +++ b/internal/services/automation/automation_runbook_resource.go @@ -9,6 +9,8 @@ import ( "github.com/Azure/azure-sdk-for-go/services/preview/automation/mgmt/2020-01-13-preview/automation" "github.com/gofrs/uuid" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" @@ -117,12 +119,12 @@ func resourceAutomationRunbook() *pluginsdk.Resource { Required: true, ForceNew: true, ValidateFunc: validation.StringInSlice([]string{ - string(automation.RunbookTypeEnumGraph), - string(automation.RunbookTypeEnumGraphPowerShell), - string(automation.RunbookTypeEnumGraphPowerShellWorkflow), - string(automation.RunbookTypeEnumPowerShell), - string(automation.RunbookTypeEnumPowerShellWorkflow), - string(automation.RunbookTypeEnumScript), + string(runbook.RunbookTypeEnumGraph), + string(runbook.RunbookTypeEnumGraphPowerShell), + string(runbook.RunbookTypeEnumGraphPowerShellWorkflow), + string(runbook.RunbookTypeEnumPowerShell), + string(runbook.RunbookTypeEnumPowerShellWorkflow), + string(runbook.RunbookTypeEnumScript), }, false), }, @@ -238,24 +240,26 @@ func resourceAutomationRunbook() *pluginsdk.Resource { } func resourceAutomationRunbookCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Automation.RunbookClient - jsClient := meta.(*clients.Client).Automation.JobScheduleClient + autoCli := meta.(*clients.Client).Automation + client := autoCli.RunbookClient + jsClient := autoCli.JobScheduleClient ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) defer cancel() log.Printf("[INFO] preparing arguments for AzureRM Automation Runbook creation.") + subscriptionID := meta.(*clients.Client).Account.SubscriptionId - id := parse.NewRunbookID(client.SubscriptionID, d.Get("resource_group_name").(string), d.Get("automation_account_name").(string), d.Get("name").(string)) + id := runbook.NewRunbookID(subscriptionID, d.Get("resource_group_name").(string), d.Get("automation_account_name").(string), d.Get("name").(string)) if d.IsNewResource() { - existing, err := client.Get(ctx, id.ResourceGroup, id.AutomationAccountName, id.Name) + existing, err := client.Get(ctx, id) if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { + if !response.WasNotFound(existing.HttpResponse) { return fmt.Errorf("checking for presence of existing %s: %s", id, err) } } - if !utils.ResponseWasNotFound(existing.Response) { + if !response.WasNotFound(existing.HttpResponse) { return tf.ImportAsExistsError("azurerm_automation_runbook", id.ID()) } } @@ -263,44 +267,47 @@ func resourceAutomationRunbookCreateUpdate(d *pluginsdk.ResourceData, meta inter location := azure.NormalizeLocation(d.Get("location").(string)) t := d.Get("tags").(map[string]interface{}) - runbookType := automation.RunbookTypeEnum(d.Get("runbook_type").(string)) + runbookType := runbook.RunbookTypeEnum(d.Get("runbook_type").(string)) logProgress := d.Get("log_progress").(bool) logVerbose := d.Get("log_verbose").(bool) description := d.Get("description").(string) - parameters := automation.RunbookCreateOrUpdateParameters{ - RunbookCreateOrUpdateProperties: &automation.RunbookCreateOrUpdateProperties{ + parameters := runbook.RunbookCreateOrUpdateParameters{ + Properties: runbook.RunbookCreateOrUpdateProperties{ LogVerbose: &logVerbose, LogProgress: &logProgress, RunbookType: runbookType, Description: &description, - LogActivityTrace: utils.Int32(int32(d.Get("log_activity_trace_level").(int))), + LogActivityTrace: utils.Int64(int64(d.Get("log_activity_trace_level").(int))), }, Location: &location, - Tags: tags.Expand(t), + } + if tagsVal := expandTags(t); tagsVal != nil { + parameters.Tags = &tagsVal } contentLink := expandContentLink(d.Get("publish_content_link").([]interface{})) if contentLink != nil { - parameters.RunbookCreateOrUpdateProperties.PublishContentLink = contentLink + parameters.Properties.PublishContentLink = contentLink } else { - parameters.RunbookCreateOrUpdateProperties.Draft = &automation.RunbookDraft{} + parameters.Properties.Draft = &runbook.RunbookDraft{} if draft := expandDraft(d.Get("draft").([]interface{})); draft != nil { - parameters.RunbookCreateOrUpdateProperties.Draft = draft + parameters.Properties.Draft = draft } } - if _, err := client.CreateOrUpdate(ctx, id.ResourceGroup, id.AutomationAccountName, id.Name, parameters); err != nil { + if _, err := client.CreateOrUpdate(ctx, id, parameters); err != nil { return fmt.Errorf("creating/updating %s: %+v", id, err) } if v, ok := d.GetOk("content"); ok { content := v.(string) reader := io.NopCloser(bytes.NewBufferString(content)) - draftClient := meta.(*clients.Client).Automation.RunbookDraftClient - _, err := draftClient.ReplaceContent(ctx, id.ResourceGroup, id.AutomationAccountName, id.Name, reader) + // need to use preview version DraftClient + // move to stable RunbookDraftClient once this issue fixed: https://github.com/Azure/azure-sdk-for-go/issues/17591#issuecomment-1233676539 + _, err := autoCli.RunbookDraftClient.ReplaceContent(ctx, id.ResourceGroupName, id.AutomationAccountName, id.RunbookName, reader) if err != nil { return fmt.Errorf("setting the draft for %s: %+v", id, err) } @@ -309,23 +316,23 @@ func resourceAutomationRunbookCreateUpdate(d *pluginsdk.ResourceData, meta inter // return fmt.Errorf("waiting for set the draft for %s: %+v", id, err) // } - f2, err := client.Publish(ctx, id.ResourceGroup, id.AutomationAccountName, id.Name) + f2, err := client.Publish(ctx, id) if err != nil { return fmt.Errorf("publishing the updated %s: %+v", id, err) } - if err := f2.WaitForCompletionRef(ctx, client.Client); err != nil { + if err := f2.Poller.PollUntilDone(); err != nil { return fmt.Errorf("waiting for publish the updated %s: %+v", id, err) } } d.SetId(id.ID()) - for jsIterator, err := jsClient.ListByAutomationAccountComplete(ctx, id.ResourceGroup, id.AutomationAccountName, ""); jsIterator.NotDone(); err = jsIterator.NextWithContext(ctx) { + for jsIterator, err := jsClient.ListByAutomationAccountComplete(ctx, id.ResourceGroupName, id.AutomationAccountName, ""); jsIterator.NotDone(); err = jsIterator.NextWithContext(ctx) { if err != nil { return fmt.Errorf("loading %s Job Schedule List: %+v", id, err) } if props := jsIterator.Value().JobScheduleProperties; props != nil { - if props.Runbook.Name != nil && *props.Runbook.Name == id.Name { + if props.Runbook.Name != nil && *props.Runbook.Name == id.RunbookName { if jsIterator.Value().JobScheduleID == nil || *jsIterator.Value().JobScheduleID == "" { return fmt.Errorf("job schedule Id is nil or empty listed by %s Job Schedule List: %+v", id, err) } @@ -333,7 +340,7 @@ func resourceAutomationRunbookCreateUpdate(d *pluginsdk.ResourceData, meta inter if err != nil { return fmt.Errorf("parsing job schedule Id listed by %s Job Schedule List:%v", id, err) } - if resp, err := jsClient.Delete(ctx, id.ResourceGroup, id.AutomationAccountName, jsId); err != nil { + if resp, err := jsClient.Delete(ctx, id.ResourceGroupName, id.AutomationAccountName, jsId); err != nil { if !utils.ResponseWasNotFound(resp) { return fmt.Errorf("deleting job schedule Id listed by %s Job Schedule List:%v", id, err) } @@ -343,12 +350,12 @@ func resourceAutomationRunbookCreateUpdate(d *pluginsdk.ResourceData, meta inter } if v, ok := d.GetOk("job_schedule"); ok { - jsMap, err := helper.ExpandAutomationJobSchedule(v.(*pluginsdk.Set).List(), id.Name) + jsMap, err := helper.ExpandAutomationJobSchedule(v.(*pluginsdk.Set).List(), id.RunbookName) if err != nil { return err } for jsuuid, js := range *jsMap { - if _, err := jsClient.Create(ctx, id.ResourceGroup, id.AutomationAccountName, jsuuid, js); err != nil { + if _, err := jsClient.Create(ctx, id.ResourceGroupName, id.AutomationAccountName, jsuuid, js); err != nil { return fmt.Errorf("creating %s: %+v", id, err) } } @@ -358,34 +365,36 @@ func resourceAutomationRunbookCreateUpdate(d *pluginsdk.ResourceData, meta inter } func resourceAutomationRunbookRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Automation.RunbookClient - jsClient := meta.(*clients.Client).Automation.JobScheduleClient + autoCli := meta.(*clients.Client).Automation + client := autoCli.RunbookClient + jsClient := autoCli.JobScheduleClient ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.RunbookID(d.Id()) + id, err := runbook.ParseRunbookID(d.Id()) if err != nil { return err } - resp, err := client.Get(ctx, id.ResourceGroup, id.AutomationAccountName, id.Name) + resp, err := client.Get(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { d.SetId("") return nil } - return fmt.Errorf("making Read request on AzureRM Automation Runbook %q (Account %q / Resource Group %q): %+v", id.Name, id.AutomationAccountName, id.ResourceGroup, err) + return fmt.Errorf("making Read request on AzureRM Automation Runbook %q (Account %q / Resource Group %q): %+v", id.RunbookName, id.AutomationAccountName, id.ResourceGroupName, err) } - d.Set("name", id.Name) - d.Set("resource_group_name", id.ResourceGroup) - if location := resp.Location; location != nil { + d.Set("name", id.RunbookName) + d.Set("resource_group_name", id.ResourceGroupName) + model := resp.Model + if location := model.Location; location != nil { d.Set("location", azure.NormalizeLocation(*location)) } d.Set("automation_account_name", id.AutomationAccountName) - if props := resp.RunbookProperties; props != nil { + if props := model.Properties; props != nil { d.Set("log_verbose", props.LogVerbose) d.Set("log_progress", props.LogProgress) d.Set("runbook_type", props.RunbookType) @@ -393,33 +402,33 @@ func resourceAutomationRunbookRead(d *pluginsdk.ResourceData, meta interface{}) d.Set("log_activity_trace_level", props.LogActivityTrace) } - response, err := client.GetContent(ctx, id.ResourceGroup, id.AutomationAccountName, id.Name) + // GetContent need to use preview version client RunbookClientHack + // move to stable RunbookClient once this issue fixed: https://github.com/Azure/azure-sdk-for-go/issues/17591#issuecomment-1233676539 + contentResp, err := autoCli.RunbookClientHack.GetContent(ctx, id.ResourceGroupName, id.AutomationAccountName, id.RunbookName) if err != nil { - if utils.ResponseWasNotFound(response.Response) { + if utils.ResponseWasNotFound(contentResp.Response) { d.Set("content", "") } else { - return fmt.Errorf("retrieving content for Automation Runbook %q (Account %q / Resource Group %q): %+v", id.Name, id.AutomationAccountName, id.ResourceGroup, err) + return fmt.Errorf("retrieving content for Automation Runbook %s: %+v", id, err) } } - if v := response.Value; v != nil { - if contentBytes := *response.Value; contentBytes != nil { - buf := new(bytes.Buffer) - if _, err := buf.ReadFrom(contentBytes); err != nil { - return fmt.Errorf("reading from Automation Runbook buffer %q: %+v", id.Name, err) - } - content := buf.String() - d.Set("content", content) + if v := contentResp.Value; v != nil && *v != nil { + buf := new(bytes.Buffer) + if _, err := buf.ReadFrom(*v); err != nil { + return fmt.Errorf("reading from Automation Runbook buffer %q: %+v", id.RunbookName, err) } + content := buf.String() + d.Set("content", content) } jsMap := make(map[uuid.UUID]automation.JobScheduleProperties) - for jsIterator, err := jsClient.ListByAutomationAccountComplete(ctx, id.ResourceGroup, id.AutomationAccountName, ""); jsIterator.NotDone(); err = jsIterator.NextWithContext(ctx) { + for jsIterator, err := jsClient.ListByAutomationAccountComplete(ctx, id.ResourceGroupName, id.AutomationAccountName, ""); jsIterator.NotDone(); err = jsIterator.NextWithContext(ctx) { if err != nil { return fmt.Errorf("loading Automation Account %q Job Schedule List: %+v", id.AutomationAccountName, err) } if props := jsIterator.Value().JobScheduleProperties; props != nil { - if props.Runbook.Name != nil && *props.Runbook.Name == id.Name { + if props.Runbook.Name != nil && *props.Runbook.Name == id.RunbookName { if jsIterator.Value().JobScheduleID == nil || *jsIterator.Value().JobScheduleID == "" { return fmt.Errorf("job schedule Id is nil or empty listed by Automation Account %q Job Schedule List: %+v", id.AutomationAccountName, err) } @@ -437,8 +446,8 @@ func resourceAutomationRunbookRead(d *pluginsdk.ResourceData, meta interface{}) return fmt.Errorf("setting `job_schedule`: %+v", err) } - if t := resp.Tags; t != nil { - return tags.FlattenAndSet(d, t) + if t := model.Tags; t != nil { + return flattenAndSetTags(d, *t) } return nil @@ -449,24 +458,24 @@ func resourceAutomationRunbookDelete(d *pluginsdk.ResourceData, meta interface{} ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.RunbookID(d.Id()) + id, err := runbook.ParseRunbookID(d.Id()) if err != nil { return err } - resp, err := client.Delete(ctx, id.ResourceGroup, id.AutomationAccountName, id.Name) + resp, err := client.Delete(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp) { + if response.WasNotFound(resp.HttpResponse) { return nil } - return fmt.Errorf("issuing AzureRM delete request for Automation Runbook '%s': %+v", id.Name, err) + return fmt.Errorf("issuing AzureRM delete request for Automation Runbook '%s': %+v", id.RunbookName, err) } return nil } -func expandContentLink(inputs []interface{}) *automation.ContentLink { +func expandContentLink(inputs []interface{}) *runbook.ContentLink { if len(inputs) == 0 || inputs[0] == nil { return nil } @@ -481,44 +490,45 @@ func expandContentLink(inputs []interface{}) *automation.ContentLink { hashValue := hash["value"].(string) hashAlgorithm := hash["algorithm"].(string) - return &automation.ContentLink{ - URI: &uri, + return &runbook.ContentLink{ + Uri: &uri, Version: &version, - ContentHash: &automation.ContentHash{ - Algorithm: &hashAlgorithm, - Value: &hashValue, + ContentHash: &runbook.ContentHash{ + Algorithm: hashAlgorithm, + Value: hashValue, }, } } - return &automation.ContentLink{ - URI: &uri, + return &runbook.ContentLink{ + Uri: &uri, Version: &version, } } -func expandDraft(inputs []interface{}) *automation.RunbookDraft { +func expandDraft(inputs []interface{}) *runbook.RunbookDraft { if len(inputs) == 0 || inputs[0] == nil { return nil } input := inputs[0].(map[string]interface{}) - var res automation.RunbookDraft + var res runbook.RunbookDraft res.DraftContentLink = expandContentLink(input["content_link"].([]interface{})) res.InEdit = utils.Bool(input["edit_mode_enabled"].(bool)) - res.Parameters = map[string]*automation.RunbookParameter{} + parameter := map[string]runbook.RunbookParameter{} for _, iparam := range input["parameters"].([]interface{}) { param := iparam.(map[string]interface{}) key := param["key"].(string) - res.Parameters[key] = &automation.RunbookParameter{ + parameter[key] = runbook.RunbookParameter{ Type: utils.String(param["type"].(string)), IsMandatory: utils.Bool(param["mandatory"].(bool)), - Position: utils.Int32(int32(param["position"].(int))), + Position: utils.Int64(int64(param["position"].(int))), DefaultValue: utils.String(param["default_value"].(string)), } } + res.Parameters = ¶meter var types []string for _, v := range input["output_types"].([]interface{}) { diff --git a/internal/services/automation/automation_runbook_resource_test.go b/internal/services/automation/automation_runbook_resource_test.go index 13087e2f4497..51c9b680a0d4 100644 --- a/internal/services/automation/automation_runbook_resource_test.go +++ b/internal/services/automation/automation_runbook_resource_test.go @@ -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" ) @@ -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 { diff --git a/internal/services/automation/client/client.go b/internal/services/automation/client/client.go index 3d5a5b897a3e..f6c68ab66f60 100644 --- a/internal/services/automation/client/client.go +++ b/internal/services/automation/client/client.go @@ -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" @@ -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 @@ -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) @@ -104,6 +109,7 @@ func NewClient(o *common.ClientOptions) *Client { JobScheduleClient: &jobScheduleClient, ModuleClient: &moduleClient, RunbookClient: &runbookClient, + RunbookClientHack: &runbookClient2, RunbookDraftClient: &runbookDraftClient, RunBookWgClient: &runbookWgClient, RunbookWorkerClient: &runbookWorkerClient, diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/README.md new file mode 100644 index 000000000000..dc7bc0c34a1d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/README.md @@ -0,0 +1,139 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook` Documentation + +The `runbook` SDK allows for interaction with the Azure Resource Manager Service `automation` (API Version `2019-06-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/automation/2019-06-01/runbook" +``` + + +### Client Initialization + +```go +client := runbook.NewRunbookClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `RunbookClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := runbook.NewRunbookID("12345678-1234-9876-4563-123456789012", "example-resource-group", "automationAccountValue", "runbookValue") + +payload := runbook.RunbookCreateOrUpdateParameters{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RunbookClient.Delete` + +```go +ctx := context.TODO() +id := runbook.NewRunbookID("12345678-1234-9876-4563-123456789012", "example-resource-group", "automationAccountValue", "runbookValue") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RunbookClient.Get` + +```go +ctx := context.TODO() +id := runbook.NewRunbookID("12345678-1234-9876-4563-123456789012", "example-resource-group", "automationAccountValue", "runbookValue") + +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: `RunbookClient.GetContent` + +```go +ctx := context.TODO() +id := runbook.NewRunbookID("12345678-1234-9876-4563-123456789012", "example-resource-group", "automationAccountValue", "runbookValue") + +read, err := client.GetContent(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RunbookClient.ListByAutomationAccount` + +```go +ctx := context.TODO() +id := runbook.NewAutomationAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "automationAccountValue") + +// alternatively `client.ListByAutomationAccount(ctx, id)` can be used to do batched pagination +items, err := client.ListByAutomationAccountComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `RunbookClient.Publish` + +```go +ctx := context.TODO() +id := runbook.NewRunbookID("12345678-1234-9876-4563-123456789012", "example-resource-group", "automationAccountValue", "runbookValue") + +if err := client.PublishThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `RunbookClient.Update` + +```go +ctx := context.TODO() +id := runbook.NewRunbookID("12345678-1234-9876-4563-123456789012", "example-resource-group", "automationAccountValue", "runbookValue") + +payload := runbook.RunbookUpdateParameters{ + // ... +} + + +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/automation/2019-06-01/runbook/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/client.go new file mode 100644 index 000000000000..9db531d95ffd --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/client.go @@ -0,0 +1,18 @@ +package runbook + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RunbookClient struct { + Client autorest.Client + baseUri string +} + +func NewRunbookClientWithBaseURI(endpoint string) RunbookClient { + return RunbookClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/constants.go new file mode 100644 index 000000000000..d6b40a67147a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/constants.go @@ -0,0 +1,108 @@ +package runbook + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RunbookProvisioningState string + +const ( + RunbookProvisioningStateSucceeded RunbookProvisioningState = "Succeeded" +) + +func PossibleValuesForRunbookProvisioningState() []string { + return []string{ + string(RunbookProvisioningStateSucceeded), + } +} + +func parseRunbookProvisioningState(input string) (*RunbookProvisioningState, error) { + vals := map[string]RunbookProvisioningState{ + "succeeded": RunbookProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RunbookProvisioningState(input) + return &out, nil +} + +type RunbookState string + +const ( + RunbookStateEdit RunbookState = "Edit" + RunbookStateNew RunbookState = "New" + RunbookStatePublished RunbookState = "Published" +) + +func PossibleValuesForRunbookState() []string { + return []string{ + string(RunbookStateEdit), + string(RunbookStateNew), + string(RunbookStatePublished), + } +} + +func parseRunbookState(input string) (*RunbookState, error) { + vals := map[string]RunbookState{ + "edit": RunbookStateEdit, + "new": RunbookStateNew, + "published": RunbookStatePublished, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RunbookState(input) + return &out, nil +} + +type RunbookTypeEnum string + +const ( + RunbookTypeEnumGraph RunbookTypeEnum = "Graph" + RunbookTypeEnumGraphPowerShell RunbookTypeEnum = "GraphPowerShell" + RunbookTypeEnumGraphPowerShellWorkflow RunbookTypeEnum = "GraphPowerShellWorkflow" + RunbookTypeEnumPowerShell RunbookTypeEnum = "PowerShell" + RunbookTypeEnumPowerShellWorkflow RunbookTypeEnum = "PowerShellWorkflow" + RunbookTypeEnumPythonThree RunbookTypeEnum = "Python3" + RunbookTypeEnumPythonTwo RunbookTypeEnum = "Python2" + RunbookTypeEnumScript RunbookTypeEnum = "Script" +) + +func PossibleValuesForRunbookTypeEnum() []string { + return []string{ + string(RunbookTypeEnumGraph), + string(RunbookTypeEnumGraphPowerShell), + string(RunbookTypeEnumGraphPowerShellWorkflow), + string(RunbookTypeEnumPowerShell), + string(RunbookTypeEnumPowerShellWorkflow), + string(RunbookTypeEnumPythonThree), + string(RunbookTypeEnumPythonTwo), + string(RunbookTypeEnumScript), + } +} + +func parseRunbookTypeEnum(input string) (*RunbookTypeEnum, error) { + vals := map[string]RunbookTypeEnum{ + "graph": RunbookTypeEnumGraph, + "graphpowershell": RunbookTypeEnumGraphPowerShell, + "graphpowershellworkflow": RunbookTypeEnumGraphPowerShellWorkflow, + "powershell": RunbookTypeEnumPowerShell, + "powershellworkflow": RunbookTypeEnumPowerShellWorkflow, + "python3": RunbookTypeEnumPythonThree, + "python2": RunbookTypeEnumPythonTwo, + "script": RunbookTypeEnumScript, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RunbookTypeEnum(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/id_automationaccount.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/id_automationaccount.go new file mode 100644 index 000000000000..9c237c20bab1 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/id_automationaccount.go @@ -0,0 +1,124 @@ +package runbook + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = AutomationAccountId{} + +// AutomationAccountId is a struct representing the Resource ID for a Automation Account +type AutomationAccountId struct { + SubscriptionId string + ResourceGroupName string + AutomationAccountName string +} + +// NewAutomationAccountID returns a new AutomationAccountId struct +func NewAutomationAccountID(subscriptionId string, resourceGroupName string, automationAccountName string) AutomationAccountId { + return AutomationAccountId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + AutomationAccountName: automationAccountName, + } +} + +// ParseAutomationAccountID parses 'input' into a AutomationAccountId +func ParseAutomationAccountID(input string) (*AutomationAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(AutomationAccountId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := AutomationAccountId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.AutomationAccountName, ok = parsed.Parsed["automationAccountName"]; !ok { + return nil, fmt.Errorf("the segment 'automationAccountName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseAutomationAccountIDInsensitively parses 'input' case-insensitively into a AutomationAccountId +// note: this method should only be used for API response data and not user input +func ParseAutomationAccountIDInsensitively(input string) (*AutomationAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(AutomationAccountId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := AutomationAccountId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.AutomationAccountName, ok = parsed.Parsed["automationAccountName"]; !ok { + return nil, fmt.Errorf("the segment 'automationAccountName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateAutomationAccountID checks that 'input' can be parsed as a Automation Account ID +func ValidateAutomationAccountID(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 := ParseAutomationAccountID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Automation Account ID +func (id AutomationAccountId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Automation/automationAccounts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.AutomationAccountName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Automation Account ID +func (id AutomationAccountId) 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("staticMicrosoftAutomation", "Microsoft.Automation", "Microsoft.Automation"), + resourceids.StaticSegment("staticAutomationAccounts", "automationAccounts", "automationAccounts"), + resourceids.UserSpecifiedSegment("automationAccountName", "automationAccountValue"), + } +} + +// String returns a human-readable description of this Automation Account ID +func (id AutomationAccountId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Automation Account Name: %q", id.AutomationAccountName), + } + return fmt.Sprintf("Automation Account (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/id_runbook.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/id_runbook.go new file mode 100644 index 000000000000..a571e0bcf8a3 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/id_runbook.go @@ -0,0 +1,137 @@ +package runbook + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = RunbookId{} + +// RunbookId is a struct representing the Resource ID for a Runbook +type RunbookId struct { + SubscriptionId string + ResourceGroupName string + AutomationAccountName string + RunbookName string +} + +// NewRunbookID returns a new RunbookId struct +func NewRunbookID(subscriptionId string, resourceGroupName string, automationAccountName string, runbookName string) RunbookId { + return RunbookId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + AutomationAccountName: automationAccountName, + RunbookName: runbookName, + } +} + +// ParseRunbookID parses 'input' into a RunbookId +func ParseRunbookID(input string) (*RunbookId, error) { + parser := resourceids.NewParserFromResourceIdType(RunbookId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := RunbookId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.AutomationAccountName, ok = parsed.Parsed["automationAccountName"]; !ok { + return nil, fmt.Errorf("the segment 'automationAccountName' was not found in the resource id %q", input) + } + + if id.RunbookName, ok = parsed.Parsed["runbookName"]; !ok { + return nil, fmt.Errorf("the segment 'runbookName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseRunbookIDInsensitively parses 'input' case-insensitively into a RunbookId +// note: this method should only be used for API response data and not user input +func ParseRunbookIDInsensitively(input string) (*RunbookId, error) { + parser := resourceids.NewParserFromResourceIdType(RunbookId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := RunbookId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.AutomationAccountName, ok = parsed.Parsed["automationAccountName"]; !ok { + return nil, fmt.Errorf("the segment 'automationAccountName' was not found in the resource id %q", input) + } + + if id.RunbookName, ok = parsed.Parsed["runbookName"]; !ok { + return nil, fmt.Errorf("the segment 'runbookName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateRunbookID checks that 'input' can be parsed as a Runbook ID +func ValidateRunbookID(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 := ParseRunbookID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Runbook ID +func (id RunbookId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Automation/automationAccounts/%s/runbooks/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.AutomationAccountName, id.RunbookName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Runbook ID +func (id RunbookId) 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("staticMicrosoftAutomation", "Microsoft.Automation", "Microsoft.Automation"), + resourceids.StaticSegment("staticAutomationAccounts", "automationAccounts", "automationAccounts"), + resourceids.UserSpecifiedSegment("automationAccountName", "automationAccountValue"), + resourceids.StaticSegment("staticRunbooks", "runbooks", "runbooks"), + resourceids.UserSpecifiedSegment("runbookName", "runbookValue"), + } +} + +// String returns a human-readable description of this Runbook ID +func (id RunbookId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Automation Account Name: %q", id.AutomationAccountName), + fmt.Sprintf("Runbook Name: %q", id.RunbookName), + } + return fmt.Sprintf("Runbook (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/method_createorupdate_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/method_createorupdate_autorest.go new file mode 100644 index 000000000000..b4c13df46117 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/method_createorupdate_autorest.go @@ -0,0 +1,69 @@ +package runbook + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// 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 { + HttpResponse *http.Response + Model *Runbook +} + +// CreateOrUpdate ... +func (c RunbookClient) CreateOrUpdate(ctx context.Context, id RunbookId, input RunbookCreateOrUpdateParameters) (result CreateOrUpdateOperationResponse, err error) { + req, err := c.preparerForCreateOrUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "runbook.RunbookClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "runbook.RunbookClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForCreateOrUpdate(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "runbook.RunbookClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForCreateOrUpdate prepares the CreateOrUpdate request. +func (c RunbookClient) preparerForCreateOrUpdate(ctx context.Context, id RunbookId, input RunbookCreateOrUpdateParameters) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForCreateOrUpdate handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (c RunbookClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/method_delete_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/method_delete_autorest.go new file mode 100644 index 000000000000..de2022f0cb3d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/method_delete_autorest.go @@ -0,0 +1,66 @@ +package runbook + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// 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 { + HttpResponse *http.Response +} + +// Delete ... +func (c RunbookClient) Delete(ctx context.Context, id RunbookId) (result DeleteOperationResponse, err error) { + req, err := c.preparerForDelete(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "runbook.RunbookClient", "Delete", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "runbook.RunbookClient", "Delete", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForDelete(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "runbook.RunbookClient", "Delete", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForDelete prepares the Delete request. +func (c RunbookClient) preparerForDelete(ctx context.Context, id RunbookId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsDelete(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForDelete handles the response to the Delete request. The method always +// closes the http.Response Body. +func (c RunbookClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/method_get_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/method_get_autorest.go new file mode 100644 index 000000000000..2379b32301e9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/method_get_autorest.go @@ -0,0 +1,68 @@ +package runbook + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// 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 + Model *Runbook +} + +// Get ... +func (c RunbookClient) Get(ctx context.Context, id RunbookId) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "runbook.RunbookClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "runbook.RunbookClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "runbook.RunbookClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c RunbookClient) preparerForGet(ctx context.Context, id RunbookId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGet handles the response to the Get request. The method always +// closes the http.Response Body. +func (c RunbookClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/method_getcontent_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/method_getcontent_autorest.go new file mode 100644 index 000000000000..22370327dcde --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/method_getcontent_autorest.go @@ -0,0 +1,69 @@ +package runbook + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetContentOperationResponse struct { + HttpResponse *http.Response + Model *string +} + +// GetContent ... +func (c RunbookClient) GetContent(ctx context.Context, id RunbookId) (result GetContentOperationResponse, err error) { + req, err := c.preparerForGetContent(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "runbook.RunbookClient", "GetContent", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "runbook.RunbookClient", "GetContent", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGetContent(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "runbook.RunbookClient", "GetContent", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGetContent prepares the GetContent request. +func (c RunbookClient) preparerForGetContent(ctx context.Context, id RunbookId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/content", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGetContent handles the response to the GetContent request. The method always +// closes the http.Response Body. +func (c RunbookClient) responderForGetContent(resp *http.Response) (result GetContentOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/method_listbyautomationaccount_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/method_listbyautomationaccount_autorest.go new file mode 100644 index 000000000000..79b15e3dca19 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/method_listbyautomationaccount_autorest.go @@ -0,0 +1,186 @@ +package runbook + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByAutomationAccountOperationResponse struct { + HttpResponse *http.Response + Model *[]Runbook + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListByAutomationAccountOperationResponse, error) +} + +type ListByAutomationAccountCompleteResult struct { + Items []Runbook +} + +func (r ListByAutomationAccountOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListByAutomationAccountOperationResponse) LoadMore(ctx context.Context) (resp ListByAutomationAccountOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +// ListByAutomationAccount ... +func (c RunbookClient) ListByAutomationAccount(ctx context.Context, id AutomationAccountId) (resp ListByAutomationAccountOperationResponse, err error) { + req, err := c.preparerForListByAutomationAccount(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "runbook.RunbookClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "runbook.RunbookClient", "ListByAutomationAccount", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForListByAutomationAccount(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "runbook.RunbookClient", "ListByAutomationAccount", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForListByAutomationAccount prepares the ListByAutomationAccount request. +func (c RunbookClient) preparerForListByAutomationAccount(ctx context.Context, id AutomationAccountId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/runbooks", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListByAutomationAccountWithNextLink prepares the ListByAutomationAccount request with the given nextLink token. +func (c RunbookClient) preparerForListByAutomationAccountWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForListByAutomationAccount handles the response to the ListByAutomationAccount request. The method always +// closes the http.Response Body. +func (c RunbookClient) responderForListByAutomationAccount(resp *http.Response) (result ListByAutomationAccountOperationResponse, err error) { + type page struct { + Values []Runbook `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByAutomationAccountOperationResponse, err error) { + req, err := c.preparerForListByAutomationAccountWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "runbook.RunbookClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "runbook.RunbookClient", "ListByAutomationAccount", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForListByAutomationAccount(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "runbook.RunbookClient", "ListByAutomationAccount", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// ListByAutomationAccountComplete retrieves all of the results into a single object +func (c RunbookClient) ListByAutomationAccountComplete(ctx context.Context, id AutomationAccountId) (ListByAutomationAccountCompleteResult, error) { + return c.ListByAutomationAccountCompleteMatchingPredicate(ctx, id, RunbookOperationPredicate{}) +} + +// ListByAutomationAccountCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c RunbookClient) ListByAutomationAccountCompleteMatchingPredicate(ctx context.Context, id AutomationAccountId, predicate RunbookOperationPredicate) (resp ListByAutomationAccountCompleteResult, err error) { + items := make([]Runbook, 0) + + page, err := c.ListByAutomationAccount(ctx, id) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := ListByAutomationAccountCompleteResult{ + Items: items, + } + return out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/method_publish_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/method_publish_autorest.go new file mode 100644 index 000000000000..f2e736037d78 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/method_publish_autorest.go @@ -0,0 +1,78 @@ +package runbook + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/polling" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublishOperationResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +// Publish ... +func (c RunbookClient) Publish(ctx context.Context, id RunbookId) (result PublishOperationResponse, err error) { + req, err := c.preparerForPublish(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "runbook.RunbookClient", "Publish", nil, "Failure preparing request") + return + } + + result, err = c.senderForPublish(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "runbook.RunbookClient", "Publish", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// PublishThenPoll performs Publish then polls until it's completed +func (c RunbookClient) PublishThenPoll(ctx context.Context, id RunbookId) error { + result, err := c.Publish(ctx, id) + if err != nil { + return fmt.Errorf("performing Publish: %+v", err) + } + + if err := result.Poller.PollUntilDone(); err != nil { + return fmt.Errorf("polling after Publish: %+v", err) + } + + return nil +} + +// preparerForPublish prepares the Publish request. +func (c RunbookClient) preparerForPublish(ctx context.Context, id RunbookId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/publish", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// senderForPublish sends the Publish request. The method will close the +// http.Response Body if it receives an error. +func (c RunbookClient) senderForPublish(ctx context.Context, req *http.Request) (future PublishOperationResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + + future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/method_update_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/method_update_autorest.go new file mode 100644 index 000000000000..0d6a67ad38d1 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/method_update_autorest.go @@ -0,0 +1,69 @@ +package runbook + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// 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 + Model *Runbook +} + +// Update ... +func (c RunbookClient) Update(ctx context.Context, id RunbookId, input RunbookUpdateParameters) (result UpdateOperationResponse, err error) { + req, err := c.preparerForUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "runbook.RunbookClient", "Update", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "runbook.RunbookClient", "Update", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForUpdate(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "runbook.RunbookClient", "Update", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForUpdate prepares the Update request. +func (c RunbookClient) preparerForUpdate(ctx context.Context, id RunbookId, input RunbookUpdateParameters) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForUpdate handles the response to the Update request. The method always +// closes the http.Response Body. +func (c RunbookClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/model_contenthash.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/model_contenthash.go new file mode 100644 index 000000000000..017efc1b0c13 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/model_contenthash.go @@ -0,0 +1,9 @@ +package runbook + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContentHash struct { + Algorithm string `json:"algorithm"` + Value string `json:"value"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/model_contentlink.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/model_contentlink.go new file mode 100644 index 000000000000..2656e468716e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/model_contentlink.go @@ -0,0 +1,10 @@ +package runbook + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContentLink struct { + ContentHash *ContentHash `json:"contentHash,omitempty"` + Uri *string `json:"uri,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/model_runbook.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/model_runbook.go new file mode 100644 index 000000000000..151256c8e879 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/model_runbook.go @@ -0,0 +1,14 @@ +package runbook + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Runbook struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RunbookProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/model_runbookcreateorupdateparameters.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/model_runbookcreateorupdateparameters.go new file mode 100644 index 000000000000..d0b7ae400f0e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/model_runbookcreateorupdateparameters.go @@ -0,0 +1,11 @@ +package runbook + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RunbookCreateOrUpdateParameters struct { + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties RunbookCreateOrUpdateProperties `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/model_runbookcreateorupdateproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/model_runbookcreateorupdateproperties.go new file mode 100644 index 000000000000..bfd925628499 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/model_runbookcreateorupdateproperties.go @@ -0,0 +1,14 @@ +package runbook + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RunbookCreateOrUpdateProperties struct { + Description *string `json:"description,omitempty"` + Draft *RunbookDraft `json:"draft,omitempty"` + LogActivityTrace *int64 `json:"logActivityTrace,omitempty"` + LogProgress *bool `json:"logProgress,omitempty"` + LogVerbose *bool `json:"logVerbose,omitempty"` + PublishContentLink *ContentLink `json:"publishContentLink,omitempty"` + RunbookType RunbookTypeEnum `json:"runbookType"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/model_runbookdraft.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/model_runbookdraft.go new file mode 100644 index 000000000000..a0686cd6c00d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/model_runbookdraft.go @@ -0,0 +1,43 @@ +package runbook + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RunbookDraft struct { + CreationTime *string `json:"creationTime,omitempty"` + DraftContentLink *ContentLink `json:"draftContentLink,omitempty"` + InEdit *bool `json:"inEdit,omitempty"` + LastModifiedTime *string `json:"lastModifiedTime,omitempty"` + OutputTypes *[]string `json:"outputTypes,omitempty"` + Parameters *map[string]RunbookParameter `json:"parameters,omitempty"` +} + +func (o *RunbookDraft) GetCreationTimeAsTime() (*time.Time, error) { + if o.CreationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RunbookDraft) SetCreationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTime = &formatted +} + +func (o *RunbookDraft) GetLastModifiedTimeAsTime() (*time.Time, error) { + if o.LastModifiedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastModifiedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RunbookDraft) SetLastModifiedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastModifiedTime = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/model_runbookparameter.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/model_runbookparameter.go new file mode 100644 index 000000000000..e7dc9b847595 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/model_runbookparameter.go @@ -0,0 +1,11 @@ +package runbook + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RunbookParameter struct { + DefaultValue *string `json:"defaultValue,omitempty"` + IsMandatory *bool `json:"isMandatory,omitempty"` + Position *int64 `json:"position,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/model_runbookproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/model_runbookproperties.go new file mode 100644 index 000000000000..34088469d39c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/model_runbookproperties.go @@ -0,0 +1,52 @@ +package runbook + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RunbookProperties struct { + CreationTime *string `json:"creationTime,omitempty"` + Description *string `json:"description,omitempty"` + Draft *RunbookDraft `json:"draft,omitempty"` + JobCount *int64 `json:"jobCount,omitempty"` + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + LastModifiedTime *string `json:"lastModifiedTime,omitempty"` + LogActivityTrace *int64 `json:"logActivityTrace,omitempty"` + LogProgress *bool `json:"logProgress,omitempty"` + LogVerbose *bool `json:"logVerbose,omitempty"` + OutputTypes *[]string `json:"outputTypes,omitempty"` + Parameters *map[string]RunbookParameter `json:"parameters,omitempty"` + ProvisioningState *RunbookProvisioningState `json:"provisioningState,omitempty"` + PublishContentLink *ContentLink `json:"publishContentLink,omitempty"` + RunbookType *RunbookTypeEnum `json:"runbookType,omitempty"` + State *RunbookState `json:"state,omitempty"` +} + +func (o *RunbookProperties) GetCreationTimeAsTime() (*time.Time, error) { + if o.CreationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RunbookProperties) SetCreationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTime = &formatted +} + +func (o *RunbookProperties) GetLastModifiedTimeAsTime() (*time.Time, error) { + if o.LastModifiedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastModifiedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RunbookProperties) SetLastModifiedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastModifiedTime = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/model_runbookupdateparameters.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/model_runbookupdateparameters.go new file mode 100644 index 000000000000..64cdc09fce98 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/model_runbookupdateparameters.go @@ -0,0 +1,11 @@ +package runbook + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RunbookUpdateParameters struct { + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RunbookUpdateProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/model_runbookupdateproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/model_runbookupdateproperties.go new file mode 100644 index 000000000000..ebd52032b89f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/model_runbookupdateproperties.go @@ -0,0 +1,11 @@ +package runbook + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RunbookUpdateProperties struct { + Description *string `json:"description,omitempty"` + LogActivityTrace *int64 `json:"logActivityTrace,omitempty"` + LogProgress *bool `json:"logProgress,omitempty"` + LogVerbose *bool `json:"logVerbose,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/predicates.go new file mode 100644 index 000000000000..94e54ee40bfd --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/predicates.go @@ -0,0 +1,34 @@ +package runbook + +type RunbookOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p RunbookOperationPredicate) Matches(input Runbook) bool { + + if p.Etag != nil && (input.Etag == nil && *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil && *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil && *p.Location != *input.Location) { + 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/automation/2019-06-01/runbook/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/version.go new file mode 100644 index 000000000000..21e80754253c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/automation/2019-06-01/runbook/version.go @@ -0,0 +1,12 @@ +package runbook + +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 = "2019-06-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/runbook/%s", defaultApiVersion) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 646e90af5f27..96dafafadcc0 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -194,6 +194,7 @@ github.com/hashicorp/go-azure-sdk/resource-manager/appconfiguration/2022-05-01/d github.com/hashicorp/go-azure-sdk/resource-manager/applicationinsights/2020-11-20/workbooktemplatesapis github.com/hashicorp/go-azure-sdk/resource-manager/applicationinsights/2022-04-01/workbooksapis github.com/hashicorp/go-azure-sdk/resource-manager/attestation/2020-10-01/attestationproviders +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 diff --git a/website/docs/r/automation_runbook.html.markdown b/website/docs/r/automation_runbook.html.markdown index d7a7006df233..ca016dbed5de 100644 --- a/website/docs/r/automation_runbook.html.markdown +++ b/website/docs/r/automation_runbook.html.markdown @@ -88,7 +88,7 @@ The following arguments are supported: * `automation_account_name` - (Required) The name of the automation account in which the Runbook is created. Changing this forces a new resource to be created. -* `runbook_type` - (Required) The type of the runbook - can be either `Graph`, `GraphPowerShell`, `GraphPowerShellWorkflow`, `PowerShellWorkflow`, `PowerShell` or `Script`. +* `runbook_type` - (Required) The type of the runbook - can be either `Graph`, `GraphPowerShell`, `GraphPowerShellWorkflow`, `PowerShellWorkflow`, `PowerShell`, `Python3`, `Python2` or `Script`. * `log_progress` - (Required) Progress log option.