From 87b36c034493dd0043d50976e940777a4f3a2ac7 Mon Sep 17 00:00:00 2001 From: Azure SDK Bot Date: Sun, 10 Nov 2019 11:23:11 +0000 Subject: [PATCH 1/2] Generated from cd736d4605f25bafc1e210b4e83e6805863fe23f Merge pull request #2 from yibirnba2/swaggerCompletenessIssue Update operationId --- .../security/mgmt/v1.0/security/alerts.go | 271 ++++++++++++++---- .../v1.0/security/securityapi/interfaces.go | 6 +- .../security/mgmt/v2.0/security/alerts.go | 271 ++++++++++++++---- .../v2.0/security/securityapi/interfaces.go | 6 +- .../security/mgmt/v3.0/security/alerts.go | 271 ++++++++++++++---- .../v3.0/security/securityapi/interfaces.go | 6 +- 6 files changed, 666 insertions(+), 165 deletions(-) diff --git a/services/preview/security/mgmt/v1.0/security/alerts.go b/services/preview/security/mgmt/v1.0/security/alerts.go index fb6af65cb174..1a29f482d751 100644 --- a/services/preview/security/mgmt/v1.0/security/alerts.go +++ b/services/preview/security/mgmt/v1.0/security/alerts.go @@ -41,6 +41,175 @@ func NewAlertsClientWithBaseURI(baseURI string, subscriptionID string, ascLocati return AlertsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} } +// Dismiss update the alert's state +// Parameters: +// alertName - name of the alert object +func (client AlertsClient) Dismiss(ctx context.Context, alertName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.Dismiss") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + 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 { + return result, validation.NewError("security.AlertsClient", "Dismiss", err.Error()) + } + + req, err := client.DismissPreparer(ctx, alertName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "Dismiss", nil, "Failure preparing request") + return + } + + resp, err := client.DismissSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "security.AlertsClient", "Dismiss", resp, "Failure sending request") + return + } + + result, err = client.DismissResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "Dismiss", resp, "Failure responding to request") + } + + return +} + +// DismissPreparer prepares the Dismiss request. +func (client AlertsClient) DismissPreparer(ctx context.Context, alertName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "alertName": autorest.Encode("path", alertName), + "ascLocation": autorest.Encode("path", client.AscLocation), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/dismiss", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DismissSender sends the Dismiss request. The method will close the +// http.Response Body if it receives an error. +func (client AlertsClient) DismissSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// DismissResponder handles the response to the Dismiss request. The method always +// closes the http.Response Body. +func (client AlertsClient) DismissResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Dismiss1 update the alert's state +// Parameters: +// alertName - name of the alert object +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +func (client AlertsClient) Dismiss1(ctx context.Context, alertName string, resourceGroupName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.Dismiss1") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + 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}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.AlertsClient", "Dismiss1", err.Error()) + } + + req, err := client.Dismiss1Preparer(ctx, alertName, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "Dismiss1", nil, "Failure preparing request") + return + } + + resp, err := client.Dismiss1Sender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "security.AlertsClient", "Dismiss1", resp, "Failure sending request") + return + } + + result, err = client.Dismiss1Responder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "Dismiss1", resp, "Failure responding to request") + } + + return +} + +// Dismiss1Preparer prepares the Dismiss1 request. +func (client AlertsClient) Dismiss1Preparer(ctx context.Context, alertName string, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "alertName": autorest.Encode("path", alertName), + "ascLocation": autorest.Encode("path", client.AscLocation), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/dismiss", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// Dismiss1Sender sends the Dismiss1 request. The method will close the +// http.Response Body if it receives an error. +func (client AlertsClient) Dismiss1Sender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// Dismiss1Responder handles the response to the Dismiss1 request. The method always +// closes the http.Response Body. +func (client AlertsClient) Dismiss1Responder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + // GetResourceGroupLevelAlerts get an alert that is associated a resource group or a resource in a resource group // Parameters: // alertName - name of the alert object @@ -746,15 +915,12 @@ func (client AlertsClient) ListSubscriptionLevelAlertsByRegionComplete(ctx conte return } -// UpdateResourceGroupLevelAlertState update the alert's state +// Reactivate update the alert's state // Parameters: // alertName - name of the alert object -// alertUpdateActionType - type of the action to do on the alert -// resourceGroupName - the name of the resource group within the user's subscription. The name is case -// insensitive. -func (client AlertsClient) UpdateResourceGroupLevelAlertState(ctx context.Context, alertName string, alertUpdateActionType string, resourceGroupName string) (result autorest.Response, err error) { +func (client AlertsClient) Reactivate(ctx context.Context, alertName string) (result autorest.Response, err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.UpdateResourceGroupLevelAlertState") + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.Reactivate") defer func() { sc := -1 if result.Response != nil { @@ -765,43 +931,37 @@ func (client AlertsClient) UpdateResourceGroupLevelAlertState(ctx context.Contex } if err := validation.Validate([]validation.Validation{ {TargetValue: client.SubscriptionID, - 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}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("security.AlertsClient", "UpdateResourceGroupLevelAlertState", err.Error()) + 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 { + return result, validation.NewError("security.AlertsClient", "Reactivate", err.Error()) } - req, err := client.UpdateResourceGroupLevelAlertStatePreparer(ctx, alertName, alertUpdateActionType, resourceGroupName) + req, err := client.ReactivatePreparer(ctx, alertName) if err != nil { - err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateResourceGroupLevelAlertState", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "security.AlertsClient", "Reactivate", nil, "Failure preparing request") return } - resp, err := client.UpdateResourceGroupLevelAlertStateSender(req) + resp, err := client.ReactivateSender(req) if err != nil { result.Response = resp - err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateResourceGroupLevelAlertState", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "security.AlertsClient", "Reactivate", resp, "Failure sending request") return } - result, err = client.UpdateResourceGroupLevelAlertStateResponder(resp) + result, err = client.ReactivateResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateResourceGroupLevelAlertState", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "security.AlertsClient", "Reactivate", resp, "Failure responding to request") } return } -// UpdateResourceGroupLevelAlertStatePreparer prepares the UpdateResourceGroupLevelAlertState request. -func (client AlertsClient) UpdateResourceGroupLevelAlertStatePreparer(ctx context.Context, alertName string, alertUpdateActionType string, resourceGroupName string) (*http.Request, error) { +// ReactivatePreparer prepares the Reactivate request. +func (client AlertsClient) ReactivatePreparer(ctx context.Context, alertName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "alertName": autorest.Encode("path", alertName), - "alertUpdateActionType": autorest.Encode("path", alertUpdateActionType), - "ascLocation": autorest.Encode("path", client.AscLocation), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "alertName": autorest.Encode("path", alertName), + "ascLocation": autorest.Encode("path", client.AscLocation), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } const APIVersion = "2015-06-01-preview" @@ -812,21 +972,21 @@ func (client AlertsClient) UpdateResourceGroupLevelAlertStatePreparer(ctx contex preparer := autorest.CreatePreparer( autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/{alertUpdateActionType}", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/reactivate", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) } -// UpdateResourceGroupLevelAlertStateSender sends the UpdateResourceGroupLevelAlertState request. The method will close the +// ReactivateSender sends the Reactivate request. The method will close the // http.Response Body if it receives an error. -func (client AlertsClient) UpdateResourceGroupLevelAlertStateSender(req *http.Request) (*http.Response, error) { +func (client AlertsClient) ReactivateSender(req *http.Request) (*http.Response, error) { sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) return autorest.SendWithSender(client, req, sd...) } -// UpdateResourceGroupLevelAlertStateResponder handles the response to the UpdateResourceGroupLevelAlertState request. The method always +// ReactivateResponder handles the response to the Reactivate request. The method always // closes the http.Response Body. -func (client AlertsClient) UpdateResourceGroupLevelAlertStateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client AlertsClient) ReactivateResponder(resp *http.Response) (result autorest.Response, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -836,13 +996,14 @@ func (client AlertsClient) UpdateResourceGroupLevelAlertStateResponder(resp *htt return } -// UpdateSubscriptionLevelAlertState update the alert's state +// Reactivate1 update the alert's state // Parameters: // alertName - name of the alert object -// alertUpdateActionType - type of the action to do on the alert -func (client AlertsClient) UpdateSubscriptionLevelAlertState(ctx context.Context, alertName string, alertUpdateActionType string) (result autorest.Response, err error) { +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +func (client AlertsClient) Reactivate1(ctx context.Context, alertName string, resourceGroupName string) (result autorest.Response, err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.UpdateSubscriptionLevelAlertState") + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.Reactivate1") defer func() { sc := -1 if result.Response != nil { @@ -853,38 +1014,42 @@ func (client AlertsClient) UpdateSubscriptionLevelAlertState(ctx context.Context } if err := validation.Validate([]validation.Validation{ {TargetValue: client.SubscriptionID, - 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 { - return result, validation.NewError("security.AlertsClient", "UpdateSubscriptionLevelAlertState", err.Error()) + 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}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.AlertsClient", "Reactivate1", err.Error()) } - req, err := client.UpdateSubscriptionLevelAlertStatePreparer(ctx, alertName, alertUpdateActionType) + req, err := client.Reactivate1Preparer(ctx, alertName, resourceGroupName) if err != nil { - err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateSubscriptionLevelAlertState", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "security.AlertsClient", "Reactivate1", nil, "Failure preparing request") return } - resp, err := client.UpdateSubscriptionLevelAlertStateSender(req) + resp, err := client.Reactivate1Sender(req) if err != nil { result.Response = resp - err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateSubscriptionLevelAlertState", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "security.AlertsClient", "Reactivate1", resp, "Failure sending request") return } - result, err = client.UpdateSubscriptionLevelAlertStateResponder(resp) + result, err = client.Reactivate1Responder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateSubscriptionLevelAlertState", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "security.AlertsClient", "Reactivate1", resp, "Failure responding to request") } return } -// UpdateSubscriptionLevelAlertStatePreparer prepares the UpdateSubscriptionLevelAlertState request. -func (client AlertsClient) UpdateSubscriptionLevelAlertStatePreparer(ctx context.Context, alertName string, alertUpdateActionType string) (*http.Request, error) { +// Reactivate1Preparer prepares the Reactivate1 request. +func (client AlertsClient) Reactivate1Preparer(ctx context.Context, alertName string, resourceGroupName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "alertName": autorest.Encode("path", alertName), - "alertUpdateActionType": autorest.Encode("path", alertUpdateActionType), - "ascLocation": autorest.Encode("path", client.AscLocation), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "alertName": autorest.Encode("path", alertName), + "ascLocation": autorest.Encode("path", client.AscLocation), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } const APIVersion = "2015-06-01-preview" @@ -895,21 +1060,21 @@ func (client AlertsClient) UpdateSubscriptionLevelAlertStatePreparer(ctx context preparer := autorest.CreatePreparer( autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/{alertUpdateActionType}", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/reactivate", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) } -// UpdateSubscriptionLevelAlertStateSender sends the UpdateSubscriptionLevelAlertState request. The method will close the +// Reactivate1Sender sends the Reactivate1 request. The method will close the // http.Response Body if it receives an error. -func (client AlertsClient) UpdateSubscriptionLevelAlertStateSender(req *http.Request) (*http.Response, error) { +func (client AlertsClient) Reactivate1Sender(req *http.Request) (*http.Response, error) { sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) return autorest.SendWithSender(client, req, sd...) } -// UpdateSubscriptionLevelAlertStateResponder handles the response to the UpdateSubscriptionLevelAlertState request. The method always +// Reactivate1Responder handles the response to the Reactivate1 request. The method always // closes the http.Response Body. -func (client AlertsClient) UpdateSubscriptionLevelAlertStateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client AlertsClient) Reactivate1Responder(resp *http.Response) (result autorest.Response, err error) { err = autorest.Respond( resp, client.ByInspecting(), diff --git a/services/preview/security/mgmt/v1.0/security/securityapi/interfaces.go b/services/preview/security/mgmt/v1.0/security/securityapi/interfaces.go index 811063e3ef89..e2f6893b11b3 100644 --- a/services/preview/security/mgmt/v1.0/security/securityapi/interfaces.go +++ b/services/preview/security/mgmt/v1.0/security/securityapi/interfaces.go @@ -173,14 +173,16 @@ var _ TasksClientAPI = (*security.TasksClient)(nil) // AlertsClientAPI contains the set of methods on the AlertsClient type. type AlertsClientAPI interface { + Dismiss(ctx context.Context, alertName string) (result autorest.Response, err error) + Dismiss1(ctx context.Context, alertName string, resourceGroupName string) (result autorest.Response, err error) GetResourceGroupLevelAlerts(ctx context.Context, alertName string, resourceGroupName string) (result security.Alert, err error) GetSubscriptionLevelAlert(ctx context.Context, alertName string) (result security.Alert, err error) List(ctx context.Context, filter string, selectParameter string, expand string) (result security.AlertListPage, err error) ListByResourceGroup(ctx context.Context, resourceGroupName string, filter string, selectParameter string, expand string) (result security.AlertListPage, err error) ListResourceGroupLevelAlertsByRegion(ctx context.Context, resourceGroupName string, filter string, selectParameter string, expand string) (result security.AlertListPage, err error) ListSubscriptionLevelAlertsByRegion(ctx context.Context, filter string, selectParameter string, expand string) (result security.AlertListPage, err error) - UpdateResourceGroupLevelAlertState(ctx context.Context, alertName string, alertUpdateActionType string, resourceGroupName string) (result autorest.Response, err error) - UpdateSubscriptionLevelAlertState(ctx context.Context, alertName string, alertUpdateActionType string) (result autorest.Response, err error) + Reactivate(ctx context.Context, alertName string) (result autorest.Response, err error) + Reactivate1(ctx context.Context, alertName string, resourceGroupName string) (result autorest.Response, err error) } var _ AlertsClientAPI = (*security.AlertsClient)(nil) diff --git a/services/preview/security/mgmt/v2.0/security/alerts.go b/services/preview/security/mgmt/v2.0/security/alerts.go index f41504c09789..cfeefed86b3b 100644 --- a/services/preview/security/mgmt/v2.0/security/alerts.go +++ b/services/preview/security/mgmt/v2.0/security/alerts.go @@ -41,6 +41,175 @@ func NewAlertsClientWithBaseURI(baseURI string, subscriptionID string, ascLocati return AlertsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} } +// Dismiss update the alert's state +// Parameters: +// alertName - name of the alert object +func (client AlertsClient) Dismiss(ctx context.Context, alertName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.Dismiss") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + 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 { + return result, validation.NewError("security.AlertsClient", "Dismiss", err.Error()) + } + + req, err := client.DismissPreparer(ctx, alertName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "Dismiss", nil, "Failure preparing request") + return + } + + resp, err := client.DismissSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "security.AlertsClient", "Dismiss", resp, "Failure sending request") + return + } + + result, err = client.DismissResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "Dismiss", resp, "Failure responding to request") + } + + return +} + +// DismissPreparer prepares the Dismiss request. +func (client AlertsClient) DismissPreparer(ctx context.Context, alertName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "alertName": autorest.Encode("path", alertName), + "ascLocation": autorest.Encode("path", client.AscLocation), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/dismiss", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DismissSender sends the Dismiss request. The method will close the +// http.Response Body if it receives an error. +func (client AlertsClient) DismissSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// DismissResponder handles the response to the Dismiss request. The method always +// closes the http.Response Body. +func (client AlertsClient) DismissResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Dismiss1 update the alert's state +// Parameters: +// alertName - name of the alert object +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +func (client AlertsClient) Dismiss1(ctx context.Context, alertName string, resourceGroupName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.Dismiss1") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + 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}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.AlertsClient", "Dismiss1", err.Error()) + } + + req, err := client.Dismiss1Preparer(ctx, alertName, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "Dismiss1", nil, "Failure preparing request") + return + } + + resp, err := client.Dismiss1Sender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "security.AlertsClient", "Dismiss1", resp, "Failure sending request") + return + } + + result, err = client.Dismiss1Responder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "Dismiss1", resp, "Failure responding to request") + } + + return +} + +// Dismiss1Preparer prepares the Dismiss1 request. +func (client AlertsClient) Dismiss1Preparer(ctx context.Context, alertName string, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "alertName": autorest.Encode("path", alertName), + "ascLocation": autorest.Encode("path", client.AscLocation), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/dismiss", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// Dismiss1Sender sends the Dismiss1 request. The method will close the +// http.Response Body if it receives an error. +func (client AlertsClient) Dismiss1Sender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// Dismiss1Responder handles the response to the Dismiss1 request. The method always +// closes the http.Response Body. +func (client AlertsClient) Dismiss1Responder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + // GetResourceGroupLevelAlerts get an alert that is associated a resource group or a resource in a resource group // Parameters: // alertName - name of the alert object @@ -746,15 +915,12 @@ func (client AlertsClient) ListSubscriptionLevelAlertsByRegionComplete(ctx conte return } -// UpdateResourceGroupLevelAlertState update the alert's state +// Reactivate update the alert's state // Parameters: // alertName - name of the alert object -// alertUpdateActionType - type of the action to do on the alert -// resourceGroupName - the name of the resource group within the user's subscription. The name is case -// insensitive. -func (client AlertsClient) UpdateResourceGroupLevelAlertState(ctx context.Context, alertName string, alertUpdateActionType string, resourceGroupName string) (result autorest.Response, err error) { +func (client AlertsClient) Reactivate(ctx context.Context, alertName string) (result autorest.Response, err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.UpdateResourceGroupLevelAlertState") + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.Reactivate") defer func() { sc := -1 if result.Response != nil { @@ -765,43 +931,37 @@ func (client AlertsClient) UpdateResourceGroupLevelAlertState(ctx context.Contex } if err := validation.Validate([]validation.Validation{ {TargetValue: client.SubscriptionID, - 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}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("security.AlertsClient", "UpdateResourceGroupLevelAlertState", err.Error()) + 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 { + return result, validation.NewError("security.AlertsClient", "Reactivate", err.Error()) } - req, err := client.UpdateResourceGroupLevelAlertStatePreparer(ctx, alertName, alertUpdateActionType, resourceGroupName) + req, err := client.ReactivatePreparer(ctx, alertName) if err != nil { - err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateResourceGroupLevelAlertState", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "security.AlertsClient", "Reactivate", nil, "Failure preparing request") return } - resp, err := client.UpdateResourceGroupLevelAlertStateSender(req) + resp, err := client.ReactivateSender(req) if err != nil { result.Response = resp - err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateResourceGroupLevelAlertState", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "security.AlertsClient", "Reactivate", resp, "Failure sending request") return } - result, err = client.UpdateResourceGroupLevelAlertStateResponder(resp) + result, err = client.ReactivateResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateResourceGroupLevelAlertState", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "security.AlertsClient", "Reactivate", resp, "Failure responding to request") } return } -// UpdateResourceGroupLevelAlertStatePreparer prepares the UpdateResourceGroupLevelAlertState request. -func (client AlertsClient) UpdateResourceGroupLevelAlertStatePreparer(ctx context.Context, alertName string, alertUpdateActionType string, resourceGroupName string) (*http.Request, error) { +// ReactivatePreparer prepares the Reactivate request. +func (client AlertsClient) ReactivatePreparer(ctx context.Context, alertName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "alertName": autorest.Encode("path", alertName), - "alertUpdateActionType": autorest.Encode("path", alertUpdateActionType), - "ascLocation": autorest.Encode("path", client.AscLocation), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "alertName": autorest.Encode("path", alertName), + "ascLocation": autorest.Encode("path", client.AscLocation), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } const APIVersion = "2019-01-01" @@ -812,21 +972,21 @@ func (client AlertsClient) UpdateResourceGroupLevelAlertStatePreparer(ctx contex preparer := autorest.CreatePreparer( autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/{alertUpdateActionType}", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/reactivate", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) } -// UpdateResourceGroupLevelAlertStateSender sends the UpdateResourceGroupLevelAlertState request. The method will close the +// ReactivateSender sends the Reactivate request. The method will close the // http.Response Body if it receives an error. -func (client AlertsClient) UpdateResourceGroupLevelAlertStateSender(req *http.Request) (*http.Response, error) { +func (client AlertsClient) ReactivateSender(req *http.Request) (*http.Response, error) { sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) return autorest.SendWithSender(client, req, sd...) } -// UpdateResourceGroupLevelAlertStateResponder handles the response to the UpdateResourceGroupLevelAlertState request. The method always +// ReactivateResponder handles the response to the Reactivate request. The method always // closes the http.Response Body. -func (client AlertsClient) UpdateResourceGroupLevelAlertStateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client AlertsClient) ReactivateResponder(resp *http.Response) (result autorest.Response, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -836,13 +996,14 @@ func (client AlertsClient) UpdateResourceGroupLevelAlertStateResponder(resp *htt return } -// UpdateSubscriptionLevelAlertState update the alert's state +// Reactivate1 update the alert's state // Parameters: // alertName - name of the alert object -// alertUpdateActionType - type of the action to do on the alert -func (client AlertsClient) UpdateSubscriptionLevelAlertState(ctx context.Context, alertName string, alertUpdateActionType string) (result autorest.Response, err error) { +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +func (client AlertsClient) Reactivate1(ctx context.Context, alertName string, resourceGroupName string) (result autorest.Response, err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.UpdateSubscriptionLevelAlertState") + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.Reactivate1") defer func() { sc := -1 if result.Response != nil { @@ -853,38 +1014,42 @@ func (client AlertsClient) UpdateSubscriptionLevelAlertState(ctx context.Context } if err := validation.Validate([]validation.Validation{ {TargetValue: client.SubscriptionID, - 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 { - return result, validation.NewError("security.AlertsClient", "UpdateSubscriptionLevelAlertState", err.Error()) + 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}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.AlertsClient", "Reactivate1", err.Error()) } - req, err := client.UpdateSubscriptionLevelAlertStatePreparer(ctx, alertName, alertUpdateActionType) + req, err := client.Reactivate1Preparer(ctx, alertName, resourceGroupName) if err != nil { - err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateSubscriptionLevelAlertState", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "security.AlertsClient", "Reactivate1", nil, "Failure preparing request") return } - resp, err := client.UpdateSubscriptionLevelAlertStateSender(req) + resp, err := client.Reactivate1Sender(req) if err != nil { result.Response = resp - err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateSubscriptionLevelAlertState", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "security.AlertsClient", "Reactivate1", resp, "Failure sending request") return } - result, err = client.UpdateSubscriptionLevelAlertStateResponder(resp) + result, err = client.Reactivate1Responder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateSubscriptionLevelAlertState", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "security.AlertsClient", "Reactivate1", resp, "Failure responding to request") } return } -// UpdateSubscriptionLevelAlertStatePreparer prepares the UpdateSubscriptionLevelAlertState request. -func (client AlertsClient) UpdateSubscriptionLevelAlertStatePreparer(ctx context.Context, alertName string, alertUpdateActionType string) (*http.Request, error) { +// Reactivate1Preparer prepares the Reactivate1 request. +func (client AlertsClient) Reactivate1Preparer(ctx context.Context, alertName string, resourceGroupName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "alertName": autorest.Encode("path", alertName), - "alertUpdateActionType": autorest.Encode("path", alertUpdateActionType), - "ascLocation": autorest.Encode("path", client.AscLocation), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "alertName": autorest.Encode("path", alertName), + "ascLocation": autorest.Encode("path", client.AscLocation), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } const APIVersion = "2019-01-01" @@ -895,21 +1060,21 @@ func (client AlertsClient) UpdateSubscriptionLevelAlertStatePreparer(ctx context preparer := autorest.CreatePreparer( autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/{alertUpdateActionType}", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/reactivate", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) } -// UpdateSubscriptionLevelAlertStateSender sends the UpdateSubscriptionLevelAlertState request. The method will close the +// Reactivate1Sender sends the Reactivate1 request. The method will close the // http.Response Body if it receives an error. -func (client AlertsClient) UpdateSubscriptionLevelAlertStateSender(req *http.Request) (*http.Response, error) { +func (client AlertsClient) Reactivate1Sender(req *http.Request) (*http.Response, error) { sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) return autorest.SendWithSender(client, req, sd...) } -// UpdateSubscriptionLevelAlertStateResponder handles the response to the UpdateSubscriptionLevelAlertState request. The method always +// Reactivate1Responder handles the response to the Reactivate1 request. The method always // closes the http.Response Body. -func (client AlertsClient) UpdateSubscriptionLevelAlertStateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client AlertsClient) Reactivate1Responder(resp *http.Response) (result autorest.Response, err error) { err = autorest.Respond( resp, client.ByInspecting(), diff --git a/services/preview/security/mgmt/v2.0/security/securityapi/interfaces.go b/services/preview/security/mgmt/v2.0/security/securityapi/interfaces.go index dec22bd03f50..223083b111b7 100644 --- a/services/preview/security/mgmt/v2.0/security/securityapi/interfaces.go +++ b/services/preview/security/mgmt/v2.0/security/securityapi/interfaces.go @@ -231,14 +231,16 @@ var _ TasksClientAPI = (*security.TasksClient)(nil) // AlertsClientAPI contains the set of methods on the AlertsClient type. type AlertsClientAPI interface { + Dismiss(ctx context.Context, alertName string) (result autorest.Response, err error) + Dismiss1(ctx context.Context, alertName string, resourceGroupName string) (result autorest.Response, err error) GetResourceGroupLevelAlerts(ctx context.Context, alertName string, resourceGroupName string) (result security.Alert, err error) GetSubscriptionLevelAlert(ctx context.Context, alertName string) (result security.Alert, err error) List(ctx context.Context, filter string, selectParameter string, expand string) (result security.AlertListPage, err error) ListByResourceGroup(ctx context.Context, resourceGroupName string, filter string, selectParameter string, expand string) (result security.AlertListPage, err error) ListResourceGroupLevelAlertsByRegion(ctx context.Context, resourceGroupName string, filter string, selectParameter string, expand string) (result security.AlertListPage, err error) ListSubscriptionLevelAlertsByRegion(ctx context.Context, filter string, selectParameter string, expand string) (result security.AlertListPage, err error) - UpdateResourceGroupLevelAlertState(ctx context.Context, alertName string, alertUpdateActionType string, resourceGroupName string) (result autorest.Response, err error) - UpdateSubscriptionLevelAlertState(ctx context.Context, alertName string, alertUpdateActionType string) (result autorest.Response, err error) + Reactivate(ctx context.Context, alertName string) (result autorest.Response, err error) + Reactivate1(ctx context.Context, alertName string, resourceGroupName string) (result autorest.Response, err error) } var _ AlertsClientAPI = (*security.AlertsClient)(nil) diff --git a/services/preview/security/mgmt/v3.0/security/alerts.go b/services/preview/security/mgmt/v3.0/security/alerts.go index f41504c09789..cfeefed86b3b 100644 --- a/services/preview/security/mgmt/v3.0/security/alerts.go +++ b/services/preview/security/mgmt/v3.0/security/alerts.go @@ -41,6 +41,175 @@ func NewAlertsClientWithBaseURI(baseURI string, subscriptionID string, ascLocati return AlertsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} } +// Dismiss update the alert's state +// Parameters: +// alertName - name of the alert object +func (client AlertsClient) Dismiss(ctx context.Context, alertName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.Dismiss") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + 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 { + return result, validation.NewError("security.AlertsClient", "Dismiss", err.Error()) + } + + req, err := client.DismissPreparer(ctx, alertName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "Dismiss", nil, "Failure preparing request") + return + } + + resp, err := client.DismissSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "security.AlertsClient", "Dismiss", resp, "Failure sending request") + return + } + + result, err = client.DismissResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "Dismiss", resp, "Failure responding to request") + } + + return +} + +// DismissPreparer prepares the Dismiss request. +func (client AlertsClient) DismissPreparer(ctx context.Context, alertName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "alertName": autorest.Encode("path", alertName), + "ascLocation": autorest.Encode("path", client.AscLocation), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/dismiss", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DismissSender sends the Dismiss request. The method will close the +// http.Response Body if it receives an error. +func (client AlertsClient) DismissSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// DismissResponder handles the response to the Dismiss request. The method always +// closes the http.Response Body. +func (client AlertsClient) DismissResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Dismiss1 update the alert's state +// Parameters: +// alertName - name of the alert object +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +func (client AlertsClient) Dismiss1(ctx context.Context, alertName string, resourceGroupName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.Dismiss1") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + 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}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.AlertsClient", "Dismiss1", err.Error()) + } + + req, err := client.Dismiss1Preparer(ctx, alertName, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "Dismiss1", nil, "Failure preparing request") + return + } + + resp, err := client.Dismiss1Sender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "security.AlertsClient", "Dismiss1", resp, "Failure sending request") + return + } + + result, err = client.Dismiss1Responder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "Dismiss1", resp, "Failure responding to request") + } + + return +} + +// Dismiss1Preparer prepares the Dismiss1 request. +func (client AlertsClient) Dismiss1Preparer(ctx context.Context, alertName string, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "alertName": autorest.Encode("path", alertName), + "ascLocation": autorest.Encode("path", client.AscLocation), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/dismiss", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// Dismiss1Sender sends the Dismiss1 request. The method will close the +// http.Response Body if it receives an error. +func (client AlertsClient) Dismiss1Sender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// Dismiss1Responder handles the response to the Dismiss1 request. The method always +// closes the http.Response Body. +func (client AlertsClient) Dismiss1Responder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + // GetResourceGroupLevelAlerts get an alert that is associated a resource group or a resource in a resource group // Parameters: // alertName - name of the alert object @@ -746,15 +915,12 @@ func (client AlertsClient) ListSubscriptionLevelAlertsByRegionComplete(ctx conte return } -// UpdateResourceGroupLevelAlertState update the alert's state +// Reactivate update the alert's state // Parameters: // alertName - name of the alert object -// alertUpdateActionType - type of the action to do on the alert -// resourceGroupName - the name of the resource group within the user's subscription. The name is case -// insensitive. -func (client AlertsClient) UpdateResourceGroupLevelAlertState(ctx context.Context, alertName string, alertUpdateActionType string, resourceGroupName string) (result autorest.Response, err error) { +func (client AlertsClient) Reactivate(ctx context.Context, alertName string) (result autorest.Response, err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.UpdateResourceGroupLevelAlertState") + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.Reactivate") defer func() { sc := -1 if result.Response != nil { @@ -765,43 +931,37 @@ func (client AlertsClient) UpdateResourceGroupLevelAlertState(ctx context.Contex } if err := validation.Validate([]validation.Validation{ {TargetValue: client.SubscriptionID, - 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}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("security.AlertsClient", "UpdateResourceGroupLevelAlertState", err.Error()) + 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 { + return result, validation.NewError("security.AlertsClient", "Reactivate", err.Error()) } - req, err := client.UpdateResourceGroupLevelAlertStatePreparer(ctx, alertName, alertUpdateActionType, resourceGroupName) + req, err := client.ReactivatePreparer(ctx, alertName) if err != nil { - err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateResourceGroupLevelAlertState", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "security.AlertsClient", "Reactivate", nil, "Failure preparing request") return } - resp, err := client.UpdateResourceGroupLevelAlertStateSender(req) + resp, err := client.ReactivateSender(req) if err != nil { result.Response = resp - err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateResourceGroupLevelAlertState", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "security.AlertsClient", "Reactivate", resp, "Failure sending request") return } - result, err = client.UpdateResourceGroupLevelAlertStateResponder(resp) + result, err = client.ReactivateResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateResourceGroupLevelAlertState", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "security.AlertsClient", "Reactivate", resp, "Failure responding to request") } return } -// UpdateResourceGroupLevelAlertStatePreparer prepares the UpdateResourceGroupLevelAlertState request. -func (client AlertsClient) UpdateResourceGroupLevelAlertStatePreparer(ctx context.Context, alertName string, alertUpdateActionType string, resourceGroupName string) (*http.Request, error) { +// ReactivatePreparer prepares the Reactivate request. +func (client AlertsClient) ReactivatePreparer(ctx context.Context, alertName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "alertName": autorest.Encode("path", alertName), - "alertUpdateActionType": autorest.Encode("path", alertUpdateActionType), - "ascLocation": autorest.Encode("path", client.AscLocation), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "alertName": autorest.Encode("path", alertName), + "ascLocation": autorest.Encode("path", client.AscLocation), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } const APIVersion = "2019-01-01" @@ -812,21 +972,21 @@ func (client AlertsClient) UpdateResourceGroupLevelAlertStatePreparer(ctx contex preparer := autorest.CreatePreparer( autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/{alertUpdateActionType}", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/reactivate", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) } -// UpdateResourceGroupLevelAlertStateSender sends the UpdateResourceGroupLevelAlertState request. The method will close the +// ReactivateSender sends the Reactivate request. The method will close the // http.Response Body if it receives an error. -func (client AlertsClient) UpdateResourceGroupLevelAlertStateSender(req *http.Request) (*http.Response, error) { +func (client AlertsClient) ReactivateSender(req *http.Request) (*http.Response, error) { sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) return autorest.SendWithSender(client, req, sd...) } -// UpdateResourceGroupLevelAlertStateResponder handles the response to the UpdateResourceGroupLevelAlertState request. The method always +// ReactivateResponder handles the response to the Reactivate request. The method always // closes the http.Response Body. -func (client AlertsClient) UpdateResourceGroupLevelAlertStateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client AlertsClient) ReactivateResponder(resp *http.Response) (result autorest.Response, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -836,13 +996,14 @@ func (client AlertsClient) UpdateResourceGroupLevelAlertStateResponder(resp *htt return } -// UpdateSubscriptionLevelAlertState update the alert's state +// Reactivate1 update the alert's state // Parameters: // alertName - name of the alert object -// alertUpdateActionType - type of the action to do on the alert -func (client AlertsClient) UpdateSubscriptionLevelAlertState(ctx context.Context, alertName string, alertUpdateActionType string) (result autorest.Response, err error) { +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +func (client AlertsClient) Reactivate1(ctx context.Context, alertName string, resourceGroupName string) (result autorest.Response, err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.UpdateSubscriptionLevelAlertState") + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.Reactivate1") defer func() { sc := -1 if result.Response != nil { @@ -853,38 +1014,42 @@ func (client AlertsClient) UpdateSubscriptionLevelAlertState(ctx context.Context } if err := validation.Validate([]validation.Validation{ {TargetValue: client.SubscriptionID, - 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 { - return result, validation.NewError("security.AlertsClient", "UpdateSubscriptionLevelAlertState", err.Error()) + 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}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.AlertsClient", "Reactivate1", err.Error()) } - req, err := client.UpdateSubscriptionLevelAlertStatePreparer(ctx, alertName, alertUpdateActionType) + req, err := client.Reactivate1Preparer(ctx, alertName, resourceGroupName) if err != nil { - err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateSubscriptionLevelAlertState", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "security.AlertsClient", "Reactivate1", nil, "Failure preparing request") return } - resp, err := client.UpdateSubscriptionLevelAlertStateSender(req) + resp, err := client.Reactivate1Sender(req) if err != nil { result.Response = resp - err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateSubscriptionLevelAlertState", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "security.AlertsClient", "Reactivate1", resp, "Failure sending request") return } - result, err = client.UpdateSubscriptionLevelAlertStateResponder(resp) + result, err = client.Reactivate1Responder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateSubscriptionLevelAlertState", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "security.AlertsClient", "Reactivate1", resp, "Failure responding to request") } return } -// UpdateSubscriptionLevelAlertStatePreparer prepares the UpdateSubscriptionLevelAlertState request. -func (client AlertsClient) UpdateSubscriptionLevelAlertStatePreparer(ctx context.Context, alertName string, alertUpdateActionType string) (*http.Request, error) { +// Reactivate1Preparer prepares the Reactivate1 request. +func (client AlertsClient) Reactivate1Preparer(ctx context.Context, alertName string, resourceGroupName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "alertName": autorest.Encode("path", alertName), - "alertUpdateActionType": autorest.Encode("path", alertUpdateActionType), - "ascLocation": autorest.Encode("path", client.AscLocation), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "alertName": autorest.Encode("path", alertName), + "ascLocation": autorest.Encode("path", client.AscLocation), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } const APIVersion = "2019-01-01" @@ -895,21 +1060,21 @@ func (client AlertsClient) UpdateSubscriptionLevelAlertStatePreparer(ctx context preparer := autorest.CreatePreparer( autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/{alertUpdateActionType}", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/reactivate", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) } -// UpdateSubscriptionLevelAlertStateSender sends the UpdateSubscriptionLevelAlertState request. The method will close the +// Reactivate1Sender sends the Reactivate1 request. The method will close the // http.Response Body if it receives an error. -func (client AlertsClient) UpdateSubscriptionLevelAlertStateSender(req *http.Request) (*http.Response, error) { +func (client AlertsClient) Reactivate1Sender(req *http.Request) (*http.Response, error) { sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) return autorest.SendWithSender(client, req, sd...) } -// UpdateSubscriptionLevelAlertStateResponder handles the response to the UpdateSubscriptionLevelAlertState request. The method always +// Reactivate1Responder handles the response to the Reactivate1 request. The method always // closes the http.Response Body. -func (client AlertsClient) UpdateSubscriptionLevelAlertStateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client AlertsClient) Reactivate1Responder(resp *http.Response) (result autorest.Response, err error) { err = autorest.Respond( resp, client.ByInspecting(), diff --git a/services/preview/security/mgmt/v3.0/security/securityapi/interfaces.go b/services/preview/security/mgmt/v3.0/security/securityapi/interfaces.go index 3b70713dc7cb..e42c438d526a 100644 --- a/services/preview/security/mgmt/v3.0/security/securityapi/interfaces.go +++ b/services/preview/security/mgmt/v3.0/security/securityapi/interfaces.go @@ -42,14 +42,16 @@ var _ PricingsClientAPI = (*security.PricingsClient)(nil) // AlertsClientAPI contains the set of methods on the AlertsClient type. type AlertsClientAPI interface { + Dismiss(ctx context.Context, alertName string) (result autorest.Response, err error) + Dismiss1(ctx context.Context, alertName string, resourceGroupName string) (result autorest.Response, err error) GetResourceGroupLevelAlerts(ctx context.Context, alertName string, resourceGroupName string) (result security.Alert, err error) GetSubscriptionLevelAlert(ctx context.Context, alertName string) (result security.Alert, err error) List(ctx context.Context, filter string, selectParameter string, expand string) (result security.AlertListPage, err error) ListByResourceGroup(ctx context.Context, resourceGroupName string, filter string, selectParameter string, expand string) (result security.AlertListPage, err error) ListResourceGroupLevelAlertsByRegion(ctx context.Context, resourceGroupName string, filter string, selectParameter string, expand string) (result security.AlertListPage, err error) ListSubscriptionLevelAlertsByRegion(ctx context.Context, filter string, selectParameter string, expand string) (result security.AlertListPage, err error) - UpdateResourceGroupLevelAlertState(ctx context.Context, alertName string, alertUpdateActionType string, resourceGroupName string) (result autorest.Response, err error) - UpdateSubscriptionLevelAlertState(ctx context.Context, alertName string, alertUpdateActionType string) (result autorest.Response, err error) + Reactivate(ctx context.Context, alertName string) (result autorest.Response, err error) + Reactivate1(ctx context.Context, alertName string, resourceGroupName string) (result autorest.Response, err error) } var _ AlertsClientAPI = (*security.AlertsClient)(nil) From 83c5bde7954b27b2ac2b6cadbfadf71ae3a5f220 Mon Sep 17 00:00:00 2001 From: Azure SDK Bot Date: Sun, 10 Nov 2019 12:41:58 +0000 Subject: [PATCH 2/2] Generated from e6e7573b8f17ee08d9ecc68eeaa525f51172f720 Merge pull request #3 from yibirnba2/swaggerCompletenessIssue Change operationId --- .../security/mgmt/v1.0/security/alerts.go | 412 +++++++++--------- .../v1.0/security/securityapi/interfaces.go | 8 +- .../security/mgmt/v2.0/security/alerts.go | 412 +++++++++--------- .../v2.0/security/securityapi/interfaces.go | 8 +- .../security/mgmt/v3.0/security/alerts.go | 412 +++++++++--------- .../v3.0/security/securityapi/interfaces.go | 8 +- 6 files changed, 630 insertions(+), 630 deletions(-) diff --git a/services/preview/security/mgmt/v1.0/security/alerts.go b/services/preview/security/mgmt/v1.0/security/alerts.go index 1a29f482d751..5934b920847d 100644 --- a/services/preview/security/mgmt/v1.0/security/alerts.go +++ b/services/preview/security/mgmt/v1.0/security/alerts.go @@ -41,175 +41,6 @@ func NewAlertsClientWithBaseURI(baseURI string, subscriptionID string, ascLocati return AlertsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} } -// Dismiss update the alert's state -// Parameters: -// alertName - name of the alert object -func (client AlertsClient) Dismiss(ctx context.Context, alertName string) (result autorest.Response, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.Dismiss") - defer func() { - sc := -1 - if result.Response != nil { - sc = result.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - 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 { - return result, validation.NewError("security.AlertsClient", "Dismiss", err.Error()) - } - - req, err := client.DismissPreparer(ctx, alertName) - if err != nil { - err = autorest.NewErrorWithError(err, "security.AlertsClient", "Dismiss", nil, "Failure preparing request") - return - } - - resp, err := client.DismissSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "security.AlertsClient", "Dismiss", resp, "Failure sending request") - return - } - - result, err = client.DismissResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "security.AlertsClient", "Dismiss", resp, "Failure responding to request") - } - - return -} - -// DismissPreparer prepares the Dismiss request. -func (client AlertsClient) DismissPreparer(ctx context.Context, alertName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "alertName": autorest.Encode("path", alertName), - "ascLocation": autorest.Encode("path", client.AscLocation), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2015-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/dismiss", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DismissSender sends the Dismiss request. The method will close the -// http.Response Body if it receives an error. -func (client AlertsClient) DismissSender(req *http.Request) (*http.Response, error) { - sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) - return autorest.SendWithSender(client, req, sd...) -} - -// DismissResponder handles the response to the Dismiss request. The method always -// closes the http.Response Body. -func (client AlertsClient) DismissResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// Dismiss1 update the alert's state -// Parameters: -// alertName - name of the alert object -// resourceGroupName - the name of the resource group within the user's subscription. The name is case -// insensitive. -func (client AlertsClient) Dismiss1(ctx context.Context, alertName string, resourceGroupName string) (result autorest.Response, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.Dismiss1") - defer func() { - sc := -1 - if result.Response != nil { - sc = result.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - 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}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("security.AlertsClient", "Dismiss1", err.Error()) - } - - req, err := client.Dismiss1Preparer(ctx, alertName, resourceGroupName) - if err != nil { - err = autorest.NewErrorWithError(err, "security.AlertsClient", "Dismiss1", nil, "Failure preparing request") - return - } - - resp, err := client.Dismiss1Sender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "security.AlertsClient", "Dismiss1", resp, "Failure sending request") - return - } - - result, err = client.Dismiss1Responder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "security.AlertsClient", "Dismiss1", resp, "Failure responding to request") - } - - return -} - -// Dismiss1Preparer prepares the Dismiss1 request. -func (client AlertsClient) Dismiss1Preparer(ctx context.Context, alertName string, resourceGroupName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "alertName": autorest.Encode("path", alertName), - "ascLocation": autorest.Encode("path", client.AscLocation), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2015-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/dismiss", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// Dismiss1Sender sends the Dismiss1 request. The method will close the -// http.Response Body if it receives an error. -func (client AlertsClient) Dismiss1Sender(req *http.Request) (*http.Response, error) { - sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) - return autorest.SendWithSender(client, req, sd...) -} - -// Dismiss1Responder handles the response to the Dismiss1 request. The method always -// closes the http.Response Body. -func (client AlertsClient) Dismiss1Responder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - // GetResourceGroupLevelAlerts get an alert that is associated a resource group or a resource in a resource group // Parameters: // alertName - name of the alert object @@ -915,12 +746,14 @@ func (client AlertsClient) ListSubscriptionLevelAlertsByRegionComplete(ctx conte return } -// Reactivate update the alert's state +// UpdateResourceGroupLevelAlertStateToDismiss update the alert's state // Parameters: // alertName - name of the alert object -func (client AlertsClient) Reactivate(ctx context.Context, alertName string) (result autorest.Response, err error) { +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +func (client AlertsClient) UpdateResourceGroupLevelAlertStateToDismiss(ctx context.Context, alertName string, resourceGroupName string) (result autorest.Response, err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.Reactivate") + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.UpdateResourceGroupLevelAlertStateToDismiss") defer func() { sc := -1 if result.Response != nil { @@ -931,37 +764,42 @@ func (client AlertsClient) Reactivate(ctx context.Context, alertName string) (re } if err := validation.Validate([]validation.Validation{ {TargetValue: client.SubscriptionID, - 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 { - return result, validation.NewError("security.AlertsClient", "Reactivate", err.Error()) + 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}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.AlertsClient", "UpdateResourceGroupLevelAlertStateToDismiss", err.Error()) } - req, err := client.ReactivatePreparer(ctx, alertName) + req, err := client.UpdateResourceGroupLevelAlertStateToDismissPreparer(ctx, alertName, resourceGroupName) if err != nil { - err = autorest.NewErrorWithError(err, "security.AlertsClient", "Reactivate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateResourceGroupLevelAlertStateToDismiss", nil, "Failure preparing request") return } - resp, err := client.ReactivateSender(req) + resp, err := client.UpdateResourceGroupLevelAlertStateToDismissSender(req) if err != nil { result.Response = resp - err = autorest.NewErrorWithError(err, "security.AlertsClient", "Reactivate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateResourceGroupLevelAlertStateToDismiss", resp, "Failure sending request") return } - result, err = client.ReactivateResponder(resp) + result, err = client.UpdateResourceGroupLevelAlertStateToDismissResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "security.AlertsClient", "Reactivate", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateResourceGroupLevelAlertStateToDismiss", resp, "Failure responding to request") } return } -// ReactivatePreparer prepares the Reactivate request. -func (client AlertsClient) ReactivatePreparer(ctx context.Context, alertName string) (*http.Request, error) { +// UpdateResourceGroupLevelAlertStateToDismissPreparer prepares the UpdateResourceGroupLevelAlertStateToDismiss request. +func (client AlertsClient) UpdateResourceGroupLevelAlertStateToDismissPreparer(ctx context.Context, alertName string, resourceGroupName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "alertName": autorest.Encode("path", alertName), - "ascLocation": autorest.Encode("path", client.AscLocation), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "alertName": autorest.Encode("path", alertName), + "ascLocation": autorest.Encode("path", client.AscLocation), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } const APIVersion = "2015-06-01-preview" @@ -972,21 +810,21 @@ func (client AlertsClient) ReactivatePreparer(ctx context.Context, alertName str preparer := autorest.CreatePreparer( autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/reactivate", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/dismiss", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) } -// ReactivateSender sends the Reactivate request. The method will close the +// UpdateResourceGroupLevelAlertStateToDismissSender sends the UpdateResourceGroupLevelAlertStateToDismiss request. The method will close the // http.Response Body if it receives an error. -func (client AlertsClient) ReactivateSender(req *http.Request) (*http.Response, error) { +func (client AlertsClient) UpdateResourceGroupLevelAlertStateToDismissSender(req *http.Request) (*http.Response, error) { sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) return autorest.SendWithSender(client, req, sd...) } -// ReactivateResponder handles the response to the Reactivate request. The method always +// UpdateResourceGroupLevelAlertStateToDismissResponder handles the response to the UpdateResourceGroupLevelAlertStateToDismiss request. The method always // closes the http.Response Body. -func (client AlertsClient) ReactivateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client AlertsClient) UpdateResourceGroupLevelAlertStateToDismissResponder(resp *http.Response) (result autorest.Response, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -996,14 +834,14 @@ func (client AlertsClient) ReactivateResponder(resp *http.Response) (result auto return } -// Reactivate1 update the alert's state +// UpdateResourceGroupLevelAlertStateToReactivate update the alert's state // Parameters: // alertName - name of the alert object // resourceGroupName - the name of the resource group within the user's subscription. The name is case // insensitive. -func (client AlertsClient) Reactivate1(ctx context.Context, alertName string, resourceGroupName string) (result autorest.Response, err error) { +func (client AlertsClient) UpdateResourceGroupLevelAlertStateToReactivate(ctx context.Context, alertName string, resourceGroupName string) (result autorest.Response, err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.Reactivate1") + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.UpdateResourceGroupLevelAlertStateToReactivate") defer func() { sc := -1 if result.Response != nil { @@ -1019,32 +857,32 @@ func (client AlertsClient) Reactivate1(ctx context.Context, alertName string, re Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("security.AlertsClient", "Reactivate1", err.Error()) + return result, validation.NewError("security.AlertsClient", "UpdateResourceGroupLevelAlertStateToReactivate", err.Error()) } - req, err := client.Reactivate1Preparer(ctx, alertName, resourceGroupName) + req, err := client.UpdateResourceGroupLevelAlertStateToReactivatePreparer(ctx, alertName, resourceGroupName) if err != nil { - err = autorest.NewErrorWithError(err, "security.AlertsClient", "Reactivate1", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateResourceGroupLevelAlertStateToReactivate", nil, "Failure preparing request") return } - resp, err := client.Reactivate1Sender(req) + resp, err := client.UpdateResourceGroupLevelAlertStateToReactivateSender(req) if err != nil { result.Response = resp - err = autorest.NewErrorWithError(err, "security.AlertsClient", "Reactivate1", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateResourceGroupLevelAlertStateToReactivate", resp, "Failure sending request") return } - result, err = client.Reactivate1Responder(resp) + result, err = client.UpdateResourceGroupLevelAlertStateToReactivateResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "security.AlertsClient", "Reactivate1", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateResourceGroupLevelAlertStateToReactivate", resp, "Failure responding to request") } return } -// Reactivate1Preparer prepares the Reactivate1 request. -func (client AlertsClient) Reactivate1Preparer(ctx context.Context, alertName string, resourceGroupName string) (*http.Request, error) { +// UpdateResourceGroupLevelAlertStateToReactivatePreparer prepares the UpdateResourceGroupLevelAlertStateToReactivate request. +func (client AlertsClient) UpdateResourceGroupLevelAlertStateToReactivatePreparer(ctx context.Context, alertName string, resourceGroupName string) (*http.Request, error) { pathParameters := map[string]interface{}{ "alertName": autorest.Encode("path", alertName), "ascLocation": autorest.Encode("path", client.AscLocation), @@ -1065,16 +903,178 @@ func (client AlertsClient) Reactivate1Preparer(ctx context.Context, alertName st return preparer.Prepare((&http.Request{}).WithContext(ctx)) } -// Reactivate1Sender sends the Reactivate1 request. The method will close the +// UpdateResourceGroupLevelAlertStateToReactivateSender sends the UpdateResourceGroupLevelAlertStateToReactivate request. The method will close the +// http.Response Body if it receives an error. +func (client AlertsClient) UpdateResourceGroupLevelAlertStateToReactivateSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// UpdateResourceGroupLevelAlertStateToReactivateResponder handles the response to the UpdateResourceGroupLevelAlertStateToReactivate request. The method always +// closes the http.Response Body. +func (client AlertsClient) UpdateResourceGroupLevelAlertStateToReactivateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// UpdateSubscriptionLevelAlertStateToDismiss update the alert's state +// Parameters: +// alertName - name of the alert object +func (client AlertsClient) UpdateSubscriptionLevelAlertStateToDismiss(ctx context.Context, alertName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.UpdateSubscriptionLevelAlertStateToDismiss") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + 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 { + return result, validation.NewError("security.AlertsClient", "UpdateSubscriptionLevelAlertStateToDismiss", err.Error()) + } + + req, err := client.UpdateSubscriptionLevelAlertStateToDismissPreparer(ctx, alertName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateSubscriptionLevelAlertStateToDismiss", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSubscriptionLevelAlertStateToDismissSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateSubscriptionLevelAlertStateToDismiss", resp, "Failure sending request") + return + } + + result, err = client.UpdateSubscriptionLevelAlertStateToDismissResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateSubscriptionLevelAlertStateToDismiss", resp, "Failure responding to request") + } + + return +} + +// UpdateSubscriptionLevelAlertStateToDismissPreparer prepares the UpdateSubscriptionLevelAlertStateToDismiss request. +func (client AlertsClient) UpdateSubscriptionLevelAlertStateToDismissPreparer(ctx context.Context, alertName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "alertName": autorest.Encode("path", alertName), + "ascLocation": autorest.Encode("path", client.AscLocation), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/dismiss", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSubscriptionLevelAlertStateToDismissSender sends the UpdateSubscriptionLevelAlertStateToDismiss request. The method will close the +// http.Response Body if it receives an error. +func (client AlertsClient) UpdateSubscriptionLevelAlertStateToDismissSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// UpdateSubscriptionLevelAlertStateToDismissResponder handles the response to the UpdateSubscriptionLevelAlertStateToDismiss request. The method always +// closes the http.Response Body. +func (client AlertsClient) UpdateSubscriptionLevelAlertStateToDismissResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// UpdateSubscriptionLevelAlertStateToReactivate update the alert's state +// Parameters: +// alertName - name of the alert object +func (client AlertsClient) UpdateSubscriptionLevelAlertStateToReactivate(ctx context.Context, alertName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.UpdateSubscriptionLevelAlertStateToReactivate") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + 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 { + return result, validation.NewError("security.AlertsClient", "UpdateSubscriptionLevelAlertStateToReactivate", err.Error()) + } + + req, err := client.UpdateSubscriptionLevelAlertStateToReactivatePreparer(ctx, alertName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateSubscriptionLevelAlertStateToReactivate", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSubscriptionLevelAlertStateToReactivateSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateSubscriptionLevelAlertStateToReactivate", resp, "Failure sending request") + return + } + + result, err = client.UpdateSubscriptionLevelAlertStateToReactivateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateSubscriptionLevelAlertStateToReactivate", resp, "Failure responding to request") + } + + return +} + +// UpdateSubscriptionLevelAlertStateToReactivatePreparer prepares the UpdateSubscriptionLevelAlertStateToReactivate request. +func (client AlertsClient) UpdateSubscriptionLevelAlertStateToReactivatePreparer(ctx context.Context, alertName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "alertName": autorest.Encode("path", alertName), + "ascLocation": autorest.Encode("path", client.AscLocation), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/reactivate", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSubscriptionLevelAlertStateToReactivateSender sends the UpdateSubscriptionLevelAlertStateToReactivate request. The method will close the // http.Response Body if it receives an error. -func (client AlertsClient) Reactivate1Sender(req *http.Request) (*http.Response, error) { +func (client AlertsClient) UpdateSubscriptionLevelAlertStateToReactivateSender(req *http.Request) (*http.Response, error) { sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) return autorest.SendWithSender(client, req, sd...) } -// Reactivate1Responder handles the response to the Reactivate1 request. The method always +// UpdateSubscriptionLevelAlertStateToReactivateResponder handles the response to the UpdateSubscriptionLevelAlertStateToReactivate request. The method always // closes the http.Response Body. -func (client AlertsClient) Reactivate1Responder(resp *http.Response) (result autorest.Response, err error) { +func (client AlertsClient) UpdateSubscriptionLevelAlertStateToReactivateResponder(resp *http.Response) (result autorest.Response, err error) { err = autorest.Respond( resp, client.ByInspecting(), diff --git a/services/preview/security/mgmt/v1.0/security/securityapi/interfaces.go b/services/preview/security/mgmt/v1.0/security/securityapi/interfaces.go index e2f6893b11b3..f5068b92147a 100644 --- a/services/preview/security/mgmt/v1.0/security/securityapi/interfaces.go +++ b/services/preview/security/mgmt/v1.0/security/securityapi/interfaces.go @@ -173,16 +173,16 @@ var _ TasksClientAPI = (*security.TasksClient)(nil) // AlertsClientAPI contains the set of methods on the AlertsClient type. type AlertsClientAPI interface { - Dismiss(ctx context.Context, alertName string) (result autorest.Response, err error) - Dismiss1(ctx context.Context, alertName string, resourceGroupName string) (result autorest.Response, err error) GetResourceGroupLevelAlerts(ctx context.Context, alertName string, resourceGroupName string) (result security.Alert, err error) GetSubscriptionLevelAlert(ctx context.Context, alertName string) (result security.Alert, err error) List(ctx context.Context, filter string, selectParameter string, expand string) (result security.AlertListPage, err error) ListByResourceGroup(ctx context.Context, resourceGroupName string, filter string, selectParameter string, expand string) (result security.AlertListPage, err error) ListResourceGroupLevelAlertsByRegion(ctx context.Context, resourceGroupName string, filter string, selectParameter string, expand string) (result security.AlertListPage, err error) ListSubscriptionLevelAlertsByRegion(ctx context.Context, filter string, selectParameter string, expand string) (result security.AlertListPage, err error) - Reactivate(ctx context.Context, alertName string) (result autorest.Response, err error) - Reactivate1(ctx context.Context, alertName string, resourceGroupName string) (result autorest.Response, err error) + UpdateResourceGroupLevelAlertStateToDismiss(ctx context.Context, alertName string, resourceGroupName string) (result autorest.Response, err error) + UpdateResourceGroupLevelAlertStateToReactivate(ctx context.Context, alertName string, resourceGroupName string) (result autorest.Response, err error) + UpdateSubscriptionLevelAlertStateToDismiss(ctx context.Context, alertName string) (result autorest.Response, err error) + UpdateSubscriptionLevelAlertStateToReactivate(ctx context.Context, alertName string) (result autorest.Response, err error) } var _ AlertsClientAPI = (*security.AlertsClient)(nil) diff --git a/services/preview/security/mgmt/v2.0/security/alerts.go b/services/preview/security/mgmt/v2.0/security/alerts.go index cfeefed86b3b..c7f9d8aab297 100644 --- a/services/preview/security/mgmt/v2.0/security/alerts.go +++ b/services/preview/security/mgmt/v2.0/security/alerts.go @@ -41,175 +41,6 @@ func NewAlertsClientWithBaseURI(baseURI string, subscriptionID string, ascLocati return AlertsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} } -// Dismiss update the alert's state -// Parameters: -// alertName - name of the alert object -func (client AlertsClient) Dismiss(ctx context.Context, alertName string) (result autorest.Response, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.Dismiss") - defer func() { - sc := -1 - if result.Response != nil { - sc = result.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - 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 { - return result, validation.NewError("security.AlertsClient", "Dismiss", err.Error()) - } - - req, err := client.DismissPreparer(ctx, alertName) - if err != nil { - err = autorest.NewErrorWithError(err, "security.AlertsClient", "Dismiss", nil, "Failure preparing request") - return - } - - resp, err := client.DismissSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "security.AlertsClient", "Dismiss", resp, "Failure sending request") - return - } - - result, err = client.DismissResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "security.AlertsClient", "Dismiss", resp, "Failure responding to request") - } - - return -} - -// DismissPreparer prepares the Dismiss request. -func (client AlertsClient) DismissPreparer(ctx context.Context, alertName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "alertName": autorest.Encode("path", alertName), - "ascLocation": autorest.Encode("path", client.AscLocation), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2019-01-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/dismiss", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DismissSender sends the Dismiss request. The method will close the -// http.Response Body if it receives an error. -func (client AlertsClient) DismissSender(req *http.Request) (*http.Response, error) { - sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) - return autorest.SendWithSender(client, req, sd...) -} - -// DismissResponder handles the response to the Dismiss request. The method always -// closes the http.Response Body. -func (client AlertsClient) DismissResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// Dismiss1 update the alert's state -// Parameters: -// alertName - name of the alert object -// resourceGroupName - the name of the resource group within the user's subscription. The name is case -// insensitive. -func (client AlertsClient) Dismiss1(ctx context.Context, alertName string, resourceGroupName string) (result autorest.Response, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.Dismiss1") - defer func() { - sc := -1 - if result.Response != nil { - sc = result.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - 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}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("security.AlertsClient", "Dismiss1", err.Error()) - } - - req, err := client.Dismiss1Preparer(ctx, alertName, resourceGroupName) - if err != nil { - err = autorest.NewErrorWithError(err, "security.AlertsClient", "Dismiss1", nil, "Failure preparing request") - return - } - - resp, err := client.Dismiss1Sender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "security.AlertsClient", "Dismiss1", resp, "Failure sending request") - return - } - - result, err = client.Dismiss1Responder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "security.AlertsClient", "Dismiss1", resp, "Failure responding to request") - } - - return -} - -// Dismiss1Preparer prepares the Dismiss1 request. -func (client AlertsClient) Dismiss1Preparer(ctx context.Context, alertName string, resourceGroupName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "alertName": autorest.Encode("path", alertName), - "ascLocation": autorest.Encode("path", client.AscLocation), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2019-01-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/dismiss", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// Dismiss1Sender sends the Dismiss1 request. The method will close the -// http.Response Body if it receives an error. -func (client AlertsClient) Dismiss1Sender(req *http.Request) (*http.Response, error) { - sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) - return autorest.SendWithSender(client, req, sd...) -} - -// Dismiss1Responder handles the response to the Dismiss1 request. The method always -// closes the http.Response Body. -func (client AlertsClient) Dismiss1Responder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - // GetResourceGroupLevelAlerts get an alert that is associated a resource group or a resource in a resource group // Parameters: // alertName - name of the alert object @@ -915,12 +746,14 @@ func (client AlertsClient) ListSubscriptionLevelAlertsByRegionComplete(ctx conte return } -// Reactivate update the alert's state +// UpdateResourceGroupLevelAlertStateToDismiss update the alert's state // Parameters: // alertName - name of the alert object -func (client AlertsClient) Reactivate(ctx context.Context, alertName string) (result autorest.Response, err error) { +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +func (client AlertsClient) UpdateResourceGroupLevelAlertStateToDismiss(ctx context.Context, alertName string, resourceGroupName string) (result autorest.Response, err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.Reactivate") + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.UpdateResourceGroupLevelAlertStateToDismiss") defer func() { sc := -1 if result.Response != nil { @@ -931,37 +764,42 @@ func (client AlertsClient) Reactivate(ctx context.Context, alertName string) (re } if err := validation.Validate([]validation.Validation{ {TargetValue: client.SubscriptionID, - 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 { - return result, validation.NewError("security.AlertsClient", "Reactivate", err.Error()) + 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}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.AlertsClient", "UpdateResourceGroupLevelAlertStateToDismiss", err.Error()) } - req, err := client.ReactivatePreparer(ctx, alertName) + req, err := client.UpdateResourceGroupLevelAlertStateToDismissPreparer(ctx, alertName, resourceGroupName) if err != nil { - err = autorest.NewErrorWithError(err, "security.AlertsClient", "Reactivate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateResourceGroupLevelAlertStateToDismiss", nil, "Failure preparing request") return } - resp, err := client.ReactivateSender(req) + resp, err := client.UpdateResourceGroupLevelAlertStateToDismissSender(req) if err != nil { result.Response = resp - err = autorest.NewErrorWithError(err, "security.AlertsClient", "Reactivate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateResourceGroupLevelAlertStateToDismiss", resp, "Failure sending request") return } - result, err = client.ReactivateResponder(resp) + result, err = client.UpdateResourceGroupLevelAlertStateToDismissResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "security.AlertsClient", "Reactivate", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateResourceGroupLevelAlertStateToDismiss", resp, "Failure responding to request") } return } -// ReactivatePreparer prepares the Reactivate request. -func (client AlertsClient) ReactivatePreparer(ctx context.Context, alertName string) (*http.Request, error) { +// UpdateResourceGroupLevelAlertStateToDismissPreparer prepares the UpdateResourceGroupLevelAlertStateToDismiss request. +func (client AlertsClient) UpdateResourceGroupLevelAlertStateToDismissPreparer(ctx context.Context, alertName string, resourceGroupName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "alertName": autorest.Encode("path", alertName), - "ascLocation": autorest.Encode("path", client.AscLocation), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "alertName": autorest.Encode("path", alertName), + "ascLocation": autorest.Encode("path", client.AscLocation), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } const APIVersion = "2019-01-01" @@ -972,21 +810,21 @@ func (client AlertsClient) ReactivatePreparer(ctx context.Context, alertName str preparer := autorest.CreatePreparer( autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/reactivate", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/dismiss", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) } -// ReactivateSender sends the Reactivate request. The method will close the +// UpdateResourceGroupLevelAlertStateToDismissSender sends the UpdateResourceGroupLevelAlertStateToDismiss request. The method will close the // http.Response Body if it receives an error. -func (client AlertsClient) ReactivateSender(req *http.Request) (*http.Response, error) { +func (client AlertsClient) UpdateResourceGroupLevelAlertStateToDismissSender(req *http.Request) (*http.Response, error) { sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) return autorest.SendWithSender(client, req, sd...) } -// ReactivateResponder handles the response to the Reactivate request. The method always +// UpdateResourceGroupLevelAlertStateToDismissResponder handles the response to the UpdateResourceGroupLevelAlertStateToDismiss request. The method always // closes the http.Response Body. -func (client AlertsClient) ReactivateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client AlertsClient) UpdateResourceGroupLevelAlertStateToDismissResponder(resp *http.Response) (result autorest.Response, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -996,14 +834,14 @@ func (client AlertsClient) ReactivateResponder(resp *http.Response) (result auto return } -// Reactivate1 update the alert's state +// UpdateResourceGroupLevelAlertStateToReactivate update the alert's state // Parameters: // alertName - name of the alert object // resourceGroupName - the name of the resource group within the user's subscription. The name is case // insensitive. -func (client AlertsClient) Reactivate1(ctx context.Context, alertName string, resourceGroupName string) (result autorest.Response, err error) { +func (client AlertsClient) UpdateResourceGroupLevelAlertStateToReactivate(ctx context.Context, alertName string, resourceGroupName string) (result autorest.Response, err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.Reactivate1") + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.UpdateResourceGroupLevelAlertStateToReactivate") defer func() { sc := -1 if result.Response != nil { @@ -1019,32 +857,32 @@ func (client AlertsClient) Reactivate1(ctx context.Context, alertName string, re Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("security.AlertsClient", "Reactivate1", err.Error()) + return result, validation.NewError("security.AlertsClient", "UpdateResourceGroupLevelAlertStateToReactivate", err.Error()) } - req, err := client.Reactivate1Preparer(ctx, alertName, resourceGroupName) + req, err := client.UpdateResourceGroupLevelAlertStateToReactivatePreparer(ctx, alertName, resourceGroupName) if err != nil { - err = autorest.NewErrorWithError(err, "security.AlertsClient", "Reactivate1", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateResourceGroupLevelAlertStateToReactivate", nil, "Failure preparing request") return } - resp, err := client.Reactivate1Sender(req) + resp, err := client.UpdateResourceGroupLevelAlertStateToReactivateSender(req) if err != nil { result.Response = resp - err = autorest.NewErrorWithError(err, "security.AlertsClient", "Reactivate1", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateResourceGroupLevelAlertStateToReactivate", resp, "Failure sending request") return } - result, err = client.Reactivate1Responder(resp) + result, err = client.UpdateResourceGroupLevelAlertStateToReactivateResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "security.AlertsClient", "Reactivate1", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateResourceGroupLevelAlertStateToReactivate", resp, "Failure responding to request") } return } -// Reactivate1Preparer prepares the Reactivate1 request. -func (client AlertsClient) Reactivate1Preparer(ctx context.Context, alertName string, resourceGroupName string) (*http.Request, error) { +// UpdateResourceGroupLevelAlertStateToReactivatePreparer prepares the UpdateResourceGroupLevelAlertStateToReactivate request. +func (client AlertsClient) UpdateResourceGroupLevelAlertStateToReactivatePreparer(ctx context.Context, alertName string, resourceGroupName string) (*http.Request, error) { pathParameters := map[string]interface{}{ "alertName": autorest.Encode("path", alertName), "ascLocation": autorest.Encode("path", client.AscLocation), @@ -1065,16 +903,178 @@ func (client AlertsClient) Reactivate1Preparer(ctx context.Context, alertName st return preparer.Prepare((&http.Request{}).WithContext(ctx)) } -// Reactivate1Sender sends the Reactivate1 request. The method will close the +// UpdateResourceGroupLevelAlertStateToReactivateSender sends the UpdateResourceGroupLevelAlertStateToReactivate request. The method will close the +// http.Response Body if it receives an error. +func (client AlertsClient) UpdateResourceGroupLevelAlertStateToReactivateSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// UpdateResourceGroupLevelAlertStateToReactivateResponder handles the response to the UpdateResourceGroupLevelAlertStateToReactivate request. The method always +// closes the http.Response Body. +func (client AlertsClient) UpdateResourceGroupLevelAlertStateToReactivateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// UpdateSubscriptionLevelAlertStateToDismiss update the alert's state +// Parameters: +// alertName - name of the alert object +func (client AlertsClient) UpdateSubscriptionLevelAlertStateToDismiss(ctx context.Context, alertName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.UpdateSubscriptionLevelAlertStateToDismiss") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + 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 { + return result, validation.NewError("security.AlertsClient", "UpdateSubscriptionLevelAlertStateToDismiss", err.Error()) + } + + req, err := client.UpdateSubscriptionLevelAlertStateToDismissPreparer(ctx, alertName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateSubscriptionLevelAlertStateToDismiss", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSubscriptionLevelAlertStateToDismissSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateSubscriptionLevelAlertStateToDismiss", resp, "Failure sending request") + return + } + + result, err = client.UpdateSubscriptionLevelAlertStateToDismissResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateSubscriptionLevelAlertStateToDismiss", resp, "Failure responding to request") + } + + return +} + +// UpdateSubscriptionLevelAlertStateToDismissPreparer prepares the UpdateSubscriptionLevelAlertStateToDismiss request. +func (client AlertsClient) UpdateSubscriptionLevelAlertStateToDismissPreparer(ctx context.Context, alertName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "alertName": autorest.Encode("path", alertName), + "ascLocation": autorest.Encode("path", client.AscLocation), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/dismiss", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSubscriptionLevelAlertStateToDismissSender sends the UpdateSubscriptionLevelAlertStateToDismiss request. The method will close the +// http.Response Body if it receives an error. +func (client AlertsClient) UpdateSubscriptionLevelAlertStateToDismissSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// UpdateSubscriptionLevelAlertStateToDismissResponder handles the response to the UpdateSubscriptionLevelAlertStateToDismiss request. The method always +// closes the http.Response Body. +func (client AlertsClient) UpdateSubscriptionLevelAlertStateToDismissResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// UpdateSubscriptionLevelAlertStateToReactivate update the alert's state +// Parameters: +// alertName - name of the alert object +func (client AlertsClient) UpdateSubscriptionLevelAlertStateToReactivate(ctx context.Context, alertName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.UpdateSubscriptionLevelAlertStateToReactivate") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + 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 { + return result, validation.NewError("security.AlertsClient", "UpdateSubscriptionLevelAlertStateToReactivate", err.Error()) + } + + req, err := client.UpdateSubscriptionLevelAlertStateToReactivatePreparer(ctx, alertName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateSubscriptionLevelAlertStateToReactivate", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSubscriptionLevelAlertStateToReactivateSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateSubscriptionLevelAlertStateToReactivate", resp, "Failure sending request") + return + } + + result, err = client.UpdateSubscriptionLevelAlertStateToReactivateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateSubscriptionLevelAlertStateToReactivate", resp, "Failure responding to request") + } + + return +} + +// UpdateSubscriptionLevelAlertStateToReactivatePreparer prepares the UpdateSubscriptionLevelAlertStateToReactivate request. +func (client AlertsClient) UpdateSubscriptionLevelAlertStateToReactivatePreparer(ctx context.Context, alertName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "alertName": autorest.Encode("path", alertName), + "ascLocation": autorest.Encode("path", client.AscLocation), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/reactivate", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSubscriptionLevelAlertStateToReactivateSender sends the UpdateSubscriptionLevelAlertStateToReactivate request. The method will close the // http.Response Body if it receives an error. -func (client AlertsClient) Reactivate1Sender(req *http.Request) (*http.Response, error) { +func (client AlertsClient) UpdateSubscriptionLevelAlertStateToReactivateSender(req *http.Request) (*http.Response, error) { sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) return autorest.SendWithSender(client, req, sd...) } -// Reactivate1Responder handles the response to the Reactivate1 request. The method always +// UpdateSubscriptionLevelAlertStateToReactivateResponder handles the response to the UpdateSubscriptionLevelAlertStateToReactivate request. The method always // closes the http.Response Body. -func (client AlertsClient) Reactivate1Responder(resp *http.Response) (result autorest.Response, err error) { +func (client AlertsClient) UpdateSubscriptionLevelAlertStateToReactivateResponder(resp *http.Response) (result autorest.Response, err error) { err = autorest.Respond( resp, client.ByInspecting(), diff --git a/services/preview/security/mgmt/v2.0/security/securityapi/interfaces.go b/services/preview/security/mgmt/v2.0/security/securityapi/interfaces.go index 223083b111b7..d644808b3439 100644 --- a/services/preview/security/mgmt/v2.0/security/securityapi/interfaces.go +++ b/services/preview/security/mgmt/v2.0/security/securityapi/interfaces.go @@ -231,16 +231,16 @@ var _ TasksClientAPI = (*security.TasksClient)(nil) // AlertsClientAPI contains the set of methods on the AlertsClient type. type AlertsClientAPI interface { - Dismiss(ctx context.Context, alertName string) (result autorest.Response, err error) - Dismiss1(ctx context.Context, alertName string, resourceGroupName string) (result autorest.Response, err error) GetResourceGroupLevelAlerts(ctx context.Context, alertName string, resourceGroupName string) (result security.Alert, err error) GetSubscriptionLevelAlert(ctx context.Context, alertName string) (result security.Alert, err error) List(ctx context.Context, filter string, selectParameter string, expand string) (result security.AlertListPage, err error) ListByResourceGroup(ctx context.Context, resourceGroupName string, filter string, selectParameter string, expand string) (result security.AlertListPage, err error) ListResourceGroupLevelAlertsByRegion(ctx context.Context, resourceGroupName string, filter string, selectParameter string, expand string) (result security.AlertListPage, err error) ListSubscriptionLevelAlertsByRegion(ctx context.Context, filter string, selectParameter string, expand string) (result security.AlertListPage, err error) - Reactivate(ctx context.Context, alertName string) (result autorest.Response, err error) - Reactivate1(ctx context.Context, alertName string, resourceGroupName string) (result autorest.Response, err error) + UpdateResourceGroupLevelAlertStateToDismiss(ctx context.Context, alertName string, resourceGroupName string) (result autorest.Response, err error) + UpdateResourceGroupLevelAlertStateToReactivate(ctx context.Context, alertName string, resourceGroupName string) (result autorest.Response, err error) + UpdateSubscriptionLevelAlertStateToDismiss(ctx context.Context, alertName string) (result autorest.Response, err error) + UpdateSubscriptionLevelAlertStateToReactivate(ctx context.Context, alertName string) (result autorest.Response, err error) } var _ AlertsClientAPI = (*security.AlertsClient)(nil) diff --git a/services/preview/security/mgmt/v3.0/security/alerts.go b/services/preview/security/mgmt/v3.0/security/alerts.go index cfeefed86b3b..c7f9d8aab297 100644 --- a/services/preview/security/mgmt/v3.0/security/alerts.go +++ b/services/preview/security/mgmt/v3.0/security/alerts.go @@ -41,175 +41,6 @@ func NewAlertsClientWithBaseURI(baseURI string, subscriptionID string, ascLocati return AlertsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} } -// Dismiss update the alert's state -// Parameters: -// alertName - name of the alert object -func (client AlertsClient) Dismiss(ctx context.Context, alertName string) (result autorest.Response, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.Dismiss") - defer func() { - sc := -1 - if result.Response != nil { - sc = result.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - 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 { - return result, validation.NewError("security.AlertsClient", "Dismiss", err.Error()) - } - - req, err := client.DismissPreparer(ctx, alertName) - if err != nil { - err = autorest.NewErrorWithError(err, "security.AlertsClient", "Dismiss", nil, "Failure preparing request") - return - } - - resp, err := client.DismissSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "security.AlertsClient", "Dismiss", resp, "Failure sending request") - return - } - - result, err = client.DismissResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "security.AlertsClient", "Dismiss", resp, "Failure responding to request") - } - - return -} - -// DismissPreparer prepares the Dismiss request. -func (client AlertsClient) DismissPreparer(ctx context.Context, alertName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "alertName": autorest.Encode("path", alertName), - "ascLocation": autorest.Encode("path", client.AscLocation), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2019-01-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/dismiss", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DismissSender sends the Dismiss request. The method will close the -// http.Response Body if it receives an error. -func (client AlertsClient) DismissSender(req *http.Request) (*http.Response, error) { - sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) - return autorest.SendWithSender(client, req, sd...) -} - -// DismissResponder handles the response to the Dismiss request. The method always -// closes the http.Response Body. -func (client AlertsClient) DismissResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// Dismiss1 update the alert's state -// Parameters: -// alertName - name of the alert object -// resourceGroupName - the name of the resource group within the user's subscription. The name is case -// insensitive. -func (client AlertsClient) Dismiss1(ctx context.Context, alertName string, resourceGroupName string) (result autorest.Response, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.Dismiss1") - defer func() { - sc := -1 - if result.Response != nil { - sc = result.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - 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}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("security.AlertsClient", "Dismiss1", err.Error()) - } - - req, err := client.Dismiss1Preparer(ctx, alertName, resourceGroupName) - if err != nil { - err = autorest.NewErrorWithError(err, "security.AlertsClient", "Dismiss1", nil, "Failure preparing request") - return - } - - resp, err := client.Dismiss1Sender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "security.AlertsClient", "Dismiss1", resp, "Failure sending request") - return - } - - result, err = client.Dismiss1Responder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "security.AlertsClient", "Dismiss1", resp, "Failure responding to request") - } - - return -} - -// Dismiss1Preparer prepares the Dismiss1 request. -func (client AlertsClient) Dismiss1Preparer(ctx context.Context, alertName string, resourceGroupName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "alertName": autorest.Encode("path", alertName), - "ascLocation": autorest.Encode("path", client.AscLocation), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2019-01-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/dismiss", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// Dismiss1Sender sends the Dismiss1 request. The method will close the -// http.Response Body if it receives an error. -func (client AlertsClient) Dismiss1Sender(req *http.Request) (*http.Response, error) { - sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) - return autorest.SendWithSender(client, req, sd...) -} - -// Dismiss1Responder handles the response to the Dismiss1 request. The method always -// closes the http.Response Body. -func (client AlertsClient) Dismiss1Responder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - // GetResourceGroupLevelAlerts get an alert that is associated a resource group or a resource in a resource group // Parameters: // alertName - name of the alert object @@ -915,12 +746,14 @@ func (client AlertsClient) ListSubscriptionLevelAlertsByRegionComplete(ctx conte return } -// Reactivate update the alert's state +// UpdateResourceGroupLevelAlertStateToDismiss update the alert's state // Parameters: // alertName - name of the alert object -func (client AlertsClient) Reactivate(ctx context.Context, alertName string) (result autorest.Response, err error) { +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +func (client AlertsClient) UpdateResourceGroupLevelAlertStateToDismiss(ctx context.Context, alertName string, resourceGroupName string) (result autorest.Response, err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.Reactivate") + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.UpdateResourceGroupLevelAlertStateToDismiss") defer func() { sc := -1 if result.Response != nil { @@ -931,37 +764,42 @@ func (client AlertsClient) Reactivate(ctx context.Context, alertName string) (re } if err := validation.Validate([]validation.Validation{ {TargetValue: client.SubscriptionID, - 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 { - return result, validation.NewError("security.AlertsClient", "Reactivate", err.Error()) + 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}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.AlertsClient", "UpdateResourceGroupLevelAlertStateToDismiss", err.Error()) } - req, err := client.ReactivatePreparer(ctx, alertName) + req, err := client.UpdateResourceGroupLevelAlertStateToDismissPreparer(ctx, alertName, resourceGroupName) if err != nil { - err = autorest.NewErrorWithError(err, "security.AlertsClient", "Reactivate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateResourceGroupLevelAlertStateToDismiss", nil, "Failure preparing request") return } - resp, err := client.ReactivateSender(req) + resp, err := client.UpdateResourceGroupLevelAlertStateToDismissSender(req) if err != nil { result.Response = resp - err = autorest.NewErrorWithError(err, "security.AlertsClient", "Reactivate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateResourceGroupLevelAlertStateToDismiss", resp, "Failure sending request") return } - result, err = client.ReactivateResponder(resp) + result, err = client.UpdateResourceGroupLevelAlertStateToDismissResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "security.AlertsClient", "Reactivate", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateResourceGroupLevelAlertStateToDismiss", resp, "Failure responding to request") } return } -// ReactivatePreparer prepares the Reactivate request. -func (client AlertsClient) ReactivatePreparer(ctx context.Context, alertName string) (*http.Request, error) { +// UpdateResourceGroupLevelAlertStateToDismissPreparer prepares the UpdateResourceGroupLevelAlertStateToDismiss request. +func (client AlertsClient) UpdateResourceGroupLevelAlertStateToDismissPreparer(ctx context.Context, alertName string, resourceGroupName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "alertName": autorest.Encode("path", alertName), - "ascLocation": autorest.Encode("path", client.AscLocation), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "alertName": autorest.Encode("path", alertName), + "ascLocation": autorest.Encode("path", client.AscLocation), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } const APIVersion = "2019-01-01" @@ -972,21 +810,21 @@ func (client AlertsClient) ReactivatePreparer(ctx context.Context, alertName str preparer := autorest.CreatePreparer( autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/reactivate", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/dismiss", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) } -// ReactivateSender sends the Reactivate request. The method will close the +// UpdateResourceGroupLevelAlertStateToDismissSender sends the UpdateResourceGroupLevelAlertStateToDismiss request. The method will close the // http.Response Body if it receives an error. -func (client AlertsClient) ReactivateSender(req *http.Request) (*http.Response, error) { +func (client AlertsClient) UpdateResourceGroupLevelAlertStateToDismissSender(req *http.Request) (*http.Response, error) { sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) return autorest.SendWithSender(client, req, sd...) } -// ReactivateResponder handles the response to the Reactivate request. The method always +// UpdateResourceGroupLevelAlertStateToDismissResponder handles the response to the UpdateResourceGroupLevelAlertStateToDismiss request. The method always // closes the http.Response Body. -func (client AlertsClient) ReactivateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client AlertsClient) UpdateResourceGroupLevelAlertStateToDismissResponder(resp *http.Response) (result autorest.Response, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -996,14 +834,14 @@ func (client AlertsClient) ReactivateResponder(resp *http.Response) (result auto return } -// Reactivate1 update the alert's state +// UpdateResourceGroupLevelAlertStateToReactivate update the alert's state // Parameters: // alertName - name of the alert object // resourceGroupName - the name of the resource group within the user's subscription. The name is case // insensitive. -func (client AlertsClient) Reactivate1(ctx context.Context, alertName string, resourceGroupName string) (result autorest.Response, err error) { +func (client AlertsClient) UpdateResourceGroupLevelAlertStateToReactivate(ctx context.Context, alertName string, resourceGroupName string) (result autorest.Response, err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.Reactivate1") + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.UpdateResourceGroupLevelAlertStateToReactivate") defer func() { sc := -1 if result.Response != nil { @@ -1019,32 +857,32 @@ func (client AlertsClient) Reactivate1(ctx context.Context, alertName string, re Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("security.AlertsClient", "Reactivate1", err.Error()) + return result, validation.NewError("security.AlertsClient", "UpdateResourceGroupLevelAlertStateToReactivate", err.Error()) } - req, err := client.Reactivate1Preparer(ctx, alertName, resourceGroupName) + req, err := client.UpdateResourceGroupLevelAlertStateToReactivatePreparer(ctx, alertName, resourceGroupName) if err != nil { - err = autorest.NewErrorWithError(err, "security.AlertsClient", "Reactivate1", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateResourceGroupLevelAlertStateToReactivate", nil, "Failure preparing request") return } - resp, err := client.Reactivate1Sender(req) + resp, err := client.UpdateResourceGroupLevelAlertStateToReactivateSender(req) if err != nil { result.Response = resp - err = autorest.NewErrorWithError(err, "security.AlertsClient", "Reactivate1", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateResourceGroupLevelAlertStateToReactivate", resp, "Failure sending request") return } - result, err = client.Reactivate1Responder(resp) + result, err = client.UpdateResourceGroupLevelAlertStateToReactivateResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "security.AlertsClient", "Reactivate1", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateResourceGroupLevelAlertStateToReactivate", resp, "Failure responding to request") } return } -// Reactivate1Preparer prepares the Reactivate1 request. -func (client AlertsClient) Reactivate1Preparer(ctx context.Context, alertName string, resourceGroupName string) (*http.Request, error) { +// UpdateResourceGroupLevelAlertStateToReactivatePreparer prepares the UpdateResourceGroupLevelAlertStateToReactivate request. +func (client AlertsClient) UpdateResourceGroupLevelAlertStateToReactivatePreparer(ctx context.Context, alertName string, resourceGroupName string) (*http.Request, error) { pathParameters := map[string]interface{}{ "alertName": autorest.Encode("path", alertName), "ascLocation": autorest.Encode("path", client.AscLocation), @@ -1065,16 +903,178 @@ func (client AlertsClient) Reactivate1Preparer(ctx context.Context, alertName st return preparer.Prepare((&http.Request{}).WithContext(ctx)) } -// Reactivate1Sender sends the Reactivate1 request. The method will close the +// UpdateResourceGroupLevelAlertStateToReactivateSender sends the UpdateResourceGroupLevelAlertStateToReactivate request. The method will close the +// http.Response Body if it receives an error. +func (client AlertsClient) UpdateResourceGroupLevelAlertStateToReactivateSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// UpdateResourceGroupLevelAlertStateToReactivateResponder handles the response to the UpdateResourceGroupLevelAlertStateToReactivate request. The method always +// closes the http.Response Body. +func (client AlertsClient) UpdateResourceGroupLevelAlertStateToReactivateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// UpdateSubscriptionLevelAlertStateToDismiss update the alert's state +// Parameters: +// alertName - name of the alert object +func (client AlertsClient) UpdateSubscriptionLevelAlertStateToDismiss(ctx context.Context, alertName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.UpdateSubscriptionLevelAlertStateToDismiss") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + 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 { + return result, validation.NewError("security.AlertsClient", "UpdateSubscriptionLevelAlertStateToDismiss", err.Error()) + } + + req, err := client.UpdateSubscriptionLevelAlertStateToDismissPreparer(ctx, alertName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateSubscriptionLevelAlertStateToDismiss", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSubscriptionLevelAlertStateToDismissSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateSubscriptionLevelAlertStateToDismiss", resp, "Failure sending request") + return + } + + result, err = client.UpdateSubscriptionLevelAlertStateToDismissResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateSubscriptionLevelAlertStateToDismiss", resp, "Failure responding to request") + } + + return +} + +// UpdateSubscriptionLevelAlertStateToDismissPreparer prepares the UpdateSubscriptionLevelAlertStateToDismiss request. +func (client AlertsClient) UpdateSubscriptionLevelAlertStateToDismissPreparer(ctx context.Context, alertName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "alertName": autorest.Encode("path", alertName), + "ascLocation": autorest.Encode("path", client.AscLocation), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/dismiss", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSubscriptionLevelAlertStateToDismissSender sends the UpdateSubscriptionLevelAlertStateToDismiss request. The method will close the +// http.Response Body if it receives an error. +func (client AlertsClient) UpdateSubscriptionLevelAlertStateToDismissSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// UpdateSubscriptionLevelAlertStateToDismissResponder handles the response to the UpdateSubscriptionLevelAlertStateToDismiss request. The method always +// closes the http.Response Body. +func (client AlertsClient) UpdateSubscriptionLevelAlertStateToDismissResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// UpdateSubscriptionLevelAlertStateToReactivate update the alert's state +// Parameters: +// alertName - name of the alert object +func (client AlertsClient) UpdateSubscriptionLevelAlertStateToReactivate(ctx context.Context, alertName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.UpdateSubscriptionLevelAlertStateToReactivate") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + 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 { + return result, validation.NewError("security.AlertsClient", "UpdateSubscriptionLevelAlertStateToReactivate", err.Error()) + } + + req, err := client.UpdateSubscriptionLevelAlertStateToReactivatePreparer(ctx, alertName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateSubscriptionLevelAlertStateToReactivate", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSubscriptionLevelAlertStateToReactivateSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateSubscriptionLevelAlertStateToReactivate", resp, "Failure sending request") + return + } + + result, err = client.UpdateSubscriptionLevelAlertStateToReactivateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateSubscriptionLevelAlertStateToReactivate", resp, "Failure responding to request") + } + + return +} + +// UpdateSubscriptionLevelAlertStateToReactivatePreparer prepares the UpdateSubscriptionLevelAlertStateToReactivate request. +func (client AlertsClient) UpdateSubscriptionLevelAlertStateToReactivatePreparer(ctx context.Context, alertName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "alertName": autorest.Encode("path", alertName), + "ascLocation": autorest.Encode("path", client.AscLocation), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/reactivate", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSubscriptionLevelAlertStateToReactivateSender sends the UpdateSubscriptionLevelAlertStateToReactivate request. The method will close the // http.Response Body if it receives an error. -func (client AlertsClient) Reactivate1Sender(req *http.Request) (*http.Response, error) { +func (client AlertsClient) UpdateSubscriptionLevelAlertStateToReactivateSender(req *http.Request) (*http.Response, error) { sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) return autorest.SendWithSender(client, req, sd...) } -// Reactivate1Responder handles the response to the Reactivate1 request. The method always +// UpdateSubscriptionLevelAlertStateToReactivateResponder handles the response to the UpdateSubscriptionLevelAlertStateToReactivate request. The method always // closes the http.Response Body. -func (client AlertsClient) Reactivate1Responder(resp *http.Response) (result autorest.Response, err error) { +func (client AlertsClient) UpdateSubscriptionLevelAlertStateToReactivateResponder(resp *http.Response) (result autorest.Response, err error) { err = autorest.Respond( resp, client.ByInspecting(), diff --git a/services/preview/security/mgmt/v3.0/security/securityapi/interfaces.go b/services/preview/security/mgmt/v3.0/security/securityapi/interfaces.go index e42c438d526a..22e5109dcd51 100644 --- a/services/preview/security/mgmt/v3.0/security/securityapi/interfaces.go +++ b/services/preview/security/mgmt/v3.0/security/securityapi/interfaces.go @@ -42,16 +42,16 @@ var _ PricingsClientAPI = (*security.PricingsClient)(nil) // AlertsClientAPI contains the set of methods on the AlertsClient type. type AlertsClientAPI interface { - Dismiss(ctx context.Context, alertName string) (result autorest.Response, err error) - Dismiss1(ctx context.Context, alertName string, resourceGroupName string) (result autorest.Response, err error) GetResourceGroupLevelAlerts(ctx context.Context, alertName string, resourceGroupName string) (result security.Alert, err error) GetSubscriptionLevelAlert(ctx context.Context, alertName string) (result security.Alert, err error) List(ctx context.Context, filter string, selectParameter string, expand string) (result security.AlertListPage, err error) ListByResourceGroup(ctx context.Context, resourceGroupName string, filter string, selectParameter string, expand string) (result security.AlertListPage, err error) ListResourceGroupLevelAlertsByRegion(ctx context.Context, resourceGroupName string, filter string, selectParameter string, expand string) (result security.AlertListPage, err error) ListSubscriptionLevelAlertsByRegion(ctx context.Context, filter string, selectParameter string, expand string) (result security.AlertListPage, err error) - Reactivate(ctx context.Context, alertName string) (result autorest.Response, err error) - Reactivate1(ctx context.Context, alertName string, resourceGroupName string) (result autorest.Response, err error) + UpdateResourceGroupLevelAlertStateToDismiss(ctx context.Context, alertName string, resourceGroupName string) (result autorest.Response, err error) + UpdateResourceGroupLevelAlertStateToReactivate(ctx context.Context, alertName string, resourceGroupName string) (result autorest.Response, err error) + UpdateSubscriptionLevelAlertStateToDismiss(ctx context.Context, alertName string) (result autorest.Response, err error) + UpdateSubscriptionLevelAlertStateToReactivate(ctx context.Context, alertName string) (result autorest.Response, err error) } var _ AlertsClientAPI = (*security.AlertsClient)(nil)