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-01-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-01-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-01-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-01-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-01-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-01-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 group
640// Parameters:
641// resourceGroupName - the name of the resource group within the user's subscription.
642// filter - the query used to filter the search results using OData syntax. Filtering is permitted on the
643// 'name' property only and with limited number of OData operations. These operations are: the 'contains'
644// function as well as the following logical operations: not, and, or, eq (for equal), and ne (for not equal).
645// No arithmetic operations are supported. The following is a valid filter example: $filter=contains(namE,
646// 'PATTERN') and name ne 'PATTERN-1'. The following is not a valid filter example: $filter=location eq
647// 'westus'.
648// top - the number of results to return per page for the list operation. Valid range for top parameter is 1 to
649// 100. If not specified, the default number of results to be returned is 20 items per page.
650func (client EventSubscriptionsClient) ListGlobalByResourceGroup(ctx context.Context, resourceGroupName string, filter string, top *int32) (result EventSubscriptionsListResultPage, err error) {
651	if tracing.IsEnabled() {
652		ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListGlobalByResourceGroup")
653		defer func() {
654			sc := -1
655			if result.eslr.Response.Response != nil {
656				sc = result.eslr.Response.Response.StatusCode
657			}
658			tracing.EndSpan(ctx, sc, err)
659		}()
660	}
661	result.fn = client.listGlobalByResourceGroupNextResults
662	req, err := client.ListGlobalByResourceGroupPreparer(ctx, resourceGroupName, filter, top)
663	if err != nil {
664		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalByResourceGroup", nil, "Failure preparing request")
665		return
666	}
667
668	resp, err := client.ListGlobalByResourceGroupSender(req)
669	if err != nil {
670		result.eslr.Response = autorest.Response{Response: resp}
671		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalByResourceGroup", resp, "Failure sending request")
672		return
673	}
674
675	result.eslr, err = client.ListGlobalByResourceGroupResponder(resp)
676	if err != nil {
677		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalByResourceGroup", resp, "Failure responding to request")
678	}
679
680	return
681}
682
683// ListGlobalByResourceGroupPreparer prepares the ListGlobalByResourceGroup request.
684func (client EventSubscriptionsClient) ListGlobalByResourceGroupPreparer(ctx context.Context, resourceGroupName string, filter string, top *int32) (*http.Request, error) {
685	pathParameters := map[string]interface{}{
686		"resourceGroupName": autorest.Encode("path", resourceGroupName),
687		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
688	}
689
690	const APIVersion = "2020-01-01-preview"
691	queryParameters := map[string]interface{}{
692		"api-version": APIVersion,
693	}
694	if len(filter) > 0 {
695		queryParameters["$filter"] = autorest.Encode("query", filter)
696	}
697	if top != nil {
698		queryParameters["$top"] = autorest.Encode("query", *top)
699	}
700
701	preparer := autorest.CreatePreparer(
702		autorest.AsGet(),
703		autorest.WithBaseURL(client.BaseURI),
704		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/eventSubscriptions", pathParameters),
705		autorest.WithQueryParameters(queryParameters))
706	return preparer.Prepare((&http.Request{}).WithContext(ctx))
707}
708
709// ListGlobalByResourceGroupSender sends the ListGlobalByResourceGroup request. The method will close the
710// http.Response Body if it receives an error.
711func (client EventSubscriptionsClient) ListGlobalByResourceGroupSender(req *http.Request) (*http.Response, error) {
712	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
713}
714
715// ListGlobalByResourceGroupResponder handles the response to the ListGlobalByResourceGroup request. The method always
716// closes the http.Response Body.
717func (client EventSubscriptionsClient) ListGlobalByResourceGroupResponder(resp *http.Response) (result EventSubscriptionsListResult, err error) {
718	err = autorest.Respond(
719		resp,
720		client.ByInspecting(),
721		azure.WithErrorUnlessStatusCode(http.StatusOK),
722		autorest.ByUnmarshallingJSON(&result),
723		autorest.ByClosing())
724	result.Response = autorest.Response{Response: resp}
725	return
726}
727
728// listGlobalByResourceGroupNextResults retrieves the next set of results, if any.
729func (client EventSubscriptionsClient) listGlobalByResourceGroupNextResults(ctx context.Context, lastResults EventSubscriptionsListResult) (result EventSubscriptionsListResult, err error) {
730	req, err := lastResults.eventSubscriptionsListResultPreparer(ctx)
731	if err != nil {
732		return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listGlobalByResourceGroupNextResults", nil, "Failure preparing next results request")
733	}
734	if req == nil {
735		return
736	}
737	resp, err := client.ListGlobalByResourceGroupSender(req)
738	if err != nil {
739		result.Response = autorest.Response{Response: resp}
740		return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listGlobalByResourceGroupNextResults", resp, "Failure sending next results request")
741	}
742	result, err = client.ListGlobalByResourceGroupResponder(resp)
743	if err != nil {
744		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listGlobalByResourceGroupNextResults", resp, "Failure responding to next results request")
745	}
746	return
747}
748
749// ListGlobalByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required.
750func (client EventSubscriptionsClient) ListGlobalByResourceGroupComplete(ctx context.Context, resourceGroupName string, filter string, top *int32) (result EventSubscriptionsListResultIterator, err error) {
751	if tracing.IsEnabled() {
752		ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListGlobalByResourceGroup")
753		defer func() {
754			sc := -1
755			if result.Response().Response.Response != nil {
756				sc = result.page.Response().Response.Response.StatusCode
757			}
758			tracing.EndSpan(ctx, sc, err)
759		}()
760	}
761	result.page, err = client.ListGlobalByResourceGroup(ctx, resourceGroupName, filter, top)
762	return
763}
764
765// ListGlobalByResourceGroupForTopicType list all global event subscriptions under a resource group for a specific
766// topic type.
767// Parameters:
768// resourceGroupName - the name of the resource group within the user's subscription.
769// topicTypeName - name of the topic type
770// filter - the query used to filter the search results using OData syntax. Filtering is permitted on the
771// 'name' property only and with limited number of OData operations. These operations are: the 'contains'
772// function as well as the following logical operations: not, and, or, eq (for equal), and ne (for not equal).
773// No arithmetic operations are supported. The following is a valid filter example: $filter=contains(namE,
774// 'PATTERN') and name ne 'PATTERN-1'. The following is not a valid filter example: $filter=location eq
775// 'westus'.
776// top - the number of results to return per page for the list operation. Valid range for top parameter is 1 to
777// 100. If not specified, the default number of results to be returned is 20 items per page.
778func (client EventSubscriptionsClient) ListGlobalByResourceGroupForTopicType(ctx context.Context, resourceGroupName string, topicTypeName string, filter string, top *int32) (result EventSubscriptionsListResultPage, err error) {
779	if tracing.IsEnabled() {
780		ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListGlobalByResourceGroupForTopicType")
781		defer func() {
782			sc := -1
783			if result.eslr.Response.Response != nil {
784				sc = result.eslr.Response.Response.StatusCode
785			}
786			tracing.EndSpan(ctx, sc, err)
787		}()
788	}
789	result.fn = client.listGlobalByResourceGroupForTopicTypeNextResults
790	req, err := client.ListGlobalByResourceGroupForTopicTypePreparer(ctx, resourceGroupName, topicTypeName, filter, top)
791	if err != nil {
792		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalByResourceGroupForTopicType", nil, "Failure preparing request")
793		return
794	}
795
796	resp, err := client.ListGlobalByResourceGroupForTopicTypeSender(req)
797	if err != nil {
798		result.eslr.Response = autorest.Response{Response: resp}
799		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalByResourceGroupForTopicType", resp, "Failure sending request")
800		return
801	}
802
803	result.eslr, err = client.ListGlobalByResourceGroupForTopicTypeResponder(resp)
804	if err != nil {
805		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalByResourceGroupForTopicType", resp, "Failure responding to request")
806	}
807
808	return
809}
810
811// ListGlobalByResourceGroupForTopicTypePreparer prepares the ListGlobalByResourceGroupForTopicType request.
812func (client EventSubscriptionsClient) ListGlobalByResourceGroupForTopicTypePreparer(ctx context.Context, resourceGroupName string, topicTypeName string, filter string, top *int32) (*http.Request, error) {
813	pathParameters := map[string]interface{}{
814		"resourceGroupName": autorest.Encode("path", resourceGroupName),
815		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
816		"topicTypeName":     autorest.Encode("path", topicTypeName),
817	}
818
819	const APIVersion = "2020-01-01-preview"
820	queryParameters := map[string]interface{}{
821		"api-version": APIVersion,
822	}
823	if len(filter) > 0 {
824		queryParameters["$filter"] = autorest.Encode("query", filter)
825	}
826	if top != nil {
827		queryParameters["$top"] = autorest.Encode("query", *top)
828	}
829
830	preparer := autorest.CreatePreparer(
831		autorest.AsGet(),
832		autorest.WithBaseURL(client.BaseURI),
833		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topicTypes/{topicTypeName}/eventSubscriptions", pathParameters),
834		autorest.WithQueryParameters(queryParameters))
835	return preparer.Prepare((&http.Request{}).WithContext(ctx))
836}
837
838// ListGlobalByResourceGroupForTopicTypeSender sends the ListGlobalByResourceGroupForTopicType request. The method will close the
839// http.Response Body if it receives an error.
840func (client EventSubscriptionsClient) ListGlobalByResourceGroupForTopicTypeSender(req *http.Request) (*http.Response, error) {
841	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
842}
843
844// ListGlobalByResourceGroupForTopicTypeResponder handles the response to the ListGlobalByResourceGroupForTopicType request. The method always
845// closes the http.Response Body.
846func (client EventSubscriptionsClient) ListGlobalByResourceGroupForTopicTypeResponder(resp *http.Response) (result EventSubscriptionsListResult, err error) {
847	err = autorest.Respond(
848		resp,
849		client.ByInspecting(),
850		azure.WithErrorUnlessStatusCode(http.StatusOK),
851		autorest.ByUnmarshallingJSON(&result),
852		autorest.ByClosing())
853	result.Response = autorest.Response{Response: resp}
854	return
855}
856
857// listGlobalByResourceGroupForTopicTypeNextResults retrieves the next set of results, if any.
858func (client EventSubscriptionsClient) listGlobalByResourceGroupForTopicTypeNextResults(ctx context.Context, lastResults EventSubscriptionsListResult) (result EventSubscriptionsListResult, err error) {
859	req, err := lastResults.eventSubscriptionsListResultPreparer(ctx)
860	if err != nil {
861		return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listGlobalByResourceGroupForTopicTypeNextResults", nil, "Failure preparing next results request")
862	}
863	if req == nil {
864		return
865	}
866	resp, err := client.ListGlobalByResourceGroupForTopicTypeSender(req)
867	if err != nil {
868		result.Response = autorest.Response{Response: resp}
869		return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listGlobalByResourceGroupForTopicTypeNextResults", resp, "Failure sending next results request")
870	}
871	result, err = client.ListGlobalByResourceGroupForTopicTypeResponder(resp)
872	if err != nil {
873		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listGlobalByResourceGroupForTopicTypeNextResults", resp, "Failure responding to next results request")
874	}
875	return
876}
877
878// ListGlobalByResourceGroupForTopicTypeComplete enumerates all values, automatically crossing page boundaries as required.
879func (client EventSubscriptionsClient) ListGlobalByResourceGroupForTopicTypeComplete(ctx context.Context, resourceGroupName string, topicTypeName string, filter string, top *int32) (result EventSubscriptionsListResultIterator, err error) {
880	if tracing.IsEnabled() {
881		ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListGlobalByResourceGroupForTopicType")
882		defer func() {
883			sc := -1
884			if result.Response().Response.Response != nil {
885				sc = result.page.Response().Response.Response.StatusCode
886			}
887			tracing.EndSpan(ctx, sc, err)
888		}()
889	}
890	result.page, err = client.ListGlobalByResourceGroupForTopicType(ctx, resourceGroupName, topicTypeName, filter, top)
891	return
892}
893
894// ListGlobalBySubscription list all aggregated global event subscriptions under a specific Azure subscription
895// Parameters:
896// filter - the query used to filter the search results using OData syntax. Filtering is permitted on the
897// 'name' property only and with limited number of OData operations. These operations are: the 'contains'
898// function as well as the following logical operations: not, and, or, eq (for equal), and ne (for not equal).
899// No arithmetic operations are supported. The following is a valid filter example: $filter=contains(namE,
900// 'PATTERN') and name ne 'PATTERN-1'. The following is not a valid filter example: $filter=location eq
901// 'westus'.
902// top - the number of results to return per page for the list operation. Valid range for top parameter is 1 to
903// 100. If not specified, the default number of results to be returned is 20 items per page.
904func (client EventSubscriptionsClient) ListGlobalBySubscription(ctx context.Context, filter string, top *int32) (result EventSubscriptionsListResultPage, err error) {
905	if tracing.IsEnabled() {
906		ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListGlobalBySubscription")
907		defer func() {
908			sc := -1
909			if result.eslr.Response.Response != nil {
910				sc = result.eslr.Response.Response.StatusCode
911			}
912			tracing.EndSpan(ctx, sc, err)
913		}()
914	}
915	result.fn = client.listGlobalBySubscriptionNextResults
916	req, err := client.ListGlobalBySubscriptionPreparer(ctx, filter, top)
917	if err != nil {
918		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalBySubscription", nil, "Failure preparing request")
919		return
920	}
921
922	resp, err := client.ListGlobalBySubscriptionSender(req)
923	if err != nil {
924		result.eslr.Response = autorest.Response{Response: resp}
925		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalBySubscription", resp, "Failure sending request")
926		return
927	}
928
929	result.eslr, err = client.ListGlobalBySubscriptionResponder(resp)
930	if err != nil {
931		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalBySubscription", resp, "Failure responding to request")
932	}
933
934	return
935}
936
937// ListGlobalBySubscriptionPreparer prepares the ListGlobalBySubscription request.
938func (client EventSubscriptionsClient) ListGlobalBySubscriptionPreparer(ctx context.Context, filter string, top *int32) (*http.Request, error) {
939	pathParameters := map[string]interface{}{
940		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
941	}
942
943	const APIVersion = "2020-01-01-preview"
944	queryParameters := map[string]interface{}{
945		"api-version": APIVersion,
946	}
947	if len(filter) > 0 {
948		queryParameters["$filter"] = autorest.Encode("query", filter)
949	}
950	if top != nil {
951		queryParameters["$top"] = autorest.Encode("query", *top)
952	}
953
954	preparer := autorest.CreatePreparer(
955		autorest.AsGet(),
956		autorest.WithBaseURL(client.BaseURI),
957		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/eventSubscriptions", pathParameters),
958		autorest.WithQueryParameters(queryParameters))
959	return preparer.Prepare((&http.Request{}).WithContext(ctx))
960}
961
962// ListGlobalBySubscriptionSender sends the ListGlobalBySubscription request. The method will close the
963// http.Response Body if it receives an error.
964func (client EventSubscriptionsClient) ListGlobalBySubscriptionSender(req *http.Request) (*http.Response, error) {
965	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
966}
967
968// ListGlobalBySubscriptionResponder handles the response to the ListGlobalBySubscription request. The method always
969// closes the http.Response Body.
970func (client EventSubscriptionsClient) ListGlobalBySubscriptionResponder(resp *http.Response) (result EventSubscriptionsListResult, err error) {
971	err = autorest.Respond(
972		resp,
973		client.ByInspecting(),
974		azure.WithErrorUnlessStatusCode(http.StatusOK),
975		autorest.ByUnmarshallingJSON(&result),
976		autorest.ByClosing())
977	result.Response = autorest.Response{Response: resp}
978	return
979}
980
981// listGlobalBySubscriptionNextResults retrieves the next set of results, if any.
982func (client EventSubscriptionsClient) listGlobalBySubscriptionNextResults(ctx context.Context, lastResults EventSubscriptionsListResult) (result EventSubscriptionsListResult, err error) {
983	req, err := lastResults.eventSubscriptionsListResultPreparer(ctx)
984	if err != nil {
985		return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listGlobalBySubscriptionNextResults", nil, "Failure preparing next results request")
986	}
987	if req == nil {
988		return
989	}
990	resp, err := client.ListGlobalBySubscriptionSender(req)
991	if err != nil {
992		result.Response = autorest.Response{Response: resp}
993		return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listGlobalBySubscriptionNextResults", resp, "Failure sending next results request")
994	}
995	result, err = client.ListGlobalBySubscriptionResponder(resp)
996	if err != nil {
997		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listGlobalBySubscriptionNextResults", resp, "Failure responding to next results request")
998	}
999	return
1000}
1001
1002// ListGlobalBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required.
1003func (client EventSubscriptionsClient) ListGlobalBySubscriptionComplete(ctx context.Context, filter string, top *int32) (result EventSubscriptionsListResultIterator, err error) {
1004	if tracing.IsEnabled() {
1005		ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListGlobalBySubscription")
1006		defer func() {
1007			sc := -1
1008			if result.Response().Response.Response != nil {
1009				sc = result.page.Response().Response.Response.StatusCode
1010			}
1011			tracing.EndSpan(ctx, sc, err)
1012		}()
1013	}
1014	result.page, err = client.ListGlobalBySubscription(ctx, filter, top)
1015	return
1016}
1017
1018// ListGlobalBySubscriptionForTopicType list all global event subscriptions under an Azure subscription for a topic
1019// type.
1020// Parameters:
1021// topicTypeName - name of the topic type
1022// filter - the query used to filter the search results using OData syntax. Filtering is permitted on the
1023// 'name' property only and with limited number of OData operations. These operations are: the 'contains'
1024// function as well as the following logical operations: not, and, or, eq (for equal), and ne (for not equal).
1025// No arithmetic operations are supported. The following is a valid filter example: $filter=contains(namE,
1026// 'PATTERN') and name ne 'PATTERN-1'. The following is not a valid filter example: $filter=location eq
1027// 'westus'.
1028// top - the number of results to return per page for the list operation. Valid range for top parameter is 1 to
1029// 100. If not specified, the default number of results to be returned is 20 items per page.
1030func (client EventSubscriptionsClient) ListGlobalBySubscriptionForTopicType(ctx context.Context, topicTypeName string, filter string, top *int32) (result EventSubscriptionsListResultPage, err error) {
1031	if tracing.IsEnabled() {
1032		ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListGlobalBySubscriptionForTopicType")
1033		defer func() {
1034			sc := -1
1035			if result.eslr.Response.Response != nil {
1036				sc = result.eslr.Response.Response.StatusCode
1037			}
1038			tracing.EndSpan(ctx, sc, err)
1039		}()
1040	}
1041	result.fn = client.listGlobalBySubscriptionForTopicTypeNextResults
1042	req, err := client.ListGlobalBySubscriptionForTopicTypePreparer(ctx, topicTypeName, filter, top)
1043	if err != nil {
1044		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalBySubscriptionForTopicType", nil, "Failure preparing request")
1045		return
1046	}
1047
1048	resp, err := client.ListGlobalBySubscriptionForTopicTypeSender(req)
1049	if err != nil {
1050		result.eslr.Response = autorest.Response{Response: resp}
1051		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalBySubscriptionForTopicType", resp, "Failure sending request")
1052		return
1053	}
1054
1055	result.eslr, err = client.ListGlobalBySubscriptionForTopicTypeResponder(resp)
1056	if err != nil {
1057		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalBySubscriptionForTopicType", resp, "Failure responding to request")
1058	}
1059
1060	return
1061}
1062
1063// ListGlobalBySubscriptionForTopicTypePreparer prepares the ListGlobalBySubscriptionForTopicType request.
1064func (client EventSubscriptionsClient) ListGlobalBySubscriptionForTopicTypePreparer(ctx context.Context, topicTypeName string, filter string, top *int32) (*http.Request, error) {
1065	pathParameters := map[string]interface{}{
1066		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
1067		"topicTypeName":  autorest.Encode("path", topicTypeName),
1068	}
1069
1070	const APIVersion = "2020-01-01-preview"
1071	queryParameters := map[string]interface{}{
1072		"api-version": APIVersion,
1073	}
1074	if len(filter) > 0 {
1075		queryParameters["$filter"] = autorest.Encode("query", filter)
1076	}
1077	if top != nil {
1078		queryParameters["$top"] = autorest.Encode("query", *top)
1079	}
1080
1081	preparer := autorest.CreatePreparer(
1082		autorest.AsGet(),
1083		autorest.WithBaseURL(client.BaseURI),
1084		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/topicTypes/{topicTypeName}/eventSubscriptions", pathParameters),
1085		autorest.WithQueryParameters(queryParameters))
1086	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1087}
1088
1089// ListGlobalBySubscriptionForTopicTypeSender sends the ListGlobalBySubscriptionForTopicType request. The method will close the
1090// http.Response Body if it receives an error.
1091func (client EventSubscriptionsClient) ListGlobalBySubscriptionForTopicTypeSender(req *http.Request) (*http.Response, error) {
1092	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
1093}
1094
1095// ListGlobalBySubscriptionForTopicTypeResponder handles the response to the ListGlobalBySubscriptionForTopicType request. The method always
1096// closes the http.Response Body.
1097func (client EventSubscriptionsClient) ListGlobalBySubscriptionForTopicTypeResponder(resp *http.Response) (result EventSubscriptionsListResult, err error) {
1098	err = autorest.Respond(
1099		resp,
1100		client.ByInspecting(),
1101		azure.WithErrorUnlessStatusCode(http.StatusOK),
1102		autorest.ByUnmarshallingJSON(&result),
1103		autorest.ByClosing())
1104	result.Response = autorest.Response{Response: resp}
1105	return
1106}
1107
1108// listGlobalBySubscriptionForTopicTypeNextResults retrieves the next set of results, if any.
1109func (client EventSubscriptionsClient) listGlobalBySubscriptionForTopicTypeNextResults(ctx context.Context, lastResults EventSubscriptionsListResult) (result EventSubscriptionsListResult, err error) {
1110	req, err := lastResults.eventSubscriptionsListResultPreparer(ctx)
1111	if err != nil {
1112		return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listGlobalBySubscriptionForTopicTypeNextResults", nil, "Failure preparing next results request")
1113	}
1114	if req == nil {
1115		return
1116	}
1117	resp, err := client.ListGlobalBySubscriptionForTopicTypeSender(req)
1118	if err != nil {
1119		result.Response = autorest.Response{Response: resp}
1120		return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listGlobalBySubscriptionForTopicTypeNextResults", resp, "Failure sending next results request")
1121	}
1122	result, err = client.ListGlobalBySubscriptionForTopicTypeResponder(resp)
1123	if err != nil {
1124		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listGlobalBySubscriptionForTopicTypeNextResults", resp, "Failure responding to next results request")
1125	}
1126	return
1127}
1128
1129// ListGlobalBySubscriptionForTopicTypeComplete enumerates all values, automatically crossing page boundaries as required.
1130func (client EventSubscriptionsClient) ListGlobalBySubscriptionForTopicTypeComplete(ctx context.Context, topicTypeName string, filter string, top *int32) (result EventSubscriptionsListResultIterator, err error) {
1131	if tracing.IsEnabled() {
1132		ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListGlobalBySubscriptionForTopicType")
1133		defer func() {
1134			sc := -1
1135			if result.Response().Response.Response != nil {
1136				sc = result.page.Response().Response.Response.StatusCode
1137			}
1138			tracing.EndSpan(ctx, sc, err)
1139		}()
1140	}
1141	result.page, err = client.ListGlobalBySubscriptionForTopicType(ctx, topicTypeName, filter, top)
1142	return
1143}
1144
1145// ListRegionalByResourceGroup list all event subscriptions from the given location under a specific Azure subscription
1146// and resource group
1147// Parameters:
1148// resourceGroupName - the name of the resource group within the user's subscription.
1149// location - name of the location
1150// filter - the query used to filter the search results using OData syntax. Filtering is permitted on the
1151// 'name' property only and with limited number of OData operations. These operations are: the 'contains'
1152// function as well as the following logical operations: not, and, or, eq (for equal), and ne (for not equal).
1153// No arithmetic operations are supported. The following is a valid filter example: $filter=contains(namE,
1154// 'PATTERN') and name ne 'PATTERN-1'. The following is not a valid filter example: $filter=location eq
1155// 'westus'.
1156// top - the number of results to return per page for the list operation. Valid range for top parameter is 1 to
1157// 100. If not specified, the default number of results to be returned is 20 items per page.
1158func (client EventSubscriptionsClient) ListRegionalByResourceGroup(ctx context.Context, resourceGroupName string, location string, filter string, top *int32) (result EventSubscriptionsListResultPage, err error) {
1159	if tracing.IsEnabled() {
1160		ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListRegionalByResourceGroup")
1161		defer func() {
1162			sc := -1
1163			if result.eslr.Response.Response != nil {
1164				sc = result.eslr.Response.Response.StatusCode
1165			}
1166			tracing.EndSpan(ctx, sc, err)
1167		}()
1168	}
1169	result.fn = client.listRegionalByResourceGroupNextResults
1170	req, err := client.ListRegionalByResourceGroupPreparer(ctx, resourceGroupName, location, filter, top)
1171	if err != nil {
1172		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalByResourceGroup", nil, "Failure preparing request")
1173		return
1174	}
1175
1176	resp, err := client.ListRegionalByResourceGroupSender(req)
1177	if err != nil {
1178		result.eslr.Response = autorest.Response{Response: resp}
1179		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalByResourceGroup", resp, "Failure sending request")
1180		return
1181	}
1182
1183	result.eslr, err = client.ListRegionalByResourceGroupResponder(resp)
1184	if err != nil {
1185		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalByResourceGroup", resp, "Failure responding to request")
1186	}
1187
1188	return
1189}
1190
1191// ListRegionalByResourceGroupPreparer prepares the ListRegionalByResourceGroup request.
1192func (client EventSubscriptionsClient) ListRegionalByResourceGroupPreparer(ctx context.Context, resourceGroupName string, location string, filter string, top *int32) (*http.Request, error) {
1193	pathParameters := map[string]interface{}{
1194		"location":          autorest.Encode("path", location),
1195		"resourceGroupName": autorest.Encode("path", resourceGroupName),
1196		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
1197	}
1198
1199	const APIVersion = "2020-01-01-preview"
1200	queryParameters := map[string]interface{}{
1201		"api-version": APIVersion,
1202	}
1203	if len(filter) > 0 {
1204		queryParameters["$filter"] = autorest.Encode("query", filter)
1205	}
1206	if top != nil {
1207		queryParameters["$top"] = autorest.Encode("query", *top)
1208	}
1209
1210	preparer := autorest.CreatePreparer(
1211		autorest.AsGet(),
1212		autorest.WithBaseURL(client.BaseURI),
1213		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/locations/{location}/eventSubscriptions", pathParameters),
1214		autorest.WithQueryParameters(queryParameters))
1215	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1216}
1217
1218// ListRegionalByResourceGroupSender sends the ListRegionalByResourceGroup request. The method will close the
1219// http.Response Body if it receives an error.
1220func (client EventSubscriptionsClient) ListRegionalByResourceGroupSender(req *http.Request) (*http.Response, error) {
1221	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
1222}
1223
1224// ListRegionalByResourceGroupResponder handles the response to the ListRegionalByResourceGroup request. The method always
1225// closes the http.Response Body.
1226func (client EventSubscriptionsClient) ListRegionalByResourceGroupResponder(resp *http.Response) (result EventSubscriptionsListResult, err error) {
1227	err = autorest.Respond(
1228		resp,
1229		client.ByInspecting(),
1230		azure.WithErrorUnlessStatusCode(http.StatusOK),
1231		autorest.ByUnmarshallingJSON(&result),
1232		autorest.ByClosing())
1233	result.Response = autorest.Response{Response: resp}
1234	return
1235}
1236
1237// listRegionalByResourceGroupNextResults retrieves the next set of results, if any.
1238func (client EventSubscriptionsClient) listRegionalByResourceGroupNextResults(ctx context.Context, lastResults EventSubscriptionsListResult) (result EventSubscriptionsListResult, err error) {
1239	req, err := lastResults.eventSubscriptionsListResultPreparer(ctx)
1240	if err != nil {
1241		return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listRegionalByResourceGroupNextResults", nil, "Failure preparing next results request")
1242	}
1243	if req == nil {
1244		return
1245	}
1246	resp, err := client.ListRegionalByResourceGroupSender(req)
1247	if err != nil {
1248		result.Response = autorest.Response{Response: resp}
1249		return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listRegionalByResourceGroupNextResults", resp, "Failure sending next results request")
1250	}
1251	result, err = client.ListRegionalByResourceGroupResponder(resp)
1252	if err != nil {
1253		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listRegionalByResourceGroupNextResults", resp, "Failure responding to next results request")
1254	}
1255	return
1256}
1257
1258// ListRegionalByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required.
1259func (client EventSubscriptionsClient) ListRegionalByResourceGroupComplete(ctx context.Context, resourceGroupName string, location string, filter string, top *int32) (result EventSubscriptionsListResultIterator, err error) {
1260	if tracing.IsEnabled() {
1261		ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListRegionalByResourceGroup")
1262		defer func() {
1263			sc := -1
1264			if result.Response().Response.Response != nil {
1265				sc = result.page.Response().Response.Response.StatusCode
1266			}
1267			tracing.EndSpan(ctx, sc, err)
1268		}()
1269	}
1270	result.page, err = client.ListRegionalByResourceGroup(ctx, resourceGroupName, location, filter, top)
1271	return
1272}
1273
1274// ListRegionalByResourceGroupForTopicType list all event subscriptions from the given location under a specific Azure
1275// subscription and resource group and topic type
1276// Parameters:
1277// resourceGroupName - the name of the resource group within the user's subscription.
1278// location - name of the location
1279// topicTypeName - name of the topic type
1280// filter - the query used to filter the search results using OData syntax. Filtering is permitted on the
1281// 'name' property only and with limited number of OData operations. These operations are: the 'contains'
1282// function as well as the following logical operations: not, and, or, eq (for equal), and ne (for not equal).
1283// No arithmetic operations are supported. The following is a valid filter example: $filter=contains(namE,
1284// 'PATTERN') and name ne 'PATTERN-1'. The following is not a valid filter example: $filter=location eq
1285// 'westus'.
1286// top - the number of results to return per page for the list operation. Valid range for top parameter is 1 to
1287// 100. If not specified, the default number of results to be returned is 20 items per page.
1288func (client EventSubscriptionsClient) ListRegionalByResourceGroupForTopicType(ctx context.Context, resourceGroupName string, location string, topicTypeName string, filter string, top *int32) (result EventSubscriptionsListResultPage, err error) {
1289	if tracing.IsEnabled() {
1290		ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListRegionalByResourceGroupForTopicType")
1291		defer func() {
1292			sc := -1
1293			if result.eslr.Response.Response != nil {
1294				sc = result.eslr.Response.Response.StatusCode
1295			}
1296			tracing.EndSpan(ctx, sc, err)
1297		}()
1298	}
1299	result.fn = client.listRegionalByResourceGroupForTopicTypeNextResults
1300	req, err := client.ListRegionalByResourceGroupForTopicTypePreparer(ctx, resourceGroupName, location, topicTypeName, filter, top)
1301	if err != nil {
1302		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalByResourceGroupForTopicType", nil, "Failure preparing request")
1303		return
1304	}
1305
1306	resp, err := client.ListRegionalByResourceGroupForTopicTypeSender(req)
1307	if err != nil {
1308		result.eslr.Response = autorest.Response{Response: resp}
1309		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalByResourceGroupForTopicType", resp, "Failure sending request")
1310		return
1311	}
1312
1313	result.eslr, err = client.ListRegionalByResourceGroupForTopicTypeResponder(resp)
1314	if err != nil {
1315		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalByResourceGroupForTopicType", resp, "Failure responding to request")
1316	}
1317
1318	return
1319}
1320
1321// ListRegionalByResourceGroupForTopicTypePreparer prepares the ListRegionalByResourceGroupForTopicType request.
1322func (client EventSubscriptionsClient) ListRegionalByResourceGroupForTopicTypePreparer(ctx context.Context, resourceGroupName string, location string, topicTypeName string, filter string, top *int32) (*http.Request, error) {
1323	pathParameters := map[string]interface{}{
1324		"location":          autorest.Encode("path", location),
1325		"resourceGroupName": autorest.Encode("path", resourceGroupName),
1326		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
1327		"topicTypeName":     autorest.Encode("path", topicTypeName),
1328	}
1329
1330	const APIVersion = "2020-01-01-preview"
1331	queryParameters := map[string]interface{}{
1332		"api-version": APIVersion,
1333	}
1334	if len(filter) > 0 {
1335		queryParameters["$filter"] = autorest.Encode("query", filter)
1336	}
1337	if top != nil {
1338		queryParameters["$top"] = autorest.Encode("query", *top)
1339	}
1340
1341	preparer := autorest.CreatePreparer(
1342		autorest.AsGet(),
1343		autorest.WithBaseURL(client.BaseURI),
1344		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/locations/{location}/topicTypes/{topicTypeName}/eventSubscriptions", pathParameters),
1345		autorest.WithQueryParameters(queryParameters))
1346	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1347}
1348
1349// ListRegionalByResourceGroupForTopicTypeSender sends the ListRegionalByResourceGroupForTopicType request. The method will close the
1350// http.Response Body if it receives an error.
1351func (client EventSubscriptionsClient) ListRegionalByResourceGroupForTopicTypeSender(req *http.Request) (*http.Response, error) {
1352	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
1353}
1354
1355// ListRegionalByResourceGroupForTopicTypeResponder handles the response to the ListRegionalByResourceGroupForTopicType request. The method always
1356// closes the http.Response Body.
1357func (client EventSubscriptionsClient) ListRegionalByResourceGroupForTopicTypeResponder(resp *http.Response) (result EventSubscriptionsListResult, err error) {
1358	err = autorest.Respond(
1359		resp,
1360		client.ByInspecting(),
1361		azure.WithErrorUnlessStatusCode(http.StatusOK),
1362		autorest.ByUnmarshallingJSON(&result),
1363		autorest.ByClosing())
1364	result.Response = autorest.Response{Response: resp}
1365	return
1366}
1367
1368// listRegionalByResourceGroupForTopicTypeNextResults retrieves the next set of results, if any.
1369func (client EventSubscriptionsClient) listRegionalByResourceGroupForTopicTypeNextResults(ctx context.Context, lastResults EventSubscriptionsListResult) (result EventSubscriptionsListResult, err error) {
1370	req, err := lastResults.eventSubscriptionsListResultPreparer(ctx)
1371	if err != nil {
1372		return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listRegionalByResourceGroupForTopicTypeNextResults", nil, "Failure preparing next results request")
1373	}
1374	if req == nil {
1375		return
1376	}
1377	resp, err := client.ListRegionalByResourceGroupForTopicTypeSender(req)
1378	if err != nil {
1379		result.Response = autorest.Response{Response: resp}
1380		return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listRegionalByResourceGroupForTopicTypeNextResults", resp, "Failure sending next results request")
1381	}
1382	result, err = client.ListRegionalByResourceGroupForTopicTypeResponder(resp)
1383	if err != nil {
1384		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listRegionalByResourceGroupForTopicTypeNextResults", resp, "Failure responding to next results request")
1385	}
1386	return
1387}
1388
1389// ListRegionalByResourceGroupForTopicTypeComplete enumerates all values, automatically crossing page boundaries as required.
1390func (client EventSubscriptionsClient) ListRegionalByResourceGroupForTopicTypeComplete(ctx context.Context, resourceGroupName string, location string, topicTypeName string, filter string, top *int32) (result EventSubscriptionsListResultIterator, err error) {
1391	if tracing.IsEnabled() {
1392		ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListRegionalByResourceGroupForTopicType")
1393		defer func() {
1394			sc := -1
1395			if result.Response().Response.Response != nil {
1396				sc = result.page.Response().Response.Response.StatusCode
1397			}
1398			tracing.EndSpan(ctx, sc, err)
1399		}()
1400	}
1401	result.page, err = client.ListRegionalByResourceGroupForTopicType(ctx, resourceGroupName, location, topicTypeName, filter, top)
1402	return
1403}
1404
1405// ListRegionalBySubscription list all event subscriptions from the given location under a specific Azure subscription
1406// Parameters:
1407// location - name of the location
1408// filter - the query used to filter the search results using OData syntax. Filtering is permitted on the
1409// 'name' property only and with limited number of OData operations. These operations are: the 'contains'
1410// function as well as the following logical operations: not, and, or, eq (for equal), and ne (for not equal).
1411// No arithmetic operations are supported. The following is a valid filter example: $filter=contains(namE,
1412// 'PATTERN') and name ne 'PATTERN-1'. The following is not a valid filter example: $filter=location eq
1413// 'westus'.
1414// top - the number of results to return per page for the list operation. Valid range for top parameter is 1 to
1415// 100. If not specified, the default number of results to be returned is 20 items per page.
1416func (client EventSubscriptionsClient) ListRegionalBySubscription(ctx context.Context, location string, filter string, top *int32) (result EventSubscriptionsListResultPage, err error) {
1417	if tracing.IsEnabled() {
1418		ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListRegionalBySubscription")
1419		defer func() {
1420			sc := -1
1421			if result.eslr.Response.Response != nil {
1422				sc = result.eslr.Response.Response.StatusCode
1423			}
1424			tracing.EndSpan(ctx, sc, err)
1425		}()
1426	}
1427	result.fn = client.listRegionalBySubscriptionNextResults
1428	req, err := client.ListRegionalBySubscriptionPreparer(ctx, location, filter, top)
1429	if err != nil {
1430		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalBySubscription", nil, "Failure preparing request")
1431		return
1432	}
1433
1434	resp, err := client.ListRegionalBySubscriptionSender(req)
1435	if err != nil {
1436		result.eslr.Response = autorest.Response{Response: resp}
1437		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalBySubscription", resp, "Failure sending request")
1438		return
1439	}
1440
1441	result.eslr, err = client.ListRegionalBySubscriptionResponder(resp)
1442	if err != nil {
1443		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalBySubscription", resp, "Failure responding to request")
1444	}
1445
1446	return
1447}
1448
1449// ListRegionalBySubscriptionPreparer prepares the ListRegionalBySubscription request.
1450func (client EventSubscriptionsClient) ListRegionalBySubscriptionPreparer(ctx context.Context, location string, filter string, top *int32) (*http.Request, error) {
1451	pathParameters := map[string]interface{}{
1452		"location":       autorest.Encode("path", location),
1453		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
1454	}
1455
1456	const APIVersion = "2020-01-01-preview"
1457	queryParameters := map[string]interface{}{
1458		"api-version": APIVersion,
1459	}
1460	if len(filter) > 0 {
1461		queryParameters["$filter"] = autorest.Encode("query", filter)
1462	}
1463	if top != nil {
1464		queryParameters["$top"] = autorest.Encode("query", *top)
1465	}
1466
1467	preparer := autorest.CreatePreparer(
1468		autorest.AsGet(),
1469		autorest.WithBaseURL(client.BaseURI),
1470		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/locations/{location}/eventSubscriptions", pathParameters),
1471		autorest.WithQueryParameters(queryParameters))
1472	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1473}
1474
1475// ListRegionalBySubscriptionSender sends the ListRegionalBySubscription request. The method will close the
1476// http.Response Body if it receives an error.
1477func (client EventSubscriptionsClient) ListRegionalBySubscriptionSender(req *http.Request) (*http.Response, error) {
1478	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
1479}
1480
1481// ListRegionalBySubscriptionResponder handles the response to the ListRegionalBySubscription request. The method always
1482// closes the http.Response Body.
1483func (client EventSubscriptionsClient) ListRegionalBySubscriptionResponder(resp *http.Response) (result EventSubscriptionsListResult, err error) {
1484	err = autorest.Respond(
1485		resp,
1486		client.ByInspecting(),
1487		azure.WithErrorUnlessStatusCode(http.StatusOK),
1488		autorest.ByUnmarshallingJSON(&result),
1489		autorest.ByClosing())
1490	result.Response = autorest.Response{Response: resp}
1491	return
1492}
1493
1494// listRegionalBySubscriptionNextResults retrieves the next set of results, if any.
1495func (client EventSubscriptionsClient) listRegionalBySubscriptionNextResults(ctx context.Context, lastResults EventSubscriptionsListResult) (result EventSubscriptionsListResult, err error) {
1496	req, err := lastResults.eventSubscriptionsListResultPreparer(ctx)
1497	if err != nil {
1498		return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listRegionalBySubscriptionNextResults", nil, "Failure preparing next results request")
1499	}
1500	if req == nil {
1501		return
1502	}
1503	resp, err := client.ListRegionalBySubscriptionSender(req)
1504	if err != nil {
1505		result.Response = autorest.Response{Response: resp}
1506		return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listRegionalBySubscriptionNextResults", resp, "Failure sending next results request")
1507	}
1508	result, err = client.ListRegionalBySubscriptionResponder(resp)
1509	if err != nil {
1510		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listRegionalBySubscriptionNextResults", resp, "Failure responding to next results request")
1511	}
1512	return
1513}
1514
1515// ListRegionalBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required.
1516func (client EventSubscriptionsClient) ListRegionalBySubscriptionComplete(ctx context.Context, location string, filter string, top *int32) (result EventSubscriptionsListResultIterator, err error) {
1517	if tracing.IsEnabled() {
1518		ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListRegionalBySubscription")
1519		defer func() {
1520			sc := -1
1521			if result.Response().Response.Response != nil {
1522				sc = result.page.Response().Response.Response.StatusCode
1523			}
1524			tracing.EndSpan(ctx, sc, err)
1525		}()
1526	}
1527	result.page, err = client.ListRegionalBySubscription(ctx, location, filter, top)
1528	return
1529}
1530
1531// ListRegionalBySubscriptionForTopicType list all event subscriptions from the given location under a specific Azure
1532// subscription and topic type.
1533// Parameters:
1534// location - name of the location
1535// topicTypeName - name of the topic type
1536// filter - the query used to filter the search results using OData syntax. Filtering is permitted on the
1537// 'name' property only and with limited number of OData operations. These operations are: the 'contains'
1538// function as well as the following logical operations: not, and, or, eq (for equal), and ne (for not equal).
1539// No arithmetic operations are supported. The following is a valid filter example: $filter=contains(namE,
1540// 'PATTERN') and name ne 'PATTERN-1'. The following is not a valid filter example: $filter=location eq
1541// 'westus'.
1542// top - the number of results to return per page for the list operation. Valid range for top parameter is 1 to
1543// 100. If not specified, the default number of results to be returned is 20 items per page.
1544func (client EventSubscriptionsClient) ListRegionalBySubscriptionForTopicType(ctx context.Context, location string, topicTypeName string, filter string, top *int32) (result EventSubscriptionsListResultPage, err error) {
1545	if tracing.IsEnabled() {
1546		ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListRegionalBySubscriptionForTopicType")
1547		defer func() {
1548			sc := -1
1549			if result.eslr.Response.Response != nil {
1550				sc = result.eslr.Response.Response.StatusCode
1551			}
1552			tracing.EndSpan(ctx, sc, err)
1553		}()
1554	}
1555	result.fn = client.listRegionalBySubscriptionForTopicTypeNextResults
1556	req, err := client.ListRegionalBySubscriptionForTopicTypePreparer(ctx, location, topicTypeName, filter, top)
1557	if err != nil {
1558		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalBySubscriptionForTopicType", nil, "Failure preparing request")
1559		return
1560	}
1561
1562	resp, err := client.ListRegionalBySubscriptionForTopicTypeSender(req)
1563	if err != nil {
1564		result.eslr.Response = autorest.Response{Response: resp}
1565		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalBySubscriptionForTopicType", resp, "Failure sending request")
1566		return
1567	}
1568
1569	result.eslr, err = client.ListRegionalBySubscriptionForTopicTypeResponder(resp)
1570	if err != nil {
1571		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalBySubscriptionForTopicType", resp, "Failure responding to request")
1572	}
1573
1574	return
1575}
1576
1577// ListRegionalBySubscriptionForTopicTypePreparer prepares the ListRegionalBySubscriptionForTopicType request.
1578func (client EventSubscriptionsClient) ListRegionalBySubscriptionForTopicTypePreparer(ctx context.Context, location string, topicTypeName string, filter string, top *int32) (*http.Request, error) {
1579	pathParameters := map[string]interface{}{
1580		"location":       autorest.Encode("path", location),
1581		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
1582		"topicTypeName":  autorest.Encode("path", topicTypeName),
1583	}
1584
1585	const APIVersion = "2020-01-01-preview"
1586	queryParameters := map[string]interface{}{
1587		"api-version": APIVersion,
1588	}
1589	if len(filter) > 0 {
1590		queryParameters["$filter"] = autorest.Encode("query", filter)
1591	}
1592	if top != nil {
1593		queryParameters["$top"] = autorest.Encode("query", *top)
1594	}
1595
1596	preparer := autorest.CreatePreparer(
1597		autorest.AsGet(),
1598		autorest.WithBaseURL(client.BaseURI),
1599		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/locations/{location}/topicTypes/{topicTypeName}/eventSubscriptions", pathParameters),
1600		autorest.WithQueryParameters(queryParameters))
1601	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1602}
1603
1604// ListRegionalBySubscriptionForTopicTypeSender sends the ListRegionalBySubscriptionForTopicType request. The method will close the
1605// http.Response Body if it receives an error.
1606func (client EventSubscriptionsClient) ListRegionalBySubscriptionForTopicTypeSender(req *http.Request) (*http.Response, error) {
1607	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
1608}
1609
1610// ListRegionalBySubscriptionForTopicTypeResponder handles the response to the ListRegionalBySubscriptionForTopicType request. The method always
1611// closes the http.Response Body.
1612func (client EventSubscriptionsClient) ListRegionalBySubscriptionForTopicTypeResponder(resp *http.Response) (result EventSubscriptionsListResult, err error) {
1613	err = autorest.Respond(
1614		resp,
1615		client.ByInspecting(),
1616		azure.WithErrorUnlessStatusCode(http.StatusOK),
1617		autorest.ByUnmarshallingJSON(&result),
1618		autorest.ByClosing())
1619	result.Response = autorest.Response{Response: resp}
1620	return
1621}
1622
1623// listRegionalBySubscriptionForTopicTypeNextResults retrieves the next set of results, if any.
1624func (client EventSubscriptionsClient) listRegionalBySubscriptionForTopicTypeNextResults(ctx context.Context, lastResults EventSubscriptionsListResult) (result EventSubscriptionsListResult, err error) {
1625	req, err := lastResults.eventSubscriptionsListResultPreparer(ctx)
1626	if err != nil {
1627		return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listRegionalBySubscriptionForTopicTypeNextResults", nil, "Failure preparing next results request")
1628	}
1629	if req == nil {
1630		return
1631	}
1632	resp, err := client.ListRegionalBySubscriptionForTopicTypeSender(req)
1633	if err != nil {
1634		result.Response = autorest.Response{Response: resp}
1635		return result, autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listRegionalBySubscriptionForTopicTypeNextResults", resp, "Failure sending next results request")
1636	}
1637	result, err = client.ListRegionalBySubscriptionForTopicTypeResponder(resp)
1638	if err != nil {
1639		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "listRegionalBySubscriptionForTopicTypeNextResults", resp, "Failure responding to next results request")
1640	}
1641	return
1642}
1643
1644// ListRegionalBySubscriptionForTopicTypeComplete enumerates all values, automatically crossing page boundaries as required.
1645func (client EventSubscriptionsClient) ListRegionalBySubscriptionForTopicTypeComplete(ctx context.Context, location string, topicTypeName string, filter string, top *int32) (result EventSubscriptionsListResultIterator, err error) {
1646	if tracing.IsEnabled() {
1647		ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListRegionalBySubscriptionForTopicType")
1648		defer func() {
1649			sc := -1
1650			if result.Response().Response.Response != nil {
1651				sc = result.page.Response().Response.Response.StatusCode
1652			}
1653			tracing.EndSpan(ctx, sc, err)
1654		}()
1655	}
1656	result.page, err = client.ListRegionalBySubscriptionForTopicType(ctx, location, topicTypeName, filter, top)
1657	return
1658}
1659
1660// Update asynchronously updates an existing event subscription.
1661// Parameters:
1662// scope - the scope of existing event subscription. The scope can be a subscription, or a resource group, or a
1663// top level resource belonging to a resource provider namespace, or an EventGrid topic. For example, use
1664// '/subscriptions/{subscriptionId}/' for a subscription,
1665// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for a resource group, and
1666// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}'
1667// for a resource, and
1668// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}'
1669// for an EventGrid topic.
1670// eventSubscriptionName - name of the event subscription to be updated
1671// eventSubscriptionUpdateParameters - updated event subscription information
1672func (client EventSubscriptionsClient) Update(ctx context.Context, scope string, eventSubscriptionName string, eventSubscriptionUpdateParameters EventSubscriptionUpdateParameters) (result EventSubscriptionsUpdateFuture, err error) {
1673	if tracing.IsEnabled() {
1674		ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.Update")
1675		defer func() {
1676			sc := -1
1677			if result.Response() != nil {
1678				sc = result.Response().StatusCode
1679			}
1680			tracing.EndSpan(ctx, sc, err)
1681		}()
1682	}
1683	req, err := client.UpdatePreparer(ctx, scope, eventSubscriptionName, eventSubscriptionUpdateParameters)
1684	if err != nil {
1685		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "Update", nil, "Failure preparing request")
1686		return
1687	}
1688
1689	result, err = client.UpdateSender(req)
1690	if err != nil {
1691		err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "Update", result.Response(), "Failure sending request")
1692		return
1693	}
1694
1695	return
1696}
1697
1698// UpdatePreparer prepares the Update request.
1699func (client EventSubscriptionsClient) UpdatePreparer(ctx context.Context, scope string, eventSubscriptionName string, eventSubscriptionUpdateParameters EventSubscriptionUpdateParameters) (*http.Request, error) {
1700	pathParameters := map[string]interface{}{
1701		"eventSubscriptionName": autorest.Encode("path", eventSubscriptionName),
1702		"scope":                 scope,
1703	}
1704
1705	const APIVersion = "2020-01-01-preview"
1706	queryParameters := map[string]interface{}{
1707		"api-version": APIVersion,
1708	}
1709
1710	preparer := autorest.CreatePreparer(
1711		autorest.AsContentType("application/json; charset=utf-8"),
1712		autorest.AsPatch(),
1713		autorest.WithBaseURL(client.BaseURI),
1714		autorest.WithPathParameters("/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}", pathParameters),
1715		autorest.WithJSON(eventSubscriptionUpdateParameters),
1716		autorest.WithQueryParameters(queryParameters))
1717	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1718}
1719
1720// UpdateSender sends the Update request. The method will close the
1721// http.Response Body if it receives an error.
1722func (client EventSubscriptionsClient) UpdateSender(req *http.Request) (future EventSubscriptionsUpdateFuture, err error) {
1723	var resp *http.Response
1724	resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
1725	if err != nil {
1726		return
1727	}
1728	future.Future, err = azure.NewFutureFromResponse(resp)
1729	return
1730}
1731
1732// UpdateResponder handles the response to the Update request. The method always
1733// closes the http.Response Body.
1734func (client EventSubscriptionsClient) UpdateResponder(resp *http.Response) (result EventSubscription, err error) {
1735	err = autorest.Respond(
1736		resp,
1737		client.ByInspecting(),
1738		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
1739		autorest.ByUnmarshallingJSON(&result),
1740		autorest.ByClosing())
1741	result.Response = autorest.Response{Response: resp}
1742	return
1743}
1744