1package security
2
3// Copyright (c) Microsoft Corporation. All rights reserved.
4// Licensed under the MIT License. See License.txt in the project root for license information.
5//
6// Code generated by Microsoft (R) AutoRest Code Generator.
7// Changes may cause incorrect behavior and will be lost if the code is regenerated.
8
9import (
10	"context"
11	"github.com/Azure/go-autorest/autorest"
12	"github.com/Azure/go-autorest/autorest/azure"
13	"github.com/Azure/go-autorest/autorest/validation"
14	"github.com/Azure/go-autorest/tracing"
15	"net/http"
16)
17
18// AlertsClient is the API spec for Microsoft.Security (Azure Security Center) resource provider
19type AlertsClient struct {
20	BaseClient
21}
22
23// NewAlertsClient creates an instance of the AlertsClient client.
24func NewAlertsClient(subscriptionID string, ascLocation string) AlertsClient {
25	return NewAlertsClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation)
26}
27
28// NewAlertsClientWithBaseURI creates an instance of the AlertsClient client using a custom endpoint.  Use this when
29// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
30func NewAlertsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) AlertsClient {
31	return AlertsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)}
32}
33
34// GetResourceGroupLevelAlerts get an alert that is associated a resource group or a resource in a resource group
35// Parameters:
36// alertName - name of the alert object
37// resourceGroupName - the name of the resource group within the user's subscription. The name is case
38// insensitive.
39func (client AlertsClient) GetResourceGroupLevelAlerts(ctx context.Context, alertName string, resourceGroupName string) (result Alert, err error) {
40	if tracing.IsEnabled() {
41		ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.GetResourceGroupLevelAlerts")
42		defer func() {
43			sc := -1
44			if result.Response.Response != nil {
45				sc = result.Response.Response.StatusCode
46			}
47			tracing.EndSpan(ctx, sc, err)
48		}()
49	}
50	if err := validation.Validate([]validation.Validation{
51		{TargetValue: client.SubscriptionID,
52			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}},
53		{TargetValue: resourceGroupName,
54			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
55				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
56				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
57		return result, validation.NewError("security.AlertsClient", "GetResourceGroupLevelAlerts", err.Error())
58	}
59
60	req, err := client.GetResourceGroupLevelAlertsPreparer(ctx, alertName, resourceGroupName)
61	if err != nil {
62		err = autorest.NewErrorWithError(err, "security.AlertsClient", "GetResourceGroupLevelAlerts", nil, "Failure preparing request")
63		return
64	}
65
66	resp, err := client.GetResourceGroupLevelAlertsSender(req)
67	if err != nil {
68		result.Response = autorest.Response{Response: resp}
69		err = autorest.NewErrorWithError(err, "security.AlertsClient", "GetResourceGroupLevelAlerts", resp, "Failure sending request")
70		return
71	}
72
73	result, err = client.GetResourceGroupLevelAlertsResponder(resp)
74	if err != nil {
75		err = autorest.NewErrorWithError(err, "security.AlertsClient", "GetResourceGroupLevelAlerts", resp, "Failure responding to request")
76		return
77	}
78
79	return
80}
81
82// GetResourceGroupLevelAlertsPreparer prepares the GetResourceGroupLevelAlerts request.
83func (client AlertsClient) GetResourceGroupLevelAlertsPreparer(ctx context.Context, alertName string, resourceGroupName string) (*http.Request, error) {
84	pathParameters := map[string]interface{}{
85		"alertName":         autorest.Encode("path", alertName),
86		"ascLocation":       autorest.Encode("path", client.AscLocation),
87		"resourceGroupName": autorest.Encode("path", resourceGroupName),
88		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
89	}
90
91	const APIVersion = "2015-06-01-preview"
92	queryParameters := map[string]interface{}{
93		"api-version": APIVersion,
94	}
95
96	preparer := autorest.CreatePreparer(
97		autorest.AsGet(),
98		autorest.WithBaseURL(client.BaseURI),
99		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}", pathParameters),
100		autorest.WithQueryParameters(queryParameters))
101	return preparer.Prepare((&http.Request{}).WithContext(ctx))
102}
103
104// GetResourceGroupLevelAlertsSender sends the GetResourceGroupLevelAlerts request. The method will close the
105// http.Response Body if it receives an error.
106func (client AlertsClient) GetResourceGroupLevelAlertsSender(req *http.Request) (*http.Response, error) {
107	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
108}
109
110// GetResourceGroupLevelAlertsResponder handles the response to the GetResourceGroupLevelAlerts request. The method always
111// closes the http.Response Body.
112func (client AlertsClient) GetResourceGroupLevelAlertsResponder(resp *http.Response) (result Alert, err error) {
113	err = autorest.Respond(
114		resp,
115		azure.WithErrorUnlessStatusCode(http.StatusOK),
116		autorest.ByUnmarshallingJSON(&result),
117		autorest.ByClosing())
118	result.Response = autorest.Response{Response: resp}
119	return
120}
121
122// GetSubscriptionLevelAlert get an alert that is associated with a subscription
123// Parameters:
124// alertName - name of the alert object
125func (client AlertsClient) GetSubscriptionLevelAlert(ctx context.Context, alertName string) (result Alert, err error) {
126	if tracing.IsEnabled() {
127		ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.GetSubscriptionLevelAlert")
128		defer func() {
129			sc := -1
130			if result.Response.Response != nil {
131				sc = result.Response.Response.StatusCode
132			}
133			tracing.EndSpan(ctx, sc, err)
134		}()
135	}
136	if err := validation.Validate([]validation.Validation{
137		{TargetValue: client.SubscriptionID,
138			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil {
139		return result, validation.NewError("security.AlertsClient", "GetSubscriptionLevelAlert", err.Error())
140	}
141
142	req, err := client.GetSubscriptionLevelAlertPreparer(ctx, alertName)
143	if err != nil {
144		err = autorest.NewErrorWithError(err, "security.AlertsClient", "GetSubscriptionLevelAlert", nil, "Failure preparing request")
145		return
146	}
147
148	resp, err := client.GetSubscriptionLevelAlertSender(req)
149	if err != nil {
150		result.Response = autorest.Response{Response: resp}
151		err = autorest.NewErrorWithError(err, "security.AlertsClient", "GetSubscriptionLevelAlert", resp, "Failure sending request")
152		return
153	}
154
155	result, err = client.GetSubscriptionLevelAlertResponder(resp)
156	if err != nil {
157		err = autorest.NewErrorWithError(err, "security.AlertsClient", "GetSubscriptionLevelAlert", resp, "Failure responding to request")
158		return
159	}
160
161	return
162}
163
164// GetSubscriptionLevelAlertPreparer prepares the GetSubscriptionLevelAlert request.
165func (client AlertsClient) GetSubscriptionLevelAlertPreparer(ctx context.Context, alertName string) (*http.Request, error) {
166	pathParameters := map[string]interface{}{
167		"alertName":      autorest.Encode("path", alertName),
168		"ascLocation":    autorest.Encode("path", client.AscLocation),
169		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
170	}
171
172	const APIVersion = "2015-06-01-preview"
173	queryParameters := map[string]interface{}{
174		"api-version": APIVersion,
175	}
176
177	preparer := autorest.CreatePreparer(
178		autorest.AsGet(),
179		autorest.WithBaseURL(client.BaseURI),
180		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}", pathParameters),
181		autorest.WithQueryParameters(queryParameters))
182	return preparer.Prepare((&http.Request{}).WithContext(ctx))
183}
184
185// GetSubscriptionLevelAlertSender sends the GetSubscriptionLevelAlert request. The method will close the
186// http.Response Body if it receives an error.
187func (client AlertsClient) GetSubscriptionLevelAlertSender(req *http.Request) (*http.Response, error) {
188	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
189}
190
191// GetSubscriptionLevelAlertResponder handles the response to the GetSubscriptionLevelAlert request. The method always
192// closes the http.Response Body.
193func (client AlertsClient) GetSubscriptionLevelAlertResponder(resp *http.Response) (result Alert, err error) {
194	err = autorest.Respond(
195		resp,
196		azure.WithErrorUnlessStatusCode(http.StatusOK),
197		autorest.ByUnmarshallingJSON(&result),
198		autorest.ByClosing())
199	result.Response = autorest.Response{Response: resp}
200	return
201}
202
203// List list all the alerts that are associated with the subscription
204// Parameters:
205// filter - oData filter. Optional.
206// selectParameter - oData select. Optional.
207// expand - oData expand. Optional.
208func (client AlertsClient) List(ctx context.Context, filter string, selectParameter string, expand string) (result AlertListPage, err error) {
209	if tracing.IsEnabled() {
210		ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.List")
211		defer func() {
212			sc := -1
213			if result.al.Response.Response != nil {
214				sc = result.al.Response.Response.StatusCode
215			}
216			tracing.EndSpan(ctx, sc, err)
217		}()
218	}
219	if err := validation.Validate([]validation.Validation{
220		{TargetValue: client.SubscriptionID,
221			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil {
222		return result, validation.NewError("security.AlertsClient", "List", err.Error())
223	}
224
225	result.fn = client.listNextResults
226	req, err := client.ListPreparer(ctx, filter, selectParameter, expand)
227	if err != nil {
228		err = autorest.NewErrorWithError(err, "security.AlertsClient", "List", nil, "Failure preparing request")
229		return
230	}
231
232	resp, err := client.ListSender(req)
233	if err != nil {
234		result.al.Response = autorest.Response{Response: resp}
235		err = autorest.NewErrorWithError(err, "security.AlertsClient", "List", resp, "Failure sending request")
236		return
237	}
238
239	result.al, err = client.ListResponder(resp)
240	if err != nil {
241		err = autorest.NewErrorWithError(err, "security.AlertsClient", "List", resp, "Failure responding to request")
242		return
243	}
244	if result.al.hasNextLink() && result.al.IsEmpty() {
245		err = result.NextWithContext(ctx)
246		return
247	}
248
249	return
250}
251
252// ListPreparer prepares the List request.
253func (client AlertsClient) ListPreparer(ctx context.Context, filter string, selectParameter string, expand string) (*http.Request, error) {
254	pathParameters := map[string]interface{}{
255		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
256	}
257
258	const APIVersion = "2015-06-01-preview"
259	queryParameters := map[string]interface{}{
260		"api-version": APIVersion,
261	}
262	if len(filter) > 0 {
263		queryParameters["$filter"] = autorest.Encode("query", filter)
264	}
265	if len(selectParameter) > 0 {
266		queryParameters["$select"] = autorest.Encode("query", selectParameter)
267	}
268	if len(expand) > 0 {
269		queryParameters["$expand"] = autorest.Encode("query", expand)
270	}
271
272	preparer := autorest.CreatePreparer(
273		autorest.AsGet(),
274		autorest.WithBaseURL(client.BaseURI),
275		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/alerts", pathParameters),
276		autorest.WithQueryParameters(queryParameters))
277	return preparer.Prepare((&http.Request{}).WithContext(ctx))
278}
279
280// ListSender sends the List request. The method will close the
281// http.Response Body if it receives an error.
282func (client AlertsClient) ListSender(req *http.Request) (*http.Response, error) {
283	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
284}
285
286// ListResponder handles the response to the List request. The method always
287// closes the http.Response Body.
288func (client AlertsClient) ListResponder(resp *http.Response) (result AlertList, err error) {
289	err = autorest.Respond(
290		resp,
291		azure.WithErrorUnlessStatusCode(http.StatusOK),
292		autorest.ByUnmarshallingJSON(&result),
293		autorest.ByClosing())
294	result.Response = autorest.Response{Response: resp}
295	return
296}
297
298// listNextResults retrieves the next set of results, if any.
299func (client AlertsClient) listNextResults(ctx context.Context, lastResults AlertList) (result AlertList, err error) {
300	req, err := lastResults.alertListPreparer(ctx)
301	if err != nil {
302		return result, autorest.NewErrorWithError(err, "security.AlertsClient", "listNextResults", nil, "Failure preparing next results request")
303	}
304	if req == nil {
305		return
306	}
307	resp, err := client.ListSender(req)
308	if err != nil {
309		result.Response = autorest.Response{Response: resp}
310		return result, autorest.NewErrorWithError(err, "security.AlertsClient", "listNextResults", resp, "Failure sending next results request")
311	}
312	result, err = client.ListResponder(resp)
313	if err != nil {
314		err = autorest.NewErrorWithError(err, "security.AlertsClient", "listNextResults", resp, "Failure responding to next results request")
315	}
316	return
317}
318
319// ListComplete enumerates all values, automatically crossing page boundaries as required.
320func (client AlertsClient) ListComplete(ctx context.Context, filter string, selectParameter string, expand string) (result AlertListIterator, err error) {
321	if tracing.IsEnabled() {
322		ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.List")
323		defer func() {
324			sc := -1
325			if result.Response().Response.Response != nil {
326				sc = result.page.Response().Response.Response.StatusCode
327			}
328			tracing.EndSpan(ctx, sc, err)
329		}()
330	}
331	result.page, err = client.List(ctx, filter, selectParameter, expand)
332	return
333}
334
335// ListByResourceGroup list all the alerts that are associated with the resource group
336// Parameters:
337// resourceGroupName - the name of the resource group within the user's subscription. The name is case
338// insensitive.
339// filter - oData filter. Optional.
340// selectParameter - oData select. Optional.
341// expand - oData expand. Optional.
342func (client AlertsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, filter string, selectParameter string, expand string) (result AlertListPage, err error) {
343	if tracing.IsEnabled() {
344		ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.ListByResourceGroup")
345		defer func() {
346			sc := -1
347			if result.al.Response.Response != nil {
348				sc = result.al.Response.Response.StatusCode
349			}
350			tracing.EndSpan(ctx, sc, err)
351		}()
352	}
353	if err := validation.Validate([]validation.Validation{
354		{TargetValue: client.SubscriptionID,
355			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}},
356		{TargetValue: resourceGroupName,
357			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
358				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
359				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
360		return result, validation.NewError("security.AlertsClient", "ListByResourceGroup", err.Error())
361	}
362
363	result.fn = client.listByResourceGroupNextResults
364	req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName, filter, selectParameter, expand)
365	if err != nil {
366		err = autorest.NewErrorWithError(err, "security.AlertsClient", "ListByResourceGroup", nil, "Failure preparing request")
367		return
368	}
369
370	resp, err := client.ListByResourceGroupSender(req)
371	if err != nil {
372		result.al.Response = autorest.Response{Response: resp}
373		err = autorest.NewErrorWithError(err, "security.AlertsClient", "ListByResourceGroup", resp, "Failure sending request")
374		return
375	}
376
377	result.al, err = client.ListByResourceGroupResponder(resp)
378	if err != nil {
379		err = autorest.NewErrorWithError(err, "security.AlertsClient", "ListByResourceGroup", resp, "Failure responding to request")
380		return
381	}
382	if result.al.hasNextLink() && result.al.IsEmpty() {
383		err = result.NextWithContext(ctx)
384		return
385	}
386
387	return
388}
389
390// ListByResourceGroupPreparer prepares the ListByResourceGroup request.
391func (client AlertsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string, filter string, selectParameter string, expand string) (*http.Request, error) {
392	pathParameters := map[string]interface{}{
393		"resourceGroupName": autorest.Encode("path", resourceGroupName),
394		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
395	}
396
397	const APIVersion = "2015-06-01-preview"
398	queryParameters := map[string]interface{}{
399		"api-version": APIVersion,
400	}
401	if len(filter) > 0 {
402		queryParameters["$filter"] = autorest.Encode("query", filter)
403	}
404	if len(selectParameter) > 0 {
405		queryParameters["$select"] = autorest.Encode("query", selectParameter)
406	}
407	if len(expand) > 0 {
408		queryParameters["$expand"] = autorest.Encode("query", expand)
409	}
410
411	preparer := autorest.CreatePreparer(
412		autorest.AsGet(),
413		autorest.WithBaseURL(client.BaseURI),
414		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/alerts", pathParameters),
415		autorest.WithQueryParameters(queryParameters))
416	return preparer.Prepare((&http.Request{}).WithContext(ctx))
417}
418
419// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the
420// http.Response Body if it receives an error.
421func (client AlertsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
422	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
423}
424
425// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always
426// closes the http.Response Body.
427func (client AlertsClient) ListByResourceGroupResponder(resp *http.Response) (result AlertList, err error) {
428	err = autorest.Respond(
429		resp,
430		azure.WithErrorUnlessStatusCode(http.StatusOK),
431		autorest.ByUnmarshallingJSON(&result),
432		autorest.ByClosing())
433	result.Response = autorest.Response{Response: resp}
434	return
435}
436
437// listByResourceGroupNextResults retrieves the next set of results, if any.
438func (client AlertsClient) listByResourceGroupNextResults(ctx context.Context, lastResults AlertList) (result AlertList, err error) {
439	req, err := lastResults.alertListPreparer(ctx)
440	if err != nil {
441		return result, autorest.NewErrorWithError(err, "security.AlertsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
442	}
443	if req == nil {
444		return
445	}
446	resp, err := client.ListByResourceGroupSender(req)
447	if err != nil {
448		result.Response = autorest.Response{Response: resp}
449		return result, autorest.NewErrorWithError(err, "security.AlertsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request")
450	}
451	result, err = client.ListByResourceGroupResponder(resp)
452	if err != nil {
453		err = autorest.NewErrorWithError(err, "security.AlertsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
454	}
455	return
456}
457
458// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required.
459func (client AlertsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string, filter string, selectParameter string, expand string) (result AlertListIterator, err error) {
460	if tracing.IsEnabled() {
461		ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.ListByResourceGroup")
462		defer func() {
463			sc := -1
464			if result.Response().Response.Response != nil {
465				sc = result.page.Response().Response.Response.StatusCode
466			}
467			tracing.EndSpan(ctx, sc, err)
468		}()
469	}
470	result.page, err = client.ListByResourceGroup(ctx, resourceGroupName, filter, selectParameter, expand)
471	return
472}
473
474// ListResourceGroupLevelAlertsByRegion list all the alerts that are associated with the resource group that are stored
475// in a specific location
476// Parameters:
477// resourceGroupName - the name of the resource group within the user's subscription. The name is case
478// insensitive.
479// filter - oData filter. Optional.
480// selectParameter - oData select. Optional.
481// expand - oData expand. Optional.
482func (client AlertsClient) ListResourceGroupLevelAlertsByRegion(ctx context.Context, resourceGroupName string, filter string, selectParameter string, expand string) (result AlertListPage, err error) {
483	if tracing.IsEnabled() {
484		ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.ListResourceGroupLevelAlertsByRegion")
485		defer func() {
486			sc := -1
487			if result.al.Response.Response != nil {
488				sc = result.al.Response.Response.StatusCode
489			}
490			tracing.EndSpan(ctx, sc, err)
491		}()
492	}
493	if err := validation.Validate([]validation.Validation{
494		{TargetValue: client.SubscriptionID,
495			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}},
496		{TargetValue: resourceGroupName,
497			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
498				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
499				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
500		return result, validation.NewError("security.AlertsClient", "ListResourceGroupLevelAlertsByRegion", err.Error())
501	}
502
503	result.fn = client.listResourceGroupLevelAlertsByRegionNextResults
504	req, err := client.ListResourceGroupLevelAlertsByRegionPreparer(ctx, resourceGroupName, filter, selectParameter, expand)
505	if err != nil {
506		err = autorest.NewErrorWithError(err, "security.AlertsClient", "ListResourceGroupLevelAlertsByRegion", nil, "Failure preparing request")
507		return
508	}
509
510	resp, err := client.ListResourceGroupLevelAlertsByRegionSender(req)
511	if err != nil {
512		result.al.Response = autorest.Response{Response: resp}
513		err = autorest.NewErrorWithError(err, "security.AlertsClient", "ListResourceGroupLevelAlertsByRegion", resp, "Failure sending request")
514		return
515	}
516
517	result.al, err = client.ListResourceGroupLevelAlertsByRegionResponder(resp)
518	if err != nil {
519		err = autorest.NewErrorWithError(err, "security.AlertsClient", "ListResourceGroupLevelAlertsByRegion", resp, "Failure responding to request")
520		return
521	}
522	if result.al.hasNextLink() && result.al.IsEmpty() {
523		err = result.NextWithContext(ctx)
524		return
525	}
526
527	return
528}
529
530// ListResourceGroupLevelAlertsByRegionPreparer prepares the ListResourceGroupLevelAlertsByRegion request.
531func (client AlertsClient) ListResourceGroupLevelAlertsByRegionPreparer(ctx context.Context, resourceGroupName string, filter string, selectParameter string, expand string) (*http.Request, error) {
532	pathParameters := map[string]interface{}{
533		"ascLocation":       autorest.Encode("path", client.AscLocation),
534		"resourceGroupName": autorest.Encode("path", resourceGroupName),
535		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
536	}
537
538	const APIVersion = "2015-06-01-preview"
539	queryParameters := map[string]interface{}{
540		"api-version": APIVersion,
541	}
542	if len(filter) > 0 {
543		queryParameters["$filter"] = autorest.Encode("query", filter)
544	}
545	if len(selectParameter) > 0 {
546		queryParameters["$select"] = autorest.Encode("query", selectParameter)
547	}
548	if len(expand) > 0 {
549		queryParameters["$expand"] = autorest.Encode("query", expand)
550	}
551
552	preparer := autorest.CreatePreparer(
553		autorest.AsGet(),
554		autorest.WithBaseURL(client.BaseURI),
555		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts", pathParameters),
556		autorest.WithQueryParameters(queryParameters))
557	return preparer.Prepare((&http.Request{}).WithContext(ctx))
558}
559
560// ListResourceGroupLevelAlertsByRegionSender sends the ListResourceGroupLevelAlertsByRegion request. The method will close the
561// http.Response Body if it receives an error.
562func (client AlertsClient) ListResourceGroupLevelAlertsByRegionSender(req *http.Request) (*http.Response, error) {
563	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
564}
565
566// ListResourceGroupLevelAlertsByRegionResponder handles the response to the ListResourceGroupLevelAlertsByRegion request. The method always
567// closes the http.Response Body.
568func (client AlertsClient) ListResourceGroupLevelAlertsByRegionResponder(resp *http.Response) (result AlertList, err error) {
569	err = autorest.Respond(
570		resp,
571		azure.WithErrorUnlessStatusCode(http.StatusOK),
572		autorest.ByUnmarshallingJSON(&result),
573		autorest.ByClosing())
574	result.Response = autorest.Response{Response: resp}
575	return
576}
577
578// listResourceGroupLevelAlertsByRegionNextResults retrieves the next set of results, if any.
579func (client AlertsClient) listResourceGroupLevelAlertsByRegionNextResults(ctx context.Context, lastResults AlertList) (result AlertList, err error) {
580	req, err := lastResults.alertListPreparer(ctx)
581	if err != nil {
582		return result, autorest.NewErrorWithError(err, "security.AlertsClient", "listResourceGroupLevelAlertsByRegionNextResults", nil, "Failure preparing next results request")
583	}
584	if req == nil {
585		return
586	}
587	resp, err := client.ListResourceGroupLevelAlertsByRegionSender(req)
588	if err != nil {
589		result.Response = autorest.Response{Response: resp}
590		return result, autorest.NewErrorWithError(err, "security.AlertsClient", "listResourceGroupLevelAlertsByRegionNextResults", resp, "Failure sending next results request")
591	}
592	result, err = client.ListResourceGroupLevelAlertsByRegionResponder(resp)
593	if err != nil {
594		err = autorest.NewErrorWithError(err, "security.AlertsClient", "listResourceGroupLevelAlertsByRegionNextResults", resp, "Failure responding to next results request")
595	}
596	return
597}
598
599// ListResourceGroupLevelAlertsByRegionComplete enumerates all values, automatically crossing page boundaries as required.
600func (client AlertsClient) ListResourceGroupLevelAlertsByRegionComplete(ctx context.Context, resourceGroupName string, filter string, selectParameter string, expand string) (result AlertListIterator, err error) {
601	if tracing.IsEnabled() {
602		ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.ListResourceGroupLevelAlertsByRegion")
603		defer func() {
604			sc := -1
605			if result.Response().Response.Response != nil {
606				sc = result.page.Response().Response.Response.StatusCode
607			}
608			tracing.EndSpan(ctx, sc, err)
609		}()
610	}
611	result.page, err = client.ListResourceGroupLevelAlertsByRegion(ctx, resourceGroupName, filter, selectParameter, expand)
612	return
613}
614
615// ListSubscriptionLevelAlertsByRegion list all the alerts that are associated with the subscription that are stored in
616// a specific location
617// Parameters:
618// filter - oData filter. Optional.
619// selectParameter - oData select. Optional.
620// expand - oData expand. Optional.
621func (client AlertsClient) ListSubscriptionLevelAlertsByRegion(ctx context.Context, filter string, selectParameter string, expand string) (result AlertListPage, err error) {
622	if tracing.IsEnabled() {
623		ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.ListSubscriptionLevelAlertsByRegion")
624		defer func() {
625			sc := -1
626			if result.al.Response.Response != nil {
627				sc = result.al.Response.Response.StatusCode
628			}
629			tracing.EndSpan(ctx, sc, err)
630		}()
631	}
632	if err := validation.Validate([]validation.Validation{
633		{TargetValue: client.SubscriptionID,
634			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil {
635		return result, validation.NewError("security.AlertsClient", "ListSubscriptionLevelAlertsByRegion", err.Error())
636	}
637
638	result.fn = client.listSubscriptionLevelAlertsByRegionNextResults
639	req, err := client.ListSubscriptionLevelAlertsByRegionPreparer(ctx, filter, selectParameter, expand)
640	if err != nil {
641		err = autorest.NewErrorWithError(err, "security.AlertsClient", "ListSubscriptionLevelAlertsByRegion", nil, "Failure preparing request")
642		return
643	}
644
645	resp, err := client.ListSubscriptionLevelAlertsByRegionSender(req)
646	if err != nil {
647		result.al.Response = autorest.Response{Response: resp}
648		err = autorest.NewErrorWithError(err, "security.AlertsClient", "ListSubscriptionLevelAlertsByRegion", resp, "Failure sending request")
649		return
650	}
651
652	result.al, err = client.ListSubscriptionLevelAlertsByRegionResponder(resp)
653	if err != nil {
654		err = autorest.NewErrorWithError(err, "security.AlertsClient", "ListSubscriptionLevelAlertsByRegion", resp, "Failure responding to request")
655		return
656	}
657	if result.al.hasNextLink() && result.al.IsEmpty() {
658		err = result.NextWithContext(ctx)
659		return
660	}
661
662	return
663}
664
665// ListSubscriptionLevelAlertsByRegionPreparer prepares the ListSubscriptionLevelAlertsByRegion request.
666func (client AlertsClient) ListSubscriptionLevelAlertsByRegionPreparer(ctx context.Context, filter string, selectParameter string, expand string) (*http.Request, error) {
667	pathParameters := map[string]interface{}{
668		"ascLocation":    autorest.Encode("path", client.AscLocation),
669		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
670	}
671
672	const APIVersion = "2015-06-01-preview"
673	queryParameters := map[string]interface{}{
674		"api-version": APIVersion,
675	}
676	if len(filter) > 0 {
677		queryParameters["$filter"] = autorest.Encode("query", filter)
678	}
679	if len(selectParameter) > 0 {
680		queryParameters["$select"] = autorest.Encode("query", selectParameter)
681	}
682	if len(expand) > 0 {
683		queryParameters["$expand"] = autorest.Encode("query", expand)
684	}
685
686	preparer := autorest.CreatePreparer(
687		autorest.AsGet(),
688		autorest.WithBaseURL(client.BaseURI),
689		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts", pathParameters),
690		autorest.WithQueryParameters(queryParameters))
691	return preparer.Prepare((&http.Request{}).WithContext(ctx))
692}
693
694// ListSubscriptionLevelAlertsByRegionSender sends the ListSubscriptionLevelAlertsByRegion request. The method will close the
695// http.Response Body if it receives an error.
696func (client AlertsClient) ListSubscriptionLevelAlertsByRegionSender(req *http.Request) (*http.Response, error) {
697	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
698}
699
700// ListSubscriptionLevelAlertsByRegionResponder handles the response to the ListSubscriptionLevelAlertsByRegion request. The method always
701// closes the http.Response Body.
702func (client AlertsClient) ListSubscriptionLevelAlertsByRegionResponder(resp *http.Response) (result AlertList, err error) {
703	err = autorest.Respond(
704		resp,
705		azure.WithErrorUnlessStatusCode(http.StatusOK),
706		autorest.ByUnmarshallingJSON(&result),
707		autorest.ByClosing())
708	result.Response = autorest.Response{Response: resp}
709	return
710}
711
712// listSubscriptionLevelAlertsByRegionNextResults retrieves the next set of results, if any.
713func (client AlertsClient) listSubscriptionLevelAlertsByRegionNextResults(ctx context.Context, lastResults AlertList) (result AlertList, err error) {
714	req, err := lastResults.alertListPreparer(ctx)
715	if err != nil {
716		return result, autorest.NewErrorWithError(err, "security.AlertsClient", "listSubscriptionLevelAlertsByRegionNextResults", nil, "Failure preparing next results request")
717	}
718	if req == nil {
719		return
720	}
721	resp, err := client.ListSubscriptionLevelAlertsByRegionSender(req)
722	if err != nil {
723		result.Response = autorest.Response{Response: resp}
724		return result, autorest.NewErrorWithError(err, "security.AlertsClient", "listSubscriptionLevelAlertsByRegionNextResults", resp, "Failure sending next results request")
725	}
726	result, err = client.ListSubscriptionLevelAlertsByRegionResponder(resp)
727	if err != nil {
728		err = autorest.NewErrorWithError(err, "security.AlertsClient", "listSubscriptionLevelAlertsByRegionNextResults", resp, "Failure responding to next results request")
729	}
730	return
731}
732
733// ListSubscriptionLevelAlertsByRegionComplete enumerates all values, automatically crossing page boundaries as required.
734func (client AlertsClient) ListSubscriptionLevelAlertsByRegionComplete(ctx context.Context, filter string, selectParameter string, expand string) (result AlertListIterator, err error) {
735	if tracing.IsEnabled() {
736		ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.ListSubscriptionLevelAlertsByRegion")
737		defer func() {
738			sc := -1
739			if result.Response().Response.Response != nil {
740				sc = result.page.Response().Response.Response.StatusCode
741			}
742			tracing.EndSpan(ctx, sc, err)
743		}()
744	}
745	result.page, err = client.ListSubscriptionLevelAlertsByRegion(ctx, filter, selectParameter, expand)
746	return
747}
748
749// UpdateResourceGroupLevelAlertStateToDismiss update the alert's state
750// Parameters:
751// alertName - name of the alert object
752// resourceGroupName - the name of the resource group within the user's subscription. The name is case
753// insensitive.
754func (client AlertsClient) UpdateResourceGroupLevelAlertStateToDismiss(ctx context.Context, alertName string, resourceGroupName string) (result autorest.Response, err error) {
755	if tracing.IsEnabled() {
756		ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.UpdateResourceGroupLevelAlertStateToDismiss")
757		defer func() {
758			sc := -1
759			if result.Response != nil {
760				sc = result.Response.StatusCode
761			}
762			tracing.EndSpan(ctx, sc, err)
763		}()
764	}
765	if err := validation.Validate([]validation.Validation{
766		{TargetValue: client.SubscriptionID,
767			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}},
768		{TargetValue: resourceGroupName,
769			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
770				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
771				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
772		return result, validation.NewError("security.AlertsClient", "UpdateResourceGroupLevelAlertStateToDismiss", err.Error())
773	}
774
775	req, err := client.UpdateResourceGroupLevelAlertStateToDismissPreparer(ctx, alertName, resourceGroupName)
776	if err != nil {
777		err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateResourceGroupLevelAlertStateToDismiss", nil, "Failure preparing request")
778		return
779	}
780
781	resp, err := client.UpdateResourceGroupLevelAlertStateToDismissSender(req)
782	if err != nil {
783		result.Response = resp
784		err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateResourceGroupLevelAlertStateToDismiss", resp, "Failure sending request")
785		return
786	}
787
788	result, err = client.UpdateResourceGroupLevelAlertStateToDismissResponder(resp)
789	if err != nil {
790		err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateResourceGroupLevelAlertStateToDismiss", resp, "Failure responding to request")
791		return
792	}
793
794	return
795}
796
797// UpdateResourceGroupLevelAlertStateToDismissPreparer prepares the UpdateResourceGroupLevelAlertStateToDismiss request.
798func (client AlertsClient) UpdateResourceGroupLevelAlertStateToDismissPreparer(ctx context.Context, alertName string, resourceGroupName string) (*http.Request, error) {
799	pathParameters := map[string]interface{}{
800		"alertName":         autorest.Encode("path", alertName),
801		"ascLocation":       autorest.Encode("path", client.AscLocation),
802		"resourceGroupName": autorest.Encode("path", resourceGroupName),
803		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
804	}
805
806	const APIVersion = "2015-06-01-preview"
807	queryParameters := map[string]interface{}{
808		"api-version": APIVersion,
809	}
810
811	preparer := autorest.CreatePreparer(
812		autorest.AsPost(),
813		autorest.WithBaseURL(client.BaseURI),
814		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/dismiss", pathParameters),
815		autorest.WithQueryParameters(queryParameters))
816	return preparer.Prepare((&http.Request{}).WithContext(ctx))
817}
818
819// UpdateResourceGroupLevelAlertStateToDismissSender sends the UpdateResourceGroupLevelAlertStateToDismiss request. The method will close the
820// http.Response Body if it receives an error.
821func (client AlertsClient) UpdateResourceGroupLevelAlertStateToDismissSender(req *http.Request) (*http.Response, error) {
822	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
823}
824
825// UpdateResourceGroupLevelAlertStateToDismissResponder handles the response to the UpdateResourceGroupLevelAlertStateToDismiss request. The method always
826// closes the http.Response Body.
827func (client AlertsClient) UpdateResourceGroupLevelAlertStateToDismissResponder(resp *http.Response) (result autorest.Response, err error) {
828	err = autorest.Respond(
829		resp,
830		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
831		autorest.ByClosing())
832	result.Response = resp
833	return
834}
835
836// UpdateResourceGroupLevelAlertStateToReactivate update the alert's state
837// Parameters:
838// alertName - name of the alert object
839// resourceGroupName - the name of the resource group within the user's subscription. The name is case
840// insensitive.
841func (client AlertsClient) UpdateResourceGroupLevelAlertStateToReactivate(ctx context.Context, alertName string, resourceGroupName string) (result autorest.Response, err error) {
842	if tracing.IsEnabled() {
843		ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.UpdateResourceGroupLevelAlertStateToReactivate")
844		defer func() {
845			sc := -1
846			if result.Response != nil {
847				sc = result.Response.StatusCode
848			}
849			tracing.EndSpan(ctx, sc, err)
850		}()
851	}
852	if err := validation.Validate([]validation.Validation{
853		{TargetValue: client.SubscriptionID,
854			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}},
855		{TargetValue: resourceGroupName,
856			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
857				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
858				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
859		return result, validation.NewError("security.AlertsClient", "UpdateResourceGroupLevelAlertStateToReactivate", err.Error())
860	}
861
862	req, err := client.UpdateResourceGroupLevelAlertStateToReactivatePreparer(ctx, alertName, resourceGroupName)
863	if err != nil {
864		err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateResourceGroupLevelAlertStateToReactivate", nil, "Failure preparing request")
865		return
866	}
867
868	resp, err := client.UpdateResourceGroupLevelAlertStateToReactivateSender(req)
869	if err != nil {
870		result.Response = resp
871		err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateResourceGroupLevelAlertStateToReactivate", resp, "Failure sending request")
872		return
873	}
874
875	result, err = client.UpdateResourceGroupLevelAlertStateToReactivateResponder(resp)
876	if err != nil {
877		err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateResourceGroupLevelAlertStateToReactivate", resp, "Failure responding to request")
878		return
879	}
880
881	return
882}
883
884// UpdateResourceGroupLevelAlertStateToReactivatePreparer prepares the UpdateResourceGroupLevelAlertStateToReactivate request.
885func (client AlertsClient) UpdateResourceGroupLevelAlertStateToReactivatePreparer(ctx context.Context, alertName string, resourceGroupName string) (*http.Request, error) {
886	pathParameters := map[string]interface{}{
887		"alertName":         autorest.Encode("path", alertName),
888		"ascLocation":       autorest.Encode("path", client.AscLocation),
889		"resourceGroupName": autorest.Encode("path", resourceGroupName),
890		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
891	}
892
893	const APIVersion = "2015-06-01-preview"
894	queryParameters := map[string]interface{}{
895		"api-version": APIVersion,
896	}
897
898	preparer := autorest.CreatePreparer(
899		autorest.AsPost(),
900		autorest.WithBaseURL(client.BaseURI),
901		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/reactivate", pathParameters),
902		autorest.WithQueryParameters(queryParameters))
903	return preparer.Prepare((&http.Request{}).WithContext(ctx))
904}
905
906// UpdateResourceGroupLevelAlertStateToReactivateSender sends the UpdateResourceGroupLevelAlertStateToReactivate request. The method will close the
907// http.Response Body if it receives an error.
908func (client AlertsClient) UpdateResourceGroupLevelAlertStateToReactivateSender(req *http.Request) (*http.Response, error) {
909	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
910}
911
912// UpdateResourceGroupLevelAlertStateToReactivateResponder handles the response to the UpdateResourceGroupLevelAlertStateToReactivate request. The method always
913// closes the http.Response Body.
914func (client AlertsClient) UpdateResourceGroupLevelAlertStateToReactivateResponder(resp *http.Response) (result autorest.Response, err error) {
915	err = autorest.Respond(
916		resp,
917		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
918		autorest.ByClosing())
919	result.Response = resp
920	return
921}
922
923// UpdateSubscriptionLevelAlertStateToDismiss update the alert's state
924// Parameters:
925// alertName - name of the alert object
926func (client AlertsClient) UpdateSubscriptionLevelAlertStateToDismiss(ctx context.Context, alertName string) (result autorest.Response, err error) {
927	if tracing.IsEnabled() {
928		ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.UpdateSubscriptionLevelAlertStateToDismiss")
929		defer func() {
930			sc := -1
931			if result.Response != nil {
932				sc = result.Response.StatusCode
933			}
934			tracing.EndSpan(ctx, sc, err)
935		}()
936	}
937	if err := validation.Validate([]validation.Validation{
938		{TargetValue: client.SubscriptionID,
939			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil {
940		return result, validation.NewError("security.AlertsClient", "UpdateSubscriptionLevelAlertStateToDismiss", err.Error())
941	}
942
943	req, err := client.UpdateSubscriptionLevelAlertStateToDismissPreparer(ctx, alertName)
944	if err != nil {
945		err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateSubscriptionLevelAlertStateToDismiss", nil, "Failure preparing request")
946		return
947	}
948
949	resp, err := client.UpdateSubscriptionLevelAlertStateToDismissSender(req)
950	if err != nil {
951		result.Response = resp
952		err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateSubscriptionLevelAlertStateToDismiss", resp, "Failure sending request")
953		return
954	}
955
956	result, err = client.UpdateSubscriptionLevelAlertStateToDismissResponder(resp)
957	if err != nil {
958		err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateSubscriptionLevelAlertStateToDismiss", resp, "Failure responding to request")
959		return
960	}
961
962	return
963}
964
965// UpdateSubscriptionLevelAlertStateToDismissPreparer prepares the UpdateSubscriptionLevelAlertStateToDismiss request.
966func (client AlertsClient) UpdateSubscriptionLevelAlertStateToDismissPreparer(ctx context.Context, alertName string) (*http.Request, error) {
967	pathParameters := map[string]interface{}{
968		"alertName":      autorest.Encode("path", alertName),
969		"ascLocation":    autorest.Encode("path", client.AscLocation),
970		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
971	}
972
973	const APIVersion = "2015-06-01-preview"
974	queryParameters := map[string]interface{}{
975		"api-version": APIVersion,
976	}
977
978	preparer := autorest.CreatePreparer(
979		autorest.AsPost(),
980		autorest.WithBaseURL(client.BaseURI),
981		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/dismiss", pathParameters),
982		autorest.WithQueryParameters(queryParameters))
983	return preparer.Prepare((&http.Request{}).WithContext(ctx))
984}
985
986// UpdateSubscriptionLevelAlertStateToDismissSender sends the UpdateSubscriptionLevelAlertStateToDismiss request. The method will close the
987// http.Response Body if it receives an error.
988func (client AlertsClient) UpdateSubscriptionLevelAlertStateToDismissSender(req *http.Request) (*http.Response, error) {
989	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
990}
991
992// UpdateSubscriptionLevelAlertStateToDismissResponder handles the response to the UpdateSubscriptionLevelAlertStateToDismiss request. The method always
993// closes the http.Response Body.
994func (client AlertsClient) UpdateSubscriptionLevelAlertStateToDismissResponder(resp *http.Response) (result autorest.Response, err error) {
995	err = autorest.Respond(
996		resp,
997		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
998		autorest.ByClosing())
999	result.Response = resp
1000	return
1001}
1002
1003// UpdateSubscriptionLevelAlertStateToReactivate update the alert's state
1004// Parameters:
1005// alertName - name of the alert object
1006func (client AlertsClient) UpdateSubscriptionLevelAlertStateToReactivate(ctx context.Context, alertName string) (result autorest.Response, err error) {
1007	if tracing.IsEnabled() {
1008		ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.UpdateSubscriptionLevelAlertStateToReactivate")
1009		defer func() {
1010			sc := -1
1011			if result.Response != nil {
1012				sc = result.Response.StatusCode
1013			}
1014			tracing.EndSpan(ctx, sc, err)
1015		}()
1016	}
1017	if err := validation.Validate([]validation.Validation{
1018		{TargetValue: client.SubscriptionID,
1019			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil {
1020		return result, validation.NewError("security.AlertsClient", "UpdateSubscriptionLevelAlertStateToReactivate", err.Error())
1021	}
1022
1023	req, err := client.UpdateSubscriptionLevelAlertStateToReactivatePreparer(ctx, alertName)
1024	if err != nil {
1025		err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateSubscriptionLevelAlertStateToReactivate", nil, "Failure preparing request")
1026		return
1027	}
1028
1029	resp, err := client.UpdateSubscriptionLevelAlertStateToReactivateSender(req)
1030	if err != nil {
1031		result.Response = resp
1032		err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateSubscriptionLevelAlertStateToReactivate", resp, "Failure sending request")
1033		return
1034	}
1035
1036	result, err = client.UpdateSubscriptionLevelAlertStateToReactivateResponder(resp)
1037	if err != nil {
1038		err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateSubscriptionLevelAlertStateToReactivate", resp, "Failure responding to request")
1039		return
1040	}
1041
1042	return
1043}
1044
1045// UpdateSubscriptionLevelAlertStateToReactivatePreparer prepares the UpdateSubscriptionLevelAlertStateToReactivate request.
1046func (client AlertsClient) UpdateSubscriptionLevelAlertStateToReactivatePreparer(ctx context.Context, alertName string) (*http.Request, error) {
1047	pathParameters := map[string]interface{}{
1048		"alertName":      autorest.Encode("path", alertName),
1049		"ascLocation":    autorest.Encode("path", client.AscLocation),
1050		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
1051	}
1052
1053	const APIVersion = "2015-06-01-preview"
1054	queryParameters := map[string]interface{}{
1055		"api-version": APIVersion,
1056	}
1057
1058	preparer := autorest.CreatePreparer(
1059		autorest.AsPost(),
1060		autorest.WithBaseURL(client.BaseURI),
1061		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/reactivate", pathParameters),
1062		autorest.WithQueryParameters(queryParameters))
1063	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1064}
1065
1066// UpdateSubscriptionLevelAlertStateToReactivateSender sends the UpdateSubscriptionLevelAlertStateToReactivate request. The method will close the
1067// http.Response Body if it receives an error.
1068func (client AlertsClient) UpdateSubscriptionLevelAlertStateToReactivateSender(req *http.Request) (*http.Response, error) {
1069	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
1070}
1071
1072// UpdateSubscriptionLevelAlertStateToReactivateResponder handles the response to the UpdateSubscriptionLevelAlertStateToReactivate request. The method always
1073// closes the http.Response Body.
1074func (client AlertsClient) UpdateSubscriptionLevelAlertStateToReactivateResponder(resp *http.Response) (result autorest.Response, err error) {
1075	err = autorest.Respond(
1076		resp,
1077		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
1078		autorest.ByClosing())
1079	result.Response = resp
1080	return
1081}
1082