diff --git a/profiles/latest/mysql/mgmt/mysql/models.go b/profiles/latest/mysql/mgmt/mysql/models.go index 88eb9495407b..f87a2d0f3a12 100644 --- a/profiles/latest/mysql/mgmt/mysql/models.go +++ b/profiles/latest/mysql/mgmt/mysql/models.go @@ -57,6 +57,13 @@ const ( User OperationOrigin = original.User ) +type ServerSecurityAlertPolicyState = original.ServerSecurityAlertPolicyState + +const ( + ServerSecurityAlertPolicyStateDisabled ServerSecurityAlertPolicyState = original.ServerSecurityAlertPolicyStateDisabled + ServerSecurityAlertPolicyStateEnabled ServerSecurityAlertPolicyState = original.ServerSecurityAlertPolicyStateEnabled +) + type ServerState = original.ServerState const ( @@ -123,6 +130,7 @@ type PerformanceTierListResult = original.PerformanceTierListResult type PerformanceTierProperties = original.PerformanceTierProperties type PerformanceTierServiceLevelObjectives = original.PerformanceTierServiceLevelObjectives type ProxyResource = original.ProxyResource +type SecurityAlertPolicyProperties = original.SecurityAlertPolicyProperties type Server = original.Server type ServerForCreate = original.ServerForCreate type ServerListResult = original.ServerListResult @@ -134,6 +142,8 @@ type ServerPropertiesForGeoRestore = original.ServerPropertiesForGeoRestore type ServerPropertiesForRestore = original.ServerPropertiesForRestore type ServersCreateFuture = original.ServersCreateFuture type ServersDeleteFuture = original.ServersDeleteFuture +type ServerSecurityAlertPoliciesCreateOrUpdateFuture = original.ServerSecurityAlertPoliciesCreateOrUpdateFuture +type ServerSecurityAlertPolicy = original.ServerSecurityAlertPolicy type ServersUpdateFuture = original.ServersUpdateFuture type ServerUpdateParameters = original.ServerUpdateParameters type ServerUpdateParametersProperties = original.ServerUpdateParametersProperties @@ -149,6 +159,7 @@ type VirtualNetworkRulesCreateOrUpdateFuture = original.VirtualNetworkRulesCreat type VirtualNetworkRulesDeleteFuture = original.VirtualNetworkRulesDeleteFuture type OperationsClient = original.OperationsClient type ServersClient = original.ServersClient +type ServerSecurityAlertPoliciesClient = original.ServerSecurityAlertPoliciesClient type VirtualNetworkRulesClient = original.VirtualNetworkRulesClient func NewCheckNameAvailabilityClient(subscriptionID string) CheckNameAvailabilityClient { @@ -202,6 +213,9 @@ func PossibleGeoRedundantBackupValues() []GeoRedundantBackup { func PossibleOperationOriginValues() []OperationOrigin { return original.PossibleOperationOriginValues() } +func PossibleServerSecurityAlertPolicyStateValues() []ServerSecurityAlertPolicyState { + return original.PossibleServerSecurityAlertPolicyStateValues() +} func PossibleServerStateValues() []ServerState { return original.PossibleServerStateValues() } @@ -229,6 +243,12 @@ func NewServersClient(subscriptionID string) ServersClient { func NewServersClientWithBaseURI(baseURI string, subscriptionID string) ServersClient { return original.NewServersClientWithBaseURI(baseURI, subscriptionID) } +func NewServerSecurityAlertPoliciesClient(subscriptionID string) ServerSecurityAlertPoliciesClient { + return original.NewServerSecurityAlertPoliciesClient(subscriptionID) +} +func NewServerSecurityAlertPoliciesClientWithBaseURI(baseURI string, subscriptionID string) ServerSecurityAlertPoliciesClient { + return original.NewServerSecurityAlertPoliciesClientWithBaseURI(baseURI, subscriptionID) +} func UserAgent() string { return original.UserAgent() + " profiles/latest" } diff --git a/profiles/preview/mysql/mgmt/mysql/models.go b/profiles/preview/mysql/mgmt/mysql/models.go index c54dbb930d5d..f0ec278d9e0f 100644 --- a/profiles/preview/mysql/mgmt/mysql/models.go +++ b/profiles/preview/mysql/mgmt/mysql/models.go @@ -57,6 +57,13 @@ const ( User OperationOrigin = original.User ) +type ServerSecurityAlertPolicyState = original.ServerSecurityAlertPolicyState + +const ( + ServerSecurityAlertPolicyStateDisabled ServerSecurityAlertPolicyState = original.ServerSecurityAlertPolicyStateDisabled + ServerSecurityAlertPolicyStateEnabled ServerSecurityAlertPolicyState = original.ServerSecurityAlertPolicyStateEnabled +) + type ServerState = original.ServerState const ( @@ -123,6 +130,7 @@ type PerformanceTierListResult = original.PerformanceTierListResult type PerformanceTierProperties = original.PerformanceTierProperties type PerformanceTierServiceLevelObjectives = original.PerformanceTierServiceLevelObjectives type ProxyResource = original.ProxyResource +type SecurityAlertPolicyProperties = original.SecurityAlertPolicyProperties type Server = original.Server type ServerForCreate = original.ServerForCreate type ServerListResult = original.ServerListResult @@ -134,6 +142,8 @@ type ServerPropertiesForGeoRestore = original.ServerPropertiesForGeoRestore type ServerPropertiesForRestore = original.ServerPropertiesForRestore type ServersCreateFuture = original.ServersCreateFuture type ServersDeleteFuture = original.ServersDeleteFuture +type ServerSecurityAlertPoliciesCreateOrUpdateFuture = original.ServerSecurityAlertPoliciesCreateOrUpdateFuture +type ServerSecurityAlertPolicy = original.ServerSecurityAlertPolicy type ServersUpdateFuture = original.ServersUpdateFuture type ServerUpdateParameters = original.ServerUpdateParameters type ServerUpdateParametersProperties = original.ServerUpdateParametersProperties @@ -149,6 +159,7 @@ type VirtualNetworkRulesCreateOrUpdateFuture = original.VirtualNetworkRulesCreat type VirtualNetworkRulesDeleteFuture = original.VirtualNetworkRulesDeleteFuture type OperationsClient = original.OperationsClient type ServersClient = original.ServersClient +type ServerSecurityAlertPoliciesClient = original.ServerSecurityAlertPoliciesClient type VirtualNetworkRulesClient = original.VirtualNetworkRulesClient func NewCheckNameAvailabilityClient(subscriptionID string) CheckNameAvailabilityClient { @@ -202,6 +213,9 @@ func PossibleGeoRedundantBackupValues() []GeoRedundantBackup { func PossibleOperationOriginValues() []OperationOrigin { return original.PossibleOperationOriginValues() } +func PossibleServerSecurityAlertPolicyStateValues() []ServerSecurityAlertPolicyState { + return original.PossibleServerSecurityAlertPolicyStateValues() +} func PossibleServerStateValues() []ServerState { return original.PossibleServerStateValues() } @@ -229,6 +243,12 @@ func NewServersClient(subscriptionID string) ServersClient { func NewServersClientWithBaseURI(baseURI string, subscriptionID string) ServersClient { return original.NewServersClientWithBaseURI(baseURI, subscriptionID) } +func NewServerSecurityAlertPoliciesClient(subscriptionID string) ServerSecurityAlertPoliciesClient { + return original.NewServerSecurityAlertPoliciesClient(subscriptionID) +} +func NewServerSecurityAlertPoliciesClientWithBaseURI(baseURI string, subscriptionID string) ServerSecurityAlertPoliciesClient { + return original.NewServerSecurityAlertPoliciesClientWithBaseURI(baseURI, subscriptionID) +} func UserAgent() string { return original.UserAgent() + " profiles/preview" } diff --git a/services/mysql/mgmt/2017-12-01/mysql/models.go b/services/mysql/mgmt/2017-12-01/mysql/models.go index 2511603f4c7e..d646a1b90b73 100644 --- a/services/mysql/mgmt/2017-12-01/mysql/models.go +++ b/services/mysql/mgmt/2017-12-01/mysql/models.go @@ -77,6 +77,21 @@ func PossibleOperationOriginValues() []OperationOrigin { return []OperationOrigin{NotSpecified, System, User} } +// ServerSecurityAlertPolicyState enumerates the values for server security alert policy state. +type ServerSecurityAlertPolicyState string + +const ( + // ServerSecurityAlertPolicyStateDisabled ... + ServerSecurityAlertPolicyStateDisabled ServerSecurityAlertPolicyState = "Disabled" + // ServerSecurityAlertPolicyStateEnabled ... + ServerSecurityAlertPolicyStateEnabled ServerSecurityAlertPolicyState = "Enabled" +) + +// PossibleServerSecurityAlertPolicyStateValues returns an array of possible values for the ServerSecurityAlertPolicyState const type. +func PossibleServerSecurityAlertPolicyStateValues() []ServerSecurityAlertPolicyState { + return []ServerSecurityAlertPolicyState{ServerSecurityAlertPolicyStateDisabled, ServerSecurityAlertPolicyStateEnabled} +} + // ServerState enumerates the values for server state. type ServerState string @@ -807,6 +822,24 @@ type ProxyResource struct { Type *string `json:"type,omitempty"` } +// SecurityAlertPolicyProperties properties of a security alert policy. +type SecurityAlertPolicyProperties struct { + // State - Specifies the state of the policy, whether it is enabled or disabled. Possible values include: 'ServerSecurityAlertPolicyStateEnabled', 'ServerSecurityAlertPolicyStateDisabled' + State ServerSecurityAlertPolicyState `json:"state,omitempty"` + // DisabledAlerts - Specifies an array of alerts that are disabled. Allowed values are: Sql_Injection, Sql_Injection_Vulnerability, Access_Anomaly + DisabledAlerts *[]string `json:"disabledAlerts,omitempty"` + // EmailAddresses - Specifies an array of e-mail addresses to which the alert is sent. + EmailAddresses *[]string `json:"emailAddresses,omitempty"` + // EmailAccountAdmins - Specifies that the alert is sent to the account administrators. + EmailAccountAdmins *bool `json:"emailAccountAdmins,omitempty"` + // StorageEndpoint - Specifies the blob storage endpoint (e.g. https://MyAccount.blob.core.windows.net). This blob storage will hold all Threat Detection audit logs. + StorageEndpoint *string `json:"storageEndpoint,omitempty"` + // StorageAccountAccessKey - Specifies the identifier key of the Threat Detection audit storage account. + StorageAccountAccessKey *string `json:"storageAccountAccessKey,omitempty"` + // RetentionDays - Specifies the number of days to keep in the Threat Detection audit logs. + RetentionDays *int32 `json:"retentionDays,omitempty"` +} + // Server represents a server. type Server struct { autorest.Response `json:"-"` @@ -1387,6 +1420,117 @@ func (future *ServersDeleteFuture) Result(client ServersClient) (ar autorest.Res return } +// ServerSecurityAlertPoliciesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ServerSecurityAlertPoliciesCreateOrUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ServerSecurityAlertPoliciesCreateOrUpdateFuture) Result(client ServerSecurityAlertPoliciesClient) (ssap ServerSecurityAlertPolicy, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "mysql.ServerSecurityAlertPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("mysql.ServerSecurityAlertPoliciesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ssap.Response.Response, err = future.GetResult(sender); err == nil && ssap.Response.Response.StatusCode != http.StatusNoContent { + ssap, err = client.CreateOrUpdateResponder(ssap.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "mysql.ServerSecurityAlertPoliciesCreateOrUpdateFuture", "Result", ssap.Response.Response, "Failure responding to request") + } + } + return +} + +// ServerSecurityAlertPolicy a server security alert policy. +type ServerSecurityAlertPolicy struct { + autorest.Response `json:"-"` + // SecurityAlertPolicyProperties - Resource properties. + *SecurityAlertPolicyProperties `json:"properties,omitempty"` + // ID - Resource ID + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerSecurityAlertPolicy. +func (ssap ServerSecurityAlertPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ssap.SecurityAlertPolicyProperties != nil { + objectMap["properties"] = ssap.SecurityAlertPolicyProperties + } + if ssap.ID != nil { + objectMap["id"] = ssap.ID + } + if ssap.Name != nil { + objectMap["name"] = ssap.Name + } + if ssap.Type != nil { + objectMap["type"] = ssap.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServerSecurityAlertPolicy struct. +func (ssap *ServerSecurityAlertPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var securityAlertPolicyProperties SecurityAlertPolicyProperties + err = json.Unmarshal(*v, &securityAlertPolicyProperties) + if err != nil { + return err + } + ssap.SecurityAlertPolicyProperties = &securityAlertPolicyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ssap.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ssap.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ssap.Type = &typeVar + } + } + } + + return nil +} + // ServersUpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation. type ServersUpdateFuture struct { azure.Future diff --git a/services/mysql/mgmt/2017-12-01/mysql/serversecurityalertpolicies.go b/services/mysql/mgmt/2017-12-01/mysql/serversecurityalertpolicies.go new file mode 100644 index 000000000000..8b9e8ab82e60 --- /dev/null +++ b/services/mysql/mgmt/2017-12-01/mysql/serversecurityalertpolicies.go @@ -0,0 +1,187 @@ +package mysql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// ServerSecurityAlertPoliciesClient is the the Microsoft Azure management API provides create, read, update, and +// delete functionality for Azure MySQL resources including servers, databases, firewall rules, VNET rules, log files +// and configurations with new business model. +type ServerSecurityAlertPoliciesClient struct { + BaseClient +} + +// NewServerSecurityAlertPoliciesClient creates an instance of the ServerSecurityAlertPoliciesClient client. +func NewServerSecurityAlertPoliciesClient(subscriptionID string) ServerSecurityAlertPoliciesClient { + return NewServerSecurityAlertPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServerSecurityAlertPoliciesClientWithBaseURI creates an instance of the ServerSecurityAlertPoliciesClient client. +func NewServerSecurityAlertPoliciesClientWithBaseURI(baseURI string, subscriptionID string) ServerSecurityAlertPoliciesClient { + return ServerSecurityAlertPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a threat detection policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// parameters - the server security alert policy. +func (client ServerSecurityAlertPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters ServerSecurityAlertPolicy) (result ServerSecurityAlertPoliciesCreateOrUpdateFuture, err error) { + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "mysql.ServerSecurityAlertPoliciesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "mysql.ServerSecurityAlertPoliciesClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ServerSecurityAlertPoliciesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, parameters ServerSecurityAlertPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "securityAlertPolicyName": autorest.Encode("path", "Default"), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-12-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/servers/{serverName}/securityAlertPolicies/{securityAlertPolicyName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ServerSecurityAlertPoliciesClient) CreateOrUpdateSender(req *http.Request) (future ServerSecurityAlertPoliciesCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServerSecurityAlertPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result ServerSecurityAlertPolicy, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get get a server's security alert policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client ServerSecurityAlertPoliciesClient) Get(ctx context.Context, resourceGroupName string, serverName string) (result ServerSecurityAlertPolicy, err error) { + req, err := client.GetPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "mysql.ServerSecurityAlertPoliciesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "mysql.ServerSecurityAlertPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "mysql.ServerSecurityAlertPoliciesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServerSecurityAlertPoliciesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "securityAlertPolicyName": autorest.Encode("path", "Default"), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-12-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/servers/{serverName}/securityAlertPolicies/{securityAlertPolicyName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ServerSecurityAlertPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServerSecurityAlertPoliciesClient) GetResponder(resp *http.Response) (result ServerSecurityAlertPolicy, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +}