1package eventgrid
2
3// Copyright (c) Microsoft and contributors.  All rights reserved.
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13//
14// See the License for the specific language governing permissions and
15// limitations under the License.
16//
17// Code generated by Microsoft (R) AutoRest Code Generator.
18// Changes may cause incorrect behavior and will be lost if the code is regenerated.
19
20import (
21	"context"
22	"github.com/Azure/go-autorest/autorest"
23	"github.com/Azure/go-autorest/autorest/azure"
24	"github.com/Azure/go-autorest/tracing"
25	"net/http"
26)
27
28// EventSubscriptionsClient is the azure EventGrid Management Client
29type EventSubscriptionsClient struct {
30	BaseClient
31}
32
33// NewEventSubscriptionsClient creates an instance of the EventSubscriptionsClient client.
34func NewEventSubscriptionsClient(subscriptionID string) EventSubscriptionsClient {
35	return NewEventSubscriptionsClientWithBaseURI(DefaultBaseURI, subscriptionID)
36}
37
38// NewEventSubscriptionsClientWithBaseURI creates an instance of the EventSubscriptionsClient client using a custom
39// endpoint.  Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure
40// stack).
41func NewEventSubscriptionsClientWithBaseURI(baseURI string, subscriptionID string) EventSubscriptionsClient {
42	return EventSubscriptionsClient{NewWithBaseURI(baseURI, subscriptionID)}
43}
44
45// CreateOrUpdate asynchronously creates a new event subscription or updates an existing event subscription based on
46// the specified scope.
47// Parameters:
48// scope - the identifier of the resource to which the event subscription needs to be created or updated. The
49// scope can be a subscription, or a resource group, or a top level resource belonging to a resource provider
50// namespace, or an EventGrid topic. For example, use '/subscriptions/{subscriptionId}/' for a subscription,
51// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for a resource group, and
52// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}'
53// for a resource, and
54// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}'
55// for an EventGrid topic.
56// eventSubscriptionName - name of the event subscription. Event subscription names must be between 3 and 64
57// characters in length and should use alphanumeric letters only.
58// eventSubscriptionInfo - event subscription properties containing the destination and filter information.
59func (client EventSubscriptionsClient) CreateOrUpdate(ctx context.Context, scope string, eventSubscriptionName string, eventSubscriptionInfo EventSubscription) (result EventSubscriptionsCreateOrUpdateFuture, err error) {
60	if tracing.IsEnabled() {
61		ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.CreateOrUpdate")
62		defer func() {
63			sc := -1
64			if result.Response() != nil {
65				sc = result.Response().StatusCode
66			}
67			tracing.EndSpan(ctx, sc, err)
68		}()
69	}
70	req, err := client.CreateOrUpdatePreparer(ctx, scope, eventSubscriptionName, eventSubscriptionInfo)
71	if err != nil {
72		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "CreateOrUpdate", nil, "Failure preparing request")
73		return
74	}
75
76	result, err = client.CreateOrUpdateSender(req)
77	if err != nil {
78		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "CreateOrUpdate", result.Response(), "Failure sending request")
79		return
80	}
81
82	return
83}
84
85// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
86func (client EventSubscriptionsClient) CreateOrUpdatePreparer(ctx context.Context, scope string, eventSubscriptionName string, eventSubscriptionInfo EventSubscription) (*http.Request, error) {
87	pathParameters := map[string]interface{}{
88		"eventSubscriptionName": autorest.Encode("path", eventSubscriptionName),
89		"scope":                 scope,
90	}
91
92	const APIVersion = "2020-04-01-preview"
93	queryParameters := map[string]interface{}{
94		"api-version": APIVersion,
95	}
96
97	preparer := autorest.CreatePreparer(
98		autorest.AsContentType("application/json; charset=utf-8"),
99		autorest.AsPut(),
100		autorest.WithBaseURL(client.BaseURI),
101		autorest.WithPathParameters("/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}", pathParameters),
102		autorest.WithJSON(eventSubscriptionInfo),
103		autorest.WithQueryParameters(queryParameters))
104	return preparer.Prepare((&http.Request{}).WithContext(ctx))
105}
106
107// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
108// http.Response Body if it receives an error.
109func (client EventSubscriptionsClient) CreateOrUpdateSender(req *http.Request) (future EventSubscriptionsCreateOrUpdateFuture, err error) {
110	var resp *http.Response
111	resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
112	if err != nil {
113		return
114	}
115	future.Future, err = azure.NewFutureFromResponse(resp)
116	return
117}
118
119// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
120// closes the http.Response Body.
121func (client EventSubscriptionsClient) CreateOrUpdateResponder(resp *http.Response) (result EventSubscription, err error) {
122	err = autorest.Respond(
123		resp,
124		client.ByInspecting(),
125		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
126		autorest.ByUnmarshallingJSON(&result),
127		autorest.ByClosing())
128	result.Response = autorest.Response{Response: resp}
129	return
130}
131
132// Delete delete an existing event subscription.
133// Parameters:
134// scope - the scope of the event subscription. The scope can be a subscription, or a resource group, or a top
135// level resource belonging to a resource provider namespace, or an EventGrid topic. For example, use
136// '/subscriptions/{subscriptionId}/' for a subscription,
137// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for a resource group, and
138// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}'
139// for a resource, and
140// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}'
141// for an EventGrid topic.
142// eventSubscriptionName - name of the event subscription.
143func (client EventSubscriptionsClient) Delete(ctx context.Context, scope string, eventSubscriptionName string) (result EventSubscriptionsDeleteFuture, err error) {
144	if tracing.IsEnabled() {
145		ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.Delete")
146		defer func() {
147			sc := -1
148			if result.Response() != nil {
149				sc = result.Response().StatusCode
150			}
151			tracing.EndSpan(ctx, sc, err)
152		}()
153	}
154	req, err := client.DeletePreparer(ctx, scope, eventSubscriptionName)
155	if err != nil {
156		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "Delete", nil, "Failure preparing request")
157		return
158	}
159
160	result, err = client.DeleteSender(req)
161	if err != nil {
162		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "Delete", result.Response(), "Failure sending request")
163		return
164	}
165
166	return
167}
168
169// DeletePreparer prepares the Delete request.
170func (client EventSubscriptionsClient) DeletePreparer(ctx context.Context, scope string, eventSubscriptionName string) (*http.Request, error) {
171	pathParameters := map[string]interface{}{
172		"eventSubscriptionName": autorest.Encode("path", eventSubscriptionName),
173		"scope":                 scope,
174	}
175
176	const APIVersion = "2020-04-01-preview"
177	queryParameters := map[string]interface{}{
178		"api-version": APIVersion,
179	}
180
181	preparer := autorest.CreatePreparer(
182		autorest.AsDelete(),
183		autorest.WithBaseURL(client.BaseURI),
184		autorest.WithPathParameters("/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}", pathParameters),
185		autorest.WithQueryParameters(queryParameters))
186	return preparer.Prepare((&http.Request{}).WithContext(ctx))
187}
188
189// DeleteSender sends the Delete request. The method will close the
190// http.Response Body if it receives an error.
191func (client EventSubscriptionsClient) DeleteSender(req *http.Request) (future EventSubscriptionsDeleteFuture, err error) {
192	var resp *http.Response
193	resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
194	if err != nil {
195		return
196	}
197	future.Future, err = azure.NewFutureFromResponse(resp)
198	return
199}
200
201// DeleteResponder handles the response to the Delete request. The method always
202// closes the http.Response Body.
203func (client EventSubscriptionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
204	err = autorest.Respond(
205		resp,
206		client.ByInspecting(),
207		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
208		autorest.ByClosing())
209	result.Response = resp
210	return
211}
212
213// Get get properties of an event subscription.
214// Parameters:
215// scope - the scope of the event subscription. The scope can be a subscription, or a resource group, or a top
216// level resource belonging to a resource provider namespace, or an EventGrid topic. For example, use
217// '/subscriptions/{subscriptionId}/' for a subscription,
218// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for a resource group, and
219// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}'
220// for a resource, and
221// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}'
222// for an EventGrid topic.
223// eventSubscriptionName - name of the event subscription.
224func (client EventSubscriptionsClient) Get(ctx context.Context, scope string, eventSubscriptionName string) (result EventSubscription, err error) {
225	if tracing.IsEnabled() {
226		ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.Get")
227		defer func() {
228			sc := -1
229			if result.Response.Response != nil {
230				sc = result.Response.Response.StatusCode
231			}
232			tracing.EndSpan(ctx, sc, err)
233		}()
234	}
235	req, err := client.GetPreparer(ctx, scope, eventSubscriptionName)
236	if err != nil {
237		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "Get", nil, "Failure preparing request")
238		return
239	}
240
241	resp, err := client.GetSender(req)
242	if err != nil {
243		result.Response = autorest.Response{Response: resp}
244		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "Get", resp, "Failure sending request")
245		return
246	}
247
248	result, err = client.GetResponder(resp)
249	if err != nil {
250		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "Get", resp, "Failure responding to request")
251	}
252
253	return
254}
255
256// GetPreparer prepares the Get request.
257func (client EventSubscriptionsClient) GetPreparer(ctx context.Context, scope string, eventSubscriptionName string) (*http.Request, error) {
258	pathParameters := map[string]interface{}{
259		"eventSubscriptionName": autorest.Encode("path", eventSubscriptionName),
260		"scope":                 scope,
261	}
262
263	const APIVersion = "2020-04-01-preview"
264	queryParameters := map[string]interface{}{
265		"api-version": APIVersion,
266	}
267
268	preparer := autorest.CreatePreparer(
269		autorest.AsGet(),
270		autorest.WithBaseURL(client.BaseURI),
271		autorest.WithPathParameters("/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}", pathParameters),
272		autorest.WithQueryParameters(queryParameters))
273	return preparer.Prepare((&http.Request{}).WithContext(ctx))
274}
275
276// GetSender sends the Get request. The method will close the
277// http.Response Body if it receives an error.
278func (client EventSubscriptionsClient) GetSender(req *http.Request) (*http.Response, error) {
279	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
280}
281
282// GetResponder handles the response to the Get request. The method always
283// closes the http.Response Body.
284func (client EventSubscriptionsClient) GetResponder(resp *http.Response) (result EventSubscription, err error) {
285	err = autorest.Respond(
286		resp,
287		client.ByInspecting(),
288		azure.WithErrorUnlessStatusCode(http.StatusOK),
289		autorest.ByUnmarshallingJSON(&result),
290		autorest.ByClosing())
291	result.Response = autorest.Response{Response: resp}
292	return
293}
294
295// GetFullURL get the full endpoint URL for an event subscription.
296// Parameters:
297// scope - the scope of the event subscription. The scope can be a subscription, or a resource group, or a top
298// level resource belonging to a resource provider namespace, or an EventGrid topic. For example, use
299// '/subscriptions/{subscriptionId}/' for a subscription,
300// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for a resource group, and
301// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}'
302// for a resource, and
303// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}'
304// for an EventGrid topic.
305// eventSubscriptionName - name of the event subscription.
306func (client EventSubscriptionsClient) GetFullURL(ctx context.Context, scope string, eventSubscriptionName string) (result EventSubscriptionFullURL, err error) {
307	if tracing.IsEnabled() {
308		ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.GetFullURL")
309		defer func() {
310			sc := -1
311			if result.Response.Response != nil {
312				sc = result.Response.Response.StatusCode
313			}
314			tracing.EndSpan(ctx, sc, err)
315		}()
316	}
317	req, err := client.GetFullURLPreparer(ctx, scope, eventSubscriptionName)
318	if err != nil {
319		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "GetFullURL", nil, "Failure preparing request")
320		return
321	}
322
323	resp, err := client.GetFullURLSender(req)
324	if err != nil {
325		result.Response = autorest.Response{Response: resp}
326		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "GetFullURL", resp, "Failure sending request")
327		return
328	}
329
330	result, err = client.GetFullURLResponder(resp)
331	if err != nil {
332		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "GetFullURL", resp, "Failure responding to request")
333	}
334
335	return
336}
337
338// GetFullURLPreparer prepares the GetFullURL request.
339func (client EventSubscriptionsClient) GetFullURLPreparer(ctx context.Context, scope string, eventSubscriptionName string) (*http.Request, error) {
340	pathParameters := map[string]interface{}{
341		"eventSubscriptionName": autorest.Encode("path", eventSubscriptionName),
342		"scope":                 scope,
343	}
344
345	const APIVersion = "2020-04-01-preview"
346	queryParameters := map[string]interface{}{
347		"api-version": APIVersion,
348	}
349
350	preparer := autorest.CreatePreparer(
351		autorest.AsPost(),
352		autorest.WithBaseURL(client.BaseURI),
353		autorest.WithPathParameters("/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}/getFullUrl", pathParameters),
354		autorest.WithQueryParameters(queryParameters))
355	return preparer.Prepare((&http.Request{}).WithContext(ctx))
356}
357
358// GetFullURLSender sends the GetFullURL request. The method will close the
359// http.Response Body if it receives an error.
360func (client EventSubscriptionsClient) GetFullURLSender(req *http.Request) (*http.Response, error) {
361	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
362}
363
364// GetFullURLResponder handles the response to the GetFullURL request. The method always
365// closes the http.Response Body.
366func (client EventSubscriptionsClient) GetFullURLResponder(resp *http.Response) (result EventSubscriptionFullURL, err error) {
367	err = autorest.Respond(
368		resp,
369		client.ByInspecting(),
370		azure.WithErrorUnlessStatusCode(http.StatusOK),
371		autorest.ByUnmarshallingJSON(&result),
372		autorest.ByClosing())
373	result.Response = autorest.Response{Response: resp}
374	return
375}
376
377// ListByDomainTopic list all event subscriptions that have been created for a specific domain topic.
378// Parameters:
379// resourceGroupName - the name of the resource group within the user's subscription.
380// domainName - name of the top level domain.
381// topicName - name of the domain topic.
382// filter - the query used to filter the search results using OData syntax. Filtering is permitted on the
383// 'name' property only and with limited number of OData operations. These operations are: the 'contains'
384// function as well as the following logical operations: not, and, or, eq (for equal), and ne (for not equal).
385// No arithmetic operations are supported. The following is a valid filter example: $filter=contains(namE,
386// 'PATTERN') and name ne 'PATTERN-1'. The following is not a valid filter example: $filter=location eq
387// 'westus'.
388// top - the number of results to return per page for the list operation. Valid range for top parameter is 1 to
389// 100. If not specified, the default number of results to be returned is 20 items per page.
390func (client EventSubscriptionsClient) ListByDomainTopic(ctx context.Context, resourceGroupName string, domainName string, topicName string, filter string, top *int32) (result EventSubscriptionsListResultPage, err error) {
391	if tracing.IsEnabled() {
392		ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListByDomainTopic")
393		defer func() {
394			sc := -1
395			if result.eslr.Response.Response != nil {
396				sc = result.eslr.Response.Response.StatusCode
397			}
398			tracing.EndSpan(ctx, sc, err)
399		}()
400	}
401	result.fn = client.listByDomainTopicNextResults
402	req, err := client.ListByDomainTopicPreparer(ctx, resourceGroupName, domainName, topicName, filter, top)
403	if err != nil {
404		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListByDomainTopic", nil, "Failure preparing request")
405		return
406	}
407
408	resp, err := client.ListByDomainTopicSender(req)
409	if err != nil {
410		result.eslr.Response = autorest.Response{Response: resp}
411		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListByDomainTopic", resp, "Failure sending request")
412		return
413	}
414
415	result.eslr, err = client.ListByDomainTopicResponder(resp)
416	if err != nil {
417		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListByDomainTopic", resp, "Failure responding to request")
418	}
419
420	return
421}
422
423// ListByDomainTopicPreparer prepares the ListByDomainTopic request.
424func (client EventSubscriptionsClient) ListByDomainTopicPreparer(ctx context.Context, resourceGroupName string, domainName string, topicName string, filter string, top *int32) (*http.Request, error) {
425	pathParameters := map[string]interface{}{
426		"domainName":        autorest.Encode("path", domainName),
427		"resourceGroupName": autorest.Encode("path", resourceGroupName),
428		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
429		"topicName":         autorest.Encode("path", topicName),
430	}
431
432	const APIVersion = "2020-04-01-preview"
433	queryParameters := map[string]interface{}{
434		"api-version": APIVersion,
435	}
436	if len(filter) > 0 {
437		queryParameters["$filter"] = autorest.Encode("query", filter)
438	}
439	if top != nil {
440		queryParameters["$top"] = autorest.Encode("query", *top)
441	}
442
443	preparer := autorest.CreatePreparer(
444		autorest.AsGet(),
445		autorest.WithBaseURL(client.BaseURI),
446		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/providers/Microsoft.EventGrid/eventSubscriptions", pathParameters),
447		autorest.WithQueryParameters(queryParameters))
448	return preparer.Prepare((&http.Request{}).WithContext(ctx))
449}
450
451// ListByDomainTopicSender sends the ListByDomainTopic request. The method will close the
452// http.Response Body if it receives an error.
453func (client EventSubscriptionsClient) ListByDomainTopicSender(req *http.Request) (*http.Response, error) {
454	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
455}
456
457// ListByDomainTopicResponder handles the response to the ListByDomainTopic request. The method always
458// closes the http.Response Body.
459func (client EventSubscriptionsClient) ListByDomainTopicResponder(resp *http.Response) (result EventSubscriptionsListResult, err error) {
460	err = autorest.Respond(
461		resp,
462		client.ByInspecting(),
463		azure.WithErrorUnlessStatusCode(http.StatusOK),
464		autorest.ByUnmarshallingJSON(&result),
465		autorest.ByClosing())
466	result.Response = autorest.Response{Response: resp}
467	return
468}
469
470// listByDomainTopicNextResults retrieves the next set of results, if any.
471func (client EventSubscriptionsClient) listByDomainTopicNextResults(ctx context.Context, lastResults EventSubscriptionsListResult) (result EventSubscriptionsListResult, err error) {
472	req, err := lastResults.eventSubscriptionsListResultPreparer(ctx)
473	if err != nil {
474		return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listByDomainTopicNextResults", nil, "Failure preparing next results request")
475	}
476	if req == nil {
477		return
478	}
479	resp, err := client.ListByDomainTopicSender(req)
480	if err != nil {
481		result.Response = autorest.Response{Response: resp}
482		return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listByDomainTopicNextResults", resp, "Failure sending next results request")
483	}
484	result, err = client.ListByDomainTopicResponder(resp)
485	if err != nil {
486		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listByDomainTopicNextResults", resp, "Failure responding to next results request")
487	}
488	return
489}
490
491// ListByDomainTopicComplete enumerates all values, automatically crossing page boundaries as required.
492func (client EventSubscriptionsClient) ListByDomainTopicComplete(ctx context.Context, resourceGroupName string, domainName string, topicName string, filter string, top *int32) (result EventSubscriptionsListResultIterator, err error) {
493	if tracing.IsEnabled() {
494		ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListByDomainTopic")
495		defer func() {
496			sc := -1
497			if result.Response().Response.Response != nil {
498				sc = result.page.Response().Response.Response.StatusCode
499			}
500			tracing.EndSpan(ctx, sc, err)
501		}()
502	}
503	result.page, err = client.ListByDomainTopic(ctx, resourceGroupName, domainName, topicName, filter, top)
504	return
505}
506
507// ListByResource list all event subscriptions that have been created for a specific topic.
508// Parameters:
509// resourceGroupName - the name of the resource group within the user's subscription.
510// providerNamespace - namespace of the provider of the topic.
511// resourceTypeName - name of the resource type.
512// resourceName - name of the resource.
513// filter - the query used to filter the search results using OData syntax. Filtering is permitted on the
514// 'name' property only and with limited number of OData operations. These operations are: the 'contains'
515// function as well as the following logical operations: not, and, or, eq (for equal), and ne (for not equal).
516// No arithmetic operations are supported. The following is a valid filter example: $filter=contains(namE,
517// 'PATTERN') and name ne 'PATTERN-1'. The following is not a valid filter example: $filter=location eq
518// 'westus'.
519// top - the number of results to return per page for the list operation. Valid range for top parameter is 1 to
520// 100. If not specified, the default number of results to be returned is 20 items per page.
521func (client EventSubscriptionsClient) ListByResource(ctx context.Context, resourceGroupName string, providerNamespace string, resourceTypeName string, resourceName string, filter string, top *int32) (result EventSubscriptionsListResultPage, err error) {
522	if tracing.IsEnabled() {
523		ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListByResource")
524		defer func() {
525			sc := -1
526			if result.eslr.Response.Response != nil {
527				sc = result.eslr.Response.Response.StatusCode
528			}
529			tracing.EndSpan(ctx, sc, err)
530		}()
531	}
532	result.fn = client.listByResourceNextResults
533	req, err := client.ListByResourcePreparer(ctx, resourceGroupName, providerNamespace, resourceTypeName, resourceName, filter, top)
534	if err != nil {
535		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListByResource", nil, "Failure preparing request")
536		return
537	}
538
539	resp, err := client.ListByResourceSender(req)
540	if err != nil {
541		result.eslr.Response = autorest.Response{Response: resp}
542		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListByResource", resp, "Failure sending request")
543		return
544	}
545
546	result.eslr, err = client.ListByResourceResponder(resp)
547	if err != nil {
548		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListByResource", resp, "Failure responding to request")
549	}
550
551	return
552}
553
554// ListByResourcePreparer prepares the ListByResource request.
555func (client EventSubscriptionsClient) ListByResourcePreparer(ctx context.Context, resourceGroupName string, providerNamespace string, resourceTypeName string, resourceName string, filter string, top *int32) (*http.Request, error) {
556	pathParameters := map[string]interface{}{
557		"providerNamespace": autorest.Encode("path", providerNamespace),
558		"resourceGroupName": autorest.Encode("path", resourceGroupName),
559		"resourceName":      autorest.Encode("path", resourceName),
560		"resourceTypeName":  autorest.Encode("path", resourceTypeName),
561		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
562	}
563
564	const APIVersion = "2020-04-01-preview"
565	queryParameters := map[string]interface{}{
566		"api-version": APIVersion,
567	}
568	if len(filter) > 0 {
569		queryParameters["$filter"] = autorest.Encode("query", filter)
570	}
571	if top != nil {
572		queryParameters["$top"] = autorest.Encode("query", *top)
573	}
574
575	preparer := autorest.CreatePreparer(
576		autorest.AsGet(),
577		autorest.WithBaseURL(client.BaseURI),
578		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{providerNamespace}/{resourceTypeName}/{resourceName}/providers/Microsoft.EventGrid/eventSubscriptions", pathParameters),
579		autorest.WithQueryParameters(queryParameters))
580	return preparer.Prepare((&http.Request{}).WithContext(ctx))
581}
582
583// ListByResourceSender sends the ListByResource request. The method will close the
584// http.Response Body if it receives an error.
585func (client EventSubscriptionsClient) ListByResourceSender(req *http.Request) (*http.Response, error) {
586	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
587}
588
589// ListByResourceResponder handles the response to the ListByResource request. The method always
590// closes the http.Response Body.
591func (client EventSubscriptionsClient) ListByResourceResponder(resp *http.Response) (result EventSubscriptionsListResult, err error) {
592	err = autorest.Respond(
593		resp,
594		client.ByInspecting(),
595		azure.WithErrorUnlessStatusCode(http.StatusOK),
596		autorest.ByUnmarshallingJSON(&result),
597		autorest.ByClosing())
598	result.Response = autorest.Response{Response: resp}
599	return
600}
601
602// listByResourceNextResults retrieves the next set of results, if any.
603func (client EventSubscriptionsClient) listByResourceNextResults(ctx context.Context, lastResults EventSubscriptionsListResult) (result EventSubscriptionsListResult, err error) {
604	req, err := lastResults.eventSubscriptionsListResultPreparer(ctx)
605	if err != nil {
606		return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listByResourceNextResults", nil, "Failure preparing next results request")
607	}
608	if req == nil {
609		return
610	}
611	resp, err := client.ListByResourceSender(req)
612	if err != nil {
613		result.Response = autorest.Response{Response: resp}
614		return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listByResourceNextResults", resp, "Failure sending next results request")
615	}
616	result, err = client.ListByResourceResponder(resp)
617	if err != nil {
618		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listByResourceNextResults", resp, "Failure responding to next results request")
619	}
620	return
621}
622
623// ListByResourceComplete enumerates all values, automatically crossing page boundaries as required.
624func (client EventSubscriptionsClient) ListByResourceComplete(ctx context.Context, resourceGroupName string, providerNamespace string, resourceTypeName string, resourceName string, filter string, top *int32) (result EventSubscriptionsListResultIterator, err error) {
625	if tracing.IsEnabled() {
626		ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListByResource")
627		defer func() {
628			sc := -1
629			if result.Response().Response.Response != nil {
630				sc = result.page.Response().Response.Response.StatusCode
631			}
632			tracing.EndSpan(ctx, sc, err)
633		}()
634	}
635	result.page, err = client.ListByResource(ctx, resourceGroupName, providerNamespace, resourceTypeName, resourceName, filter, top)
636	return
637}
638
639// ListGlobalByResourceGroup list all global event subscriptions under a specific Azure subscription and resource
640// group.
641// Parameters:
642// resourceGroupName - the name of the resource group within the user's subscription.
643// filter - the query used to filter the search results using OData syntax. Filtering is permitted on the
644// 'name' property only and with limited number of OData operations. These operations are: the 'contains'
645// function as well as the following logical operations: not, and, or, eq (for equal), and ne (for not equal).
646// No arithmetic operations are supported. The following is a valid filter example: $filter=contains(namE,
647// 'PATTERN') and name ne 'PATTERN-1'. The following is not a valid filter example: $filter=location eq
648// 'westus'.
649// top - the number of results to return per page for the list operation. Valid range for top parameter is 1 to
650// 100. If not specified, the default number of results to be returned is 20 items per page.
651func (client EventSubscriptionsClient) ListGlobalByResourceGroup(ctx context.Context, resourceGroupName string, filter string, top *int32) (result EventSubscriptionsListResultPage, err error) {
652	if tracing.IsEnabled() {
653		ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListGlobalByResourceGroup")
654		defer func() {
655			sc := -1
656			if result.eslr.Response.Response != nil {
657				sc = result.eslr.Response.Response.StatusCode
658			}
659			tracing.EndSpan(ctx, sc, err)
660		}()
661	}
662	result.fn = client.listGlobalByResourceGroupNextResults
663	req, err := client.ListGlobalByResourceGroupPreparer(ctx, resourceGroupName, filter, top)
664	if err != nil {
665		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalByResourceGroup", nil, "Failure preparing request")
666		return
667	}
668
669	resp, err := client.ListGlobalByResourceGroupSender(req)
670	if err != nil {
671		result.eslr.Response = autorest.Response{Response: resp}
672		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalByResourceGroup", resp, "Failure sending request")
673		return
674	}
675
676	result.eslr, err = client.ListGlobalByResourceGroupResponder(resp)
677	if err != nil {
678		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalByResourceGroup", resp, "Failure responding to request")
679	}
680
681	return
682}
683
684// ListGlobalByResourceGroupPreparer prepares the ListGlobalByResourceGroup request.
685func (client EventSubscriptionsClient) ListGlobalByResourceGroupPreparer(ctx context.Context, resourceGroupName string, filter string, top *int32) (*http.Request, error) {
686	pathParameters := map[string]interface{}{
687		"resourceGroupName": autorest.Encode("path", resourceGroupName),
688		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
689	}
690
691	const APIVersion = "2020-04-01-preview"
692	queryParameters := map[string]interface{}{
693		"api-version": APIVersion,
694	}
695	if len(filter) > 0 {
696		queryParameters["$filter"] = autorest.Encode("query", filter)
697	}
698	if top != nil {
699		queryParameters["$top"] = autorest.Encode("query", *top)
700	}
701
702	preparer := autorest.CreatePreparer(
703		autorest.AsGet(),
704		autorest.WithBaseURL(client.BaseURI),
705		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/eventSubscriptions", pathParameters),
706		autorest.WithQueryParameters(queryParameters))
707	return preparer.Prepare((&http.Request{}).WithContext(ctx))
708}
709
710// ListGlobalByResourceGroupSender sends the ListGlobalByResourceGroup request. The method will close the
711// http.Response Body if it receives an error.
712func (client EventSubscriptionsClient) ListGlobalByResourceGroupSender(req *http.Request) (*http.Response, error) {
713	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
714}
715
716// ListGlobalByResourceGroupResponder handles the response to the ListGlobalByResourceGroup request. The method always
717// closes the http.Response Body.
718func (client EventSubscriptionsClient) ListGlobalByResourceGroupResponder(resp *http.Response) (result EventSubscriptionsListResult, err error) {
719	err = autorest.Respond(
720		resp,
721		client.ByInspecting(),
722		azure.WithErrorUnlessStatusCode(http.StatusOK),
723		autorest.ByUnmarshallingJSON(&result),
724		autorest.ByClosing())
725	result.Response = autorest.Response{Response: resp}
726	return
727}
728
729// listGlobalByResourceGroupNextResults retrieves the next set of results, if any.
730func (client EventSubscriptionsClient) listGlobalByResourceGroupNextResults(ctx context.Context, lastResults EventSubscriptionsListResult) (result EventSubscriptionsListResult, err error) {
731	req, err := lastResults.eventSubscriptionsListResultPreparer(ctx)
732	if err != nil {
733		return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listGlobalByResourceGroupNextResults", nil, "Failure preparing next results request")
734	}
735	if req == nil {
736		return
737	}
738	resp, err := client.ListGlobalByResourceGroupSender(req)
739	if err != nil {
740		result.Response = autorest.Response{Response: resp}
741		return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listGlobalByResourceGroupNextResults", resp, "Failure sending next results request")
742	}
743	result, err = client.ListGlobalByResourceGroupResponder(resp)
744	if err != nil {
745		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listGlobalByResourceGroupNextResults", resp, "Failure responding to next results request")
746	}
747	return
748}
749
750// ListGlobalByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required.
751func (client EventSubscriptionsClient) ListGlobalByResourceGroupComplete(ctx context.Context, resourceGroupName string, filter string, top *int32) (result EventSubscriptionsListResultIterator, err error) {
752	if tracing.IsEnabled() {
753		ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListGlobalByResourceGroup")
754		defer func() {
755			sc := -1
756			if result.Response().Response.Response != nil {
757				sc = result.page.Response().Response.Response.StatusCode
758			}
759			tracing.EndSpan(ctx, sc, err)
760		}()
761	}
762	result.page, err = client.ListGlobalByResourceGroup(ctx, resourceGroupName, filter, top)
763	return
764}
765
766// ListGlobalByResourceGroupForTopicType list all global event subscriptions under a resource group for a specific
767// topic type.
768// Parameters:
769// resourceGroupName - the name of the resource group within the user's subscription.
770// topicTypeName - name of the topic type.
771// filter - the query used to filter the search results using OData syntax. Filtering is permitted on the
772// 'name' property only and with limited number of OData operations. These operations are: the 'contains'
773// function as well as the following logical operations: not, and, or, eq (for equal), and ne (for not equal).
774// No arithmetic operations are supported. The following is a valid filter example: $filter=contains(namE,
775// 'PATTERN') and name ne 'PATTERN-1'. The following is not a valid filter example: $filter=location eq
776// 'westus'.
777// top - the number of results to return per page for the list operation. Valid range for top parameter is 1 to
778// 100. If not specified, the default number of results to be returned is 20 items per page.
779func (client EventSubscriptionsClient) ListGlobalByResourceGroupForTopicType(ctx context.Context, resourceGroupName string, topicTypeName string, filter string, top *int32) (result EventSubscriptionsListResultPage, err error) {
780	if tracing.IsEnabled() {
781		ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListGlobalByResourceGroupForTopicType")
782		defer func() {
783			sc := -1
784			if result.eslr.Response.Response != nil {
785				sc = result.eslr.Response.Response.StatusCode
786			}
787			tracing.EndSpan(ctx, sc, err)
788		}()
789	}
790	result.fn = client.listGlobalByResourceGroupForTopicTypeNextResults
791	req, err := client.ListGlobalByResourceGroupForTopicTypePreparer(ctx, resourceGroupName, topicTypeName, filter, top)
792	if err != nil {
793		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalByResourceGroupForTopicType", nil, "Failure preparing request")
794		return
795	}
796
797	resp, err := client.ListGlobalByResourceGroupForTopicTypeSender(req)
798	if err != nil {
799		result.eslr.Response = autorest.Response{Response: resp}
800		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalByResourceGroupForTopicType", resp, "Failure sending request")
801		return
802	}
803
804	result.eslr, err = client.ListGlobalByResourceGroupForTopicTypeResponder(resp)
805	if err != nil {
806		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalByResourceGroupForTopicType", resp, "Failure responding to request")
807	}
808
809	return
810}
811
812// ListGlobalByResourceGroupForTopicTypePreparer prepares the ListGlobalByResourceGroupForTopicType request.
813func (client EventSubscriptionsClient) ListGlobalByResourceGroupForTopicTypePreparer(ctx context.Context, resourceGroupName string, topicTypeName string, filter string, top *int32) (*http.Request, error) {
814	pathParameters := map[string]interface{}{
815		"resourceGroupName": autorest.Encode("path", resourceGroupName),
816		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
817		"topicTypeName":     autorest.Encode("path", topicTypeName),
818	}
819
820	const APIVersion = "2020-04-01-preview"
821	queryParameters := map[string]interface{}{
822		"api-version": APIVersion,
823	}
824	if len(filter) > 0 {
825		queryParameters["$filter"] = autorest.Encode("query", filter)
826	}
827	if top != nil {
828		queryParameters["$top"] = autorest.Encode("query", *top)
829	}
830
831	preparer := autorest.CreatePreparer(
832		autorest.AsGet(),
833		autorest.WithBaseURL(client.BaseURI),
834		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topicTypes/{topicTypeName}/eventSubscriptions", pathParameters),
835		autorest.WithQueryParameters(queryParameters))
836	return preparer.Prepare((&http.Request{}).WithContext(ctx))
837}
838
839// ListGlobalByResourceGroupForTopicTypeSender sends the ListGlobalByResourceGroupForTopicType request. The method will close the
840// http.Response Body if it receives an error.
841func (client EventSubscriptionsClient) ListGlobalByResourceGroupForTopicTypeSender(req *http.Request) (*http.Response, error) {
842	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
843}
844
845// ListGlobalByResourceGroupForTopicTypeResponder handles the response to the ListGlobalByResourceGroupForTopicType request. The method always
846// closes the http.Response Body.
847func (client EventSubscriptionsClient) ListGlobalByResourceGroupForTopicTypeResponder(resp *http.Response) (result EventSubscriptionsListResult, err error) {
848	err = autorest.Respond(
849		resp,
850		client.ByInspecting(),
851		azure.WithErrorUnlessStatusCode(http.StatusOK),
852		autorest.ByUnmarshallingJSON(&result),
853		autorest.ByClosing())
854	result.Response = autorest.Response{Response: resp}
855	return
856}
857
858// listGlobalByResourceGroupForTopicTypeNextResults retrieves the next set of results, if any.
859func (client EventSubscriptionsClient) listGlobalByResourceGroupForTopicTypeNextResults(ctx context.Context, lastResults EventSubscriptionsListResult) (result EventSubscriptionsListResult, err error) {
860	req, err := lastResults.eventSubscriptionsListResultPreparer(ctx)
861	if err != nil {
862		return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listGlobalByResourceGroupForTopicTypeNextResults", nil, "Failure preparing next results request")
863	}
864	if req == nil {
865		return
866	}
867	resp, err := client.ListGlobalByResourceGroupForTopicTypeSender(req)
868	if err != nil {
869		result.Response = autorest.Response{Response: resp}
870		return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listGlobalByResourceGroupForTopicTypeNextResults", resp, "Failure sending next results request")
871	}
872	result, err = client.ListGlobalByResourceGroupForTopicTypeResponder(resp)
873	if err != nil {
874		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listGlobalByResourceGroupForTopicTypeNextResults", resp, "Failure responding to next results request")
875	}
876	return
877}
878
879// ListGlobalByResourceGroupForTopicTypeComplete enumerates all values, automatically crossing page boundaries as required.
880func (client EventSubscriptionsClient) ListGlobalByResourceGroupForTopicTypeComplete(ctx context.Context, resourceGroupName string, topicTypeName string, filter string, top *int32) (result EventSubscriptionsListResultIterator, err error) {
881	if tracing.IsEnabled() {
882		ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListGlobalByResourceGroupForTopicType")
883		defer func() {
884			sc := -1
885			if result.Response().Response.Response != nil {
886				sc = result.page.Response().Response.Response.StatusCode
887			}
888			tracing.EndSpan(ctx, sc, err)
889		}()
890	}
891	result.page, err = client.ListGlobalByResourceGroupForTopicType(ctx, resourceGroupName, topicTypeName, filter, top)
892	return
893}
894
895// ListGlobalBySubscription list all aggregated global event subscriptions under a specific Azure subscription.
896// Parameters:
897// filter - the query used to filter the search results using OData syntax. Filtering is permitted on the
898// 'name' property only and with limited number of OData operations. These operations are: the 'contains'
899// function as well as the following logical operations: not, and, or, eq (for equal), and ne (for not equal).
900// No arithmetic operations are supported. The following is a valid filter example: $filter=contains(namE,
901// 'PATTERN') and name ne 'PATTERN-1'. The following is not a valid filter example: $filter=location eq
902// 'westus'.
903// top - the number of results to return per page for the list operation. Valid range for top parameter is 1 to
904// 100. If not specified, the default number of results to be returned is 20 items per page.
905func (client EventSubscriptionsClient) ListGlobalBySubscription(ctx context.Context, filter string, top *int32) (result EventSubscriptionsListResultPage, err error) {
906	if tracing.IsEnabled() {
907		ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListGlobalBySubscription")
908		defer func() {
909			sc := -1
910			if result.eslr.Response.Response != nil {
911				sc = result.eslr.Response.Response.StatusCode
912			}
913			tracing.EndSpan(ctx, sc, err)
914		}()
915	}
916	result.fn = client.listGlobalBySubscriptionNextResults
917	req, err := client.ListGlobalBySubscriptionPreparer(ctx, filter, top)
918	if err != nil {
919		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalBySubscription", nil, "Failure preparing request")
920		return
921	}
922
923	resp, err := client.ListGlobalBySubscriptionSender(req)
924	if err != nil {
925		result.eslr.Response = autorest.Response{Response: resp}
926		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalBySubscription", resp, "Failure sending request")
927		return
928	}
929
930	result.eslr, err = client.ListGlobalBySubscriptionResponder(resp)
931	if err != nil {
932		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalBySubscription", resp, "Failure responding to request")
933	}
934
935	return
936}
937
938// ListGlobalBySubscriptionPreparer prepares the ListGlobalBySubscription request.
939func (client EventSubscriptionsClient) ListGlobalBySubscriptionPreparer(ctx context.Context, filter string, top *int32) (*http.Request, error) {
940	pathParameters := map[string]interface{}{
941		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
942	}
943
944	const APIVersion = "2020-04-01-preview"
945	queryParameters := map[string]interface{}{
946		"api-version": APIVersion,
947	}
948	if len(filter) > 0 {
949		queryParameters["$filter"] = autorest.Encode("query", filter)
950	}
951	if top != nil {
952		queryParameters["$top"] = autorest.Encode("query", *top)
953	}
954
955	preparer := autorest.CreatePreparer(
956		autorest.AsGet(),
957		autorest.WithBaseURL(client.BaseURI),
958		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/eventSubscriptions", pathParameters),
959		autorest.WithQueryParameters(queryParameters))
960	return preparer.Prepare((&http.Request{}).WithContext(ctx))
961}
962
963// ListGlobalBySubscriptionSender sends the ListGlobalBySubscription request. The method will close the
964// http.Response Body if it receives an error.
965func (client EventSubscriptionsClient) ListGlobalBySubscriptionSender(req *http.Request) (*http.Response, error) {
966	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
967}
968
969// ListGlobalBySubscriptionResponder handles the response to the ListGlobalBySubscription request. The method always
970// closes the http.Response Body.
971func (client EventSubscriptionsClient) ListGlobalBySubscriptionResponder(resp *http.Response) (result EventSubscriptionsListResult, err error) {
972	err = autorest.Respond(
973		resp,
974		client.ByInspecting(),
975		azure.WithErrorUnlessStatusCode(http.StatusOK),
976		autorest.ByUnmarshallingJSON(&result),
977		autorest.ByClosing())
978	result.Response = autorest.Response{Response: resp}
979	return
980}
981
982// listGlobalBySubscriptionNextResults retrieves the next set of results, if any.
983func (client EventSubscriptionsClient) listGlobalBySubscriptionNextResults(ctx context.Context, lastResults EventSubscriptionsListResult) (result EventSubscriptionsListResult, err error) {
984	req, err := lastResults.eventSubscriptionsListResultPreparer(ctx)
985	if err != nil {
986		return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listGlobalBySubscriptionNextResults", nil, "Failure preparing next results request")
987	}
988	if req == nil {
989		return
990	}
991	resp, err := client.ListGlobalBySubscriptionSender(req)
992	if err != nil {
993		result.Response = autorest.Response{Response: resp}
994		return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listGlobalBySubscriptionNextResults", resp, "Failure sending next results request")
995	}
996	result, err = client.ListGlobalBySubscriptionResponder(resp)
997	if err != nil {
998		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listGlobalBySubscriptionNextResults", resp, "Failure responding to next results request")
999	}
1000	return
1001}
1002
1003// ListGlobalBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required.
1004func (client EventSubscriptionsClient) ListGlobalBySubscriptionComplete(ctx context.Context, filter string, top *int32) (result EventSubscriptionsListResultIterator, err error) {
1005	if tracing.IsEnabled() {
1006		ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListGlobalBySubscription")
1007		defer func() {
1008			sc := -1
1009			if result.Response().Response.Response != nil {
1010				sc = result.page.Response().Response.Response.StatusCode
1011			}
1012			tracing.EndSpan(ctx, sc, err)
1013		}()
1014	}
1015	result.page, err = client.ListGlobalBySubscription(ctx, filter, top)
1016	return
1017}
1018
1019// ListGlobalBySubscriptionForTopicType list all global event subscriptions under an Azure subscription for a topic
1020// type.
1021// Parameters:
1022// topicTypeName - name of the topic type.
1023// filter - the query used to filter the search results using OData syntax. Filtering is permitted on the
1024// 'name' property only and with limited number of OData operations. These operations are: the 'contains'
1025// function as well as the following logical operations: not, and, or, eq (for equal), and ne (for not equal).
1026// No arithmetic operations are supported. The following is a valid filter example: $filter=contains(namE,
1027// 'PATTERN') and name ne 'PATTERN-1'. The following is not a valid filter example: $filter=location eq
1028// 'westus'.
1029// top - the number of results to return per page for the list operation. Valid range for top parameter is 1 to
1030// 100. If not specified, the default number of results to be returned is 20 items per page.
1031func (client EventSubscriptionsClient) ListGlobalBySubscriptionForTopicType(ctx context.Context, topicTypeName string, filter string, top *int32) (result EventSubscriptionsListResultPage, err error) {
1032	if tracing.IsEnabled() {
1033		ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListGlobalBySubscriptionForTopicType")
1034		defer func() {
1035			sc := -1
1036			if result.eslr.Response.Response != nil {
1037				sc = result.eslr.Response.Response.StatusCode
1038			}
1039			tracing.EndSpan(ctx, sc, err)
1040		}()
1041	}
1042	result.fn = client.listGlobalBySubscriptionForTopicTypeNextResults
1043	req, err := client.ListGlobalBySubscriptionForTopicTypePreparer(ctx, topicTypeName, filter, top)
1044	if err != nil {
1045		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalBySubscriptionForTopicType", nil, "Failure preparing request")
1046		return
1047	}
1048
1049	resp, err := client.ListGlobalBySubscriptionForTopicTypeSender(req)
1050	if err != nil {
1051		result.eslr.Response = autorest.Response{Response: resp}
1052		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalBySubscriptionForTopicType", resp, "Failure sending request")
1053		return
1054	}
1055
1056	result.eslr, err = client.ListGlobalBySubscriptionForTopicTypeResponder(resp)
1057	if err != nil {
1058		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalBySubscriptionForTopicType", resp, "Failure responding to request")
1059	}
1060
1061	return
1062}
1063
1064// ListGlobalBySubscriptionForTopicTypePreparer prepares the ListGlobalBySubscriptionForTopicType request.
1065func (client EventSubscriptionsClient) ListGlobalBySubscriptionForTopicTypePreparer(ctx context.Context, topicTypeName string, filter string, top *int32) (*http.Request, error) {
1066	pathParameters := map[string]interface{}{
1067		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
1068		"topicTypeName":  autorest.Encode("path", topicTypeName),
1069	}
1070
1071	const APIVersion = "2020-04-01-preview"
1072	queryParameters := map[string]interface{}{
1073		"api-version": APIVersion,
1074	}
1075	if len(filter) > 0 {
1076		queryParameters["$filter"] = autorest.Encode("query", filter)
1077	}
1078	if top != nil {
1079		queryParameters["$top"] = autorest.Encode("query", *top)
1080	}
1081
1082	preparer := autorest.CreatePreparer(
1083		autorest.AsGet(),
1084		autorest.WithBaseURL(client.BaseURI),
1085		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/topicTypes/{topicTypeName}/eventSubscriptions", pathParameters),
1086		autorest.WithQueryParameters(queryParameters))
1087	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1088}
1089
1090// ListGlobalBySubscriptionForTopicTypeSender sends the ListGlobalBySubscriptionForTopicType request. The method will close the
1091// http.Response Body if it receives an error.
1092func (client EventSubscriptionsClient) ListGlobalBySubscriptionForTopicTypeSender(req *http.Request) (*http.Response, error) {
1093	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
1094}
1095
1096// ListGlobalBySubscriptionForTopicTypeResponder handles the response to the ListGlobalBySubscriptionForTopicType request. The method always
1097// closes the http.Response Body.
1098func (client EventSubscriptionsClient) ListGlobalBySubscriptionForTopicTypeResponder(resp *http.Response) (result EventSubscriptionsListResult, err error) {
1099	err = autorest.Respond(
1100		resp,
1101		client.ByInspecting(),
1102		azure.WithErrorUnlessStatusCode(http.StatusOK),
1103		autorest.ByUnmarshallingJSON(&result),
1104		autorest.ByClosing())
1105	result.Response = autorest.Response{Response: resp}
1106	return
1107}
1108
1109// listGlobalBySubscriptionForTopicTypeNextResults retrieves the next set of results, if any.
1110func (client EventSubscriptionsClient) listGlobalBySubscriptionForTopicTypeNextResults(ctx context.Context, lastResults EventSubscriptionsListResult) (result EventSubscriptionsListResult, err error) {
1111	req, err := lastResults.eventSubscriptionsListResultPreparer(ctx)
1112	if err != nil {
1113		return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listGlobalBySubscriptionForTopicTypeNextResults", nil, "Failure preparing next results request")
1114	}
1115	if req == nil {
1116		return
1117	}
1118	resp, err := client.ListGlobalBySubscriptionForTopicTypeSender(req)
1119	if err != nil {
1120		result.Response = autorest.Response{Response: resp}
1121		return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listGlobalBySubscriptionForTopicTypeNextResults", resp, "Failure sending next results request")
1122	}
1123	result, err = client.ListGlobalBySubscriptionForTopicTypeResponder(resp)
1124	if err != nil {
1125		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listGlobalBySubscriptionForTopicTypeNextResults", resp, "Failure responding to next results request")
1126	}
1127	return
1128}
1129
1130// ListGlobalBySubscriptionForTopicTypeComplete enumerates all values, automatically crossing page boundaries as required.
1131func (client EventSubscriptionsClient) ListGlobalBySubscriptionForTopicTypeComplete(ctx context.Context, topicTypeName string, filter string, top *int32) (result EventSubscriptionsListResultIterator, err error) {
1132	if tracing.IsEnabled() {
1133		ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListGlobalBySubscriptionForTopicType")
1134		defer func() {
1135			sc := -1
1136			if result.Response().Response.Response != nil {
1137				sc = result.page.Response().Response.Response.StatusCode
1138			}
1139			tracing.EndSpan(ctx, sc, err)
1140		}()
1141	}
1142	result.page, err = client.ListGlobalBySubscriptionForTopicType(ctx, topicTypeName, filter, top)
1143	return
1144}
1145
1146// ListRegionalByResourceGroup list all event subscriptions from the given location under a specific Azure subscription
1147// and resource group.
1148// Parameters:
1149// resourceGroupName - the name of the resource group within the user's subscription.
1150// location - name of the location.
1151// filter - the query used to filter the search results using OData syntax. Filtering is permitted on the
1152// 'name' property only and with limited number of OData operations. These operations are: the 'contains'
1153// function as well as the following logical operations: not, and, or, eq (for equal), and ne (for not equal).
1154// No arithmetic operations are supported. The following is a valid filter example: $filter=contains(namE,
1155// 'PATTERN') and name ne 'PATTERN-1'. The following is not a valid filter example: $filter=location eq
1156// 'westus'.
1157// top - the number of results to return per page for the list operation. Valid range for top parameter is 1 to
1158// 100. If not specified, the default number of results to be returned is 20 items per page.
1159func (client EventSubscriptionsClient) ListRegionalByResourceGroup(ctx context.Context, resourceGroupName string, location string, filter string, top *int32) (result EventSubscriptionsListResultPage, err error) {
1160	if tracing.IsEnabled() {
1161		ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListRegionalByResourceGroup")
1162		defer func() {
1163			sc := -1
1164			if result.eslr.Response.Response != nil {
1165				sc = result.eslr.Response.Response.StatusCode
1166			}
1167			tracing.EndSpan(ctx, sc, err)
1168		}()
1169	}
1170	result.fn = client.listRegionalByResourceGroupNextResults
1171	req, err := client.ListRegionalByResourceGroupPreparer(ctx, resourceGroupName, location, filter, top)
1172	if err != nil {
1173		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalByResourceGroup", nil, "Failure preparing request")
1174		return
1175	}
1176
1177	resp, err := client.ListRegionalByResourceGroupSender(req)
1178	if err != nil {
1179		result.eslr.Response = autorest.Response{Response: resp}
1180		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalByResourceGroup", resp, "Failure sending request")
1181		return
1182	}
1183
1184	result.eslr, err = client.ListRegionalByResourceGroupResponder(resp)
1185	if err != nil {
1186		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalByResourceGroup", resp, "Failure responding to request")
1187	}
1188
1189	return
1190}
1191
1192// ListRegionalByResourceGroupPreparer prepares the ListRegionalByResourceGroup request.
1193func (client EventSubscriptionsClient) ListRegionalByResourceGroupPreparer(ctx context.Context, resourceGroupName string, location string, filter string, top *int32) (*http.Request, error) {
1194	pathParameters := map[string]interface{}{
1195		"location":          autorest.Encode("path", location),
1196		"resourceGroupName": autorest.Encode("path", resourceGroupName),
1197		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
1198	}
1199
1200	const APIVersion = "2020-04-01-preview"
1201	queryParameters := map[string]interface{}{
1202		"api-version": APIVersion,
1203	}
1204	if len(filter) > 0 {
1205		queryParameters["$filter"] = autorest.Encode("query", filter)
1206	}
1207	if top != nil {
1208		queryParameters["$top"] = autorest.Encode("query", *top)
1209	}
1210
1211	preparer := autorest.CreatePreparer(
1212		autorest.AsGet(),
1213		autorest.WithBaseURL(client.BaseURI),
1214		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/locations/{location}/eventSubscriptions", pathParameters),
1215		autorest.WithQueryParameters(queryParameters))
1216	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1217}
1218
1219// ListRegionalByResourceGroupSender sends the ListRegionalByResourceGroup request. The method will close the
1220// http.Response Body if it receives an error.
1221func (client EventSubscriptionsClient) ListRegionalByResourceGroupSender(req *http.Request) (*http.Response, error) {
1222	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
1223}
1224
1225// ListRegionalByResourceGroupResponder handles the response to the ListRegionalByResourceGroup request. The method always
1226// closes the http.Response Body.
1227func (client EventSubscriptionsClient) ListRegionalByResourceGroupResponder(resp *http.Response) (result EventSubscriptionsListResult, err error) {
1228	err = autorest.Respond(
1229		resp,
1230		client.ByInspecting(),
1231		azure.WithErrorUnlessStatusCode(http.StatusOK),
1232		autorest.ByUnmarshallingJSON(&result),
1233		autorest.ByClosing())
1234	result.Response = autorest.Response{Response: resp}
1235	return
1236}
1237
1238// listRegionalByResourceGroupNextResults retrieves the next set of results, if any.
1239func (client EventSubscriptionsClient) listRegionalByResourceGroupNextResults(ctx context.Context, lastResults EventSubscriptionsListResult) (result EventSubscriptionsListResult, err error) {
1240	req, err := lastResults.eventSubscriptionsListResultPreparer(ctx)
1241	if err != nil {
1242		return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listRegionalByResourceGroupNextResults", nil, "Failure preparing next results request")
1243	}
1244	if req == nil {
1245		return
1246	}
1247	resp, err := client.ListRegionalByResourceGroupSender(req)
1248	if err != nil {
1249		result.Response = autorest.Response{Response: resp}
1250		return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listRegionalByResourceGroupNextResults", resp, "Failure sending next results request")
1251	}
1252	result, err = client.ListRegionalByResourceGroupResponder(resp)
1253	if err != nil {
1254		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listRegionalByResourceGroupNextResults", resp, "Failure responding to next results request")
1255	}
1256	return
1257}
1258
1259// ListRegionalByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required.
1260func (client EventSubscriptionsClient) ListRegionalByResourceGroupComplete(ctx context.Context, resourceGroupName string, location string, filter string, top *int32) (result EventSubscriptionsListResultIterator, err error) {
1261	if tracing.IsEnabled() {
1262		ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListRegionalByResourceGroup")
1263		defer func() {
1264			sc := -1
1265			if result.Response().Response.Response != nil {
1266				sc = result.page.Response().Response.Response.StatusCode
1267			}
1268			tracing.EndSpan(ctx, sc, err)
1269		}()
1270	}
1271	result.page, err = client.ListRegionalByResourceGroup(ctx, resourceGroupName, location, filter, top)
1272	return
1273}
1274
1275// ListRegionalByResourceGroupForTopicType list all event subscriptions from the given location under a specific Azure
1276// subscription and resource group and topic type.
1277// Parameters:
1278// resourceGroupName - the name of the resource group within the user's subscription.
1279// location - name of the location.
1280// topicTypeName - name of the topic type.
1281// filter - the query used to filter the search results using OData syntax. Filtering is permitted on the
1282// 'name' property only and with limited number of OData operations. These operations are: the 'contains'
1283// function as well as the following logical operations: not, and, or, eq (for equal), and ne (for not equal).
1284// No arithmetic operations are supported. The following is a valid filter example: $filter=contains(namE,
1285// 'PATTERN') and name ne 'PATTERN-1'. The following is not a valid filter example: $filter=location eq
1286// 'westus'.
1287// top - the number of results to return per page for the list operation. Valid range for top parameter is 1 to
1288// 100. If not specified, the default number of results to be returned is 20 items per page.
1289func (client EventSubscriptionsClient) ListRegionalByResourceGroupForTopicType(ctx context.Context, resourceGroupName string, location string, topicTypeName string, filter string, top *int32) (result EventSubscriptionsListResultPage, err error) {
1290	if tracing.IsEnabled() {
1291		ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListRegionalByResourceGroupForTopicType")
1292		defer func() {
1293			sc := -1
1294			if result.eslr.Response.Response != nil {
1295				sc = result.eslr.Response.Response.StatusCode
1296			}
1297			tracing.EndSpan(ctx, sc, err)
1298		}()
1299	}
1300	result.fn = client.listRegionalByResourceGroupForTopicTypeNextResults
1301	req, err := client.ListRegionalByResourceGroupForTopicTypePreparer(ctx, resourceGroupName, location, topicTypeName, filter, top)
1302	if err != nil {
1303		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalByResourceGroupForTopicType", nil, "Failure preparing request")
1304		return
1305	}
1306
1307	resp, err := client.ListRegionalByResourceGroupForTopicTypeSender(req)
1308	if err != nil {
1309		result.eslr.Response = autorest.Response{Response: resp}
1310		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalByResourceGroupForTopicType", resp, "Failure sending request")
1311		return
1312	}
1313
1314	result.eslr, err = client.ListRegionalByResourceGroupForTopicTypeResponder(resp)
1315	if err != nil {
1316		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalByResourceGroupForTopicType", resp, "Failure responding to request")
1317	}
1318
1319	return
1320}
1321
1322// ListRegionalByResourceGroupForTopicTypePreparer prepares the ListRegionalByResourceGroupForTopicType request.
1323func (client EventSubscriptionsClient) ListRegionalByResourceGroupForTopicTypePreparer(ctx context.Context, resourceGroupName string, location string, topicTypeName string, filter string, top *int32) (*http.Request, error) {
1324	pathParameters := map[string]interface{}{
1325		"location":          autorest.Encode("path", location),
1326		"resourceGroupName": autorest.Encode("path", resourceGroupName),
1327		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
1328		"topicTypeName":     autorest.Encode("path", topicTypeName),
1329	}
1330
1331	const APIVersion = "2020-04-01-preview"
1332	queryParameters := map[string]interface{}{
1333		"api-version": APIVersion,
1334	}
1335	if len(filter) > 0 {
1336		queryParameters["$filter"] = autorest.Encode("query", filter)
1337	}
1338	if top != nil {
1339		queryParameters["$top"] = autorest.Encode("query", *top)
1340	}
1341
1342	preparer := autorest.CreatePreparer(
1343		autorest.AsGet(),
1344		autorest.WithBaseURL(client.BaseURI),
1345		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/locations/{location}/topicTypes/{topicTypeName}/eventSubscriptions", pathParameters),
1346		autorest.WithQueryParameters(queryParameters))
1347	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1348}
1349
1350// ListRegionalByResourceGroupForTopicTypeSender sends the ListRegionalByResourceGroupForTopicType request. The method will close the
1351// http.Response Body if it receives an error.
1352func (client EventSubscriptionsClient) ListRegionalByResourceGroupForTopicTypeSender(req *http.Request) (*http.Response, error) {
1353	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
1354}
1355
1356// ListRegionalByResourceGroupForTopicTypeResponder handles the response to the ListRegionalByResourceGroupForTopicType request. The method always
1357// closes the http.Response Body.
1358func (client EventSubscriptionsClient) ListRegionalByResourceGroupForTopicTypeResponder(resp *http.Response) (result EventSubscriptionsListResult, err error) {
1359	err = autorest.Respond(
1360		resp,
1361		client.ByInspecting(),
1362		azure.WithErrorUnlessStatusCode(http.StatusOK),
1363		autorest.ByUnmarshallingJSON(&result),
1364		autorest.ByClosing())
1365	result.Response = autorest.Response{Response: resp}
1366	return
1367}
1368
1369// listRegionalByResourceGroupForTopicTypeNextResults retrieves the next set of results, if any.
1370func (client EventSubscriptionsClient) listRegionalByResourceGroupForTopicTypeNextResults(ctx context.Context, lastResults EventSubscriptionsListResult) (result EventSubscriptionsListResult, err error) {
1371	req, err := lastResults.eventSubscriptionsListResultPreparer(ctx)
1372	if err != nil {
1373		return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listRegionalByResourceGroupForTopicTypeNextResults", nil, "Failure preparing next results request")
1374	}
1375	if req == nil {
1376		return
1377	}
1378	resp, err := client.ListRegionalByResourceGroupForTopicTypeSender(req)
1379	if err != nil {
1380		result.Response = autorest.Response{Response: resp}
1381		return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listRegionalByResourceGroupForTopicTypeNextResults", resp, "Failure sending next results request")
1382	}
1383	result, err = client.ListRegionalByResourceGroupForTopicTypeResponder(resp)
1384	if err != nil {
1385		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listRegionalByResourceGroupForTopicTypeNextResults", resp, "Failure responding to next results request")
1386	}
1387	return
1388}
1389
1390// ListRegionalByResourceGroupForTopicTypeComplete enumerates all values, automatically crossing page boundaries as required.
1391func (client EventSubscriptionsClient) ListRegionalByResourceGroupForTopicTypeComplete(ctx context.Context, resourceGroupName string, location string, topicTypeName string, filter string, top *int32) (result EventSubscriptionsListResultIterator, err error) {
1392	if tracing.IsEnabled() {
1393		ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListRegionalByResourceGroupForTopicType")
1394		defer func() {
1395			sc := -1
1396			if result.Response().Response.Response != nil {
1397				sc = result.page.Response().Response.Response.StatusCode
1398			}
1399			tracing.EndSpan(ctx, sc, err)
1400		}()
1401	}
1402	result.page, err = client.ListRegionalByResourceGroupForTopicType(ctx, resourceGroupName, location, topicTypeName, filter, top)
1403	return
1404}
1405
1406// ListRegionalBySubscription list all event subscriptions from the given location under a specific Azure subscription.
1407// Parameters:
1408// location - name of the location.
1409// filter - the query used to filter the search results using OData syntax. Filtering is permitted on the
1410// 'name' property only and with limited number of OData operations. These operations are: the 'contains'
1411// function as well as the following logical operations: not, and, or, eq (for equal), and ne (for not equal).
1412// No arithmetic operations are supported. The following is a valid filter example: $filter=contains(namE,
1413// 'PATTERN') and name ne 'PATTERN-1'. The following is not a valid filter example: $filter=location eq
1414// 'westus'.
1415// top - the number of results to return per page for the list operation. Valid range for top parameter is 1 to
1416// 100. If not specified, the default number of results to be returned is 20 items per page.
1417func (client EventSubscriptionsClient) ListRegionalBySubscription(ctx context.Context, location string, filter string, top *int32) (result EventSubscriptionsListResultPage, err error) {
1418	if tracing.IsEnabled() {
1419		ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListRegionalBySubscription")
1420		defer func() {
1421			sc := -1
1422			if result.eslr.Response.Response != nil {
1423				sc = result.eslr.Response.Response.StatusCode
1424			}
1425			tracing.EndSpan(ctx, sc, err)
1426		}()
1427	}
1428	result.fn = client.listRegionalBySubscriptionNextResults
1429	req, err := client.ListRegionalBySubscriptionPreparer(ctx, location, filter, top)
1430	if err != nil {
1431		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalBySubscription", nil, "Failure preparing request")
1432		return
1433	}
1434
1435	resp, err := client.ListRegionalBySubscriptionSender(req)
1436	if err != nil {
1437		result.eslr.Response = autorest.Response{Response: resp}
1438		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalBySubscription", resp, "Failure sending request")
1439		return
1440	}
1441
1442	result.eslr, err = client.ListRegionalBySubscriptionResponder(resp)
1443	if err != nil {
1444		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalBySubscription", resp, "Failure responding to request")
1445	}
1446
1447	return
1448}
1449
1450// ListRegionalBySubscriptionPreparer prepares the ListRegionalBySubscription request.
1451func (client EventSubscriptionsClient) ListRegionalBySubscriptionPreparer(ctx context.Context, location string, filter string, top *int32) (*http.Request, error) {
1452	pathParameters := map[string]interface{}{
1453		"location":       autorest.Encode("path", location),
1454		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
1455	}
1456
1457	const APIVersion = "2020-04-01-preview"
1458	queryParameters := map[string]interface{}{
1459		"api-version": APIVersion,
1460	}
1461	if len(filter) > 0 {
1462		queryParameters["$filter"] = autorest.Encode("query", filter)
1463	}
1464	if top != nil {
1465		queryParameters["$top"] = autorest.Encode("query", *top)
1466	}
1467
1468	preparer := autorest.CreatePreparer(
1469		autorest.AsGet(),
1470		autorest.WithBaseURL(client.BaseURI),
1471		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/locations/{location}/eventSubscriptions", pathParameters),
1472		autorest.WithQueryParameters(queryParameters))
1473	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1474}
1475
1476// ListRegionalBySubscriptionSender sends the ListRegionalBySubscription request. The method will close the
1477// http.Response Body if it receives an error.
1478func (client EventSubscriptionsClient) ListRegionalBySubscriptionSender(req *http.Request) (*http.Response, error) {
1479	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
1480}
1481
1482// ListRegionalBySubscriptionResponder handles the response to the ListRegionalBySubscription request. The method always
1483// closes the http.Response Body.
1484func (client EventSubscriptionsClient) ListRegionalBySubscriptionResponder(resp *http.Response) (result EventSubscriptionsListResult, err error) {
1485	err = autorest.Respond(
1486		resp,
1487		client.ByInspecting(),
1488		azure.WithErrorUnlessStatusCode(http.StatusOK),
1489		autorest.ByUnmarshallingJSON(&result),
1490		autorest.ByClosing())
1491	result.Response = autorest.Response{Response: resp}
1492	return
1493}
1494
1495// listRegionalBySubscriptionNextResults retrieves the next set of results, if any.
1496func (client EventSubscriptionsClient) listRegionalBySubscriptionNextResults(ctx context.Context, lastResults EventSubscriptionsListResult) (result EventSubscriptionsListResult, err error) {
1497	req, err := lastResults.eventSubscriptionsListResultPreparer(ctx)
1498	if err != nil {
1499		return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listRegionalBySubscriptionNextResults", nil, "Failure preparing next results request")
1500	}
1501	if req == nil {
1502		return
1503	}
1504	resp, err := client.ListRegionalBySubscriptionSender(req)
1505	if err != nil {
1506		result.Response = autorest.Response{Response: resp}
1507		return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listRegionalBySubscriptionNextResults", resp, "Failure sending next results request")
1508	}
1509	result, err = client.ListRegionalBySubscriptionResponder(resp)
1510	if err != nil {
1511		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listRegionalBySubscriptionNextResults", resp, "Failure responding to next results request")
1512	}
1513	return
1514}
1515
1516// ListRegionalBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required.
1517func (client EventSubscriptionsClient) ListRegionalBySubscriptionComplete(ctx context.Context, location string, filter string, top *int32) (result EventSubscriptionsListResultIterator, err error) {
1518	if tracing.IsEnabled() {
1519		ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListRegionalBySubscription")
1520		defer func() {
1521			sc := -1
1522			if result.Response().Response.Response != nil {
1523				sc = result.page.Response().Response.Response.StatusCode
1524			}
1525			tracing.EndSpan(ctx, sc, err)
1526		}()
1527	}
1528	result.page, err = client.ListRegionalBySubscription(ctx, location, filter, top)
1529	return
1530}
1531
1532// ListRegionalBySubscriptionForTopicType list all event subscriptions from the given location under a specific Azure
1533// subscription and topic type.
1534// Parameters:
1535// location - name of the location.
1536// topicTypeName - name of the topic type.
1537// filter - the query used to filter the search results using OData syntax. Filtering is permitted on the
1538// 'name' property only and with limited number of OData operations. These operations are: the 'contains'
1539// function as well as the following logical operations: not, and, or, eq (for equal), and ne (for not equal).
1540// No arithmetic operations are supported. The following is a valid filter example: $filter=contains(namE,
1541// 'PATTERN') and name ne 'PATTERN-1'. The following is not a valid filter example: $filter=location eq
1542// 'westus'.
1543// top - the number of results to return per page for the list operation. Valid range for top parameter is 1 to
1544// 100. If not specified, the default number of results to be returned is 20 items per page.
1545func (client EventSubscriptionsClient) ListRegionalBySubscriptionForTopicType(ctx context.Context, location string, topicTypeName string, filter string, top *int32) (result EventSubscriptionsListResultPage, err error) {
1546	if tracing.IsEnabled() {
1547		ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListRegionalBySubscriptionForTopicType")
1548		defer func() {
1549			sc := -1
1550			if result.eslr.Response.Response != nil {
1551				sc = result.eslr.Response.Response.StatusCode
1552			}
1553			tracing.EndSpan(ctx, sc, err)
1554		}()
1555	}
1556	result.fn = client.listRegionalBySubscriptionForTopicTypeNextResults
1557	req, err := client.ListRegionalBySubscriptionForTopicTypePreparer(ctx, location, topicTypeName, filter, top)
1558	if err != nil {
1559		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalBySubscriptionForTopicType", nil, "Failure preparing request")
1560		return
1561	}
1562
1563	resp, err := client.ListRegionalBySubscriptionForTopicTypeSender(req)
1564	if err != nil {
1565		result.eslr.Response = autorest.Response{Response: resp}
1566		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalBySubscriptionForTopicType", resp, "Failure sending request")
1567		return
1568	}
1569
1570	result.eslr, err = client.ListRegionalBySubscriptionForTopicTypeResponder(resp)
1571	if err != nil {
1572		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalBySubscriptionForTopicType", resp, "Failure responding to request")
1573	}
1574
1575	return
1576}
1577
1578// ListRegionalBySubscriptionForTopicTypePreparer prepares the ListRegionalBySubscriptionForTopicType request.
1579func (client EventSubscriptionsClient) ListRegionalBySubscriptionForTopicTypePreparer(ctx context.Context, location string, topicTypeName string, filter string, top *int32) (*http.Request, error) {
1580	pathParameters := map[string]interface{}{
1581		"location":       autorest.Encode("path", location),
1582		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
1583		"topicTypeName":  autorest.Encode("path", topicTypeName),
1584	}
1585
1586	const APIVersion = "2020-04-01-preview"
1587	queryParameters := map[string]interface{}{
1588		"api-version": APIVersion,
1589	}
1590	if len(filter) > 0 {
1591		queryParameters["$filter"] = autorest.Encode("query", filter)
1592	}
1593	if top != nil {
1594		queryParameters["$top"] = autorest.Encode("query", *top)
1595	}
1596
1597	preparer := autorest.CreatePreparer(
1598		autorest.AsGet(),
1599		autorest.WithBaseURL(client.BaseURI),
1600		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/locations/{location}/topicTypes/{topicTypeName}/eventSubscriptions", pathParameters),
1601		autorest.WithQueryParameters(queryParameters))
1602	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1603}
1604
1605// ListRegionalBySubscriptionForTopicTypeSender sends the ListRegionalBySubscriptionForTopicType request. The method will close the
1606// http.Response Body if it receives an error.
1607func (client EventSubscriptionsClient) ListRegionalBySubscriptionForTopicTypeSender(req *http.Request) (*http.Response, error) {
1608	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
1609}
1610
1611// ListRegionalBySubscriptionForTopicTypeResponder handles the response to the ListRegionalBySubscriptionForTopicType request. The method always
1612// closes the http.Response Body.
1613func (client EventSubscriptionsClient) ListRegionalBySubscriptionForTopicTypeResponder(resp *http.Response) (result EventSubscriptionsListResult, err error) {
1614	err = autorest.Respond(
1615		resp,
1616		client.ByInspecting(),
1617		azure.WithErrorUnlessStatusCode(http.StatusOK),
1618		autorest.ByUnmarshallingJSON(&result),
1619		autorest.ByClosing())
1620	result.Response = autorest.Response{Response: resp}
1621	return
1622}
1623
1624// listRegionalBySubscriptionForTopicTypeNextResults retrieves the next set of results, if any.
1625func (client EventSubscriptionsClient) listRegionalBySubscriptionForTopicTypeNextResults(ctx context.Context, lastResults EventSubscriptionsListResult) (result EventSubscriptionsListResult, err error) {
1626	req, err := lastResults.eventSubscriptionsListResultPreparer(ctx)
1627	if err != nil {
1628		return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listRegionalBySubscriptionForTopicTypeNextResults", nil, "Failure preparing next results request")
1629	}
1630	if req == nil {
1631		return
1632	}
1633	resp, err := client.ListRegionalBySubscriptionForTopicTypeSender(req)
1634	if err != nil {
1635		result.Response = autorest.Response{Response: resp}
1636		return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listRegionalBySubscriptionForTopicTypeNextResults", resp, "Failure sending next results request")
1637	}
1638	result, err = client.ListRegionalBySubscriptionForTopicTypeResponder(resp)
1639	if err != nil {
1640		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listRegionalBySubscriptionForTopicTypeNextResults", resp, "Failure responding to next results request")
1641	}
1642	return
1643}
1644
1645// ListRegionalBySubscriptionForTopicTypeComplete enumerates all values, automatically crossing page boundaries as required.
1646func (client EventSubscriptionsClient) ListRegionalBySubscriptionForTopicTypeComplete(ctx context.Context, location string, topicTypeName string, filter string, top *int32) (result EventSubscriptionsListResultIterator, err error) {
1647	if tracing.IsEnabled() {
1648		ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListRegionalBySubscriptionForTopicType")
1649		defer func() {
1650			sc := -1
1651			if result.Response().Response.Response != nil {
1652				sc = result.page.Response().Response.Response.StatusCode
1653			}
1654			tracing.EndSpan(ctx, sc, err)
1655		}()
1656	}
1657	result.page, err = client.ListRegionalBySubscriptionForTopicType(ctx, location, topicTypeName, filter, top)
1658	return
1659}
1660
1661// Update asynchronously updates an existing event subscription.
1662// Parameters:
1663// scope - the scope of existing event subscription. The scope can be a subscription, or a resource group, or a
1664// top level resource belonging to a resource provider namespace, or an EventGrid topic. For example, use
1665// '/subscriptions/{subscriptionId}/' for a subscription,
1666// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for a resource group, and
1667// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}'
1668// for a resource, and
1669// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}'
1670// for an EventGrid topic.
1671// eventSubscriptionName - name of the event subscription to be updated.
1672// eventSubscriptionUpdateParameters - updated event subscription information.
1673func (client EventSubscriptionsClient) Update(ctx context.Context, scope string, eventSubscriptionName string, eventSubscriptionUpdateParameters EventSubscriptionUpdateParameters) (result EventSubscriptionsUpdateFuture, err error) {
1674	if tracing.IsEnabled() {
1675		ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.Update")
1676		defer func() {
1677			sc := -1
1678			if result.Response() != nil {
1679				sc = result.Response().StatusCode
1680			}
1681			tracing.EndSpan(ctx, sc, err)
1682		}()
1683	}
1684	req, err := client.UpdatePreparer(ctx, scope, eventSubscriptionName, eventSubscriptionUpdateParameters)
1685	if err != nil {
1686		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "Update", nil, "Failure preparing request")
1687		return
1688	}
1689
1690	result, err = client.UpdateSender(req)
1691	if err != nil {
1692		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "Update", result.Response(), "Failure sending request")
1693		return
1694	}
1695
1696	return
1697}
1698
1699// UpdatePreparer prepares the Update request.
1700func (client EventSubscriptionsClient) UpdatePreparer(ctx context.Context, scope string, eventSubscriptionName string, eventSubscriptionUpdateParameters EventSubscriptionUpdateParameters) (*http.Request, error) {
1701	pathParameters := map[string]interface{}{
1702		"eventSubscriptionName": autorest.Encode("path", eventSubscriptionName),
1703		"scope":                 scope,
1704	}
1705
1706	const APIVersion = "2020-04-01-preview"
1707	queryParameters := map[string]interface{}{
1708		"api-version": APIVersion,
1709	}
1710
1711	preparer := autorest.CreatePreparer(
1712		autorest.AsContentType("application/json; charset=utf-8"),
1713		autorest.AsPatch(),
1714		autorest.WithBaseURL(client.BaseURI),
1715		autorest.WithPathParameters("/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}", pathParameters),
1716		autorest.WithJSON(eventSubscriptionUpdateParameters),
1717		autorest.WithQueryParameters(queryParameters))
1718	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1719}
1720
1721// UpdateSender sends the Update request. The method will close the
1722// http.Response Body if it receives an error.
1723func (client EventSubscriptionsClient) UpdateSender(req *http.Request) (future EventSubscriptionsUpdateFuture, err error) {
1724	var resp *http.Response
1725	resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
1726	if err != nil {
1727		return
1728	}
1729	future.Future, err = azure.NewFutureFromResponse(resp)
1730	return
1731}
1732
1733// UpdateResponder handles the response to the Update request. The method always
1734// closes the http.Response Body.
1735func (client EventSubscriptionsClient) UpdateResponder(resp *http.Response) (result EventSubscription, err error) {
1736	err = autorest.Respond(
1737		resp,
1738		client.ByInspecting(),
1739		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
1740		autorest.ByUnmarshallingJSON(&result),
1741		autorest.ByClosing())
1742	result.Response = autorest.Response{Response: resp}
1743	return
1744}
1745