diff --git a/azurerm/internal/services/containers/client.go b/azurerm/internal/services/containers/client.go index 0d098df6d7ed..fee94ac2e3e4 100644 --- a/azurerm/internal/services/containers/client.go +++ b/azurerm/internal/services/containers/client.go @@ -11,6 +11,7 @@ type Client struct { KubernetesClustersClient *containerservice.ManagedClustersClient GroupsClient *containerinstance.ContainerGroupsClient RegistriesClient *containerregistry.RegistriesClient + WebhooksClient *containerregistry.WebhooksClient ReplicationsClient *containerregistry.ReplicationsClient ServicesClient *containerservice.ContainerServicesClient } @@ -20,6 +21,9 @@ func BuildClient(o *common.ClientOptions) *Client { RegistriesClient := containerregistry.NewRegistriesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) o.ConfigureClient(&RegistriesClient.Client, o.ResourceManagerAuthorizer) + WebhooksClient := containerregistry.NewWebhooksClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) + o.ConfigureClient(&WebhooksClient.Client, o.ResourceManagerAuthorizer) + ReplicationsClient := containerregistry.NewReplicationsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) o.ConfigureClient(&ReplicationsClient.Client, o.ResourceManagerAuthorizer) @@ -38,6 +42,7 @@ func BuildClient(o *common.ClientOptions) *Client { KubernetesClustersClient: &KubernetesClustersClient, GroupsClient: &GroupsClient, RegistriesClient: &RegistriesClient, + WebhooksClient: &WebhooksClient, ReplicationsClient: &ReplicationsClient, ServicesClient: &ServicesClient, } diff --git a/azurerm/provider.go b/azurerm/provider.go index 656f10c15c87..20323438ed1e 100644 --- a/azurerm/provider.go +++ b/azurerm/provider.go @@ -177,6 +177,7 @@ func Provider() terraform.ResourceProvider { "azurerm_cognitive_account": resourceArmCognitiveAccount(), "azurerm_connection_monitor": resourceArmConnectionMonitor(), "azurerm_container_group": resourceArmContainerGroup(), + "azurerm_container_registry_webhook": resourceArmContainerRegistryWebhook(), "azurerm_container_registry": resourceArmContainerRegistry(), "azurerm_container_service": resourceArmContainerService(), "azurerm_cosmosdb_account": resourceArmCosmosDbAccount(), diff --git a/azurerm/resource_arm_container_registry_webhook.go b/azurerm/resource_arm_container_registry_webhook.go new file mode 100644 index 000000000000..118d3b7b076e --- /dev/null +++ b/azurerm/resource_arm_container_registry_webhook.go @@ -0,0 +1,350 @@ +package azurerm + +import ( + "fmt" + "log" + "regexp" + + "github.com/Azure/azure-sdk-for-go/services/containerregistry/mgmt/2018-09-01/containerregistry" + "github.com/hashicorp/terraform/helper/schema" + "github.com/hashicorp/terraform/helper/validation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/response" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func resourceArmContainerRegistryWebhook() *schema.Resource { + return &schema.Resource{ + Create: resourceArmContainerRegistryWebhookCreate, + Read: resourceArmContainerRegistryWebhookRead, + Update: resourceArmContainerRegistryWebhookUpdate, + Delete: resourceArmContainerRegistryWebhookDelete, + + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validateAzureRMContainerRegistryWebhookName, + }, + + "resource_group_name": azure.SchemaResourceGroupName(), + + "registry_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validateAzureRMContainerRegistryName, + }, + + "service_uri": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validateAzureRMContainerRegistryWebhookServiceUri, + }, + + "custom_headers": { + Type: schema.TypeMap, + Optional: true, + }, + + "status": { + Type: schema.TypeString, + Optional: true, + Default: containerregistry.WebhookStatusEnabled, + ValidateFunc: validation.StringInSlice([]string{ + string(containerregistry.WebhookStatusDisabled), + string(containerregistry.WebhookStatusEnabled), + }, false), + }, + + "scope": { + Type: schema.TypeString, + Optional: true, + Default: "", + }, + + "actions": { + Type: schema.TypeSet, + Required: true, + MinItems: 1, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.StringInSlice([]string{ + string(containerregistry.ChartDelete), + string(containerregistry.ChartPush), + string(containerregistry.Delete), + string(containerregistry.Push), + string(containerregistry.Quarantine), + }, false), + }, + }, + + "location": azure.SchemaLocation(), + + "tags": tagsSchema(), + }, + } +} + +func resourceArmContainerRegistryWebhookCreate(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).containers.WebhooksClient + ctx := meta.(*ArmClient).StopContext + log.Printf("[INFO] preparing arguments for AzureRM Container Registry Webhook creation.") + + resourceGroup := d.Get("resource_group_name").(string) + registryName := d.Get("registry_name").(string) + name := d.Get("name").(string) + + if requireResourcesToBeImported && d.IsNewResource() { + existing, err := client.Get(ctx, resourceGroup, registryName, name) + if err != nil { + if !utils.ResponseWasNotFound(existing.Response) { + return fmt.Errorf("Error checking for presence of existing Container Registry Webhook %q (Resource Group %q, Registry %q): %s", name, resourceGroup, registryName, err) + } + } + + if existing.ID != nil && *existing.ID != "" { + return tf.ImportAsExistsError("azurerm_container_registry_webhook", *existing.ID) + } + } + + location := azure.NormalizeLocation(d.Get("location").(string)) + tags := d.Get("tags").(map[string]interface{}) + + webhook := containerregistry.WebhookCreateParameters{ + Location: &location, + WebhookPropertiesCreateParameters: expandWebhookPropertiesCreateParameters(d), + Tags: expandTags(tags), + } + + future, err := client.Create(ctx, resourceGroup, registryName, name, webhook) + if err != nil { + return fmt.Errorf("Error creating Container Registry Webhook %q (Resource Group %q, Registry %q): %+v", name, resourceGroup, registryName, err) + } + + if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { + return fmt.Errorf("Error waiting for creation of Container Registry %q (Resource Group %q, Registry %q): %+v", name, resourceGroup, registryName, err) + } + + read, err := client.Get(ctx, resourceGroup, registryName, name) + if err != nil { + return fmt.Errorf("Error retrieving Container Registry %q (Resource Group %q, Registry %q): %+v", name, resourceGroup, registryName, err) + } + + if read.ID == nil { + return fmt.Errorf("Cannot read Container Registry %q (resource group %q, Registry %q) ID", name, resourceGroup, registryName) + } + + d.SetId(*read.ID) + + return resourceArmContainerRegistryWebhookRead(d, meta) +} + +func resourceArmContainerRegistryWebhookUpdate(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).containers.WebhooksClient + ctx := meta.(*ArmClient).StopContext + + log.Printf("[INFO] preparing arguments for AzureRM Container Registry Webhook update.") + + id, err := azure.ParseAzureResourceID(d.Id()) + if err != nil { + return err + } + + resourceGroup := id.ResourceGroup + registryName := id.Path["registries"] + name := id.Path["webhooks"] + + tags := d.Get("tags").(map[string]interface{}) + + webhook := containerregistry.WebhookUpdateParameters{ + WebhookPropertiesUpdateParameters: expandWebhookPropertiesUpdateParameters(d), + Tags: expandTags(tags), + } + + future, err := client.Update(ctx, resourceGroup, registryName, name, webhook) + if err != nil { + return fmt.Errorf("Error updating Container Registry Webhook %q (Resource Group %q, Registry %q): %+v", name, resourceGroup, registryName, err) + } + + if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { + return fmt.Errorf("Error waiting for completion of Container Registry Webhook %q (Resource Group %q, Registry %q): %+v", name, resourceGroup, registryName, err) + } + + return resourceArmContainerRegistryWebhookRead(d, meta) +} + +func resourceArmContainerRegistryWebhookRead(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).containers.WebhooksClient + ctx := meta.(*ArmClient).StopContext + + id, err := azure.ParseAzureResourceID(d.Id()) + if err != nil { + return err + } + resourceGroup := id.ResourceGroup + registryName := id.Path["registries"] + name := id.Path["webhooks"] + + resp, err := client.Get(ctx, resourceGroup, registryName, name) + if err != nil { + if utils.ResponseWasNotFound(resp.Response) { + log.Printf("[DEBUG] Container Registry Webhook %q was not found in Resource Group %q for Registry %q", name, resourceGroup, registryName) + d.SetId("") + return nil + } + + return fmt.Errorf("Error making Read request on Azure Container Registry Webhook %q (Resource Group %q, Registry %q): %+v", name, resourceGroup, registryName, err) + } + + callbackConfig, err := client.GetCallbackConfig(ctx, resourceGroup, registryName, name) + if err != nil { + return fmt.Errorf("Error making Read request on Azure Container Registry Webhook Callback Config %q (Resource Group %q, Registry %q): %+v", name, resourceGroup, registryName, err) + } + + d.Set("resource_group_name", resourceGroup) + d.Set("registry_name", registryName) + d.Set("name", name) + + if location := resp.Location; location != nil { + d.Set("location", azure.NormalizeLocation(*location)) + } + + d.Set("service_uri", callbackConfig.ServiceURI) + + if callbackConfig.CustomHeaders != nil { + customHeaders := make(map[string]string) + for k, v := range callbackConfig.CustomHeaders { + customHeaders[k] = *v + } + d.Set("custom_headers", customHeaders) + } + + if webhookProps := resp.WebhookProperties; webhookProps != nil { + if webhookProps.Status != "" { + d.Set("status", string(webhookProps.Status)) + } + + if webhookProps.Scope != nil { + d.Set("scope", webhookProps.Scope) + } + + webhookActions := make([]string, len(*webhookProps.Actions)) + for i, action := range *webhookProps.Actions { + webhookActions[i] = string(action) + } + d.Set("actions", webhookActions) + } + + flattenAndSetTags(d, resp.Tags) + + return nil +} + +func resourceArmContainerRegistryWebhookDelete(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).containers.WebhooksClient + ctx := meta.(*ArmClient).StopContext + + id, err := azure.ParseAzureResourceID(d.Id()) + if err != nil { + return err + } + resourceGroup := id.ResourceGroup + registryName := id.Path["registries"] + name := id.Path["webhooks"] + + future, err := client.Delete(ctx, resourceGroup, registryName, name) + if err != nil { + if response.WasNotFound(future.Response()) { + return nil + } + return fmt.Errorf("Error issuing Azure ARM delete request of Container Registry Webhook '%s': %+v", name, err) + } + + if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { + if response.WasNotFound(future.Response()) { + return nil + } + return fmt.Errorf("Error issuing Azure ARM delete request of Container Registry Webhook '%s': %+v", name, err) + } + + return nil +} + +func validateAzureRMContainerRegistryWebhookName(v interface{}, k string) (warnings []string, errors []error) { + value := v.(string) + if !regexp.MustCompile(`^[a-zA-Z0-9]{5,50}$`).MatchString(value) { + errors = append(errors, fmt.Errorf( + "alpha numeric characters only are allowed and between 5 and 50 characters in %q: %q", k, value)) + } + + return warnings, errors +} + +func validateAzureRMContainerRegistryWebhookServiceUri(v interface{}, k string) (warnings []string, errors []error) { + value := v.(string) + if !regexp.MustCompile(`^https?://[^\s]+$`).MatchString(value) { + errors = append(errors, fmt.Errorf( + "%q must start with http:// or https:// and must not contain whitespaces: %q", k, value)) + } + + return warnings, errors +} + +func expandWebhookPropertiesCreateParameters(d *schema.ResourceData) *containerregistry.WebhookPropertiesCreateParameters { + serviceUri := d.Get("service_uri").(string) + scope := d.Get("scope").(string) + + customHeaders := make(map[string]*string) + for k, v := range d.Get("custom_headers").(map[string]interface{}) { + customHeaders[k] = utils.String(v.(string)) + } + + actions := expandWebhookActions(d) + + webhookProperties := containerregistry.WebhookPropertiesCreateParameters{ + ServiceURI: &serviceUri, + CustomHeaders: customHeaders, + Actions: actions, + Scope: &scope, + } + + webhookProperties.Status = containerregistry.WebhookStatus(d.Get("status").(string)) + + return &webhookProperties +} + +func expandWebhookPropertiesUpdateParameters(d *schema.ResourceData) *containerregistry.WebhookPropertiesUpdateParameters { + serviceUri := d.Get("service_uri").(string) + scope := d.Get("scope").(string) + + customHeaders := make(map[string]*string) + for k, v := range d.Get("custom_headers").(map[string]interface{}) { + customHeaders[k] = utils.String(v.(string)) + } + + webhookProperties := containerregistry.WebhookPropertiesUpdateParameters{ + ServiceURI: &serviceUri, + CustomHeaders: customHeaders, + Actions: expandWebhookActions(d), + Scope: &scope, + Status: containerregistry.WebhookStatus(d.Get("status").(string)), + } + + return &webhookProperties +} + +func expandWebhookActions(d *schema.ResourceData) *[]containerregistry.WebhookAction { + actions := make([]containerregistry.WebhookAction, 0) + for _, action := range d.Get("actions").(*schema.Set).List() { + actions = append(actions, containerregistry.WebhookAction(action.(string))) + } + + return &actions +} diff --git a/azurerm/resource_arm_container_registry_webhook_test.go b/azurerm/resource_arm_container_registry_webhook_test.go new file mode 100644 index 000000000000..65454369f0d9 --- /dev/null +++ b/azurerm/resource_arm_container_registry_webhook_test.go @@ -0,0 +1,685 @@ +package azurerm + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform/helper/resource" + "github.com/hashicorp/terraform/terraform" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func TestAccAzureRMContainerRegistryWebhook_basic(t *testing.T) { + resourceName := "azurerm_container_registry_webhook.test" + ri := tf.AccRandTimeInt() + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMContainerRegistryWebhookDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMContainerRegistryWebhook_basic(ri, testLocation()), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMContainerRegistryWebhookExists(resourceName), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccAzureRMContainerRegistryWebhook_withTags(t *testing.T) { + resourceName := "azurerm_container_registry_webhook.test" + ri := tf.AccRandTimeInt() + preConfig := testAccAzureRMContainerRegistryWebhook_withTags(ri, testLocation()) + postConfig := testAccAzureRMContainerRegistryWebhook_withTagsUpdate(ri, testLocation()) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMContainerRegistryWebhookDestroy, + Steps: []resource.TestStep{ + { + Config: preConfig, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMContainerRegistryWebhookExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), + resource.TestCheckResourceAttr(resourceName, "tags.label", "test"), + ), + }, + { + Config: postConfig, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMContainerRegistryWebhookExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "tags.%", "2"), + resource.TestCheckResourceAttr(resourceName, "tags.label", "test1"), + resource.TestCheckResourceAttr(resourceName, "tags.ENV", "prod"), + ), + }, + }, + }) +} + +func TestAccAzureRMContainerRegistryWebhook_actions(t *testing.T) { + resourceName := "azurerm_container_registry_webhook.test" + ri := tf.AccRandTimeInt() + preConfig := testAccAzureRMContainerRegistryWebhook_actions(ri, testLocation()) + postConfig := testAccAzureRMContainerRegistryWebhook_actionsUpdate(ri, testLocation()) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMContainerRegistryWebhookDestroy, + Steps: []resource.TestStep{ + { + Config: preConfig, + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + { + Config: postConfig, + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccAzureRMContainerRegistryWebhook_status(t *testing.T) { + resourceName := "azurerm_container_registry_webhook.test" + ri := tf.AccRandTimeInt() + preConfig := testAccAzureRMContainerRegistryWebhook_status(ri, testLocation()) + postConfig := testAccAzureRMContainerRegistryWebhook_statusUpdate(ri, testLocation()) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMContainerRegistryWebhookDestroy, + Steps: []resource.TestStep{ + { + Config: preConfig, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMContainerRegistryWebhookExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "status", "enabled"), + ), + }, + { + Config: postConfig, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMContainerRegistryWebhookExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "status", "disabled"), + ), + }, + }, + }) +} + +func TestAccAzureRMContainerRegistryWebhook_serviceUri(t *testing.T) { + resourceName := "azurerm_container_registry_webhook.test" + ri := tf.AccRandTimeInt() + preConfig := testAccAzureRMContainerRegistryWebhook_serviceUri(ri, testLocation()) + postConfig := testAccAzureRMContainerRegistryWebhook_serviceUriUpdate(ri, testLocation()) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMContainerRegistryWebhookDestroy, + Steps: []resource.TestStep{ + { + Config: preConfig, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMContainerRegistryWebhookExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "service_uri", "https://mywebhookreceiver.example/mytag"), + ), + }, + { + Config: postConfig, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMContainerRegistryWebhookExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "service_uri", "https://my.webhookreceiver.example/mytag/2"), + ), + }, + }, + }) +} + +func TestAccAzureRMContainerRegistryWebhook_scope(t *testing.T) { + resourceName := "azurerm_container_registry_webhook.test" + ri := tf.AccRandTimeInt() + preConfig := testAccAzureRMContainerRegistryWebhook_scope(ri, testLocation()) + postConfig := testAccAzureRMContainerRegistryWebhook_scopeUpdate(ri, testLocation()) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMContainerRegistryWebhookDestroy, + Steps: []resource.TestStep{ + { + Config: preConfig, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMContainerRegistryWebhookExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "scope", "mytag:*"), + ), + }, + { + Config: postConfig, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMContainerRegistryWebhookExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "scope", "mytag:4"), + ), + }, + }, + }) +} + +func TestAccAzureRMContainerRegistryWebhook_customHeaders(t *testing.T) { + resourceName := "azurerm_container_registry_webhook.test" + ri := tf.AccRandTimeInt() + preConfig := testAccAzureRMContainerRegistryWebhook_customHeaders(ri, testLocation()) + postConfig := testAccAzureRMContainerRegistryWebhook_customHeadersUpdate(ri, testLocation()) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMContainerRegistryWebhookDestroy, + Steps: []resource.TestStep{ + { + Config: preConfig, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMContainerRegistryWebhookExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "custom_headers.%", "1"), + resource.TestCheckResourceAttr(resourceName, "custom_headers.Content-Type", "application/json"), + ), + }, + { + Config: postConfig, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMContainerRegistryWebhookExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "custom_headers.%", "2"), + resource.TestCheckResourceAttr(resourceName, "custom_headers.Content-Type", "application/xml"), + resource.TestCheckResourceAttr(resourceName, "custom_headers.Accept-Charset", "utf-8"), + ), + }, + }, + }) +} + +func testAccAzureRMContainerRegistryWebhook_basic(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "rg" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_container_registry" "acr" { + name = "acrwebhooktest%d" + resource_group_name = azurerm_resource_group.rg.name + location = "%s" + sku = "Standard" +} + +resource "azurerm_container_registry_webhook" "test" { + name = "testwebhook%d" + resource_group_name = azurerm_resource_group.rg.name + registry_name = azurerm_container_registry.acr.name + location = "%s" + + service_uri = "https://mywebhookreceiver.example/mytag" + + actions = [ + "push" + ] +} +`, rInt, location, rInt, location, rInt, location) +} + +func testAccAzureRMContainerRegistryWebhook_withTags(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "rg" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_container_registry" "acr" { + name = "acrwebhooktest%d" + resource_group_name = azurerm_resource_group.rg.name + location = "%s" + sku = "Standard" +} + +resource "azurerm_container_registry_webhook" "test" { + name = "testwebhook%d" + resource_group_name = azurerm_resource_group.rg.name + registry_name = azurerm_container_registry.acr.name + location = "%s" + + service_uri = "https://mywebhookreceiver.example/mytag" + + actions = [ + "push" + ] + + tags = { + label = "test" + } +} +`, rInt, location, rInt, location, rInt, location) +} + +func testAccAzureRMContainerRegistryWebhook_withTagsUpdate(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "rg" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_container_registry" "acr" { + name = "acrwebhooktest%d" + resource_group_name = azurerm_resource_group.rg.name + location = "%s" + sku = "Standard" +} + +resource "azurerm_container_registry_webhook" "test" { + name = "testwebhook%d" + resource_group_name = azurerm_resource_group.rg.name + registry_name = azurerm_container_registry.acr.name + location = "%s" + + service_uri = "https://mywebhookreceiver.example/mytag" + + actions = [ + "push" + ] + + tags = { + label = "test1" + ENV = "prod" + } +} +`, rInt, location, rInt, location, rInt, location) +} + +func testAccAzureRMContainerRegistryWebhook_actions(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "rg" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_container_registry" "acr" { + name = "acrwebhooktest%d" + resource_group_name = azurerm_resource_group.rg.name + location = "%s" + sku = "Standard" +} + +resource "azurerm_container_registry_webhook" "test" { + name = "testwebhook%d" + resource_group_name = azurerm_resource_group.rg.name + registry_name = azurerm_container_registry.acr.name + location = "%s" + + service_uri = "https://mywebhookreceiver.example/mytag" + + actions = [ + "push" + ] +} +`, rInt, location, rInt, location, rInt, location) +} + +func testAccAzureRMContainerRegistryWebhook_actionsUpdate(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "rg" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_container_registry" "acr" { + name = "acrwebhooktest%d" + resource_group_name = azurerm_resource_group.rg.name + location = "%s" + sku = "Standard" +} + +resource "azurerm_container_registry_webhook" "test" { + name = "testwebhook%d" + resource_group_name = azurerm_resource_group.rg.name + registry_name = azurerm_container_registry.acr.name + location = "%s" + + service_uri = "https://mywebhookreceiver.example/mytag" + + actions = [ + "push", + "delete" + ] +} +`, rInt, location, rInt, location, rInt, location) +} + +func testAccAzureRMContainerRegistryWebhook_status(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "rg" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_container_registry" "acr" { + name = "acrwebhooktest%d" + resource_group_name = azurerm_resource_group.rg.name + location = "%s" + sku = "Standard" +} + +resource "azurerm_container_registry_webhook" "test" { + name = "testwebhook%d" + resource_group_name = azurerm_resource_group.rg.name + registry_name = azurerm_container_registry.acr.name + location = "%s" + + service_uri = "https://mywebhookreceiver.example/mytag" + + status = "enabled" + + actions = [ + "push" + ] +} +`, rInt, location, rInt, location, rInt, location) +} + +func testAccAzureRMContainerRegistryWebhook_statusUpdate(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "rg" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_container_registry" "acr" { + name = "acrwebhooktest%d" + resource_group_name = azurerm_resource_group.rg.name + location = "%s" + sku = "Standard" +} + +resource "azurerm_container_registry_webhook" "test" { + name = "testwebhook%d" + resource_group_name = azurerm_resource_group.rg.name + registry_name = azurerm_container_registry.acr.name + location = "%s" + + service_uri = "https://mywebhookreceiver.example/mytag" + + status = "disabled" + + actions = [ + "push" + ] +} +`, rInt, location, rInt, location, rInt, location) +} + +func testAccAzureRMContainerRegistryWebhook_serviceUri(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "rg" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_container_registry" "acr" { + name = "acrwebhooktest%d" + resource_group_name = azurerm_resource_group.rg.name + location = "%s" + sku = "Standard" +} + +resource "azurerm_container_registry_webhook" "test" { + name = "testwebhook%d" + resource_group_name = azurerm_resource_group.rg.name + registry_name = azurerm_container_registry.acr.name + location = "%s" + + service_uri = "https://mywebhookreceiver.example/mytag" + + actions = [ + "push" + ] +} +`, rInt, location, rInt, location, rInt, location) +} + +func testAccAzureRMContainerRegistryWebhook_serviceUriUpdate(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "rg" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_container_registry" "acr" { + name = "acrwebhooktest%d" + resource_group_name = azurerm_resource_group.rg.name + location = "%s" + sku = "Standard" +} + +resource "azurerm_container_registry_webhook" "test" { + name = "testwebhook%d" + resource_group_name = azurerm_resource_group.rg.name + registry_name = azurerm_container_registry.acr.name + location = "%s" + + service_uri = "https://my.webhookreceiver.example/mytag/2" + + status = "disabled" + + actions = [ + "push" + ] +} +`, rInt, location, rInt, location, rInt, location) +} + +func testAccAzureRMContainerRegistryWebhook_scope(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "rg" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_container_registry" "acr" { + name = "acrwebhooktest%d" + resource_group_name = azurerm_resource_group.rg.name + location = "%s" + sku = "Standard" +} + +resource "azurerm_container_registry_webhook" "test" { + name = "testwebhook%d" + resource_group_name = azurerm_resource_group.rg.name + registry_name = azurerm_container_registry.acr.name + location = "%s" + + service_uri = "https://mywebhookreceiver.example/mytag" + + scope = "mytag:*" + + actions = [ + "push" + ] +} +`, rInt, location, rInt, location, rInt, location) +} + +func testAccAzureRMContainerRegistryWebhook_scopeUpdate(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "rg" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_container_registry" "acr" { + name = "acrwebhooktest%d" + resource_group_name = azurerm_resource_group.rg.name + location = "%s" + sku = "Standard" +} + +resource "azurerm_container_registry_webhook" "test" { + name = "testwebhook%d" + resource_group_name = azurerm_resource_group.rg.name + registry_name = azurerm_container_registry.acr.name + location = "%s" + + service_uri = "https://mywebhookreceiver.example/mytag" + + scope = "mytag:4" + + actions = [ + "push" + ] +} +`, rInt, location, rInt, location, rInt, location) +} + +func testAccAzureRMContainerRegistryWebhook_customHeaders(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "rg" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_container_registry" "acr" { + name = "acrwebhooktest%d" + resource_group_name = azurerm_resource_group.rg.name + location = "%s" + sku = "Standard" +} + +resource "azurerm_container_registry_webhook" "test" { + name = "testwebhook%d" + resource_group_name = azurerm_resource_group.rg.name + registry_name = azurerm_container_registry.acr.name + location = "%s" + + service_uri = "https://mywebhookreceiver.example/mytag" + + custom_headers = { + "Content-Type" = "application/json" + } + + actions = [ + "push" + ] +} +`, rInt, location, rInt, location, rInt, location) +} + +func testAccAzureRMContainerRegistryWebhook_customHeadersUpdate(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "rg" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_container_registry" "acr" { + name = "acrwebhooktest%d" + resource_group_name = azurerm_resource_group.rg.name + location = "%s" + sku = "Standard" +} + +resource "azurerm_container_registry_webhook" "test" { + name = "testwebhook%d" + resource_group_name = azurerm_resource_group.rg.name + registry_name = azurerm_container_registry.acr.name + location = "%s" + + service_uri = "https://mywebhookreceiver.example/mytag" + + custom_headers = { + "Content-Type" = "application/xml" + "Accept-Charset" = "utf-8" + } + + actions = [ + "push" + ] +} +`, rInt, location, rInt, location, rInt, location) +} + +func testCheckAzureRMContainerRegistryWebhookDestroy(s *terraform.State) error { + client := testAccProvider.Meta().(*ArmClient).containers.WebhooksClient + + for _, rs := range s.RootModule().Resources { + if rs.Type != "azurerm_container_registry_webhook" { + continue + } + + resourceGroup := rs.Primary.Attributes["resource_group_name"] + registryName := rs.Primary.Attributes["registry_name"] + name := rs.Primary.Attributes["name"] + + ctx := testAccProvider.Meta().(*ArmClient).StopContext + resp, err := client.Get(ctx, resourceGroup, registryName, name) + + if err != nil { + if utils.ResponseWasNotFound(resp.Response) { + return nil + } + return err + } + + return nil + } + + return nil +} + +func testCheckAzureRMContainerRegistryWebhookExists(resourceName 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[resourceName] + if !ok { + return fmt.Errorf("Not found: %s", resourceName) + } + + webhookName := 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 Webhook: %s", webhookName) + } + + registryName, hasRegistryName := rs.Primary.Attributes["registry_name"] + if !hasRegistryName { + return fmt.Errorf("Bad: no registry name found in state for Container Registry Webhook: %s", webhookName) + } + + client := testAccProvider.Meta().(*ArmClient).containers.WebhooksClient + ctx := testAccProvider.Meta().(*ArmClient).StopContext + resp, err := client.Get(ctx, resourceGroup, registryName, webhookName) + if err != nil { + if utils.ResponseWasNotFound(resp.Response) { + return fmt.Errorf("Bad: Container Registry Webhook %q (resource group: %q) does not exist", webhookName, resourceGroup) + } + + return fmt.Errorf("Bad: Get on WebhooksClient: %+v", err) + } + + return nil + } +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/classicadministrators.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/classicadministrators.go deleted file mode 100644 index c66bfbaf6024..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/classicadministrators.go +++ /dev/null @@ -1,151 +0,0 @@ -package authorization - -// 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. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// ClassicAdministratorsClient is the client for the ClassicAdministrators methods of the Authorization service. -type ClassicAdministratorsClient struct { - BaseClient -} - -// NewClassicAdministratorsClient creates an instance of the ClassicAdministratorsClient client. -func NewClassicAdministratorsClient(subscriptionID string) ClassicAdministratorsClient { - return NewClassicAdministratorsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewClassicAdministratorsClientWithBaseURI creates an instance of the ClassicAdministratorsClient client. -func NewClassicAdministratorsClientWithBaseURI(baseURI string, subscriptionID string) ClassicAdministratorsClient { - return ClassicAdministratorsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// List gets service administrator, account administrator, and co-administrators for the subscription. -func (client ClassicAdministratorsClient) List(ctx context.Context) (result ClassicAdministratorListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ClassicAdministratorsClient.List") - defer func() { - sc := -1 - if result.calr.Response.Response != nil { - sc = result.calr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.fn = client.listNextResults - req, err := client.ListPreparer(ctx) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.ClassicAdministratorsClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.calr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "authorization.ClassicAdministratorsClient", "List", resp, "Failure sending request") - return - } - - result.calr, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.ClassicAdministratorsClient", "List", resp, "Failure responding to request") - } - - return -} - -// ListPreparer prepares the List request. -func (client ClassicAdministratorsClient) ListPreparer(ctx context.Context) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2015-06-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/classicAdministrators", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client ClassicAdministratorsClient) ListSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client ClassicAdministratorsClient) ListResponder(resp *http.Response) (result ClassicAdministratorListResult, 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 ClassicAdministratorsClient) listNextResults(ctx context.Context, lastResults ClassicAdministratorListResult) (result ClassicAdministratorListResult, err error) { - req, err := lastResults.classicAdministratorListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "authorization.ClassicAdministratorsClient", "listNextResults", 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, "authorization.ClassicAdministratorsClient", "listNextResults", resp, "Failure sending next results request") - } - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.ClassicAdministratorsClient", "listNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListComplete enumerates all values, automatically crossing page boundaries as required. -func (client ClassicAdministratorsClient) ListComplete(ctx context.Context) (result ClassicAdministratorListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ClassicAdministratorsClient.List") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.List(ctx) - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/client.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/client.go deleted file mode 100644 index 362420bdfa36..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/client.go +++ /dev/null @@ -1,51 +0,0 @@ -// Package authorization implements the Azure ARM Authorization service API version . -// -// -package authorization - -// 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. -// 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 Authorization - DefaultBaseURI = "https://management.azure.com" -) - -// BaseClient is the base client for Authorization. -type BaseClient struct { - autorest.Client - BaseURI string - SubscriptionID string -} - -// New creates an instance of the BaseClient client. -func New(subscriptionID string) BaseClient { - return NewWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewWithBaseURI creates an instance of the BaseClient client. -func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { - return BaseClient{ - Client: autorest.NewClientWithUserAgent(UserAgent()), - BaseURI: baseURI, - SubscriptionID: subscriptionID, - } -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/globaladministrator.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/globaladministrator.go deleted file mode 100644 index d9e0167cdbcc..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/globaladministrator.go +++ /dev/null @@ -1,108 +0,0 @@ -package authorization - -// 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. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// GlobalAdministratorClient is the client for the GlobalAdministrator methods of the Authorization service. -type GlobalAdministratorClient struct { - BaseClient -} - -// NewGlobalAdministratorClient creates an instance of the GlobalAdministratorClient client. -func NewGlobalAdministratorClient(subscriptionID string) GlobalAdministratorClient { - return NewGlobalAdministratorClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewGlobalAdministratorClientWithBaseURI creates an instance of the GlobalAdministratorClient client. -func NewGlobalAdministratorClientWithBaseURI(baseURI string, subscriptionID string) GlobalAdministratorClient { - return GlobalAdministratorClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// ElevateAccess elevates access for a Global Administrator. -func (client GlobalAdministratorClient) ElevateAccess(ctx context.Context) (result autorest.Response, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/GlobalAdministratorClient.ElevateAccess") - defer func() { - sc := -1 - if result.Response != nil { - sc = result.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.ElevateAccessPreparer(ctx) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.GlobalAdministratorClient", "ElevateAccess", nil, "Failure preparing request") - return - } - - resp, err := client.ElevateAccessSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "authorization.GlobalAdministratorClient", "ElevateAccess", resp, "Failure sending request") - return - } - - result, err = client.ElevateAccessResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.GlobalAdministratorClient", "ElevateAccess", resp, "Failure responding to request") - } - - return -} - -// ElevateAccessPreparer prepares the ElevateAccess request. -func (client GlobalAdministratorClient) ElevateAccessPreparer(ctx context.Context) (*http.Request, error) { - const APIVersion = "2015-07-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/providers/Microsoft.Authorization/elevateAccess"), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ElevateAccessSender sends the ElevateAccess request. The method will close the -// http.Response Body if it receives an error. -func (client GlobalAdministratorClient) ElevateAccessSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// ElevateAccessResponder handles the response to the ElevateAccess request. The method always -// closes the http.Response Body. -func (client GlobalAdministratorClient) ElevateAccessResponder(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/services/preview/authorization/mgmt/2018-01-01-preview/authorization/models.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/models.go deleted file mode 100644 index 0a03dbb03294..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/models.go +++ /dev/null @@ -1,1143 +0,0 @@ -package authorization - -// 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. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "encoding/json" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/to" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// The package's fully qualified name. -const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization" - -// ClassicAdministrator classic Administrators -type ClassicAdministrator struct { - // ID - The ID of the administrator. - ID *string `json:"id,omitempty"` - // Name - The name of the administrator. - Name *string `json:"name,omitempty"` - // Type - The type of the administrator. - Type *string `json:"type,omitempty"` - // ClassicAdministratorProperties - Properties for the classic administrator. - *ClassicAdministratorProperties `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for ClassicAdministrator. -func (ca ClassicAdministrator) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if ca.ID != nil { - objectMap["id"] = ca.ID - } - if ca.Name != nil { - objectMap["name"] = ca.Name - } - if ca.Type != nil { - objectMap["type"] = ca.Type - } - if ca.ClassicAdministratorProperties != nil { - objectMap["properties"] = ca.ClassicAdministratorProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for ClassicAdministrator struct. -func (ca *ClassicAdministrator) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - ca.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - ca.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - ca.Type = &typeVar - } - case "properties": - if v != nil { - var classicAdministratorProperties ClassicAdministratorProperties - err = json.Unmarshal(*v, &classicAdministratorProperties) - if err != nil { - return err - } - ca.ClassicAdministratorProperties = &classicAdministratorProperties - } - } - } - - return nil -} - -// ClassicAdministratorListResult classicAdministrator list result information. -type ClassicAdministratorListResult struct { - autorest.Response `json:"-"` - // Value - An array of administrators. - Value *[]ClassicAdministrator `json:"value,omitempty"` - // NextLink - The URL to use for getting the next set of results. - NextLink *string `json:"nextLink,omitempty"` -} - -// ClassicAdministratorListResultIterator provides access to a complete listing of ClassicAdministrator -// values. -type ClassicAdministratorListResultIterator struct { - i int - page ClassicAdministratorListResultPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *ClassicAdministratorListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ClassicAdministratorListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *ClassicAdministratorListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter ClassicAdministratorListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter ClassicAdministratorListResultIterator) Response() ClassicAdministratorListResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter ClassicAdministratorListResultIterator) Value() ClassicAdministrator { - if !iter.page.NotDone() { - return ClassicAdministrator{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the ClassicAdministratorListResultIterator type. -func NewClassicAdministratorListResultIterator(page ClassicAdministratorListResultPage) ClassicAdministratorListResultIterator { - return ClassicAdministratorListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (calr ClassicAdministratorListResult) IsEmpty() bool { - return calr.Value == nil || len(*calr.Value) == 0 -} - -// classicAdministratorListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (calr ClassicAdministratorListResult) classicAdministratorListResultPreparer(ctx context.Context) (*http.Request, error) { - if calr.NextLink == nil || len(to.String(calr.NextLink)) < 1 { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(calr.NextLink))) -} - -// ClassicAdministratorListResultPage contains a page of ClassicAdministrator values. -type ClassicAdministratorListResultPage struct { - fn func(context.Context, ClassicAdministratorListResult) (ClassicAdministratorListResult, error) - calr ClassicAdministratorListResult -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *ClassicAdministratorListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ClassicAdministratorListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - next, err := page.fn(ctx, page.calr) - if err != nil { - return err - } - page.calr = next - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *ClassicAdministratorListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page ClassicAdministratorListResultPage) NotDone() bool { - return !page.calr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page ClassicAdministratorListResultPage) Response() ClassicAdministratorListResult { - return page.calr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page ClassicAdministratorListResultPage) Values() []ClassicAdministrator { - if page.calr.IsEmpty() { - return nil - } - return *page.calr.Value -} - -// Creates a new instance of the ClassicAdministratorListResultPage type. -func NewClassicAdministratorListResultPage(getNextPage func(context.Context, ClassicAdministratorListResult) (ClassicAdministratorListResult, error)) ClassicAdministratorListResultPage { - return ClassicAdministratorListResultPage{fn: getNextPage} -} - -// ClassicAdministratorProperties classic Administrator properties. -type ClassicAdministratorProperties struct { - // EmailAddress - The email address of the administrator. - EmailAddress *string `json:"emailAddress,omitempty"` - // Role - The role of the administrator. - Role *string `json:"role,omitempty"` -} - -// Permission role definition permissions. -type Permission struct { - // Actions - Allowed actions. - Actions *[]string `json:"actions,omitempty"` - // NotActions - Denied actions. - NotActions *[]string `json:"notActions,omitempty"` - // DataActions - Allowed Data actions. - DataActions *[]string `json:"dataActions,omitempty"` - // NotDataActions - Denied Data actions. - NotDataActions *[]string `json:"notDataActions,omitempty"` -} - -// PermissionGetResult permissions information. -type PermissionGetResult struct { - autorest.Response `json:"-"` - // Value - An array of permissions. - Value *[]Permission `json:"value,omitempty"` - // NextLink - The URL to use for getting the next set of results. - NextLink *string `json:"nextLink,omitempty"` -} - -// PermissionGetResultIterator provides access to a complete listing of Permission values. -type PermissionGetResultIterator struct { - i int - page PermissionGetResultPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *PermissionGetResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/PermissionGetResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *PermissionGetResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter PermissionGetResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter PermissionGetResultIterator) Response() PermissionGetResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter PermissionGetResultIterator) Value() Permission { - if !iter.page.NotDone() { - return Permission{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the PermissionGetResultIterator type. -func NewPermissionGetResultIterator(page PermissionGetResultPage) PermissionGetResultIterator { - return PermissionGetResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (pgr PermissionGetResult) IsEmpty() bool { - return pgr.Value == nil || len(*pgr.Value) == 0 -} - -// permissionGetResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (pgr PermissionGetResult) permissionGetResultPreparer(ctx context.Context) (*http.Request, error) { - if pgr.NextLink == nil || len(to.String(pgr.NextLink)) < 1 { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(pgr.NextLink))) -} - -// PermissionGetResultPage contains a page of Permission values. -type PermissionGetResultPage struct { - fn func(context.Context, PermissionGetResult) (PermissionGetResult, error) - pgr PermissionGetResult -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *PermissionGetResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/PermissionGetResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - next, err := page.fn(ctx, page.pgr) - if err != nil { - return err - } - page.pgr = next - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *PermissionGetResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page PermissionGetResultPage) NotDone() bool { - return !page.pgr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page PermissionGetResultPage) Response() PermissionGetResult { - return page.pgr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page PermissionGetResultPage) Values() []Permission { - if page.pgr.IsEmpty() { - return nil - } - return *page.pgr.Value -} - -// Creates a new instance of the PermissionGetResultPage type. -func NewPermissionGetResultPage(getNextPage func(context.Context, PermissionGetResult) (PermissionGetResult, error)) PermissionGetResultPage { - return PermissionGetResultPage{fn: getNextPage} -} - -// ProviderOperation operation -type ProviderOperation struct { - // Name - The operation name. - Name *string `json:"name,omitempty"` - // DisplayName - The operation display name. - DisplayName *string `json:"displayName,omitempty"` - // Description - The operation description. - Description *string `json:"description,omitempty"` - // Origin - The operation origin. - Origin *string `json:"origin,omitempty"` - // Properties - The operation properties. - Properties interface{} `json:"properties,omitempty"` - // IsDataAction - The dataAction flag to specify the operation type. - IsDataAction *bool `json:"isDataAction,omitempty"` -} - -// ProviderOperationsMetadata provider Operations metadata -type ProviderOperationsMetadata struct { - autorest.Response `json:"-"` - // ID - The provider id. - ID *string `json:"id,omitempty"` - // Name - The provider name. - Name *string `json:"name,omitempty"` - // Type - The provider type. - Type *string `json:"type,omitempty"` - // DisplayName - The provider display name. - DisplayName *string `json:"displayName,omitempty"` - // ResourceTypes - The provider resource types - ResourceTypes *[]ResourceType `json:"resourceTypes,omitempty"` - // Operations - The provider operations. - Operations *[]ProviderOperation `json:"operations,omitempty"` -} - -// ProviderOperationsMetadataListResult provider operations metadata list -type ProviderOperationsMetadataListResult struct { - autorest.Response `json:"-"` - // Value - The list of providers. - Value *[]ProviderOperationsMetadata `json:"value,omitempty"` - // NextLink - The URL to use for getting the next set of results. - NextLink *string `json:"nextLink,omitempty"` -} - -// ProviderOperationsMetadataListResultIterator provides access to a complete listing of -// ProviderOperationsMetadata values. -type ProviderOperationsMetadataListResultIterator struct { - i int - page ProviderOperationsMetadataListResultPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *ProviderOperationsMetadataListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ProviderOperationsMetadataListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *ProviderOperationsMetadataListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter ProviderOperationsMetadataListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter ProviderOperationsMetadataListResultIterator) Response() ProviderOperationsMetadataListResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter ProviderOperationsMetadataListResultIterator) Value() ProviderOperationsMetadata { - if !iter.page.NotDone() { - return ProviderOperationsMetadata{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the ProviderOperationsMetadataListResultIterator type. -func NewProviderOperationsMetadataListResultIterator(page ProviderOperationsMetadataListResultPage) ProviderOperationsMetadataListResultIterator { - return ProviderOperationsMetadataListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (pomlr ProviderOperationsMetadataListResult) IsEmpty() bool { - return pomlr.Value == nil || len(*pomlr.Value) == 0 -} - -// providerOperationsMetadataListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (pomlr ProviderOperationsMetadataListResult) providerOperationsMetadataListResultPreparer(ctx context.Context) (*http.Request, error) { - if pomlr.NextLink == nil || len(to.String(pomlr.NextLink)) < 1 { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(pomlr.NextLink))) -} - -// ProviderOperationsMetadataListResultPage contains a page of ProviderOperationsMetadata values. -type ProviderOperationsMetadataListResultPage struct { - fn func(context.Context, ProviderOperationsMetadataListResult) (ProviderOperationsMetadataListResult, error) - pomlr ProviderOperationsMetadataListResult -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *ProviderOperationsMetadataListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ProviderOperationsMetadataListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - next, err := page.fn(ctx, page.pomlr) - if err != nil { - return err - } - page.pomlr = next - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *ProviderOperationsMetadataListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page ProviderOperationsMetadataListResultPage) NotDone() bool { - return !page.pomlr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page ProviderOperationsMetadataListResultPage) Response() ProviderOperationsMetadataListResult { - return page.pomlr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page ProviderOperationsMetadataListResultPage) Values() []ProviderOperationsMetadata { - if page.pomlr.IsEmpty() { - return nil - } - return *page.pomlr.Value -} - -// Creates a new instance of the ProviderOperationsMetadataListResultPage type. -func NewProviderOperationsMetadataListResultPage(getNextPage func(context.Context, ProviderOperationsMetadataListResult) (ProviderOperationsMetadataListResult, error)) ProviderOperationsMetadataListResultPage { - return ProviderOperationsMetadataListResultPage{fn: getNextPage} -} - -// ResourceType resource Type -type ResourceType struct { - // Name - The resource type name. - Name *string `json:"name,omitempty"` - // DisplayName - The resource type display name. - DisplayName *string `json:"displayName,omitempty"` - // Operations - The resource type operations. - Operations *[]ProviderOperation `json:"operations,omitempty"` -} - -// RoleAssignment role Assignments -type RoleAssignment struct { - autorest.Response `json:"-"` - // ID - READ-ONLY; The role assignment ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The role assignment name. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The role assignment type. - Type *string `json:"type,omitempty"` - // RoleAssignmentPropertiesWithScope - Role assignment properties. - *RoleAssignmentPropertiesWithScope `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for RoleAssignment. -func (ra RoleAssignment) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if ra.RoleAssignmentPropertiesWithScope != nil { - objectMap["properties"] = ra.RoleAssignmentPropertiesWithScope - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for RoleAssignment struct. -func (ra *RoleAssignment) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - ra.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - ra.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - ra.Type = &typeVar - } - case "properties": - if v != nil { - var roleAssignmentPropertiesWithScope RoleAssignmentPropertiesWithScope - err = json.Unmarshal(*v, &roleAssignmentPropertiesWithScope) - if err != nil { - return err - } - ra.RoleAssignmentPropertiesWithScope = &roleAssignmentPropertiesWithScope - } - } - } - - return nil -} - -// RoleAssignmentCreateParameters role assignment create parameters. -type RoleAssignmentCreateParameters struct { - // RoleAssignmentProperties - Role assignment properties. - *RoleAssignmentProperties `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for RoleAssignmentCreateParameters. -func (racp RoleAssignmentCreateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if racp.RoleAssignmentProperties != nil { - objectMap["properties"] = racp.RoleAssignmentProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for RoleAssignmentCreateParameters struct. -func (racp *RoleAssignmentCreateParameters) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var roleAssignmentProperties RoleAssignmentProperties - err = json.Unmarshal(*v, &roleAssignmentProperties) - if err != nil { - return err - } - racp.RoleAssignmentProperties = &roleAssignmentProperties - } - } - } - - return nil -} - -// RoleAssignmentFilter role Assignments filter -type RoleAssignmentFilter struct { - // PrincipalID - Returns role assignment of the specific principal. - PrincipalID *string `json:"principalId,omitempty"` - // CanDelegate - The Delegation flag for the role assignment - CanDelegate *bool `json:"canDelegate,omitempty"` -} - -// RoleAssignmentListResult role assignment list operation result. -type RoleAssignmentListResult struct { - autorest.Response `json:"-"` - // Value - Role assignment list. - Value *[]RoleAssignment `json:"value,omitempty"` - // NextLink - The URL to use for getting the next set of results. - NextLink *string `json:"nextLink,omitempty"` -} - -// RoleAssignmentListResultIterator provides access to a complete listing of RoleAssignment values. -type RoleAssignmentListResultIterator struct { - i int - page RoleAssignmentListResultPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *RoleAssignmentListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *RoleAssignmentListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter RoleAssignmentListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter RoleAssignmentListResultIterator) Response() RoleAssignmentListResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter RoleAssignmentListResultIterator) Value() RoleAssignment { - if !iter.page.NotDone() { - return RoleAssignment{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the RoleAssignmentListResultIterator type. -func NewRoleAssignmentListResultIterator(page RoleAssignmentListResultPage) RoleAssignmentListResultIterator { - return RoleAssignmentListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (ralr RoleAssignmentListResult) IsEmpty() bool { - return ralr.Value == nil || len(*ralr.Value) == 0 -} - -// roleAssignmentListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (ralr RoleAssignmentListResult) roleAssignmentListResultPreparer(ctx context.Context) (*http.Request, error) { - if ralr.NextLink == nil || len(to.String(ralr.NextLink)) < 1 { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(ralr.NextLink))) -} - -// RoleAssignmentListResultPage contains a page of RoleAssignment values. -type RoleAssignmentListResultPage struct { - fn func(context.Context, RoleAssignmentListResult) (RoleAssignmentListResult, error) - ralr RoleAssignmentListResult -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *RoleAssignmentListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - next, err := page.fn(ctx, page.ralr) - if err != nil { - return err - } - page.ralr = next - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *RoleAssignmentListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page RoleAssignmentListResultPage) NotDone() bool { - return !page.ralr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page RoleAssignmentListResultPage) Response() RoleAssignmentListResult { - return page.ralr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page RoleAssignmentListResultPage) Values() []RoleAssignment { - if page.ralr.IsEmpty() { - return nil - } - return *page.ralr.Value -} - -// Creates a new instance of the RoleAssignmentListResultPage type. -func NewRoleAssignmentListResultPage(getNextPage func(context.Context, RoleAssignmentListResult) (RoleAssignmentListResult, error)) RoleAssignmentListResultPage { - return RoleAssignmentListResultPage{fn: getNextPage} -} - -// RoleAssignmentProperties role assignment properties. -type RoleAssignmentProperties struct { - // RoleDefinitionID - The role definition ID used in the role assignment. - RoleDefinitionID *string `json:"roleDefinitionId,omitempty"` - // PrincipalID - The principal ID assigned to the role. This maps to the ID inside the Active Directory. It can point to a user, service principal, or security group. - PrincipalID *string `json:"principalId,omitempty"` - // CanDelegate - The delegation flag used for creating a role assignment - CanDelegate *bool `json:"canDelegate,omitempty"` -} - -// RoleAssignmentPropertiesWithScope role assignment properties with scope. -type RoleAssignmentPropertiesWithScope struct { - // Scope - The role assignment scope. - Scope *string `json:"scope,omitempty"` - // RoleDefinitionID - The role definition ID. - RoleDefinitionID *string `json:"roleDefinitionId,omitempty"` - // PrincipalID - The principal ID. - PrincipalID *string `json:"principalId,omitempty"` - // CanDelegate - The Delegation flag for the role assignment - CanDelegate *bool `json:"canDelegate,omitempty"` -} - -// RoleDefinition role definition. -type RoleDefinition struct { - autorest.Response `json:"-"` - // ID - READ-ONLY; The role definition ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The role definition name. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The role definition type. - Type *string `json:"type,omitempty"` - // RoleDefinitionProperties - Role definition properties. - *RoleDefinitionProperties `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for RoleDefinition. -func (rd RoleDefinition) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if rd.RoleDefinitionProperties != nil { - objectMap["properties"] = rd.RoleDefinitionProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for RoleDefinition struct. -func (rd *RoleDefinition) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - rd.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - rd.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - rd.Type = &typeVar - } - case "properties": - if v != nil { - var roleDefinitionProperties RoleDefinitionProperties - err = json.Unmarshal(*v, &roleDefinitionProperties) - if err != nil { - return err - } - rd.RoleDefinitionProperties = &roleDefinitionProperties - } - } - } - - return nil -} - -// RoleDefinitionFilter role Definitions filter -type RoleDefinitionFilter struct { - // RoleName - Returns role definition with the specific name. - RoleName *string `json:"roleName,omitempty"` - // Type - Returns role definition with the specific type. - Type *string `json:"type,omitempty"` -} - -// RoleDefinitionListResult role definition list operation result. -type RoleDefinitionListResult struct { - autorest.Response `json:"-"` - // Value - Role definition list. - Value *[]RoleDefinition `json:"value,omitempty"` - // NextLink - The URL to use for getting the next set of results. - NextLink *string `json:"nextLink,omitempty"` -} - -// RoleDefinitionListResultIterator provides access to a complete listing of RoleDefinition values. -type RoleDefinitionListResultIterator struct { - i int - page RoleDefinitionListResultPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *RoleDefinitionListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleDefinitionListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *RoleDefinitionListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter RoleDefinitionListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter RoleDefinitionListResultIterator) Response() RoleDefinitionListResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter RoleDefinitionListResultIterator) Value() RoleDefinition { - if !iter.page.NotDone() { - return RoleDefinition{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the RoleDefinitionListResultIterator type. -func NewRoleDefinitionListResultIterator(page RoleDefinitionListResultPage) RoleDefinitionListResultIterator { - return RoleDefinitionListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (rdlr RoleDefinitionListResult) IsEmpty() bool { - return rdlr.Value == nil || len(*rdlr.Value) == 0 -} - -// roleDefinitionListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (rdlr RoleDefinitionListResult) roleDefinitionListResultPreparer(ctx context.Context) (*http.Request, error) { - if rdlr.NextLink == nil || len(to.String(rdlr.NextLink)) < 1 { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(rdlr.NextLink))) -} - -// RoleDefinitionListResultPage contains a page of RoleDefinition values. -type RoleDefinitionListResultPage struct { - fn func(context.Context, RoleDefinitionListResult) (RoleDefinitionListResult, error) - rdlr RoleDefinitionListResult -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *RoleDefinitionListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleDefinitionListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - next, err := page.fn(ctx, page.rdlr) - if err != nil { - return err - } - page.rdlr = next - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *RoleDefinitionListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page RoleDefinitionListResultPage) NotDone() bool { - return !page.rdlr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page RoleDefinitionListResultPage) Response() RoleDefinitionListResult { - return page.rdlr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page RoleDefinitionListResultPage) Values() []RoleDefinition { - if page.rdlr.IsEmpty() { - return nil - } - return *page.rdlr.Value -} - -// Creates a new instance of the RoleDefinitionListResultPage type. -func NewRoleDefinitionListResultPage(getNextPage func(context.Context, RoleDefinitionListResult) (RoleDefinitionListResult, error)) RoleDefinitionListResultPage { - return RoleDefinitionListResultPage{fn: getNextPage} -} - -// RoleDefinitionProperties role definition properties. -type RoleDefinitionProperties struct { - // RoleName - The role name. - RoleName *string `json:"roleName,omitempty"` - // Description - The role definition description. - Description *string `json:"description,omitempty"` - // RoleType - The role type. - RoleType *string `json:"type,omitempty"` - // Permissions - Role definition permissions. - Permissions *[]Permission `json:"permissions,omitempty"` - // AssignableScopes - Role definition assignable scopes. - AssignableScopes *[]string `json:"assignableScopes,omitempty"` -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/permissions.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/permissions.go deleted file mode 100644 index 4fcabb91de6d..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/permissions.go +++ /dev/null @@ -1,275 +0,0 @@ -package authorization - -// 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. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// PermissionsClient is the client for the Permissions methods of the Authorization service. -type PermissionsClient struct { - BaseClient -} - -// NewPermissionsClient creates an instance of the PermissionsClient client. -func NewPermissionsClient(subscriptionID string) PermissionsClient { - return NewPermissionsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewPermissionsClientWithBaseURI creates an instance of the PermissionsClient client. -func NewPermissionsClientWithBaseURI(baseURI string, subscriptionID string) PermissionsClient { - return PermissionsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// ListForResource gets all permissions the caller has for a resource. -// Parameters: -// resourceGroupName - the name of the resource group. -// resourceProviderNamespace - the namespace of the resource provider. -// parentResourcePath - the parent resource identity. -// resourceType - the resource type of the resource. -// resourceName - the name of the resource to get the permissions for. -func (client PermissionsClient) ListForResource(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string) (result PermissionGetResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/PermissionsClient.ListForResource") - defer func() { - sc := -1 - if result.pgr.Response.Response != nil { - sc = result.pgr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.fn = client.listForResourceNextResults - req, err := client.ListForResourcePreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.PermissionsClient", "ListForResource", nil, "Failure preparing request") - return - } - - resp, err := client.ListForResourceSender(req) - if err != nil { - result.pgr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "authorization.PermissionsClient", "ListForResource", resp, "Failure sending request") - return - } - - result.pgr, err = client.ListForResourceResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.PermissionsClient", "ListForResource", resp, "Failure responding to request") - } - - return -} - -// ListForResourcePreparer prepares the ListForResource request. -func (client PermissionsClient) ListForResourcePreparer(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "parentResourcePath": parentResourcePath, - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "resourceName": autorest.Encode("path", resourceName), - "resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace), - "resourceType": resourceType, - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2018-01-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/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/permissions", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListForResourceSender sends the ListForResource request. The method will close the -// http.Response Body if it receives an error. -func (client PermissionsClient) ListForResourceSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// ListForResourceResponder handles the response to the ListForResource request. The method always -// closes the http.Response Body. -func (client PermissionsClient) ListForResourceResponder(resp *http.Response) (result PermissionGetResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listForResourceNextResults retrieves the next set of results, if any. -func (client PermissionsClient) listForResourceNextResults(ctx context.Context, lastResults PermissionGetResult) (result PermissionGetResult, err error) { - req, err := lastResults.permissionGetResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "authorization.PermissionsClient", "listForResourceNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListForResourceSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "authorization.PermissionsClient", "listForResourceNextResults", resp, "Failure sending next results request") - } - result, err = client.ListForResourceResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.PermissionsClient", "listForResourceNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListForResourceComplete enumerates all values, automatically crossing page boundaries as required. -func (client PermissionsClient) ListForResourceComplete(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string) (result PermissionGetResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/PermissionsClient.ListForResource") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.ListForResource(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName) - return -} - -// ListForResourceGroup gets all permissions the caller has for a resource group. -// Parameters: -// resourceGroupName - the name of the resource group. -func (client PermissionsClient) ListForResourceGroup(ctx context.Context, resourceGroupName string) (result PermissionGetResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/PermissionsClient.ListForResourceGroup") - defer func() { - sc := -1 - if result.pgr.Response.Response != nil { - sc = result.pgr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.fn = client.listForResourceGroupNextResults - req, err := client.ListForResourceGroupPreparer(ctx, resourceGroupName) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.PermissionsClient", "ListForResourceGroup", nil, "Failure preparing request") - return - } - - resp, err := client.ListForResourceGroupSender(req) - if err != nil { - result.pgr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "authorization.PermissionsClient", "ListForResourceGroup", resp, "Failure sending request") - return - } - - result.pgr, err = client.ListForResourceGroupResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.PermissionsClient", "ListForResourceGroup", resp, "Failure responding to request") - } - - return -} - -// ListForResourceGroupPreparer prepares the ListForResourceGroup request. -func (client PermissionsClient) ListForResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2018-01-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.Authorization/permissions", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListForResourceGroupSender sends the ListForResourceGroup request. The method will close the -// http.Response Body if it receives an error. -func (client PermissionsClient) ListForResourceGroupSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// ListForResourceGroupResponder handles the response to the ListForResourceGroup request. The method always -// closes the http.Response Body. -func (client PermissionsClient) ListForResourceGroupResponder(resp *http.Response) (result PermissionGetResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listForResourceGroupNextResults retrieves the next set of results, if any. -func (client PermissionsClient) listForResourceGroupNextResults(ctx context.Context, lastResults PermissionGetResult) (result PermissionGetResult, err error) { - req, err := lastResults.permissionGetResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "authorization.PermissionsClient", "listForResourceGroupNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListForResourceGroupSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "authorization.PermissionsClient", "listForResourceGroupNextResults", resp, "Failure sending next results request") - } - result, err = client.ListForResourceGroupResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.PermissionsClient", "listForResourceGroupNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListForResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. -func (client PermissionsClient) ListForResourceGroupComplete(ctx context.Context, resourceGroupName string) (result PermissionGetResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/PermissionsClient.ListForResourceGroup") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.ListForResourceGroup(ctx, resourceGroupName) - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/provideroperationsmetadata.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/provideroperationsmetadata.go deleted file mode 100644 index c1555423f6fb..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/provideroperationsmetadata.go +++ /dev/null @@ -1,235 +0,0 @@ -package authorization - -// 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. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// ProviderOperationsMetadataClient is the client for the ProviderOperationsMetadata methods of the Authorization -// service. -type ProviderOperationsMetadataClient struct { - BaseClient -} - -// NewProviderOperationsMetadataClient creates an instance of the ProviderOperationsMetadataClient client. -func NewProviderOperationsMetadataClient(subscriptionID string) ProviderOperationsMetadataClient { - return NewProviderOperationsMetadataClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewProviderOperationsMetadataClientWithBaseURI creates an instance of the ProviderOperationsMetadataClient client. -func NewProviderOperationsMetadataClientWithBaseURI(baseURI string, subscriptionID string) ProviderOperationsMetadataClient { - return ProviderOperationsMetadataClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// Get gets provider operations metadata for the specified resource provider. -// Parameters: -// resourceProviderNamespace - the namespace of the resource provider. -// expand - specifies whether to expand the values. -func (client ProviderOperationsMetadataClient) Get(ctx context.Context, resourceProviderNamespace string, expand string) (result ProviderOperationsMetadata, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ProviderOperationsMetadataClient.Get") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.GetPreparer(ctx, resourceProviderNamespace, expand) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.ProviderOperationsMetadataClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "authorization.ProviderOperationsMetadataClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.ProviderOperationsMetadataClient", "Get", resp, "Failure responding to request") - } - - return -} - -// GetPreparer prepares the Get request. -func (client ProviderOperationsMetadataClient) GetPreparer(ctx context.Context, resourceProviderNamespace string, expand string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace), - } - - const APIVersion = "2018-01-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if len(expand) > 0 { - queryParameters["$expand"] = autorest.Encode("query", expand) - } else { - queryParameters["$expand"] = autorest.Encode("query", "resourceTypes") - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/providers/Microsoft.Authorization/providerOperations/{resourceProviderNamespace}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client ProviderOperationsMetadataClient) GetSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client ProviderOperationsMetadataClient) GetResponder(resp *http.Response) (result ProviderOperationsMetadata, 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 gets provider operations metadata for all resource providers. -// Parameters: -// expand - specifies whether to expand the values. -func (client ProviderOperationsMetadataClient) List(ctx context.Context, expand string) (result ProviderOperationsMetadataListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ProviderOperationsMetadataClient.List") - defer func() { - sc := -1 - if result.pomlr.Response.Response != nil { - sc = result.pomlr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.fn = client.listNextResults - req, err := client.ListPreparer(ctx, expand) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.ProviderOperationsMetadataClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.pomlr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "authorization.ProviderOperationsMetadataClient", "List", resp, "Failure sending request") - return - } - - result.pomlr, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.ProviderOperationsMetadataClient", "List", resp, "Failure responding to request") - } - - return -} - -// ListPreparer prepares the List request. -func (client ProviderOperationsMetadataClient) ListPreparer(ctx context.Context, expand string) (*http.Request, error) { - const APIVersion = "2018-01-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if len(expand) > 0 { - queryParameters["$expand"] = autorest.Encode("query", expand) - } else { - queryParameters["$expand"] = autorest.Encode("query", "resourceTypes") - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/providers/Microsoft.Authorization/providerOperations"), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client ProviderOperationsMetadataClient) ListSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client ProviderOperationsMetadataClient) ListResponder(resp *http.Response) (result ProviderOperationsMetadataListResult, 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 ProviderOperationsMetadataClient) listNextResults(ctx context.Context, lastResults ProviderOperationsMetadataListResult) (result ProviderOperationsMetadataListResult, err error) { - req, err := lastResults.providerOperationsMetadataListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "authorization.ProviderOperationsMetadataClient", "listNextResults", 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, "authorization.ProviderOperationsMetadataClient", "listNextResults", resp, "Failure sending next results request") - } - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.ProviderOperationsMetadataClient", "listNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListComplete enumerates all values, automatically crossing page boundaries as required. -func (client ProviderOperationsMetadataClient) ListComplete(ctx context.Context, expand string) (result ProviderOperationsMetadataListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ProviderOperationsMetadataClient.List") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.List(ctx, expand) - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/roleassignments.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/roleassignments.go deleted file mode 100644 index 93f32d4cf6dd..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/roleassignments.go +++ /dev/null @@ -1,1001 +0,0 @@ -package authorization - -// 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. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// RoleAssignmentsClient is the client for the RoleAssignments methods of the Authorization service. -type RoleAssignmentsClient struct { - BaseClient -} - -// NewRoleAssignmentsClient creates an instance of the RoleAssignmentsClient client. -func NewRoleAssignmentsClient(subscriptionID string) RoleAssignmentsClient { - return NewRoleAssignmentsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewRoleAssignmentsClientWithBaseURI creates an instance of the RoleAssignmentsClient client. -func NewRoleAssignmentsClientWithBaseURI(baseURI string, subscriptionID string) RoleAssignmentsClient { - return RoleAssignmentsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// Create creates a role assignment. -// Parameters: -// scope - the scope of the role assignment to create. The scope can be any REST resource instance. For -// example, use '/subscriptions/{subscription-id}/' for a subscription, -// '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and -// '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' -// for a resource. -// roleAssignmentName - the name of the role assignment to create. It can be any valid GUID. -// parameters - parameters for the role assignment. -func (client RoleAssignmentsClient) Create(ctx context.Context, scope string, roleAssignmentName string, parameters RoleAssignmentCreateParameters) (result RoleAssignment, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.Create") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: parameters, - Constraints: []validation.Constraint{{Target: "parameters.RoleAssignmentProperties", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "parameters.RoleAssignmentProperties.RoleDefinitionID", Name: validation.Null, Rule: true, Chain: nil}, - {Target: "parameters.RoleAssignmentProperties.PrincipalID", Name: validation.Null, Rule: true, Chain: nil}, - }}}}}); err != nil { - return result, validation.NewError("authorization.RoleAssignmentsClient", "Create", err.Error()) - } - - req, err := client.CreatePreparer(ctx, scope, roleAssignmentName, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "Create", nil, "Failure preparing request") - return - } - - resp, err := client.CreateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "Create", resp, "Failure sending request") - return - } - - result, err = client.CreateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "Create", resp, "Failure responding to request") - } - - return -} - -// CreatePreparer prepares the Create request. -func (client RoleAssignmentsClient) CreatePreparer(ctx context.Context, scope string, roleAssignmentName string, parameters RoleAssignmentCreateParameters) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "roleAssignmentName": autorest.Encode("path", roleAssignmentName), - "scope": scope, - } - - const APIVersion = "2018-01-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateSender sends the Create request. The method will close the -// http.Response Body if it receives an error. -func (client RoleAssignmentsClient) CreateSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// CreateResponder handles the response to the Create request. The method always -// closes the http.Response Body. -func (client RoleAssignmentsClient) CreateResponder(resp *http.Response) (result RoleAssignment, 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 -} - -// CreateByID creates a role assignment by ID. -// Parameters: -// roleID - the ID of the role assignment to create. -// parameters - parameters for the role assignment. -func (client RoleAssignmentsClient) CreateByID(ctx context.Context, roleID string, parameters RoleAssignmentCreateParameters) (result RoleAssignment, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.CreateByID") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: parameters, - Constraints: []validation.Constraint{{Target: "parameters.RoleAssignmentProperties", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "parameters.RoleAssignmentProperties.RoleDefinitionID", Name: validation.Null, Rule: true, Chain: nil}, - {Target: "parameters.RoleAssignmentProperties.PrincipalID", Name: validation.Null, Rule: true, Chain: nil}, - }}}}}); err != nil { - return result, validation.NewError("authorization.RoleAssignmentsClient", "CreateByID", err.Error()) - } - - req, err := client.CreateByIDPreparer(ctx, roleID, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "CreateByID", nil, "Failure preparing request") - return - } - - resp, err := client.CreateByIDSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "CreateByID", resp, "Failure sending request") - return - } - - result, err = client.CreateByIDResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "CreateByID", resp, "Failure responding to request") - } - - return -} - -// CreateByIDPreparer prepares the CreateByID request. -func (client RoleAssignmentsClient) CreateByIDPreparer(ctx context.Context, roleID string, parameters RoleAssignmentCreateParameters) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "roleId": roleID, - } - - const APIVersion = "2018-01-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/{roleId}", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateByIDSender sends the CreateByID request. The method will close the -// http.Response Body if it receives an error. -func (client RoleAssignmentsClient) CreateByIDSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// CreateByIDResponder handles the response to the CreateByID request. The method always -// closes the http.Response Body. -func (client RoleAssignmentsClient) CreateByIDResponder(resp *http.Response) (result RoleAssignment, 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 deletes a role assignment. -// Parameters: -// scope - the scope of the role assignment to delete. -// roleAssignmentName - the name of the role assignment to delete. -func (client RoleAssignmentsClient) Delete(ctx context.Context, scope string, roleAssignmentName string) (result RoleAssignment, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.Delete") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.DeletePreparer(ctx, scope, roleAssignmentName) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "Delete", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "Delete", resp, "Failure sending request") - return - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "Delete", resp, "Failure responding to request") - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client RoleAssignmentsClient) DeletePreparer(ctx context.Context, scope string, roleAssignmentName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "roleAssignmentName": autorest.Encode("path", roleAssignmentName), - "scope": scope, - } - - const APIVersion = "2018-01-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSender sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (client RoleAssignmentsClient) DeleteSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client RoleAssignmentsClient) DeleteResponder(resp *http.Response) (result RoleAssignment, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// DeleteByID deletes a role assignment. -// Parameters: -// roleID - the ID of the role assignment to delete. -func (client RoleAssignmentsClient) DeleteByID(ctx context.Context, roleID string) (result RoleAssignment, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.DeleteByID") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.DeleteByIDPreparer(ctx, roleID) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "DeleteByID", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteByIDSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "DeleteByID", resp, "Failure sending request") - return - } - - result, err = client.DeleteByIDResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "DeleteByID", resp, "Failure responding to request") - } - - return -} - -// DeleteByIDPreparer prepares the DeleteByID request. -func (client RoleAssignmentsClient) DeleteByIDPreparer(ctx context.Context, roleID string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "roleId": roleID, - } - - const APIVersion = "2018-01-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/{roleId}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteByIDSender sends the DeleteByID request. The method will close the -// http.Response Body if it receives an error. -func (client RoleAssignmentsClient) DeleteByIDSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// DeleteByIDResponder handles the response to the DeleteByID request. The method always -// closes the http.Response Body. -func (client RoleAssignmentsClient) DeleteByIDResponder(resp *http.Response) (result RoleAssignment, 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 get the specified role assignment. -// Parameters: -// scope - the scope of the role assignment. -// roleAssignmentName - the name of the role assignment to get. -func (client RoleAssignmentsClient) Get(ctx context.Context, scope string, roleAssignmentName string) (result RoleAssignment, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.Get") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.GetPreparer(ctx, scope, roleAssignmentName) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "Get", resp, "Failure responding to request") - } - - return -} - -// GetPreparer prepares the Get request. -func (client RoleAssignmentsClient) GetPreparer(ctx context.Context, scope string, roleAssignmentName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "roleAssignmentName": autorest.Encode("path", roleAssignmentName), - "scope": scope, - } - - const APIVersion = "2018-01-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client RoleAssignmentsClient) GetSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client RoleAssignmentsClient) GetResponder(resp *http.Response) (result RoleAssignment, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// GetByID gets a role assignment by ID. -// Parameters: -// roleID - the ID of the role assignment to get. -func (client RoleAssignmentsClient) GetByID(ctx context.Context, roleID string) (result RoleAssignment, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.GetByID") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.GetByIDPreparer(ctx, roleID) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "GetByID", nil, "Failure preparing request") - return - } - - resp, err := client.GetByIDSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "GetByID", resp, "Failure sending request") - return - } - - result, err = client.GetByIDResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "GetByID", resp, "Failure responding to request") - } - - return -} - -// GetByIDPreparer prepares the GetByID request. -func (client RoleAssignmentsClient) GetByIDPreparer(ctx context.Context, roleID string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "roleId": roleID, - } - - const APIVersion = "2018-01-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/{roleId}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetByIDSender sends the GetByID request. The method will close the -// http.Response Body if it receives an error. -func (client RoleAssignmentsClient) GetByIDSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// GetByIDResponder handles the response to the GetByID request. The method always -// closes the http.Response Body. -func (client RoleAssignmentsClient) GetByIDResponder(resp *http.Response) (result RoleAssignment, 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 gets all role assignments for the subscription. -// Parameters: -// filter - the filter to apply on the operation. Use $filter=atScope() to return all role assignments at or -// above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope -// for the specified principal. -func (client RoleAssignmentsClient) List(ctx context.Context, filter string) (result RoleAssignmentListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.List") - defer func() { - sc := -1 - if result.ralr.Response.Response != nil { - sc = result.ralr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.fn = client.listNextResults - req, err := client.ListPreparer(ctx, filter) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.ralr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "List", resp, "Failure sending request") - return - } - - result.ralr, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "List", resp, "Failure responding to request") - } - - return -} - -// ListPreparer prepares the List request. -func (client RoleAssignmentsClient) ListPreparer(ctx context.Context, filter string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2018-01-01-preview" - 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}/providers/Microsoft.Authorization/roleAssignments", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client RoleAssignmentsClient) ListSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client RoleAssignmentsClient) ListResponder(resp *http.Response) (result RoleAssignmentListResult, 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 RoleAssignmentsClient) listNextResults(ctx context.Context, lastResults RoleAssignmentListResult) (result RoleAssignmentListResult, err error) { - req, err := lastResults.roleAssignmentListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "listNextResults", 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, "authorization.RoleAssignmentsClient", "listNextResults", resp, "Failure sending next results request") - } - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "listNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListComplete enumerates all values, automatically crossing page boundaries as required. -func (client RoleAssignmentsClient) ListComplete(ctx context.Context, filter string) (result RoleAssignmentListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.List") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.List(ctx, filter) - return -} - -// ListForResource gets role assignments for a resource. -// Parameters: -// resourceGroupName - the name of the resource group. -// resourceProviderNamespace - the namespace of the resource provider. -// parentResourcePath - the parent resource identity. -// resourceType - the resource type of the resource. -// resourceName - the name of the resource to get role assignments for. -// filter - the filter to apply on the operation. Use $filter=atScope() to return all role assignments at or -// above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope -// for the specified principal. -func (client RoleAssignmentsClient) ListForResource(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, filter string) (result RoleAssignmentListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.ListForResource") - defer func() { - sc := -1 - if result.ralr.Response.Response != nil { - sc = result.ralr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.fn = client.listForResourceNextResults - req, err := client.ListForResourcePreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, filter) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "ListForResource", nil, "Failure preparing request") - return - } - - resp, err := client.ListForResourceSender(req) - if err != nil { - result.ralr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "ListForResource", resp, "Failure sending request") - return - } - - result.ralr, err = client.ListForResourceResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "ListForResource", resp, "Failure responding to request") - } - - return -} - -// ListForResourcePreparer prepares the ListForResource request. -func (client RoleAssignmentsClient) ListForResourcePreparer(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, filter string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "parentResourcePath": parentResourcePath, - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "resourceName": autorest.Encode("path", resourceName), - "resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace), - "resourceType": resourceType, - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2018-01-01-preview" - 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/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListForResourceSender sends the ListForResource request. The method will close the -// http.Response Body if it receives an error. -func (client RoleAssignmentsClient) ListForResourceSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// ListForResourceResponder handles the response to the ListForResource request. The method always -// closes the http.Response Body. -func (client RoleAssignmentsClient) ListForResourceResponder(resp *http.Response) (result RoleAssignmentListResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listForResourceNextResults retrieves the next set of results, if any. -func (client RoleAssignmentsClient) listForResourceNextResults(ctx context.Context, lastResults RoleAssignmentListResult) (result RoleAssignmentListResult, err error) { - req, err := lastResults.roleAssignmentListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "listForResourceNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListForResourceSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "listForResourceNextResults", resp, "Failure sending next results request") - } - result, err = client.ListForResourceResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "listForResourceNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListForResourceComplete enumerates all values, automatically crossing page boundaries as required. -func (client RoleAssignmentsClient) ListForResourceComplete(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, filter string) (result RoleAssignmentListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.ListForResource") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.ListForResource(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, filter) - return -} - -// ListForResourceGroup gets role assignments for a resource group. -// Parameters: -// resourceGroupName - the name of the resource group. -// filter - the filter to apply on the operation. Use $filter=atScope() to return all role assignments at or -// above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope -// for the specified principal. -func (client RoleAssignmentsClient) ListForResourceGroup(ctx context.Context, resourceGroupName string, filter string) (result RoleAssignmentListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.ListForResourceGroup") - defer func() { - sc := -1 - if result.ralr.Response.Response != nil { - sc = result.ralr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.fn = client.listForResourceGroupNextResults - req, err := client.ListForResourceGroupPreparer(ctx, resourceGroupName, filter) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "ListForResourceGroup", nil, "Failure preparing request") - return - } - - resp, err := client.ListForResourceGroupSender(req) - if err != nil { - result.ralr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "ListForResourceGroup", resp, "Failure sending request") - return - } - - result.ralr, err = client.ListForResourceGroupResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "ListForResourceGroup", resp, "Failure responding to request") - } - - return -} - -// ListForResourceGroupPreparer prepares the ListForResourceGroup request. -func (client RoleAssignmentsClient) ListForResourceGroupPreparer(ctx context.Context, resourceGroupName string, filter string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2018-01-01-preview" - 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.Authorization/roleAssignments", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListForResourceGroupSender sends the ListForResourceGroup request. The method will close the -// http.Response Body if it receives an error. -func (client RoleAssignmentsClient) ListForResourceGroupSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// ListForResourceGroupResponder handles the response to the ListForResourceGroup request. The method always -// closes the http.Response Body. -func (client RoleAssignmentsClient) ListForResourceGroupResponder(resp *http.Response) (result RoleAssignmentListResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listForResourceGroupNextResults retrieves the next set of results, if any. -func (client RoleAssignmentsClient) listForResourceGroupNextResults(ctx context.Context, lastResults RoleAssignmentListResult) (result RoleAssignmentListResult, err error) { - req, err := lastResults.roleAssignmentListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "listForResourceGroupNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListForResourceGroupSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "listForResourceGroupNextResults", resp, "Failure sending next results request") - } - result, err = client.ListForResourceGroupResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "listForResourceGroupNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListForResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. -func (client RoleAssignmentsClient) ListForResourceGroupComplete(ctx context.Context, resourceGroupName string, filter string) (result RoleAssignmentListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.ListForResourceGroup") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.ListForResourceGroup(ctx, resourceGroupName, filter) - return -} - -// ListForScope gets role assignments for a scope. -// Parameters: -// scope - the scope of the role assignments. -// filter - the filter to apply on the operation. Use $filter=atScope() to return all role assignments at or -// above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope -// for the specified principal. -func (client RoleAssignmentsClient) ListForScope(ctx context.Context, scope string, filter string) (result RoleAssignmentListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.ListForScope") - defer func() { - sc := -1 - if result.ralr.Response.Response != nil { - sc = result.ralr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.fn = client.listForScopeNextResults - req, err := client.ListForScopePreparer(ctx, scope, filter) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "ListForScope", nil, "Failure preparing request") - return - } - - resp, err := client.ListForScopeSender(req) - if err != nil { - result.ralr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "ListForScope", resp, "Failure sending request") - return - } - - result.ralr, err = client.ListForScopeResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "ListForScope", resp, "Failure responding to request") - } - - return -} - -// ListForScopePreparer prepares the ListForScope request. -func (client RoleAssignmentsClient) ListForScopePreparer(ctx context.Context, scope string, filter string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "scope": scope, - } - - const APIVersion = "2018-01-01-preview" - 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("/{scope}/providers/Microsoft.Authorization/roleAssignments", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListForScopeSender sends the ListForScope request. The method will close the -// http.Response Body if it receives an error. -func (client RoleAssignmentsClient) ListForScopeSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// ListForScopeResponder handles the response to the ListForScope request. The method always -// closes the http.Response Body. -func (client RoleAssignmentsClient) ListForScopeResponder(resp *http.Response) (result RoleAssignmentListResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listForScopeNextResults retrieves the next set of results, if any. -func (client RoleAssignmentsClient) listForScopeNextResults(ctx context.Context, lastResults RoleAssignmentListResult) (result RoleAssignmentListResult, err error) { - req, err := lastResults.roleAssignmentListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "listForScopeNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListForScopeSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "listForScopeNextResults", resp, "Failure sending next results request") - } - result, err = client.ListForScopeResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "listForScopeNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListForScopeComplete enumerates all values, automatically crossing page boundaries as required. -func (client RoleAssignmentsClient) ListForScopeComplete(ctx context.Context, scope string, filter string) (result RoleAssignmentListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.ListForScope") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.ListForScope(ctx, scope, filter) - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/roledefinitions.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/roledefinitions.go deleted file mode 100644 index 8156456638c3..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/roledefinitions.go +++ /dev/null @@ -1,469 +0,0 @@ -package authorization - -// 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. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// RoleDefinitionsClient is the client for the RoleDefinitions methods of the Authorization service. -type RoleDefinitionsClient struct { - BaseClient -} - -// NewRoleDefinitionsClient creates an instance of the RoleDefinitionsClient client. -func NewRoleDefinitionsClient(subscriptionID string) RoleDefinitionsClient { - return NewRoleDefinitionsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewRoleDefinitionsClientWithBaseURI creates an instance of the RoleDefinitionsClient client. -func NewRoleDefinitionsClientWithBaseURI(baseURI string, subscriptionID string) RoleDefinitionsClient { - return RoleDefinitionsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// CreateOrUpdate creates or updates a role definition. -// Parameters: -// scope - the scope of the role definition. -// roleDefinitionID - the ID of the role definition. -// roleDefinition - the values for the role definition. -func (client RoleDefinitionsClient) CreateOrUpdate(ctx context.Context, scope string, roleDefinitionID string, roleDefinition RoleDefinition) (result RoleDefinition, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleDefinitionsClient.CreateOrUpdate") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.CreateOrUpdatePreparer(ctx, scope, roleDefinitionID, roleDefinition) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "CreateOrUpdate", resp, "Failure sending request") - return - } - - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return -} - -// CreateOrUpdatePreparer prepares the CreateOrUpdate request. -func (client RoleDefinitionsClient) CreateOrUpdatePreparer(ctx context.Context, scope string, roleDefinitionID string, roleDefinition RoleDefinition) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "roleDefinitionId": autorest.Encode("path", roleDefinitionID), - "scope": scope, - } - - const APIVersion = "2018-01-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - roleDefinition.ID = nil - roleDefinition.Name = nil - roleDefinition.Type = nil - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}", pathParameters), - autorest.WithJSON(roleDefinition), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (client RoleDefinitionsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (client RoleDefinitionsClient) CreateOrUpdateResponder(resp *http.Response) (result RoleDefinition, 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 deletes a role definition. -// Parameters: -// scope - the scope of the role definition. -// roleDefinitionID - the ID of the role definition to delete. -func (client RoleDefinitionsClient) Delete(ctx context.Context, scope string, roleDefinitionID string) (result RoleDefinition, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleDefinitionsClient.Delete") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.DeletePreparer(ctx, scope, roleDefinitionID) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "Delete", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "Delete", resp, "Failure sending request") - return - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "Delete", resp, "Failure responding to request") - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client RoleDefinitionsClient) DeletePreparer(ctx context.Context, scope string, roleDefinitionID string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "roleDefinitionId": autorest.Encode("path", roleDefinitionID), - "scope": scope, - } - - const APIVersion = "2018-01-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSender sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (client RoleDefinitionsClient) DeleteSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client RoleDefinitionsClient) DeleteResponder(resp *http.Response) (result RoleDefinition, 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 get role definition by name (GUID). -// Parameters: -// scope - the scope of the role definition. -// roleDefinitionID - the ID of the role definition. -func (client RoleDefinitionsClient) Get(ctx context.Context, scope string, roleDefinitionID string) (result RoleDefinition, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleDefinitionsClient.Get") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.GetPreparer(ctx, scope, roleDefinitionID) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "Get", resp, "Failure responding to request") - } - - return -} - -// GetPreparer prepares the Get request. -func (client RoleDefinitionsClient) GetPreparer(ctx context.Context, scope string, roleDefinitionID string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "roleDefinitionId": autorest.Encode("path", roleDefinitionID), - "scope": scope, - } - - const APIVersion = "2018-01-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client RoleDefinitionsClient) GetSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client RoleDefinitionsClient) GetResponder(resp *http.Response) (result RoleDefinition, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// GetByID gets a role definition by ID. -// Parameters: -// roleID - the fully qualified role definition ID. Use the format, -// /subscriptions/{guid}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId} for subscription -// level role definitions, or /providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId} for tenant -// level role definitions. -func (client RoleDefinitionsClient) GetByID(ctx context.Context, roleID string) (result RoleDefinition, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleDefinitionsClient.GetByID") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.GetByIDPreparer(ctx, roleID) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "GetByID", nil, "Failure preparing request") - return - } - - resp, err := client.GetByIDSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "GetByID", resp, "Failure sending request") - return - } - - result, err = client.GetByIDResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "GetByID", resp, "Failure responding to request") - } - - return -} - -// GetByIDPreparer prepares the GetByID request. -func (client RoleDefinitionsClient) GetByIDPreparer(ctx context.Context, roleID string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "roleId": roleID, - } - - const APIVersion = "2018-01-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/{roleId}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetByIDSender sends the GetByID request. The method will close the -// http.Response Body if it receives an error. -func (client RoleDefinitionsClient) GetByIDSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// GetByIDResponder handles the response to the GetByID request. The method always -// closes the http.Response Body. -func (client RoleDefinitionsClient) GetByIDResponder(resp *http.Response) (result RoleDefinition, 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 all role definitions that are applicable at scope and above. -// Parameters: -// scope - the scope of the role definition. -// filter - the filter to apply on the operation. Use atScopeAndBelow filter to search below the given scope as -// well. -func (client RoleDefinitionsClient) List(ctx context.Context, scope string, filter string) (result RoleDefinitionListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleDefinitionsClient.List") - defer func() { - sc := -1 - if result.rdlr.Response.Response != nil { - sc = result.rdlr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.fn = client.listNextResults - req, err := client.ListPreparer(ctx, scope, filter) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.rdlr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "List", resp, "Failure sending request") - return - } - - result.rdlr, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "List", resp, "Failure responding to request") - } - - return -} - -// ListPreparer prepares the List request. -func (client RoleDefinitionsClient) ListPreparer(ctx context.Context, scope string, filter string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "scope": scope, - } - - const APIVersion = "2018-01-01-preview" - 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("/{scope}/providers/Microsoft.Authorization/roleDefinitions", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client RoleDefinitionsClient) ListSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client RoleDefinitionsClient) ListResponder(resp *http.Response) (result RoleDefinitionListResult, 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 RoleDefinitionsClient) listNextResults(ctx context.Context, lastResults RoleDefinitionListResult) (result RoleDefinitionListResult, err error) { - req, err := lastResults.roleDefinitionListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "listNextResults", 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, "authorization.RoleDefinitionsClient", "listNextResults", resp, "Failure sending next results request") - } - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "listNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListComplete enumerates all values, automatically crossing page boundaries as required. -func (client RoleDefinitionsClient) ListComplete(ctx context.Context, scope string, filter string) (result RoleDefinitionListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleDefinitionsClient.List") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.List(ctx, scope, filter) - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/version.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/version.go deleted file mode 100644 index 2833e0b21000..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/version.go +++ /dev/null @@ -1,30 +0,0 @@ -package authorization - -import "github.com/Azure/azure-sdk-for-go/version" - -// 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. -// 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/" + version.Number + " authorization/2018-01-01-preview" -} - -// Version returns the semantic version (see http://semver.org) of the client. -func Version() string { - return version.Number -} diff --git a/vendor/modules.txt b/vendor/modules.txt index d83dd51a0a3d..750902fe71a3 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -73,7 +73,6 @@ github.com/Azure/azure-sdk-for-go/services/streamanalytics/mgmt/2016-03-01/strea github.com/Azure/azure-sdk-for-go/services/trafficmanager/mgmt/2018-04-01/trafficmanager github.com/Azure/azure-sdk-for-go/services/web/mgmt/2018-02-01/web github.com/Azure/azure-sdk-for-go/storage -github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-06-01/subscriptions github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-02-01/resources github.com/Azure/azure-sdk-for-go/version diff --git a/website/azurerm.erb b/website/azurerm.erb index 885644d65f76..3f8de1387da9 100644 --- a/website/azurerm.erb +++ b/website/azurerm.erb @@ -711,6 +711,10 @@ azurerm_container_registry +
  • + azurerm_container_registry_webhook +
  • +
  • azurerm_container_service
  • diff --git a/website/docs/r/container_registry_webhook.html.markdown b/website/docs/r/container_registry_webhook.html.markdown new file mode 100644 index 000000000000..21de13634afe --- /dev/null +++ b/website/docs/r/container_registry_webhook.html.markdown @@ -0,0 +1,79 @@ +--- +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_container_registry_webhook" +sidebar_current: "docs-azurerm-resource-container-registry-webhook" +description: |- + Manages an Azure Container Registry Webhook. + +--- + +# azurerm_container_registry_webhook + +Manages an Azure Container Registry Webhook. + +## Example Usage + +```hcl +resource "azurerm_resource_group" "rg" { + name = "resourceGroup1" + location = "West US" +} + +resource "azurerm_container_registry" "acr" { + name = "containerRegistry1" + resource_group_name = "${azurerm_resource_group.rg.name}" + location = "${azurerm_resource_group.rg.location}" + sku = "Standard" + admin_enabled = false +} + +resource "azurerm_container_registry_webhook" "webhook" { + name = "mywebhook" + resource_group_name = "${azurerm_resource_group.rg.name}" + registry_name = "${azurerm_container_registry.acr.name}" + location = "${azurerm_resource_group.rg.location}" + + service_uri = "https://mywebhookreceiver.example/mytag" + status = "enabled" + scope = "mytag:*" + actions = ["push"] + custom_headers = { "Content-Type" = "application/json" } +} +``` + +## Argument Reference + +The following arguments are supported: + +* `name` - (Required) Specifies the name of the Container Registry Webhook. Changing this forces a new resource to be created. + +* `resource_group_name` - (Required) The name of the resource group in which to create the Container Registry Webhook. Changing this forces a new resource to be created. + +* `registry_name` - (Required) The Name of Container registry this Webhook belongs to. Changing this forces a new resource to be created. + +* `location` - (Required) Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created. + +* `service_uri` - (Required) Specifies the service URI for the Webhook to post notifications. + +* `actions` - (Required) A list of actions that trigger the Webhook to post notifications. At least one action needs to be specified. Valid values are: `push`, `delete`, `quarantine`, `chart_push`, `chart_delete` + +* `status` - (Optional) Specifies if this Webhook triggers notifications or not. Valid values: `enabled` and `disabled`. Default is `enabled`. + +* `scope` - (Optional) Specifies the scope of repositories that can trigger an event. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' only. 'foo' is equivalent to 'foo:latest'. Empty means all events. + +* `custom_headers` - (Optional) Custom headers that will be added to the webhook notifications request. + +--- +## Attributes Reference + +The following attributes are exported: + +* `id` - The Container Registry Webhook ID. + +## Import + +Container Registry Webhooks can be imported using the `resource id`, e.g. + +```shell +terraform import azurerm_container_registry_webhook.test /subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/mygroup1/providers/Microsoft.ContainerRegistry/registries/myregistry1/webhooks/mywebhook1 +```