diff --git a/CHANGELOG.md b/CHANGELOG.md index b68b0f128c65..107d07ab427d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,16 +1,51 @@ -## 0.1.7 (Unreleased) +## 0.2.2 (Unreleased) +## 0.2.1 (September 25, 2017) FEATURES: -* **New Resource:** `azurerm_postgresql_configuration` [GH-210] -* **New Resource:** `azurerm_postgresql_database` [GH-210] -* **New Resource:** `azurerm_postgresql_firewall_rule` [GH-210] -* **New Resource:** `azurerm_postgresql_server` [GH-210] +* **New Resource:** `azurerm_automation_account` ([#257](https://github.com/terraform-providers/terraform-provider-azurerm/issues/257)) +* **New Resource:** `azurerm_automation_credential` ([#257](https://github.com/terraform-providers/terraform-provider-azurerm/issues/257)) +* **New Resource:** `azurerm_automation_runbook` ([#257](https://github.com/terraform-providers/terraform-provider-azurerm/issues/257)) +* **New Resource:** `azurerm_automation_schedule` ([#257](https://github.com/terraform-providers/terraform-provider-azurerm/issues/257)) +* **New Resource:** `azurerm_app_service` ([#344](https://github.com/terraform-providers/terraform-provider-azurerm/issues/344)) IMPROVEMENTS: -* `azurerm_cdn_endpoint` - defaulting the `http_port` and `https_port` [GH-301] -* `azurerm_cosmos_db_account`: allow setting the Kind to MongoDB/GlobalDocumentDB [GH-299] +* `azurerm_client_config` - adding `service_principal_application_id` ([#348](https://github.com/terraform-providers/terraform-provider-azurerm/issues/348)) +* `azurerm_key_vault` - adding `application_id` and `certificate_permissions` ([#348](https://github.com/terraform-providers/terraform-provider-azurerm/issues/348)) + +BUG FIXES: + +* `azurerm_virtual_machine_scale_set` - fix panic with `additional_unattend_config` block ([#266](https://github.com/terraform-providers/terraform-provider-azurerm/issues/266)) + +## 0.2.0 (September 15, 2017) + +FEATURES: + +* **Support for authenticating using the Azure CLI** ([#316](https://github.com/terraform-providers/terraform-provider-azurerm/issues/316)) +* **New Resource:** `azurerm_container_group` ([#333](https://github.com/terraform-providers/terraform-provider-azurerm/issues/333)] [[#311](https://github.com/terraform-providers/terraform-provider-azurerm/issues/311)] [[#338](https://github.com/terraform-providers/terraform-provider-azurerm/issues/338)) + +IMPROVEMENTS: + +* `azurerm_app_service_plan` - support for Linux App Service Plans ([#332](https://github.com/terraform-providers/terraform-provider-azurerm/issues/332)) +* `azurerm_postgresql_server` - supporting additional storage sizes ([#239](https://github.com/terraform-providers/terraform-provider-azurerm/issues/239)) +* `azurerm_public_ip` - verifying the ID is valid before importing ([#320](https://github.com/terraform-providers/terraform-provider-azurerm/issues/320)) +* `azurerm_sql_server` - verifying the name is valid before creating ([#323](https://github.com/terraform-providers/terraform-provider-azurerm/issues/323)) +* `resource_group_name` - validation has been added to all resources that use this attribute ([#330](https://github.com/terraform-providers/terraform-provider-azurerm/issues/330)) + +## 0.1.7 (September 11, 2017) + +FEATURES: + +* **New Resource:** `azurerm_postgresql_configuration` ([#210](https://github.com/terraform-providers/terraform-provider-azurerm/issues/210)) +* **New Resource:** `azurerm_postgresql_database` ([#210](https://github.com/terraform-providers/terraform-provider-azurerm/issues/210)) +* **New Resource:** `azurerm_postgresql_firewall_rule` ([#210](https://github.com/terraform-providers/terraform-provider-azurerm/issues/210)) +* **New Resource:** `azurerm_postgresql_server` ([#210](https://github.com/terraform-providers/terraform-provider-azurerm/issues/210)) + +IMPROVEMENTS: + +* `azurerm_cdn_endpoint` - defaulting the `http_port` and `https_port` ([#301](https://github.com/terraform-providers/terraform-provider-azurerm/issues/301)) +* `azurerm_cosmos_db_account`: allow setting the Kind to MongoDB/GlobalDocumentDB ([#299](https://github.com/terraform-providers/terraform-provider-azurerm/issues/299)) ## 0.1.6 (August 31, 2017) diff --git a/azurerm/config.go b/azurerm/config.go index 7620559630d6..d91ec8185301 100644 --- a/azurerm/config.go +++ b/azurerm/config.go @@ -8,8 +8,10 @@ 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/containerinstance" "github.com/Azure/azure-sdk-for-go/arm/containerregistry" "github.com/Azure/azure-sdk-for-go/arm/containerservice" "github.com/Azure/azure-sdk-for-go/arm/cosmos-db" @@ -58,8 +60,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 @@ -85,6 +91,7 @@ type ArmClient struct { containerRegistryClient containerregistry.RegistriesClient containerServicesClient containerservice.ContainerServicesClient + containerGroupsClient containerinstance.ContainerGroupsClient eventGridTopicsClient eventgrid.TopicsClient eventHubClient eventhub.EventHubsClient @@ -131,12 +138,11 @@ type ArmClient struct { sqlServersClient sql.ServersClient appServicePlansClient web.AppServicePlansClient + appServicesClient web.AppsClient appInsightsClient appinsights.ComponentsClient servicePrincipalsClient graphrbac.ServicePrincipalsClient - - appsClient web.AppsClient } func withRequestLogging() autorest.SendDecorator { @@ -172,6 +178,36 @@ func setUserAgent(client *autorest.Client) { client.UserAgent = fmt.Sprintf("HashiCorp-Terraform-v%s", version) } +func (c *Config) getAuthorizationToken(oauthConfig *adal.OAuthConfig, endpoint string) (*autorest.BearerAuthorizer, error) { + useServicePrincipal := c.ClientSecret != "" + + if useServicePrincipal { + spt, err := adal.NewServicePrincipalToken(*oauthConfig, c.ClientID, c.ClientSecret, endpoint) + if err != nil { + return nil, err + } + + auth := autorest.NewBearerAuthorizer(spt) + return auth, nil + } + + if c.IsCloudShell { + // load the refreshed tokens from the Azure CLI + err := c.LoadTokensFromAzureCLI() + if err != nil { + return nil, fmt.Errorf("Error loading the refreshed CloudShell tokens: %+v", err) + } + } + + spt, err := adal.NewServicePrincipalTokenFromManualToken(*oauthConfig, c.ClientID, endpoint, *c.AccessToken) + if err != nil { + return nil, err + } + + auth := autorest.NewBearerAuthorizer(spt) + return auth, nil +} + // getArmClient is a helper method which returns a fully instantiated // *ArmClient based on the Config's current settings. func (c *Config) getArmClient() (*ArmClient, error) { @@ -204,31 +240,30 @@ func (c *Config) getArmClient() (*ArmClient, error) { return nil, fmt.Errorf("Unable to configure OAuthConfig for tenant %s", c.TenantID) } + sender := autorest.CreateSender(withRequestLogging()) + // Resource Manager endpoints endpoint := env.ResourceManagerEndpoint - spt, err := adal.NewServicePrincipalToken(*oauthConfig, c.ClientID, c.ClientSecret, endpoint) + auth, err := c.getAuthorizationToken(oauthConfig, endpoint) if err != nil { return nil, err } - auth := autorest.NewBearerAuthorizer(spt) // Graph Endpoints graphEndpoint := env.GraphEndpoint - graphSpt, err := adal.NewServicePrincipalToken(*oauthConfig, c.ClientID, c.ClientSecret, graphEndpoint) + graphAuth, err := c.getAuthorizationToken(oauthConfig, graphEndpoint) if err != nil { return nil, err } - graphAuth := autorest.NewBearerAuthorizer(graphSpt) // Key Vault Endpoints - sender := autorest.CreateSender(withRequestLogging()) keyVaultAuth := autorest.NewBearerAuthorizerCallback(sender, func(tenantID, resource string) (*autorest.BearerAuthorizer, error) { - keyVaultSpt, err := adal.NewServicePrincipalToken(*oauthConfig, c.ClientID, c.ClientSecret, resource) + keyVaultSpt, err := c.getAuthorizationToken(oauthConfig, resource) if err != nil { return nil, err } - return autorest.NewBearerAuthorizer(keyVaultSpt), nil + return keyVaultSpt, nil }) // NOTE: these declarations should be left separate for clarity should the @@ -236,175 +271,181 @@ func (c *Config) getArmClient() (*ArmClient, error) { asc := compute.NewAvailabilitySetsClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&asc.Client) asc.Authorizer = auth - asc.Sender = autorest.CreateSender(withRequestLogging()) + asc.Sender = sender client.availSetClient = asc uoc := compute.NewUsageClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&uoc.Client) uoc.Authorizer = auth - uoc.Sender = autorest.CreateSender(withRequestLogging()) + uoc.Sender = sender client.usageOpsClient = uoc vmeic := compute.NewVirtualMachineExtensionImagesClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&vmeic.Client) vmeic.Authorizer = auth - vmeic.Sender = autorest.CreateSender(withRequestLogging()) + vmeic.Sender = sender client.vmExtensionImageClient = vmeic vmec := compute.NewVirtualMachineExtensionsClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&vmec.Client) vmec.Authorizer = auth - vmec.Sender = autorest.CreateSender(withRequestLogging()) + vmec.Sender = sender client.vmExtensionClient = vmec vmic := compute.NewVirtualMachineImagesClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&vmic.Client) vmic.Authorizer = auth - vmic.Sender = autorest.CreateSender(withRequestLogging()) + vmic.Sender = sender client.vmImageClient = vmic vmssc := compute.NewVirtualMachineScaleSetsClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&vmssc.Client) vmssc.Authorizer = auth - vmssc.Sender = autorest.CreateSender(withRequestLogging()) + vmssc.Sender = sender client.vmScaleSetClient = vmssc vmc := compute.NewVirtualMachinesClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&vmc.Client) vmc.Authorizer = auth - vmc.Sender = autorest.CreateSender(withRequestLogging()) + vmc.Sender = sender client.vmClient = vmc agc := network.NewApplicationGatewaysClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&agc.Client) agc.Authorizer = auth - agc.Sender = autorest.CreateSender(withRequestLogging()) + agc.Sender = sender client.appGatewayClient = agc crc := containerregistry.NewRegistriesClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&crc.Client) crc.Authorizer = auth - crc.Sender = autorest.CreateSender(withRequestLogging()) + crc.Sender = sender client.containerRegistryClient = crc csc := containerservice.NewContainerServicesClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&csc.Client) csc.Authorizer = auth - csc.Sender = autorest.CreateSender(withRequestLogging()) + csc.Sender = sender client.containerServicesClient = csc + cgc := containerinstance.NewContainerGroupsClientWithBaseURI(endpoint, c.SubscriptionID) + setUserAgent(&cgc.Client) + cgc.Authorizer = auth + cgc.Sender = autorest.CreateSender(withRequestLogging()) + client.containerGroupsClient = cgc + cdb := cosmosdb.NewDatabaseAccountsClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&cdb.Client) cdb.Authorizer = auth - cdb.Sender = autorest.CreateSender(withRequestLogging()) + cdb.Sender = sender client.cosmosDBClient = cdb dkc := disk.NewDisksClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&dkc.Client) dkc.Authorizer = auth - dkc.Sender = autorest.CreateSender(withRequestLogging()) + dkc.Sender = sender client.diskClient = dkc img := compute.NewImagesClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&img.Client) img.Authorizer = auth - img.Sender = autorest.CreateSender(withRequestLogging()) + img.Sender = sender client.imageClient = img egtc := eventgrid.NewTopicsClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&egtc.Client) egtc.Authorizer = auth - egtc.Sender = autorest.CreateSender(withRequestLogging()) + egtc.Sender = sender client.eventGridTopicsClient = egtc ehc := eventhub.NewEventHubsClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&ehc.Client) ehc.Authorizer = auth - ehc.Sender = autorest.CreateSender(withRequestLogging()) + ehc.Sender = sender client.eventHubClient = ehc chcgc := eventhub.NewConsumerGroupsClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&chcgc.Client) chcgc.Authorizer = auth - chcgc.Sender = autorest.CreateSender(withRequestLogging()) + chcgc.Sender = sender client.eventHubConsumerGroupClient = chcgc ehnc := eventhub.NewNamespacesClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&ehnc.Client) ehnc.Authorizer = auth - ehnc.Sender = autorest.CreateSender(withRequestLogging()) + ehnc.Sender = sender client.eventHubNamespacesClient = ehnc ifc := network.NewInterfacesClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&ifc.Client) ifc.Authorizer = auth - ifc.Sender = autorest.CreateSender(withRequestLogging()) + ifc.Sender = sender client.ifaceClient = ifc erc := network.NewExpressRouteCircuitsClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&erc.Client) erc.Authorizer = auth - erc.Sender = autorest.CreateSender(withRequestLogging()) + erc.Sender = sender client.expressRouteCircuitClient = erc lbc := network.NewLoadBalancersClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&lbc.Client) lbc.Authorizer = auth - lbc.Sender = autorest.CreateSender(withRequestLogging()) + lbc.Sender = sender client.loadBalancerClient = lbc lgc := network.NewLocalNetworkGatewaysClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&lgc.Client) lgc.Authorizer = auth - lgc.Sender = autorest.CreateSender(withRequestLogging()) + lgc.Sender = sender client.localNetConnClient = lgc pipc := network.NewPublicIPAddressesClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&pipc.Client) pipc.Authorizer = auth - pipc.Sender = autorest.CreateSender(withRequestLogging()) + pipc.Sender = sender client.publicIPClient = pipc sgc := network.NewSecurityGroupsClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&sgc.Client) sgc.Authorizer = auth - sgc.Sender = autorest.CreateSender(withRequestLogging()) + sgc.Sender = sender client.secGroupClient = sgc src := network.NewSecurityRulesClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&src.Client) src.Authorizer = auth - src.Sender = autorest.CreateSender(withRequestLogging()) + src.Sender = sender client.secRuleClient = src snc := network.NewSubnetsClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&snc.Client) snc.Authorizer = auth - snc.Sender = autorest.CreateSender(withRequestLogging()) + snc.Sender = sender client.subnetClient = snc vgcc := network.NewVirtualNetworkGatewayConnectionsClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&vgcc.Client) vgcc.Authorizer = auth - vgcc.Sender = autorest.CreateSender(withRequestLogging()) + vgcc.Sender = sender client.vnetGatewayConnectionsClient = vgcc vgc := network.NewVirtualNetworkGatewaysClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&vgc.Client) vgc.Authorizer = auth - vgc.Sender = autorest.CreateSender(withRequestLogging()) + vgc.Sender = sender client.vnetGatewayClient = vgc vnc := network.NewVirtualNetworksClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&vnc.Client) vnc.Authorizer = auth - vnc.Sender = autorest.CreateSender(withRequestLogging()) + vnc.Sender = sender client.vnetClient = vnc vnpc := network.NewVirtualNetworkPeeringsClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&vnpc.Client) vnpc.Authorizer = auth - vnpc.Sender = autorest.CreateSender(withRequestLogging()) + vnpc.Sender = sender client.vnetPeeringsClient = vnpc pcc := postgresql.NewConfigurationsClientWithBaseURI(endpoint, c.SubscriptionID) @@ -434,199 +475,223 @@ func (c *Config) getArmClient() (*ArmClient, error) { rtc := network.NewRouteTablesClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&rtc.Client) rtc.Authorizer = auth - rtc.Sender = autorest.CreateSender(withRequestLogging()) + rtc.Sender = sender client.routeTablesClient = rtc rc := network.NewRoutesClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&rc.Client) rc.Authorizer = auth - rc.Sender = autorest.CreateSender(withRequestLogging()) + rc.Sender = sender client.routesClient = rc dn := dns.NewRecordSetsClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&dn.Client) dn.Authorizer = auth - dn.Sender = autorest.CreateSender(withRequestLogging()) + dn.Sender = sender client.dnsClient = dn zo := dns.NewZonesClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&zo.Client) zo.Authorizer = auth - zo.Sender = autorest.CreateSender(withRequestLogging()) + zo.Sender = sender client.zonesClient = zo rgc := resources.NewGroupsClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&rgc.Client) rgc.Authorizer = auth - rgc.Sender = autorest.CreateSender(withRequestLogging()) + rgc.Sender = sender client.resourceGroupClient = rgc pc := resources.NewProvidersClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&pc.Client) pc.Authorizer = auth - pc.Sender = autorest.CreateSender(withRequestLogging()) + pc.Sender = sender client.providers = pc tc := resources.NewTagsClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&tc.Client) tc.Authorizer = auth - tc.Sender = autorest.CreateSender(withRequestLogging()) + tc.Sender = sender client.tagsClient = tc rf := resources.NewGroupClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&rf.Client) rf.Authorizer = auth - rf.Sender = autorest.CreateSender(withRequestLogging()) + rf.Sender = sender client.resourceFindClient = rf subgc := subscriptions.NewGroupClientWithBaseURI(endpoint) setUserAgent(&subgc.Client) subgc.Authorizer = auth - subgc.Sender = autorest.CreateSender(withRequestLogging()) + subgc.Sender = sender client.subscriptionsGroupClient = subgc jc := scheduler.NewJobsClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&jc.Client) jc.Authorizer = auth - jc.Sender = autorest.CreateSender(withRequestLogging()) + jc.Sender = sender client.jobsClient = jc jcc := scheduler.NewJobCollectionsClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&jcc.Client) jcc.Authorizer = auth - jcc.Sender = autorest.CreateSender(withRequestLogging()) + jcc.Sender = sender client.jobsCollectionsClient = jcc ssc := storage.NewAccountsClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&ssc.Client) ssc.Authorizer = auth - ssc.Sender = autorest.CreateSender(withRequestLogging()) + ssc.Sender = sender client.storageServiceClient = ssc suc := storage.NewUsageClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&suc.Client) suc.Authorizer = auth - suc.Sender = autorest.CreateSender(withRequestLogging()) + suc.Sender = sender client.storageUsageClient = suc cpc := cdn.NewProfilesClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&cpc.Client) cpc.Authorizer = auth - cpc.Sender = autorest.CreateSender(withRequestLogging()) + cpc.Sender = sender client.cdnProfilesClient = cpc cec := cdn.NewEndpointsClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&cec.Client) cec.Authorizer = auth - cec.Sender = autorest.CreateSender(withRequestLogging()) + cec.Sender = sender client.cdnEndpointsClient = cec dc := resources.NewDeploymentsClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&dc.Client) dc.Authorizer = auth - dc.Sender = autorest.CreateSender(withRequestLogging()) + dc.Sender = sender client.deploymentsClient = dc tmpc := trafficmanager.NewProfilesClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&tmpc.Client) tmpc.Authorizer = auth - tmpc.Sender = autorest.CreateSender(withRequestLogging()) + tmpc.Sender = sender client.trafficManagerProfilesClient = tmpc tmec := trafficmanager.NewEndpointsClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&tmec.Client) tmec.Authorizer = auth - tmec.Sender = autorest.CreateSender(withRequestLogging()) + tmec.Sender = sender client.trafficManagerEndpointsClient = tmec rdc := redis.NewGroupClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&rdc.Client) rdc.Authorizer = auth - rdc.Sender = autorest.CreateSender(withRequestLogging()) + rdc.Sender = sender client.redisClient = rdc sesc := search.NewServicesClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&sesc.Client) sesc.Authorizer = auth - sesc.Sender = autorest.CreateSender(withRequestLogging()) + sesc.Sender = sender client.searchServicesClient = sesc sbnc := servicebus.NewNamespacesClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&sbnc.Client) sbnc.Authorizer = auth - sbnc.Sender = autorest.CreateSender(withRequestLogging()) + sbnc.Sender = sender client.serviceBusNamespacesClient = sbnc sbqc := servicebus.NewQueuesClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&sbqc.Client) sbqc.Authorizer = auth - sbqc.Sender = autorest.CreateSender(withRequestLogging()) + sbqc.Sender = sender client.serviceBusQueuesClient = sbqc sbtc := servicebus.NewTopicsClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&sbtc.Client) sbtc.Authorizer = auth - sbtc.Sender = autorest.CreateSender(withRequestLogging()) + sbtc.Sender = sender client.serviceBusTopicsClient = sbtc sbsc := servicebus.NewSubscriptionsClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&sbsc.Client) sbsc.Authorizer = auth - sbsc.Sender = autorest.CreateSender(withRequestLogging()) + sbsc.Sender = sender client.serviceBusSubscriptionsClient = sbsc sqldc := sql.NewDatabasesClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&sqldc.Client) sqldc.Authorizer = auth - sqldc.Sender = autorest.CreateSender(withRequestLogging()) + sqldc.Sender = sender client.sqlDatabasesClient = sqldc sqlfrc := sql.NewFirewallRulesClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&sqlfrc.Client) sqlfrc.Authorizer = auth - sqlfrc.Sender = autorest.CreateSender(withRequestLogging()) + sqlfrc.Sender = sender client.sqlFirewallRulesClient = sqlfrc sqlepc := sql.NewElasticPoolsClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&sqlepc.Client) sqlepc.Authorizer = auth - sqlepc.Sender = autorest.CreateSender(withRequestLogging()) + sqlepc.Sender = sender client.sqlElasticPoolsClient = sqlepc sqlsrv := sql.NewServersClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&sqlsrv.Client) sqlsrv.Authorizer = auth - sqlsrv.Sender = autorest.CreateSender(withRequestLogging()) + sqlsrv.Sender = sender client.sqlServersClient = sqlsrv aspc := web.NewAppServicePlansClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&aspc.Client) aspc.Authorizer = auth - aspc.Sender = autorest.CreateSender(withRequestLogging()) + aspc.Sender = sender client.appServicePlansClient = aspc + ac := web.NewAppsClientWithBaseURI(endpoint, c.SubscriptionID) + setUserAgent(&ac.Client) + ac.Authorizer = auth + ac.Sender = autorest.CreateSender(withRequestLogging()) + client.appServicesClient = ac + ai := appinsights.NewComponentsClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&ai.Client) ai.Authorizer = auth - ai.Sender = autorest.CreateSender(withRequestLogging()) + ai.Sender = sender client.appInsightsClient = ai spc := graphrbac.NewServicePrincipalsClientWithBaseURI(graphEndpoint, c.TenantID) setUserAgent(&spc.Client) spc.Authorizer = graphAuth - spc.Sender = autorest.CreateSender(withRequestLogging()) + spc.Sender = sender client.servicePrincipalsClient = spc - ac := web.NewAppsClientWithBaseURI(endpoint, c.SubscriptionID) - setUserAgent(&ac.Client) - ac.Authorizer = auth - ac.Sender = autorest.CreateSender(withRequestLogging()) - client.appsClient = ac + aadb := automation.NewAccountClientWithBaseURI(endpoint, c.SubscriptionID) + setUserAgent(&aadb.Client) + aadb.Authorizer = auth + aadb.Sender = sender + client.automationAccountClient = aadb + + arc := automation.NewRunbookClientWithBaseURI(endpoint, c.SubscriptionID) + setUserAgent(&arc.Client) + arc.Authorizer = auth + arc.Sender = sender + client.automationRunbookClient = arc + + acc := automation.NewCredentialClientWithBaseURI(endpoint, c.SubscriptionID) + setUserAgent(&acc.Client) + acc.Authorizer = auth + acc.Sender = sender + client.automationCredentialClient = acc + + aschc := automation.NewScheduleClientWithBaseURI(endpoint, c.SubscriptionID) + setUserAgent(&aschc.Client) + aschc.Authorizer = auth + aschc.Sender = sender + client.automationScheduleClient = aschc kvc := keyvault.NewVaultsClientWithBaseURI(endpoint, c.SubscriptionID) setUserAgent(&kvc.Client) kvc.Authorizer = auth - kvc.Sender = autorest.CreateSender(withRequestLogging()) + kvc.Sender = sender client.keyVaultClient = kvc kvmc := keyVault.New() diff --git a/azurerm/data_source_arm_client_config.go b/azurerm/data_source_arm_client_config.go index fec87c98edb2..d60205b4d466 100644 --- a/azurerm/data_source_arm_client_config.go +++ b/azurerm/data_source_arm_client_config.go @@ -24,6 +24,10 @@ func dataSourceArmClientConfig() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "service_principal_application_id": { + Type: schema.TypeString, + Computed: true, + }, "service_principal_object_id": { Type: schema.TypeString, Computed: true, @@ -54,6 +58,7 @@ func dataSourceArmClientConfigRead(d *schema.ResourceData, meta interface{}) err d.Set("client_id", client.clientId) d.Set("tenant_id", client.tenantId) d.Set("subscription_id", client.subscriptionId) + d.Set("service_principal_application_id", *servicePrincipal.AppID) d.Set("service_principal_object_id", *servicePrincipal.ObjectID) return nil diff --git a/azurerm/data_source_arm_client_config_test.go b/azurerm/data_source_arm_client_config_test.go index b92cb96b5cfe..80a17219874a 100644 --- a/azurerm/data_source_arm_client_config_test.go +++ b/azurerm/data_source_arm_client_config_test.go @@ -25,6 +25,7 @@ func TestAccDataSourceAzureRMClientConfig_basic(t *testing.T) { testAzureRMClientConfigAttr(dataSourceName, "client_id", clientId), testAzureRMClientConfigAttr(dataSourceName, "tenant_id", tenantId), testAzureRMClientConfigAttr(dataSourceName, "subscription_id", subscriptionId), + testAzureRMClientConfigGUIDAttr(dataSourceName, "service_principal_application_id"), testAzureRMClientConfigGUIDAttr(dataSourceName, "service_principal_object_id"), ), }, diff --git a/azurerm/data_source_arm_public_ip.go b/azurerm/data_source_arm_public_ip.go index bc71f9c488d7..a156c9e42d16 100644 --- a/azurerm/data_source_arm_public_ip.go +++ b/azurerm/data_source_arm_public_ip.go @@ -16,10 +16,7 @@ func dataSourceArmPublicIP() *schema.Resource { Required: true, }, - "resource_group_name": { - Type: schema.TypeString, - Required: true, - }, + "resource_group_name": resourceGroupNameForDataSourceSchema(), "domain_name_label": { Type: schema.TypeString, diff --git a/azurerm/data_source_arm_resource_group.go b/azurerm/data_source_arm_resource_group.go index bb46eb979755..ea410923a418 100644 --- a/azurerm/data_source_arm_resource_group.go +++ b/azurerm/data_source_arm_resource_group.go @@ -9,11 +9,7 @@ func dataSourceArmResourceGroup() *schema.Resource { Read: dataSourceArmResourceGroupRead, Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Required: true, - }, - + "name": resourceGroupNameForDataSourceSchema(), "location": locationForDataSourceSchema(), "tags": tagsForDataSourceSchema(), }, diff --git a/azurerm/data_source_managed_disk.go b/azurerm/data_source_managed_disk.go index 3034d6b8d65e..92472178a50c 100644 --- a/azurerm/data_source_managed_disk.go +++ b/azurerm/data_source_managed_disk.go @@ -17,10 +17,7 @@ func dataSourceArmManagedDisk() *schema.Resource { Required: true, }, - "resource_group_name": { - Type: schema.TypeString, - Required: true, - }, + "resource_group_name": resourceGroupNameForDataSourceSchema(), "storage_account_type": { Type: schema.TypeString, diff --git a/azurerm/import_arm_app_service_plan_test.go b/azurerm/import_arm_app_service_plan_test.go index 6e7445789674..516d3cfb64fd 100644 --- a/azurerm/import_arm_app_service_plan_test.go +++ b/azurerm/import_arm_app_service_plan_test.go @@ -7,11 +7,11 @@ import ( "github.com/hashicorp/terraform/helper/resource" ) -func TestAccAzureRMAppServicePlan_importBasic(t *testing.T) { +func TestAccAzureRMAppServicePlan_importBasicWindows(t *testing.T) { resourceName := "azurerm_app_service_plan.test" ri := acctest.RandInt() - config := testAccAzureRMAppServicePlan_basic(ri, testLocation()) + config := testAccAzureRMAppServicePlan_basicWindows(ri, testLocation()) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -30,11 +30,11 @@ func TestAccAzureRMAppServicePlan_importBasic(t *testing.T) { }) } -func TestAccAzureRMAppServicePlan_importStandard(t *testing.T) { +func TestAccAzureRMAppServicePlan_importWindowsStandard(t *testing.T) { resourceName := "azurerm_app_service_plan.test" ri := acctest.RandInt() - config := testAccAzureRMAppServicePlan_standard(ri, testLocation()) + config := testAccAzureRMAppServicePlan_standardWindows(ri, testLocation()) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -53,11 +53,11 @@ func TestAccAzureRMAppServicePlan_importStandard(t *testing.T) { }) } -func TestAccAzureRMAppServicePlan_importPremium(t *testing.T) { +func TestAccAzureRMAppServicePlan_importPremiumWindows(t *testing.T) { resourceName := "azurerm_app_service_plan.test" ri := acctest.RandInt() - config := testAccAzureRMAppServicePlan_premium(ri, testLocation()) + config := testAccAzureRMAppServicePlan_premiumWindows(ri, testLocation()) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -76,11 +76,11 @@ func TestAccAzureRMAppServicePlan_importPremium(t *testing.T) { }) } -func TestAccAzureRMAppServicePlan_importComplete(t *testing.T) { +func TestAccAzureRMAppServicePlan_importCompleteWindows(t *testing.T) { resourceName := "azurerm_app_service_plan.test" ri := acctest.RandInt() - config := testAccAzureRMAppServicePlan_complete(ri, testLocation()) + config := testAccAzureRMAppServicePlan_completeWindows(ri, testLocation()) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, diff --git a/azurerm/import_arm_app_service_test.go b/azurerm/import_arm_app_service_test.go new file mode 100644 index 000000000000..e2bacbcbae5e --- /dev/null +++ b/azurerm/import_arm_app_service_test.go @@ -0,0 +1,468 @@ +package azurerm + +import ( + "testing" + + "github.com/hashicorp/terraform/helper/acctest" + "github.com/hashicorp/terraform/helper/resource" +) + +func TestAccAzureRMAppService_importBasic(t *testing.T) { + resourceName := "azurerm_app_service.test" + + ri := acctest.RandInt() + config := testAccAzureRMAppService_basic(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccAzureRMAppService_import32Bit(t *testing.T) { + resourceName := "azurerm_app_service.test" + + ri := acctest.RandInt() + config := testAccAzureRMAppService_32Bit(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccAzureRMAppService_importAlwaysOn(t *testing.T) { + resourceName := "azurerm_app_service.test" + + ri := acctest.RandInt() + config := testAccAzureRMAppService_alwaysOn(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccAzureRMAppService_importAppSettings(t *testing.T) { + resourceName := "azurerm_app_service.test" + + ri := acctest.RandInt() + config := testAccAzureRMAppService_appSettings(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccAzureRMAppService_importClientAffinityEnabled(t *testing.T) { + resourceName := "azurerm_app_service.test" + + ri := acctest.RandInt() + config := testAccAzureRMAppService_clientAffinityEnabled(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccAzureRMAppService_importConnectionStrings(t *testing.T) { + resourceName := "azurerm_app_service.test" + + ri := acctest.RandInt() + config := testAccAzureRMAppService_connectionStrings(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccAzureRMAppService_importDefaultDocuments(t *testing.T) { + resourceName := "azurerm_app_service.test" + + ri := acctest.RandInt() + config := testAccAzureRMAppService_defaultDocuments(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccAzureRMAppService_importEnabled(t *testing.T) { + resourceName := "azurerm_app_service.test" + + ri := acctest.RandInt() + config := testAccAzureRMAppService_enabled(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccAzureRMAppService_importLocalMySql(t *testing.T) { + resourceName := "azurerm_app_service.test" + + ri := acctest.RandInt() + config := testAccAzureRMAppService_localMySql(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccAzureRMAppService_importManagedPipelineMode(t *testing.T) { + resourceName := "azurerm_app_service.test" + + ri := acctest.RandInt() + config := testAccAzureRMAppService_managedPipelineMode(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccAzureRMAppService_importRemoteDebugging(t *testing.T) { + resourceName := "azurerm_app_service.test" + + ri := acctest.RandInt() + config := testAccAzureRMAppService_remoteDebugging(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccAzureRMAppService_importWindowsDotNet2(t *testing.T) { + resourceName := "azurerm_app_service.test" + + ri := acctest.RandInt() + config := testAccAzureRMAppService_windowsDotNet(ri, testLocation(), "v2.0") + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccAzureRMAppService_importWindowsDotNet4(t *testing.T) { + resourceName := "azurerm_app_service.test" + + ri := acctest.RandInt() + config := testAccAzureRMAppService_windowsDotNet(ri, testLocation(), "v4.0") + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccAzureRMAppService_importWindowsJava7Jetty(t *testing.T) { + resourceName := "azurerm_app_service.test" + + ri := acctest.RandInt() + config := testAccAzureRMAppService_windowsJava(ri, testLocation(), "1.7", "JETTY", "9.3") + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccAzureRMAppService_importWindowsJava8Jetty(t *testing.T) { + resourceName := "azurerm_app_service.test" + + ri := acctest.RandInt() + config := testAccAzureRMAppService_windowsJava(ri, testLocation(), "1.8", "JETTY", "9.3") + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccAzureRMAppService_importWindowsJava7Tomcat(t *testing.T) { + resourceName := "azurerm_app_service.test" + + ri := acctest.RandInt() + config := testAccAzureRMAppService_windowsJava(ri, testLocation(), "1.7", "TOMCAT", "9.0") + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccAzureRMAppService_importWindowsJava8Tomcat(t *testing.T) { + resourceName := "azurerm_app_service.test" + + ri := acctest.RandInt() + config := testAccAzureRMAppService_windowsJava(ri, testLocation(), "1.8", "TOMCAT", "9.0") + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccAzureRMAppService_importWindowsPHP7(t *testing.T) { + resourceName := "azurerm_app_service.test" + + ri := acctest.RandInt() + config := testAccAzureRMAppService_windowsPHP(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccAzureRMAppService_importWindowsPython(t *testing.T) { + resourceName := "azurerm_app_service.test" + + ri := acctest.RandInt() + config := testAccAzureRMAppService_windowsPython(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccAzureRMAppService_importWebSockets(t *testing.T) { + resourceName := "azurerm_app_service.test" + + ri := acctest.RandInt() + config := testAccAzureRMAppService_webSockets(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} diff --git a/azurerm/import_arm_automation_account_test.go b/azurerm/import_arm_automation_account_test.go new file mode 100644 index 000000000000..07e93fab8d88 --- /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_importAccountWithFreeSku(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_importAccountWithBasicSku(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..0fbc3a382a40 --- /dev/null +++ b/azurerm/import_arm_automation_credential_test.go @@ -0,0 +1,33 @@ +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_complete(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAutomationCredentialDestroy, + Steps: []resource.TestStep{ + { + Config: config, + }, + + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"password"}, + }, + }, + }) +} diff --git a/azurerm/import_arm_automation_runbook_test.go b/azurerm/import_arm_automation_runbook_test.go new file mode 100644 index 000000000000..d4d464948b46 --- /dev/null +++ b/azurerm/import_arm_automation_runbook_test.go @@ -0,0 +1,33 @@ +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, + }, + + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"publish_content_link"}, + }, + }, + }) +} diff --git a/azurerm/import_arm_automation_schedule_test.go b/azurerm/import_arm_automation_schedule_test.go new file mode 100644 index 000000000000..e814c09b5cef --- /dev/null +++ b/azurerm/import_arm_automation_schedule_test.go @@ -0,0 +1,32 @@ +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, + }, + + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} diff --git a/azurerm/import_arm_public_ip_test.go b/azurerm/import_arm_public_ip_test.go index 0755c2350905..f1e5f1e03a49 100644 --- a/azurerm/import_arm_public_ip_test.go +++ b/azurerm/import_arm_public_ip_test.go @@ -1,6 +1,9 @@ package azurerm import ( + "fmt" + "os" + "regexp" "testing" "github.com/hashicorp/terraform/helper/acctest" @@ -29,3 +32,27 @@ func TestAccAzureRMPublicIpStatic_importBasic(t *testing.T) { }, }) } + +func TestAccAzureRMPublicIpStatic_importIdError(t *testing.T) { + resourceName := "azurerm_public_ip.test" + + ri := acctest.RandInt() + config := testAccAzureRMPublicIPStatic_basic(ri, testLocation()) + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMPublicIpDestroy, + Steps: []resource.TestStep{ + { + Config: config, + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateId: fmt.Sprintf("/subscriptions/%s/resourceGroups/acctestRG-%d/providers/Microsoft.Network/publicIPAdresses/acctestpublicip-%d", os.Getenv("ARM_SUBSCRIPTION_ID"), ri, ri), + ExpectError: regexp.MustCompile("Error parsing supplied resource id."), + }, + }, + }) +} diff --git a/azurerm/provider.go b/azurerm/provider.go index e21383aa28ae..44adc70ea21c 100644 --- a/azurerm/provider.go +++ b/azurerm/provider.go @@ -8,8 +8,11 @@ import ( "log" "strings" "sync" + "time" "github.com/Azure/azure-sdk-for-go/arm/resources/resources" + "github.com/Azure/go-autorest/autorest/adal" + "github.com/Azure/go-autorest/autorest/azure/cli" "github.com/hashicorp/go-multierror" "github.com/hashicorp/terraform/helper/mutexkv" "github.com/hashicorp/terraform/helper/schema" @@ -23,25 +26,25 @@ func Provider() terraform.ResourceProvider { Schema: map[string]*schema.Schema{ "subscription_id": { Type: schema.TypeString, - Required: true, + Optional: true, DefaultFunc: schema.EnvDefaultFunc("ARM_SUBSCRIPTION_ID", ""), }, "client_id": { Type: schema.TypeString, - Required: true, + Optional: true, DefaultFunc: schema.EnvDefaultFunc("ARM_CLIENT_ID", ""), }, "client_secret": { Type: schema.TypeString, - Required: true, + Optional: true, DefaultFunc: schema.EnvDefaultFunc("ARM_CLIENT_SECRET", ""), }, "tenant_id": { Type: schema.TypeString, - Required: true, + Optional: true, DefaultFunc: schema.EnvDefaultFunc("ARM_TENANT_ID", ""), }, @@ -68,12 +71,18 @@ func Provider() terraform.ResourceProvider { ResourcesMap: map[string]*schema.Resource{ "azurerm_application_insights": resourceArmApplicationInsights(), + "azurerm_app_service": resourceArmAppService(), "azurerm_app_service_plan": resourceArmAppServicePlan(), + "azurerm_automation_account": resourceArmAutomationAccount(), + "azurerm_automation_credential": resourceArmAutomationCredential(), + "azurerm_automation_runbook": resourceArmAutomationRunbook(), + "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_container_group": resourceArmContainerGroup(), "azurerm_cosmosdb_account": resourceArmCosmosDBAccount(), "azurerm_dns_a_record": resourceArmDnsARecord(), "azurerm_dns_aaaa_record": resourceArmDnsAAAARecord(), @@ -150,17 +159,24 @@ func Provider() terraform.ResourceProvider { type Config struct { ManagementURL string - SubscriptionID string + // Core ClientID string - ClientSecret string + SubscriptionID string TenantID string Environment string SkipProviderRegistration bool + // Service Principal Auth + ClientSecret string + + // Bearer Auth + AccessToken *adal.Token + IsCloudShell bool + validateCredentialsOnce sync.Once } -func (c *Config) validate() error { +func (c *Config) validateServicePrincipal() error { var err *multierror.Error if c.SubscriptionID == "" { @@ -182,6 +198,116 @@ func (c *Config) validate() error { return err.ErrorOrNil() } +func (c *Config) validateBearerAuth() error { + var err *multierror.Error + + if c.AccessToken == nil { + err = multierror.Append(err, fmt.Errorf("Access Token was not found in your Azure CLI Credentials.\n\nPlease login to the Azure CLI again via `az login`")) + } + + if c.ClientID == "" { + err = multierror.Append(err, fmt.Errorf("Client ID was not found in your Azure CLI Credentials.\n\nPlease login to the Azure CLI again via `az login`")) + } + + if c.SubscriptionID == "" { + err = multierror.Append(err, fmt.Errorf("Subscription ID was not found in your Azure CLI Credentials.\n\nPlease login to the Azure CLI again via `az login`")) + } + + if c.TenantID == "" { + err = multierror.Append(err, fmt.Errorf("Tenant ID was not found in your Azure CLI Credentials.\n\nPlease login to the Azure CLI again via `az login`")) + } + + return err.ErrorOrNil() +} + +func (c *Config) LoadTokensFromAzureCLI() error { + profilePath, err := cli.ProfilePath() + if err != nil { + return fmt.Errorf("Error loading the Profile Path from the Azure CLI: %+v", err) + } + + profile, err := cli.LoadProfile(profilePath) + if err != nil { + return fmt.Errorf("Azure CLI Authorization Profile was not found. Please ensure the Azure CLI is installed and then log-in with `az login`.") + } + + // pull out the TenantID and Subscription ID from the Azure Profile + for _, subscription := range profile.Subscriptions { + if subscription.IsDefault { + c.SubscriptionID = subscription.ID + c.TenantID = subscription.TenantID + c.Environment = normalizeEnvironmentName(subscription.EnvironmentName) + break + } + } + + foundToken := false + if c.TenantID != "" { + // pull out the ClientID and the AccessToken from the Azure Access Token + tokensPath, err := cli.AccessTokensPath() + if err != nil { + return fmt.Errorf("Error loading the Tokens Path from the Azure CLI: %+v", err) + } + + tokens, err := cli.LoadTokens(tokensPath) + if err != nil { + return fmt.Errorf("Azure CLI Authorization Tokens were not found. Please ensure the Azure CLI is installed and then log-in with `az login`.") + } + + for _, accessToken := range tokens { + token, err := accessToken.ToADALToken() + if err != nil { + return fmt.Errorf("[DEBUG] Error converting access token to token: %+v", err) + } + + expirationDate, err := cli.ParseExpirationDate(accessToken.ExpiresOn) + if err != nil { + return fmt.Errorf("Error parsing expiration date: %q", accessToken.ExpiresOn) + } + + if expirationDate.UTC().Before(time.Now().UTC()) { + log.Printf("[DEBUG] Token '%s' has expired", token.AccessToken) + continue + } + + if !strings.Contains(accessToken.Resource, "management") { + log.Printf("[DEBUG] Resource '%s' isn't a management domain", accessToken.Resource) + continue + } + + if !strings.HasSuffix(accessToken.Authority, c.TenantID) { + log.Printf("[DEBUG] Resource '%s' isn't for the correct Tenant", accessToken.Resource) + continue + } + + c.ClientID = accessToken.ClientID + c.AccessToken = &token + c.IsCloudShell = accessToken.RefreshToken == "" + foundToken = true + break + } + } + + if !foundToken { + return fmt.Errorf("No valid (unexpired) Azure CLI Auth Tokens found. Please run `az login`.") + } + + return nil +} + +func normalizeEnvironmentName(input string) string { + // Environment is stored as `Azure{Environment}Cloud` + output := strings.ToLower(input) + output = strings.TrimPrefix(output, "azure") + output = strings.TrimSuffix(output, "cloud") + + // however Azure Public is `AzureCloud` in the CLI Profile and not `AzurePublicCloud`. + if output == "" { + return "public" + } + return output +} + func providerConfigure(p *schema.Provider) schema.ConfigureFunc { return func(d *schema.ResourceData) (interface{}, error) { config := &Config{ @@ -193,8 +319,20 @@ func providerConfigure(p *schema.Provider) schema.ConfigureFunc { SkipProviderRegistration: d.Get("skip_provider_registration").(bool), } - if err := config.validate(); err != nil { - return nil, err + if config.ClientSecret != "" { + log.Printf("[DEBUG] Client Secret specified - using Service Principal for Authentication") + if err := config.validateServicePrincipal(); err != nil { + return nil, err + } + } else { + log.Printf("[DEBUG] No Client Secret specified - loading credentials from Azure CLI") + if err := config.LoadTokensFromAzureCLI(); err != nil { + return nil, err + } + + if err := config.validateBearerAuth(); err != nil { + return nil, fmt.Errorf("Please specify either a Service Principal, or log in with the Azure CLI (using `az login`)") + } } client, err := config.getArmClient() @@ -243,9 +381,11 @@ var providerRegistrationOnce sync.Once func determineAzureResourceProvidersToRegister(providerList []resources.Provider) map[string]struct{} { providers := map[string]struct{}{ + "Microsoft.Automation": {}, "Microsoft.Cache": {}, "Microsoft.Cdn": {}, "Microsoft.Compute": {}, + "Microsoft.ContainerInstance": {}, "Microsoft.ContainerRegistry": {}, "Microsoft.ContainerService": {}, "Microsoft.DBforPostgreSQL": {}, @@ -284,7 +424,6 @@ func determineAzureResourceProvidersToRegister(providerList []resources.Provider func registerAzureResourceProvidersWithSubscription(providerList []resources.Provider, client resources.ProvidersClient) error { var err error providerRegistrationOnce.Do(func() { - providers := determineAzureResourceProvidersToRegister(providerList) var wg sync.WaitGroup diff --git a/azurerm/resource_arm_app_service.go b/azurerm/resource_arm_app_service.go new file mode 100644 index 000000000000..adcbc368f22d --- /dev/null +++ b/azurerm/resource_arm_app_service.go @@ -0,0 +1,631 @@ +package azurerm + +import ( + "fmt" + "log" + + "github.com/Azure/azure-sdk-for-go/arm/web" + "github.com/hashicorp/terraform/helper/schema" + "github.com/hashicorp/terraform/helper/validation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func resourceArmAppService() *schema.Resource { + return &schema.Resource{ + Create: resourceArmAppServiceCreate, + Read: resourceArmAppServiceRead, + Update: resourceArmAppServiceUpdate, + Delete: resourceArmAppServiceDelete, + 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, + }, + + "location": locationSchema(), + + "app_service_plan_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "site_config": { + Type: schema.TypeList, + Optional: true, + Computed: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "always_on": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + + "default_documents": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + + "dotnet_framework_version": { + Type: schema.TypeString, + Optional: true, + Default: "v4.0", + ValidateFunc: validation.StringInSlice([]string{ + "v2.0", + "v4.0", + }, true), + DiffSuppressFunc: ignoreCaseDiffSuppressFunc, + }, + + "java_version": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{ + "1.7", + "1.8", + }, false), + }, + + "java_container": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{ + "JETTY", + "TOMCAT", + }, true), + DiffSuppressFunc: ignoreCaseDiffSuppressFunc, + }, + + "java_container_version": { + Type: schema.TypeString, + Optional: true, + }, + + "local_mysql_enabled": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + }, + + "managed_pipeline_mode": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ValidateFunc: validation.StringInSlice([]string{ + string(web.Classic), + string(web.Integrated), + }, true), + DiffSuppressFunc: ignoreCaseDiffSuppressFunc, + }, + + "php_version": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{ + "5.5", + "5.6", + "7.0", + "7.1", + }, false), + }, + + "python_version": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{ + "2.7", + "3.4", + }, false), + }, + + "remote_debugging_enabled": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + + "remote_debugging_version": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ValidateFunc: validation.StringInSlice([]string{ + "VS2012", + "VS2013", + "VS2015", + "VS2017", + }, true), + DiffSuppressFunc: ignoreCaseDiffSuppressFunc, + }, + + "use_32_bit_worker_process": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + }, + + "websockets_enabled": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + }, + }, + }, + }, + + "client_affinity_enabled": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + + // TODO: (tombuildsstuff) support Update once the API is fixed: + // https://github.com/Azure/azure-rest-api-specs/issues/1697 + ForceNew: true, + }, + + "enabled": { + Type: schema.TypeBool, + Optional: true, + Default: true, + + // TODO: (tombuildsstuff) support Update once the API is fixed: + // https://github.com/Azure/azure-rest-api-specs/issues/1697 + ForceNew: true, + }, + + "app_settings": { + Type: schema.TypeMap, + Optional: true, + Computed: true, + }, + + "connection_string": { + Type: schema.TypeList, + Optional: true, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + }, + "value": { + Type: schema.TypeString, + Required: true, + }, + "type": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + string(web.APIHub), + string(web.Custom), + string(web.DocDb), + string(web.EventHub), + string(web.MySQL), + string(web.NotificationHub), + string(web.PostgreSQL), + string(web.RedisCache), + string(web.ServiceBus), + string(web.SQLAzure), + string(web.SQLServer), + }, true), + DiffSuppressFunc: ignoreCaseDiffSuppressFunc, + }, + }, + }, + }, + + // TODO: (tombuildsstuff) support Update once the API is fixed: + // https://github.com/Azure/azure-rest-api-specs/issues/1697 + "tags": tagsForceNewSchema(), + }, + } +} + +func resourceArmAppServiceCreate(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).appServicesClient + + log.Printf("[INFO] preparing arguments for AzureRM App Service creation.") + + name := d.Get("name").(string) + resGroup := d.Get("resource_group_name").(string) + location := d.Get("location").(string) + appServicePlanId := d.Get("app_service_plan_id").(string) + enabled := d.Get("enabled").(bool) + tags := d.Get("tags").(map[string]interface{}) + + siteConfig := expandAppServiceSiteConfig(d) + + siteEnvelope := web.Site{ + Location: &location, + Tags: expandTags(tags), + SiteProperties: &web.SiteProperties{ + ServerFarmID: utils.String(appServicePlanId), + Enabled: utils.Bool(enabled), + SiteConfig: &siteConfig, + }, + } + + if v, ok := d.GetOk("client_affinity_enabled"); ok { + enabled := v.(bool) + siteEnvelope.SiteProperties.ClientAffinityEnabled = utils.Bool(enabled) + } + + // NOTE: these seem like sensible defaults, in lieu of any better documentation. + skipDNSRegistration := false + forceDNSRegistration := false + skipCustomDomainVerification := true + ttlInSeconds := "60" + _, createErr := client.CreateOrUpdate(resGroup, name, siteEnvelope, &skipDNSRegistration, &skipCustomDomainVerification, &forceDNSRegistration, ttlInSeconds, make(chan struct{})) + err := <-createErr + 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 App Service %s (resource group %s) ID", name, resGroup) + } + + d.SetId(*read.ID) + + return resourceArmAppServiceUpdate(d, meta) +} + +func resourceArmAppServiceUpdate(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).appServicesClient + + id, err := parseAzureResourceID(d.Id()) + if err != nil { + return err + } + + resGroup := id.ResourceGroup + name := id.Path["sites"] + + if d.HasChange("site_config") { + // update the main configuration + siteConfig := expandAppServiceSiteConfig(d) + siteConfigResource := web.SiteConfigResource{ + SiteConfig: &siteConfig, + } + _, err := client.CreateOrUpdateConfiguration(resGroup, name, siteConfigResource) + if err != nil { + return fmt.Errorf("Error updating Configuration for App Service %q: %+v", name, err) + } + } + + if d.HasChange("app_settings") { + // update the AppSettings + appSettings := expandAppServiceAppSettings(d) + settings := web.StringDictionary{ + Properties: appSettings, + } + + _, err := client.UpdateApplicationSettings(resGroup, name, settings) + if err != nil { + return fmt.Errorf("Error updating Application Settings for App Service %q: %+v", name, err) + } + } + + if d.HasChange("connection_string") { + // update the ConnectionStrings + connectionStrings := expandAppServiceConnectionStrings(d) + properties := web.ConnectionStringDictionary{ + Properties: connectionStrings, + } + + _, err := client.UpdateConnectionStrings(resGroup, name, properties) + if err != nil { + return fmt.Errorf("Error updating Connection Strings for App Service %q: %+v", name, err) + } + } + + return resourceArmAppServiceRead(d, meta) +} + +func resourceArmAppServiceRead(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).appServicesClient + + id, err := parseAzureResourceID(d.Id()) + if err != nil { + return err + } + + resGroup := id.ResourceGroup + name := id.Path["sites"] + + resp, err := client.Get(resGroup, name) + if err != nil { + if utils.ResponseWasNotFound(resp.Response) { + log.Printf("[DEBUG] App Service %q (resource group %q) was not found - removing from state", name, resGroup) + d.SetId("") + return nil + } + return fmt.Errorf("Error making Read request on AzureRM App Service %q: %+v", name, err) + } + + configResp, err := client.GetConfiguration(resGroup, name) + if err != nil { + return fmt.Errorf("Error making Read request on AzureRM App Service Configuration %q: %+v", name, err) + } + + appSettingsResp, err := client.ListApplicationSettings(resGroup, name) + if err != nil { + return fmt.Errorf("Error making Read request on AzureRM App Service AppSettings %q: %+v", name, err) + } + + connectionStringsResp, err := client.ListConnectionStrings(resGroup, name) + if err != nil { + return fmt.Errorf("Error making Read request on AzureRM App Service ConnectionStrings %q: %+v", name, err) + } + + d.Set("name", name) + d.Set("resource_group_name", resGroup) + d.Set("location", azureRMNormalizeLocation(*resp.Location)) + + if props := resp.SiteProperties; props != nil { + d.Set("app_service_plan_id", props.ServerFarmID) + d.Set("client_affinity_enabled", props.ClientAffinityEnabled) + d.Set("enabled", props.Enabled) + } + + if err := d.Set("app_settings", flattenAppServiceAppSettings(appSettingsResp.Properties)); err != nil { + return err + } + if err := d.Set("connection_string", flattenAppServiceConnectionStrings(connectionStringsResp.Properties)); err != nil { + return err + } + + siteConfig := flattenAppServiceSiteConfig(configResp.SiteConfig) + if err := d.Set("site_config", siteConfig); err != nil { + return err + } + + flattenAndSetTags(d, resp.Tags) + + return nil +} + +func resourceArmAppServiceDelete(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).appServicesClient + + id, err := parseAzureResourceID(d.Id()) + if err != nil { + return err + } + resGroup := id.ResourceGroup + name := id.Path["sites"] + + log.Printf("[DEBUG] Deleting App Service %q (resource group %q)", name, resGroup) + + deleteMetrics := true + deleteEmptyServerFarm := false + skipDNSRegistration := true + resp, err := client.Delete(resGroup, name, &deleteMetrics, &deleteEmptyServerFarm, &skipDNSRegistration) + if err != nil { + if !utils.ResponseWasNotFound(resp) { + return err + } + } + + return nil +} + +func expandAppServiceSiteConfig(d *schema.ResourceData) web.SiteConfig { + configs := d.Get("site_config").([]interface{}) + siteConfig := web.SiteConfig{} + + if len(configs) == 0 { + return siteConfig + } + + config := configs[0].(map[string]interface{}) + + if v, ok := config["always_on"]; ok { + siteConfig.AlwaysOn = utils.Bool(v.(bool)) + } + + if v, ok := config["default_documents"]; ok { + input := v.([]interface{}) + + documents := make([]string, 0) + for _, document := range input { + documents = append(documents, document.(string)) + } + + siteConfig.DefaultDocuments = &documents + } + + if v, ok := config["dotnet_framework_version"]; ok { + siteConfig.NetFrameworkVersion = utils.String(v.(string)) + } + + if v, ok := config["java_version"]; ok { + siteConfig.JavaVersion = utils.String(v.(string)) + } + + if v, ok := config["java_container"]; ok { + siteConfig.JavaContainer = utils.String(v.(string)) + } + + if v, ok := config["java_container_version"]; ok { + siteConfig.JavaContainerVersion = utils.String(v.(string)) + } + + if v, ok := config["local_mysql_enabled"]; ok { + siteConfig.LocalMySQLEnabled = utils.Bool(v.(bool)) + } + + if v, ok := config["managed_pipeline_mode"]; ok { + siteConfig.ManagedPipelineMode = web.ManagedPipelineMode(v.(string)) + } + + if v, ok := config["php_version"]; ok { + siteConfig.PhpVersion = utils.String(v.(string)) + } + + if v, ok := config["python_version"]; ok { + siteConfig.PythonVersion = utils.String(v.(string)) + } + + if v, ok := config["remote_debugging_enabled"]; ok { + siteConfig.RemoteDebuggingEnabled = utils.Bool(v.(bool)) + } + + if v, ok := config["remote_debugging_version"]; ok { + siteConfig.RemoteDebuggingVersion = utils.String(v.(string)) + } + + if v, ok := config["use_32_bit_worker_process"]; ok { + siteConfig.Use32BitWorkerProcess = utils.Bool(v.(bool)) + } + + if v, ok := config["websockets_enabled"]; ok { + siteConfig.WebSocketsEnabled = utils.Bool(v.(bool)) + } + + return siteConfig +} + +func flattenAppServiceSiteConfig(input *web.SiteConfig) []interface{} { + results := make([]interface{}, 0) + result := make(map[string]interface{}, 0) + + if input == nil { + log.Printf("[DEBUG] SiteConfig is nil") + return results + } + + if input.AlwaysOn != nil { + result["always_on"] = *input.AlwaysOn + } + + if input.DefaultDocuments != nil { + documents := make([]string, 0) + for _, document := range *input.DefaultDocuments { + documents = append(documents, document) + } + + result["default_documents"] = documents + } + + if input.NetFrameworkVersion != nil { + result["dotnet_framework_version"] = *input.NetFrameworkVersion + } + + if input.JavaVersion != nil { + result["java_version"] = *input.JavaVersion + } + + if input.JavaContainer != nil { + result["java_container"] = *input.JavaContainer + } + + if input.JavaContainerVersion != nil { + result["java_container_version"] = *input.JavaContainerVersion + } + + if input.LocalMySQLEnabled != nil { + result["local_mysql_enabled"] = *input.LocalMySQLEnabled + } + + result["managed_pipeline_mode"] = string(input.ManagedPipelineMode) + + if input.PhpVersion != nil { + result["php_version"] = *input.PhpVersion + } + + if input.PythonVersion != nil { + result["python_version"] = *input.PythonVersion + } + + if input.RemoteDebuggingEnabled != nil { + result["remote_debugging_enabled"] = *input.RemoteDebuggingEnabled + } + + if input.RemoteDebuggingVersion != nil { + result["remote_debugging_version"] = *input.RemoteDebuggingVersion + } + + if input.Use32BitWorkerProcess != nil { + result["use_32_bit_worker_process"] = *input.Use32BitWorkerProcess + } + + if input.WebSocketsEnabled != nil { + result["websockets_enabled"] = *input.WebSocketsEnabled + } + + results = append(results, result) + return results +} + +func expandAppServiceAppSettings(d *schema.ResourceData) *map[string]*string { + input := d.Get("app_settings").(map[string]interface{}) + output := make(map[string]*string, len(input)) + + for k, v := range input { + output[k] = utils.String(v.(string)) + } + + return &output +} + +func expandAppServiceConnectionStrings(d *schema.ResourceData) *map[string]*web.ConnStringValueTypePair { + input := d.Get("connection_string").([]interface{}) + output := make(map[string]*web.ConnStringValueTypePair, len(input)) + + for _, v := range input { + vals := v.(map[string]interface{}) + + csName := vals["name"].(string) + csType := vals["type"].(string) + csValue := vals["value"].(string) + + output[csName] = &web.ConnStringValueTypePair{ + Value: utils.String(csValue), + Type: web.ConnectionStringType(csType), + } + } + + return &output +} + +func flattenAppServiceConnectionStrings(input *map[string]*web.ConnStringValueTypePair) interface{} { + results := make([]interface{}, 0) + + for k, v := range *input { + result := make(map[string]interface{}, 0) + result["name"] = k + result["type"] = string(v.Type) + result["value"] = *v.Value + results = append(results, result) + } + + return results +} + +func flattenAppServiceAppSettings(input *map[string]*string) map[string]string { + output := make(map[string]string, 0) + for k, v := range *input { + output[k] = *v + } + + return output +} diff --git a/azurerm/resource_arm_app_service_plan.go b/azurerm/resource_arm_app_service_plan.go index d542bb2dc23c..dd681debf745 100644 --- a/azurerm/resource_arm_app_service_plan.go +++ b/azurerm/resource_arm_app_service_plan.go @@ -6,6 +6,7 @@ import ( "github.com/Azure/azure-sdk-for-go/arm/web" "github.com/hashicorp/terraform/helper/schema" + "github.com/hashicorp/terraform/helper/validation" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) @@ -26,14 +27,22 @@ func resourceArmAppServicePlan() *schema.Resource { ForceNew: true, }, - "resource_group_name": { + "resource_group_name": resourceGroupNameSchema(), + + "location": locationSchema(), + + "kind": { Type: schema.TypeString, - Required: true, + Optional: true, + Default: "Windows", ForceNew: true, + ValidateFunc: validation.StringInSlice([]string{ + "Linux", + "Windows", + }, true), + DiffSuppressFunc: ignoreCaseDiffSuppressFunc, }, - "location": locationSchema(), - "sku": { Type: schema.TypeList, Required: true, @@ -96,6 +105,7 @@ func resourceArmAppServicePlanCreateUpdate(d *schema.ResourceData, meta interfac resGroup := d.Get("resource_group_name").(string) name := d.Get("name").(string) location := d.Get("location").(string) + kind := d.Get("kind").(string) tags := d.Get("tags").(map[string]interface{}) sku := expandAzureRmAppServicePlanSku(d) @@ -104,6 +114,7 @@ func resourceArmAppServicePlanCreateUpdate(d *schema.ResourceData, meta interfac appServicePlan := web.AppServicePlan{ Location: &location, AppServicePlanProperties: properties, + Kind: &kind, Tags: expandTags(tags), Sku: &sku, } @@ -153,6 +164,7 @@ func resourceArmAppServicePlanRead(d *schema.ResourceData, meta interface{}) err d.Set("name", name) d.Set("resource_group_name", resGroup) d.Set("location", azureRMNormalizeLocation(*resp.Location)) + d.Set("kind", resp.Kind) if props := resp.AppServicePlanProperties; props != nil { d.Set("properties", flattenAppServiceProperties(props)) diff --git a/azurerm/resource_arm_app_service_plan_test.go b/azurerm/resource_arm_app_service_plan_test.go index ebab314b6dcf..1fec9ca40617 100644 --- a/azurerm/resource_arm_app_service_plan_test.go +++ b/azurerm/resource_arm_app_service_plan_test.go @@ -10,9 +10,9 @@ import ( "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) -func TestAccAzureRMAppServicePlan_basic(t *testing.T) { +func TestAccAzureRMAppServicePlan_basicWindows(t *testing.T) { ri := acctest.RandInt() - config := testAccAzureRMAppServicePlan_basic(ri, testLocation()) + config := testAccAzureRMAppServicePlan_basicWindows(ri, testLocation()) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -29,9 +29,9 @@ func TestAccAzureRMAppServicePlan_basic(t *testing.T) { }) } -func TestAccAzureRMAppServicePlan_standard(t *testing.T) { +func TestAccAzureRMAppServicePlan_basicLinux(t *testing.T) { ri := acctest.RandInt() - config := testAccAzureRMAppServicePlan_standard(ri, testLocation()) + config := testAccAzureRMAppServicePlan_basicLinux(ri, testLocation()) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -48,9 +48,9 @@ func TestAccAzureRMAppServicePlan_standard(t *testing.T) { }) } -func TestAccAzureRMAppServicePlan_premium(t *testing.T) { +func TestAccAzureRMAppServicePlan_standardWindows(t *testing.T) { ri := acctest.RandInt() - config := testAccAzureRMAppServicePlan_premium(ri, testLocation()) + config := testAccAzureRMAppServicePlan_standardWindows(ri, testLocation()) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -67,12 +67,31 @@ func TestAccAzureRMAppServicePlan_premium(t *testing.T) { }) } -func TestAccAzureRMAppServicePlan_premiumUpdated(t *testing.T) { +func TestAccAzureRMAppServicePlan_premiumWindows(t *testing.T) { + ri := acctest.RandInt() + config := testAccAzureRMAppServicePlan_premiumWindows(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServicePlanDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAppServicePlanExists("azurerm_app_service_plan.test"), + ), + }, + }, + }) +} + +func TestAccAzureRMAppServicePlan_premiumWindowsUpdated(t *testing.T) { resourceName := "azurerm_app_service_plan.test" ri := acctest.RandInt() location := testLocation() - config := testAccAzureRMAppServicePlan_premium(ri, location) - updatedConfig := testAccAzureRMAppServicePlan_premiumUpdated(ri, location) + config := testAccAzureRMAppServicePlan_premiumWindows(ri, location) + updatedConfig := testAccAzureRMAppServicePlan_premiumWindowsUpdated(ri, location) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -97,10 +116,10 @@ func TestAccAzureRMAppServicePlan_premiumUpdated(t *testing.T) { }) } -func TestAccAzureRMAppServicePlan_complete(t *testing.T) { +func TestAccAzureRMAppServicePlan_completeWindows(t *testing.T) { resourceName := "azurerm_app_service_plan.test" ri := acctest.RandInt() - config := testAccAzureRMAppServicePlan_complete(ri, testLocation()) + config := testAccAzureRMAppServicePlan_completeWindows(ri, testLocation()) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -175,7 +194,27 @@ func testCheckAzureRMAppServicePlanExists(name string) resource.TestCheckFunc { } } -func testAccAzureRMAppServicePlan_basic(rInt int, location string) string { +func testAccAzureRMAppServicePlan_basicWindows(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_app_service_plan" "test" { + name = "acctestASP-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + + sku { + tier = "Basic" + size = "B1" + } +} +`, rInt, location, rInt) +} + +func testAccAzureRMAppServicePlan_basicLinux(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { name = "acctestRG-%d" @@ -186,6 +225,7 @@ resource "azurerm_app_service_plan" "test" { name = "acctestASP-%d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" + kind = "Linux" sku { tier = "Basic" @@ -195,7 +235,7 @@ resource "azurerm_app_service_plan" "test" { `, rInt, location, rInt) } -func testAccAzureRMAppServicePlan_standard(rInt int, location string) string { +func testAccAzureRMAppServicePlan_standardWindows(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { name = "acctestRG-%d" @@ -215,7 +255,7 @@ resource "azurerm_app_service_plan" "test" { `, rInt, location, rInt) } -func testAccAzureRMAppServicePlan_premium(rInt int, location string) string { +func testAccAzureRMAppServicePlan_premiumWindows(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { name = "acctestRG-%d" @@ -235,7 +275,7 @@ resource "azurerm_app_service_plan" "test" { `, rInt, location, rInt) } -func testAccAzureRMAppServicePlan_premiumUpdated(rInt int, location string) string { +func testAccAzureRMAppServicePlan_premiumWindowsUpdated(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { name = "acctestRG-%d" @@ -256,7 +296,7 @@ resource "azurerm_app_service_plan" "test" { `, rInt, location, rInt) } -func testAccAzureRMAppServicePlan_complete(rInt int, location string) string { +func testAccAzureRMAppServicePlan_completeWindows(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { name = "acctestRG-%d" @@ -267,6 +307,7 @@ resource "azurerm_app_service_plan" "test" { name = "acctestASP-%d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" + kind = "Windows" sku { tier = "Standard" diff --git a/azurerm/resource_arm_app_service_test.go b/azurerm/resource_arm_app_service_test.go new file mode 100644 index 000000000000..0a15e47f23f9 --- /dev/null +++ b/azurerm/resource_arm_app_service_test.go @@ -0,0 +1,1120 @@ +package azurerm + +import ( + "fmt" + "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 TestAccAzureRMAppService_basic(t *testing.T) { + resourceName := "azurerm_app_service.test" + ri := acctest.RandInt() + config := testAccAzureRMAppService_basic(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAppServiceExists(resourceName), + ), + }, + }, + }) +} + +func TestAccAzureRMAppService_32Bit(t *testing.T) { + resourceName := "azurerm_app_service.test" + ri := acctest.RandInt() + config := testAccAzureRMAppService_32Bit(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAppServiceExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "site_config.0.use_32_bit_worker_process", "true"), + ), + }, + }, + }) +} + +func TestAccAzureRMAppService_alwaysOn(t *testing.T) { + resourceName := "azurerm_app_service.test" + ri := acctest.RandInt() + config := testAccAzureRMAppService_alwaysOn(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAppServiceExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "site_config.0.always_on", "true"), + ), + }, + }, + }) +} + +func TestAccAzureRMAppService_appSettings(t *testing.T) { + resourceName := "azurerm_app_service.test" + ri := acctest.RandInt() + config := testAccAzureRMAppService_appSettings(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAppServiceExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "app_settings.foo", "bar"), + ), + }, + }, + }) +} + +func TestAccAzureRMAppService_clientAffinityEnabled(t *testing.T) { + resourceName := "azurerm_app_service.test" + ri := acctest.RandInt() + config := testAccAzureRMAppService_clientAffinityEnabled(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAppServiceExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "client_affinity_enabled", "true"), + ), + }, + }, + }) +} + +func TestAccAzureRMAppService_connectionStrings(t *testing.T) { + resourceName := "azurerm_app_service.test" + ri := acctest.RandInt() + config := testAccAzureRMAppService_connectionStrings(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAppServiceExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "connection_string.0.name", "Example"), + resource.TestCheckResourceAttr(resourceName, "connection_string.0.value", "some-postgresql-connection-string"), + resource.TestCheckResourceAttr(resourceName, "connection_string.0.type", "PostgreSQL"), + ), + }, + }, + }) +} + +func TestAccAzureRMAppService_defaultDocuments(t *testing.T) { + resourceName := "azurerm_app_service.test" + ri := acctest.RandInt() + config := testAccAzureRMAppService_defaultDocuments(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAppServiceExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "site_config.0.default_documents.0", "first.html"), + resource.TestCheckResourceAttr(resourceName, "site_config.0.default_documents.1", "second.jsp"), + resource.TestCheckResourceAttr(resourceName, "site_config.0.default_documents.2", "third.aspx"), + ), + }, + }, + }) +} + +func TestAccAzureRMAppService_enabled(t *testing.T) { + resourceName := "azurerm_app_service.test" + ri := acctest.RandInt() + config := testAccAzureRMAppService_enabled(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAppServiceExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "enabled", "false"), + ), + }, + }, + }) +} + +func TestAccAzureRMAppService_localMySql(t *testing.T) { + resourceName := "azurerm_app_service.test" + ri := acctest.RandInt() + config := testAccAzureRMAppService_localMySql(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAppServiceExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "site_config.0.local_mysql_enabled", "true"), + ), + }, + }, + }) +} + +func TestAccAzureRMAppService_managedPipelineMode(t *testing.T) { + resourceName := "azurerm_app_service.test" + ri := acctest.RandInt() + config := testAccAzureRMAppService_managedPipelineMode(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAppServiceExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "site_config.0.managed_pipeline_mode", "Classic"), + ), + }, + }, + }) +} + +func TestAccAzureRMAppService_tagsUpdate(t *testing.T) { + resourceName := "azurerm_app_service.test" + ri := acctest.RandInt() + config := testAccAzureRMAppService_tags(ri, testLocation()) + updatedConfig := testAccAzureRMAppService_tagsUpdated(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAppServiceExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), + resource.TestCheckResourceAttr(resourceName, "tags.Hello", "World"), + ), + }, + { + Config: updatedConfig, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAppServiceExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "tags.%", "2"), + resource.TestCheckResourceAttr(resourceName, "tags.Hello", "World"), + resource.TestCheckResourceAttr(resourceName, "tags.Terraform", "AcceptanceTests"), + ), + }, + }, + }) +} + +func TestAccAzureRMAppService_remoteDebugging(t *testing.T) { + resourceName := "azurerm_app_service.test" + ri := acctest.RandInt() + config := testAccAzureRMAppService_remoteDebugging(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAppServiceExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "site_config.0.remote_debugging_enabled", "true"), + resource.TestCheckResourceAttr(resourceName, "site_config.0.remote_debugging_version", "VS2015"), + ), + }, + }, + }) +} + +func TestAccAzureRMAppService_windowsDotNet2(t *testing.T) { + resourceName := "azurerm_app_service.test" + ri := acctest.RandInt() + config := testAccAzureRMAppService_windowsDotNet(ri, testLocation(), "v2.0") + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAppServiceExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "site_config.0.dotnet_framework_version", "v2.0"), + ), + }, + }, + }) +} + +func TestAccAzureRMAppService_windowsDotNet4(t *testing.T) { + resourceName := "azurerm_app_service.test" + ri := acctest.RandInt() + config := testAccAzureRMAppService_windowsDotNet(ri, testLocation(), "v4.0") + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAppServiceExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "site_config.0.dotnet_framework_version", "v4.0"), + ), + }, + }, + }) +} + +func TestAccAzureRMAppService_windowsDotNetUpdate(t *testing.T) { + resourceName := "azurerm_app_service.test" + ri := acctest.RandInt() + config := testAccAzureRMAppService_windowsDotNet(ri, testLocation(), "v2.0") + updatedConfig := testAccAzureRMAppService_windowsDotNet(ri, testLocation(), "v4.0") + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAppServiceExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "site_config.0.dotnet_framework_version", "v2.0"), + ), + }, + { + Config: updatedConfig, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAppServiceExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "site_config.0.dotnet_framework_version", "v4.0"), + ), + }, + }, + }) +} + +func TestAccAzureRMAppService_windowsJava7Jetty(t *testing.T) { + resourceName := "azurerm_app_service.test" + ri := acctest.RandInt() + config := testAccAzureRMAppService_windowsJava(ri, testLocation(), "1.7", "JETTY", "9.3") + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAppServiceExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "site_config.0.java_version", "1.7"), + resource.TestCheckResourceAttr(resourceName, "site_config.0.java_container", "JETTY"), + resource.TestCheckResourceAttr(resourceName, "site_config.0.java_container_version", "9.3"), + ), + }, + }, + }) +} + +func TestAccAzureRMAppService_windowsJava8Jetty(t *testing.T) { + resourceName := "azurerm_app_service.test" + ri := acctest.RandInt() + config := testAccAzureRMAppService_windowsJava(ri, testLocation(), "1.8", "JETTY", "9.3") + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAppServiceExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "site_config.0.java_version", "1.8"), + resource.TestCheckResourceAttr(resourceName, "site_config.0.java_container", "JETTY"), + resource.TestCheckResourceAttr(resourceName, "site_config.0.java_container_version", "9.3"), + ), + }, + }, + }) +} +func TestAccAzureRMAppService_windowsJava7Tomcat(t *testing.T) { + resourceName := "azurerm_app_service.test" + ri := acctest.RandInt() + config := testAccAzureRMAppService_windowsJava(ri, testLocation(), "1.7", "TOMCAT", "9.0") + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAppServiceExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "site_config.0.java_version", "1.7"), + resource.TestCheckResourceAttr(resourceName, "site_config.0.java_container", "TOMCAT"), + resource.TestCheckResourceAttr(resourceName, "site_config.0.java_container_version", "9.0"), + ), + }, + }, + }) +} + +func TestAccAzureRMAppService_windowsJava8Tomcat(t *testing.T) { + resourceName := "azurerm_app_service.test" + ri := acctest.RandInt() + config := testAccAzureRMAppService_windowsJava(ri, testLocation(), "1.8", "TOMCAT", "9.0") + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAppServiceExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "site_config.0.java_version", "1.8"), + resource.TestCheckResourceAttr(resourceName, "site_config.0.java_container", "TOMCAT"), + resource.TestCheckResourceAttr(resourceName, "site_config.0.java_container_version", "9.0"), + ), + }, + }, + }) +} + +func TestAccAzureRMAppService_windowsPHP7(t *testing.T) { + resourceName := "azurerm_app_service.test" + ri := acctest.RandInt() + config := testAccAzureRMAppService_windowsPHP(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAppServiceExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "site_config.0.php_version", "7.1"), + ), + }, + }, + }) +} + +func TestAccAzureRMAppService_windowsPython(t *testing.T) { + resourceName := "azurerm_app_service.test" + ri := acctest.RandInt() + config := testAccAzureRMAppService_windowsPython(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAppServiceExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "site_config.0.python_version", "3.4"), + ), + }, + }, + }) +} + +func TestAccAzureRMAppService_webSockets(t *testing.T) { + resourceName := "azurerm_app_service.test" + ri := acctest.RandInt() + config := testAccAzureRMAppService_webSockets(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAppServiceExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "site_config.0.websockets_enabled", "true"), + ), + }, + }, + }) +} + +func testCheckAzureRMAppServiceDestroy(s *terraform.State) error { + client := testAccProvider.Meta().(*ArmClient).appServicesClient + + for _, rs := range s.RootModule().Resources { + if rs.Type != "azurerm_app_service" { + continue + } + + name := rs.Primary.Attributes["name"] + resourceGroup := rs.Primary.Attributes["resource_group_name"] + + resp, err := client.Get(resourceGroup, name) + + if err != nil { + if utils.ResponseWasNotFound(resp.Response) { + return nil + } + return err + } + + return fmt.Errorf("App Service still exists:\n%#v", resp) + } + + return nil +} + +func testCheckAzureRMAppServiceExists(name 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) + } + + appServiceName := 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 App Service: %s", appServiceName) + } + + client := testAccProvider.Meta().(*ArmClient).appServicesClient + + resp, err := client.Get(resourceGroup, appServiceName) + if err != nil { + if utils.ResponseWasNotFound(resp.Response) { + return fmt.Errorf("Bad: App Service %q (resource group: %q) does not exist", appServiceName, resourceGroup) + } + + return fmt.Errorf("Bad: Get on appServicesClient: %+v", err) + } + + return nil + } +} + +func testAccAzureRMAppService_basic(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_app_service_plan" "test" { + name = "acctestASP-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + + sku { + tier = "Standard" + size = "S1" + } +} + +resource "azurerm_app_service" "test" { + name = "acctestAS-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + app_service_plan_id = "${azurerm_app_service_plan.test.id}" +} +`, rInt, location, rInt, rInt) +} + +func testAccAzureRMAppService_alwaysOn(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_app_service_plan" "test" { + name = "acctestASP-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + + sku { + tier = "Standard" + size = "S1" + } +} + +resource "azurerm_app_service" "test" { + name = "acctestAS-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + app_service_plan_id = "${azurerm_app_service_plan.test.id}" + + site_config { + always_on = true + } +} +`, rInt, location, rInt, rInt) +} + +func testAccAzureRMAppService_32Bit(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_app_service_plan" "test" { + name = "acctestASP-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + + sku { + tier = "Standard" + size = "S1" + } +} + +resource "azurerm_app_service" "test" { + name = "acctestAS-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + app_service_plan_id = "${azurerm_app_service_plan.test.id}" + + site_config { + use_32_bit_worker_process = true + } +} +`, rInt, location, rInt, rInt) +} + +func testAccAzureRMAppService_appSettings(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_app_service_plan" "test" { + name = "acctestASP-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + + sku { + tier = "Standard" + size = "S1" + } +} + +resource "azurerm_app_service" "test" { + name = "acctestAS-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + app_service_plan_id = "${azurerm_app_service_plan.test.id}" + + app_settings { + "foo" = "bar" + } +} +`, rInt, location, rInt, rInt) +} + +func testAccAzureRMAppService_clientAffinityEnabled(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_app_service_plan" "test" { + name = "acctestASP-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + + sku { + tier = "Standard" + size = "S1" + } +} + +resource "azurerm_app_service" "test" { + name = "acctestAS-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + app_service_plan_id = "${azurerm_app_service_plan.test.id}" + client_affinity_enabled = true +} +`, rInt, location, rInt, rInt) +} + +func testAccAzureRMAppService_connectionStrings(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_app_service_plan" "test" { + name = "acctestASP-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + + sku { + tier = "Standard" + size = "S1" + } +} + +resource "azurerm_app_service" "test" { + name = "acctestAS-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + app_service_plan_id = "${azurerm_app_service_plan.test.id}" + + connection_string { + name = "Example" + value = "some-postgresql-connection-string" + type = "PostgreSQL" + } +} +`, rInt, location, rInt, rInt) +} + +func testAccAzureRMAppService_defaultDocuments(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_app_service_plan" "test" { + name = "acctestASP-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + + sku { + tier = "Standard" + size = "S1" + } +} + +resource "azurerm_app_service" "test" { + name = "acctestAS-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + app_service_plan_id = "${azurerm_app_service_plan.test.id}" + + site_config { + default_documents = [ + "first.html", + "second.jsp", + "third.aspx", + ] + } +} +`, rInt, location, rInt, rInt) +} + +func testAccAzureRMAppService_enabled(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_app_service_plan" "test" { + name = "acctestASP-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + + sku { + tier = "Standard" + size = "S1" + } +} + +resource "azurerm_app_service" "test" { + name = "acctestAS-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + app_service_plan_id = "${azurerm_app_service_plan.test.id}" + enabled = false +} +`, rInt, location, rInt, rInt) +} + +func testAccAzureRMAppService_localMySql(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_app_service_plan" "test" { + name = "acctestASP-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + + sku { + tier = "Standard" + size = "S1" + } +} + +resource "azurerm_app_service" "test" { + name = "acctestAS-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + app_service_plan_id = "${azurerm_app_service_plan.test.id}" + + site_config { + local_mysql_enabled = true + } +} +`, rInt, location, rInt, rInt) +} + +func testAccAzureRMAppService_managedPipelineMode(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_app_service_plan" "test" { + name = "acctestASP-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + + sku { + tier = "Standard" + size = "S1" + } +} + +resource "azurerm_app_service" "test" { + name = "acctestAS-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + app_service_plan_id = "${azurerm_app_service_plan.test.id}" + + site_config { + managed_pipeline_mode = "Classic" + } +} +`, rInt, location, rInt, rInt) +} + +func testAccAzureRMAppService_remoteDebugging(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_app_service_plan" "test" { + name = "acctestASP-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + + sku { + tier = "Standard" + size = "S1" + } +} + +resource "azurerm_app_service" "test" { + name = "acctestAS-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + app_service_plan_id = "${azurerm_app_service_plan.test.id}" + + site_config { + remote_debugging_enabled = true + remote_debugging_version = "VS2015" + } + + tags { + "Hello" = "World" + } +} +`, rInt, location, rInt, rInt) +} + +func testAccAzureRMAppService_tags(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_app_service_plan" "test" { + name = "acctestASP-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + + sku { + tier = "Standard" + size = "S1" + } +} + +resource "azurerm_app_service" "test" { + name = "acctestAS-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + app_service_plan_id = "${azurerm_app_service_plan.test.id}" + + tags { + "Hello" = "World" + } +} +`, rInt, location, rInt, rInt) +} + +func testAccAzureRMAppService_tagsUpdated(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_app_service_plan" "test" { + name = "acctestASP-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + + sku { + tier = "Standard" + size = "S1" + } +} + +resource "azurerm_app_service" "test" { + name = "acctestAS-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + app_service_plan_id = "${azurerm_app_service_plan.test.id}" + + tags { + "Hello" = "World" + "Terraform" = "AcceptanceTests" + } +} +`, rInt, location, rInt, rInt) +} + +func testAccAzureRMAppService_windowsDotNet(rInt int, location, version string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_app_service_plan" "test" { + name = "acctestASP-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + + sku { + tier = "Standard" + size = "S1" + } +} + +resource "azurerm_app_service" "test" { + name = "acctestAS-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + app_service_plan_id = "${azurerm_app_service_plan.test.id}" + + site_config { + dotnet_framework_version = "%s" + } +} +`, rInt, location, rInt, rInt, version) +} + +func testAccAzureRMAppService_windowsJava(rInt int, location, javaVersion, container, containerVersion string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_app_service_plan" "test" { + name = "acctestASP-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + + sku { + tier = "Standard" + size = "S1" + } +} + +resource "azurerm_app_service" "test" { + name = "acctestAS-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + app_service_plan_id = "${azurerm_app_service_plan.test.id}" + + site_config { + java_version = "%s" + java_container = "%s" + java_container_version = "%s" + } +} +`, rInt, location, rInt, rInt, javaVersion, container, containerVersion) +} + +func testAccAzureRMAppService_windowsPHP(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_app_service_plan" "test" { + name = "acctestASP-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + + sku { + tier = "Standard" + size = "S1" + } +} + +resource "azurerm_app_service" "test" { + name = "acctestAS-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + app_service_plan_id = "${azurerm_app_service_plan.test.id}" + + site_config { + php_version = "7.1" + } +} +`, rInt, location, rInt, rInt) +} + +func testAccAzureRMAppService_windowsPython(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_app_service_plan" "test" { + name = "acctestASP-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + + sku { + tier = "Standard" + size = "S1" + } +} + +resource "azurerm_app_service" "test" { + name = "acctestAS-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + app_service_plan_id = "${azurerm_app_service_plan.test.id}" + + site_config { + python_version = "3.4" + } +} +`, rInt, location, rInt, rInt) +} + +func testAccAzureRMAppService_webSockets(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_app_service_plan" "test" { + name = "acctestASP-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + + sku { + tier = "Standard" + size = "S1" + } +} + +resource "azurerm_app_service" "test" { + name = "acctestAS-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + app_service_plan_id = "${azurerm_app_service_plan.test.id}" + + site_config { + websockets_enabled = true + } +} +`, rInt, location, rInt, rInt) +} diff --git a/azurerm/resource_arm_application_insights.go b/azurerm/resource_arm_application_insights.go index 1bdc91dd3359..421798e6fdbe 100644 --- a/azurerm/resource_arm_application_insights.go +++ b/azurerm/resource_arm_application_insights.go @@ -28,11 +28,7 @@ func resourceArmApplicationInsights() *schema.Resource { ForceNew: true, }, - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "location": locationSchema(), diff --git a/azurerm/resource_arm_automation_account.go b/azurerm/resource_arm_automation_account.go new file mode 100644 index 000000000000..9d7e8c713b88 --- /dev/null +++ b/azurerm/resource_arm_automation_account.go @@ -0,0 +1,172 @@ +package azurerm + +import ( + "fmt" + "log" + + "github.com/Azure/azure-sdk-for-go/arm/automation" + "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 { + 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": locationSchema(), + + "resource_group_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "sku": { + Type: schema.TypeList, + 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), + }, + }, + }, + }, + "tags": tagsSchema(), + }, + } +} + +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, + }, + + 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 utils.ResponseWasNotFound(resp.Response) { + d.SetId("") + return nil + } + + return fmt.Errorf("Error making Read request on AzureRM Automation Account '%s': %+v", 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 utils.ResponseWasNotFound(resp) { + 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 := make([]interface{}, 1) + + result := map[string]interface{}{} + result["name"] = string(sku.Name) + results[0] = result + + d.Set("sku", &results) +} + +func expandSku(d *schema.ResourceData) automation.Sku { + inputs := d.Get("sku").([]interface{}) + 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..a25c0d99213a --- /dev/null +++ b/azurerm/resource_arm_automation_account_test.go @@ -0,0 +1,147 @@ +package azurerm + +import ( + "fmt" + "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 TestAccAzureRMAutomationAccount_skuBasic(t *testing.T) { + ri := acctest.RandInt() + resourceName := "azurerm_automation_account.test" + 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( + testCheckAzureRMAutomationAccountExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "sku.0.name", "Basic"), + ), + }, + }, + }) +} + +func TestAccAzureRMAutomationAccount_skuFree(t *testing.T) { + ri := acctest.RandInt() + resourceName := "azurerm_automation_account.test" + 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( + testCheckAzureRMAutomationAccountExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "sku.0.name", "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 { + if utils.ResponseWasNotFound(resp.Response) { + return nil + } + + return err + } + + return fmt.Errorf("Automation Account still exists:\n%#v", resp) + } + + return nil +} + +func testCheckAzureRMAutomationAccountExists(name 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"] + 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 { + if utils.ResponseWasNotFound(resp.Response) { + return fmt.Errorf("Automation Account '%s' (resource group: '%s') was not found: %+v", name, resourceGroup, err) + } + + return fmt.Errorf("Bad: Get on automationClient: %s", err) + } + + 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..d76ab4d3c99a --- /dev/null +++ b/azurerm/resource_arm_automation_credential.go @@ -0,0 +1,150 @@ +package azurerm + +import ( + "fmt" + "log" + + "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 { + 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, + }, + + "username": { + Type: schema.TypeString, + Required: true, + }, + + "password": { + Type: schema.TypeString, + Required: true, + Sensitive: true, + }, + "description": { + Type: schema.TypeString, + Optional: 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("username").(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 utils.ResponseWasNotFound(resp.Response) { + d.SetId("") + return nil + } + + 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) + if props := resp.CredentialProperties; props != nil { + d.Set("username", props.UserName) + } + 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 utils.ResponseWasNotFound(resp) { + 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..1cd5c916341e --- /dev/null +++ b/azurerm/resource_arm_automation_credential_test.go @@ -0,0 +1,169 @@ +package azurerm + +import ( + "fmt" + "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_basic(t *testing.T) { + resourceName := "azurerm_automation_credential.test" + ri := acctest.RandInt() + config := testAccAzureRMAutomationCredential_basic(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"), + ), + }, + }, + }) +} + +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"), + ), + }, + }, + }) +} + +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 { + if utils.ResponseWasNotFound(resp.Response) { + return nil + } + + return err + } + + return fmt.Errorf("Automation Credential still exists:\n%#v", resp) + + } + + return nil +} + +func testCheckAzureRMAutomationCredentialExists(name 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 { + if utils.ResponseWasNotFound(resp.Response) { + return fmt.Errorf("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) + } + + return nil + } +} + +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" + 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" + 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..6134055e7f2b --- /dev/null +++ b/azurerm/resource_arm_automation_runbook.go @@ -0,0 +1,252 @@ +package azurerm + +import ( + "fmt" + "log" + + "github.com/Azure/azure-sdk-for-go/arm/automation" + "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 { + 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": locationSchema(), + + "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, + Optional: true, + }, + + "publish_content_link": { + Type: schema.TypeList, + Required: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "uri": { + 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, + }, + }, + }, + }, + }, + }, + }, + "tags": tagsSchema(), + }, + } +} + +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, + }, + + 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 utils.ResponseWasNotFound(resp.Response) { + d.SetId("") + return nil + } + + return fmt.Errorf("Error making Read request on AzureRM Automation Runbook '%s': %+v", name, err) + } + + d.Set("name", resp.Name) + d.Set("location", azureRMNormalizeLocation(*resp.Location)) + d.Set("resource_group_name", resGroup) + + d.Set("account_name", accName) + 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) + } + + 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 utils.ResponseWasNotFound(resp) { + 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").([]interface{}) + input := inputs[0].(map[string]interface{}) + uri := input["uri"].(string) + version := input["version"].(string) + + hashes := input["hash"].([]interface{}) + + if len(hashes) > 0 { + hash := hashes[0].(map[string]interface{}) + hashValue := hash["value"].(string) + hashAlgorithm := hash["algorithm"].(string) + + return automation.ContentLink{ + URI: &uri, + Version: &version, + ContentHash: &automation.ContentHash{ + Algorithm: &hashAlgorithm, + Value: &hashValue, + }, + } + } + + return automation.ContentLink{ + URI: &uri, + Version: &version, + } +} diff --git a/azurerm/resource_arm_automation_runbook_test.go b/azurerm/resource_arm_automation_runbook_test.go new file mode 100644 index 000000000000..16efdbd93013 --- /dev/null +++ b/azurerm/resource_arm_automation_runbook_test.go @@ -0,0 +1,185 @@ +package azurerm + +import ( + "fmt" + "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 TestAccAzureRMAutomationRunbook_PSWorkflow(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, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAutomationRunbookExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "runbook_type", "PowerShellWorkflow"), + ), + }, + }, + }) +} + +func TestAccAzureRMAutomationRunbook_PSWorkflowWithHash(t *testing.T) { + resourceName := "azurerm_automation_runbook.test" + 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( + testCheckAzureRMAutomationRunbookExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "runbook_type", "PowerShellWorkflow"), + ), + }, + }, + }) +} + +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 { + if utils.ResponseWasNotFound(resp.Response) { + return nil + } + + return err + } + + return fmt.Errorf("Automation Runbook still exists:\n%#v", resp) + } + + return nil +} + +func testCheckAzureRMAutomationRunbookExists(name 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 Runbook: '%s'", name) + } + + conn := testAccProvider.Meta().(*ArmClient).automationRunbookClient + + resp, err := conn.Get(resourceGroup, accName, name) + + if err != nil { + if utils.ResponseWasNotFound(resp.Response) { + return fmt.Errorf("Automation Runbook '%s' (resource group: '%s') does not exist", name, resourceGroup) + } + + return fmt.Errorf("Bad: Get on automationRunbookClient: %+v", err) + } + + 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) +} + +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) +} diff --git a/azurerm/resource_arm_automation_schedule.go b/azurerm/resource_arm_automation_schedule.go new file mode 100644 index 000000000000..6d74ba612118 --- /dev/null +++ b/azurerm/resource_arm_automation_schedule.go @@ -0,0 +1,219 @@ +package azurerm + +import ( + "fmt" + "log" + "time" + + "github.com/Azure/azure-sdk-for-go/arm/automation" + "github.com/Azure/go-autorest/autorest/date" + "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 { + 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, + Computed: true, + }, + + "resource_group_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "start_time": { + Type: schema.TypeString, + Required: true, + DiffSuppressFunc: compareDataAsUTCSuppressFunc, + ValidateFunc: validateStartTime, + }, + + "expiry_time": { + Type: schema.TypeString, + DiffSuppressFunc: compareDataAsUTCSuppressFunc, + Optional: true, + Computed: 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), + }, + "timezone": { + Type: schema.TypeString, + Optional: true, + Default: "UTC", + }, + }, + } +} + +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 { + 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.") + + 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) + starttime, tperr := time.Parse(time.RFC3339, cst) + if tperr != nil { + return fmt.Errorf("Cannot parse start_time: %q", cst) + } + + 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) + timezone := d.Get("timezone").(string) + + parameters := automation.ScheduleCreateOrUpdateParameters{ + Name: &name, + ScheduleCreateOrUpdateProperties: &automation.ScheduleCreateOrUpdateProperties{ + Description: &description, + Frequency: freq, + StartTime: &stdt, + ExpiryTime: &etdt, + 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 utils.ResponseWasNotFound(resp.Response) { + d.SetId("") + return nil + } + + return fmt.Errorf("Error making Read request on AzureRM Automation Schedule '%s': %+v", 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("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 +} + +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 utils.ResponseWasNotFound(resp) { + 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..c93804d36d5d --- /dev/null +++ b/azurerm/resource_arm_automation_schedule_test.go @@ -0,0 +1,126 @@ +package azurerm + +import ( + "fmt" + "testing" + "time" + + "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/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +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), + ), + }, + }, + }) +} + +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 { + if utils.ResponseWasNotFound(resp.Response) { + return nil + } + + return err + } + + 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 { + if utils.ResponseWasNotFound(resp.Response) { + return fmt.Errorf("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) + } + return nil + } +} + +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" { + 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" + timezone = "Central Europe Standard Time" + start_time = "%s" + description = "This is a test runbook for terraform acceptance test" +} +`, rInt, location, rInt, rInt, startTime.Format(time.RFC3339)) +} diff --git a/azurerm/resource_arm_availability_set.go b/azurerm/resource_arm_availability_set.go index e2ba5a98edb4..c54c4b206840 100644 --- a/azurerm/resource_arm_availability_set.go +++ b/azurerm/resource_arm_availability_set.go @@ -28,11 +28,7 @@ func resourceArmAvailabilitySet() *schema.Resource { ForceNew: true, }, - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "location": locationSchema(), diff --git a/azurerm/resource_arm_cdn_endpoint.go b/azurerm/resource_arm_cdn_endpoint.go index 0cbde9cf0be3..3fc481f2bc87 100644 --- a/azurerm/resource_arm_cdn_endpoint.go +++ b/azurerm/resource_arm_cdn_endpoint.go @@ -32,11 +32,7 @@ func resourceArmCdnEndpoint() *schema.Resource { "location": locationSchema(), - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "profile_name": { Type: schema.TypeString, diff --git a/azurerm/resource_arm_cdn_profile.go b/azurerm/resource_arm_cdn_profile.go index 64449649bb3a..022c9fca8e7a 100644 --- a/azurerm/resource_arm_cdn_profile.go +++ b/azurerm/resource_arm_cdn_profile.go @@ -29,11 +29,7 @@ func resourceArmCdnProfile() *schema.Resource { "location": locationSchema(), - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "sku": { Type: schema.TypeString, diff --git a/azurerm/resource_arm_container_group.go b/azurerm/resource_arm_container_group.go new file mode 100644 index 000000000000..2627ee9120e3 --- /dev/null +++ b/azurerm/resource_arm_container_group.go @@ -0,0 +1,370 @@ +package azurerm + +import ( + "fmt" + "strings" + + "github.com/Azure/azure-sdk-for-go/arm/containerinstance" + "github.com/hashicorp/terraform/helper/schema" + "github.com/hashicorp/terraform/helper/validation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func resourceArmContainerGroup() *schema.Resource { + return &schema.Resource{ + Create: resourceArmContainerGroupCreate, + Read: resourceArmContainerGroupRead, + Delete: resourceArmContainerGroupDelete, + + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "location": locationSchema(), + + "resource_group_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "ip_address_type": { + Type: schema.TypeString, + Optional: true, + Default: "Public", + ForceNew: true, + DiffSuppressFunc: ignoreCaseDiffSuppressFunc, + ValidateFunc: validation.StringInSlice([]string{ + "Public", + }, true), + }, + + "os_type": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + DiffSuppressFunc: ignoreCaseDiffSuppressFunc, + ValidateFunc: validation.StringInSlice([]string{ + "windows", + "linux", + }, true), + }, + + "tags": tagsForceNewSchema(), + + "ip_address": { + Type: schema.TypeString, + Computed: true, + }, + + "container": { + Type: schema.TypeList, + Required: true, + ForceNew: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "image": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "cpu": { + Type: schema.TypeFloat, + Required: true, + ForceNew: true, + }, + + "memory": { + Type: schema.TypeFloat, + Required: true, + ForceNew: true, + }, + + "port": { + Type: schema.TypeInt, + Optional: true, + ForceNew: true, + ValidateFunc: validation.IntBetween(1, 65535), + }, + + "protocol": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + DiffSuppressFunc: ignoreCaseDiffSuppressFunc, + ValidateFunc: validation.StringInSlice([]string{ + "tcp", + "udp", + }, true), + }, + + "environment_variables": { + Type: schema.TypeMap, + Optional: true, + ForceNew: true, + }, + + "command": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + }, + }, + }, + }, + } +} + +func resourceArmContainerGroupCreate(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient) + containerGroupsClient := client.containerGroupsClient + + // container group properties + resGroup := d.Get("resource_group_name").(string) + name := d.Get("name").(string) + location := d.Get("location").(string) + OSType := d.Get("os_type").(string) + IPAddressType := d.Get("ip_address_type").(string) + tags := d.Get("tags").(map[string]interface{}) + + containers, containerGroupPorts := expandContainerGroupContainers(d) + + containerGroup := containerinstance.ContainerGroup{ + Name: &name, + Location: &location, + Tags: expandTags(tags), + ContainerGroupProperties: &containerinstance.ContainerGroupProperties{ + Containers: containers, + IPAddress: &containerinstance.IPAddress{ + Type: &IPAddressType, + Ports: containerGroupPorts, + }, + OsType: containerinstance.OperatingSystemTypes(OSType), + }, + } + + _, err := containerGroupsClient.CreateOrUpdate(resGroup, name, containerGroup) + if err != nil { + return err + } + + read, err := containerGroupsClient.Get(resGroup, name) + if err != nil { + return err + } + + if read.ID == nil { + return fmt.Errorf("Cannot read container group %s (resource group %s) ID", name, resGroup) + } + + d.SetId(*read.ID) + + return resourceArmContainerGroupRead(d, meta) +} +func resourceArmContainerGroupRead(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient) + containterGroupsClient := client.containerGroupsClient + + id, err := parseAzureResourceID(d.Id()) + + if err != nil { + return err + } + + resGroup := id.ResourceGroup + name := id.Path["containerGroups"] + + resp, err := containterGroupsClient.Get(resGroup, name) + + if err != nil { + if utils.ResponseWasNotFound(resp.Response) { + d.SetId("") + return nil + } + return err + } + + d.Set("name", name) + d.Set("resource_group_name", resGroup) + d.Set("location", azureRMNormalizeLocation(*resp.Location)) + flattenAndSetTags(d, resp.Tags) + + d.Set("os_type", string(resp.OsType)) + if address := resp.IPAddress; address != nil { + d.Set("ip_address_type", address.Type) + d.Set("ip_address", address.IP) + } + + containerConfigs := flattenContainerGroupContainers(resp.Containers) + err = d.Set("container", containerConfigs) + if err != nil { + return fmt.Errorf("Error setting `container`: %+v", err) + } + + return nil +} + +func resourceArmContainerGroupDelete(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient) + containterGroupsClient := client.containerGroupsClient + + id, err := parseAzureResourceID(d.Id()) + + if err != nil { + return err + } + + // container group properties + resGroup := id.ResourceGroup + name := id.Path["containerGroups"] + + resp, err := containterGroupsClient.Delete(resGroup, name) + if err != nil { + if utils.ResponseWasNotFound(resp.Response) { + return nil + } + return err + } + + return nil +} + +func flattenContainerGroupContainers(containers *[]containerinstance.Container) []interface{} { + + containerConfigs := make([]interface{}, 0, len(*containers)) + for _, container := range *containers { + containerConfig := make(map[string]interface{}) + containerConfig["name"] = *container.Name + containerConfig["image"] = *container.Image + + if resources := container.Resources; resources != nil { + if resourceRequests := resources.Requests; resourceRequests != nil { + containerConfig["cpu"] = *resourceRequests.CPU + containerConfig["memory"] = *resourceRequests.MemoryInGB + } + } + + if len(*container.Ports) > 0 { + containerConfig["port"] = *(*container.Ports)[0].Port + } + // protocol isn't returned in container config + + if container.EnvironmentVariables != nil { + if len(*container.EnvironmentVariables) > 0 { + containerConfig["environment_variables"] = flattenContainerEnvironmentVariables(container.EnvironmentVariables) + } + } + + if command := container.Command; command != nil { + containerConfig["command"] = strings.Join(*command, " ") + } + + containerConfigs = append(containerConfigs, containerConfig) + } + + return containerConfigs +} + +func flattenContainerEnvironmentVariables(input *[]containerinstance.EnvironmentVariable) map[string]interface{} { + output := make(map[string]interface{}) + + for _, envVar := range *input { + k := *envVar.Name + v := *envVar.Value + + output[k] = v + } + + return output +} + +func expandContainerGroupContainers(d *schema.ResourceData) (*[]containerinstance.Container, *[]containerinstance.Port) { + containersConfig := d.Get("container").([]interface{}) + containers := make([]containerinstance.Container, 0, len(containersConfig)) + containerGroupPorts := make([]containerinstance.Port, 0, len(containersConfig)) + + for _, containerConfig := range containersConfig { + data := containerConfig.(map[string]interface{}) + + // required + name := data["name"].(string) + image := data["image"].(string) + cpu := data["cpu"].(float64) + memory := data["memory"].(float64) + + container := containerinstance.Container{ + Name: &name, + ContainerProperties: &containerinstance.ContainerProperties{ + Image: &image, + Resources: &containerinstance.ResourceRequirements{ + Requests: &containerinstance.ResourceRequests{ + MemoryInGB: &memory, + CPU: &cpu, + }, + }, + }, + } + + if v, _ := data["port"]; v != 0 { + port := int32(v.(int)) + + // container port (port number) + containerPort := containerinstance.ContainerPort{ + Port: &port, + } + + container.Ports = &[]containerinstance.ContainerPort{containerPort} + + // container group port (port number + protocol) + containerGroupPort := containerinstance.Port{ + Port: &port, + } + + if v, ok := data["protocol"]; ok { + protocol := v.(string) + containerGroupPort.Protocol = containerinstance.ContainerGroupNetworkProtocol(strings.ToUpper(protocol)) + } + + containerGroupPorts = append(containerGroupPorts, containerGroupPort) + } + + if v, ok := data["environment_variables"]; ok { + container.EnvironmentVariables = expandContainerEnvironmentVariables(v) + } + + if v, _ := data["command"]; v != "" { + command := strings.Split(v.(string), " ") + container.Command = &command + } + + containers = append(containers, container) + } + + return &containers, &containerGroupPorts +} + +func expandContainerEnvironmentVariables(input interface{}) *[]containerinstance.EnvironmentVariable { + envVars := input.(map[string]interface{}) + output := make([]containerinstance.EnvironmentVariable, 0, len(envVars)) + + for k, v := range envVars { + ev := containerinstance.EnvironmentVariable{ + Name: utils.String(k), + Value: utils.String(v.(string)), + } + output = append(output, ev) + } + + return &output +} diff --git a/azurerm/resource_arm_container_group_test.go b/azurerm/resource_arm_container_group_test.go new file mode 100644 index 000000000000..375a8d6061cb --- /dev/null +++ b/azurerm/resource_arm_container_group_test.go @@ -0,0 +1,358 @@ +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 TestAccAzureRMContainerGroup_linuxBasic(t *testing.T) { + resourceName := "azurerm_container_group.test" + ri := acctest.RandInt() + + config := testAccAzureRMContainerGroup_linuxBasic(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMContainerGroupDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMContainerGroupExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "container.#", "1"), + resource.TestCheckResourceAttr(resourceName, "os_type", "Linux"), + ), + }, + }, + }) +} + +func TestAccAzureRMContainerGroup_linuxBasicUpdate(t *testing.T) { + resourceName := "azurerm_container_group.test" + ri := acctest.RandInt() + + config := testAccAzureRMContainerGroup_linuxBasic(ri, testLocation()) + updatedConfig := testAccAzureRMContainerGroup_linuxBasicUpdated(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMContainerGroupDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMContainerGroupExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "container.#", "1"), + ), + }, + { + Config: updatedConfig, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMContainerGroupExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "container.#", "2"), + ), + }, + }, + }) +} + +func TestAccAzureRMContainerGroup_linuxComplete(t *testing.T) { + resourceName := "azurerm_container_group.test" + ri := acctest.RandInt() + + config := testAccAzureRMContainerGroup_linuxComplete(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMContainerGroupDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMContainerGroupExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "container.#", "1"), + resource.TestCheckResourceAttr(resourceName, "container.0.command", "/bin/bash -c ls"), + resource.TestCheckResourceAttr(resourceName, "container.0.environment_variables.%", "2"), + resource.TestCheckResourceAttr(resourceName, "container.0.environment_variables.foo", "bar"), + resource.TestCheckResourceAttr(resourceName, "container.0.environment_variables.foo1", "bar1"), + resource.TestCheckResourceAttr(resourceName, "os_type", "Linux"), + ), + }, + }, + }) +} + +func TestAccAzureRMContainerGroup_windowsBasic(t *testing.T) { + resourceName := "azurerm_container_group.test" + ri := acctest.RandInt() + + config := testAccAzureRMContainerGroup_windowsBasic(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMContainerGroupDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMContainerGroupExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "container.#", "1"), + resource.TestCheckResourceAttr(resourceName, "os_type", "Windows"), + ), + }, + }, + }) +} + +func TestAccAzureRMContainerGroup_windowsComplete(t *testing.T) { + resourceName := "azurerm_container_group.test" + ri := acctest.RandInt() + + config := testAccAzureRMContainerGroup_windowsComplete(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMContainerGroupDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMContainerGroupExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "container.#", "1"), + resource.TestCheckResourceAttr(resourceName, "container.0.command", "cmd.exe echo hi"), + resource.TestCheckResourceAttr(resourceName, "container.0.environment_variables.%", "2"), + resource.TestCheckResourceAttr(resourceName, "container.0.environment_variables.foo", "bar"), + resource.TestCheckResourceAttr(resourceName, "container.0.environment_variables.foo1", "bar1"), + resource.TestCheckResourceAttr(resourceName, "os_type", "Windows"), + ), + }, + }, + }) +} + +func testAccAzureRMContainerGroup_linuxBasic(ri int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_container_group" "test" { + name = "acctestcontainergroup-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + ip_address_type = "public" + os_type = "linux" + + container { + name = "hw" + image = "microsoft/aci-helloworld:latest" + cpu = "0.5" + memory = "0.5" + port = "80" + } + + tags { + environment = "testing" + } +} +`, ri, location, ri) +} + +func testAccAzureRMContainerGroup_linuxBasicUpdated(ri int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_container_group" "test" { + name = "acctestcontainergroup-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + ip_address_type = "public" + os_type = "linux" + + container { + name = "hw" + image = "microsoft/aci-helloworld:latest" + cpu = "0.5" + memory = "0.5" + port = "80" + } + + container { + name = "sidecar" + image = "microsoft/aci-tutorial-sidecar" + cpu = "0.5" + memory = "0.5" + } + + tags { + environment = "testing" + } +} +`, ri, location, ri) +} + +func testAccAzureRMContainerGroup_linuxComplete(ri int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_container_group" "test" { + name = "acctestcontainergroup-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + ip_address_type = "public" + os_type = "linux" + + container { + name = "hw" + image = "microsoft/aci-helloworld:latest" + cpu = "0.5" + memory = "0.5" + port = "80" + environment_variables { + "foo" = "bar" + "foo1" = "bar1" + } + command = "/bin/bash -c ls" + } + + tags { + environment = "testing" + } +} +`, ri, location, ri) +} + +func testAccAzureRMContainerGroup_windowsBasic(ri int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_container_group" "test" { + name = "acctestcontainergroup-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + ip_address_type = "public" + os_type = "windows" + + container { + name = "winapp" + image = "winappimage:latest" + cpu = "2.0" + memory = "3.5" + port = "80" + } + + tags { + environment = "testing" + } +} +`, ri, location, ri) +} + +func testAccAzureRMContainerGroup_windowsComplete(ri int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_container_group" "test" { + name = "acctestcontainergroup-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + ip_address_type = "public" + os_type = "windows" + + container { + name = "winapp" + image = "winappimage:latest" + cpu = "2.0" + memory = "3.5" + port = "80" + environment_variables { + "foo" = "bar" + "foo1" = "bar1" + } + command = "cmd.exe echo hi" + } + + tags { + environment = "testing" + } +} +`, ri, location, ri) +} + +func testCheckAzureRMContainerGroupExists(name 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"] + resourceGroup, hasResourceGroup := rs.Primary.Attributes["resource_group_name"] + if !hasResourceGroup { + return fmt.Errorf("Bad: no resource group found in state for Container Registry: %s", name) + } + + conn := testAccProvider.Meta().(*ArmClient).containerGroupsClient + + resp, err := conn.Get(resourceGroup, name) + if err != nil { + if utils.ResponseWasNotFound(resp.Response) { + return fmt.Errorf("Bad: Container Group %q (resource group: %q) does not exist", name, resourceGroup) + } + return fmt.Errorf("Bad: Get on containerGroupsClient: %+v", err) + } + + return nil + } +} + +func testCheckAzureRMContainerGroupDestroy(s *terraform.State) error { + conn := testAccProvider.Meta().(*ArmClient).containerGroupsClient + + for _, rs := range s.RootModule().Resources { + if rs.Type != "azurerm_container_group" { + continue + } + + name := rs.Primary.Attributes["name"] + resourceGroup := rs.Primary.Attributes["resource_group_name"] + + resp, err := conn.Get(resourceGroup, name) + + if err != nil { + if resp.StatusCode != http.StatusNotFound { + return fmt.Errorf("Container Group still exists:\n%#v", resp) + } + + return nil + } + + } + + return nil +} diff --git a/azurerm/resource_arm_container_registry.go b/azurerm/resource_arm_container_registry.go index 2f51b224bf66..72e85462d314 100644 --- a/azurerm/resource_arm_container_registry.go +++ b/azurerm/resource_arm_container_registry.go @@ -33,11 +33,7 @@ func resourceArmContainerRegistry() *schema.Resource { ValidateFunc: validateAzureRMContainerRegistryName, }, - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "location": locationSchema(), diff --git a/azurerm/resource_arm_container_service.go b/azurerm/resource_arm_container_service.go index 629a388b0de1..2cc9ca285e87 100644 --- a/azurerm/resource_arm_container_service.go +++ b/azurerm/resource_arm_container_service.go @@ -33,11 +33,7 @@ func resourceArmContainerService() *schema.Resource { "location": locationSchema(), - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "orchestration_platform": { Type: schema.TypeString, diff --git a/azurerm/resource_arm_cosmos_db_account.go b/azurerm/resource_arm_cosmos_db_account.go index 08081a16484b..eacbc5ec11b6 100644 --- a/azurerm/resource_arm_cosmos_db_account.go +++ b/azurerm/resource_arm_cosmos_db_account.go @@ -5,7 +5,6 @@ import ( "fmt" "log" "net/http" - "regexp" "github.com/Azure/azure-sdk-for-go/arm/cosmos-db" "github.com/hashicorp/terraform/helper/hashcode" @@ -29,7 +28,7 @@ func resourceArmCosmosDBAccount() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - ValidateFunc: validateAzureRmCosmosDBAccountName, + ValidateFunc: validateDBAccountName, }, "location": { @@ -39,11 +38,7 @@ func resourceArmCosmosDBAccount() *schema.Resource { StateFunc: azureRMNormalizeLocation, }, - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "offer_type": { Type: schema.TypeString, @@ -410,19 +405,3 @@ func resourceAzureRMCosmosDBAccountFailoverPolicyHash(v interface{}) int { return hashcode.String(buf.String()) } - -func validateAzureRmCosmosDBAccountName(v interface{}, k string) (ws []string, errors []error) { - value := v.(string) - - r, _ := regexp.Compile("^[a-z0-9\\-]+$") - if !r.MatchString(value) { - errors = append(errors, fmt.Errorf("CosmosDB Account Name can only contain lower-case characters, numbers and the `-` character.")) - } - - length := len(value) - if length > 50 || 3 > length { - errors = append(errors, fmt.Errorf("CosmosDB Account Name can only be between 3 and 50 seconds.")) - } - - return -} diff --git a/azurerm/resource_arm_cosmos_db_account_test.go b/azurerm/resource_arm_cosmos_db_account_test.go index a4b3a902bd82..2da692c91a4b 100644 --- a/azurerm/resource_arm_cosmos_db_account_test.go +++ b/azurerm/resource_arm_cosmos_db_account_test.go @@ -60,47 +60,6 @@ func testSweepCosmosDBAccount(region string) error { return nil } -func TestAccAzureRMCosmosDBAccountName_validation(t *testing.T) { - str := acctest.RandString(50) - cases := []struct { - Value string - ErrCount int - }{ - { - Value: "ab", - ErrCount: 1, - }, - { - Value: "abc", - ErrCount: 0, - }, - { - Value: "cosmosDBAccount1", - ErrCount: 1, - }, - { - Value: "hello-world", - ErrCount: 0, - }, - { - Value: str, - ErrCount: 0, - }, - { - Value: str + "a", - ErrCount: 1, - }, - } - - for _, tc := range cases { - _, errors := validateAzureRmCosmosDBAccountName(tc.Value, "azurerm_cosmosdb_account") - - if len(errors) != tc.ErrCount { - t.Fatalf("Expected the AzureRM CosmosDB Name to trigger a validation error for '%s'", tc.Value) - } - } -} - func TestAccAzureRMCosmosDBAccount_boundedStaleness(t *testing.T) { resourceName := "azurerm_cosmosdb_account.test" ri := acctest.RandInt() diff --git a/azurerm/resource_arm_dns_a_record.go b/azurerm/resource_arm_dns_a_record.go index e29b13551d1f..058602de3cfd 100644 --- a/azurerm/resource_arm_dns_a_record.go +++ b/azurerm/resource_arm_dns_a_record.go @@ -26,11 +26,7 @@ func resourceArmDnsARecord() *schema.Resource { ForceNew: true, }, - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "zone_name": { Type: schema.TypeString, diff --git a/azurerm/resource_arm_dns_aaaa_record.go b/azurerm/resource_arm_dns_aaaa_record.go index 9e0ab237cf77..127bdd02a7bf 100644 --- a/azurerm/resource_arm_dns_aaaa_record.go +++ b/azurerm/resource_arm_dns_aaaa_record.go @@ -26,11 +26,7 @@ func resourceArmDnsAAAARecord() *schema.Resource { ForceNew: true, }, - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "zone_name": { Type: schema.TypeString, diff --git a/azurerm/resource_arm_dns_cname_record.go b/azurerm/resource_arm_dns_cname_record.go index 80d518e07d60..4e7465ccd1eb 100644 --- a/azurerm/resource_arm_dns_cname_record.go +++ b/azurerm/resource_arm_dns_cname_record.go @@ -26,11 +26,7 @@ func resourceArmDnsCNameRecord() *schema.Resource { ForceNew: true, }, - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "zone_name": { Type: schema.TypeString, diff --git a/azurerm/resource_arm_dns_mx_record.go b/azurerm/resource_arm_dns_mx_record.go index d036396bb9e6..d9b138524518 100644 --- a/azurerm/resource_arm_dns_mx_record.go +++ b/azurerm/resource_arm_dns_mx_record.go @@ -29,11 +29,7 @@ func resourceArmDnsMxRecord() *schema.Resource { ForceNew: true, }, - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "zone_name": { Type: schema.TypeString, diff --git a/azurerm/resource_arm_dns_ns_record.go b/azurerm/resource_arm_dns_ns_record.go index b8724af3f710..5fb699610bce 100644 --- a/azurerm/resource_arm_dns_ns_record.go +++ b/azurerm/resource_arm_dns_ns_record.go @@ -26,11 +26,7 @@ func resourceArmDnsNsRecord() *schema.Resource { ForceNew: true, }, - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "zone_name": { Type: schema.TypeString, diff --git a/azurerm/resource_arm_dns_ptr_record.go b/azurerm/resource_arm_dns_ptr_record.go index 5cade63b3696..0bcca7658bbd 100644 --- a/azurerm/resource_arm_dns_ptr_record.go +++ b/azurerm/resource_arm_dns_ptr_record.go @@ -26,11 +26,7 @@ func resourceArmDnsPtrRecord() *schema.Resource { ForceNew: true, }, - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "zone_name": { Type: schema.TypeString, diff --git a/azurerm/resource_arm_dns_srv_record.go b/azurerm/resource_arm_dns_srv_record.go index b254026e62a5..0f5132eec53e 100644 --- a/azurerm/resource_arm_dns_srv_record.go +++ b/azurerm/resource_arm_dns_srv_record.go @@ -28,11 +28,7 @@ func resourceArmDnsSrvRecord() *schema.Resource { ForceNew: true, }, - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "zone_name": { Type: schema.TypeString, diff --git a/azurerm/resource_arm_dns_txt_record.go b/azurerm/resource_arm_dns_txt_record.go index 57eb47e42260..281e201682d9 100644 --- a/azurerm/resource_arm_dns_txt_record.go +++ b/azurerm/resource_arm_dns_txt_record.go @@ -26,11 +26,7 @@ func resourceArmDnsTxtRecord() *schema.Resource { ForceNew: true, }, - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "zone_name": { Type: schema.TypeString, diff --git a/azurerm/resource_arm_dns_zone.go b/azurerm/resource_arm_dns_zone.go index 9d8414a927ae..073ec6aa40b1 100644 --- a/azurerm/resource_arm_dns_zone.go +++ b/azurerm/resource_arm_dns_zone.go @@ -25,12 +25,7 @@ func resourceArmDnsZone() *schema.Resource { ForceNew: true, }, - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - DiffSuppressFunc: resourceAzurermResourceGroupNameDiffSuppress, - }, + "resource_group_name": resourceGroupNameDiffSuppressSchema(), "number_of_record_sets": { Type: schema.TypeString, diff --git a/azurerm/resource_arm_eventgrid_topic.go b/azurerm/resource_arm_eventgrid_topic.go index 0bb954848c99..6620501ad777 100644 --- a/azurerm/resource_arm_eventgrid_topic.go +++ b/azurerm/resource_arm_eventgrid_topic.go @@ -28,11 +28,7 @@ func resourceArmEventGridTopic() *schema.Resource { "location": locationSchema(), - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "tags": tagsSchema(), diff --git a/azurerm/resource_arm_eventhub.go b/azurerm/resource_arm_eventhub.go index 07b208a87ea7..6f83b88e4a95 100644 --- a/azurerm/resource_arm_eventhub.go +++ b/azurerm/resource_arm_eventhub.go @@ -33,11 +33,7 @@ func resourceArmEventHub() *schema.Resource { ForceNew: true, }, - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "location": locationSchema(), diff --git a/azurerm/resource_arm_eventhub_authorization_rule.go b/azurerm/resource_arm_eventhub_authorization_rule.go index d8bc0163308f..a87c65645ddb 100644 --- a/azurerm/resource_arm_eventhub_authorization_rule.go +++ b/azurerm/resource_arm_eventhub_authorization_rule.go @@ -39,11 +39,7 @@ func resourceArmEventHubAuthorizationRule() *schema.Resource { ForceNew: true, }, - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "location": locationSchema(), diff --git a/azurerm/resource_arm_eventhub_consumer_group.go b/azurerm/resource_arm_eventhub_consumer_group.go index 17f50452288c..75021193c1c3 100644 --- a/azurerm/resource_arm_eventhub_consumer_group.go +++ b/azurerm/resource_arm_eventhub_consumer_group.go @@ -39,11 +39,7 @@ func resourceArmEventHubConsumerGroup() *schema.Resource { ForceNew: true, }, - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "location": locationSchema(), diff --git a/azurerm/resource_arm_eventhub_namespace.go b/azurerm/resource_arm_eventhub_namespace.go index fd7bd2d7153f..d6e3c3df38d5 100644 --- a/azurerm/resource_arm_eventhub_namespace.go +++ b/azurerm/resource_arm_eventhub_namespace.go @@ -35,11 +35,7 @@ func resourceArmEventHubNamespace() *schema.Resource { "location": locationSchema(), - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "sku": { Type: schema.TypeString, diff --git a/azurerm/resource_arm_express_route_circuit.go b/azurerm/resource_arm_express_route_circuit.go index a241dcc4e4df..824217deeb69 100644 --- a/azurerm/resource_arm_express_route_circuit.go +++ b/azurerm/resource_arm_express_route_circuit.go @@ -31,11 +31,7 @@ func resourceArmExpressRouteCircuit() *schema.Resource { ForceNew: true, }, - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "location": locationSchema(), diff --git a/azurerm/resource_arm_image.go b/azurerm/resource_arm_image.go index b762e6db727a..6d04db4ddfeb 100644 --- a/azurerm/resource_arm_image.go +++ b/azurerm/resource_arm_image.go @@ -29,11 +29,7 @@ func resourceArmImage() *schema.Resource { "location": locationSchema(), - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "source_virtual_machine_id": { Type: schema.TypeString, diff --git a/azurerm/resource_arm_key_vault.go b/azurerm/resource_arm_key_vault.go index 80e6000399ec..cd813f0940f0 100644 --- a/azurerm/resource_arm_key_vault.go +++ b/azurerm/resource_arm_key_vault.go @@ -37,11 +37,7 @@ func resourceArmKeyVault() *schema.Resource { "location": locationSchema(), - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "sku": { Type: schema.TypeSet, @@ -88,6 +84,34 @@ func resourceArmKeyVault() *schema.Resource { Required: true, ValidateFunc: validateUUID, }, + "application_id": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validateUUID, + }, + "certificate_permissions": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.StringInSlice([]string{ + string(keyvault.All), + string(keyvault.Create), + string(keyvault.Delete), + string(keyvault.Deleteissuers), + string(keyvault.Get), + string(keyvault.Getissuers), + string(keyvault.Import), + string(keyvault.List), + string(keyvault.Listissuers), + string(keyvault.Managecontacts), + string(keyvault.Manageissuers), + string(keyvault.Setissuers), + string(keyvault.Update), + }, true), + DiffSuppressFunc: ignoreCaseDiffSuppressFunc, + }, + }, "key_permissions": { Type: schema.TypeList, Required: true, @@ -109,7 +133,8 @@ func resourceArmKeyVault() *schema.Resource { string(keyvault.KeyPermissionsUpdate), string(keyvault.KeyPermissionsVerify), string(keyvault.KeyPermissionsWrapKey), - }, false), + }, true), + DiffSuppressFunc: ignoreCaseDiffSuppressFunc, }, }, "secret_permissions": { @@ -123,7 +148,8 @@ func resourceArmKeyVault() *schema.Resource { string(keyvault.SecretPermissionsGet), string(keyvault.SecretPermissionsList), string(keyvault.SecretPermissionsSet), - }, false), + }, true), + DiffSuppressFunc: ignoreCaseDiffSuppressFunc, }, }, }, @@ -261,6 +287,12 @@ func expandKeyVaultAccessPolicies(d *schema.ResourceData) *[]keyvault.AccessPoli for _, policySet := range policies { policyRaw := policySet.(map[string]interface{}) + certificatePermissionsRaw := policyRaw["certificate_permissions"].([]interface{}) + certificatePermissions := []keyvault.CertificatePermissions{} + for _, permission := range certificatePermissionsRaw { + certificatePermissions = append(certificatePermissions, keyvault.CertificatePermissions(permission.(string))) + } + keyPermissionsRaw := policyRaw["key_permissions"].([]interface{}) keyPermissions := []keyvault.KeyPermissions{} for _, permission := range keyPermissionsRaw { @@ -275,8 +307,9 @@ func expandKeyVaultAccessPolicies(d *schema.ResourceData) *[]keyvault.AccessPoli policy := keyvault.AccessPolicyEntry{ Permissions: &keyvault.Permissions{ - Keys: &keyPermissions, - Secrets: &secretPermissions, + Certificates: &certificatePermissions, + Keys: &keyPermissions, + Secrets: &secretPermissions, }, } @@ -285,6 +318,11 @@ func expandKeyVaultAccessPolicies(d *schema.ResourceData) *[]keyvault.AccessPoli objectUUID := policyRaw["object_id"].(string) policy.ObjectID = &objectUUID + if v := policyRaw["application_id"]; v != "" { + applicationUUID := uuid.FromStringOrNil(v.(string)) + policy.ApplicationID = &applicationUUID + } + result = append(result, policy) } @@ -305,6 +343,11 @@ func flattenKeyVaultAccessPolicies(policies *[]keyvault.AccessPolicyEntry) []int for _, policy := range *policies { policyRaw := make(map[string]interface{}) + certificatePermissionsRaw := make([]interface{}, 0, len(*policy.Permissions.Keys)) + for _, certificatePermission := range *policy.Permissions.Certificates { + certificatePermissionsRaw = append(certificatePermissionsRaw, string(certificatePermission)) + } + keyPermissionsRaw := make([]interface{}, 0, len(*policy.Permissions.Keys)) for _, keyPermission := range *policy.Permissions.Keys { keyPermissionsRaw = append(keyPermissionsRaw, string(keyPermission)) @@ -317,6 +360,10 @@ func flattenKeyVaultAccessPolicies(policies *[]keyvault.AccessPolicyEntry) []int policyRaw["tenant_id"] = policy.TenantID.String() policyRaw["object_id"] = *policy.ObjectID + if policy.ApplicationID != nil { + policyRaw["application_id"] = policy.ApplicationID.String() + } + policyRaw["certificate_permissions"] = certificatePermissionsRaw policyRaw["key_permissions"] = keyPermissionsRaw policyRaw["secret_permissions"] = secretPermissionsRaw diff --git a/azurerm/resource_arm_key_vault_test.go b/azurerm/resource_arm_key_vault_test.go index c03a702bf64f..a9c232a28f24 100644 --- a/azurerm/resource_arm_key_vault_test.go +++ b/azurerm/resource_arm_key_vault_test.go @@ -87,6 +87,27 @@ func TestAccAzureRMKeyVault_basic(t *testing.T) { }) } +func TestAccAzureRMKeyVault_complete(t *testing.T) { + resourceName := "azurerm_key_vault.test" + ri := acctest.RandInt() + config := testAccAzureRMKeyVault_complete(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMKeyVaultDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMKeyVaultExists(resourceName), + resource.TestCheckResourceAttrSet(resourceName, "access_policy.0.application_id"), + ), + }, + }, + }) +} + func TestAccAzureRMKeyVault_update(t *testing.T) { ri := acctest.RandInt() resourceName := "azurerm_key_vault.test" @@ -257,3 +278,47 @@ resource "azurerm_key_vault" "test" { } `, rInt, location, rInt) } + +func testAccAzureRMKeyVault_complete(rInt int, location string) string { + return fmt.Sprintf(` +data "azurerm_client_config" "current" {} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_key_vault" "test" { + name = "vault%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + tenant_id = "${data.azurerm_client_config.current.tenant_id}" + + sku { + name = "premium" + } + + access_policy { + tenant_id = "${data.azurerm_client_config.current.tenant_id}" + object_id = "${data.azurerm_client_config.current.client_id}" + application_id = "${data.azurerm_client_config.current.service_principal_application_id}" + + certificate_permissions = [ + "get", + ] + + key_permissions = [ + "get", + ] + + secret_permissions = [ + "get", + ] + } + + tags { + environment = "Production" + } +} +`, rInt, location, rInt) +} diff --git a/azurerm/resource_arm_loadbalancer.go b/azurerm/resource_arm_loadbalancer.go index 751ae690cfe0..9f7aaac1b6ff 100644 --- a/azurerm/resource_arm_loadbalancer.go +++ b/azurerm/resource_arm_loadbalancer.go @@ -31,11 +31,7 @@ func resourceArmLoadBalancer() *schema.Resource { "location": locationSchema(), - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "frontend_ip_configuration": { Type: schema.TypeList, diff --git a/azurerm/resource_arm_loadbalancer_backend_address_pool.go b/azurerm/resource_arm_loadbalancer_backend_address_pool.go index 9aaff61c5336..04f210c98308 100644 --- a/azurerm/resource_arm_loadbalancer_backend_address_pool.go +++ b/azurerm/resource_arm_loadbalancer_backend_address_pool.go @@ -30,11 +30,7 @@ func resourceArmLoadBalancerBackendAddressPool() *schema.Resource { "location": deprecatedLocationSchema(), - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "loadbalancer_id": { Type: schema.TypeString, diff --git a/azurerm/resource_arm_loadbalancer_nat_pool.go b/azurerm/resource_arm_loadbalancer_nat_pool.go index bb78f746e843..02762fb93cbb 100644 --- a/azurerm/resource_arm_loadbalancer_nat_pool.go +++ b/azurerm/resource_arm_loadbalancer_nat_pool.go @@ -31,11 +31,7 @@ func resourceArmLoadBalancerNatPool() *schema.Resource { "location": deprecatedLocationSchema(), - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "loadbalancer_id": { Type: schema.TypeString, diff --git a/azurerm/resource_arm_loadbalancer_nat_rule.go b/azurerm/resource_arm_loadbalancer_nat_rule.go index 54868a5fe724..d56929b19c5c 100644 --- a/azurerm/resource_arm_loadbalancer_nat_rule.go +++ b/azurerm/resource_arm_loadbalancer_nat_rule.go @@ -31,11 +31,7 @@ func resourceArmLoadBalancerNatRule() *schema.Resource { "location": deprecatedLocationSchema(), - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "loadbalancer_id": { Type: schema.TypeString, diff --git a/azurerm/resource_arm_loadbalancer_probe.go b/azurerm/resource_arm_loadbalancer_probe.go index e19bb1c4936f..bafa3d61568d 100644 --- a/azurerm/resource_arm_loadbalancer_probe.go +++ b/azurerm/resource_arm_loadbalancer_probe.go @@ -31,11 +31,7 @@ func resourceArmLoadBalancerProbe() *schema.Resource { "location": deprecatedLocationSchema(), - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "loadbalancer_id": { Type: schema.TypeString, diff --git a/azurerm/resource_arm_loadbalancer_rule.go b/azurerm/resource_arm_loadbalancer_rule.go index 2b4f0ee27263..4c2bda5aa7f6 100644 --- a/azurerm/resource_arm_loadbalancer_rule.go +++ b/azurerm/resource_arm_loadbalancer_rule.go @@ -33,11 +33,7 @@ func resourceArmLoadBalancerRule() *schema.Resource { "location": deprecatedLocationSchema(), - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "loadbalancer_id": { Type: schema.TypeString, diff --git a/azurerm/resource_arm_local_network_gateway.go b/azurerm/resource_arm_local_network_gateway.go index b4ebccd1ea66..a0384371c1e6 100644 --- a/azurerm/resource_arm_local_network_gateway.go +++ b/azurerm/resource_arm_local_network_gateway.go @@ -28,11 +28,7 @@ func resourceArmLocalNetworkGateway() *schema.Resource { "location": locationSchema(), - "resource_group_name": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "gateway_address": { Type: schema.TypeString, diff --git a/azurerm/resource_arm_managed_disk.go b/azurerm/resource_arm_managed_disk.go index de24007c334e..398af4b5abbf 100644 --- a/azurerm/resource_arm_managed_disk.go +++ b/azurerm/resource_arm_managed_disk.go @@ -30,11 +30,7 @@ func resourceArmManagedDisk() *schema.Resource { "location": locationSchema(), - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "storage_account_type": { Type: schema.TypeString, diff --git a/azurerm/resource_arm_network_interface.go b/azurerm/resource_arm_network_interface.go index 9b8b7d7a5c97..af46d689e491 100644 --- a/azurerm/resource_arm_network_interface.go +++ b/azurerm/resource_arm_network_interface.go @@ -30,11 +30,7 @@ func resourceArmNetworkInterface() *schema.Resource { "location": locationSchema(), - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "network_security_group_id": { Type: schema.TypeString, diff --git a/azurerm/resource_arm_network_security_group.go b/azurerm/resource_arm_network_security_group.go index b74c0a3bb181..d3e10c4615eb 100644 --- a/azurerm/resource_arm_network_security_group.go +++ b/azurerm/resource_arm_network_security_group.go @@ -34,11 +34,7 @@ func resourceArmNetworkSecurityGroup() *schema.Resource { "location": locationSchema(), - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "security_rule": { Type: schema.TypeSet, diff --git a/azurerm/resource_arm_network_security_rule.go b/azurerm/resource_arm_network_security_rule.go index eeba5a126392..14e733dc62a4 100644 --- a/azurerm/resource_arm_network_security_rule.go +++ b/azurerm/resource_arm_network_security_rule.go @@ -25,11 +25,7 @@ func resourceArmNetworkSecurityRule() *schema.Resource { ForceNew: true, }, - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "network_security_group_name": { Type: schema.TypeString, diff --git a/azurerm/resource_arm_postgresql_configuration.go b/azurerm/resource_arm_postgresql_configuration.go index 2b8c252aca79..dd32bc8c2232 100644 --- a/azurerm/resource_arm_postgresql_configuration.go +++ b/azurerm/resource_arm_postgresql_configuration.go @@ -25,11 +25,7 @@ func resourceArmPostgreSQLConfiguration() *schema.Resource { ForceNew: true, }, - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "server_name": { Type: schema.TypeString, diff --git a/azurerm/resource_arm_postgresql_database.go b/azurerm/resource_arm_postgresql_database.go index e1445c75befc..f139ca30d925 100644 --- a/azurerm/resource_arm_postgresql_database.go +++ b/azurerm/resource_arm_postgresql_database.go @@ -25,11 +25,7 @@ func resourceArmPostgreSQLDatabase() *schema.Resource { ForceNew: true, }, - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "server_name": { Type: schema.TypeString, diff --git a/azurerm/resource_arm_postgresql_firewall_rule.go b/azurerm/resource_arm_postgresql_firewall_rule.go index c44c0d653cd6..8844eee6aebb 100644 --- a/azurerm/resource_arm_postgresql_firewall_rule.go +++ b/azurerm/resource_arm_postgresql_firewall_rule.go @@ -25,11 +25,7 @@ func resourceArmPostgreSQLFirewallRule() *schema.Resource { ForceNew: true, }, - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "server_name": { Type: schema.TypeString, diff --git a/azurerm/resource_arm_postgresql_server.go b/azurerm/resource_arm_postgresql_server.go index 11994e8e2bb0..a1b35cea27b6 100644 --- a/azurerm/resource_arm_postgresql_server.go +++ b/azurerm/resource_arm_postgresql_server.go @@ -30,11 +30,7 @@ func resourceArmPostgreSQLServer() *schema.Resource { "location": locationSchema(), - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "sku": { Type: schema.TypeSet, @@ -102,7 +98,13 @@ func resourceArmPostgreSQLServer() *schema.Resource { ForceNew: true, ValidateFunc: validateIntInSlice([]int{ 51200, - 102400, + 179200, + 307200, + 435200, + 563200, + 691200, + 819200, + 947200, }), }, diff --git a/azurerm/resource_arm_postgresql_server_test.go b/azurerm/resource_arm_postgresql_server_test.go index 97c0238391f4..0fa30665e944 100644 --- a/azurerm/resource_arm_postgresql_server_test.go +++ b/azurerm/resource_arm_postgresql_server_test.go @@ -58,6 +58,30 @@ func TestAccAzureRMPostgreSQLServer_basicNinePointSix(t *testing.T) { }) } +func TestAccAzureRMPostgreSQLServer_basicMaxStorage(t *testing.T) { + resourceName := "azurerm_postgresql_server.test" + ri := acctest.RandInt() + config := testAccAzureRMPostgreSQLServer_basicMaxStorage(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMPostgreSQLServerDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMPostgreSQLServerExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "administrator_login", "acctestun"), + resource.TestCheckResourceAttr(resourceName, "version", "9.6"), + resource.TestCheckResourceAttr(resourceName, "storage_mb", "947200"), + resource.TestCheckResourceAttr(resourceName, "ssl_enforcement", "Enabled"), + ), + }, + }, + }) +} + func TestAccAzureRMPostgreSQLServer_updatePassword(t *testing.T) { resourceName := "azurerm_postgresql_server.test" ri := acctest.RandInt() @@ -223,3 +247,30 @@ resource "azurerm_postgresql_server" "test" { `, rInt, location, rInt) } + +func testAccAzureRMPostgreSQLServer_basicMaxStorage(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_postgresql_server" "test" { + name = "acctestpsqlsvr-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + + sku { + name = "PGSQLB50" + capacity = 50 + tier = "Basic" + } + + administrator_login = "acctestun" + administrator_login_password = "H@Sh1CoR3!" + version = "9.6" + storage_mb = 947200 + ssl_enforcement = "Enabled" +} +`, rInt, location, rInt) +} diff --git a/azurerm/resource_arm_public_ip.go b/azurerm/resource_arm_public_ip.go index 4526f19c9448..c7a01129f252 100644 --- a/azurerm/resource_arm_public_ip.go +++ b/azurerm/resource_arm_public_ip.go @@ -18,7 +18,17 @@ func resourceArmPublicIp() *schema.Resource { Update: resourceArmPublicIpCreate, Delete: resourceArmPublicIpDelete, Importer: &schema.ResourceImporter{ - State: schema.ImportStatePassthrough, + State: func(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { + id, err := parseAzureResourceID(d.Id()) + if err != nil { + return nil, err + } + name := id.Path["publicIPAddresses"] + if name == "" { + return nil, fmt.Errorf("Error parsing supplied resource id. Please check it and rerun:\n %s", d.Id()) + } + return []*schema.ResourceData{d}, nil + }, }, Schema: map[string]*schema.Schema{ @@ -30,11 +40,7 @@ func resourceArmPublicIp() *schema.Resource { "location": locationSchema(), - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "public_ip_address_allocation": { Type: schema.TypeString, diff --git a/azurerm/resource_arm_redis_cache.go b/azurerm/resource_arm_redis_cache.go index 370fdf744227..f25c321d66d0 100644 --- a/azurerm/resource_arm_redis_cache.go +++ b/azurerm/resource_arm_redis_cache.go @@ -36,11 +36,7 @@ func resourceArmRedisCache() *schema.Resource { StateFunc: azureRMNormalizeLocation, }, - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "capacity": { Type: schema.TypeInt, diff --git a/azurerm/resource_arm_resource_group.go b/azurerm/resource_arm_resource_group.go index c8ad4e9fa8a8..d8c248d1d3b6 100644 --- a/azurerm/resource_arm_resource_group.go +++ b/azurerm/resource_arm_resource_group.go @@ -3,8 +3,6 @@ package azurerm import ( "fmt" "log" - "regexp" - "strings" "github.com/Azure/azure-sdk-for-go/arm/resources/resources" "github.com/hashicorp/terraform/helper/schema" @@ -23,12 +21,7 @@ func resourceArmResourceGroup() *schema.Resource { }, Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validateArmResourceGroupName, - }, + "name": resourceGroupNameSchema(), "location": locationSchema(), @@ -135,22 +128,3 @@ func resourceArmResourceGroupDelete(d *schema.ResourceData, meta interface{}) er return nil } - -func validateArmResourceGroupName(v interface{}, k string) (ws []string, es []error) { - value := v.(string) - - if len(value) > 80 { - es = append(es, fmt.Errorf("%q may not exceed 80 characters in length", k)) - } - - if strings.HasSuffix(value, ".") { - es = append(es, fmt.Errorf("%q may not end with a period", k)) - } - - // regex pulled from https://docs.microsoft.com/en-us/rest/api/resources/resourcegroups/createorupdate - if matched := regexp.MustCompile(`^[-\w\._\(\)]+$`).Match([]byte(value)); !matched { - es = append(es, fmt.Errorf("%q may only contain alphanumeric characters, dash, underscores, parentheses and periods", k)) - } - - return -} diff --git a/azurerm/resource_arm_resource_group_test.go b/azurerm/resource_arm_resource_group_test.go index 267adb58196f..5da260bf2dd0 100644 --- a/azurerm/resource_arm_resource_group_test.go +++ b/azurerm/resource_arm_resource_group_test.go @@ -10,66 +10,6 @@ import ( "github.com/hashicorp/terraform/terraform" ) -func TestValidateArmResourceGroupName(t *testing.T) { - cases := []struct { - Value string - ErrCount int - }{ - { - Value: "", - ErrCount: 1, - }, - { - Value: "hello", - ErrCount: 0, - }, - { - Value: "Hello", - ErrCount: 0, - }, - { - Value: "hello-world", - ErrCount: 0, - }, - { - Value: "Hello_World", - ErrCount: 0, - }, - { - Value: "HelloWithNumbers12345", - ErrCount: 0, - }, - { - Value: "(Did)You(Know)That(Brackets)Are(Allowed)In(Resource)Group(Names)", - ErrCount: 0, - }, - { - Value: "EndingWithAPeriod.", - ErrCount: 1, - }, - { - Value: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/foo", - ErrCount: 1, - }, - { - Value: acctest.RandString(80), - ErrCount: 0, - }, - { - Value: acctest.RandString(81), - ErrCount: 1, - }, - } - - for _, tc := range cases { - _, errors := validateArmResourceGroupName(tc.Value, "azurerm_resource_group") - - if len(errors) != tc.ErrCount { - t.Fatalf("Expected validateArmResourceGroupName to trigger '%d' errors for '%s' - got '%d'", tc.ErrCount, tc.Value, len(errors)) - } - } -} - func TestAccAzureRMResourceGroup_basic(t *testing.T) { ri := acctest.RandInt() config := testAccAzureRMResourceGroup_basic(ri, testLocation()) diff --git a/azurerm/resource_arm_route.go b/azurerm/resource_arm_route.go index c7a0f4838206..1a83102c0c4c 100644 --- a/azurerm/resource_arm_route.go +++ b/azurerm/resource_arm_route.go @@ -26,11 +26,7 @@ func resourceArmRoute() *schema.Resource { ForceNew: true, }, - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "route_table_name": { Type: schema.TypeString, diff --git a/azurerm/resource_arm_route_table.go b/azurerm/resource_arm_route_table.go index fded78cab192..6806247cc124 100644 --- a/azurerm/resource_arm_route_table.go +++ b/azurerm/resource_arm_route_table.go @@ -33,11 +33,7 @@ func resourceArmRouteTable() *schema.Resource { "location": locationSchema(), - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "route": { Type: schema.TypeSet, diff --git a/azurerm/resource_arm_search_service.go b/azurerm/resource_arm_search_service.go index e742ae58029c..ccd3312868f8 100644 --- a/azurerm/resource_arm_search_service.go +++ b/azurerm/resource_arm_search_service.go @@ -28,11 +28,7 @@ func resourceArmSearchService() *schema.Resource { "location": locationSchema(), - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "sku": { Type: schema.TypeString, diff --git a/azurerm/resource_arm_servicebus_namespace.go b/azurerm/resource_arm_servicebus_namespace.go index 4c14e111b650..bef4954339b0 100644 --- a/azurerm/resource_arm_servicebus_namespace.go +++ b/azurerm/resource_arm_servicebus_namespace.go @@ -35,11 +35,7 @@ func resourceArmServiceBusNamespace() *schema.Resource { "location": locationSchema(), - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "sku": { Type: schema.TypeString, diff --git a/azurerm/resource_arm_servicebus_queue.go b/azurerm/resource_arm_servicebus_queue.go index 549d7b2ed344..584a9d35ed1a 100644 --- a/azurerm/resource_arm_servicebus_queue.go +++ b/azurerm/resource_arm_servicebus_queue.go @@ -34,11 +34,7 @@ func resourceArmServiceBusQueue() *schema.Resource { "location": locationSchema(), - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "auto_delete_on_idle": { Type: schema.TypeString, diff --git a/azurerm/resource_arm_servicebus_subscription.go b/azurerm/resource_arm_servicebus_subscription.go index 06b93c8d8435..9d26c39d7f20 100644 --- a/azurerm/resource_arm_servicebus_subscription.go +++ b/azurerm/resource_arm_servicebus_subscription.go @@ -40,11 +40,7 @@ func resourceArmServiceBusSubscription() *schema.Resource { "location": locationSchema(), - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "auto_delete_on_idle": { Type: schema.TypeString, diff --git a/azurerm/resource_arm_servicebus_topic.go b/azurerm/resource_arm_servicebus_topic.go index b7d901b431c7..4522c674ede0 100644 --- a/azurerm/resource_arm_servicebus_topic.go +++ b/azurerm/resource_arm_servicebus_topic.go @@ -35,11 +35,7 @@ func resourceArmServiceBusTopic() *schema.Resource { "location": locationSchema(), - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "status": { Type: schema.TypeString, diff --git a/azurerm/resource_arm_sql_database.go b/azurerm/resource_arm_sql_database.go index 49ab62e9a610..fd3f41b706fb 100644 --- a/azurerm/resource_arm_sql_database.go +++ b/azurerm/resource_arm_sql_database.go @@ -32,11 +32,7 @@ func resourceArmSqlDatabase() *schema.Resource { "location": locationSchema(), - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "server_name": { Type: schema.TypeString, diff --git a/azurerm/resource_arm_sql_elasticpool.go b/azurerm/resource_arm_sql_elasticpool.go index 715aefbd9467..510648b79fe6 100644 --- a/azurerm/resource_arm_sql_elasticpool.go +++ b/azurerm/resource_arm_sql_elasticpool.go @@ -30,11 +30,7 @@ func resourceArmSqlElasticPool() *schema.Resource { "location": locationSchema(), - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "server_name": { Type: schema.TypeString, diff --git a/azurerm/resource_arm_sql_firewall_rule.go b/azurerm/resource_arm_sql_firewall_rule.go index 79a261c4437a..17393f98b510 100644 --- a/azurerm/resource_arm_sql_firewall_rule.go +++ b/azurerm/resource_arm_sql_firewall_rule.go @@ -26,11 +26,7 @@ func resourceArmSqlFirewallRule() *schema.Resource { ForceNew: true, }, - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "server_name": { Type: schema.TypeString, diff --git a/azurerm/resource_arm_sql_server.go b/azurerm/resource_arm_sql_server.go index e35a4719f6ea..8815350d3a72 100644 --- a/azurerm/resource_arm_sql_server.go +++ b/azurerm/resource_arm_sql_server.go @@ -22,18 +22,15 @@ func resourceArmSqlServer() *schema.Resource { Schema: map[string]*schema.Schema{ "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validateDBAccountName, }, "location": locationSchema(), - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "version": { Type: schema.TypeString, diff --git a/azurerm/resource_arm_storage_account.go b/azurerm/resource_arm_storage_account.go index 102ef4d1c75e..9e1d993f1770 100644 --- a/azurerm/resource_arm_storage_account.go +++ b/azurerm/resource_arm_storage_account.go @@ -38,12 +38,7 @@ func resourceArmStorageAccount() *schema.Resource { ValidateFunc: validateArmStorageAccountName, }, - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - DiffSuppressFunc: resourceAzurermResourceGroupNameDiffSuppress, - }, + "resource_group_name": resourceGroupNameDiffSuppressSchema(), "location": locationSchema(), diff --git a/azurerm/resource_arm_storage_blob.go b/azurerm/resource_arm_storage_blob.go index 8ee2ea6c2ca8..36645de0f850 100644 --- a/azurerm/resource_arm_storage_blob.go +++ b/azurerm/resource_arm_storage_blob.go @@ -29,11 +29,7 @@ func resourceArmStorageBlob() *schema.Resource { Required: true, ForceNew: true, }, - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "storage_account_name": { Type: schema.TypeString, Required: true, diff --git a/azurerm/resource_arm_storage_container.go b/azurerm/resource_arm_storage_container.go index b6f50ef8c52f..e359fddb8aba 100644 --- a/azurerm/resource_arm_storage_container.go +++ b/azurerm/resource_arm_storage_container.go @@ -25,11 +25,7 @@ func resourceArmStorageContainer() *schema.Resource { ForceNew: true, ValidateFunc: validateArmStorageContainerName, }, - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "storage_account_name": { Type: schema.TypeString, Required: true, diff --git a/azurerm/resource_arm_storage_queue.go b/azurerm/resource_arm_storage_queue.go index 7ef603a91213..755b8852683b 100644 --- a/azurerm/resource_arm_storage_queue.go +++ b/azurerm/resource_arm_storage_queue.go @@ -23,11 +23,7 @@ func resourceArmStorageQueue() *schema.Resource { ForceNew: true, ValidateFunc: validateArmStorageQueueName, }, - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "storage_account_name": { Type: schema.TypeString, Required: true, diff --git a/azurerm/resource_arm_storage_share.go b/azurerm/resource_arm_storage_share.go index f7543ef03ce7..4c92d920a937 100644 --- a/azurerm/resource_arm_storage_share.go +++ b/azurerm/resource_arm_storage_share.go @@ -23,11 +23,7 @@ func resourceArmStorageShare() *schema.Resource { ForceNew: true, ValidateFunc: validateArmStorageShareName, }, - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "storage_account_name": { Type: schema.TypeString, Required: true, diff --git a/azurerm/resource_arm_storage_table.go b/azurerm/resource_arm_storage_table.go index f82ec1d8338c..4867e0a6f69f 100644 --- a/azurerm/resource_arm_storage_table.go +++ b/azurerm/resource_arm_storage_table.go @@ -22,11 +22,7 @@ func resourceArmStorageTable() *schema.Resource { ForceNew: true, ValidateFunc: validateArmStorageTableName, }, - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "storage_account_name": { Type: schema.TypeString, Required: true, diff --git a/azurerm/resource_arm_subnet.go b/azurerm/resource_arm_subnet.go index b5a89a488f02..fafca054ca78 100644 --- a/azurerm/resource_arm_subnet.go +++ b/azurerm/resource_arm_subnet.go @@ -28,11 +28,7 @@ func resourceArmSubnet() *schema.Resource { ForceNew: true, }, - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "virtual_network_name": { Type: schema.TypeString, diff --git a/azurerm/resource_arm_template_deployment.go b/azurerm/resource_arm_template_deployment.go index 3c36603470d5..7e6252e05f33 100644 --- a/azurerm/resource_arm_template_deployment.go +++ b/azurerm/resource_arm_template_deployment.go @@ -28,11 +28,7 @@ func resourceArmTemplateDeployment() *schema.Resource { ForceNew: true, }, - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "template_body": { Type: schema.TypeString, diff --git a/azurerm/resource_arm_traffic_manager_endpoint.go b/azurerm/resource_arm_traffic_manager_endpoint.go index da88663ab781..c73028ba1878 100644 --- a/azurerm/resource_arm_traffic_manager_endpoint.go +++ b/azurerm/resource_arm_traffic_manager_endpoint.go @@ -91,12 +91,7 @@ func resourceArmTrafficManagerEndpoint() *schema.Resource { Optional: true, }, - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - DiffSuppressFunc: resourceAzurermResourceGroupNameDiffSuppress, - }, + "resource_group_name": resourceGroupNameDiffSuppressSchema(), }, } } diff --git a/azurerm/resource_arm_traffic_manager_profile.go b/azurerm/resource_arm_traffic_manager_profile.go index b152d8ba41a6..9fc935135882 100644 --- a/azurerm/resource_arm_traffic_manager_profile.go +++ b/azurerm/resource_arm_traffic_manager_profile.go @@ -104,12 +104,7 @@ func resourceArmTrafficManagerProfile() *schema.Resource { Set: resourceAzureRMTrafficManagerMonitorConfigHash, }, - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - DiffSuppressFunc: resourceAzurermResourceGroupNameDiffSuppress, - }, + "resource_group_name": resourceGroupNameDiffSuppressSchema(), "tags": tagsSchema(), }, diff --git a/azurerm/resource_arm_virtual_machine.go b/azurerm/resource_arm_virtual_machine.go index 8d96f7dcb39f..26bbd000f701 100644 --- a/azurerm/resource_arm_virtual_machine.go +++ b/azurerm/resource_arm_virtual_machine.go @@ -34,11 +34,7 @@ func resourceArmVirtualMachine() *schema.Resource { "location": locationSchema(), - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "plan": { Type: schema.TypeSet, diff --git a/azurerm/resource_arm_virtual_machine_extension.go b/azurerm/resource_arm_virtual_machine_extension.go index 2ee8e7c2ee24..063133613a91 100644 --- a/azurerm/resource_arm_virtual_machine_extension.go +++ b/azurerm/resource_arm_virtual_machine_extension.go @@ -29,11 +29,7 @@ func resourceArmVirtualMachineExtensions() *schema.Resource { "location": locationSchema(), - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "virtual_machine_name": { Type: schema.TypeString, diff --git a/azurerm/resource_arm_virtual_machine_scale_set.go b/azurerm/resource_arm_virtual_machine_scale_set.go index a74cb129013d..bcdf614d3e44 100644 --- a/azurerm/resource_arm_virtual_machine_scale_set.go +++ b/azurerm/resource_arm_virtual_machine_scale_set.go @@ -33,11 +33,7 @@ func resourceArmVirtualMachineScaleSet() *schema.Resource { "location": locationSchema(), - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "sku": { Type: schema.TypeSet, @@ -177,7 +173,7 @@ func resourceArmVirtualMachineScaleSet() *schema.Resource { }, }, "additional_unattend_config": { - Type: schema.TypeSet, + Type: schema.TypeList, Optional: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -660,7 +656,7 @@ func resourceArmVirtualMachineScaleSetRead(d *schema.ResourceData, meta interfac if properties.VirtualMachineProfile.OsProfile.LinuxConfiguration != nil { if err := d.Set("os_profile_linux_config", flattenAzureRmVirtualMachineScaleSetOsProfileLinuxConfig(properties.VirtualMachineProfile.OsProfile.LinuxConfiguration)); err != nil { - return fmt.Errorf("[DEBUG] Error setting Virtual Machine Scale Set OS Profile Windows config error: %#v", err) + return fmt.Errorf("[DEBUG] Error setting Virtual Machine Scale Set OS Profile Linux config error: %#v", err) } } @@ -776,7 +772,10 @@ func flattenAzureRmVirtualMachineScaleSetOsProfileWindowsConfig(config *compute. c["pass"] = i.PassName c["component"] = i.ComponentName c["setting_name"] = i.SettingName - c["content"] = *i.Content + + if i.Content != nil { + c["content"] = *i.Content + } content = append(content, c) } @@ -1442,7 +1441,7 @@ func expandAzureRmVirtualMachineScaleSetOsProfileWindowsConfig(d *schema.Resourc } } if v := osProfileConfig["additional_unattend_config"]; v != nil { - additionalConfig := v.(*schema.Set).List() + additionalConfig := v.([]interface{}) if len(additionalConfig) > 0 { additionalConfigContent := make([]compute.AdditionalUnattendContent, 0, len(additionalConfig)) for _, addConfig := range additionalConfig { diff --git a/azurerm/resource_arm_virtual_machine_scale_set_test.go b/azurerm/resource_arm_virtual_machine_scale_set_test.go index ada6a61eb362..84a12f211a08 100644 --- a/azurerm/resource_arm_virtual_machine_scale_set_test.go +++ b/azurerm/resource_arm_virtual_machine_scale_set_test.go @@ -119,6 +119,24 @@ func TestAccAzureRMVirtualMachineScaleSet_basicLinux_managedDisk(t *testing.T) { }) } +func TestAccAzureRMVirtualMachineScaleSet_basicWindows_managedDisk(t *testing.T) { + ri := acctest.RandInt() + config := testAccAzureRMVirtualMachineScaleSet_basicWindows_managedDisk(ri, testLocation()) + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMVirtualMachineScaleSetDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMVirtualMachineScaleSetExists("azurerm_virtual_machine_scale_set.test"), + ), + }, + }, + }) +} + func TestAccAzureRMVirtualMachineScaleSet_basicLinux_managedDiskNoName(t *testing.T) { ri := acctest.RandInt() config := testAccAzureRMVirtualMachineScaleSet_basicLinux_managedDiskNoName(ri, testLocation()) @@ -1062,6 +1080,90 @@ resource "azurerm_virtual_machine_scale_set" "test" { `, rInt, location, rInt, rInt, rInt, rInt, rInt) } +func testAccAzureRMVirtualMachineScaleSet_basicWindows_managedDisk(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_virtual_network" "test" { + name = "acctvn-%d" + address_space = ["10.0.0.0/16"] + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" +} + +resource "azurerm_subnet" "test" { + name = "acctsub-%d" + resource_group_name = "${azurerm_resource_group.test.name}" + virtual_network_name = "${azurerm_virtual_network.test.name}" + address_prefix = "10.0.2.0/24" +} + +resource "azurerm_virtual_machine_scale_set" "test" { + name = "acctvmss-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + upgrade_policy_mode = "Manual" + + sku { + name = "Standard_D1_v2" + tier = "Standard" + capacity = 2 + } + + os_profile { + computer_name_prefix = "testvm" + admin_username = "myadmin" + admin_password = "Passwword1234" + } + + os_profile_windows_config { + enable_automatic_upgrades = false + provision_vm_agent = true + + additional_unattend_config { + pass = "oobeSystem" + component = "Microsoft-Windows-Shell-Setup" + setting_name = "AutoLogon" + content = "myadminPasswword1234true1" + } + + additional_unattend_config { + pass = "oobeSystem" + component = "Microsoft-Windows-Shell-Setup" + setting_name = "FirstLogonCommands" + content = "shutdown /r /t 0 /c \"initial reboot\"reboot1" + } + } + + network_profile { + name = "TestNetworkProfile-%d" + primary = true + ip_configuration { + name = "TestIPConfiguration" + subnet_id = "${azurerm_subnet.test.id}" + } + } + + storage_profile_os_disk { + name = "" + caching = "ReadWrite" + create_option = "FromImage" + managed_disk_type = "Standard_LRS" + } + + storage_profile_image_reference { + publisher = "MicrosoftWindowsServer" + offer = "WindowsServer" + sku = "2016-Datacenter-Server-Core" + version = "latest" + } +} +`, rInt, location, rInt, rInt, rInt, rInt) +} + func testAccAzureRMVirtualMachineScaleSet_basicLinux_managedDiskNoName(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { diff --git a/azurerm/resource_arm_virtual_network.go b/azurerm/resource_arm_virtual_network.go index 2fefe35e33f1..089c78362451 100644 --- a/azurerm/resource_arm_virtual_network.go +++ b/azurerm/resource_arm_virtual_network.go @@ -72,11 +72,7 @@ func resourceArmVirtualNetwork() *schema.Resource { "location": locationSchema(), - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "tags": tagsSchema(), }, diff --git a/azurerm/resource_arm_virtual_network_peering.go b/azurerm/resource_arm_virtual_network_peering.go index 0c119f039e9d..81bb3818b7d9 100644 --- a/azurerm/resource_arm_virtual_network_peering.go +++ b/azurerm/resource_arm_virtual_network_peering.go @@ -31,11 +31,7 @@ func resourceArmVirtualNetworkPeering() *schema.Resource { ForceNew: true, }, - "resource_group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "resource_group_name": resourceGroupNameSchema(), "virtual_network_name": { Type: schema.TypeString, diff --git a/azurerm/resource_group_name.go b/azurerm/resource_group_name.go new file mode 100644 index 000000000000..52ca959345a5 --- /dev/null +++ b/azurerm/resource_group_name.go @@ -0,0 +1,54 @@ +package azurerm + +import ( + "fmt" + "regexp" + "strings" + + "github.com/hashicorp/terraform/helper/schema" +) + +func resourceGroupNameSchema() *schema.Schema { + return &schema.Schema{ + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validateArmResourceGroupName, + } +} + +func resourceGroupNameDiffSuppressSchema() *schema.Schema { + return &schema.Schema{ + Type: schema.TypeString, + Required: true, + ForceNew: true, + DiffSuppressFunc: resourceAzurermResourceGroupNameDiffSuppress, + ValidateFunc: validateArmResourceGroupName, + } +} + +func resourceGroupNameForDataSourceSchema() *schema.Schema { + return &schema.Schema{ + Type: schema.TypeString, + Required: true, + } +} + +func validateArmResourceGroupName(v interface{}, k string) (ws []string, es []error) { + value := v.(string) + + if len(value) > 80 { + es = append(es, fmt.Errorf("%q may not exceed 80 characters in length", k)) + } + + if strings.HasSuffix(value, ".") { + es = append(es, fmt.Errorf("%q may not end with a period", k)) + } + + // regex pulled from https://docs.microsoft.com/en-us/rest/api/resources/resourcegroups/createorupdate + if matched := regexp.MustCompile(`^[-\w\._\(\)]+$`).Match([]byte(value)); !matched { + es = append(es, fmt.Errorf("%q may only contain alphanumeric characters, dash, underscores, parentheses and periods", k)) + } + + return +} diff --git a/azurerm/resource_group_name_test.go b/azurerm/resource_group_name_test.go new file mode 100644 index 000000000000..1029b4eb75f5 --- /dev/null +++ b/azurerm/resource_group_name_test.go @@ -0,0 +1,67 @@ +package azurerm + +import ( + "testing" + + "github.com/hashicorp/terraform/helper/acctest" +) + +func TestValidateArmResourceGroupName(t *testing.T) { + cases := []struct { + Value string + ErrCount int + }{ + { + Value: "", + ErrCount: 1, + }, + { + Value: "hello", + ErrCount: 0, + }, + { + Value: "Hello", + ErrCount: 0, + }, + { + Value: "hello-world", + ErrCount: 0, + }, + { + Value: "Hello_World", + ErrCount: 0, + }, + { + Value: "HelloWithNumbers12345", + ErrCount: 0, + }, + { + Value: "(Did)You(Know)That(Brackets)Are(Allowed)In(Resource)Group(Names)", + ErrCount: 0, + }, + { + Value: "EndingWithAPeriod.", + ErrCount: 1, + }, + { + Value: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/foo", + ErrCount: 1, + }, + { + Value: acctest.RandString(80), + ErrCount: 0, + }, + { + Value: acctest.RandString(81), + ErrCount: 1, + }, + } + + for _, tc := range cases { + _, errors := validateArmResourceGroupName(tc.Value, "azurerm_resource_group") + + if len(errors) != tc.ErrCount { + t.Fatalf("Expected validateArmResourceGroupName to trigger '%d' errors for '%s' - got '%d'", tc.ErrCount, tc.Value, len(errors)) + } + } +} diff --git a/azurerm/validators.go b/azurerm/validators.go index 88ae3116a08f..f224c8a4eb2b 100644 --- a/azurerm/validators.go +++ b/azurerm/validators.go @@ -2,6 +2,7 @@ package azurerm import ( "fmt" + "regexp" "time" "github.com/Azure/go-autorest/autorest/date" @@ -46,3 +47,19 @@ func validateUUID(v interface{}, k string) (ws []string, errors []error) { } return } + +func validateDBAccountName(v interface{}, k string) (ws []string, errors []error) { + value := v.(string) + + r, _ := regexp.Compile("^[a-z0-9\\-]+$") + if !r.MatchString(value) { + errors = append(errors, fmt.Errorf("Account Name can only contain lower-case characters, numbers and the `-` character.")) + } + + length := len(value) + if length > 50 || 3 > length { + errors = append(errors, fmt.Errorf("Account Name can only be between 3 and 50 seconds.")) + } + + return +} diff --git a/azurerm/validators_test.go b/azurerm/validators_test.go index 97f53f78df88..7294ad2f821d 100644 --- a/azurerm/validators_test.go +++ b/azurerm/validators_test.go @@ -1,6 +1,10 @@ package azurerm -import "testing" +import ( + "testing" + + "github.com/hashicorp/terraform/helper/acctest" +) func TestValidateRFC3339Date(t *testing.T) { cases := []struct { @@ -85,3 +89,44 @@ func TestValidateIntInSlice(t *testing.T) { } } + +func TestDBAccountName_validation(t *testing.T) { + str := acctest.RandString(50) + cases := []struct { + Value string + ErrCount int + }{ + { + Value: "ab", + ErrCount: 1, + }, + { + Value: "abc", + ErrCount: 0, + }, + { + Value: "cosmosDBAccount1", + ErrCount: 1, + }, + { + Value: "hello-world", + ErrCount: 0, + }, + { + Value: str, + ErrCount: 0, + }, + { + Value: str + "a", + ErrCount: 1, + }, + } + + for _, tc := range cases { + _, errors := validateDBAccountName(tc.Value, "azurerm_cosmosdb_account") + + if len(errors) != tc.ErrCount { + t.Fatalf("Expected the AzureRM CosmosDB Name to trigger a validation error for '%s'", tc.Value) + } + } +} diff --git a/examples/aci-linux-multi/main.tf b/examples/aci-linux-multi/main.tf new file mode 100644 index 000000000000..fb1903209c3e --- /dev/null +++ b/examples/aci-linux-multi/main.tf @@ -0,0 +1,30 @@ +resource "azurerm_resource_group" "aci-rg" { + name="aci-test" + location="west us" +} + +resource "azurerm_container_group" "aci-test" { + name = "my-aci-hw" + location = "${azurerm_resource_group.aci-rg.location}" + resource_group_name = "${azurerm_resource_group.aci-rg.name}" + ip_address_type="public" + os_type = "linux" + + container { + name = "hw" + image = "microsoft/aci-helloworld:latest" + cpu ="0.5" + memory = "1.5" + port = "80" + } + container { + name = "sidecar" + image = "microsoft/aci-tutorial-sidecar" + cpu="0.5" + memory="1.5" + } + tags { + environment = "testing" + } +} + 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..efa3e6c245c3 --- /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.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.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.3.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 +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/containerinstance/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerinstance/client.go new file mode 100644 index 000000000000..8428722c57b1 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerinstance/client.go @@ -0,0 +1,51 @@ +// Package containerinstance implements the Azure ARM Containerinstance service API version 2017-08-01-preview. +// +// +package containerinstance + +// 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.2.2.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 Containerinstance + DefaultBaseURI = "https://management.azure.com" +) + +// ManagementClient is the base client for Containerinstance. +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/containerinstance/containergroups.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerinstance/containergroups.go new file mode 100644 index 000000000000..0396dac00950 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerinstance/containergroups.go @@ -0,0 +1,512 @@ +package containerinstance + +// 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.2.2.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" +) + +// ContainerGroupsClient is the client for the ContainerGroups methods of the Containerinstance service. +type ContainerGroupsClient struct { + ManagementClient +} + +// NewContainerGroupsClient creates an instance of the ContainerGroupsClient client. +func NewContainerGroupsClient(subscriptionID string) ContainerGroupsClient { + return NewContainerGroupsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewContainerGroupsClientWithBaseURI creates an instance of the ContainerGroupsClient client. +func NewContainerGroupsClientWithBaseURI(baseURI string, subscriptionID string) ContainerGroupsClient { + return ContainerGroupsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or update container groups. +// +// resourceGroupName is azure resource group name containerGroupName is container group name containerGroup is +// definition of the container to be created. +func (client ContainerGroupsClient) CreateOrUpdate(resourceGroupName string, containerGroupName string, containerGroup ContainerGroup) (result ContainerGroup, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: containerGroup, + Constraints: []validation.Constraint{{Target: "containerGroup.ContainerGroupProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "containerGroup.ContainerGroupProperties.IPAddress", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "containerGroup.ContainerGroupProperties.IPAddress.Ports", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "containerGroup.ContainerGroupProperties.IPAddress.Type", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "containerinstance.ContainerGroupsClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, containerGroupName, containerGroup) + if err != nil { + err = autorest.NewErrorWithError(err, "containerinstance.ContainerGroupsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "containerinstance.ContainerGroupsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerinstance.ContainerGroupsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ContainerGroupsClient) CreateOrUpdatePreparer(resourceGroupName string, containerGroupName string, containerGroup ContainerGroup) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "containerGroupName": autorest.Encode("path", containerGroupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-08-01-preview" + 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.ContainerInstance/containerGroups/{containerGroupName}", pathParameters), + autorest.WithJSON(containerGroup), + 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 ContainerGroupsClient) 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 ContainerGroupsClient) CreateOrUpdateResponder(resp *http.Response) (result ContainerGroup, 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 container groups. +// +// resourceGroupName is azure resource group name containerGroupName is name of the container group to be deleted +func (client ContainerGroupsClient) Delete(resourceGroupName string, containerGroupName string) (result ContainerGroup, err error) { + req, err := client.DeletePreparer(resourceGroupName, containerGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "containerinstance.ContainerGroupsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "containerinstance.ContainerGroupsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerinstance.ContainerGroupsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ContainerGroupsClient) DeletePreparer(resourceGroupName string, containerGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "containerGroupName": autorest.Encode("path", containerGroupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}", 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 ContainerGroupsClient) 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 ContainerGroupsClient) DeleteResponder(resp *http.Response) (result ContainerGroup, 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 get details for this container group. +// +// resourceGroupName is azure resource group name containerGroupName is container group name +func (client ContainerGroupsClient) Get(resourceGroupName string, containerGroupName string) (result ContainerGroup, err error) { + req, err := client.GetPreparer(resourceGroupName, containerGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "containerinstance.ContainerGroupsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "containerinstance.ContainerGroupsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerinstance.ContainerGroupsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ContainerGroupsClient) GetPreparer(resourceGroupName string, containerGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "containerGroupName": autorest.Encode("path", containerGroupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}", 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 ContainerGroupsClient) 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 ContainerGroupsClient) GetResponder(resp *http.Response) (result ContainerGroup, 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 get the list of container groups in a given subscription. +func (client ContainerGroupsClient) List() (result ContainerGroupListResult, err error) { + req, err := client.ListPreparer() + if err != nil { + err = autorest.NewErrorWithError(err, "containerinstance.ContainerGroupsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "containerinstance.ContainerGroupsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerinstance.ContainerGroupsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ContainerGroupsClient) ListPreparer() (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/containerGroups", 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 ContainerGroupsClient) 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 ContainerGroupsClient) ListResponder(resp *http.Response) (result ContainerGroupListResult, 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 ContainerGroupsClient) ListNextResults(lastResults ContainerGroupListResult) (result ContainerGroupListResult, err error) { + req, err := lastResults.ContainerGroupListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "containerinstance.ContainerGroupsClient", "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, "containerinstance.ContainerGroupsClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerinstance.ContainerGroupsClient", "List", resp, "Failure responding to next results request") + } + + return +} + +// ListComplete gets all elements from the list without paging. +func (client ContainerGroupsClient) ListComplete(cancel <-chan struct{}) (<-chan ContainerGroup, <-chan error) { + resultChan := make(chan ContainerGroup) + errChan := make(chan error, 1) + go func() { + defer func() { + close(resultChan) + close(errChan) + }() + list, err := client.List() + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + for list.NextLink != nil { + list, err = client.ListNextResults(list) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + } + }() + return resultChan, errChan +} + +// ListByResourceGroup get the list of container groups in a given resource group. +// +// resourceGroupName is azure resource group name +func (client ContainerGroupsClient) ListByResourceGroup(resourceGroupName string) (result ContainerGroupListResult, err error) { + req, err := client.ListByResourceGroupPreparer(resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "containerinstance.ContainerGroupsClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "containerinstance.ContainerGroupsClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerinstance.ContainerGroupsClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client ContainerGroupsClient) ListByResourceGroupPreparer(resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups", 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 ContainerGroupsClient) 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 ContainerGroupsClient) ListByResourceGroupResponder(resp *http.Response) (result ContainerGroupListResult, 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 ContainerGroupsClient) ListByResourceGroupNextResults(lastResults ContainerGroupListResult) (result ContainerGroupListResult, err error) { + req, err := lastResults.ContainerGroupListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "containerinstance.ContainerGroupsClient", "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, "containerinstance.ContainerGroupsClient", "ListByResourceGroup", resp, "Failure sending next results request") + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerinstance.ContainerGroupsClient", "ListByResourceGroup", resp, "Failure responding to next results request") + } + + return +} + +// ListByResourceGroupComplete gets all elements from the list without paging. +func (client ContainerGroupsClient) ListByResourceGroupComplete(resourceGroupName string, cancel <-chan struct{}) (<-chan ContainerGroup, <-chan error) { + resultChan := make(chan ContainerGroup) + errChan := make(chan error, 1) + go func() { + defer func() { + close(resultChan) + close(errChan) + }() + list, err := client.ListByResourceGroup(resourceGroupName) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + for list.NextLink != nil { + list, err = client.ListByResourceGroupNextResults(list) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + } + }() + return resultChan, errChan +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/containerinstance/containerlogs.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerinstance/containerlogs.go new file mode 100644 index 000000000000..c11264b1800b --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerinstance/containerlogs.go @@ -0,0 +1,109 @@ +package containerinstance + +// 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.2.2.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" +) + +// ContainerLogsClient is the client for the ContainerLogs methods of the Containerinstance service. +type ContainerLogsClient struct { + ManagementClient +} + +// NewContainerLogsClient creates an instance of the ContainerLogsClient client. +func NewContainerLogsClient(subscriptionID string) ContainerLogsClient { + return NewContainerLogsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewContainerLogsClientWithBaseURI creates an instance of the ContainerLogsClient client. +func NewContainerLogsClientWithBaseURI(baseURI string, subscriptionID string) ContainerLogsClient { + return ContainerLogsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List get the logs for this container. +// +// resourceGroupName is azure resource group name containerName is container name containerGroupName is container group +// name tail is only show this number of log lines. If not provided, all available logs are shown. +func (client ContainerLogsClient) List(resourceGroupName string, containerName string, containerGroupName string, tail *int32) (result Logs, err error) { + req, err := client.ListPreparer(resourceGroupName, containerName, containerGroupName, tail) + if err != nil { + err = autorest.NewErrorWithError(err, "containerinstance.ContainerLogsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "containerinstance.ContainerLogsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerinstance.ContainerLogsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ContainerLogsClient) ListPreparer(resourceGroupName string, containerName string, containerGroupName string, tail *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "containerGroupName": autorest.Encode("path", containerGroupName), + "containerName": autorest.Encode("path", containerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if tail != nil { + queryParameters["tail"] = autorest.Encode("query", *tail) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/containers/{containerName}/logs", 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 ContainerLogsClient) 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 ContainerLogsClient) ListResponder(resp *http.Response) (result Logs, 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/containerinstance/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerinstance/models.go new file mode 100644 index 000000000000..51aea50b0eb8 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerinstance/models.go @@ -0,0 +1,223 @@ +package containerinstance + +// 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.2.2.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" + "net/http" +) + +// ContainerGroupNetworkProtocol enumerates the values for container group network protocol. +type ContainerGroupNetworkProtocol string + +const ( + // TCP specifies the tcp state for container group network protocol. + TCP ContainerGroupNetworkProtocol = "TCP" + // UDP specifies the udp state for container group network protocol. + UDP ContainerGroupNetworkProtocol = "UDP" +) + +// ContainerRestartPolicy enumerates the values for container restart policy. +type ContainerRestartPolicy string + +const ( + // Always specifies the always state for container restart policy. + Always ContainerRestartPolicy = "always" +) + +// OperatingSystemTypes enumerates the values for operating system types. +type OperatingSystemTypes string + +const ( + // Linux specifies the linux state for operating system types. + Linux OperatingSystemTypes = "Linux" + // Windows specifies the windows state for operating system types. + Windows OperatingSystemTypes = "Windows" +) + +// AzureFileVolume is the Azure file volume. +type AzureFileVolume struct { + ShareName *string `json:"shareName,omitempty"` + ReadOnly *bool `json:"readOnly,omitempty"` + StorageAccountName *string `json:"storageAccountName,omitempty"` + StorageAccountKey *string `json:"storageAccountKey,omitempty"` +} + +// Container is a container instance. +type Container struct { + Name *string `json:"name,omitempty"` + *ContainerProperties `json:"properties,omitempty"` +} + +// ContainerEvent is a container event. +type ContainerEvent struct { + Count *int32 `json:"count,omitempty"` + FirstTimestamp *date.Time `json:"firstTimestamp,omitempty"` + LastTimestamp *date.Time `json:"lastTimestamp,omitempty"` + Message *string `json:"message,omitempty"` + Type *string `json:"type,omitempty"` +} + +// ContainerGroup is a container group. +type ContainerGroup 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"` + *ContainerGroupProperties `json:"properties,omitempty"` +} + +// ContainerGroupProperties is +type ContainerGroupProperties struct { + ProvisioningState *string `json:"provisioningState,omitempty"` + Containers *[]Container `json:"containers,omitempty"` + ImageRegistryCredentials *[]ImageRegistryCredential `json:"imageRegistryCredentials,omitempty"` + RestartPolicy ContainerRestartPolicy `json:"restartPolicy,omitempty"` + IPAddress *IPAddress `json:"ipAddress,omitempty"` + OsType OperatingSystemTypes `json:"osType,omitempty"` + State *string `json:"state,omitempty"` + Volumes *[]Volume `json:"volumes,omitempty"` +} + +// ContainerGroupListResult is the container group list response that contains the container group properties. +type ContainerGroupListResult struct { + autorest.Response `json:"-"` + Value *[]ContainerGroup `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// ContainerGroupListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client ContainerGroupListResult) ContainerGroupListResultPreparer() (*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))) +} + +// ContainerPort is the container port. +type ContainerPort struct { + Port *int32 `json:"port,omitempty"` +} + +// ContainerProperties is the container properties. +type ContainerProperties struct { + Image *string `json:"image,omitempty"` + Command *[]string `json:"command,omitempty"` + Ports *[]ContainerPort `json:"ports,omitempty"` + EnvironmentVariables *[]EnvironmentVariable `json:"environmentVariables,omitempty"` + InstanceView *ContainerPropertiesInstanceView `json:"instanceView,omitempty"` + Resources *ResourceRequirements `json:"resources,omitempty"` + VolumeMounts *[]VolumeMount `json:"volumeMounts,omitempty"` +} + +// ContainerPropertiesInstanceView is the instance view of the container. Only valid in response. +type ContainerPropertiesInstanceView struct { + RestartCount *int32 `json:"restartCount,omitempty"` + CurrentState *ContainerState `json:"currentState,omitempty"` + PreviousState *ContainerState `json:"previousState,omitempty"` + Events *[]ContainerEvent `json:"events,omitempty"` +} + +// ContainerState is the container state. +type ContainerState struct { + State *string `json:"state,omitempty"` + StartTime *date.Time `json:"startTime,omitempty"` + ExitCode *int32 `json:"exitCode,omitempty"` + FinishTime *date.Time `json:"finishTime,omitempty"` + DetailStatus *string `json:"detailStatus,omitempty"` +} + +// EnvironmentVariable is environment variable to set within the container. +type EnvironmentVariable struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} + +// ImageRegistryCredential is image registry credential. +type ImageRegistryCredential struct { + Server *string `json:"server,omitempty"` + Username *string `json:"username,omitempty"` + Password *string `json:"password,omitempty"` +} + +// IPAddress is IP address for the group. +type IPAddress struct { + Ports *[]Port `json:"ports,omitempty"` + Type *string `json:"type,omitempty"` + IP *string `json:"ip,omitempty"` +} + +// Logs is the logs. +type Logs struct { + autorest.Response `json:"-"` + Content *string `json:"content,omitempty"` +} + +// Port is the port. +type Port struct { + Protocol ContainerGroupNetworkProtocol `json:"protocol,omitempty"` + Port *int32 `json:"port,omitempty"` +} + +// Resource is the Resource model 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"` +} + +// ResourceLimits is the resource limits. +type ResourceLimits struct { + MemoryInGB *float64 `json:"memoryInGB,omitempty"` + CPU *float64 `json:"cpu,omitempty"` +} + +// ResourceRequests is the resource requests. +type ResourceRequests struct { + MemoryInGB *float64 `json:"memoryInGB,omitempty"` + CPU *float64 `json:"cpu,omitempty"` +} + +// ResourceRequirements is the resource requirements. +type ResourceRequirements struct { + Requests *ResourceRequests `json:"requests,omitempty"` + Limits *ResourceLimits `json:"limits,omitempty"` +} + +// Volume is the volume. +type Volume struct { + Name *string `json:"name,omitempty"` + AzureFile *AzureFileVolume `json:"azureFile,omitempty"` +} + +// VolumeMount is the volume mount. +type VolumeMount struct { + Name *string `json:"name,omitempty"` + MountPath *string `json:"mountPath,omitempty"` + ReadOnly *bool `json:"readOnly,omitempty"` +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/containerinstance/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerinstance/version.go new file mode 100644 index 000000000000..227dd95f5945 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerinstance/version.go @@ -0,0 +1,28 @@ +package containerinstance + +// 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.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.3.0-beta arm-containerinstance/2017-08-01-preview" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return "v10.3.0-beta" +} diff --git a/vendor/github.com/Azure/go-autorest/autorest/adal/msi.go b/vendor/github.com/Azure/go-autorest/autorest/adal/msi.go new file mode 100644 index 000000000000..e87911e835d9 --- /dev/null +++ b/vendor/github.com/Azure/go-autorest/autorest/adal/msi.go @@ -0,0 +1,6 @@ +// +build !windows + +package adal + +// msiPath is the path to the MSI Extension settings file (to discover the endpoint) +var msiPath = "/var/lib/waagent/ManagedIdentity-Settings" diff --git a/vendor/github.com/Azure/go-autorest/autorest/adal/msi_windows.go b/vendor/github.com/Azure/go-autorest/autorest/adal/msi_windows.go new file mode 100644 index 000000000000..80f8004327f1 --- /dev/null +++ b/vendor/github.com/Azure/go-autorest/autorest/adal/msi_windows.go @@ -0,0 +1,11 @@ +// +build windows + +package adal + +import ( + "os" + "strings" +) + +// msiPath is the path to the MSI Extension settings file (to discover the endpoint) +var msiPath = strings.Join([]string{os.Getenv("SystemDrive"), "WindowsAzure/Config/ManagedIdentity-Settings"}, "/") diff --git a/vendor/github.com/Azure/go-autorest/autorest/adal/token.go b/vendor/github.com/Azure/go-autorest/autorest/adal/token.go index 559fc6653583..2ac8c3c22040 100644 --- a/vendor/github.com/Azure/go-autorest/autorest/adal/token.go +++ b/vendor/github.com/Azure/go-autorest/autorest/adal/token.go @@ -15,12 +15,12 @@ import ( "strings" "time" + "github.com/Azure/go-autorest/autorest/date" "github.com/dgrijalva/jwt-go" ) const ( defaultRefresh = 5 * time.Minute - tokenBaseDate = "1970-01-01T00:00:00Z" // OAuthGrantTypeDeviceCode is the "grant_type" identifier used in device flow OAuthGrantTypeDeviceCode = "device_code" @@ -31,16 +31,10 @@ const ( // OAuthGrantTypeRefreshToken is the "grant_type" identifier used in refresh token flows OAuthGrantTypeRefreshToken = "refresh_token" - // managedIdentitySettingsPath is the path to the MSI Extension settings file (to discover the endpoint) - managedIdentitySettingsPath = "/var/lib/waagent/ManagedIdentity-Settings" + // metadataHeader is the header required by MSI extension + metadataHeader = "Metadata" ) -var expirationBase time.Time - -func init() { - expirationBase, _ = time.Parse(time.RFC3339, tokenBaseDate) -} - // OAuthTokenProvider is an interface which should be implemented by an access token retriever type OAuthTokenProvider interface { OAuthToken() string @@ -76,7 +70,10 @@ func (t Token) Expires() time.Time { if err != nil { s = -3600 } - return expirationBase.Add(time.Duration(s) * time.Second).UTC() + + expiration := date.NewUnixTimeFromSeconds(float64(s)) + + return time.Time(expiration).UTC() } // IsExpired returns true if the Token is expired, false otherwise. @@ -135,9 +132,7 @@ type ServicePrincipalMSISecret struct { } // SetAuthenticationValues is a method of the interface ServicePrincipalSecret. -// MSI extension requires the authority field to be set to the real tenant authority endpoint func (msiSecret *ServicePrincipalMSISecret) SetAuthenticationValues(spt *ServicePrincipalToken, v *url.Values) error { - v.Set("authority", spt.oauthConfig.AuthorityEndpoint.String()) return nil } @@ -261,41 +256,43 @@ func NewServicePrincipalTokenFromCertificate(oauthConfig OAuthConfig, clientID s ) } -// NewServicePrincipalTokenFromMSI creates a ServicePrincipalToken via the MSI VM Extension. -func NewServicePrincipalTokenFromMSI(oauthConfig OAuthConfig, resource string, callbacks ...TokenRefreshCallback) (*ServicePrincipalToken, error) { - return newServicePrincipalTokenFromMSI(oauthConfig, resource, managedIdentitySettingsPath, callbacks...) +// GetMSIVMEndpoint gets the MSI endpoint on Virtual Machines. +func GetMSIVMEndpoint() (string, error) { + return getMSIVMEndpoint(msiPath) } -func newServicePrincipalTokenFromMSI(oauthConfig OAuthConfig, resource, settingsPath string, callbacks ...TokenRefreshCallback) (*ServicePrincipalToken, error) { +func getMSIVMEndpoint(path string) (string, error) { // Read MSI settings - bytes, err := ioutil.ReadFile(settingsPath) + bytes, err := ioutil.ReadFile(path) if err != nil { - return nil, err + return "", err } msiSettings := struct { URL string `json:"url"` }{} err = json.Unmarshal(bytes, &msiSettings) if err != nil { - return nil, err + return "", err } + return msiSettings.URL, nil +} + +// NewServicePrincipalTokenFromMSI creates a ServicePrincipalToken via the MSI VM Extension. +func NewServicePrincipalTokenFromMSI(msiEndpoint, resource string, callbacks ...TokenRefreshCallback) (*ServicePrincipalToken, error) { // We set the oauth config token endpoint to be MSI's endpoint - // We leave the authority as-is so MSI can POST it with the token request - msiEndpointURL, err := url.Parse(msiSettings.URL) + msiEndpointURL, err := url.Parse(msiEndpoint) if err != nil { return nil, err } - msiTokenEndpointURL, err := msiEndpointURL.Parse("/oauth2/token") + oauthConfig, err := NewOAuthConfig(msiEndpointURL.String(), "") if err != nil { return nil, err } - oauthConfig.TokenEndpoint = *msiTokenEndpointURL - spt := &ServicePrincipalToken{ - oauthConfig: oauthConfig, + oauthConfig: *oauthConfig, secret: &ServicePrincipalMSISecret{}, resource: resource, autoRefresh: true, @@ -364,16 +361,24 @@ func (spt *ServicePrincipalToken) refreshInternal(resource string) error { req.ContentLength = int64(len(s)) req.Header.Set(contentType, mimeTypeFormPost) + if _, ok := spt.secret.(*ServicePrincipalMSISecret); ok { + req.Header.Set(metadataHeader, "true") + } resp, err := spt.sender.Do(req) if err != nil { return fmt.Errorf("adal: Failed to execute the refresh request. Error = '%v'", err) } + defer resp.Body.Close() + rb, err := ioutil.ReadAll(resp.Body) + if resp.StatusCode != http.StatusOK { - return fmt.Errorf("adal: Refresh request failed. Status Code = '%d'", resp.StatusCode) + if err != nil { + return fmt.Errorf("adal: Refresh request failed. Status Code = '%d'. Failed reading response body", resp.StatusCode) + } + return fmt.Errorf("adal: Refresh request failed. Status Code = '%d'. Response body: %s", resp.StatusCode, string(rb)) } - rb, err := ioutil.ReadAll(resp.Body) if err != nil { return fmt.Errorf("adal: Failed to read a new service principal token during refresh. Error = '%v'", err) } diff --git a/vendor/github.com/Azure/go-autorest/autorest/azure/cli/profile.go b/vendor/github.com/Azure/go-autorest/autorest/azure/cli/profile.go new file mode 100644 index 000000000000..b5b897c7df9e --- /dev/null +++ b/vendor/github.com/Azure/go-autorest/autorest/azure/cli/profile.go @@ -0,0 +1,51 @@ +package cli + +import ( + "bytes" + "encoding/json" + "fmt" + "io/ioutil" + + "github.com/dimchansky/utfbom" + "github.com/mitchellh/go-homedir" +) + +// Profile represents a Profile from the Azure CLI +type Profile struct { + InstallationID string `json:"installationId"` + Subscriptions []Subscription `json:"subscriptions"` +} + +// Subscription represents a Subscription from the Azure CLI +type Subscription struct { + EnvironmentName string `json:"environmentName"` + ID string `json:"id"` + IsDefault bool `json:"isDefault"` + Name string `json:"name"` + State string `json:"state"` + TenantID string `json:"tenantId"` +} + +// ProfilePath returns the path where the Azure Profile is stored from the Azure CLI +func ProfilePath() (string, error) { + return homedir.Expand("~/.azure/azureProfile.json") +} + +// LoadProfile restores a Profile object from a file located at 'path'. +func LoadProfile(path string) (result Profile, err error) { + var contents []byte + contents, err = ioutil.ReadFile(path) + if err != nil { + err = fmt.Errorf("failed to open file (%s) while loading token: %v", path, err) + return + } + reader := utfbom.SkipOnly(bytes.NewReader(contents)) + + dec := json.NewDecoder(reader) + if err = dec.Decode(&result); err != nil { + err = fmt.Errorf("failed to decode contents of file (%s) into a Profile representation: %v", path, err) + return + } + + return +} diff --git a/vendor/github.com/Azure/go-autorest/autorest/azure/cli/token.go b/vendor/github.com/Azure/go-autorest/autorest/azure/cli/token.go new file mode 100644 index 000000000000..a1f3af1517f0 --- /dev/null +++ b/vendor/github.com/Azure/go-autorest/autorest/azure/cli/token.go @@ -0,0 +1,89 @@ +package cli + +import ( + "encoding/json" + "fmt" + "os" + "strconv" + "time" + + "github.com/Azure/go-autorest/autorest/adal" + "github.com/Azure/go-autorest/autorest/date" + "github.com/mitchellh/go-homedir" +) + +// Token represents an AccessToken from the Azure CLI +type Token struct { + AccessToken string `json:"accessToken"` + Authority string `json:"_authority"` + ClientID string `json:"_clientId"` + ExpiresOn string `json:"expiresOn"` + IdentityProvider string `json:"identityProvider"` + IsMRRT bool `json:"isMRRT"` + RefreshToken string `json:"refreshToken"` + Resource string `json:"resource"` + TokenType string `json:"tokenType"` + UserID string `json:"userId"` +} + +// ToADALToken converts an Azure CLI `Token`` to an `adal.Token`` +func (t Token) ToADALToken() (converted adal.Token, err error) { + tokenExpirationDate, err := ParseExpirationDate(t.ExpiresOn) + if err != nil { + err = fmt.Errorf("Error parsing Token Expiration Date %q: %+v", t.ExpiresOn, err) + return + } + + difference := tokenExpirationDate.Sub(date.UnixEpoch()) + + converted = adal.Token{ + AccessToken: t.AccessToken, + Type: t.TokenType, + ExpiresIn: "3600", + ExpiresOn: strconv.Itoa(int(difference.Seconds())), + RefreshToken: t.RefreshToken, + Resource: t.Resource, + } + return +} + +// AccessTokensPath returns the path where access tokens are stored from the Azure CLI +func AccessTokensPath() (string, error) { + return homedir.Expand("~/.azure/accessTokens.json") +} + +// ParseExpirationDate parses either a Azure CLI or CloudShell date into a time object +func ParseExpirationDate(input string) (*time.Time, error) { + // CloudShell (and potentially the Azure CLI in future) + expirationDate, cloudShellErr := time.Parse(time.RFC3339, input) + if cloudShellErr != nil { + // Azure CLI (Python) e.g. 2017-08-31 19:48:57.998857 (plus the local timezone) + const cliFormat = "2006-01-02 15:04:05.999999" + expirationDate, cliErr := time.ParseInLocation(cliFormat, input, time.Local) + if cliErr == nil { + return &expirationDate, nil + } + + return nil, fmt.Errorf("Error parsing expiration date %q.\n\nCloudShell Error: \n%+v\n\nCLI Error:\n%+v", input, cloudShellErr, cliErr) + } + + return &expirationDate, nil +} + +// LoadTokens restores a set of Token objects from a file located at 'path'. +func LoadTokens(path string) ([]Token, error) { + file, err := os.Open(path) + if err != nil { + return nil, fmt.Errorf("failed to open file (%s) while loading token: %v", path, err) + } + defer file.Close() + + var tokens []Token + + dec := json.NewDecoder(file) + if err = dec.Decode(&tokens); err != nil { + return nil, fmt.Errorf("failed to decode contents of file (%s) into a `cli.Token` representation: %v", path, err) + } + + return tokens, nil +} diff --git a/vendor/github.com/dimchansky/utfbom/LICENSE b/vendor/github.com/dimchansky/utfbom/LICENSE new file mode 100644 index 000000000000..8dada3edaf50 --- /dev/null +++ b/vendor/github.com/dimchansky/utfbom/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + 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. diff --git a/vendor/github.com/dimchansky/utfbom/README.md b/vendor/github.com/dimchansky/utfbom/README.md new file mode 100644 index 000000000000..2f06ecacd039 --- /dev/null +++ b/vendor/github.com/dimchansky/utfbom/README.md @@ -0,0 +1,81 @@ +# utfbom [![Godoc](https://godoc.org/github.com/dimchansky/utfbom?status.png)](https://godoc.org/github.com/dimchansky/utfbom) [![License](https://img.shields.io/:license-apache-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![Build Status](https://travis-ci.org/dimchansky/utfbom.svg?branch=master)](https://travis-ci.org/dimchansky/utfbom) [![Go Report Card](https://goreportcard.com/badge/github.com/dimchansky/utfbom)](https://goreportcard.com/report/github.com/dimchansky/utfbom) [![Coverage Status](https://coveralls.io/repos/github/dimchansky/utfbom/badge.svg?branch=master)](https://coveralls.io/github/dimchansky/utfbom?branch=master) + +The package utfbom implements the detection of the BOM (Unicode Byte Order Mark) and removing as necessary. It can also return the encoding detected by the BOM. + +## Installation + + go get -u github.com/dimchansky/utfbom + +## Example + +```go +package main + +import ( + "bytes" + "fmt" + "io/ioutil" + + "github.com/dimchansky/utfbom" +) + +func main() { + trySkip([]byte("\xEF\xBB\xBFhello")) + trySkip([]byte("hello")) +} + +func trySkip(byteData []byte) { + fmt.Println("Input:", byteData) + + // just skip BOM + output, err := ioutil.ReadAll(utfbom.SkipOnly(bytes.NewReader(byteData))) + if err != nil { + fmt.Println(err) + return + } + fmt.Println("ReadAll with BOM skipping", output) + + // skip BOM and detect encoding + sr, enc := utfbom.Skip(bytes.NewReader(byteData)) + var encStr string + switch enc { + case utfbom.UTF8: + encStr = "UTF8" + case utfbom.UTF16BigEndian: + encStr = "UTF16 big endian" + case utfbom.UTF16LittleEndian: + encStr = "UTF16 little endian" + case utfbom.UTF32BigEndian: + encStr = "UTF32 big endian" + case utfbom.UTF32LittleEndian: + encStr = "UTF32 little endian" + default: + encStr = "Unknown, no byte-order mark found" + } + fmt.Println("Detected encoding:", encStr) + output, err = ioutil.ReadAll(sr) + if err != nil { + fmt.Println(err) + return + } + fmt.Println("ReadAll with BOM detection and skipping", output) + fmt.Println() +} +``` + +Output: + +``` +$ go run main.go +Input: [239 187 191 104 101 108 108 111] +ReadAll with BOM skipping [104 101 108 108 111] +Detected encoding: UTF8 +ReadAll with BOM detection and skipping [104 101 108 108 111] + +Input: [104 101 108 108 111] +ReadAll with BOM skipping [104 101 108 108 111] +Detected encoding: Unknown, no byte-order mark found +ReadAll with BOM detection and skipping [104 101 108 108 111] +``` + + diff --git a/vendor/github.com/dimchansky/utfbom/utfbom.go b/vendor/github.com/dimchansky/utfbom/utfbom.go new file mode 100644 index 000000000000..648184a12dec --- /dev/null +++ b/vendor/github.com/dimchansky/utfbom/utfbom.go @@ -0,0 +1,174 @@ +// Package utfbom implements the detection of the BOM (Unicode Byte Order Mark) and removing as necessary. +// It wraps an io.Reader object, creating another object (Reader) that also implements the io.Reader +// interface but provides automatic BOM checking and removing as necessary. +package utfbom + +import ( + "errors" + "io" +) + +// Encoding is type alias for detected UTF encoding. +type Encoding int + +// Constants to identify detected UTF encodings. +const ( + // Unknown encoding, returned when no BOM was detected + Unknown Encoding = iota + + // UTF8, BOM bytes: EF BB BF + UTF8 + + // UTF-16, big-endian, BOM bytes: FE FF + UTF16BigEndian + + // UTF-16, little-endian, BOM bytes: FF FE + UTF16LittleEndian + + // UTF-32, big-endian, BOM bytes: 00 00 FE FF + UTF32BigEndian + + // UTF-32, little-endian, BOM bytes: FF FE 00 00 + UTF32LittleEndian +) + +const maxConsecutiveEmptyReads = 100 + +// Skip creates Reader which automatically detects BOM (Unicode Byte Order Mark) and removes it as necessary. +// It also returns the encoding detected by the BOM. +// If the detected encoding is not needed, you can call the SkipOnly function. +func Skip(rd io.Reader) (*Reader, Encoding) { + // Is it already a Reader? + b, ok := rd.(*Reader) + if ok { + return b, Unknown + } + + enc, left, err := detectUtf(rd) + return &Reader{ + rd: rd, + buf: left, + err: err, + }, enc +} + +// SkipOnly creates Reader which automatically detects BOM (Unicode Byte Order Mark) and removes it as necessary. +func SkipOnly(rd io.Reader) *Reader { + r, _ := Skip(rd) + return r +} + +// Reader implements automatic BOM (Unicode Byte Order Mark) checking and +// removing as necessary for an io.Reader object. +type Reader struct { + rd io.Reader // reader provided by the client + buf []byte // buffered data + err error // last error +} + +// Read is an implementation of io.Reader interface. +// The bytes are taken from the underlying Reader, but it checks for BOMs, removing them as necessary. +func (r *Reader) Read(p []byte) (n int, err error) { + if len(p) == 0 { + return 0, nil + } + + if r.buf == nil { + if r.err != nil { + return 0, r.readErr() + } + + return r.rd.Read(p) + } + + // copy as much as we can + n = copy(p, r.buf) + r.buf = nilIfEmpty(r.buf[n:]) + return n, nil +} + +func (r *Reader) readErr() error { + err := r.err + r.err = nil + return err +} + +var errNegativeRead = errors.New("utfbom: reader returned negative count from Read") + +func detectUtf(rd io.Reader) (enc Encoding, buf []byte, err error) { + buf, err = readBOM(rd) + + if len(buf) >= 4 { + if isUTF32BigEndianBOM4(buf) { + return UTF32BigEndian, nilIfEmpty(buf[4:]), err + } + if isUTF32LittleEndianBOM4(buf) { + return UTF32LittleEndian, nilIfEmpty(buf[4:]), err + } + } + + if len(buf) > 2 && isUTF8BOM3(buf) { + return UTF8, nilIfEmpty(buf[3:]), err + } + + if (err != nil && err != io.EOF) || (len(buf) < 2) { + return Unknown, nilIfEmpty(buf), err + } + + if isUTF16BigEndianBOM2(buf) { + return UTF16BigEndian, nilIfEmpty(buf[2:]), err + } + if isUTF16LittleEndianBOM2(buf) { + return UTF16LittleEndian, nilIfEmpty(buf[2:]), err + } + + return Unknown, nilIfEmpty(buf), err +} + +func readBOM(rd io.Reader) (buf []byte, err error) { + const maxBOMSize = 4 + var bom [maxBOMSize]byte // used to read BOM + + // read as many bytes as possible + for nEmpty, n := 0, 0; err == nil && len(buf) < maxBOMSize; buf = bom[:len(buf)+n] { + if n, err = rd.Read(bom[len(buf):]); n < 0 { + panic(errNegativeRead) + } + if n > 0 { + nEmpty = 0 + } else { + nEmpty++ + if nEmpty >= maxConsecutiveEmptyReads { + err = io.ErrNoProgress + } + } + } + return +} + +func isUTF32BigEndianBOM4(buf []byte) bool { + return buf[0] == 0x00 && buf[1] == 0x00 && buf[2] == 0xFE && buf[3] == 0xFF +} + +func isUTF32LittleEndianBOM4(buf []byte) bool { + return buf[0] == 0xFF && buf[1] == 0xFE && buf[2] == 0x00 && buf[3] == 0x00 +} + +func isUTF8BOM3(buf []byte) bool { + return buf[0] == 0xEF && buf[1] == 0xBB && buf[2] == 0xBF +} + +func isUTF16BigEndianBOM2(buf []byte) bool { + return buf[0] == 0xFE && buf[1] == 0xFF +} + +func isUTF16LittleEndianBOM2(buf []byte) bool { + return buf[0] == 0xFF && buf[1] == 0xFE +} + +func nilIfEmpty(buf []byte) (res []byte) { + if len(buf) > 0 { + res = buf + } + return +} diff --git a/vendor/vendor.json b/vendor/vendor.json index 9cd53209f38f..6ada02111892 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", @@ -26,6 +34,14 @@ "version": "=v10.3.0-beta", "versionExact": "v10.3.0-beta" }, + { + "checksumSHA1": "MqsrM6ecN0KvCc15+F0asFR34/I=", + "path": "github.com/Azure/azure-sdk-for-go/arm/containerinstance", + "revision": "57db66900881e9fd21fd041a9d013514700ecab3", + "revisionTime": "2017-08-18T20:19:01Z", + "version": "v10.3.0-beta", + "versionExact": "v10.3.0-beta" + }, { "checksumSHA1": "chn3haEbJWbCx0yBkusQ6SGiURg=", "path": "github.com/Azure/azure-sdk-for-go/arm/containerregistry", @@ -212,57 +228,66 @@ }, { "checksumSHA1": "+4d+Y67AMKKuyR1EO33Zdt+RVx0=", - "comment": "v8.3.0", + "comment": "v8.4.0", "path": "github.com/Azure/go-autorest/autorest", - "revision": "77a52603f06947221c672f10275abc9bf2c7d557", - "revisionTime": "2017-08-16T16:57:29Z", - "version": "v8.3.0", - "versionExact": "v8.3.0" + "revision": "f6be1abbb5abd0517522f850dd785990d373da7e", + "revisionTime": "2017-09-13T23:19:17Z", + "version": "v8.4.0", + "versionExact": "v8.4.0" }, { - "checksumSHA1": "KOETWLsF6QW+lrPVPsMNHDZP+xA=", - "comment": "v8.3.0", + "checksumSHA1": "7G4HgRaIT25bgz/hPtXG6Kv8Fho=", + "comment": "v8.4.0", "path": "github.com/Azure/go-autorest/autorest/adal", - "revision": "77a52603f06947221c672f10275abc9bf2c7d557", - "revisionTime": "2017-08-16T16:57:29Z", - "version": "v8.3.0", - "versionExact": "v8.3.0" + "revision": "f6be1abbb5abd0517522f850dd785990d373da7e", + "revisionTime": "2017-09-13T23:19:17Z", + "version": "v8.4.0", + "versionExact": "v8.4.0" }, { "checksumSHA1": "2KdBFgT4qY+fMOkBTa5vA9V0AiM=", - "comment": "v8.3.0", + "comment": "v8.4.0", "path": "github.com/Azure/go-autorest/autorest/azure", - "revision": "77a52603f06947221c672f10275abc9bf2c7d557", - "revisionTime": "2017-08-16T16:57:29Z", - "version": "v8.3.0", - "versionExact": "v8.3.0" + "revision": "f6be1abbb5abd0517522f850dd785990d373da7e", + "revisionTime": "2017-09-13T23:19:17Z", + "version": "v8.4.0", + "versionExact": "v8.4.0" + }, + { + "checksumSHA1": "apxw17Dm1naEXMbVDCRnEDkQDQ8=", + "comment": "v8.4.0", + "path": "github.com/Azure/go-autorest/autorest/azure/cli", + "revision": "f6be1abbb5abd0517522f850dd785990d373da7e", + "revisionTime": "2017-09-13T23:19:17Z", + "version": "v8.4.0", + "versionExact": "v8.4.0" }, { "checksumSHA1": "LSF/pNrjhIxl6jiS6bKooBFCOxI=", - "comment": "v8.3.0", + "comment": "v8.4.0", "path": "github.com/Azure/go-autorest/autorest/date", - "revision": "77a52603f06947221c672f10275abc9bf2c7d557", - "revisionTime": "2017-08-16T16:57:29Z", - "version": "v8.3.0", - "versionExact": "v8.3.0" + "revision": "f6be1abbb5abd0517522f850dd785990d373da7e", + "revisionTime": "2017-09-13T23:19:17Z", + "version": "v8.4.0", + "versionExact": "v8.4.0" }, { "checksumSHA1": "Ev8qCsbFjDlMlX0N2tYAhYQFpUc=", - "comment": "v8.3.0", + "comment": "v8.4.0", "path": "github.com/Azure/go-autorest/autorest/to", - "revision": "77a52603f06947221c672f10275abc9bf2c7d557", - "revisionTime": "2017-08-16T16:57:29Z", - "version": "v8.3.0", - "versionExact": "v8.3.0" + "revision": "f6be1abbb5abd0517522f850dd785990d373da7e", + "revisionTime": "2017-09-13T23:19:17Z", + "version": "v8.4.0", + "versionExact": "v8.4.0" }, { "checksumSHA1": "rGkTfIycpeix5TAbZS74ceGAPHI=", - "comment": "v8.3.0", + "comment": "v8.4.0", "path": "github.com/Azure/go-autorest/autorest/validation", - "revision": "77a52603f06947221c672f10275abc9bf2c7d557", - "revisionTime": "2017-08-16T16:57:29Z", - "version": "v8.3.0", - "versionExact": "v8.3.0" + "revision": "f6be1abbb5abd0517522f850dd785990d373da7e", + "revisionTime": "2017-09-13T23:19:17Z", + "version": "v8.4.0", + "versionExact": "v8.4.0" }, { "checksumSHA1": "FIL83loX9V9APvGQIjJpbxq53F0=", @@ -501,6 +526,12 @@ "revision": "f0777076321ab64f6efc15a82d9d23b98539b943", "revisionTime": "2016-06-17T17:01:58Z" }, + { + "checksumSHA1": "vI06gXltt7k8zik7bOZvG2PmfYo=", + "path": "github.com/dimchansky/utfbom", + "revision": "6c6132ff69f0f6c088739067407b5d32c52e1d0f", + "revisionTime": "2017-03-28T06:13:12Z" + }, { "checksumSHA1": "BCv50o5pDkoSG3vYKOSai1Z8p3w=", "path": "github.com/fsouza/go-dockerclient", diff --git a/website/azurerm.erb b/website/azurerm.erb index ad9f44fad760..beb08b95efd7 100644 --- a/website/azurerm.erb +++ b/website/azurerm.erb @@ -9,6 +9,15 @@ > Microsoft Azure Provider + > @@ -50,6 +59,10 @@ App Service (Web Apps) Resources + > + Automation Resources + + + > Application Insights Resources