From 48cf83da295483ed95919aafcf138b5fd19f822d Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Thu, 11 Jul 2019 05:31:01 +0000 Subject: [PATCH 1/2] Generated from cffdbb2188858ec6220a0833db370ceb2249074b fix enum --- .../preview/security/mgmt/security/models.go | 162 ++ .../mgmt/security/securityapi/models.go | 8 + .../mgmt/v3.0/security/iotsecuritysolution.go | 413 +++++ .../v3.0/security/iotsecuritysolutions.go | 163 ++ .../security/iotsecuritysolutionsanalytics.go | 219 +++ ...curitysolutionsanalyticsaggregatedalert.go | 224 +++ ...uritysolutionsanalyticsaggregatedalerts.go | 175 +++ ...ecuritysolutionsanalyticsrecommendation.go | 135 ++ ...curitysolutionsanalyticsrecommendations.go | 175 +++ .../iotsecuritysolutionsresourcegroup.go | 173 +++ .../security/mgmt/v3.0/security/models.go | 1349 +++++++++++++++-- .../v3.0/security/securityapi/interfaces.go | 61 + 12 files changed, 3141 insertions(+), 116 deletions(-) create mode 100644 services/preview/security/mgmt/v3.0/security/iotsecuritysolution.go create mode 100644 services/preview/security/mgmt/v3.0/security/iotsecuritysolutions.go create mode 100644 services/preview/security/mgmt/v3.0/security/iotsecuritysolutionsanalytics.go create mode 100644 services/preview/security/mgmt/v3.0/security/iotsecuritysolutionsanalyticsaggregatedalert.go create mode 100644 services/preview/security/mgmt/v3.0/security/iotsecuritysolutionsanalyticsaggregatedalerts.go create mode 100644 services/preview/security/mgmt/v3.0/security/iotsecuritysolutionsanalyticsrecommendation.go create mode 100644 services/preview/security/mgmt/v3.0/security/iotsecuritysolutionsanalyticsrecommendations.go create mode 100644 services/preview/security/mgmt/v3.0/security/iotsecuritysolutionsresourcegroup.go diff --git a/profiles/preview/preview/security/mgmt/security/models.go b/profiles/preview/preview/security/mgmt/security/models.go index cfbee9f1de94..5e8378212ba4 100644 --- a/profiles/preview/preview/security/mgmt/security/models.go +++ b/profiles/preview/preview/security/mgmt/security/models.go @@ -65,6 +65,18 @@ const ( Internal ConnectionType = original.Internal ) +type DataSource = original.DataSource + +const ( + TwinData DataSource = original.TwinData +) + +type ExportData = original.ExportData + +const ( + RawEvents ExportData = original.RawEvents +) + type ExternalSecuritySolutionKind = original.ExternalSecuritySolutionKind const ( @@ -116,6 +128,30 @@ const ( Succeeded ProvisioningState = original.Succeeded ) +type RecommendationConfigStatus = original.RecommendationConfigStatus + +const ( + TurnedOff RecommendationConfigStatus = original.TurnedOff + TurnedOn RecommendationConfigStatus = original.TurnedOn +) + +type RecommendationType = original.RecommendationType + +const ( + DenyDefaultIPPolicy RecommendationType = original.DenyDefaultIPPolicy + EnableDiagnosticsLog RecommendationType = original.EnableDiagnosticsLog + IdenticalAuthenticationCredentials RecommendationType = original.IdenticalAuthenticationCredentials + OpenPortsOnDevice RecommendationType = original.OpenPortsOnDevice + OperationSystemNotValid RecommendationType = original.OperationSystemNotValid + PermissiveFirewallPolicy RecommendationType = original.PermissiveFirewallPolicy + PermissiveFirewallRuleInput RecommendationType = original.PermissiveFirewallRuleInput + PermissiveFirewallRuleOut RecommendationType = original.PermissiveFirewallRuleOut + SecurityTwinConfigurationConflict RecommendationType = original.SecurityTwinConfigurationConflict + SecurityTwinConfigurationNotOptimal RecommendationType = original.SecurityTwinConfigurationNotOptimal + TooLargeIPRange RecommendationType = original.TooLargeIPRange + UnutilizedMessagesFromAgent RecommendationType = original.UnutilizedMessagesFromAgent +) + type ReportedSeverity = original.ReportedSeverity const ( @@ -141,6 +177,13 @@ const ( SettingKindDataExportSetting SettingKind = original.SettingKindDataExportSetting ) +type SolutionStatus = original.SolutionStatus + +const ( + Disabled SolutionStatus = original.Disabled + Enabled SolutionStatus = original.Enabled +) + type State = original.State const ( @@ -249,6 +292,40 @@ type InformationProtectionPolicyListIterator = original.InformationProtectionPol type InformationProtectionPolicyListPage = original.InformationProtectionPolicyListPage type InformationProtectionPolicyProperties = original.InformationProtectionPolicyProperties type InformationType = original.InformationType +type IoTSecurityAggregatedAlert = original.IoTSecurityAggregatedAlert +type IoTSecurityAggregatedAlertList = original.IoTSecurityAggregatedAlertList +type IoTSecurityAggregatedAlertListIterator = original.IoTSecurityAggregatedAlertListIterator +type IoTSecurityAggregatedAlertListPage = original.IoTSecurityAggregatedAlertListPage +type IoTSecurityAggregatedAlertProperties = original.IoTSecurityAggregatedAlertProperties +type IoTSecurityAggregatedRecommendation = original.IoTSecurityAggregatedRecommendation +type IoTSecurityAggregatedRecommendationList = original.IoTSecurityAggregatedRecommendationList +type IoTSecurityAggregatedRecommendationListIterator = original.IoTSecurityAggregatedRecommendationListIterator +type IoTSecurityAggregatedRecommendationListPage = original.IoTSecurityAggregatedRecommendationListPage +type IoTSecurityAggregatedRecommendationProperties = original.IoTSecurityAggregatedRecommendationProperties +type IoTSecurityAlertedDevice = original.IoTSecurityAlertedDevice +type IoTSecurityAlertedDevicesList = original.IoTSecurityAlertedDevicesList +type IoTSecurityDeviceAlert = original.IoTSecurityDeviceAlert +type IoTSecurityDeviceAlertsList = original.IoTSecurityDeviceAlertsList +type IoTSecurityDeviceRecommendation = original.IoTSecurityDeviceRecommendation +type IoTSecurityDeviceRecommendationsList = original.IoTSecurityDeviceRecommendationsList +type IoTSecuritySolutionAnalyticsModel = original.IoTSecuritySolutionAnalyticsModel +type IoTSecuritySolutionAnalyticsModelList = original.IoTSecuritySolutionAnalyticsModelList +type IoTSecuritySolutionAnalyticsModelProperties = original.IoTSecuritySolutionAnalyticsModelProperties +type IoTSecuritySolutionAnalyticsModelPropertiesDevicesMetricsItem = original.IoTSecuritySolutionAnalyticsModelPropertiesDevicesMetricsItem +type IoTSecuritySolutionModel = original.IoTSecuritySolutionModel +type IoTSecuritySolutionProperties = original.IoTSecuritySolutionProperties +type IoTSecuritySolutionsAnalyticsAggregatedAlertClient = original.IoTSecuritySolutionsAnalyticsAggregatedAlertClient +type IoTSecuritySolutionsAnalyticsAggregatedAlertsClient = original.IoTSecuritySolutionsAnalyticsAggregatedAlertsClient +type IoTSecuritySolutionsAnalyticsClient = original.IoTSecuritySolutionsAnalyticsClient +type IoTSecuritySolutionsAnalyticsRecommendationClient = original.IoTSecuritySolutionsAnalyticsRecommendationClient +type IoTSecuritySolutionsAnalyticsRecommendationsClient = original.IoTSecuritySolutionsAnalyticsRecommendationsClient +type IoTSecuritySolutionsClient = original.IoTSecuritySolutionsClient +type IoTSecuritySolutionsList = original.IoTSecuritySolutionsList +type IoTSecuritySolutionsListIterator = original.IoTSecuritySolutionsListIterator +type IoTSecuritySolutionsListPage = original.IoTSecuritySolutionsListPage +type IoTSecuritySolutionsResourceGroupClient = original.IoTSecuritySolutionsResourceGroupClient +type IoTSeverityMetrics = original.IoTSeverityMetrics +type IotSecuritySolutionClient = original.IotSecuritySolutionClient type JitNetworkAccessPoliciesClient = original.JitNetworkAccessPoliciesClient type JitNetworkAccessPoliciesList = original.JitNetworkAccessPoliciesList type JitNetworkAccessPoliciesListIterator = original.JitNetworkAccessPoliciesListIterator @@ -276,6 +353,7 @@ type Pricing = original.Pricing type PricingList = original.PricingList type PricingProperties = original.PricingProperties type PricingsClient = original.PricingsClient +type RecommendationConfigurationProperties = original.RecommendationConfigurationProperties type RegulatoryComplianceAssessment = original.RegulatoryComplianceAssessment type RegulatoryComplianceAssessmentList = original.RegulatoryComplianceAssessmentList type RegulatoryComplianceAssessmentListIterator = original.RegulatoryComplianceAssessmentListIterator @@ -306,6 +384,7 @@ type SettingsClient = original.SettingsClient type SettingsList = original.SettingsList type SettingsListIterator = original.SettingsListIterator type SettingsListPage = original.SettingsListPage +type TagsResource = original.TagsResource type Task = original.Task type TaskList = original.TaskList type TaskListIterator = original.TaskListIterator @@ -322,6 +401,8 @@ type TopologyResourceProperties = original.TopologyResourceProperties type TopologySingleResource = original.TopologySingleResource type TopologySingleResourceChild = original.TopologySingleResourceChild type TopologySingleResourceParent = original.TopologySingleResourceParent +type UpdateIotSecuritySolutionData = original.UpdateIotSecuritySolutionData +type UserDefinedResourcesProperties = original.UserDefinedResourcesProperties type WorkspaceSetting = original.WorkspaceSetting type WorkspaceSettingList = original.WorkspaceSettingList type WorkspaceSettingListIterator = original.WorkspaceSettingListIterator @@ -452,6 +533,72 @@ func NewInformationProtectionPolicyListIterator(page InformationProtectionPolicy func NewInformationProtectionPolicyListPage(getNextPage func(context.Context, InformationProtectionPolicyList) (InformationProtectionPolicyList, error)) InformationProtectionPolicyListPage { return original.NewInformationProtectionPolicyListPage(getNextPage) } +func NewIoTSecurityAggregatedAlertListIterator(page IoTSecurityAggregatedAlertListPage) IoTSecurityAggregatedAlertListIterator { + return original.NewIoTSecurityAggregatedAlertListIterator(page) +} +func NewIoTSecurityAggregatedAlertListPage(getNextPage func(context.Context, IoTSecurityAggregatedAlertList) (IoTSecurityAggregatedAlertList, error)) IoTSecurityAggregatedAlertListPage { + return original.NewIoTSecurityAggregatedAlertListPage(getNextPage) +} +func NewIoTSecurityAggregatedRecommendationListIterator(page IoTSecurityAggregatedRecommendationListPage) IoTSecurityAggregatedRecommendationListIterator { + return original.NewIoTSecurityAggregatedRecommendationListIterator(page) +} +func NewIoTSecurityAggregatedRecommendationListPage(getNextPage func(context.Context, IoTSecurityAggregatedRecommendationList) (IoTSecurityAggregatedRecommendationList, error)) IoTSecurityAggregatedRecommendationListPage { + return original.NewIoTSecurityAggregatedRecommendationListPage(getNextPage) +} +func NewIoTSecuritySolutionsAnalyticsAggregatedAlertClient(subscriptionID string, ascLocation string) IoTSecuritySolutionsAnalyticsAggregatedAlertClient { + return original.NewIoTSecuritySolutionsAnalyticsAggregatedAlertClient(subscriptionID, ascLocation) +} +func NewIoTSecuritySolutionsAnalyticsAggregatedAlertClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) IoTSecuritySolutionsAnalyticsAggregatedAlertClient { + return original.NewIoTSecuritySolutionsAnalyticsAggregatedAlertClientWithBaseURI(baseURI, subscriptionID, ascLocation) +} +func NewIoTSecuritySolutionsAnalyticsAggregatedAlertsClient(subscriptionID string, ascLocation string) IoTSecuritySolutionsAnalyticsAggregatedAlertsClient { + return original.NewIoTSecuritySolutionsAnalyticsAggregatedAlertsClient(subscriptionID, ascLocation) +} +func NewIoTSecuritySolutionsAnalyticsAggregatedAlertsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) IoTSecuritySolutionsAnalyticsAggregatedAlertsClient { + return original.NewIoTSecuritySolutionsAnalyticsAggregatedAlertsClientWithBaseURI(baseURI, subscriptionID, ascLocation) +} +func NewIoTSecuritySolutionsAnalyticsClient(subscriptionID string, ascLocation string) IoTSecuritySolutionsAnalyticsClient { + return original.NewIoTSecuritySolutionsAnalyticsClient(subscriptionID, ascLocation) +} +func NewIoTSecuritySolutionsAnalyticsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) IoTSecuritySolutionsAnalyticsClient { + return original.NewIoTSecuritySolutionsAnalyticsClientWithBaseURI(baseURI, subscriptionID, ascLocation) +} +func NewIoTSecuritySolutionsAnalyticsRecommendationClient(subscriptionID string, ascLocation string) IoTSecuritySolutionsAnalyticsRecommendationClient { + return original.NewIoTSecuritySolutionsAnalyticsRecommendationClient(subscriptionID, ascLocation) +} +func NewIoTSecuritySolutionsAnalyticsRecommendationClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) IoTSecuritySolutionsAnalyticsRecommendationClient { + return original.NewIoTSecuritySolutionsAnalyticsRecommendationClientWithBaseURI(baseURI, subscriptionID, ascLocation) +} +func NewIoTSecuritySolutionsAnalyticsRecommendationsClient(subscriptionID string, ascLocation string) IoTSecuritySolutionsAnalyticsRecommendationsClient { + return original.NewIoTSecuritySolutionsAnalyticsRecommendationsClient(subscriptionID, ascLocation) +} +func NewIoTSecuritySolutionsAnalyticsRecommendationsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) IoTSecuritySolutionsAnalyticsRecommendationsClient { + return original.NewIoTSecuritySolutionsAnalyticsRecommendationsClientWithBaseURI(baseURI, subscriptionID, ascLocation) +} +func NewIoTSecuritySolutionsClient(subscriptionID string, ascLocation string) IoTSecuritySolutionsClient { + return original.NewIoTSecuritySolutionsClient(subscriptionID, ascLocation) +} +func NewIoTSecuritySolutionsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) IoTSecuritySolutionsClient { + return original.NewIoTSecuritySolutionsClientWithBaseURI(baseURI, subscriptionID, ascLocation) +} +func NewIoTSecuritySolutionsListIterator(page IoTSecuritySolutionsListPage) IoTSecuritySolutionsListIterator { + return original.NewIoTSecuritySolutionsListIterator(page) +} +func NewIoTSecuritySolutionsListPage(getNextPage func(context.Context, IoTSecuritySolutionsList) (IoTSecuritySolutionsList, error)) IoTSecuritySolutionsListPage { + return original.NewIoTSecuritySolutionsListPage(getNextPage) +} +func NewIoTSecuritySolutionsResourceGroupClient(subscriptionID string, ascLocation string) IoTSecuritySolutionsResourceGroupClient { + return original.NewIoTSecuritySolutionsResourceGroupClient(subscriptionID, ascLocation) +} +func NewIoTSecuritySolutionsResourceGroupClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) IoTSecuritySolutionsResourceGroupClient { + return original.NewIoTSecuritySolutionsResourceGroupClientWithBaseURI(baseURI, subscriptionID, ascLocation) +} +func NewIotSecuritySolutionClient(subscriptionID string, ascLocation string) IotSecuritySolutionClient { + return original.NewIotSecuritySolutionClient(subscriptionID, ascLocation) +} +func NewIotSecuritySolutionClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) IotSecuritySolutionClient { + return original.NewIotSecuritySolutionClientWithBaseURI(baseURI, subscriptionID, ascLocation) +} func NewJitNetworkAccessPoliciesClient(subscriptionID string, ascLocation string) JitNetworkAccessPoliciesClient { return original.NewJitNetworkAccessPoliciesClient(subscriptionID, ascLocation) } @@ -596,6 +743,12 @@ func PossibleAutoProvisionValues() []AutoProvision { func PossibleConnectionTypeValues() []ConnectionType { return original.PossibleConnectionTypeValues() } +func PossibleDataSourceValues() []DataSource { + return original.PossibleDataSourceValues() +} +func PossibleExportDataValues() []ExportData { + return original.PossibleExportDataValues() +} func PossibleExternalSecuritySolutionKindValues() []ExternalSecuritySolutionKind { return original.PossibleExternalSecuritySolutionKindValues() } @@ -614,6 +767,12 @@ func PossibleProtocolValues() []Protocol { func PossibleProvisioningStateValues() []ProvisioningState { return original.PossibleProvisioningStateValues() } +func PossibleRecommendationConfigStatusValues() []RecommendationConfigStatus { + return original.PossibleRecommendationConfigStatusValues() +} +func PossibleRecommendationTypeValues() []RecommendationType { + return original.PossibleRecommendationTypeValues() +} func PossibleReportedSeverityValues() []ReportedSeverity { return original.PossibleReportedSeverityValues() } @@ -623,6 +782,9 @@ func PossibleResourceStatusValues() []ResourceStatus { func PossibleSettingKindValues() []SettingKind { return original.PossibleSettingKindValues() } +func PossibleSolutionStatusValues() []SolutionStatus { + return original.PossibleSolutionStatusValues() +} func PossibleStateValues() []State { return original.PossibleStateValues() } diff --git a/profiles/preview/preview/security/mgmt/security/securityapi/models.go b/profiles/preview/preview/security/mgmt/security/securityapi/models.go index 87d60a743168..be5a0930486c 100644 --- a/profiles/preview/preview/security/mgmt/security/securityapi/models.go +++ b/profiles/preview/preview/security/mgmt/security/securityapi/models.go @@ -31,6 +31,14 @@ type ContactsClientAPI = original.ContactsClientAPI type DiscoveredSecuritySolutionsClientAPI = original.DiscoveredSecuritySolutionsClientAPI type ExternalSecuritySolutionsClientAPI = original.ExternalSecuritySolutionsClientAPI type InformationProtectionPoliciesClientAPI = original.InformationProtectionPoliciesClientAPI +type IoTSecuritySolutionsAnalyticsAggregatedAlertClientAPI = original.IoTSecuritySolutionsAnalyticsAggregatedAlertClientAPI +type IoTSecuritySolutionsAnalyticsAggregatedAlertsClientAPI = original.IoTSecuritySolutionsAnalyticsAggregatedAlertsClientAPI +type IoTSecuritySolutionsAnalyticsClientAPI = original.IoTSecuritySolutionsAnalyticsClientAPI +type IoTSecuritySolutionsAnalyticsRecommendationClientAPI = original.IoTSecuritySolutionsAnalyticsRecommendationClientAPI +type IoTSecuritySolutionsAnalyticsRecommendationsClientAPI = original.IoTSecuritySolutionsAnalyticsRecommendationsClientAPI +type IoTSecuritySolutionsClientAPI = original.IoTSecuritySolutionsClientAPI +type IoTSecuritySolutionsResourceGroupClientAPI = original.IoTSecuritySolutionsResourceGroupClientAPI +type IotSecuritySolutionClientAPI = original.IotSecuritySolutionClientAPI type JitNetworkAccessPoliciesClientAPI = original.JitNetworkAccessPoliciesClientAPI type LocationsClientAPI = original.LocationsClientAPI type OperationsClientAPI = original.OperationsClientAPI diff --git a/services/preview/security/mgmt/v3.0/security/iotsecuritysolution.go b/services/preview/security/mgmt/v3.0/security/iotsecuritysolution.go new file mode 100644 index 000000000000..6600ee165766 --- /dev/null +++ b/services/preview/security/mgmt/v3.0/security/iotsecuritysolution.go @@ -0,0 +1,413 @@ +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" +) + +// IotSecuritySolutionClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type IotSecuritySolutionClient struct { + BaseClient +} + +// NewIotSecuritySolutionClient creates an instance of the IotSecuritySolutionClient client. +func NewIotSecuritySolutionClient(subscriptionID string, ascLocation string) IotSecuritySolutionClient { + return NewIotSecuritySolutionClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewIotSecuritySolutionClientWithBaseURI creates an instance of the IotSecuritySolutionClient client. +func NewIotSecuritySolutionClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) IotSecuritySolutionClient { + return IotSecuritySolutionClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Create create new solution manager +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// solutionName - the solution manager name +// iotSecuritySolutionData - the security solution data +func (client IotSecuritySolutionClient) Create(ctx context.Context, resourceGroupName string, solutionName string, iotSecuritySolutionData IoTSecuritySolutionModel) (result IoTSecuritySolutionModel, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotSecuritySolutionClient.Create") + 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}}}, + {TargetValue: iotSecuritySolutionData, + Constraints: []validation.Constraint{{Target: "iotSecuritySolutionData.IoTSecuritySolutionProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "iotSecuritySolutionData.IoTSecuritySolutionProperties.Workspace", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "iotSecuritySolutionData.IoTSecuritySolutionProperties.DisplayName", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "iotSecuritySolutionData.IoTSecuritySolutionProperties.IotHubs", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "iotSecuritySolutionData.IoTSecuritySolutionProperties.UserDefinedResources", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "iotSecuritySolutionData.IoTSecuritySolutionProperties.UserDefinedResources.Query", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "iotSecuritySolutionData.IoTSecuritySolutionProperties.UserDefinedResources.QuerySubscriptions", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}}}}); err != nil { + return result, validation.NewError("security.IotSecuritySolutionClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, solutionName, iotSecuritySolutionData) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client IotSecuritySolutionClient) CreatePreparer(ctx context.Context, resourceGroupName string, solutionName string, iotSecuritySolutionData IoTSecuritySolutionModel) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "solutionName": autorest.Encode("path", solutionName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + iotSecuritySolutionData.ID = nil + iotSecuritySolutionData.Name = nil + iotSecuritySolutionData.Type = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}", pathParameters), + autorest.WithJSON(iotSecuritySolutionData), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client IotSecuritySolutionClient) CreateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client IotSecuritySolutionClient) CreateResponder(resp *http.Response) (result IoTSecuritySolutionModel, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete create new solution manager +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// solutionName - the solution manager name +func (client IotSecuritySolutionClient) Delete(ctx context.Context, resourceGroupName string, solutionName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotSecuritySolutionClient.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}}}, + {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.IotSecuritySolutionClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, solutionName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client IotSecuritySolutionClient) DeletePreparer(ctx context.Context, resourceGroupName string, solutionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "solutionName": autorest.Encode("path", solutionName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}", 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 IotSecuritySolutionClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client IotSecuritySolutionClient) DeleteResponder(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 +} + +// Get details of a specific iot security solution +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// solutionName - the solution manager name +func (client IotSecuritySolutionClient) Get(ctx context.Context, resourceGroupName string, solutionName string) (result IoTSecuritySolutionModel, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotSecuritySolutionClient.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.IotSecuritySolutionClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, solutionName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionClient", "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.IotSecuritySolutionClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client IotSecuritySolutionClient) GetPreparer(ctx context.Context, resourceGroupName string, solutionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "solutionName": autorest.Encode("path", solutionName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}", 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 IotSecuritySolutionClient) 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 IotSecuritySolutionClient) GetResponder(resp *http.Response) (result IoTSecuritySolutionModel, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update update existing Security Solution tags or user defined resources. To update other fields use the +// CreateOrUpdate method +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// solutionName - the solution manager name +// updateIotSecuritySolutionData - the security solution data +func (client IotSecuritySolutionClient) Update(ctx context.Context, resourceGroupName string, solutionName string, updateIotSecuritySolutionData UpdateIotSecuritySolutionData) (result IoTSecuritySolutionModel, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotSecuritySolutionClient.Update") + 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.IotSecuritySolutionClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, solutionName, updateIotSecuritySolutionData) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client IotSecuritySolutionClient) UpdatePreparer(ctx context.Context, resourceGroupName string, solutionName string, updateIotSecuritySolutionData UpdateIotSecuritySolutionData) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "solutionName": autorest.Encode("path", solutionName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}", pathParameters), + autorest.WithJSON(updateIotSecuritySolutionData), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client IotSecuritySolutionClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client IotSecuritySolutionClient) UpdateResponder(resp *http.Response) (result IoTSecuritySolutionModel, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/security/mgmt/v3.0/security/iotsecuritysolutions.go b/services/preview/security/mgmt/v3.0/security/iotsecuritysolutions.go new file mode 100644 index 000000000000..4605efaa2ed5 --- /dev/null +++ b/services/preview/security/mgmt/v3.0/security/iotsecuritysolutions.go @@ -0,0 +1,163 @@ +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" +) + +// IoTSecuritySolutionsClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type IoTSecuritySolutionsClient struct { + BaseClient +} + +// NewIoTSecuritySolutionsClient creates an instance of the IoTSecuritySolutionsClient client. +func NewIoTSecuritySolutionsClient(subscriptionID string, ascLocation string) IoTSecuritySolutionsClient { + return NewIoTSecuritySolutionsClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewIoTSecuritySolutionsClientWithBaseURI creates an instance of the IoTSecuritySolutionsClient client. +func NewIoTSecuritySolutionsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) IoTSecuritySolutionsClient { + return IoTSecuritySolutionsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// List list of security solutions +// Parameters: +// filter - filter the Security Solution with OData syntax. supporting filter by iotHubs +func (client IoTSecuritySolutionsClient) List(ctx context.Context, filter string) (result IoTSecuritySolutionsListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IoTSecuritySolutionsClient.List") + defer func() { + sc := -1 + if result.itssl.Response.Response != nil { + sc = result.itssl.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}}}}); err != nil { + return result, validation.NewError("security.IoTSecuritySolutionsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IoTSecuritySolutionsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.itssl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.IoTSecuritySolutionsClient", "List", resp, "Failure sending request") + return + } + + result.itssl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IoTSecuritySolutionsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client IoTSecuritySolutionsClient) ListPreparer(ctx context.Context, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/iotSecuritySolutions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client IoTSecuritySolutionsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client IoTSecuritySolutionsClient) ListResponder(resp *http.Response) (result IoTSecuritySolutionsList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client IoTSecuritySolutionsClient) listNextResults(ctx context.Context, lastResults IoTSecuritySolutionsList) (result IoTSecuritySolutionsList, err error) { + req, err := lastResults.ioTSecuritySolutionsListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.IoTSecuritySolutionsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.IoTSecuritySolutionsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IoTSecuritySolutionsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client IoTSecuritySolutionsClient) ListComplete(ctx context.Context, filter string) (result IoTSecuritySolutionsListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IoTSecuritySolutionsClient.List") + 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.List(ctx, filter) + return +} diff --git a/services/preview/security/mgmt/v3.0/security/iotsecuritysolutionsanalytics.go b/services/preview/security/mgmt/v3.0/security/iotsecuritysolutionsanalytics.go new file mode 100644 index 000000000000..6058a5761f13 --- /dev/null +++ b/services/preview/security/mgmt/v3.0/security/iotsecuritysolutionsanalytics.go @@ -0,0 +1,219 @@ +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" +) + +// IoTSecuritySolutionsAnalyticsClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type IoTSecuritySolutionsAnalyticsClient struct { + BaseClient +} + +// NewIoTSecuritySolutionsAnalyticsClient creates an instance of the IoTSecuritySolutionsAnalyticsClient client. +func NewIoTSecuritySolutionsAnalyticsClient(subscriptionID string, ascLocation string) IoTSecuritySolutionsAnalyticsClient { + return NewIoTSecuritySolutionsAnalyticsClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewIoTSecuritySolutionsAnalyticsClientWithBaseURI creates an instance of the IoTSecuritySolutionsAnalyticsClient +// client. +func NewIoTSecuritySolutionsAnalyticsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) IoTSecuritySolutionsAnalyticsClient { + return IoTSecuritySolutionsAnalyticsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// GetAll security Analytics of a security solution +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// solutionName - the solution manager name +func (client IoTSecuritySolutionsAnalyticsClient) GetAll(ctx context.Context, resourceGroupName string, solutionName string) (result IoTSecuritySolutionAnalyticsModelList, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IoTSecuritySolutionsAnalyticsClient.GetAll") + 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.IoTSecuritySolutionsAnalyticsClient", "GetAll", err.Error()) + } + + req, err := client.GetAllPreparer(ctx, resourceGroupName, solutionName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IoTSecuritySolutionsAnalyticsClient", "GetAll", nil, "Failure preparing request") + return + } + + resp, err := client.GetAllSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.IoTSecuritySolutionsAnalyticsClient", "GetAll", resp, "Failure sending request") + return + } + + result, err = client.GetAllResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IoTSecuritySolutionsAnalyticsClient", "GetAll", resp, "Failure responding to request") + } + + return +} + +// GetAllPreparer prepares the GetAll request. +func (client IoTSecuritySolutionsAnalyticsClient) GetAllPreparer(ctx context.Context, resourceGroupName string, solutionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "solutionName": autorest.Encode("path", solutionName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetAllSender sends the GetAll request. The method will close the +// http.Response Body if it receives an error. +func (client IoTSecuritySolutionsAnalyticsClient) GetAllSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetAllResponder handles the response to the GetAll request. The method always +// closes the http.Response Body. +func (client IoTSecuritySolutionsAnalyticsClient) GetAllResponder(resp *http.Response) (result IoTSecuritySolutionAnalyticsModelList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetDefault security Analytics of a security solution +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// solutionName - the solution manager name +func (client IoTSecuritySolutionsAnalyticsClient) GetDefault(ctx context.Context, resourceGroupName string, solutionName string) (result IoTSecuritySolutionAnalyticsModel, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IoTSecuritySolutionsAnalyticsClient.GetDefault") + 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.IoTSecuritySolutionsAnalyticsClient", "GetDefault", err.Error()) + } + + req, err := client.GetDefaultPreparer(ctx, resourceGroupName, solutionName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IoTSecuritySolutionsAnalyticsClient", "GetDefault", nil, "Failure preparing request") + return + } + + resp, err := client.GetDefaultSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.IoTSecuritySolutionsAnalyticsClient", "GetDefault", resp, "Failure sending request") + return + } + + result, err = client.GetDefaultResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IoTSecuritySolutionsAnalyticsClient", "GetDefault", resp, "Failure responding to request") + } + + return +} + +// GetDefaultPreparer prepares the GetDefault request. +func (client IoTSecuritySolutionsAnalyticsClient) GetDefaultPreparer(ctx context.Context, resourceGroupName string, solutionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "solutionName": autorest.Encode("path", solutionName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetDefaultSender sends the GetDefault request. The method will close the +// http.Response Body if it receives an error. +func (client IoTSecuritySolutionsAnalyticsClient) GetDefaultSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetDefaultResponder handles the response to the GetDefault request. The method always +// closes the http.Response Body. +func (client IoTSecuritySolutionsAnalyticsClient) GetDefaultResponder(resp *http.Response) (result IoTSecuritySolutionAnalyticsModel, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/security/mgmt/v3.0/security/iotsecuritysolutionsanalyticsaggregatedalert.go b/services/preview/security/mgmt/v3.0/security/iotsecuritysolutionsanalyticsaggregatedalert.go new file mode 100644 index 000000000000..644d2d7792c1 --- /dev/null +++ b/services/preview/security/mgmt/v3.0/security/iotsecuritysolutionsanalyticsaggregatedalert.go @@ -0,0 +1,224 @@ +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" +) + +// IoTSecuritySolutionsAnalyticsAggregatedAlertClient is the API spec for Microsoft.Security (Azure Security Center) +// resource provider +type IoTSecuritySolutionsAnalyticsAggregatedAlertClient struct { + BaseClient +} + +// NewIoTSecuritySolutionsAnalyticsAggregatedAlertClient creates an instance of the +// IoTSecuritySolutionsAnalyticsAggregatedAlertClient client. +func NewIoTSecuritySolutionsAnalyticsAggregatedAlertClient(subscriptionID string, ascLocation string) IoTSecuritySolutionsAnalyticsAggregatedAlertClient { + return NewIoTSecuritySolutionsAnalyticsAggregatedAlertClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewIoTSecuritySolutionsAnalyticsAggregatedAlertClientWithBaseURI creates an instance of the +// IoTSecuritySolutionsAnalyticsAggregatedAlertClient client. +func NewIoTSecuritySolutionsAnalyticsAggregatedAlertClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) IoTSecuritySolutionsAnalyticsAggregatedAlertClient { + return IoTSecuritySolutionsAnalyticsAggregatedAlertClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Dismiss security Analytics of a security solution +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// solutionName - the solution manager name +// aggregatedAlertName - identifier of the aggregated alert +func (client IoTSecuritySolutionsAnalyticsAggregatedAlertClient) Dismiss(ctx context.Context, resourceGroupName string, solutionName string, aggregatedAlertName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IoTSecuritySolutionsAnalyticsAggregatedAlertClient.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}}}, + {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.IoTSecuritySolutionsAnalyticsAggregatedAlertClient", "Dismiss", err.Error()) + } + + req, err := client.DismissPreparer(ctx, resourceGroupName, solutionName, aggregatedAlertName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IoTSecuritySolutionsAnalyticsAggregatedAlertClient", "Dismiss", nil, "Failure preparing request") + return + } + + resp, err := client.DismissSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "security.IoTSecuritySolutionsAnalyticsAggregatedAlertClient", "Dismiss", resp, "Failure sending request") + return + } + + result, err = client.DismissResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IoTSecuritySolutionsAnalyticsAggregatedAlertClient", "Dismiss", resp, "Failure responding to request") + } + + return +} + +// DismissPreparer prepares the Dismiss request. +func (client IoTSecuritySolutionsAnalyticsAggregatedAlertClient) DismissPreparer(ctx context.Context, resourceGroupName string, solutionName string, aggregatedAlertName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "aggregatedAlertName": autorest.Encode("path", aggregatedAlertName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "solutionName": autorest.Encode("path", solutionName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-08-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/iotSecuritySolutions/{solutionName}/analyticsModels/default/aggregatedAlerts/{aggregatedAlertName}/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 IoTSecuritySolutionsAnalyticsAggregatedAlertClient) DismissSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DismissResponder handles the response to the Dismiss request. The method always +// closes the http.Response Body. +func (client IoTSecuritySolutionsAnalyticsAggregatedAlertClient) DismissResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get security Analytics of a security solution +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// solutionName - the solution manager name +// aggregatedAlertName - identifier of the aggregated alert +func (client IoTSecuritySolutionsAnalyticsAggregatedAlertClient) Get(ctx context.Context, resourceGroupName string, solutionName string, aggregatedAlertName string) (result IoTSecurityAggregatedAlert, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IoTSecuritySolutionsAnalyticsAggregatedAlertClient.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.IoTSecuritySolutionsAnalyticsAggregatedAlertClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, solutionName, aggregatedAlertName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IoTSecuritySolutionsAnalyticsAggregatedAlertClient", "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.IoTSecuritySolutionsAnalyticsAggregatedAlertClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IoTSecuritySolutionsAnalyticsAggregatedAlertClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client IoTSecuritySolutionsAnalyticsAggregatedAlertClient) GetPreparer(ctx context.Context, resourceGroupName string, solutionName string, aggregatedAlertName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "aggregatedAlertName": autorest.Encode("path", aggregatedAlertName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "solutionName": autorest.Encode("path", solutionName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default/aggregatedAlerts/{aggregatedAlertName}", 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 IoTSecuritySolutionsAnalyticsAggregatedAlertClient) 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 IoTSecuritySolutionsAnalyticsAggregatedAlertClient) GetResponder(resp *http.Response) (result IoTSecurityAggregatedAlert, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/security/mgmt/v3.0/security/iotsecuritysolutionsanalyticsaggregatedalerts.go b/services/preview/security/mgmt/v3.0/security/iotsecuritysolutionsanalyticsaggregatedalerts.go new file mode 100644 index 000000000000..78cf92058350 --- /dev/null +++ b/services/preview/security/mgmt/v3.0/security/iotsecuritysolutionsanalyticsaggregatedalerts.go @@ -0,0 +1,175 @@ +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" +) + +// IoTSecuritySolutionsAnalyticsAggregatedAlertsClient is the API spec for Microsoft.Security (Azure Security Center) +// resource provider +type IoTSecuritySolutionsAnalyticsAggregatedAlertsClient struct { + BaseClient +} + +// NewIoTSecuritySolutionsAnalyticsAggregatedAlertsClient creates an instance of the +// IoTSecuritySolutionsAnalyticsAggregatedAlertsClient client. +func NewIoTSecuritySolutionsAnalyticsAggregatedAlertsClient(subscriptionID string, ascLocation string) IoTSecuritySolutionsAnalyticsAggregatedAlertsClient { + return NewIoTSecuritySolutionsAnalyticsAggregatedAlertsClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewIoTSecuritySolutionsAnalyticsAggregatedAlertsClientWithBaseURI creates an instance of the +// IoTSecuritySolutionsAnalyticsAggregatedAlertsClient client. +func NewIoTSecuritySolutionsAnalyticsAggregatedAlertsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) IoTSecuritySolutionsAnalyticsAggregatedAlertsClient { + return IoTSecuritySolutionsAnalyticsAggregatedAlertsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// List security Analytics of a security solution +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// solutionName - the solution manager name +// top - the number of results to retrieve. +func (client IoTSecuritySolutionsAnalyticsAggregatedAlertsClient) List(ctx context.Context, resourceGroupName string, solutionName string, top *int32) (result IoTSecurityAggregatedAlertListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IoTSecuritySolutionsAnalyticsAggregatedAlertsClient.List") + defer func() { + sc := -1 + if result.itsaal.Response.Response != nil { + sc = result.itsaal.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.IoTSecuritySolutionsAnalyticsAggregatedAlertsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, solutionName, top) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IoTSecuritySolutionsAnalyticsAggregatedAlertsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.itsaal.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.IoTSecuritySolutionsAnalyticsAggregatedAlertsClient", "List", resp, "Failure sending request") + return + } + + result.itsaal, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IoTSecuritySolutionsAnalyticsAggregatedAlertsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client IoTSecuritySolutionsAnalyticsAggregatedAlertsClient) ListPreparer(ctx context.Context, resourceGroupName string, solutionName string, top *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "solutionName": autorest.Encode("path", solutionName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default/aggregatedAlerts", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client IoTSecuritySolutionsAnalyticsAggregatedAlertsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client IoTSecuritySolutionsAnalyticsAggregatedAlertsClient) ListResponder(resp *http.Response) (result IoTSecurityAggregatedAlertList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client IoTSecuritySolutionsAnalyticsAggregatedAlertsClient) listNextResults(ctx context.Context, lastResults IoTSecurityAggregatedAlertList) (result IoTSecurityAggregatedAlertList, err error) { + req, err := lastResults.ioTSecurityAggregatedAlertListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.IoTSecuritySolutionsAnalyticsAggregatedAlertsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.IoTSecuritySolutionsAnalyticsAggregatedAlertsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IoTSecuritySolutionsAnalyticsAggregatedAlertsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client IoTSecuritySolutionsAnalyticsAggregatedAlertsClient) ListComplete(ctx context.Context, resourceGroupName string, solutionName string, top *int32) (result IoTSecurityAggregatedAlertListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IoTSecuritySolutionsAnalyticsAggregatedAlertsClient.List") + 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.List(ctx, resourceGroupName, solutionName, top) + return +} diff --git a/services/preview/security/mgmt/v3.0/security/iotsecuritysolutionsanalyticsrecommendation.go b/services/preview/security/mgmt/v3.0/security/iotsecuritysolutionsanalyticsrecommendation.go new file mode 100644 index 000000000000..a05c732aa31f --- /dev/null +++ b/services/preview/security/mgmt/v3.0/security/iotsecuritysolutionsanalyticsrecommendation.go @@ -0,0 +1,135 @@ +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" +) + +// IoTSecuritySolutionsAnalyticsRecommendationClient is the API spec for Microsoft.Security (Azure Security Center) +// resource provider +type IoTSecuritySolutionsAnalyticsRecommendationClient struct { + BaseClient +} + +// NewIoTSecuritySolutionsAnalyticsRecommendationClient creates an instance of the +// IoTSecuritySolutionsAnalyticsRecommendationClient client. +func NewIoTSecuritySolutionsAnalyticsRecommendationClient(subscriptionID string, ascLocation string) IoTSecuritySolutionsAnalyticsRecommendationClient { + return NewIoTSecuritySolutionsAnalyticsRecommendationClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewIoTSecuritySolutionsAnalyticsRecommendationClientWithBaseURI creates an instance of the +// IoTSecuritySolutionsAnalyticsRecommendationClient client. +func NewIoTSecuritySolutionsAnalyticsRecommendationClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) IoTSecuritySolutionsAnalyticsRecommendationClient { + return IoTSecuritySolutionsAnalyticsRecommendationClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Get security Analytics of a security solution +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// solutionName - the solution manager name +// aggregatedRecommendationName - identifier of the aggregated recommendation +func (client IoTSecuritySolutionsAnalyticsRecommendationClient) Get(ctx context.Context, resourceGroupName string, solutionName string, aggregatedRecommendationName string) (result IoTSecurityAggregatedRecommendation, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IoTSecuritySolutionsAnalyticsRecommendationClient.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.IoTSecuritySolutionsAnalyticsRecommendationClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, solutionName, aggregatedRecommendationName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IoTSecuritySolutionsAnalyticsRecommendationClient", "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.IoTSecuritySolutionsAnalyticsRecommendationClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IoTSecuritySolutionsAnalyticsRecommendationClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client IoTSecuritySolutionsAnalyticsRecommendationClient) GetPreparer(ctx context.Context, resourceGroupName string, solutionName string, aggregatedRecommendationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "aggregatedRecommendationName": autorest.Encode("path", aggregatedRecommendationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "solutionName": autorest.Encode("path", solutionName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default/aggregatedRecommendations/{aggregatedRecommendationName}", 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 IoTSecuritySolutionsAnalyticsRecommendationClient) 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 IoTSecuritySolutionsAnalyticsRecommendationClient) GetResponder(resp *http.Response) (result IoTSecurityAggregatedRecommendation, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/security/mgmt/v3.0/security/iotsecuritysolutionsanalyticsrecommendations.go b/services/preview/security/mgmt/v3.0/security/iotsecuritysolutionsanalyticsrecommendations.go new file mode 100644 index 000000000000..d3a01a5985be --- /dev/null +++ b/services/preview/security/mgmt/v3.0/security/iotsecuritysolutionsanalyticsrecommendations.go @@ -0,0 +1,175 @@ +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" +) + +// IoTSecuritySolutionsAnalyticsRecommendationsClient is the API spec for Microsoft.Security (Azure Security Center) +// resource provider +type IoTSecuritySolutionsAnalyticsRecommendationsClient struct { + BaseClient +} + +// NewIoTSecuritySolutionsAnalyticsRecommendationsClient creates an instance of the +// IoTSecuritySolutionsAnalyticsRecommendationsClient client. +func NewIoTSecuritySolutionsAnalyticsRecommendationsClient(subscriptionID string, ascLocation string) IoTSecuritySolutionsAnalyticsRecommendationsClient { + return NewIoTSecuritySolutionsAnalyticsRecommendationsClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewIoTSecuritySolutionsAnalyticsRecommendationsClientWithBaseURI creates an instance of the +// IoTSecuritySolutionsAnalyticsRecommendationsClient client. +func NewIoTSecuritySolutionsAnalyticsRecommendationsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) IoTSecuritySolutionsAnalyticsRecommendationsClient { + return IoTSecuritySolutionsAnalyticsRecommendationsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// List security Analytics of a security solution +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// solutionName - the solution manager name +// top - the number of results to retrieve. +func (client IoTSecuritySolutionsAnalyticsRecommendationsClient) List(ctx context.Context, resourceGroupName string, solutionName string, top *int32) (result IoTSecurityAggregatedRecommendationListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IoTSecuritySolutionsAnalyticsRecommendationsClient.List") + defer func() { + sc := -1 + if result.itsarl.Response.Response != nil { + sc = result.itsarl.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.IoTSecuritySolutionsAnalyticsRecommendationsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, solutionName, top) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IoTSecuritySolutionsAnalyticsRecommendationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.itsarl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.IoTSecuritySolutionsAnalyticsRecommendationsClient", "List", resp, "Failure sending request") + return + } + + result.itsarl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IoTSecuritySolutionsAnalyticsRecommendationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client IoTSecuritySolutionsAnalyticsRecommendationsClient) ListPreparer(ctx context.Context, resourceGroupName string, solutionName string, top *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "solutionName": autorest.Encode("path", solutionName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default/aggregatedRecommendations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client IoTSecuritySolutionsAnalyticsRecommendationsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client IoTSecuritySolutionsAnalyticsRecommendationsClient) ListResponder(resp *http.Response) (result IoTSecurityAggregatedRecommendationList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client IoTSecuritySolutionsAnalyticsRecommendationsClient) listNextResults(ctx context.Context, lastResults IoTSecurityAggregatedRecommendationList) (result IoTSecurityAggregatedRecommendationList, err error) { + req, err := lastResults.ioTSecurityAggregatedRecommendationListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.IoTSecuritySolutionsAnalyticsRecommendationsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.IoTSecuritySolutionsAnalyticsRecommendationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IoTSecuritySolutionsAnalyticsRecommendationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client IoTSecuritySolutionsAnalyticsRecommendationsClient) ListComplete(ctx context.Context, resourceGroupName string, solutionName string, top *int32) (result IoTSecurityAggregatedRecommendationListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IoTSecuritySolutionsAnalyticsRecommendationsClient.List") + 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.List(ctx, resourceGroupName, solutionName, top) + return +} diff --git a/services/preview/security/mgmt/v3.0/security/iotsecuritysolutionsresourcegroup.go b/services/preview/security/mgmt/v3.0/security/iotsecuritysolutionsresourcegroup.go new file mode 100644 index 000000000000..4b590c2a5b13 --- /dev/null +++ b/services/preview/security/mgmt/v3.0/security/iotsecuritysolutionsresourcegroup.go @@ -0,0 +1,173 @@ +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" +) + +// IoTSecuritySolutionsResourceGroupClient is the API spec for Microsoft.Security (Azure Security Center) resource +// provider +type IoTSecuritySolutionsResourceGroupClient struct { + BaseClient +} + +// NewIoTSecuritySolutionsResourceGroupClient creates an instance of the IoTSecuritySolutionsResourceGroupClient +// client. +func NewIoTSecuritySolutionsResourceGroupClient(subscriptionID string, ascLocation string) IoTSecuritySolutionsResourceGroupClient { + return NewIoTSecuritySolutionsResourceGroupClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewIoTSecuritySolutionsResourceGroupClientWithBaseURI creates an instance of the +// IoTSecuritySolutionsResourceGroupClient client. +func NewIoTSecuritySolutionsResourceGroupClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) IoTSecuritySolutionsResourceGroupClient { + return IoTSecuritySolutionsResourceGroupClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// List list of security solutions +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// filter - filter the Security Solution with OData syntax. supporting filter by iotHubs +func (client IoTSecuritySolutionsResourceGroupClient) List(ctx context.Context, resourceGroupName string, filter string) (result IoTSecuritySolutionsListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IoTSecuritySolutionsResourceGroupClient.List") + defer func() { + sc := -1 + if result.itssl.Response.Response != nil { + sc = result.itssl.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.IoTSecuritySolutionsResourceGroupClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IoTSecuritySolutionsResourceGroupClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.itssl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.IoTSecuritySolutionsResourceGroupClient", "List", resp, "Failure sending request") + return + } + + result.itssl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IoTSecuritySolutionsResourceGroupClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client IoTSecuritySolutionsResourceGroupClient) ListPreparer(ctx context.Context, resourceGroupName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client IoTSecuritySolutionsResourceGroupClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client IoTSecuritySolutionsResourceGroupClient) ListResponder(resp *http.Response) (result IoTSecuritySolutionsList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client IoTSecuritySolutionsResourceGroupClient) listNextResults(ctx context.Context, lastResults IoTSecuritySolutionsList) (result IoTSecuritySolutionsList, err error) { + req, err := lastResults.ioTSecuritySolutionsListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.IoTSecuritySolutionsResourceGroupClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.IoTSecuritySolutionsResourceGroupClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IoTSecuritySolutionsResourceGroupClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client IoTSecuritySolutionsResourceGroupClient) ListComplete(ctx context.Context, resourceGroupName string, filter string) (result IoTSecuritySolutionsListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IoTSecuritySolutionsResourceGroupClient.List") + 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.List(ctx, resourceGroupName, filter) + return +} diff --git a/services/preview/security/mgmt/v3.0/security/models.go b/services/preview/security/mgmt/v3.0/security/models.go index 8187d3f8cf07..698bf1b3f0a8 100644 --- a/services/preview/security/mgmt/v3.0/security/models.go +++ b/services/preview/security/mgmt/v3.0/security/models.go @@ -108,6 +108,32 @@ func PossibleConnectionTypeValues() []ConnectionType { return []ConnectionType{External, Internal} } +// DataSource enumerates the values for data source. +type DataSource string + +const ( + // TwinData Devices twin data + TwinData DataSource = "TwinData" +) + +// PossibleDataSourceValues returns an array of possible values for the DataSource const type. +func PossibleDataSourceValues() []DataSource { + return []DataSource{TwinData} +} + +// ExportData enumerates the values for export data. +type ExportData string + +const ( + // RawEvents Agent raw events + RawEvents ExportData = "RawEvents" +) + +// PossibleExportDataValues returns an array of possible values for the ExportData const type. +func PossibleExportDataValues() []ExportData { + return []ExportData{RawEvents} +} + // ExternalSecuritySolutionKind enumerates the values for external security solution kind. type ExternalSecuritySolutionKind string @@ -216,6 +242,66 @@ func PossibleProvisioningStateValues() []ProvisioningState { return []ProvisioningState{Canceled, Deprovisioning, Failed, Provisioning, Succeeded} } +// RecommendationConfigStatus enumerates the values for recommendation config status. +type RecommendationConfigStatus string + +const ( + // TurnedOff ... + TurnedOff RecommendationConfigStatus = "TurnedOff" + // TurnedOn ... + TurnedOn RecommendationConfigStatus = "TurnedOn" +) + +// PossibleRecommendationConfigStatusValues returns an array of possible values for the RecommendationConfigStatus const type. +func PossibleRecommendationConfigStatusValues() []RecommendationConfigStatus { + return []RecommendationConfigStatus{TurnedOff, TurnedOn} +} + +// RecommendationType enumerates the values for recommendation type. +type RecommendationType string + +const ( + // DenyDefaultIPPolicy IP filter configuration should have rules defined for allowed traffic, and should by + // default, deny all other traffic by default. + DenyDefaultIPPolicy RecommendationType = "DenyDefaultIpPolicy" + // EnableDiagnosticsLog Enable logs and retain them for up to a year. Retaining logs enables you to + // recreate activity trails for investigation purposes when a security incident occurs or your network is + // compromised. + EnableDiagnosticsLog RecommendationType = "EnableDiagnosticsLog" + // IdenticalAuthenticationCredentials IoT Hub authentication credentials are used by multiple devices. This + // may indicate an illegitimate device impersonating a legitimate device. Duplicate credential use + // increases the risk of device impersonation by a malicious actor. + IdenticalAuthenticationCredentials RecommendationType = "IdenticalAuthenticationCredentials" + // OpenPortsOnDevice A listening endpoint was found on the device. + OpenPortsOnDevice RecommendationType = "OpenPortsOnDevice" + // OperationSystemNotValid Device doesn't comply with CIS Linux benchmarks. + OperationSystemNotValid RecommendationType = "OperationSystemNotValid" + // PermissiveFirewallPolicy Allowed firewall policy found (INPUT/OUTPUT). Firewall policy should deny all + // traffic by default, and define rules to allow necessary communication to/from the device. + PermissiveFirewallPolicy RecommendationType = "PermissiveFirewallPolicy" + // PermissiveFirewallRuleInput A rule in the firewall in the input chain has been found that contains a + // permissive pattern for a wide range of IP addresses or ports. + PermissiveFirewallRuleInput RecommendationType = "PermissiveFirewallRuleInput" + // PermissiveFirewallRuleOut A rule in the firewall in the output chain has been found that contains a + // permissive pattern for a wide range of IP addresses or ports. + PermissiveFirewallRuleOut RecommendationType = "PermissiveFirewallRuleOut" + // SecurityTwinConfigurationConflict Conflicts were identified in the security twin configuration. + SecurityTwinConfigurationConflict RecommendationType = "SecurityTwinConfigurationConflict" + // SecurityTwinConfigurationNotOptimal Security twin configuration is not optimal. + SecurityTwinConfigurationNotOptimal RecommendationType = "SecurityTwinConfigurationNotOptimal" + // TooLargeIPRange An allow IP filter rule source IP range is too large. Overly permissive rules can expose + // your IoT hub to malicious actors. + TooLargeIPRange RecommendationType = "TooLargeIPRange" + // UnutilizedMessagesFromAgent 10% or more of security messages were smaller than 4kb during the last 24 + // hours. + UnutilizedMessagesFromAgent RecommendationType = "UnutilizedMessagesFromAgent" +) + +// PossibleRecommendationTypeValues returns an array of possible values for the RecommendationType const type. +func PossibleRecommendationTypeValues() []RecommendationType { + return []RecommendationType{DenyDefaultIPPolicy, EnableDiagnosticsLog, IdenticalAuthenticationCredentials, OpenPortsOnDevice, OperationSystemNotValid, PermissiveFirewallPolicy, PermissiveFirewallRuleInput, PermissiveFirewallRuleOut, SecurityTwinConfigurationConflict, SecurityTwinConfigurationNotOptimal, TooLargeIPRange, UnutilizedMessagesFromAgent} +} + // ReportedSeverity enumerates the values for reported severity. type ReportedSeverity string @@ -269,6 +355,21 @@ func PossibleSettingKindValues() []SettingKind { return []SettingKind{SettingKindAlertSuppressionSetting, SettingKindDataExportSetting} } +// SolutionStatus enumerates the values for solution status. +type SolutionStatus string + +const ( + // Disabled ... + Disabled SolutionStatus = "Disabled" + // Enabled ... + Enabled SolutionStatus = "Enabled" +) + +// PossibleSolutionStatusValues returns an array of possible values for the SolutionStatus const type. +func PossibleSolutionStatusValues() []SolutionStatus { + return []SolutionStatus{Disabled, Enabled} +} + // State enumerates the values for state. type State string @@ -3509,26 +3610,114 @@ type InformationType struct { Keywords *[]InformationProtectionKeyword `json:"keywords,omitempty"` } -// JitNetworkAccessPoliciesList ... -type JitNetworkAccessPoliciesList struct { +// IoTSecurityAggregatedAlert security Solution Aggregated Alert information +type IoTSecurityAggregatedAlert struct { autorest.Response `json:"-"` - Value *[]JitNetworkAccessPolicy `json:"value,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"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // IoTSecurityAggregatedAlertProperties - Security Solution Aggregated Alert data + *IoTSecurityAggregatedAlertProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for IoTSecurityAggregatedAlert. +func (itsaa IoTSecurityAggregatedAlert) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if itsaa.Tags != nil { + objectMap["tags"] = itsaa.Tags + } + if itsaa.IoTSecurityAggregatedAlertProperties != nil { + objectMap["properties"] = itsaa.IoTSecurityAggregatedAlertProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for IoTSecurityAggregatedAlert struct. +func (itsaa *IoTSecurityAggregatedAlert) 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 "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + itsaa.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + itsaa.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + itsaa.Type = &typeVar + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + itsaa.Tags = tags + } + case "properties": + if v != nil { + var ioTSecurityAggregatedAlertProperties IoTSecurityAggregatedAlertProperties + err = json.Unmarshal(*v, &ioTSecurityAggregatedAlertProperties) + if err != nil { + return err + } + itsaa.IoTSecurityAggregatedAlertProperties = &ioTSecurityAggregatedAlertProperties + } + } + } + + return nil +} + +// IoTSecurityAggregatedAlertList list of IoT aggregated security alerts +type IoTSecurityAggregatedAlertList struct { + autorest.Response `json:"-"` + // Value - List of aggregated alerts data + Value *[]IoTSecurityAggregatedAlert `json:"value,omitempty"` // NextLink - READ-ONLY; The URI to fetch the next page. NextLink *string `json:"nextLink,omitempty"` } -// JitNetworkAccessPoliciesListIterator provides access to a complete listing of JitNetworkAccessPolicy -// values. -type JitNetworkAccessPoliciesListIterator struct { +// IoTSecurityAggregatedAlertListIterator provides access to a complete listing of +// IoTSecurityAggregatedAlert values. +type IoTSecurityAggregatedAlertListIterator struct { i int - page JitNetworkAccessPoliciesListPage + page IoTSecurityAggregatedAlertListPage } // 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 *JitNetworkAccessPoliciesListIterator) NextWithContext(ctx context.Context) (err error) { +func (iter *IoTSecurityAggregatedAlertListIterator) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/JitNetworkAccessPoliciesListIterator.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/IoTSecurityAggregatedAlertListIterator.NextWithContext") defer func() { sc := -1 if iter.Response().Response.Response != nil { @@ -3553,62 +3742,62 @@ func (iter *JitNetworkAccessPoliciesListIterator) NextWithContext(ctx context.Co // 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 *JitNetworkAccessPoliciesListIterator) Next() error { +func (iter *IoTSecurityAggregatedAlertListIterator) Next() error { return iter.NextWithContext(context.Background()) } // NotDone returns true if the enumeration should be started or is not yet complete. -func (iter JitNetworkAccessPoliciesListIterator) NotDone() bool { +func (iter IoTSecurityAggregatedAlertListIterator) 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 JitNetworkAccessPoliciesListIterator) Response() JitNetworkAccessPoliciesList { +func (iter IoTSecurityAggregatedAlertListIterator) Response() IoTSecurityAggregatedAlertList { 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 JitNetworkAccessPoliciesListIterator) Value() JitNetworkAccessPolicy { +func (iter IoTSecurityAggregatedAlertListIterator) Value() IoTSecurityAggregatedAlert { if !iter.page.NotDone() { - return JitNetworkAccessPolicy{} + return IoTSecurityAggregatedAlert{} } return iter.page.Values()[iter.i] } -// Creates a new instance of the JitNetworkAccessPoliciesListIterator type. -func NewJitNetworkAccessPoliciesListIterator(page JitNetworkAccessPoliciesListPage) JitNetworkAccessPoliciesListIterator { - return JitNetworkAccessPoliciesListIterator{page: page} +// Creates a new instance of the IoTSecurityAggregatedAlertListIterator type. +func NewIoTSecurityAggregatedAlertListIterator(page IoTSecurityAggregatedAlertListPage) IoTSecurityAggregatedAlertListIterator { + return IoTSecurityAggregatedAlertListIterator{page: page} } // IsEmpty returns true if the ListResult contains no values. -func (jnapl JitNetworkAccessPoliciesList) IsEmpty() bool { - return jnapl.Value == nil || len(*jnapl.Value) == 0 +func (itsaal IoTSecurityAggregatedAlertList) IsEmpty() bool { + return itsaal.Value == nil || len(*itsaal.Value) == 0 } -// jitNetworkAccessPoliciesListPreparer prepares a request to retrieve the next set of results. +// ioTSecurityAggregatedAlertListPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. -func (jnapl JitNetworkAccessPoliciesList) jitNetworkAccessPoliciesListPreparer(ctx context.Context) (*http.Request, error) { - if jnapl.NextLink == nil || len(to.String(jnapl.NextLink)) < 1 { +func (itsaal IoTSecurityAggregatedAlertList) ioTSecurityAggregatedAlertListPreparer(ctx context.Context) (*http.Request, error) { + if itsaal.NextLink == nil || len(to.String(itsaal.NextLink)) < 1 { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), autorest.AsJSON(), autorest.AsGet(), - autorest.WithBaseURL(to.String(jnapl.NextLink))) + autorest.WithBaseURL(to.String(itsaal.NextLink))) } -// JitNetworkAccessPoliciesListPage contains a page of JitNetworkAccessPolicy values. -type JitNetworkAccessPoliciesListPage struct { - fn func(context.Context, JitNetworkAccessPoliciesList) (JitNetworkAccessPoliciesList, error) - jnapl JitNetworkAccessPoliciesList +// IoTSecurityAggregatedAlertListPage contains a page of IoTSecurityAggregatedAlert values. +type IoTSecurityAggregatedAlertListPage struct { + fn func(context.Context, IoTSecurityAggregatedAlertList) (IoTSecurityAggregatedAlertList, error) + itsaal IoTSecurityAggregatedAlertList } // 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 *JitNetworkAccessPoliciesListPage) NextWithContext(ctx context.Context) (err error) { +func (page *IoTSecurityAggregatedAlertListPage) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/JitNetworkAccessPoliciesListPage.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/IoTSecurityAggregatedAlertListPage.NextWithContext") defer func() { sc := -1 if page.Response().Response.Response != nil { @@ -3617,46 +3806,74 @@ func (page *JitNetworkAccessPoliciesListPage) NextWithContext(ctx context.Contex tracing.EndSpan(ctx, sc, err) }() } - next, err := page.fn(ctx, page.jnapl) + next, err := page.fn(ctx, page.itsaal) if err != nil { return err } - page.jnapl = next + page.itsaal = 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 *JitNetworkAccessPoliciesListPage) Next() error { +func (page *IoTSecurityAggregatedAlertListPage) Next() error { return page.NextWithContext(context.Background()) } // NotDone returns true if the page enumeration should be started or is not yet complete. -func (page JitNetworkAccessPoliciesListPage) NotDone() bool { - return !page.jnapl.IsEmpty() +func (page IoTSecurityAggregatedAlertListPage) NotDone() bool { + return !page.itsaal.IsEmpty() } // Response returns the raw server response from the last page request. -func (page JitNetworkAccessPoliciesListPage) Response() JitNetworkAccessPoliciesList { - return page.jnapl +func (page IoTSecurityAggregatedAlertListPage) Response() IoTSecurityAggregatedAlertList { + return page.itsaal } // Values returns the slice of values for the current page or nil if there are no values. -func (page JitNetworkAccessPoliciesListPage) Values() []JitNetworkAccessPolicy { - if page.jnapl.IsEmpty() { +func (page IoTSecurityAggregatedAlertListPage) Values() []IoTSecurityAggregatedAlert { + if page.itsaal.IsEmpty() { return nil } - return *page.jnapl.Value + return *page.itsaal.Value } -// Creates a new instance of the JitNetworkAccessPoliciesListPage type. -func NewJitNetworkAccessPoliciesListPage(getNextPage func(context.Context, JitNetworkAccessPoliciesList) (JitNetworkAccessPoliciesList, error)) JitNetworkAccessPoliciesListPage { - return JitNetworkAccessPoliciesListPage{fn: getNextPage} +// Creates a new instance of the IoTSecurityAggregatedAlertListPage type. +func NewIoTSecurityAggregatedAlertListPage(getNextPage func(context.Context, IoTSecurityAggregatedAlertList) (IoTSecurityAggregatedAlertList, error)) IoTSecurityAggregatedAlertListPage { + return IoTSecurityAggregatedAlertListPage{fn: getNextPage} } -// JitNetworkAccessPolicy ... -type JitNetworkAccessPolicy struct { +// IoTSecurityAggregatedAlertProperties security Solution Aggregated Alert data +type IoTSecurityAggregatedAlertProperties struct { + // AlertType - READ-ONLY; Name of the alert type + AlertType *string `json:"alertType,omitempty"` + // AlertDisplayName - READ-ONLY; Display name of the alert type + AlertDisplayName *string `json:"alertDisplayName,omitempty"` + // AggregatedDateUtc - READ-ONLY; The date the incidents were detected by the vendor + AggregatedDateUtc *date.Date `json:"aggregatedDateUtc,omitempty"` + // VendorName - READ-ONLY; Name of the vendor that discovered the incident + VendorName *string `json:"vendorName,omitempty"` + // ReportedSeverity - READ-ONLY; Estimated severity of this alert. Possible values include: 'Informational', 'Low', 'Medium', 'High' + ReportedSeverity ReportedSeverity `json:"reportedSeverity,omitempty"` + // RemediationSteps - READ-ONLY; Recommended steps for remediation + RemediationSteps *string `json:"remediationSteps,omitempty"` + // Description - READ-ONLY; Description of the incident and what it means + Description *string `json:"description,omitempty"` + // Count - READ-ONLY; Occurrence number of the alert within the aggregated date + Count *int32 `json:"count,omitempty"` + // EffectedResourceType - READ-ONLY; Azure resource ID of the resource that got the alerts + EffectedResourceType *string `json:"effectedResourceType,omitempty"` + // SystemSource - READ-ONLY; The type of the alerted resource (Azure, Non-Azure) + SystemSource *string `json:"systemSource,omitempty"` + // ActionTaken - READ-ONLY; The action that was taken as a response to the alert (Active, Blocked etc.) + ActionTaken *string `json:"actionTaken,omitempty"` + // LogAnalyticsQuery - READ-ONLY; query in log analytics to get the list of affected devices/alerts + LogAnalyticsQuery *string `json:"logAnalyticsQuery,omitempty"` +} + +// IoTSecurityAggregatedRecommendation security Solution Recommendation Information +type IoTSecurityAggregatedRecommendation struct { autorest.Response `json:"-"` // ID - READ-ONLY; Resource Id ID *string `json:"id,omitempty"` @@ -3664,27 +3881,26 @@ type JitNetworkAccessPolicy struct { Name *string `json:"name,omitempty"` // Type - READ-ONLY; Resource type Type *string `json:"type,omitempty"` - // Kind - Kind of the resource - Kind *string `json:"kind,omitempty"` - // Location - READ-ONLY; Location where the resource is stored - Location *string `json:"location,omitempty"` - *JitNetworkAccessPolicyProperties `json:"properties,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // IoTSecurityAggregatedRecommendationProperties - Security Solution data + *IoTSecurityAggregatedRecommendationProperties `json:"properties,omitempty"` } -// MarshalJSON is the custom marshaler for JitNetworkAccessPolicy. -func (jnap JitNetworkAccessPolicy) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for IoTSecurityAggregatedRecommendation. +func (itsar IoTSecurityAggregatedRecommendation) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if jnap.Kind != nil { - objectMap["kind"] = jnap.Kind + if itsar.Tags != nil { + objectMap["tags"] = itsar.Tags } - if jnap.JitNetworkAccessPolicyProperties != nil { - objectMap["properties"] = jnap.JitNetworkAccessPolicyProperties + if itsar.IoTSecurityAggregatedRecommendationProperties != nil { + objectMap["properties"] = itsar.IoTSecurityAggregatedRecommendationProperties } return json.Marshal(objectMap) } -// UnmarshalJSON is the custom unmarshaler for JitNetworkAccessPolicy struct. -func (jnap *JitNetworkAccessPolicy) UnmarshalJSON(body []byte) error { +// UnmarshalJSON is the custom unmarshaler for IoTSecurityAggregatedRecommendation struct. +func (itsar *IoTSecurityAggregatedRecommendation) UnmarshalJSON(body []byte) error { var m map[string]*json.RawMessage err := json.Unmarshal(body, &m) if err != nil { @@ -3699,7 +3915,7 @@ func (jnap *JitNetworkAccessPolicy) UnmarshalJSON(body []byte) error { if err != nil { return err } - jnap.ID = &ID + itsar.ID = &ID } case "name": if v != nil { @@ -3708,7 +3924,7 @@ func (jnap *JitNetworkAccessPolicy) UnmarshalJSON(body []byte) error { if err != nil { return err } - jnap.Name = &name + itsar.Name = &name } case "type": if v != nil { @@ -3717,34 +3933,25 @@ func (jnap *JitNetworkAccessPolicy) UnmarshalJSON(body []byte) error { if err != nil { return err } - jnap.Type = &typeVar - } - case "kind": - if v != nil { - var kind string - err = json.Unmarshal(*v, &kind) - if err != nil { - return err - } - jnap.Kind = &kind + itsar.Type = &typeVar } - case "location": + case "tags": if v != nil { - var location string - err = json.Unmarshal(*v, &location) + var tags map[string]*string + err = json.Unmarshal(*v, &tags) if err != nil { return err } - jnap.Location = &location + itsar.Tags = tags } case "properties": if v != nil { - var jitNetworkAccessPolicyProperties JitNetworkAccessPolicyProperties - err = json.Unmarshal(*v, &jitNetworkAccessPolicyProperties) + var ioTSecurityAggregatedRecommendationProperties IoTSecurityAggregatedRecommendationProperties + err = json.Unmarshal(*v, &ioTSecurityAggregatedRecommendationProperties) if err != nil { return err } - jnap.JitNetworkAccessPolicyProperties = &jitNetworkAccessPolicyProperties + itsar.IoTSecurityAggregatedRecommendationProperties = &ioTSecurityAggregatedRecommendationProperties } } } @@ -3752,56 +3959,910 @@ func (jnap *JitNetworkAccessPolicy) UnmarshalJSON(body []byte) error { return nil } -// JitNetworkAccessPolicyInitiatePort ... -type JitNetworkAccessPolicyInitiatePort struct { - Number *int32 `json:"number,omitempty"` - // AllowedSourceAddressPrefix - Source of the allowed traffic. If omitted, the request will be for the source IP address of the initiate request. - AllowedSourceAddressPrefix *string `json:"allowedSourceAddressPrefix,omitempty"` - // EndTimeUtc - The time to close the request in UTC - EndTimeUtc *date.Time `json:"endTimeUtc,omitempty"` +// IoTSecurityAggregatedRecommendationList list of IoT aggregated security recommendations +type IoTSecurityAggregatedRecommendationList struct { + autorest.Response `json:"-"` + // Value - List of aggregated alerts data + Value *[]IoTSecurityAggregatedRecommendation `json:"value,omitempty"` + // NextLink - READ-ONLY; The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` } -// JitNetworkAccessPolicyInitiateRequest ... -type JitNetworkAccessPolicyInitiateRequest struct { - // VirtualMachines - A list of virtual machines & ports to open access for - VirtualMachines *[]JitNetworkAccessPolicyInitiateVirtualMachine `json:"virtualMachines,omitempty"` +// IoTSecurityAggregatedRecommendationListIterator provides access to a complete listing of +// IoTSecurityAggregatedRecommendation values. +type IoTSecurityAggregatedRecommendationListIterator struct { + i int + page IoTSecurityAggregatedRecommendationListPage } -// JitNetworkAccessPolicyInitiateVirtualMachine ... -type JitNetworkAccessPolicyInitiateVirtualMachine struct { - // ID - Resource ID of the virtual machine that is linked to this policy - ID *string `json:"id,omitempty"` - // Ports - The ports to open for the resource with the `id` - Ports *[]JitNetworkAccessPolicyInitiatePort `json:"ports,omitempty"` +// 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 *IoTSecurityAggregatedRecommendationListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IoTSecurityAggregatedRecommendationListIterator.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 } -// JitNetworkAccessPolicyProperties ... -type JitNetworkAccessPolicyProperties struct { - // VirtualMachines - Configurations for Microsoft.Compute/virtualMachines resource type. - VirtualMachines *[]JitNetworkAccessPolicyVirtualMachine `json:"virtualMachines,omitempty"` - Requests *[]JitNetworkAccessRequest `json:"requests,omitempty"` - // ProvisioningState - READ-ONLY; Gets the provisioning state of the Just-in-Time policy. - ProvisioningState *string `json:"provisioningState,omitempty"` +// 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 *IoTSecurityAggregatedRecommendationListIterator) Next() error { + return iter.NextWithContext(context.Background()) } -// JitNetworkAccessPolicyVirtualMachine ... -type JitNetworkAccessPolicyVirtualMachine struct { - // ID - Resource ID of the virtual machine that is linked to this policy - ID *string `json:"id,omitempty"` - // Ports - Port configurations for the virtual machine - Ports *[]JitNetworkAccessPortRule `json:"ports,omitempty"` - // PublicIPAddress - Public IP address of the Azure Firewall that is linked to this policy, if applicable - PublicIPAddress *string `json:"publicIpAddress,omitempty"` +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter IoTSecurityAggregatedRecommendationListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) } -// JitNetworkAccessPortRule ... -type JitNetworkAccessPortRule struct { - Number *int32 `json:"number,omitempty"` - // Protocol - Possible values include: 'TCP', 'UDP', 'All' - Protocol Protocol `json:"protocol,omitempty"` - // AllowedSourceAddressPrefix - Mutually exclusive with the "allowedSourceAddressPrefixes" parameter. Should be an IP address or CIDR, for example "192.168.0.3" or "192.168.0.0/16". - AllowedSourceAddressPrefix *string `json:"allowedSourceAddressPrefix,omitempty"` - // AllowedSourceAddressPrefixes - Mutually exclusive with the "allowedSourceAddressPrefix" parameter. +// Response returns the raw server response from the last page request. +func (iter IoTSecurityAggregatedRecommendationListIterator) Response() IoTSecurityAggregatedRecommendationList { + 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 IoTSecurityAggregatedRecommendationListIterator) Value() IoTSecurityAggregatedRecommendation { + if !iter.page.NotDone() { + return IoTSecurityAggregatedRecommendation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the IoTSecurityAggregatedRecommendationListIterator type. +func NewIoTSecurityAggregatedRecommendationListIterator(page IoTSecurityAggregatedRecommendationListPage) IoTSecurityAggregatedRecommendationListIterator { + return IoTSecurityAggregatedRecommendationListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (itsarl IoTSecurityAggregatedRecommendationList) IsEmpty() bool { + return itsarl.Value == nil || len(*itsarl.Value) == 0 +} + +// ioTSecurityAggregatedRecommendationListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (itsarl IoTSecurityAggregatedRecommendationList) ioTSecurityAggregatedRecommendationListPreparer(ctx context.Context) (*http.Request, error) { + if itsarl.NextLink == nil || len(to.String(itsarl.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(itsarl.NextLink))) +} + +// IoTSecurityAggregatedRecommendationListPage contains a page of IoTSecurityAggregatedRecommendation +// values. +type IoTSecurityAggregatedRecommendationListPage struct { + fn func(context.Context, IoTSecurityAggregatedRecommendationList) (IoTSecurityAggregatedRecommendationList, error) + itsarl IoTSecurityAggregatedRecommendationList +} + +// 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 *IoTSecurityAggregatedRecommendationListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IoTSecurityAggregatedRecommendationListPage.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.itsarl) + if err != nil { + return err + } + page.itsarl = 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 *IoTSecurityAggregatedRecommendationListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page IoTSecurityAggregatedRecommendationListPage) NotDone() bool { + return !page.itsarl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page IoTSecurityAggregatedRecommendationListPage) Response() IoTSecurityAggregatedRecommendationList { + return page.itsarl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page IoTSecurityAggregatedRecommendationListPage) Values() []IoTSecurityAggregatedRecommendation { + if page.itsarl.IsEmpty() { + return nil + } + return *page.itsarl.Value +} + +// Creates a new instance of the IoTSecurityAggregatedRecommendationListPage type. +func NewIoTSecurityAggregatedRecommendationListPage(getNextPage func(context.Context, IoTSecurityAggregatedRecommendationList) (IoTSecurityAggregatedRecommendationList, error)) IoTSecurityAggregatedRecommendationListPage { + return IoTSecurityAggregatedRecommendationListPage{fn: getNextPage} +} + +// IoTSecurityAggregatedRecommendationProperties security Solution Recommendation Information +type IoTSecurityAggregatedRecommendationProperties struct { + // RecommendationName - Name of the recommendation + RecommendationName *string `json:"recommendationName,omitempty"` + // RecommendationDisplayName - READ-ONLY; Display name of the recommendation type. + RecommendationDisplayName *string `json:"recommendationDisplayName,omitempty"` + // Description - READ-ONLY; Description of the incident and what it means + Description *string `json:"description,omitempty"` + // RecommendationTypeID - READ-ONLY; The recommendation-type GUID. + RecommendationTypeID *string `json:"recommendationTypeId,omitempty"` + // DetectedBy - READ-ONLY; Name of the vendor that discovered the issue + DetectedBy *string `json:"detectedBy,omitempty"` + // RemediationSteps - READ-ONLY; Recommended steps for remediation + RemediationSteps *string `json:"remediationSteps,omitempty"` + // ReportedSeverity - READ-ONLY; Estimated severity of this recommendation. Possible values include: 'Informational', 'Low', 'Medium', 'High' + ReportedSeverity ReportedSeverity `json:"reportedSeverity,omitempty"` + // HealthyDevices - READ-ONLY; the number of the healthy devices within the solution + HealthyDevices *int32 `json:"healthyDevices,omitempty"` + // UnhealthyDeviceCount - READ-ONLY; the number of the unhealthy devices within the solution + UnhealthyDeviceCount *int32 `json:"unhealthyDeviceCount,omitempty"` + // LogAnalyticsQuery - READ-ONLY; query in log analytics to get the list of affected devices/alerts + LogAnalyticsQuery *string `json:"logAnalyticsQuery,omitempty"` +} + +// IoTSecurityAlertedDevice statistic information about the number of alerts per device during the last +// period +type IoTSecurityAlertedDevice struct { + // DeviceID - READ-ONLY; Name of the alert type + DeviceID *string `json:"deviceId,omitempty"` + // AlertsCount - READ-ONLY; the number of alerts raised for this device + AlertsCount *int32 `json:"alertsCount,omitempty"` +} + +// IoTSecurityAlertedDevicesList list of devices with the count of raised alerts +type IoTSecurityAlertedDevicesList struct { + // Value - List of aggregated alerts data + Value *[]IoTSecurityAlertedDevice `json:"value,omitempty"` + // NextLink - READ-ONLY; The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// IoTSecurityDeviceAlert statistic information about the number of alerts per alert type during the last +// period +type IoTSecurityDeviceAlert struct { + // AlertDisplayName - READ-ONLY; Display name of the alert + AlertDisplayName *string `json:"alertDisplayName,omitempty"` + // ReportedSeverity - READ-ONLY; Estimated severity of this alert. Possible values include: 'Informational', 'Low', 'Medium', 'High' + ReportedSeverity ReportedSeverity `json:"reportedSeverity,omitempty"` + // AlertsCount - READ-ONLY; the number of alerts raised for this alert type + AlertsCount *int32 `json:"alertsCount,omitempty"` +} + +// IoTSecurityDeviceAlertsList list of alerts with the count of raised alerts +type IoTSecurityDeviceAlertsList struct { + // Value - List of top alerts data + Value *[]IoTSecurityDeviceAlert `json:"value,omitempty"` + // NextLink - READ-ONLY; The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// IoTSecurityDeviceRecommendation statistic information about the number of recommendations per +// recommendation type +type IoTSecurityDeviceRecommendation struct { + // RecommendationDisplayName - READ-ONLY; Display name of the recommendation + RecommendationDisplayName *string `json:"recommendationDisplayName,omitempty"` + // ReportedSeverity - READ-ONLY; Estimated severity of this recommendation. Possible values include: 'Informational', 'Low', 'Medium', 'High' + ReportedSeverity ReportedSeverity `json:"reportedSeverity,omitempty"` + // DevicesCount - READ-ONLY; the number of device with this recommendation + DevicesCount *int32 `json:"devicesCount,omitempty"` +} + +// IoTSecurityDeviceRecommendationsList list of recommendations with the count of devices +type IoTSecurityDeviceRecommendationsList struct { + // Value - List of aggregated recommendation data + Value *[]IoTSecurityDeviceRecommendation `json:"value,omitempty"` + // NextLink - READ-ONLY; The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// IoTSecuritySolutionAnalyticsModel security Analytics of a security solution +type IoTSecuritySolutionAnalyticsModel struct { + autorest.Response `json:"-"` + // IoTSecuritySolutionAnalyticsModelProperties - Security Solution Aggregated Alert data + *IoTSecuritySolutionAnalyticsModelProperties `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 IoTSecuritySolutionAnalyticsModel. +func (itssam IoTSecuritySolutionAnalyticsModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if itssam.IoTSecuritySolutionAnalyticsModelProperties != nil { + objectMap["properties"] = itssam.IoTSecuritySolutionAnalyticsModelProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for IoTSecuritySolutionAnalyticsModel struct. +func (itssam *IoTSecuritySolutionAnalyticsModel) 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 ioTSecuritySolutionAnalyticsModelProperties IoTSecuritySolutionAnalyticsModelProperties + err = json.Unmarshal(*v, &ioTSecuritySolutionAnalyticsModelProperties) + if err != nil { + return err + } + itssam.IoTSecuritySolutionAnalyticsModelProperties = &ioTSecuritySolutionAnalyticsModelProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + itssam.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + itssam.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + itssam.Type = &typeVar + } + } + } + + return nil +} + +// IoTSecuritySolutionAnalyticsModelList list of Security Analytics of a security solution +type IoTSecuritySolutionAnalyticsModelList struct { + autorest.Response `json:"-"` + // Value - List of Security Analytics of a security solution + Value *[]IoTSecuritySolutionAnalyticsModel `json:"value,omitempty"` + // NextLink - READ-ONLY; The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// IoTSecuritySolutionAnalyticsModelProperties security Analytics of a security solution properties +type IoTSecuritySolutionAnalyticsModelProperties struct { + // Metrics - READ-ONLY; Security Analytics of a security solution + Metrics *IoTSeverityMetrics `json:"metrics,omitempty"` + // UnhealthyDeviceCount - READ-ONLY; number of unhealthy devices + UnhealthyDeviceCount *int32 `json:"unhealthyDeviceCount,omitempty"` + // DevicesMetrics - READ-ONLY; The list of devices metrics by the aggregated date. + DevicesMetrics *[]IoTSecuritySolutionAnalyticsModelPropertiesDevicesMetricsItem `json:"devicesMetrics,omitempty"` + // TopAlertedDevices - The list of top 3 devices with the most attacked. + TopAlertedDevices *IoTSecurityAlertedDevicesList `json:"topAlertedDevices,omitempty"` + // MostPrevalentDeviceAlerts - The list of most prevalent 3 alerts. + MostPrevalentDeviceAlerts *IoTSecurityDeviceAlertsList `json:"mostPrevalentDeviceAlerts,omitempty"` + // MostPrevalentDeviceRecommendations - The list of most prevalent 3 recommendations. + MostPrevalentDeviceRecommendations *IoTSecurityDeviceRecommendationsList `json:"mostPrevalentDeviceRecommendations,omitempty"` +} + +// IoTSecuritySolutionAnalyticsModelPropertiesDevicesMetricsItem ... +type IoTSecuritySolutionAnalyticsModelPropertiesDevicesMetricsItem struct { + // Date - the date of the metrics + Date *date.Time `json:"date,omitempty"` + // DevicesMetrics - devices alerts count by severity. + DevicesMetrics *IoTSeverityMetrics `json:"devicesMetrics,omitempty"` +} + +// IoTSecuritySolutionModel security Solution +type IoTSecuritySolutionModel struct { + autorest.Response `json:"-"` + // 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"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // Location - The resource location. + Location *string `json:"location,omitempty"` + // IoTSecuritySolutionProperties - Security Solution data + *IoTSecuritySolutionProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for IoTSecuritySolutionModel. +func (itssm IoTSecuritySolutionModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if itssm.Tags != nil { + objectMap["tags"] = itssm.Tags + } + if itssm.Location != nil { + objectMap["location"] = itssm.Location + } + if itssm.IoTSecuritySolutionProperties != nil { + objectMap["properties"] = itssm.IoTSecuritySolutionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for IoTSecuritySolutionModel struct. +func (itssm *IoTSecuritySolutionModel) 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 "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + itssm.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + itssm.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + itssm.Type = &typeVar + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + itssm.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + itssm.Location = &location + } + case "properties": + if v != nil { + var ioTSecuritySolutionProperties IoTSecuritySolutionProperties + err = json.Unmarshal(*v, &ioTSecuritySolutionProperties) + if err != nil { + return err + } + itssm.IoTSecuritySolutionProperties = &ioTSecuritySolutionProperties + } + } + } + + return nil +} + +// IoTSecuritySolutionProperties security Solution setting data +type IoTSecuritySolutionProperties struct { + // Workspace - Workspace resource ID + Workspace *string `json:"workspace,omitempty"` + // DisplayName - Resource display name. + DisplayName *string `json:"displayName,omitempty"` + // Status - Security solution status. Possible values include: 'Enabled', 'Disabled' + Status SolutionStatus `json:"status,omitempty"` + // Export - List of additional export to workspace data options + Export *[]ExportData `json:"export,omitempty"` + // DisabledDataSources - Disabled data sources. Disabling these data sources compromises the system. + DisabledDataSources *[]DataSource `json:"disabledDataSources,omitempty"` + // IotHubs - IoT Hub resource IDs + IotHubs *[]string `json:"iotHubs,omitempty"` + UserDefinedResources *UserDefinedResourcesProperties `json:"userDefinedResources,omitempty"` + // AutoDiscoveredResources - READ-ONLY; List of resources that were automatically discovered as relevant to the security solution. + AutoDiscoveredResources *[]string `json:"autoDiscoveredResources,omitempty"` + RecommendationsConfiguration *[]RecommendationConfigurationProperties `json:"recommendationsConfiguration,omitempty"` +} + +// IoTSecuritySolutionsList list of iot solutions +type IoTSecuritySolutionsList struct { + autorest.Response `json:"-"` + // Value - List of security solutions + Value *[]IoTSecuritySolutionModel `json:"value,omitempty"` + // NextLink - READ-ONLY; The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// IoTSecuritySolutionsListIterator provides access to a complete listing of IoTSecuritySolutionModel +// values. +type IoTSecuritySolutionsListIterator struct { + i int + page IoTSecuritySolutionsListPage +} + +// 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 *IoTSecuritySolutionsListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IoTSecuritySolutionsListIterator.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 *IoTSecuritySolutionsListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter IoTSecuritySolutionsListIterator) 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 IoTSecuritySolutionsListIterator) Response() IoTSecuritySolutionsList { + 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 IoTSecuritySolutionsListIterator) Value() IoTSecuritySolutionModel { + if !iter.page.NotDone() { + return IoTSecuritySolutionModel{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the IoTSecuritySolutionsListIterator type. +func NewIoTSecuritySolutionsListIterator(page IoTSecuritySolutionsListPage) IoTSecuritySolutionsListIterator { + return IoTSecuritySolutionsListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (itssl IoTSecuritySolutionsList) IsEmpty() bool { + return itssl.Value == nil || len(*itssl.Value) == 0 +} + +// ioTSecuritySolutionsListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (itssl IoTSecuritySolutionsList) ioTSecuritySolutionsListPreparer(ctx context.Context) (*http.Request, error) { + if itssl.NextLink == nil || len(to.String(itssl.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(itssl.NextLink))) +} + +// IoTSecuritySolutionsListPage contains a page of IoTSecuritySolutionModel values. +type IoTSecuritySolutionsListPage struct { + fn func(context.Context, IoTSecuritySolutionsList) (IoTSecuritySolutionsList, error) + itssl IoTSecuritySolutionsList +} + +// 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 *IoTSecuritySolutionsListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IoTSecuritySolutionsListPage.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.itssl) + if err != nil { + return err + } + page.itssl = 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 *IoTSecuritySolutionsListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page IoTSecuritySolutionsListPage) NotDone() bool { + return !page.itssl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page IoTSecuritySolutionsListPage) Response() IoTSecuritySolutionsList { + return page.itssl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page IoTSecuritySolutionsListPage) Values() []IoTSecuritySolutionModel { + if page.itssl.IsEmpty() { + return nil + } + return *page.itssl.Value +} + +// Creates a new instance of the IoTSecuritySolutionsListPage type. +func NewIoTSecuritySolutionsListPage(getNextPage func(context.Context, IoTSecuritySolutionsList) (IoTSecuritySolutionsList, error)) IoTSecuritySolutionsListPage { + return IoTSecuritySolutionsListPage{fn: getNextPage} +} + +// IoTSeverityMetrics severity metrics +type IoTSeverityMetrics struct { + // High - count of high severity items + High *int32 `json:"high,omitempty"` + // Medium - count of medium severity items + Medium *int32 `json:"medium,omitempty"` + // Low - count of low severity items + Low *int32 `json:"low,omitempty"` +} + +// JitNetworkAccessPoliciesList ... +type JitNetworkAccessPoliciesList struct { + autorest.Response `json:"-"` + Value *[]JitNetworkAccessPolicy `json:"value,omitempty"` + // NextLink - READ-ONLY; The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// JitNetworkAccessPoliciesListIterator provides access to a complete listing of JitNetworkAccessPolicy +// values. +type JitNetworkAccessPoliciesListIterator struct { + i int + page JitNetworkAccessPoliciesListPage +} + +// 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 *JitNetworkAccessPoliciesListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JitNetworkAccessPoliciesListIterator.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 *JitNetworkAccessPoliciesListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter JitNetworkAccessPoliciesListIterator) 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 JitNetworkAccessPoliciesListIterator) Response() JitNetworkAccessPoliciesList { + 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 JitNetworkAccessPoliciesListIterator) Value() JitNetworkAccessPolicy { + if !iter.page.NotDone() { + return JitNetworkAccessPolicy{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the JitNetworkAccessPoliciesListIterator type. +func NewJitNetworkAccessPoliciesListIterator(page JitNetworkAccessPoliciesListPage) JitNetworkAccessPoliciesListIterator { + return JitNetworkAccessPoliciesListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (jnapl JitNetworkAccessPoliciesList) IsEmpty() bool { + return jnapl.Value == nil || len(*jnapl.Value) == 0 +} + +// jitNetworkAccessPoliciesListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (jnapl JitNetworkAccessPoliciesList) jitNetworkAccessPoliciesListPreparer(ctx context.Context) (*http.Request, error) { + if jnapl.NextLink == nil || len(to.String(jnapl.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(jnapl.NextLink))) +} + +// JitNetworkAccessPoliciesListPage contains a page of JitNetworkAccessPolicy values. +type JitNetworkAccessPoliciesListPage struct { + fn func(context.Context, JitNetworkAccessPoliciesList) (JitNetworkAccessPoliciesList, error) + jnapl JitNetworkAccessPoliciesList +} + +// 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 *JitNetworkAccessPoliciesListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JitNetworkAccessPoliciesListPage.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.jnapl) + if err != nil { + return err + } + page.jnapl = 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 *JitNetworkAccessPoliciesListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page JitNetworkAccessPoliciesListPage) NotDone() bool { + return !page.jnapl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page JitNetworkAccessPoliciesListPage) Response() JitNetworkAccessPoliciesList { + return page.jnapl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page JitNetworkAccessPoliciesListPage) Values() []JitNetworkAccessPolicy { + if page.jnapl.IsEmpty() { + return nil + } + return *page.jnapl.Value +} + +// Creates a new instance of the JitNetworkAccessPoliciesListPage type. +func NewJitNetworkAccessPoliciesListPage(getNextPage func(context.Context, JitNetworkAccessPoliciesList) (JitNetworkAccessPoliciesList, error)) JitNetworkAccessPoliciesListPage { + return JitNetworkAccessPoliciesListPage{fn: getNextPage} +} + +// JitNetworkAccessPolicy ... +type JitNetworkAccessPolicy struct { + autorest.Response `json:"-"` + // 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"` + // Kind - Kind of the resource + Kind *string `json:"kind,omitempty"` + // Location - READ-ONLY; Location where the resource is stored + Location *string `json:"location,omitempty"` + *JitNetworkAccessPolicyProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for JitNetworkAccessPolicy. +func (jnap JitNetworkAccessPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if jnap.Kind != nil { + objectMap["kind"] = jnap.Kind + } + if jnap.JitNetworkAccessPolicyProperties != nil { + objectMap["properties"] = jnap.JitNetworkAccessPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for JitNetworkAccessPolicy struct. +func (jnap *JitNetworkAccessPolicy) 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 "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + jnap.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + jnap.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + jnap.Type = &typeVar + } + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + jnap.Kind = &kind + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + jnap.Location = &location + } + case "properties": + if v != nil { + var jitNetworkAccessPolicyProperties JitNetworkAccessPolicyProperties + err = json.Unmarshal(*v, &jitNetworkAccessPolicyProperties) + if err != nil { + return err + } + jnap.JitNetworkAccessPolicyProperties = &jitNetworkAccessPolicyProperties + } + } + } + + return nil +} + +// JitNetworkAccessPolicyInitiatePort ... +type JitNetworkAccessPolicyInitiatePort struct { + Number *int32 `json:"number,omitempty"` + // AllowedSourceAddressPrefix - Source of the allowed traffic. If omitted, the request will be for the source IP address of the initiate request. + AllowedSourceAddressPrefix *string `json:"allowedSourceAddressPrefix,omitempty"` + // EndTimeUtc - The time to close the request in UTC + EndTimeUtc *date.Time `json:"endTimeUtc,omitempty"` +} + +// JitNetworkAccessPolicyInitiateRequest ... +type JitNetworkAccessPolicyInitiateRequest struct { + // VirtualMachines - A list of virtual machines & ports to open access for + VirtualMachines *[]JitNetworkAccessPolicyInitiateVirtualMachine `json:"virtualMachines,omitempty"` +} + +// JitNetworkAccessPolicyInitiateVirtualMachine ... +type JitNetworkAccessPolicyInitiateVirtualMachine struct { + // ID - Resource ID of the virtual machine that is linked to this policy + ID *string `json:"id,omitempty"` + // Ports - The ports to open for the resource with the `id` + Ports *[]JitNetworkAccessPolicyInitiatePort `json:"ports,omitempty"` +} + +// JitNetworkAccessPolicyProperties ... +type JitNetworkAccessPolicyProperties struct { + // VirtualMachines - Configurations for Microsoft.Compute/virtualMachines resource type. + VirtualMachines *[]JitNetworkAccessPolicyVirtualMachine `json:"virtualMachines,omitempty"` + Requests *[]JitNetworkAccessRequest `json:"requests,omitempty"` + // ProvisioningState - READ-ONLY; Gets the provisioning state of the Just-in-Time policy. + ProvisioningState *string `json:"provisioningState,omitempty"` +} + +// JitNetworkAccessPolicyVirtualMachine ... +type JitNetworkAccessPolicyVirtualMachine struct { + // ID - Resource ID of the virtual machine that is linked to this policy + ID *string `json:"id,omitempty"` + // Ports - Port configurations for the virtual machine + Ports *[]JitNetworkAccessPortRule `json:"ports,omitempty"` + // PublicIPAddress - Public IP address of the Azure Firewall that is linked to this policy, if applicable + PublicIPAddress *string `json:"publicIpAddress,omitempty"` +} + +// JitNetworkAccessPortRule ... +type JitNetworkAccessPortRule struct { + Number *int32 `json:"number,omitempty"` + // Protocol - Possible values include: 'TCP', 'UDP', 'All' + Protocol Protocol `json:"protocol,omitempty"` + // AllowedSourceAddressPrefix - Mutually exclusive with the "allowedSourceAddressPrefixes" parameter. Should be an IP address or CIDR, for example "192.168.0.3" or "192.168.0.0/16". + AllowedSourceAddressPrefix *string `json:"allowedSourceAddressPrefix,omitempty"` + // AllowedSourceAddressPrefixes - Mutually exclusive with the "allowedSourceAddressPrefix" parameter. AllowedSourceAddressPrefixes *[]string `json:"allowedSourceAddressPrefixes,omitempty"` // MaxRequestAccessDuration - Maximum duration requests can be made for. In ISO 8601 duration format. Minimum 5 minutes, maximum 1 day MaxRequestAccessDuration *string `json:"maxRequestAccessDuration,omitempty"` @@ -4109,6 +5170,16 @@ type PricingProperties struct { FreeTrialRemainingTime *string `json:"freeTrialRemainingTime,omitempty"` } +// RecommendationConfigurationProperties recommendation configuration +type RecommendationConfigurationProperties struct { + // RecommendationType - The recommendation type. Possible values include: 'OpenPortsOnDevice', 'PermissiveFirewallPolicy', 'PermissiveFirewallRuleInput', 'PermissiveFirewallRuleOut', 'OperationSystemNotValid', 'UnutilizedMessagesFromAgent', 'SecurityTwinConfigurationNotOptimal', 'SecurityTwinConfigurationConflict', 'IdenticalAuthenticationCredentials', 'DenyDefaultIPPolicy', 'TooLargeIPRange', 'EnableDiagnosticsLog' + RecommendationType RecommendationType `json:"recommendationType,omitempty"` + // Description - READ-ONLY + Description *string `json:"description,omitempty"` + // Status - Recommendation status. The recommendation is not generated when the status is turned off. Possible values include: 'TurnedOff', 'TurnedOn' + Status RecommendationConfigStatus `json:"status,omitempty"` +} + // RegulatoryComplianceAssessment regulatory compliance assessment details and state type RegulatoryComplianceAssessment struct { autorest.Response `json:"-"` @@ -5090,6 +6161,21 @@ func NewSettingsListPage(getNextPage func(context.Context, SettingsList) (Settin return SettingsListPage{fn: getNextPage} } +// TagsResource a container holding only the Tags for a resource, allowing the user to update the tags. +type TagsResource struct { + // Tags - Resource tags + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for TagsResource. +func (tr TagsResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tr.Tags != nil { + objectMap["tags"] = tr.Tags + } + return json.Marshal(objectMap) +} + // Task security task that we recommend to do in order to strengthen security type Task struct { autorest.Response `json:"-"` @@ -5642,6 +6728,37 @@ type TopologySingleResourceParent struct { ResourceID *string `json:"resourceId,omitempty"` } +// UpdateIotSecuritySolutionData ... +type UpdateIotSecuritySolutionData struct { + UserDefinedResources *UserDefinedResourcesProperties `json:"userDefinedResources,omitempty"` + RecommendationsConfiguration *[]RecommendationConfigurationProperties `json:"recommendationsConfiguration,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for UpdateIotSecuritySolutionData. +func (uissd UpdateIotSecuritySolutionData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if uissd.UserDefinedResources != nil { + objectMap["userDefinedResources"] = uissd.UserDefinedResources + } + if uissd.RecommendationsConfiguration != nil { + objectMap["recommendationsConfiguration"] = uissd.RecommendationsConfiguration + } + if uissd.Tags != nil { + objectMap["tags"] = uissd.Tags + } + return json.Marshal(objectMap) +} + +// UserDefinedResourcesProperties properties of the solution's user defined resources. +type UserDefinedResourcesProperties struct { + // Query - Azure Resource Graph query which represents the security solution's user defined resources. Required to start with "where type != "Microsoft.Devices/IotHubs"" + Query *string `json:"query,omitempty"` + // QuerySubscriptions - List of Azure subscription ids on which the user defined resources query should be executed. + QuerySubscriptions *[]string `json:"querySubscriptions,omitempty"` +} + // WorkspaceSetting configures where to store the OMS agent data for workspaces under a scope type WorkspaceSetting struct { autorest.Response `json:"-"` 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 cf6808518f0e..064b14cc1245 100644 --- a/services/preview/security/mgmt/v3.0/security/securityapi/interfaces.go +++ b/services/preview/security/mgmt/v3.0/security/securityapi/interfaces.go @@ -197,6 +197,67 @@ type WorkspaceSettingsClientAPI interface { var _ WorkspaceSettingsClientAPI = (*security.WorkspaceSettingsClient)(nil) +// IoTSecuritySolutionsClientAPI contains the set of methods on the IoTSecuritySolutionsClient type. +type IoTSecuritySolutionsClientAPI interface { + List(ctx context.Context, filter string) (result security.IoTSecuritySolutionsListPage, err error) +} + +var _ IoTSecuritySolutionsClientAPI = (*security.IoTSecuritySolutionsClient)(nil) + +// IoTSecuritySolutionsResourceGroupClientAPI contains the set of methods on the IoTSecuritySolutionsResourceGroupClient type. +type IoTSecuritySolutionsResourceGroupClientAPI interface { + List(ctx context.Context, resourceGroupName string, filter string) (result security.IoTSecuritySolutionsListPage, err error) +} + +var _ IoTSecuritySolutionsResourceGroupClientAPI = (*security.IoTSecuritySolutionsResourceGroupClient)(nil) + +// IotSecuritySolutionClientAPI contains the set of methods on the IotSecuritySolutionClient type. +type IotSecuritySolutionClientAPI interface { + Create(ctx context.Context, resourceGroupName string, solutionName string, iotSecuritySolutionData security.IoTSecuritySolutionModel) (result security.IoTSecuritySolutionModel, err error) + Delete(ctx context.Context, resourceGroupName string, solutionName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, solutionName string) (result security.IoTSecuritySolutionModel, err error) + Update(ctx context.Context, resourceGroupName string, solutionName string, updateIotSecuritySolutionData security.UpdateIotSecuritySolutionData) (result security.IoTSecuritySolutionModel, err error) +} + +var _ IotSecuritySolutionClientAPI = (*security.IotSecuritySolutionClient)(nil) + +// IoTSecuritySolutionsAnalyticsClientAPI contains the set of methods on the IoTSecuritySolutionsAnalyticsClient type. +type IoTSecuritySolutionsAnalyticsClientAPI interface { + GetAll(ctx context.Context, resourceGroupName string, solutionName string) (result security.IoTSecuritySolutionAnalyticsModelList, err error) + GetDefault(ctx context.Context, resourceGroupName string, solutionName string) (result security.IoTSecuritySolutionAnalyticsModel, err error) +} + +var _ IoTSecuritySolutionsAnalyticsClientAPI = (*security.IoTSecuritySolutionsAnalyticsClient)(nil) + +// IoTSecuritySolutionsAnalyticsAggregatedAlertsClientAPI contains the set of methods on the IoTSecuritySolutionsAnalyticsAggregatedAlertsClient type. +type IoTSecuritySolutionsAnalyticsAggregatedAlertsClientAPI interface { + List(ctx context.Context, resourceGroupName string, solutionName string, top *int32) (result security.IoTSecurityAggregatedAlertListPage, err error) +} + +var _ IoTSecuritySolutionsAnalyticsAggregatedAlertsClientAPI = (*security.IoTSecuritySolutionsAnalyticsAggregatedAlertsClient)(nil) + +// IoTSecuritySolutionsAnalyticsAggregatedAlertClientAPI contains the set of methods on the IoTSecuritySolutionsAnalyticsAggregatedAlertClient type. +type IoTSecuritySolutionsAnalyticsAggregatedAlertClientAPI interface { + Dismiss(ctx context.Context, resourceGroupName string, solutionName string, aggregatedAlertName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, solutionName string, aggregatedAlertName string) (result security.IoTSecurityAggregatedAlert, err error) +} + +var _ IoTSecuritySolutionsAnalyticsAggregatedAlertClientAPI = (*security.IoTSecuritySolutionsAnalyticsAggregatedAlertClient)(nil) + +// IoTSecuritySolutionsAnalyticsRecommendationClientAPI contains the set of methods on the IoTSecuritySolutionsAnalyticsRecommendationClient type. +type IoTSecuritySolutionsAnalyticsRecommendationClientAPI interface { + Get(ctx context.Context, resourceGroupName string, solutionName string, aggregatedRecommendationName string) (result security.IoTSecurityAggregatedRecommendation, err error) +} + +var _ IoTSecuritySolutionsAnalyticsRecommendationClientAPI = (*security.IoTSecuritySolutionsAnalyticsRecommendationClient)(nil) + +// IoTSecuritySolutionsAnalyticsRecommendationsClientAPI contains the set of methods on the IoTSecuritySolutionsAnalyticsRecommendationsClient type. +type IoTSecuritySolutionsAnalyticsRecommendationsClientAPI interface { + List(ctx context.Context, resourceGroupName string, solutionName string, top *int32) (result security.IoTSecurityAggregatedRecommendationListPage, err error) +} + +var _ IoTSecuritySolutionsAnalyticsRecommendationsClientAPI = (*security.IoTSecuritySolutionsAnalyticsRecommendationsClient)(nil) + // RegulatoryComplianceStandardsClientAPI contains the set of methods on the RegulatoryComplianceStandardsClient type. type RegulatoryComplianceStandardsClientAPI interface { Get(ctx context.Context, regulatoryComplianceStandardName string) (result security.RegulatoryComplianceStandard, err error) From 7466986753fe5b9d0d3a4238e96c0f79dd5f80a3 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Fri, 12 Jul 2019 05:51:26 +0000 Subject: [PATCH 2/2] Generated from 49d63b74e2f79f927e36dd1628c82f51ecf353f1 remove dependency --- .../preview/security/mgmt/security/models.go | 60 ++++ .../mgmt/security/securityapi/models.go | 2 + .../mgmt/v1.0/security/assessmentsmetadata.go | 221 +++++++++++++ .../assessmentsmetadatasubscription.go | 241 ++++++++++++++ .../security/mgmt/v1.0/security/models.go | 295 ++++++++++++++++++ .../v1.0/security/securityapi/interfaces.go | 16 + .../mgmt/v2.0/security/assessmentsmetadata.go | 221 +++++++++++++ .../assessmentsmetadatasubscription.go | 241 ++++++++++++++ .../security/mgmt/v2.0/security/models.go | 295 ++++++++++++++++++ .../v2.0/security/securityapi/interfaces.go | 16 + .../mgmt/v3.0/security/assessmentsmetadata.go | 221 +++++++++++++ .../assessmentsmetadatasubscription.go | 241 ++++++++++++++ .../security/mgmt/v3.0/security/models.go | 295 ++++++++++++++++++ .../v3.0/security/securityapi/interfaces.go | 16 + 14 files changed, 2381 insertions(+) create mode 100644 services/preview/security/mgmt/v1.0/security/assessmentsmetadata.go create mode 100644 services/preview/security/mgmt/v1.0/security/assessmentsmetadatasubscription.go create mode 100644 services/preview/security/mgmt/v2.0/security/assessmentsmetadata.go create mode 100644 services/preview/security/mgmt/v2.0/security/assessmentsmetadatasubscription.go create mode 100644 services/preview/security/mgmt/v3.0/security/assessmentsmetadata.go create mode 100644 services/preview/security/mgmt/v3.0/security/assessmentsmetadatasubscription.go diff --git a/profiles/preview/preview/security/mgmt/security/models.go b/profiles/preview/preview/security/mgmt/security/models.go index 5e8378212ba4..2af323cf1f84 100644 --- a/profiles/preview/preview/security/mgmt/security/models.go +++ b/profiles/preview/preview/security/mgmt/security/models.go @@ -51,6 +51,13 @@ const ( AlertsToAdminsOn AlertsToAdmins = original.AlertsToAdminsOn ) +type AssessmentType = original.AssessmentType + +const ( + BuiltIn AssessmentType = original.BuiltIn + Custom AssessmentType = original.Custom +) + type AutoProvision = original.AutoProvision const ( @@ -58,6 +65,16 @@ const ( AutoProvisionOn AutoProvision = original.AutoProvisionOn ) +type Category = original.Category + +const ( + Compute Category = original.Compute + Data Category = original.Data + IdentityAndAccess Category = original.IdentityAndAccess + IoT Category = original.IoT + Network Category = original.Network +) + type ConnectionType = original.ConnectionType const ( @@ -161,6 +178,15 @@ const ( Medium ReportedSeverity = original.Medium ) +type RequiredPricingBundle = original.RequiredPricingBundle + +const ( + AppServices RequiredPricingBundle = original.AppServices + SQLServers RequiredPricingBundle = original.SQLServers + StorageAccounts RequiredPricingBundle = original.StorageAccounts + VirtualMachines RequiredPricingBundle = original.VirtualMachines +) + type ResourceStatus = original.ResourceStatus const ( @@ -232,6 +258,13 @@ type AscLocation = original.AscLocation type AscLocationList = original.AscLocationList type AscLocationListIterator = original.AscLocationListIterator type AscLocationListPage = original.AscLocationListPage +type AssessmentMetadata = original.AssessmentMetadata +type AssessmentMetadataList = original.AssessmentMetadataList +type AssessmentMetadataListIterator = original.AssessmentMetadataListIterator +type AssessmentMetadataListPage = original.AssessmentMetadataListPage +type AssessmentMetadataProperties = original.AssessmentMetadataProperties +type AssessmentsMetadataClient = original.AssessmentsMetadataClient +type AssessmentsMetadataSubscriptionClient = original.AssessmentsMetadataSubscriptionClient type AtaExternalSecuritySolution = original.AtaExternalSecuritySolution type AtaSolutionProperties = original.AtaSolutionProperties type AutoProvisioningSetting = original.AutoProvisioningSetting @@ -449,6 +482,24 @@ func NewAscLocationListIterator(page AscLocationListPage) AscLocationListIterato func NewAscLocationListPage(getNextPage func(context.Context, AscLocationList) (AscLocationList, error)) AscLocationListPage { return original.NewAscLocationListPage(getNextPage) } +func NewAssessmentMetadataListIterator(page AssessmentMetadataListPage) AssessmentMetadataListIterator { + return original.NewAssessmentMetadataListIterator(page) +} +func NewAssessmentMetadataListPage(getNextPage func(context.Context, AssessmentMetadataList) (AssessmentMetadataList, error)) AssessmentMetadataListPage { + return original.NewAssessmentMetadataListPage(getNextPage) +} +func NewAssessmentsMetadataClient(subscriptionID string, ascLocation string) AssessmentsMetadataClient { + return original.NewAssessmentsMetadataClient(subscriptionID, ascLocation) +} +func NewAssessmentsMetadataClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) AssessmentsMetadataClient { + return original.NewAssessmentsMetadataClientWithBaseURI(baseURI, subscriptionID, ascLocation) +} +func NewAssessmentsMetadataSubscriptionClient(subscriptionID string, ascLocation string) AssessmentsMetadataSubscriptionClient { + return original.NewAssessmentsMetadataSubscriptionClient(subscriptionID, ascLocation) +} +func NewAssessmentsMetadataSubscriptionClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) AssessmentsMetadataSubscriptionClient { + return original.NewAssessmentsMetadataSubscriptionClientWithBaseURI(baseURI, subscriptionID, ascLocation) +} func NewAutoProvisioningSettingListIterator(page AutoProvisioningSettingListPage) AutoProvisioningSettingListIterator { return original.NewAutoProvisioningSettingListIterator(page) } @@ -737,9 +788,15 @@ func PossibleAlertNotificationsValues() []AlertNotifications { func PossibleAlertsToAdminsValues() []AlertsToAdmins { return original.PossibleAlertsToAdminsValues() } +func PossibleAssessmentTypeValues() []AssessmentType { + return original.PossibleAssessmentTypeValues() +} func PossibleAutoProvisionValues() []AutoProvision { return original.PossibleAutoProvisionValues() } +func PossibleCategoryValues() []Category { + return original.PossibleCategoryValues() +} func PossibleConnectionTypeValues() []ConnectionType { return original.PossibleConnectionTypeValues() } @@ -776,6 +833,9 @@ func PossibleRecommendationTypeValues() []RecommendationType { func PossibleReportedSeverityValues() []ReportedSeverity { return original.PossibleReportedSeverityValues() } +func PossibleRequiredPricingBundleValues() []RequiredPricingBundle { + return original.PossibleRequiredPricingBundleValues() +} func PossibleResourceStatusValues() []ResourceStatus { return original.PossibleResourceStatusValues() } diff --git a/profiles/preview/preview/security/mgmt/security/securityapi/models.go b/profiles/preview/preview/security/mgmt/security/securityapi/models.go index be5a0930486c..45611f5942d9 100644 --- a/profiles/preview/preview/security/mgmt/security/securityapi/models.go +++ b/profiles/preview/preview/security/mgmt/security/securityapi/models.go @@ -24,6 +24,8 @@ import original "github.com/Azure/azure-sdk-for-go/services/preview/security/mgm type AdvancedThreatProtectionClientAPI = original.AdvancedThreatProtectionClientAPI type AlertsClientAPI = original.AlertsClientAPI type AllowedConnectionsClientAPI = original.AllowedConnectionsClientAPI +type AssessmentsMetadataClientAPI = original.AssessmentsMetadataClientAPI +type AssessmentsMetadataSubscriptionClientAPI = original.AssessmentsMetadataSubscriptionClientAPI type AutoProvisioningSettingsClientAPI = original.AutoProvisioningSettingsClientAPI type ComplianceResultsClientAPI = original.ComplianceResultsClientAPI type CompliancesClientAPI = original.CompliancesClientAPI diff --git a/services/preview/security/mgmt/v1.0/security/assessmentsmetadata.go b/services/preview/security/mgmt/v1.0/security/assessmentsmetadata.go new file mode 100644 index 000000000000..1fc3026a4c73 --- /dev/null +++ b/services/preview/security/mgmt/v1.0/security/assessmentsmetadata.go @@ -0,0 +1,221 @@ +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/tracing" + "net/http" +) + +// AssessmentsMetadataClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type AssessmentsMetadataClient struct { + BaseClient +} + +// NewAssessmentsMetadataClient creates an instance of the AssessmentsMetadataClient client. +func NewAssessmentsMetadataClient(subscriptionID string, ascLocation string) AssessmentsMetadataClient { + return NewAssessmentsMetadataClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewAssessmentsMetadataClientWithBaseURI creates an instance of the AssessmentsMetadataClient client. +func NewAssessmentsMetadataClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) AssessmentsMetadataClient { + return AssessmentsMetadataClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Get get metadata information on an assessment type +// Parameters: +// assessmentsMetadataName - the Assessment Key - Unique key for the assessment type +func (client AssessmentsMetadataClient) Get(ctx context.Context, assessmentsMetadataName string) (result AssessmentMetadata, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentsMetadataClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, assessmentsMetadataName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "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.AssessmentsMetadataClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client AssessmentsMetadataClient) GetPreparer(ctx context.Context, assessmentsMetadataName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "assessmentsMetadataName": autorest.Encode("path", assessmentsMetadataName), + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Security/assessmentsMetadata/{assessmentsMetadataName}", 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 AssessmentsMetadataClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AssessmentsMetadataClient) GetResponder(resp *http.Response) (result AssessmentMetadata, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List get metadata information on all assessment types +func (client AssessmentsMetadataClient) List(ctx context.Context) (result AssessmentMetadataListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentsMetadataClient.List") + defer func() { + sc := -1 + if result.aml.Response.Response != nil { + sc = result.aml.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.aml.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "List", resp, "Failure sending request") + return + } + + result.aml, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client AssessmentsMetadataClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Security/assessmentsMetadata"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client AssessmentsMetadataClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client AssessmentsMetadataClient) ListResponder(resp *http.Response) (result AssessmentMetadataList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client AssessmentsMetadataClient) listNextResults(ctx context.Context, lastResults AssessmentMetadataList) (result AssessmentMetadataList, err error) { + req, err := lastResults.assessmentMetadataListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client AssessmentsMetadataClient) ListComplete(ctx context.Context) (result AssessmentMetadataListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentsMetadataClient.List") + 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.List(ctx) + return +} diff --git a/services/preview/security/mgmt/v1.0/security/assessmentsmetadatasubscription.go b/services/preview/security/mgmt/v1.0/security/assessmentsmetadatasubscription.go new file mode 100644 index 000000000000..e88c4591d691 --- /dev/null +++ b/services/preview/security/mgmt/v1.0/security/assessmentsmetadatasubscription.go @@ -0,0 +1,241 @@ +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" +) + +// AssessmentsMetadataSubscriptionClient is the API spec for Microsoft.Security (Azure Security Center) resource +// provider +type AssessmentsMetadataSubscriptionClient struct { + BaseClient +} + +// NewAssessmentsMetadataSubscriptionClient creates an instance of the AssessmentsMetadataSubscriptionClient client. +func NewAssessmentsMetadataSubscriptionClient(subscriptionID string, ascLocation string) AssessmentsMetadataSubscriptionClient { + return NewAssessmentsMetadataSubscriptionClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewAssessmentsMetadataSubscriptionClientWithBaseURI creates an instance of the AssessmentsMetadataSubscriptionClient +// client. +func NewAssessmentsMetadataSubscriptionClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) AssessmentsMetadataSubscriptionClient { + return AssessmentsMetadataSubscriptionClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Get get metadata information on an assessment type in a specific subscription +// Parameters: +// assessmentsMetadataName - the Assessment Key - Unique key for the assessment type +func (client AssessmentsMetadataSubscriptionClient) Get(ctx context.Context, assessmentsMetadataName string) (result AssessmentMetadata, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentsMetadataSubscriptionClient.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}}}}); err != nil { + return result, validation.NewError("security.AssessmentsMetadataSubscriptionClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, assessmentsMetadataName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataSubscriptionClient", "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.AssessmentsMetadataSubscriptionClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataSubscriptionClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client AssessmentsMetadataSubscriptionClient) GetPreparer(ctx context.Context, assessmentsMetadataName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "assessmentsMetadataName": autorest.Encode("path", assessmentsMetadataName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentsMetadata/{assessmentsMetadataName}", 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 AssessmentsMetadataSubscriptionClient) 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 AssessmentsMetadataSubscriptionClient) GetResponder(resp *http.Response) (result AssessmentMetadata, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List get metadata information on all assessment types in a specific subscription +func (client AssessmentsMetadataSubscriptionClient) List(ctx context.Context) (result AssessmentMetadataListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentsMetadataSubscriptionClient.List") + defer func() { + sc := -1 + if result.aml.Response.Response != nil { + sc = result.aml.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}}}}); err != nil { + return result, validation.NewError("security.AssessmentsMetadataSubscriptionClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataSubscriptionClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.aml.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataSubscriptionClient", "List", resp, "Failure sending request") + return + } + + result.aml, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataSubscriptionClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client AssessmentsMetadataSubscriptionClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentsMetadata", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client AssessmentsMetadataSubscriptionClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client AssessmentsMetadataSubscriptionClient) ListResponder(resp *http.Response) (result AssessmentMetadataList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client AssessmentsMetadataSubscriptionClient) listNextResults(ctx context.Context, lastResults AssessmentMetadataList) (result AssessmentMetadataList, err error) { + req, err := lastResults.assessmentMetadataListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.AssessmentsMetadataSubscriptionClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.AssessmentsMetadataSubscriptionClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataSubscriptionClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client AssessmentsMetadataSubscriptionClient) ListComplete(ctx context.Context) (result AssessmentMetadataListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentsMetadataSubscriptionClient.List") + 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.List(ctx) + return +} diff --git a/services/preview/security/mgmt/v1.0/security/models.go b/services/preview/security/mgmt/v1.0/security/models.go index a3517580ed06..76c2fdd625cd 100644 --- a/services/preview/security/mgmt/v1.0/security/models.go +++ b/services/preview/security/mgmt/v1.0/security/models.go @@ -79,6 +79,21 @@ func PossibleAlertsToAdminsValues() []AlertsToAdmins { return []AlertsToAdmins{AlertsToAdminsOff, AlertsToAdminsOn} } +// AssessmentType enumerates the values for assessment type. +type AssessmentType string + +const ( + // BuiltIn ... + BuiltIn AssessmentType = "BuiltIn" + // Custom ... + Custom AssessmentType = "Custom" +) + +// PossibleAssessmentTypeValues returns an array of possible values for the AssessmentType const type. +func PossibleAssessmentTypeValues() []AssessmentType { + return []AssessmentType{BuiltIn, Custom} +} + // AutoProvision enumerates the values for auto provision. type AutoProvision string @@ -94,6 +109,27 @@ func PossibleAutoProvisionValues() []AutoProvision { return []AutoProvision{AutoProvisionOff, AutoProvisionOn} } +// Category enumerates the values for category. +type Category string + +const ( + // Compute ... + Compute Category = "Compute" + // Data ... + Data Category = "Data" + // IdentityAndAccess ... + IdentityAndAccess Category = "IdentityAndAccess" + // IoT ... + IoT Category = "IoT" + // Network ... + Network Category = "Network" +) + +// PossibleCategoryValues returns an array of possible values for the Category const type. +func PossibleCategoryValues() []Category { + return []Category{Compute, Data, IdentityAndAccess, IoT, Network} +} + // ConnectionType enumerates the values for connection type. type ConnectionType string @@ -230,6 +266,25 @@ func PossibleReportedSeverityValues() []ReportedSeverity { return []ReportedSeverity{High, Information, Low, Silent} } +// RequiredPricingBundle enumerates the values for required pricing bundle. +type RequiredPricingBundle string + +const ( + // AppServices ... + AppServices RequiredPricingBundle = "AppServices" + // SQLServers ... + SQLServers RequiredPricingBundle = "SqlServers" + // StorageAccounts ... + StorageAccounts RequiredPricingBundle = "StorageAccounts" + // VirtualMachines ... + VirtualMachines RequiredPricingBundle = "VirtualMachines" +) + +// PossibleRequiredPricingBundleValues returns an array of possible values for the RequiredPricingBundle const type. +func PossibleRequiredPricingBundleValues() []RequiredPricingBundle { + return []RequiredPricingBundle{AppServices, SQLServers, StorageAccounts, VirtualMachines} +} + // SettingKind enumerates the values for setting kind. type SettingKind string @@ -1489,6 +1544,246 @@ func NewAscLocationListPage(getNextPage func(context.Context, AscLocationList) ( return AscLocationListPage{fn: getNextPage} } +// AssessmentMetadata security assessment metadata +type AssessmentMetadata struct { + autorest.Response `json:"-"` + *AssessmentMetadataProperties `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 AssessmentMetadata. +func (am AssessmentMetadata) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if am.AssessmentMetadataProperties != nil { + objectMap["properties"] = am.AssessmentMetadataProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AssessmentMetadata struct. +func (am *AssessmentMetadata) 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 assessmentMetadataProperties AssessmentMetadataProperties + err = json.Unmarshal(*v, &assessmentMetadataProperties) + if err != nil { + return err + } + am.AssessmentMetadataProperties = &assessmentMetadataProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + am.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + am.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + am.Type = &typeVar + } + } + } + + return nil +} + +// AssessmentMetadataList list of security assessment metadata +type AssessmentMetadataList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY + Value *[]AssessmentMetadata `json:"value,omitempty"` + // NextLink - READ-ONLY; The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// AssessmentMetadataListIterator provides access to a complete listing of AssessmentMetadata values. +type AssessmentMetadataListIterator struct { + i int + page AssessmentMetadataListPage +} + +// 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 *AssessmentMetadataListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentMetadataListIterator.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 *AssessmentMetadataListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter AssessmentMetadataListIterator) 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 AssessmentMetadataListIterator) Response() AssessmentMetadataList { + 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 AssessmentMetadataListIterator) Value() AssessmentMetadata { + if !iter.page.NotDone() { + return AssessmentMetadata{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the AssessmentMetadataListIterator type. +func NewAssessmentMetadataListIterator(page AssessmentMetadataListPage) AssessmentMetadataListIterator { + return AssessmentMetadataListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (aml AssessmentMetadataList) IsEmpty() bool { + return aml.Value == nil || len(*aml.Value) == 0 +} + +// assessmentMetadataListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (aml AssessmentMetadataList) assessmentMetadataListPreparer(ctx context.Context) (*http.Request, error) { + if aml.NextLink == nil || len(to.String(aml.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(aml.NextLink))) +} + +// AssessmentMetadataListPage contains a page of AssessmentMetadata values. +type AssessmentMetadataListPage struct { + fn func(context.Context, AssessmentMetadataList) (AssessmentMetadataList, error) + aml AssessmentMetadataList +} + +// 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 *AssessmentMetadataListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentMetadataListPage.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.aml) + if err != nil { + return err + } + page.aml = 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 *AssessmentMetadataListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page AssessmentMetadataListPage) NotDone() bool { + return !page.aml.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page AssessmentMetadataListPage) Response() AssessmentMetadataList { + return page.aml +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page AssessmentMetadataListPage) Values() []AssessmentMetadata { + if page.aml.IsEmpty() { + return nil + } + return *page.aml.Value +} + +// Creates a new instance of the AssessmentMetadataListPage type. +func NewAssessmentMetadataListPage(getNextPage func(context.Context, AssessmentMetadataList) (AssessmentMetadataList, error)) AssessmentMetadataListPage { + return AssessmentMetadataListPage{fn: getNextPage} +} + +// AssessmentMetadataProperties describes properties of an assessment metadata. +type AssessmentMetadataProperties struct { + // DisplayName - READ-ONLY; User friendly display name of the assessment + DisplayName *string `json:"displayName,omitempty"` + // PolicyDefinitionID - READ-ONLY; Azure resource ID of the policy definition that turns this assessment calculation on + PolicyDefinitionID *string `json:"policyDefinitionId,omitempty"` + // Description - READ-ONLY; Human readable description of the assessment + Description *string `json:"description,omitempty"` + // RemediationDescription - READ-ONLY; Human readable description of what you should do to mitigate this security issue + RemediationDescription *string `json:"remediationDescription,omitempty"` + // Category - READ-ONLY + Category *[]Category `json:"category,omitempty"` + // SecureScoreWeight - READ-ONLY; Weight for the security score calculation. the higher this number, this severity of this assessment is higher + SecureScoreWeight *int32 `json:"secureScoreWeight,omitempty"` + // RequiredPricingBundle - READ-ONLY + RequiredPricingBundle *[]RequiredPricingBundle `json:"requiredPricingBundle,omitempty"` + // Preview - READ-ONLY; True if this assessment is in preview release status + Preview *bool `json:"preview,omitempty"` + // AssessmentType - READ-ONLY; BuiltIn if the assessment based on built-in Azure Policy definition, Custom if the assessment based on custom Azure Policy definition. Possible values include: 'BuiltIn', 'Custom' + AssessmentType AssessmentType `json:"assessmentType,omitempty"` +} + // AtaExternalSecuritySolution represents an ATA security solution which sends logs to an OMS workspace type AtaExternalSecuritySolution struct { Properties *AtaSolutionProperties `json:"properties,omitempty"` 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 8d8207b0e5f5..98583e0919a6 100644 --- a/services/preview/security/mgmt/v1.0/security/securityapi/interfaces.go +++ b/services/preview/security/mgmt/v1.0/security/securityapi/interfaces.go @@ -47,6 +47,22 @@ type RegulatoryComplianceAssessmentsClientAPI interface { var _ RegulatoryComplianceAssessmentsClientAPI = (*security.RegulatoryComplianceAssessmentsClient)(nil) +// AssessmentsMetadataClientAPI contains the set of methods on the AssessmentsMetadataClient type. +type AssessmentsMetadataClientAPI interface { + Get(ctx context.Context, assessmentsMetadataName string) (result security.AssessmentMetadata, err error) + List(ctx context.Context) (result security.AssessmentMetadataListPage, err error) +} + +var _ AssessmentsMetadataClientAPI = (*security.AssessmentsMetadataClient)(nil) + +// AssessmentsMetadataSubscriptionClientAPI contains the set of methods on the AssessmentsMetadataSubscriptionClient type. +type AssessmentsMetadataSubscriptionClientAPI interface { + Get(ctx context.Context, assessmentsMetadataName string) (result security.AssessmentMetadata, err error) + List(ctx context.Context) (result security.AssessmentMetadataListPage, err error) +} + +var _ AssessmentsMetadataSubscriptionClientAPI = (*security.AssessmentsMetadataSubscriptionClient)(nil) + // PricingsClientAPI contains the set of methods on the PricingsClient type. type PricingsClientAPI interface { CreateOrUpdateResourceGroupPricing(ctx context.Context, resourceGroupName string, pricingName string, pricing security.Pricing) (result security.Pricing, err error) diff --git a/services/preview/security/mgmt/v2.0/security/assessmentsmetadata.go b/services/preview/security/mgmt/v2.0/security/assessmentsmetadata.go new file mode 100644 index 000000000000..1fc3026a4c73 --- /dev/null +++ b/services/preview/security/mgmt/v2.0/security/assessmentsmetadata.go @@ -0,0 +1,221 @@ +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/tracing" + "net/http" +) + +// AssessmentsMetadataClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type AssessmentsMetadataClient struct { + BaseClient +} + +// NewAssessmentsMetadataClient creates an instance of the AssessmentsMetadataClient client. +func NewAssessmentsMetadataClient(subscriptionID string, ascLocation string) AssessmentsMetadataClient { + return NewAssessmentsMetadataClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewAssessmentsMetadataClientWithBaseURI creates an instance of the AssessmentsMetadataClient client. +func NewAssessmentsMetadataClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) AssessmentsMetadataClient { + return AssessmentsMetadataClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Get get metadata information on an assessment type +// Parameters: +// assessmentsMetadataName - the Assessment Key - Unique key for the assessment type +func (client AssessmentsMetadataClient) Get(ctx context.Context, assessmentsMetadataName string) (result AssessmentMetadata, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentsMetadataClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, assessmentsMetadataName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "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.AssessmentsMetadataClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client AssessmentsMetadataClient) GetPreparer(ctx context.Context, assessmentsMetadataName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "assessmentsMetadataName": autorest.Encode("path", assessmentsMetadataName), + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Security/assessmentsMetadata/{assessmentsMetadataName}", 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 AssessmentsMetadataClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AssessmentsMetadataClient) GetResponder(resp *http.Response) (result AssessmentMetadata, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List get metadata information on all assessment types +func (client AssessmentsMetadataClient) List(ctx context.Context) (result AssessmentMetadataListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentsMetadataClient.List") + defer func() { + sc := -1 + if result.aml.Response.Response != nil { + sc = result.aml.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.aml.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "List", resp, "Failure sending request") + return + } + + result.aml, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client AssessmentsMetadataClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Security/assessmentsMetadata"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client AssessmentsMetadataClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client AssessmentsMetadataClient) ListResponder(resp *http.Response) (result AssessmentMetadataList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client AssessmentsMetadataClient) listNextResults(ctx context.Context, lastResults AssessmentMetadataList) (result AssessmentMetadataList, err error) { + req, err := lastResults.assessmentMetadataListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client AssessmentsMetadataClient) ListComplete(ctx context.Context) (result AssessmentMetadataListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentsMetadataClient.List") + 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.List(ctx) + return +} diff --git a/services/preview/security/mgmt/v2.0/security/assessmentsmetadatasubscription.go b/services/preview/security/mgmt/v2.0/security/assessmentsmetadatasubscription.go new file mode 100644 index 000000000000..e88c4591d691 --- /dev/null +++ b/services/preview/security/mgmt/v2.0/security/assessmentsmetadatasubscription.go @@ -0,0 +1,241 @@ +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" +) + +// AssessmentsMetadataSubscriptionClient is the API spec for Microsoft.Security (Azure Security Center) resource +// provider +type AssessmentsMetadataSubscriptionClient struct { + BaseClient +} + +// NewAssessmentsMetadataSubscriptionClient creates an instance of the AssessmentsMetadataSubscriptionClient client. +func NewAssessmentsMetadataSubscriptionClient(subscriptionID string, ascLocation string) AssessmentsMetadataSubscriptionClient { + return NewAssessmentsMetadataSubscriptionClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewAssessmentsMetadataSubscriptionClientWithBaseURI creates an instance of the AssessmentsMetadataSubscriptionClient +// client. +func NewAssessmentsMetadataSubscriptionClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) AssessmentsMetadataSubscriptionClient { + return AssessmentsMetadataSubscriptionClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Get get metadata information on an assessment type in a specific subscription +// Parameters: +// assessmentsMetadataName - the Assessment Key - Unique key for the assessment type +func (client AssessmentsMetadataSubscriptionClient) Get(ctx context.Context, assessmentsMetadataName string) (result AssessmentMetadata, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentsMetadataSubscriptionClient.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}}}}); err != nil { + return result, validation.NewError("security.AssessmentsMetadataSubscriptionClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, assessmentsMetadataName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataSubscriptionClient", "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.AssessmentsMetadataSubscriptionClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataSubscriptionClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client AssessmentsMetadataSubscriptionClient) GetPreparer(ctx context.Context, assessmentsMetadataName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "assessmentsMetadataName": autorest.Encode("path", assessmentsMetadataName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentsMetadata/{assessmentsMetadataName}", 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 AssessmentsMetadataSubscriptionClient) 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 AssessmentsMetadataSubscriptionClient) GetResponder(resp *http.Response) (result AssessmentMetadata, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List get metadata information on all assessment types in a specific subscription +func (client AssessmentsMetadataSubscriptionClient) List(ctx context.Context) (result AssessmentMetadataListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentsMetadataSubscriptionClient.List") + defer func() { + sc := -1 + if result.aml.Response.Response != nil { + sc = result.aml.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}}}}); err != nil { + return result, validation.NewError("security.AssessmentsMetadataSubscriptionClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataSubscriptionClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.aml.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataSubscriptionClient", "List", resp, "Failure sending request") + return + } + + result.aml, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataSubscriptionClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client AssessmentsMetadataSubscriptionClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentsMetadata", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client AssessmentsMetadataSubscriptionClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client AssessmentsMetadataSubscriptionClient) ListResponder(resp *http.Response) (result AssessmentMetadataList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client AssessmentsMetadataSubscriptionClient) listNextResults(ctx context.Context, lastResults AssessmentMetadataList) (result AssessmentMetadataList, err error) { + req, err := lastResults.assessmentMetadataListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.AssessmentsMetadataSubscriptionClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.AssessmentsMetadataSubscriptionClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataSubscriptionClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client AssessmentsMetadataSubscriptionClient) ListComplete(ctx context.Context) (result AssessmentMetadataListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentsMetadataSubscriptionClient.List") + 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.List(ctx) + return +} diff --git a/services/preview/security/mgmt/v2.0/security/models.go b/services/preview/security/mgmt/v2.0/security/models.go index 88c0d9fc630b..bfd9fde122c0 100644 --- a/services/preview/security/mgmt/v2.0/security/models.go +++ b/services/preview/security/mgmt/v2.0/security/models.go @@ -79,6 +79,21 @@ func PossibleAlertsToAdminsValues() []AlertsToAdmins { return []AlertsToAdmins{AlertsToAdminsOff, AlertsToAdminsOn} } +// AssessmentType enumerates the values for assessment type. +type AssessmentType string + +const ( + // BuiltIn ... + BuiltIn AssessmentType = "BuiltIn" + // Custom ... + Custom AssessmentType = "Custom" +) + +// PossibleAssessmentTypeValues returns an array of possible values for the AssessmentType const type. +func PossibleAssessmentTypeValues() []AssessmentType { + return []AssessmentType{BuiltIn, Custom} +} + // AutoProvision enumerates the values for auto provision. type AutoProvision string @@ -94,6 +109,27 @@ func PossibleAutoProvisionValues() []AutoProvision { return []AutoProvision{AutoProvisionOff, AutoProvisionOn} } +// Category enumerates the values for category. +type Category string + +const ( + // Compute ... + Compute Category = "Compute" + // Data ... + Data Category = "Data" + // IdentityAndAccess ... + IdentityAndAccess Category = "IdentityAndAccess" + // IoT ... + IoT Category = "IoT" + // Network ... + Network Category = "Network" +) + +// PossibleCategoryValues returns an array of possible values for the Category const type. +func PossibleCategoryValues() []Category { + return []Category{Compute, Data, IdentityAndAccess, IoT, Network} +} + // ConnectionType enumerates the values for connection type. type ConnectionType string @@ -230,6 +266,25 @@ func PossibleReportedSeverityValues() []ReportedSeverity { return []ReportedSeverity{High, Informational, Low, Medium} } +// RequiredPricingBundle enumerates the values for required pricing bundle. +type RequiredPricingBundle string + +const ( + // AppServices ... + AppServices RequiredPricingBundle = "AppServices" + // SQLServers ... + SQLServers RequiredPricingBundle = "SqlServers" + // StorageAccounts ... + StorageAccounts RequiredPricingBundle = "StorageAccounts" + // VirtualMachines ... + VirtualMachines RequiredPricingBundle = "VirtualMachines" +) + +// PossibleRequiredPricingBundleValues returns an array of possible values for the RequiredPricingBundle const type. +func PossibleRequiredPricingBundleValues() []RequiredPricingBundle { + return []RequiredPricingBundle{AppServices, SQLServers, StorageAccounts, VirtualMachines} +} + // SettingKind enumerates the values for setting kind. type SettingKind string @@ -1489,6 +1544,246 @@ func NewAscLocationListPage(getNextPage func(context.Context, AscLocationList) ( return AscLocationListPage{fn: getNextPage} } +// AssessmentMetadata security assessment metadata +type AssessmentMetadata struct { + autorest.Response `json:"-"` + *AssessmentMetadataProperties `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 AssessmentMetadata. +func (am AssessmentMetadata) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if am.AssessmentMetadataProperties != nil { + objectMap["properties"] = am.AssessmentMetadataProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AssessmentMetadata struct. +func (am *AssessmentMetadata) 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 assessmentMetadataProperties AssessmentMetadataProperties + err = json.Unmarshal(*v, &assessmentMetadataProperties) + if err != nil { + return err + } + am.AssessmentMetadataProperties = &assessmentMetadataProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + am.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + am.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + am.Type = &typeVar + } + } + } + + return nil +} + +// AssessmentMetadataList list of security assessment metadata +type AssessmentMetadataList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY + Value *[]AssessmentMetadata `json:"value,omitempty"` + // NextLink - READ-ONLY; The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// AssessmentMetadataListIterator provides access to a complete listing of AssessmentMetadata values. +type AssessmentMetadataListIterator struct { + i int + page AssessmentMetadataListPage +} + +// 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 *AssessmentMetadataListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentMetadataListIterator.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 *AssessmentMetadataListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter AssessmentMetadataListIterator) 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 AssessmentMetadataListIterator) Response() AssessmentMetadataList { + 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 AssessmentMetadataListIterator) Value() AssessmentMetadata { + if !iter.page.NotDone() { + return AssessmentMetadata{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the AssessmentMetadataListIterator type. +func NewAssessmentMetadataListIterator(page AssessmentMetadataListPage) AssessmentMetadataListIterator { + return AssessmentMetadataListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (aml AssessmentMetadataList) IsEmpty() bool { + return aml.Value == nil || len(*aml.Value) == 0 +} + +// assessmentMetadataListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (aml AssessmentMetadataList) assessmentMetadataListPreparer(ctx context.Context) (*http.Request, error) { + if aml.NextLink == nil || len(to.String(aml.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(aml.NextLink))) +} + +// AssessmentMetadataListPage contains a page of AssessmentMetadata values. +type AssessmentMetadataListPage struct { + fn func(context.Context, AssessmentMetadataList) (AssessmentMetadataList, error) + aml AssessmentMetadataList +} + +// 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 *AssessmentMetadataListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentMetadataListPage.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.aml) + if err != nil { + return err + } + page.aml = 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 *AssessmentMetadataListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page AssessmentMetadataListPage) NotDone() bool { + return !page.aml.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page AssessmentMetadataListPage) Response() AssessmentMetadataList { + return page.aml +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page AssessmentMetadataListPage) Values() []AssessmentMetadata { + if page.aml.IsEmpty() { + return nil + } + return *page.aml.Value +} + +// Creates a new instance of the AssessmentMetadataListPage type. +func NewAssessmentMetadataListPage(getNextPage func(context.Context, AssessmentMetadataList) (AssessmentMetadataList, error)) AssessmentMetadataListPage { + return AssessmentMetadataListPage{fn: getNextPage} +} + +// AssessmentMetadataProperties describes properties of an assessment metadata. +type AssessmentMetadataProperties struct { + // DisplayName - READ-ONLY; User friendly display name of the assessment + DisplayName *string `json:"displayName,omitempty"` + // PolicyDefinitionID - READ-ONLY; Azure resource ID of the policy definition that turns this assessment calculation on + PolicyDefinitionID *string `json:"policyDefinitionId,omitempty"` + // Description - READ-ONLY; Human readable description of the assessment + Description *string `json:"description,omitempty"` + // RemediationDescription - READ-ONLY; Human readable description of what you should do to mitigate this security issue + RemediationDescription *string `json:"remediationDescription,omitempty"` + // Category - READ-ONLY + Category *[]Category `json:"category,omitempty"` + // SecureScoreWeight - READ-ONLY; Weight for the security score calculation. the higher this number, this severity of this assessment is higher + SecureScoreWeight *int32 `json:"secureScoreWeight,omitempty"` + // RequiredPricingBundle - READ-ONLY + RequiredPricingBundle *[]RequiredPricingBundle `json:"requiredPricingBundle,omitempty"` + // Preview - READ-ONLY; True if this assessment is in preview release status + Preview *bool `json:"preview,omitempty"` + // AssessmentType - READ-ONLY; BuiltIn if the assessment based on built-in Azure Policy definition, Custom if the assessment based on custom Azure Policy definition. Possible values include: 'BuiltIn', 'Custom' + AssessmentType AssessmentType `json:"assessmentType,omitempty"` +} + // AtaExternalSecuritySolution represents an ATA security solution which sends logs to an OMS workspace type AtaExternalSecuritySolution struct { Properties *AtaSolutionProperties `json:"properties,omitempty"` 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 333b51d906f9..f739050b209c 100644 --- a/services/preview/security/mgmt/v2.0/security/securityapi/interfaces.go +++ b/services/preview/security/mgmt/v2.0/security/securityapi/interfaces.go @@ -47,6 +47,22 @@ type RegulatoryComplianceAssessmentsClientAPI interface { var _ RegulatoryComplianceAssessmentsClientAPI = (*security.RegulatoryComplianceAssessmentsClient)(nil) +// AssessmentsMetadataClientAPI contains the set of methods on the AssessmentsMetadataClient type. +type AssessmentsMetadataClientAPI interface { + Get(ctx context.Context, assessmentsMetadataName string) (result security.AssessmentMetadata, err error) + List(ctx context.Context) (result security.AssessmentMetadataListPage, err error) +} + +var _ AssessmentsMetadataClientAPI = (*security.AssessmentsMetadataClient)(nil) + +// AssessmentsMetadataSubscriptionClientAPI contains the set of methods on the AssessmentsMetadataSubscriptionClient type. +type AssessmentsMetadataSubscriptionClientAPI interface { + Get(ctx context.Context, assessmentsMetadataName string) (result security.AssessmentMetadata, err error) + List(ctx context.Context) (result security.AssessmentMetadataListPage, err error) +} + +var _ AssessmentsMetadataSubscriptionClientAPI = (*security.AssessmentsMetadataSubscriptionClient)(nil) + // PricingsClientAPI contains the set of methods on the PricingsClient type. type PricingsClientAPI interface { Get(ctx context.Context, pricingName string) (result security.Pricing, err error) diff --git a/services/preview/security/mgmt/v3.0/security/assessmentsmetadata.go b/services/preview/security/mgmt/v3.0/security/assessmentsmetadata.go new file mode 100644 index 000000000000..1fc3026a4c73 --- /dev/null +++ b/services/preview/security/mgmt/v3.0/security/assessmentsmetadata.go @@ -0,0 +1,221 @@ +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/tracing" + "net/http" +) + +// AssessmentsMetadataClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type AssessmentsMetadataClient struct { + BaseClient +} + +// NewAssessmentsMetadataClient creates an instance of the AssessmentsMetadataClient client. +func NewAssessmentsMetadataClient(subscriptionID string, ascLocation string) AssessmentsMetadataClient { + return NewAssessmentsMetadataClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewAssessmentsMetadataClientWithBaseURI creates an instance of the AssessmentsMetadataClient client. +func NewAssessmentsMetadataClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) AssessmentsMetadataClient { + return AssessmentsMetadataClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Get get metadata information on an assessment type +// Parameters: +// assessmentsMetadataName - the Assessment Key - Unique key for the assessment type +func (client AssessmentsMetadataClient) Get(ctx context.Context, assessmentsMetadataName string) (result AssessmentMetadata, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentsMetadataClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, assessmentsMetadataName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "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.AssessmentsMetadataClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client AssessmentsMetadataClient) GetPreparer(ctx context.Context, assessmentsMetadataName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "assessmentsMetadataName": autorest.Encode("path", assessmentsMetadataName), + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Security/assessmentsMetadata/{assessmentsMetadataName}", 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 AssessmentsMetadataClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AssessmentsMetadataClient) GetResponder(resp *http.Response) (result AssessmentMetadata, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List get metadata information on all assessment types +func (client AssessmentsMetadataClient) List(ctx context.Context) (result AssessmentMetadataListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentsMetadataClient.List") + defer func() { + sc := -1 + if result.aml.Response.Response != nil { + sc = result.aml.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.aml.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "List", resp, "Failure sending request") + return + } + + result.aml, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client AssessmentsMetadataClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Security/assessmentsMetadata"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client AssessmentsMetadataClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client AssessmentsMetadataClient) ListResponder(resp *http.Response) (result AssessmentMetadataList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client AssessmentsMetadataClient) listNextResults(ctx context.Context, lastResults AssessmentMetadataList) (result AssessmentMetadataList, err error) { + req, err := lastResults.assessmentMetadataListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client AssessmentsMetadataClient) ListComplete(ctx context.Context) (result AssessmentMetadataListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentsMetadataClient.List") + 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.List(ctx) + return +} diff --git a/services/preview/security/mgmt/v3.0/security/assessmentsmetadatasubscription.go b/services/preview/security/mgmt/v3.0/security/assessmentsmetadatasubscription.go new file mode 100644 index 000000000000..e88c4591d691 --- /dev/null +++ b/services/preview/security/mgmt/v3.0/security/assessmentsmetadatasubscription.go @@ -0,0 +1,241 @@ +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" +) + +// AssessmentsMetadataSubscriptionClient is the API spec for Microsoft.Security (Azure Security Center) resource +// provider +type AssessmentsMetadataSubscriptionClient struct { + BaseClient +} + +// NewAssessmentsMetadataSubscriptionClient creates an instance of the AssessmentsMetadataSubscriptionClient client. +func NewAssessmentsMetadataSubscriptionClient(subscriptionID string, ascLocation string) AssessmentsMetadataSubscriptionClient { + return NewAssessmentsMetadataSubscriptionClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewAssessmentsMetadataSubscriptionClientWithBaseURI creates an instance of the AssessmentsMetadataSubscriptionClient +// client. +func NewAssessmentsMetadataSubscriptionClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) AssessmentsMetadataSubscriptionClient { + return AssessmentsMetadataSubscriptionClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Get get metadata information on an assessment type in a specific subscription +// Parameters: +// assessmentsMetadataName - the Assessment Key - Unique key for the assessment type +func (client AssessmentsMetadataSubscriptionClient) Get(ctx context.Context, assessmentsMetadataName string) (result AssessmentMetadata, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentsMetadataSubscriptionClient.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}}}}); err != nil { + return result, validation.NewError("security.AssessmentsMetadataSubscriptionClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, assessmentsMetadataName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataSubscriptionClient", "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.AssessmentsMetadataSubscriptionClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataSubscriptionClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client AssessmentsMetadataSubscriptionClient) GetPreparer(ctx context.Context, assessmentsMetadataName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "assessmentsMetadataName": autorest.Encode("path", assessmentsMetadataName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentsMetadata/{assessmentsMetadataName}", 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 AssessmentsMetadataSubscriptionClient) 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 AssessmentsMetadataSubscriptionClient) GetResponder(resp *http.Response) (result AssessmentMetadata, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List get metadata information on all assessment types in a specific subscription +func (client AssessmentsMetadataSubscriptionClient) List(ctx context.Context) (result AssessmentMetadataListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentsMetadataSubscriptionClient.List") + defer func() { + sc := -1 + if result.aml.Response.Response != nil { + sc = result.aml.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}}}}); err != nil { + return result, validation.NewError("security.AssessmentsMetadataSubscriptionClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataSubscriptionClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.aml.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataSubscriptionClient", "List", resp, "Failure sending request") + return + } + + result.aml, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataSubscriptionClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client AssessmentsMetadataSubscriptionClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentsMetadata", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client AssessmentsMetadataSubscriptionClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client AssessmentsMetadataSubscriptionClient) ListResponder(resp *http.Response) (result AssessmentMetadataList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client AssessmentsMetadataSubscriptionClient) listNextResults(ctx context.Context, lastResults AssessmentMetadataList) (result AssessmentMetadataList, err error) { + req, err := lastResults.assessmentMetadataListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.AssessmentsMetadataSubscriptionClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.AssessmentsMetadataSubscriptionClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataSubscriptionClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client AssessmentsMetadataSubscriptionClient) ListComplete(ctx context.Context) (result AssessmentMetadataListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentsMetadataSubscriptionClient.List") + 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.List(ctx) + return +} diff --git a/services/preview/security/mgmt/v3.0/security/models.go b/services/preview/security/mgmt/v3.0/security/models.go index 698bf1b3f0a8..2939d09b507d 100644 --- a/services/preview/security/mgmt/v3.0/security/models.go +++ b/services/preview/security/mgmt/v3.0/security/models.go @@ -78,6 +78,21 @@ func PossibleAlertsToAdminsValues() []AlertsToAdmins { return []AlertsToAdmins{AlertsToAdminsOff, AlertsToAdminsOn} } +// AssessmentType enumerates the values for assessment type. +type AssessmentType string + +const ( + // BuiltIn ... + BuiltIn AssessmentType = "BuiltIn" + // Custom ... + Custom AssessmentType = "Custom" +) + +// PossibleAssessmentTypeValues returns an array of possible values for the AssessmentType const type. +func PossibleAssessmentTypeValues() []AssessmentType { + return []AssessmentType{BuiltIn, Custom} +} + // AutoProvision enumerates the values for auto provision. type AutoProvision string @@ -93,6 +108,27 @@ func PossibleAutoProvisionValues() []AutoProvision { return []AutoProvision{AutoProvisionOff, AutoProvisionOn} } +// Category enumerates the values for category. +type Category string + +const ( + // Compute ... + Compute Category = "Compute" + // Data ... + Data Category = "Data" + // IdentityAndAccess ... + IdentityAndAccess Category = "IdentityAndAccess" + // IoT ... + IoT Category = "IoT" + // Network ... + Network Category = "Network" +) + +// PossibleCategoryValues returns an array of possible values for the Category const type. +func PossibleCategoryValues() []Category { + return []Category{Compute, Data, IdentityAndAccess, IoT, Network} +} + // ConnectionType enumerates the values for connection type. type ConnectionType string @@ -321,6 +357,25 @@ func PossibleReportedSeverityValues() []ReportedSeverity { return []ReportedSeverity{High, Informational, Low, Medium} } +// RequiredPricingBundle enumerates the values for required pricing bundle. +type RequiredPricingBundle string + +const ( + // AppServices ... + AppServices RequiredPricingBundle = "AppServices" + // SQLServers ... + SQLServers RequiredPricingBundle = "SqlServers" + // StorageAccounts ... + StorageAccounts RequiredPricingBundle = "StorageAccounts" + // VirtualMachines ... + VirtualMachines RequiredPricingBundle = "VirtualMachines" +) + +// PossibleRequiredPricingBundleValues returns an array of possible values for the RequiredPricingBundle const type. +func PossibleRequiredPricingBundleValues() []RequiredPricingBundle { + return []RequiredPricingBundle{AppServices, SQLServers, StorageAccounts, VirtualMachines} +} + // ResourceStatus enumerates the values for resource status. type ResourceStatus string @@ -1306,6 +1361,246 @@ func NewAscLocationListPage(getNextPage func(context.Context, AscLocationList) ( return AscLocationListPage{fn: getNextPage} } +// AssessmentMetadata security assessment metadata +type AssessmentMetadata struct { + autorest.Response `json:"-"` + *AssessmentMetadataProperties `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 AssessmentMetadata. +func (am AssessmentMetadata) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if am.AssessmentMetadataProperties != nil { + objectMap["properties"] = am.AssessmentMetadataProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AssessmentMetadata struct. +func (am *AssessmentMetadata) 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 assessmentMetadataProperties AssessmentMetadataProperties + err = json.Unmarshal(*v, &assessmentMetadataProperties) + if err != nil { + return err + } + am.AssessmentMetadataProperties = &assessmentMetadataProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + am.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + am.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + am.Type = &typeVar + } + } + } + + return nil +} + +// AssessmentMetadataList list of security assessment metadata +type AssessmentMetadataList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY + Value *[]AssessmentMetadata `json:"value,omitempty"` + // NextLink - READ-ONLY; The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// AssessmentMetadataListIterator provides access to a complete listing of AssessmentMetadata values. +type AssessmentMetadataListIterator struct { + i int + page AssessmentMetadataListPage +} + +// 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 *AssessmentMetadataListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentMetadataListIterator.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 *AssessmentMetadataListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter AssessmentMetadataListIterator) 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 AssessmentMetadataListIterator) Response() AssessmentMetadataList { + 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 AssessmentMetadataListIterator) Value() AssessmentMetadata { + if !iter.page.NotDone() { + return AssessmentMetadata{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the AssessmentMetadataListIterator type. +func NewAssessmentMetadataListIterator(page AssessmentMetadataListPage) AssessmentMetadataListIterator { + return AssessmentMetadataListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (aml AssessmentMetadataList) IsEmpty() bool { + return aml.Value == nil || len(*aml.Value) == 0 +} + +// assessmentMetadataListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (aml AssessmentMetadataList) assessmentMetadataListPreparer(ctx context.Context) (*http.Request, error) { + if aml.NextLink == nil || len(to.String(aml.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(aml.NextLink))) +} + +// AssessmentMetadataListPage contains a page of AssessmentMetadata values. +type AssessmentMetadataListPage struct { + fn func(context.Context, AssessmentMetadataList) (AssessmentMetadataList, error) + aml AssessmentMetadataList +} + +// 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 *AssessmentMetadataListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentMetadataListPage.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.aml) + if err != nil { + return err + } + page.aml = 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 *AssessmentMetadataListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page AssessmentMetadataListPage) NotDone() bool { + return !page.aml.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page AssessmentMetadataListPage) Response() AssessmentMetadataList { + return page.aml +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page AssessmentMetadataListPage) Values() []AssessmentMetadata { + if page.aml.IsEmpty() { + return nil + } + return *page.aml.Value +} + +// Creates a new instance of the AssessmentMetadataListPage type. +func NewAssessmentMetadataListPage(getNextPage func(context.Context, AssessmentMetadataList) (AssessmentMetadataList, error)) AssessmentMetadataListPage { + return AssessmentMetadataListPage{fn: getNextPage} +} + +// AssessmentMetadataProperties describes properties of an assessment metadata. +type AssessmentMetadataProperties struct { + // DisplayName - READ-ONLY; User friendly display name of the assessment + DisplayName *string `json:"displayName,omitempty"` + // PolicyDefinitionID - READ-ONLY; Azure resource ID of the policy definition that turns this assessment calculation on + PolicyDefinitionID *string `json:"policyDefinitionId,omitempty"` + // Description - READ-ONLY; Human readable description of the assessment + Description *string `json:"description,omitempty"` + // RemediationDescription - READ-ONLY; Human readable description of what you should do to mitigate this security issue + RemediationDescription *string `json:"remediationDescription,omitempty"` + // Category - READ-ONLY + Category *[]Category `json:"category,omitempty"` + // SecureScoreWeight - READ-ONLY; Weight for the security score calculation. the higher this number, this severity of this assessment is higher + SecureScoreWeight *int32 `json:"secureScoreWeight,omitempty"` + // RequiredPricingBundle - READ-ONLY + RequiredPricingBundle *[]RequiredPricingBundle `json:"requiredPricingBundle,omitempty"` + // Preview - READ-ONLY; True if this assessment is in preview release status + Preview *bool `json:"preview,omitempty"` + // AssessmentType - READ-ONLY; BuiltIn if the assessment based on built-in Azure Policy definition, Custom if the assessment based on custom Azure Policy definition. Possible values include: 'BuiltIn', 'Custom' + AssessmentType AssessmentType `json:"assessmentType,omitempty"` +} + // AtaExternalSecuritySolution represents an ATA security solution which sends logs to an OMS workspace type AtaExternalSecuritySolution struct { Properties *AtaSolutionProperties `json:"properties,omitempty"` 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 064b14cc1245..003ce80937e5 100644 --- a/services/preview/security/mgmt/v3.0/security/securityapi/interfaces.go +++ b/services/preview/security/mgmt/v3.0/security/securityapi/interfaces.go @@ -282,6 +282,22 @@ type RegulatoryComplianceAssessmentsClientAPI interface { var _ RegulatoryComplianceAssessmentsClientAPI = (*security.RegulatoryComplianceAssessmentsClient)(nil) +// AssessmentsMetadataClientAPI contains the set of methods on the AssessmentsMetadataClient type. +type AssessmentsMetadataClientAPI interface { + Get(ctx context.Context, assessmentsMetadataName string) (result security.AssessmentMetadata, err error) + List(ctx context.Context) (result security.AssessmentMetadataListPage, err error) +} + +var _ AssessmentsMetadataClientAPI = (*security.AssessmentsMetadataClient)(nil) + +// AssessmentsMetadataSubscriptionClientAPI contains the set of methods on the AssessmentsMetadataSubscriptionClient type. +type AssessmentsMetadataSubscriptionClientAPI interface { + Get(ctx context.Context, assessmentsMetadataName string) (result security.AssessmentMetadata, err error) + List(ctx context.Context) (result security.AssessmentMetadataListPage, err error) +} + +var _ AssessmentsMetadataSubscriptionClientAPI = (*security.AssessmentsMetadataSubscriptionClient)(nil) + // ServerVulnerabilityAssessmentClientAPI contains the set of methods on the ServerVulnerabilityAssessmentClient type. type ServerVulnerabilityAssessmentClientAPI interface { CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string) (result security.ServerVulnerabilityAssessment, err error)