diff --git a/azurerm/internal/services/eventgrid/client/client.go b/azurerm/internal/services/eventgrid/client/client.go index e32a89cac3b4..562628695865 100644 --- a/azurerm/internal/services/eventgrid/client/client.go +++ b/azurerm/internal/services/eventgrid/client/client.go @@ -1,12 +1,13 @@ package client import ( - "github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2018-09-15-preview/eventgrid" + "github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2020-01-01-preview/eventgrid" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/common" ) type Client struct { DomainsClient *eventgrid.DomainsClient + DomainTopicsClient *eventgrid.DomainTopicsClient EventSubscriptionsClient *eventgrid.EventSubscriptionsClient TopicsClient *eventgrid.TopicsClient } @@ -15,6 +16,9 @@ func NewClient(o *common.ClientOptions) *Client { DomainsClient := eventgrid.NewDomainsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) o.ConfigureClient(&DomainsClient.Client, o.ResourceManagerAuthorizer) + DomainTopicsClient := eventgrid.NewDomainTopicsClient(o.SubscriptionId) + o.ConfigureClient(&DomainTopicsClient.Client, o.ResourceManagerAuthorizer) + EventSubscriptionsClient := eventgrid.NewEventSubscriptionsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) o.ConfigureClient(&EventSubscriptionsClient.Client, o.ResourceManagerAuthorizer) @@ -23,6 +27,7 @@ func NewClient(o *common.ClientOptions) *Client { return &Client{ DomainsClient: &DomainsClient, + DomainTopicsClient: &DomainTopicsClient, EventSubscriptionsClient: &EventSubscriptionsClient, TopicsClient: &TopicsClient, } diff --git a/azurerm/internal/services/eventgrid/registration.go b/azurerm/internal/services/eventgrid/registration.go index f1b2feda1dc8..7ea4410b7d24 100644 --- a/azurerm/internal/services/eventgrid/registration.go +++ b/azurerm/internal/services/eventgrid/registration.go @@ -29,6 +29,7 @@ func (r Registration) SupportedDataSources() map[string]*schema.Resource { func (r Registration) SupportedResources() map[string]*schema.Resource { return map[string]*schema.Resource{ "azurerm_eventgrid_domain": resourceArmEventGridDomain(), + "azurerm_eventgrid_domain_topic": resourceArmEventGridDomainTopic(), "azurerm_eventgrid_event_subscription": resourceArmEventGridEventSubscription(), "azurerm_eventgrid_topic": resourceArmEventGridTopic(), } diff --git a/azurerm/internal/services/eventgrid/resource_arm_eventgrid_domain.go b/azurerm/internal/services/eventgrid/resource_arm_eventgrid_domain.go index 6330b171cf83..73b450a8c955 100644 --- a/azurerm/internal/services/eventgrid/resource_arm_eventgrid_domain.go +++ b/azurerm/internal/services/eventgrid/resource_arm_eventgrid_domain.go @@ -5,7 +5,7 @@ import ( "log" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2018-09-15-preview/eventgrid" + "github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2020-01-01-preview/eventgrid" "github.com/hashicorp/go-azure-helpers/response" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" @@ -54,7 +54,7 @@ func resourceArmEventGridDomain() *schema.Resource { Default: string(eventgrid.InputSchemaEventGridSchema), ForceNew: true, ValidateFunc: validation.StringInSlice([]string{ - string(eventgrid.InputSchemaCloudEventV01Schema), + string(eventgrid.InputSchemaCloudEventSchemaV10), string(eventgrid.InputSchemaCustomEventSchema), string(eventgrid.InputSchemaEventGridSchema), }, false), diff --git a/azurerm/internal/services/eventgrid/resource_arm_eventgrid_domain_topic.go b/azurerm/internal/services/eventgrid/resource_arm_eventgrid_domain_topic.go new file mode 100644 index 000000000000..ed459b36ff71 --- /dev/null +++ b/azurerm/internal/services/eventgrid/resource_arm_eventgrid_domain_topic.go @@ -0,0 +1,156 @@ +package eventgrid + +import ( + "fmt" + "log" + "time" + + "github.com/hashicorp/go-azure-helpers/response" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/features" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func resourceArmEventGridDomainTopic() *schema.Resource { + return &schema.Resource{ + Create: resourceArmEventGridDomainTopicCreateUpdate, + Read: resourceArmEventGridDomainTopicRead, + Update: resourceArmEventGridDomainTopicCreateUpdate, + Delete: resourceArmEventGridDomainTopicDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + + Timeouts: &schema.ResourceTimeout{ + Create: schema.DefaultTimeout(30 * time.Minute), + Read: schema.DefaultTimeout(5 * time.Minute), + Update: schema.DefaultTimeout(30 * time.Minute), + Delete: schema.DefaultTimeout(30 * time.Minute), + }, + + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "domain_name": { + Type: schema.TypeString, + Required: true, + }, + + "resource_group_name": azure.SchemaResourceGroupName(), + }, + } +} + +func resourceArmEventGridDomainTopicCreateUpdate(d *schema.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).EventGrid.DomainTopicsClient + ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) + defer cancel() + + name := d.Get("name").(string) + domainName := d.Get("domain_name").(string) + resourceGroup := d.Get("resource_group_name").(string) + + if features.ShouldResourcesBeImported() && d.IsNewResource() { + existing, err := client.Get(ctx, resourceGroup, domainName, name) + if err != nil { + if !utils.ResponseWasNotFound(existing.Response) { + return fmt.Errorf("Error checking for presence of existing EventGrid Domain Topic %q (Resource Group %q): %s", name, resourceGroup, err) + } + } + + if existing.ID != nil && *existing.ID != "" { + return tf.ImportAsExistsError("azurerm_eventgrid_domain_topic", *existing.ID) + } + } + + future, err := client.CreateOrUpdate(ctx, resourceGroup, domainName, name) + if err != nil { + return fmt.Errorf("Error creating/updating EventGrid Domain Topic %q (Resource Group %q): %s", name, resourceGroup, err) + } + + if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { + return fmt.Errorf("Error waiting for EventGrid Domain Topic %q (Resource Group %q) to become available: %s", name, resourceGroup, err) + } + + read, err := client.Get(ctx, resourceGroup, domainName, name) + if err != nil { + return fmt.Errorf("Error retrieving EventGrid Domain Topic %q (Resource Group %q): %s", name, resourceGroup, err) + } + if read.ID == nil { + return fmt.Errorf("Cannot read EventGrid Domain Topic %q (resource group %s) ID", name, resourceGroup) + } + + d.SetId(*read.ID) + + return resourceArmEventGridDomainTopicRead(d, meta) +} + +func resourceArmEventGridDomainTopicRead(d *schema.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).EventGrid.DomainTopicsClient + ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) + defer cancel() + + id, err := azure.ParseAzureResourceID(d.Id()) + if err != nil { + return err + } + resourceGroup := id.ResourceGroup + domainName := id.Path["domains"] + name := id.Path["topics"] + + resp, err := client.Get(ctx, resourceGroup, domainName, name) + if err != nil { + if utils.ResponseWasNotFound(resp.Response) { + log.Printf("[WARN] EventGrid Domain Topic %q was not found (Resource Group %q)", name, resourceGroup) + d.SetId("") + return nil + } + + return fmt.Errorf("Error making Read request on EventGrid Domain Topic %q: %+v", name, err) + } + + d.Set("name", resp.Name) + d.Set("domain_name", domainName) + d.Set("resource_group_name", resourceGroup) + + return nil +} + +func resourceArmEventGridDomainTopicDelete(d *schema.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).EventGrid.DomainTopicsClient + ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) + defer cancel() + + id, err := azure.ParseAzureResourceID(d.Id()) + if err != nil { + return err + } + resGroup := id.ResourceGroup + domainName := id.Path["domains"] + name := id.Path["topics"] + + future, err := client.Delete(ctx, resGroup, domainName, name) + if err != nil { + if response.WasNotFound(future.Response()) { + return nil + } + return fmt.Errorf("Error deleting Event Grid Domain Topic %q: %+v", name, err) + } + + if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { + if response.WasNotFound(future.Response()) { + return nil + } + return fmt.Errorf("Error deleting Event Grid Domain Topic %q: %+v", name, err) + } + + return nil +} diff --git a/azurerm/internal/services/eventgrid/resource_arm_eventgrid_event_subscription.go b/azurerm/internal/services/eventgrid/resource_arm_eventgrid_event_subscription.go index e78ec1676ce0..2bdf8840cb09 100644 --- a/azurerm/internal/services/eventgrid/resource_arm_eventgrid_event_subscription.go +++ b/azurerm/internal/services/eventgrid/resource_arm_eventgrid_event_subscription.go @@ -3,10 +3,12 @@ package eventgrid import ( "fmt" "log" + "strconv" "strings" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2018-09-15-preview/eventgrid" + "github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2020-01-01-preview/eventgrid" + "github.com/Azure/go-autorest/autorest/date" "github.com/hashicorp/go-azure-helpers/response" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" @@ -18,6 +20,46 @@ import ( "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) +func getEnpointTypes() []string { + return []string{"webhook_endpoint", "storage_queue_endpoint", "eventhub_endpoint", "hybrid_connection_endpoint", "service_bus_queue_endpoint", "service_bus_topic_endpoint", "azure_function_endpoint"} +} + +// RemoveFromStringArray removes all matching values from a string array +func RemoveFromStringArray(elements []string, remove string) []string { + for i, v := range elements { + if v == remove { + return append(elements[:i], elements[i+1:]...) + } + } + return elements +} + +// AdvancedFilterDiffSuppressFunc performs a type relaxed diff +func AdvancedFilterDiffSuppressFunc(k, old, new string, d *schema.ResourceData) bool { + if strings.EqualFold(old, new) { + return true + } else if o, err := strconv.ParseFloat(old, 64); err == nil { + n, err := strconv.ParseFloat(new, 64) + if err == nil { + return o == n + } + } else if o, err := strconv.ParseBool(old); err == nil { + n, err := strconv.ParseBool(new) + if err == nil { + return o == n + } + } + return false +} + +// ParseFloat tries to convert a string to a float64 value +func ParseFloat(value string) (*float64, error) { + if f, err := strconv.ParseFloat(value, 64); err == nil { + return &f, nil + } + return nil, fmt.Errorf("Value %q is not a float number", value) +} + func resourceArmEventGridEventSubscription() *schema.Resource { return &schema.Resource{ Create: resourceArmEventGridEventSubscriptionCreateUpdate, @@ -56,23 +98,23 @@ func resourceArmEventGridEventSubscription() *schema.Resource { ForceNew: true, Default: string(eventgrid.EventGridSchema), ValidateFunc: validation.StringInSlice([]string{ - string(eventgrid.CloudEventV01Schema), - string(eventgrid.CustomInputSchema), string(eventgrid.EventGridSchema), + string(eventgrid.CloudEventSchemaV10), + string(eventgrid.CustomInputSchema), }, false), }, - "topic_name": { - Type: schema.TypeString, - Optional: true, - Computed: true, + "expiration_time_utc": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringIsNotEmpty, }, "storage_queue_endpoint": { Type: schema.TypeList, MaxItems: 1, Optional: true, - ConflictsWith: []string{"eventhub_endpoint", "hybrid_connection_endpoint", "webhook_endpoint"}, + ConflictsWith: RemoveFromStringArray(getEnpointTypes(), "storage_queue_endpoint"), Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "storage_account_id": { @@ -93,7 +135,7 @@ func resourceArmEventGridEventSubscription() *schema.Resource { Type: schema.TypeList, MaxItems: 1, Optional: true, - ConflictsWith: []string{"storage_queue_endpoint", "hybrid_connection_endpoint", "webhook_endpoint"}, + ConflictsWith: RemoveFromStringArray(getEnpointTypes(), "eventhub_endpoint"), Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "eventhub_id": { @@ -109,7 +151,7 @@ func resourceArmEventGridEventSubscription() *schema.Resource { Type: schema.TypeList, MaxItems: 1, Optional: true, - ConflictsWith: []string{"storage_queue_endpoint", "eventhub_endpoint", "webhook_endpoint"}, + ConflictsWith: RemoveFromStringArray(getEnpointTypes(), "hybrid_connection_endpoint"), Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "hybrid_connection_id": { @@ -125,7 +167,7 @@ func resourceArmEventGridEventSubscription() *schema.Resource { Type: schema.TypeList, MaxItems: 1, Optional: true, - ConflictsWith: []string{"storage_queue_endpoint", "eventhub_endpoint", "hybrid_connection_endpoint"}, + ConflictsWith: RemoveFromStringArray(getEnpointTypes(), "webhook_endpoint"), Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "url": { @@ -137,12 +179,61 @@ func resourceArmEventGridEventSubscription() *schema.Resource { }, }, + "service_bus_queue_endpoint": { + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + ConflictsWith: RemoveFromStringArray(getEnpointTypes(), "service_bus_queue_endpoint"), + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "service_bus_queue_id": { + Type: schema.TypeString, + Required: true, + ValidateFunc: azure.ValidateResourceID, + }, + }, + }, + }, + + "service_bus_topic_endpoint": { + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + ConflictsWith: RemoveFromStringArray(getEnpointTypes(), "service_bus_topic_endpoint"), + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "service_bus_queue_id": { + Type: schema.TypeString, + Required: true, + ValidateFunc: azure.ValidateResourceID, + }, + }, + }, + }, + + "azure_function_endpoint": { + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + ConflictsWith: RemoveFromStringArray(getEnpointTypes(), "azure_function_endpoint"), + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "azure_function_id": { + Type: schema.TypeString, + Required: true, + ValidateFunc: azure.ValidateResourceID, + }, + }, + }, + }, + "included_event_types": { Type: schema.TypeList, Optional: true, Computed: true, Elem: &schema.Schema{ - Type: schema.TypeString, + Type: schema.TypeString, + ValidateFunc: validation.StringIsNotEmpty, }, }, @@ -168,6 +259,58 @@ func resourceArmEventGridEventSubscription() *schema.Resource { }, }, + "advanced_filter": { + Type: schema.TypeList, + MaxItems: 5, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "key": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + "operator_type": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + string(eventgrid.OperatorTypeAdvancedFilter), + string(eventgrid.OperatorTypeBoolEquals), + string(eventgrid.OperatorTypeNumberGreaterThan), + string(eventgrid.OperatorTypeNumberGreaterThanOrEquals), + string(eventgrid.OperatorTypeNumberLessThan), + string(eventgrid.OperatorTypeNumberLessThanOrEquals), + string(eventgrid.OperatorTypeNumberIn), + string(eventgrid.OperatorTypeNumberNotIn), + string(eventgrid.OperatorTypeStringBeginsWith), + string(eventgrid.OperatorTypeStringContains), + string(eventgrid.OperatorTypeStringEndsWith), + string(eventgrid.OperatorTypeStringIn), + string(eventgrid.OperatorTypeStringNotIn), + }, false), + }, + "value": { + Type: schema.TypeString, + Optional: true, + ConflictsWith: []string{"advanced_filter.values"}, + DiffSuppressFunc: AdvancedFilterDiffSuppressFunc, + }, + "values": { + Type: schema.TypeList, + MinItems: 1, + MaxItems: 5, + Optional: true, + ConflictsWith: []string{"advanced_filter.value"}, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.StringIsNotEmpty, + DiffSuppressFunc: AdvancedFilterDiffSuppressFunc, + }, + }, + }, + }, + }, + "storage_blob_dead_letter_destination": { Type: schema.TypeList, MaxItems: 1, @@ -216,6 +359,12 @@ func resourceArmEventGridEventSubscription() *schema.Resource { Type: schema.TypeString, }, }, + + "topic_name": { + Type: schema.TypeString, + Optional: true, + Computed: true, + }, }, } } @@ -243,20 +392,29 @@ func resourceArmEventGridEventSubscriptionCreateUpdate(d *schema.ResourceData, m destination := expandEventGridEventSubscriptionDestination(d) if destination == nil { - return fmt.Errorf("One of `webhook_endpoint`, eventhub_endpoint` `hybrid_connection_endpoint` or `storage_queue_endpoint` must be specificed to create an EventGrid Event Subscription") + return fmt.Errorf("One of the following endpoint types must be specificed to create an EventGrid Event Subscription: %q", getEnpointTypes()) + } + + filter, err := expandEventGridEventSubscriptionFilter(d) + if err != nil { + return fmt.Errorf("Error creating/updating EventGrid Event Subscription %q (Scope %q): %s", name, scope, err) + } + + parsedTime, err := date.ParseTime(time.RFC3339, d.Get("expiration_time_utc").(string)) + if err != nil { + return fmt.Errorf("Error creating/updating EventGrid Event Subscription %q (Scope %q): %s", name, scope, err) } + expirationTime := date.Time{Time: parsedTime} + eventSubscriptionProperties := eventgrid.EventSubscriptionProperties{ Destination: destination, - Filter: expandEventGridEventSubscriptionFilter(d), + Filter: filter, DeadLetterDestination: expandEventGridEventSubscriptionStorageBlobDeadLetterDestination(d), RetryPolicy: expandEventGridEventSubscriptionRetryPolicy(d), Labels: utils.ExpandStringSlice(d.Get("labels").([]interface{})), EventDeliverySchema: eventgrid.EventDeliverySchema(d.Get("event_delivery_schema").(string)), - } - - if v, ok := d.GetOk("topic_name"); ok { - eventSubscriptionProperties.Topic = utils.String(v.(string)) + ExpirationTimeUtc: &expirationTime, } eventSubscription := eventgrid.EventSubscription{ @@ -312,7 +470,7 @@ func resourceArmEventGridEventSubscriptionRead(d *schema.ResourceData, meta inte d.Set("scope", id.Scope) if props := resp.EventSubscriptionProperties; props != nil { - d.Set("event_delivery_schema", string(props.EventDeliverySchema)) + d.Set("expiration_time_utc", props.ExpirationTimeUtc.Format(time.RFC3339)) if props.Topic != nil && *props.Topic != "" { d.Set("topic_name", props.Topic) @@ -333,6 +491,21 @@ func resourceArmEventGridEventSubscriptionRead(d *schema.ResourceData, meta inte return fmt.Errorf("Error setting `hybrid_connection_endpoint` for EventGrid Event Subscription %q (Scope %q): %s", id.Name, id.Scope, err) } } + if serviceBusQueueEndpoint, ok := props.Destination.AsServiceBusQueueEventSubscriptionDestination(); ok { + if err := d.Set("service_bus_queue_endpoint", flattenEventGridEventSubscriptionServiceBusQueueEndpoint(serviceBusQueueEndpoint)); err != nil { + return fmt.Errorf("Error setting `service_bus_queue_endpoint` for EventGrid Event Subscription %q (Scope %q): %s", id.Name, id.Scope, err) + } + } + if serviceBusTopicEndpoint, ok := props.Destination.AsServiceBusTopicEventSubscriptionDestination(); ok { + if err := d.Set("service_bus_topic_endpoint", flattenEventGridEventSubscriptionServiceBusTopicEndpoint(serviceBusTopicEndpoint)); err != nil { + return fmt.Errorf("Error setting `service_bus_topic_endpoint` for EventGrid Event Subscription %q (Scope %q): %s", id.Name, id.Scope, err) + } + } + if azureFunctionEndpoint, ok := props.Destination.AsAzureFunctionEventSubscriptionDestination(); ok { + if err := d.Set("azure_function_endpoint", flattenEventGridEventSubscriptionAzureFunctionEndpoint(azureFunctionEndpoint)); err != nil { + return fmt.Errorf("Error setting `azure_function_endpoint` for EventGrid Event Subscription %q (Scope %q): %s", id.Name, id.Scope, err) + } + } if _, ok := props.Destination.AsWebHookEventSubscriptionDestination(); ok { fullURL, err := client.GetFullURL(ctx, id.Scope, id.Name) if err != nil { @@ -348,6 +521,10 @@ func resourceArmEventGridEventSubscriptionRead(d *schema.ResourceData, meta inte if err := d.Set("subject_filter", flattenEventGridEventSubscriptionSubjectFilter(filter)); err != nil { return fmt.Errorf("Error setting `subject_filter` for EventGrid Event Subscription %q (Scope %q): %s", id.Name, id.Scope, err) } + + if err := d.Set("advanced_filter", flattenEventGridEventSubscriptionAdvancedFilter(filter.AdvancedFilters)); err != nil { + return fmt.Errorf("Error setting `advanced_filter` for EventGrid Event Subscription %q (Scope %q): %s", id.Name, id.Scope, err) + } } if props.DeadLetterDestination != nil { @@ -437,6 +614,18 @@ func expandEventGridEventSubscriptionDestination(d *schema.ResourceData) eventgr return expandEventGridEventSubscriptionWebhookEndpoint(d) } + if _, ok := d.GetOk("service_bus_queue_endpoint"); ok { + return expandEventGridEventSubscriptionServiceBusQueueEndpoint(d) + } + + if _, ok := d.GetOk("service_bus_topic_endpoint"); ok { + return expandEventGridEventSubscriptionServiceBusTopicEndpoint(d) + } + + if _, ok := d.GetOk("azure_function"); ok { + return expandEventGridEventSubscriptionAzureFunctionEndpoint(d) + } + return nil } @@ -494,7 +683,46 @@ func expandEventGridEventSubscriptionWebhookEndpoint(d *schema.ResourceData) eve return webhookEndpoint } -func expandEventGridEventSubscriptionFilter(d *schema.ResourceData) *eventgrid.EventSubscriptionFilter { +func expandEventGridEventSubscriptionServiceBusQueueEndpoint(d *schema.ResourceData) eventgrid.BasicEventSubscriptionDestination { + props := d.Get("service_bus_queue_endpoint").([]interface{})[0].(map[string]interface{}) + serviceBusQueueID := props["service_bus_queue_id"].(string) + + serviceBusQueueEndpoint := eventgrid.ServiceBusQueueEventSubscriptionDestination{ + EndpointType: eventgrid.EndpointTypeServiceBusQueue, + ServiceBusQueueEventSubscriptionDestinationProperties: &eventgrid.ServiceBusQueueEventSubscriptionDestinationProperties{ + ResourceID: &serviceBusQueueID, + }, + } + return serviceBusQueueEndpoint +} + +func expandEventGridEventSubscriptionServiceBusTopicEndpoint(d *schema.ResourceData) eventgrid.BasicEventSubscriptionDestination { + props := d.Get("service_bus_topic_endpoint").([]interface{})[0].(map[string]interface{}) + serviceBusTopicID := props["service_bus_topic_id"].(string) + + serviceBusTopicEndpoint := eventgrid.ServiceBusTopicEventSubscriptionDestination{ + EndpointType: eventgrid.EndpointTypeServiceBusTopic, + ServiceBusTopicEventSubscriptionDestinationProperties: &eventgrid.ServiceBusTopicEventSubscriptionDestinationProperties{ + ResourceID: &serviceBusTopicID, + }, + } + return serviceBusTopicEndpoint +} + +func expandEventGridEventSubscriptionAzureFunctionEndpoint(d *schema.ResourceData) eventgrid.BasicEventSubscriptionDestination { + props := d.Get("azure_function_endpoint").([]interface{})[0].(map[string]interface{}) + azureFunctionResourceID := props["azure_function_id"].(string) + + azureFunctionEndpoint := eventgrid.AzureFunctionEventSubscriptionDestination{ + EndpointType: eventgrid.EndpointTypeAzureFunction, + AzureFunctionEventSubscriptionDestinationProperties: &eventgrid.AzureFunctionEventSubscriptionDestinationProperties{ + ResourceID: &azureFunctionResourceID, + }, + } + return azureFunctionEndpoint +} + +func expandEventGridEventSubscriptionFilter(d *schema.ResourceData) (*eventgrid.EventSubscriptionFilter, error) { filter := &eventgrid.EventSubscriptionFilter{} if includedEvents, ok := d.GetOk("included_event_types"); ok { @@ -512,7 +740,137 @@ func expandEventGridEventSubscriptionFilter(d *schema.ResourceData) *eventgrid.E filter.IsSubjectCaseSensitive = &caseSensitive } - return filter + if advancedFilter, ok := d.GetOk("advanced_filter"); ok { + advancedFilters := make([]eventgrid.BasicAdvancedFilter, 0) + for _, v := range advancedFilter.([]interface{}) { + config := v.(map[string]interface{}) + + if filter, err := expandAdvancedFilter(config); err == nil { + advancedFilters = append(advancedFilters, filter) + } else { + return nil, err + } + } + filter.AdvancedFilters = &advancedFilters + } + + return filter, nil +} + +func expandAdvancedFilter(config map[string]interface{}) (eventgrid.BasicAdvancedFilter, error) { + operatorType := config["operator_type"].(string) + key := config["key"].(string) + value := config["value"].(string) + values := utils.ExpandStringSlice(config["values"].([]interface{})) + + switch operatorType { + case string(eventgrid.OperatorTypeAdvancedFilter), + string(eventgrid.OperatorTypeBoolEquals), + string(eventgrid.OperatorTypeNumberGreaterThan), + string(eventgrid.OperatorTypeNumberGreaterThanOrEquals), + string(eventgrid.OperatorTypeNumberLessThan), + string(eventgrid.OperatorTypeNumberLessThanOrEquals): + // Workaround as long as nested schema validation is not working as expected (see https://github.com/hashicorp/terraform-plugin-sdk/issues/71) + if values != nil && len(*values) > 0 { + return nil, fmt.Errorf("Conflicting field for `advanced_filter` (key=%s, operator_type=%s): values", key, operatorType) + } + if len(value) == 0 { + return nil, fmt.Errorf("Missing value for`advanced_filter` (key=%s, operator_type=%s, value=%q)", key, operatorType, value) + } + return expandScalarAdvancedFilter(key, operatorType, value) + case + string(eventgrid.OperatorTypeNumberIn), + string(eventgrid.OperatorTypeNumberNotIn), + string(eventgrid.OperatorTypeStringBeginsWith), + string(eventgrid.OperatorTypeStringContains), + string(eventgrid.OperatorTypeStringEndsWith), + string(eventgrid.OperatorTypeStringIn), + string(eventgrid.OperatorTypeStringNotIn): + // Workaround as long as nested schema validation is not working as expected (see https://github.com/hashicorp/terraform-plugin-sdk/issues/71) + if len(value) > 0 { + return nil, fmt.Errorf("Conflicting field for `advanced_filter` (key=%s, operator_type=%s): value", key, operatorType) + } + if values != nil && len(*values) == 0 { + return nil, fmt.Errorf("Missing values for `advanced_filter` (key=%s, operator_type=%s, values=%q)", key, operatorType, values) + } + return expandArrayAdvancedFilter(key, operatorType, *values) + default: + return nil, fmt.Errorf("Invalid `advanced_filter` operator_type %s used", operatorType) + } +} + +func expandArrayAdvancedFilter(key string, operatorType string, values []string) (eventgrid.BasicAdvancedFilter, error) { + switch operatorType { + case string(eventgrid.OperatorTypeNumberIn): + var numbers = []float64{} + for _, v := range values { + if f, err := ParseFloat(v); err == nil { + numbers = append(numbers, *f) + } else { + return nil, err + } + } + return eventgrid.NumberInAdvancedFilter{Key: &key, OperatorType: eventgrid.OperatorTypeNumberIn, Values: &numbers}, nil + case string(eventgrid.OperatorTypeNumberNotIn): + var numbers = []float64{} + for _, v := range values { + if f, err := ParseFloat(v); err == nil { + numbers = append(numbers, *f) + } else { + return nil, err + } + } + return eventgrid.NumberNotInAdvancedFilter{Key: &key, OperatorType: eventgrid.OperatorTypeNumberIn, Values: &numbers}, nil + case string(eventgrid.OperatorTypeStringIn): + return eventgrid.StringInAdvancedFilter{Key: &key, OperatorType: eventgrid.OperatorTypeStringIn, Values: &values}, nil + case string(eventgrid.OperatorTypeStringNotIn): + return eventgrid.StringNotInAdvancedFilter{Key: &key, OperatorType: eventgrid.OperatorTypeStringNotIn, Values: &values}, nil + case string(eventgrid.OperatorTypeStringBeginsWith): + return eventgrid.StringBeginsWithAdvancedFilter{Key: &key, OperatorType: eventgrid.OperatorTypeStringBeginsWith, Values: &values}, nil + case string(eventgrid.OperatorTypeStringEndsWith): + return eventgrid.StringEndsWithAdvancedFilter{Key: &key, OperatorType: eventgrid.OperatorTypeStringEndsWith, Values: &values}, nil + case string(eventgrid.OperatorTypeStringContains): + return eventgrid.StringContainsAdvancedFilter{Key: &key, OperatorType: eventgrid.OperatorTypeStringContains, Values: &values}, nil + default: + return nil, nil + } +} + +func expandScalarAdvancedFilter(key string, operatorType string, value string) (eventgrid.BasicAdvancedFilter, error) { + switch operatorType { + case string(eventgrid.OperatorTypeNumberLessThan): + v, err := strconv.ParseFloat(value, 64) + if err == nil { + return eventgrid.NumberLessThanAdvancedFilter{Key: &key, OperatorType: eventgrid.OperatorTypeNumberLessThan, Value: &v}, nil + } + return nil, fmt.Errorf("Value %q is not a float number", value) + case string(eventgrid.OperatorTypeNumberGreaterThan): + v, err := strconv.ParseFloat(value, 64) + if err == nil { + return eventgrid.NumberGreaterThanAdvancedFilter{Key: &key, OperatorType: eventgrid.OperatorTypeNumberGreaterThan, Value: &v}, nil + } + return nil, fmt.Errorf("Value %q is not a float number", value) + case string(eventgrid.OperatorTypeNumberLessThanOrEquals): + v, err := strconv.ParseFloat(value, 64) + if err == nil { + return eventgrid.NumberLessThanOrEqualsAdvancedFilter{Key: &key, OperatorType: eventgrid.OperatorTypeNumberLessThanOrEquals, Value: &v}, nil + } + return nil, fmt.Errorf("Value %q is not a float number", value) + case string(eventgrid.OperatorTypeNumberGreaterThanOrEquals): + v, err := strconv.ParseFloat(value, 64) + if err == nil { + return eventgrid.NumberGreaterThanOrEqualsAdvancedFilter{Key: &key, OperatorType: eventgrid.OperatorTypeNumberGreaterThanOrEquals, Value: &v}, nil + } + return nil, fmt.Errorf("Value %q is not a float number", value) + case string(eventgrid.OperatorTypeBoolEquals): + v, err := strconv.ParseBool(value) + if err == nil { + return eventgrid.BoolEqualsAdvancedFilter{Key: &key, OperatorType: eventgrid.OperatorTypeBoolEquals, Value: &v}, nil + } + return nil, fmt.Errorf("Value %q is not a bool", value) + default: + return nil, nil + } } func expandEventGridEventSubscriptionStorageBlobDeadLetterDestination(d *schema.ResourceData) eventgrid.BasicDeadLetterDestination { @@ -599,6 +957,45 @@ func flattenEventGridEventSubscriptionWebhookEndpoint(input *eventgrid.EventSubs return []interface{}{result} } +func flattenEventGridEventSubscriptionServiceBusQueueEndpoint(input *eventgrid.ServiceBusQueueEventSubscriptionDestination) []interface{} { + if input == nil { + return nil + } + result := make(map[string]interface{}) + + if input.ResourceID != nil { + result["service_bus_queue_id"] = *input.ResourceID + } + + return []interface{}{result} +} + +func flattenEventGridEventSubscriptionServiceBusTopicEndpoint(input *eventgrid.ServiceBusTopicEventSubscriptionDestination) []interface{} { + if input == nil { + return nil + } + result := make(map[string]interface{}) + + if input.ResourceID != nil { + result["service_bus_topic_id"] = *input.ResourceID + } + + return []interface{}{result} +} + +func flattenEventGridEventSubscriptionAzureFunctionEndpoint(input *eventgrid.AzureFunctionEventSubscriptionDestination) []interface{} { + if input == nil { + return nil + } + result := make(map[string]interface{}) + + if input.ResourceID != nil { + result["azure_function_id"] = *input.ResourceID + } + + return []interface{}{result} +} + func flattenEventGridEventSubscriptionSubjectFilter(filter *eventgrid.EventSubscriptionFilter) []interface{} { if (filter.SubjectBeginsWith != nil && *filter.SubjectBeginsWith == "") && (filter.SubjectEndsWith != nil && *filter.SubjectEndsWith == "") { return nil @@ -620,6 +1017,93 @@ func flattenEventGridEventSubscriptionSubjectFilter(filter *eventgrid.EventSubsc return []interface{}{result} } +func flattenEventGridEventSubscriptionAdvancedFilter(input *[]eventgrid.BasicAdvancedFilter) []interface{} { + results := make([]interface{}, 0) + if input == nil { + return results + } + + for _, item := range *input { + var key interface{} + var operatorType eventgrid.OperatorType + var value interface{} + var values interface{} + + switch f := item.(type) { + case eventgrid.AdvancedFilter: + key = *f.Key + operatorType = f.OperatorType + case eventgrid.BoolEqualsAdvancedFilter: + key = *f.Key + operatorType = f.OperatorType + value = strconv.FormatBool(*f.Value) + case eventgrid.NumberGreaterThanAdvancedFilter: + key = *f.Key + operatorType = f.OperatorType + value = strconv.FormatFloat(*f.Value, 'f', -1, 64) + case eventgrid.NumberGreaterThanOrEqualsAdvancedFilter: + key = *f.Key + operatorType = f.OperatorType + value = strconv.FormatFloat(*f.Value, 'f', -1, 64) + case eventgrid.NumberLessThanAdvancedFilter: + key = *f.Key + operatorType = f.OperatorType + value = strconv.FormatFloat(*f.Value, 'f', -1, 64) + case eventgrid.NumberInAdvancedFilter: + key = *f.Key + operatorType = f.OperatorType + var numbers = []string{} + for _, f := range *f.Values { + number := strconv.FormatFloat(f, 'f', -1, 64) + numbers = append(numbers, number) + } + values = utils.FlattenStringSlice(&numbers) + case eventgrid.NumberNotInAdvancedFilter: + key = *f.Key + operatorType = f.OperatorType + var numbers = []string{} + for _, f := range *f.Values { + number := strconv.FormatFloat(f, 'f', -1, 64) + numbers = append(numbers, number) + } + values = utils.FlattenStringSlice(&numbers) + case eventgrid.StringBeginsWithAdvancedFilter: + key = *f.Key + operatorType = f.OperatorType + values = utils.FlattenStringSlice(f.Values) + case eventgrid.StringContainsAdvancedFilter: + key = *f.Key + operatorType = f.OperatorType + values = utils.FlattenStringSlice(f.Values) + case eventgrid.StringEndsWithAdvancedFilter: + key = *f.Key + operatorType = f.OperatorType + values = utils.FlattenStringSlice(f.Values) + case eventgrid.StringInAdvancedFilter: + key = *f.Key + operatorType = f.OperatorType + values = utils.FlattenStringSlice(f.Values) + case eventgrid.StringNotInAdvancedFilter: + key = *f.Key + operatorType = f.OperatorType + values = utils.FlattenStringSlice(f.Values) + case eventgrid.NumberLessThanOrEqualsAdvancedFilter: + key = *f.Key + operatorType = f.OperatorType + value = strconv.FormatFloat(*f.Value, 'f', -1, 64) + } + + results = append(results, map[string]interface{}{ + "key": key, + "operator_type": operatorType, + "value": value, + "values": values, + }) + } + + return results +} + func flattenEventGridEventSubscriptionStorageBlobDeadLetterDestination(dest *eventgrid.StorageBlobDeadLetterDestination) []interface{} { if dest == nil { return nil diff --git a/azurerm/internal/services/eventgrid/resource_arm_eventgrid_topic.go b/azurerm/internal/services/eventgrid/resource_arm_eventgrid_topic.go index 1272e8314483..44823881c67a 100644 --- a/azurerm/internal/services/eventgrid/resource_arm_eventgrid_topic.go +++ b/azurerm/internal/services/eventgrid/resource_arm_eventgrid_topic.go @@ -5,7 +5,7 @@ import ( "log" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2018-09-15-preview/eventgrid" + "github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2020-01-01-preview/eventgrid" "github.com/hashicorp/go-azure-helpers/response" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" @@ -47,6 +47,85 @@ func resourceArmEventGridTopic() *schema.Resource { "resource_group_name": azure.SchemaResourceGroupName(), + "input_schema": { + Type: schema.TypeString, + Optional: true, + Default: string(eventgrid.InputSchemaEventGridSchema), + ForceNew: true, + ValidateFunc: validation.StringInSlice([]string{ + string(eventgrid.InputSchemaCloudEventSchemaV10), + string(eventgrid.InputSchemaCustomEventSchema), + string(eventgrid.InputSchemaEventGridSchema), + }, false), + }, + + "input_mapping_fields": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + ForceNew: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeString, + ForceNew: true, + Optional: true, + }, + "topic": { + Type: schema.TypeString, + ForceNew: true, + Optional: true, + }, + "event_time": { + Type: schema.TypeString, + ForceNew: true, + Optional: true, + }, + "event_type": { + Type: schema.TypeString, + ForceNew: true, + Optional: true, + }, + "subject": { + Type: schema.TypeString, + ForceNew: true, + Optional: true, + }, + "data_version": { + Type: schema.TypeString, + ForceNew: true, + Optional: true, + }, + }, + }, + }, + + "input_mapping_default_values": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + ForceNew: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "event_type": { + Type: schema.TypeString, + ForceNew: true, + Optional: true, + }, + "subject": { + Type: schema.TypeString, + ForceNew: true, + Optional: true, + }, + "data_version": { + Type: schema.TypeString, + ForceNew: true, + Optional: true, + }, + }, + }, + }, + "endpoint": { Type: schema.TypeString, Computed: true, @@ -93,9 +172,14 @@ func resourceArmEventGridTopicCreateUpdate(d *schema.ResourceData, meta interfac location := azure.NormalizeLocation(d.Get("location").(string)) t := d.Get("tags").(map[string]interface{}) + topicProperties := &eventgrid.TopicProperties{ + InputSchemaMapping: expandAzureRmEventgridTopicInputMapping(d), + InputSchema: eventgrid.InputSchema(d.Get("input_schema").(string)), + } + properties := eventgrid.Topic{ Location: &location, - TopicProperties: &eventgrid.TopicProperties{}, + TopicProperties: topicProperties, Tags: tags.Expand(t), } @@ -146,6 +230,28 @@ func resourceArmEventGridTopicRead(d *schema.ResourceData, meta interface{}) err return fmt.Errorf("Error making Read request on EventGrid Topic '%s': %+v", name, err) } + if props := resp.TopicProperties; props != nil { + d.Set("endpoint", props.Endpoint) + + d.Set("input_schema", string(props.InputSchema)) + + inputMappingFields, err := flattenAzureRmEventgridTopicInputMapping(props.InputSchemaMapping) + if err != nil { + return fmt.Errorf("Unable to flatten `input_schema_mapping_fields` for EventGrid Topic %q (Resource Group %q): %s", name, resourceGroup, err) + } + if err := d.Set("input_mapping_fields", inputMappingFields); err != nil { + return fmt.Errorf("Error setting `input_schema_mapping_fields` for EventGrid Topic %q (Resource Group %q): %s", name, resourceGroup, err) + } + + inputMappingDefaultValues, err := flattenAzureRmEventgridTopicInputMappingDefaultValues(props.InputSchemaMapping) + if err != nil { + return fmt.Errorf("Unable to flatten `input_schema_mapping_default_values` for EventGrid Topic %q (Resource Group %q): %s", name, resourceGroup, err) + } + if err := d.Set("input_mapping_default_values", inputMappingDefaultValues); err != nil { + return fmt.Errorf("Error setting `input_schema_mapping_fields` for EventGrid Topic %q (Resource Group %q): %s", name, resourceGroup, err) + } + } + keys, err := client.ListSharedAccessKeys(ctx, resourceGroup, name) if err != nil { return fmt.Errorf("Error retrieving Shared Access Keys for EventGrid Topic '%s': %+v", name, err) @@ -196,3 +302,134 @@ func resourceArmEventGridTopicDelete(d *schema.ResourceData, meta interface{}) e return nil } + +func expandAzureRmEventgridTopicInputMapping(d *schema.ResourceData) *eventgrid.JSONInputSchemaMapping { + imf, imfok := d.GetOk("input_mapping_fields") + + imdv, imdvok := d.GetOk("input_mapping_default_values") + + if !imfok && !imdvok { + return nil + } + + jismp := eventgrid.JSONInputSchemaMappingProperties{} + + if imfok { + mappings := imf.([]interface{}) + mapping := mappings[0].(map[string]interface{}) + + if id := mapping["id"].(string); id != "" { + jismp.ID = &eventgrid.JSONField{SourceField: &id} + } + + if eventTime := mapping["event_time"].(string); eventTime != "" { + jismp.EventTime = &eventgrid.JSONField{SourceField: &eventTime} + } + + if topic := mapping["topic"].(string); topic != "" { + jismp.Topic = &eventgrid.JSONField{SourceField: &topic} + } + + if dataVersion := mapping["data_version"].(string); dataVersion != "" { + jismp.DataVersion = &eventgrid.JSONFieldWithDefault{SourceField: &dataVersion} + } + + if subject := mapping["subject"].(string); subject != "" { + jismp.Subject = &eventgrid.JSONFieldWithDefault{SourceField: &subject} + } + + if eventType := mapping["event_type"].(string); eventType != "" { + jismp.EventType = &eventgrid.JSONFieldWithDefault{SourceField: &eventType} + } + } + + if imdvok { + mappings := imdv.([]interface{}) + mapping := mappings[0].(map[string]interface{}) + + if dataVersion := mapping["data_version"].(string); dataVersion != "" { + jismp.DataVersion = &eventgrid.JSONFieldWithDefault{DefaultValue: &dataVersion} + } + + if subject := mapping["subject"].(string); subject != "" { + jismp.Subject = &eventgrid.JSONFieldWithDefault{DefaultValue: &subject} + } + + if eventType := mapping["event_type"].(string); eventType != "" { + jismp.EventType = &eventgrid.JSONFieldWithDefault{DefaultValue: &eventType} + } + } + + jsonMapping := eventgrid.JSONInputSchemaMapping{ + JSONInputSchemaMappingProperties: &jismp, + InputSchemaMappingType: eventgrid.InputSchemaMappingTypeJSON, + } + + return &jsonMapping +} + +func flattenAzureRmEventgridTopicInputMapping(input eventgrid.BasicInputSchemaMapping) ([]interface{}, error) { + if input == nil { + return nil, nil + } + result := make(map[string]interface{}) + + jsonValues, ok := input.(eventgrid.JSONInputSchemaMapping) + if !ok { + return nil, fmt.Errorf("Unable to read JSONInputSchemaMapping") + } + props := jsonValues.JSONInputSchemaMappingProperties + + if props.EventTime != nil && props.EventTime.SourceField != nil { + result["event_time"] = *props.EventTime.SourceField + } + + if props.ID != nil && props.ID.SourceField != nil { + result["id"] = *props.ID.SourceField + } + + if props.Topic != nil && props.Topic.SourceField != nil { + result["topic"] = *props.Topic.SourceField + } + + if props.DataVersion != nil && props.DataVersion.SourceField != nil { + result["data_version"] = *props.DataVersion.SourceField + } + + if props.EventType != nil && props.EventType.SourceField != nil { + result["event_type"] = *props.EventType.SourceField + } + + if props.Subject != nil && props.Subject.SourceField != nil { + result["subject"] = *props.Subject.SourceField + } + + return []interface{}{result}, nil +} + +func flattenAzureRmEventgridTopicInputMappingDefaultValues(input eventgrid.BasicInputSchemaMapping) ([]interface{}, error) { + if input == nil { + return nil, nil + } + result := make(map[string]interface{}) + + jsonValues, ok := input.(eventgrid.JSONInputSchemaMapping) + if !ok { + return nil, fmt.Errorf("Unable to read JSONInputSchemaMapping") + } + props := jsonValues.JSONInputSchemaMappingProperties + + if props.DataVersion != nil && props.DataVersion.DefaultValue != nil { + result["data_version"] = *props.DataVersion.DefaultValue + } + + if props.EventType != nil && props.EventType.DefaultValue != nil { + result["event_type"] = *props.EventType.DefaultValue + } + + if props.Subject != nil && props.Subject.DefaultValue != nil { + result["subject"] = *props.Subject.DefaultValue + } + + return []interface{}{result}, nil +} diff --git a/azurerm/internal/services/eventgrid/tests/resource_arm_eventgrid_domain_test.go b/azurerm/internal/services/eventgrid/tests/resource_arm_eventgrid_domain_test.go index 3dd1e68cfccc..1a406056fc4b 100644 --- a/azurerm/internal/services/eventgrid/tests/resource_arm_eventgrid_domain_test.go +++ b/azurerm/internal/services/eventgrid/tests/resource_arm_eventgrid_domain_test.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/terraform" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/acceptance" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/features" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) @@ -34,6 +35,33 @@ func TestAccAzureRMEventGridDomain_basic(t *testing.T) { }) } +func TestAccAzureRMEventGridDomain_requiresImport(t *testing.T) { + if !features.ShouldResourcesBeImported() { + t.Skip("Skipping since resources aren't required to be imported") + return + } + + data := acceptance.BuildTestData(t, "azurerm_eventgrid_domain", "test") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + CheckDestroy: testCheckAzureRMEventGridDomainDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMEventGridDomain_basic(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMEventGridDomainExists(data.ResourceName), + ), + }, + { + Config: testAccAzureRMEventGridDomain_requiresImport(data), + ExpectError: acceptance.RequiresImportError("azurerm_eventgrid_domain"), + }, + }, + }) +} + func TestAccAzureRMEventGridDomain_mapping(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_eventgrid_domain", "test") @@ -156,6 +184,19 @@ resource "azurerm_eventgrid_domain" "test" { `, data.RandomInteger, data.Locations.Primary, data.RandomInteger) } +func testAccAzureRMEventGridDomain_requiresImport(data acceptance.TestData) string { + template := testAccAzureRMEventGridDomain_basic(data) + return fmt.Sprintf(` +%s + +resource "azurerm_eventgrid_domain" "import" { + name = azurerm_eventgrid_domain.test.name + location = azurerm_eventgrid_domain.test.location + resource_group_name = azurerm_eventgrid_domain.test.resource_group_name +} +`, template) +} + func testAccAzureRMEventGridDomain_mapping(data acceptance.TestData) string { return fmt.Sprintf(` provider "azurerm" { diff --git a/azurerm/internal/services/eventgrid/tests/resource_arm_eventgrid_domain_topic_test.go b/azurerm/internal/services/eventgrid/tests/resource_arm_eventgrid_domain_topic_test.go new file mode 100644 index 000000000000..552ca9f4084c --- /dev/null +++ b/azurerm/internal/services/eventgrid/tests/resource_arm_eventgrid_domain_topic_test.go @@ -0,0 +1,160 @@ +package tests + +import ( + "fmt" + "net/http" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/acceptance" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/features" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func TestAccAzureRMEventGridDomainTopic_basic(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_eventgrid_domain_topic", "test") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + CheckDestroy: testCheckAzureRMEventGridDomainTopicDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMEventGridDomainTopic_basic(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMEventGridDomainTopicExists(data.ResourceName), + resource.TestCheckResourceAttrSet(data.ResourceName, "id"), + ), + }, + data.ImportStep(), + }, + }) +} + +func TestAccAzureRMEventGridDomainTopic_requiresImport(t *testing.T) { + if !features.ShouldResourcesBeImported() { + t.Skip("Skipping since resources aren't required to be imported") + return + } + + data := acceptance.BuildTestData(t, "azurerm_eventgrid_domain_topic", "test") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + CheckDestroy: testCheckAzureRMEventGridTopicDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMEventGridDomainTopic_basic(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMEventGridDomainTopicExists(data.ResourceName), + ), + }, + { + Config: testAccAzureRMEventGridDomainTopic_requiresImport(data), + ExpectError: acceptance.RequiresImportError("azurerm_eventgrid_domain_topic"), + }, + }, + }) +} + +func testCheckAzureRMEventGridDomainTopicDestroy(s *terraform.State) error { + client := acceptance.AzureProvider.Meta().(*clients.Client).EventGrid.DomainTopicsClient + ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext + + for _, rs := range s.RootModule().Resources { + if rs.Type != "azurerm_eventgrid_domain_topic" { + continue + } + + name := rs.Primary.Attributes["name"] + domainName := rs.Primary.Attributes["domain_name"] + resourceGroup := rs.Primary.Attributes["resource_group_name"] + + resp, err := client.Get(ctx, resourceGroup, domainName, name) + if err != nil { + if utils.ResponseWasNotFound(resp.Response) { + return nil + } + + return err + } + + if resp.StatusCode != http.StatusNotFound { + return fmt.Errorf("EventGrid Domain Topic still exists:\n%#v", resp) + } + } + + return nil +} + +func testCheckAzureRMEventGridDomainTopicExists(resourceName string) resource.TestCheckFunc { + return func(s *terraform.State) error { + client := acceptance.AzureProvider.Meta().(*clients.Client).EventGrid.DomainTopicsClient + ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext + + // 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) + } + + name := rs.Primary.Attributes["name"] + domainName := rs.Primary.Attributes["domain_name"] + resourceGroup, hasResourceGroup := rs.Primary.Attributes["resource_group_name"] + if !hasResourceGroup { + return fmt.Errorf("Bad: no resource group found in state for EventGrid Domain Topic: %s", name) + } + + resp, err := client.Get(ctx, resourceGroup, domainName, name) + if err != nil { + if utils.ResponseWasNotFound(resp.Response) { + return fmt.Errorf("Bad: EventGrid Domain Topic %q (resource group: %s) does not exist", name, resourceGroup) + } + + return fmt.Errorf("Bad: Get on EventGrid.DomainTopicsClient: %s", err) + } + + return nil + } +} + +func testAccAzureRMEventGridDomainTopic_basic(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_eventgrid_domain" "test" { + name = "acctestegdomain-%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name +} + +resource "azurerm_eventgrid_domain_topic" "test" { + name = "acctestegtopic-%d" + domain_name = azurerm_eventgrid_domain.test.name + resource_group_name = azurerm_resource_group.test.name +} +`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger) +} + +func testAccAzureRMEventGridDomainTopic_requiresImport(data acceptance.TestData) string { + template := testAccAzureRMEventGridDomain_basic(data) + return fmt.Sprintf(` +%s + +resource "azurerm_eventgrid_domain_topic" "import" { + name = azurerm_eventgrid_domain_topic.test.name + domain_name = azurerm_eventgrid_domain_topic.test.domain_name + resource_group_name = azurerm_eventgrid_domain_topic.test.resource_group_name +} +`, template) +} diff --git a/azurerm/internal/services/eventgrid/tests/resource_arm_eventgrid_event_subscription_test.go b/azurerm/internal/services/eventgrid/tests/resource_arm_eventgrid_event_subscription_test.go index 5d0000541e6d..23348da42546 100644 --- a/azurerm/internal/services/eventgrid/tests/resource_arm_eventgrid_event_subscription_test.go +++ b/azurerm/internal/services/eventgrid/tests/resource_arm_eventgrid_event_subscription_test.go @@ -44,7 +44,7 @@ func TestAccAzureRMEventGridEventSubscription_eventhub(t *testing.T) { Config: testAccAzureRMEventGridEventSubscription_eventhub(data), Check: resource.ComposeTestCheckFunc( testCheckAzureRMEventGridEventSubscriptionExists(data.ResourceName), - resource.TestCheckResourceAttr(data.ResourceName, "event_delivery_schema", "CloudEventV01Schema"), + resource.TestCheckResourceAttr(data.ResourceName, "event_delivery_schema", "CloudEventSchemaV1_0"), resource.TestCheckResourceAttr(data.ResourceName, "eventhub_endpoint.#", "1"), ), }, @@ -53,6 +53,69 @@ func TestAccAzureRMEventGridEventSubscription_eventhub(t *testing.T) { }) } +func TestAccAzureRMEventGridEventSubscription_serviceBusQueue(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_eventgrid_event_subscription", "test") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + CheckDestroy: testCheckAzureRMEventGridEventSubscriptionDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMEventGridEventSubscription_serviceBusQueue(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMEventGridEventSubscriptionExists(data.ResourceName), + resource.TestCheckResourceAttr(data.ResourceName, "event_delivery_schema", "CloudEventSchemaV1_0"), + resource.TestCheckResourceAttr(data.ResourceName, "service_bus_queue_endpoint.#", "1"), + ), + }, + data.ImportStep(), + }, + }) +} + +func TestAccAzureRMEventGridEventSubscription_serviceBusTopic(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_eventgrid_event_subscription", "test") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + CheckDestroy: testCheckAzureRMEventGridEventSubscriptionDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMEventGridEventSubscription_serviceBusTopic(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMEventGridEventSubscriptionExists(data.ResourceName), + resource.TestCheckResourceAttr(data.ResourceName, "event_delivery_schema", "CloudEventSchemaV1_0"), + resource.TestCheckResourceAttr(data.ResourceName, "service_bus_topic_endpoint.#", "1"), + ), + }, + data.ImportStep(), + }, + }) +} + +func TestAccAzureRMEventGridEventSubscription_azureFunction(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_eventgrid_event_subscription", "test") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + CheckDestroy: testCheckAzureRMEventGridEventSubscriptionDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMEventGridEventSubscription_azureFunction(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMEventGridEventSubscriptionExists(data.ResourceName), + resource.TestCheckResourceAttr(data.ResourceName, "event_delivery_schema", "CloudEventSchemaV1_0"), + resource.TestCheckResourceAttr(data.ResourceName, "azure_function_endpoint.#", "1"), + ), + }, + data.ImportStep(), + }, + }) +} + func TestAccAzureRMEventGridEventSubscription_update(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_eventgrid_event_subscription", "test") @@ -116,6 +179,31 @@ func TestAccAzureRMEventGridEventSubscription_filter(t *testing.T) { }) } +func TestAccAzureRMEventGridEventSubscription_advancedFilter(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_eventgrid_event_subscription", "test") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + CheckDestroy: testCheckAzureRMEventGridEventSubscriptionDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMEventGridEventSubscription_advancedFilter(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMEventGridEventSubscriptionExists(data.ResourceName), + resource.TestCheckResourceAttr(data.ResourceName, "advanced_filter_array.0.key", "data.filesite"), + resource.TestCheckResourceAttr(data.ResourceName, "advanced_filter_array.0.operator_type", "NumberLessThan"), + resource.TestCheckResourceAttr(data.ResourceName, "advanced_filter_array.0.value", "42.0"), + resource.TestCheckResourceAttr(data.ResourceName, "advanced_filter_array.1.key", "topic"), + resource.TestCheckResourceAttr(data.ResourceName, "advanced_filter_array.1.operator_type", "StringBeginsWith"), + resource.TestCheckResourceAttr(data.ResourceName, "advanced_filter_array.1.value", "topic_prefix"), + ), + }, + data.ImportStep(), + }, + }) +} + func testCheckAzureRMEventGridEventSubscriptionDestroy(s *terraform.State) error { client := acceptance.AzureProvider.Meta().(*clients.Client).EventGrid.EventSubscriptionsClient ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext @@ -346,7 +434,7 @@ resource "azurerm_eventhub" "test" { resource "azurerm_eventgrid_event_subscription" "test" { name = "acctesteg-%d" scope = azurerm_resource_group.test.id - event_delivery_schema = "CloudEventV01Schema" + event_delivery_schema = "CloudEventSchemaV1_0" eventhub_endpoint { eventhub_id = azurerm_eventhub.test.id @@ -355,6 +443,134 @@ resource "azurerm_eventgrid_event_subscription" "test" { `, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, data.RandomInteger) } +func testAccAzureRMEventGridEventSubscription_serviceBusQueue(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_servicebus_namespace" "example" { + name = "acctestservicebusnamespace-%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + sku = "Basic" +} + +resource "azurerm_servicebus_queue" "test" { + name = "acctestservicebusqueue-%d" + resource_group_name = azurerm_resource_group.test.name + namespace_name = azurerm_servicebus_namespace.example.name + enable_partitioning = true +} + +resource "azurerm_eventgrid_event_subscription" "test" { + name = "acctesteg-%d" + scope = azurerm_resource_group.test.id + event_delivery_schema = "CloudEventSchemaV1_0" + + service_bus_queue_endpoint { + service_bus_queue_id = "${azurerm_servicebus_queue.test.id}" + } +} +`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, data.RandomInteger) +} + +func testAccAzureRMEventGridEventSubscription_serviceBusTopic(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_servicebus_namespace" "example" { + name = "acctestservicebusnamespace-%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + sku = "Basic" +} + +resource "azurerm_servicebus_topic" "test" { + name = "acctestservicebustopic-%d" + resource_group_name = azurerm_resource_group.test.name + namespace_name = azurerm_servicebus_namespace.example.name + enable_partitioning = true +} + +resource "azurerm_eventgrid_event_subscription" "test" { + name = "acctesteg-%d" + scope = azurerm_resource_group.test.id + event_delivery_schema = "CloudEventSchemaV1_0" + + service_bus_topic_endpoint { + service_bus_topic_id = "${azurerm_servicebus_topic.test.id}" + } +} +`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, data.RandomInteger) +} + +func testAccAzureRMEventGridEventSubscription_azureFunction(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_storage_account" "test" { + name = "acctestacc%s" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + account_tier = "Standard" + account_replication_type = "LRS" + + tags = { + environment = "staging" + } +} + +resource "azurerm_app_service_plan" "test" { + name = "acctestASP-%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + + sku { + tier = "Standard" + size = "S1" + } +} + +resource "azurerm_function_app" "test" { + name = "acctest-%d-func" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + app_service_plan_id = azurerm_app_service_plan.test.id + storage_connection_string = azurerm_storage_account.test.primary_connection_string +} + +resource "azurerm_eventgrid_event_subscription" "test" { + name = "acctesteg-%d" + scope = azurerm_resource_group.test.id + event_delivery_schema = "CloudEventSchemaV1_0" + + azure_function_endpoint { + azure_function_id = "${azurerm_function_app.test.id}" + } +} +`, data.RandomInteger, data.Locations.Primary, data.RandomString, data.RandomInteger, data.RandomInteger, data.RandomInteger) +} + func testAccAzureRMEventGridEventSubscription_filter(data acceptance.TestData) string { return fmt.Sprintf(` provider "azurerm" { @@ -401,3 +617,56 @@ resource "azurerm_eventgrid_event_subscription" "test" { } `, data.RandomInteger, data.Locations.Primary, data.RandomString, data.RandomInteger, data.RandomInteger) } + +func testAccAzureRMEventGridEventSubscription_advancedFilter(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_storage_account" "test" { + name = "acctestacc%s" + resource_group_name = "${azurerm_resource_group.test.name}" + location = "${azurerm_resource_group.test.location}" + account_tier = "Standard" + account_replication_type = "LRS" + + tags = { + environment = "staging" + } +} + +resource "azurerm_storage_queue" "test" { + name = "mysamplequeue-%d" + resource_group_name = "${azurerm_resource_group.test.name}" + storage_account_name = "${azurerm_storage_account.test.name}" +} + +resource "azurerm_eventgrid_event_subscription" "test" { + name = "acctesteg-%d" + scope = "${azurerm_resource_group.test.id}" + + storage_queue_endpoint { + storage_account_id = "${azurerm_storage_account.test.id}" + queue_name = "${azurerm_storage_queue.test.name}" + } + + advanced_filter { + key = "data.filesize" + operator_type = "NumberLessThan" + value = 42.0 + } + + advanced_filter { + key = "topic" + operator_type = "StringBeginsWith" + value = ["topic_prefix"] + } +} +`, data.RandomInteger, data.Locations.Primary, data.RandomString, data.RandomInteger, data.RandomInteger) +} diff --git a/azurerm/internal/services/eventgrid/tests/resource_arm_eventgrid_topic_test.go b/azurerm/internal/services/eventgrid/tests/resource_arm_eventgrid_topic_test.go index d2c9873d58bf..23b6e9bcb8d2 100644 --- a/azurerm/internal/services/eventgrid/tests/resource_arm_eventgrid_topic_test.go +++ b/azurerm/internal/services/eventgrid/tests/resource_arm_eventgrid_topic_test.go @@ -56,6 +56,29 @@ func TestAccAzureRMEventGridTopic_requiresImport(t *testing.T) { }) } +func TestAccAzureRMEventGridTopic_mapping(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_eventgrid_topic", "test") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + CheckDestroy: testCheckAzureRMEventGridTopicDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMEventGridTopic_mapping(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMEventGridTopicExists(data.ResourceName), + resource.TestCheckResourceAttr(data.ResourceName, "input_mapping_fields.0.topic", "test"), + resource.TestCheckResourceAttr(data.ResourceName, "input_mapping_fields.0.topic", "test"), + resource.TestCheckResourceAttr(data.ResourceName, "input_mapping_default_values.0.data_version", "1.0"), + resource.TestCheckResourceAttr(data.ResourceName, "input_mapping_default_values.0.subject", "DefaultSubject"), + ), + }, + data.ImportStep(), + }, + }) +} + func TestAccAzureRMEventGridTopic_basicWithTags(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_eventgrid_topic", "test") @@ -174,6 +197,37 @@ resource "azurerm_eventgrid_topic" "import" { `, template) } +func testAccAzureRMEventGridTopic_mapping(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_eventgrid_topic" "test" { + name = "acctesteg-%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + + input_schema = "CustomEventSchema" + + input_mapping_fields { + topic = "test" + event_type = "test" + } + + input_mapping_default_values { + data_version = "1.0" + subject = "DefaultSubject" + } +} +`, data.RandomInteger, data.Locations.Primary, data.RandomInteger) +} + func testAccAzureRMEventGridTopic_basicWithTags(data acceptance.TestData) string { // currently only supported in "West Central US" & "West US 2" location := "westus2" diff --git a/go.sum b/go.sum index 8a5324772e93..2815ca1b83a7 100644 --- a/go.sum +++ b/go.sum @@ -303,6 +303,7 @@ golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBn golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0 h1:Dh6fw+p6FyRl5x/FvNswO1ji0lIGzm3KP8Y9VkS9PTE= golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2018-09-15-preview/eventgrid/domaintopics.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2018-09-15-preview/eventgrid/domaintopics.go deleted file mode 100644 index 0c8b9214eaa8..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2018-09-15-preview/eventgrid/domaintopics.go +++ /dev/null @@ -1,196 +0,0 @@ -package eventgrid - -// 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" -) - -// DomainTopicsClient is the azure EventGrid Management Client -type DomainTopicsClient struct { - BaseClient -} - -// NewDomainTopicsClient creates an instance of the DomainTopicsClient client. -func NewDomainTopicsClient(subscriptionID string) DomainTopicsClient { - return NewDomainTopicsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewDomainTopicsClientWithBaseURI creates an instance of the DomainTopicsClient client using a custom endpoint. Use -// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). -func NewDomainTopicsClientWithBaseURI(baseURI string, subscriptionID string) DomainTopicsClient { - return DomainTopicsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// Get get properties of a domain topic -// Parameters: -// resourceGroupName - the name of the resource group within the user's subscription. -// domainName - name of the domain -// topicName - name of the topic -func (client DomainTopicsClient) Get(ctx context.Context, resourceGroupName string, domainName string, topicName string) (result DomainTopic, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DomainTopicsClient.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, resourceGroupName, domainName, topicName) - if err != nil { - err = autorest.NewErrorWithError(err, "eventgrid.DomainTopicsClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "eventgrid.DomainTopicsClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "eventgrid.DomainTopicsClient", "Get", resp, "Failure responding to request") - } - - return -} - -// GetPreparer prepares the Get request. -func (client DomainTopicsClient) GetPreparer(ctx context.Context, resourceGroupName string, domainName string, topicName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "domainName": autorest.Encode("path", domainName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "topicName": autorest.Encode("path", topicName), - } - - const APIVersion = "2018-09-15-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.EventGrid/domains/{domainName}/topics/{topicName}", 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 DomainTopicsClient) GetSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client DomainTopicsClient) GetResponder(resp *http.Response) (result DomainTopic, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListByDomain list all the topics in a domain. -// Parameters: -// resourceGroupName - the name of the resource group within the user's subscription. -// domainName - domain name. -func (client DomainTopicsClient) ListByDomain(ctx context.Context, resourceGroupName string, domainName string) (result DomainTopicsListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DomainTopicsClient.ListByDomain") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.ListByDomainPreparer(ctx, resourceGroupName, domainName) - if err != nil { - err = autorest.NewErrorWithError(err, "eventgrid.DomainTopicsClient", "ListByDomain", nil, "Failure preparing request") - return - } - - resp, err := client.ListByDomainSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "eventgrid.DomainTopicsClient", "ListByDomain", resp, "Failure sending request") - return - } - - result, err = client.ListByDomainResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "eventgrid.DomainTopicsClient", "ListByDomain", resp, "Failure responding to request") - } - - return -} - -// ListByDomainPreparer prepares the ListByDomain request. -func (client DomainTopicsClient) ListByDomainPreparer(ctx context.Context, resourceGroupName string, domainName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "domainName": autorest.Encode("path", domainName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2018-09-15-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.EventGrid/domains/{domainName}/topics", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListByDomainSender sends the ListByDomain request. The method will close the -// http.Response Body if it receives an error. -func (client DomainTopicsClient) ListByDomainSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListByDomainResponder handles the response to the ListByDomain request. The method always -// closes the http.Response Body. -func (client DomainTopicsClient) ListByDomainResponder(resp *http.Response) (result DomainTopicsListResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2018-09-15-preview/eventgrid/client.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2020-01-01-preview/eventgrid/client.go similarity index 98% rename from vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2018-09-15-preview/eventgrid/client.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2020-01-01-preview/eventgrid/client.go index 05818ba810a5..d833cff0d58d 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2018-09-15-preview/eventgrid/client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2020-01-01-preview/eventgrid/client.go @@ -1,4 +1,4 @@ -// Package eventgrid implements the Azure ARM Eventgrid service API version 2018-09-15-preview. +// Package eventgrid implements the Azure ARM Eventgrid service API version 2020-01-01-preview. // // Azure EventGrid Management Client package eventgrid diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2018-09-15-preview/eventgrid/domains.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2020-01-01-preview/eventgrid/domains.go similarity index 79% rename from vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2018-09-15-preview/eventgrid/domains.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2020-01-01-preview/eventgrid/domains.go index 1dbd761b7bfa..a3886ed406fc 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2018-09-15-preview/eventgrid/domains.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2020-01-01-preview/eventgrid/domains.go @@ -42,7 +42,7 @@ func NewDomainsClientWithBaseURI(baseURI string, subscriptionID string) DomainsC return DomainsClient{NewWithBaseURI(baseURI, subscriptionID)} } -// CreateOrUpdate asynchronously creates a new domain with the specified parameters. +// CreateOrUpdate asynchronously creates or updates a new domain with the specified parameters. // Parameters: // resourceGroupName - the name of the resource group within the user's subscription. // domainName - name of the domain @@ -81,7 +81,7 @@ func (client DomainsClient) CreateOrUpdatePreparer(ctx context.Context, resource "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2018-09-15-preview" + const APIVersion = "2020-01-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -159,7 +159,7 @@ func (client DomainsClient) DeletePreparer(ctx context.Context, resourceGroupNam "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2018-09-15-preview" + const APIVersion = "2020-01-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -240,7 +240,7 @@ func (client DomainsClient) GetPreparer(ctx context.Context, resourceGroupName s "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2018-09-15-preview" + const APIVersion = "2020-01-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -275,18 +275,27 @@ func (client DomainsClient) GetResponder(resp *http.Response) (result Domain, er // ListByResourceGroup list all the domains under a resource group // Parameters: // resourceGroupName - the name of the resource group within the user's subscription. -func (client DomainsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result DomainsListResult, err error) { +// filter - the query used to filter the search results using OData syntax. Filtering is permitted on the +// 'name' property only and with limited number of OData operations. These operations are: the 'contains' +// function as well as the following logical operations: not, and, or, eq (for equal), and ne (for not equal). +// No arithmetic operations are supported. The following is a valid filter example: $filter=contains(namE, +// 'PATTERN') and name ne 'PATTERN-1'. The following is not a valid filter example: $filter=location eq +// 'westus'. +// top - the number of results to return per page for the list operation. Valid range for top parameter is 1 to +// 100. If not specified, the default number of results to be returned is 20 items per page. +func (client DomainsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, filter string, top *int32) (result DomainsListResultPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/DomainsClient.ListByResourceGroup") defer func() { sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode + if result.dlr.Response.Response != nil { + sc = result.dlr.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() } - req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName, filter, top) if err != nil { err = autorest.NewErrorWithError(err, "eventgrid.DomainsClient", "ListByResourceGroup", nil, "Failure preparing request") return @@ -294,12 +303,12 @@ func (client DomainsClient) ListByResourceGroup(ctx context.Context, resourceGro resp, err := client.ListByResourceGroupSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.dlr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "eventgrid.DomainsClient", "ListByResourceGroup", resp, "Failure sending request") return } - result, err = client.ListByResourceGroupResponder(resp) + result.dlr, err = client.ListByResourceGroupResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "eventgrid.DomainsClient", "ListByResourceGroup", resp, "Failure responding to request") } @@ -308,16 +317,22 @@ func (client DomainsClient) ListByResourceGroup(ctx context.Context, resourceGro } // ListByResourceGroupPreparer prepares the ListByResourceGroup request. -func (client DomainsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { +func (client DomainsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string, filter string, top *int32) (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2018-09-15-preview" + const APIVersion = "2020-01-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } preparer := autorest.CreatePreparer( autorest.AsGet(), @@ -346,19 +361,66 @@ func (client DomainsClient) ListByResourceGroupResponder(resp *http.Response) (r return } +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client DomainsClient) listByResourceGroupNextResults(ctx context.Context, lastResults DomainsListResult) (result DomainsListResult, err error) { + req, err := lastResults.domainsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "eventgrid.DomainsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "eventgrid.DomainsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "eventgrid.DomainsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client DomainsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string, filter string, top *int32) (result DomainsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DomainsClient.ListByResourceGroup") + 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.ListByResourceGroup(ctx, resourceGroupName, filter, top) + return +} + // ListBySubscription list all the domains under an Azure subscription -func (client DomainsClient) ListBySubscription(ctx context.Context) (result DomainsListResult, err error) { +// Parameters: +// filter - the query used to filter the search results using OData syntax. Filtering is permitted on the +// 'name' property only and with limited number of OData operations. These operations are: the 'contains' +// function as well as the following logical operations: not, and, or, eq (for equal), and ne (for not equal). +// No arithmetic operations are supported. The following is a valid filter example: $filter=contains(namE, +// 'PATTERN') and name ne 'PATTERN-1'. The following is not a valid filter example: $filter=location eq +// 'westus'. +// top - the number of results to return per page for the list operation. Valid range for top parameter is 1 to +// 100. If not specified, the default number of results to be returned is 20 items per page. +func (client DomainsClient) ListBySubscription(ctx context.Context, filter string, top *int32) (result DomainsListResultPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/DomainsClient.ListBySubscription") defer func() { sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode + if result.dlr.Response.Response != nil { + sc = result.dlr.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() } - req, err := client.ListBySubscriptionPreparer(ctx) + result.fn = client.listBySubscriptionNextResults + req, err := client.ListBySubscriptionPreparer(ctx, filter, top) if err != nil { err = autorest.NewErrorWithError(err, "eventgrid.DomainsClient", "ListBySubscription", nil, "Failure preparing request") return @@ -366,12 +428,12 @@ func (client DomainsClient) ListBySubscription(ctx context.Context) (result Doma resp, err := client.ListBySubscriptionSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.dlr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "eventgrid.DomainsClient", "ListBySubscription", resp, "Failure sending request") return } - result, err = client.ListBySubscriptionResponder(resp) + result.dlr, err = client.ListBySubscriptionResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "eventgrid.DomainsClient", "ListBySubscription", resp, "Failure responding to request") } @@ -380,15 +442,21 @@ func (client DomainsClient) ListBySubscription(ctx context.Context) (result Doma } // ListBySubscriptionPreparer prepares the ListBySubscription request. -func (client DomainsClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { +func (client DomainsClient) ListBySubscriptionPreparer(ctx context.Context, filter string, top *int32) (*http.Request, error) { pathParameters := map[string]interface{}{ "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2018-09-15-preview" + const APIVersion = "2020-01-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } preparer := autorest.CreatePreparer( autorest.AsGet(), @@ -417,6 +485,43 @@ func (client DomainsClient) ListBySubscriptionResponder(resp *http.Response) (re return } +// listBySubscriptionNextResults retrieves the next set of results, if any. +func (client DomainsClient) listBySubscriptionNextResults(ctx context.Context, lastResults DomainsListResult) (result DomainsListResult, err error) { + req, err := lastResults.domainsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "eventgrid.DomainsClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "eventgrid.DomainsClient", "listBySubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "eventgrid.DomainsClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client DomainsClient) ListBySubscriptionComplete(ctx context.Context, filter string, top *int32) (result DomainsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DomainsClient.ListBySubscription") + 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.ListBySubscription(ctx, filter, top) + return +} + // ListSharedAccessKeys list the two keys used to publish to a domain // Parameters: // resourceGroupName - the name of the resource group within the user's subscription. @@ -461,7 +566,7 @@ func (client DomainsClient) ListSharedAccessKeysPreparer(ctx context.Context, re "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2018-09-15-preview" + const APIVersion = "2020-01-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -544,7 +649,7 @@ func (client DomainsClient) RegenerateKeyPreparer(ctx context.Context, resourceG "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2018-09-15-preview" + const APIVersion = "2020-01-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -617,7 +722,7 @@ func (client DomainsClient) UpdatePreparer(ctx context.Context, resourceGroupNam "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2018-09-15-preview" + const APIVersion = "2020-01-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2020-01-01-preview/eventgrid/domaintopics.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2020-01-01-preview/eventgrid/domaintopics.go new file mode 100644 index 000000000000..d0547fb51334 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2020-01-01-preview/eventgrid/domaintopics.go @@ -0,0 +1,403 @@ +package eventgrid + +// 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" +) + +// DomainTopicsClient is the azure EventGrid Management Client +type DomainTopicsClient struct { + BaseClient +} + +// NewDomainTopicsClient creates an instance of the DomainTopicsClient client. +func NewDomainTopicsClient(subscriptionID string) DomainTopicsClient { + return NewDomainTopicsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDomainTopicsClientWithBaseURI creates an instance of the DomainTopicsClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewDomainTopicsClientWithBaseURI(baseURI string, subscriptionID string) DomainTopicsClient { + return DomainTopicsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate asynchronously creates or updates a new domain topic with the specified parameters. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. +// domainName - name of the domain +// domainTopicName - name of the domain topic +func (client DomainTopicsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, domainName string, domainTopicName string) (result DomainTopicsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DomainTopicsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, domainName, domainTopicName) + if err != nil { + err = autorest.NewErrorWithError(err, "eventgrid.DomainTopicsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "eventgrid.DomainTopicsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DomainTopicsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, domainName string, domainTopicName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "domainName": autorest.Encode("path", domainName), + "domainTopicName": autorest.Encode("path", domainTopicName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{domainTopicName}", pathParameters), + 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 DomainTopicsClient) CreateOrUpdateSender(req *http.Request) (future DomainTopicsCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DomainTopicsClient) CreateOrUpdateResponder(resp *http.Response) (result DomainTopic, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete existing domain topic +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. +// domainName - name of the domain +// domainTopicName - name of the domain topic +func (client DomainTopicsClient) Delete(ctx context.Context, resourceGroupName string, domainName string, domainTopicName string) (result DomainTopicsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DomainTopicsClient.Delete") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, domainName, domainTopicName) + if err != nil { + err = autorest.NewErrorWithError(err, "eventgrid.DomainTopicsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "eventgrid.DomainTopicsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client DomainTopicsClient) DeletePreparer(ctx context.Context, resourceGroupName string, domainName string, domainTopicName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "domainName": autorest.Encode("path", domainName), + "domainTopicName": autorest.Encode("path", domainTopicName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{domainTopicName}", 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 DomainTopicsClient) DeleteSender(req *http.Request) (future DomainTopicsDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DomainTopicsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get properties of a domain topic +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. +// domainName - name of the domain +// domainTopicName - name of the topic +func (client DomainTopicsClient) Get(ctx context.Context, resourceGroupName string, domainName string, domainTopicName string) (result DomainTopic, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DomainTopicsClient.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, resourceGroupName, domainName, domainTopicName) + if err != nil { + err = autorest.NewErrorWithError(err, "eventgrid.DomainTopicsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "eventgrid.DomainTopicsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "eventgrid.DomainTopicsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client DomainTopicsClient) GetPreparer(ctx context.Context, resourceGroupName string, domainName string, domainTopicName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "domainName": autorest.Encode("path", domainName), + "domainTopicName": autorest.Encode("path", domainTopicName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-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.EventGrid/domains/{domainName}/topics/{domainTopicName}", 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 DomainTopicsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DomainTopicsClient) GetResponder(resp *http.Response) (result DomainTopic, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDomain list all the topics in a domain. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. +// domainName - domain name. +// filter - the query used to filter the search results using OData syntax. Filtering is permitted on the +// 'name' property only and with limited number of OData operations. These operations are: the 'contains' +// function as well as the following logical operations: not, and, or, eq (for equal), and ne (for not equal). +// No arithmetic operations are supported. The following is a valid filter example: $filter=contains(namE, +// 'PATTERN') and name ne 'PATTERN-1'. The following is not a valid filter example: $filter=location eq +// 'westus'. +// top - the number of results to return per page for the list operation. Valid range for top parameter is 1 to +// 100. If not specified, the default number of results to be returned is 20 items per page. +func (client DomainTopicsClient) ListByDomain(ctx context.Context, resourceGroupName string, domainName string, filter string, top *int32) (result DomainTopicsListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DomainTopicsClient.ListByDomain") + defer func() { + sc := -1 + if result.dtlr.Response.Response != nil { + sc = result.dtlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDomainNextResults + req, err := client.ListByDomainPreparer(ctx, resourceGroupName, domainName, filter, top) + if err != nil { + err = autorest.NewErrorWithError(err, "eventgrid.DomainTopicsClient", "ListByDomain", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDomainSender(req) + if err != nil { + result.dtlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "eventgrid.DomainTopicsClient", "ListByDomain", resp, "Failure sending request") + return + } + + result.dtlr, err = client.ListByDomainResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "eventgrid.DomainTopicsClient", "ListByDomain", resp, "Failure responding to request") + } + + return +} + +// ListByDomainPreparer prepares the ListByDomain request. +func (client DomainTopicsClient) ListByDomainPreparer(ctx context.Context, resourceGroupName string, domainName string, filter string, top *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "domainName": autorest.Encode("path", domainName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDomainSender sends the ListByDomain request. The method will close the +// http.Response Body if it receives an error. +func (client DomainTopicsClient) ListByDomainSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDomainResponder handles the response to the ListByDomain request. The method always +// closes the http.Response Body. +func (client DomainTopicsClient) ListByDomainResponder(resp *http.Response) (result DomainTopicsListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDomainNextResults retrieves the next set of results, if any. +func (client DomainTopicsClient) listByDomainNextResults(ctx context.Context, lastResults DomainTopicsListResult) (result DomainTopicsListResult, err error) { + req, err := lastResults.domainTopicsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "eventgrid.DomainTopicsClient", "listByDomainNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByDomainSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "eventgrid.DomainTopicsClient", "listByDomainNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDomainResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "eventgrid.DomainTopicsClient", "listByDomainNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDomainComplete enumerates all values, automatically crossing page boundaries as required. +func (client DomainTopicsClient) ListByDomainComplete(ctx context.Context, resourceGroupName string, domainName string, filter string, top *int32) (result DomainTopicsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DomainTopicsClient.ListByDomain") + 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.ListByDomain(ctx, resourceGroupName, domainName, filter, top) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2018-09-15-preview/eventgrid/eventsubscriptions.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2020-01-01-preview/eventgrid/eventsubscriptions.go similarity index 60% rename from vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2018-09-15-preview/eventgrid/eventsubscriptions.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2020-01-01-preview/eventgrid/eventsubscriptions.go index a3ade990e8c7..58f796738446 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2018-09-15-preview/eventgrid/eventsubscriptions.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2020-01-01-preview/eventgrid/eventsubscriptions.go @@ -89,7 +89,7 @@ func (client EventSubscriptionsClient) CreateOrUpdatePreparer(ctx context.Contex "scope": scope, } - const APIVersion = "2018-09-15-preview" + const APIVersion = "2020-01-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -173,7 +173,7 @@ func (client EventSubscriptionsClient) DeletePreparer(ctx context.Context, scope "scope": scope, } - const APIVersion = "2018-09-15-preview" + const APIVersion = "2020-01-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -260,7 +260,7 @@ func (client EventSubscriptionsClient) GetPreparer(ctx context.Context, scope st "scope": scope, } - const APIVersion = "2018-09-15-preview" + const APIVersion = "2020-01-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -342,7 +342,7 @@ func (client EventSubscriptionsClient) GetFullURLPreparer(ctx context.Context, s "scope": scope, } - const APIVersion = "2018-09-15-preview" + const APIVersion = "2020-01-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -379,18 +379,27 @@ func (client EventSubscriptionsClient) GetFullURLResponder(resp *http.Response) // resourceGroupName - the name of the resource group within the user's subscription. // domainName - name of the top level domain // topicName - name of the domain topic -func (client EventSubscriptionsClient) ListByDomainTopic(ctx context.Context, resourceGroupName string, domainName string, topicName string) (result EventSubscriptionsListResult, err error) { +// filter - the query used to filter the search results using OData syntax. Filtering is permitted on the +// 'name' property only and with limited number of OData operations. These operations are: the 'contains' +// function as well as the following logical operations: not, and, or, eq (for equal), and ne (for not equal). +// No arithmetic operations are supported. The following is a valid filter example: $filter=contains(namE, +// 'PATTERN') and name ne 'PATTERN-1'. The following is not a valid filter example: $filter=location eq +// 'westus'. +// top - the number of results to return per page for the list operation. Valid range for top parameter is 1 to +// 100. If not specified, the default number of results to be returned is 20 items per page. +func (client EventSubscriptionsClient) ListByDomainTopic(ctx context.Context, resourceGroupName string, domainName string, topicName string, filter string, top *int32) (result EventSubscriptionsListResultPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListByDomainTopic") defer func() { sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode + if result.eslr.Response.Response != nil { + sc = result.eslr.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() } - req, err := client.ListByDomainTopicPreparer(ctx, resourceGroupName, domainName, topicName) + result.fn = client.listByDomainTopicNextResults + req, err := client.ListByDomainTopicPreparer(ctx, resourceGroupName, domainName, topicName, filter, top) if err != nil { err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListByDomainTopic", nil, "Failure preparing request") return @@ -398,12 +407,12 @@ func (client EventSubscriptionsClient) ListByDomainTopic(ctx context.Context, re resp, err := client.ListByDomainTopicSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.eslr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListByDomainTopic", resp, "Failure sending request") return } - result, err = client.ListByDomainTopicResponder(resp) + result.eslr, err = client.ListByDomainTopicResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListByDomainTopic", resp, "Failure responding to request") } @@ -412,7 +421,7 @@ func (client EventSubscriptionsClient) ListByDomainTopic(ctx context.Context, re } // ListByDomainTopicPreparer prepares the ListByDomainTopic request. -func (client EventSubscriptionsClient) ListByDomainTopicPreparer(ctx context.Context, resourceGroupName string, domainName string, topicName string) (*http.Request, error) { +func (client EventSubscriptionsClient) ListByDomainTopicPreparer(ctx context.Context, resourceGroupName string, domainName string, topicName string, filter string, top *int32) (*http.Request, error) { pathParameters := map[string]interface{}{ "domainName": autorest.Encode("path", domainName), "resourceGroupName": autorest.Encode("path", resourceGroupName), @@ -420,10 +429,16 @@ func (client EventSubscriptionsClient) ListByDomainTopicPreparer(ctx context.Con "topicName": autorest.Encode("path", topicName), } - const APIVersion = "2018-09-15-preview" + const APIVersion = "2020-01-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } preparer := autorest.CreatePreparer( autorest.AsGet(), @@ -452,24 +467,70 @@ func (client EventSubscriptionsClient) ListByDomainTopicResponder(resp *http.Res return } +// listByDomainTopicNextResults retrieves the next set of results, if any. +func (client EventSubscriptionsClient) listByDomainTopicNextResults(ctx context.Context, lastResults EventSubscriptionsListResult) (result EventSubscriptionsListResult, err error) { + req, err := lastResults.eventSubscriptionsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listByDomainTopicNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByDomainTopicSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listByDomainTopicNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDomainTopicResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listByDomainTopicNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDomainTopicComplete enumerates all values, automatically crossing page boundaries as required. +func (client EventSubscriptionsClient) ListByDomainTopicComplete(ctx context.Context, resourceGroupName string, domainName string, topicName string, filter string, top *int32) (result EventSubscriptionsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListByDomainTopic") + 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.ListByDomainTopic(ctx, resourceGroupName, domainName, topicName, filter, top) + return +} + // ListByResource list all event subscriptions that have been created for a specific topic // Parameters: // resourceGroupName - the name of the resource group within the user's subscription. // providerNamespace - namespace of the provider of the topic // resourceTypeName - name of the resource type // resourceName - name of the resource -func (client EventSubscriptionsClient) ListByResource(ctx context.Context, resourceGroupName string, providerNamespace string, resourceTypeName string, resourceName string) (result EventSubscriptionsListResult, err error) { +// filter - the query used to filter the search results using OData syntax. Filtering is permitted on the +// 'name' property only and with limited number of OData operations. These operations are: the 'contains' +// function as well as the following logical operations: not, and, or, eq (for equal), and ne (for not equal). +// No arithmetic operations are supported. The following is a valid filter example: $filter=contains(namE, +// 'PATTERN') and name ne 'PATTERN-1'. The following is not a valid filter example: $filter=location eq +// 'westus'. +// top - the number of results to return per page for the list operation. Valid range for top parameter is 1 to +// 100. If not specified, the default number of results to be returned is 20 items per page. +func (client EventSubscriptionsClient) ListByResource(ctx context.Context, resourceGroupName string, providerNamespace string, resourceTypeName string, resourceName string, filter string, top *int32) (result EventSubscriptionsListResultPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListByResource") defer func() { sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode + if result.eslr.Response.Response != nil { + sc = result.eslr.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() } - req, err := client.ListByResourcePreparer(ctx, resourceGroupName, providerNamespace, resourceTypeName, resourceName) + result.fn = client.listByResourceNextResults + req, err := client.ListByResourcePreparer(ctx, resourceGroupName, providerNamespace, resourceTypeName, resourceName, filter, top) if err != nil { err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListByResource", nil, "Failure preparing request") return @@ -477,12 +538,12 @@ func (client EventSubscriptionsClient) ListByResource(ctx context.Context, resou resp, err := client.ListByResourceSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.eslr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListByResource", resp, "Failure sending request") return } - result, err = client.ListByResourceResponder(resp) + result.eslr, err = client.ListByResourceResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListByResource", resp, "Failure responding to request") } @@ -491,7 +552,7 @@ func (client EventSubscriptionsClient) ListByResource(ctx context.Context, resou } // ListByResourcePreparer prepares the ListByResource request. -func (client EventSubscriptionsClient) ListByResourcePreparer(ctx context.Context, resourceGroupName string, providerNamespace string, resourceTypeName string, resourceName string) (*http.Request, error) { +func (client EventSubscriptionsClient) ListByResourcePreparer(ctx context.Context, resourceGroupName string, providerNamespace string, resourceTypeName string, resourceName string, filter string, top *int32) (*http.Request, error) { pathParameters := map[string]interface{}{ "providerNamespace": autorest.Encode("path", providerNamespace), "resourceGroupName": autorest.Encode("path", resourceGroupName), @@ -500,10 +561,16 @@ func (client EventSubscriptionsClient) ListByResourcePreparer(ctx context.Contex "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2018-09-15-preview" + const APIVersion = "2020-01-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } preparer := autorest.CreatePreparer( autorest.AsGet(), @@ -532,21 +599,67 @@ func (client EventSubscriptionsClient) ListByResourceResponder(resp *http.Respon return } +// listByResourceNextResults retrieves the next set of results, if any. +func (client EventSubscriptionsClient) listByResourceNextResults(ctx context.Context, lastResults EventSubscriptionsListResult) (result EventSubscriptionsListResult, err error) { + req, err := lastResults.eventSubscriptionsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listByResourceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listByResourceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listByResourceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceComplete enumerates all values, automatically crossing page boundaries as required. +func (client EventSubscriptionsClient) ListByResourceComplete(ctx context.Context, resourceGroupName string, providerNamespace string, resourceTypeName string, resourceName string, filter string, top *int32) (result EventSubscriptionsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListByResource") + 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.ListByResource(ctx, resourceGroupName, providerNamespace, resourceTypeName, resourceName, filter, top) + return +} + // ListGlobalByResourceGroup list all global event subscriptions under a specific Azure subscription and resource group // Parameters: // resourceGroupName - the name of the resource group within the user's subscription. -func (client EventSubscriptionsClient) ListGlobalByResourceGroup(ctx context.Context, resourceGroupName string) (result EventSubscriptionsListResult, err error) { +// filter - the query used to filter the search results using OData syntax. Filtering is permitted on the +// 'name' property only and with limited number of OData operations. These operations are: the 'contains' +// function as well as the following logical operations: not, and, or, eq (for equal), and ne (for not equal). +// No arithmetic operations are supported. The following is a valid filter example: $filter=contains(namE, +// 'PATTERN') and name ne 'PATTERN-1'. The following is not a valid filter example: $filter=location eq +// 'westus'. +// top - the number of results to return per page for the list operation. Valid range for top parameter is 1 to +// 100. If not specified, the default number of results to be returned is 20 items per page. +func (client EventSubscriptionsClient) ListGlobalByResourceGroup(ctx context.Context, resourceGroupName string, filter string, top *int32) (result EventSubscriptionsListResultPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListGlobalByResourceGroup") defer func() { sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode + if result.eslr.Response.Response != nil { + sc = result.eslr.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() } - req, err := client.ListGlobalByResourceGroupPreparer(ctx, resourceGroupName) + result.fn = client.listGlobalByResourceGroupNextResults + req, err := client.ListGlobalByResourceGroupPreparer(ctx, resourceGroupName, filter, top) if err != nil { err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalByResourceGroup", nil, "Failure preparing request") return @@ -554,12 +667,12 @@ func (client EventSubscriptionsClient) ListGlobalByResourceGroup(ctx context.Con resp, err := client.ListGlobalByResourceGroupSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.eslr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalByResourceGroup", resp, "Failure sending request") return } - result, err = client.ListGlobalByResourceGroupResponder(resp) + result.eslr, err = client.ListGlobalByResourceGroupResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalByResourceGroup", resp, "Failure responding to request") } @@ -568,16 +681,22 @@ func (client EventSubscriptionsClient) ListGlobalByResourceGroup(ctx context.Con } // ListGlobalByResourceGroupPreparer prepares the ListGlobalByResourceGroup request. -func (client EventSubscriptionsClient) ListGlobalByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { +func (client EventSubscriptionsClient) ListGlobalByResourceGroupPreparer(ctx context.Context, resourceGroupName string, filter string, top *int32) (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2018-09-15-preview" + const APIVersion = "2020-01-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } preparer := autorest.CreatePreparer( autorest.AsGet(), @@ -606,23 +725,69 @@ func (client EventSubscriptionsClient) ListGlobalByResourceGroupResponder(resp * return } +// listGlobalByResourceGroupNextResults retrieves the next set of results, if any. +func (client EventSubscriptionsClient) listGlobalByResourceGroupNextResults(ctx context.Context, lastResults EventSubscriptionsListResult) (result EventSubscriptionsListResult, err error) { + req, err := lastResults.eventSubscriptionsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listGlobalByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListGlobalByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listGlobalByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListGlobalByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listGlobalByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListGlobalByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client EventSubscriptionsClient) ListGlobalByResourceGroupComplete(ctx context.Context, resourceGroupName string, filter string, top *int32) (result EventSubscriptionsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListGlobalByResourceGroup") + 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.ListGlobalByResourceGroup(ctx, resourceGroupName, filter, top) + return +} + // ListGlobalByResourceGroupForTopicType list all global event subscriptions under a resource group for a specific // topic type. // Parameters: // resourceGroupName - the name of the resource group within the user's subscription. // topicTypeName - name of the topic type -func (client EventSubscriptionsClient) ListGlobalByResourceGroupForTopicType(ctx context.Context, resourceGroupName string, topicTypeName string) (result EventSubscriptionsListResult, err error) { +// filter - the query used to filter the search results using OData syntax. Filtering is permitted on the +// 'name' property only and with limited number of OData operations. These operations are: the 'contains' +// function as well as the following logical operations: not, and, or, eq (for equal), and ne (for not equal). +// No arithmetic operations are supported. The following is a valid filter example: $filter=contains(namE, +// 'PATTERN') and name ne 'PATTERN-1'. The following is not a valid filter example: $filter=location eq +// 'westus'. +// top - the number of results to return per page for the list operation. Valid range for top parameter is 1 to +// 100. If not specified, the default number of results to be returned is 20 items per page. +func (client EventSubscriptionsClient) ListGlobalByResourceGroupForTopicType(ctx context.Context, resourceGroupName string, topicTypeName string, filter string, top *int32) (result EventSubscriptionsListResultPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListGlobalByResourceGroupForTopicType") defer func() { sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode + if result.eslr.Response.Response != nil { + sc = result.eslr.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() } - req, err := client.ListGlobalByResourceGroupForTopicTypePreparer(ctx, resourceGroupName, topicTypeName) + result.fn = client.listGlobalByResourceGroupForTopicTypeNextResults + req, err := client.ListGlobalByResourceGroupForTopicTypePreparer(ctx, resourceGroupName, topicTypeName, filter, top) if err != nil { err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalByResourceGroupForTopicType", nil, "Failure preparing request") return @@ -630,12 +795,12 @@ func (client EventSubscriptionsClient) ListGlobalByResourceGroupForTopicType(ctx resp, err := client.ListGlobalByResourceGroupForTopicTypeSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.eslr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalByResourceGroupForTopicType", resp, "Failure sending request") return } - result, err = client.ListGlobalByResourceGroupForTopicTypeResponder(resp) + result.eslr, err = client.ListGlobalByResourceGroupForTopicTypeResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalByResourceGroupForTopicType", resp, "Failure responding to request") } @@ -644,17 +809,23 @@ func (client EventSubscriptionsClient) ListGlobalByResourceGroupForTopicType(ctx } // ListGlobalByResourceGroupForTopicTypePreparer prepares the ListGlobalByResourceGroupForTopicType request. -func (client EventSubscriptionsClient) ListGlobalByResourceGroupForTopicTypePreparer(ctx context.Context, resourceGroupName string, topicTypeName string) (*http.Request, error) { +func (client EventSubscriptionsClient) ListGlobalByResourceGroupForTopicTypePreparer(ctx context.Context, resourceGroupName string, topicTypeName string, filter string, top *int32) (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), "topicTypeName": autorest.Encode("path", topicTypeName), } - const APIVersion = "2018-09-15-preview" + const APIVersion = "2020-01-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } preparer := autorest.CreatePreparer( autorest.AsGet(), @@ -683,19 +854,66 @@ func (client EventSubscriptionsClient) ListGlobalByResourceGroupForTopicTypeResp return } +// listGlobalByResourceGroupForTopicTypeNextResults retrieves the next set of results, if any. +func (client EventSubscriptionsClient) listGlobalByResourceGroupForTopicTypeNextResults(ctx context.Context, lastResults EventSubscriptionsListResult) (result EventSubscriptionsListResult, err error) { + req, err := lastResults.eventSubscriptionsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listGlobalByResourceGroupForTopicTypeNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListGlobalByResourceGroupForTopicTypeSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listGlobalByResourceGroupForTopicTypeNextResults", resp, "Failure sending next results request") + } + result, err = client.ListGlobalByResourceGroupForTopicTypeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listGlobalByResourceGroupForTopicTypeNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListGlobalByResourceGroupForTopicTypeComplete enumerates all values, automatically crossing page boundaries as required. +func (client EventSubscriptionsClient) ListGlobalByResourceGroupForTopicTypeComplete(ctx context.Context, resourceGroupName string, topicTypeName string, filter string, top *int32) (result EventSubscriptionsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListGlobalByResourceGroupForTopicType") + 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.ListGlobalByResourceGroupForTopicType(ctx, resourceGroupName, topicTypeName, filter, top) + return +} + // ListGlobalBySubscription list all aggregated global event subscriptions under a specific Azure subscription -func (client EventSubscriptionsClient) ListGlobalBySubscription(ctx context.Context) (result EventSubscriptionsListResult, err error) { +// Parameters: +// filter - the query used to filter the search results using OData syntax. Filtering is permitted on the +// 'name' property only and with limited number of OData operations. These operations are: the 'contains' +// function as well as the following logical operations: not, and, or, eq (for equal), and ne (for not equal). +// No arithmetic operations are supported. The following is a valid filter example: $filter=contains(namE, +// 'PATTERN') and name ne 'PATTERN-1'. The following is not a valid filter example: $filter=location eq +// 'westus'. +// top - the number of results to return per page for the list operation. Valid range for top parameter is 1 to +// 100. If not specified, the default number of results to be returned is 20 items per page. +func (client EventSubscriptionsClient) ListGlobalBySubscription(ctx context.Context, filter string, top *int32) (result EventSubscriptionsListResultPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListGlobalBySubscription") defer func() { sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode + if result.eslr.Response.Response != nil { + sc = result.eslr.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() } - req, err := client.ListGlobalBySubscriptionPreparer(ctx) + result.fn = client.listGlobalBySubscriptionNextResults + req, err := client.ListGlobalBySubscriptionPreparer(ctx, filter, top) if err != nil { err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalBySubscription", nil, "Failure preparing request") return @@ -703,12 +921,12 @@ func (client EventSubscriptionsClient) ListGlobalBySubscription(ctx context.Cont resp, err := client.ListGlobalBySubscriptionSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.eslr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalBySubscription", resp, "Failure sending request") return } - result, err = client.ListGlobalBySubscriptionResponder(resp) + result.eslr, err = client.ListGlobalBySubscriptionResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalBySubscription", resp, "Failure responding to request") } @@ -717,15 +935,21 @@ func (client EventSubscriptionsClient) ListGlobalBySubscription(ctx context.Cont } // ListGlobalBySubscriptionPreparer prepares the ListGlobalBySubscription request. -func (client EventSubscriptionsClient) ListGlobalBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { +func (client EventSubscriptionsClient) ListGlobalBySubscriptionPreparer(ctx context.Context, filter string, top *int32) (*http.Request, error) { pathParameters := map[string]interface{}{ "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2018-09-15-preview" + const APIVersion = "2020-01-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } preparer := autorest.CreatePreparer( autorest.AsGet(), @@ -754,22 +978,68 @@ func (client EventSubscriptionsClient) ListGlobalBySubscriptionResponder(resp *h return } +// listGlobalBySubscriptionNextResults retrieves the next set of results, if any. +func (client EventSubscriptionsClient) listGlobalBySubscriptionNextResults(ctx context.Context, lastResults EventSubscriptionsListResult) (result EventSubscriptionsListResult, err error) { + req, err := lastResults.eventSubscriptionsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listGlobalBySubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListGlobalBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listGlobalBySubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListGlobalBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listGlobalBySubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListGlobalBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client EventSubscriptionsClient) ListGlobalBySubscriptionComplete(ctx context.Context, filter string, top *int32) (result EventSubscriptionsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListGlobalBySubscription") + 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.ListGlobalBySubscription(ctx, filter, top) + return +} + // ListGlobalBySubscriptionForTopicType list all global event subscriptions under an Azure subscription for a topic // type. // Parameters: // topicTypeName - name of the topic type -func (client EventSubscriptionsClient) ListGlobalBySubscriptionForTopicType(ctx context.Context, topicTypeName string) (result EventSubscriptionsListResult, err error) { +// filter - the query used to filter the search results using OData syntax. Filtering is permitted on the +// 'name' property only and with limited number of OData operations. These operations are: the 'contains' +// function as well as the following logical operations: not, and, or, eq (for equal), and ne (for not equal). +// No arithmetic operations are supported. The following is a valid filter example: $filter=contains(namE, +// 'PATTERN') and name ne 'PATTERN-1'. The following is not a valid filter example: $filter=location eq +// 'westus'. +// top - the number of results to return per page for the list operation. Valid range for top parameter is 1 to +// 100. If not specified, the default number of results to be returned is 20 items per page. +func (client EventSubscriptionsClient) ListGlobalBySubscriptionForTopicType(ctx context.Context, topicTypeName string, filter string, top *int32) (result EventSubscriptionsListResultPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListGlobalBySubscriptionForTopicType") defer func() { sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode + if result.eslr.Response.Response != nil { + sc = result.eslr.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() } - req, err := client.ListGlobalBySubscriptionForTopicTypePreparer(ctx, topicTypeName) + result.fn = client.listGlobalBySubscriptionForTopicTypeNextResults + req, err := client.ListGlobalBySubscriptionForTopicTypePreparer(ctx, topicTypeName, filter, top) if err != nil { err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalBySubscriptionForTopicType", nil, "Failure preparing request") return @@ -777,12 +1047,12 @@ func (client EventSubscriptionsClient) ListGlobalBySubscriptionForTopicType(ctx resp, err := client.ListGlobalBySubscriptionForTopicTypeSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.eslr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalBySubscriptionForTopicType", resp, "Failure sending request") return } - result, err = client.ListGlobalBySubscriptionForTopicTypeResponder(resp) + result.eslr, err = client.ListGlobalBySubscriptionForTopicTypeResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalBySubscriptionForTopicType", resp, "Failure responding to request") } @@ -791,16 +1061,22 @@ func (client EventSubscriptionsClient) ListGlobalBySubscriptionForTopicType(ctx } // ListGlobalBySubscriptionForTopicTypePreparer prepares the ListGlobalBySubscriptionForTopicType request. -func (client EventSubscriptionsClient) ListGlobalBySubscriptionForTopicTypePreparer(ctx context.Context, topicTypeName string) (*http.Request, error) { +func (client EventSubscriptionsClient) ListGlobalBySubscriptionForTopicTypePreparer(ctx context.Context, topicTypeName string, filter string, top *int32) (*http.Request, error) { pathParameters := map[string]interface{}{ "subscriptionId": autorest.Encode("path", client.SubscriptionID), "topicTypeName": autorest.Encode("path", topicTypeName), } - const APIVersion = "2018-09-15-preview" + const APIVersion = "2020-01-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } preparer := autorest.CreatePreparer( autorest.AsGet(), @@ -829,23 +1105,69 @@ func (client EventSubscriptionsClient) ListGlobalBySubscriptionForTopicTypeRespo return } +// listGlobalBySubscriptionForTopicTypeNextResults retrieves the next set of results, if any. +func (client EventSubscriptionsClient) listGlobalBySubscriptionForTopicTypeNextResults(ctx context.Context, lastResults EventSubscriptionsListResult) (result EventSubscriptionsListResult, err error) { + req, err := lastResults.eventSubscriptionsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listGlobalBySubscriptionForTopicTypeNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListGlobalBySubscriptionForTopicTypeSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listGlobalBySubscriptionForTopicTypeNextResults", resp, "Failure sending next results request") + } + result, err = client.ListGlobalBySubscriptionForTopicTypeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listGlobalBySubscriptionForTopicTypeNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListGlobalBySubscriptionForTopicTypeComplete enumerates all values, automatically crossing page boundaries as required. +func (client EventSubscriptionsClient) ListGlobalBySubscriptionForTopicTypeComplete(ctx context.Context, topicTypeName string, filter string, top *int32) (result EventSubscriptionsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListGlobalBySubscriptionForTopicType") + 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.ListGlobalBySubscriptionForTopicType(ctx, topicTypeName, filter, top) + return +} + // ListRegionalByResourceGroup list all event subscriptions from the given location under a specific Azure subscription // and resource group // Parameters: // resourceGroupName - the name of the resource group within the user's subscription. // location - name of the location -func (client EventSubscriptionsClient) ListRegionalByResourceGroup(ctx context.Context, resourceGroupName string, location string) (result EventSubscriptionsListResult, err error) { +// filter - the query used to filter the search results using OData syntax. Filtering is permitted on the +// 'name' property only and with limited number of OData operations. These operations are: the 'contains' +// function as well as the following logical operations: not, and, or, eq (for equal), and ne (for not equal). +// No arithmetic operations are supported. The following is a valid filter example: $filter=contains(namE, +// 'PATTERN') and name ne 'PATTERN-1'. The following is not a valid filter example: $filter=location eq +// 'westus'. +// top - the number of results to return per page for the list operation. Valid range for top parameter is 1 to +// 100. If not specified, the default number of results to be returned is 20 items per page. +func (client EventSubscriptionsClient) ListRegionalByResourceGroup(ctx context.Context, resourceGroupName string, location string, filter string, top *int32) (result EventSubscriptionsListResultPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListRegionalByResourceGroup") defer func() { sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode + if result.eslr.Response.Response != nil { + sc = result.eslr.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() } - req, err := client.ListRegionalByResourceGroupPreparer(ctx, resourceGroupName, location) + result.fn = client.listRegionalByResourceGroupNextResults + req, err := client.ListRegionalByResourceGroupPreparer(ctx, resourceGroupName, location, filter, top) if err != nil { err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalByResourceGroup", nil, "Failure preparing request") return @@ -853,12 +1175,12 @@ func (client EventSubscriptionsClient) ListRegionalByResourceGroup(ctx context.C resp, err := client.ListRegionalByResourceGroupSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.eslr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalByResourceGroup", resp, "Failure sending request") return } - result, err = client.ListRegionalByResourceGroupResponder(resp) + result.eslr, err = client.ListRegionalByResourceGroupResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalByResourceGroup", resp, "Failure responding to request") } @@ -867,17 +1189,23 @@ func (client EventSubscriptionsClient) ListRegionalByResourceGroup(ctx context.C } // ListRegionalByResourceGroupPreparer prepares the ListRegionalByResourceGroup request. -func (client EventSubscriptionsClient) ListRegionalByResourceGroupPreparer(ctx context.Context, resourceGroupName string, location string) (*http.Request, error) { +func (client EventSubscriptionsClient) ListRegionalByResourceGroupPreparer(ctx context.Context, resourceGroupName string, location string, filter string, top *int32) (*http.Request, error) { pathParameters := map[string]interface{}{ "location": autorest.Encode("path", location), "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2018-09-15-preview" + const APIVersion = "2020-01-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } preparer := autorest.CreatePreparer( autorest.AsGet(), @@ -906,24 +1234,70 @@ func (client EventSubscriptionsClient) ListRegionalByResourceGroupResponder(resp return } +// listRegionalByResourceGroupNextResults retrieves the next set of results, if any. +func (client EventSubscriptionsClient) listRegionalByResourceGroupNextResults(ctx context.Context, lastResults EventSubscriptionsListResult) (result EventSubscriptionsListResult, err error) { + req, err := lastResults.eventSubscriptionsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listRegionalByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListRegionalByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listRegionalByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListRegionalByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listRegionalByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListRegionalByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client EventSubscriptionsClient) ListRegionalByResourceGroupComplete(ctx context.Context, resourceGroupName string, location string, filter string, top *int32) (result EventSubscriptionsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListRegionalByResourceGroup") + 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.ListRegionalByResourceGroup(ctx, resourceGroupName, location, filter, top) + return +} + // ListRegionalByResourceGroupForTopicType list all event subscriptions from the given location under a specific Azure // subscription and resource group and topic type // Parameters: // resourceGroupName - the name of the resource group within the user's subscription. // location - name of the location // topicTypeName - name of the topic type -func (client EventSubscriptionsClient) ListRegionalByResourceGroupForTopicType(ctx context.Context, resourceGroupName string, location string, topicTypeName string) (result EventSubscriptionsListResult, err error) { +// filter - the query used to filter the search results using OData syntax. Filtering is permitted on the +// 'name' property only and with limited number of OData operations. These operations are: the 'contains' +// function as well as the following logical operations: not, and, or, eq (for equal), and ne (for not equal). +// No arithmetic operations are supported. The following is a valid filter example: $filter=contains(namE, +// 'PATTERN') and name ne 'PATTERN-1'. The following is not a valid filter example: $filter=location eq +// 'westus'. +// top - the number of results to return per page for the list operation. Valid range for top parameter is 1 to +// 100. If not specified, the default number of results to be returned is 20 items per page. +func (client EventSubscriptionsClient) ListRegionalByResourceGroupForTopicType(ctx context.Context, resourceGroupName string, location string, topicTypeName string, filter string, top *int32) (result EventSubscriptionsListResultPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListRegionalByResourceGroupForTopicType") defer func() { sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode + if result.eslr.Response.Response != nil { + sc = result.eslr.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() } - req, err := client.ListRegionalByResourceGroupForTopicTypePreparer(ctx, resourceGroupName, location, topicTypeName) + result.fn = client.listRegionalByResourceGroupForTopicTypeNextResults + req, err := client.ListRegionalByResourceGroupForTopicTypePreparer(ctx, resourceGroupName, location, topicTypeName, filter, top) if err != nil { err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalByResourceGroupForTopicType", nil, "Failure preparing request") return @@ -931,12 +1305,12 @@ func (client EventSubscriptionsClient) ListRegionalByResourceGroupForTopicType(c resp, err := client.ListRegionalByResourceGroupForTopicTypeSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.eslr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalByResourceGroupForTopicType", resp, "Failure sending request") return } - result, err = client.ListRegionalByResourceGroupForTopicTypeResponder(resp) + result.eslr, err = client.ListRegionalByResourceGroupForTopicTypeResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalByResourceGroupForTopicType", resp, "Failure responding to request") } @@ -945,7 +1319,7 @@ func (client EventSubscriptionsClient) ListRegionalByResourceGroupForTopicType(c } // ListRegionalByResourceGroupForTopicTypePreparer prepares the ListRegionalByResourceGroupForTopicType request. -func (client EventSubscriptionsClient) ListRegionalByResourceGroupForTopicTypePreparer(ctx context.Context, resourceGroupName string, location string, topicTypeName string) (*http.Request, error) { +func (client EventSubscriptionsClient) ListRegionalByResourceGroupForTopicTypePreparer(ctx context.Context, resourceGroupName string, location string, topicTypeName string, filter string, top *int32) (*http.Request, error) { pathParameters := map[string]interface{}{ "location": autorest.Encode("path", location), "resourceGroupName": autorest.Encode("path", resourceGroupName), @@ -953,10 +1327,16 @@ func (client EventSubscriptionsClient) ListRegionalByResourceGroupForTopicTypePr "topicTypeName": autorest.Encode("path", topicTypeName), } - const APIVersion = "2018-09-15-preview" + const APIVersion = "2020-01-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } preparer := autorest.CreatePreparer( autorest.AsGet(), @@ -985,21 +1365,67 @@ func (client EventSubscriptionsClient) ListRegionalByResourceGroupForTopicTypeRe return } +// listRegionalByResourceGroupForTopicTypeNextResults retrieves the next set of results, if any. +func (client EventSubscriptionsClient) listRegionalByResourceGroupForTopicTypeNextResults(ctx context.Context, lastResults EventSubscriptionsListResult) (result EventSubscriptionsListResult, err error) { + req, err := lastResults.eventSubscriptionsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listRegionalByResourceGroupForTopicTypeNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListRegionalByResourceGroupForTopicTypeSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listRegionalByResourceGroupForTopicTypeNextResults", resp, "Failure sending next results request") + } + result, err = client.ListRegionalByResourceGroupForTopicTypeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listRegionalByResourceGroupForTopicTypeNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListRegionalByResourceGroupForTopicTypeComplete enumerates all values, automatically crossing page boundaries as required. +func (client EventSubscriptionsClient) ListRegionalByResourceGroupForTopicTypeComplete(ctx context.Context, resourceGroupName string, location string, topicTypeName string, filter string, top *int32) (result EventSubscriptionsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListRegionalByResourceGroupForTopicType") + 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.ListRegionalByResourceGroupForTopicType(ctx, resourceGroupName, location, topicTypeName, filter, top) + return +} + // ListRegionalBySubscription list all event subscriptions from the given location under a specific Azure subscription // Parameters: // location - name of the location -func (client EventSubscriptionsClient) ListRegionalBySubscription(ctx context.Context, location string) (result EventSubscriptionsListResult, err error) { +// filter - the query used to filter the search results using OData syntax. Filtering is permitted on the +// 'name' property only and with limited number of OData operations. These operations are: the 'contains' +// function as well as the following logical operations: not, and, or, eq (for equal), and ne (for not equal). +// No arithmetic operations are supported. The following is a valid filter example: $filter=contains(namE, +// 'PATTERN') and name ne 'PATTERN-1'. The following is not a valid filter example: $filter=location eq +// 'westus'. +// top - the number of results to return per page for the list operation. Valid range for top parameter is 1 to +// 100. If not specified, the default number of results to be returned is 20 items per page. +func (client EventSubscriptionsClient) ListRegionalBySubscription(ctx context.Context, location string, filter string, top *int32) (result EventSubscriptionsListResultPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListRegionalBySubscription") defer func() { sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode + if result.eslr.Response.Response != nil { + sc = result.eslr.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() } - req, err := client.ListRegionalBySubscriptionPreparer(ctx, location) + result.fn = client.listRegionalBySubscriptionNextResults + req, err := client.ListRegionalBySubscriptionPreparer(ctx, location, filter, top) if err != nil { err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalBySubscription", nil, "Failure preparing request") return @@ -1007,12 +1433,12 @@ func (client EventSubscriptionsClient) ListRegionalBySubscription(ctx context.Co resp, err := client.ListRegionalBySubscriptionSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.eslr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalBySubscription", resp, "Failure sending request") return } - result, err = client.ListRegionalBySubscriptionResponder(resp) + result.eslr, err = client.ListRegionalBySubscriptionResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalBySubscription", resp, "Failure responding to request") } @@ -1021,16 +1447,22 @@ func (client EventSubscriptionsClient) ListRegionalBySubscription(ctx context.Co } // ListRegionalBySubscriptionPreparer prepares the ListRegionalBySubscription request. -func (client EventSubscriptionsClient) ListRegionalBySubscriptionPreparer(ctx context.Context, location string) (*http.Request, error) { +func (client EventSubscriptionsClient) ListRegionalBySubscriptionPreparer(ctx context.Context, location string, filter string, top *int32) (*http.Request, error) { pathParameters := map[string]interface{}{ "location": autorest.Encode("path", location), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2018-09-15-preview" + const APIVersion = "2020-01-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } preparer := autorest.CreatePreparer( autorest.AsGet(), @@ -1059,23 +1491,69 @@ func (client EventSubscriptionsClient) ListRegionalBySubscriptionResponder(resp return } +// listRegionalBySubscriptionNextResults retrieves the next set of results, if any. +func (client EventSubscriptionsClient) listRegionalBySubscriptionNextResults(ctx context.Context, lastResults EventSubscriptionsListResult) (result EventSubscriptionsListResult, err error) { + req, err := lastResults.eventSubscriptionsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listRegionalBySubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListRegionalBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listRegionalBySubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListRegionalBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listRegionalBySubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListRegionalBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client EventSubscriptionsClient) ListRegionalBySubscriptionComplete(ctx context.Context, location string, filter string, top *int32) (result EventSubscriptionsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListRegionalBySubscription") + 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.ListRegionalBySubscription(ctx, location, filter, top) + return +} + // ListRegionalBySubscriptionForTopicType list all event subscriptions from the given location under a specific Azure // subscription and topic type. // Parameters: // location - name of the location // topicTypeName - name of the topic type -func (client EventSubscriptionsClient) ListRegionalBySubscriptionForTopicType(ctx context.Context, location string, topicTypeName string) (result EventSubscriptionsListResult, err error) { +// filter - the query used to filter the search results using OData syntax. Filtering is permitted on the +// 'name' property only and with limited number of OData operations. These operations are: the 'contains' +// function as well as the following logical operations: not, and, or, eq (for equal), and ne (for not equal). +// No arithmetic operations are supported. The following is a valid filter example: $filter=contains(namE, +// 'PATTERN') and name ne 'PATTERN-1'. The following is not a valid filter example: $filter=location eq +// 'westus'. +// top - the number of results to return per page for the list operation. Valid range for top parameter is 1 to +// 100. If not specified, the default number of results to be returned is 20 items per page. +func (client EventSubscriptionsClient) ListRegionalBySubscriptionForTopicType(ctx context.Context, location string, topicTypeName string, filter string, top *int32) (result EventSubscriptionsListResultPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListRegionalBySubscriptionForTopicType") defer func() { sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode + if result.eslr.Response.Response != nil { + sc = result.eslr.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() } - req, err := client.ListRegionalBySubscriptionForTopicTypePreparer(ctx, location, topicTypeName) + result.fn = client.listRegionalBySubscriptionForTopicTypeNextResults + req, err := client.ListRegionalBySubscriptionForTopicTypePreparer(ctx, location, topicTypeName, filter, top) if err != nil { err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalBySubscriptionForTopicType", nil, "Failure preparing request") return @@ -1083,12 +1561,12 @@ func (client EventSubscriptionsClient) ListRegionalBySubscriptionForTopicType(ct resp, err := client.ListRegionalBySubscriptionForTopicTypeSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.eslr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalBySubscriptionForTopicType", resp, "Failure sending request") return } - result, err = client.ListRegionalBySubscriptionForTopicTypeResponder(resp) + result.eslr, err = client.ListRegionalBySubscriptionForTopicTypeResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalBySubscriptionForTopicType", resp, "Failure responding to request") } @@ -1097,17 +1575,23 @@ func (client EventSubscriptionsClient) ListRegionalBySubscriptionForTopicType(ct } // ListRegionalBySubscriptionForTopicTypePreparer prepares the ListRegionalBySubscriptionForTopicType request. -func (client EventSubscriptionsClient) ListRegionalBySubscriptionForTopicTypePreparer(ctx context.Context, location string, topicTypeName string) (*http.Request, error) { +func (client EventSubscriptionsClient) ListRegionalBySubscriptionForTopicTypePreparer(ctx context.Context, location string, topicTypeName string, filter string, top *int32) (*http.Request, error) { pathParameters := map[string]interface{}{ "location": autorest.Encode("path", location), "subscriptionId": autorest.Encode("path", client.SubscriptionID), "topicTypeName": autorest.Encode("path", topicTypeName), } - const APIVersion = "2018-09-15-preview" + const APIVersion = "2020-01-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } preparer := autorest.CreatePreparer( autorest.AsGet(), @@ -1136,6 +1620,43 @@ func (client EventSubscriptionsClient) ListRegionalBySubscriptionForTopicTypeRes return } +// listRegionalBySubscriptionForTopicTypeNextResults retrieves the next set of results, if any. +func (client EventSubscriptionsClient) listRegionalBySubscriptionForTopicTypeNextResults(ctx context.Context, lastResults EventSubscriptionsListResult) (result EventSubscriptionsListResult, err error) { + req, err := lastResults.eventSubscriptionsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listRegionalBySubscriptionForTopicTypeNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListRegionalBySubscriptionForTopicTypeSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listRegionalBySubscriptionForTopicTypeNextResults", resp, "Failure sending next results request") + } + result, err = client.ListRegionalBySubscriptionForTopicTypeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listRegionalBySubscriptionForTopicTypeNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListRegionalBySubscriptionForTopicTypeComplete enumerates all values, automatically crossing page boundaries as required. +func (client EventSubscriptionsClient) ListRegionalBySubscriptionForTopicTypeComplete(ctx context.Context, location string, topicTypeName string, filter string, top *int32) (result EventSubscriptionsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListRegionalBySubscriptionForTopicType") + 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.ListRegionalBySubscriptionForTopicType(ctx, location, topicTypeName, filter, top) + return +} + // Update asynchronously updates an existing event subscription. // Parameters: // scope - the scope of existing event subscription. The scope can be a subscription, or a resource group, or a @@ -1181,7 +1702,7 @@ func (client EventSubscriptionsClient) UpdatePreparer(ctx context.Context, scope "scope": scope, } - const APIVersion = "2018-09-15-preview" + const APIVersion = "2020-01-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2018-09-15-preview/eventgrid/models.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2020-01-01-preview/eventgrid/models.go similarity index 73% rename from vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2018-09-15-preview/eventgrid/models.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2020-01-01-preview/eventgrid/models.go index 53c8b1cb83ea..d22750f18259 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2018-09-15-preview/eventgrid/models.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2020-01-01-preview/eventgrid/models.go @@ -23,11 +23,13 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "github.com/Azure/go-autorest/autorest/date" + "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/eventgrid/mgmt/2018-09-15-preview/eventgrid" +const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2020-01-01-preview/eventgrid" // DomainProvisioningState enumerates the values for domain provisioning state. type DomainProvisioningState string @@ -52,16 +54,45 @@ func PossibleDomainProvisioningStateValues() []DomainProvisioningState { return []DomainProvisioningState{Canceled, Creating, Deleting, Failed, Succeeded, Updating} } +// DomainTopicProvisioningState enumerates the values for domain topic provisioning state. +type DomainTopicProvisioningState string + +const ( + // DomainTopicProvisioningStateCanceled ... + DomainTopicProvisioningStateCanceled DomainTopicProvisioningState = "Canceled" + // DomainTopicProvisioningStateCreating ... + DomainTopicProvisioningStateCreating DomainTopicProvisioningState = "Creating" + // DomainTopicProvisioningStateDeleting ... + DomainTopicProvisioningStateDeleting DomainTopicProvisioningState = "Deleting" + // DomainTopicProvisioningStateFailed ... + DomainTopicProvisioningStateFailed DomainTopicProvisioningState = "Failed" + // DomainTopicProvisioningStateSucceeded ... + DomainTopicProvisioningStateSucceeded DomainTopicProvisioningState = "Succeeded" + // DomainTopicProvisioningStateUpdating ... + DomainTopicProvisioningStateUpdating DomainTopicProvisioningState = "Updating" +) + +// PossibleDomainTopicProvisioningStateValues returns an array of possible values for the DomainTopicProvisioningState const type. +func PossibleDomainTopicProvisioningStateValues() []DomainTopicProvisioningState { + return []DomainTopicProvisioningState{DomainTopicProvisioningStateCanceled, DomainTopicProvisioningStateCreating, DomainTopicProvisioningStateDeleting, DomainTopicProvisioningStateFailed, DomainTopicProvisioningStateSucceeded, DomainTopicProvisioningStateUpdating} +} + // EndpointType enumerates the values for endpoint type. type EndpointType string const ( + // EndpointTypeAzureFunction ... + EndpointTypeAzureFunction EndpointType = "AzureFunction" // EndpointTypeEventHub ... EndpointTypeEventHub EndpointType = "EventHub" // EndpointTypeEventSubscriptionDestination ... EndpointTypeEventSubscriptionDestination EndpointType = "EventSubscriptionDestination" // EndpointTypeHybridConnection ... EndpointTypeHybridConnection EndpointType = "HybridConnection" + // EndpointTypeServiceBusQueue ... + EndpointTypeServiceBusQueue EndpointType = "ServiceBusQueue" + // EndpointTypeServiceBusTopic ... + EndpointTypeServiceBusTopic EndpointType = "ServiceBusTopic" // EndpointTypeStorageQueue ... EndpointTypeStorageQueue EndpointType = "StorageQueue" // EndpointTypeWebHook ... @@ -70,7 +101,7 @@ const ( // PossibleEndpointTypeValues returns an array of possible values for the EndpointType const type. func PossibleEndpointTypeValues() []EndpointType { - return []EndpointType{EndpointTypeEventHub, EndpointTypeEventSubscriptionDestination, EndpointTypeHybridConnection, EndpointTypeStorageQueue, EndpointTypeWebHook} + return []EndpointType{EndpointTypeAzureFunction, EndpointTypeEventHub, EndpointTypeEventSubscriptionDestination, EndpointTypeHybridConnection, EndpointTypeServiceBusQueue, EndpointTypeServiceBusTopic, EndpointTypeStorageQueue, EndpointTypeWebHook} } // EndpointTypeBasicDeadLetterDestination enumerates the values for endpoint type basic dead letter @@ -93,8 +124,8 @@ func PossibleEndpointTypeBasicDeadLetterDestinationValues() []EndpointTypeBasicD type EventDeliverySchema string const ( - // CloudEventV01Schema ... - CloudEventV01Schema EventDeliverySchema = "CloudEventV01Schema" + // CloudEventSchemaV10 ... + CloudEventSchemaV10 EventDeliverySchema = "CloudEventSchemaV1_0" // CustomInputSchema ... CustomInputSchema EventDeliverySchema = "CustomInputSchema" // EventGridSchema ... @@ -103,7 +134,7 @@ const ( // PossibleEventDeliverySchemaValues returns an array of possible values for the EventDeliverySchema const type. func PossibleEventDeliverySchemaValues() []EventDeliverySchema { - return []EventDeliverySchema{CloudEventV01Schema, CustomInputSchema, EventGridSchema} + return []EventDeliverySchema{CloudEventSchemaV10, CustomInputSchema, EventGridSchema} } // EventSubscriptionProvisioningState enumerates the values for event subscription provisioning state. @@ -135,8 +166,8 @@ func PossibleEventSubscriptionProvisioningStateValues() []EventSubscriptionProvi type InputSchema string const ( - // InputSchemaCloudEventV01Schema ... - InputSchemaCloudEventV01Schema InputSchema = "CloudEventV01Schema" + // InputSchemaCloudEventSchemaV10 ... + InputSchemaCloudEventSchemaV10 InputSchema = "CloudEventSchemaV1_0" // InputSchemaCustomEventSchema ... InputSchemaCustomEventSchema InputSchema = "CustomEventSchema" // InputSchemaEventGridSchema ... @@ -145,7 +176,7 @@ const ( // PossibleInputSchemaValues returns an array of possible values for the InputSchema const type. func PossibleInputSchemaValues() []InputSchema { - return []InputSchema{InputSchemaCloudEventV01Schema, InputSchemaCustomEventSchema, InputSchemaEventGridSchema} + return []InputSchema{InputSchemaCloudEventSchemaV10, InputSchemaCustomEventSchema, InputSchemaEventGridSchema} } // InputSchemaMappingType enumerates the values for input schema mapping type. @@ -261,8 +292,10 @@ func PossibleTopicTypeProvisioningStateValues() []TopicTypeProvisioningState { return []TopicTypeProvisioningState{TopicTypeProvisioningStateCanceled, TopicTypeProvisioningStateCreating, TopicTypeProvisioningStateDeleting, TopicTypeProvisioningStateFailed, TopicTypeProvisioningStateSucceeded, TopicTypeProvisioningStateUpdating} } -// BasicAdvancedFilter represents an advanced filter that can be used to filter events based on various event -// envelope/data fields. +// BasicAdvancedFilter this is the base type that represents an advanced filter. To configure an advanced filter, do +// not directly instantiate an object of this class. Instead, instantiate an object of a derived class such as +// BoolEqualsAdvancedFilter, NumberInAdvancedFilter, StringEqualsAdvancedFilter etc. depending on the type of the key +// based on which you want to filter. type BasicAdvancedFilter interface { AsNumberInAdvancedFilter() (*NumberInAdvancedFilter, bool) AsNumberNotInAdvancedFilter() (*NumberNotInAdvancedFilter, bool) @@ -279,10 +312,12 @@ type BasicAdvancedFilter interface { AsAdvancedFilter() (*AdvancedFilter, bool) } -// AdvancedFilter represents an advanced filter that can be used to filter events based on various event -// envelope/data fields. +// AdvancedFilter this is the base type that represents an advanced filter. To configure an advanced filter, do +// not directly instantiate an object of this class. Instead, instantiate an object of a derived class such as +// BoolEqualsAdvancedFilter, NumberInAdvancedFilter, StringEqualsAdvancedFilter etc. depending on the type of +// the key based on which you want to filter. type AdvancedFilter struct { - // Key - The filter key. Represents an event property with up to two levels of nesting. + // Key - The field/property in the event based on which you want to filter. Key *string `json:"key,omitempty"` // OperatorType - Possible values include: 'OperatorTypeAdvancedFilter', 'OperatorTypeNumberIn', 'OperatorTypeNumberNotIn', 'OperatorTypeNumberLessThan', 'OperatorTypeNumberGreaterThan', 'OperatorTypeNumberLessThanOrEquals', 'OperatorTypeNumberGreaterThanOrEquals', 'OperatorTypeBoolEquals', 'OperatorTypeStringIn', 'OperatorTypeStringNotIn', 'OperatorTypeStringBeginsWith', 'OperatorTypeStringEndsWith', 'OperatorTypeStringContains' OperatorType OperatorType `json:"operatorType,omitempty"` @@ -452,11 +487,122 @@ func (af AdvancedFilter) AsBasicAdvancedFilter() (BasicAdvancedFilter, bool) { return &af, true } -// BoolEqualsAdvancedFilter boolEquals Filter +// AzureFunctionEventSubscriptionDestination information about the azure function destination for an event +// subscription. +type AzureFunctionEventSubscriptionDestination struct { + // AzureFunctionEventSubscriptionDestinationProperties - Azure Function Properties of the event subscription destination. + *AzureFunctionEventSubscriptionDestinationProperties `json:"properties,omitempty"` + // EndpointType - Possible values include: 'EndpointTypeEventSubscriptionDestination', 'EndpointTypeWebHook', 'EndpointTypeEventHub', 'EndpointTypeStorageQueue', 'EndpointTypeHybridConnection', 'EndpointTypeServiceBusQueue', 'EndpointTypeServiceBusTopic', 'EndpointTypeAzureFunction' + EndpointType EndpointType `json:"endpointType,omitempty"` +} + +// MarshalJSON is the custom marshaler for AzureFunctionEventSubscriptionDestination. +func (afesd AzureFunctionEventSubscriptionDestination) MarshalJSON() ([]byte, error) { + afesd.EndpointType = EndpointTypeAzureFunction + objectMap := make(map[string]interface{}) + if afesd.AzureFunctionEventSubscriptionDestinationProperties != nil { + objectMap["properties"] = afesd.AzureFunctionEventSubscriptionDestinationProperties + } + if afesd.EndpointType != "" { + objectMap["endpointType"] = afesd.EndpointType + } + return json.Marshal(objectMap) +} + +// AsWebHookEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for AzureFunctionEventSubscriptionDestination. +func (afesd AzureFunctionEventSubscriptionDestination) AsWebHookEventSubscriptionDestination() (*WebHookEventSubscriptionDestination, bool) { + return nil, false +} + +// AsEventHubEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for AzureFunctionEventSubscriptionDestination. +func (afesd AzureFunctionEventSubscriptionDestination) AsEventHubEventSubscriptionDestination() (*EventHubEventSubscriptionDestination, bool) { + return nil, false +} + +// AsStorageQueueEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for AzureFunctionEventSubscriptionDestination. +func (afesd AzureFunctionEventSubscriptionDestination) AsStorageQueueEventSubscriptionDestination() (*StorageQueueEventSubscriptionDestination, bool) { + return nil, false +} + +// AsHybridConnectionEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for AzureFunctionEventSubscriptionDestination. +func (afesd AzureFunctionEventSubscriptionDestination) AsHybridConnectionEventSubscriptionDestination() (*HybridConnectionEventSubscriptionDestination, bool) { + return nil, false +} + +// AsServiceBusQueueEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for AzureFunctionEventSubscriptionDestination. +func (afesd AzureFunctionEventSubscriptionDestination) AsServiceBusQueueEventSubscriptionDestination() (*ServiceBusQueueEventSubscriptionDestination, bool) { + return nil, false +} + +// AsServiceBusTopicEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for AzureFunctionEventSubscriptionDestination. +func (afesd AzureFunctionEventSubscriptionDestination) AsServiceBusTopicEventSubscriptionDestination() (*ServiceBusTopicEventSubscriptionDestination, bool) { + return nil, false +} + +// AsAzureFunctionEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for AzureFunctionEventSubscriptionDestination. +func (afesd AzureFunctionEventSubscriptionDestination) AsAzureFunctionEventSubscriptionDestination() (*AzureFunctionEventSubscriptionDestination, bool) { + return &afesd, true +} + +// AsEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for AzureFunctionEventSubscriptionDestination. +func (afesd AzureFunctionEventSubscriptionDestination) AsEventSubscriptionDestination() (*EventSubscriptionDestination, bool) { + return nil, false +} + +// AsBasicEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for AzureFunctionEventSubscriptionDestination. +func (afesd AzureFunctionEventSubscriptionDestination) AsBasicEventSubscriptionDestination() (BasicEventSubscriptionDestination, bool) { + return &afesd, true +} + +// UnmarshalJSON is the custom unmarshaler for AzureFunctionEventSubscriptionDestination struct. +func (afesd *AzureFunctionEventSubscriptionDestination) 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 azureFunctionEventSubscriptionDestinationProperties AzureFunctionEventSubscriptionDestinationProperties + err = json.Unmarshal(*v, &azureFunctionEventSubscriptionDestinationProperties) + if err != nil { + return err + } + afesd.AzureFunctionEventSubscriptionDestinationProperties = &azureFunctionEventSubscriptionDestinationProperties + } + case "endpointType": + if v != nil { + var endpointType EndpointType + err = json.Unmarshal(*v, &endpointType) + if err != nil { + return err + } + afesd.EndpointType = endpointType + } + } + } + + return nil +} + +// AzureFunctionEventSubscriptionDestinationProperties the properties that represent the Azure Function +// destination of an event subscription. +type AzureFunctionEventSubscriptionDestinationProperties struct { + // ResourceID - The Azure Resource Id that represents the endpoint of the Azure Function destination of an event subscription. + ResourceID *string `json:"resourceId,omitempty"` + // MaxEventsPerBatch - Maximum number of events per batch. + MaxEventsPerBatch *int32 `json:"maxEventsPerBatch,omitempty"` + // PreferredBatchSizeInKilobytes - Preferred batch size in Kilobytes. + PreferredBatchSizeInKilobytes *int32 `json:"preferredBatchSizeInKilobytes,omitempty"` +} + +// BoolEqualsAdvancedFilter boolEquals Advanced Filter. type BoolEqualsAdvancedFilter struct { - // Value - The filter value + // Value - The boolean filter value. Value *bool `json:"value,omitempty"` - // Key - The filter key. Represents an event property with up to two levels of nesting. + // Key - The field/property in the event based on which you want to filter. Key *string `json:"key,omitempty"` // OperatorType - Possible values include: 'OperatorTypeAdvancedFilter', 'OperatorTypeNumberIn', 'OperatorTypeNumberNotIn', 'OperatorTypeNumberLessThan', 'OperatorTypeNumberGreaterThan', 'OperatorTypeNumberLessThanOrEquals', 'OperatorTypeNumberGreaterThanOrEquals', 'OperatorTypeBoolEquals', 'OperatorTypeStringIn', 'OperatorTypeStringNotIn', 'OperatorTypeStringBeginsWith', 'OperatorTypeStringEndsWith', 'OperatorTypeStringContains' OperatorType OperatorType `json:"operatorType,omitempty"` @@ -734,10 +880,12 @@ type DomainProperties struct { ProvisioningState DomainProvisioningState `json:"provisioningState,omitempty"` // Endpoint - READ-ONLY; Endpoint for the domain. Endpoint *string `json:"endpoint,omitempty"` - // InputSchema - This determines the format that Event Grid should expect for incoming events published to the domain. Possible values include: 'InputSchemaEventGridSchema', 'InputSchemaCustomEventSchema', 'InputSchemaCloudEventV01Schema' + // InputSchema - This determines the format that Event Grid should expect for incoming events published to the domain. Possible values include: 'InputSchemaEventGridSchema', 'InputSchemaCustomEventSchema', 'InputSchemaCloudEventSchemaV10' InputSchema InputSchema `json:"inputSchema,omitempty"` // InputSchemaMapping - Information about the InputSchemaMapping which specified the info about mapping event payload. InputSchemaMapping BasicInputSchemaMapping `json:"inputSchemaMapping,omitempty"` + // MetricResourceID - READ-ONLY; Metric resource id for the domain. + MetricResourceID *string `json:"metricResourceId,omitempty"` } // UnmarshalJSON is the custom unmarshaler for DomainProperties struct. @@ -784,6 +932,15 @@ func (dp *DomainProperties) UnmarshalJSON(body []byte) error { } dp.InputSchemaMapping = inputSchemaMapping } + case "metricResourceId": + if v != nil { + var metricResourceID string + err = json.Unmarshal(*v, &metricResourceID) + if err != nil { + return err + } + dp.MetricResourceID = &metricResourceID + } } } @@ -862,6 +1019,145 @@ type DomainsListResult struct { autorest.Response `json:"-"` // Value - A collection of Domains Value *[]Domain `json:"value,omitempty"` + // NextLink - A link for the next page of domains + NextLink *string `json:"nextLink,omitempty"` +} + +// DomainsListResultIterator provides access to a complete listing of Domain values. +type DomainsListResultIterator struct { + i int + page DomainsListResultPage +} + +// 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 *DomainsListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DomainsListResultIterator.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 *DomainsListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DomainsListResultIterator) 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 DomainsListResultIterator) Response() DomainsListResult { + 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 DomainsListResultIterator) Value() Domain { + if !iter.page.NotDone() { + return Domain{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the DomainsListResultIterator type. +func NewDomainsListResultIterator(page DomainsListResultPage) DomainsListResultIterator { + return DomainsListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (dlr DomainsListResult) IsEmpty() bool { + return dlr.Value == nil || len(*dlr.Value) == 0 +} + +// domainsListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dlr DomainsListResult) domainsListResultPreparer(ctx context.Context) (*http.Request, error) { + if dlr.NextLink == nil || len(to.String(dlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dlr.NextLink))) +} + +// DomainsListResultPage contains a page of Domain values. +type DomainsListResultPage struct { + fn func(context.Context, DomainsListResult) (DomainsListResult, error) + dlr DomainsListResult +} + +// 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 *DomainsListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DomainsListResultPage.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.dlr) + if err != nil { + return err + } + page.dlr = 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 *DomainsListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DomainsListResultPage) NotDone() bool { + return !page.dlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DomainsListResultPage) Response() DomainsListResult { + return page.dlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DomainsListResultPage) Values() []Domain { + if page.dlr.IsEmpty() { + return nil + } + return *page.dlr.Value +} + +// Creates a new instance of the DomainsListResultPage type. +func NewDomainsListResultPage(getNextPage func(context.Context, DomainsListResult) (DomainsListResult, error)) DomainsListResultPage { + return DomainsListResultPage{fn: getNextPage} } // DomainsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running @@ -896,6 +1192,8 @@ func (future *DomainsUpdateFuture) Result(client DomainsClient) (d Domain, err e // DomainTopic domain Topic type DomainTopic struct { autorest.Response `json:"-"` + // DomainTopicProperties - Properties of the Domain Topic + *DomainTopicProperties `json:"properties,omitempty"` // ID - READ-ONLY; Fully qualified identifier of the resource ID *string `json:"id,omitempty"` // Name - READ-ONLY; Name of the resource @@ -904,11 +1202,268 @@ type DomainTopic struct { Type *string `json:"type,omitempty"` } +// MarshalJSON is the custom marshaler for DomainTopic. +func (dt DomainTopic) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dt.DomainTopicProperties != nil { + objectMap["properties"] = dt.DomainTopicProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DomainTopic struct. +func (dt *DomainTopic) 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 domainTopicProperties DomainTopicProperties + err = json.Unmarshal(*v, &domainTopicProperties) + if err != nil { + return err + } + dt.DomainTopicProperties = &domainTopicProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dt.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dt.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dt.Type = &typeVar + } + } + } + + return nil +} + +// DomainTopicProperties properties of the Domain Topic +type DomainTopicProperties struct { + // ProvisioningState - Provisioning state of the domain topic. Possible values include: 'DomainTopicProvisioningStateCreating', 'DomainTopicProvisioningStateUpdating', 'DomainTopicProvisioningStateDeleting', 'DomainTopicProvisioningStateSucceeded', 'DomainTopicProvisioningStateCanceled', 'DomainTopicProvisioningStateFailed' + ProvisioningState DomainTopicProvisioningState `json:"provisioningState,omitempty"` +} + +// DomainTopicsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type DomainTopicsCreateOrUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *DomainTopicsCreateOrUpdateFuture) Result(client DomainTopicsClient) (dt DomainTopic, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "eventgrid.DomainTopicsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("eventgrid.DomainTopicsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if dt.Response.Response, err = future.GetResult(sender); err == nil && dt.Response.Response.StatusCode != http.StatusNoContent { + dt, err = client.CreateOrUpdateResponder(dt.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "eventgrid.DomainTopicsCreateOrUpdateFuture", "Result", dt.Response.Response, "Failure responding to request") + } + } + return +} + +// DomainTopicsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DomainTopicsDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *DomainTopicsDeleteFuture) Result(client DomainTopicsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "eventgrid.DomainTopicsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("eventgrid.DomainTopicsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + // DomainTopicsListResult result of the List Domain Topics operation type DomainTopicsListResult struct { autorest.Response `json:"-"` // Value - A collection of Domain Topics Value *[]DomainTopic `json:"value,omitempty"` + // NextLink - A link for the next page of domain topics + NextLink *string `json:"nextLink,omitempty"` +} + +// DomainTopicsListResultIterator provides access to a complete listing of DomainTopic values. +type DomainTopicsListResultIterator struct { + i int + page DomainTopicsListResultPage +} + +// 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 *DomainTopicsListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DomainTopicsListResultIterator.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 *DomainTopicsListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DomainTopicsListResultIterator) 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 DomainTopicsListResultIterator) Response() DomainTopicsListResult { + 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 DomainTopicsListResultIterator) Value() DomainTopic { + if !iter.page.NotDone() { + return DomainTopic{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the DomainTopicsListResultIterator type. +func NewDomainTopicsListResultIterator(page DomainTopicsListResultPage) DomainTopicsListResultIterator { + return DomainTopicsListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (dtlr DomainTopicsListResult) IsEmpty() bool { + return dtlr.Value == nil || len(*dtlr.Value) == 0 +} + +// domainTopicsListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dtlr DomainTopicsListResult) domainTopicsListResultPreparer(ctx context.Context) (*http.Request, error) { + if dtlr.NextLink == nil || len(to.String(dtlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dtlr.NextLink))) +} + +// DomainTopicsListResultPage contains a page of DomainTopic values. +type DomainTopicsListResultPage struct { + fn func(context.Context, DomainTopicsListResult) (DomainTopicsListResult, error) + dtlr DomainTopicsListResult +} + +// 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 *DomainTopicsListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DomainTopicsListResultPage.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.dtlr) + if err != nil { + return err + } + page.dtlr = 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 *DomainTopicsListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DomainTopicsListResultPage) NotDone() bool { + return !page.dtlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DomainTopicsListResultPage) Response() DomainTopicsListResult { + return page.dtlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DomainTopicsListResultPage) Values() []DomainTopic { + if page.dtlr.IsEmpty() { + return nil + } + return *page.dtlr.Value +} + +// Creates a new instance of the DomainTopicsListResultPage type. +func NewDomainTopicsListResultPage(getNextPage func(context.Context, DomainTopicsListResult) (DomainTopicsListResult, error)) DomainTopicsListResultPage { + return DomainTopicsListResultPage{fn: getNextPage} } // DomainUpdateParameters properties of the Domain update @@ -931,7 +1486,7 @@ func (dup DomainUpdateParameters) MarshalJSON() ([]byte, error) { type EventHubEventSubscriptionDestination struct { // EventHubEventSubscriptionDestinationProperties - Event Hub Properties of the event subscription destination *EventHubEventSubscriptionDestinationProperties `json:"properties,omitempty"` - // EndpointType - Possible values include: 'EndpointTypeEventSubscriptionDestination', 'EndpointTypeWebHook', 'EndpointTypeEventHub', 'EndpointTypeStorageQueue', 'EndpointTypeHybridConnection' + // EndpointType - Possible values include: 'EndpointTypeEventSubscriptionDestination', 'EndpointTypeWebHook', 'EndpointTypeEventHub', 'EndpointTypeStorageQueue', 'EndpointTypeHybridConnection', 'EndpointTypeServiceBusQueue', 'EndpointTypeServiceBusTopic', 'EndpointTypeAzureFunction' EndpointType EndpointType `json:"endpointType,omitempty"` } @@ -968,6 +1523,21 @@ func (ehesd EventHubEventSubscriptionDestination) AsHybridConnectionEventSubscri return nil, false } +// AsServiceBusQueueEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for EventHubEventSubscriptionDestination. +func (ehesd EventHubEventSubscriptionDestination) AsServiceBusQueueEventSubscriptionDestination() (*ServiceBusQueueEventSubscriptionDestination, bool) { + return nil, false +} + +// AsServiceBusTopicEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for EventHubEventSubscriptionDestination. +func (ehesd EventHubEventSubscriptionDestination) AsServiceBusTopicEventSubscriptionDestination() (*ServiceBusTopicEventSubscriptionDestination, bool) { + return nil, false +} + +// AsAzureFunctionEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for EventHubEventSubscriptionDestination. +func (ehesd EventHubEventSubscriptionDestination) AsAzureFunctionEventSubscriptionDestination() (*AzureFunctionEventSubscriptionDestination, bool) { + return nil, false +} + // AsEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for EventHubEventSubscriptionDestination. func (ehesd EventHubEventSubscriptionDestination) AsEventSubscriptionDestination() (*EventSubscriptionDestination, bool) { return nil, false @@ -1096,12 +1666,15 @@ type BasicEventSubscriptionDestination interface { AsEventHubEventSubscriptionDestination() (*EventHubEventSubscriptionDestination, bool) AsStorageQueueEventSubscriptionDestination() (*StorageQueueEventSubscriptionDestination, bool) AsHybridConnectionEventSubscriptionDestination() (*HybridConnectionEventSubscriptionDestination, bool) + AsServiceBusQueueEventSubscriptionDestination() (*ServiceBusQueueEventSubscriptionDestination, bool) + AsServiceBusTopicEventSubscriptionDestination() (*ServiceBusTopicEventSubscriptionDestination, bool) + AsAzureFunctionEventSubscriptionDestination() (*AzureFunctionEventSubscriptionDestination, bool) AsEventSubscriptionDestination() (*EventSubscriptionDestination, bool) } // EventSubscriptionDestination information about the destination for an event subscription type EventSubscriptionDestination struct { - // EndpointType - Possible values include: 'EndpointTypeEventSubscriptionDestination', 'EndpointTypeWebHook', 'EndpointTypeEventHub', 'EndpointTypeStorageQueue', 'EndpointTypeHybridConnection' + // EndpointType - Possible values include: 'EndpointTypeEventSubscriptionDestination', 'EndpointTypeWebHook', 'EndpointTypeEventHub', 'EndpointTypeStorageQueue', 'EndpointTypeHybridConnection', 'EndpointTypeServiceBusQueue', 'EndpointTypeServiceBusTopic', 'EndpointTypeAzureFunction' EndpointType EndpointType `json:"endpointType,omitempty"` } @@ -1129,6 +1702,18 @@ func unmarshalBasicEventSubscriptionDestination(body []byte) (BasicEventSubscrip var hcesd HybridConnectionEventSubscriptionDestination err := json.Unmarshal(body, &hcesd) return hcesd, err + case string(EndpointTypeServiceBusQueue): + var sbqesd ServiceBusQueueEventSubscriptionDestination + err := json.Unmarshal(body, &sbqesd) + return sbqesd, err + case string(EndpointTypeServiceBusTopic): + var sbtesd ServiceBusTopicEventSubscriptionDestination + err := json.Unmarshal(body, &sbtesd) + return sbtesd, err + case string(EndpointTypeAzureFunction): + var afesd AzureFunctionEventSubscriptionDestination + err := json.Unmarshal(body, &afesd) + return afesd, err default: var esd EventSubscriptionDestination err := json.Unmarshal(body, &esd) @@ -1184,6 +1769,21 @@ func (esd EventSubscriptionDestination) AsHybridConnectionEventSubscriptionDesti return nil, false } +// AsServiceBusQueueEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for EventSubscriptionDestination. +func (esd EventSubscriptionDestination) AsServiceBusQueueEventSubscriptionDestination() (*ServiceBusQueueEventSubscriptionDestination, bool) { + return nil, false +} + +// AsServiceBusTopicEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for EventSubscriptionDestination. +func (esd EventSubscriptionDestination) AsServiceBusTopicEventSubscriptionDestination() (*ServiceBusTopicEventSubscriptionDestination, bool) { + return nil, false +} + +// AsAzureFunctionEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for EventSubscriptionDestination. +func (esd EventSubscriptionDestination) AsAzureFunctionEventSubscriptionDestination() (*AzureFunctionEventSubscriptionDestination, bool) { + return nil, false +} + // AsEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for EventSubscriptionDestination. func (esd EventSubscriptionDestination) AsEventSubscriptionDestination() (*EventSubscriptionDestination, bool) { return &esd, true @@ -1203,13 +1803,12 @@ type EventSubscriptionFilter struct { // SubjectEndsWith - An optional string to filter events for an event subscription based on a resource path suffix. // Wildcard characters are not supported in this path. SubjectEndsWith *string `json:"subjectEndsWith,omitempty"` - // IncludedEventTypes - A list of applicable event types that need to be part of the event subscription. - // If it is desired to subscribe to all event types, the string "all" needs to be specified as an element in this list. + // IncludedEventTypes - A list of applicable event types that need to be part of the event subscription. If it is desired to subscribe to all default event types, set the IncludedEventTypes to null. IncludedEventTypes *[]string `json:"includedEventTypes,omitempty"` // IsSubjectCaseSensitive - Specifies if the SubjectBeginsWith and SubjectEndsWith properties of the filter // should be compared in a case sensitive manner. IsSubjectCaseSensitive *bool `json:"isSubjectCaseSensitive,omitempty"` - // AdvancedFilters - A list of advanced filters. + // AdvancedFilters - An array of advanced filters that are used for filtering event subscriptions. AdvancedFilters *[]BasicAdvancedFilter `json:"advancedFilters,omitempty"` } @@ -1293,7 +1892,7 @@ type EventSubscriptionProperties struct { Labels *[]string `json:"labels,omitempty"` // ExpirationTimeUtc - Expiration time of the event subscription. ExpirationTimeUtc *date.Time `json:"expirationTimeUtc,omitempty"` - // EventDeliverySchema - The event delivery schema for the event subscription. Possible values include: 'EventGridSchema', 'CloudEventV01Schema', 'CustomInputSchema' + // EventDeliverySchema - The event delivery schema for the event subscription. Possible values include: 'EventGridSchema', 'CustomInputSchema', 'CloudEventSchemaV10' EventDeliverySchema EventDeliverySchema `json:"eventDeliverySchema,omitempty"` // RetryPolicy - The retry policy for events. This can be used to configure maximum number of delivery attempts and time to live for events. RetryPolicy *RetryPolicy `json:"retryPolicy,omitempty"` @@ -1414,44 +2013,183 @@ func (future *EventSubscriptionsCreateOrUpdateFuture) Result(client EventSubscri err = azure.NewAsyncOpIncompleteError("eventgrid.EventSubscriptionsCreateOrUpdateFuture") return } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if es.Response.Response, err = future.GetResult(sender); err == nil && es.Response.Response.StatusCode != http.StatusNoContent { - es, err = client.CreateOrUpdateResponder(es.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsCreateOrUpdateFuture", "Result", es.Response.Response, "Failure responding to request") - } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if es.Response.Response, err = future.GetResult(sender); err == nil && es.Response.Response.StatusCode != http.StatusNoContent { + es, err = client.CreateOrUpdateResponder(es.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsCreateOrUpdateFuture", "Result", es.Response.Response, "Failure responding to request") + } + } + return +} + +// EventSubscriptionsDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type EventSubscriptionsDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *EventSubscriptionsDeleteFuture) Result(client EventSubscriptionsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("eventgrid.EventSubscriptionsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// EventSubscriptionsListResult result of the List EventSubscriptions operation +type EventSubscriptionsListResult struct { + autorest.Response `json:"-"` + // Value - A collection of EventSubscriptions + Value *[]EventSubscription `json:"value,omitempty"` + // NextLink - A link for the next page of event subscriptions + NextLink *string `json:"nextLink,omitempty"` +} + +// EventSubscriptionsListResultIterator provides access to a complete listing of EventSubscription values. +type EventSubscriptionsListResultIterator struct { + i int + page EventSubscriptionsListResultPage +} + +// 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 *EventSubscriptionsListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsListResultIterator.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 *EventSubscriptionsListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter EventSubscriptionsListResultIterator) 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 EventSubscriptionsListResultIterator) Response() EventSubscriptionsListResult { + 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 EventSubscriptionsListResultIterator) Value() EventSubscription { + if !iter.page.NotDone() { + return EventSubscription{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the EventSubscriptionsListResultIterator type. +func NewEventSubscriptionsListResultIterator(page EventSubscriptionsListResultPage) EventSubscriptionsListResultIterator { + return EventSubscriptionsListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (eslr EventSubscriptionsListResult) IsEmpty() bool { + return eslr.Value == nil || len(*eslr.Value) == 0 +} + +// eventSubscriptionsListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (eslr EventSubscriptionsListResult) eventSubscriptionsListResultPreparer(ctx context.Context) (*http.Request, error) { + if eslr.NextLink == nil || len(to.String(eslr.NextLink)) < 1 { + return nil, nil } - return + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(eslr.NextLink))) } -// EventSubscriptionsDeleteFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type EventSubscriptionsDeleteFuture struct { - azure.Future +// EventSubscriptionsListResultPage contains a page of EventSubscription values. +type EventSubscriptionsListResultPage struct { + fn func(context.Context, EventSubscriptionsListResult) (EventSubscriptionsListResult, error) + eslr EventSubscriptionsListResult } -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *EventSubscriptionsDeleteFuture) Result(client EventSubscriptionsClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) +// 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 *EventSubscriptionsListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsListResultPage.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.eslr) if err != nil { - err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsDeleteFuture", "Result", future.Response(), "Polling failure") - return + return err } - if !done { - err = azure.NewAsyncOpIncompleteError("eventgrid.EventSubscriptionsDeleteFuture") - return + page.eslr = 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 *EventSubscriptionsListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page EventSubscriptionsListResultPage) NotDone() bool { + return !page.eslr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page EventSubscriptionsListResultPage) Response() EventSubscriptionsListResult { + return page.eslr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page EventSubscriptionsListResultPage) Values() []EventSubscription { + if page.eslr.IsEmpty() { + return nil } - ar.Response = future.Response() - return + return *page.eslr.Value } -// EventSubscriptionsListResult result of the List EventSubscriptions operation -type EventSubscriptionsListResult struct { - autorest.Response `json:"-"` - // Value - A collection of EventSubscriptions - Value *[]EventSubscription `json:"value,omitempty"` +// Creates a new instance of the EventSubscriptionsListResultPage type. +func NewEventSubscriptionsListResultPage(getNextPage func(context.Context, EventSubscriptionsListResult) (EventSubscriptionsListResult, error)) EventSubscriptionsListResultPage { + return EventSubscriptionsListResultPage{fn: getNextPage} } // EventSubscriptionsUpdateFuture an abstraction for monitoring and retrieving the results of a @@ -1493,7 +2231,7 @@ type EventSubscriptionUpdateParameters struct { Labels *[]string `json:"labels,omitempty"` // ExpirationTimeUtc - Information about the expiration time for the event subscription. ExpirationTimeUtc *date.Time `json:"expirationTimeUtc,omitempty"` - // EventDeliverySchema - The event delivery schema for the event subscription. Possible values include: 'EventGridSchema', 'CloudEventV01Schema', 'CustomInputSchema' + // EventDeliverySchema - The event delivery schema for the event subscription. Possible values include: 'EventGridSchema', 'CustomInputSchema', 'CloudEventSchemaV10' EventDeliverySchema EventDeliverySchema `json:"eventDeliverySchema,omitempty"` // RetryPolicy - The retry policy for events. This can be used to configure maximum number of delivery attempts and time to live for events. RetryPolicy *RetryPolicy `json:"retryPolicy,omitempty"` @@ -1657,6 +2395,8 @@ type EventTypeProperties struct { Description *string `json:"description,omitempty"` // SchemaURL - Url of the schema for this event type. SchemaURL *string `json:"schemaUrl,omitempty"` + // IsInDefaultSet - IsInDefaultSet flag of the event type. + IsInDefaultSet *bool `json:"isInDefaultSet,omitempty"` } // EventTypesListResult result of the List Event Types operation @@ -1671,7 +2411,7 @@ type EventTypesListResult struct { type HybridConnectionEventSubscriptionDestination struct { // HybridConnectionEventSubscriptionDestinationProperties - Hybrid connection Properties of the event subscription destination *HybridConnectionEventSubscriptionDestinationProperties `json:"properties,omitempty"` - // EndpointType - Possible values include: 'EndpointTypeEventSubscriptionDestination', 'EndpointTypeWebHook', 'EndpointTypeEventHub', 'EndpointTypeStorageQueue', 'EndpointTypeHybridConnection' + // EndpointType - Possible values include: 'EndpointTypeEventSubscriptionDestination', 'EndpointTypeWebHook', 'EndpointTypeEventHub', 'EndpointTypeStorageQueue', 'EndpointTypeHybridConnection', 'EndpointTypeServiceBusQueue', 'EndpointTypeServiceBusTopic', 'EndpointTypeAzureFunction' EndpointType EndpointType `json:"endpointType,omitempty"` } @@ -1708,6 +2448,21 @@ func (hcesd HybridConnectionEventSubscriptionDestination) AsHybridConnectionEven return &hcesd, true } +// AsServiceBusQueueEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for HybridConnectionEventSubscriptionDestination. +func (hcesd HybridConnectionEventSubscriptionDestination) AsServiceBusQueueEventSubscriptionDestination() (*ServiceBusQueueEventSubscriptionDestination, bool) { + return nil, false +} + +// AsServiceBusTopicEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for HybridConnectionEventSubscriptionDestination. +func (hcesd HybridConnectionEventSubscriptionDestination) AsServiceBusTopicEventSubscriptionDestination() (*ServiceBusTopicEventSubscriptionDestination, bool) { + return nil, false +} + +// AsAzureFunctionEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for HybridConnectionEventSubscriptionDestination. +func (hcesd HybridConnectionEventSubscriptionDestination) AsAzureFunctionEventSubscriptionDestination() (*AzureFunctionEventSubscriptionDestination, bool) { + return nil, false +} + // AsEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for HybridConnectionEventSubscriptionDestination. func (hcesd HybridConnectionEventSubscriptionDestination) AsEventSubscriptionDestination() (*EventSubscriptionDestination, bool) { return nil, false @@ -1837,7 +2592,7 @@ func (ism InputSchemaMapping) AsBasicInputSchemaMapping() (BasicInputSchemaMappi } // JSONField this is used to express the source of an input schema mapping for a single target field in the -// Event Grid Event schema. This is currently used in the mappings for the 'id','topic' and 'eventTime' +// Event Grid Event schema. This is currently used in the mappings for the 'id', 'topic' and 'eventtime' // properties. This represents a field in the input event schema. type JSONField struct { // SourceField - Name of a field in the input event schema that's to be used as the source of a mapping. @@ -1845,8 +2600,9 @@ type JSONField struct { } // JSONFieldWithDefault this is used to express the source of an input schema mapping for a single target -// field in the Event Grid Event schema. This is currently used in the mappings for the -// 'subject','eventType' and 'dataVersion' properties. This represents a field in the input event schema +// field +// in the Event Grid Event schema. This is currently used in the mappings for the 'subject', +// 'eventtype' and 'dataversion' properties. This represents a field in the input event schema // along with a default value to be used, and at least one of these two properties should be provided. type JSONFieldWithDefault struct { // SourceField - Name of a field in the input event schema that's to be used as the source of a mapping. @@ -1942,11 +2698,11 @@ type JSONInputSchemaMappingProperties struct { DataVersion *JSONFieldWithDefault `json:"dataVersion,omitempty"` } -// NumberGreaterThanAdvancedFilter numberGreaterThan Filter +// NumberGreaterThanAdvancedFilter numberGreaterThan Advanced Filter. type NumberGreaterThanAdvancedFilter struct { - // Value - The filter value + // Value - The filter value. Value *float64 `json:"value,omitempty"` - // Key - The filter key. Represents an event property with up to two levels of nesting. + // Key - The field/property in the event based on which you want to filter. Key *string `json:"key,omitempty"` // OperatorType - Possible values include: 'OperatorTypeAdvancedFilter', 'OperatorTypeNumberIn', 'OperatorTypeNumberNotIn', 'OperatorTypeNumberLessThan', 'OperatorTypeNumberGreaterThan', 'OperatorTypeNumberLessThanOrEquals', 'OperatorTypeNumberGreaterThanOrEquals', 'OperatorTypeBoolEquals', 'OperatorTypeStringIn', 'OperatorTypeStringNotIn', 'OperatorTypeStringBeginsWith', 'OperatorTypeStringEndsWith', 'OperatorTypeStringContains' OperatorType OperatorType `json:"operatorType,omitempty"` @@ -2038,11 +2794,11 @@ func (ngtaf NumberGreaterThanAdvancedFilter) AsBasicAdvancedFilter() (BasicAdvan return &ngtaf, true } -// NumberGreaterThanOrEqualsAdvancedFilter numberGreaterThanOrEquals Filter +// NumberGreaterThanOrEqualsAdvancedFilter numberGreaterThanOrEquals Advanced Filter. type NumberGreaterThanOrEqualsAdvancedFilter struct { - // Value - The filter value + // Value - The filter value. Value *float64 `json:"value,omitempty"` - // Key - The filter key. Represents an event property with up to two levels of nesting. + // Key - The field/property in the event based on which you want to filter. Key *string `json:"key,omitempty"` // OperatorType - Possible values include: 'OperatorTypeAdvancedFilter', 'OperatorTypeNumberIn', 'OperatorTypeNumberNotIn', 'OperatorTypeNumberLessThan', 'OperatorTypeNumberGreaterThan', 'OperatorTypeNumberLessThanOrEquals', 'OperatorTypeNumberGreaterThanOrEquals', 'OperatorTypeBoolEquals', 'OperatorTypeStringIn', 'OperatorTypeStringNotIn', 'OperatorTypeStringBeginsWith', 'OperatorTypeStringEndsWith', 'OperatorTypeStringContains' OperatorType OperatorType `json:"operatorType,omitempty"` @@ -2134,11 +2890,11 @@ func (ngtoeaf NumberGreaterThanOrEqualsAdvancedFilter) AsBasicAdvancedFilter() ( return &ngtoeaf, true } -// NumberInAdvancedFilter numberIn filter +// NumberInAdvancedFilter numberIn Advanced Filter. type NumberInAdvancedFilter struct { - // Values - The set of filter values + // Values - The set of filter values. Values *[]float64 `json:"values,omitempty"` - // Key - The filter key. Represents an event property with up to two levels of nesting. + // Key - The field/property in the event based on which you want to filter. Key *string `json:"key,omitempty"` // OperatorType - Possible values include: 'OperatorTypeAdvancedFilter', 'OperatorTypeNumberIn', 'OperatorTypeNumberNotIn', 'OperatorTypeNumberLessThan', 'OperatorTypeNumberGreaterThan', 'OperatorTypeNumberLessThanOrEquals', 'OperatorTypeNumberGreaterThanOrEquals', 'OperatorTypeBoolEquals', 'OperatorTypeStringIn', 'OperatorTypeStringNotIn', 'OperatorTypeStringBeginsWith', 'OperatorTypeStringEndsWith', 'OperatorTypeStringContains' OperatorType OperatorType `json:"operatorType,omitempty"` @@ -2230,11 +2986,11 @@ func (niaf NumberInAdvancedFilter) AsBasicAdvancedFilter() (BasicAdvancedFilter, return &niaf, true } -// NumberLessThanAdvancedFilter numberLessThan Filter +// NumberLessThanAdvancedFilter numberLessThan Advanced Filter. type NumberLessThanAdvancedFilter struct { - // Value - The filter value + // Value - The filter value. Value *float64 `json:"value,omitempty"` - // Key - The filter key. Represents an event property with up to two levels of nesting. + // Key - The field/property in the event based on which you want to filter. Key *string `json:"key,omitempty"` // OperatorType - Possible values include: 'OperatorTypeAdvancedFilter', 'OperatorTypeNumberIn', 'OperatorTypeNumberNotIn', 'OperatorTypeNumberLessThan', 'OperatorTypeNumberGreaterThan', 'OperatorTypeNumberLessThanOrEquals', 'OperatorTypeNumberGreaterThanOrEquals', 'OperatorTypeBoolEquals', 'OperatorTypeStringIn', 'OperatorTypeStringNotIn', 'OperatorTypeStringBeginsWith', 'OperatorTypeStringEndsWith', 'OperatorTypeStringContains' OperatorType OperatorType `json:"operatorType,omitempty"` @@ -2326,11 +3082,11 @@ func (nltaf NumberLessThanAdvancedFilter) AsBasicAdvancedFilter() (BasicAdvanced return &nltaf, true } -// NumberLessThanOrEqualsAdvancedFilter numberLessThanOrEquals Filter +// NumberLessThanOrEqualsAdvancedFilter numberLessThanOrEquals Advanced Filter. type NumberLessThanOrEqualsAdvancedFilter struct { - // Value - The filter value + // Value - The filter value. Value *float64 `json:"value,omitempty"` - // Key - The filter key. Represents an event property with up to two levels of nesting. + // Key - The field/property in the event based on which you want to filter. Key *string `json:"key,omitempty"` // OperatorType - Possible values include: 'OperatorTypeAdvancedFilter', 'OperatorTypeNumberIn', 'OperatorTypeNumberNotIn', 'OperatorTypeNumberLessThan', 'OperatorTypeNumberGreaterThan', 'OperatorTypeNumberLessThanOrEquals', 'OperatorTypeNumberGreaterThanOrEquals', 'OperatorTypeBoolEquals', 'OperatorTypeStringIn', 'OperatorTypeStringNotIn', 'OperatorTypeStringBeginsWith', 'OperatorTypeStringEndsWith', 'OperatorTypeStringContains' OperatorType OperatorType `json:"operatorType,omitempty"` @@ -2422,11 +3178,11 @@ func (nltoeaf NumberLessThanOrEqualsAdvancedFilter) AsBasicAdvancedFilter() (Bas return &nltoeaf, true } -// NumberNotInAdvancedFilter numberNotIn Filter +// NumberNotInAdvancedFilter numberNotIn Advanced Filter. type NumberNotInAdvancedFilter struct { - // Values - The set of filter values + // Values - The set of filter values. Values *[]float64 `json:"values,omitempty"` - // Key - The filter key. Represents an event property with up to two levels of nesting. + // Key - The field/property in the event based on which you want to filter. Key *string `json:"key,omitempty"` // OperatorType - Possible values include: 'OperatorTypeAdvancedFilter', 'OperatorTypeNumberIn', 'OperatorTypeNumberNotIn', 'OperatorTypeNumberLessThan', 'OperatorTypeNumberGreaterThan', 'OperatorTypeNumberLessThanOrEquals', 'OperatorTypeNumberGreaterThanOrEquals', 'OperatorTypeBoolEquals', 'OperatorTypeStringIn', 'OperatorTypeStringNotIn', 'OperatorTypeStringBeginsWith', 'OperatorTypeStringEndsWith', 'OperatorTypeStringContains' OperatorType OperatorType `json:"operatorType,omitempty"` @@ -2567,6 +3323,220 @@ type RetryPolicy struct { EventTimeToLiveInMinutes *int32 `json:"eventTimeToLiveInMinutes,omitempty"` } +// ServiceBusQueueEventSubscriptionDestination information about the service bus destination for an event +// subscription +type ServiceBusQueueEventSubscriptionDestination struct { + // ServiceBusQueueEventSubscriptionDestinationProperties - Service Bus Properties of the event subscription destination + *ServiceBusQueueEventSubscriptionDestinationProperties `json:"properties,omitempty"` + // EndpointType - Possible values include: 'EndpointTypeEventSubscriptionDestination', 'EndpointTypeWebHook', 'EndpointTypeEventHub', 'EndpointTypeStorageQueue', 'EndpointTypeHybridConnection', 'EndpointTypeServiceBusQueue', 'EndpointTypeServiceBusTopic', 'EndpointTypeAzureFunction' + EndpointType EndpointType `json:"endpointType,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServiceBusQueueEventSubscriptionDestination. +func (sbqesd ServiceBusQueueEventSubscriptionDestination) MarshalJSON() ([]byte, error) { + sbqesd.EndpointType = EndpointTypeServiceBusQueue + objectMap := make(map[string]interface{}) + if sbqesd.ServiceBusQueueEventSubscriptionDestinationProperties != nil { + objectMap["properties"] = sbqesd.ServiceBusQueueEventSubscriptionDestinationProperties + } + if sbqesd.EndpointType != "" { + objectMap["endpointType"] = sbqesd.EndpointType + } + return json.Marshal(objectMap) +} + +// AsWebHookEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for ServiceBusQueueEventSubscriptionDestination. +func (sbqesd ServiceBusQueueEventSubscriptionDestination) AsWebHookEventSubscriptionDestination() (*WebHookEventSubscriptionDestination, bool) { + return nil, false +} + +// AsEventHubEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for ServiceBusQueueEventSubscriptionDestination. +func (sbqesd ServiceBusQueueEventSubscriptionDestination) AsEventHubEventSubscriptionDestination() (*EventHubEventSubscriptionDestination, bool) { + return nil, false +} + +// AsStorageQueueEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for ServiceBusQueueEventSubscriptionDestination. +func (sbqesd ServiceBusQueueEventSubscriptionDestination) AsStorageQueueEventSubscriptionDestination() (*StorageQueueEventSubscriptionDestination, bool) { + return nil, false +} + +// AsHybridConnectionEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for ServiceBusQueueEventSubscriptionDestination. +func (sbqesd ServiceBusQueueEventSubscriptionDestination) AsHybridConnectionEventSubscriptionDestination() (*HybridConnectionEventSubscriptionDestination, bool) { + return nil, false +} + +// AsServiceBusQueueEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for ServiceBusQueueEventSubscriptionDestination. +func (sbqesd ServiceBusQueueEventSubscriptionDestination) AsServiceBusQueueEventSubscriptionDestination() (*ServiceBusQueueEventSubscriptionDestination, bool) { + return &sbqesd, true +} + +// AsServiceBusTopicEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for ServiceBusQueueEventSubscriptionDestination. +func (sbqesd ServiceBusQueueEventSubscriptionDestination) AsServiceBusTopicEventSubscriptionDestination() (*ServiceBusTopicEventSubscriptionDestination, bool) { + return nil, false +} + +// AsAzureFunctionEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for ServiceBusQueueEventSubscriptionDestination. +func (sbqesd ServiceBusQueueEventSubscriptionDestination) AsAzureFunctionEventSubscriptionDestination() (*AzureFunctionEventSubscriptionDestination, bool) { + return nil, false +} + +// AsEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for ServiceBusQueueEventSubscriptionDestination. +func (sbqesd ServiceBusQueueEventSubscriptionDestination) AsEventSubscriptionDestination() (*EventSubscriptionDestination, bool) { + return nil, false +} + +// AsBasicEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for ServiceBusQueueEventSubscriptionDestination. +func (sbqesd ServiceBusQueueEventSubscriptionDestination) AsBasicEventSubscriptionDestination() (BasicEventSubscriptionDestination, bool) { + return &sbqesd, true +} + +// UnmarshalJSON is the custom unmarshaler for ServiceBusQueueEventSubscriptionDestination struct. +func (sbqesd *ServiceBusQueueEventSubscriptionDestination) 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 serviceBusQueueEventSubscriptionDestinationProperties ServiceBusQueueEventSubscriptionDestinationProperties + err = json.Unmarshal(*v, &serviceBusQueueEventSubscriptionDestinationProperties) + if err != nil { + return err + } + sbqesd.ServiceBusQueueEventSubscriptionDestinationProperties = &serviceBusQueueEventSubscriptionDestinationProperties + } + case "endpointType": + if v != nil { + var endpointType EndpointType + err = json.Unmarshal(*v, &endpointType) + if err != nil { + return err + } + sbqesd.EndpointType = endpointType + } + } + } + + return nil +} + +// ServiceBusQueueEventSubscriptionDestinationProperties the properties that represent the Service Bus +// destination of an event subscription. +type ServiceBusQueueEventSubscriptionDestinationProperties struct { + // ResourceID - The Azure Resource Id that represents the endpoint of the Service Bus destination of an event subscription. + ResourceID *string `json:"resourceId,omitempty"` +} + +// ServiceBusTopicEventSubscriptionDestination information about the service bus topic destination for an +// event subscription. +type ServiceBusTopicEventSubscriptionDestination struct { + // ServiceBusTopicEventSubscriptionDestinationProperties - Service Bus Topic Properties of the event subscription destination. + *ServiceBusTopicEventSubscriptionDestinationProperties `json:"properties,omitempty"` + // EndpointType - Possible values include: 'EndpointTypeEventSubscriptionDestination', 'EndpointTypeWebHook', 'EndpointTypeEventHub', 'EndpointTypeStorageQueue', 'EndpointTypeHybridConnection', 'EndpointTypeServiceBusQueue', 'EndpointTypeServiceBusTopic', 'EndpointTypeAzureFunction' + EndpointType EndpointType `json:"endpointType,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServiceBusTopicEventSubscriptionDestination. +func (sbtesd ServiceBusTopicEventSubscriptionDestination) MarshalJSON() ([]byte, error) { + sbtesd.EndpointType = EndpointTypeServiceBusTopic + objectMap := make(map[string]interface{}) + if sbtesd.ServiceBusTopicEventSubscriptionDestinationProperties != nil { + objectMap["properties"] = sbtesd.ServiceBusTopicEventSubscriptionDestinationProperties + } + if sbtesd.EndpointType != "" { + objectMap["endpointType"] = sbtesd.EndpointType + } + return json.Marshal(objectMap) +} + +// AsWebHookEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for ServiceBusTopicEventSubscriptionDestination. +func (sbtesd ServiceBusTopicEventSubscriptionDestination) AsWebHookEventSubscriptionDestination() (*WebHookEventSubscriptionDestination, bool) { + return nil, false +} + +// AsEventHubEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for ServiceBusTopicEventSubscriptionDestination. +func (sbtesd ServiceBusTopicEventSubscriptionDestination) AsEventHubEventSubscriptionDestination() (*EventHubEventSubscriptionDestination, bool) { + return nil, false +} + +// AsStorageQueueEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for ServiceBusTopicEventSubscriptionDestination. +func (sbtesd ServiceBusTopicEventSubscriptionDestination) AsStorageQueueEventSubscriptionDestination() (*StorageQueueEventSubscriptionDestination, bool) { + return nil, false +} + +// AsHybridConnectionEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for ServiceBusTopicEventSubscriptionDestination. +func (sbtesd ServiceBusTopicEventSubscriptionDestination) AsHybridConnectionEventSubscriptionDestination() (*HybridConnectionEventSubscriptionDestination, bool) { + return nil, false +} + +// AsServiceBusQueueEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for ServiceBusTopicEventSubscriptionDestination. +func (sbtesd ServiceBusTopicEventSubscriptionDestination) AsServiceBusQueueEventSubscriptionDestination() (*ServiceBusQueueEventSubscriptionDestination, bool) { + return nil, false +} + +// AsServiceBusTopicEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for ServiceBusTopicEventSubscriptionDestination. +func (sbtesd ServiceBusTopicEventSubscriptionDestination) AsServiceBusTopicEventSubscriptionDestination() (*ServiceBusTopicEventSubscriptionDestination, bool) { + return &sbtesd, true +} + +// AsAzureFunctionEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for ServiceBusTopicEventSubscriptionDestination. +func (sbtesd ServiceBusTopicEventSubscriptionDestination) AsAzureFunctionEventSubscriptionDestination() (*AzureFunctionEventSubscriptionDestination, bool) { + return nil, false +} + +// AsEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for ServiceBusTopicEventSubscriptionDestination. +func (sbtesd ServiceBusTopicEventSubscriptionDestination) AsEventSubscriptionDestination() (*EventSubscriptionDestination, bool) { + return nil, false +} + +// AsBasicEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for ServiceBusTopicEventSubscriptionDestination. +func (sbtesd ServiceBusTopicEventSubscriptionDestination) AsBasicEventSubscriptionDestination() (BasicEventSubscriptionDestination, bool) { + return &sbtesd, true +} + +// UnmarshalJSON is the custom unmarshaler for ServiceBusTopicEventSubscriptionDestination struct. +func (sbtesd *ServiceBusTopicEventSubscriptionDestination) 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 serviceBusTopicEventSubscriptionDestinationProperties ServiceBusTopicEventSubscriptionDestinationProperties + err = json.Unmarshal(*v, &serviceBusTopicEventSubscriptionDestinationProperties) + if err != nil { + return err + } + sbtesd.ServiceBusTopicEventSubscriptionDestinationProperties = &serviceBusTopicEventSubscriptionDestinationProperties + } + case "endpointType": + if v != nil { + var endpointType EndpointType + err = json.Unmarshal(*v, &endpointType) + if err != nil { + return err + } + sbtesd.EndpointType = endpointType + } + } + } + + return nil +} + +// ServiceBusTopicEventSubscriptionDestinationProperties the properties that represent the Service Bus +// Topic destination of an event subscription. +type ServiceBusTopicEventSubscriptionDestinationProperties struct { + // ResourceID - The Azure Resource Id that represents the endpoint of the Service Bus Topic destination of an event subscription. + ResourceID *string `json:"resourceId,omitempty"` +} + // StorageBlobDeadLetterDestination information about the storage blob based dead letter destination. type StorageBlobDeadLetterDestination struct { // StorageBlobDeadLetterDestinationProperties - The properties of the Storage Blob based deadletter destination @@ -2649,7 +3619,7 @@ type StorageBlobDeadLetterDestinationProperties struct { type StorageQueueEventSubscriptionDestination struct { // StorageQueueEventSubscriptionDestinationProperties - Storage Queue Properties of the event subscription destination *StorageQueueEventSubscriptionDestinationProperties `json:"properties,omitempty"` - // EndpointType - Possible values include: 'EndpointTypeEventSubscriptionDestination', 'EndpointTypeWebHook', 'EndpointTypeEventHub', 'EndpointTypeStorageQueue', 'EndpointTypeHybridConnection' + // EndpointType - Possible values include: 'EndpointTypeEventSubscriptionDestination', 'EndpointTypeWebHook', 'EndpointTypeEventHub', 'EndpointTypeStorageQueue', 'EndpointTypeHybridConnection', 'EndpointTypeServiceBusQueue', 'EndpointTypeServiceBusTopic', 'EndpointTypeAzureFunction' EndpointType EndpointType `json:"endpointType,omitempty"` } @@ -2686,6 +3656,21 @@ func (sqesd StorageQueueEventSubscriptionDestination) AsHybridConnectionEventSub return nil, false } +// AsServiceBusQueueEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for StorageQueueEventSubscriptionDestination. +func (sqesd StorageQueueEventSubscriptionDestination) AsServiceBusQueueEventSubscriptionDestination() (*ServiceBusQueueEventSubscriptionDestination, bool) { + return nil, false +} + +// AsServiceBusTopicEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for StorageQueueEventSubscriptionDestination. +func (sqesd StorageQueueEventSubscriptionDestination) AsServiceBusTopicEventSubscriptionDestination() (*ServiceBusTopicEventSubscriptionDestination, bool) { + return nil, false +} + +// AsAzureFunctionEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for StorageQueueEventSubscriptionDestination. +func (sqesd StorageQueueEventSubscriptionDestination) AsAzureFunctionEventSubscriptionDestination() (*AzureFunctionEventSubscriptionDestination, bool) { + return nil, false +} + // AsEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for StorageQueueEventSubscriptionDestination. func (sqesd StorageQueueEventSubscriptionDestination) AsEventSubscriptionDestination() (*EventSubscriptionDestination, bool) { return nil, false @@ -2737,11 +3722,11 @@ type StorageQueueEventSubscriptionDestinationProperties struct { QueueName *string `json:"queueName,omitempty"` } -// StringBeginsWithAdvancedFilter stringBeginsWith Filter +// StringBeginsWithAdvancedFilter stringBeginsWith Advanced Filter. type StringBeginsWithAdvancedFilter struct { - // Values - The set of filter values + // Values - The set of filter values. Values *[]string `json:"values,omitempty"` - // Key - The filter key. Represents an event property with up to two levels of nesting. + // Key - The field/property in the event based on which you want to filter. Key *string `json:"key,omitempty"` // OperatorType - Possible values include: 'OperatorTypeAdvancedFilter', 'OperatorTypeNumberIn', 'OperatorTypeNumberNotIn', 'OperatorTypeNumberLessThan', 'OperatorTypeNumberGreaterThan', 'OperatorTypeNumberLessThanOrEquals', 'OperatorTypeNumberGreaterThanOrEquals', 'OperatorTypeBoolEquals', 'OperatorTypeStringIn', 'OperatorTypeStringNotIn', 'OperatorTypeStringBeginsWith', 'OperatorTypeStringEndsWith', 'OperatorTypeStringContains' OperatorType OperatorType `json:"operatorType,omitempty"` @@ -2833,11 +3818,11 @@ func (sbwaf StringBeginsWithAdvancedFilter) AsBasicAdvancedFilter() (BasicAdvanc return &sbwaf, true } -// StringContainsAdvancedFilter stringContains Filter +// StringContainsAdvancedFilter stringContains Advanced Filter. type StringContainsAdvancedFilter struct { - // Values - The set of filter values + // Values - The set of filter values. Values *[]string `json:"values,omitempty"` - // Key - The filter key. Represents an event property with up to two levels of nesting. + // Key - The field/property in the event based on which you want to filter. Key *string `json:"key,omitempty"` // OperatorType - Possible values include: 'OperatorTypeAdvancedFilter', 'OperatorTypeNumberIn', 'OperatorTypeNumberNotIn', 'OperatorTypeNumberLessThan', 'OperatorTypeNumberGreaterThan', 'OperatorTypeNumberLessThanOrEquals', 'OperatorTypeNumberGreaterThanOrEquals', 'OperatorTypeBoolEquals', 'OperatorTypeStringIn', 'OperatorTypeStringNotIn', 'OperatorTypeStringBeginsWith', 'OperatorTypeStringEndsWith', 'OperatorTypeStringContains' OperatorType OperatorType `json:"operatorType,omitempty"` @@ -2929,11 +3914,11 @@ func (scaf StringContainsAdvancedFilter) AsBasicAdvancedFilter() (BasicAdvancedF return &scaf, true } -// StringEndsWithAdvancedFilter stringEndsWith Filter +// StringEndsWithAdvancedFilter stringEndsWith Advanced Filter. type StringEndsWithAdvancedFilter struct { - // Values - The set of filter values + // Values - The set of filter values. Values *[]string `json:"values,omitempty"` - // Key - The filter key. Represents an event property with up to two levels of nesting. + // Key - The field/property in the event based on which you want to filter. Key *string `json:"key,omitempty"` // OperatorType - Possible values include: 'OperatorTypeAdvancedFilter', 'OperatorTypeNumberIn', 'OperatorTypeNumberNotIn', 'OperatorTypeNumberLessThan', 'OperatorTypeNumberGreaterThan', 'OperatorTypeNumberLessThanOrEquals', 'OperatorTypeNumberGreaterThanOrEquals', 'OperatorTypeBoolEquals', 'OperatorTypeStringIn', 'OperatorTypeStringNotIn', 'OperatorTypeStringBeginsWith', 'OperatorTypeStringEndsWith', 'OperatorTypeStringContains' OperatorType OperatorType `json:"operatorType,omitempty"` @@ -3025,11 +4010,11 @@ func (sewaf StringEndsWithAdvancedFilter) AsBasicAdvancedFilter() (BasicAdvanced return &sewaf, true } -// StringInAdvancedFilter stringIn Filter +// StringInAdvancedFilter stringIn Advanced Filter. type StringInAdvancedFilter struct { - // Values - The set of filter values + // Values - The set of filter values. Values *[]string `json:"values,omitempty"` - // Key - The filter key. Represents an event property with up to two levels of nesting. + // Key - The field/property in the event based on which you want to filter. Key *string `json:"key,omitempty"` // OperatorType - Possible values include: 'OperatorTypeAdvancedFilter', 'OperatorTypeNumberIn', 'OperatorTypeNumberNotIn', 'OperatorTypeNumberLessThan', 'OperatorTypeNumberGreaterThan', 'OperatorTypeNumberLessThanOrEquals', 'OperatorTypeNumberGreaterThanOrEquals', 'OperatorTypeBoolEquals', 'OperatorTypeStringIn', 'OperatorTypeStringNotIn', 'OperatorTypeStringBeginsWith', 'OperatorTypeStringEndsWith', 'OperatorTypeStringContains' OperatorType OperatorType `json:"operatorType,omitempty"` @@ -3121,11 +4106,11 @@ func (siaf StringInAdvancedFilter) AsBasicAdvancedFilter() (BasicAdvancedFilter, return &siaf, true } -// StringNotInAdvancedFilter stringNotIn Filter +// StringNotInAdvancedFilter stringNotIn Advanced Filter. type StringNotInAdvancedFilter struct { - // Values - The set of filter values + // Values - The set of filter values. Values *[]string `json:"values,omitempty"` - // Key - The filter key. Represents an event property with up to two levels of nesting. + // Key - The field/property in the event based on which you want to filter. Key *string `json:"key,omitempty"` // OperatorType - Possible values include: 'OperatorTypeAdvancedFilter', 'OperatorTypeNumberIn', 'OperatorTypeNumberNotIn', 'OperatorTypeNumberLessThan', 'OperatorTypeNumberGreaterThan', 'OperatorTypeNumberLessThanOrEquals', 'OperatorTypeNumberGreaterThanOrEquals', 'OperatorTypeBoolEquals', 'OperatorTypeStringIn', 'OperatorTypeStringNotIn', 'OperatorTypeStringBeginsWith', 'OperatorTypeStringEndsWith', 'OperatorTypeStringContains' OperatorType OperatorType `json:"operatorType,omitempty"` @@ -3324,10 +4309,12 @@ type TopicProperties struct { ProvisioningState TopicProvisioningState `json:"provisioningState,omitempty"` // Endpoint - READ-ONLY; Endpoint for the topic. Endpoint *string `json:"endpoint,omitempty"` - // InputSchema - This determines the format that Event Grid should expect for incoming events published to the topic. Possible values include: 'InputSchemaEventGridSchema', 'InputSchemaCustomEventSchema', 'InputSchemaCloudEventV01Schema' + // InputSchema - This determines the format that Event Grid should expect for incoming events published to the topic. Possible values include: 'InputSchemaEventGridSchema', 'InputSchemaCustomEventSchema', 'InputSchemaCloudEventSchemaV10' InputSchema InputSchema `json:"inputSchema,omitempty"` // InputSchemaMapping - This enables publishing using custom event schemas. An InputSchemaMapping can be specified to map various properties of a source schema to various required properties of the EventGridEvent schema. InputSchemaMapping BasicInputSchemaMapping `json:"inputSchemaMapping,omitempty"` + // MetricResourceID - READ-ONLY; Metric resource id for the topic. + MetricResourceID *string `json:"metricResourceId,omitempty"` } // UnmarshalJSON is the custom unmarshaler for TopicProperties struct. @@ -3374,6 +4361,15 @@ func (tp *TopicProperties) UnmarshalJSON(body []byte) error { } tp.InputSchemaMapping = inputSchemaMapping } + case "metricResourceId": + if v != nil { + var metricResourceID string + err = json.Unmarshal(*v, &metricResourceID) + if err != nil { + return err + } + tp.MetricResourceID = &metricResourceID + } } } @@ -3451,6 +4447,145 @@ type TopicsListResult struct { autorest.Response `json:"-"` // Value - A collection of Topics Value *[]Topic `json:"value,omitempty"` + // NextLink - A link for the next page of topics + NextLink *string `json:"nextLink,omitempty"` +} + +// TopicsListResultIterator provides access to a complete listing of Topic values. +type TopicsListResultIterator struct { + i int + page TopicsListResultPage +} + +// 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 *TopicsListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TopicsListResultIterator.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 *TopicsListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter TopicsListResultIterator) 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 TopicsListResultIterator) Response() TopicsListResult { + 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 TopicsListResultIterator) Value() Topic { + if !iter.page.NotDone() { + return Topic{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the TopicsListResultIterator type. +func NewTopicsListResultIterator(page TopicsListResultPage) TopicsListResultIterator { + return TopicsListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (tlr TopicsListResult) IsEmpty() bool { + return tlr.Value == nil || len(*tlr.Value) == 0 +} + +// topicsListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (tlr TopicsListResult) topicsListResultPreparer(ctx context.Context) (*http.Request, error) { + if tlr.NextLink == nil || len(to.String(tlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(tlr.NextLink))) +} + +// TopicsListResultPage contains a page of Topic values. +type TopicsListResultPage struct { + fn func(context.Context, TopicsListResult) (TopicsListResult, error) + tlr TopicsListResult +} + +// 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 *TopicsListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TopicsListResultPage.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.tlr) + if err != nil { + return err + } + page.tlr = 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 *TopicsListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page TopicsListResultPage) NotDone() bool { + return !page.tlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page TopicsListResultPage) Response() TopicsListResult { + return page.tlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page TopicsListResultPage) Values() []Topic { + if page.tlr.IsEmpty() { + return nil + } + return *page.tlr.Value +} + +// Creates a new instance of the TopicsListResultPage type. +func NewTopicsListResultPage(getNextPage func(context.Context, TopicsListResult) (TopicsListResult, error)) TopicsListResultPage { + return TopicsListResultPage{fn: getNextPage} } // TopicsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation. @@ -3622,7 +4757,7 @@ func (tr TrackedResource) MarshalJSON() ([]byte, error) { type WebHookEventSubscriptionDestination struct { // WebHookEventSubscriptionDestinationProperties - WebHook Properties of the event subscription destination *WebHookEventSubscriptionDestinationProperties `json:"properties,omitempty"` - // EndpointType - Possible values include: 'EndpointTypeEventSubscriptionDestination', 'EndpointTypeWebHook', 'EndpointTypeEventHub', 'EndpointTypeStorageQueue', 'EndpointTypeHybridConnection' + // EndpointType - Possible values include: 'EndpointTypeEventSubscriptionDestination', 'EndpointTypeWebHook', 'EndpointTypeEventHub', 'EndpointTypeStorageQueue', 'EndpointTypeHybridConnection', 'EndpointTypeServiceBusQueue', 'EndpointTypeServiceBusTopic', 'EndpointTypeAzureFunction' EndpointType EndpointType `json:"endpointType,omitempty"` } @@ -3659,6 +4794,21 @@ func (whesd WebHookEventSubscriptionDestination) AsHybridConnectionEventSubscrip return nil, false } +// AsServiceBusQueueEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for WebHookEventSubscriptionDestination. +func (whesd WebHookEventSubscriptionDestination) AsServiceBusQueueEventSubscriptionDestination() (*ServiceBusQueueEventSubscriptionDestination, bool) { + return nil, false +} + +// AsServiceBusTopicEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for WebHookEventSubscriptionDestination. +func (whesd WebHookEventSubscriptionDestination) AsServiceBusTopicEventSubscriptionDestination() (*ServiceBusTopicEventSubscriptionDestination, bool) { + return nil, false +} + +// AsAzureFunctionEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for WebHookEventSubscriptionDestination. +func (whesd WebHookEventSubscriptionDestination) AsAzureFunctionEventSubscriptionDestination() (*AzureFunctionEventSubscriptionDestination, bool) { + return nil, false +} + // AsEventSubscriptionDestination is the BasicEventSubscriptionDestination implementation for WebHookEventSubscriptionDestination. func (whesd WebHookEventSubscriptionDestination) AsEventSubscriptionDestination() (*EventSubscriptionDestination, bool) { return nil, false @@ -3709,4 +4859,12 @@ type WebHookEventSubscriptionDestinationProperties struct { EndpointURL *string `json:"endpointUrl,omitempty"` // EndpointBaseURL - READ-ONLY; The base URL that represents the endpoint of the destination of an event subscription. EndpointBaseURL *string `json:"endpointBaseUrl,omitempty"` + // MaxEventsPerBatch - Maximum number of events per batch. + MaxEventsPerBatch *int32 `json:"maxEventsPerBatch,omitempty"` + // PreferredBatchSizeInKilobytes - Preferred batch size in Kilobytes. + PreferredBatchSizeInKilobytes *int32 `json:"preferredBatchSizeInKilobytes,omitempty"` + // AzureActiveDirectoryTenantID - The Azure Active Directory Tenant ID to get the access token that will be included as the bearer token in delivery requests. + AzureActiveDirectoryTenantID *string `json:"azureActiveDirectoryTenantId,omitempty"` + // AzureActiveDirectoryApplicationIDOrURI - The Azure Active Directory Application ID or URI to get the access token that will be included as the bearer token in delivery requests. + AzureActiveDirectoryApplicationIDOrURI *string `json:"azureActiveDirectoryApplicationIdOrUri,omitempty"` } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2018-09-15-preview/eventgrid/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2020-01-01-preview/eventgrid/operations.go similarity index 98% rename from vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2018-09-15-preview/eventgrid/operations.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2020-01-01-preview/eventgrid/operations.go index 01730ff5f85b..3f505a3f7b40 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2018-09-15-preview/eventgrid/operations.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2020-01-01-preview/eventgrid/operations.go @@ -76,7 +76,7 @@ func (client OperationsClient) List(ctx context.Context) (result OperationsListR // ListPreparer prepares the List request. func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { - const APIVersion = "2018-09-15-preview" + const APIVersion = "2020-01-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2018-09-15-preview/eventgrid/topics.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2020-01-01-preview/eventgrid/topics.go similarity index 81% rename from vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2018-09-15-preview/eventgrid/topics.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2020-01-01-preview/eventgrid/topics.go index 9991b5b815e7..ffcf79476157 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2018-09-15-preview/eventgrid/topics.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2020-01-01-preview/eventgrid/topics.go @@ -81,7 +81,7 @@ func (client TopicsClient) CreateOrUpdatePreparer(ctx context.Context, resourceG "topicName": autorest.Encode("path", topicName), } - const APIVersion = "2018-09-15-preview" + const APIVersion = "2020-01-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -159,7 +159,7 @@ func (client TopicsClient) DeletePreparer(ctx context.Context, resourceGroupName "topicName": autorest.Encode("path", topicName), } - const APIVersion = "2018-09-15-preview" + const APIVersion = "2020-01-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -240,7 +240,7 @@ func (client TopicsClient) GetPreparer(ctx context.Context, resourceGroupName st "topicName": autorest.Encode("path", topicName), } - const APIVersion = "2018-09-15-preview" + const APIVersion = "2020-01-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -275,18 +275,27 @@ func (client TopicsClient) GetResponder(resp *http.Response) (result Topic, err // ListByResourceGroup list all the topics under a resource group // Parameters: // resourceGroupName - the name of the resource group within the user's subscription. -func (client TopicsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result TopicsListResult, err error) { +// filter - the query used to filter the search results using OData syntax. Filtering is permitted on the +// 'name' property only and with limited number of OData operations. These operations are: the 'contains' +// function as well as the following logical operations: not, and, or, eq (for equal), and ne (for not equal). +// No arithmetic operations are supported. The following is a valid filter example: $filter=contains(namE, +// 'PATTERN') and name ne 'PATTERN-1'. The following is not a valid filter example: $filter=location eq +// 'westus'. +// top - the number of results to return per page for the list operation. Valid range for top parameter is 1 to +// 100. If not specified, the default number of results to be returned is 20 items per page. +func (client TopicsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, filter string, top *int32) (result TopicsListResultPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/TopicsClient.ListByResourceGroup") defer func() { sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode + if result.tlr.Response.Response != nil { + sc = result.tlr.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() } - req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName, filter, top) if err != nil { err = autorest.NewErrorWithError(err, "eventgrid.TopicsClient", "ListByResourceGroup", nil, "Failure preparing request") return @@ -294,12 +303,12 @@ func (client TopicsClient) ListByResourceGroup(ctx context.Context, resourceGrou resp, err := client.ListByResourceGroupSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.tlr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "eventgrid.TopicsClient", "ListByResourceGroup", resp, "Failure sending request") return } - result, err = client.ListByResourceGroupResponder(resp) + result.tlr, err = client.ListByResourceGroupResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "eventgrid.TopicsClient", "ListByResourceGroup", resp, "Failure responding to request") } @@ -308,16 +317,22 @@ func (client TopicsClient) ListByResourceGroup(ctx context.Context, resourceGrou } // ListByResourceGroupPreparer prepares the ListByResourceGroup request. -func (client TopicsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { +func (client TopicsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string, filter string, top *int32) (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2018-09-15-preview" + const APIVersion = "2020-01-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } preparer := autorest.CreatePreparer( autorest.AsGet(), @@ -346,19 +361,66 @@ func (client TopicsClient) ListByResourceGroupResponder(resp *http.Response) (re return } +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client TopicsClient) listByResourceGroupNextResults(ctx context.Context, lastResults TopicsListResult) (result TopicsListResult, err error) { + req, err := lastResults.topicsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "eventgrid.TopicsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "eventgrid.TopicsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "eventgrid.TopicsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client TopicsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string, filter string, top *int32) (result TopicsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TopicsClient.ListByResourceGroup") + 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.ListByResourceGroup(ctx, resourceGroupName, filter, top) + return +} + // ListBySubscription list all the topics under an Azure subscription -func (client TopicsClient) ListBySubscription(ctx context.Context) (result TopicsListResult, err error) { +// Parameters: +// filter - the query used to filter the search results using OData syntax. Filtering is permitted on the +// 'name' property only and with limited number of OData operations. These operations are: the 'contains' +// function as well as the following logical operations: not, and, or, eq (for equal), and ne (for not equal). +// No arithmetic operations are supported. The following is a valid filter example: $filter=contains(namE, +// 'PATTERN') and name ne 'PATTERN-1'. The following is not a valid filter example: $filter=location eq +// 'westus'. +// top - the number of results to return per page for the list operation. Valid range for top parameter is 1 to +// 100. If not specified, the default number of results to be returned is 20 items per page. +func (client TopicsClient) ListBySubscription(ctx context.Context, filter string, top *int32) (result TopicsListResultPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/TopicsClient.ListBySubscription") defer func() { sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode + if result.tlr.Response.Response != nil { + sc = result.tlr.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() } - req, err := client.ListBySubscriptionPreparer(ctx) + result.fn = client.listBySubscriptionNextResults + req, err := client.ListBySubscriptionPreparer(ctx, filter, top) if err != nil { err = autorest.NewErrorWithError(err, "eventgrid.TopicsClient", "ListBySubscription", nil, "Failure preparing request") return @@ -366,12 +428,12 @@ func (client TopicsClient) ListBySubscription(ctx context.Context) (result Topic resp, err := client.ListBySubscriptionSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.tlr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "eventgrid.TopicsClient", "ListBySubscription", resp, "Failure sending request") return } - result, err = client.ListBySubscriptionResponder(resp) + result.tlr, err = client.ListBySubscriptionResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "eventgrid.TopicsClient", "ListBySubscription", resp, "Failure responding to request") } @@ -380,15 +442,21 @@ func (client TopicsClient) ListBySubscription(ctx context.Context) (result Topic } // ListBySubscriptionPreparer prepares the ListBySubscription request. -func (client TopicsClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { +func (client TopicsClient) ListBySubscriptionPreparer(ctx context.Context, filter string, top *int32) (*http.Request, error) { pathParameters := map[string]interface{}{ "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2018-09-15-preview" + const APIVersion = "2020-01-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } preparer := autorest.CreatePreparer( autorest.AsGet(), @@ -417,6 +485,43 @@ func (client TopicsClient) ListBySubscriptionResponder(resp *http.Response) (res return } +// listBySubscriptionNextResults retrieves the next set of results, if any. +func (client TopicsClient) listBySubscriptionNextResults(ctx context.Context, lastResults TopicsListResult) (result TopicsListResult, err error) { + req, err := lastResults.topicsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "eventgrid.TopicsClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "eventgrid.TopicsClient", "listBySubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "eventgrid.TopicsClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client TopicsClient) ListBySubscriptionComplete(ctx context.Context, filter string, top *int32) (result TopicsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TopicsClient.ListBySubscription") + 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.ListBySubscription(ctx, filter, top) + return +} + // ListEventTypes list event types for a topic // Parameters: // resourceGroupName - the name of the resource group within the user's subscription. @@ -465,7 +570,7 @@ func (client TopicsClient) ListEventTypesPreparer(ctx context.Context, resourceG "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2018-09-15-preview" + const APIVersion = "2020-01-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -541,7 +646,7 @@ func (client TopicsClient) ListSharedAccessKeysPreparer(ctx context.Context, res "topicName": autorest.Encode("path", topicName), } - const APIVersion = "2018-09-15-preview" + const APIVersion = "2020-01-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -624,7 +729,7 @@ func (client TopicsClient) RegenerateKeyPreparer(ctx context.Context, resourceGr "topicName": autorest.Encode("path", topicName), } - const APIVersion = "2018-09-15-preview" + const APIVersion = "2020-01-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -697,7 +802,7 @@ func (client TopicsClient) UpdatePreparer(ctx context.Context, resourceGroupName "topicName": autorest.Encode("path", topicName), } - const APIVersion = "2018-09-15-preview" + const APIVersion = "2020-01-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2018-09-15-preview/eventgrid/topictypes.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2020-01-01-preview/eventgrid/topictypes.go similarity index 98% rename from vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2018-09-15-preview/eventgrid/topictypes.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2020-01-01-preview/eventgrid/topictypes.go index 9a3ca4c7cc10..ac7c105f3d68 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2018-09-15-preview/eventgrid/topictypes.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2020-01-01-preview/eventgrid/topictypes.go @@ -82,7 +82,7 @@ func (client TopicTypesClient) GetPreparer(ctx context.Context, topicTypeName st "topicTypeName": autorest.Encode("path", topicTypeName), } - const APIVersion = "2018-09-15-preview" + const APIVersion = "2020-01-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -149,7 +149,7 @@ func (client TopicTypesClient) List(ctx context.Context) (result TopicTypesListR // ListPreparer prepares the List request. func (client TopicTypesClient) ListPreparer(ctx context.Context) (*http.Request, error) { - const APIVersion = "2018-09-15-preview" + const APIVersion = "2020-01-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -222,7 +222,7 @@ func (client TopicTypesClient) ListEventTypesPreparer(ctx context.Context, topic "topicTypeName": autorest.Encode("path", topicTypeName), } - const APIVersion = "2018-09-15-preview" + const APIVersion = "2020-01-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2018-09-15-preview/eventgrid/version.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2020-01-01-preview/eventgrid/version.go similarity index 93% rename from vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2018-09-15-preview/eventgrid/version.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2020-01-01-preview/eventgrid/version.go index 8a5b18bcded6..3ce1a5d9a935 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2018-09-15-preview/eventgrid/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2020-01-01-preview/eventgrid/version.go @@ -21,7 +21,7 @@ import "github.com/Azure/azure-sdk-for-go/version" // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/" + version.Number + " eventgrid/2018-09-15-preview" + return "Azure-SDK-For-Go/" + version.Number + " eventgrid/2020-01-01-preview" } // Version returns the semantic version (see http://semver.org) of the client. diff --git a/vendor/modules.txt b/vendor/modules.txt index 779961db7630..ac8d25bec05c 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -57,7 +57,7 @@ github.com/Azure/azure-sdk-for-go/services/preview/appplatform/mgmt/2019-05-01-p github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization github.com/Azure/azure-sdk-for-go/services/preview/botservice/mgmt/2018-07-12/botservice github.com/Azure/azure-sdk-for-go/services/preview/customproviders/mgmt/2018-09-01-preview/customproviders -github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2018-09-15-preview/eventgrid +github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2020-01-01-preview/eventgrid github.com/Azure/azure-sdk-for-go/services/preview/hdinsight/mgmt/2018-06-01-preview/hdinsight github.com/Azure/azure-sdk-for-go/services/preview/iothub/mgmt/2018-12-01-preview/devices github.com/Azure/azure-sdk-for-go/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance diff --git a/website/azurerm.erb b/website/azurerm.erb index 6c5a4240f2f0..dad23e135a50 100644 --- a/website/azurerm.erb +++ b/website/azurerm.erb @@ -1786,6 +1786,10 @@ azurerm_eventgrid_domain +
  • + azurerm_eventgrid_domain_topic +
  • +
  • azurerm_eventgrid_event_subscription
  • diff --git a/website/docs/r/eventgrid_domain.html.markdown b/website/docs/r/eventgrid_domain.html.markdown index 4b544c603547..36df1c8a189d 100644 --- a/website/docs/r/eventgrid_domain.html.markdown +++ b/website/docs/r/eventgrid_domain.html.markdown @@ -40,7 +40,7 @@ The following arguments are supported: * `location` - (Required) Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created. -* `input_schema` - (Optional) Specifies the schema in which incoming events will be published to this domain. Allowed values are `cloudeventv01schema`, `customeventschema`, or `eventgridschema`. Defaults to `eventgridschema`. Changing this forces a new resource to be created. +* `input_schema` - (Optional) Specifies the schema in which incoming events will be published to this domain. Allowed values are `CloudEventSchemaV1_0`, `CustomEventSchema`, or `EventGridSchema`. Defaults to `eventgridschema`. Changing this forces a new resource to be created. * `input_mapping_fields` - (Optional) A `input_mapping_fields` block as defined below. diff --git a/website/docs/r/eventgrid_domain_topic.markdown b/website/docs/r/eventgrid_domain_topic.markdown new file mode 100644 index 000000000000..eef24e7d4b76 --- /dev/null +++ b/website/docs/r/eventgrid_domain_topic.markdown @@ -0,0 +1,70 @@ +--- +subcategory: "Messaging" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_eventgrid_domain_topic" +description: |- + Manages an EventGrid Domain Topic + +--- + +# azurerm_eventgrid_domain_topic + +Manages an EventGrid Domain Topic + +## Example Usage + +```hcl +resource "azurerm_resource_group" "example" { + name = "resourceGroup1" + location = "West US 2" +} + +resource "azurerm_eventgrid_domain" "example" { + name = "my-eventgrid-domain" + location = azurerm_resource_group.example.location + resource_group_name = azurerm_resource_group.example.name + + tags = { + environment = "Production" + } +} + +resource "azurerm_eventgrid_domain_topic" "example" { + name = "my-eventgrid-domain-topic" + domain_name = azurerm_eventgrid_domain.example.name + resource_group_name = azurerm_resource_group.example.name +} +``` + +## Argument Reference + +The following arguments are supported: + +* `name` - (Required) Specifies the name of the EventGrid Domain Topic resource. Changing this forces a new resource to be created. + +* `domain_name` - (Required) Specifies the name of the EventGrid Domain. Changing this forces a new resource to be created. + +* `resource_group_name` - (Required) The name of the resource group in which the EventGrid Domain exists. Changing this forces a new resource to be created. + +## Attributes Reference + +The following attributes are exported: + +* `id` - The ID of the EventGrid Domain Topic. + +## Timeouts + +The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: + +* `create` - (Defaults to 30 minutes) Used when creating the EventGrid Domain Topic. +* `update` - (Defaults to 30 minutes) Used when updating the EventGrid Domain Topic. +* `read` - (Defaults to 5 minutes) Used when retrieving the EventGrid Domain Topic. +* `delete` - (Defaults to 30 minutes) Used when deleting the EventGrid Domain Topic. + +## Import + +EventGrid Domain Topics can be imported using the `resource id`, e.g. + +```shell +terraform import azurerm_eventgrid_domain_topic.topic1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.EventGrid/domains/domain1/topics/topic1 +``` diff --git a/website/docs/r/eventgrid_event_subscription.html.markdown b/website/docs/r/eventgrid_event_subscription.html.markdown index 5a6b386c0b61..4f0e2df129d0 100644 --- a/website/docs/r/eventgrid_event_subscription.html.markdown +++ b/website/docs/r/eventgrid_event_subscription.html.markdown @@ -56,9 +56,9 @@ The following arguments are supported: * `scope` - (Required) Specifies the scope at which the EventGrid Event Subscription should be created. Changing this forces a new resource to be created. -* `event_delivery_schema` - (Optional) Specifies the event delivery schema for the event subscription. Possible values include: `EventGridSchema`, `CloudEventV01Schema`, `CustomInputSchema`. +* `expiration_time_utc` - (Optional) Specifies the expiration time of the event subscription (Datetime Format `RFC 3339`). -* `topic_name` - (Optional) Specifies the name of the topic to associate with the event subscription. +* `event_delivery_schema` - (Optional) Specifies the event delivery schema for the event subscription. Possible values include: `EventGridSchema`, `CloudEventSchemaV1_0`, `CustomInputSchema`. Defaults to `EventGridSchema`. Changing this forces a new resource to be created. * `storage_queue_endpoint` - (Optional) A `storage_queue_endpoint` block as defined below. @@ -68,12 +68,20 @@ The following arguments are supported: * `webhook_endpoint` - (Optional) A `webhook_endpoint` block as defined below. -~> **NOTE:** One of `storage_queue_endpoint`, `eventhub_endpoint`, `hybrid_connection_endpoint` or `webhook_endpoint` must be specified. +* `service_bus_queue_endpoint` - (Optional) A `service_bus_queue_endpoint` block as defined below. + +* `service_bus_topic_endpoint` - (Optional) A `service_bus_topic_endpoint` block as defined below. + +* `azure_function_endpoint` - (Optional) A `azure_function_endpoint` block as defined below. + +~> **NOTE:** One of `storage_queue_endpoint`, `eventhub_endpoint`, `hybrid_connection_endpoint`, `webhook_endpoint`, `service_bus_queue_endpoint`, `service_bus_topic_endpoint` or `azure_function_endpoint` must be specified. * `included_event_types` - (Optional) A list of applicable event types that need to be part of the event subscription. * `subject_filter` - (Optional) A `subject_filter` block as defined below. +* `advanced_filter` - (Optional) A `advanced_filter` block as defined below. + * `storage_blob_dead_letter_destination` - (Optional) A `storage_blob_dead_letter_destination` block as defined below. * `retry_policy` - (Optional) A `retry_policy` block as defined below. @@ -100,12 +108,32 @@ A `hybrid_connection_endpoint` supports the following: * `hybrid_connection_id` - (Required) Specifies the id of the hybrid connection where the Event Subscription will receive events. +--- + A `webhook_endpoint` supports the following: * `url` - (Required) Specifies the url of the webhook where the Event Subscription will receive events. --- +A `service_bus_queue_endpoint` supports the following: + +* `service_bus_queue_id` - (Required) Specifies the id where the service bus queue is located. + +--- + +A `service_bus_topic_endpoint` supports the following: + +* `service_bus_topic_id` - (Required) Specifies the id where the service bus topic is located. + +--- + +A `azure_function_endpoint` supports the following: + +* `azure_function_id` - (Required) Specifies the id where the azure function is located. + +--- + A `subject_filter` supports the following: * `subject_begins_with` - (Optional) A string to filter events for an event subscription based on a resource path prefix. @@ -116,6 +144,18 @@ A `subject_filter` supports the following: --- +A `advanced_filter` supports the following: + +* `key` - (Required) Specifies the field in the event data that you're using for filtering. It can be a number, boolean, or string. + +* `operator_type` - (Required) Specifies the type of comparison. Must be one of the following operators: `NumberLessThan`, `NumberGreaterThan`, `NumberLessThanOrEquals`, `NumberGreaterThanOrEquals`, `BoolEquals`, `NumberIn`, `NumberNotIn`, `StringIn`, `StringNotIn`, `StringBeginsWith`, `StringEndsWith`. `StringContains`. + +* `value` or `values` - (Required) Specifies the value or values to compare to the key. + +~> **NOTE:** A maximum of 5 advanced filters are allowed. + +--- + A `storage_blob_dead_letter_destination` supports the following: * `storage_account_id` - (Required) Specifies the id of the storage account id where the storage blob is located. @@ -136,9 +176,9 @@ The following attributes are exported: * `id` - The ID of the EventGrid Event Subscription. -## Timeouts - +* `topic_name` - (Optional) Specifies the name of the topic to associate with the event subscription. +## Timeouts The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: diff --git a/website/docs/r/eventgrid_topic.html.markdown b/website/docs/r/eventgrid_topic.html.markdown index 5d37e8c1102e..af8304f48cee 100644 --- a/website/docs/r/eventgrid_topic.html.markdown +++ b/website/docs/r/eventgrid_topic.html.markdown @@ -42,8 +42,40 @@ The following arguments are supported: * `location` - (Required) Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created. +* `input_schema` - (Optional) Specifies the schema in which incoming events will be published to this domain. Allowed values are `CloudEventSchemaV1_0`, `CustomEventSchema`, or `EventGridSchema`. Defaults to `EventGridSchema`. Changing this forces a new resource to be created. + +* `input_mapping_fields` - (Optional) A `input_mapping_fields` block as defined below. + +* `input_mapping_default_values` - (Optional) A `input_mapping_default_values` block as defined below. + * `tags` - (Optional) A mapping of tags to assign to the resource. +--- + +A `input_mapping_fields` supports the following: + +* `id` - (Optional) Specifies the id of the EventGrid Event to associate with the domain. Changing this forces a new resource to be created. + +* `topic` - (Optional) Specifies the topic of the EventGrid Event to associate with the domain. Changing this forces a new resource to be created. + +* `event_type` - (Optional) Specifies the event type of the EventGrid Event to associate with the domain. Changing this forces a new resource to be created. + +* `event_time` - (Optional) Specifies the event time of the EventGrid Event to associate with the domain. Changing this forces a new resource to be created. + +* `data_version` - (Optional) Specifies the data version of the EventGrid Event to associate with the domain. Changing this forces a new resource to be created. + +* `subject` - (Optional) Specifies the subject of the EventGrid Event to associate with the domain. Changing this forces a new resource to be created. + +--- + +A `input_mapping_default_values` supports the following: + +* `event_type` - (Optional) Specifies the default event type of the EventGrid Event to associate with the domain. Changing this forces a new resource to be created. + +* `data_version` - (Optional) Specifies the default data version of the EventGrid Event to associate with the domain. Changing this forces a new resource to be created. + +* `subject` - (Optional) Specifies the default subject of the EventGrid Event to associate with the domain. Changing this forces a new resource to be created. + ## Attributes Reference The following attributes are exported: