From d80fd0eb8166f52ddc1b00dc816f30bd305e2950 Mon Sep 17 00:00:00 2001 From: Kemyke Date: Thu, 10 Aug 2017 13:20:01 +0000 Subject: [PATCH 01/42] Add automation resources: account, credential, runbook, schedule --- azurerm/config.go | 33 +- azurerm/import_arm_automation_account_test.go | 56 + .../import_arm_automation_credential_test.go | 34 + azurerm/import_arm_automation_runbook_test.go | 34 + .../import_arm_automation_schedule_test.go | 34 + azurerm/provider.go | 18 +- azurerm/resource_arm_automation_account.go | 190 ++ .../resource_arm_automation_account_test.go | 147 ++ azurerm/resource_arm_automation_credential.go | 149 ++ ...resource_arm_automation_credential_test.go | 121 ++ azurerm/resource_arm_automation_runbook.go | 228 ++ .../resource_arm_automation_runbook_test.go | 129 ++ azurerm/resource_arm_automation_schedule.go | 314 +++ .../resource_arm_automation_schedule_test.go | 127 ++ .../arm/automation/account.go | 514 +++++ .../arm/automation/activity.go | 216 ++ .../agentregistrationinformation.go | 191 ++ .../arm/automation/certificate.go | 441 ++++ .../azure-sdk-for-go/arm/automation/client.go | 52 + .../arm/automation/connection.go | 442 ++++ .../arm/automation/connectiontype.go | 366 ++++ .../arm/automation/credential.go | 443 ++++ .../arm/automation/dsccompilationjob.go | 373 ++++ .../arm/automation/dscconfiguration.go | 444 ++++ .../arm/automation/dscnode.go | 362 ++++ .../arm/automation/dscnodeconfiguration.go | 377 ++++ .../azure-sdk-for-go/arm/automation/fields.go | 117 + .../automation/hybridrunbookworkergroup.go | 363 ++++ .../azure-sdk-for-go/arm/automation/job.go | 654 ++++++ .../arm/automation/jobschedule.go | 365 ++++ .../arm/automation/jobstream.go | 218 ++ .../azure-sdk-for-go/arm/automation/models.go | 1926 +++++++++++++++++ .../azure-sdk-for-go/arm/automation/module.go | 443 ++++ .../arm/automation/nodereports.go | 292 +++ .../arm/automation/objectdatatypes.go | 194 ++ .../arm/automation/operations.go | 98 + .../arm/automation/runbook.go | 523 +++++ .../arm/automation/runbookdraft.go | 447 ++++ .../arm/automation/schedule.go | 439 ++++ .../arm/automation/statistics.go | 117 + .../arm/automation/testjobs.go | 410 ++++ .../arm/automation/testjobstreams.go | 221 ++ .../azure-sdk-for-go/arm/automation/usages.go | 113 + .../arm/automation/variable.go | 438 ++++ .../arm/automation/version.go | 28 + .../arm/automation/webhook.go | 512 +++++ 46 files changed, 13745 insertions(+), 8 deletions(-) create mode 100644 azurerm/import_arm_automation_account_test.go create mode 100644 azurerm/import_arm_automation_credential_test.go create mode 100644 azurerm/import_arm_automation_runbook_test.go create mode 100644 azurerm/import_arm_automation_schedule_test.go create mode 100644 azurerm/resource_arm_automation_account.go create mode 100644 azurerm/resource_arm_automation_account_test.go create mode 100644 azurerm/resource_arm_automation_credential.go create mode 100644 azurerm/resource_arm_automation_credential_test.go create mode 100644 azurerm/resource_arm_automation_runbook.go create mode 100644 azurerm/resource_arm_automation_runbook_test.go create mode 100644 azurerm/resource_arm_automation_schedule.go create mode 100644 azurerm/resource_arm_automation_schedule_test.go create mode 100755 vendor/github.com/Azure/azure-sdk-for-go/arm/automation/account.go create mode 100755 vendor/github.com/Azure/azure-sdk-for-go/arm/automation/activity.go create mode 100755 vendor/github.com/Azure/azure-sdk-for-go/arm/automation/agentregistrationinformation.go create mode 100755 vendor/github.com/Azure/azure-sdk-for-go/arm/automation/certificate.go create mode 100755 vendor/github.com/Azure/azure-sdk-for-go/arm/automation/client.go create mode 100755 vendor/github.com/Azure/azure-sdk-for-go/arm/automation/connection.go create mode 100755 vendor/github.com/Azure/azure-sdk-for-go/arm/automation/connectiontype.go create mode 100755 vendor/github.com/Azure/azure-sdk-for-go/arm/automation/credential.go create mode 100755 vendor/github.com/Azure/azure-sdk-for-go/arm/automation/dsccompilationjob.go create mode 100755 vendor/github.com/Azure/azure-sdk-for-go/arm/automation/dscconfiguration.go create mode 100755 vendor/github.com/Azure/azure-sdk-for-go/arm/automation/dscnode.go create mode 100755 vendor/github.com/Azure/azure-sdk-for-go/arm/automation/dscnodeconfiguration.go create mode 100755 vendor/github.com/Azure/azure-sdk-for-go/arm/automation/fields.go create mode 100755 vendor/github.com/Azure/azure-sdk-for-go/arm/automation/hybridrunbookworkergroup.go create mode 100755 vendor/github.com/Azure/azure-sdk-for-go/arm/automation/job.go create mode 100755 vendor/github.com/Azure/azure-sdk-for-go/arm/automation/jobschedule.go create mode 100755 vendor/github.com/Azure/azure-sdk-for-go/arm/automation/jobstream.go create mode 100755 vendor/github.com/Azure/azure-sdk-for-go/arm/automation/models.go create mode 100755 vendor/github.com/Azure/azure-sdk-for-go/arm/automation/module.go create mode 100755 vendor/github.com/Azure/azure-sdk-for-go/arm/automation/nodereports.go create mode 100755 vendor/github.com/Azure/azure-sdk-for-go/arm/automation/objectdatatypes.go create mode 100755 vendor/github.com/Azure/azure-sdk-for-go/arm/automation/operations.go create mode 100755 vendor/github.com/Azure/azure-sdk-for-go/arm/automation/runbook.go create mode 100755 vendor/github.com/Azure/azure-sdk-for-go/arm/automation/runbookdraft.go create mode 100755 vendor/github.com/Azure/azure-sdk-for-go/arm/automation/schedule.go create mode 100755 vendor/github.com/Azure/azure-sdk-for-go/arm/automation/statistics.go create mode 100755 vendor/github.com/Azure/azure-sdk-for-go/arm/automation/testjobs.go create mode 100755 vendor/github.com/Azure/azure-sdk-for-go/arm/automation/testjobstreams.go create mode 100755 vendor/github.com/Azure/azure-sdk-for-go/arm/automation/usages.go create mode 100755 vendor/github.com/Azure/azure-sdk-for-go/arm/automation/variable.go create mode 100755 vendor/github.com/Azure/azure-sdk-for-go/arm/automation/version.go create mode 100755 vendor/github.com/Azure/azure-sdk-for-go/arm/automation/webhook.go diff --git a/azurerm/config.go b/azurerm/config.go index 4688ebc5911b..8e8c6c1d58c2 100644 --- a/azurerm/config.go +++ b/azurerm/config.go @@ -8,6 +8,7 @@ import ( "net/http/httputil" "github.com/Azure/azure-sdk-for-go/arm/appinsights" + "github.com/Azure/azure-sdk-for-go/arm/automation" "github.com/Azure/azure-sdk-for-go/arm/cdn" "github.com/Azure/azure-sdk-for-go/arm/compute" "github.com/Azure/azure-sdk-for-go/arm/containerregistry" @@ -55,8 +56,12 @@ type ArmClient struct { vmClient compute.VirtualMachinesClient imageClient compute.ImagesClient - diskClient disk.DisksClient - cosmosDBClient cosmosdb.DatabaseAccountsClient + diskClient disk.DisksClient + cosmosDBClient cosmosdb.DatabaseAccountsClient + automationAccountClient automation.AccountClient + automationRunbookClient automation.RunbookClient + automationCredentialClient automation.CredentialClient + automationScheduleClient automation.ScheduleClient appGatewayClient network.ApplicationGatewaysClient ifaceClient network.InterfacesClient @@ -538,6 +543,30 @@ func (c *Config) getArmClient() (*ArmClient, error) { spc.Sender = autorest.CreateSender(withRequestLogging()) client.servicePrincipalsClient = spc + aadb := automation.NewAccountClientWithBaseURI(endpoint, c.SubscriptionID) + setUserAgent(&aadb.Client) + aadb.Authorizer = auth + aadb.Sender = autorest.CreateSender(withRequestLogging()) + client.automationAccountClient = aadb + + arc := automation.NewRunbookClientWithBaseURI(endpoint, c.SubscriptionID) + setUserAgent(&arc.Client) + arc.Authorizer = auth + arc.Sender = autorest.CreateSender(withRequestLogging()) + client.automationRunbookClient = arc + + acc := automation.NewCredentialClientWithBaseURI(endpoint, c.SubscriptionID) + setUserAgent(&acc.Client) + acc.Authorizer = auth + acc.Sender = autorest.CreateSender(withRequestLogging()) + client.automationCredentialClient = acc + + aschc := automation.NewScheduleClientWithBaseURI(endpoint, c.SubscriptionID) + setUserAgent(&aschc.Client) + aschc.Authorizer = auth + aschc.Sender = autorest.CreateSender(withRequestLogging()) + client.automationScheduleClient = aschc + return &client, nil } diff --git a/azurerm/import_arm_automation_account_test.go b/azurerm/import_arm_automation_account_test.go new file mode 100644 index 000000000000..db28dafab45b --- /dev/null +++ b/azurerm/import_arm_automation_account_test.go @@ -0,0 +1,56 @@ +package azurerm + +import ( + "testing" + + "github.com/hashicorp/terraform/helper/acctest" + "github.com/hashicorp/terraform/helper/resource" +) + +func TestAccAzureRMAutomationAccount_importAccoutWithFreeSku(t *testing.T) { + resourceName := "azurerm_automation_account.test" + + ri := acctest.RandInt() + config := testAccAzureRMAutomationAccount_skuFree(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAutomationAccountDestroy, + Steps: []resource.TestStep{ + { + Config: config, + }, + + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccAzureRMAutomationAccount_importAccoutWithBasicSku(t *testing.T) { + resourceName := "azurerm_automation_account.test" + + ri := acctest.RandInt() + config := testAccAzureRMAutomationAccount_skuBasic(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAutomationAccountDestroy, + Steps: []resource.TestStep{ + { + Config: config, + }, + + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} diff --git a/azurerm/import_arm_automation_credential_test.go b/azurerm/import_arm_automation_credential_test.go new file mode 100644 index 000000000000..5fe35af15359 --- /dev/null +++ b/azurerm/import_arm_automation_credential_test.go @@ -0,0 +1,34 @@ +package azurerm + +import ( + "testing" + + "github.com/hashicorp/terraform/helper/acctest" + "github.com/hashicorp/terraform/helper/resource" +) + +func TestAccAzureRMAutomationCredential_importCredential(t *testing.T) { + resourceName := "azurerm_automation_credential.test" + + ri := acctest.RandInt() + config := testAccAzureRMAutomationCredential_testCredential(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAutomationCredentialDestroy, + Steps: []resource.TestStep{ + { + Config: config, + // publish content link is not returned after the runbook is created + ExpectNonEmptyPlan: true, + }, + + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} diff --git a/azurerm/import_arm_automation_runbook_test.go b/azurerm/import_arm_automation_runbook_test.go new file mode 100644 index 000000000000..71b440ec1325 --- /dev/null +++ b/azurerm/import_arm_automation_runbook_test.go @@ -0,0 +1,34 @@ +package azurerm + +import ( + "testing" + + "github.com/hashicorp/terraform/helper/acctest" + "github.com/hashicorp/terraform/helper/resource" +) + +func TestAccAzureRMAutomationRunbook_importRunbookPSWorkflow(t *testing.T) { + resourceName := "azurerm_automation_runbook.test" + + ri := acctest.RandInt() + config := testAccAzureRMAutomationRunbook_PSWorkflow(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAutomationRunbookDestroy, + Steps: []resource.TestStep{ + { + Config: config, + // publish content link is not returned after the runbook is created + ExpectNonEmptyPlan: true, + }, + + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} diff --git a/azurerm/import_arm_automation_schedule_test.go b/azurerm/import_arm_automation_schedule_test.go new file mode 100644 index 000000000000..67854b83dc05 --- /dev/null +++ b/azurerm/import_arm_automation_schedule_test.go @@ -0,0 +1,34 @@ +package azurerm + +import ( + "testing" + + "github.com/hashicorp/terraform/helper/acctest" + "github.com/hashicorp/terraform/helper/resource" +) + +func TestAccAzureRMAutomationSchedule_importScheduleOneTime(t *testing.T) { + resourceName := "azurerm_automation_schedule.test" + + ri := acctest.RandInt() + config := testAccAzureRMAutomationSchedule_oneTime(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAutomationScheduleDestroy, + Steps: []resource.TestStep{ + { + Config: config, + // publish content link is not returned after the runbook is created + ExpectNonEmptyPlan: true, + }, + + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} diff --git a/azurerm/provider.go b/azurerm/provider.go index fd6479914aa7..0de4d7df8b75 100644 --- a/azurerm/provider.go +++ b/azurerm/provider.go @@ -71,12 +71,18 @@ func Provider() terraform.ResourceProvider { ResourcesMap: map[string]*schema.Resource{ // These resources use the Azure ARM SDK "azurerm_application_insights": resourceArmApplicationInsights(), - "azurerm_availability_set": resourceArmAvailabilitySet(), - "azurerm_cdn_endpoint": resourceArmCdnEndpoint(), - "azurerm_cdn_profile": resourceArmCdnProfile(), - "azurerm_container_registry": resourceArmContainerRegistry(), - "azurerm_container_service": resourceArmContainerService(), - "azurerm_cosmosdb_account": resourceArmCosmosDBAccount(), + + "azurerm_automation_account": resourceArmAutomationAccount(), + "azurerm_automation_runbook": resourceArmAutomationRunbook(), + "azurerm_automation_credential": resourceArmAutomationCredential(), + "azurerm_automation_schedule": resourceArmAutomationSchedule(), + + "azurerm_availability_set": resourceArmAvailabilitySet(), + "azurerm_cdn_endpoint": resourceArmCdnEndpoint(), + "azurerm_cdn_profile": resourceArmCdnProfile(), + "azurerm_container_registry": resourceArmContainerRegistry(), + "azurerm_container_service": resourceArmContainerService(), + "azurerm_cosmosdb_account": resourceArmCosmosDBAccount(), "azurerm_dns_a_record": resourceArmDnsARecord(), "azurerm_dns_aaaa_record": resourceArmDnsAAAARecord(), diff --git a/azurerm/resource_arm_automation_account.go b/azurerm/resource_arm_automation_account.go new file mode 100644 index 000000000000..c20a2d14efc4 --- /dev/null +++ b/azurerm/resource_arm_automation_account.go @@ -0,0 +1,190 @@ +package azurerm + +import ( + "fmt" + "log" + "net/http" + + "github.com/Azure/azure-sdk-for-go/arm/automation" + "github.com/hashicorp/terraform/helper/hashcode" + "github.com/hashicorp/terraform/helper/schema" + "github.com/hashicorp/terraform/helper/validation" +) + +func resourceArmAutomationAccount() *schema.Resource { + return &schema.Resource{ + Create: resourceArmAutomationAccountCreateUpdate, + Read: resourceArmAutomationAccountRead, + Update: resourceArmAutomationAccountCreateUpdate, + Delete: resourceArmAutomationAccountDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "location": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + StateFunc: azureRMNormalizeLocation, + }, + + "resource_group_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "sku": { + Type: schema.TypeSet, + Required: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + DiffSuppressFunc: ignoreCaseDiffSuppressFunc, + ValidateFunc: validation.StringInSlice([]string{ + string(automation.Free), + string(automation.Basic), + }, true), + }, + }, + }, + Set: resourceAzureRMAutomationAccountSkuHash, + }, + "tags": tagsSchema(), + }, + } +} + +func resourceAzureRMAutomationAccountSkuHash(v interface{}) int { + m := v.(map[string]interface{}) + + name := m["name"].(string) + + return hashcode.String(name) +} + +func resourceArmAutomationAccountCreateUpdate(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).automationAccountClient + log.Printf("[INFO] preparing arguments for AzureRM Automation Account creation.") + + name := d.Get("name").(string) + location := d.Get("location").(string) + resGroup := d.Get("resource_group_name").(string) + tags := d.Get("tags").(map[string]interface{}) + + sku := expandSku(d) + + parameters := automation.AccountCreateOrUpdateParameters{ + AccountCreateOrUpdateProperties: &automation.AccountCreateOrUpdateProperties{ + Sku: &sku, + }, + + Name: &name, + Location: &location, + Tags: expandTags(tags), + } + + _, err := client.CreateOrUpdate(resGroup, name, parameters) + if err != nil { + return err + } + + read, err := client.Get(resGroup, name) + if err != nil { + return err + } + + if read.ID == nil { + return fmt.Errorf("Cannot read Automation Account '%s' (resource group %s) ID", name, resGroup) + } + + d.SetId(*read.ID) + + return resourceArmAutomationAccountRead(d, meta) +} + +func resourceArmAutomationAccountRead(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).automationAccountClient + id, err := parseAzureResourceID(d.Id()) + if err != nil { + return err + } + resGroup := id.ResourceGroup + name := id.Path["automationAccounts"] + + resp, err := client.Get(resGroup, name) + if err != nil { + if responseWasNotFound(resp.Response) { + d.SetId("") + return nil + } + + return fmt.Errorf("Error making Read request on AzureRM Automation Account '%s': %s", name, err) + } + + d.Set("name", resp.Name) + d.Set("location", azureRMNormalizeLocation(*resp.Location)) + d.Set("resource_group_name", resGroup) + flattenAndSetSku(d, resp.Sku) + + flattenAndSetTags(d, resp.Tags) + + return nil +} + +func resourceArmAutomationAccountDelete(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).automationAccountClient + + id, err := parseAzureResourceID(d.Id()) + if err != nil { + return err + } + resGroup := id.ResourceGroup + name := id.Path["automationAccounts"] + + resp, err := client.Delete(resGroup, name) + + if err != nil { + if resp.StatusCode == http.StatusNotFound { + return nil + } + + return fmt.Errorf("Error issuing AzureRM delete request for Automation Account '%s': %+v", name, err) + } + + return nil +} + +func flattenAndSetSku(d *schema.ResourceData, sku *automation.Sku) { + results := schema.Set{ + F: resourceAzureRMAutomationAccountSkuHash, + } + + result := map[string]interface{}{} + result["name"] = string(sku.Name) + results.Add(result) + + d.Set("sku", &results) +} + +func expandSku(d *schema.ResourceData) automation.Sku { + inputs := d.Get("sku").(*schema.Set).List() + input := inputs[0].(map[string]interface{}) + name := automation.SkuNameEnum(input["name"].(string)) + + sku := automation.Sku{ + Name: name, + } + + return sku +} diff --git a/azurerm/resource_arm_automation_account_test.go b/azurerm/resource_arm_automation_account_test.go new file mode 100644 index 000000000000..9d4dfd71160f --- /dev/null +++ b/azurerm/resource_arm_automation_account_test.go @@ -0,0 +1,147 @@ +package azurerm + +import ( + "fmt" + "net/http" + "testing" + + "github.com/hashicorp/terraform/helper/acctest" + "github.com/hashicorp/terraform/helper/resource" + "github.com/hashicorp/terraform/terraform" + + "github.com/Azure/azure-sdk-for-go/arm/automation" +) + +func TestAccAzureRMAutomationAccount_skuBasic(t *testing.T) { + ri := acctest.RandInt() + config := testAccAzureRMAutomationAccount_skuBasic(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAutomationAccountDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAutomationAccountExistsAndSku("azurerm_automation_account.test", automation.Basic), + ), + }, + }, + }) +} + +func TestAccAzureRMAutomationAccount_skuFree(t *testing.T) { + ri := acctest.RandInt() + config := testAccAzureRMAutomationAccount_skuFree(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAutomationAccountDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAutomationAccountExistsAndSku("azurerm_automation_account.test", automation.Free), + ), + }, + }, + }) +} + +func testCheckAzureRMAutomationAccountDestroy(s *terraform.State) error { + conn := testAccProvider.Meta().(*ArmClient).automationAccountClient + + for _, rs := range s.RootModule().Resources { + if rs.Type != "azurerm_automation_account" { + continue + } + + name := rs.Primary.Attributes["name"] + resourceGroup := rs.Primary.Attributes["resource_group_name"] + + resp, err := conn.Get(resourceGroup, name) + + if err != nil { + return nil + } + + if resp.StatusCode != http.StatusNotFound { + return fmt.Errorf("Automation Account still exists:\n%#v", resp) + } + } + + return nil +} + +func testCheckAzureRMAutomationAccountExistsAndSku(name string, sku automation.SkuNameEnum) resource.TestCheckFunc { + + return func(s *terraform.State) error { + // Ensure we have enough information in state to look up in API + rs, ok := s.RootModule().Resources[name] + if !ok { + return fmt.Errorf("Not found: %s", name) + } + + name := rs.Primary.Attributes["name"] + resourceGroup, hasResourceGroup := rs.Primary.Attributes["resource_group_name"] + if !hasResourceGroup { + return fmt.Errorf("Bad: no resource group found in state for Automation Account: '%s'", name) + } + + conn := testAccProvider.Meta().(*ArmClient).automationAccountClient + + resp, err := conn.Get(resourceGroup, name) + + if err != nil { + return fmt.Errorf("Bad: Get on automationClient: %s", err) + } + + if resp.StatusCode == http.StatusNotFound { + return fmt.Errorf("Bad: Automation Account '%s' (resource group: '%s') does not exist", name, resourceGroup) + } + + if resp.Sku.Name != sku { + return fmt.Errorf("Actual sku %s is not consistent with the checked value %s", resp.Sku.Name, sku) + } + + return nil + } +} + +func testAccAzureRMAutomationAccount_skuBasic(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_automation_account" "test" { + name = "acctest-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + sku { + name = "Basic" + } +} +`, rInt, location, rInt) +} + +func testAccAzureRMAutomationAccount_skuFree(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_automation_account" "test" { + name = "acctest-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + sku { + name = "Free" + } +} +`, rInt, location, rInt) +} diff --git a/azurerm/resource_arm_automation_credential.go b/azurerm/resource_arm_automation_credential.go new file mode 100644 index 000000000000..1e7f7f4f4472 --- /dev/null +++ b/azurerm/resource_arm_automation_credential.go @@ -0,0 +1,149 @@ +package azurerm + +import ( + "fmt" + "log" + "net/http" + + "github.com/Azure/azure-sdk-for-go/arm/automation" + "github.com/hashicorp/terraform/helper/schema" +) + +func resourceArmAutomationCredential() *schema.Resource { + return &schema.Resource{ + Create: resourceArmAutomationCredentialCreateUpdate, + Read: resourceArmAutomationCredentialRead, + Update: resourceArmAutomationCredentialCreateUpdate, + Delete: resourceArmAutomationCredentialDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "resource_group_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "account_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "user_name": { + Type: schema.TypeString, + Required: true, + }, + + "password": { + Type: schema.TypeString, + Required: true, + }, + "description": { + Type: schema.TypeString, + Required: true, + }, + }, + } +} + +func resourceArmAutomationCredentialCreateUpdate(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).automationCredentialClient + log.Printf("[INFO] preparing arguments for AzureRM Automation Credential creation.") + + name := d.Get("name").(string) + resGroup := d.Get("resource_group_name").(string) + accName := d.Get("account_name").(string) + user := d.Get("user_name").(string) + password := d.Get("password").(string) + description := d.Get("description").(string) + + parameters := automation.CredentialCreateOrUpdateParameters{ + CredentialCreateOrUpdateProperties: &automation.CredentialCreateOrUpdateProperties{ + UserName: &user, + Password: &password, + Description: &description, + }, + + Name: &name, + } + + _, err := client.CreateOrUpdate(resGroup, accName, name, parameters) + if err != nil { + return err + } + + read, err := client.Get(resGroup, accName, name) + if err != nil { + return err + } + + if read.ID == nil { + return fmt.Errorf("Cannot read Automation Credential '%s' (resource group %s) ID", name, resGroup) + } + + d.SetId(*read.ID) + + return resourceArmAutomationAccountRead(d, meta) +} + +func resourceArmAutomationCredentialRead(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).automationCredentialClient + id, err := parseAzureResourceID(d.Id()) + if err != nil { + return err + } + resGroup := id.ResourceGroup + accName := id.Path["automationAccounts"] + name := id.Path["credentials"] + + resp, err := client.Get(resGroup, accName, name) + + if err != nil { + if responseWasNotFound(resp.Response) { + d.SetId("") + return nil + } + + return fmt.Errorf("Error making Read request on AzureRM Automation Credential '%s': %s", name, err) + } + + d.Set("name", resp.Name) + d.Set("resource_group_name", resGroup) + d.Set("account_name", accName) + d.Set("user_name", resp.UserName) + d.Set("password", nil) + d.Set("description", resp.Description) + + return nil +} + +func resourceArmAutomationCredentialDelete(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).automationCredentialClient + + id, err := parseAzureResourceID(d.Id()) + if err != nil { + return err + } + resGroup := id.ResourceGroup + accName := id.Path["automationAccounts"] + name := id.Path["credentials"] + + resp, err := client.Delete(resGroup, accName, name) + + if err != nil { + if resp.StatusCode == http.StatusNotFound { + return nil + } + + return fmt.Errorf("Error issuing AzureRM delete request for Automation Credential '%s': %+v", name, err) + } + + return nil +} diff --git a/azurerm/resource_arm_automation_credential_test.go b/azurerm/resource_arm_automation_credential_test.go new file mode 100644 index 000000000000..167b781dc704 --- /dev/null +++ b/azurerm/resource_arm_automation_credential_test.go @@ -0,0 +1,121 @@ +package azurerm + +import ( + "fmt" + "net/http" + "testing" + + "github.com/hashicorp/terraform/helper/acctest" + "github.com/hashicorp/terraform/helper/resource" + "github.com/hashicorp/terraform/terraform" +) + +func TestAccAzureRMAutomationCredential_testCredential(t *testing.T) { + ri := acctest.RandInt() + config := testAccAzureRMAutomationCredential_testCredential(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAutomationCredentialDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAutomationCredentialExistsAndUserName("azurerm_automation_credential.test", "test_user"), + ), + ExpectNonEmptyPlan: true, + }, + }, + }) +} + +func testCheckAzureRMAutomationCredentialDestroy(s *terraform.State) error { + conn := testAccProvider.Meta().(*ArmClient).automationCredentialClient + + for _, rs := range s.RootModule().Resources { + if rs.Type != "azurerm_automation_credential" { + continue + } + + name := rs.Primary.Attributes["name"] + accName := rs.Primary.Attributes["account_name"] + resourceGroup := rs.Primary.Attributes["resource_group_name"] + + resp, err := conn.Get(resourceGroup, accName, name) + + if err != nil { + return nil + } + + if resp.StatusCode != http.StatusNotFound { + return fmt.Errorf("Automation Credential still exists:\n%#v", resp) + } + } + + return nil +} + +func testCheckAzureRMAutomationCredentialExistsAndUserName(name string, username string) resource.TestCheckFunc { + + return func(s *terraform.State) error { + // Ensure we have enough information in state to look up in API + rs, ok := s.RootModule().Resources[name] + if !ok { + return fmt.Errorf("Not found: %s", name) + } + + name := rs.Primary.Attributes["name"] + accName := rs.Primary.Attributes["account_name"] + + resourceGroup, hasResourceGroup := rs.Primary.Attributes["resource_group_name"] + if !hasResourceGroup { + return fmt.Errorf("Bad: no resource group found in state for Automation Credential: '%s'", name) + } + + conn := testAccProvider.Meta().(*ArmClient).automationCredentialClient + + resp, err := conn.Get(resourceGroup, accName, name) + + if err != nil { + return fmt.Errorf("Bad: Get on automationCredentialClient: %s\nName: %s, Account name: %s, Resource group: %s OBJECT: %+v", err, name, accName, resourceGroup, rs.Primary) + } + + if resp.StatusCode == http.StatusNotFound { + return fmt.Errorf("Bad: Automation Credential '%s' (resource group: '%s') does not exist", name, resourceGroup) + } + + if *resp.UserName != username { + return fmt.Errorf("Current username %s is not consistant with the checked value %s", resp.UserName, username) + } + + return nil + } +} + +func testAccAzureRMAutomationCredential_testCredential(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_automation_account" "test" { + name = "acctest-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + sku { + name = "Free" + } +} + +resource "azurerm_automation_credential" "test" { + name = "acctest-%d" + resource_group_name = "${azurerm_resource_group.test.name}" + account_name = "${azurerm_automation_account.test.name}" + user_name = "test_user" + password = "test_pwd" + description = "This is a test credential for terraform acceptance test" +} +`, rInt, location, rInt, rInt) +} diff --git a/azurerm/resource_arm_automation_runbook.go b/azurerm/resource_arm_automation_runbook.go new file mode 100644 index 000000000000..a32568a4166a --- /dev/null +++ b/azurerm/resource_arm_automation_runbook.go @@ -0,0 +1,228 @@ +package azurerm + +import ( + "fmt" + "log" + "net/http" + + "github.com/Azure/azure-sdk-for-go/arm/automation" + "github.com/hashicorp/terraform/helper/hashcode" + "github.com/hashicorp/terraform/helper/schema" + "github.com/hashicorp/terraform/helper/validation" +) + +func resourceArmAutomationRunbook() *schema.Resource { + return &schema.Resource{ + Create: resourceArmAutomationRunbookCreateUpdate, + Read: resourceArmAutomationRunbookRead, + Update: resourceArmAutomationRunbookCreateUpdate, + Delete: resourceArmAutomationRunbookDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "account_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "location": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + StateFunc: azureRMNormalizeLocation, + }, + + "resource_group_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "runbook_type": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + DiffSuppressFunc: ignoreCaseDiffSuppressFunc, + ValidateFunc: validation.StringInSlice([]string{ + string(automation.Graph), + string(automation.GraphPowerShell), + string(automation.GraphPowerShellWorkflow), + string(automation.PowerShell), + string(automation.PowerShellWorkflow), + string(automation.Script), + }, true), + }, + + "log_progress": { + Type: schema.TypeBool, + Required: true, + }, + + "log_verbose": { + Type: schema.TypeBool, + Required: true, + }, + + "description": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "publish_content_link": { + Type: schema.TypeSet, + Required: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "uri": { + Type: schema.TypeString, + Required: true, + }, + }, + }, + Set: resourceAzureRMAutomationRunbookContentLinkHash, + }, + "tags": tagsSchema(), + }, + } +} + +func resourceAzureRMAutomationRunbookContentLinkHash(v interface{}) int { + m := v.(map[string]interface{}) + + uri := m["uri"].(string) + + return hashcode.String(uri) +} + +func resourceArmAutomationRunbookCreateUpdate(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).automationRunbookClient + log.Printf("[INFO] preparing arguments for AzureRM Automation Runbook creation.") + + name := d.Get("name").(string) + location := d.Get("location").(string) + resGroup := d.Get("resource_group_name").(string) + tags := d.Get("tags").(map[string]interface{}) + + accName := d.Get("account_name").(string) + runbookType := automation.RunbookTypeEnum(d.Get("runbook_type").(string)) + logProgress := d.Get("log_progress").(bool) + logVerbose := d.Get("log_verbose").(bool) + description := d.Get("description").(string) + + contentLink := expandContentLink(d) + + parameters := automation.RunbookCreateOrUpdateParameters{ + RunbookCreateOrUpdateProperties: &automation.RunbookCreateOrUpdateProperties{ + LogVerbose: &logVerbose, + LogProgress: &logProgress, + RunbookType: runbookType, + Description: &description, + PublishContentLink: &contentLink, + }, + + Name: &name, + Location: &location, + Tags: expandTags(tags), + } + + _, err := client.CreateOrUpdate(resGroup, accName, name, parameters) + if err != nil { + return err + } + + read, err := client.Get(resGroup, accName, name) + if err != nil { + return err + } + + if read.ID == nil { + return fmt.Errorf("Cannot read Automation Runbook '%s' (resource group %s) ID", name, resGroup) + } + + d.SetId(*read.ID) + + return resourceArmAutomationRunbookRead(d, meta) +} + +func resourceArmAutomationRunbookRead(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).automationRunbookClient + id, err := parseAzureResourceID(d.Id()) + if err != nil { + return err + } + resGroup := id.ResourceGroup + accName := id.Path["automationAccounts"] + name := id.Path["runbooks"] + + resp, err := client.Get(resGroup, accName, name) + if err != nil { + if responseWasNotFound(resp.Response) { + d.SetId("") + return nil + } + + return fmt.Errorf("Error making Read request on AzureRM Automation Runbook '%s': %s", name, err) + } + + d.Set("name", resp.Name) + d.Set("location", azureRMNormalizeLocation(*resp.Location)) + d.Set("resource_group_name", resGroup) + + d.Set("account_name", accName) + d.Set("log_verbose", resp.LogVerbose) + d.Set("log_progress", resp.LogProgress) + d.Set("runbook_type", resp.RunbookType) + d.Set("description", resp.Description) + d.Set("publish_content_link", nil) //publish content link is not set during Get() + + flattenAndSetTags(d, resp.Tags) + + return nil +} + +func resourceArmAutomationRunbookDelete(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).automationRunbookClient + + id, err := parseAzureResourceID(d.Id()) + if err != nil { + return err + } + resGroup := id.ResourceGroup + accName := id.Path["automationAccounts"] + name := id.Path["runbooks"] + + resp, err := client.Delete(resGroup, accName, name) + + if err != nil { + if resp.StatusCode == http.StatusNotFound { + return nil + } + + return fmt.Errorf("Error issuing AzureRM delete request for Automation Runbook '%s': %+v", name, err) + } + + return nil +} + +func expandContentLink(d *schema.ResourceData) automation.ContentLink { + inputs := d.Get("publish_content_link").(*schema.Set).List() + input := inputs[0].(map[string]interface{}) + uri := input["uri"].(string) + + contentLink := automation.ContentLink{ + URI: &uri, + } + + return contentLink +} diff --git a/azurerm/resource_arm_automation_runbook_test.go b/azurerm/resource_arm_automation_runbook_test.go new file mode 100644 index 000000000000..00290609d91e --- /dev/null +++ b/azurerm/resource_arm_automation_runbook_test.go @@ -0,0 +1,129 @@ +package azurerm + +import ( + "fmt" + "net/http" + "testing" + + "github.com/hashicorp/terraform/helper/acctest" + "github.com/hashicorp/terraform/helper/resource" + "github.com/hashicorp/terraform/terraform" + + "github.com/Azure/azure-sdk-for-go/arm/automation" +) + +func TestAccAzureRMAutomationRunbook_PSWorkflow(t *testing.T) { + ri := acctest.RandInt() + config := testAccAzureRMAutomationRunbook_PSWorkflow(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAutomationRunbookDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAutomationRunbookExistsAndType("azurerm_automation_runbook.test", automation.PowerShellWorkflow), + ), + ExpectNonEmptyPlan: true, + }, + }, + }) +} + +func testCheckAzureRMAutomationRunbookDestroy(s *terraform.State) error { + conn := testAccProvider.Meta().(*ArmClient).automationRunbookClient + + for _, rs := range s.RootModule().Resources { + if rs.Type != "azurerm_automation_runbook" { + continue + } + + name := rs.Primary.Attributes["name"] + accName := rs.Primary.Attributes["account_name"] + resourceGroup := rs.Primary.Attributes["resource_group_name"] + + resp, err := conn.Get(resourceGroup, accName, name) + + if err != nil { + return nil + } + + if resp.StatusCode != http.StatusNotFound { + return fmt.Errorf("Automation Runbook still exists:\n%#v", resp) + } + } + + return nil +} + +func testCheckAzureRMAutomationRunbookExistsAndType(name string, runbookType automation.RunbookTypeEnum) resource.TestCheckFunc { + + return func(s *terraform.State) error { + // Ensure we have enough information in state to look up in API + rs, ok := s.RootModule().Resources[name] + if !ok { + return fmt.Errorf("Not found: %s", name) + } + + name := rs.Primary.Attributes["name"] + accName := rs.Primary.Attributes["account_name"] + + resourceGroup, hasResourceGroup := rs.Primary.Attributes["resource_group_name"] + if !hasResourceGroup { + return fmt.Errorf("Bad: no resource group found in state for Automation Runbook: '%s'", name) + } + + conn := testAccProvider.Meta().(*ArmClient).automationRunbookClient + + resp, err := conn.Get(resourceGroup, accName, name) + + if err != nil { + return fmt.Errorf("Bad: Get on automationRunbookClient: %s", err) + } + + if resp.StatusCode == http.StatusNotFound { + return fmt.Errorf("Bad: Automation Runbook '%s' (resource group: '%s') does not exist", name, resourceGroup) + } + + if resp.RunbookType != runbookType { + return fmt.Errorf("Current runbook type %s is not consistent with the checked value %s", resp.RunbookType, runbookType) + } + + return nil + } +} + +func testAccAzureRMAutomationRunbook_PSWorkflow(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_automation_account" "test" { + name = "acctest-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + sku { + name = "Free" + } +} + +resource "azurerm_automation_runbook" "test" { + name = "Get-AzureVMTutorial" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + + account_name = "${azurerm_automation_account.test.name}" + log_verbose = "true" + log_progress = "true" + description = "This is a test runbook for terraform acceptance test" + runbook_type = "PowerShellWorkflow" + publish_content_link { + uri = "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-automation-runbook-getvms/Runbooks/Get-AzureVMTutorial.ps1" + } +} +`, rInt, location, rInt) +} diff --git a/azurerm/resource_arm_automation_schedule.go b/azurerm/resource_arm_automation_schedule.go new file mode 100644 index 000000000000..2cffbb47e574 --- /dev/null +++ b/azurerm/resource_arm_automation_schedule.go @@ -0,0 +1,314 @@ +package azurerm + +import ( + "bytes" + "fmt" + "log" + "net/http" + "time" + + "github.com/Azure/azure-sdk-for-go/arm/automation" + "github.com/Azure/go-autorest/autorest/date" + "github.com/hashicorp/terraform/helper/hashcode" + "github.com/hashicorp/terraform/helper/schema" + "github.com/hashicorp/terraform/helper/validation" +) + +func resourceArmAutomationSchedule() *schema.Resource { + return &schema.Resource{ + Create: resourceArmAutomationScheduleCreateUpdate, + Read: resourceArmAutomationScheduleRead, + Update: resourceArmAutomationScheduleCreateUpdate, + Delete: resourceArmAutomationScheduleDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "account_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "description": { + Type: schema.TypeString, + Optional: true, + }, + + "resource_group_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "start_time": { + Type: schema.TypeString, + Optional: true, + }, + + "expiry_time": { + Type: schema.TypeString, + Optional: true, + }, + + "interval": { + Type: schema.TypeInt, + Optional: true, + }, + "frequency": { + Type: schema.TypeString, + Required: true, + DiffSuppressFunc: ignoreCaseDiffSuppressFunc, + ValidateFunc: validation.StringInSlice([]string{ + string(automation.Day), + string(automation.Hour), + string(automation.Month), + string(automation.OneTime), + string(automation.Week), + }, true), + }, + "first_run": { + Type: schema.TypeSet, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "second": { + Type: schema.TypeInt, + Optional: true, + Default: -1, + }, + "minute": { + Type: schema.TypeInt, + Optional: true, + Default: -1, + }, + "hour": { + Type: schema.TypeInt, + Optional: true, + Default: -1, + }, + "day_of_week": { + Type: schema.TypeInt, + Optional: true, + Default: -1, + }, + "day_of_month": { + Type: schema.TypeInt, + Optional: true, + Default: -1, + }, + }, + }, + Set: resourceAzureRMAutomationScheduleFreqConstraint, + }, + }, + } +} + +func resourceAzureRMAutomationScheduleFreqConstraint(v interface{}) int { + var buf bytes.Buffer + m := v.(map[string]interface{}) + + buf.WriteString(fmt.Sprintf("%d-%d-%d-%d-%d-%d", m["second"], m["minute"], m["hour"], m["day_of_week"], m["day_of_month"])) + return hashcode.String(buf.String()) +} + +func computeValidStartTime(firstRunSet *schema.Set, freq automation.ScheduleFrequency) time.Time { + + firstRunSetList := firstRunSet.List() + + closestValidStartTime := time.Now().UTC().Add(time.Duration(7) * time.Minute) + if len(firstRunSetList) == 0 { + return closestValidStartTime + } + + firstRun := firstRunSetList[0].(map[string]interface{}) + + firstRunSec := int(firstRun["second"].(int)) + if firstRunSec == -1 { + firstRunSec = closestValidStartTime.Second() + } + + firstRunMinute := int(firstRun["minute"].(int)) + if firstRunMinute == -1 { + firstRunMinute = closestValidStartTime.Minute() + } + + firstRunHour := int(firstRun["hour"].(int)) + if firstRunHour == -1 { + firstRunHour = closestValidStartTime.Hour() + } + + firstRunDayOfWeek := int(firstRun["day_of_week"].(int)) + if firstRunDayOfWeek == -1 { + firstRunDayOfWeek = int(closestValidStartTime.Weekday()) + } + + firstRunDayOfMonth := int(firstRun["day_of_month"].(int)) + if firstRunDayOfMonth == -1 { + firstRunDayOfMonth = closestValidStartTime.Day() + } + + switch freq { + case automation.Hour: + validStartTime := time.Date(closestValidStartTime.Year(), closestValidStartTime.Month(), closestValidStartTime.Day(), closestValidStartTime.Hour(), firstRunMinute, firstRunSec, 0, time.UTC) + if firstRunMinute <= closestValidStartTime.Minute() { + validStartTime.Add(time.Duration(1) * time.Hour) + } + + return validStartTime + + case automation.Day: + validStartTime := time.Date(closestValidStartTime.Year(), closestValidStartTime.Month(), closestValidStartTime.Day(), firstRunHour, firstRunMinute, firstRunSec, 0, time.UTC) + if firstRunHour <= closestValidStartTime.Hour() { + validStartTime.AddDate(0, 0, 1) + } + return validStartTime + + case automation.Week: + validStartTime := time.Date(closestValidStartTime.Year(), closestValidStartTime.Month(), closestValidStartTime.Day(), firstRunHour, firstRunMinute, firstRunSec, 0, time.UTC) + if firstRunDayOfWeek <= int(closestValidStartTime.Weekday()) { + dayadd := 7 - (int(closestValidStartTime.Weekday()) - firstRunDayOfWeek) + validStartTime.AddDate(0, 0, dayadd) + } + return validStartTime + + case automation.Month: + validStartTime := time.Date(closestValidStartTime.Year(), closestValidStartTime.Month(), firstRunDayOfMonth, firstRunHour, firstRunMinute, firstRunSec, 0, time.UTC) + if firstRunDayOfMonth <= closestValidStartTime.Day() { + validStartTime.AddDate(0, 1, 0) + } + return validStartTime + + case automation.OneTime: + validStartTime := time.Date(closestValidStartTime.Year(), closestValidStartTime.Month(), firstRunDayOfMonth, firstRunHour, firstRunMinute, firstRunSec, 0, time.UTC) + return validStartTime + + } + + fmt.Errorf("Error compute first valid run time") + return closestValidStartTime +} + +func resourceArmAutomationScheduleCreateUpdate(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).automationScheduleClient + log.Printf("[INFO] preparing arguments for AzureRM Automation Schedule creation.") + + name := d.Get("name").(string) + resGroup := d.Get("resource_group_name").(string) + + accName := d.Get("account_name").(string) + freqstr := d.Get("frequency").(string) + freq := automation.ScheduleFrequency(freqstr) + + cst := d.Get("start_time").(string) + var starttime time.Time + + if cst != "" { + var tperr error + starttime, tperr = time.Parse(time.RFC3339, cst) + if tperr != nil { + return fmt.Errorf("Cannot parse start_time: %s", cst) + } + } else { + starttime = computeValidStartTime(d.Get("first_run").(*schema.Set), freq) + } + + ardt := date.Time{Time: starttime} + + //TODO Interval handling + //interval := + description := d.Get("description").(string) + timezone := "UTC" + + parameters := automation.ScheduleCreateOrUpdateParameters{ + Name: &name, + ScheduleCreateOrUpdateProperties: &automation.ScheduleCreateOrUpdateProperties{ + Description: &description, + //Interval: &interval, + Frequency: freq, + StartTime: &ardt, + TimeZone: &timezone, + }, + } + + _, err := client.CreateOrUpdate(resGroup, accName, name, parameters) + if err != nil { + return err + } + + read, err := client.Get(resGroup, accName, name) + if err != nil { + return err + } + + if read.ID == nil { + return fmt.Errorf("Cannot read Automation Schedule '%s' (resource group %s) ID", name, resGroup) + } + + d.SetId(*read.ID) + + return resourceArmAutomationScheduleRead(d, meta) +} + +func resourceArmAutomationScheduleRead(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).automationScheduleClient + id, err := parseAzureResourceID(d.Id()) + if err != nil { + return err + } + resGroup := id.ResourceGroup + accName := id.Path["automationAccounts"] + name := id.Path["schedules"] + + resp, err := client.Get(resGroup, accName, name) + if err != nil { + if responseWasNotFound(resp.Response) { + d.SetId("") + return nil + } + + return fmt.Errorf("Error making Read request on AzureRM Automation Schedule '%s': %s", name, err) + } + + d.Set("name", resp.Name) + d.Set("resource_group_name", resGroup) + d.Set("account_name", accName) + d.Set("frequency", resp.Frequency) + d.Set("interval", resp.Interval) + d.Set("description", resp.Description) + d.Set("start_time", string(resp.StartTime.Format(time.RFC3339))) + d.Set("first_run", nil) + return nil +} + +func resourceArmAutomationScheduleDelete(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).automationScheduleClient + + id, err := parseAzureResourceID(d.Id()) + if err != nil { + return err + } + resGroup := id.ResourceGroup + accName := id.Path["automationAccounts"] + name := id.Path["schedules"] + + resp, err := client.Delete(resGroup, accName, name) + + if err != nil { + if resp.StatusCode == http.StatusNotFound { + return nil + } + + return fmt.Errorf("Error issuing AzureRM delete request for Automation Schedule '%s': %+v", name, err) + } + + return nil +} diff --git a/azurerm/resource_arm_automation_schedule_test.go b/azurerm/resource_arm_automation_schedule_test.go new file mode 100644 index 000000000000..c7de7c5f4095 --- /dev/null +++ b/azurerm/resource_arm_automation_schedule_test.go @@ -0,0 +1,127 @@ +package azurerm + +import ( + "fmt" + "net/http" + "testing" + + "github.com/hashicorp/terraform/helper/acctest" + "github.com/hashicorp/terraform/helper/resource" + "github.com/hashicorp/terraform/terraform" + + "github.com/Azure/azure-sdk-for-go/arm/automation" +) + +func TestAccAzureRMAutomationSchedule_oneTime(t *testing.T) { + ri := acctest.RandInt() + config := testAccAzureRMAutomationSchedule_oneTime(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAutomationScheduleDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAutomationScheduleExistsAndFrequencyType("azurerm_automation_schedule.test", automation.OneTime), + ), + ExpectNonEmptyPlan: true, + }, + }, + }) +} + +func testCheckAzureRMAutomationScheduleDestroy(s *terraform.State) error { + conn := testAccProvider.Meta().(*ArmClient).automationScheduleClient + + for _, rs := range s.RootModule().Resources { + if rs.Type != "azurerm_automation_schedule" { + continue + } + + name := rs.Primary.Attributes["name"] + accName := rs.Primary.Attributes["account_name"] + resourceGroup := rs.Primary.Attributes["resource_group_name"] + + resp, err := conn.Get(resourceGroup, accName, name) + + if err != nil { + return nil + } + + if resp.StatusCode != http.StatusNotFound { + return fmt.Errorf("Automation Schedule still exists:\n%#v", resp) + } + } + + return nil +} + +func testCheckAzureRMAutomationScheduleExistsAndFrequencyType(name string, freq automation.ScheduleFrequency) resource.TestCheckFunc { + + return func(s *terraform.State) error { + // Ensure we have enough information in state to look up in API + rs, ok := s.RootModule().Resources[name] + if !ok { + return fmt.Errorf("Not found: %s", name) + } + + name := rs.Primary.Attributes["name"] + accName := rs.Primary.Attributes["account_name"] + + resourceGroup, hasResourceGroup := rs.Primary.Attributes["resource_group_name"] + if !hasResourceGroup { + return fmt.Errorf("Bad: no resource group found in state for Automation Schedule: '%s'", name) + } + + conn := testAccProvider.Meta().(*ArmClient).automationScheduleClient + + resp, err := conn.Get(resourceGroup, accName, name) + + if err != nil { + return fmt.Errorf("Bad: Get on automationScheduleClient: %s", err) + } + + if resp.StatusCode == http.StatusNotFound { + return fmt.Errorf("Bad: Automation Schedule '%s' (resource group: '%s') does not exist", name, resourceGroup) + } + + + if resp.Frequency != freq { + return fmt.Errorf("Current frequency %s is not consistent with checked value %s", resp.Frequency, freq) + } + return nil + } +} + +func testAccAzureRMAutomationSchedule_oneTime(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_automation_account" "test" { + name = "acctest-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + sku { + name = "Free" + } +} + +resource "azurerm_automation_schedule" "test" { + name = "OneTimer-%d" + resource_group_name = "${azurerm_resource_group.test.name}" + account_name = "${azurerm_automation_account.test.name}" + frequency = "OneTime" + first_run { + "hour" = 20 + "minute" = 5 + "second" = 0 + } + description = "This is a test runbook for terraform acceptance test" +} +`, rInt, location, rInt, rInt) +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/account.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/account.go new file mode 100755 index 000000000000..e651973d5fa6 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/account.go @@ -0,0 +1,514 @@ +package automation + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// AccountClient is the composite Swagger json for Azure Automation Client +type AccountClient struct { + ManagementClient +} + +// NewAccountClient creates an instance of the AccountClient client. +func NewAccountClient(subscriptionID string) AccountClient { + return NewAccountClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAccountClientWithBaseURI creates an instance of the AccountClient client. +func NewAccountClientWithBaseURI(baseURI string, subscriptionID string) AccountClient { + return AccountClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or update automation account. +// +// resourceGroupName is the resource group name. automationAccountName is +// parameters supplied to the create or update automation account. parameters +// is parameters supplied to the create or update automation account. +func (client AccountClient) CreateOrUpdate(resourceGroupName string, automationAccountName string, parameters AccountCreateOrUpdateParameters) (result Account, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.AccountClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, automationAccountName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.AccountClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client AccountClient) CreateOrUpdatePreparer(resourceGroupName string, automationAccountName string, parameters AccountCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client AccountClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client AccountClient) CreateOrUpdateResponder(resp *http.Response) (result Account, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete an automation account. +// +// resourceGroupName is the resource group name. automationAccountName is +// automation account name. +func (client AccountClient) Delete(resourceGroupName string, automationAccountName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.AccountClient", "Delete") + } + + req, err := client.DeletePreparer(resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.AccountClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client AccountClient) DeletePreparer(resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client AccountClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client AccountClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get information about an Automation Account. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. +func (client AccountClient) Get(resourceGroupName string, automationAccountName string) (result Account, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.AccountClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.AccountClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client AccountClient) GetPreparer(resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client AccountClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AccountClient) GetResponder(resp *http.Response) (result Account, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List retrieve a list of accounts within a given subscription. +func (client AccountClient) List() (result AccountListResult, err error) { + req, err := client.ListPreparer() + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.AccountClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client AccountClient) ListPreparer() (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Automation/automationAccounts", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client AccountClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client AccountClient) ListResponder(resp *http.Response) (result AccountListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client AccountClient) ListNextResults(lastResults AccountListResult) (result AccountListResult, err error) { + req, err := lastResults.AccountListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.AccountClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.AccountClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "List", resp, "Failure responding to next results request") + } + + return +} + +// ListByResourceGroup retrieve a list of accounts within a given resource +// group. +// +// resourceGroupName is the resource group name. +func (client AccountClient) ListByResourceGroup(resourceGroupName string) (result AccountListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.AccountClient", "ListByResourceGroup") + } + + req, err := client.ListByResourceGroupPreparer(resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.AccountClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client AccountClient) ListByResourceGroupPreparer(resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client AccountClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client AccountClient) ListByResourceGroupResponder(resp *http.Response) (result AccountListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroupNextResults retrieves the next set of results, if any. +func (client AccountClient) ListByResourceGroupNextResults(lastResults AccountListResult) (result AccountListResult, err error) { + req, err := lastResults.AccountListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.AccountClient", "ListByResourceGroup", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.AccountClient", "ListByResourceGroup", resp, "Failure sending next results request") + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "ListByResourceGroup", resp, "Failure responding to next results request") + } + + return +} + +// Update update an automation account. +// +// resourceGroupName is the resource group name. automationAccountName is +// automation account name. parameters is parameters supplied to the update +// automation account. +func (client AccountClient) Update(resourceGroupName string, automationAccountName string, parameters AccountUpdateParameters) (result Account, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.AccountClient", "Update") + } + + req, err := client.UpdatePreparer(resourceGroupName, automationAccountName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.AccountClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client AccountClient) UpdatePreparer(resourceGroupName string, automationAccountName string, parameters AccountUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client AccountClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client AccountClient) UpdateResponder(resp *http.Response) (result Account, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/activity.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/activity.go new file mode 100755 index 000000000000..a103e55443b1 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/activity.go @@ -0,0 +1,216 @@ +package automation + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// ActivityClient is the composite Swagger json for Azure Automation Client +type ActivityClient struct { + ManagementClient +} + +// NewActivityClient creates an instance of the ActivityClient client. +func NewActivityClient(subscriptionID string) ActivityClient { + return NewActivityClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewActivityClientWithBaseURI creates an instance of the ActivityClient +// client. +func NewActivityClientWithBaseURI(baseURI string, subscriptionID string) ActivityClient { + return ActivityClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get retrieve the activity in the module identified by module name and +// activity name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. moduleName is the name of module. activityName is +// the name of activity. +func (client ActivityClient) Get(resourceGroupName string, automationAccountName string, moduleName string, activityName string) (result Activity, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.ActivityClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName, moduleName, activityName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ActivityClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ActivityClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ActivityClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ActivityClient) GetPreparer(resourceGroupName string, automationAccountName string, moduleName string, activityName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "activityName": autorest.Encode("path", activityName), + "automationAccountName": autorest.Encode("path", automationAccountName), + "moduleName": autorest.Encode("path", moduleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/activities/{activityName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ActivityClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ActivityClient) GetResponder(resp *http.Response) (result Activity, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByModule retrieve a list of activities in the module identified by +// module name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. moduleName is the name of module. +func (client ActivityClient) ListByModule(resourceGroupName string, automationAccountName string, moduleName string) (result ActivityListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.ActivityClient", "ListByModule") + } + + req, err := client.ListByModulePreparer(resourceGroupName, automationAccountName, moduleName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ActivityClient", "ListByModule", nil, "Failure preparing request") + return + } + + resp, err := client.ListByModuleSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ActivityClient", "ListByModule", resp, "Failure sending request") + return + } + + result, err = client.ListByModuleResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ActivityClient", "ListByModule", resp, "Failure responding to request") + } + + return +} + +// ListByModulePreparer prepares the ListByModule request. +func (client ActivityClient) ListByModulePreparer(resourceGroupName string, automationAccountName string, moduleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "moduleName": autorest.Encode("path", moduleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/activities", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByModuleSender sends the ListByModule request. The method will close the +// http.Response Body if it receives an error. +func (client ActivityClient) ListByModuleSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByModuleResponder handles the response to the ListByModule request. The method always +// closes the http.Response Body. +func (client ActivityClient) ListByModuleResponder(resp *http.Response) (result ActivityListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByModuleNextResults retrieves the next set of results, if any. +func (client ActivityClient) ListByModuleNextResults(lastResults ActivityListResult) (result ActivityListResult, err error) { + req, err := lastResults.ActivityListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.ActivityClient", "ListByModule", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByModuleSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.ActivityClient", "ListByModule", resp, "Failure sending next results request") + } + + result, err = client.ListByModuleResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ActivityClient", "ListByModule", resp, "Failure responding to next results request") + } + + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/agentregistrationinformation.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/agentregistrationinformation.go new file mode 100755 index 000000000000..02d16325ca5b --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/agentregistrationinformation.go @@ -0,0 +1,191 @@ +package automation + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// AgentRegistrationInformationClient is the composite Swagger json for Azure +// Automation Client +type AgentRegistrationInformationClient struct { + ManagementClient +} + +// NewAgentRegistrationInformationClient creates an instance of the +// AgentRegistrationInformationClient client. +func NewAgentRegistrationInformationClient(subscriptionID string) AgentRegistrationInformationClient { + return NewAgentRegistrationInformationClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAgentRegistrationInformationClientWithBaseURI creates an instance of the +// AgentRegistrationInformationClient client. +func NewAgentRegistrationInformationClientWithBaseURI(baseURI string, subscriptionID string) AgentRegistrationInformationClient { + return AgentRegistrationInformationClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get retrieve the automation agent registration information. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. +func (client AgentRegistrationInformationClient) Get(resourceGroupName string, automationAccountName string) (result AgentRegistration, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.AgentRegistrationInformationClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AgentRegistrationInformationClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.AgentRegistrationInformationClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AgentRegistrationInformationClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client AgentRegistrationInformationClient) GetPreparer(resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/agentRegistrationInformation", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client AgentRegistrationInformationClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AgentRegistrationInformationClient) GetResponder(resp *http.Response) (result AgentRegistration, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// RegenerateKey regenerate a primary or secondary agent registration key +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. parameters is the name of the agent registration +// key to be regenerated +func (client AgentRegistrationInformationClient) RegenerateKey(resourceGroupName string, automationAccountName string, parameters AgentRegistrationRegenerateKeyParameter) (result AgentRegistration, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.AgentRegistrationInformationClient", "RegenerateKey") + } + + req, err := client.RegenerateKeyPreparer(resourceGroupName, automationAccountName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AgentRegistrationInformationClient", "RegenerateKey", nil, "Failure preparing request") + return + } + + resp, err := client.RegenerateKeySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.AgentRegistrationInformationClient", "RegenerateKey", resp, "Failure sending request") + return + } + + result, err = client.RegenerateKeyResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AgentRegistrationInformationClient", "RegenerateKey", resp, "Failure responding to request") + } + + return +} + +// RegenerateKeyPreparer prepares the RegenerateKey request. +func (client AgentRegistrationInformationClient) RegenerateKeyPreparer(resourceGroupName string, automationAccountName string, parameters AgentRegistrationRegenerateKeyParameter) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/agentRegistrationInformation/regenerateKey", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// RegenerateKeySender sends the RegenerateKey request. The method will close the +// http.Response Body if it receives an error. +func (client AgentRegistrationInformationClient) RegenerateKeySender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// RegenerateKeyResponder handles the response to the RegenerateKey request. The method always +// closes the http.Response Body. +func (client AgentRegistrationInformationClient) RegenerateKeyResponder(resp *http.Response) (result AgentRegistration, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/certificate.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/certificate.go new file mode 100755 index 000000000000..368c73d49f9e --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/certificate.go @@ -0,0 +1,441 @@ +package automation + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// CertificateClient is the composite Swagger json for Azure Automation Client +type CertificateClient struct { + ManagementClient +} + +// NewCertificateClient creates an instance of the CertificateClient client. +func NewCertificateClient(subscriptionID string) CertificateClient { + return NewCertificateClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewCertificateClientWithBaseURI creates an instance of the CertificateClient +// client. +func NewCertificateClientWithBaseURI(baseURI string, subscriptionID string) CertificateClient { + return CertificateClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create a certificate. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. certificateName is the parameters supplied to the +// create or update certificate operation. parameters is the parameters +// supplied to the create or update certificate operation. +func (client CertificateClient) CreateOrUpdate(resourceGroupName string, automationAccountName string, certificateName string, parameters CertificateCreateOrUpdateParameters) (result Certificate, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.CertificateCreateOrUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.CertificateCreateOrUpdateProperties.Base64Value", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.CertificateClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, automationAccountName, certificateName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client CertificateClient) CreateOrUpdatePreparer(resourceGroupName string, automationAccountName string, certificateName string, parameters CertificateCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "certificateName": autorest.Encode("path", certificateName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client CertificateClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client CertificateClient) CreateOrUpdateResponder(resp *http.Response) (result Certificate, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete the certificate. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. certificateName is the name of certificate. +func (client CertificateClient) Delete(resourceGroupName string, automationAccountName string, certificateName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.CertificateClient", "Delete") + } + + req, err := client.DeletePreparer(resourceGroupName, automationAccountName, certificateName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client CertificateClient) DeletePreparer(resourceGroupName string, automationAccountName string, certificateName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "certificateName": autorest.Encode("path", certificateName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client CertificateClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client CertificateClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve the certificate identified by certificate name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. certificateName is the name of certificate. +func (client CertificateClient) Get(resourceGroupName string, automationAccountName string, certificateName string) (result Certificate, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.CertificateClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName, certificateName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client CertificateClient) GetPreparer(resourceGroupName string, automationAccountName string, certificateName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "certificateName": autorest.Encode("path", certificateName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client CertificateClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client CertificateClient) GetResponder(resp *http.Response) (result Certificate, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of certificates. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. +func (client CertificateClient) ListByAutomationAccount(resourceGroupName string, automationAccountName string) (result CertificateListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.CertificateClient", "ListByAutomationAccount") + } + + req, err := client.ListByAutomationAccountPreparer(resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client CertificateClient) ListByAutomationAccountPreparer(resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByAutomationAccountSender sends the ListByAutomationAccount request. The method will close the +// http.Response Body if it receives an error. +func (client CertificateClient) ListByAutomationAccountSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByAutomationAccountResponder handles the response to the ListByAutomationAccount request. The method always +// closes the http.Response Body. +func (client CertificateClient) ListByAutomationAccountResponder(resp *http.Response) (result CertificateListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccountNextResults retrieves the next set of results, if any. +func (client CertificateClient) ListByAutomationAccountNextResults(lastResults CertificateListResult) (result CertificateListResult, err error) { + req, err := lastResults.CertificateListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.CertificateClient", "ListByAutomationAccount", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.CertificateClient", "ListByAutomationAccount", resp, "Failure sending next results request") + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "ListByAutomationAccount", resp, "Failure responding to next results request") + } + + return +} + +// Update update a certificate. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. certificateName is the parameters supplied to the +// update certificate operation. parameters is the parameters supplied to the +// update certificate operation. +func (client CertificateClient) Update(resourceGroupName string, automationAccountName string, certificateName string, parameters CertificateUpdateParameters) (result Certificate, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.CertificateClient", "Update") + } + + req, err := client.UpdatePreparer(resourceGroupName, automationAccountName, certificateName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client CertificateClient) UpdatePreparer(resourceGroupName string, automationAccountName string, certificateName string, parameters CertificateUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "certificateName": autorest.Encode("path", certificateName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client CertificateClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client CertificateClient) UpdateResponder(resp *http.Response) (result Certificate, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/client.go new file mode 100755 index 000000000000..4d2bf5c16e0f --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/client.go @@ -0,0 +1,52 @@ +// Package automation implements the Azure ARM Automation service API version . +// +// Composite Swagger json for Azure Automation Client +package automation + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Automation + DefaultBaseURI = "https://management.azure.com" +) + +// ManagementClient is the base client for Automation. +type ManagementClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the ManagementClient client. +func New(subscriptionID string) ManagementClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the ManagementClient client. +func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient { + return ManagementClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/connection.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/connection.go new file mode 100755 index 000000000000..7d3300e5d0c6 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/connection.go @@ -0,0 +1,442 @@ +package automation + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// ConnectionClient is the composite Swagger json for Azure Automation Client +type ConnectionClient struct { + ManagementClient +} + +// NewConnectionClient creates an instance of the ConnectionClient client. +func NewConnectionClient(subscriptionID string) ConnectionClient { + return NewConnectionClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewConnectionClientWithBaseURI creates an instance of the ConnectionClient +// client. +func NewConnectionClientWithBaseURI(baseURI string, subscriptionID string) ConnectionClient { + return ConnectionClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or update a connection. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. connectionName is the parameters supplied to the +// create or update connection operation. parameters is the parameters supplied +// to the create or update connection operation. +func (client ConnectionClient) CreateOrUpdate(resourceGroupName string, automationAccountName string, connectionName string, parameters ConnectionCreateOrUpdateParameters) (result Connection, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ConnectionCreateOrUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ConnectionCreateOrUpdateProperties.ConnectionType", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.ConnectionClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, automationAccountName, connectionName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ConnectionClient) CreateOrUpdatePreparer(resourceGroupName string, automationAccountName string, connectionName string, parameters ConnectionCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "connectionName": autorest.Encode("path", connectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ConnectionClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ConnectionClient) CreateOrUpdateResponder(resp *http.Response) (result Connection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete the connection. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. connectionName is the name of connection. +func (client ConnectionClient) Delete(resourceGroupName string, automationAccountName string, connectionName string) (result Connection, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.ConnectionClient", "Delete") + } + + req, err := client.DeletePreparer(resourceGroupName, automationAccountName, connectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ConnectionClient) DeletePreparer(resourceGroupName string, automationAccountName string, connectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "connectionName": autorest.Encode("path", connectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ConnectionClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ConnectionClient) DeleteResponder(resp *http.Response) (result Connection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get retrieve the connection identified by connection name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. connectionName is the name of connection. +func (client ConnectionClient) Get(resourceGroupName string, automationAccountName string, connectionName string) (result Connection, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.ConnectionClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName, connectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ConnectionClient) GetPreparer(resourceGroupName string, automationAccountName string, connectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "connectionName": autorest.Encode("path", connectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ConnectionClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ConnectionClient) GetResponder(resp *http.Response) (result Connection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of connections. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. +func (client ConnectionClient) ListByAutomationAccount(resourceGroupName string, automationAccountName string) (result ConnectionListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.ConnectionClient", "ListByAutomationAccount") + } + + req, err := client.ListByAutomationAccountPreparer(resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client ConnectionClient) ListByAutomationAccountPreparer(resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByAutomationAccountSender sends the ListByAutomationAccount request. The method will close the +// http.Response Body if it receives an error. +func (client ConnectionClient) ListByAutomationAccountSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByAutomationAccountResponder handles the response to the ListByAutomationAccount request. The method always +// closes the http.Response Body. +func (client ConnectionClient) ListByAutomationAccountResponder(resp *http.Response) (result ConnectionListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccountNextResults retrieves the next set of results, if any. +func (client ConnectionClient) ListByAutomationAccountNextResults(lastResults ConnectionListResult) (result ConnectionListResult, err error) { + req, err := lastResults.ConnectionListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.ConnectionClient", "ListByAutomationAccount", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.ConnectionClient", "ListByAutomationAccount", resp, "Failure sending next results request") + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "ListByAutomationAccount", resp, "Failure responding to next results request") + } + + return +} + +// Update update a connection. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. connectionName is the parameters supplied to the +// update a connection operation. parameters is the parameters supplied to the +// update a connection operation. +func (client ConnectionClient) Update(resourceGroupName string, automationAccountName string, connectionName string, parameters ConnectionUpdateParameters) (result Connection, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.ConnectionClient", "Update") + } + + req, err := client.UpdatePreparer(resourceGroupName, automationAccountName, connectionName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ConnectionClient) UpdatePreparer(resourceGroupName string, automationAccountName string, connectionName string, parameters ConnectionUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "connectionName": autorest.Encode("path", connectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ConnectionClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ConnectionClient) UpdateResponder(resp *http.Response) (result Connection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/connectiontype.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/connectiontype.go new file mode 100755 index 000000000000..5e2effaf2e4e --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/connectiontype.go @@ -0,0 +1,366 @@ +package automation + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// ConnectionTypeClient is the composite Swagger json for Azure Automation +// Client +type ConnectionTypeClient struct { + ManagementClient +} + +// NewConnectionTypeClient creates an instance of the ConnectionTypeClient +// client. +func NewConnectionTypeClient(subscriptionID string) ConnectionTypeClient { + return NewConnectionTypeClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewConnectionTypeClientWithBaseURI creates an instance of the +// ConnectionTypeClient client. +func NewConnectionTypeClientWithBaseURI(baseURI string, subscriptionID string) ConnectionTypeClient { + return ConnectionTypeClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create a connectiontype. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. connectionTypeName is the parameters supplied to +// the create or update connectiontype operation. parameters is the parameters +// supplied to the create or update connectiontype operation. +func (client ConnectionTypeClient) CreateOrUpdate(resourceGroupName string, automationAccountName string, connectionTypeName string, parameters ConnectionTypeCreateOrUpdateParameters) (result ConnectionType, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ConnectionTypeCreateOrUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ConnectionTypeCreateOrUpdateProperties.FieldDefinitions", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.ConnectionTypeClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, automationAccountName, connectionTypeName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ConnectionTypeClient) CreateOrUpdatePreparer(resourceGroupName string, automationAccountName string, connectionTypeName string, parameters ConnectionTypeCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "connectionTypeName": autorest.Encode("path", connectionTypeName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ConnectionTypeClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ConnectionTypeClient) CreateOrUpdateResponder(resp *http.Response) (result ConnectionType, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusConflict), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete the connectiontype. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. connectionTypeName is the name of connectiontype. +func (client ConnectionTypeClient) Delete(resourceGroupName string, automationAccountName string, connectionTypeName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.ConnectionTypeClient", "Delete") + } + + req, err := client.DeletePreparer(resourceGroupName, automationAccountName, connectionTypeName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ConnectionTypeClient) DeletePreparer(resourceGroupName string, automationAccountName string, connectionTypeName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "connectionTypeName": autorest.Encode("path", connectionTypeName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ConnectionTypeClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ConnectionTypeClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve the connectiontype identified by connectiontype name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. connectionTypeName is the name of connectiontype. +func (client ConnectionTypeClient) Get(resourceGroupName string, automationAccountName string, connectionTypeName string) (result ConnectionType, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.ConnectionTypeClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName, connectionTypeName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ConnectionTypeClient) GetPreparer(resourceGroupName string, automationAccountName string, connectionTypeName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "connectionTypeName": autorest.Encode("path", connectionTypeName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ConnectionTypeClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ConnectionTypeClient) GetResponder(resp *http.Response) (result ConnectionType, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of connectiontypes. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. +func (client ConnectionTypeClient) ListByAutomationAccount(resourceGroupName string, automationAccountName string) (result ConnectionTypeListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.ConnectionTypeClient", "ListByAutomationAccount") + } + + req, err := client.ListByAutomationAccountPreparer(resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client ConnectionTypeClient) ListByAutomationAccountPreparer(resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByAutomationAccountSender sends the ListByAutomationAccount request. The method will close the +// http.Response Body if it receives an error. +func (client ConnectionTypeClient) ListByAutomationAccountSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByAutomationAccountResponder handles the response to the ListByAutomationAccount request. The method always +// closes the http.Response Body. +func (client ConnectionTypeClient) ListByAutomationAccountResponder(resp *http.Response) (result ConnectionTypeListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccountNextResults retrieves the next set of results, if any. +func (client ConnectionTypeClient) ListByAutomationAccountNextResults(lastResults ConnectionTypeListResult) (result ConnectionTypeListResult, err error) { + req, err := lastResults.ConnectionTypeListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "ListByAutomationAccount", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "ListByAutomationAccount", resp, "Failure sending next results request") + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "ListByAutomationAccount", resp, "Failure responding to next results request") + } + + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/credential.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/credential.go new file mode 100755 index 000000000000..5834f6ac000a --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/credential.go @@ -0,0 +1,443 @@ +package automation + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// CredentialClient is the composite Swagger json for Azure Automation Client +type CredentialClient struct { + ManagementClient +} + +// NewCredentialClient creates an instance of the CredentialClient client. +func NewCredentialClient(subscriptionID string) CredentialClient { + return NewCredentialClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewCredentialClientWithBaseURI creates an instance of the CredentialClient +// client. +func NewCredentialClientWithBaseURI(baseURI string, subscriptionID string) CredentialClient { + return CredentialClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create a credential. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. credentialName is the parameters supplied to the +// create or update credential operation. parameters is the parameters supplied +// to the create or update credential operation. +func (client CredentialClient) CreateOrUpdate(resourceGroupName string, automationAccountName string, credentialName string, parameters CredentialCreateOrUpdateParameters) (result Credential, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.CredentialCreateOrUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.CredentialCreateOrUpdateProperties.UserName", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.CredentialCreateOrUpdateProperties.Password", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.CredentialClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, automationAccountName, credentialName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client CredentialClient) CreateOrUpdatePreparer(resourceGroupName string, automationAccountName string, credentialName string, parameters CredentialCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "credentialName": autorest.Encode("path", credentialName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client CredentialClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client CredentialClient) CreateOrUpdateResponder(resp *http.Response) (result Credential, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete the credential. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. credentialName is the name of credential. +func (client CredentialClient) Delete(resourceGroupName string, automationAccountName string, credentialName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.CredentialClient", "Delete") + } + + req, err := client.DeletePreparer(resourceGroupName, automationAccountName, credentialName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client CredentialClient) DeletePreparer(resourceGroupName string, automationAccountName string, credentialName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "credentialName": autorest.Encode("path", credentialName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client CredentialClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client CredentialClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve the credential identified by credential name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. credentialName is the name of credential. +func (client CredentialClient) Get(resourceGroupName string, automationAccountName string, credentialName string) (result Credential, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.CredentialClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName, credentialName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client CredentialClient) GetPreparer(resourceGroupName string, automationAccountName string, credentialName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "credentialName": autorest.Encode("path", credentialName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client CredentialClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client CredentialClient) GetResponder(resp *http.Response) (result Credential, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of credentials. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. +func (client CredentialClient) ListByAutomationAccount(resourceGroupName string, automationAccountName string) (result CredentialListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.CredentialClient", "ListByAutomationAccount") + } + + req, err := client.ListByAutomationAccountPreparer(resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client CredentialClient) ListByAutomationAccountPreparer(resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByAutomationAccountSender sends the ListByAutomationAccount request. The method will close the +// http.Response Body if it receives an error. +func (client CredentialClient) ListByAutomationAccountSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByAutomationAccountResponder handles the response to the ListByAutomationAccount request. The method always +// closes the http.Response Body. +func (client CredentialClient) ListByAutomationAccountResponder(resp *http.Response) (result CredentialListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccountNextResults retrieves the next set of results, if any. +func (client CredentialClient) ListByAutomationAccountNextResults(lastResults CredentialListResult) (result CredentialListResult, err error) { + req, err := lastResults.CredentialListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.CredentialClient", "ListByAutomationAccount", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.CredentialClient", "ListByAutomationAccount", resp, "Failure sending next results request") + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "ListByAutomationAccount", resp, "Failure responding to next results request") + } + + return +} + +// Update update a credential. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. credentialName is the parameters supplied to the +// Update credential operation. parameters is the parameters supplied to the +// Update credential operation. +func (client CredentialClient) Update(resourceGroupName string, automationAccountName string, credentialName string, parameters CredentialUpdateParameters) (result Credential, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.CredentialClient", "Update") + } + + req, err := client.UpdatePreparer(resourceGroupName, automationAccountName, credentialName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client CredentialClient) UpdatePreparer(resourceGroupName string, automationAccountName string, credentialName string, parameters CredentialUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "credentialName": autorest.Encode("path", credentialName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client CredentialClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client CredentialClient) UpdateResponder(resp *http.Response) (result Credential, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/dsccompilationjob.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/dsccompilationjob.go new file mode 100755 index 000000000000..15fe2346d7a7 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/dsccompilationjob.go @@ -0,0 +1,373 @@ +package automation + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/satori/uuid" + "net/http" +) + +// DscCompilationJobClient is the composite Swagger json for Azure Automation +// Client +type DscCompilationJobClient struct { + ManagementClient +} + +// NewDscCompilationJobClient creates an instance of the +// DscCompilationJobClient client. +func NewDscCompilationJobClient(subscriptionID string) DscCompilationJobClient { + return NewDscCompilationJobClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDscCompilationJobClientWithBaseURI creates an instance of the +// DscCompilationJobClient client. +func NewDscCompilationJobClientWithBaseURI(baseURI string, subscriptionID string) DscCompilationJobClient { + return DscCompilationJobClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create creates the Dsc compilation job of the configuration. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. compilationJobID is the the DSC configuration Id. +// parameters is the parameters supplied to the create compilation job +// operation. +func (client DscCompilationJobClient) Create(resourceGroupName string, automationAccountName string, compilationJobID uuid.UUID, parameters DscCompilationJobCreateParameters) (result DscCompilationJob, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.DscCompilationJobCreateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.DscCompilationJobCreateProperties.Configuration", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.DscCompilationJobClient", "Create") + } + + req, err := client.CreatePreparer(resourceGroupName, automationAccountName, compilationJobID, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client DscCompilationJobClient) CreatePreparer(resourceGroupName string, automationAccountName string, compilationJobID uuid.UUID, parameters DscCompilationJobCreateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "compilationJobId": autorest.Encode("path", compilationJobID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{compilationJobId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client DscCompilationJobClient) CreateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client DscCompilationJobClient) CreateResponder(resp *http.Response) (result DscCompilationJob, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get retrieve the Dsc configuration compilation job identified by job id. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. compilationJobID is the Dsc configuration +// compilation job id. +func (client DscCompilationJobClient) Get(resourceGroupName string, automationAccountName string, compilationJobID uuid.UUID) (result DscCompilationJob, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.DscCompilationJobClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName, compilationJobID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client DscCompilationJobClient) GetPreparer(resourceGroupName string, automationAccountName string, compilationJobID uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "compilationJobId": autorest.Encode("path", compilationJobID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{compilationJobId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client DscCompilationJobClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DscCompilationJobClient) GetResponder(resp *http.Response) (result DscCompilationJob, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetStream retrieve the job stream identified by job stream id. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. jobID is the job id. jobStreamID is the job stream +// id. +func (client DscCompilationJobClient) GetStream(resourceGroupName string, automationAccountName string, jobID uuid.UUID, jobStreamID string) (result JobStream, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.DscCompilationJobClient", "GetStream") + } + + req, err := client.GetStreamPreparer(resourceGroupName, automationAccountName, jobID, jobStreamID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "GetStream", nil, "Failure preparing request") + return + } + + resp, err := client.GetStreamSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "GetStream", resp, "Failure sending request") + return + } + + result, err = client.GetStreamResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "GetStream", resp, "Failure responding to request") + } + + return +} + +// GetStreamPreparer prepares the GetStream request. +func (client DscCompilationJobClient) GetStreamPreparer(resourceGroupName string, automationAccountName string, jobID uuid.UUID, jobStreamID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobId": autorest.Encode("path", jobID), + "jobStreamId": autorest.Encode("path", jobStreamID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{jobId}/streams/{jobStreamId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetStreamSender sends the GetStream request. The method will close the +// http.Response Body if it receives an error. +func (client DscCompilationJobClient) GetStreamSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetStreamResponder handles the response to the GetStream request. The method always +// closes the http.Response Body. +func (client DscCompilationJobClient) GetStreamResponder(resp *http.Response) (result JobStream, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of dsc compilation jobs. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. filter is the filter to apply on the operation. +func (client DscCompilationJobClient) ListByAutomationAccount(resourceGroupName string, automationAccountName string, filter string) (result DscCompilationJobListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.DscCompilationJobClient", "ListByAutomationAccount") + } + + req, err := client.ListByAutomationAccountPreparer(resourceGroupName, automationAccountName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client DscCompilationJobClient) ListByAutomationAccountPreparer(resourceGroupName string, automationAccountName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByAutomationAccountSender sends the ListByAutomationAccount request. The method will close the +// http.Response Body if it receives an error. +func (client DscCompilationJobClient) ListByAutomationAccountSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByAutomationAccountResponder handles the response to the ListByAutomationAccount request. The method always +// closes the http.Response Body. +func (client DscCompilationJobClient) ListByAutomationAccountResponder(resp *http.Response) (result DscCompilationJobListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccountNextResults retrieves the next set of results, if any. +func (client DscCompilationJobClient) ListByAutomationAccountNextResults(lastResults DscCompilationJobListResult) (result DscCompilationJobListResult, err error) { + req, err := lastResults.DscCompilationJobListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "ListByAutomationAccount", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "ListByAutomationAccount", resp, "Failure sending next results request") + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "ListByAutomationAccount", resp, "Failure responding to next results request") + } + + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/dscconfiguration.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/dscconfiguration.go new file mode 100755 index 000000000000..88a8fd84562b --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/dscconfiguration.go @@ -0,0 +1,444 @@ +package automation + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// DscConfigurationClient is the composite Swagger json for Azure Automation +// Client +type DscConfigurationClient struct { + ManagementClient +} + +// NewDscConfigurationClient creates an instance of the DscConfigurationClient +// client. +func NewDscConfigurationClient(subscriptionID string) DscConfigurationClient { + return NewDscConfigurationClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDscConfigurationClientWithBaseURI creates an instance of the +// DscConfigurationClient client. +func NewDscConfigurationClientWithBaseURI(baseURI string, subscriptionID string) DscConfigurationClient { + return DscConfigurationClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create the configuration identified by configuration name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. configurationName is the create or update +// parameters for configuration. parameters is the create or update parameters +// for configuration. +func (client DscConfigurationClient) CreateOrUpdate(resourceGroupName string, automationAccountName string, configurationName string, parameters DscConfigurationCreateOrUpdateParameters) (result DscConfiguration, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.DscConfigurationCreateOrUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.DscConfigurationCreateOrUpdateProperties.Source", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.DscConfigurationCreateOrUpdateProperties.Source.Hash", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DscConfigurationCreateOrUpdateProperties.Source.Hash.Algorithm", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.DscConfigurationCreateOrUpdateProperties.Source.Hash.Value", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.DscConfigurationClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, automationAccountName, configurationName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DscConfigurationClient) CreateOrUpdatePreparer(resourceGroupName string, automationAccountName string, configurationName string, parameters DscConfigurationCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "configurationName": autorest.Encode("path", configurationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client DscConfigurationClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DscConfigurationClient) CreateOrUpdateResponder(resp *http.Response) (result DscConfiguration, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete the dsc configuration identified by configuration name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. configurationName is the configuration name. +func (client DscConfigurationClient) Delete(resourceGroupName string, automationAccountName string, configurationName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.DscConfigurationClient", "Delete") + } + + req, err := client.DeletePreparer(resourceGroupName, automationAccountName, configurationName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client DscConfigurationClient) DeletePreparer(resourceGroupName string, automationAccountName string, configurationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "configurationName": autorest.Encode("path", configurationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client DscConfigurationClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DscConfigurationClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve the configuration identified by configuration name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. configurationName is the configuration name. +func (client DscConfigurationClient) Get(resourceGroupName string, automationAccountName string, configurationName string) (result DscConfiguration, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.DscConfigurationClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName, configurationName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client DscConfigurationClient) GetPreparer(resourceGroupName string, automationAccountName string, configurationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "configurationName": autorest.Encode("path", configurationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client DscConfigurationClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DscConfigurationClient) GetResponder(resp *http.Response) (result DscConfiguration, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetContent retrieve the configuration script identified by configuration +// name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. configurationName is the configuration name. +func (client DscConfigurationClient) GetContent(resourceGroupName string, automationAccountName string, configurationName string) (result ReadCloser, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.DscConfigurationClient", "GetContent") + } + + req, err := client.GetContentPreparer(resourceGroupName, automationAccountName, configurationName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "GetContent", nil, "Failure preparing request") + return + } + + resp, err := client.GetContentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "GetContent", resp, "Failure sending request") + return + } + + result, err = client.GetContentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "GetContent", resp, "Failure responding to request") + } + + return +} + +// GetContentPreparer prepares the GetContent request. +func (client DscConfigurationClient) GetContentPreparer(resourceGroupName string, automationAccountName string, configurationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "configurationName": autorest.Encode("path", configurationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}/content", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetContentSender sends the GetContent request. The method will close the +// http.Response Body if it receives an error. +func (client DscConfigurationClient) GetContentSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetContentResponder handles the response to the GetContent request. The method always +// closes the http.Response Body. +func (client DscConfigurationClient) GetContentResponder(resp *http.Response) (result ReadCloser, err error) { + result.Value = &resp.Body + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK)) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of configurations. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. +func (client DscConfigurationClient) ListByAutomationAccount(resourceGroupName string, automationAccountName string) (result DscConfigurationListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.DscConfigurationClient", "ListByAutomationAccount") + } + + req, err := client.ListByAutomationAccountPreparer(resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client DscConfigurationClient) ListByAutomationAccountPreparer(resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByAutomationAccountSender sends the ListByAutomationAccount request. The method will close the +// http.Response Body if it receives an error. +func (client DscConfigurationClient) ListByAutomationAccountSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByAutomationAccountResponder handles the response to the ListByAutomationAccount request. The method always +// closes the http.Response Body. +func (client DscConfigurationClient) ListByAutomationAccountResponder(resp *http.Response) (result DscConfigurationListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccountNextResults retrieves the next set of results, if any. +func (client DscConfigurationClient) ListByAutomationAccountNextResults(lastResults DscConfigurationListResult) (result DscConfigurationListResult, err error) { + req, err := lastResults.DscConfigurationListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "ListByAutomationAccount", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "ListByAutomationAccount", resp, "Failure sending next results request") + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "ListByAutomationAccount", resp, "Failure responding to next results request") + } + + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/dscnode.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/dscnode.go new file mode 100755 index 000000000000..fbeb848b19ae --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/dscnode.go @@ -0,0 +1,362 @@ +package automation + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// DscNodeClient is the composite Swagger json for Azure Automation Client +type DscNodeClient struct { + ManagementClient +} + +// NewDscNodeClient creates an instance of the DscNodeClient client. +func NewDscNodeClient(subscriptionID string) DscNodeClient { + return NewDscNodeClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDscNodeClientWithBaseURI creates an instance of the DscNodeClient client. +func NewDscNodeClientWithBaseURI(baseURI string, subscriptionID string) DscNodeClient { + return DscNodeClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Delete delete the dsc node identified by node id. +// +// resourceGroupName is the resource group name. automationAccountName is +// automation account name. nodeID is the node id. +func (client DscNodeClient) Delete(resourceGroupName string, automationAccountName string, nodeID string) (result DscNode, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.DscNodeClient", "Delete") + } + + req, err := client.DeletePreparer(resourceGroupName, automationAccountName, nodeID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client DscNodeClient) DeletePreparer(resourceGroupName string, automationAccountName string, nodeID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "nodeId": autorest.Encode("path", nodeID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client DscNodeClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DscNodeClient) DeleteResponder(resp *http.Response) (result DscNode, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get retrieve the dsc node identified by node id. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. nodeID is the node id. +func (client DscNodeClient) Get(resourceGroupName string, automationAccountName string, nodeID string) (result DscNode, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.DscNodeClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName, nodeID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client DscNodeClient) GetPreparer(resourceGroupName string, automationAccountName string, nodeID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "nodeId": autorest.Encode("path", nodeID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client DscNodeClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DscNodeClient) GetResponder(resp *http.Response) (result DscNode, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of dsc nodes. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. filter is the filter to apply on the operation. +func (client DscNodeClient) ListByAutomationAccount(resourceGroupName string, automationAccountName string, filter string) (result DscNodeListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.DscNodeClient", "ListByAutomationAccount") + } + + req, err := client.ListByAutomationAccountPreparer(resourceGroupName, automationAccountName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client DscNodeClient) ListByAutomationAccountPreparer(resourceGroupName string, automationAccountName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByAutomationAccountSender sends the ListByAutomationAccount request. The method will close the +// http.Response Body if it receives an error. +func (client DscNodeClient) ListByAutomationAccountSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByAutomationAccountResponder handles the response to the ListByAutomationAccount request. The method always +// closes the http.Response Body. +func (client DscNodeClient) ListByAutomationAccountResponder(resp *http.Response) (result DscNodeListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccountNextResults retrieves the next set of results, if any. +func (client DscNodeClient) ListByAutomationAccountNextResults(lastResults DscNodeListResult) (result DscNodeListResult, err error) { + req, err := lastResults.DscNodeListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.DscNodeClient", "ListByAutomationAccount", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.DscNodeClient", "ListByAutomationAccount", resp, "Failure sending next results request") + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "ListByAutomationAccount", resp, "Failure responding to next results request") + } + + return +} + +// Update update the dsc node. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. nodeID is parameters supplied to the update dsc +// node. parameters is parameters supplied to the update dsc node. +func (client DscNodeClient) Update(resourceGroupName string, automationAccountName string, nodeID string, parameters DscNodeUpdateParameters) (result DscNode, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.DscNodeClient", "Update") + } + + req, err := client.UpdatePreparer(resourceGroupName, automationAccountName, nodeID, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client DscNodeClient) UpdatePreparer(resourceGroupName string, automationAccountName string, nodeID string, parameters DscNodeUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "nodeId": autorest.Encode("path", nodeID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client DscNodeClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client DscNodeClient) UpdateResponder(resp *http.Response) (result DscNode, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/dscnodeconfiguration.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/dscnodeconfiguration.go new file mode 100755 index 000000000000..32c31ea073ff --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/dscnodeconfiguration.go @@ -0,0 +1,377 @@ +package automation + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// DscNodeConfigurationClient is the composite Swagger json for Azure +// Automation Client +type DscNodeConfigurationClient struct { + ManagementClient +} + +// NewDscNodeConfigurationClient creates an instance of the +// DscNodeConfigurationClient client. +func NewDscNodeConfigurationClient(subscriptionID string) DscNodeConfigurationClient { + return NewDscNodeConfigurationClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDscNodeConfigurationClientWithBaseURI creates an instance of the +// DscNodeConfigurationClient client. +func NewDscNodeConfigurationClientWithBaseURI(baseURI string, subscriptionID string) DscNodeConfigurationClient { + return DscNodeConfigurationClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create the node configuration identified by node +// configuration name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. nodeConfigurationName is the create or update +// parameters for configuration. parameters is the create or update parameters +// for configuration. +func (client DscNodeConfigurationClient) CreateOrUpdate(resourceGroupName string, automationAccountName string, nodeConfigurationName string, parameters DscNodeConfigurationCreateOrUpdateParameters) (result DscNodeConfiguration, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Source", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.Source.Hash", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Source.Hash.Algorithm", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Source.Hash.Value", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}, + {Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Configuration", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.DscNodeConfigurationClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, automationAccountName, nodeConfigurationName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DscNodeConfigurationClient) CreateOrUpdatePreparer(resourceGroupName string, automationAccountName string, nodeConfigurationName string, parameters DscNodeConfigurationCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "nodeConfigurationName": autorest.Encode("path", nodeConfigurationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client DscNodeConfigurationClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DscNodeConfigurationClient) CreateOrUpdateResponder(resp *http.Response) (result DscNodeConfiguration, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete the Dsc node configurations by node configuration. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. nodeConfigurationName is the Dsc node configuration +// name. +func (client DscNodeConfigurationClient) Delete(resourceGroupName string, automationAccountName string, nodeConfigurationName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.DscNodeConfigurationClient", "Delete") + } + + req, err := client.DeletePreparer(resourceGroupName, automationAccountName, nodeConfigurationName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client DscNodeConfigurationClient) DeletePreparer(resourceGroupName string, automationAccountName string, nodeConfigurationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "nodeConfigurationName": autorest.Encode("path", nodeConfigurationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client DscNodeConfigurationClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DscNodeConfigurationClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve the Dsc node configurations by node configuration. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. nodeConfigurationName is the Dsc node configuration +// name. +func (client DscNodeConfigurationClient) Get(resourceGroupName string, automationAccountName string, nodeConfigurationName string) (result DscNodeConfiguration, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.DscNodeConfigurationClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName, nodeConfigurationName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client DscNodeConfigurationClient) GetPreparer(resourceGroupName string, automationAccountName string, nodeConfigurationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "nodeConfigurationName": autorest.Encode("path", nodeConfigurationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client DscNodeConfigurationClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DscNodeConfigurationClient) GetResponder(resp *http.Response) (result DscNodeConfiguration, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of dsc node configurations. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. filter is the filter to apply on the operation. +func (client DscNodeConfigurationClient) ListByAutomationAccount(resourceGroupName string, automationAccountName string, filter string) (result DscNodeConfigurationListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.DscNodeConfigurationClient", "ListByAutomationAccount") + } + + req, err := client.ListByAutomationAccountPreparer(resourceGroupName, automationAccountName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client DscNodeConfigurationClient) ListByAutomationAccountPreparer(resourceGroupName string, automationAccountName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByAutomationAccountSender sends the ListByAutomationAccount request. The method will close the +// http.Response Body if it receives an error. +func (client DscNodeConfigurationClient) ListByAutomationAccountSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByAutomationAccountResponder handles the response to the ListByAutomationAccount request. The method always +// closes the http.Response Body. +func (client DscNodeConfigurationClient) ListByAutomationAccountResponder(resp *http.Response) (result DscNodeConfigurationListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccountNextResults retrieves the next set of results, if any. +func (client DscNodeConfigurationClient) ListByAutomationAccountNextResults(lastResults DscNodeConfigurationListResult) (result DscNodeConfigurationListResult, err error) { + req, err := lastResults.DscNodeConfigurationListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "ListByAutomationAccount", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "ListByAutomationAccount", resp, "Failure sending next results request") + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "ListByAutomationAccount", resp, "Failure responding to next results request") + } + + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/fields.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/fields.go new file mode 100755 index 000000000000..ef597c0fb63c --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/fields.go @@ -0,0 +1,117 @@ +package automation + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// FieldsClient is the composite Swagger json for Azure Automation Client +type FieldsClient struct { + ManagementClient +} + +// NewFieldsClient creates an instance of the FieldsClient client. +func NewFieldsClient(subscriptionID string) FieldsClient { + return NewFieldsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewFieldsClientWithBaseURI creates an instance of the FieldsClient client. +func NewFieldsClientWithBaseURI(baseURI string, subscriptionID string) FieldsClient { + return FieldsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByType retrieve a list of fields of a given type identified by module +// name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. moduleName is the name of module. typeName is the +// name of type. +func (client FieldsClient) ListByType(resourceGroupName string, automationAccountName string, moduleName string, typeName string) (result TypeFieldListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.FieldsClient", "ListByType") + } + + req, err := client.ListByTypePreparer(resourceGroupName, automationAccountName, moduleName, typeName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.FieldsClient", "ListByType", nil, "Failure preparing request") + return + } + + resp, err := client.ListByTypeSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.FieldsClient", "ListByType", resp, "Failure sending request") + return + } + + result, err = client.ListByTypeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.FieldsClient", "ListByType", resp, "Failure responding to request") + } + + return +} + +// ListByTypePreparer prepares the ListByType request. +func (client FieldsClient) ListByTypePreparer(resourceGroupName string, automationAccountName string, moduleName string, typeName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "moduleName": autorest.Encode("path", moduleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "typeName": autorest.Encode("path", typeName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/types/{typeName}/fields", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByTypeSender sends the ListByType request. The method will close the +// http.Response Body if it receives an error. +func (client FieldsClient) ListByTypeSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByTypeResponder handles the response to the ListByType request. The method always +// closes the http.Response Body. +func (client FieldsClient) ListByTypeResponder(resp *http.Response) (result TypeFieldListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/hybridrunbookworkergroup.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/hybridrunbookworkergroup.go new file mode 100755 index 000000000000..b36eb3b681e8 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/hybridrunbookworkergroup.go @@ -0,0 +1,363 @@ +package automation + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// HybridRunbookWorkerGroupClient is the composite Swagger json for Azure +// Automation Client +type HybridRunbookWorkerGroupClient struct { + ManagementClient +} + +// NewHybridRunbookWorkerGroupClient creates an instance of the +// HybridRunbookWorkerGroupClient client. +func NewHybridRunbookWorkerGroupClient(subscriptionID string) HybridRunbookWorkerGroupClient { + return NewHybridRunbookWorkerGroupClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewHybridRunbookWorkerGroupClientWithBaseURI creates an instance of the +// HybridRunbookWorkerGroupClient client. +func NewHybridRunbookWorkerGroupClientWithBaseURI(baseURI string, subscriptionID string) HybridRunbookWorkerGroupClient { + return HybridRunbookWorkerGroupClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Delete delete a hybrid runbook worker group. +// +// resourceGroupName is the resource group name. automationAccountName is +// automation account name. hybridRunbookWorkerGroupName is the hybrid runbook +// worker group name +func (client HybridRunbookWorkerGroupClient) Delete(resourceGroupName string, automationAccountName string, hybridRunbookWorkerGroupName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.HybridRunbookWorkerGroupClient", "Delete") + } + + req, err := client.DeletePreparer(resourceGroupName, automationAccountName, hybridRunbookWorkerGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client HybridRunbookWorkerGroupClient) DeletePreparer(resourceGroupName string, automationAccountName string, hybridRunbookWorkerGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "hybridRunbookWorkerGroupName": autorest.Encode("path", hybridRunbookWorkerGroupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client HybridRunbookWorkerGroupClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client HybridRunbookWorkerGroupClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve a hybrid runbook worker group. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. hybridRunbookWorkerGroupName is the hybrid runbook +// worker group name +func (client HybridRunbookWorkerGroupClient) Get(resourceGroupName string, automationAccountName string, hybridRunbookWorkerGroupName string) (result HybridRunbookWorkerGroup, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.HybridRunbookWorkerGroupClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName, hybridRunbookWorkerGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client HybridRunbookWorkerGroupClient) GetPreparer(resourceGroupName string, automationAccountName string, hybridRunbookWorkerGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "hybridRunbookWorkerGroupName": autorest.Encode("path", hybridRunbookWorkerGroupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client HybridRunbookWorkerGroupClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client HybridRunbookWorkerGroupClient) GetResponder(resp *http.Response) (result HybridRunbookWorkerGroup, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of hybrid runbook worker groups. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. +func (client HybridRunbookWorkerGroupClient) ListByAutomationAccount(resourceGroupName string, automationAccountName string) (result HybridRunbookWorkerGroupsListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.HybridRunbookWorkerGroupClient", "ListByAutomationAccount") + } + + req, err := client.ListByAutomationAccountPreparer(resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client HybridRunbookWorkerGroupClient) ListByAutomationAccountPreparer(resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByAutomationAccountSender sends the ListByAutomationAccount request. The method will close the +// http.Response Body if it receives an error. +func (client HybridRunbookWorkerGroupClient) ListByAutomationAccountSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByAutomationAccountResponder handles the response to the ListByAutomationAccount request. The method always +// closes the http.Response Body. +func (client HybridRunbookWorkerGroupClient) ListByAutomationAccountResponder(resp *http.Response) (result HybridRunbookWorkerGroupsListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccountNextResults retrieves the next set of results, if any. +func (client HybridRunbookWorkerGroupClient) ListByAutomationAccountNextResults(lastResults HybridRunbookWorkerGroupsListResult) (result HybridRunbookWorkerGroupsListResult, err error) { + req, err := lastResults.HybridRunbookWorkerGroupsListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "ListByAutomationAccount", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "ListByAutomationAccount", resp, "Failure sending next results request") + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "ListByAutomationAccount", resp, "Failure responding to next results request") + } + + return +} + +// Update update a hybrid runbook worker group. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. hybridRunbookWorkerGroupName is the hybrid runbook +// worker group name parameters is the hybrid runbook worker group +func (client HybridRunbookWorkerGroupClient) Update(resourceGroupName string, automationAccountName string, hybridRunbookWorkerGroupName string, parameters HybridRunbookWorkerGroupUpdateParameters) (result HybridRunbookWorkerGroup, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.HybridRunbookWorkerGroupClient", "Update") + } + + req, err := client.UpdatePreparer(resourceGroupName, automationAccountName, hybridRunbookWorkerGroupName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client HybridRunbookWorkerGroupClient) UpdatePreparer(resourceGroupName string, automationAccountName string, hybridRunbookWorkerGroupName string, parameters HybridRunbookWorkerGroupUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "hybridRunbookWorkerGroupName": autorest.Encode("path", hybridRunbookWorkerGroupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client HybridRunbookWorkerGroupClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client HybridRunbookWorkerGroupClient) UpdateResponder(resp *http.Response) (result HybridRunbookWorkerGroup, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/job.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/job.go new file mode 100755 index 000000000000..d1257ab970cf --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/job.go @@ -0,0 +1,654 @@ +package automation + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/satori/uuid" + "net/http" +) + +// JobClient is the composite Swagger json for Azure Automation Client +type JobClient struct { + ManagementClient +} + +// NewJobClient creates an instance of the JobClient client. +func NewJobClient(subscriptionID string) JobClient { + return NewJobClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewJobClientWithBaseURI creates an instance of the JobClient client. +func NewJobClientWithBaseURI(baseURI string, subscriptionID string) JobClient { + return JobClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create create a job of the runbook. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. jobID is the job id. parameters is the parameters +// supplied to the create job operation. +func (client JobClient) Create(resourceGroupName string, automationAccountName string, jobID uuid.UUID, parameters JobCreateParameters) (result Job, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.JobCreateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.JobCreateProperties.Runbook", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.JobClient", "Create") + } + + req, err := client.CreatePreparer(resourceGroupName, automationAccountName, jobID, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.JobClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client JobClient) CreatePreparer(resourceGroupName string, automationAccountName string, jobID uuid.UUID, parameters JobCreateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobId": autorest.Encode("path", jobID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client JobClient) CreateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client JobClient) CreateResponder(resp *http.Response) (result Job, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get retrieve the job identified by job id. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. jobID is the job id. +func (client JobClient) Get(resourceGroupName string, automationAccountName string, jobID uuid.UUID) (result Job, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.JobClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName, jobID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.JobClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client JobClient) GetPreparer(resourceGroupName string, automationAccountName string, jobID uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobId": autorest.Encode("path", jobID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client JobClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client JobClient) GetResponder(resp *http.Response) (result Job, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetOutput retrieve the job output identified by job id. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. jobID is the job id. +func (client JobClient) GetOutput(resourceGroupName string, automationAccountName string, jobID string) (result ReadCloser, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.JobClient", "GetOutput") + } + + req, err := client.GetOutputPreparer(resourceGroupName, automationAccountName, jobID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "GetOutput", nil, "Failure preparing request") + return + } + + resp, err := client.GetOutputSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.JobClient", "GetOutput", resp, "Failure sending request") + return + } + + result, err = client.GetOutputResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "GetOutput", resp, "Failure responding to request") + } + + return +} + +// GetOutputPreparer prepares the GetOutput request. +func (client JobClient) GetOutputPreparer(resourceGroupName string, automationAccountName string, jobID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobId": autorest.Encode("path", jobID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobId}/output", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetOutputSender sends the GetOutput request. The method will close the +// http.Response Body if it receives an error. +func (client JobClient) GetOutputSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetOutputResponder handles the response to the GetOutput request. The method always +// closes the http.Response Body. +func (client JobClient) GetOutputResponder(resp *http.Response) (result ReadCloser, err error) { + result.Value = &resp.Body + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK)) + result.Response = autorest.Response{Response: resp} + return +} + +// GetRunbookContent retrieve the runbook content of the job identified by job +// id. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. jobID is the job id. +func (client JobClient) GetRunbookContent(resourceGroupName string, automationAccountName string, jobID string) (result ReadCloser, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.JobClient", "GetRunbookContent") + } + + req, err := client.GetRunbookContentPreparer(resourceGroupName, automationAccountName, jobID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "GetRunbookContent", nil, "Failure preparing request") + return + } + + resp, err := client.GetRunbookContentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.JobClient", "GetRunbookContent", resp, "Failure sending request") + return + } + + result, err = client.GetRunbookContentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "GetRunbookContent", resp, "Failure responding to request") + } + + return +} + +// GetRunbookContentPreparer prepares the GetRunbookContent request. +func (client JobClient) GetRunbookContentPreparer(resourceGroupName string, automationAccountName string, jobID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobId": autorest.Encode("path", jobID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobId}/runbookContent", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetRunbookContentSender sends the GetRunbookContent request. The method will close the +// http.Response Body if it receives an error. +func (client JobClient) GetRunbookContentSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetRunbookContentResponder handles the response to the GetRunbookContent request. The method always +// closes the http.Response Body. +func (client JobClient) GetRunbookContentResponder(resp *http.Response) (result ReadCloser, err error) { + result.Value = &resp.Body + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK)) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of jobs. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. filter is the filter to apply on the operation. +func (client JobClient) ListByAutomationAccount(resourceGroupName string, automationAccountName string, filter string) (result JobListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.JobClient", "ListByAutomationAccount") + } + + req, err := client.ListByAutomationAccountPreparer(resourceGroupName, automationAccountName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.JobClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client JobClient) ListByAutomationAccountPreparer(resourceGroupName string, automationAccountName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByAutomationAccountSender sends the ListByAutomationAccount request. The method will close the +// http.Response Body if it receives an error. +func (client JobClient) ListByAutomationAccountSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByAutomationAccountResponder handles the response to the ListByAutomationAccount request. The method always +// closes the http.Response Body. +func (client JobClient) ListByAutomationAccountResponder(resp *http.Response) (result JobListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccountNextResults retrieves the next set of results, if any. +func (client JobClient) ListByAutomationAccountNextResults(lastResults JobListResult) (result JobListResult, err error) { + req, err := lastResults.JobListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.JobClient", "ListByAutomationAccount", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.JobClient", "ListByAutomationAccount", resp, "Failure sending next results request") + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "ListByAutomationAccount", resp, "Failure responding to next results request") + } + + return +} + +// Resume resume the job identified by jobId. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. jobID is the job id. +func (client JobClient) Resume(resourceGroupName string, automationAccountName string, jobID uuid.UUID) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.JobClient", "Resume") + } + + req, err := client.ResumePreparer(resourceGroupName, automationAccountName, jobID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "Resume", nil, "Failure preparing request") + return + } + + resp, err := client.ResumeSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.JobClient", "Resume", resp, "Failure sending request") + return + } + + result, err = client.ResumeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "Resume", resp, "Failure responding to request") + } + + return +} + +// ResumePreparer prepares the Resume request. +func (client JobClient) ResumePreparer(resourceGroupName string, automationAccountName string, jobID uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobId": autorest.Encode("path", jobID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobId}/resume", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ResumeSender sends the Resume request. The method will close the +// http.Response Body if it receives an error. +func (client JobClient) ResumeSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ResumeResponder handles the response to the Resume request. The method always +// closes the http.Response Body. +func (client JobClient) ResumeResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Stop stop the job identified by jobId. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. jobID is the job id. +func (client JobClient) Stop(resourceGroupName string, automationAccountName string, jobID uuid.UUID) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.JobClient", "Stop") + } + + req, err := client.StopPreparer(resourceGroupName, automationAccountName, jobID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "Stop", nil, "Failure preparing request") + return + } + + resp, err := client.StopSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.JobClient", "Stop", resp, "Failure sending request") + return + } + + result, err = client.StopResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "Stop", resp, "Failure responding to request") + } + + return +} + +// StopPreparer prepares the Stop request. +func (client JobClient) StopPreparer(resourceGroupName string, automationAccountName string, jobID uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobId": autorest.Encode("path", jobID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobId}/stop", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// StopSender sends the Stop request. The method will close the +// http.Response Body if it receives an error. +func (client JobClient) StopSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// StopResponder handles the response to the Stop request. The method always +// closes the http.Response Body. +func (client JobClient) StopResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Suspend suspend the job identified by jobId. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. jobID is the job id. +func (client JobClient) Suspend(resourceGroupName string, automationAccountName string, jobID uuid.UUID) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.JobClient", "Suspend") + } + + req, err := client.SuspendPreparer(resourceGroupName, automationAccountName, jobID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "Suspend", nil, "Failure preparing request") + return + } + + resp, err := client.SuspendSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.JobClient", "Suspend", resp, "Failure sending request") + return + } + + result, err = client.SuspendResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "Suspend", resp, "Failure responding to request") + } + + return +} + +// SuspendPreparer prepares the Suspend request. +func (client JobClient) SuspendPreparer(resourceGroupName string, automationAccountName string, jobID uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobId": autorest.Encode("path", jobID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobId}/suspend", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// SuspendSender sends the Suspend request. The method will close the +// http.Response Body if it receives an error. +func (client JobClient) SuspendSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// SuspendResponder handles the response to the Suspend request. The method always +// closes the http.Response Body. +func (client JobClient) SuspendResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/jobschedule.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/jobschedule.go new file mode 100755 index 000000000000..a10ec7dba6dd --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/jobschedule.go @@ -0,0 +1,365 @@ +package automation + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/satori/uuid" + "net/http" +) + +// JobScheduleClient is the composite Swagger json for Azure Automation Client +type JobScheduleClient struct { + ManagementClient +} + +// NewJobScheduleClient creates an instance of the JobScheduleClient client. +func NewJobScheduleClient(subscriptionID string) JobScheduleClient { + return NewJobScheduleClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewJobScheduleClientWithBaseURI creates an instance of the JobScheduleClient +// client. +func NewJobScheduleClientWithBaseURI(baseURI string, subscriptionID string) JobScheduleClient { + return JobScheduleClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create create a job schedule. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. jobScheduleID is the job schedule name. parameters +// is the parameters supplied to the create job schedule operation. +func (client JobScheduleClient) Create(resourceGroupName string, automationAccountName string, jobScheduleID uuid.UUID, parameters JobScheduleCreateParameters) (result JobSchedule, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.JobScheduleCreateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.JobScheduleCreateProperties.Schedule", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.JobScheduleCreateProperties.Runbook", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.JobScheduleClient", "Create") + } + + req, err := client.CreatePreparer(resourceGroupName, automationAccountName, jobScheduleID, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client JobScheduleClient) CreatePreparer(resourceGroupName string, automationAccountName string, jobScheduleID uuid.UUID, parameters JobScheduleCreateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobScheduleId": autorest.Encode("path", jobScheduleID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client JobScheduleClient) CreateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client JobScheduleClient) CreateResponder(resp *http.Response) (result JobSchedule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete the job schedule identified by job schedule name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. jobScheduleID is the job schedule name. +func (client JobScheduleClient) Delete(resourceGroupName string, automationAccountName string, jobScheduleID uuid.UUID) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.JobScheduleClient", "Delete") + } + + req, err := client.DeletePreparer(resourceGroupName, automationAccountName, jobScheduleID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client JobScheduleClient) DeletePreparer(resourceGroupName string, automationAccountName string, jobScheduleID uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobScheduleId": autorest.Encode("path", jobScheduleID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client JobScheduleClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client JobScheduleClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve the job schedule identified by job schedule name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. jobScheduleID is the job schedule name. +func (client JobScheduleClient) Get(resourceGroupName string, automationAccountName string, jobScheduleID uuid.UUID) (result JobSchedule, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.JobScheduleClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName, jobScheduleID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client JobScheduleClient) GetPreparer(resourceGroupName string, automationAccountName string, jobScheduleID uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobScheduleId": autorest.Encode("path", jobScheduleID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client JobScheduleClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client JobScheduleClient) GetResponder(resp *http.Response) (result JobSchedule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of job schedules. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. +func (client JobScheduleClient) ListByAutomationAccount(resourceGroupName string, automationAccountName string) (result JobScheduleListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.JobScheduleClient", "ListByAutomationAccount") + } + + req, err := client.ListByAutomationAccountPreparer(resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client JobScheduleClient) ListByAutomationAccountPreparer(resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByAutomationAccountSender sends the ListByAutomationAccount request. The method will close the +// http.Response Body if it receives an error. +func (client JobScheduleClient) ListByAutomationAccountSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByAutomationAccountResponder handles the response to the ListByAutomationAccount request. The method always +// closes the http.Response Body. +func (client JobScheduleClient) ListByAutomationAccountResponder(resp *http.Response) (result JobScheduleListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccountNextResults retrieves the next set of results, if any. +func (client JobScheduleClient) ListByAutomationAccountNextResults(lastResults JobScheduleListResult) (result JobScheduleListResult, err error) { + req, err := lastResults.JobScheduleListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.JobScheduleClient", "ListByAutomationAccount", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.JobScheduleClient", "ListByAutomationAccount", resp, "Failure sending next results request") + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "ListByAutomationAccount", resp, "Failure responding to next results request") + } + + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/jobstream.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/jobstream.go new file mode 100755 index 000000000000..95b497598e34 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/jobstream.go @@ -0,0 +1,218 @@ +package automation + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// JobStreamClient is the composite Swagger json for Azure Automation Client +type JobStreamClient struct { + ManagementClient +} + +// NewJobStreamClient creates an instance of the JobStreamClient client. +func NewJobStreamClient(subscriptionID string) JobStreamClient { + return NewJobStreamClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewJobStreamClientWithBaseURI creates an instance of the JobStreamClient +// client. +func NewJobStreamClientWithBaseURI(baseURI string, subscriptionID string) JobStreamClient { + return JobStreamClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get retrieve the job stream identified by job stream id. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. jobID is the job id. jobStreamID is the job stream +// id. +func (client JobStreamClient) Get(resourceGroupName string, automationAccountName string, jobID string, jobStreamID string) (result JobStream, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.JobStreamClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName, jobID, jobStreamID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobStreamClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.JobStreamClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobStreamClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client JobStreamClient) GetPreparer(resourceGroupName string, automationAccountName string, jobID string, jobStreamID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobId": autorest.Encode("path", jobID), + "jobStreamId": autorest.Encode("path", jobStreamID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobId}/streams/{jobStreamId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client JobStreamClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client JobStreamClient) GetResponder(resp *http.Response) (result JobStream, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByJob retrieve a list of jobs streams identified by job id. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. jobID is the job Id. filter is the filter to apply +// on the operation. +func (client JobStreamClient) ListByJob(resourceGroupName string, automationAccountName string, jobID string, filter string) (result JobStreamListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.JobStreamClient", "ListByJob") + } + + req, err := client.ListByJobPreparer(resourceGroupName, automationAccountName, jobID, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobStreamClient", "ListByJob", nil, "Failure preparing request") + return + } + + resp, err := client.ListByJobSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.JobStreamClient", "ListByJob", resp, "Failure sending request") + return + } + + result, err = client.ListByJobResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobStreamClient", "ListByJob", resp, "Failure responding to request") + } + + return +} + +// ListByJobPreparer prepares the ListByJob request. +func (client JobStreamClient) ListByJobPreparer(resourceGroupName string, automationAccountName string, jobID string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobId": autorest.Encode("path", jobID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobId}/streams", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByJobSender sends the ListByJob request. The method will close the +// http.Response Body if it receives an error. +func (client JobStreamClient) ListByJobSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByJobResponder handles the response to the ListByJob request. The method always +// closes the http.Response Body. +func (client JobStreamClient) ListByJobResponder(resp *http.Response) (result JobStreamListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByJobNextResults retrieves the next set of results, if any. +func (client JobStreamClient) ListByJobNextResults(lastResults JobStreamListResult) (result JobStreamListResult, err error) { + req, err := lastResults.JobStreamListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.JobStreamClient", "ListByJob", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByJobSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.JobStreamClient", "ListByJob", resp, "Failure sending next results request") + } + + result, err = client.ListByJobResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobStreamClient", "ListByJob", resp, "Failure responding to next results request") + } + + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/models.go new file mode 100755 index 000000000000..9bba30646a3b --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/models.go @@ -0,0 +1,1926 @@ +package automation + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/satori/uuid" + "io" + "net/http" +) + +// AccountState enumerates the values for account state. +type AccountState string + +const ( + // Ok specifies the ok state for account state. + Ok AccountState = "Ok" + // Suspended specifies the suspended state for account state. + Suspended AccountState = "Suspended" + // Unavailable specifies the unavailable state for account state. + Unavailable AccountState = "Unavailable" +) + +// AgentRegistrationKeyName enumerates the values for agent registration key +// name. +type AgentRegistrationKeyName string + +const ( + // Primary specifies the primary state for agent registration key name. + Primary AgentRegistrationKeyName = "Primary" + // Secondary specifies the secondary state for agent registration key name. + Secondary AgentRegistrationKeyName = "Secondary" +) + +// ContentSourceType enumerates the values for content source type. +type ContentSourceType string + +const ( + // EmbeddedContent specifies the embedded content state for content source + // type. + EmbeddedContent ContentSourceType = "embeddedContent" + // URI specifies the uri state for content source type. + URI ContentSourceType = "uri" +) + +// DscConfigurationProvisioningState enumerates the values for dsc +// configuration provisioning state. +type DscConfigurationProvisioningState string + +const ( + // Succeeded specifies the succeeded state for dsc configuration + // provisioning state. + Succeeded DscConfigurationProvisioningState = "Succeeded" +) + +// DscConfigurationState enumerates the values for dsc configuration state. +type DscConfigurationState string + +const ( + // DscConfigurationStateEdit specifies the dsc configuration state edit + // state for dsc configuration state. + DscConfigurationStateEdit DscConfigurationState = "Edit" + // DscConfigurationStateNew specifies the dsc configuration state new state + // for dsc configuration state. + DscConfigurationStateNew DscConfigurationState = "New" + // DscConfigurationStatePublished specifies the dsc configuration state + // published state for dsc configuration state. + DscConfigurationStatePublished DscConfigurationState = "Published" +) + +// HTTPStatusCode enumerates the values for http status code. +type HTTPStatusCode string + +const ( + // Accepted specifies the accepted state for http status code. + Accepted HTTPStatusCode = "Accepted" + // Ambiguous specifies the ambiguous state for http status code. + Ambiguous HTTPStatusCode = "Ambiguous" + // BadGateway specifies the bad gateway state for http status code. + BadGateway HTTPStatusCode = "BadGateway" + // BadRequest specifies the bad request state for http status code. + BadRequest HTTPStatusCode = "BadRequest" + // Conflict specifies the conflict state for http status code. + Conflict HTTPStatusCode = "Conflict" + // Continue specifies the continue state for http status code. + Continue HTTPStatusCode = "Continue" + // Created specifies the created state for http status code. + Created HTTPStatusCode = "Created" + // ExpectationFailed specifies the expectation failed state for http status + // code. + ExpectationFailed HTTPStatusCode = "ExpectationFailed" + // Forbidden specifies the forbidden state for http status code. + Forbidden HTTPStatusCode = "Forbidden" + // Found specifies the found state for http status code. + Found HTTPStatusCode = "Found" + // GatewayTimeout specifies the gateway timeout state for http status code. + GatewayTimeout HTTPStatusCode = "GatewayTimeout" + // Gone specifies the gone state for http status code. + Gone HTTPStatusCode = "Gone" + // HTTPVersionNotSupported specifies the http version not supported state + // for http status code. + HTTPVersionNotSupported HTTPStatusCode = "HttpVersionNotSupported" + // InternalServerError specifies the internal server error state for http + // status code. + InternalServerError HTTPStatusCode = "InternalServerError" + // LengthRequired specifies the length required state for http status code. + LengthRequired HTTPStatusCode = "LengthRequired" + // MethodNotAllowed specifies the method not allowed state for http status + // code. + MethodNotAllowed HTTPStatusCode = "MethodNotAllowed" + // Moved specifies the moved state for http status code. + Moved HTTPStatusCode = "Moved" + // MovedPermanently specifies the moved permanently state for http status + // code. + MovedPermanently HTTPStatusCode = "MovedPermanently" + // MultipleChoices specifies the multiple choices state for http status + // code. + MultipleChoices HTTPStatusCode = "MultipleChoices" + // NoContent specifies the no content state for http status code. + NoContent HTTPStatusCode = "NoContent" + // NonAuthoritativeInformation specifies the non authoritative information + // state for http status code. + NonAuthoritativeInformation HTTPStatusCode = "NonAuthoritativeInformation" + // NotAcceptable specifies the not acceptable state for http status code. + NotAcceptable HTTPStatusCode = "NotAcceptable" + // NotFound specifies the not found state for http status code. + NotFound HTTPStatusCode = "NotFound" + // NotImplemented specifies the not implemented state for http status code. + NotImplemented HTTPStatusCode = "NotImplemented" + // NotModified specifies the not modified state for http status code. + NotModified HTTPStatusCode = "NotModified" + // OK specifies the ok state for http status code. + OK HTTPStatusCode = "OK" + // PartialContent specifies the partial content state for http status code. + PartialContent HTTPStatusCode = "PartialContent" + // PaymentRequired specifies the payment required state for http status + // code. + PaymentRequired HTTPStatusCode = "PaymentRequired" + // PreconditionFailed specifies the precondition failed state for http + // status code. + PreconditionFailed HTTPStatusCode = "PreconditionFailed" + // ProxyAuthenticationRequired specifies the proxy authentication required + // state for http status code. + ProxyAuthenticationRequired HTTPStatusCode = "ProxyAuthenticationRequired" + // Redirect specifies the redirect state for http status code. + Redirect HTTPStatusCode = "Redirect" + // RedirectKeepVerb specifies the redirect keep verb state for http status + // code. + RedirectKeepVerb HTTPStatusCode = "RedirectKeepVerb" + // RedirectMethod specifies the redirect method state for http status code. + RedirectMethod HTTPStatusCode = "RedirectMethod" + // RequestedRangeNotSatisfiable specifies the requested range not + // satisfiable state for http status code. + RequestedRangeNotSatisfiable HTTPStatusCode = "RequestedRangeNotSatisfiable" + // RequestEntityTooLarge specifies the request entity too large state for + // http status code. + RequestEntityTooLarge HTTPStatusCode = "RequestEntityTooLarge" + // RequestTimeout specifies the request timeout state for http status code. + RequestTimeout HTTPStatusCode = "RequestTimeout" + // RequestURITooLong specifies the request uri too long state for http + // status code. + RequestURITooLong HTTPStatusCode = "RequestUriTooLong" + // ResetContent specifies the reset content state for http status code. + ResetContent HTTPStatusCode = "ResetContent" + // SeeOther specifies the see other state for http status code. + SeeOther HTTPStatusCode = "SeeOther" + // ServiceUnavailable specifies the service unavailable state for http + // status code. + ServiceUnavailable HTTPStatusCode = "ServiceUnavailable" + // SwitchingProtocols specifies the switching protocols state for http + // status code. + SwitchingProtocols HTTPStatusCode = "SwitchingProtocols" + // TemporaryRedirect specifies the temporary redirect state for http status + // code. + TemporaryRedirect HTTPStatusCode = "TemporaryRedirect" + // Unauthorized specifies the unauthorized state for http status code. + Unauthorized HTTPStatusCode = "Unauthorized" + // UnsupportedMediaType specifies the unsupported media type state for http + // status code. + UnsupportedMediaType HTTPStatusCode = "UnsupportedMediaType" + // Unused specifies the unused state for http status code. + Unused HTTPStatusCode = "Unused" + // UpgradeRequired specifies the upgrade required state for http status + // code. + UpgradeRequired HTTPStatusCode = "UpgradeRequired" + // UseProxy specifies the use proxy state for http status code. + UseProxy HTTPStatusCode = "UseProxy" +) + +// JobStatus enumerates the values for job status. +type JobStatus string + +const ( + // JobStatusActivating specifies the job status activating state for job + // status. + JobStatusActivating JobStatus = "Activating" + // JobStatusBlocked specifies the job status blocked state for job status. + JobStatusBlocked JobStatus = "Blocked" + // JobStatusCompleted specifies the job status completed state for job + // status. + JobStatusCompleted JobStatus = "Completed" + // JobStatusDisconnected specifies the job status disconnected state for + // job status. + JobStatusDisconnected JobStatus = "Disconnected" + // JobStatusFailed specifies the job status failed state for job status. + JobStatusFailed JobStatus = "Failed" + // JobStatusNew specifies the job status new state for job status. + JobStatusNew JobStatus = "New" + // JobStatusRemoving specifies the job status removing state for job + // status. + JobStatusRemoving JobStatus = "Removing" + // JobStatusResuming specifies the job status resuming state for job + // status. + JobStatusResuming JobStatus = "Resuming" + // JobStatusRunning specifies the job status running state for job status. + JobStatusRunning JobStatus = "Running" + // JobStatusStopped specifies the job status stopped state for job status. + JobStatusStopped JobStatus = "Stopped" + // JobStatusStopping specifies the job status stopping state for job + // status. + JobStatusStopping JobStatus = "Stopping" + // JobStatusSuspended specifies the job status suspended state for job + // status. + JobStatusSuspended JobStatus = "Suspended" + // JobStatusSuspending specifies the job status suspending state for job + // status. + JobStatusSuspending JobStatus = "Suspending" +) + +// JobStreamType enumerates the values for job stream type. +type JobStreamType string + +const ( + // Any specifies the any state for job stream type. + Any JobStreamType = "Any" + // Debug specifies the debug state for job stream type. + Debug JobStreamType = "Debug" + // Error specifies the error state for job stream type. + Error JobStreamType = "Error" + // Output specifies the output state for job stream type. + Output JobStreamType = "Output" + // Progress specifies the progress state for job stream type. + Progress JobStreamType = "Progress" + // Verbose specifies the verbose state for job stream type. + Verbose JobStreamType = "Verbose" + // Warning specifies the warning state for job stream type. + Warning JobStreamType = "Warning" +) + +// ModuleProvisioningState enumerates the values for module provisioning state. +type ModuleProvisioningState string + +const ( + // ModuleProvisioningStateActivitiesStored specifies the module + // provisioning state activities stored state for module provisioning + // state. + ModuleProvisioningStateActivitiesStored ModuleProvisioningState = "ActivitiesStored" + // ModuleProvisioningStateCancelled specifies the module provisioning state + // cancelled state for module provisioning state. + ModuleProvisioningStateCancelled ModuleProvisioningState = "Cancelled" + // ModuleProvisioningStateConnectionTypeImported specifies the module + // provisioning state connection type imported state for module + // provisioning state. + ModuleProvisioningStateConnectionTypeImported ModuleProvisioningState = "ConnectionTypeImported" + // ModuleProvisioningStateContentDownloaded specifies the module + // provisioning state content downloaded state for module provisioning + // state. + ModuleProvisioningStateContentDownloaded ModuleProvisioningState = "ContentDownloaded" + // ModuleProvisioningStateContentRetrieved specifies the module + // provisioning state content retrieved state for module provisioning + // state. + ModuleProvisioningStateContentRetrieved ModuleProvisioningState = "ContentRetrieved" + // ModuleProvisioningStateContentStored specifies the module provisioning + // state content stored state for module provisioning state. + ModuleProvisioningStateContentStored ModuleProvisioningState = "ContentStored" + // ModuleProvisioningStateContentValidated specifies the module + // provisioning state content validated state for module provisioning + // state. + ModuleProvisioningStateContentValidated ModuleProvisioningState = "ContentValidated" + // ModuleProvisioningStateCreated specifies the module provisioning state + // created state for module provisioning state. + ModuleProvisioningStateCreated ModuleProvisioningState = "Created" + // ModuleProvisioningStateCreating specifies the module provisioning state + // creating state for module provisioning state. + ModuleProvisioningStateCreating ModuleProvisioningState = "Creating" + // ModuleProvisioningStateFailed specifies the module provisioning state + // failed state for module provisioning state. + ModuleProvisioningStateFailed ModuleProvisioningState = "Failed" + // ModuleProvisioningStateModuleDataStored specifies the module + // provisioning state module data stored state for module provisioning + // state. + ModuleProvisioningStateModuleDataStored ModuleProvisioningState = "ModuleDataStored" + // ModuleProvisioningStateModuleImportRunbookComplete specifies the module + // provisioning state module import runbook complete state for module + // provisioning state. + ModuleProvisioningStateModuleImportRunbookComplete ModuleProvisioningState = "ModuleImportRunbookComplete" + // ModuleProvisioningStateRunningImportModuleRunbook specifies the module + // provisioning state running import module runbook state for module + // provisioning state. + ModuleProvisioningStateRunningImportModuleRunbook ModuleProvisioningState = "RunningImportModuleRunbook" + // ModuleProvisioningStateStartingImportModuleRunbook specifies the module + // provisioning state starting import module runbook state for module + // provisioning state. + ModuleProvisioningStateStartingImportModuleRunbook ModuleProvisioningState = "StartingImportModuleRunbook" + // ModuleProvisioningStateSucceeded specifies the module provisioning state + // succeeded state for module provisioning state. + ModuleProvisioningStateSucceeded ModuleProvisioningState = "Succeeded" + // ModuleProvisioningStateUpdating specifies the module provisioning state + // updating state for module provisioning state. + ModuleProvisioningStateUpdating ModuleProvisioningState = "Updating" +) + +// RunbookProvisioningState enumerates the values for runbook provisioning +// state. +type RunbookProvisioningState string + +const ( + // RunbookProvisioningStateSucceeded specifies the runbook provisioning + // state succeeded state for runbook provisioning state. + RunbookProvisioningStateSucceeded RunbookProvisioningState = "Succeeded" +) + +// RunbookState enumerates the values for runbook state. +type RunbookState string + +const ( + // RunbookStateEdit specifies the runbook state edit state for runbook + // state. + RunbookStateEdit RunbookState = "Edit" + // RunbookStateNew specifies the runbook state new state for runbook state. + RunbookStateNew RunbookState = "New" + // RunbookStatePublished specifies the runbook state published state for + // runbook state. + RunbookStatePublished RunbookState = "Published" +) + +// RunbookTypeEnum enumerates the values for runbook type enum. +type RunbookTypeEnum string + +const ( + // Graph specifies the graph state for runbook type enum. + Graph RunbookTypeEnum = "Graph" + // GraphPowerShell specifies the graph power shell state for runbook type + // enum. + GraphPowerShell RunbookTypeEnum = "GraphPowerShell" + // GraphPowerShellWorkflow specifies the graph power shell workflow state + // for runbook type enum. + GraphPowerShellWorkflow RunbookTypeEnum = "GraphPowerShellWorkflow" + // PowerShell specifies the power shell state for runbook type enum. + PowerShell RunbookTypeEnum = "PowerShell" + // PowerShellWorkflow specifies the power shell workflow state for runbook + // type enum. + PowerShellWorkflow RunbookTypeEnum = "PowerShellWorkflow" + // Script specifies the script state for runbook type enum. + Script RunbookTypeEnum = "Script" +) + +// ScheduleDay enumerates the values for schedule day. +type ScheduleDay string + +const ( + // Friday specifies the friday state for schedule day. + Friday ScheduleDay = "Friday" + // Monday specifies the monday state for schedule day. + Monday ScheduleDay = "Monday" + // Saturday specifies the saturday state for schedule day. + Saturday ScheduleDay = "Saturday" + // Sunday specifies the sunday state for schedule day. + Sunday ScheduleDay = "Sunday" + // Thursday specifies the thursday state for schedule day. + Thursday ScheduleDay = "Thursday" + // Tuesday specifies the tuesday state for schedule day. + Tuesday ScheduleDay = "Tuesday" + // Wednesday specifies the wednesday state for schedule day. + Wednesday ScheduleDay = "Wednesday" +) + +// ScheduleFrequency enumerates the values for schedule frequency. +type ScheduleFrequency string + +const ( + // Day specifies the day state for schedule frequency. + Day ScheduleFrequency = "Day" + // Hour specifies the hour state for schedule frequency. + Hour ScheduleFrequency = "Hour" + // Month specifies the month state for schedule frequency. + Month ScheduleFrequency = "Month" + // OneTime specifies the one time state for schedule frequency. + OneTime ScheduleFrequency = "OneTime" + // Week specifies the week state for schedule frequency. + Week ScheduleFrequency = "Week" +) + +// SkuNameEnum enumerates the values for sku name enum. +type SkuNameEnum string + +const ( + // Basic specifies the basic state for sku name enum. + Basic SkuNameEnum = "Basic" + // Free specifies the free state for sku name enum. + Free SkuNameEnum = "Free" +) + +// Account is definition of the automation account type. +type Account struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + *AccountProperties `json:"properties,omitempty"` + Etag *string `json:"etag,omitempty"` +} + +// AccountCreateOrUpdateParameters is the parameters supplied to the create or +// update automation account operation. +type AccountCreateOrUpdateParameters struct { + *AccountCreateOrUpdateProperties `json:"properties,omitempty"` + Name *string `json:"name,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` +} + +// AccountCreateOrUpdateProperties is the parameters supplied to the create or +// update account properties. +type AccountCreateOrUpdateProperties struct { + Sku *Sku `json:"sku,omitempty"` +} + +// AccountListResult is the response model for the list account operation. +type AccountListResult struct { + autorest.Response `json:"-"` + Value *[]Account `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// AccountListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client AccountListResult) AccountListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// AccountProperties is definition of the account property. +type AccountProperties struct { + Sku *Sku `json:"sku,omitempty"` + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + State AccountState `json:"state,omitempty"` + CreationTime *date.Time `json:"creationTime,omitempty"` + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + Description *string `json:"description,omitempty"` +} + +// AccountUpdateParameters is the parameters supplied to the update automation +// account operation. +type AccountUpdateParameters struct { + *AccountUpdateProperties `json:"properties,omitempty"` + Name *string `json:"name,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` +} + +// AccountUpdateProperties is the parameters supplied to the update account +// properties. +type AccountUpdateProperties struct { + Sku *Sku `json:"sku,omitempty"` +} + +// Activity is definition of the activity. +type Activity struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + *ActivityProperties `json:"properties,omitempty"` +} + +// ActivityListResult is the response model for the list activity operation. +type ActivityListResult struct { + autorest.Response `json:"-"` + Value *[]Activity `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// ActivityListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client ActivityListResult) ActivityListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// ActivityOutputType is definition of the activity output type. +type ActivityOutputType struct { + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} + +// ActivityParameter is definition of the activity parameter. +type ActivityParameter struct { + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + IsMandatory *bool `json:"isMandatory,omitempty"` + IsDynamic *bool `json:"isDynamic,omitempty"` + Position *bool `json:"position,omitempty"` + ValueFromPipeline *bool `json:"valueFromPipeline,omitempty"` + ValueFromPipelineByPropertyName *bool `json:"valueFromPipelineByPropertyName,omitempty"` + ValueFromRemainingArguments *bool `json:"valueFromRemainingArguments,omitempty"` +} + +// ActivityParameterSet is definition of the activity parameter set. +type ActivityParameterSet struct { + Name *string `json:"name,omitempty"` + Parameters *[]ActivityParameter `json:"parameters,omitempty"` +} + +// ActivityProperties is properties of the activity. +type ActivityProperties struct { + Definition *string `json:"definition,omitempty"` + ParameterSets *[]ActivityParameterSet `json:"parameterSets,omitempty"` + OutputTypes *[]ActivityOutputType `json:"outputTypes,omitempty"` + CreationTime *date.Time `json:"creationTime,omitempty"` + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + Description *string `json:"description,omitempty"` +} + +// AdvancedSchedule is the properties of the create Advanced Schedule. +type AdvancedSchedule struct { + WeekDays *[]string `json:"weekDays,omitempty"` + MonthDays *[]int32 `json:"monthDays,omitempty"` + MonthlyOccurrences *[]AdvancedScheduleMonthlyOccurrence `json:"monthlyOccurrences,omitempty"` +} + +// AdvancedScheduleMonthlyOccurrence is the properties of the create advanced +// schedule monthly occurrence. +type AdvancedScheduleMonthlyOccurrence struct { + Occurrence *int32 `json:"occurrence,omitempty"` + Day ScheduleDay `json:"day,omitempty"` +} + +// AgentRegistration is definition of the agent registration infomration type. +type AgentRegistration struct { + autorest.Response `json:"-"` + DscMetaConfiguration *string `json:"dscMetaConfiguration,omitempty"` + Endpoint *string `json:"endpoint,omitempty"` + Keys *AgentRegistrationKeys `json:"keys,omitempty"` + ID *string `json:"id,omitempty"` +} + +// AgentRegistrationKeys is definition of the agent registration keys. +type AgentRegistrationKeys struct { + Primary *string `json:"primary,omitempty"` + Secondary *string `json:"secondary,omitempty"` +} + +// AgentRegistrationRegenerateKeyParameter is the parameters supplied to the +// regenerate keys operation. +type AgentRegistrationRegenerateKeyParameter struct { + KeyName AgentRegistrationKeyName `json:"keyName,omitempty"` + Name *string `json:"name,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` +} + +// Certificate is definition of the certificate. +type Certificate struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + *CertificateProperties `json:"properties,omitempty"` +} + +// CertificateCreateOrUpdateParameters is the parameters supplied to the create +// or update or replace certificate operation. +type CertificateCreateOrUpdateParameters struct { + Name *string `json:"name,omitempty"` + *CertificateCreateOrUpdateProperties `json:"properties,omitempty"` +} + +// CertificateCreateOrUpdateProperties is the properties of the create +// certificate operation. +type CertificateCreateOrUpdateProperties struct { + Base64Value *string `json:"base64Value,omitempty"` + Description *string `json:"description,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` + IsExportable *bool `json:"isExportable,omitempty"` +} + +// CertificateListResult is the response model for the list certificate +// operation. +type CertificateListResult struct { + autorest.Response `json:"-"` + Value *[]Certificate `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// CertificateListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client CertificateListResult) CertificateListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// CertificateProperties is properties of the certificate. +type CertificateProperties struct { + Thumbprint *string `json:"thumbprint,omitempty"` + ExpiryTime *date.Time `json:"expiryTime,omitempty"` + IsExportable *bool `json:"isExportable,omitempty"` + CreationTime *date.Time `json:"creationTime,omitempty"` + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + Description *string `json:"description,omitempty"` +} + +// CertificateUpdateParameters is the parameters supplied to the update +// certificate operation. +type CertificateUpdateParameters struct { + Name *string `json:"name,omitempty"` + *CertificateUpdateProperties `json:"properties,omitempty"` +} + +// CertificateUpdateProperties is the properties of the update certificate +// operation +type CertificateUpdateProperties struct { + Description *string `json:"description,omitempty"` +} + +// Connection is definition of the connection. +type Connection struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + *ConnectionProperties `json:"properties,omitempty"` +} + +// ConnectionCreateOrUpdateParameters is the parameters supplied to the create +// or update connection operation. +type ConnectionCreateOrUpdateParameters struct { + Name *string `json:"name,omitempty"` + *ConnectionCreateOrUpdateProperties `json:"properties,omitempty"` +} + +// ConnectionCreateOrUpdateProperties is the properties of the create +// connection properties +type ConnectionCreateOrUpdateProperties struct { + Description *string `json:"description,omitempty"` + ConnectionType *ConnectionTypeAssociationProperty `json:"connectionType,omitempty"` + FieldDefinitionValues *map[string]*string `json:"fieldDefinitionValues,omitempty"` +} + +// ConnectionListResult is the response model for the list connection +// operation. +type ConnectionListResult struct { + autorest.Response `json:"-"` + Value *[]Connection `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// ConnectionListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client ConnectionListResult) ConnectionListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// ConnectionProperties is definition of the connection properties. +type ConnectionProperties struct { + ConnectionType *ConnectionTypeAssociationProperty `json:"connectionType,omitempty"` + FieldDefinitionValues *map[string]*string `json:"fieldDefinitionValues,omitempty"` + CreationTime *date.Time `json:"creationTime,omitempty"` + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + Description *string `json:"description,omitempty"` +} + +// ConnectionType is definition of the connection type. +type ConnectionType struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + *ConnectionTypeProperties `json:"properties,omitempty"` +} + +// ConnectionTypeAssociationProperty is the connection type property associated +// with the entity. +type ConnectionTypeAssociationProperty struct { + Name *string `json:"name,omitempty"` +} + +// ConnectionTypeCreateOrUpdateParameters is the parameters supplied to the +// create or update connection type operation. +type ConnectionTypeCreateOrUpdateParameters struct { + Name *string `json:"name,omitempty"` + *ConnectionTypeCreateOrUpdateProperties `json:"properties,omitempty"` +} + +// ConnectionTypeCreateOrUpdateProperties is the properties of the create +// connection type. +type ConnectionTypeCreateOrUpdateProperties struct { + IsGlobal *bool `json:"isGlobal,omitempty"` + FieldDefinitions *map[string]*FieldDefinition `json:"fieldDefinitions,omitempty"` +} + +// ConnectionTypeListResult is the response model for the list connection type +// operation. +type ConnectionTypeListResult struct { + autorest.Response `json:"-"` + Value *[]ConnectionType `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// ConnectionTypeListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client ConnectionTypeListResult) ConnectionTypeListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// ConnectionTypeProperties is properties of the connection type. +type ConnectionTypeProperties struct { + IsGlobal *bool `json:"isGlobal,omitempty"` + FieldDefinitions *map[string]*FieldDefinition `json:"fieldDefinitions,omitempty"` + CreationTime *date.Time `json:"creationTime,omitempty"` + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + Description *string `json:"description,omitempty"` +} + +// ConnectionUpdateParameters is the parameters supplied to the update +// connection operation. +type ConnectionUpdateParameters struct { + Name *string `json:"name,omitempty"` + *ConnectionUpdateProperties `json:"properties,omitempty"` +} + +// ConnectionUpdateProperties is the properties of the update connection +// operation. +type ConnectionUpdateProperties struct { + Description *string `json:"description,omitempty"` + FieldDefinitionValues *map[string]*string `json:"fieldDefinitionValues,omitempty"` +} + +// ContentHash is definition of the runbook property type. +type ContentHash struct { + Algorithm *string `json:"algorithm,omitempty"` + Value *string `json:"value,omitempty"` +} + +// ContentLink is definition of the content link. +type ContentLink struct { + URI *string `json:"uri,omitempty"` + ContentHash *ContentHash `json:"contentHash,omitempty"` + Version *string `json:"version,omitempty"` +} + +// ContentSource is definition of the content source. +type ContentSource struct { + Hash *ContentHash `json:"hash,omitempty"` + Type ContentSourceType `json:"type,omitempty"` + Value *string `json:"value,omitempty"` + Version *string `json:"version,omitempty"` +} + +// Credential is definition of the credential. +type Credential struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + *CredentialProperties `json:"properties,omitempty"` +} + +// CredentialCreateOrUpdateParameters is the parameters supplied to the create +// or update credential operation. +type CredentialCreateOrUpdateParameters struct { + Name *string `json:"name,omitempty"` + *CredentialCreateOrUpdateProperties `json:"properties,omitempty"` +} + +// CredentialCreateOrUpdateProperties is the properties of the create +// cerdential operation. +type CredentialCreateOrUpdateProperties struct { + UserName *string `json:"userName,omitempty"` + Password *string `json:"password,omitempty"` + Description *string `json:"description,omitempty"` +} + +// CredentialListResult is the response model for the list credential +// operation. +type CredentialListResult struct { + autorest.Response `json:"-"` + Value *[]Credential `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// CredentialListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client CredentialListResult) CredentialListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// CredentialProperties is definition of the credential properties +type CredentialProperties struct { + UserName *string `json:"userName,omitempty"` + CreationTime *date.Time `json:"creationTime,omitempty"` + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + Description *string `json:"description,omitempty"` +} + +// CredentialUpdateParameters is the parameters supplied to the Update +// credential operation. +type CredentialUpdateParameters struct { + Name *string `json:"name,omitempty"` + *CredentialUpdateProperties `json:"properties,omitempty"` +} + +// CredentialUpdateProperties is the properties of the Update credential +type CredentialUpdateProperties struct { + UserName *string `json:"userName,omitempty"` + Password *string `json:"password,omitempty"` + Description *string `json:"description,omitempty"` +} + +// DscCompilationJob is definition of the Dsc Compilation job. +type DscCompilationJob struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + *DscCompilationJobProperties `json:"properties,omitempty"` +} + +// DscCompilationJobCreateParameters is the parameters supplied to the create +// compilation job operation. +type DscCompilationJobCreateParameters struct { + *DscCompilationJobCreateProperties `json:"properties,omitempty"` + Name *string `json:"name,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` +} + +// DscCompilationJobCreateProperties is the parameters supplied to the create +// compilation job operation. +type DscCompilationJobCreateProperties struct { + Configuration *DscConfigurationAssociationProperty `json:"configuration,omitempty"` + Parameters *map[string]*string `json:"parameters,omitempty"` +} + +// DscCompilationJobListResult is the response model for the list job +// operation. +type DscCompilationJobListResult struct { + autorest.Response `json:"-"` + Value *[]DscCompilationJob `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// DscCompilationJobListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client DscCompilationJobListResult) DscCompilationJobListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// DscCompilationJobProperties is definition of Dsc Compilation job properties. +type DscCompilationJobProperties struct { + Configuration *DscConfigurationAssociationProperty `json:"configuration,omitempty"` + StartedBy *string `json:"startedBy,omitempty"` + JobID *uuid.UUID `json:"jobId,omitempty"` + CreationTime *date.Time `json:"creationTime,omitempty"` + Status JobStatus `json:"status,omitempty"` + StatusDetails *string `json:"statusDetails,omitempty"` + StartTime *date.Time `json:"startTime,omitempty"` + EndTime *date.Time `json:"endTime,omitempty"` + Exception *string `json:"exception,omitempty"` + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + LastStatusModifiedTime *date.Time `json:"lastStatusModifiedTime,omitempty"` + Parameters *map[string]*string `json:"parameters,omitempty"` +} + +// DscConfiguration is definition of the configuration type. +type DscConfiguration struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + *DscConfigurationProperties `json:"properties,omitempty"` + Etag *string `json:"etag,omitempty"` +} + +// DscConfigurationAssociationProperty is the Dsc configuration property +// associated with the entity. +type DscConfigurationAssociationProperty struct { + Name *string `json:"name,omitempty"` +} + +// DscConfigurationCreateOrUpdateParameters is the parameters supplied to the +// create or update configuration operation. +type DscConfigurationCreateOrUpdateParameters struct { + *DscConfigurationCreateOrUpdateProperties `json:"properties,omitempty"` + Name *string `json:"name,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` +} + +// DscConfigurationCreateOrUpdateProperties is the properties to create or +// update configuration. +type DscConfigurationCreateOrUpdateProperties struct { + LogVerbose *bool `json:"logVerbose,omitempty"` + LogProgress *bool `json:"logProgress,omitempty"` + Source *ContentSource `json:"source,omitempty"` + Parameters *map[string]*DscConfigurationParameter `json:"parameters,omitempty"` + Description *string `json:"description,omitempty"` +} + +// DscConfigurationListResult is the response model for the list configuration +// operation. +type DscConfigurationListResult struct { + autorest.Response `json:"-"` + Value *[]DscConfiguration `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// DscConfigurationListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client DscConfigurationListResult) DscConfigurationListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// DscConfigurationParameter is definition of the configuration parameter type. +type DscConfigurationParameter struct { + Type *string `json:"type,omitempty"` + IsMandatory *bool `json:"isMandatory,omitempty"` + Position *int32 `json:"position,omitempty"` + DefaultValue *string `json:"defaultValue,omitempty"` +} + +// DscConfigurationProperties is definition of the configuration property type. +type DscConfigurationProperties struct { + ProvisioningState DscConfigurationProvisioningState `json:"provisioningState,omitempty"` + JobCount *int32 `json:"jobCount,omitempty"` + Parameters *map[string]*DscConfigurationParameter `json:"parameters,omitempty"` + Source *ContentSource `json:"source,omitempty"` + State DscConfigurationState `json:"state,omitempty"` + LogVerbose *bool `json:"logVerbose,omitempty"` + CreationTime *date.Time `json:"creationTime,omitempty"` + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + Description *string `json:"description,omitempty"` +} + +// DscMetaConfiguration is definition of the DSC Meta Configuration. +type DscMetaConfiguration struct { + ConfigurationModeFrequencyMins *int32 `json:"configurationModeFrequencyMins,omitempty"` + RebootNodeIfNeeded *bool `json:"rebootNodeIfNeeded,omitempty"` + ConfigurationMode *string `json:"configurationMode,omitempty"` + ActionAfterReboot *string `json:"actionAfterReboot,omitempty"` + CertificateID *string `json:"certificateId,omitempty"` + RefreshFrequencyMins *int32 `json:"refreshFrequencyMins,omitempty"` + AllowModuleOverwrite *bool `json:"allowModuleOverwrite,omitempty"` +} + +// DscNode is definition of the dsc node type. +type DscNode struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + LastSeen *date.Time `json:"lastSeen,omitempty"` + RegistrationTime *date.Time `json:"registrationTime,omitempty"` + IP *string `json:"ip,omitempty"` + AccountID *string `json:"accountId,omitempty"` + NodeConfiguration *DscNodeConfigurationAssociationProperty `json:"nodeConfiguration,omitempty"` + Status *string `json:"status,omitempty"` + NodeID *string `json:"nodeId,omitempty"` + Etag *string `json:"etag,omitempty"` +} + +// DscNodeConfiguration is definition of the dsc node configuration. +type DscNodeConfiguration struct { + autorest.Response `json:"-"` + Name *string `json:"name,omitempty"` + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + CreationTime *date.Time `json:"creationTime,omitempty"` + Configuration *DscConfigurationAssociationProperty `json:"configuration,omitempty"` + ID *string `json:"id,omitempty"` +} + +// DscNodeConfigurationAssociationProperty is the dsc nodeconfiguration +// property associated with the entity. +type DscNodeConfigurationAssociationProperty struct { + Name *string `json:"name,omitempty"` +} + +// DscNodeConfigurationCreateOrUpdateParameters is the parameters supplied to +// the create or update node configuration operation. +type DscNodeConfigurationCreateOrUpdateParameters struct { + Source *ContentSource `json:"source,omitempty"` + Name *string `json:"name,omitempty"` + Configuration *DscConfigurationAssociationProperty `json:"configuration,omitempty"` +} + +// DscNodeConfigurationListResult is the response model for the list job +// operation. +type DscNodeConfigurationListResult struct { + autorest.Response `json:"-"` + Value *[]DscNodeConfiguration `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// DscNodeConfigurationListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client DscNodeConfigurationListResult) DscNodeConfigurationListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// DscNodeListResult is the response model for the list dsc nodes operation. +type DscNodeListResult struct { + autorest.Response `json:"-"` + Value *[]DscNode `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// DscNodeListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client DscNodeListResult) DscNodeListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// DscNodeReport is definition of the dsc node report type. +type DscNodeReport struct { + autorest.Response `json:"-"` + EndTime *date.Time `json:"endTime,omitempty"` + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + StartTime *date.Time `json:"startTime,omitempty"` + Type *string `json:"type,omitempty"` + ReportID *string `json:"reportId,omitempty"` + Status *string `json:"status,omitempty"` + RefreshMode *string `json:"refreshMode,omitempty"` + RebootRequested *string `json:"rebootRequested,omitempty"` + ReportFormatVersion *string `json:"reportFormatVersion,omitempty"` + ConfigurationVersion *string `json:"configurationVersion,omitempty"` + ID *string `json:"id,omitempty"` + Errors *[]DscReportError `json:"errors,omitempty"` + Resources *[]DscReportResource `json:"resources,omitempty"` + MetaConfiguration *DscMetaConfiguration `json:"metaConfiguration,omitempty"` + HostName *string `json:"hostName,omitempty"` + IPV4Addresses *[]string `json:"iPV4Addresses,omitempty"` + IPV6Addresses *[]string `json:"iPV6Addresses,omitempty"` + NumberOfResources *int32 `json:"numberOfResources,omitempty"` + RawErrors *string `json:"rawErrors,omitempty"` +} + +// DscNodeReportListResult is the response model for the list dsc nodes +// operation. +type DscNodeReportListResult struct { + autorest.Response `json:"-"` + Value *[]DscNodeReport `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// DscNodeReportListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client DscNodeReportListResult) DscNodeReportListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// DscNodeUpdateParameters is the parameters supplied to the update dsc node +// operation. +type DscNodeUpdateParameters struct { + NodeID *string `json:"nodeId,omitempty"` + NodeConfiguration *DscNodeConfigurationAssociationProperty `json:"nodeConfiguration,omitempty"` +} + +// DscReportError is definition of the dsc node report error type. +type DscReportError struct { + ErrorSource *string `json:"errorSource,omitempty"` + ResourceID *string `json:"resourceId,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + Locale *string `json:"locale,omitempty"` + ErrorDetails *string `json:"errorDetails,omitempty"` +} + +// DscReportResource is definition of the DSC Report Resource. +type DscReportResource struct { + ResourceID *string `json:"resourceId,omitempty"` + SourceInfo *string `json:"sourceInfo,omitempty"` + DependsOn *[]DscReportResourceNavigation `json:"dependsOn,omitempty"` + ModuleName *string `json:"moduleName,omitempty"` + ModuleVersion *string `json:"moduleVersion,omitempty"` + ResourceName *string `json:"resourceName,omitempty"` + Error *string `json:"error,omitempty"` + Status *string `json:"status,omitempty"` + DurationInSeconds *float64 `json:"durationInSeconds,omitempty"` + StartDate *date.Time `json:"startDate,omitempty"` +} + +// DscReportResourceNavigation is navigation for DSC Report Resource. +type DscReportResourceNavigation struct { + ResourceID *string `json:"resourceId,omitempty"` +} + +// ErrorResponse is error response of an operation failure +type ErrorResponse struct { + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` +} + +// FieldDefinition is definition of the connection fields. +type FieldDefinition struct { + IsEncrypted *bool `json:"isEncrypted,omitempty"` + IsOptional *bool `json:"isOptional,omitempty"` + Type *string `json:"type,omitempty"` +} + +// HybridRunbookWorker is definition of hybrid runbook worker. +type HybridRunbookWorker struct { + Name *string `json:"name,omitempty"` + IP *string `json:"ip,omitempty"` + RegistrationTime *date.Time `json:"registrationTime,omitempty"` +} + +// HybridRunbookWorkerGroup is definition of hybrid runbook worker group. +type HybridRunbookWorkerGroup struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + HybridRunbookWorkers *[]HybridRunbookWorker `json:"hybridRunbookWorkers,omitempty"` + Credential *RunAsCredentialAssociationProperty `json:"credential,omitempty"` +} + +// HybridRunbookWorkerGroupsListResult is the response model for the list +// hybrid runbook worker groups. +type HybridRunbookWorkerGroupsListResult struct { + autorest.Response `json:"-"` + Value *[]HybridRunbookWorkerGroup `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// HybridRunbookWorkerGroupsListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client HybridRunbookWorkerGroupsListResult) HybridRunbookWorkerGroupsListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// HybridRunbookWorkerGroupUpdateParameters is parameters supplied to the +// update operation. +type HybridRunbookWorkerGroupUpdateParameters struct { + Credential *RunAsCredentialAssociationProperty `json:"credential,omitempty"` +} + +// Job is definition of the job. +type Job struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + *JobProperties `json:"properties,omitempty"` +} + +// JobCreateParameters is the parameters supplied to the create job operation. +type JobCreateParameters struct { + *JobCreateProperties `json:"properties,omitempty"` + Name *string `json:"name,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` +} + +// JobCreateProperties is the parameters supplied to the create job operation. +type JobCreateProperties struct { + Runbook *RunbookAssociationProperty `json:"runbook,omitempty"` + Parameters *map[string]*string `json:"parameters,omitempty"` + RunOn *string `json:"runOn,omitempty"` +} + +// JobListResult is the response model for the list job operation. +type JobListResult struct { + autorest.Response `json:"-"` + Value *[]Job `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// JobListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client JobListResult) JobListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// JobProperties is definition of job properties. +type JobProperties struct { + Runbook *RunbookAssociationProperty `json:"runbook,omitempty"` + StartedBy *string `json:"startedBy,omitempty"` + RunOn *string `json:"runOn,omitempty"` + JobID *uuid.UUID `json:"jobId,omitempty"` + CreationTime *date.Time `json:"creationTime,omitempty"` + Status JobStatus `json:"status,omitempty"` + StatusDetails *string `json:"statusDetails,omitempty"` + StartTime *date.Time `json:"startTime,omitempty"` + EndTime *date.Time `json:"endTime,omitempty"` + Exception *string `json:"exception,omitempty"` + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + LastStatusModifiedTime *date.Time `json:"lastStatusModifiedTime,omitempty"` + Parameters *map[string]*string `json:"parameters,omitempty"` +} + +// JobSchedule is definition of the job schedule. +type JobSchedule struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + *JobScheduleProperties `json:"properties,omitempty"` +} + +// JobScheduleCreateParameters is the parameters supplied to the create job +// schedule operation. +type JobScheduleCreateParameters struct { + *JobScheduleCreateProperties `json:"properties,omitempty"` +} + +// JobScheduleCreateProperties is the parameters supplied to the create job +// schedule operation. +type JobScheduleCreateProperties struct { + Schedule *ScheduleAssociationProperty `json:"schedule,omitempty"` + Runbook *RunbookAssociationProperty `json:"runbook,omitempty"` + RunOn *string `json:"runOn,omitempty"` + Parameters *map[string]*string `json:"parameters,omitempty"` +} + +// JobScheduleListResult is the response model for the list job schedule +// operation. +type JobScheduleListResult struct { + autorest.Response `json:"-"` + Value *[]JobSchedule `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// JobScheduleListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client JobScheduleListResult) JobScheduleListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// JobScheduleProperties is definition of job schedule parameters. +type JobScheduleProperties struct { + JobScheduleID *string `json:"jobScheduleId,omitempty"` + Schedule *ScheduleAssociationProperty `json:"schedule,omitempty"` + Runbook *RunbookAssociationProperty `json:"runbook,omitempty"` + RunOn *string `json:"runOn,omitempty"` + Parameters *map[string]*string `json:"parameters,omitempty"` +} + +// JobStream is definition of the job stream. +type JobStream struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + *JobStreamProperties `json:"properties,omitempty"` +} + +// JobStreamListResult is the response model for the list job stream operation. +type JobStreamListResult struct { + autorest.Response `json:"-"` + Value *[]JobStream `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// JobStreamListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client JobStreamListResult) JobStreamListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// JobStreamProperties is definition of the job stream. +type JobStreamProperties struct { + JobStreamID *string `json:"jobStreamId,omitempty"` + Time *date.Time `json:"time,omitempty"` + StreamType JobStreamType `json:"streamType,omitempty"` + StreamText *string `json:"streamText,omitempty"` + Summary *string `json:"summary,omitempty"` + Value *map[string]*map[string]interface{} `json:"value,omitempty"` +} + +// Module is definition of the module type. +type Module struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + *ModuleProperties `json:"properties,omitempty"` + Etag *string `json:"etag,omitempty"` +} + +// ModuleCreateOrUpdateParameters is the parameters supplied to the create or +// update module operation. +type ModuleCreateOrUpdateParameters struct { + *ModuleCreateOrUpdateProperties `json:"properties,omitempty"` + Name *string `json:"name,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` +} + +// ModuleCreateOrUpdateProperties is the parameters supplied to the create or +// update module properties. +type ModuleCreateOrUpdateProperties struct { + ContentLink *ContentLink `json:"contentLink,omitempty"` +} + +// ModuleErrorInfo is definition of the module error info type. +type ModuleErrorInfo struct { + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` +} + +// ModuleListResult is the response model for the list module operation. +type ModuleListResult struct { + autorest.Response `json:"-"` + Value *[]Module `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// ModuleListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client ModuleListResult) ModuleListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// ModuleProperties is definition of the module property type. +type ModuleProperties struct { + IsGlobal *bool `json:"isGlobal,omitempty"` + Version *string `json:"version,omitempty"` + SizeInBytes *int64 `json:"sizeInBytes,omitempty"` + ActivityCount *int32 `json:"activityCount,omitempty"` + ProvisioningState ModuleProvisioningState `json:"provisioningState,omitempty"` + ContentLink *ContentLink `json:"contentLink,omitempty"` + Error *ModuleErrorInfo `json:"error,omitempty"` + CreationTime *date.Time `json:"creationTime,omitempty"` + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + Description *string `json:"description,omitempty"` +} + +// ModuleUpdateParameters is the parameters supplied to the update module +// operation. +type ModuleUpdateParameters struct { + *ModuleUpdateProperties `json:"properties,omitempty"` + Name *string `json:"name,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` +} + +// ModuleUpdateProperties is the parameters supplied to the update properties. +type ModuleUpdateProperties struct { + ContentLink *ContentLink `json:"contentLink,omitempty"` +} + +// Operation is automation REST API operation +type Operation struct { + Name *string `json:"name,omitempty"` + Display *OperationDisplay `json:"display,omitempty"` +} + +// OperationDisplay is provider, Resource and Operation values +type OperationDisplay struct { + Provider *string `json:"provider,omitempty"` + Resource *string `json:"resource,omitempty"` + Operation *string `json:"operation,omitempty"` +} + +// OperationListResult is the response model for the list of Automation +// operations +type OperationListResult struct { + autorest.Response `json:"-"` + Value *[]Operation `json:"value,omitempty"` +} + +// ReadCloser is +type ReadCloser struct { + autorest.Response `json:"-"` + Value *io.ReadCloser `json:"value,omitempty"` +} + +// Resource is the Resource definition. +type Resource struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` +} + +// RunAsCredentialAssociationProperty is definition of runas credential to use +// for hybrid worker. +type RunAsCredentialAssociationProperty struct { + Name *string `json:"name,omitempty"` +} + +// Runbook is definition of the runbook type. +type Runbook struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + *RunbookProperties `json:"properties,omitempty"` + Etag *string `json:"etag,omitempty"` +} + +// RunbookAssociationProperty is the runbook property associated with the +// entity. +type RunbookAssociationProperty struct { + Name *string `json:"name,omitempty"` +} + +// RunbookCreateOrUpdateParameters is the parameters supplied to the create or +// update runbook operation. +type RunbookCreateOrUpdateParameters struct { + *RunbookCreateOrUpdateProperties `json:"properties,omitempty"` + Name *string `json:"name,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` +} + +// RunbookCreateOrUpdateProperties is the parameters supplied to the create or +// update runbook properties. +type RunbookCreateOrUpdateProperties struct { + LogVerbose *bool `json:"logVerbose,omitempty"` + LogProgress *bool `json:"logProgress,omitempty"` + RunbookType RunbookTypeEnum `json:"runbookType,omitempty"` + Draft *RunbookDraft `json:"draft,omitempty"` + PublishContentLink *ContentLink `json:"publishContentLink,omitempty"` + Description *string `json:"description,omitempty"` + LogActivityTrace *int32 `json:"logActivityTrace,omitempty"` +} + +// RunbookDraft is definition of the runbook type. +type RunbookDraft struct { + autorest.Response `json:"-"` + InEdit *bool `json:"inEdit,omitempty"` + DraftContentLink *ContentLink `json:"draftContentLink,omitempty"` + CreationTime *date.Time `json:"creationTime,omitempty"` + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + Parameters *map[string]*RunbookParameter `json:"parameters,omitempty"` + OutputTypes *[]string `json:"outputTypes,omitempty"` +} + +// RunbookDraftUndoEditResult is the response model for the undoedit runbook +// operation. +type RunbookDraftUndoEditResult struct { + autorest.Response `json:"-"` + StatusCode HTTPStatusCode `json:"statusCode,omitempty"` + RequestID *string `json:"requestId,omitempty"` +} + +// RunbookListResult is the response model for the list runbook operation. +type RunbookListResult struct { + autorest.Response `json:"-"` + Value *[]Runbook `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// RunbookListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client RunbookListResult) RunbookListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// RunbookParameter is definition of the runbook parameter type. +type RunbookParameter struct { + Type *string `json:"type,omitempty"` + IsMandatory *bool `json:"isMandatory,omitempty"` + Position *int32 `json:"position,omitempty"` + DefaultValue *string `json:"defaultValue,omitempty"` +} + +// RunbookProperties is definition of the runbook property type. +type RunbookProperties struct { + RunbookType RunbookTypeEnum `json:"runbookType,omitempty"` + PublishContentLink *ContentLink `json:"publishContentLink,omitempty"` + State RunbookState `json:"state,omitempty"` + LogVerbose *bool `json:"logVerbose,omitempty"` + LogProgress *bool `json:"logProgress,omitempty"` + LogActivityTrace *int32 `json:"logActivityTrace,omitempty"` + JobCount *int32 `json:"jobCount,omitempty"` + Parameters *map[string]*RunbookParameter `json:"parameters,omitempty"` + OutputTypes *[]string `json:"outputTypes,omitempty"` + Draft *RunbookDraft `json:"draft,omitempty"` + ProvisioningState RunbookProvisioningState `json:"provisioningState,omitempty"` + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + CreationTime *date.Time `json:"creationTime,omitempty"` + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + Description *string `json:"description,omitempty"` +} + +// RunbookUpdateParameters is the parameters supplied to the update runbook +// operation. +type RunbookUpdateParameters struct { + *RunbookUpdateProperties `json:"properties,omitempty"` + Name *string `json:"name,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` +} + +// RunbookUpdateProperties is the parameters supplied to the update runbook +// properties. +type RunbookUpdateProperties struct { + Description *string `json:"description,omitempty"` + LogVerbose *bool `json:"logVerbose,omitempty"` + LogProgress *bool `json:"logProgress,omitempty"` + LogActivityTrace *int32 `json:"logActivityTrace,omitempty"` +} + +// Schedule is definition of the schedule. +type Schedule struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + *ScheduleProperties `json:"properties,omitempty"` +} + +// ScheduleAssociationProperty is the schedule property associated with the +// entity. +type ScheduleAssociationProperty struct { + Name *string `json:"name,omitempty"` +} + +// ScheduleCreateOrUpdateParameters is the parameters supplied to the create or +// update schedule operation. +type ScheduleCreateOrUpdateParameters struct { + Name *string `json:"name,omitempty"` + *ScheduleCreateOrUpdateProperties `json:"properties,omitempty"` +} + +// ScheduleCreateOrUpdateProperties is the parameters supplied to the create or +// update schedule operation. +type ScheduleCreateOrUpdateProperties struct { + Description *string `json:"description,omitempty"` + StartTime *date.Time `json:"startTime,omitempty"` + ExpiryTime *date.Time `json:"expiryTime,omitempty"` + Interval *map[string]interface{} `json:"interval,omitempty"` + Frequency ScheduleFrequency `json:"frequency,omitempty"` + TimeZone *string `json:"timeZone,omitempty"` + AdvancedSchedule *AdvancedSchedule `json:"advancedSchedule,omitempty"` +} + +// ScheduleListResult is the response model for the list schedule operation. +type ScheduleListResult struct { + autorest.Response `json:"-"` + Value *[]Schedule `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// ScheduleListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client ScheduleListResult) ScheduleListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// ScheduleProperties is definition of schedule parameters. +type ScheduleProperties struct { + StartTime *date.Time `json:"startTime,omitempty"` + StartTimeOffsetMinutes *float64 `json:"startTimeOffsetMinutes,omitempty"` + ExpiryTime *date.Time `json:"expiryTime,omitempty"` + ExpiryTimeOffsetMinutes *float64 `json:"expiryTimeOffsetMinutes,omitempty"` + IsEnabled *bool `json:"isEnabled,omitempty"` + NextRun *date.Time `json:"nextRun,omitempty"` + NextRunOffsetMinutes *float64 `json:"nextRunOffsetMinutes,omitempty"` + Interval *map[string]interface{} `json:"interval,omitempty"` + Frequency ScheduleFrequency `json:"frequency,omitempty"` + TimeZone *string `json:"timeZone,omitempty"` + AdvancedSchedule *AdvancedSchedule `json:"advancedSchedule,omitempty"` + CreationTime *date.Time `json:"creationTime,omitempty"` + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + Description *string `json:"description,omitempty"` +} + +// ScheduleUpdateParameters is the parameters supplied to the update schedule +// operation. +type ScheduleUpdateParameters struct { + Name *string `json:"name,omitempty"` + *ScheduleUpdateProperties `json:"properties,omitempty"` +} + +// ScheduleUpdateProperties is the parameters supplied to the update schedule +// operation. +type ScheduleUpdateProperties struct { + Description *string `json:"description,omitempty"` + IsEnabled *bool `json:"isEnabled,omitempty"` +} + +// Sku is the account SKU. +type Sku struct { + Name SkuNameEnum `json:"name,omitempty"` + Family *string `json:"family,omitempty"` + Capacity *int32 `json:"capacity,omitempty"` +} + +// Statistics is definition of the statistic. +type Statistics struct { + CounterProperty *string `json:"counterProperty,omitempty"` + CounterValue *int64 `json:"counterValue,omitempty"` + StartTime *date.Time `json:"startTime,omitempty"` + EndTime *date.Time `json:"endTime,omitempty"` + ID *string `json:"id,omitempty"` +} + +// StatisticsListResult is the response model for the list statistics +// operation. +type StatisticsListResult struct { + autorest.Response `json:"-"` + Value *[]Statistics `json:"value,omitempty"` +} + +// String is +type String struct { + autorest.Response `json:"-"` + Value *string `json:"value,omitempty"` +} + +// TestJob is definition of the test job. +type TestJob struct { + autorest.Response `json:"-"` + CreationTime *date.Time `json:"creationTime,omitempty"` + Status *string `json:"status,omitempty"` + StatusDetails *string `json:"statusDetails,omitempty"` + RunOn *string `json:"runOn,omitempty"` + StartTime *date.Time `json:"startTime,omitempty"` + EndTime *date.Time `json:"endTime,omitempty"` + Exception *string `json:"exception,omitempty"` + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + LastStatusModifiedTime *date.Time `json:"lastStatusModifiedTime,omitempty"` + Parameters *map[string]*string `json:"parameters,omitempty"` +} + +// TestJobCreateParameters is the parameters supplied to the create test job +// operation. +type TestJobCreateParameters struct { + RunbookName *string `json:"runbookName,omitempty"` + Parameters *map[string]*string `json:"parameters,omitempty"` + RunOn *string `json:"runOn,omitempty"` +} + +// TypeField is information about a field of a type. +type TypeField struct { + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} + +// TypeFieldListResult is the response model for the list fields operation. +type TypeFieldListResult struct { + autorest.Response `json:"-"` + Value *[]TypeField `json:"value,omitempty"` +} + +// Usage is definition of Usage. +type Usage struct { + ID *string `json:"id,omitempty"` + Name *UsageCounterName `json:"name,omitempty"` + Unit *string `json:"unit,omitempty"` + CurrentValue *float64 `json:"currentValue,omitempty"` + Limit *int64 `json:"limit,omitempty"` + ThrottleStatus *string `json:"throttleStatus,omitempty"` +} + +// UsageCounterName is definition of usage counter name. +type UsageCounterName struct { + Value *string `json:"value,omitempty"` + LocalizedValue *string `json:"localizedValue,omitempty"` +} + +// UsageListResult is the response model for the get usage operation. +type UsageListResult struct { + autorest.Response `json:"-"` + Value *[]Usage `json:"value,omitempty"` +} + +// Variable is definition of the varible. +type Variable struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + *VariableProperties `json:"properties,omitempty"` +} + +// VariableCreateOrUpdateParameters is the parameters supplied to the create or +// update variable operation. +type VariableCreateOrUpdateParameters struct { + Name *string `json:"name,omitempty"` + *VariableCreateOrUpdateProperties `json:"properties,omitempty"` +} + +// VariableCreateOrUpdateProperties is the properties of the create variable +// operation. +type VariableCreateOrUpdateProperties struct { + Value *string `json:"value,omitempty"` + Description *string `json:"description,omitempty"` + IsEncrypted *bool `json:"isEncrypted,omitempty"` +} + +// VariableListResult is the response model for the list variables operation. +type VariableListResult struct { + autorest.Response `json:"-"` + Value *[]Variable `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// VariableListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client VariableListResult) VariableListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// VariableProperties is definition of the varible properties +type VariableProperties struct { + Value *string `json:"value,omitempty"` + IsEncrypted *bool `json:"isEncrypted,omitempty"` + CreationTime *date.Time `json:"creationTime,omitempty"` + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + Description *string `json:"description,omitempty"` +} + +// VariableUpdateParameters is the parameters supplied to the update variable +// operation. +type VariableUpdateParameters struct { + Name *string `json:"name,omitempty"` + *VariableUpdateProperties `json:"properties,omitempty"` +} + +// VariableUpdateProperties is the properties of the update variable +type VariableUpdateProperties struct { + Value *string `json:"value,omitempty"` + Description *string `json:"description,omitempty"` +} + +// Webhook is definition of the webhook type. +type Webhook struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + *WebhookProperties `json:"properties,omitempty"` +} + +// WebhookCreateOrUpdateParameters is the parameters supplied to the create or +// update webhook operation. +type WebhookCreateOrUpdateParameters struct { + Name *string `json:"name,omitempty"` + *WebhookCreateOrUpdateProperties `json:"properties,omitempty"` +} + +// WebhookCreateOrUpdateProperties is the properties of the create webhook +// operation. +type WebhookCreateOrUpdateProperties struct { + IsEnabled *bool `json:"isEnabled,omitempty"` + URI *string `json:"uri,omitempty"` + ExpiryTime *date.Time `json:"expiryTime,omitempty"` + Parameters *map[string]*string `json:"parameters,omitempty"` + Runbook *RunbookAssociationProperty `json:"runbook,omitempty"` + RunOn *string `json:"runOn,omitempty"` +} + +// WebhookListResult is the response model for the list webhook operation. +type WebhookListResult struct { + autorest.Response `json:"-"` + Value *[]Webhook `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// WebhookListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client WebhookListResult) WebhookListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// WebhookProperties is definition of the webhook properties +type WebhookProperties struct { + IsEnabled *bool `json:"isEnabled,omitempty"` + URI *string `json:"uri,omitempty"` + ExpiryTime *date.Time `json:"expiryTime,omitempty"` + LastInvokedTime *date.Time `json:"lastInvokedTime,omitempty"` + Parameters *map[string]*string `json:"parameters,omitempty"` + Runbook *RunbookAssociationProperty `json:"runbook,omitempty"` + RunOn *string `json:"runOn,omitempty"` + CreationTime *date.Time `json:"creationTime,omitempty"` + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + Description *string `json:"description,omitempty"` +} + +// WebhookUpdateParameters is the parameters supplied to the update webhook +// operation. +type WebhookUpdateParameters struct { + Name *string `json:"name,omitempty"` + *WebhookUpdateProperties `json:"properties,omitempty"` +} + +// WebhookUpdateProperties is the properties of the update webhook. +type WebhookUpdateProperties struct { + IsEnabled *bool `json:"isEnabled,omitempty"` + RunOn *string `json:"runOn,omitempty"` + Parameters *map[string]*string `json:"parameters,omitempty"` + Description *string `json:"description,omitempty"` +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/module.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/module.go new file mode 100755 index 000000000000..225b0a4957e1 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/module.go @@ -0,0 +1,443 @@ +package automation + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// ModuleClient is the composite Swagger json for Azure Automation Client +type ModuleClient struct { + ManagementClient +} + +// NewModuleClient creates an instance of the ModuleClient client. +func NewModuleClient(subscriptionID string) ModuleClient { + return NewModuleClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewModuleClientWithBaseURI creates an instance of the ModuleClient client. +func NewModuleClientWithBaseURI(baseURI string, subscriptionID string) ModuleClient { + return ModuleClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or Update the module identified by module name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. moduleName is the name of module. parameters is the +// create or update parameters for module. +func (client ModuleClient) CreateOrUpdate(resourceGroupName string, automationAccountName string, moduleName string, parameters ModuleCreateOrUpdateParameters) (result Module, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ModuleCreateOrUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ModuleCreateOrUpdateProperties.ContentLink", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ModuleCreateOrUpdateProperties.ContentLink.ContentHash", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ModuleCreateOrUpdateProperties.ContentLink.ContentHash.Algorithm", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ModuleCreateOrUpdateProperties.ContentLink.ContentHash.Value", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.ModuleClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, automationAccountName, moduleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ModuleClient) CreateOrUpdatePreparer(resourceGroupName string, automationAccountName string, moduleName string, parameters ModuleCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "moduleName": autorest.Encode("path", moduleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ModuleClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ModuleClient) CreateOrUpdateResponder(resp *http.Response) (result Module, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete the module by name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. moduleName is the module name. +func (client ModuleClient) Delete(resourceGroupName string, automationAccountName string, moduleName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.ModuleClient", "Delete") + } + + req, err := client.DeletePreparer(resourceGroupName, automationAccountName, moduleName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ModuleClient) DeletePreparer(resourceGroupName string, automationAccountName string, moduleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "moduleName": autorest.Encode("path", moduleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ModuleClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ModuleClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve the module identified by module name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. moduleName is the module name. +func (client ModuleClient) Get(resourceGroupName string, automationAccountName string, moduleName string) (result Module, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.ModuleClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName, moduleName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ModuleClient) GetPreparer(resourceGroupName string, automationAccountName string, moduleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "moduleName": autorest.Encode("path", moduleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ModuleClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ModuleClient) GetResponder(resp *http.Response) (result Module, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of modules. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. +func (client ModuleClient) ListByAutomationAccount(resourceGroupName string, automationAccountName string) (result ModuleListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.ModuleClient", "ListByAutomationAccount") + } + + req, err := client.ListByAutomationAccountPreparer(resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client ModuleClient) ListByAutomationAccountPreparer(resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByAutomationAccountSender sends the ListByAutomationAccount request. The method will close the +// http.Response Body if it receives an error. +func (client ModuleClient) ListByAutomationAccountSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByAutomationAccountResponder handles the response to the ListByAutomationAccount request. The method always +// closes the http.Response Body. +func (client ModuleClient) ListByAutomationAccountResponder(resp *http.Response) (result ModuleListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccountNextResults retrieves the next set of results, if any. +func (client ModuleClient) ListByAutomationAccountNextResults(lastResults ModuleListResult) (result ModuleListResult, err error) { + req, err := lastResults.ModuleListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.ModuleClient", "ListByAutomationAccount", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.ModuleClient", "ListByAutomationAccount", resp, "Failure sending next results request") + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "ListByAutomationAccount", resp, "Failure responding to next results request") + } + + return +} + +// Update update the module identified by module name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. moduleName is the name of module. parameters is the +// update parameters for module. +func (client ModuleClient) Update(resourceGroupName string, automationAccountName string, moduleName string, parameters ModuleUpdateParameters) (result Module, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.ModuleClient", "Update") + } + + req, err := client.UpdatePreparer(resourceGroupName, automationAccountName, moduleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ModuleClient) UpdatePreparer(resourceGroupName string, automationAccountName string, moduleName string, parameters ModuleUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "moduleName": autorest.Encode("path", moduleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ModuleClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ModuleClient) UpdateResponder(resp *http.Response) (result Module, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/nodereports.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/nodereports.go new file mode 100755 index 000000000000..ad9f6acb3d48 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/nodereports.go @@ -0,0 +1,292 @@ +package automation + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// NodeReportsClient is the composite Swagger json for Azure Automation Client +type NodeReportsClient struct { + ManagementClient +} + +// NewNodeReportsClient creates an instance of the NodeReportsClient client. +func NewNodeReportsClient(subscriptionID string) NodeReportsClient { + return NewNodeReportsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewNodeReportsClientWithBaseURI creates an instance of the NodeReportsClient +// client. +func NewNodeReportsClientWithBaseURI(baseURI string, subscriptionID string) NodeReportsClient { + return NodeReportsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get retrieve the Dsc node report data by node id and report id. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. nodeID is the Dsc node id. reportID is the report +// id. +func (client NodeReportsClient) Get(resourceGroupName string, automationAccountName string, nodeID string, reportID string) (result DscNodeReport, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.NodeReportsClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName, nodeID, reportID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.NodeReportsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.NodeReportsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.NodeReportsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client NodeReportsClient) GetPreparer(resourceGroupName string, automationAccountName string, nodeID string, reportID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "nodeId": autorest.Encode("path", nodeID), + "reportId": autorest.Encode("path", reportID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports/{reportId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client NodeReportsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client NodeReportsClient) GetResponder(resp *http.Response) (result DscNodeReport, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetContent retrieve the Dsc node reports by node id and report id. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. nodeID is the Dsc node id. reportID is the report +// id. +func (client NodeReportsClient) GetContent(resourceGroupName string, automationAccountName string, nodeID string, reportID string) (result ReadCloser, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.NodeReportsClient", "GetContent") + } + + req, err := client.GetContentPreparer(resourceGroupName, automationAccountName, nodeID, reportID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.NodeReportsClient", "GetContent", nil, "Failure preparing request") + return + } + + resp, err := client.GetContentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.NodeReportsClient", "GetContent", resp, "Failure sending request") + return + } + + result, err = client.GetContentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.NodeReportsClient", "GetContent", resp, "Failure responding to request") + } + + return +} + +// GetContentPreparer prepares the GetContent request. +func (client NodeReportsClient) GetContentPreparer(resourceGroupName string, automationAccountName string, nodeID string, reportID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "nodeId": autorest.Encode("path", nodeID), + "reportId": autorest.Encode("path", reportID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports/{reportId}/content", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetContentSender sends the GetContent request. The method will close the +// http.Response Body if it receives an error. +func (client NodeReportsClient) GetContentSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetContentResponder handles the response to the GetContent request. The method always +// closes the http.Response Body. +func (client NodeReportsClient) GetContentResponder(resp *http.Response) (result ReadCloser, err error) { + result.Value = &resp.Body + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK)) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByNode retrieve the Dsc node report list by node id. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. nodeID is the parameters supplied to the list +// operation. filter is the filter to apply on the operation. +func (client NodeReportsClient) ListByNode(resourceGroupName string, automationAccountName string, nodeID string, filter string) (result DscNodeReportListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.NodeReportsClient", "ListByNode") + } + + req, err := client.ListByNodePreparer(resourceGroupName, automationAccountName, nodeID, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.NodeReportsClient", "ListByNode", nil, "Failure preparing request") + return + } + + resp, err := client.ListByNodeSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.NodeReportsClient", "ListByNode", resp, "Failure sending request") + return + } + + result, err = client.ListByNodeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.NodeReportsClient", "ListByNode", resp, "Failure responding to request") + } + + return +} + +// ListByNodePreparer prepares the ListByNode request. +func (client NodeReportsClient) ListByNodePreparer(resourceGroupName string, automationAccountName string, nodeID string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "nodeId": autorest.Encode("path", nodeID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByNodeSender sends the ListByNode request. The method will close the +// http.Response Body if it receives an error. +func (client NodeReportsClient) ListByNodeSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByNodeResponder handles the response to the ListByNode request. The method always +// closes the http.Response Body. +func (client NodeReportsClient) ListByNodeResponder(resp *http.Response) (result DscNodeReportListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByNodeNextResults retrieves the next set of results, if any. +func (client NodeReportsClient) ListByNodeNextResults(lastResults DscNodeReportListResult) (result DscNodeReportListResult, err error) { + req, err := lastResults.DscNodeReportListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.NodeReportsClient", "ListByNode", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByNodeSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.NodeReportsClient", "ListByNode", resp, "Failure sending next results request") + } + + result, err = client.ListByNodeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.NodeReportsClient", "ListByNode", resp, "Failure responding to next results request") + } + + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/objectdatatypes.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/objectdatatypes.go new file mode 100755 index 000000000000..0a0952fb2da3 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/objectdatatypes.go @@ -0,0 +1,194 @@ +package automation + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// ObjectDataTypesClient is the composite Swagger json for Azure Automation +// Client +type ObjectDataTypesClient struct { + ManagementClient +} + +// NewObjectDataTypesClient creates an instance of the ObjectDataTypesClient +// client. +func NewObjectDataTypesClient(subscriptionID string) ObjectDataTypesClient { + return NewObjectDataTypesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewObjectDataTypesClientWithBaseURI creates an instance of the +// ObjectDataTypesClient client. +func NewObjectDataTypesClientWithBaseURI(baseURI string, subscriptionID string) ObjectDataTypesClient { + return ObjectDataTypesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListFieldsByModuleAndType retrieve a list of fields of a given type +// identified by module name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. moduleName is the name of module. typeName is the +// name of type. +func (client ObjectDataTypesClient) ListFieldsByModuleAndType(resourceGroupName string, automationAccountName string, moduleName string, typeName string) (result TypeFieldListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.ObjectDataTypesClient", "ListFieldsByModuleAndType") + } + + req, err := client.ListFieldsByModuleAndTypePreparer(resourceGroupName, automationAccountName, moduleName, typeName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ObjectDataTypesClient", "ListFieldsByModuleAndType", nil, "Failure preparing request") + return + } + + resp, err := client.ListFieldsByModuleAndTypeSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ObjectDataTypesClient", "ListFieldsByModuleAndType", resp, "Failure sending request") + return + } + + result, err = client.ListFieldsByModuleAndTypeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ObjectDataTypesClient", "ListFieldsByModuleAndType", resp, "Failure responding to request") + } + + return +} + +// ListFieldsByModuleAndTypePreparer prepares the ListFieldsByModuleAndType request. +func (client ObjectDataTypesClient) ListFieldsByModuleAndTypePreparer(resourceGroupName string, automationAccountName string, moduleName string, typeName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "moduleName": autorest.Encode("path", moduleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "typeName": autorest.Encode("path", typeName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/objectDataTypes/{typeName}/fields", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListFieldsByModuleAndTypeSender sends the ListFieldsByModuleAndType request. The method will close the +// http.Response Body if it receives an error. +func (client ObjectDataTypesClient) ListFieldsByModuleAndTypeSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListFieldsByModuleAndTypeResponder handles the response to the ListFieldsByModuleAndType request. The method always +// closes the http.Response Body. +func (client ObjectDataTypesClient) ListFieldsByModuleAndTypeResponder(resp *http.Response) (result TypeFieldListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListFieldsByType retrieve a list of fields of a given type across all +// accessible modules. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. typeName is the name of type. +func (client ObjectDataTypesClient) ListFieldsByType(resourceGroupName string, automationAccountName string, typeName string) (result TypeFieldListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.ObjectDataTypesClient", "ListFieldsByType") + } + + req, err := client.ListFieldsByTypePreparer(resourceGroupName, automationAccountName, typeName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ObjectDataTypesClient", "ListFieldsByType", nil, "Failure preparing request") + return + } + + resp, err := client.ListFieldsByTypeSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ObjectDataTypesClient", "ListFieldsByType", resp, "Failure sending request") + return + } + + result, err = client.ListFieldsByTypeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ObjectDataTypesClient", "ListFieldsByType", resp, "Failure responding to request") + } + + return +} + +// ListFieldsByTypePreparer prepares the ListFieldsByType request. +func (client ObjectDataTypesClient) ListFieldsByTypePreparer(resourceGroupName string, automationAccountName string, typeName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "typeName": autorest.Encode("path", typeName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/objectDataTypes/{typeName}/fields", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListFieldsByTypeSender sends the ListFieldsByType request. The method will close the +// http.Response Body if it receives an error. +func (client ObjectDataTypesClient) ListFieldsByTypeSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListFieldsByTypeResponder handles the response to the ListFieldsByType request. The method always +// closes the http.Response Body. +func (client ObjectDataTypesClient) ListFieldsByTypeResponder(resp *http.Response) (result TypeFieldListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/operations.go new file mode 100755 index 000000000000..a70339b7a763 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/operations.go @@ -0,0 +1,98 @@ +package automation + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// OperationsClient is the composite Swagger json for Azure Automation Client +type OperationsClient struct { + ManagementClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient +// client. +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available Automation REST API operations. +func (client OperationsClient) List() (result OperationListResult, err error) { + req, err := client.ListPreparer() + if err != nil { + err = autorest.NewErrorWithError(err, "automation.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.OperationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.OperationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer() (*http.Request, error) { + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Automation/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/runbook.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/runbook.go new file mode 100755 index 000000000000..52a522bea753 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/runbook.go @@ -0,0 +1,523 @@ +package automation + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// RunbookClient is the composite Swagger json for Azure Automation Client +type RunbookClient struct { + ManagementClient +} + +// NewRunbookClient creates an instance of the RunbookClient client. +func NewRunbookClient(subscriptionID string) RunbookClient { + return NewRunbookClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRunbookClientWithBaseURI creates an instance of the RunbookClient client. +func NewRunbookClientWithBaseURI(baseURI string, subscriptionID string) RunbookClient { + return RunbookClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create the runbook identified by runbook name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. runbookName is the runbook name. parameters is the +// create or update parameters for runbook. Provide either content link for a +// published runbook or draft, not both. +func (client RunbookClient) CreateOrUpdate(resourceGroupName string, automationAccountName string, runbookName string, parameters RunbookCreateOrUpdateParameters) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.RunbookCreateOrUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.RunbookCreateOrUpdateProperties.Draft", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.RunbookCreateOrUpdateProperties.Draft.DraftContentLink", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.RunbookCreateOrUpdateProperties.Draft.DraftContentLink.ContentHash", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.RunbookCreateOrUpdateProperties.Draft.DraftContentLink.ContentHash.Algorithm", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.RunbookCreateOrUpdateProperties.Draft.DraftContentLink.ContentHash.Value", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}, + }}, + {Target: "parameters.RunbookCreateOrUpdateProperties.PublishContentLink", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.RunbookCreateOrUpdateProperties.PublishContentLink.ContentHash", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.RunbookCreateOrUpdateProperties.PublishContentLink.ContentHash.Algorithm", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.RunbookCreateOrUpdateProperties.PublishContentLink.ContentHash.Value", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.RunbookClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, automationAccountName, runbookName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client RunbookClient) CreateOrUpdatePreparer(resourceGroupName string, automationAccountName string, runbookName string, parameters RunbookCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client RunbookClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client RunbookClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusBadRequest), + autorest.ByClosing()) + result.Response = resp + return +} + +// Delete delete the runbook by name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. runbookName is the runbook name. +func (client RunbookClient) Delete(resourceGroupName string, automationAccountName string, runbookName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.RunbookClient", "Delete") + } + + req, err := client.DeletePreparer(resourceGroupName, automationAccountName, runbookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client RunbookClient) DeletePreparer(resourceGroupName string, automationAccountName string, runbookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client RunbookClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client RunbookClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve the runbook identified by runbook name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. runbookName is the runbook name. +func (client RunbookClient) Get(resourceGroupName string, automationAccountName string, runbookName string) (result Runbook, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.RunbookClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName, runbookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client RunbookClient) GetPreparer(resourceGroupName string, automationAccountName string, runbookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client RunbookClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RunbookClient) GetResponder(resp *http.Response) (result Runbook, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetContent retrieve the content of runbook identified by runbook name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. runbookName is the runbook name. +func (client RunbookClient) GetContent(resourceGroupName string, automationAccountName string, runbookName string) (result ReadCloser, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.RunbookClient", "GetContent") + } + + req, err := client.GetContentPreparer(resourceGroupName, automationAccountName, runbookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "GetContent", nil, "Failure preparing request") + return + } + + resp, err := client.GetContentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "GetContent", resp, "Failure sending request") + return + } + + result, err = client.GetContentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "GetContent", resp, "Failure responding to request") + } + + return +} + +// GetContentPreparer prepares the GetContent request. +func (client RunbookClient) GetContentPreparer(resourceGroupName string, automationAccountName string, runbookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/content", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetContentSender sends the GetContent request. The method will close the +// http.Response Body if it receives an error. +func (client RunbookClient) GetContentSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetContentResponder handles the response to the GetContent request. The method always +// closes the http.Response Body. +func (client RunbookClient) GetContentResponder(resp *http.Response) (result ReadCloser, err error) { + result.Value = &resp.Body + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK)) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of runbooks. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. +func (client RunbookClient) ListByAutomationAccount(resourceGroupName string, automationAccountName string) (result RunbookListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.RunbookClient", "ListByAutomationAccount") + } + + req, err := client.ListByAutomationAccountPreparer(resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client RunbookClient) ListByAutomationAccountPreparer(resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByAutomationAccountSender sends the ListByAutomationAccount request. The method will close the +// http.Response Body if it receives an error. +func (client RunbookClient) ListByAutomationAccountSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByAutomationAccountResponder handles the response to the ListByAutomationAccount request. The method always +// closes the http.Response Body. +func (client RunbookClient) ListByAutomationAccountResponder(resp *http.Response) (result RunbookListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccountNextResults retrieves the next set of results, if any. +func (client RunbookClient) ListByAutomationAccountNextResults(lastResults RunbookListResult) (result RunbookListResult, err error) { + req, err := lastResults.RunbookListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.RunbookClient", "ListByAutomationAccount", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.RunbookClient", "ListByAutomationAccount", resp, "Failure sending next results request") + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "ListByAutomationAccount", resp, "Failure responding to next results request") + } + + return +} + +// Update update the runbook identified by runbook name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. runbookName is the runbook name. parameters is the +// update parameters for runbook. +func (client RunbookClient) Update(resourceGroupName string, automationAccountName string, runbookName string, parameters RunbookUpdateParameters) (result Runbook, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.RunbookClient", "Update") + } + + req, err := client.UpdatePreparer(resourceGroupName, automationAccountName, runbookName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client RunbookClient) UpdatePreparer(resourceGroupName string, automationAccountName string, runbookName string, parameters RunbookUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client RunbookClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client RunbookClient) UpdateResponder(resp *http.Response) (result Runbook, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/runbookdraft.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/runbookdraft.go new file mode 100755 index 000000000000..d3679ee4370f --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/runbookdraft.go @@ -0,0 +1,447 @@ +package automation + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "io" + "net/http" +) + +// RunbookDraftClient is the composite Swagger json for Azure Automation Client +type RunbookDraftClient struct { + ManagementClient +} + +// NewRunbookDraftClient creates an instance of the RunbookDraftClient client. +func NewRunbookDraftClient(subscriptionID string) RunbookDraftClient { + return NewRunbookDraftClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRunbookDraftClientWithBaseURI creates an instance of the +// RunbookDraftClient client. +func NewRunbookDraftClientWithBaseURI(baseURI string, subscriptionID string) RunbookDraftClient { + return RunbookDraftClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate updates the runbook draft with runbookStream as its content. +// This method may poll for completion. Polling can be canceled by passing the +// cancel channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. runbookName is the runbook name. runbookContent is +// the runbook draft content. runbookContent will be closed upon successful +// return. Callers should ensure closure when receiving an error. +func (client RunbookDraftClient) CreateOrUpdate(resourceGroupName string, automationAccountName string, runbookName string, runbookContent io.ReadCloser, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "automation.RunbookDraftClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, automationAccountName, runbookName, runbookContent, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client RunbookDraftClient) CreateOrUpdatePreparer(resourceGroupName string, automationAccountName string, runbookName string, runbookContent io.ReadCloser, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/content", pathParameters), + autorest.WithFile(runbookContent), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client RunbookDraftClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client RunbookDraftClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve the runbook draft identified by runbook name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. runbookName is the runbook name. +func (client RunbookDraftClient) Get(resourceGroupName string, automationAccountName string, runbookName string) (result RunbookDraft, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.RunbookDraftClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName, runbookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client RunbookDraftClient) GetPreparer(resourceGroupName string, automationAccountName string, runbookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client RunbookDraftClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RunbookDraftClient) GetResponder(resp *http.Response) (result RunbookDraft, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetContent retrieve the content of runbook draft identified by runbook name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. runbookName is the runbook name. +func (client RunbookDraftClient) GetContent(resourceGroupName string, automationAccountName string, runbookName string) (result ReadCloser, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.RunbookDraftClient", "GetContent") + } + + req, err := client.GetContentPreparer(resourceGroupName, automationAccountName, runbookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "GetContent", nil, "Failure preparing request") + return + } + + resp, err := client.GetContentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "GetContent", resp, "Failure sending request") + return + } + + result, err = client.GetContentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "GetContent", resp, "Failure responding to request") + } + + return +} + +// GetContentPreparer prepares the GetContent request. +func (client RunbookDraftClient) GetContentPreparer(resourceGroupName string, automationAccountName string, runbookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/content", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetContentSender sends the GetContent request. The method will close the +// http.Response Body if it receives an error. +func (client RunbookDraftClient) GetContentSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetContentResponder handles the response to the GetContent request. The method always +// closes the http.Response Body. +func (client RunbookDraftClient) GetContentResponder(resp *http.Response) (result ReadCloser, err error) { + result.Value = &resp.Body + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK)) + result.Response = autorest.Response{Response: resp} + return +} + +// Publish publish runbook draft. This method may poll for completion. Polling +// can be canceled by passing the cancel channel argument. The channel will be +// used to cancel polling and any outstanding HTTP requests. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. runbookName is the parameters supplied to the +// publish runbook operation. +func (client RunbookDraftClient) Publish(resourceGroupName string, automationAccountName string, runbookName string, cancel <-chan struct{}) (<-chan Runbook, <-chan error) { + resultChan := make(chan Runbook, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "automation.RunbookDraftClient", "Publish") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result Runbook + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.PublishPreparer(resourceGroupName, automationAccountName, runbookName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "Publish", nil, "Failure preparing request") + return + } + + resp, err := client.PublishSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "Publish", resp, "Failure sending request") + return + } + + result, err = client.PublishResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "Publish", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// PublishPreparer prepares the Publish request. +func (client RunbookDraftClient) PublishPreparer(resourceGroupName string, automationAccountName string, runbookName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/publish", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// PublishSender sends the Publish request. The method will close the +// http.Response Body if it receives an error. +func (client RunbookDraftClient) PublishSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// PublishResponder handles the response to the Publish request. The method always +// closes the http.Response Body. +func (client RunbookDraftClient) PublishResponder(resp *http.Response) (result Runbook, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UndoEdit retrieve the runbook identified by runbook name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. runbookName is the runbook name. +func (client RunbookDraftClient) UndoEdit(resourceGroupName string, automationAccountName string, runbookName string) (result RunbookDraftUndoEditResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.RunbookDraftClient", "UndoEdit") + } + + req, err := client.UndoEditPreparer(resourceGroupName, automationAccountName, runbookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "UndoEdit", nil, "Failure preparing request") + return + } + + resp, err := client.UndoEditSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "UndoEdit", resp, "Failure sending request") + return + } + + result, err = client.UndoEditResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "UndoEdit", resp, "Failure responding to request") + } + + return +} + +// UndoEditPreparer prepares the UndoEdit request. +func (client RunbookDraftClient) UndoEditPreparer(resourceGroupName string, automationAccountName string, runbookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/undoEdit", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// UndoEditSender sends the UndoEdit request. The method will close the +// http.Response Body if it receives an error. +func (client RunbookDraftClient) UndoEditSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UndoEditResponder handles the response to the UndoEdit request. The method always +// closes the http.Response Body. +func (client RunbookDraftClient) UndoEditResponder(resp *http.Response) (result RunbookDraftUndoEditResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/schedule.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/schedule.go new file mode 100755 index 000000000000..9a98147d6976 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/schedule.go @@ -0,0 +1,439 @@ +package automation + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// ScheduleClient is the composite Swagger json for Azure Automation Client +type ScheduleClient struct { + ManagementClient +} + +// NewScheduleClient creates an instance of the ScheduleClient client. +func NewScheduleClient(subscriptionID string) ScheduleClient { + return NewScheduleClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewScheduleClientWithBaseURI creates an instance of the ScheduleClient +// client. +func NewScheduleClientWithBaseURI(baseURI string, subscriptionID string) ScheduleClient { + return ScheduleClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create a schedule. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. scheduleName is the schedule name. parameters is +// the parameters supplied to the create or update schedule operation. +func (client ScheduleClient) CreateOrUpdate(resourceGroupName string, automationAccountName string, scheduleName string, parameters ScheduleCreateOrUpdateParameters) (result Schedule, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ScheduleCreateOrUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ScheduleCreateOrUpdateProperties.StartTime", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.ScheduleClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, automationAccountName, scheduleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ScheduleClient) CreateOrUpdatePreparer(resourceGroupName string, automationAccountName string, scheduleName string, parameters ScheduleCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scheduleName": autorest.Encode("path", scheduleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ScheduleClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ScheduleClient) CreateOrUpdateResponder(resp *http.Response) (result Schedule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusConflict), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete the schedule identified by schedule name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. scheduleName is the schedule name. +func (client ScheduleClient) Delete(resourceGroupName string, automationAccountName string, scheduleName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.ScheduleClient", "Delete") + } + + req, err := client.DeletePreparer(resourceGroupName, automationAccountName, scheduleName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ScheduleClient) DeletePreparer(resourceGroupName string, automationAccountName string, scheduleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scheduleName": autorest.Encode("path", scheduleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ScheduleClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ScheduleClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNotFound), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve the schedule identified by schedule name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. scheduleName is the schedule name. +func (client ScheduleClient) Get(resourceGroupName string, automationAccountName string, scheduleName string) (result Schedule, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.ScheduleClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName, scheduleName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ScheduleClient) GetPreparer(resourceGroupName string, automationAccountName string, scheduleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scheduleName": autorest.Encode("path", scheduleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ScheduleClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ScheduleClient) GetResponder(resp *http.Response) (result Schedule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of schedules. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. +func (client ScheduleClient) ListByAutomationAccount(resourceGroupName string, automationAccountName string) (result ScheduleListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.ScheduleClient", "ListByAutomationAccount") + } + + req, err := client.ListByAutomationAccountPreparer(resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client ScheduleClient) ListByAutomationAccountPreparer(resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByAutomationAccountSender sends the ListByAutomationAccount request. The method will close the +// http.Response Body if it receives an error. +func (client ScheduleClient) ListByAutomationAccountSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByAutomationAccountResponder handles the response to the ListByAutomationAccount request. The method always +// closes the http.Response Body. +func (client ScheduleClient) ListByAutomationAccountResponder(resp *http.Response) (result ScheduleListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccountNextResults retrieves the next set of results, if any. +func (client ScheduleClient) ListByAutomationAccountNextResults(lastResults ScheduleListResult) (result ScheduleListResult, err error) { + req, err := lastResults.ScheduleListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.ScheduleClient", "ListByAutomationAccount", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.ScheduleClient", "ListByAutomationAccount", resp, "Failure sending next results request") + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "ListByAutomationAccount", resp, "Failure responding to next results request") + } + + return +} + +// Update update the schedule identified by schedule name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. scheduleName is the schedule name. parameters is +// the parameters supplied to the update schedule operation. +func (client ScheduleClient) Update(resourceGroupName string, automationAccountName string, scheduleName string, parameters ScheduleUpdateParameters) (result Schedule, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.ScheduleClient", "Update") + } + + req, err := client.UpdatePreparer(resourceGroupName, automationAccountName, scheduleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ScheduleClient) UpdatePreparer(resourceGroupName string, automationAccountName string, scheduleName string, parameters ScheduleUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scheduleName": autorest.Encode("path", scheduleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ScheduleClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ScheduleClient) UpdateResponder(resp *http.Response) (result Schedule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/statistics.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/statistics.go new file mode 100755 index 000000000000..74d027ebe340 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/statistics.go @@ -0,0 +1,117 @@ +package automation + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// StatisticsClient is the composite Swagger json for Azure Automation Client +type StatisticsClient struct { + ManagementClient +} + +// NewStatisticsClient creates an instance of the StatisticsClient client. +func NewStatisticsClient(subscriptionID string) StatisticsClient { + return NewStatisticsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewStatisticsClientWithBaseURI creates an instance of the StatisticsClient +// client. +func NewStatisticsClientWithBaseURI(baseURI string, subscriptionID string) StatisticsClient { + return StatisticsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByAutomationAccount retrieve the statistics for the account. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. filter is the filter to apply on the operation. +func (client StatisticsClient) ListByAutomationAccount(resourceGroupName string, automationAccountName string, filter string) (result StatisticsListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.StatisticsClient", "ListByAutomationAccount") + } + + req, err := client.ListByAutomationAccountPreparer(resourceGroupName, automationAccountName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.StatisticsClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.StatisticsClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.StatisticsClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client StatisticsClient) ListByAutomationAccountPreparer(resourceGroupName string, automationAccountName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/statistics", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByAutomationAccountSender sends the ListByAutomationAccount request. The method will close the +// http.Response Body if it receives an error. +func (client StatisticsClient) ListByAutomationAccountSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByAutomationAccountResponder handles the response to the ListByAutomationAccount request. The method always +// closes the http.Response Body. +func (client StatisticsClient) ListByAutomationAccountResponder(resp *http.Response) (result StatisticsListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/testjobs.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/testjobs.go new file mode 100755 index 000000000000..55a39599a1db --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/testjobs.go @@ -0,0 +1,410 @@ +package automation + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// TestJobsClient is the composite Swagger json for Azure Automation Client +type TestJobsClient struct { + ManagementClient +} + +// NewTestJobsClient creates an instance of the TestJobsClient client. +func NewTestJobsClient(subscriptionID string) TestJobsClient { + return NewTestJobsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewTestJobsClientWithBaseURI creates an instance of the TestJobsClient +// client. +func NewTestJobsClientWithBaseURI(baseURI string, subscriptionID string) TestJobsClient { + return TestJobsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create create a test job of the runbook. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. runbookName is the parameters supplied to the +// create test job operation. parameters is the parameters supplied to the +// create test job operation. +func (client TestJobsClient) Create(resourceGroupName string, automationAccountName string, runbookName string, parameters TestJobCreateParameters) (result TestJob, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.RunbookName", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.TestJobsClient", "Create") + } + + req, err := client.CreatePreparer(resourceGroupName, automationAccountName, runbookName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobsClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.TestJobsClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobsClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client TestJobsClient) CreatePreparer(resourceGroupName string, automationAccountName string, runbookName string, parameters TestJobCreateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client TestJobsClient) CreateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client TestJobsClient) CreateResponder(resp *http.Response) (result TestJob, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get retrieve the test job for the specified runbook. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. runbookName is the runbook name. +func (client TestJobsClient) Get(resourceGroupName string, automationAccountName string, runbookName string) (result TestJob, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.TestJobsClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName, runbookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.TestJobsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client TestJobsClient) GetPreparer(resourceGroupName string, automationAccountName string, runbookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client TestJobsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client TestJobsClient) GetResponder(resp *http.Response) (result TestJob, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Resume resume the test job. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. runbookName is the runbook name. +func (client TestJobsClient) Resume(resourceGroupName string, automationAccountName string, runbookName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.TestJobsClient", "Resume") + } + + req, err := client.ResumePreparer(resourceGroupName, automationAccountName, runbookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobsClient", "Resume", nil, "Failure preparing request") + return + } + + resp, err := client.ResumeSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.TestJobsClient", "Resume", resp, "Failure sending request") + return + } + + result, err = client.ResumeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobsClient", "Resume", resp, "Failure responding to request") + } + + return +} + +// ResumePreparer prepares the Resume request. +func (client TestJobsClient) ResumePreparer(resourceGroupName string, automationAccountName string, runbookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/resume", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ResumeSender sends the Resume request. The method will close the +// http.Response Body if it receives an error. +func (client TestJobsClient) ResumeSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ResumeResponder handles the response to the Resume request. The method always +// closes the http.Response Body. +func (client TestJobsClient) ResumeResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Stop stop the test job. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. runbookName is the runbook name. +func (client TestJobsClient) Stop(resourceGroupName string, automationAccountName string, runbookName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.TestJobsClient", "Stop") + } + + req, err := client.StopPreparer(resourceGroupName, automationAccountName, runbookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobsClient", "Stop", nil, "Failure preparing request") + return + } + + resp, err := client.StopSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.TestJobsClient", "Stop", resp, "Failure sending request") + return + } + + result, err = client.StopResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobsClient", "Stop", resp, "Failure responding to request") + } + + return +} + +// StopPreparer prepares the Stop request. +func (client TestJobsClient) StopPreparer(resourceGroupName string, automationAccountName string, runbookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/stop", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// StopSender sends the Stop request. The method will close the +// http.Response Body if it receives an error. +func (client TestJobsClient) StopSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// StopResponder handles the response to the Stop request. The method always +// closes the http.Response Body. +func (client TestJobsClient) StopResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Suspend suspend the test job. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. runbookName is the runbook name. +func (client TestJobsClient) Suspend(resourceGroupName string, automationAccountName string, runbookName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.TestJobsClient", "Suspend") + } + + req, err := client.SuspendPreparer(resourceGroupName, automationAccountName, runbookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobsClient", "Suspend", nil, "Failure preparing request") + return + } + + resp, err := client.SuspendSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.TestJobsClient", "Suspend", resp, "Failure sending request") + return + } + + result, err = client.SuspendResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobsClient", "Suspend", resp, "Failure responding to request") + } + + return +} + +// SuspendPreparer prepares the Suspend request. +func (client TestJobsClient) SuspendPreparer(resourceGroupName string, automationAccountName string, runbookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/suspend", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// SuspendSender sends the Suspend request. The method will close the +// http.Response Body if it receives an error. +func (client TestJobsClient) SuspendSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// SuspendResponder handles the response to the Suspend request. The method always +// closes the http.Response Body. +func (client TestJobsClient) SuspendResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/testjobstreams.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/testjobstreams.go new file mode 100755 index 000000000000..f5f608457c29 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/testjobstreams.go @@ -0,0 +1,221 @@ +package automation + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// TestJobStreamsClient is the composite Swagger json for Azure Automation +// Client +type TestJobStreamsClient struct { + ManagementClient +} + +// NewTestJobStreamsClient creates an instance of the TestJobStreamsClient +// client. +func NewTestJobStreamsClient(subscriptionID string) TestJobStreamsClient { + return NewTestJobStreamsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewTestJobStreamsClientWithBaseURI creates an instance of the +// TestJobStreamsClient client. +func NewTestJobStreamsClientWithBaseURI(baseURI string, subscriptionID string) TestJobStreamsClient { + return TestJobStreamsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get retrieve a test job streams identified by runbook name and stream id. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. runbookName is the runbook name. jobStreamID is the +// job stream id. +func (client TestJobStreamsClient) Get(resourceGroupName string, automationAccountName string, runbookName string, jobStreamID string) (result JobStream, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.TestJobStreamsClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName, runbookName, jobStreamID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobStreamsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.TestJobStreamsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobStreamsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client TestJobStreamsClient) GetPreparer(resourceGroupName string, automationAccountName string, runbookName string, jobStreamID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobStreamId": autorest.Encode("path", jobStreamID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/streams/{jobStreamId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client TestJobStreamsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client TestJobStreamsClient) GetResponder(resp *http.Response) (result JobStream, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByTestJob retrieve a list of test job streams identified by runbook +// name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. runbookName is the runbook name. filter is the +// filter to apply on the operation. +func (client TestJobStreamsClient) ListByTestJob(resourceGroupName string, automationAccountName string, runbookName string, filter string) (result JobStreamListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.TestJobStreamsClient", "ListByTestJob") + } + + req, err := client.ListByTestJobPreparer(resourceGroupName, automationAccountName, runbookName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobStreamsClient", "ListByTestJob", nil, "Failure preparing request") + return + } + + resp, err := client.ListByTestJobSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.TestJobStreamsClient", "ListByTestJob", resp, "Failure sending request") + return + } + + result, err = client.ListByTestJobResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobStreamsClient", "ListByTestJob", resp, "Failure responding to request") + } + + return +} + +// ListByTestJobPreparer prepares the ListByTestJob request. +func (client TestJobStreamsClient) ListByTestJobPreparer(resourceGroupName string, automationAccountName string, runbookName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/streams", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByTestJobSender sends the ListByTestJob request. The method will close the +// http.Response Body if it receives an error. +func (client TestJobStreamsClient) ListByTestJobSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByTestJobResponder handles the response to the ListByTestJob request. The method always +// closes the http.Response Body. +func (client TestJobStreamsClient) ListByTestJobResponder(resp *http.Response) (result JobStreamListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByTestJobNextResults retrieves the next set of results, if any. +func (client TestJobStreamsClient) ListByTestJobNextResults(lastResults JobStreamListResult) (result JobStreamListResult, err error) { + req, err := lastResults.JobStreamListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.TestJobStreamsClient", "ListByTestJob", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByTestJobSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.TestJobStreamsClient", "ListByTestJob", resp, "Failure sending next results request") + } + + result, err = client.ListByTestJobResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobStreamsClient", "ListByTestJob", resp, "Failure responding to next results request") + } + + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/usages.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/usages.go new file mode 100755 index 000000000000..63057bebad69 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/usages.go @@ -0,0 +1,113 @@ +package automation + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// UsagesClient is the composite Swagger json for Azure Automation Client +type UsagesClient struct { + ManagementClient +} + +// NewUsagesClient creates an instance of the UsagesClient client. +func NewUsagesClient(subscriptionID string) UsagesClient { + return NewUsagesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewUsagesClientWithBaseURI creates an instance of the UsagesClient client. +func NewUsagesClientWithBaseURI(baseURI string, subscriptionID string) UsagesClient { + return UsagesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByAutomationAccount retrieve the usage for the account id. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. +func (client UsagesClient) ListByAutomationAccount(resourceGroupName string, automationAccountName string) (result UsageListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.UsagesClient", "ListByAutomationAccount") + } + + req, err := client.ListByAutomationAccountPreparer(resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.UsagesClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.UsagesClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.UsagesClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client UsagesClient) ListByAutomationAccountPreparer(resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/usages", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByAutomationAccountSender sends the ListByAutomationAccount request. The method will close the +// http.Response Body if it receives an error. +func (client UsagesClient) ListByAutomationAccountSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByAutomationAccountResponder handles the response to the ListByAutomationAccount request. The method always +// closes the http.Response Body. +func (client UsagesClient) ListByAutomationAccountResponder(resp *http.Response) (result UsageListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/variable.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/variable.go new file mode 100755 index 000000000000..22da1431d9f3 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/variable.go @@ -0,0 +1,438 @@ +package automation + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// VariableClient is the composite Swagger json for Azure Automation Client +type VariableClient struct { + ManagementClient +} + +// NewVariableClient creates an instance of the VariableClient client. +func NewVariableClient(subscriptionID string) VariableClient { + return NewVariableClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewVariableClientWithBaseURI creates an instance of the VariableClient +// client. +func NewVariableClientWithBaseURI(baseURI string, subscriptionID string) VariableClient { + return VariableClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create a variable. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. variableName is the variable name. parameters is +// the parameters supplied to the create or update variable operation. +func (client VariableClient) CreateOrUpdate(resourceGroupName string, automationAccountName string, variableName string, parameters VariableCreateOrUpdateParameters) (result Variable, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.VariableCreateOrUpdateProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.VariableClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, automationAccountName, variableName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.VariableClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.VariableClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.VariableClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client VariableClient) CreateOrUpdatePreparer(resourceGroupName string, automationAccountName string, variableName string, parameters VariableCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "variableName": autorest.Encode("path", variableName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client VariableClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client VariableClient) CreateOrUpdateResponder(resp *http.Response) (result Variable, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete the variable. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. variableName is the name of variable. +func (client VariableClient) Delete(resourceGroupName string, automationAccountName string, variableName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.VariableClient", "Delete") + } + + req, err := client.DeletePreparer(resourceGroupName, automationAccountName, variableName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.VariableClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.VariableClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.VariableClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client VariableClient) DeletePreparer(resourceGroupName string, automationAccountName string, variableName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "variableName": autorest.Encode("path", variableName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client VariableClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client VariableClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve the variable identified by variable name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. variableName is the name of variable. +func (client VariableClient) Get(resourceGroupName string, automationAccountName string, variableName string) (result Variable, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.VariableClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName, variableName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.VariableClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.VariableClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.VariableClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client VariableClient) GetPreparer(resourceGroupName string, automationAccountName string, variableName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "variableName": autorest.Encode("path", variableName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client VariableClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client VariableClient) GetResponder(resp *http.Response) (result Variable, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of variables. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. +func (client VariableClient) ListByAutomationAccount(resourceGroupName string, automationAccountName string) (result VariableListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.VariableClient", "ListByAutomationAccount") + } + + req, err := client.ListByAutomationAccountPreparer(resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.VariableClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.VariableClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.VariableClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client VariableClient) ListByAutomationAccountPreparer(resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByAutomationAccountSender sends the ListByAutomationAccount request. The method will close the +// http.Response Body if it receives an error. +func (client VariableClient) ListByAutomationAccountSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByAutomationAccountResponder handles the response to the ListByAutomationAccount request. The method always +// closes the http.Response Body. +func (client VariableClient) ListByAutomationAccountResponder(resp *http.Response) (result VariableListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccountNextResults retrieves the next set of results, if any. +func (client VariableClient) ListByAutomationAccountNextResults(lastResults VariableListResult) (result VariableListResult, err error) { + req, err := lastResults.VariableListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.VariableClient", "ListByAutomationAccount", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.VariableClient", "ListByAutomationAccount", resp, "Failure sending next results request") + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.VariableClient", "ListByAutomationAccount", resp, "Failure responding to next results request") + } + + return +} + +// Update update a variable. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. variableName is the variable name. parameters is +// the parameters supplied to the update variable operation. +func (client VariableClient) Update(resourceGroupName string, automationAccountName string, variableName string, parameters VariableUpdateParameters) (result Variable, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.VariableClient", "Update") + } + + req, err := client.UpdatePreparer(resourceGroupName, automationAccountName, variableName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.VariableClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.VariableClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.VariableClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client VariableClient) UpdatePreparer(resourceGroupName string, automationAccountName string, variableName string, parameters VariableUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "variableName": autorest.Encode("path", variableName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client VariableClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client VariableClient) UpdateResponder(resp *http.Response) (result Variable, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/version.go new file mode 100755 index 000000000000..2ae93d27a8fc --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/version.go @@ -0,0 +1,28 @@ +package automation + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/v10.2.0-beta arm-automation/" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return "v10.2.0-beta" +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/webhook.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/webhook.go new file mode 100755 index 000000000000..8b172c07278d --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/webhook.go @@ -0,0 +1,512 @@ +package automation + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// WebhookClient is the composite Swagger json for Azure Automation Client +type WebhookClient struct { + ManagementClient +} + +// NewWebhookClient creates an instance of the WebhookClient client. +func NewWebhookClient(subscriptionID string) WebhookClient { + return NewWebhookClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWebhookClientWithBaseURI creates an instance of the WebhookClient client. +func NewWebhookClientWithBaseURI(baseURI string, subscriptionID string) WebhookClient { + return WebhookClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create the webhook identified by webhook name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. webhookName is the webhook name. parameters is the +// create or update parameters for webhook. +func (client WebhookClient) CreateOrUpdate(resourceGroupName string, automationAccountName string, webhookName string, parameters WebhookCreateOrUpdateParameters) (result Webhook, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.WebhookCreateOrUpdateProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.WebhookClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, automationAccountName, webhookName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client WebhookClient) CreateOrUpdatePreparer(resourceGroupName string, automationAccountName string, webhookName string, parameters WebhookCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "webhookName": autorest.Encode("path", webhookName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client WebhookClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client WebhookClient) CreateOrUpdateResponder(resp *http.Response) (result Webhook, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete the webhook by name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. webhookName is the webhook name. +func (client WebhookClient) Delete(resourceGroupName string, automationAccountName string, webhookName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.WebhookClient", "Delete") + } + + req, err := client.DeletePreparer(resourceGroupName, automationAccountName, webhookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client WebhookClient) DeletePreparer(resourceGroupName string, automationAccountName string, webhookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "webhookName": autorest.Encode("path", webhookName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client WebhookClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client WebhookClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// GenerateURI generates a Uri for use in creating a webhook. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. +func (client WebhookClient) GenerateURI(resourceGroupName string, automationAccountName string) (result String, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.WebhookClient", "GenerateURI") + } + + req, err := client.GenerateURIPreparer(resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "GenerateURI", nil, "Failure preparing request") + return + } + + resp, err := client.GenerateURISender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "GenerateURI", resp, "Failure sending request") + return + } + + result, err = client.GenerateURIResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "GenerateURI", resp, "Failure responding to request") + } + + return +} + +// GenerateURIPreparer prepares the GenerateURI request. +func (client WebhookClient) GenerateURIPreparer(resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/generateUri", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GenerateURISender sends the GenerateURI request. The method will close the +// http.Response Body if it receives an error. +func (client WebhookClient) GenerateURISender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GenerateURIResponder handles the response to the GenerateURI request. The method always +// closes the http.Response Body. +func (client WebhookClient) GenerateURIResponder(resp *http.Response) (result String, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Value), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get retrieve the webhook identified by webhook name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. webhookName is the webhook name. +func (client WebhookClient) Get(resourceGroupName string, automationAccountName string, webhookName string) (result Webhook, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.WebhookClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName, webhookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client WebhookClient) GetPreparer(resourceGroupName string, automationAccountName string, webhookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "webhookName": autorest.Encode("path", webhookName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client WebhookClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client WebhookClient) GetResponder(resp *http.Response) (result Webhook, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of webhooks. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. filter is the filter to apply on the operation. +func (client WebhookClient) ListByAutomationAccount(resourceGroupName string, automationAccountName string, filter string) (result WebhookListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.WebhookClient", "ListByAutomationAccount") + } + + req, err := client.ListByAutomationAccountPreparer(resourceGroupName, automationAccountName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client WebhookClient) ListByAutomationAccountPreparer(resourceGroupName string, automationAccountName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByAutomationAccountSender sends the ListByAutomationAccount request. The method will close the +// http.Response Body if it receives an error. +func (client WebhookClient) ListByAutomationAccountSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByAutomationAccountResponder handles the response to the ListByAutomationAccount request. The method always +// closes the http.Response Body. +func (client WebhookClient) ListByAutomationAccountResponder(resp *http.Response) (result WebhookListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccountNextResults retrieves the next set of results, if any. +func (client WebhookClient) ListByAutomationAccountNextResults(lastResults WebhookListResult) (result WebhookListResult, err error) { + req, err := lastResults.WebhookListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.WebhookClient", "ListByAutomationAccount", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.WebhookClient", "ListByAutomationAccount", resp, "Failure sending next results request") + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "ListByAutomationAccount", resp, "Failure responding to next results request") + } + + return +} + +// Update update the webhook identified by webhook name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. webhookName is the webhook name. parameters is the +// update parameters for webhook. +func (client WebhookClient) Update(resourceGroupName string, automationAccountName string, webhookName string, parameters WebhookUpdateParameters) (result Webhook, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.WebhookClient", "Update") + } + + req, err := client.UpdatePreparer(resourceGroupName, automationAccountName, webhookName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client WebhookClient) UpdatePreparer(resourceGroupName string, automationAccountName string, webhookName string, parameters WebhookUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "webhookName": autorest.Encode("path", webhookName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client WebhookClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client WebhookClient) UpdateResponder(resp *http.Response) (result Webhook, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} From 6c0911509955874f66e90078ee9646a85faf152d Mon Sep 17 00:00:00 2001 From: Kemyke Date: Thu, 17 Aug 2017 13:25:44 +0000 Subject: [PATCH 02/42] Add issue links --- azurerm/resource_arm_automation_schedule.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/azurerm/resource_arm_automation_schedule.go b/azurerm/resource_arm_automation_schedule.go index 2cffbb47e574..7e9603bbfdb3 100644 --- a/azurerm/resource_arm_automation_schedule.go +++ b/azurerm/resource_arm_automation_schedule.go @@ -223,8 +223,11 @@ func resourceArmAutomationScheduleCreateUpdate(d *schema.ResourceData, meta inte ardt := date.Time{Time: starttime} - //TODO Interval handling + //TODO Interval handling currently not supported via Go SDK + //Related ticket in the azure go sdk: https://github.com/Azure/azure-sdk-for-go/issues/725 + //Related ticket in the azure rest api spec: https://github.com/Azure/azure-rest-api-specs/issues/1545 //interval := + description := d.Get("description").(string) timezone := "UTC" From 523e08e6707a35fbe1cccdca3979d6acfd56285b Mon Sep 17 00:00:00 2001 From: Kemyke Date: Fri, 18 Aug 2017 07:08:33 +0000 Subject: [PATCH 03/42] Formatting --- azurerm/import_arm_automation_account_test.go | 42 +++++++++---------- azurerm/resource_arm_automation_schedule.go | 8 ++-- .../resource_arm_automation_schedule_test.go | 3 +- 3 files changed, 26 insertions(+), 27 deletions(-) diff --git a/azurerm/import_arm_automation_account_test.go b/azurerm/import_arm_automation_account_test.go index db28dafab45b..9bd49f5bef89 100644 --- a/azurerm/import_arm_automation_account_test.go +++ b/azurerm/import_arm_automation_account_test.go @@ -32,25 +32,25 @@ func TestAccAzureRMAutomationAccount_importAccoutWithFreeSku(t *testing.T) { } func TestAccAzureRMAutomationAccount_importAccoutWithBasicSku(t *testing.T) { - resourceName := "azurerm_automation_account.test" - - ri := acctest.RandInt() - config := testAccAzureRMAutomationAccount_skuBasic(ri, testLocation()) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testCheckAzureRMAutomationAccountDestroy, - Steps: []resource.TestStep{ - { - Config: config, - }, - - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) + resourceName := "azurerm_automation_account.test" + + ri := acctest.RandInt() + config := testAccAzureRMAutomationAccount_skuBasic(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAutomationAccountDestroy, + Steps: []resource.TestStep{ + { + Config: config, + }, + + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) } diff --git a/azurerm/resource_arm_automation_schedule.go b/azurerm/resource_arm_automation_schedule.go index 7e9603bbfdb3..1a481235653f 100644 --- a/azurerm/resource_arm_automation_schedule.go +++ b/azurerm/resource_arm_automation_schedule.go @@ -225,12 +225,12 @@ func resourceArmAutomationScheduleCreateUpdate(d *schema.ResourceData, meta inte //TODO Interval handling currently not supported via Go SDK //Related ticket in the azure go sdk: https://github.com/Azure/azure-sdk-for-go/issues/725 - //Related ticket in the azure rest api spec: https://github.com/Azure/azure-rest-api-specs/issues/1545 + //Related ticket in the azure rest api spec: https://github.com/Azure/azure-rest-api-specs/issues/1545 //interval := description := d.Get("description").(string) - timezone := "UTC" - + timezone := "UTC" + parameters := automation.ScheduleCreateOrUpdateParameters{ Name: &name, ScheduleCreateOrUpdateProperties: &automation.ScheduleCreateOrUpdateProperties{ @@ -238,7 +238,7 @@ func resourceArmAutomationScheduleCreateUpdate(d *schema.ResourceData, meta inte //Interval: &interval, Frequency: freq, StartTime: &ardt, - TimeZone: &timezone, + TimeZone: &timezone, }, } diff --git a/azurerm/resource_arm_automation_schedule_test.go b/azurerm/resource_arm_automation_schedule_test.go index c7de7c5f4095..20728298e73a 100644 --- a/azurerm/resource_arm_automation_schedule_test.go +++ b/azurerm/resource_arm_automation_schedule_test.go @@ -87,9 +87,8 @@ func testCheckAzureRMAutomationScheduleExistsAndFrequencyType(name string, freq return fmt.Errorf("Bad: Automation Schedule '%s' (resource group: '%s') does not exist", name, resourceGroup) } - if resp.Frequency != freq { - return fmt.Errorf("Current frequency %s is not consistent with checked value %s", resp.Frequency, freq) + return fmt.Errorf("Current frequency %s is not consistent with checked value %s", resp.Frequency, freq) } return nil } From 1c34e27c8bf74dad0855a5ee03b25ae8680e1ba5 Mon Sep 17 00:00:00 2001 From: Kemyke Date: Fri, 18 Aug 2017 08:10:48 +0000 Subject: [PATCH 04/42] Fix formatting and logging --- azurerm/resource_arm_automation_credential_test.go | 2 +- azurerm/resource_arm_automation_schedule.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/azurerm/resource_arm_automation_credential_test.go b/azurerm/resource_arm_automation_credential_test.go index 167b781dc704..075c0455ac0e 100644 --- a/azurerm/resource_arm_automation_credential_test.go +++ b/azurerm/resource_arm_automation_credential_test.go @@ -86,7 +86,7 @@ func testCheckAzureRMAutomationCredentialExistsAndUserName(name string, username } if *resp.UserName != username { - return fmt.Errorf("Current username %s is not consistant with the checked value %s", resp.UserName, username) + return fmt.Errorf("Current username %s is not consistant with the checked value %s", *resp.UserName, username) } return nil diff --git a/azurerm/resource_arm_automation_schedule.go b/azurerm/resource_arm_automation_schedule.go index 1a481235653f..0fa1ae156cbf 100644 --- a/azurerm/resource_arm_automation_schedule.go +++ b/azurerm/resource_arm_automation_schedule.go @@ -116,7 +116,7 @@ func resourceAzureRMAutomationScheduleFreqConstraint(v interface{}) int { var buf bytes.Buffer m := v.(map[string]interface{}) - buf.WriteString(fmt.Sprintf("%d-%d-%d-%d-%d-%d", m["second"], m["minute"], m["hour"], m["day_of_week"], m["day_of_month"])) + buf.WriteString(fmt.Sprintf("%d-%d-%d-%d-%d", m["second"], m["minute"], m["hour"], m["day_of_week"], m["day_of_month"])) return hashcode.String(buf.String()) } @@ -193,7 +193,7 @@ func computeValidStartTime(firstRunSet *schema.Set, freq automation.ScheduleFreq } - fmt.Errorf("Error compute first valid run time") + log.Printf("[WARN] error compute first valid run time") return closestValidStartTime } From 9bfd5357bde712cf877c976ed91b53a68b83d015 Mon Sep 17 00:00:00 2001 From: Kemyke Date: Fri, 18 Aug 2017 11:59:50 +0000 Subject: [PATCH 05/42] Add documentation --- .../docs/r/automation_account.html.markdown | 65 ++++++++++++++ .../r/automation_credential.html.markdown | 67 ++++++++++++++ .../docs/r/automation_runbook.html.markdown | 83 +++++++++++++++++ .../docs/r/automation_schedule.html.markdown | 90 +++++++++++++++++++ 4 files changed, 305 insertions(+) create mode 100644 website/docs/r/automation_account.html.markdown create mode 100644 website/docs/r/automation_credential.html.markdown create mode 100644 website/docs/r/automation_runbook.html.markdown create mode 100644 website/docs/r/automation_schedule.html.markdown diff --git a/website/docs/r/automation_account.html.markdown b/website/docs/r/automation_account.html.markdown new file mode 100644 index 000000000000..47b3e6a689ba --- /dev/null +++ b/website/docs/r/automation_account.html.markdown @@ -0,0 +1,65 @@ +--- +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_automation_account" +sidebar_current: "docs-azurerm-resource-automation-account" +description: |- + Creates a new Automation Account. +--- + +# azurerm\_automation\_account + +Creates a new Automation Account. + +## Example Usage + +``` +resource "azurerm_resource_group" "example" { + name = "resourceGroup1" + location = "West Europe" +} + +resource "azurerm_automation_account" "example" { + name = "automationAccount1" + location = "${azurerm_resource_group.example.location}" + resource_group_name = "${azurerm_resource_group.example.name}" + sku { + name = "Free" + } + tags { + environment = "development" + } + +} +``` + +## Argument Reference + +The following arguments are supported: + +* `name` - (Required) Specifies the name of the Automation Account. Changing this forces a new resource to be created. + +* `resource_group_name` - (Required) The name of the resource group in which the Automation Account is created. Changing this forces a new resource to be created. + +* `location` - (Required) Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created. + +* `sku` - (Required) he account SKU. + +* `tags` - (Optional) A mapping of tags to assign to the resource. + +`sku` supports the following: + +* `name` - (Required) The SKU name of the account: - can be either `Free` or `Basic`. + +## Attributes Reference + +The following attributes are exported: + +* `id` - The Automation Account ID. + +## Import + +Automation Accounts can be imported using the `resource id`, e.g. + +``` +terraform import azurerm_automation_account.account1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Automation/automationAccounts/account1 +``` diff --git a/website/docs/r/automation_credential.html.markdown b/website/docs/r/automation_credential.html.markdown new file mode 100644 index 000000000000..b3ff82521473 --- /dev/null +++ b/website/docs/r/automation_credential.html.markdown @@ -0,0 +1,67 @@ +--- +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_automation_credential" +sidebar_current: "docs-azurerm-resource-automation-credential" +description: |- + Creates a new Automation Credential. +--- + +# azurerm\_automation\_credential + +Creates a new Automation Credential. + +## Example Usage + +``` +resource "azurerm_resource_group" "example" { + name = "resourceGroup1" + location = "West Europe" +} + +resource "azurerm_automation_account" "example" { + name = "account1" + location = "${azurerm_resource_group.example.location}" + resource_group_name = "${azurerm_resource_group.example.name}" + sku { + name = "Free" + } +} + +resource "azurerm_automation_credential" "example" { + name = "credential1" + resource_group_name = "${azurerm_resource_group.example.name}" + account_name = "${azurerm_automation_account.example.name}" + user_name = "example_user" + password = "example_pwd" + description = "This is an example credential" +``` + +## Argument Reference + +The following arguments are supported: + +* `name` - (Required) Specifies the name of the Credential. Changing this forces a new resource to be created. + +* `resource_group_name` - (Required) The name of the resource group in which the Credential is created. Changing this forces a new resource to be created. + +* `account_name` - (Required) The name of the automation account in which the Credential is created. Changing this forces a new resource to be created. + +* `user_name` - (Required) The user name of the Credential. + +* `password` - (Required) The password of the Credential. + +* `description` - (Optional) A description for this Credential. + +## Attributes Reference + +The following attributes are exported: + +* `id` - The Automation Credential ID. + +## Import + +Automation Credentials can be imported using the `resource id`, e.g. + +``` +terraform import azurerm_automation_credential.credential1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Automation/automationAccounts/account1/credentials/credential1 +``` diff --git a/website/docs/r/automation_runbook.html.markdown b/website/docs/r/automation_runbook.html.markdown new file mode 100644 index 000000000000..a991daa7664c --- /dev/null +++ b/website/docs/r/automation_runbook.html.markdown @@ -0,0 +1,83 @@ +--- +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_automation_runbook" +sidebar_current: "docs-azurerm-resource-automation-runbook" +description: |- + Creates a new Automation Runbook. +--- + +# azurerm\_automation\_runbook + +Creates a new Automation Runbook. + +## Example Usage + +``` +resource "azurerm_resource_group" "example" { + name = "resourceGroup1" + location = "West Europe" +} + +resource "azurerm_automation_account" "example" { + name = "account1" + location = "${azurerm_resource_group.example.location}" + resource_group_name = "${azurerm_resource_group.example.name}" + sku { + name = "Free" + } +} + +resource "azurerm_automation_runbook" "example" { + name = "Get-AzureVMTutorial" + location = "${azurerm_resource_group.example.location}" + resource_group_name = "${azurerm_resource_group.exmaple.name}" + account_name = "${azurerm_automation_account.example.name}" + log_verbose = "true" + log_progress = "true" + description = "This is an example runbook" + runbook_type = "PowerShellWorkflow" + publish_content_link { + uri = "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-automation-runbook-getvms/Runbooks/Get-AzureVMTutorial.ps1" + } +} +``` + +## Argument Reference + +The following arguments are supported: + +* `name` - (Required) Specifies the name of the Runbook. Changing this forces a new resource to be created. + +* `resource_group_name` - (Required) The name of the resource group in which the Runbook is created. Changing this forces a new resource to be created. + +* `location` - (Required) Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created. + +* `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`. + +* `log_progress` - (Required) Progress log option. + +* `log_verbose` - (Required) Verbose log option. + +* `publish_content_link` - (Required) The published runbook content link. + +* `description` - (Optional) A description for this credential. + +`publish_content_link` supports the following: + +* `uri` - (Required) The uri of the runbook content. + +## Attributes Reference + +The following attributes are exported: + +* `id` - The Automation Runbook ID. + +## Import + +Automation Runbooks can be imported using the `resource id`, e.g. + +``` +terraform import azurerm_automation_runbook.Get-AzureVMTutorial /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Automation/automationAccounts/account1/runbooks/Get-AzureVMTutorial +``` diff --git a/website/docs/r/automation_schedule.html.markdown b/website/docs/r/automation_schedule.html.markdown new file mode 100644 index 000000000000..7ba20e669b03 --- /dev/null +++ b/website/docs/r/automation_schedule.html.markdown @@ -0,0 +1,90 @@ +--- +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_automation_schedule" +sidebar_current: "docs-azurerm-resource-automation-schedule" +description: |- + Creates a new Automation Schedule. +--- + +# azurerm\_automation\_schedule + +Creates a new Automation Schedule. + +## Example Usage + +``` +resource "azurerm_resource_group" "example" { + name = "resourceGroup1" + location = "West Europe" +} + +resource "azurerm_automation_account" "example" { + name = "account1" + location = "${azurerm_resource_group.example.location}" + resource_group_name = "${azurerm_resource_group.example.name}" + sku { + name = "Free" + } +} + +resource "azurerm_automation_schedule" "example" { + name = "schedule1" + resource_group_name = "${azurerm_resource_group.example.name}" + account_name = "${azurerm_automation_account.example.name}" + frequency = "OneTime" + first_run { + "hour" = 20 + "minute" = 5 + "second" = 0 + } + description = "This is an example schedule" +} +``` + +## Argument Reference + +The following arguments are supported: + +* `name` - (Required) Specifies the name of the Schedule. Changing this forces a new resource to be created. + +* `resource_group_name` - (Required) The name of the resource group in which the Schedule is created. Changing this forces a new resource to be created. + +* `account_name` - (Required) The name of the automation account in which the Schedule is created. Changing this forces a new resource to be created. + +* `description` - (Optional) A description for this Schedule. + +* `start_time` - (Optional) Start time of the schedule. Must be at least five minutes in the future. + +* `expiry_time` - (Optional) The end time of the schedule. + +* `interval` - (Optional) The interval of the schedule. Must be set if the schedule is recurring. NOT YET SUPPORTED due to lack of SDK support. + +* `frequency` - (Required) The frequency of the schedule. - can be either `OneTime`, `Day`, `Hour`, `Week`, or `Month`. + +* `first_run` - (Optional) If an exact start time is not suitable, it can be used to make constraints for the first run. The start time will be calculated depending on these constraints. `start_time` will override this settings if defined. + +`first_run` supports the following: + +* `second` - (Optional) In which second should the schedule first triggered. + +* `minute` - (Optional) In which minute should the schedule first triggered. + +* `hour` - (Optional) In which hour should the schedule first triggered. Ignored if the frequency is `Hour`. + +* `day_of_week` - (Optional) On which day of the week should the schedule first triggered. Ignored if the frequency is `OneTime`, `Hour` or `Day`. (0 - Sunday) + +* `day_of_month` - (Optional) On which day of the month should the schedule first triggered. Ignored if the frequency is `Hour`, `Day` or `Week`. + +## Attributes Reference + +The following attributes are exported: + +* `id` - The Automation Schedule ID. + +## Import + +Automation Schedule can be imported using the `resource id`, e.g. + +``` +terraform import azurerm_automation_schedule.schedule1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Automation/automationAccounts/account1/schedules/schedule1 +``` From 3b04f5467086a326324604f4bf6f932cf630f38a Mon Sep 17 00:00:00 2001 From: "NEXOGEN\\kemenya" Date: Thu, 31 Aug 2017 09:59:49 +0200 Subject: [PATCH 06/42] Fix auto-merge --- azurerm/provider.go | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/azurerm/provider.go b/azurerm/provider.go index 9fd47714fe85..ac314341eff3 100644 --- a/azurerm/provider.go +++ b/azurerm/provider.go @@ -67,34 +67,12 @@ func Provider() terraform.ResourceProvider { }, ResourcesMap: map[string]*schema.Resource{ - - // These resources use the Azure ARM SDK - "azurerm_application_insights": resourceArmApplicationInsights(), - - "azurerm_automation_account": resourceArmAutomationAccount(), - "azurerm_automation_runbook": resourceArmAutomationRunbook(), - "azurerm_automation_credential": resourceArmAutomationCredential(), - "azurerm_automation_schedule": resourceArmAutomationSchedule(), - - "azurerm_availability_set": resourceArmAvailabilitySet(), - "azurerm_cdn_endpoint": resourceArmCdnEndpoint(), - "azurerm_cdn_profile": resourceArmCdnProfile(), - "azurerm_container_registry": resourceArmContainerRegistry(), - "azurerm_container_service": resourceArmContainerService(), - "azurerm_cosmosdb_account": resourceArmCosmosDBAccount(), - - "azurerm_dns_a_record": resourceArmDnsARecord(), - "azurerm_dns_aaaa_record": resourceArmDnsAAAARecord(), - "azurerm_dns_cname_record": resourceArmDnsCNameRecord(), - "azurerm_dns_mx_record": resourceArmDnsMxRecord(), - "azurerm_dns_ns_record": resourceArmDnsNsRecord(), - "azurerm_dns_ptr_record": resourceArmDnsPtrRecord(), - "azurerm_dns_srv_record": resourceArmDnsSrvRecord(), - "azurerm_dns_txt_record": resourceArmDnsTxtRecord(), - "azurerm_dns_zone": resourceArmDnsZone(), - "azurerm_application_insights": resourceArmApplicationInsights(), "azurerm_app_service_plan": resourceArmAppServicePlan(), + "azurerm_automation_account": resourceArmAutomationAccount(), + "azurerm_automation_runbook": resourceArmAutomationRunbook(), + "azurerm_automation_credential": resourceArmAutomationCredential(), + "azurerm_automation_schedule": resourceArmAutomationSchedule(), "azurerm_availability_set": resourceArmAvailabilitySet(), "azurerm_cdn_endpoint": resourceArmCdnEndpoint(), "azurerm_cdn_profile": resourceArmCdnProfile(), From 90020607bc2a6e25b87f59527f654f1742987c58 Mon Sep 17 00:00:00 2001 From: "NEXOGEN\\kemenya" Date: Thu, 31 Aug 2017 11:01:31 +0200 Subject: [PATCH 07/42] Use new utils library --- azurerm/resource_arm_automation_account.go | 3 ++- azurerm/resource_arm_automation_credential.go | 3 ++- azurerm/resource_arm_automation_runbook.go | 3 ++- azurerm/resource_arm_automation_schedule.go | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/azurerm/resource_arm_automation_account.go b/azurerm/resource_arm_automation_account.go index c20a2d14efc4..562697a8bc50 100644 --- a/azurerm/resource_arm_automation_account.go +++ b/azurerm/resource_arm_automation_account.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/terraform/helper/hashcode" "github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/helper/validation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) func resourceArmAutomationAccount() *schema.Resource { @@ -124,7 +125,7 @@ func resourceArmAutomationAccountRead(d *schema.ResourceData, meta interface{}) resp, err := client.Get(resGroup, name) if err != nil { - if responseWasNotFound(resp.Response) { + if utils.responseWasNotFound(resp.Response) { d.SetId("") return nil } diff --git a/azurerm/resource_arm_automation_credential.go b/azurerm/resource_arm_automation_credential.go index 1e7f7f4f4472..4a487487765f 100644 --- a/azurerm/resource_arm_automation_credential.go +++ b/azurerm/resource_arm_automation_credential.go @@ -7,6 +7,7 @@ import ( "github.com/Azure/azure-sdk-for-go/arm/automation" "github.com/hashicorp/terraform/helper/schema" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) func resourceArmAutomationCredential() *schema.Resource { @@ -106,7 +107,7 @@ func resourceArmAutomationCredentialRead(d *schema.ResourceData, meta interface{ resp, err := client.Get(resGroup, accName, name) if err != nil { - if responseWasNotFound(resp.Response) { + if utils.ResponseWasNotFound(resp.Response) { d.SetId("") return nil } diff --git a/azurerm/resource_arm_automation_runbook.go b/azurerm/resource_arm_automation_runbook.go index a32568a4166a..70a1f0ce7ade 100644 --- a/azurerm/resource_arm_automation_runbook.go +++ b/azurerm/resource_arm_automation_runbook.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/terraform/helper/hashcode" "github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/helper/validation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) func resourceArmAutomationRunbook() *schema.Resource { @@ -167,7 +168,7 @@ func resourceArmAutomationRunbookRead(d *schema.ResourceData, meta interface{}) resp, err := client.Get(resGroup, accName, name) if err != nil { - if responseWasNotFound(resp.Response) { + if utils.ResponseWasNotFound(resp.Response) { d.SetId("") return nil } diff --git a/azurerm/resource_arm_automation_schedule.go b/azurerm/resource_arm_automation_schedule.go index 0fa1ae156cbf..5d0dc8d91c54 100644 --- a/azurerm/resource_arm_automation_schedule.go +++ b/azurerm/resource_arm_automation_schedule.go @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/terraform/helper/hashcode" "github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/helper/validation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) func resourceArmAutomationSchedule() *schema.Resource { @@ -273,7 +274,7 @@ func resourceArmAutomationScheduleRead(d *schema.ResourceData, meta interface{}) resp, err := client.Get(resGroup, accName, name) if err != nil { - if responseWasNotFound(resp.Response) { + if utils.ResponseWasNotFound(resp.Response) { d.SetId("") return nil } From 50fa59711c315ab2cf26b30d8b6f3c4ec644f210 Mon Sep 17 00:00:00 2001 From: "NEXOGEN\\kemenya" Date: Thu, 31 Aug 2017 12:01:05 +0200 Subject: [PATCH 08/42] Fix method name --- azurerm/resource_arm_automation_account.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azurerm/resource_arm_automation_account.go b/azurerm/resource_arm_automation_account.go index 562697a8bc50..e5a77b064e8b 100644 --- a/azurerm/resource_arm_automation_account.go +++ b/azurerm/resource_arm_automation_account.go @@ -125,7 +125,7 @@ func resourceArmAutomationAccountRead(d *schema.ResourceData, meta interface{}) resp, err := client.Get(resGroup, name) if err != nil { - if utils.responseWasNotFound(resp.Response) { + if utils.ResponseWasNotFound(resp.Response) { d.SetId("") return nil } From b220c77ebb08433ff2622a16771c2ebbbd3db824 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 31 Aug 2017 11:47:05 +0000 Subject: [PATCH 09/42] Minor fixes based on the review --- azurerm/import_arm_automation_account_test.go | 4 ++-- azurerm/resource_arm_automation_account.go | 12 +++------- .../resource_arm_automation_account_test.go | 23 ++++++++++--------- azurerm/resource_arm_automation_credential.go | 17 +++++++------- ...resource_arm_automation_credential_test.go | 23 +++++++++++-------- azurerm/resource_arm_automation_runbook.go | 13 +++-------- .../resource_arm_automation_runbook_test.go | 21 +++++++++-------- azurerm/resource_arm_automation_schedule.go | 3 +-- .../resource_arm_automation_schedule_test.go | 22 ++++++++++-------- .../docs/r/automation_account.html.markdown | 2 +- .../r/automation_credential.html.markdown | 8 +++---- .../docs/r/automation_runbook.html.markdown | 2 +- 12 files changed, 71 insertions(+), 79 deletions(-) diff --git a/azurerm/import_arm_automation_account_test.go b/azurerm/import_arm_automation_account_test.go index 9bd49f5bef89..07e93fab8d88 100644 --- a/azurerm/import_arm_automation_account_test.go +++ b/azurerm/import_arm_automation_account_test.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform/helper/resource" ) -func TestAccAzureRMAutomationAccount_importAccoutWithFreeSku(t *testing.T) { +func TestAccAzureRMAutomationAccount_importAccountWithFreeSku(t *testing.T) { resourceName := "azurerm_automation_account.test" ri := acctest.RandInt() @@ -31,7 +31,7 @@ func TestAccAzureRMAutomationAccount_importAccoutWithFreeSku(t *testing.T) { }) } -func TestAccAzureRMAutomationAccount_importAccoutWithBasicSku(t *testing.T) { +func TestAccAzureRMAutomationAccount_importAccountWithBasicSku(t *testing.T) { resourceName := "azurerm_automation_account.test" ri := acctest.RandInt() diff --git a/azurerm/resource_arm_automation_account.go b/azurerm/resource_arm_automation_account.go index e5a77b064e8b..d2ebe2799403 100644 --- a/azurerm/resource_arm_automation_account.go +++ b/azurerm/resource_arm_automation_account.go @@ -3,7 +3,6 @@ package azurerm import ( "fmt" "log" - "net/http" "github.com/Azure/azure-sdk-for-go/arm/automation" "github.com/hashicorp/terraform/helper/hashcode" @@ -29,12 +28,7 @@ func resourceArmAutomationAccount() *schema.Resource { ForceNew: true, }, - "location": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - StateFunc: azureRMNormalizeLocation, - }, + "location": locationSchema(), "resource_group_name": { Type: schema.TypeString, @@ -130,7 +124,7 @@ func resourceArmAutomationAccountRead(d *schema.ResourceData, meta interface{}) return nil } - return fmt.Errorf("Error making Read request on AzureRM Automation Account '%s': %s", name, err) + return fmt.Errorf("Error making Read request on AzureRM Automation Account '%s': %+v", name, err) } d.Set("name", resp.Name) @@ -156,7 +150,7 @@ func resourceArmAutomationAccountDelete(d *schema.ResourceData, meta interface{} resp, err := client.Delete(resGroup, name) if err != nil { - if resp.StatusCode == http.StatusNotFound { + if utils.ResponseWasNotFound(resp) { return nil } diff --git a/azurerm/resource_arm_automation_account_test.go b/azurerm/resource_arm_automation_account_test.go index 9d4dfd71160f..3161a82058d1 100644 --- a/azurerm/resource_arm_automation_account_test.go +++ b/azurerm/resource_arm_automation_account_test.go @@ -2,14 +2,13 @@ package azurerm import ( "fmt" - "net/http" "testing" "github.com/hashicorp/terraform/helper/acctest" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" - "github.com/Azure/azure-sdk-for-go/arm/automation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) func TestAccAzureRMAutomationAccount_skuBasic(t *testing.T) { @@ -64,12 +63,14 @@ func testCheckAzureRMAutomationAccountDestroy(s *terraform.State) error { resp, err := conn.Get(resourceGroup, name) if err != nil { - return nil - } + if utils.ResponseWasNotFound(resp.Response) { + return nil + } - if resp.StatusCode != http.StatusNotFound { - return fmt.Errorf("Automation Account still exists:\n%#v", resp) + return err } + + return fmt.Errorf("Automation Account still exists:\n%#v", resp) } return nil @@ -95,15 +96,15 @@ func testCheckAzureRMAutomationAccountExistsAndSku(name string, sku automation.S resp, err := conn.Get(resourceGroup, name) if err != nil { - return fmt.Errorf("Bad: Get on automationClient: %s", err) - } + if utils.ResponseWasNotFound(resp.Response) { + return fmt.Errorf("Automation Account '%s' (resource group: '%s') was not found: %+v", name, resourceGroup, err) + } - if resp.StatusCode == http.StatusNotFound { - return fmt.Errorf("Bad: Automation Account '%s' (resource group: '%s') does not exist", name, resourceGroup) + return fmt.Errorf("Bad: Get on automationClient: %s", err) } if resp.Sku.Name != sku { - return fmt.Errorf("Actual sku %s is not consistent with the checked value %s", resp.Sku.Name, sku) + return fmt.Errorf("Actual sku %s is not consistent with the expected value %q", resp.Sku.Name, sku) } return nil diff --git a/azurerm/resource_arm_automation_credential.go b/azurerm/resource_arm_automation_credential.go index 4a487487765f..fe0489f5369c 100644 --- a/azurerm/resource_arm_automation_credential.go +++ b/azurerm/resource_arm_automation_credential.go @@ -3,7 +3,6 @@ package azurerm import ( "fmt" "log" - "net/http" "github.com/Azure/azure-sdk-for-go/arm/automation" "github.com/hashicorp/terraform/helper/schema" @@ -37,14 +36,15 @@ func resourceArmAutomationCredential() *schema.Resource { ForceNew: true, }, - "user_name": { + "username": { Type: schema.TypeString, Required: true, }, "password": { - Type: schema.TypeString, - Required: true, + Type: schema.TypeString, + Required: true, + Sensitive: true, }, "description": { Type: schema.TypeString, @@ -61,7 +61,7 @@ func resourceArmAutomationCredentialCreateUpdate(d *schema.ResourceData, meta in name := d.Get("name").(string) resGroup := d.Get("resource_group_name").(string) accName := d.Get("account_name").(string) - user := d.Get("user_name").(string) + user := d.Get("username").(string) password := d.Get("password").(string) description := d.Get("description").(string) @@ -71,7 +71,6 @@ func resourceArmAutomationCredentialCreateUpdate(d *schema.ResourceData, meta in Password: &password, Description: &description, }, - Name: &name, } @@ -112,13 +111,13 @@ func resourceArmAutomationCredentialRead(d *schema.ResourceData, meta interface{ return nil } - return fmt.Errorf("Error making Read request on AzureRM Automation Credential '%s': %s", name, err) + return fmt.Errorf("Error making Read request on AzureRM Automation Credential '%s': %+v", name, err) } d.Set("name", resp.Name) d.Set("resource_group_name", resGroup) d.Set("account_name", accName) - d.Set("user_name", resp.UserName) + d.Set("username", resp.UserName) d.Set("password", nil) d.Set("description", resp.Description) @@ -139,7 +138,7 @@ func resourceArmAutomationCredentialDelete(d *schema.ResourceData, meta interfac resp, err := client.Delete(resGroup, accName, name) if err != nil { - if resp.StatusCode == http.StatusNotFound { + if utils.ResponseWasNotFound(resp) { return nil } diff --git a/azurerm/resource_arm_automation_credential_test.go b/azurerm/resource_arm_automation_credential_test.go index 075c0455ac0e..82f4da4d58b3 100644 --- a/azurerm/resource_arm_automation_credential_test.go +++ b/azurerm/resource_arm_automation_credential_test.go @@ -2,12 +2,12 @@ package azurerm import ( "fmt" - "net/http" "testing" "github.com/hashicorp/terraform/helper/acctest" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) func TestAccAzureRMAutomationCredential_testCredential(t *testing.T) { @@ -45,12 +45,15 @@ func testCheckAzureRMAutomationCredentialDestroy(s *terraform.State) error { resp, err := conn.Get(resourceGroup, accName, name) if err != nil { - return nil - } + if utils.ResponseWasNotFound(resp.Response) { + return nil + } - if resp.StatusCode != http.StatusNotFound { - return fmt.Errorf("Automation Credential still exists:\n%#v", resp) + return err } + + return fmt.Errorf("EventGrid Topic still exists:\n%#v", resp) + } return nil @@ -78,11 +81,11 @@ func testCheckAzureRMAutomationCredentialExistsAndUserName(name string, username resp, err := conn.Get(resourceGroup, accName, name) if err != nil { - return fmt.Errorf("Bad: Get on automationCredentialClient: %s\nName: %s, Account name: %s, Resource group: %s OBJECT: %+v", err, name, accName, resourceGroup, rs.Primary) - } + if utils.ResponseWasNotFound(resp.Response) { + return fmt.Errorf("Automation Credential '%s' (resource group: '%s') does not exist", name, resourceGroup) + } - if resp.StatusCode == http.StatusNotFound { - return fmt.Errorf("Bad: Automation Credential '%s' (resource group: '%s') does not exist", name, resourceGroup) + return fmt.Errorf("Bad: Get on automationCredentialClient: %s\nName: %s, Account name: %s, Resource group: %s OBJECT: %+v", err, name, accName, resourceGroup, rs.Primary) } if *resp.UserName != username { @@ -113,7 +116,7 @@ resource "azurerm_automation_credential" "test" { name = "acctest-%d" resource_group_name = "${azurerm_resource_group.test.name}" account_name = "${azurerm_automation_account.test.name}" - user_name = "test_user" + username = "test_user" password = "test_pwd" description = "This is a test credential for terraform acceptance test" } diff --git a/azurerm/resource_arm_automation_runbook.go b/azurerm/resource_arm_automation_runbook.go index 70a1f0ce7ade..e168ef13fcd6 100644 --- a/azurerm/resource_arm_automation_runbook.go +++ b/azurerm/resource_arm_automation_runbook.go @@ -3,7 +3,6 @@ package azurerm import ( "fmt" "log" - "net/http" "github.com/Azure/azure-sdk-for-go/arm/automation" "github.com/hashicorp/terraform/helper/hashcode" @@ -35,12 +34,7 @@ func resourceArmAutomationRunbook() *schema.Resource { ForceNew: true, }, - "location": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - StateFunc: azureRMNormalizeLocation, - }, + "location": locationSchema(), "resource_group_name": { Type: schema.TypeString, @@ -132,7 +126,6 @@ func resourceArmAutomationRunbookCreateUpdate(d *schema.ResourceData, meta inter PublishContentLink: &contentLink, }, - Name: &name, Location: &location, Tags: expandTags(tags), } @@ -173,7 +166,7 @@ func resourceArmAutomationRunbookRead(d *schema.ResourceData, meta interface{}) return nil } - return fmt.Errorf("Error making Read request on AzureRM Automation Runbook '%s': %s", name, err) + return fmt.Errorf("Error making Read request on AzureRM Automation Runbook '%s': %+v", name, err) } d.Set("name", resp.Name) @@ -206,7 +199,7 @@ func resourceArmAutomationRunbookDelete(d *schema.ResourceData, meta interface{} resp, err := client.Delete(resGroup, accName, name) if err != nil { - if resp.StatusCode == http.StatusNotFound { + if utils.ResponseWasNotFound(resp) { return nil } diff --git a/azurerm/resource_arm_automation_runbook_test.go b/azurerm/resource_arm_automation_runbook_test.go index 00290609d91e..f3339699cc97 100644 --- a/azurerm/resource_arm_automation_runbook_test.go +++ b/azurerm/resource_arm_automation_runbook_test.go @@ -2,14 +2,13 @@ package azurerm import ( "fmt" - "net/http" "testing" "github.com/hashicorp/terraform/helper/acctest" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" - "github.com/Azure/azure-sdk-for-go/arm/automation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) func TestAccAzureRMAutomationRunbook_PSWorkflow(t *testing.T) { @@ -47,12 +46,14 @@ func testCheckAzureRMAutomationRunbookDestroy(s *terraform.State) error { resp, err := conn.Get(resourceGroup, accName, name) if err != nil { - return nil - } + if utils.ResponseWasNotFound(resp.Response) { + return nil + } - if resp.StatusCode != http.StatusNotFound { - return fmt.Errorf("Automation Runbook still exists:\n%#v", resp) + return err } + + return fmt.Errorf("Automation Runbook still exists:\n%#v", resp) } return nil @@ -80,11 +81,11 @@ func testCheckAzureRMAutomationRunbookExistsAndType(name string, runbookType aut resp, err := conn.Get(resourceGroup, accName, name) if err != nil { - return fmt.Errorf("Bad: Get on automationRunbookClient: %s", err) - } + if utils.ResponseWasNotFound(resp.Response) { + return fmt.Errorf("Automation Runbook '%s' (resource group: '%s') does not exist", name, resourceGroup) + } - if resp.StatusCode == http.StatusNotFound { - return fmt.Errorf("Bad: Automation Runbook '%s' (resource group: '%s') does not exist", name, resourceGroup) + return fmt.Errorf("Bad: Get on automationRunbookClient: %s", err) } if resp.RunbookType != runbookType { diff --git a/azurerm/resource_arm_automation_schedule.go b/azurerm/resource_arm_automation_schedule.go index 5d0dc8d91c54..f81d2743224f 100644 --- a/azurerm/resource_arm_automation_schedule.go +++ b/azurerm/resource_arm_automation_schedule.go @@ -4,7 +4,6 @@ import ( "bytes" "fmt" "log" - "net/http" "time" "github.com/Azure/azure-sdk-for-go/arm/automation" @@ -307,7 +306,7 @@ func resourceArmAutomationScheduleDelete(d *schema.ResourceData, meta interface{ resp, err := client.Delete(resGroup, accName, name) if err != nil { - if resp.StatusCode == http.StatusNotFound { + if utils.ResponseWasNotFound(resp) { return nil } diff --git a/azurerm/resource_arm_automation_schedule_test.go b/azurerm/resource_arm_automation_schedule_test.go index 20728298e73a..3b47ec07a885 100644 --- a/azurerm/resource_arm_automation_schedule_test.go +++ b/azurerm/resource_arm_automation_schedule_test.go @@ -2,14 +2,13 @@ package azurerm import ( "fmt" - "net/http" "testing" "github.com/hashicorp/terraform/helper/acctest" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" - "github.com/Azure/azure-sdk-for-go/arm/automation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) func TestAccAzureRMAutomationSchedule_oneTime(t *testing.T) { @@ -47,12 +46,14 @@ func testCheckAzureRMAutomationScheduleDestroy(s *terraform.State) error { resp, err := conn.Get(resourceGroup, accName, name) if err != nil { - return nil - } + if utils.ResponseWasNotFound(resp.Response) { + return nil + } - if resp.StatusCode != http.StatusNotFound { - return fmt.Errorf("Automation Schedule still exists:\n%#v", resp) + return err } + + return fmt.Errorf("Automation Schedule still exists:\n%#v", resp) } return nil @@ -80,13 +81,14 @@ func testCheckAzureRMAutomationScheduleExistsAndFrequencyType(name string, freq resp, err := conn.Get(resourceGroup, accName, name) if err != nil { - return fmt.Errorf("Bad: Get on automationScheduleClient: %s", err) - } + if utils.ResponseWasNotFound(resp.Response) { + return fmt.Errorf("Automation Schedule '%s' (resource group: '%s') does not exist", name, resourceGroup) + } - if resp.StatusCode == http.StatusNotFound { - return fmt.Errorf("Bad: Automation Schedule '%s' (resource group: '%s') does not exist", name, resourceGroup) + return fmt.Errorf("Bad: Get on automationScheduleClient: %+v", err) } + if resp.Frequency != freq { return fmt.Errorf("Current frequency %s is not consistent with checked value %s", resp.Frequency, freq) } diff --git a/website/docs/r/automation_account.html.markdown b/website/docs/r/automation_account.html.markdown index 47b3e6a689ba..96e71fa81b92 100644 --- a/website/docs/r/automation_account.html.markdown +++ b/website/docs/r/automation_account.html.markdown @@ -42,7 +42,7 @@ The following arguments are supported: * `location` - (Required) Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created. -* `sku` - (Required) he account SKU. +* `sku` - (Required) A `sku` block as defined below. * `tags` - (Optional) A mapping of tags to assign to the resource. diff --git a/website/docs/r/automation_credential.html.markdown b/website/docs/r/automation_credential.html.markdown index b3ff82521473..372179c4cba7 100644 --- a/website/docs/r/automation_credential.html.markdown +++ b/website/docs/r/automation_credential.html.markdown @@ -31,7 +31,7 @@ resource "azurerm_automation_credential" "example" { name = "credential1" resource_group_name = "${azurerm_resource_group.example.name}" account_name = "${azurerm_automation_account.example.name}" - user_name = "example_user" + username = "example_user" password = "example_pwd" description = "This is an example credential" ``` @@ -46,11 +46,11 @@ The following arguments are supported: * `account_name` - (Required) The name of the automation account in which the Credential is created. Changing this forces a new resource to be created. -* `user_name` - (Required) The user name of the Credential. +* `username` - (Required) The username associated with this Automation Credential. -* `password` - (Required) The password of the Credential. +* `password` - (Required) The password associated with this Automation Credential. -* `description` - (Optional) A description for this Credential. +* `description` - (Optional) The description associated with this Automation Credential. ## Attributes Reference diff --git a/website/docs/r/automation_runbook.html.markdown b/website/docs/r/automation_runbook.html.markdown index a991daa7664c..8318d7fb5965 100644 --- a/website/docs/r/automation_runbook.html.markdown +++ b/website/docs/r/automation_runbook.html.markdown @@ -54,7 +54,7 @@ The following arguments are supported: * `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` or `Script`. * `log_progress` - (Required) Progress log option. From 72d53c62251e592f5011c20e96490d67fa2b4fcb Mon Sep 17 00:00:00 2001 From: root Date: Thu, 31 Aug 2017 11:56:46 +0000 Subject: [PATCH 10/42] Fix formatting --- azurerm/resource_arm_automation_account_test.go | 2 +- azurerm/resource_arm_automation_runbook_test.go | 2 +- azurerm/resource_arm_automation_schedule_test.go | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/azurerm/resource_arm_automation_account_test.go b/azurerm/resource_arm_automation_account_test.go index 3161a82058d1..7d919032f552 100644 --- a/azurerm/resource_arm_automation_account_test.go +++ b/azurerm/resource_arm_automation_account_test.go @@ -4,10 +4,10 @@ import ( "fmt" "testing" + "github.com/Azure/azure-sdk-for-go/arm/automation" "github.com/hashicorp/terraform/helper/acctest" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" - "github.com/Azure/azure-sdk-for-go/arm/automation" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) diff --git a/azurerm/resource_arm_automation_runbook_test.go b/azurerm/resource_arm_automation_runbook_test.go index f3339699cc97..4e125a542496 100644 --- a/azurerm/resource_arm_automation_runbook_test.go +++ b/azurerm/resource_arm_automation_runbook_test.go @@ -4,10 +4,10 @@ import ( "fmt" "testing" + "github.com/Azure/azure-sdk-for-go/arm/automation" "github.com/hashicorp/terraform/helper/acctest" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" - "github.com/Azure/azure-sdk-for-go/arm/automation" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) diff --git a/azurerm/resource_arm_automation_schedule_test.go b/azurerm/resource_arm_automation_schedule_test.go index 3b47ec07a885..07675e1fd13f 100644 --- a/azurerm/resource_arm_automation_schedule_test.go +++ b/azurerm/resource_arm_automation_schedule_test.go @@ -4,10 +4,10 @@ import ( "fmt" "testing" + "github.com/Azure/azure-sdk-for-go/arm/automation" "github.com/hashicorp/terraform/helper/acctest" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" - "github.com/Azure/azure-sdk-for-go/arm/automation" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) @@ -88,7 +88,6 @@ func testCheckAzureRMAutomationScheduleExistsAndFrequencyType(name string, freq return fmt.Errorf("Bad: Get on automationScheduleClient: %+v", err) } - if resp.Frequency != freq { return fmt.Errorf("Current frequency %s is not consistent with checked value %s", resp.Frequency, freq) } From a4d9c3841698aba36c6f5141f33e10ad95803a1e Mon Sep 17 00:00:00 2001 From: root Date: Fri, 1 Sep 2017 08:37:51 +0000 Subject: [PATCH 11/42] Refactor sku as List Remove name AccountCreateOrUpdateProperties --- azurerm/resource_arm_automation_account.go | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/azurerm/resource_arm_automation_account.go b/azurerm/resource_arm_automation_account.go index d2ebe2799403..9d7e8c713b88 100644 --- a/azurerm/resource_arm_automation_account.go +++ b/azurerm/resource_arm_automation_account.go @@ -5,7 +5,6 @@ import ( "log" "github.com/Azure/azure-sdk-for-go/arm/automation" - "github.com/hashicorp/terraform/helper/hashcode" "github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/helper/validation" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" @@ -37,7 +36,7 @@ func resourceArmAutomationAccount() *schema.Resource { }, "sku": { - Type: schema.TypeSet, + Type: schema.TypeList, Required: true, MaxItems: 1, Elem: &schema.Resource{ @@ -53,21 +52,12 @@ func resourceArmAutomationAccount() *schema.Resource { }, }, }, - Set: resourceAzureRMAutomationAccountSkuHash, }, "tags": tagsSchema(), }, } } -func resourceAzureRMAutomationAccountSkuHash(v interface{}) int { - m := v.(map[string]interface{}) - - name := m["name"].(string) - - return hashcode.String(name) -} - func resourceArmAutomationAccountCreateUpdate(d *schema.ResourceData, meta interface{}) error { client := meta.(*ArmClient).automationAccountClient log.Printf("[INFO] preparing arguments for AzureRM Automation Account creation.") @@ -84,7 +74,6 @@ func resourceArmAutomationAccountCreateUpdate(d *schema.ResourceData, meta inter Sku: &sku, }, - Name: &name, Location: &location, Tags: expandTags(tags), } @@ -161,19 +150,17 @@ func resourceArmAutomationAccountDelete(d *schema.ResourceData, meta interface{} } func flattenAndSetSku(d *schema.ResourceData, sku *automation.Sku) { - results := schema.Set{ - F: resourceAzureRMAutomationAccountSkuHash, - } + results := make([]interface{}, 1) result := map[string]interface{}{} result["name"] = string(sku.Name) - results.Add(result) + results[0] = result d.Set("sku", &results) } func expandSku(d *schema.ResourceData) automation.Sku { - inputs := d.Get("sku").(*schema.Set).List() + inputs := d.Get("sku").([]interface{}) input := inputs[0].(map[string]interface{}) name := automation.SkuNameEnum(input["name"].(string)) From 4d62cd926e277c9a536d00e15a9c061136983ed6 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 1 Sep 2017 08:47:13 +0000 Subject: [PATCH 12/42] Get UserName from CredentialProperties instead of top level property --- azurerm/resource_arm_automation_credential.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/azurerm/resource_arm_automation_credential.go b/azurerm/resource_arm_automation_credential.go index fe0489f5369c..4221bce01d0d 100644 --- a/azurerm/resource_arm_automation_credential.go +++ b/azurerm/resource_arm_automation_credential.go @@ -117,7 +117,9 @@ func resourceArmAutomationCredentialRead(d *schema.ResourceData, meta interface{ d.Set("name", resp.Name) d.Set("resource_group_name", resGroup) d.Set("account_name", accName) - d.Set("username", resp.UserName) + if props := resp.CredentialProperties; props != nil { + d.Set("username", props.UserName) + } d.Set("password", nil) d.Set("description", resp.Description) From cb9e4d96e718755c084f9c8b935e0200f6a13a31 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 1 Sep 2017 09:49:35 +0000 Subject: [PATCH 13/42] Extend content_link schema with hash and version --- azurerm/resource_arm_automation_credential.go | 2 +- azurerm/resource_arm_automation_runbook.go | 65 ++++++++++++++----- .../resource_arm_automation_runbook_test.go | 58 +++++++++++++++++ 3 files changed, 109 insertions(+), 16 deletions(-) diff --git a/azurerm/resource_arm_automation_credential.go b/azurerm/resource_arm_automation_credential.go index 4221bce01d0d..c1a0c53b82a9 100644 --- a/azurerm/resource_arm_automation_credential.go +++ b/azurerm/resource_arm_automation_credential.go @@ -118,7 +118,7 @@ func resourceArmAutomationCredentialRead(d *schema.ResourceData, meta interface{ d.Set("resource_group_name", resGroup) d.Set("account_name", accName) if props := resp.CredentialProperties; props != nil { - d.Set("username", props.UserName) + d.Set("username", props.UserName) } d.Set("password", nil) d.Set("description", resp.Description) diff --git a/azurerm/resource_arm_automation_runbook.go b/azurerm/resource_arm_automation_runbook.go index e168ef13fcd6..c267cfdd1fb4 100644 --- a/azurerm/resource_arm_automation_runbook.go +++ b/azurerm/resource_arm_automation_runbook.go @@ -5,7 +5,6 @@ import ( "log" "github.com/Azure/azure-sdk-for-go/arm/automation" - "github.com/hashicorp/terraform/helper/hashcode" "github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/helper/validation" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" @@ -74,7 +73,7 @@ func resourceArmAutomationRunbook() *schema.Resource { }, "publish_content_link": { - Type: schema.TypeSet, + Type: schema.TypeList, Required: true, MaxItems: 1, Elem: &schema.Resource{ @@ -83,23 +82,37 @@ func resourceArmAutomationRunbook() *schema.Resource { Type: schema.TypeString, Required: true, }, + + "version": { + Type: schema.TypeString, + Optional: true, + }, + + "hash": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "algorithm": { + Type: schema.TypeString, + Required: true, + }, + "value": { + Type: schema.TypeString, + Required: true, + }, + }, + }, + }, }, }, - Set: resourceAzureRMAutomationRunbookContentLinkHash, }, "tags": tagsSchema(), }, } } -func resourceAzureRMAutomationRunbookContentLinkHash(v interface{}) int { - m := v.(map[string]interface{}) - - uri := m["uri"].(string) - - return hashcode.String(uri) -} - func resourceArmAutomationRunbookCreateUpdate(d *schema.ResourceData, meta interface{}) error { client := meta.(*ArmClient).automationRunbookClient log.Printf("[INFO] preparing arguments for AzureRM Automation Runbook creation.") @@ -210,12 +223,34 @@ func resourceArmAutomationRunbookDelete(d *schema.ResourceData, meta interface{} } func expandContentLink(d *schema.ResourceData) automation.ContentLink { - inputs := d.Get("publish_content_link").(*schema.Set).List() + inputs := d.Get("publish_content_link").([]interface{}) input := inputs[0].(map[string]interface{}) uri := input["uri"].(string) - - contentLink := automation.ContentLink{ - URI: &uri, + version := input["version"].(string) + + hashes := input["hash"].([]interface{}) + var contentLink automation.ContentLink + var contentHash automation.ContentHash + + if len(hashes) > 0 { + hash := hashes[0].(map[string]interface{}) + hashValue := hash["value"].(string) + hashAlgorithm := hash["algorithm"].(string) + contentHash = automation.ContentHash{ + Algorithm: &hashAlgorithm, + Value: &hashValue, + } + + contentLink = automation.ContentLink{ + URI: &uri, + Version: &version, + ContentHash: &contentHash, + } + } else { + contentLink = automation.ContentLink{ + URI: &uri, + Version: &version, + } } return contentLink diff --git a/azurerm/resource_arm_automation_runbook_test.go b/azurerm/resource_arm_automation_runbook_test.go index 4e125a542496..b73b939a9000 100644 --- a/azurerm/resource_arm_automation_runbook_test.go +++ b/azurerm/resource_arm_automation_runbook_test.go @@ -31,6 +31,26 @@ func TestAccAzureRMAutomationRunbook_PSWorkflow(t *testing.T) { }) } +func TestAccAzureRMAutomationRunbook_PSWorkflowWithHash(t *testing.T) { + ri := acctest.RandInt() + config := testAccAzureRMAutomationRunbook_PSWorkflowWithHash(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAutomationRunbookDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAutomationRunbookExistsAndType("azurerm_automation_runbook.test", automation.PowerShellWorkflow), + ), + ExpectNonEmptyPlan: true, + }, + }, + }) +} + func testCheckAzureRMAutomationRunbookDestroy(s *terraform.State) error { conn := testAccProvider.Meta().(*ArmClient).automationRunbookClient @@ -128,3 +148,41 @@ resource "azurerm_automation_runbook" "test" { } `, rInt, location, rInt) } + +func testAccAzureRMAutomationRunbook_PSWorkflowWithHash(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_automation_account" "test" { + name = "acctest-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + sku { + name = "Free" + } +} + +resource "azurerm_automation_runbook" "test" { + name = "Get-AzureVMTutorial" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + + account_name = "${azurerm_automation_account.test.name}" + log_verbose = "true" + log_progress = "true" + description = "This is a test runbook for terraform acceptance test" + runbook_type = "PowerShellWorkflow" + publish_content_link { + uri = "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-automation-runbook-getvms/Runbooks/Get-AzureVMTutorial.ps1" + version = "1.0.0.0" + hash { + algorithm = "SHA256" + value = "115775B8FF2BE672D8A946BD0B489918C724DDE15A440373CA54461D53010A80" + } + } +} +`, rInt, location, rInt) +} From 7dbda41f1bc01b5e1429c37b085b7ff4a5c9320c Mon Sep 17 00:00:00 2001 From: root Date: Fri, 1 Sep 2017 10:49:29 +0000 Subject: [PATCH 14/42] Use properties from RunbookProperties --- azurerm/resource_arm_automation_runbook.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/azurerm/resource_arm_automation_runbook.go b/azurerm/resource_arm_automation_runbook.go index c267cfdd1fb4..591d1511d66f 100644 --- a/azurerm/resource_arm_automation_runbook.go +++ b/azurerm/resource_arm_automation_runbook.go @@ -187,10 +187,13 @@ func resourceArmAutomationRunbookRead(d *schema.ResourceData, meta interface{}) d.Set("resource_group_name", resGroup) d.Set("account_name", accName) - d.Set("log_verbose", resp.LogVerbose) - d.Set("log_progress", resp.LogProgress) - d.Set("runbook_type", resp.RunbookType) - d.Set("description", resp.Description) + if props := resp.RunbookProperties; props != nil { + d.Set("log_verbose", props.LogVerbose) + d.Set("log_progress", props.LogProgress) + d.Set("runbook_type", props.RunbookType) + d.Set("description", props.Description) + } + d.Set("publish_content_link", nil) //publish content link is not set during Get() flattenAndSetTags(d, resp.Tags) From fe3cd901a448a240422c93c92132c886582056e7 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 1 Sep 2017 11:13:24 +0000 Subject: [PATCH 15/42] Use TypeList instead of TypeSet --- azurerm/resource_arm_automation_runbook.go | 14 ++++---- .../resource_arm_automation_runbook_test.go | 36 +++++++++---------- azurerm/resource_arm_automation_schedule.go | 23 +++--------- 3 files changed, 30 insertions(+), 43 deletions(-) diff --git a/azurerm/resource_arm_automation_runbook.go b/azurerm/resource_arm_automation_runbook.go index 591d1511d66f..08ca38a8946c 100644 --- a/azurerm/resource_arm_automation_runbook.go +++ b/azurerm/resource_arm_automation_runbook.go @@ -230,7 +230,7 @@ func expandContentLink(d *schema.ResourceData) automation.ContentLink { input := inputs[0].(map[string]interface{}) uri := input["uri"].(string) version := input["version"].(string) - + hashes := input["hash"].([]interface{}) var contentLink automation.ContentLink var contentHash automation.ContentHash @@ -240,14 +240,14 @@ func expandContentLink(d *schema.ResourceData) automation.ContentLink { hashValue := hash["value"].(string) hashAlgorithm := hash["algorithm"].(string) contentHash = automation.ContentHash{ - Algorithm: &hashAlgorithm, - Value: &hashValue, + Algorithm: &hashAlgorithm, + Value: &hashValue, } - + contentLink = automation.ContentLink{ - URI: &uri, - Version: &version, - ContentHash: &contentHash, + URI: &uri, + Version: &version, + ContentHash: &contentHash, } } else { contentLink = automation.ContentLink{ diff --git a/azurerm/resource_arm_automation_runbook_test.go b/azurerm/resource_arm_automation_runbook_test.go index b73b939a9000..be3057ab7bba 100644 --- a/azurerm/resource_arm_automation_runbook_test.go +++ b/azurerm/resource_arm_automation_runbook_test.go @@ -32,23 +32,23 @@ func TestAccAzureRMAutomationRunbook_PSWorkflow(t *testing.T) { } func TestAccAzureRMAutomationRunbook_PSWorkflowWithHash(t *testing.T) { - ri := acctest.RandInt() - config := testAccAzureRMAutomationRunbook_PSWorkflowWithHash(ri, testLocation()) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testCheckAzureRMAutomationRunbookDestroy, - Steps: []resource.TestStep{ - { - Config: config, - Check: resource.ComposeTestCheckFunc( - testCheckAzureRMAutomationRunbookExistsAndType("azurerm_automation_runbook.test", automation.PowerShellWorkflow), - ), - ExpectNonEmptyPlan: true, - }, - }, - }) + ri := acctest.RandInt() + config := testAccAzureRMAutomationRunbook_PSWorkflowWithHash(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAutomationRunbookDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAutomationRunbookExistsAndType("azurerm_automation_runbook.test", automation.PowerShellWorkflow), + ), + ExpectNonEmptyPlan: true, + }, + }, + }) } func testCheckAzureRMAutomationRunbookDestroy(s *terraform.State) error { @@ -150,7 +150,7 @@ resource "azurerm_automation_runbook" "test" { } func testAccAzureRMAutomationRunbook_PSWorkflowWithHash(rInt int, location string) string { - return fmt.Sprintf(` + return fmt.Sprintf(` resource "azurerm_resource_group" "test" { name = "acctestRG-%d" location = "%s" diff --git a/azurerm/resource_arm_automation_schedule.go b/azurerm/resource_arm_automation_schedule.go index f81d2743224f..3046457de568 100644 --- a/azurerm/resource_arm_automation_schedule.go +++ b/azurerm/resource_arm_automation_schedule.go @@ -1,14 +1,12 @@ package azurerm import ( - "bytes" "fmt" "log" "time" "github.com/Azure/azure-sdk-for-go/arm/automation" "github.com/Azure/go-autorest/autorest/date" - "github.com/hashicorp/terraform/helper/hashcode" "github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/helper/validation" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" @@ -74,7 +72,7 @@ func resourceArmAutomationSchedule() *schema.Resource { }, true), }, "first_run": { - Type: schema.TypeSet, + Type: schema.TypeList, Optional: true, MaxItems: 1, Elem: &schema.Resource{ @@ -106,30 +104,19 @@ func resourceArmAutomationSchedule() *schema.Resource { }, }, }, - Set: resourceAzureRMAutomationScheduleFreqConstraint, }, }, } } -func resourceAzureRMAutomationScheduleFreqConstraint(v interface{}) int { - var buf bytes.Buffer - m := v.(map[string]interface{}) - - buf.WriteString(fmt.Sprintf("%d-%d-%d-%d-%d", m["second"], m["minute"], m["hour"], m["day_of_week"], m["day_of_month"])) - return hashcode.String(buf.String()) -} - -func computeValidStartTime(firstRunSet *schema.Set, freq automation.ScheduleFrequency) time.Time { - - firstRunSetList := firstRunSet.List() +func computeValidStartTime(firstRunList []interface{}, freq automation.ScheduleFrequency) time.Time { closestValidStartTime := time.Now().UTC().Add(time.Duration(7) * time.Minute) - if len(firstRunSetList) == 0 { + if len(firstRunList) == 0 { return closestValidStartTime } - firstRun := firstRunSetList[0].(map[string]interface{}) + firstRun := firstRunList[0].(map[string]interface{}) firstRunSec := int(firstRun["second"].(int)) if firstRunSec == -1 { @@ -218,7 +205,7 @@ func resourceArmAutomationScheduleCreateUpdate(d *schema.ResourceData, meta inte return fmt.Errorf("Cannot parse start_time: %s", cst) } } else { - starttime = computeValidStartTime(d.Get("first_run").(*schema.Set), freq) + starttime = computeValidStartTime(d.Get("first_run").([]interface{}), freq) } ardt := date.Time{Time: starttime} From 612a1a93a29d1a19a6ba0379d493ef5258d55bc4 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 1 Sep 2017 12:06:54 +0000 Subject: [PATCH 16/42] Add timezone to schedule --- azurerm/resource_arm_automation_schedule.go | 12 ++++++++++-- azurerm/resource_arm_automation_schedule_test.go | 1 + website/docs/r/automation_schedule.html.markdown | 3 +++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/azurerm/resource_arm_automation_schedule.go b/azurerm/resource_arm_automation_schedule.go index 3046457de568..4a3a05f53633 100644 --- a/azurerm/resource_arm_automation_schedule.go +++ b/azurerm/resource_arm_automation_schedule.go @@ -71,6 +71,10 @@ func resourceArmAutomationSchedule() *schema.Resource { string(automation.Week), }, true), }, + "timezone": { + Type: schema.TypeString, + Optional: true, + }, "first_run": { Type: schema.TypeList, Optional: true, @@ -216,8 +220,12 @@ func resourceArmAutomationScheduleCreateUpdate(d *schema.ResourceData, meta inte //interval := description := d.Get("description").(string) - timezone := "UTC" - + var timezone string + if v, ok := d.GetOk("timezone"); ok { + timezone = v.(string) + } else { + timezone = "UTC" + } parameters := automation.ScheduleCreateOrUpdateParameters{ Name: &name, ScheduleCreateOrUpdateProperties: &automation.ScheduleCreateOrUpdateProperties{ diff --git a/azurerm/resource_arm_automation_schedule_test.go b/azurerm/resource_arm_automation_schedule_test.go index 07675e1fd13f..293d5f67dde0 100644 --- a/azurerm/resource_arm_automation_schedule_test.go +++ b/azurerm/resource_arm_automation_schedule_test.go @@ -116,6 +116,7 @@ resource "azurerm_automation_schedule" "test" { resource_group_name = "${azurerm_resource_group.test.name}" account_name = "${azurerm_automation_account.test.name}" frequency = "OneTime" + timezone = "Central Europe Standard Time" first_run { "hour" = 20 "minute" = 5 diff --git a/website/docs/r/automation_schedule.html.markdown b/website/docs/r/automation_schedule.html.markdown index 7ba20e669b03..66e5a73c29a4 100644 --- a/website/docs/r/automation_schedule.html.markdown +++ b/website/docs/r/automation_schedule.html.markdown @@ -32,6 +32,7 @@ resource "azurerm_automation_schedule" "example" { resource_group_name = "${azurerm_resource_group.example.name}" account_name = "${azurerm_automation_account.example.name}" frequency = "OneTime" + timezone = "Central Europe Standard Time" first_run { "hour" = 20 "minute" = 5 @@ -61,6 +62,8 @@ The following arguments are supported: * `frequency` - (Required) The frequency of the schedule. - can be either `OneTime`, `Day`, `Hour`, `Week`, or `Month`. +* `timezone` - (Optional) The timezone of the start time. For possible values see: https://msdn.microsoft.com/en-us/library/ms912391(v=winembedded.11).aspx + * `first_run` - (Optional) If an exact start time is not suitable, it can be used to make constraints for the first run. The start time will be calculated depending on these constraints. `start_time` will override this settings if defined. `first_run` supports the following: From 124f4669ecc1f174a141d6782e4809953cb072e0 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 1 Sep 2017 12:23:59 +0000 Subject: [PATCH 17/42] Remove unsupported interval --- azurerm/resource_arm_automation_schedule.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/azurerm/resource_arm_automation_schedule.go b/azurerm/resource_arm_automation_schedule.go index 4a3a05f53633..60d5dfa569db 100644 --- a/azurerm/resource_arm_automation_schedule.go +++ b/azurerm/resource_arm_automation_schedule.go @@ -214,11 +214,6 @@ func resourceArmAutomationScheduleCreateUpdate(d *schema.ResourceData, meta inte ardt := date.Time{Time: starttime} - //TODO Interval handling currently not supported via Go SDK - //Related ticket in the azure go sdk: https://github.com/Azure/azure-sdk-for-go/issues/725 - //Related ticket in the azure rest api spec: https://github.com/Azure/azure-rest-api-specs/issues/1545 - //interval := - description := d.Get("description").(string) var timezone string if v, ok := d.GetOk("timezone"); ok { @@ -280,7 +275,6 @@ func resourceArmAutomationScheduleRead(d *schema.ResourceData, meta interface{}) d.Set("resource_group_name", resGroup) d.Set("account_name", accName) d.Set("frequency", resp.Frequency) - d.Set("interval", resp.Interval) d.Set("description", resp.Description) d.Set("start_time", string(resp.StartTime.Format(time.RFC3339))) d.Set("first_run", nil) From 3b9ee8d58821c1fbfb457189830adfc55ea56f8d Mon Sep 17 00:00:00 2001 From: root Date: Fri, 1 Sep 2017 12:38:43 +0000 Subject: [PATCH 18/42] Remove interval from schema --- azurerm/resource_arm_automation_schedule.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/azurerm/resource_arm_automation_schedule.go b/azurerm/resource_arm_automation_schedule.go index 60d5dfa569db..7e1f253baab9 100644 --- a/azurerm/resource_arm_automation_schedule.go +++ b/azurerm/resource_arm_automation_schedule.go @@ -55,10 +55,6 @@ func resourceArmAutomationSchedule() *schema.Resource { Optional: true, }, - "interval": { - Type: schema.TypeInt, - Optional: true, - }, "frequency": { Type: schema.TypeString, Required: true, From 1b0425ba297f53e59ba0296e51f1a33c340cadf5 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 1 Sep 2017 12:50:28 +0000 Subject: [PATCH 19/42] Remove interval from docs --- website/docs/r/automation_schedule.html.markdown | 2 -- 1 file changed, 2 deletions(-) diff --git a/website/docs/r/automation_schedule.html.markdown b/website/docs/r/automation_schedule.html.markdown index 66e5a73c29a4..dbb942ca5476 100644 --- a/website/docs/r/automation_schedule.html.markdown +++ b/website/docs/r/automation_schedule.html.markdown @@ -58,8 +58,6 @@ The following arguments are supported: * `expiry_time` - (Optional) The end time of the schedule. -* `interval` - (Optional) The interval of the schedule. Must be set if the schedule is recurring. NOT YET SUPPORTED due to lack of SDK support. - * `frequency` - (Required) The frequency of the schedule. - can be either `OneTime`, `Day`, `Hour`, `Week`, or `Month`. * `timezone` - (Optional) The timezone of the start time. For possible values see: https://msdn.microsoft.com/en-us/library/ms912391(v=winembedded.11).aspx From fe7f5367ff4793bc985dd0567516c9c0ded21b8b Mon Sep 17 00:00:00 2001 From: root Date: Fri, 1 Sep 2017 15:06:13 +0000 Subject: [PATCH 20/42] Remove first_run field and switch start_time as required field --- azurerm/resource_arm_automation_schedule.go | 132 +----------------- .../resource_arm_automation_schedule_test.go | 12 +- .../docs/r/automation_schedule.html.markdown | 22 +-- 3 files changed, 14 insertions(+), 152 deletions(-) diff --git a/azurerm/resource_arm_automation_schedule.go b/azurerm/resource_arm_automation_schedule.go index 7e1f253baab9..e9a114190d46 100644 --- a/azurerm/resource_arm_automation_schedule.go +++ b/azurerm/resource_arm_automation_schedule.go @@ -47,7 +47,7 @@ func resourceArmAutomationSchedule() *schema.Resource { }, "start_time": { Type: schema.TypeString, - Optional: true, + Required: true, }, "expiry_time": { @@ -71,119 +71,10 @@ func resourceArmAutomationSchedule() *schema.Resource { Type: schema.TypeString, Optional: true, }, - "first_run": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "second": { - Type: schema.TypeInt, - Optional: true, - Default: -1, - }, - "minute": { - Type: schema.TypeInt, - Optional: true, - Default: -1, - }, - "hour": { - Type: schema.TypeInt, - Optional: true, - Default: -1, - }, - "day_of_week": { - Type: schema.TypeInt, - Optional: true, - Default: -1, - }, - "day_of_month": { - Type: schema.TypeInt, - Optional: true, - Default: -1, - }, - }, - }, - }, }, } } -func computeValidStartTime(firstRunList []interface{}, freq automation.ScheduleFrequency) time.Time { - - closestValidStartTime := time.Now().UTC().Add(time.Duration(7) * time.Minute) - if len(firstRunList) == 0 { - return closestValidStartTime - } - - firstRun := firstRunList[0].(map[string]interface{}) - - firstRunSec := int(firstRun["second"].(int)) - if firstRunSec == -1 { - firstRunSec = closestValidStartTime.Second() - } - - firstRunMinute := int(firstRun["minute"].(int)) - if firstRunMinute == -1 { - firstRunMinute = closestValidStartTime.Minute() - } - - firstRunHour := int(firstRun["hour"].(int)) - if firstRunHour == -1 { - firstRunHour = closestValidStartTime.Hour() - } - - firstRunDayOfWeek := int(firstRun["day_of_week"].(int)) - if firstRunDayOfWeek == -1 { - firstRunDayOfWeek = int(closestValidStartTime.Weekday()) - } - - firstRunDayOfMonth := int(firstRun["day_of_month"].(int)) - if firstRunDayOfMonth == -1 { - firstRunDayOfMonth = closestValidStartTime.Day() - } - - switch freq { - case automation.Hour: - validStartTime := time.Date(closestValidStartTime.Year(), closestValidStartTime.Month(), closestValidStartTime.Day(), closestValidStartTime.Hour(), firstRunMinute, firstRunSec, 0, time.UTC) - if firstRunMinute <= closestValidStartTime.Minute() { - validStartTime.Add(time.Duration(1) * time.Hour) - } - - return validStartTime - - case automation.Day: - validStartTime := time.Date(closestValidStartTime.Year(), closestValidStartTime.Month(), closestValidStartTime.Day(), firstRunHour, firstRunMinute, firstRunSec, 0, time.UTC) - if firstRunHour <= closestValidStartTime.Hour() { - validStartTime.AddDate(0, 0, 1) - } - return validStartTime - - case automation.Week: - validStartTime := time.Date(closestValidStartTime.Year(), closestValidStartTime.Month(), closestValidStartTime.Day(), firstRunHour, firstRunMinute, firstRunSec, 0, time.UTC) - if firstRunDayOfWeek <= int(closestValidStartTime.Weekday()) { - dayadd := 7 - (int(closestValidStartTime.Weekday()) - firstRunDayOfWeek) - validStartTime.AddDate(0, 0, dayadd) - } - return validStartTime - - case automation.Month: - validStartTime := time.Date(closestValidStartTime.Year(), closestValidStartTime.Month(), firstRunDayOfMonth, firstRunHour, firstRunMinute, firstRunSec, 0, time.UTC) - if firstRunDayOfMonth <= closestValidStartTime.Day() { - validStartTime.AddDate(0, 1, 0) - } - return validStartTime - - case automation.OneTime: - validStartTime := time.Date(closestValidStartTime.Year(), closestValidStartTime.Month(), firstRunDayOfMonth, firstRunHour, firstRunMinute, firstRunSec, 0, time.UTC) - return validStartTime - - } - - log.Printf("[WARN] error compute first valid run time") - return closestValidStartTime -} - func resourceArmAutomationScheduleCreateUpdate(d *schema.ResourceData, meta interface{}) error { client := meta.(*ArmClient).automationScheduleClient log.Printf("[INFO] preparing arguments for AzureRM Automation Schedule creation.") @@ -196,16 +87,9 @@ func resourceArmAutomationScheduleCreateUpdate(d *schema.ResourceData, meta inte freq := automation.ScheduleFrequency(freqstr) cst := d.Get("start_time").(string) - var starttime time.Time - - if cst != "" { - var tperr error - starttime, tperr = time.Parse(time.RFC3339, cst) - if tperr != nil { - return fmt.Errorf("Cannot parse start_time: %s", cst) - } - } else { - starttime = computeValidStartTime(d.Get("first_run").([]interface{}), freq) + starttime, tperr := time.Parse(time.RFC3339, cst) + if tperr != nil { + return fmt.Errorf("Cannot parse start_time: %s", cst) } ardt := date.Time{Time: starttime} @@ -221,10 +105,9 @@ func resourceArmAutomationScheduleCreateUpdate(d *schema.ResourceData, meta inte Name: &name, ScheduleCreateOrUpdateProperties: &automation.ScheduleCreateOrUpdateProperties{ Description: &description, - //Interval: &interval, - Frequency: freq, - StartTime: &ardt, - TimeZone: &timezone, + Frequency: freq, + StartTime: &ardt, + TimeZone: &timezone, }, } @@ -273,7 +156,6 @@ func resourceArmAutomationScheduleRead(d *schema.ResourceData, meta interface{}) d.Set("frequency", resp.Frequency) d.Set("description", resp.Description) d.Set("start_time", string(resp.StartTime.Format(time.RFC3339))) - d.Set("first_run", nil) return nil } diff --git a/azurerm/resource_arm_automation_schedule_test.go b/azurerm/resource_arm_automation_schedule_test.go index 293d5f67dde0..4cae22711b6a 100644 --- a/azurerm/resource_arm_automation_schedule_test.go +++ b/azurerm/resource_arm_automation_schedule_test.go @@ -3,6 +3,7 @@ package azurerm import ( "fmt" "testing" + "time" "github.com/Azure/azure-sdk-for-go/arm/automation" "github.com/hashicorp/terraform/helper/acctest" @@ -60,7 +61,6 @@ func testCheckAzureRMAutomationScheduleDestroy(s *terraform.State) error { } func testCheckAzureRMAutomationScheduleExistsAndFrequencyType(name string, freq automation.ScheduleFrequency) resource.TestCheckFunc { - return func(s *terraform.State) error { // Ensure we have enough information in state to look up in API rs, ok := s.RootModule().Resources[name] @@ -96,6 +96,8 @@ func testCheckAzureRMAutomationScheduleExistsAndFrequencyType(name string, freq } func testAccAzureRMAutomationSchedule_oneTime(rInt int, location string) string { + startTime := time.Now().UTC().Add(time.Duration(7) * time.Minute) + return fmt.Sprintf(` resource "azurerm_resource_group" "test" { name = "acctestRG-%d" @@ -117,12 +119,8 @@ resource "azurerm_automation_schedule" "test" { account_name = "${azurerm_automation_account.test.name}" frequency = "OneTime" timezone = "Central Europe Standard Time" - first_run { - "hour" = 20 - "minute" = 5 - "second" = 0 - } + start_time = "%s" description = "This is a test runbook for terraform acceptance test" } -`, rInt, location, rInt, rInt) +`, rInt, location, rInt, rInt, startTime.Format(time.RFC3339)) } diff --git a/website/docs/r/automation_schedule.html.markdown b/website/docs/r/automation_schedule.html.markdown index dbb942ca5476..1b964a52e952 100644 --- a/website/docs/r/automation_schedule.html.markdown +++ b/website/docs/r/automation_schedule.html.markdown @@ -33,11 +33,7 @@ resource "azurerm_automation_schedule" "example" { account_name = "${azurerm_automation_account.example.name}" frequency = "OneTime" timezone = "Central Europe Standard Time" - first_run { - "hour" = 20 - "minute" = 5 - "second" = 0 - } + start_time = "2014-04-15T18:00:15-07:00" description = "This is an example schedule" } ``` @@ -54,7 +50,7 @@ The following arguments are supported: * `description` - (Optional) A description for this Schedule. -* `start_time` - (Optional) Start time of the schedule. Must be at least five minutes in the future. +* `start_time` - (Required) Start time of the schedule. Must be at least five minutes in the future. * `expiry_time` - (Optional) The end time of the schedule. @@ -62,20 +58,6 @@ The following arguments are supported: * `timezone` - (Optional) The timezone of the start time. For possible values see: https://msdn.microsoft.com/en-us/library/ms912391(v=winembedded.11).aspx -* `first_run` - (Optional) If an exact start time is not suitable, it can be used to make constraints for the first run. The start time will be calculated depending on these constraints. `start_time` will override this settings if defined. - -`first_run` supports the following: - -* `second` - (Optional) In which second should the schedule first triggered. - -* `minute` - (Optional) In which minute should the schedule first triggered. - -* `hour` - (Optional) In which hour should the schedule first triggered. Ignored if the frequency is `Hour`. - -* `day_of_week` - (Optional) On which day of the week should the schedule first triggered. Ignored if the frequency is `OneTime`, `Hour` or `Day`. (0 - Sunday) - -* `day_of_month` - (Optional) On which day of the month should the schedule first triggered. Ignored if the frequency is `Hour`, `Day` or `Week`. - ## Attributes Reference The following attributes are exported: From 6b2c8e1efa7bf8d586e2e2ce7a2ae8bc439f5bdb Mon Sep 17 00:00:00 2001 From: root Date: Mon, 4 Sep 2017 07:09:20 +0000 Subject: [PATCH 21/42] Fix example in documentation --- website/docs/r/automation_credential.html.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/website/docs/r/automation_credential.html.markdown b/website/docs/r/automation_credential.html.markdown index 372179c4cba7..8b8c064084cd 100644 --- a/website/docs/r/automation_credential.html.markdown +++ b/website/docs/r/automation_credential.html.markdown @@ -34,6 +34,7 @@ resource "azurerm_automation_credential" "example" { username = "example_user" password = "example_pwd" description = "This is an example credential" +} ``` ## Argument Reference From 3c93fe6887cbd4bd5490da20541f88585727072b Mon Sep 17 00:00:00 2001 From: root Date: Mon, 4 Sep 2017 07:10:32 +0000 Subject: [PATCH 22/42] Fix typo in documentation --- website/docs/r/automation_runbook.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/r/automation_runbook.html.markdown b/website/docs/r/automation_runbook.html.markdown index 8318d7fb5965..5f72d0d39231 100644 --- a/website/docs/r/automation_runbook.html.markdown +++ b/website/docs/r/automation_runbook.html.markdown @@ -30,7 +30,7 @@ resource "azurerm_automation_account" "example" { resource "azurerm_automation_runbook" "example" { name = "Get-AzureVMTutorial" location = "${azurerm_resource_group.example.location}" - resource_group_name = "${azurerm_resource_group.exmaple.name}" + resource_group_name = "${azurerm_resource_group.example.name}" account_name = "${azurerm_automation_account.example.name}" log_verbose = "true" log_progress = "true" From 90f30d50aba6aa2e707f4af6fec9ee74aba218be Mon Sep 17 00:00:00 2001 From: root Date: Mon, 4 Sep 2017 07:24:12 +0000 Subject: [PATCH 23/42] Remove nil association --- azurerm/resource_arm_automation_credential.go | 1 - azurerm/resource_arm_automation_credential_test.go | 1 - 2 files changed, 2 deletions(-) diff --git a/azurerm/resource_arm_automation_credential.go b/azurerm/resource_arm_automation_credential.go index c1a0c53b82a9..21af774e1dea 100644 --- a/azurerm/resource_arm_automation_credential.go +++ b/azurerm/resource_arm_automation_credential.go @@ -120,7 +120,6 @@ func resourceArmAutomationCredentialRead(d *schema.ResourceData, meta interface{ if props := resp.CredentialProperties; props != nil { d.Set("username", props.UserName) } - d.Set("password", nil) d.Set("description", resp.Description) return nil diff --git a/azurerm/resource_arm_automation_credential_test.go b/azurerm/resource_arm_automation_credential_test.go index 82f4da4d58b3..3066901dcb98 100644 --- a/azurerm/resource_arm_automation_credential_test.go +++ b/azurerm/resource_arm_automation_credential_test.go @@ -24,7 +24,6 @@ func TestAccAzureRMAutomationCredential_testCredential(t *testing.T) { Check: resource.ComposeTestCheckFunc( testCheckAzureRMAutomationCredentialExistsAndUserName("azurerm_automation_credential.test", "test_user"), ), - ExpectNonEmptyPlan: true, }, }, }) From cab95de235eb18fbff1ac13a29a685588c04e0b9 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 4 Sep 2017 07:55:58 +0000 Subject: [PATCH 24/42] Add validate function for start_time field --- azurerm/resource_arm_automation_schedule.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/azurerm/resource_arm_automation_schedule.go b/azurerm/resource_arm_automation_schedule.go index e9a114190d46..f7f5a85a51ce 100644 --- a/azurerm/resource_arm_automation_schedule.go +++ b/azurerm/resource_arm_automation_schedule.go @@ -46,8 +46,9 @@ func resourceArmAutomationSchedule() *schema.Resource { ForceNew: true, }, "start_time": { - Type: schema.TypeString, - Required: true, + Type: schema.TypeString, + Required: true, + ValidateFunc: validateStartTime, }, "expiry_time": { @@ -75,6 +76,20 @@ func resourceArmAutomationSchedule() *schema.Resource { } } +func validateStartTime(v interface{}, k string) (ws []string, errors []error) { + starttime, tperr := time.Parse(time.RFC3339, v.(string)) + if tperr != nil { + errors = append(errors, fmt.Errorf("Cannot parse %q", k)) + } + + u := time.Until(starttime) + if u < 5 * time.Minute { + errors = append(errors, fmt.Errorf("%q should be at least 5 minutes in the future", k)) + } + + return +} + func resourceArmAutomationScheduleCreateUpdate(d *schema.ResourceData, meta interface{}) error { client := meta.(*ArmClient).automationScheduleClient log.Printf("[INFO] preparing arguments for AzureRM Automation Schedule creation.") From 1a9e856084759d8a813d19f42cc3e1bc6fcb0a48 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 4 Sep 2017 08:00:54 +0000 Subject: [PATCH 25/42] Fix timezone in example --- website/docs/r/automation_schedule.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/r/automation_schedule.html.markdown b/website/docs/r/automation_schedule.html.markdown index 1b964a52e952..e7d3d439d64a 100644 --- a/website/docs/r/automation_schedule.html.markdown +++ b/website/docs/r/automation_schedule.html.markdown @@ -33,7 +33,7 @@ resource "azurerm_automation_schedule" "example" { account_name = "${azurerm_automation_account.example.name}" frequency = "OneTime" timezone = "Central Europe Standard Time" - start_time = "2014-04-15T18:00:15-07:00" + start_time = "2014-04-15T18:00:15+02:00" description = "This is an example schedule" } ``` From 789bd766b36f871d8aea6ba0d5e8460da64e00a1 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 4 Sep 2017 08:16:42 +0000 Subject: [PATCH 26/42] Formatting --- azurerm/resource_arm_automation_schedule.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azurerm/resource_arm_automation_schedule.go b/azurerm/resource_arm_automation_schedule.go index f7f5a85a51ce..74a1c6b6d2fc 100644 --- a/azurerm/resource_arm_automation_schedule.go +++ b/azurerm/resource_arm_automation_schedule.go @@ -83,7 +83,7 @@ func validateStartTime(v interface{}, k string) (ws []string, errors []error) { } u := time.Until(starttime) - if u < 5 * time.Minute { + if u < 5*time.Minute { errors = append(errors, fmt.Errorf("%q should be at least 5 minutes in the future", k)) } From 92f5b178af07411468236e8e161bb142a7759433 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 4 Sep 2017 08:23:15 +0000 Subject: [PATCH 27/42] Add resrouce provider registration --- azurerm/provider.go | 1 + 1 file changed, 1 insertion(+) diff --git a/azurerm/provider.go b/azurerm/provider.go index ac314341eff3..38cc1cb2f8ac 100644 --- a/azurerm/provider.go +++ b/azurerm/provider.go @@ -243,6 +243,7 @@ var providerRegistrationOnce sync.Once func determineAzureResourceProvidersToRegister(providerList []resources.Provider) map[string]struct{} { providers := map[string]struct{}{ + "Microsoft.Automation": struct{}{}, "Microsoft.Cache": struct{}{}, "Microsoft.Cdn": struct{}{}, "Microsoft.Compute": struct{}{}, From 8bde7e8c8448b5822f97209e38f570bab1ac0129 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 4 Sep 2017 09:56:01 +0000 Subject: [PATCH 28/42] Remove publish content link from read --- azurerm/resource_arm_automation_runbook.go | 2 -- azurerm/resource_arm_automation_runbook_test.go | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/azurerm/resource_arm_automation_runbook.go b/azurerm/resource_arm_automation_runbook.go index 08ca38a8946c..0ae0075d90d8 100644 --- a/azurerm/resource_arm_automation_runbook.go +++ b/azurerm/resource_arm_automation_runbook.go @@ -194,8 +194,6 @@ func resourceArmAutomationRunbookRead(d *schema.ResourceData, meta interface{}) d.Set("description", props.Description) } - d.Set("publish_content_link", nil) //publish content link is not set during Get() - flattenAndSetTags(d, resp.Tags) return nil diff --git a/azurerm/resource_arm_automation_runbook_test.go b/azurerm/resource_arm_automation_runbook_test.go index be3057ab7bba..0b647e994217 100644 --- a/azurerm/resource_arm_automation_runbook_test.go +++ b/azurerm/resource_arm_automation_runbook_test.go @@ -25,7 +25,7 @@ func TestAccAzureRMAutomationRunbook_PSWorkflow(t *testing.T) { Check: resource.ComposeTestCheckFunc( testCheckAzureRMAutomationRunbookExistsAndType("azurerm_automation_runbook.test", automation.PowerShellWorkflow), ), - ExpectNonEmptyPlan: true, + //ExpectNonEmptyPlan: true, }, }, }) From 97b96a35368ec1bd5c57627c94447f78716b89b9 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 11 Sep 2017 14:33:39 +0000 Subject: [PATCH 29/42] Fix test, add expirytime, fix logging --- azurerm/resource_arm_automation_credential.go | 2 +- ...resource_arm_automation_credential_test.go | 2 +- azurerm/resource_arm_automation_runbook.go | 3 +- .../resource_arm_automation_runbook_test.go | 4 +-- azurerm/resource_arm_automation_schedule.go | 29 ++++++++++++------- 5 files changed, 23 insertions(+), 17 deletions(-) diff --git a/azurerm/resource_arm_automation_credential.go b/azurerm/resource_arm_automation_credential.go index 21af774e1dea..d76ab4d3c99a 100644 --- a/azurerm/resource_arm_automation_credential.go +++ b/azurerm/resource_arm_automation_credential.go @@ -48,7 +48,7 @@ func resourceArmAutomationCredential() *schema.Resource { }, "description": { Type: schema.TypeString, - Required: true, + Optional: true, }, }, } diff --git a/azurerm/resource_arm_automation_credential_test.go b/azurerm/resource_arm_automation_credential_test.go index 3066901dcb98..a8991eaf81b1 100644 --- a/azurerm/resource_arm_automation_credential_test.go +++ b/azurerm/resource_arm_automation_credential_test.go @@ -51,7 +51,7 @@ func testCheckAzureRMAutomationCredentialDestroy(s *terraform.State) error { return err } - return fmt.Errorf("EventGrid Topic still exists:\n%#v", resp) + return fmt.Errorf("Automation Credential still exists:\n%#v", resp) } diff --git a/azurerm/resource_arm_automation_runbook.go b/azurerm/resource_arm_automation_runbook.go index 0ae0075d90d8..dc932059fa4f 100644 --- a/azurerm/resource_arm_automation_runbook.go +++ b/azurerm/resource_arm_automation_runbook.go @@ -68,8 +68,7 @@ func resourceArmAutomationRunbook() *schema.Resource { "description": { Type: schema.TypeString, - Required: true, - ForceNew: true, + Optional: true, }, "publish_content_link": { diff --git a/azurerm/resource_arm_automation_runbook_test.go b/azurerm/resource_arm_automation_runbook_test.go index 0b647e994217..43821f666311 100644 --- a/azurerm/resource_arm_automation_runbook_test.go +++ b/azurerm/resource_arm_automation_runbook_test.go @@ -25,7 +25,6 @@ func TestAccAzureRMAutomationRunbook_PSWorkflow(t *testing.T) { Check: resource.ComposeTestCheckFunc( testCheckAzureRMAutomationRunbookExistsAndType("azurerm_automation_runbook.test", automation.PowerShellWorkflow), ), - //ExpectNonEmptyPlan: true, }, }, }) @@ -45,7 +44,6 @@ func TestAccAzureRMAutomationRunbook_PSWorkflowWithHash(t *testing.T) { Check: resource.ComposeTestCheckFunc( testCheckAzureRMAutomationRunbookExistsAndType("azurerm_automation_runbook.test", automation.PowerShellWorkflow), ), - ExpectNonEmptyPlan: true, }, }, }) @@ -105,7 +103,7 @@ func testCheckAzureRMAutomationRunbookExistsAndType(name string, runbookType aut return fmt.Errorf("Automation Runbook '%s' (resource group: '%s') does not exist", name, resourceGroup) } - return fmt.Errorf("Bad: Get on automationRunbookClient: %s", err) + return fmt.Errorf("Bad: Get on automationRunbookClient: %+v", err) } if resp.RunbookType != runbookType { diff --git a/azurerm/resource_arm_automation_schedule.go b/azurerm/resource_arm_automation_schedule.go index 74a1c6b6d2fc..bafa249e022c 100644 --- a/azurerm/resource_arm_automation_schedule.go +++ b/azurerm/resource_arm_automation_schedule.go @@ -38,6 +38,7 @@ func resourceArmAutomationSchedule() *schema.Resource { "description": { Type: schema.TypeString, Optional: true, + Computed: true, }, "resource_group_name": { @@ -54,6 +55,7 @@ func resourceArmAutomationSchedule() *schema.Resource { "expiry_time": { Type: schema.TypeString, Optional: true, + Computed: true, }, "frequency": { @@ -71,6 +73,8 @@ func resourceArmAutomationSchedule() *schema.Resource { "timezone": { Type: schema.TypeString, Optional: true, + Computed: true, + Default: "UTC", }, }, } @@ -104,24 +108,27 @@ func resourceArmAutomationScheduleCreateUpdate(d *schema.ResourceData, meta inte cst := d.Get("start_time").(string) starttime, tperr := time.Parse(time.RFC3339, cst) if tperr != nil { - return fmt.Errorf("Cannot parse start_time: %s", cst) + return fmt.Errorf("Cannot parse start_time: %q", cst) } - ardt := date.Time{Time: starttime} + expirytime, teperr := time.Parse(time.RFC3339, cst) + if teperr != nil { + return fmt.Errorf("Cannot parse expiry_time: %q", cst) + } + + stdt := date.Time{Time: starttime} + etdt := date.Time{Time: expirytime} description := d.Get("description").(string) - var timezone string - if v, ok := d.GetOk("timezone"); ok { - timezone = v.(string) - } else { - timezone = "UTC" - } + timezone := d.Get("timezone").(string) + parameters := automation.ScheduleCreateOrUpdateParameters{ Name: &name, ScheduleCreateOrUpdateProperties: &automation.ScheduleCreateOrUpdateProperties{ Description: &description, Frequency: freq, - StartTime: &ardt, + StartTime: &stdt, + ExpiryTime: &etdt, TimeZone: &timezone, }, } @@ -162,7 +169,7 @@ func resourceArmAutomationScheduleRead(d *schema.ResourceData, meta interface{}) return nil } - return fmt.Errorf("Error making Read request on AzureRM Automation Schedule '%s': %s", name, err) + return fmt.Errorf("Error making Read request on AzureRM Automation Schedule '%s': %+v", name, err) } d.Set("name", resp.Name) @@ -171,6 +178,8 @@ func resourceArmAutomationScheduleRead(d *schema.ResourceData, meta interface{}) d.Set("frequency", resp.Frequency) d.Set("description", resp.Description) d.Set("start_time", string(resp.StartTime.Format(time.RFC3339))) + d.Set("expiry_time", string(resp.ExpiryTime.Format(time.RFC3339))) + d.Set("timezone", resp.TimeZone) return nil } From 6f5ea1105c52ac94e0591bffccfa3f182afdee63 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 12 Sep 2017 07:05:40 +0000 Subject: [PATCH 30/42] Remove Computed tag --- azurerm/resource_arm_automation_schedule.go | 1 - 1 file changed, 1 deletion(-) diff --git a/azurerm/resource_arm_automation_schedule.go b/azurerm/resource_arm_automation_schedule.go index bafa249e022c..dda31cbf2b20 100644 --- a/azurerm/resource_arm_automation_schedule.go +++ b/azurerm/resource_arm_automation_schedule.go @@ -73,7 +73,6 @@ func resourceArmAutomationSchedule() *schema.Resource { "timezone": { Type: schema.TypeString, Optional: true, - Computed: true, Default: "UTC", }, }, From 7caaa745cf7d0cc87f86a6917c727171103d9706 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 12 Sep 2017 07:27:03 +0000 Subject: [PATCH 31/42] Check from state --- azurerm/resource_arm_automation_account_test.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/azurerm/resource_arm_automation_account_test.go b/azurerm/resource_arm_automation_account_test.go index 7d919032f552..a25c0d99213a 100644 --- a/azurerm/resource_arm_automation_account_test.go +++ b/azurerm/resource_arm_automation_account_test.go @@ -4,7 +4,6 @@ import ( "fmt" "testing" - "github.com/Azure/azure-sdk-for-go/arm/automation" "github.com/hashicorp/terraform/helper/acctest" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" @@ -13,6 +12,7 @@ import ( func TestAccAzureRMAutomationAccount_skuBasic(t *testing.T) { ri := acctest.RandInt() + resourceName := "azurerm_automation_account.test" config := testAccAzureRMAutomationAccount_skuBasic(ri, testLocation()) resource.Test(t, resource.TestCase{ @@ -23,7 +23,8 @@ func TestAccAzureRMAutomationAccount_skuBasic(t *testing.T) { { Config: config, Check: resource.ComposeTestCheckFunc( - testCheckAzureRMAutomationAccountExistsAndSku("azurerm_automation_account.test", automation.Basic), + testCheckAzureRMAutomationAccountExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "sku.0.name", "Basic"), ), }, }, @@ -32,6 +33,7 @@ func TestAccAzureRMAutomationAccount_skuBasic(t *testing.T) { func TestAccAzureRMAutomationAccount_skuFree(t *testing.T) { ri := acctest.RandInt() + resourceName := "azurerm_automation_account.test" config := testAccAzureRMAutomationAccount_skuFree(ri, testLocation()) resource.Test(t, resource.TestCase{ @@ -42,7 +44,8 @@ func TestAccAzureRMAutomationAccount_skuFree(t *testing.T) { { Config: config, Check: resource.ComposeTestCheckFunc( - testCheckAzureRMAutomationAccountExistsAndSku("azurerm_automation_account.test", automation.Free), + testCheckAzureRMAutomationAccountExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "sku.0.name", "Free"), ), }, }, @@ -76,7 +79,7 @@ func testCheckAzureRMAutomationAccountDestroy(s *terraform.State) error { return nil } -func testCheckAzureRMAutomationAccountExistsAndSku(name string, sku automation.SkuNameEnum) resource.TestCheckFunc { +func testCheckAzureRMAutomationAccountExists(name string) resource.TestCheckFunc { return func(s *terraform.State) error { // Ensure we have enough information in state to look up in API @@ -103,10 +106,6 @@ func testCheckAzureRMAutomationAccountExistsAndSku(name string, sku automation.S return fmt.Errorf("Bad: Get on automationClient: %s", err) } - if resp.Sku.Name != sku { - return fmt.Errorf("Actual sku %s is not consistent with the expected value %q", resp.Sku.Name, sku) - } - return nil } } From 8d96426812c9544907a2b451b197a365e50c27d3 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 12 Sep 2017 14:02:34 +0000 Subject: [PATCH 32/42] Refactor credential tests --- .../import_arm_automation_credential_test.go | 11 ++-- ...resource_arm_automation_credential_test.go | 64 ++++++++++++++++--- 2 files changed, 60 insertions(+), 15 deletions(-) diff --git a/azurerm/import_arm_automation_credential_test.go b/azurerm/import_arm_automation_credential_test.go index 5fe35af15359..0fbc3a382a40 100644 --- a/azurerm/import_arm_automation_credential_test.go +++ b/azurerm/import_arm_automation_credential_test.go @@ -11,7 +11,7 @@ func TestAccAzureRMAutomationCredential_importCredential(t *testing.T) { resourceName := "azurerm_automation_credential.test" ri := acctest.RandInt() - config := testAccAzureRMAutomationCredential_testCredential(ri, testLocation()) + config := testAccAzureRMAutomationCredential_complete(ri, testLocation()) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -20,14 +20,13 @@ func TestAccAzureRMAutomationCredential_importCredential(t *testing.T) { Steps: []resource.TestStep{ { Config: config, - // publish content link is not returned after the runbook is created - ExpectNonEmptyPlan: true, }, { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"password"}, }, }, }) diff --git a/azurerm/resource_arm_automation_credential_test.go b/azurerm/resource_arm_automation_credential_test.go index a8991eaf81b1..1cd5c916341e 100644 --- a/azurerm/resource_arm_automation_credential_test.go +++ b/azurerm/resource_arm_automation_credential_test.go @@ -10,9 +10,10 @@ import ( "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) -func TestAccAzureRMAutomationCredential_testCredential(t *testing.T) { +func TestAccAzureRMAutomationCredential_basic(t *testing.T) { + resourceName := "azurerm_automation_credential.test" ri := acctest.RandInt() - config := testAccAzureRMAutomationCredential_testCredential(ri, testLocation()) + config := testAccAzureRMAutomationCredential_basic(ri, testLocation()) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -22,7 +23,30 @@ func TestAccAzureRMAutomationCredential_testCredential(t *testing.T) { { Config: config, Check: resource.ComposeTestCheckFunc( - testCheckAzureRMAutomationCredentialExistsAndUserName("azurerm_automation_credential.test", "test_user"), + testCheckAzureRMAutomationCredentialExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "username", "test_user"), + ), + }, + }, + }) +} + +func TestAccAzureRMAutomationCredential_complete(t *testing.T) { + resourceName := "azurerm_automation_credential.test" + ri := acctest.RandInt() + config := testAccAzureRMAutomationCredential_complete(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAutomationCredentialDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAutomationCredentialExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "username", "test_user"), + resource.TestCheckResourceAttr(resourceName, "description", "This is a test credential for terraform acceptance test"), ), }, }, @@ -58,7 +82,7 @@ func testCheckAzureRMAutomationCredentialDestroy(s *terraform.State) error { return nil } -func testCheckAzureRMAutomationCredentialExistsAndUserName(name string, username string) resource.TestCheckFunc { +func testCheckAzureRMAutomationCredentialExists(name string) resource.TestCheckFunc { return func(s *terraform.State) error { // Ensure we have enough information in state to look up in API @@ -87,15 +111,37 @@ func testCheckAzureRMAutomationCredentialExistsAndUserName(name string, username return fmt.Errorf("Bad: Get on automationCredentialClient: %s\nName: %s, Account name: %s, Resource group: %s OBJECT: %+v", err, name, accName, resourceGroup, rs.Primary) } - if *resp.UserName != username { - return fmt.Errorf("Current username %s is not consistant with the checked value %s", *resp.UserName, username) - } - return nil } } -func testAccAzureRMAutomationCredential_testCredential(rInt int, location string) string { +func testAccAzureRMAutomationCredential_basic(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_automation_account" "test" { + name = "acctest-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + sku { + name = "Free" + } +} + +resource "azurerm_automation_credential" "test" { + name = "acctest-%d" + resource_group_name = "${azurerm_resource_group.test.name}" + account_name = "${azurerm_automation_account.test.name}" + username = "test_user" + password = "test_pwd" +} +`, rInt, location, rInt, rInt) +} + +func testAccAzureRMAutomationCredential_complete(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { name = "acctestRG-%d" From a540b75941dbb8fd08e61b82ae498377c13413f5 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 12 Sep 2017 14:12:09 +0000 Subject: [PATCH 33/42] Fix runbook import test --- azurerm/import_arm_automation_runbook_test.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/azurerm/import_arm_automation_runbook_test.go b/azurerm/import_arm_automation_runbook_test.go index 71b440ec1325..d4d464948b46 100644 --- a/azurerm/import_arm_automation_runbook_test.go +++ b/azurerm/import_arm_automation_runbook_test.go @@ -20,14 +20,13 @@ func TestAccAzureRMAutomationRunbook_importRunbookPSWorkflow(t *testing.T) { Steps: []resource.TestStep{ { Config: config, - // publish content link is not returned after the runbook is created - ExpectNonEmptyPlan: true, }, { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"publish_content_link"}, }, }, }) From 13a4bdb1ec65f873cc18a623e0f77c2eb3de90ed Mon Sep 17 00:00:00 2001 From: root Date: Tue, 12 Sep 2017 14:24:55 +0000 Subject: [PATCH 34/42] Refactor logic --- azurerm/resource_arm_automation_runbook.go | 23 +++++++++------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/azurerm/resource_arm_automation_runbook.go b/azurerm/resource_arm_automation_runbook.go index dc932059fa4f..6134055e7f2b 100644 --- a/azurerm/resource_arm_automation_runbook.go +++ b/azurerm/resource_arm_automation_runbook.go @@ -229,29 +229,24 @@ func expandContentLink(d *schema.ResourceData) automation.ContentLink { version := input["version"].(string) hashes := input["hash"].([]interface{}) - var contentLink automation.ContentLink - var contentHash automation.ContentHash if len(hashes) > 0 { hash := hashes[0].(map[string]interface{}) hashValue := hash["value"].(string) hashAlgorithm := hash["algorithm"].(string) - contentHash = automation.ContentHash{ - Algorithm: &hashAlgorithm, - Value: &hashValue, - } - contentLink = automation.ContentLink{ - URI: &uri, - Version: &version, - ContentHash: &contentHash, - } - } else { - contentLink = automation.ContentLink{ + return automation.ContentLink{ URI: &uri, Version: &version, + ContentHash: &automation.ContentHash{ + Algorithm: &hashAlgorithm, + Value: &hashValue, + }, } } - return contentLink + return automation.ContentLink{ + URI: &uri, + Version: &version, + } } From 0b5f90a2c5a1d1c46b6146167658f5566a4b356f Mon Sep 17 00:00:00 2001 From: root Date: Tue, 12 Sep 2017 14:32:51 +0000 Subject: [PATCH 35/42] Refactor schedule tests --- azurerm/resource_arm_automation_runbook_test.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/azurerm/resource_arm_automation_runbook_test.go b/azurerm/resource_arm_automation_runbook_test.go index 43821f666311..16efdbd93013 100644 --- a/azurerm/resource_arm_automation_runbook_test.go +++ b/azurerm/resource_arm_automation_runbook_test.go @@ -4,7 +4,6 @@ import ( "fmt" "testing" - "github.com/Azure/azure-sdk-for-go/arm/automation" "github.com/hashicorp/terraform/helper/acctest" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" @@ -12,6 +11,7 @@ import ( ) func TestAccAzureRMAutomationRunbook_PSWorkflow(t *testing.T) { + resourceName := "azurerm_automation_runbook.test" ri := acctest.RandInt() config := testAccAzureRMAutomationRunbook_PSWorkflow(ri, testLocation()) @@ -23,7 +23,8 @@ func TestAccAzureRMAutomationRunbook_PSWorkflow(t *testing.T) { { Config: config, Check: resource.ComposeTestCheckFunc( - testCheckAzureRMAutomationRunbookExistsAndType("azurerm_automation_runbook.test", automation.PowerShellWorkflow), + testCheckAzureRMAutomationRunbookExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "runbook_type", "PowerShellWorkflow"), ), }, }, @@ -31,6 +32,7 @@ func TestAccAzureRMAutomationRunbook_PSWorkflow(t *testing.T) { } func TestAccAzureRMAutomationRunbook_PSWorkflowWithHash(t *testing.T) { + resourceName := "azurerm_automation_runbook.test" ri := acctest.RandInt() config := testAccAzureRMAutomationRunbook_PSWorkflowWithHash(ri, testLocation()) @@ -42,7 +44,8 @@ func TestAccAzureRMAutomationRunbook_PSWorkflowWithHash(t *testing.T) { { Config: config, Check: resource.ComposeTestCheckFunc( - testCheckAzureRMAutomationRunbookExistsAndType("azurerm_automation_runbook.test", automation.PowerShellWorkflow), + testCheckAzureRMAutomationRunbookExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "runbook_type", "PowerShellWorkflow"), ), }, }, @@ -77,7 +80,7 @@ func testCheckAzureRMAutomationRunbookDestroy(s *terraform.State) error { return nil } -func testCheckAzureRMAutomationRunbookExistsAndType(name string, runbookType automation.RunbookTypeEnum) resource.TestCheckFunc { +func testCheckAzureRMAutomationRunbookExists(name string) resource.TestCheckFunc { return func(s *terraform.State) error { // Ensure we have enough information in state to look up in API @@ -106,10 +109,6 @@ func testCheckAzureRMAutomationRunbookExistsAndType(name string, runbookType aut return fmt.Errorf("Bad: Get on automationRunbookClient: %+v", err) } - if resp.RunbookType != runbookType { - return fmt.Errorf("Current runbook type %s is not consistent with the checked value %s", resp.RunbookType, runbookType) - } - return nil } } From 816e8562d4c2f6c0578047c1346ee1d558bf4ce8 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 18 Sep 2017 07:29:20 +0000 Subject: [PATCH 36/42] Add diff function for start_time --- azurerm/import_arm_automation_schedule_test.go | 2 -- azurerm/resource_arm_automation_schedule.go | 17 ++++++++++++++--- .../resource_arm_automation_schedule_test.go | 1 + 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/azurerm/import_arm_automation_schedule_test.go b/azurerm/import_arm_automation_schedule_test.go index 67854b83dc05..e814c09b5cef 100644 --- a/azurerm/import_arm_automation_schedule_test.go +++ b/azurerm/import_arm_automation_schedule_test.go @@ -20,8 +20,6 @@ func TestAccAzureRMAutomationSchedule_importScheduleOneTime(t *testing.T) { Steps: []resource.TestStep{ { Config: config, - // publish content link is not returned after the runbook is created - ExpectNonEmptyPlan: true, }, { diff --git a/azurerm/resource_arm_automation_schedule.go b/azurerm/resource_arm_automation_schedule.go index dda31cbf2b20..5bd08a8c410c 100644 --- a/azurerm/resource_arm_automation_schedule.go +++ b/azurerm/resource_arm_automation_schedule.go @@ -47,9 +47,10 @@ func resourceArmAutomationSchedule() *schema.Resource { ForceNew: true, }, "start_time": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validateStartTime, + Type: schema.TypeString, + Required: true, + DiffSuppressFunc: compareDataAsUTCSuppressFunc, + ValidateFunc: validateStartTime, }, "expiry_time": { @@ -79,6 +80,16 @@ func resourceArmAutomationSchedule() *schema.Resource { } } +func compareDataAsUTCSuppressFunc(k, old, new string, d *schema.ResourceData) bool { + ot, oerr := time.Parse(time.RFC3339, old) + nt, nerr := time.Parse(time.RFC3339, new) + if oerr != nil || nerr != nil { + return false + } + + return nt.Equal(ot) +} + func validateStartTime(v interface{}, k string) (ws []string, errors []error) { starttime, tperr := time.Parse(time.RFC3339, v.(string)) if tperr != nil { diff --git a/azurerm/resource_arm_automation_schedule_test.go b/azurerm/resource_arm_automation_schedule_test.go index 4cae22711b6a..26db79af8f36 100644 --- a/azurerm/resource_arm_automation_schedule_test.go +++ b/azurerm/resource_arm_automation_schedule_test.go @@ -97,6 +97,7 @@ func testCheckAzureRMAutomationScheduleExistsAndFrequencyType(name string, freq func testAccAzureRMAutomationSchedule_oneTime(rInt int, location string) string { startTime := time.Now().UTC().Add(time.Duration(7) * time.Minute) + startTime = startTime.Add(time.Duration(-1 * startTime.Second()) * time.Second) return fmt.Sprintf(` resource "azurerm_resource_group" "test" { From 5cdc5d9e171d9d243c899a2fe82785659fffcb88 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 18 Sep 2017 07:51:21 +0000 Subject: [PATCH 37/42] Remove ExpectNonEmptyPlan --- azurerm/resource_arm_automation_schedule_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/azurerm/resource_arm_automation_schedule_test.go b/azurerm/resource_arm_automation_schedule_test.go index 26db79af8f36..86f36f13217d 100644 --- a/azurerm/resource_arm_automation_schedule_test.go +++ b/azurerm/resource_arm_automation_schedule_test.go @@ -26,7 +26,6 @@ func TestAccAzureRMAutomationSchedule_oneTime(t *testing.T) { Check: resource.ComposeTestCheckFunc( testCheckAzureRMAutomationScheduleExistsAndFrequencyType("azurerm_automation_schedule.test", automation.OneTime), ), - ExpectNonEmptyPlan: true, }, }, }) From 2fe3b6685406bb07a9284d9ef6b4fb8141d54de3 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 18 Sep 2017 07:59:58 +0000 Subject: [PATCH 38/42] Add DiffSuppressFunc, formatting --- azurerm/resource_arm_automation_schedule.go | 7 ++++--- azurerm/resource_arm_automation_schedule_test.go | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/azurerm/resource_arm_automation_schedule.go b/azurerm/resource_arm_automation_schedule.go index 5bd08a8c410c..6d74ba612118 100644 --- a/azurerm/resource_arm_automation_schedule.go +++ b/azurerm/resource_arm_automation_schedule.go @@ -54,9 +54,10 @@ func resourceArmAutomationSchedule() *schema.Resource { }, "expiry_time": { - Type: schema.TypeString, - Optional: true, - Computed: true, + Type: schema.TypeString, + DiffSuppressFunc: compareDataAsUTCSuppressFunc, + Optional: true, + Computed: true, }, "frequency": { diff --git a/azurerm/resource_arm_automation_schedule_test.go b/azurerm/resource_arm_automation_schedule_test.go index 86f36f13217d..c93804d36d5d 100644 --- a/azurerm/resource_arm_automation_schedule_test.go +++ b/azurerm/resource_arm_automation_schedule_test.go @@ -96,7 +96,7 @@ func testCheckAzureRMAutomationScheduleExistsAndFrequencyType(name string, freq func testAccAzureRMAutomationSchedule_oneTime(rInt int, location string) string { startTime := time.Now().UTC().Add(time.Duration(7) * time.Minute) - startTime = startTime.Add(time.Duration(-1 * startTime.Second()) * time.Second) + startTime = startTime.Add(time.Duration(-1*startTime.Second()) * time.Second) return fmt.Sprintf(` resource "azurerm_resource_group" "test" { From 69b00d65ef8eaeb0aa7145fc861b8985a874d164 Mon Sep 17 00:00:00 2001 From: Tom Harvey Date: Wed, 20 Sep 2017 09:28:23 +0100 Subject: [PATCH 39/42] Fixing the broken build (caused by a bad rebase) Also swapping the re-initialisation of `sender` to use the shared variable --- azurerm/config.go | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/azurerm/config.go b/azurerm/config.go index 6792d39bb273..d91ec8185301 100644 --- a/azurerm/config.go +++ b/azurerm/config.go @@ -667,33 +667,27 @@ func (c *Config) getArmClient() (*ArmClient, error) { aadb := automation.NewAccountClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&aadb.Client) aadb.Authorizer = auth - aadb.Sender = autorest.CreateSender(withRequestLogging()) + aadb.Sender = sender client.automationAccountClient = aadb arc := automation.NewRunbookClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&arc.Client) arc.Authorizer = auth - arc.Sender = autorest.CreateSender(withRequestLogging()) + arc.Sender = sender client.automationRunbookClient = arc acc := automation.NewCredentialClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&acc.Client) acc.Authorizer = auth - acc.Sender = autorest.CreateSender(withRequestLogging()) + acc.Sender = sender client.automationCredentialClient = acc aschc := automation.NewScheduleClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&aschc.Client) aschc.Authorizer = auth - aschc.Sender = autorest.CreateSender(withRequestLogging()) + aschc.Sender = sender client.automationScheduleClient = aschc - ac := web.NewAppsClientWithBaseURI(endpoint, c.SubscriptionID) - setUserAgent(&ac.Client) - ac.Authorizer = auth - ac.Sender = autorest.CreateSender(withRequestLogging()) - client.appsClient = ac - kvc := keyvault.NewVaultsClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&kvc.Client) kvc.Authorizer = auth From 231c7cc0bbf13b37498317b00b77de2344b01109 Mon Sep 17 00:00:00 2001 From: Tom Harvey Date: Wed, 20 Sep 2017 09:30:38 +0100 Subject: [PATCH 40/42] Vendoring the Azure Automation SDK --- vendor/vendor.json | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/vendor/vendor.json b/vendor/vendor.json index 7f30c84b936a..d20068941f81 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -10,6 +10,14 @@ "version": "=v10.3.0-beta", "versionExact": "v10.3.0-beta" }, + { + "checksumSHA1": "kDu+bApbVn1n9OGBoBJT8p6YZGc=" + "path": "github.com/Azure/azure-sdk-for-go/arm/automation", + "revision": "57db66900881e9fd21fd041a9d013514700ecab3", + "revisionTime": "2017-08-18T20:19:01Z", + "version": "=v10.3.0-beta", + "versionExact": "v10.3.0-beta" + }, { "checksumSHA1": "1K/j9mahBUFLBfRPhEHxQ5Pjx/M=", "path": "github.com/Azure/azure-sdk-for-go/arm/cdn", From d830bca8d536d61dc51cf4f157ba8a96f44e5853 Mon Sep 17 00:00:00 2001 From: Tom Harvey Date: Wed, 20 Sep 2017 09:31:02 +0100 Subject: [PATCH 41/42] Vendoring (plus comma) --- vendor/vendor.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/vendor.json b/vendor/vendor.json index d20068941f81..6ada02111892 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -11,7 +11,7 @@ "versionExact": "v10.3.0-beta" }, { - "checksumSHA1": "kDu+bApbVn1n9OGBoBJT8p6YZGc=" + "checksumSHA1": "kDu+bApbVn1n9OGBoBJT8p6YZGc=", "path": "github.com/Azure/azure-sdk-for-go/arm/automation", "revision": "57db66900881e9fd21fd041a9d013514700ecab3", "revisionTime": "2017-08-18T20:19:01Z", From 17a304ceffba359c1ccd8197f7722207223d11cf Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Wed, 20 Sep 2017 09:35:38 +0100 Subject: [PATCH 42/42] Upgrading to SDK 10.3 --- .../Azure/azure-sdk-for-go/arm/automation/version.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/version.go index 2ae93d27a8fc..efa3e6c245c3 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/version.go @@ -14,15 +14,15 @@ package automation // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.2.2.0 // Changes may cause incorrect behavior and will be lost if the code is regenerated. // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.2.0-beta arm-automation/" + return "Azure-SDK-For-Go/v10.3.0-beta arm-automation/2015-10-31" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.2.0-beta" + return "v10.3.0-beta" }