diff --git a/profiles/preview/preview/security/mgmt/security/models.go b/profiles/preview/preview/security/mgmt/security/models.go index 34926a49a44b..dc4cddb15503 100644 --- a/profiles/preview/preview/security/mgmt/security/models.go +++ b/profiles/preview/preview/security/mgmt/security/models.go @@ -81,6 +81,14 @@ const ( AssessedResourceTypeSQLServerVulnerability AssessedResourceType = original.AssessedResourceTypeSQLServerVulnerability ) +type AssessmentStatusCode = original.AssessmentStatusCode + +const ( + Healthy AssessmentStatusCode = original.Healthy + NotApplicable AssessmentStatusCode = original.NotApplicable + Unhealthy AssessmentStatusCode = original.Unhealthy +) + type AutoProvision = original.AutoProvision const ( @@ -170,6 +178,13 @@ const ( ExecutableNone Executable = original.ExecutableNone ) +type ExpandEnum = original.ExpandEnum + +const ( + Links ExpandEnum = original.Links + Metadata ExpandEnum = original.Metadata +) + type ExportData = original.ExportData const ( @@ -345,10 +360,10 @@ const ( type ResourceStatus = original.ResourceStatus const ( - Healthy ResourceStatus = original.Healthy - NotApplicable ResourceStatus = original.NotApplicable - NotHealthy ResourceStatus = original.NotHealthy - OffByPolicy ResourceStatus = original.OffByPolicy + ResourceStatusHealthy ResourceStatus = original.ResourceStatusHealthy + ResourceStatusNotApplicable ResourceStatus = original.ResourceStatusNotApplicable + ResourceStatusNotHealthy ResourceStatus = original.ResourceStatusNotHealthy + ResourceStatusOffByPolicy ResourceStatus = original.ResourceStatusOffByPolicy ) type Script = original.Script @@ -384,8 +399,8 @@ const ( type Source = original.Source const ( - SourceAws Source = original.SourceAws SourceAzure Source = original.SourceAzure + SourceOnPremise Source = original.SourceOnPremise SourceResourceDetails Source = original.SourceResourceDetails ) @@ -488,6 +503,14 @@ type AscLocation = original.AscLocation type AscLocationList = original.AscLocationList type AscLocationListIterator = original.AscLocationListIterator type AscLocationListPage = original.AscLocationListPage +type Assessment = original.Assessment +type AssessmentLinks = original.AssessmentLinks +type AssessmentList = original.AssessmentList +type AssessmentListIterator = original.AssessmentListIterator +type AssessmentListPage = original.AssessmentListPage +type AssessmentProperties = original.AssessmentProperties +type AssessmentStatus = original.AssessmentStatus +type AssessmentsClient = original.AssessmentsClient type AtaExternalSecuritySolution = original.AtaExternalSecuritySolution type AtaSolutionProperties = original.AtaSolutionProperties type AutoProvisioningSetting = original.AutoProvisioningSetting @@ -516,7 +539,6 @@ type AutomationSource = original.AutomationSource type AutomationTriggeringRule = original.AutomationTriggeringRule type AutomationValidationStatus = original.AutomationValidationStatus type AutomationsClient = original.AutomationsClient -type AwsResourceDetails = original.AwsResourceDetails type AzureResourceDetails = original.AzureResourceDetails type BaseClient = original.BaseClient type BasicAdditionalData = original.BasicAdditionalData @@ -633,6 +655,7 @@ type Kind = original.Kind type ListCustomAlertRule = original.ListCustomAlertRule type Location = original.Location type LocationsClient = original.LocationsClient +type OnPremiseResourceDetails = original.OnPremiseResourceDetails type Operation = original.Operation type OperationDisplay = original.OperationDisplay type OperationList = original.OperationList @@ -766,6 +789,18 @@ func NewAscLocationListIterator(page AscLocationListPage) AscLocationListIterato func NewAscLocationListPage(getNextPage func(context.Context, AscLocationList) (AscLocationList, error)) AscLocationListPage { return original.NewAscLocationListPage(getNextPage) } +func NewAssessmentListIterator(page AssessmentListPage) AssessmentListIterator { + return original.NewAssessmentListIterator(page) +} +func NewAssessmentListPage(getNextPage func(context.Context, AssessmentList) (AssessmentList, error)) AssessmentListPage { + return original.NewAssessmentListPage(getNextPage) +} +func NewAssessmentsClient(subscriptionID string, ascLocation string) AssessmentsClient { + return original.NewAssessmentsClient(subscriptionID, ascLocation) +} +func NewAssessmentsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) AssessmentsClient { + return original.NewAssessmentsClientWithBaseURI(baseURI, subscriptionID, ascLocation) +} func NewAutoProvisioningSettingListIterator(page AutoProvisioningSettingListPage) AutoProvisioningSettingListIterator { return original.NewAutoProvisioningSettingListIterator(page) } @@ -1075,6 +1110,9 @@ func PossibleAlertsToAdminsValues() []AlertsToAdmins { func PossibleAssessedResourceTypeValues() []AssessedResourceType { return original.PossibleAssessedResourceTypeValues() } +func PossibleAssessmentStatusCodeValues() []AssessmentStatusCode { + return original.PossibleAssessmentStatusCodeValues() +} func PossibleAutoProvisionValues() []AutoProvision { return original.PossibleAutoProvisionValues() } @@ -1108,6 +1146,9 @@ func PossibleExeValues() []Exe { func PossibleExecutableValues() []Executable { return original.PossibleExecutableValues() } +func PossibleExpandEnumValues() []ExpandEnum { + return original.PossibleExpandEnumValues() +} func PossibleExportDataValues() []ExportData { return original.PossibleExportDataValues() } diff --git a/profiles/preview/preview/security/mgmt/security/securityapi/models.go b/profiles/preview/preview/security/mgmt/security/securityapi/models.go index 7e83ea774e55..dae67ca200c6 100644 --- a/profiles/preview/preview/security/mgmt/security/securityapi/models.go +++ b/profiles/preview/preview/security/mgmt/security/securityapi/models.go @@ -25,6 +25,7 @@ type AdaptiveApplicationControlsClientAPI = original.AdaptiveApplicationControls type AdvancedThreatProtectionClientAPI = original.AdvancedThreatProtectionClientAPI type AlertsClientAPI = original.AlertsClientAPI type AllowedConnectionsClientAPI = original.AllowedConnectionsClientAPI +type AssessmentsClientAPI = original.AssessmentsClientAPI type AutoProvisioningSettingsClientAPI = original.AutoProvisioningSettingsClientAPI type AutomationsClientAPI = original.AutomationsClientAPI type ComplianceResultsClientAPI = original.ComplianceResultsClientAPI diff --git a/services/preview/security/mgmt/v1.0/security/models.go b/services/preview/security/mgmt/v1.0/security/models.go index 6e0742f71f59..fe44ab060270 100644 --- a/services/preview/security/mgmt/v1.0/security/models.go +++ b/services/preview/security/mgmt/v1.0/security/models.go @@ -656,17 +656,17 @@ func PossibleSeverityValues() []Severity { type Source string const ( - // SourceAws ... - SourceAws Source = "Aws" // SourceAzure ... SourceAzure Source = "Azure" + // SourceOnPremise ... + SourceOnPremise Source = "OnPremise" // SourceResourceDetails ... SourceResourceDetails Source = "ResourceDetails" ) // PossibleSourceValues returns an array of possible values for the Source const type. func PossibleSourceValues() []Source { - return []Source{SourceAws, SourceAzure, SourceResourceDetails} + return []Source{SourceAzure, SourceOnPremise, SourceResourceDetails} } // SourceSystem enumerates the values for source system. @@ -3777,51 +3777,11 @@ type AutoProvisioningSettingProperties struct { AutoProvision AutoProvision `json:"autoProvision,omitempty"` } -// AwsResourceDetails details of the resource that was assessed -type AwsResourceDetails struct { - // AccountID - READ-ONLY; AWS account ID - AccountID *string `json:"accountId,omitempty"` - // AwsResourceID - READ-ONLY; AWS resource ID. can be ARN or other - AwsResourceID *string `json:"awsResourceId,omitempty"` - // Source - Possible values include: 'SourceResourceDetails', 'SourceAzure', 'SourceAws' - Source Source `json:"source,omitempty"` -} - -// MarshalJSON is the custom marshaler for AwsResourceDetails. -func (ard AwsResourceDetails) MarshalJSON() ([]byte, error) { - ard.Source = SourceAws - objectMap := make(map[string]interface{}) - if ard.Source != "" { - objectMap["source"] = ard.Source - } - return json.Marshal(objectMap) -} - -// AsAzureResourceDetails is the BasicResourceDetails implementation for AwsResourceDetails. -func (ard AwsResourceDetails) AsAzureResourceDetails() (*AzureResourceDetails, bool) { - return nil, false -} - -// AsAwsResourceDetails is the BasicResourceDetails implementation for AwsResourceDetails. -func (ard AwsResourceDetails) AsAwsResourceDetails() (*AwsResourceDetails, bool) { - return &ard, true -} - -// AsResourceDetails is the BasicResourceDetails implementation for AwsResourceDetails. -func (ard AwsResourceDetails) AsResourceDetails() (*ResourceDetails, bool) { - return nil, false -} - -// AsBasicResourceDetails is the BasicResourceDetails implementation for AwsResourceDetails. -func (ard AwsResourceDetails) AsBasicResourceDetails() (BasicResourceDetails, bool) { - return &ard, true -} - -// AzureResourceDetails details of the resource that was assessed +// AzureResourceDetails details of the Azure resource that was assessed type AzureResourceDetails struct { - // ID - READ-ONLY; Azure resource ID of the assessed resource + // ID - Azure resource Id of the assessed resource ID *string `json:"id,omitempty"` - // Source - Possible values include: 'SourceResourceDetails', 'SourceAzure', 'SourceAws' + // Source - Possible values include: 'SourceResourceDetails', 'SourceOnPremise', 'SourceAzure' Source Source `json:"source,omitempty"` } @@ -3829,22 +3789,25 @@ type AzureResourceDetails struct { func (ard AzureResourceDetails) MarshalJSON() ([]byte, error) { ard.Source = SourceAzure objectMap := make(map[string]interface{}) + if ard.ID != nil { + objectMap["id"] = ard.ID + } if ard.Source != "" { objectMap["source"] = ard.Source } return json.Marshal(objectMap) } +// AsOnPremiseResourceDetails is the BasicResourceDetails implementation for AzureResourceDetails. +func (ard AzureResourceDetails) AsOnPremiseResourceDetails() (*OnPremiseResourceDetails, bool) { + return nil, false +} + // AsAzureResourceDetails is the BasicResourceDetails implementation for AzureResourceDetails. func (ard AzureResourceDetails) AsAzureResourceDetails() (*AzureResourceDetails, bool) { return &ard, true } -// AsAwsResourceDetails is the BasicResourceDetails implementation for AzureResourceDetails. -func (ard AzureResourceDetails) AsAwsResourceDetails() (*AwsResourceDetails, bool) { - return nil, false -} - // AsResourceDetails is the BasicResourceDetails implementation for AzureResourceDetails. func (ard AzureResourceDetails) AsResourceDetails() (*ResourceDetails, bool) { return nil, false @@ -6270,6 +6233,62 @@ type Location struct { Location *string `json:"location,omitempty"` } +// OnPremiseResourceDetails details of the On Premise resource that was assessed +type OnPremiseResourceDetails struct { + // WorkspaceID - Azure resource Id of the workspace the machine is attached to + WorkspaceID *string `json:"workspaceId,omitempty"` + // Vmuuid - The unique Id of the machine + Vmuuid *string `json:"vmuuid,omitempty"` + // SourceComputerID - The oms agent Id installed on the machine + SourceComputerID *string `json:"sourceComputerId,omitempty"` + // MachineName - The name of the machine + MachineName *string `json:"machineName,omitempty"` + // Source - Possible values include: 'SourceResourceDetails', 'SourceOnPremise', 'SourceAzure' + Source Source `json:"source,omitempty"` +} + +// MarshalJSON is the custom marshaler for OnPremiseResourceDetails. +func (oprd OnPremiseResourceDetails) MarshalJSON() ([]byte, error) { + oprd.Source = SourceOnPremise + objectMap := make(map[string]interface{}) + if oprd.WorkspaceID != nil { + objectMap["workspaceId"] = oprd.WorkspaceID + } + if oprd.Vmuuid != nil { + objectMap["vmuuid"] = oprd.Vmuuid + } + if oprd.SourceComputerID != nil { + objectMap["sourceComputerId"] = oprd.SourceComputerID + } + if oprd.MachineName != nil { + objectMap["machineName"] = oprd.MachineName + } + if oprd.Source != "" { + objectMap["source"] = oprd.Source + } + return json.Marshal(objectMap) +} + +// AsOnPremiseResourceDetails is the BasicResourceDetails implementation for OnPremiseResourceDetails. +func (oprd OnPremiseResourceDetails) AsOnPremiseResourceDetails() (*OnPremiseResourceDetails, bool) { + return &oprd, true +} + +// AsAzureResourceDetails is the BasicResourceDetails implementation for OnPremiseResourceDetails. +func (oprd OnPremiseResourceDetails) AsAzureResourceDetails() (*AzureResourceDetails, bool) { + return nil, false +} + +// AsResourceDetails is the BasicResourceDetails implementation for OnPremiseResourceDetails. +func (oprd OnPremiseResourceDetails) AsResourceDetails() (*ResourceDetails, bool) { + return nil, false +} + +// AsBasicResourceDetails is the BasicResourceDetails implementation for OnPremiseResourceDetails. +func (oprd OnPremiseResourceDetails) AsBasicResourceDetails() (BasicResourceDetails, bool) { + return &oprd, true +} + // Operation possible operation in the REST API of Microsoft.Security type Operation struct { // Name - READ-ONLY; Name of the operation @@ -7424,14 +7443,14 @@ type Resource struct { // BasicResourceDetails details of the resource that was assessed type BasicResourceDetails interface { + AsOnPremiseResourceDetails() (*OnPremiseResourceDetails, bool) AsAzureResourceDetails() (*AzureResourceDetails, bool) - AsAwsResourceDetails() (*AwsResourceDetails, bool) AsResourceDetails() (*ResourceDetails, bool) } // ResourceDetails details of the resource that was assessed type ResourceDetails struct { - // Source - Possible values include: 'SourceResourceDetails', 'SourceAzure', 'SourceAws' + // Source - Possible values include: 'SourceResourceDetails', 'SourceOnPremise', 'SourceAzure' Source Source `json:"source,omitempty"` } @@ -7443,14 +7462,14 @@ func unmarshalBasicResourceDetails(body []byte) (BasicResourceDetails, error) { } switch m["source"] { + case string(SourceOnPremise): + var oprd OnPremiseResourceDetails + err := json.Unmarshal(body, &oprd) + return oprd, err case string(SourceAzure): var ard AzureResourceDetails err := json.Unmarshal(body, &ard) return ard, err - case string(SourceAws): - var ard AwsResourceDetails - err := json.Unmarshal(body, &ard) - return ard, err default: var rd ResourceDetails err := json.Unmarshal(body, &rd) @@ -7486,13 +7505,13 @@ func (rd ResourceDetails) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } -// AsAzureResourceDetails is the BasicResourceDetails implementation for ResourceDetails. -func (rd ResourceDetails) AsAzureResourceDetails() (*AzureResourceDetails, bool) { +// AsOnPremiseResourceDetails is the BasicResourceDetails implementation for ResourceDetails. +func (rd ResourceDetails) AsOnPremiseResourceDetails() (*OnPremiseResourceDetails, bool) { return nil, false } -// AsAwsResourceDetails is the BasicResourceDetails implementation for ResourceDetails. -func (rd ResourceDetails) AsAwsResourceDetails() (*AwsResourceDetails, bool) { +// AsAzureResourceDetails is the BasicResourceDetails implementation for ResourceDetails. +func (rd ResourceDetails) AsAzureResourceDetails() (*AzureResourceDetails, bool) { return nil, false } diff --git a/services/preview/security/mgmt/v2.0/security/models.go b/services/preview/security/mgmt/v2.0/security/models.go index cee44b1a4a87..e7a7792a8d7e 100644 --- a/services/preview/security/mgmt/v2.0/security/models.go +++ b/services/preview/security/mgmt/v2.0/security/models.go @@ -767,17 +767,17 @@ func PossibleSolutionStatusValues() []SolutionStatus { type Source string const ( - // SourceAws ... - SourceAws Source = "Aws" // SourceAzure ... SourceAzure Source = "Azure" + // SourceOnPremise ... + SourceOnPremise Source = "OnPremise" // SourceResourceDetails ... SourceResourceDetails Source = "ResourceDetails" ) // PossibleSourceValues returns an array of possible values for the Source const type. func PossibleSourceValues() []Source { - return []Source{SourceAws, SourceAzure, SourceResourceDetails} + return []Source{SourceAzure, SourceOnPremise, SourceResourceDetails} } // SourceSystem enumerates the values for source system. @@ -3888,51 +3888,11 @@ type AutoProvisioningSettingProperties struct { AutoProvision AutoProvision `json:"autoProvision,omitempty"` } -// AwsResourceDetails details of the resource that was assessed -type AwsResourceDetails struct { - // AccountID - READ-ONLY; AWS account ID - AccountID *string `json:"accountId,omitempty"` - // AwsResourceID - READ-ONLY; AWS resource ID. can be ARN or other - AwsResourceID *string `json:"awsResourceId,omitempty"` - // Source - Possible values include: 'SourceResourceDetails', 'SourceAzure', 'SourceAws' - Source Source `json:"source,omitempty"` -} - -// MarshalJSON is the custom marshaler for AwsResourceDetails. -func (ard AwsResourceDetails) MarshalJSON() ([]byte, error) { - ard.Source = SourceAws - objectMap := make(map[string]interface{}) - if ard.Source != "" { - objectMap["source"] = ard.Source - } - return json.Marshal(objectMap) -} - -// AsAzureResourceDetails is the BasicResourceDetails implementation for AwsResourceDetails. -func (ard AwsResourceDetails) AsAzureResourceDetails() (*AzureResourceDetails, bool) { - return nil, false -} - -// AsAwsResourceDetails is the BasicResourceDetails implementation for AwsResourceDetails. -func (ard AwsResourceDetails) AsAwsResourceDetails() (*AwsResourceDetails, bool) { - return &ard, true -} - -// AsResourceDetails is the BasicResourceDetails implementation for AwsResourceDetails. -func (ard AwsResourceDetails) AsResourceDetails() (*ResourceDetails, bool) { - return nil, false -} - -// AsBasicResourceDetails is the BasicResourceDetails implementation for AwsResourceDetails. -func (ard AwsResourceDetails) AsBasicResourceDetails() (BasicResourceDetails, bool) { - return &ard, true -} - -// AzureResourceDetails details of the resource that was assessed +// AzureResourceDetails details of the Azure resource that was assessed type AzureResourceDetails struct { - // ID - READ-ONLY; Azure resource ID of the assessed resource + // ID - Azure resource Id of the assessed resource ID *string `json:"id,omitempty"` - // Source - Possible values include: 'SourceResourceDetails', 'SourceAzure', 'SourceAws' + // Source - Possible values include: 'SourceResourceDetails', 'SourceOnPremise', 'SourceAzure' Source Source `json:"source,omitempty"` } @@ -3940,22 +3900,25 @@ type AzureResourceDetails struct { func (ard AzureResourceDetails) MarshalJSON() ([]byte, error) { ard.Source = SourceAzure objectMap := make(map[string]interface{}) + if ard.ID != nil { + objectMap["id"] = ard.ID + } if ard.Source != "" { objectMap["source"] = ard.Source } return json.Marshal(objectMap) } +// AsOnPremiseResourceDetails is the BasicResourceDetails implementation for AzureResourceDetails. +func (ard AzureResourceDetails) AsOnPremiseResourceDetails() (*OnPremiseResourceDetails, bool) { + return nil, false +} + // AsAzureResourceDetails is the BasicResourceDetails implementation for AzureResourceDetails. func (ard AzureResourceDetails) AsAzureResourceDetails() (*AzureResourceDetails, bool) { return &ard, true } -// AsAwsResourceDetails is the BasicResourceDetails implementation for AzureResourceDetails. -func (ard AzureResourceDetails) AsAwsResourceDetails() (*AwsResourceDetails, bool) { - return nil, false -} - // AsResourceDetails is the BasicResourceDetails implementation for AzureResourceDetails. func (ard AzureResourceDetails) AsResourceDetails() (*ResourceDetails, bool) { return nil, false @@ -7341,6 +7304,62 @@ type Location struct { Location *string `json:"location,omitempty"` } +// OnPremiseResourceDetails details of the On Premise resource that was assessed +type OnPremiseResourceDetails struct { + // WorkspaceID - Azure resource Id of the workspace the machine is attached to + WorkspaceID *string `json:"workspaceId,omitempty"` + // Vmuuid - The unique Id of the machine + Vmuuid *string `json:"vmuuid,omitempty"` + // SourceComputerID - The oms agent Id installed on the machine + SourceComputerID *string `json:"sourceComputerId,omitempty"` + // MachineName - The name of the machine + MachineName *string `json:"machineName,omitempty"` + // Source - Possible values include: 'SourceResourceDetails', 'SourceOnPremise', 'SourceAzure' + Source Source `json:"source,omitempty"` +} + +// MarshalJSON is the custom marshaler for OnPremiseResourceDetails. +func (oprd OnPremiseResourceDetails) MarshalJSON() ([]byte, error) { + oprd.Source = SourceOnPremise + objectMap := make(map[string]interface{}) + if oprd.WorkspaceID != nil { + objectMap["workspaceId"] = oprd.WorkspaceID + } + if oprd.Vmuuid != nil { + objectMap["vmuuid"] = oprd.Vmuuid + } + if oprd.SourceComputerID != nil { + objectMap["sourceComputerId"] = oprd.SourceComputerID + } + if oprd.MachineName != nil { + objectMap["machineName"] = oprd.MachineName + } + if oprd.Source != "" { + objectMap["source"] = oprd.Source + } + return json.Marshal(objectMap) +} + +// AsOnPremiseResourceDetails is the BasicResourceDetails implementation for OnPremiseResourceDetails. +func (oprd OnPremiseResourceDetails) AsOnPremiseResourceDetails() (*OnPremiseResourceDetails, bool) { + return &oprd, true +} + +// AsAzureResourceDetails is the BasicResourceDetails implementation for OnPremiseResourceDetails. +func (oprd OnPremiseResourceDetails) AsAzureResourceDetails() (*AzureResourceDetails, bool) { + return nil, false +} + +// AsResourceDetails is the BasicResourceDetails implementation for OnPremiseResourceDetails. +func (oprd OnPremiseResourceDetails) AsResourceDetails() (*ResourceDetails, bool) { + return nil, false +} + +// AsBasicResourceDetails is the BasicResourceDetails implementation for OnPremiseResourceDetails. +func (oprd OnPremiseResourceDetails) AsBasicResourceDetails() (BasicResourceDetails, bool) { + return &oprd, true +} + // Operation possible operation in the REST API of Microsoft.Security type Operation struct { // Name - READ-ONLY; Name of the operation @@ -8370,14 +8389,14 @@ type Resource struct { // BasicResourceDetails details of the resource that was assessed type BasicResourceDetails interface { + AsOnPremiseResourceDetails() (*OnPremiseResourceDetails, bool) AsAzureResourceDetails() (*AzureResourceDetails, bool) - AsAwsResourceDetails() (*AwsResourceDetails, bool) AsResourceDetails() (*ResourceDetails, bool) } // ResourceDetails details of the resource that was assessed type ResourceDetails struct { - // Source - Possible values include: 'SourceResourceDetails', 'SourceAzure', 'SourceAws' + // Source - Possible values include: 'SourceResourceDetails', 'SourceOnPremise', 'SourceAzure' Source Source `json:"source,omitempty"` } @@ -8389,14 +8408,14 @@ func unmarshalBasicResourceDetails(body []byte) (BasicResourceDetails, error) { } switch m["source"] { + case string(SourceOnPremise): + var oprd OnPremiseResourceDetails + err := json.Unmarshal(body, &oprd) + return oprd, err case string(SourceAzure): var ard AzureResourceDetails err := json.Unmarshal(body, &ard) return ard, err - case string(SourceAws): - var ard AwsResourceDetails - err := json.Unmarshal(body, &ard) - return ard, err default: var rd ResourceDetails err := json.Unmarshal(body, &rd) @@ -8432,13 +8451,13 @@ func (rd ResourceDetails) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } -// AsAzureResourceDetails is the BasicResourceDetails implementation for ResourceDetails. -func (rd ResourceDetails) AsAzureResourceDetails() (*AzureResourceDetails, bool) { +// AsOnPremiseResourceDetails is the BasicResourceDetails implementation for ResourceDetails. +func (rd ResourceDetails) AsOnPremiseResourceDetails() (*OnPremiseResourceDetails, bool) { return nil, false } -// AsAwsResourceDetails is the BasicResourceDetails implementation for ResourceDetails. -func (rd ResourceDetails) AsAwsResourceDetails() (*AwsResourceDetails, bool) { +// AsAzureResourceDetails is the BasicResourceDetails implementation for ResourceDetails. +func (rd ResourceDetails) AsAzureResourceDetails() (*AzureResourceDetails, bool) { return nil, false } diff --git a/services/preview/security/mgmt/v3.0/security/assessments.go b/services/preview/security/mgmt/v3.0/security/assessments.go new file mode 100644 index 000000000000..92bb9796e30f --- /dev/null +++ b/services/preview/security/mgmt/v3.0/security/assessments.go @@ -0,0 +1,400 @@ +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" +) + +// AssessmentsClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type AssessmentsClient struct { + BaseClient +} + +// NewAssessmentsClient creates an instance of the AssessmentsClient client. +func NewAssessmentsClient(subscriptionID string, ascLocation string) AssessmentsClient { + return NewAssessmentsClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewAssessmentsClientWithBaseURI creates an instance of the AssessmentsClient client. +func NewAssessmentsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) AssessmentsClient { + return AssessmentsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Create create a security assessment on your resource. An assessment metadata that describes this assessment must be +// predefined with the same name before inserting the assessment result +// Parameters: +// resourceID - the identifier of the resource. +// assessmentName - the Assessment Key - Unique key for the assessment type +// body - calculated assessment on a pre-defined assessment metadata +func (client AssessmentsClient) Create(ctx context.Context, resourceID string, assessmentName string, body Assessment) (result Assessment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentsClient.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: body, + Constraints: []validation.Constraint{{Target: "body.AssessmentProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "body.AssessmentProperties.ResourceDetails", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "body.AssessmentProperties.Status", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("security.AssessmentsClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceID, assessmentName, body) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsClient", "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.AssessmentsClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client AssessmentsClient) CreatePreparer(ctx context.Context, resourceID string, assessmentName string, body Assessment) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "assessmentName": autorest.Encode("path", assessmentName), + "resourceId": autorest.Encode("path", resourceID), + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}", pathParameters), + autorest.WithJSON(body), + 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 AssessmentsClient) CreateSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + return autorest.SendWithSender(client, req, sd...) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client AssessmentsClient) CreateResponder(resp *http.Response) (result Assessment, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete a security assessment on your resource. An assessment metadata that describes this assessment must be +// predefined with the same name before inserting the assessment result +// Parameters: +// resourceID - the identifier of the resource. +// assessmentName - the Assessment Key - Unique key for the assessment type +func (client AssessmentsClient) Delete(ctx context.Context, resourceID string, assessmentName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceID, assessmentName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "security.AssessmentsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client AssessmentsClient) DeletePreparer(ctx context.Context, resourceID string, assessmentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "assessmentName": autorest.Encode("path", assessmentName), + "resourceId": autorest.Encode("path", resourceID), + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}", 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 AssessmentsClient) DeleteSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + return autorest.SendWithSender(client, req, sd...) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client AssessmentsClient) DeleteResponder(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 get a security assessment on your scanned resource +// Parameters: +// resourceID - the identifier of the resource. +// assessmentName - the Assessment Key - Unique key for the assessment type +// expand - oData expand. Optional. +func (client AssessmentsClient) Get(ctx context.Context, resourceID string, assessmentName string, expand ExpandEnum) (result Assessment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentsClient.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, resourceID, assessmentName, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsClient", "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.AssessmentsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client AssessmentsClient) GetPreparer(ctx context.Context, resourceID string, assessmentName string, expand ExpandEnum) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "assessmentName": autorest.Encode("path", assessmentName), + "resourceId": autorest.Encode("path", resourceID), + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(string(expand)) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}", 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 AssessmentsClient) GetSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + return autorest.SendWithSender(client, req, sd...) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AssessmentsClient) GetResponder(resp *http.Response) (result Assessment, 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 security assessments on all your scanned resources inside a scope +// Parameters: +// scope - scope of the query, can be subscription (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or +// management group (/providers/Microsoft.Management/managementGroups/mgName). +func (client AssessmentsClient) List(ctx context.Context, scope string) (result AssessmentListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentsClient.List") + defer func() { + sc := -1 + if result.al.Response.Response != nil { + sc = result.al.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, scope) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.al.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.AssessmentsClient", "List", resp, "Failure sending request") + return + } + + result.al, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client AssessmentsClient) ListPreparer(ctx context.Context, scope string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "scope": autorest.Encode("path", scope), + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.Security/assessments", 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 AssessmentsClient) ListSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client AssessmentsClient) ListResponder(resp *http.Response) (result AssessmentList, 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 AssessmentsClient) listNextResults(ctx context.Context, lastResults AssessmentList) (result AssessmentList, err error) { + req, err := lastResults.assessmentListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.AssessmentsClient", "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.AssessmentsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client AssessmentsClient) ListComplete(ctx context.Context, scope string) (result AssessmentListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentsClient.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, scope) + return +} diff --git a/services/preview/security/mgmt/v3.0/security/models.go b/services/preview/security/mgmt/v3.0/security/models.go index 41b00dc8f79c..4d1584c79177 100644 --- a/services/preview/security/mgmt/v3.0/security/models.go +++ b/services/preview/security/mgmt/v3.0/security/models.go @@ -141,6 +141,23 @@ func PossibleAssessedResourceTypeValues() []AssessedResourceType { return []AssessedResourceType{AssessedResourceTypeAdditionalData, AssessedResourceTypeContainerRegistryVulnerability, AssessedResourceTypeServerVulnerabilityAssessment, AssessedResourceTypeSQLServerVulnerability} } +// AssessmentStatusCode enumerates the values for assessment status code. +type AssessmentStatusCode string + +const ( + // Healthy The resource is healthy + Healthy AssessmentStatusCode = "Healthy" + // NotApplicable Assessment for this resource did not happen + NotApplicable AssessmentStatusCode = "NotApplicable" + // Unhealthy The resource has a security issue that needs to be addressed + Unhealthy AssessmentStatusCode = "Unhealthy" +) + +// PossibleAssessmentStatusCodeValues returns an array of possible values for the AssessmentStatusCode const type. +func PossibleAssessmentStatusCodeValues() []AssessmentStatusCode { + return []AssessmentStatusCode{Healthy, NotApplicable, Unhealthy} +} + // AutoProvision enumerates the values for auto provision. type AutoProvision string @@ -330,6 +347,21 @@ func PossibleExecutableValues() []Executable { return []Executable{ExecutableAudit, ExecutableEnforce, ExecutableNone} } +// ExpandEnum enumerates the values for expand enum. +type ExpandEnum string + +const ( + // Links All links associated with an assessment + Links ExpandEnum = "links" + // Metadata Assessment metadata + Metadata ExpandEnum = "metadata" +) + +// PossibleExpandEnumValues returns an array of possible values for the ExpandEnum const type. +func PossibleExpandEnumValues() []ExpandEnum { + return []ExpandEnum{Links, Metadata} +} + // ExportData enumerates the values for export data. type ExportData string @@ -708,19 +740,19 @@ func PossibleReportedSeverityValues() []ReportedSeverity { type ResourceStatus string const ( - // Healthy This assessment on the resource is healthy - Healthy ResourceStatus = "Healthy" - // NotApplicable This assessment is not applicable to this resource - NotApplicable ResourceStatus = "NotApplicable" - // NotHealthy This assessment on the resource is not healthy - NotHealthy ResourceStatus = "NotHealthy" - // OffByPolicy This assessment is turned off by policy on this subscription - OffByPolicy ResourceStatus = "OffByPolicy" + // ResourceStatusHealthy This assessment on the resource is healthy + ResourceStatusHealthy ResourceStatus = "Healthy" + // ResourceStatusNotApplicable This assessment is not applicable to this resource + ResourceStatusNotApplicable ResourceStatus = "NotApplicable" + // ResourceStatusNotHealthy This assessment on the resource is not healthy + ResourceStatusNotHealthy ResourceStatus = "NotHealthy" + // ResourceStatusOffByPolicy This assessment is turned off by policy on this subscription + ResourceStatusOffByPolicy ResourceStatus = "OffByPolicy" ) // PossibleResourceStatusValues returns an array of possible values for the ResourceStatus const type. func PossibleResourceStatusValues() []ResourceStatus { - return []ResourceStatus{Healthy, NotApplicable, NotHealthy, OffByPolicy} + return []ResourceStatus{ResourceStatusHealthy, ResourceStatusNotApplicable, ResourceStatusNotHealthy, ResourceStatusOffByPolicy} } // Script enumerates the values for script. @@ -791,17 +823,17 @@ func PossibleSolutionStatusValues() []SolutionStatus { type Source string const ( - // SourceAws ... - SourceAws Source = "Aws" // SourceAzure ... SourceAzure Source = "Azure" + // SourceOnPremise ... + SourceOnPremise Source = "OnPremise" // SourceResourceDetails ... SourceResourceDetails Source = "ResourceDetails" ) // PossibleSourceValues returns an array of possible values for the Source const type. func PossibleSourceValues() []Source { - return []Source{SourceAws, SourceAzure, SourceResourceDetails} + return []Source{SourceAzure, SourceOnPremise, SourceResourceDetails} } // SourceSystem enumerates the values for source system. @@ -2067,6 +2099,326 @@ func NewAscLocationListPage(getNextPage func(context.Context, AscLocationList) ( return AscLocationListPage{fn: getNextPage} } +// Assessment security assessment on a resource +type Assessment struct { + autorest.Response `json:"-"` + *AssessmentProperties `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 Assessment. +func (a Assessment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if a.AssessmentProperties != nil { + objectMap["properties"] = a.AssessmentProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Assessment struct. +func (a *Assessment) 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 assessmentProperties AssessmentProperties + err = json.Unmarshal(*v, &assessmentProperties) + if err != nil { + return err + } + a.AssessmentProperties = &assessmentProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + a.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + a.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + a.Type = &typeVar + } + } + } + + return nil +} + +// AssessmentLinks links relevant to the assessment +type AssessmentLinks struct { + // AzurePortal - READ-ONLY; Link to assessment in Azure Portal + AzurePortal *string `json:"azurePortal,omitempty"` +} + +// AssessmentList page of a security assessments list +type AssessmentList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Collection of security assessments in this page + Value *[]Assessment `json:"value,omitempty"` + // NextLink - READ-ONLY; The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// AssessmentListIterator provides access to a complete listing of Assessment values. +type AssessmentListIterator struct { + i int + page AssessmentListPage +} + +// 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 *AssessmentListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentListIterator.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 *AssessmentListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter AssessmentListIterator) 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 AssessmentListIterator) Response() AssessmentList { + 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 AssessmentListIterator) Value() Assessment { + if !iter.page.NotDone() { + return Assessment{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the AssessmentListIterator type. +func NewAssessmentListIterator(page AssessmentListPage) AssessmentListIterator { + return AssessmentListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (al AssessmentList) IsEmpty() bool { + return al.Value == nil || len(*al.Value) == 0 +} + +// assessmentListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (al AssessmentList) assessmentListPreparer(ctx context.Context) (*http.Request, error) { + if al.NextLink == nil || len(to.String(al.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(al.NextLink))) +} + +// AssessmentListPage contains a page of Assessment values. +type AssessmentListPage struct { + fn func(context.Context, AssessmentList) (AssessmentList, error) + al AssessmentList +} + +// 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 *AssessmentListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentListPage.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.al) + if err != nil { + return err + } + page.al = 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 *AssessmentListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page AssessmentListPage) NotDone() bool { + return !page.al.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page AssessmentListPage) Response() AssessmentList { + return page.al +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page AssessmentListPage) Values() []Assessment { + if page.al.IsEmpty() { + return nil + } + return *page.al.Value +} + +// Creates a new instance of the AssessmentListPage type. +func NewAssessmentListPage(getNextPage func(context.Context, AssessmentList) (AssessmentList, error)) AssessmentListPage { + return AssessmentListPage{fn: getNextPage} +} + +// AssessmentProperties describes properties of an assessment. +type AssessmentProperties struct { + ResourceDetails BasicResourceDetails `json:"resourceDetails,omitempty"` + // DisplayName - READ-ONLY; User friendly display name of the assessment + DisplayName *string `json:"displayName,omitempty"` + Status *AssessmentStatus `json:"status,omitempty"` + // AdditionalData - Additional data regarding the assessment + AdditionalData map[string]*string `json:"additionalData"` + Links *AssessmentLinks `json:"links,omitempty"` +} + +// MarshalJSON is the custom marshaler for AssessmentProperties. +func (ap AssessmentProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + objectMap["resourceDetails"] = ap.ResourceDetails + if ap.Status != nil { + objectMap["status"] = ap.Status + } + if ap.AdditionalData != nil { + objectMap["additionalData"] = ap.AdditionalData + } + if ap.Links != nil { + objectMap["links"] = ap.Links + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AssessmentProperties struct. +func (ap *AssessmentProperties) 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 "resourceDetails": + if v != nil { + resourceDetails, err := unmarshalBasicResourceDetails(*v) + if err != nil { + return err + } + ap.ResourceDetails = resourceDetails + } + case "displayName": + if v != nil { + var displayName string + err = json.Unmarshal(*v, &displayName) + if err != nil { + return err + } + ap.DisplayName = &displayName + } + case "status": + if v != nil { + var status AssessmentStatus + err = json.Unmarshal(*v, &status) + if err != nil { + return err + } + ap.Status = &status + } + case "additionalData": + if v != nil { + var additionalData map[string]*string + err = json.Unmarshal(*v, &additionalData) + if err != nil { + return err + } + ap.AdditionalData = additionalData + } + case "links": + if v != nil { + var links AssessmentLinks + err = json.Unmarshal(*v, &links) + if err != nil { + return err + } + ap.Links = &links + } + } + } + + return nil +} + +// AssessmentStatus the result of the assessment +type AssessmentStatus struct { + // Code - Programmatic code for the status of the assessment. Possible values include: 'Healthy', 'Unhealthy', 'NotApplicable' + Code AssessmentStatusCode `json:"code,omitempty"` + // Cause - Programmatic code for the cause of the assessment status + Cause *string `json:"cause,omitempty"` + // Description - Human readable description of the assessment status + Description *string `json:"description,omitempty"` +} + // AtaExternalSecuritySolution represents an ATA security solution which sends logs to an OMS workspace type AtaExternalSecuritySolution struct { Properties *AtaSolutionProperties `json:"properties,omitempty"` @@ -3650,51 +4002,11 @@ type AutoProvisioningSettingProperties struct { AutoProvision AutoProvision `json:"autoProvision,omitempty"` } -// AwsResourceDetails details of the resource that was assessed -type AwsResourceDetails struct { - // AccountID - READ-ONLY; AWS account ID - AccountID *string `json:"accountId,omitempty"` - // AwsResourceID - READ-ONLY; AWS resource ID. can be ARN or other - AwsResourceID *string `json:"awsResourceId,omitempty"` - // Source - Possible values include: 'SourceResourceDetails', 'SourceAzure', 'SourceAws' - Source Source `json:"source,omitempty"` -} - -// MarshalJSON is the custom marshaler for AwsResourceDetails. -func (ard AwsResourceDetails) MarshalJSON() ([]byte, error) { - ard.Source = SourceAws - objectMap := make(map[string]interface{}) - if ard.Source != "" { - objectMap["source"] = ard.Source - } - return json.Marshal(objectMap) -} - -// AsAzureResourceDetails is the BasicResourceDetails implementation for AwsResourceDetails. -func (ard AwsResourceDetails) AsAzureResourceDetails() (*AzureResourceDetails, bool) { - return nil, false -} - -// AsAwsResourceDetails is the BasicResourceDetails implementation for AwsResourceDetails. -func (ard AwsResourceDetails) AsAwsResourceDetails() (*AwsResourceDetails, bool) { - return &ard, true -} - -// AsResourceDetails is the BasicResourceDetails implementation for AwsResourceDetails. -func (ard AwsResourceDetails) AsResourceDetails() (*ResourceDetails, bool) { - return nil, false -} - -// AsBasicResourceDetails is the BasicResourceDetails implementation for AwsResourceDetails. -func (ard AwsResourceDetails) AsBasicResourceDetails() (BasicResourceDetails, bool) { - return &ard, true -} - -// AzureResourceDetails details of the resource that was assessed +// AzureResourceDetails details of the Azure resource that was assessed type AzureResourceDetails struct { - // ID - READ-ONLY; Azure resource ID of the assessed resource + // ID - Azure resource Id of the assessed resource ID *string `json:"id,omitempty"` - // Source - Possible values include: 'SourceResourceDetails', 'SourceAzure', 'SourceAws' + // Source - Possible values include: 'SourceResourceDetails', 'SourceOnPremise', 'SourceAzure' Source Source `json:"source,omitempty"` } @@ -3702,22 +4014,25 @@ type AzureResourceDetails struct { func (ard AzureResourceDetails) MarshalJSON() ([]byte, error) { ard.Source = SourceAzure objectMap := make(map[string]interface{}) + if ard.ID != nil { + objectMap["id"] = ard.ID + } if ard.Source != "" { objectMap["source"] = ard.Source } return json.Marshal(objectMap) } +// AsOnPremiseResourceDetails is the BasicResourceDetails implementation for AzureResourceDetails. +func (ard AzureResourceDetails) AsOnPremiseResourceDetails() (*OnPremiseResourceDetails, bool) { + return nil, false +} + // AsAzureResourceDetails is the BasicResourceDetails implementation for AzureResourceDetails. func (ard AzureResourceDetails) AsAzureResourceDetails() (*AzureResourceDetails, bool) { return &ard, true } -// AsAwsResourceDetails is the BasicResourceDetails implementation for AzureResourceDetails. -func (ard AzureResourceDetails) AsAwsResourceDetails() (*AwsResourceDetails, bool) { - return nil, false -} - // AsResourceDetails is the BasicResourceDetails implementation for AzureResourceDetails. func (ard AzureResourceDetails) AsResourceDetails() (*ResourceDetails, bool) { return nil, false @@ -4400,7 +4715,7 @@ func NewComplianceResultListPage(getNextPage func(context.Context, ComplianceRes // ComplianceResultProperties compliance result data type ComplianceResultProperties struct { - // ResourceStatus - READ-ONLY; The status of the resource regarding a single assessment. Possible values include: 'Healthy', 'NotApplicable', 'OffByPolicy', 'NotHealthy' + // ResourceStatus - READ-ONLY; The status of the resource regarding a single assessment. Possible values include: 'ResourceStatusHealthy', 'ResourceStatusNotApplicable', 'ResourceStatusOffByPolicy', 'ResourceStatusNotHealthy' ResourceStatus ResourceStatus `json:"resourceStatus,omitempty"` } @@ -7311,6 +7626,62 @@ type Location struct { Location *string `json:"location,omitempty"` } +// OnPremiseResourceDetails details of the On Premise resource that was assessed +type OnPremiseResourceDetails struct { + // WorkspaceID - Azure resource Id of the workspace the machine is attached to + WorkspaceID *string `json:"workspaceId,omitempty"` + // Vmuuid - The unique Id of the machine + Vmuuid *string `json:"vmuuid,omitempty"` + // SourceComputerID - The oms agent Id installed on the machine + SourceComputerID *string `json:"sourceComputerId,omitempty"` + // MachineName - The name of the machine + MachineName *string `json:"machineName,omitempty"` + // Source - Possible values include: 'SourceResourceDetails', 'SourceOnPremise', 'SourceAzure' + Source Source `json:"source,omitempty"` +} + +// MarshalJSON is the custom marshaler for OnPremiseResourceDetails. +func (oprd OnPremiseResourceDetails) MarshalJSON() ([]byte, error) { + oprd.Source = SourceOnPremise + objectMap := make(map[string]interface{}) + if oprd.WorkspaceID != nil { + objectMap["workspaceId"] = oprd.WorkspaceID + } + if oprd.Vmuuid != nil { + objectMap["vmuuid"] = oprd.Vmuuid + } + if oprd.SourceComputerID != nil { + objectMap["sourceComputerId"] = oprd.SourceComputerID + } + if oprd.MachineName != nil { + objectMap["machineName"] = oprd.MachineName + } + if oprd.Source != "" { + objectMap["source"] = oprd.Source + } + return json.Marshal(objectMap) +} + +// AsOnPremiseResourceDetails is the BasicResourceDetails implementation for OnPremiseResourceDetails. +func (oprd OnPremiseResourceDetails) AsOnPremiseResourceDetails() (*OnPremiseResourceDetails, bool) { + return &oprd, true +} + +// AsAzureResourceDetails is the BasicResourceDetails implementation for OnPremiseResourceDetails. +func (oprd OnPremiseResourceDetails) AsAzureResourceDetails() (*AzureResourceDetails, bool) { + return nil, false +} + +// AsResourceDetails is the BasicResourceDetails implementation for OnPremiseResourceDetails. +func (oprd OnPremiseResourceDetails) AsResourceDetails() (*ResourceDetails, bool) { + return nil, false +} + +// AsBasicResourceDetails is the BasicResourceDetails implementation for OnPremiseResourceDetails. +func (oprd OnPremiseResourceDetails) AsBasicResourceDetails() (BasicResourceDetails, bool) { + return &oprd, true +} + // Operation possible operation in the REST API of Microsoft.Security type Operation struct { // Name - READ-ONLY; Name of the operation @@ -8340,14 +8711,14 @@ type Resource struct { // BasicResourceDetails details of the resource that was assessed type BasicResourceDetails interface { + AsOnPremiseResourceDetails() (*OnPremiseResourceDetails, bool) AsAzureResourceDetails() (*AzureResourceDetails, bool) - AsAwsResourceDetails() (*AwsResourceDetails, bool) AsResourceDetails() (*ResourceDetails, bool) } // ResourceDetails details of the resource that was assessed type ResourceDetails struct { - // Source - Possible values include: 'SourceResourceDetails', 'SourceAzure', 'SourceAws' + // Source - Possible values include: 'SourceResourceDetails', 'SourceOnPremise', 'SourceAzure' Source Source `json:"source,omitempty"` } @@ -8359,14 +8730,14 @@ func unmarshalBasicResourceDetails(body []byte) (BasicResourceDetails, error) { } switch m["source"] { + case string(SourceOnPremise): + var oprd OnPremiseResourceDetails + err := json.Unmarshal(body, &oprd) + return oprd, err case string(SourceAzure): var ard AzureResourceDetails err := json.Unmarshal(body, &ard) return ard, err - case string(SourceAws): - var ard AwsResourceDetails - err := json.Unmarshal(body, &ard) - return ard, err default: var rd ResourceDetails err := json.Unmarshal(body, &rd) @@ -8402,13 +8773,13 @@ func (rd ResourceDetails) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } -// AsAzureResourceDetails is the BasicResourceDetails implementation for ResourceDetails. -func (rd ResourceDetails) AsAzureResourceDetails() (*AzureResourceDetails, bool) { +// AsOnPremiseResourceDetails is the BasicResourceDetails implementation for ResourceDetails. +func (rd ResourceDetails) AsOnPremiseResourceDetails() (*OnPremiseResourceDetails, bool) { return nil, false } -// AsAwsResourceDetails is the BasicResourceDetails implementation for ResourceDetails. -func (rd ResourceDetails) AsAwsResourceDetails() (*AwsResourceDetails, bool) { +// AsAzureResourceDetails is the BasicResourceDetails implementation for ResourceDetails. +func (rd ResourceDetails) AsAzureResourceDetails() (*AzureResourceDetails, bool) { return nil, false } 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 8be8f8406950..47d6d7dbdb3d 100644 --- a/services/preview/security/mgmt/v3.0/security/securityapi/interfaces.go +++ b/services/preview/security/mgmt/v3.0/security/securityapi/interfaces.go @@ -309,3 +309,13 @@ type AutomationsClientAPI interface { } var _ AutomationsClientAPI = (*security.AutomationsClient)(nil) + +// AssessmentsClientAPI contains the set of methods on the AssessmentsClient type. +type AssessmentsClientAPI interface { + Create(ctx context.Context, resourceID string, assessmentName string, body security.Assessment) (result security.Assessment, err error) + Delete(ctx context.Context, resourceID string, assessmentName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceID string, assessmentName string, expand security.ExpandEnum) (result security.Assessment, err error) + List(ctx context.Context, scope string) (result security.AssessmentListPage, err error) +} + +var _ AssessmentsClientAPI = (*security.AssessmentsClient)(nil)