diff --git a/services/preview/security/mgmt/v3.0/security/adaptiveapplicationcontrols.go b/services/preview/security/mgmt/v3.0/security/adaptiveapplicationcontrols.go index 3539525c7196..3c6bb4585652 100644 --- a/services/preview/security/mgmt/v3.0/security/adaptiveapplicationcontrols.go +++ b/services/preview/security/mgmt/v3.0/security/adaptiveapplicationcontrols.go @@ -43,6 +43,86 @@ func NewAdaptiveApplicationControlsClientWithBaseURI(baseURI string, subscriptio return AdaptiveApplicationControlsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} } +// Delete delete an application control VM/server group +// Parameters: +// groupName - name of an application control VM/server group +func (client AdaptiveApplicationControlsClient) Delete(ctx context.Context, groupName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AdaptiveApplicationControlsClient.Delete") + 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.AdaptiveApplicationControlsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, groupName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AdaptiveApplicationControlsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "security.AdaptiveApplicationControlsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AdaptiveApplicationControlsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client AdaptiveApplicationControlsClient) DeletePreparer(ctx context.Context, groupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "ascLocation": autorest.Encode("path", client.AscLocation), + "groupName": autorest.Encode("path", groupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/applicationWhitelistings/{groupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client AdaptiveApplicationControlsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client AdaptiveApplicationControlsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + // Get gets an application control VM/server group. // Parameters: // groupName - name of an application control VM/server group diff --git a/services/preview/security/mgmt/v3.0/security/adaptivenetworkhardenings.go b/services/preview/security/mgmt/v3.0/security/adaptivenetworkhardenings.go new file mode 100644 index 000000000000..a70653929ab7 --- /dev/null +++ b/services/preview/security/mgmt/v3.0/security/adaptivenetworkhardenings.go @@ -0,0 +1,364 @@ +package security + +// 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" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// AdaptiveNetworkHardeningsClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type AdaptiveNetworkHardeningsClient struct { + BaseClient +} + +// NewAdaptiveNetworkHardeningsClient creates an instance of the AdaptiveNetworkHardeningsClient client. +func NewAdaptiveNetworkHardeningsClient(subscriptionID string, ascLocation string) AdaptiveNetworkHardeningsClient { + return NewAdaptiveNetworkHardeningsClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewAdaptiveNetworkHardeningsClientWithBaseURI creates an instance of the AdaptiveNetworkHardeningsClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewAdaptiveNetworkHardeningsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) AdaptiveNetworkHardeningsClient { + return AdaptiveNetworkHardeningsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Enforce enforces the given rules on the NSG(s) listed in the request +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// resourceNamespace - the Namespace of the resource. +// resourceType - the type of the resource. +// resourceName - name of the resource. +// adaptiveNetworkHardeningResourceName - the name of the Adaptive Network Hardening resource. +func (client AdaptiveNetworkHardeningsClient) Enforce(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, adaptiveNetworkHardeningResourceName string, body AdaptiveNetworkHardeningEnforceRequest) (result AdaptiveNetworkHardeningsEnforceFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AdaptiveNetworkHardeningsClient.Enforce") + 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}}}, + {TargetValue: body, + Constraints: []validation.Constraint{{Target: "body.Rules", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "body.NetworkSecurityGroups", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.AdaptiveNetworkHardeningsClient", "Enforce", err.Error()) + } + + req, err := client.EnforcePreparer(ctx, resourceGroupName, resourceNamespace, resourceType, resourceName, adaptiveNetworkHardeningResourceName, body) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AdaptiveNetworkHardeningsClient", "Enforce", nil, "Failure preparing request") + return + } + + result, err = client.EnforceSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AdaptiveNetworkHardeningsClient", "Enforce", result.Response(), "Failure sending request") + return + } + + return +} + +// EnforcePreparer prepares the Enforce request. +func (client AdaptiveNetworkHardeningsClient) EnforcePreparer(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, adaptiveNetworkHardeningResourceName string, body AdaptiveNetworkHardeningEnforceRequest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "adaptiveNetworkHardeningEnforceAction": autorest.Encode("path", "enforce"), + "adaptiveNetworkHardeningResourceName": autorest.Encode("path", adaptiveNetworkHardeningResourceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceNamespace": autorest.Encode("path", resourceNamespace), + "resourceType": autorest.Encode("path", resourceType), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/adaptiveNetworkHardenings/{adaptiveNetworkHardeningResourceName}/{adaptiveNetworkHardeningEnforceAction}", pathParameters), + autorest.WithJSON(body), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// EnforceSender sends the Enforce request. The method will close the +// http.Response Body if it receives an error. +func (client AdaptiveNetworkHardeningsClient) EnforceSender(req *http.Request) (future AdaptiveNetworkHardeningsEnforceFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// EnforceResponder handles the response to the Enforce request. The method always +// closes the http.Response Body. +func (client AdaptiveNetworkHardeningsClient) EnforceResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a single Adaptive Network Hardening resource +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// resourceNamespace - the Namespace of the resource. +// resourceType - the type of the resource. +// resourceName - name of the resource. +// adaptiveNetworkHardeningResourceName - the name of the Adaptive Network Hardening resource. +func (client AdaptiveNetworkHardeningsClient) Get(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, adaptiveNetworkHardeningResourceName string) (result AdaptiveNetworkHardening, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AdaptiveNetworkHardeningsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.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.AdaptiveNetworkHardeningsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceNamespace, resourceType, resourceName, adaptiveNetworkHardeningResourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AdaptiveNetworkHardeningsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.AdaptiveNetworkHardeningsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AdaptiveNetworkHardeningsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client AdaptiveNetworkHardeningsClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, adaptiveNetworkHardeningResourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "adaptiveNetworkHardeningResourceName": autorest.Encode("path", adaptiveNetworkHardeningResourceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceNamespace": autorest.Encode("path", resourceNamespace), + "resourceType": autorest.Encode("path", resourceType), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/adaptiveNetworkHardenings/{adaptiveNetworkHardeningResourceName}", 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 AdaptiveNetworkHardeningsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AdaptiveNetworkHardeningsClient) GetResponder(resp *http.Response) (result AdaptiveNetworkHardening, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByExtendedResource gets a list of Adaptive Network Hardenings resources in scope of an extended resource. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// resourceNamespace - the Namespace of the resource. +// resourceType - the type of the resource. +// resourceName - name of the resource. +func (client AdaptiveNetworkHardeningsClient) ListByExtendedResource(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string) (result AdaptiveNetworkHardeningsListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AdaptiveNetworkHardeningsClient.ListByExtendedResource") + defer func() { + sc := -1 + if result.anhl.Response.Response != nil { + sc = result.anhl.Response.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.AdaptiveNetworkHardeningsClient", "ListByExtendedResource", err.Error()) + } + + result.fn = client.listByExtendedResourceNextResults + req, err := client.ListByExtendedResourcePreparer(ctx, resourceGroupName, resourceNamespace, resourceType, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AdaptiveNetworkHardeningsClient", "ListByExtendedResource", nil, "Failure preparing request") + return + } + + resp, err := client.ListByExtendedResourceSender(req) + if err != nil { + result.anhl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.AdaptiveNetworkHardeningsClient", "ListByExtendedResource", resp, "Failure sending request") + return + } + + result.anhl, err = client.ListByExtendedResourceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AdaptiveNetworkHardeningsClient", "ListByExtendedResource", resp, "Failure responding to request") + } + + return +} + +// ListByExtendedResourcePreparer prepares the ListByExtendedResource request. +func (client AdaptiveNetworkHardeningsClient) ListByExtendedResourcePreparer(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceNamespace": autorest.Encode("path", resourceNamespace), + "resourceType": autorest.Encode("path", resourceType), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/adaptiveNetworkHardenings", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByExtendedResourceSender sends the ListByExtendedResource request. The method will close the +// http.Response Body if it receives an error. +func (client AdaptiveNetworkHardeningsClient) ListByExtendedResourceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByExtendedResourceResponder handles the response to the ListByExtendedResource request. The method always +// closes the http.Response Body. +func (client AdaptiveNetworkHardeningsClient) ListByExtendedResourceResponder(resp *http.Response) (result AdaptiveNetworkHardeningsList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByExtendedResourceNextResults retrieves the next set of results, if any. +func (client AdaptiveNetworkHardeningsClient) listByExtendedResourceNextResults(ctx context.Context, lastResults AdaptiveNetworkHardeningsList) (result AdaptiveNetworkHardeningsList, err error) { + req, err := lastResults.adaptiveNetworkHardeningsListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.AdaptiveNetworkHardeningsClient", "listByExtendedResourceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByExtendedResourceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.AdaptiveNetworkHardeningsClient", "listByExtendedResourceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByExtendedResourceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AdaptiveNetworkHardeningsClient", "listByExtendedResourceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByExtendedResourceComplete enumerates all values, automatically crossing page boundaries as required. +func (client AdaptiveNetworkHardeningsClient) ListByExtendedResourceComplete(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string) (result AdaptiveNetworkHardeningsListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AdaptiveNetworkHardeningsClient.ListByExtendedResource") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByExtendedResource(ctx, resourceGroupName, resourceNamespace, resourceType, resourceName) + return +} diff --git a/services/preview/security/mgmt/v3.0/security/allowedconnections.go b/services/preview/security/mgmt/v3.0/security/allowedconnections.go index 0eeca0685693..9732ca27ba65 100644 --- a/services/preview/security/mgmt/v3.0/security/allowedconnections.go +++ b/services/preview/security/mgmt/v3.0/security/allowedconnections.go @@ -100,7 +100,7 @@ func (client AllowedConnectionsClient) GetPreparer(ctx context.Context, resource "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2015-06-01-preview" + const APIVersion = "2020-01-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -178,7 +178,7 @@ func (client AllowedConnectionsClient) ListPreparer(ctx context.Context) (*http. "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2015-06-01-preview" + const APIVersion = "2020-01-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -294,7 +294,7 @@ func (client AllowedConnectionsClient) ListByHomeRegionPreparer(ctx context.Cont "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2015-06-01-preview" + const APIVersion = "2020-01-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/services/preview/security/mgmt/v3.0/security/models.go b/services/preview/security/mgmt/v3.0/security/models.go index fd736271261b..f15577176c87 100644 --- a/services/preview/security/mgmt/v3.0/security/models.go +++ b/services/preview/security/mgmt/v3.0/security/models.go @@ -21,6 +21,7 @@ import ( "context" "encoding/json" "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" "github.com/Azure/go-autorest/autorest/date" "github.com/Azure/go-autorest/autorest/to" "github.com/Azure/go-autorest/tracing" @@ -298,6 +299,21 @@ func PossibleDataSourceValues() []DataSource { return []DataSource{TwinData} } +// Direction enumerates the values for direction. +type Direction string + +const ( + // Inbound ... + Inbound Direction = "Inbound" + // Outbound ... + Outbound Direction = "Outbound" +) + +// PossibleDirectionValues returns an array of possible values for the Direction const type. +func PossibleDirectionValues() []Direction { + return []Direction{Inbound, Outbound} +} + // EnforcementMode enumerates the values for enforcement mode. type EnforcementMode string @@ -1021,6 +1037,21 @@ func PossibleThreatsValues() []Threats { return []Threats{AccountBreach, DataExfiltration, DataSpillage, DenialOfService, ElevationOfPrivilege, MaliciousInsider, MissingCoverage, ThreatResistance} } +// TransportProtocol enumerates the values for transport protocol. +type TransportProtocol string + +const ( + // TransportProtocolTCP ... + TransportProtocolTCP TransportProtocol = "TCP" + // TransportProtocolUDP ... + TransportProtocolUDP TransportProtocol = "UDP" +) + +// PossibleTransportProtocolValues returns an array of possible values for the TransportProtocol const type. +func PossibleTransportProtocolValues() []TransportProtocol { + return []TransportProtocol{TransportProtocolTCP, TransportProtocolUDP} +} + // Type enumerates the values for type. type Type string @@ -1160,6 +1191,268 @@ type AadSolutionProperties struct { ConnectivityState AadConnectivityState `json:"connectivityState,omitempty"` } +// AdaptiveNetworkHardening the resource whose properties describes the Adaptive Network Hardening settings +// for some Azure resource +type AdaptiveNetworkHardening struct { + autorest.Response `json:"-"` + // AdaptiveNetworkHardeningProperties - Properties of the Adaptive Network Hardening resource + *AdaptiveNetworkHardeningProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for AdaptiveNetworkHardening. +func (anh AdaptiveNetworkHardening) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if anh.AdaptiveNetworkHardeningProperties != nil { + objectMap["properties"] = anh.AdaptiveNetworkHardeningProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AdaptiveNetworkHardening struct. +func (anh *AdaptiveNetworkHardening) 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 adaptiveNetworkHardeningProperties AdaptiveNetworkHardeningProperties + err = json.Unmarshal(*v, &adaptiveNetworkHardeningProperties) + if err != nil { + return err + } + anh.AdaptiveNetworkHardeningProperties = &adaptiveNetworkHardeningProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + anh.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + anh.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + anh.Type = &typeVar + } + } + } + + return nil +} + +// AdaptiveNetworkHardeningEnforceRequest ... +type AdaptiveNetworkHardeningEnforceRequest struct { + // Rules - The rules to enforce + Rules *[]Rule `json:"rules,omitempty"` + // NetworkSecurityGroups - The Azure resource IDs of the effective network security groups that will be updated with the created security rules from the Adaptive Network Hardening rules + NetworkSecurityGroups *[]string `json:"networkSecurityGroups,omitempty"` +} + +// AdaptiveNetworkHardeningProperties adaptive Network Hardening resource properties +type AdaptiveNetworkHardeningProperties struct { + // Rules - The security rules which are recommended to be effective on the VM + Rules *[]Rule `json:"rules,omitempty"` + // RulesCalculationTime - The UTC time on which the rules were calculated + RulesCalculationTime *date.Time `json:"rulesCalculationTime,omitempty"` + // EffectiveNetworkSecurityGroups - The Network Security Groups effective on the network interfaces of the protected resource + EffectiveNetworkSecurityGroups *[]EffectiveNetworkSecurityGroups `json:"effectiveNetworkSecurityGroups,omitempty"` +} + +// AdaptiveNetworkHardeningsEnforceFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type AdaptiveNetworkHardeningsEnforceFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *AdaptiveNetworkHardeningsEnforceFuture) Result(client AdaptiveNetworkHardeningsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AdaptiveNetworkHardeningsEnforceFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("security.AdaptiveNetworkHardeningsEnforceFuture") + return + } + ar.Response = future.Response() + return +} + +// AdaptiveNetworkHardeningsList response for ListAdaptiveNetworkHardenings API service call +type AdaptiveNetworkHardeningsList struct { + autorest.Response `json:"-"` + // Value - A list of Adaptive Network Hardenings resources + Value *[]AdaptiveNetworkHardening `json:"value,omitempty"` + // NextLink - The URL to get the next set of results + NextLink *string `json:"nextLink,omitempty"` +} + +// AdaptiveNetworkHardeningsListIterator provides access to a complete listing of AdaptiveNetworkHardening +// values. +type AdaptiveNetworkHardeningsListIterator struct { + i int + page AdaptiveNetworkHardeningsListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *AdaptiveNetworkHardeningsListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AdaptiveNetworkHardeningsListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *AdaptiveNetworkHardeningsListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter AdaptiveNetworkHardeningsListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter AdaptiveNetworkHardeningsListIterator) Response() AdaptiveNetworkHardeningsList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter AdaptiveNetworkHardeningsListIterator) Value() AdaptiveNetworkHardening { + if !iter.page.NotDone() { + return AdaptiveNetworkHardening{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the AdaptiveNetworkHardeningsListIterator type. +func NewAdaptiveNetworkHardeningsListIterator(page AdaptiveNetworkHardeningsListPage) AdaptiveNetworkHardeningsListIterator { + return AdaptiveNetworkHardeningsListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (anhl AdaptiveNetworkHardeningsList) IsEmpty() bool { + return anhl.Value == nil || len(*anhl.Value) == 0 +} + +// adaptiveNetworkHardeningsListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (anhl AdaptiveNetworkHardeningsList) adaptiveNetworkHardeningsListPreparer(ctx context.Context) (*http.Request, error) { + if anhl.NextLink == nil || len(to.String(anhl.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(anhl.NextLink))) +} + +// AdaptiveNetworkHardeningsListPage contains a page of AdaptiveNetworkHardening values. +type AdaptiveNetworkHardeningsListPage struct { + fn func(context.Context, AdaptiveNetworkHardeningsList) (AdaptiveNetworkHardeningsList, error) + anhl AdaptiveNetworkHardeningsList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *AdaptiveNetworkHardeningsListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AdaptiveNetworkHardeningsListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.anhl) + if err != nil { + return err + } + page.anhl = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *AdaptiveNetworkHardeningsListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page AdaptiveNetworkHardeningsListPage) NotDone() bool { + return !page.anhl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page AdaptiveNetworkHardeningsListPage) Response() AdaptiveNetworkHardeningsList { + return page.anhl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page AdaptiveNetworkHardeningsListPage) Values() []AdaptiveNetworkHardening { + if page.anhl.IsEmpty() { + return nil + } + return *page.anhl.Value +} + +// Creates a new instance of the AdaptiveNetworkHardeningsListPage type. +func NewAdaptiveNetworkHardeningsListPage(getNextPage func(context.Context, AdaptiveNetworkHardeningsList) (AdaptiveNetworkHardeningsList, error)) AdaptiveNetworkHardeningsListPage { + return AdaptiveNetworkHardeningsListPage{fn: getNextPage} +} + // BasicAdditionalData details of the sub-assessment type BasicAdditionalData interface { AsSQLServerVulnerabilityProperties() (*SQLServerVulnerabilityProperties, bool) @@ -5480,6 +5773,14 @@ type DiscoveredSecuritySolutionProperties struct { Sku *string `json:"sku,omitempty"` } +// EffectiveNetworkSecurityGroups describes the Network Security Groups effective on a network interface +type EffectiveNetworkSecurityGroups struct { + // NetworkInterface - The Azure resource ID of the network interface + NetworkInterface *string `json:"networkInterface,omitempty"` + // NetworkSecurityGroups - The Network Security Groups effective on the network interface + NetworkSecurityGroups *[]string `json:"networkSecurityGroups,omitempty"` +} + // ETag entity tag is used for comparing two or more entities from the same requested resource. type ETag struct { // Etag - Entity tag is used for comparing two or more entities from the same requested resource. @@ -8624,6 +8925,21 @@ func (rd ResourceDetails) AsBasicResourceDetails() (BasicResourceDetails, bool) return &rd, true } +// Rule describes remote addresses that is recommended to communicate with the Azure resource on some +// (Protocol, Port, Direction). All other remote addresses are recommended to be blocked +type Rule struct { + // Name - The name of the rule + Name *string `json:"name,omitempty"` + // Direction - The rule's direction. Possible values include: 'Inbound', 'Outbound' + Direction Direction `json:"direction,omitempty"` + // DestinationPort - The rule's destination port + DestinationPort *int32 `json:"destinationPort,omitempty"` + // Protocols - The rule's transport protocols + Protocols *[]TransportProtocol `json:"protocols,omitempty"` + // IPAddresses - The remote IP addresses that should be able to communicate with the Azure resource on the rule's destination port and protocol + IPAddresses *[]string `json:"ipAddresses,omitempty"` +} + // SensitivityLabel the sensitivity label. type SensitivityLabel struct { // DisplayName - The name of the sensitivity label. 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 c476f0febd3d..24bbfa3698d8 100644 --- a/services/preview/security/mgmt/v3.0/security/securityapi/interfaces.go +++ b/services/preview/security/mgmt/v3.0/security/securityapi/interfaces.go @@ -131,17 +131,6 @@ type IotSecuritySolutionsAnalyticsRecommendationClientAPI interface { var _ IotSecuritySolutionsAnalyticsRecommendationClientAPI = (*security.IotSecuritySolutionsAnalyticsRecommendationClient)(nil) -// AllowedConnectionsClientAPI contains the set of methods on the AllowedConnectionsClient type. -type AllowedConnectionsClientAPI interface { - Get(ctx context.Context, resourceGroupName string, connectionType security.ConnectionType) (result security.AllowedConnectionsResource, err error) - List(ctx context.Context) (result security.AllowedConnectionsListPage, err error) - ListComplete(ctx context.Context) (result security.AllowedConnectionsListIterator, err error) - ListByHomeRegion(ctx context.Context) (result security.AllowedConnectionsListPage, err error) - ListByHomeRegionComplete(ctx context.Context) (result security.AllowedConnectionsListIterator, err error) -} - -var _ AllowedConnectionsClientAPI = (*security.AllowedConnectionsClient)(nil) - // DiscoveredSecuritySolutionsClientAPI contains the set of methods on the DiscoveredSecuritySolutionsClient type. type DiscoveredSecuritySolutionsClientAPI interface { Get(ctx context.Context, resourceGroupName string, discoveredSecuritySolutionName string) (result security.DiscoveredSecuritySolution, err error) @@ -184,6 +173,7 @@ var _ JitNetworkAccessPoliciesClientAPI = (*security.JitNetworkAccessPoliciesCli // AdaptiveApplicationControlsClientAPI contains the set of methods on the AdaptiveApplicationControlsClient type. type AdaptiveApplicationControlsClientAPI interface { + Delete(ctx context.Context, groupName string) (result autorest.Response, err error) Get(ctx context.Context, groupName string) (result security.AppWhitelistingGroup, err error) List(ctx context.Context, includePathRecommendations *bool, summary *bool) (result security.AppWhitelistingGroups, err error) Put(ctx context.Context, groupName string, body security.AppWhitelistingPutGroupData) (result security.AppWhitelistingGroup, err error) @@ -224,17 +214,6 @@ type TasksClientAPI interface { var _ TasksClientAPI = (*security.TasksClient)(nil) -// TopologyClientAPI contains the set of methods on the TopologyClient type. -type TopologyClientAPI interface { - Get(ctx context.Context, resourceGroupName string, topologyResourceName string) (result security.TopologyResource, err error) - List(ctx context.Context) (result security.TopologyListPage, err error) - ListComplete(ctx context.Context) (result security.TopologyListIterator, err error) - ListByHomeRegion(ctx context.Context) (result security.TopologyListPage, err error) - ListByHomeRegionComplete(ctx context.Context) (result security.TopologyListIterator, err error) -} - -var _ TopologyClientAPI = (*security.TopologyClient)(nil) - // AutoProvisioningSettingsClientAPI contains the set of methods on the AutoProvisioningSettingsClient type. type AutoProvisioningSettingsClientAPI interface { Create(ctx context.Context, settingName string, setting security.AutoProvisioningSetting) (result security.AutoProvisioningSetting, err error) @@ -374,3 +353,35 @@ type AssessmentsClientAPI interface { } var _ AssessmentsClientAPI = (*security.AssessmentsClient)(nil) + +// AdaptiveNetworkHardeningsClientAPI contains the set of methods on the AdaptiveNetworkHardeningsClient type. +type AdaptiveNetworkHardeningsClientAPI interface { + Enforce(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, adaptiveNetworkHardeningResourceName string, body security.AdaptiveNetworkHardeningEnforceRequest) (result security.AdaptiveNetworkHardeningsEnforceFuture, err error) + Get(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, adaptiveNetworkHardeningResourceName string) (result security.AdaptiveNetworkHardening, err error) + ListByExtendedResource(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string) (result security.AdaptiveNetworkHardeningsListPage, err error) + ListByExtendedResourceComplete(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string) (result security.AdaptiveNetworkHardeningsListIterator, err error) +} + +var _ AdaptiveNetworkHardeningsClientAPI = (*security.AdaptiveNetworkHardeningsClient)(nil) + +// AllowedConnectionsClientAPI contains the set of methods on the AllowedConnectionsClient type. +type AllowedConnectionsClientAPI interface { + Get(ctx context.Context, resourceGroupName string, connectionType security.ConnectionType) (result security.AllowedConnectionsResource, err error) + List(ctx context.Context) (result security.AllowedConnectionsListPage, err error) + ListComplete(ctx context.Context) (result security.AllowedConnectionsListIterator, err error) + ListByHomeRegion(ctx context.Context) (result security.AllowedConnectionsListPage, err error) + ListByHomeRegionComplete(ctx context.Context) (result security.AllowedConnectionsListIterator, err error) +} + +var _ AllowedConnectionsClientAPI = (*security.AllowedConnectionsClient)(nil) + +// TopologyClientAPI contains the set of methods on the TopologyClient type. +type TopologyClientAPI interface { + Get(ctx context.Context, resourceGroupName string, topologyResourceName string) (result security.TopologyResource, err error) + List(ctx context.Context) (result security.TopologyListPage, err error) + ListComplete(ctx context.Context) (result security.TopologyListIterator, err error) + ListByHomeRegion(ctx context.Context) (result security.TopologyListPage, err error) + ListByHomeRegionComplete(ctx context.Context) (result security.TopologyListIterator, err error) +} + +var _ TopologyClientAPI = (*security.TopologyClient)(nil) diff --git a/services/preview/security/mgmt/v3.0/security/topology.go b/services/preview/security/mgmt/v3.0/security/topology.go index 5a020bc9863c..03905404718f 100644 --- a/services/preview/security/mgmt/v3.0/security/topology.go +++ b/services/preview/security/mgmt/v3.0/security/topology.go @@ -98,7 +98,7 @@ func (client TopologyClient) GetPreparer(ctx context.Context, resourceGroupName "topologyResourceName": autorest.Encode("path", topologyResourceName), } - const APIVersion = "2015-06-01-preview" + const APIVersion = "2020-01-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -176,7 +176,7 @@ func (client TopologyClient) ListPreparer(ctx context.Context) (*http.Request, e "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2015-06-01-preview" + const APIVersion = "2020-01-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -292,7 +292,7 @@ func (client TopologyClient) ListByHomeRegionPreparer(ctx context.Context) (*htt "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2015-06-01-preview" + const APIVersion = "2020-01-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, }