diff --git a/profiles/preview/preview/securityinsight/mgmt/securityinsight/models.go b/profiles/preview/preview/securityinsight/mgmt/securityinsight/models.go index 7acae24dff0f..f5fcaaf299ef 100644 --- a/profiles/preview/preview/securityinsight/mgmt/securityinsight/models.go +++ b/profiles/preview/preview/securityinsight/mgmt/securityinsight/models.go @@ -35,6 +35,42 @@ const ( Scheduled AlertRuleKind = original.Scheduled ) +type AlertSeverity = original.AlertSeverity + +const ( + High AlertSeverity = original.High + Informational AlertSeverity = original.Informational + Low AlertSeverity = original.Low + Medium AlertSeverity = original.Medium +) + +type CaseSeverity = original.CaseSeverity + +const ( + CaseSeverityCritical CaseSeverity = original.CaseSeverityCritical + CaseSeverityHigh CaseSeverity = original.CaseSeverityHigh + CaseSeverityInformational CaseSeverity = original.CaseSeverityInformational + CaseSeverityLow CaseSeverity = original.CaseSeverityLow + CaseSeverityMedium CaseSeverity = original.CaseSeverityMedium +) + +type CaseStatus = original.CaseStatus + +const ( + Closed CaseStatus = original.Closed + Draft CaseStatus = original.Draft + InProgress CaseStatus = original.InProgress + Open CaseStatus = original.Open +) + +type CloseReason = original.CloseReason + +const ( + Dismissed CloseReason = original.Dismissed + Other CloseReason = original.Other + Resolved CloseReason = original.Resolved +) + type DataConnectorKind = original.DataConnectorKind const ( @@ -52,6 +88,14 @@ const ( Enabled DataTypeState = original.Enabled ) +type EntityKind = original.EntityKind + +const ( + Account EntityKind = original.Account + File EntityKind = original.File + Host EntityKind = original.Host +) + type Kind = original.Kind const ( @@ -65,19 +109,49 @@ const ( KindAzureActiveDirectory KindBasicDataConnector = original.KindAzureActiveDirectory KindAzureSecurityCenter KindBasicDataConnector = original.KindAzureSecurityCenter KindDataConnector KindBasicDataConnector = original.KindDataConnector - KindDataConnectorWithAlerts KindBasicDataConnector = original.KindDataConnectorWithAlerts KindMicrosoftCloudAppSecurity KindBasicDataConnector = original.KindMicrosoftCloudAppSecurity KindOffice365 KindBasicDataConnector = original.KindOffice365 KindThreatIntelligence KindBasicDataConnector = original.KindThreatIntelligence ) -type Severity = original.Severity +type KindBasicEntity = original.KindBasicEntity const ( - High Severity = original.High - Informational Severity = original.Informational - Low Severity = original.Low - Medium Severity = original.Medium + KindAccount KindBasicEntity = original.KindAccount + KindEntity KindBasicEntity = original.KindEntity + KindFile KindBasicEntity = original.KindFile + KindHost KindBasicEntity = original.KindHost +) + +type KindBasicSettings = original.KindBasicSettings + +const ( + KindSettings KindBasicSettings = original.KindSettings + KindToggleSettings KindBasicSettings = original.KindToggleSettings + KindUebaSettings KindBasicSettings = original.KindUebaSettings +) + +type OSFamily = original.OSFamily + +const ( + Android OSFamily = original.Android + IOS OSFamily = original.IOS + Linux OSFamily = original.Linux + Windows OSFamily = original.Windows +) + +type SettingKind = original.SettingKind + +const ( + SettingKindToggleSettings SettingKind = original.SettingKindToggleSettings + SettingKindUebaSettings SettingKind = original.SettingKindUebaSettings +) + +type StatusInMcas = original.StatusInMcas + +const ( + StatusInMcasDisabled StatusInMcas = original.StatusInMcasDisabled + StatusInMcasEnabled StatusInMcas = original.StatusInMcasEnabled ) type TriggerOperator = original.TriggerOperator @@ -90,7 +164,17 @@ const ( ) type AADDataConnector = original.AADDataConnector +type AADDataConnectorProperties = original.AADDataConnectorProperties type ASCDataConnector = original.ASCDataConnector +type ASCDataConnectorProperties = original.ASCDataConnectorProperties +type AccountEntity = original.AccountEntity +type AccountEntityProperties = original.AccountEntityProperties +type Action = original.Action +type ActionProperties = original.ActionProperties +type ActionsClient = original.ActionsClient +type ActionsList = original.ActionsList +type ActionsListIterator = original.ActionsListIterator +type ActionsListPage = original.ActionsListPage type AlertRule = original.AlertRule type AlertRuleKind1 = original.AlertRuleKind1 type AlertRuleModel = original.AlertRuleModel @@ -103,21 +187,51 @@ type AlertsDataTypeOfDataConnectorAlerts = original.AlertsDataTypeOfDataConnecto type BaseClient = original.BaseClient type BasicAlertRule = original.BasicAlertRule type BasicDataConnector = original.BasicDataConnector -type BasicDataConnectorWithAlerts = original.BasicDataConnectorWithAlerts +type BasicEntity = original.BasicEntity +type BasicSettings = original.BasicSettings +type Bookmark = original.Bookmark +type BookmarkList = original.BookmarkList +type BookmarkListIterator = original.BookmarkListIterator +type BookmarkListPage = original.BookmarkListPage +type BookmarkProperties = original.BookmarkProperties +type BookmarksClient = original.BookmarksClient +type Case = original.Case +type CaseList = original.CaseList +type CaseListIterator = original.CaseListIterator +type CaseListPage = original.CaseListPage +type CaseProperties = original.CaseProperties +type CasesClient = original.CasesClient type CloudError = original.CloudError type CloudErrorBody = original.CloudErrorBody type DataConnector = original.DataConnector -type DataConnectorContextID = original.DataConnectorContextID type DataConnectorDataTypeCommon = original.DataConnectorDataTypeCommon type DataConnectorKind1 = original.DataConnectorKind1 type DataConnectorList = original.DataConnectorList type DataConnectorListIterator = original.DataConnectorListIterator type DataConnectorListPage = original.DataConnectorListPage type DataConnectorModel = original.DataConnectorModel -type DataConnectorWithAlerts = original.DataConnectorWithAlerts +type DataConnectorTenantID = original.DataConnectorTenantID type DataConnectorWithAlertsProperties = original.DataConnectorWithAlertsProperties type DataConnectorsClient = original.DataConnectorsClient +type EntitiesClient = original.EntitiesClient +type Entity = original.Entity +type EntityKind1 = original.EntityKind1 +type EntityList = original.EntityList +type EntityListIterator = original.EntityListIterator +type EntityListPage = original.EntityListPage +type EntityModel = original.EntityModel +type FileEntity = original.FileEntity +type FileEntityProperties = original.FileEntityProperties +type HostEntity = original.HostEntity +type HostEntityProperties = original.HostEntityProperties type MCASDataConnector = original.MCASDataConnector +type MCASDataConnectorProperties = original.MCASDataConnectorProperties +type OfficeConsent = original.OfficeConsent +type OfficeConsentList = original.OfficeConsentList +type OfficeConsentListIterator = original.OfficeConsentListIterator +type OfficeConsentListPage = original.OfficeConsentListPage +type OfficeConsentProperties = original.OfficeConsentProperties +type OfficeConsentsClient = original.OfficeConsentsClient type OfficeDataConnector = original.OfficeDataConnector type OfficeDataConnectorDataTypes = original.OfficeDataConnectorDataTypes type OfficeDataConnectorDataTypesExchange = original.OfficeDataConnectorDataTypesExchange @@ -129,17 +243,38 @@ type OperationsClient = original.OperationsClient type OperationsList = original.OperationsList type OperationsListIterator = original.OperationsListIterator type OperationsListPage = original.OperationsListPage +type ProductSettingsClient = original.ProductSettingsClient type Resource = original.Resource type ScheduledAlertRule = original.ScheduledAlertRule type ScheduledAlertRuleProperties = original.ScheduledAlertRuleProperties +type Settings = original.Settings +type SettingsKind = original.SettingsKind +type SettingsModel = original.SettingsModel type TIDataConnector = original.TIDataConnector type TIDataConnectorDataTypes = original.TIDataConnectorDataTypes type TIDataConnectorDataTypesIndicators = original.TIDataConnectorDataTypesIndicators type TIDataConnectorProperties = original.TIDataConnectorProperties +type ToggleSettings = original.ToggleSettings +type ToggleSettingsProperties = original.ToggleSettingsProperties +type UebaSettings = original.UebaSettings +type UebaSettingsProperties = original.UebaSettingsProperties +type UserInfo = original.UserInfo func New(subscriptionID string) BaseClient { return original.New(subscriptionID) } +func NewActionsClient(subscriptionID string) ActionsClient { + return original.NewActionsClient(subscriptionID) +} +func NewActionsClientWithBaseURI(baseURI string, subscriptionID string) ActionsClient { + return original.NewActionsClientWithBaseURI(baseURI, subscriptionID) +} +func NewActionsListIterator(page ActionsListPage) ActionsListIterator { + return original.NewActionsListIterator(page) +} +func NewActionsListPage(getNextPage func(context.Context, ActionsList) (ActionsList, error)) ActionsListPage { + return original.NewActionsListPage(getNextPage) +} func NewAlertRulesClient(subscriptionID string) AlertRulesClient { return original.NewAlertRulesClient(subscriptionID) } @@ -152,6 +287,30 @@ func NewAlertRulesListIterator(page AlertRulesListPage) AlertRulesListIterator { func NewAlertRulesListPage(getNextPage func(context.Context, AlertRulesList) (AlertRulesList, error)) AlertRulesListPage { return original.NewAlertRulesListPage(getNextPage) } +func NewBookmarkListIterator(page BookmarkListPage) BookmarkListIterator { + return original.NewBookmarkListIterator(page) +} +func NewBookmarkListPage(getNextPage func(context.Context, BookmarkList) (BookmarkList, error)) BookmarkListPage { + return original.NewBookmarkListPage(getNextPage) +} +func NewBookmarksClient(subscriptionID string) BookmarksClient { + return original.NewBookmarksClient(subscriptionID) +} +func NewBookmarksClientWithBaseURI(baseURI string, subscriptionID string) BookmarksClient { + return original.NewBookmarksClientWithBaseURI(baseURI, subscriptionID) +} +func NewCaseListIterator(page CaseListPage) CaseListIterator { + return original.NewCaseListIterator(page) +} +func NewCaseListPage(getNextPage func(context.Context, CaseList) (CaseList, error)) CaseListPage { + return original.NewCaseListPage(getNextPage) +} +func NewCasesClient(subscriptionID string) CasesClient { + return original.NewCasesClient(subscriptionID) +} +func NewCasesClientWithBaseURI(baseURI string, subscriptionID string) CasesClient { + return original.NewCasesClientWithBaseURI(baseURI, subscriptionID) +} func NewDataConnectorListIterator(page DataConnectorListPage) DataConnectorListIterator { return original.NewDataConnectorListIterator(page) } @@ -164,6 +323,30 @@ func NewDataConnectorsClient(subscriptionID string) DataConnectorsClient { func NewDataConnectorsClientWithBaseURI(baseURI string, subscriptionID string) DataConnectorsClient { return original.NewDataConnectorsClientWithBaseURI(baseURI, subscriptionID) } +func NewEntitiesClient(subscriptionID string) EntitiesClient { + return original.NewEntitiesClient(subscriptionID) +} +func NewEntitiesClientWithBaseURI(baseURI string, subscriptionID string) EntitiesClient { + return original.NewEntitiesClientWithBaseURI(baseURI, subscriptionID) +} +func NewEntityListIterator(page EntityListPage) EntityListIterator { + return original.NewEntityListIterator(page) +} +func NewEntityListPage(getNextPage func(context.Context, EntityList) (EntityList, error)) EntityListPage { + return original.NewEntityListPage(getNextPage) +} +func NewOfficeConsentListIterator(page OfficeConsentListPage) OfficeConsentListIterator { + return original.NewOfficeConsentListIterator(page) +} +func NewOfficeConsentListPage(getNextPage func(context.Context, OfficeConsentList) (OfficeConsentList, error)) OfficeConsentListPage { + return original.NewOfficeConsentListPage(getNextPage) +} +func NewOfficeConsentsClient(subscriptionID string) OfficeConsentsClient { + return original.NewOfficeConsentsClient(subscriptionID) +} +func NewOfficeConsentsClientWithBaseURI(baseURI string, subscriptionID string) OfficeConsentsClient { + return original.NewOfficeConsentsClientWithBaseURI(baseURI, subscriptionID) +} func NewOperationsClient(subscriptionID string) OperationsClient { return original.NewOperationsClient(subscriptionID) } @@ -176,26 +359,59 @@ func NewOperationsListIterator(page OperationsListPage) OperationsListIterator { func NewOperationsListPage(getNextPage func(context.Context, OperationsList) (OperationsList, error)) OperationsListPage { return original.NewOperationsListPage(getNextPage) } +func NewProductSettingsClient(subscriptionID string) ProductSettingsClient { + return original.NewProductSettingsClient(subscriptionID) +} +func NewProductSettingsClientWithBaseURI(baseURI string, subscriptionID string) ProductSettingsClient { + return original.NewProductSettingsClientWithBaseURI(baseURI, subscriptionID) +} func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { return original.NewWithBaseURI(baseURI, subscriptionID) } func PossibleAlertRuleKindValues() []AlertRuleKind { return original.PossibleAlertRuleKindValues() } +func PossibleAlertSeverityValues() []AlertSeverity { + return original.PossibleAlertSeverityValues() +} +func PossibleCaseSeverityValues() []CaseSeverity { + return original.PossibleCaseSeverityValues() +} +func PossibleCaseStatusValues() []CaseStatus { + return original.PossibleCaseStatusValues() +} +func PossibleCloseReasonValues() []CloseReason { + return original.PossibleCloseReasonValues() +} func PossibleDataConnectorKindValues() []DataConnectorKind { return original.PossibleDataConnectorKindValues() } func PossibleDataTypeStateValues() []DataTypeState { return original.PossibleDataTypeStateValues() } +func PossibleEntityKindValues() []EntityKind { + return original.PossibleEntityKindValues() +} func PossibleKindBasicDataConnectorValues() []KindBasicDataConnector { return original.PossibleKindBasicDataConnectorValues() } +func PossibleKindBasicEntityValues() []KindBasicEntity { + return original.PossibleKindBasicEntityValues() +} +func PossibleKindBasicSettingsValues() []KindBasicSettings { + return original.PossibleKindBasicSettingsValues() +} func PossibleKindValues() []Kind { return original.PossibleKindValues() } -func PossibleSeverityValues() []Severity { - return original.PossibleSeverityValues() +func PossibleOSFamilyValues() []OSFamily { + return original.PossibleOSFamilyValues() +} +func PossibleSettingKindValues() []SettingKind { + return original.PossibleSettingKindValues() +} +func PossibleStatusInMcasValues() []StatusInMcas { + return original.PossibleStatusInMcasValues() } func PossibleTriggerOperatorValues() []TriggerOperator { return original.PossibleTriggerOperatorValues() diff --git a/profiles/preview/preview/securityinsight/mgmt/securityinsight/securityinsightapi/models.go b/profiles/preview/preview/securityinsight/mgmt/securityinsight/securityinsightapi/models.go index b1312cfcf2d6..4108e71b917d 100644 --- a/profiles/preview/preview/securityinsight/mgmt/securityinsight/securityinsightapi/models.go +++ b/profiles/preview/preview/securityinsight/mgmt/securityinsight/securityinsightapi/models.go @@ -21,6 +21,12 @@ package securityinsightapi import original "github.com/Azure/azure-sdk-for-go/services/preview/securityinsight/mgmt/2017-08-01-preview/securityinsight/securityinsightapi" +type ActionsClientAPI = original.ActionsClientAPI type AlertRulesClientAPI = original.AlertRulesClientAPI +type BookmarksClientAPI = original.BookmarksClientAPI +type CasesClientAPI = original.CasesClientAPI type DataConnectorsClientAPI = original.DataConnectorsClientAPI +type EntitiesClientAPI = original.EntitiesClientAPI +type OfficeConsentsClientAPI = original.OfficeConsentsClientAPI type OperationsClientAPI = original.OperationsClientAPI +type ProductSettingsClientAPI = original.ProductSettingsClientAPI diff --git a/services/preview/securityinsight/mgmt/2017-08-01-preview/securityinsight/actions.go b/services/preview/securityinsight/mgmt/2017-08-01-preview/securityinsight/actions.go new file mode 100644 index 000000000000..56311b61d525 --- /dev/null +++ b/services/preview/securityinsight/mgmt/2017-08-01-preview/securityinsight/actions.go @@ -0,0 +1,176 @@ +package securityinsight + +// 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" +) + +// ActionsClient is the API spec for Microsoft.SecurityInsights (Azure Security Insights) resource provider +type ActionsClient struct { + BaseClient +} + +// NewActionsClient creates an instance of the ActionsClient client. +func NewActionsClient(subscriptionID string) ActionsClient { + return NewActionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewActionsClientWithBaseURI creates an instance of the ActionsClient client. +func NewActionsClientWithBaseURI(baseURI string, subscriptionID string) ActionsClient { + return ActionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByAlertRule gets all actions of alert rule. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// operationalInsightsResourceProvider - the namespace of workspaces resource provider- +// Microsoft.OperationalInsights. +// workspaceName - the name of the workspace. +// ruleID - alert rule ID +func (client ActionsClient) ListByAlertRule(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, ruleID string) (result ActionsListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ActionsClient.ListByAlertRule") + defer func() { + sc := -1 + if result.al.Response.Response != nil { + sc = result.al.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: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("securityinsight.ActionsClient", "ListByAlertRule", err.Error()) + } + + result.fn = client.listByAlertRuleNextResults + req, err := client.ListByAlertRulePreparer(ctx, resourceGroupName, operationalInsightsResourceProvider, workspaceName, ruleID) + if err != nil { + err = autorest.NewErrorWithError(err, "securityinsight.ActionsClient", "ListByAlertRule", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAlertRuleSender(req) + if err != nil { + result.al.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "securityinsight.ActionsClient", "ListByAlertRule", resp, "Failure sending request") + return + } + + result.al, err = client.ListByAlertRuleResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "securityinsight.ActionsClient", "ListByAlertRule", resp, "Failure responding to request") + } + + return +} + +// ListByAlertRulePreparer prepares the ListByAlertRule request. +func (client ActionsClient) ListByAlertRulePreparer(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, ruleID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "operationalInsightsResourceProvider": autorest.Encode("path", operationalInsightsResourceProvider), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleId": autorest.Encode("path", ruleID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + 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}/resourceGroups/{resourceGroupName}/providers/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/alertRules/{ruleId}/actions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByAlertRuleSender sends the ListByAlertRule request. The method will close the +// http.Response Body if it receives an error. +func (client ActionsClient) ListByAlertRuleSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByAlertRuleResponder handles the response to the ListByAlertRule request. The method always +// closes the http.Response Body. +func (client ActionsClient) ListByAlertRuleResponder(resp *http.Response) (result ActionsList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAlertRuleNextResults retrieves the next set of results, if any. +func (client ActionsClient) listByAlertRuleNextResults(ctx context.Context, lastResults ActionsList) (result ActionsList, err error) { + req, err := lastResults.actionsListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "securityinsight.ActionsClient", "listByAlertRuleNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAlertRuleSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "securityinsight.ActionsClient", "listByAlertRuleNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAlertRuleResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "securityinsight.ActionsClient", "listByAlertRuleNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAlertRuleComplete enumerates all values, automatically crossing page boundaries as required. +func (client ActionsClient) ListByAlertRuleComplete(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, ruleID string) (result ActionsListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ActionsClient.ListByAlertRule") + 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.ListByAlertRule(ctx, resourceGroupName, operationalInsightsResourceProvider, workspaceName, ruleID) + return +} diff --git a/services/preview/securityinsight/mgmt/2017-08-01-preview/securityinsight/alertrules.go b/services/preview/securityinsight/mgmt/2017-08-01-preview/securityinsight/alertrules.go index 6309c2fa5a14..4a6b70f60563 100644 --- a/services/preview/securityinsight/mgmt/2017-08-01-preview/securityinsight/alertrules.go +++ b/services/preview/securityinsight/mgmt/2017-08-01-preview/securityinsight/alertrules.go @@ -41,7 +41,7 @@ func NewAlertRulesClientWithBaseURI(baseURI string, subscriptionID string) Alert return AlertRulesClient{NewWithBaseURI(baseURI, subscriptionID)} } -// Create creates or updates the alert rule. +// CreateOrUpdate creates or updates the alert rule. // Parameters: // resourceGroupName - the name of the resource group within the user's subscription. The name is case // insensitive. @@ -50,9 +50,9 @@ func NewAlertRulesClientWithBaseURI(baseURI string, subscriptionID string) Alert // workspaceName - the name of the workspace. // ruleID - alert rule ID // alertRule - the alert rule -func (client AlertRulesClient) Create(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, ruleID string, alertRule BasicAlertRule) (result AlertRuleModel, err error) { +func (client AlertRulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, ruleID string, alertRule BasicAlertRule) (result AlertRuleModel, err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/AlertRulesClient.Create") + ctx = tracing.StartSpan(ctx, fqdn+"/AlertRulesClient.CreateOrUpdate") defer func() { sc := -1 if result.Response.Response != nil { @@ -70,35 +70,33 @@ func (client AlertRulesClient) Create(ctx context.Context, resourceGroupName str {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, {TargetValue: workspaceName, Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "workspaceName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: ruleID, - Constraints: []validation.Constraint{{Target: "ruleID", 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("securityinsight.AlertRulesClient", "Create", err.Error()) + {Target: "workspaceName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("securityinsight.AlertRulesClient", "CreateOrUpdate", err.Error()) } - req, err := client.CreatePreparer(ctx, resourceGroupName, operationalInsightsResourceProvider, workspaceName, ruleID, alertRule) + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, operationalInsightsResourceProvider, workspaceName, ruleID, alertRule) if err != nil { - err = autorest.NewErrorWithError(err, "securityinsight.AlertRulesClient", "Create", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "securityinsight.AlertRulesClient", "CreateOrUpdate", nil, "Failure preparing request") return } - resp, err := client.CreateSender(req) + resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "securityinsight.AlertRulesClient", "Create", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "securityinsight.AlertRulesClient", "CreateOrUpdate", resp, "Failure sending request") return } - result, err = client.CreateResponder(resp) + result, err = client.CreateOrUpdateResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "securityinsight.AlertRulesClient", "Create", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "securityinsight.AlertRulesClient", "CreateOrUpdate", resp, "Failure responding to request") } return } -// CreatePreparer prepares the Create request. -func (client AlertRulesClient) CreatePreparer(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, ruleID string, alertRule BasicAlertRule) (*http.Request, error) { +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client AlertRulesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, ruleID string, alertRule BasicAlertRule) (*http.Request, error) { pathParameters := map[string]interface{}{ "operationalInsightsResourceProvider": autorest.Encode("path", operationalInsightsResourceProvider), "resourceGroupName": autorest.Encode("path", resourceGroupName), @@ -122,16 +120,117 @@ func (client AlertRulesClient) CreatePreparer(ctx context.Context, resourceGroup return preparer.Prepare((&http.Request{}).WithContext(ctx)) } -// CreateSender sends the Create request. The method will close the +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client AlertRulesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client AlertRulesClient) CreateOrUpdateResponder(resp *http.Response) (result AlertRuleModel, 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 +} + +// CreateOrUpdateAction creates or updates the action of alert rule. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// operationalInsightsResourceProvider - the namespace of workspaces resource provider- +// Microsoft.OperationalInsights. +// workspaceName - the name of the workspace. +// ruleID - alert rule ID +// actionID - action ID +// action - the action +func (client AlertRulesClient) CreateOrUpdateAction(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, ruleID string, actionID string, action Action) (result Action, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertRulesClient.CreateOrUpdateAction") + 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: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("securityinsight.AlertRulesClient", "CreateOrUpdateAction", err.Error()) + } + + req, err := client.CreateOrUpdateActionPreparer(ctx, resourceGroupName, operationalInsightsResourceProvider, workspaceName, ruleID, actionID, action) + if err != nil { + err = autorest.NewErrorWithError(err, "securityinsight.AlertRulesClient", "CreateOrUpdateAction", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateActionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "securityinsight.AlertRulesClient", "CreateOrUpdateAction", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateActionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "securityinsight.AlertRulesClient", "CreateOrUpdateAction", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdateActionPreparer prepares the CreateOrUpdateAction request. +func (client AlertRulesClient) CreateOrUpdateActionPreparer(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, ruleID string, actionID string, action Action) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "actionId": autorest.Encode("path", actionID), + "operationalInsightsResourceProvider": autorest.Encode("path", operationalInsightsResourceProvider), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleId": autorest.Encode("path", ruleID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + 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("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/alertRules/{ruleId}/actions/{actionId}", pathParameters), + autorest.WithJSON(action), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateActionSender sends the CreateOrUpdateAction request. The method will close the // http.Response Body if it receives an error. -func (client AlertRulesClient) CreateSender(req *http.Request) (*http.Response, error) { +func (client AlertRulesClient) CreateOrUpdateActionSender(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 +// CreateOrUpdateActionResponder handles the response to the CreateOrUpdateAction request. The method always // closes the http.Response Body. -func (client AlertRulesClient) CreateResponder(resp *http.Response) (result AlertRuleModel, err error) { +func (client AlertRulesClient) CreateOrUpdateActionResponder(resp *http.Response) (result Action, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -170,9 +269,7 @@ func (client AlertRulesClient) Delete(ctx context.Context, resourceGroupName str {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, {TargetValue: workspaceName, Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "workspaceName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: ruleID, - Constraints: []validation.Constraint{{Target: "ruleID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + {Target: "workspaceName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("securityinsight.AlertRulesClient", "Delete", err.Error()) } @@ -239,7 +336,104 @@ func (client AlertRulesClient) DeleteResponder(resp *http.Response) (result auto return } -// Get gets a alert rule. +// DeleteAction delete the action of alert rule. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// operationalInsightsResourceProvider - the namespace of workspaces resource provider- +// Microsoft.OperationalInsights. +// workspaceName - the name of the workspace. +// ruleID - alert rule ID +// actionID - action ID +func (client AlertRulesClient) DeleteAction(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, ruleID string, actionID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertRulesClient.DeleteAction") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("securityinsight.AlertRulesClient", "DeleteAction", err.Error()) + } + + req, err := client.DeleteActionPreparer(ctx, resourceGroupName, operationalInsightsResourceProvider, workspaceName, ruleID, actionID) + if err != nil { + err = autorest.NewErrorWithError(err, "securityinsight.AlertRulesClient", "DeleteAction", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteActionSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "securityinsight.AlertRulesClient", "DeleteAction", resp, "Failure sending request") + return + } + + result, err = client.DeleteActionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "securityinsight.AlertRulesClient", "DeleteAction", resp, "Failure responding to request") + } + + return +} + +// DeleteActionPreparer prepares the DeleteAction request. +func (client AlertRulesClient) DeleteActionPreparer(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, ruleID string, actionID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "actionId": autorest.Encode("path", actionID), + "operationalInsightsResourceProvider": autorest.Encode("path", operationalInsightsResourceProvider), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleId": autorest.Encode("path", ruleID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2019-01-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/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/alertRules/{ruleId}/actions/{actionId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteActionSender sends the DeleteAction request. The method will close the +// http.Response Body if it receives an error. +func (client AlertRulesClient) DeleteActionSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteActionResponder handles the response to the DeleteAction request. The method always +// closes the http.Response Body. +func (client AlertRulesClient) DeleteActionResponder(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 gets the alert rule. // Parameters: // resourceGroupName - the name of the resource group within the user's subscription. The name is case // insensitive. @@ -267,9 +461,7 @@ func (client AlertRulesClient) Get(ctx context.Context, resourceGroupName string {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, {TargetValue: workspaceName, Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "workspaceName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: ruleID, - Constraints: []validation.Constraint{{Target: "ruleID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + {Target: "workspaceName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("securityinsight.AlertRulesClient", "Get", err.Error()) } @@ -337,6 +529,104 @@ func (client AlertRulesClient) GetResponder(resp *http.Response) (result AlertRu return } +// GetAction gets the action of alert rule. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// operationalInsightsResourceProvider - the namespace of workspaces resource provider- +// Microsoft.OperationalInsights. +// workspaceName - the name of the workspace. +// ruleID - alert rule ID +// actionID - action ID +func (client AlertRulesClient) GetAction(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, ruleID string, actionID string) (result Action, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertRulesClient.GetAction") + 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: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("securityinsight.AlertRulesClient", "GetAction", err.Error()) + } + + req, err := client.GetActionPreparer(ctx, resourceGroupName, operationalInsightsResourceProvider, workspaceName, ruleID, actionID) + if err != nil { + err = autorest.NewErrorWithError(err, "securityinsight.AlertRulesClient", "GetAction", nil, "Failure preparing request") + return + } + + resp, err := client.GetActionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "securityinsight.AlertRulesClient", "GetAction", resp, "Failure sending request") + return + } + + result, err = client.GetActionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "securityinsight.AlertRulesClient", "GetAction", resp, "Failure responding to request") + } + + return +} + +// GetActionPreparer prepares the GetAction request. +func (client AlertRulesClient) GetActionPreparer(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, ruleID string, actionID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "actionId": autorest.Encode("path", actionID), + "operationalInsightsResourceProvider": autorest.Encode("path", operationalInsightsResourceProvider), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleId": autorest.Encode("path", ruleID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + 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}/resourceGroups/{resourceGroupName}/providers/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/alertRules/{ruleId}/actions/{actionId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetActionSender sends the GetAction request. The method will close the +// http.Response Body if it receives an error. +func (client AlertRulesClient) GetActionSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetActionResponder handles the response to the GetAction request. The method always +// closes the http.Response Body. +func (client AlertRulesClient) GetActionResponder(resp *http.Response) (result Action, 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 gets all alert rules. // Parameters: // resourceGroupName - the name of the resource group within the user's subscription. The name is case diff --git a/services/preview/securityinsight/mgmt/2017-08-01-preview/securityinsight/bookmarks.go b/services/preview/securityinsight/mgmt/2017-08-01-preview/securityinsight/bookmarks.go new file mode 100644 index 000000000000..e9c7224ad3fd --- /dev/null +++ b/services/preview/securityinsight/mgmt/2017-08-01-preview/securityinsight/bookmarks.go @@ -0,0 +1,469 @@ +package securityinsight + +// 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" +) + +// BookmarksClient is the API spec for Microsoft.SecurityInsights (Azure Security Insights) resource provider +type BookmarksClient struct { + BaseClient +} + +// NewBookmarksClient creates an instance of the BookmarksClient client. +func NewBookmarksClient(subscriptionID string) BookmarksClient { + return NewBookmarksClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewBookmarksClientWithBaseURI creates an instance of the BookmarksClient client. +func NewBookmarksClientWithBaseURI(baseURI string, subscriptionID string) BookmarksClient { + return BookmarksClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates the bookmark. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// operationalInsightsResourceProvider - the namespace of workspaces resource provider- +// Microsoft.OperationalInsights. +// workspaceName - the name of the workspace. +// bookmarkID - bookmark ID +// bookmark - the bookmark +func (client BookmarksClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, bookmarkID string, bookmark Bookmark) (result Bookmark, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BookmarksClient.CreateOrUpdate") + 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: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: bookmark, + Constraints: []validation.Constraint{{Target: "bookmark.BookmarkProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "bookmark.BookmarkProperties.DisplayName", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "bookmark.BookmarkProperties.Query", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("securityinsight.BookmarksClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, operationalInsightsResourceProvider, workspaceName, bookmarkID, bookmark) + if err != nil { + err = autorest.NewErrorWithError(err, "securityinsight.BookmarksClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "securityinsight.BookmarksClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "securityinsight.BookmarksClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client BookmarksClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, bookmarkID string, bookmark Bookmark) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "bookmarkId": autorest.Encode("path", bookmarkID), + "operationalInsightsResourceProvider": autorest.Encode("path", operationalInsightsResourceProvider), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + 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("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/bookmarks/{bookmarkId}", pathParameters), + autorest.WithJSON(bookmark), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client BookmarksClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client BookmarksClient) CreateOrUpdateResponder(resp *http.Response) (result Bookmark, 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 delete the bookmark. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// operationalInsightsResourceProvider - the namespace of workspaces resource provider- +// Microsoft.OperationalInsights. +// workspaceName - the name of the workspace. +// bookmarkID - bookmark ID +func (client BookmarksClient) Delete(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, bookmarkID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BookmarksClient.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}}}, + {TargetValue: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("securityinsight.BookmarksClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, operationalInsightsResourceProvider, workspaceName, bookmarkID) + if err != nil { + err = autorest.NewErrorWithError(err, "securityinsight.BookmarksClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "securityinsight.BookmarksClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "securityinsight.BookmarksClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client BookmarksClient) DeletePreparer(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, bookmarkID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "bookmarkId": autorest.Encode("path", bookmarkID), + "operationalInsightsResourceProvider": autorest.Encode("path", operationalInsightsResourceProvider), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2019-01-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/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/bookmarks/{bookmarkId}", 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 BookmarksClient) 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 BookmarksClient) 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 gets a bookmark. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// operationalInsightsResourceProvider - the namespace of workspaces resource provider- +// Microsoft.OperationalInsights. +// workspaceName - the name of the workspace. +// bookmarkID - bookmark ID +func (client BookmarksClient) Get(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, bookmarkID string) (result Bookmark, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BookmarksClient.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}}}, + {TargetValue: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("securityinsight.BookmarksClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, operationalInsightsResourceProvider, workspaceName, bookmarkID) + if err != nil { + err = autorest.NewErrorWithError(err, "securityinsight.BookmarksClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "securityinsight.BookmarksClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "securityinsight.BookmarksClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client BookmarksClient) GetPreparer(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, bookmarkID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "bookmarkId": autorest.Encode("path", bookmarkID), + "operationalInsightsResourceProvider": autorest.Encode("path", operationalInsightsResourceProvider), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + 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}/resourceGroups/{resourceGroupName}/providers/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/bookmarks/{bookmarkId}", 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 BookmarksClient) 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 BookmarksClient) GetResponder(resp *http.Response) (result Bookmark, 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 gets all bookmarks. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// operationalInsightsResourceProvider - the namespace of workspaces resource provider- +// Microsoft.OperationalInsights. +// workspaceName - the name of the workspace. +func (client BookmarksClient) List(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string) (result BookmarkListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BookmarksClient.List") + defer func() { + sc := -1 + if result.bl.Response.Response != nil { + sc = result.bl.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: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("securityinsight.BookmarksClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, operationalInsightsResourceProvider, workspaceName) + if err != nil { + err = autorest.NewErrorWithError(err, "securityinsight.BookmarksClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.bl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "securityinsight.BookmarksClient", "List", resp, "Failure sending request") + return + } + + result.bl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "securityinsight.BookmarksClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client BookmarksClient) ListPreparer(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "operationalInsightsResourceProvider": autorest.Encode("path", operationalInsightsResourceProvider), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + 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}/resourceGroups/{resourceGroupName}/providers/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/bookmarks", 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 BookmarksClient) 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 BookmarksClient) ListResponder(resp *http.Response) (result BookmarkList, 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 BookmarksClient) listNextResults(ctx context.Context, lastResults BookmarkList) (result BookmarkList, err error) { + req, err := lastResults.bookmarkListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "securityinsight.BookmarksClient", "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, "securityinsight.BookmarksClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "securityinsight.BookmarksClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client BookmarksClient) ListComplete(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string) (result BookmarkListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BookmarksClient.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, operationalInsightsResourceProvider, workspaceName) + return +} diff --git a/services/preview/securityinsight/mgmt/2017-08-01-preview/securityinsight/cases.go b/services/preview/securityinsight/mgmt/2017-08-01-preview/securityinsight/cases.go new file mode 100644 index 000000000000..1f4a027471e5 --- /dev/null +++ b/services/preview/securityinsight/mgmt/2017-08-01-preview/securityinsight/cases.go @@ -0,0 +1,467 @@ +package securityinsight + +// 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" +) + +// CasesClient is the API spec for Microsoft.SecurityInsights (Azure Security Insights) resource provider +type CasesClient struct { + BaseClient +} + +// NewCasesClient creates an instance of the CasesClient client. +func NewCasesClient(subscriptionID string) CasesClient { + return NewCasesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewCasesClientWithBaseURI creates an instance of the CasesClient client. +func NewCasesClientWithBaseURI(baseURI string, subscriptionID string) CasesClient { + return CasesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates the case. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// operationalInsightsResourceProvider - the namespace of workspaces resource provider- +// Microsoft.OperationalInsights. +// workspaceName - the name of the workspace. +// caseID - case ID +// caseParameter - the case +func (client CasesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, caseID string, caseParameter Case) (result Case, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CasesClient.CreateOrUpdate") + 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: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: caseParameter, + Constraints: []validation.Constraint{{Target: "caseParameter.CaseProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "caseParameter.CaseProperties.Title", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("securityinsight.CasesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, operationalInsightsResourceProvider, workspaceName, caseID, caseParameter) + if err != nil { + err = autorest.NewErrorWithError(err, "securityinsight.CasesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "securityinsight.CasesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "securityinsight.CasesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client CasesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, caseID string, caseParameter Case) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "caseId": autorest.Encode("path", caseID), + "operationalInsightsResourceProvider": autorest.Encode("path", operationalInsightsResourceProvider), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + 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("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/cases/{caseId}", pathParameters), + autorest.WithJSON(caseParameter), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client CasesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client CasesClient) CreateOrUpdateResponder(resp *http.Response) (result Case, 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 delete the case. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// operationalInsightsResourceProvider - the namespace of workspaces resource provider- +// Microsoft.OperationalInsights. +// workspaceName - the name of the workspace. +// caseID - case ID +func (client CasesClient) Delete(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, caseID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CasesClient.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}}}, + {TargetValue: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("securityinsight.CasesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, operationalInsightsResourceProvider, workspaceName, caseID) + if err != nil { + err = autorest.NewErrorWithError(err, "securityinsight.CasesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "securityinsight.CasesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "securityinsight.CasesClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client CasesClient) DeletePreparer(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, caseID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "caseId": autorest.Encode("path", caseID), + "operationalInsightsResourceProvider": autorest.Encode("path", operationalInsightsResourceProvider), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2019-01-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/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/cases/{caseId}", 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 CasesClient) 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 CasesClient) 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 gets a case. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// operationalInsightsResourceProvider - the namespace of workspaces resource provider- +// Microsoft.OperationalInsights. +// workspaceName - the name of the workspace. +// caseID - case ID +func (client CasesClient) Get(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, caseID string) (result Case, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CasesClient.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}}}, + {TargetValue: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("securityinsight.CasesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, operationalInsightsResourceProvider, workspaceName, caseID) + if err != nil { + err = autorest.NewErrorWithError(err, "securityinsight.CasesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "securityinsight.CasesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "securityinsight.CasesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client CasesClient) GetPreparer(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, caseID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "caseId": autorest.Encode("path", caseID), + "operationalInsightsResourceProvider": autorest.Encode("path", operationalInsightsResourceProvider), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + 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}/resourceGroups/{resourceGroupName}/providers/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/cases/{caseId}", 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 CasesClient) 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 CasesClient) GetResponder(resp *http.Response) (result Case, 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 gets all cases. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// operationalInsightsResourceProvider - the namespace of workspaces resource provider- +// Microsoft.OperationalInsights. +// workspaceName - the name of the workspace. +func (client CasesClient) List(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string) (result CaseListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CasesClient.List") + defer func() { + sc := -1 + if result.cl.Response.Response != nil { + sc = result.cl.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: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("securityinsight.CasesClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, operationalInsightsResourceProvider, workspaceName) + if err != nil { + err = autorest.NewErrorWithError(err, "securityinsight.CasesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.cl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "securityinsight.CasesClient", "List", resp, "Failure sending request") + return + } + + result.cl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "securityinsight.CasesClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client CasesClient) ListPreparer(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "operationalInsightsResourceProvider": autorest.Encode("path", operationalInsightsResourceProvider), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + 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}/resourceGroups/{resourceGroupName}/providers/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/cases", 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 CasesClient) 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 CasesClient) ListResponder(resp *http.Response) (result CaseList, 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 CasesClient) listNextResults(ctx context.Context, lastResults CaseList) (result CaseList, err error) { + req, err := lastResults.caseListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "securityinsight.CasesClient", "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, "securityinsight.CasesClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "securityinsight.CasesClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client CasesClient) ListComplete(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string) (result CaseListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CasesClient.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, operationalInsightsResourceProvider, workspaceName) + return +} diff --git a/services/preview/securityinsight/mgmt/2017-08-01-preview/securityinsight/dataconnectors.go b/services/preview/securityinsight/mgmt/2017-08-01-preview/securityinsight/dataconnectors.go index 6865387e4645..329fca2b4d70 100644 --- a/services/preview/securityinsight/mgmt/2017-08-01-preview/securityinsight/dataconnectors.go +++ b/services/preview/securityinsight/mgmt/2017-08-01-preview/securityinsight/dataconnectors.go @@ -41,7 +41,7 @@ func NewDataConnectorsClientWithBaseURI(baseURI string, subscriptionID string) D return DataConnectorsClient{NewWithBaseURI(baseURI, subscriptionID)} } -// Create creates or updates the data connector. +// CreateOrUpdate creates or updates the data connector. // Parameters: // resourceGroupName - the name of the resource group within the user's subscription. The name is case // insensitive. @@ -50,9 +50,9 @@ func NewDataConnectorsClientWithBaseURI(baseURI string, subscriptionID string) D // workspaceName - the name of the workspace. // dataConnectorID - connector ID // dataConnector - the data connector -func (client DataConnectorsClient) Create(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, dataConnectorID string, dataConnector BasicDataConnector) (result DataConnectorModel, err error) { +func (client DataConnectorsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, dataConnectorID string, dataConnector BasicDataConnector) (result DataConnectorModel, err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DataConnectorsClient.Create") + ctx = tracing.StartSpan(ctx, fqdn+"/DataConnectorsClient.CreateOrUpdate") defer func() { sc := -1 if result.Response.Response != nil { @@ -71,32 +71,32 @@ func (client DataConnectorsClient) Create(ctx context.Context, resourceGroupName {TargetValue: workspaceName, Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 90, Chain: nil}, {Target: "workspaceName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("securityinsight.DataConnectorsClient", "Create", err.Error()) + return result, validation.NewError("securityinsight.DataConnectorsClient", "CreateOrUpdate", err.Error()) } - req, err := client.CreatePreparer(ctx, resourceGroupName, operationalInsightsResourceProvider, workspaceName, dataConnectorID, dataConnector) + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, operationalInsightsResourceProvider, workspaceName, dataConnectorID, dataConnector) if err != nil { - err = autorest.NewErrorWithError(err, "securityinsight.DataConnectorsClient", "Create", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "securityinsight.DataConnectorsClient", "CreateOrUpdate", nil, "Failure preparing request") return } - resp, err := client.CreateSender(req) + resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "securityinsight.DataConnectorsClient", "Create", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "securityinsight.DataConnectorsClient", "CreateOrUpdate", resp, "Failure sending request") return } - result, err = client.CreateResponder(resp) + result, err = client.CreateOrUpdateResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "securityinsight.DataConnectorsClient", "Create", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "securityinsight.DataConnectorsClient", "CreateOrUpdate", resp, "Failure responding to request") } return } -// CreatePreparer prepares the Create request. -func (client DataConnectorsClient) CreatePreparer(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, dataConnectorID string, dataConnector BasicDataConnector) (*http.Request, error) { +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DataConnectorsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, dataConnectorID string, dataConnector BasicDataConnector) (*http.Request, error) { pathParameters := map[string]interface{}{ "dataConnectorId": autorest.Encode("path", dataConnectorID), "operationalInsightsResourceProvider": autorest.Encode("path", operationalInsightsResourceProvider), @@ -120,16 +120,16 @@ func (client DataConnectorsClient) CreatePreparer(ctx context.Context, resourceG return preparer.Prepare((&http.Request{}).WithContext(ctx)) } -// CreateSender sends the Create request. The method will close the +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the // http.Response Body if it receives an error. -func (client DataConnectorsClient) CreateSender(req *http.Request) (*http.Response, error) { +func (client DataConnectorsClient) CreateOrUpdateSender(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 +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client DataConnectorsClient) CreateResponder(resp *http.Response) (result DataConnectorModel, err error) { +func (client DataConnectorsClient) CreateOrUpdateResponder(resp *http.Response) (result DataConnectorModel, err error) { err = autorest.Respond( resp, client.ByInspecting(), diff --git a/services/preview/securityinsight/mgmt/2017-08-01-preview/securityinsight/entities.go b/services/preview/securityinsight/mgmt/2017-08-01-preview/securityinsight/entities.go new file mode 100644 index 000000000000..4d1418e4c1b1 --- /dev/null +++ b/services/preview/securityinsight/mgmt/2017-08-01-preview/securityinsight/entities.go @@ -0,0 +1,270 @@ +package securityinsight + +// 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" +) + +// EntitiesClient is the API spec for Microsoft.SecurityInsights (Azure Security Insights) resource provider +type EntitiesClient struct { + BaseClient +} + +// NewEntitiesClient creates an instance of the EntitiesClient client. +func NewEntitiesClient(subscriptionID string) EntitiesClient { + return NewEntitiesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewEntitiesClientWithBaseURI creates an instance of the EntitiesClient client. +func NewEntitiesClientWithBaseURI(baseURI string, subscriptionID string) EntitiesClient { + return EntitiesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets an entity. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// operationalInsightsResourceProvider - the namespace of workspaces resource provider- +// Microsoft.OperationalInsights. +// workspaceName - the name of the workspace. +// entityID - entity ID +func (client EntitiesClient) Get(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, entityID string) (result EntityModel, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EntitiesClient.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}}}, + {TargetValue: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("securityinsight.EntitiesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, operationalInsightsResourceProvider, workspaceName, entityID) + if err != nil { + err = autorest.NewErrorWithError(err, "securityinsight.EntitiesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "securityinsight.EntitiesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "securityinsight.EntitiesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client EntitiesClient) GetPreparer(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, entityID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "entityId": autorest.Encode("path", entityID), + "operationalInsightsResourceProvider": autorest.Encode("path", operationalInsightsResourceProvider), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + 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}/resourceGroups/{resourceGroupName}/providers/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/entities/{entityId}", 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 EntitiesClient) 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 EntitiesClient) GetResponder(resp *http.Response) (result EntityModel, 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 gets all entities. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// operationalInsightsResourceProvider - the namespace of workspaces resource provider- +// Microsoft.OperationalInsights. +// workspaceName - the name of the workspace. +func (client EntitiesClient) List(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string) (result EntityListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EntitiesClient.List") + defer func() { + sc := -1 + if result.el.Response.Response != nil { + sc = result.el.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: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("securityinsight.EntitiesClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, operationalInsightsResourceProvider, workspaceName) + if err != nil { + err = autorest.NewErrorWithError(err, "securityinsight.EntitiesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.el.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "securityinsight.EntitiesClient", "List", resp, "Failure sending request") + return + } + + result.el, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "securityinsight.EntitiesClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client EntitiesClient) ListPreparer(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "operationalInsightsResourceProvider": autorest.Encode("path", operationalInsightsResourceProvider), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + 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}/resourceGroups/{resourceGroupName}/providers/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/entities", 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 EntitiesClient) 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 EntitiesClient) ListResponder(resp *http.Response) (result EntityList, 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 EntitiesClient) listNextResults(ctx context.Context, lastResults EntityList) (result EntityList, err error) { + req, err := lastResults.entityListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "securityinsight.EntitiesClient", "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, "securityinsight.EntitiesClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "securityinsight.EntitiesClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client EntitiesClient) ListComplete(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string) (result EntityListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EntitiesClient.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, operationalInsightsResourceProvider, workspaceName) + return +} diff --git a/services/preview/securityinsight/mgmt/2017-08-01-preview/securityinsight/models.go b/services/preview/securityinsight/mgmt/2017-08-01-preview/securityinsight/models.go index 70cbbe685408..26c8459d263a 100644 --- a/services/preview/securityinsight/mgmt/2017-08-01-preview/securityinsight/models.go +++ b/services/preview/securityinsight/mgmt/2017-08-01-preview/securityinsight/models.go @@ -21,8 +21,10 @@ import ( "context" "encoding/json" "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/date" "github.com/Azure/go-autorest/autorest/to" "github.com/Azure/go-autorest/tracing" + "github.com/satori/go.uuid" "net/http" ) @@ -42,6 +44,82 @@ func PossibleAlertRuleKindValues() []AlertRuleKind { return []AlertRuleKind{Scheduled} } +// AlertSeverity enumerates the values for alert severity. +type AlertSeverity string + +const ( + // High High severity + High AlertSeverity = "High" + // Informational Informational severity + Informational AlertSeverity = "Informational" + // Low Low severity + Low AlertSeverity = "Low" + // Medium Medium severity + Medium AlertSeverity = "Medium" +) + +// PossibleAlertSeverityValues returns an array of possible values for the AlertSeverity const type. +func PossibleAlertSeverityValues() []AlertSeverity { + return []AlertSeverity{High, Informational, Low, Medium} +} + +// CaseSeverity enumerates the values for case severity. +type CaseSeverity string + +const ( + // CaseSeverityCritical Critical severity + CaseSeverityCritical CaseSeverity = "Critical" + // CaseSeverityHigh High severity + CaseSeverityHigh CaseSeverity = "High" + // CaseSeverityInformational Informational severity + CaseSeverityInformational CaseSeverity = "Informational" + // CaseSeverityLow Low severity + CaseSeverityLow CaseSeverity = "Low" + // CaseSeverityMedium Medium severity + CaseSeverityMedium CaseSeverity = "Medium" +) + +// PossibleCaseSeverityValues returns an array of possible values for the CaseSeverity const type. +func PossibleCaseSeverityValues() []CaseSeverity { + return []CaseSeverity{CaseSeverityCritical, CaseSeverityHigh, CaseSeverityInformational, CaseSeverityLow, CaseSeverityMedium} +} + +// CaseStatus enumerates the values for case status. +type CaseStatus string + +const ( + // Closed A non active case + Closed CaseStatus = "Closed" + // Draft Case that wasn't promoted yet to active + Draft CaseStatus = "Draft" + // InProgress An active case which is handled + InProgress CaseStatus = "InProgress" + // Open An active case which isn't handled currently + Open CaseStatus = "Open" +) + +// PossibleCaseStatusValues returns an array of possible values for the CaseStatus const type. +func PossibleCaseStatusValues() []CaseStatus { + return []CaseStatus{Closed, Draft, InProgress, Open} +} + +// CloseReason enumerates the values for close reason. +type CloseReason string + +const ( + // Dismissed Case was dismissed + Dismissed CloseReason = "Dismissed" + // Other Case was closed for another reason + Other CloseReason = "Other" + // Resolved Case was resolved + Resolved CloseReason = "Resolved" +) + +// PossibleCloseReasonValues returns an array of possible values for the CloseReason const type. +func PossibleCloseReasonValues() []CloseReason { + return []CloseReason{Dismissed, Other, Resolved} +} + // DataConnectorKind enumerates the values for data connector kind. type DataConnectorKind string @@ -78,6 +156,23 @@ func PossibleDataTypeStateValues() []DataTypeState { return []DataTypeState{Disabled, Enabled} } +// EntityKind enumerates the values for entity kind. +type EntityKind string + +const ( + // Account Entity represents account in the system. + Account EntityKind = "Account" + // File Entity represents file in the system. + File EntityKind = "File" + // Host Entity represents host in the system. + Host EntityKind = "Host" +) + +// PossibleEntityKindValues returns an array of possible values for the EntityKind const type. +func PossibleEntityKindValues() []EntityKind { + return []EntityKind{Account, File, Host} +} + // Kind enumerates the values for kind. type Kind string @@ -103,8 +198,6 @@ const ( KindAzureSecurityCenter KindBasicDataConnector = "AzureSecurityCenter" // KindDataConnector ... KindDataConnector KindBasicDataConnector = "DataConnector" - // KindDataConnectorWithAlerts ... - KindDataConnectorWithAlerts KindBasicDataConnector = "DataConnectorWithAlerts" // KindMicrosoftCloudAppSecurity ... KindMicrosoftCloudAppSecurity KindBasicDataConnector = "MicrosoftCloudAppSecurity" // KindOffice365 ... @@ -115,26 +208,92 @@ const ( // PossibleKindBasicDataConnectorValues returns an array of possible values for the KindBasicDataConnector const type. func PossibleKindBasicDataConnectorValues() []KindBasicDataConnector { - return []KindBasicDataConnector{KindAzureActiveDirectory, KindAzureSecurityCenter, KindDataConnector, KindDataConnectorWithAlerts, KindMicrosoftCloudAppSecurity, KindOffice365, KindThreatIntelligence} + return []KindBasicDataConnector{KindAzureActiveDirectory, KindAzureSecurityCenter, KindDataConnector, KindMicrosoftCloudAppSecurity, KindOffice365, KindThreatIntelligence} +} + +// KindBasicEntity enumerates the values for kind basic entity. +type KindBasicEntity string + +const ( + // KindAccount ... + KindAccount KindBasicEntity = "Account" + // KindEntity ... + KindEntity KindBasicEntity = "Entity" + // KindFile ... + KindFile KindBasicEntity = "File" + // KindHost ... + KindHost KindBasicEntity = "Host" +) + +// PossibleKindBasicEntityValues returns an array of possible values for the KindBasicEntity const type. +func PossibleKindBasicEntityValues() []KindBasicEntity { + return []KindBasicEntity{KindAccount, KindEntity, KindFile, KindHost} +} + +// KindBasicSettings enumerates the values for kind basic settings. +type KindBasicSettings string + +const ( + // KindSettings ... + KindSettings KindBasicSettings = "Settings" + // KindToggleSettings ... + KindToggleSettings KindBasicSettings = "ToggleSettings" + // KindUebaSettings ... + KindUebaSettings KindBasicSettings = "UebaSettings" +) + +// PossibleKindBasicSettingsValues returns an array of possible values for the KindBasicSettings const type. +func PossibleKindBasicSettingsValues() []KindBasicSettings { + return []KindBasicSettings{KindSettings, KindToggleSettings, KindUebaSettings} +} + +// OSFamily enumerates the values for os family. +type OSFamily string + +const ( + // Android Host with Android operating system. + Android OSFamily = "Android" + // IOS Host with IOS operating system. + IOS OSFamily = "IOS" + // Linux Host with Linux operating system. + Linux OSFamily = "Linux" + // Windows Host with Windows operating system. + Windows OSFamily = "Windows" +) + +// PossibleOSFamilyValues returns an array of possible values for the OSFamily const type. +func PossibleOSFamilyValues() []OSFamily { + return []OSFamily{Android, IOS, Linux, Windows} } -// Severity enumerates the values for severity. -type Severity string +// SettingKind enumerates the values for setting kind. +type SettingKind string const ( - // High ... - High Severity = "High" - // Informational ... - Informational Severity = "Informational" - // Low ... - Low Severity = "Low" - // Medium ... - Medium Severity = "Medium" + // SettingKindToggleSettings ... + SettingKindToggleSettings SettingKind = "ToggleSettings" + // SettingKindUebaSettings ... + SettingKindUebaSettings SettingKind = "UebaSettings" ) -// PossibleSeverityValues returns an array of possible values for the Severity const type. -func PossibleSeverityValues() []Severity { - return []Severity{High, Informational, Low, Medium} +// PossibleSettingKindValues returns an array of possible values for the SettingKind const type. +func PossibleSettingKindValues() []SettingKind { + return []SettingKind{SettingKindToggleSettings, SettingKindUebaSettings} +} + +// StatusInMcas enumerates the values for status in mcas. +type StatusInMcas string + +const ( + // StatusInMcasDisabled ... + StatusInMcasDisabled StatusInMcas = "Disabled" + // StatusInMcasEnabled ... + StatusInMcasEnabled StatusInMcas = "Enabled" +) + +// PossibleStatusInMcasValues returns an array of possible values for the StatusInMcas const type. +func PossibleStatusInMcasValues() []StatusInMcas { + return []StatusInMcas{StatusInMcasDisabled, StatusInMcasEnabled} } // TriggerOperator enumerates the values for trigger operator. @@ -158,8 +317,8 @@ func PossibleTriggerOperatorValues() []TriggerOperator { // AADDataConnector represents AAD (Azure Active Directory) data connector. type AADDataConnector struct { - // DataConnectorWithAlertsProperties - Data connector properties. - *DataConnectorWithAlertsProperties `json:"properties,omitempty"` + // AADDataConnectorProperties - AAD (Azure Active Directory) data connector properties. + *AADDataConnectorProperties `json:"properties,omitempty"` // ID - Azure resource Id ID *string `json:"id,omitempty"` // Type - Azure resource type @@ -168,7 +327,7 @@ type AADDataConnector struct { Name *string `json:"name,omitempty"` // Etag - Etag of the data connector. Etag *string `json:"etag,omitempty"` - // Kind - Possible values include: 'KindDataConnector', 'KindOffice365', 'KindThreatIntelligence', 'KindAzureActiveDirectory', 'KindAzureSecurityCenter', 'KindMicrosoftCloudAppSecurity', 'KindDataConnectorWithAlerts' + // Kind - Possible values include: 'KindDataConnector', 'KindOffice365', 'KindThreatIntelligence', 'KindAzureActiveDirectory', 'KindAzureSecurityCenter', 'KindMicrosoftCloudAppSecurity' Kind KindBasicDataConnector `json:"kind,omitempty"` } @@ -176,8 +335,8 @@ type AADDataConnector struct { func (adc AADDataConnector) MarshalJSON() ([]byte, error) { adc.Kind = KindAzureActiveDirectory objectMap := make(map[string]interface{}) - if adc.DataConnectorWithAlertsProperties != nil { - objectMap["properties"] = adc.DataConnectorWithAlertsProperties + if adc.AADDataConnectorProperties != nil { + objectMap["properties"] = adc.AADDataConnectorProperties } if adc.ID != nil { objectMap["id"] = adc.ID @@ -222,16 +381,6 @@ func (adc AADDataConnector) AsMCASDataConnector() (*MCASDataConnector, bool) { return nil, false } -// AsDataConnectorWithAlerts is the BasicDataConnector implementation for AADDataConnector. -func (adc AADDataConnector) AsDataConnectorWithAlerts() (*DataConnectorWithAlerts, bool) { - return nil, false -} - -// AsBasicDataConnectorWithAlerts is the BasicDataConnector implementation for AADDataConnector. -func (adc AADDataConnector) AsBasicDataConnectorWithAlerts() (BasicDataConnectorWithAlerts, bool) { - return &adc, true -} - // AsDataConnector is the BasicDataConnector implementation for AADDataConnector. func (adc AADDataConnector) AsDataConnector() (*DataConnector, bool) { return nil, false @@ -242,135 +391,146 @@ func (adc AADDataConnector) AsBasicDataConnector() (BasicDataConnector, bool) { return &adc, true } -// BasicAlertRule alert rule. -type BasicAlertRule interface { - AsScheduledAlertRule() (*ScheduledAlertRule, bool) - AsAlertRule() (*AlertRule, bool) +// UnmarshalJSON is the custom unmarshaler for AADDataConnector struct. +func (adc *AADDataConnector) 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 aADDataConnectorProperties AADDataConnectorProperties + err = json.Unmarshal(*v, &aADDataConnectorProperties) + if err != nil { + return err + } + adc.AADDataConnectorProperties = &aADDataConnectorProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + adc.ID = &ID + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + adc.Type = &typeVar + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + adc.Name = &name + } + case "etag": + if v != nil { + var etag string + err = json.Unmarshal(*v, &etag) + if err != nil { + return err + } + adc.Etag = &etag + } + case "kind": + if v != nil { + var kind KindBasicDataConnector + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + adc.Kind = kind + } + } + } + + return nil } -// AlertRule alert rule. -type AlertRule struct { - autorest.Response `json:"-"` +// AADDataConnectorProperties AAD (Azure Active Directory) data connector properties. +type AADDataConnectorProperties struct { + // TenantID - The tenant id to connect to, and get the data from. + TenantID *string `json:"tenantId,omitempty"` + // DataTypes - The available data types for the connector. + DataTypes *AlertsDataTypeOfDataConnector `json:"dataTypes,omitempty"` +} + +// AccountEntity represents an account entity. +type AccountEntity struct { + // AccountEntityProperties - Account entity properties + *AccountEntityProperties `json:"properties,omitempty"` // ID - Azure resource Id ID *string `json:"id,omitempty"` // Type - Azure resource type Type *string `json:"type,omitempty"` // Name - Azure resource name Name *string `json:"name,omitempty"` - // Etag - Etag of the alert rule. - Etag *string `json:"etag,omitempty"` - // Kind - Possible values include: 'KindAlertRule', 'KindScheduled' - Kind Kind `json:"kind,omitempty"` -} - -func unmarshalBasicAlertRule(body []byte) (BasicAlertRule, error) { - var m map[string]interface{} - err := json.Unmarshal(body, &m) - if err != nil { - return nil, err - } - - switch m["kind"] { - case string(KindScheduled): - var sar ScheduledAlertRule - err := json.Unmarshal(body, &sar) - return sar, err - default: - var ar AlertRule - err := json.Unmarshal(body, &ar) - return ar, err - } -} -func unmarshalBasicAlertRuleArray(body []byte) ([]BasicAlertRule, error) { - var rawMessages []*json.RawMessage - err := json.Unmarshal(body, &rawMessages) - if err != nil { - return nil, err - } - - arArray := make([]BasicAlertRule, len(rawMessages)) - - for index, rawMessage := range rawMessages { - ar, err := unmarshalBasicAlertRule(*rawMessage) - if err != nil { - return nil, err - } - arArray[index] = ar - } - return arArray, nil + // Kind - Possible values include: 'KindEntity', 'KindAccount', 'KindHost', 'KindFile' + Kind KindBasicEntity `json:"kind,omitempty"` } -// MarshalJSON is the custom marshaler for AlertRule. -func (ar AlertRule) MarshalJSON() ([]byte, error) { - ar.Kind = KindAlertRule +// MarshalJSON is the custom marshaler for AccountEntity. +func (ae AccountEntity) MarshalJSON() ([]byte, error) { + ae.Kind = KindAccount objectMap := make(map[string]interface{}) - if ar.ID != nil { - objectMap["id"] = ar.ID + if ae.AccountEntityProperties != nil { + objectMap["properties"] = ae.AccountEntityProperties } - if ar.Type != nil { - objectMap["type"] = ar.Type + if ae.ID != nil { + objectMap["id"] = ae.ID } - if ar.Name != nil { - objectMap["name"] = ar.Name + if ae.Type != nil { + objectMap["type"] = ae.Type } - if ar.Etag != nil { - objectMap["etag"] = ar.Etag + if ae.Name != nil { + objectMap["name"] = ae.Name } - if ar.Kind != "" { - objectMap["kind"] = ar.Kind + if ae.Kind != "" { + objectMap["kind"] = ae.Kind } return json.Marshal(objectMap) } -// AsScheduledAlertRule is the BasicAlertRule implementation for AlertRule. -func (ar AlertRule) AsScheduledAlertRule() (*ScheduledAlertRule, bool) { - return nil, false -} - -// AsAlertRule is the BasicAlertRule implementation for AlertRule. -func (ar AlertRule) AsAlertRule() (*AlertRule, bool) { - return &ar, true -} - -// AsBasicAlertRule is the BasicAlertRule implementation for AlertRule. -func (ar AlertRule) AsBasicAlertRule() (BasicAlertRule, bool) { - return &ar, true +// AsAccountEntity is the BasicEntity implementation for AccountEntity. +func (ae AccountEntity) AsAccountEntity() (*AccountEntity, bool) { + return &ae, true } -// AlertRuleKind1 describes an Azure resource with kind. -type AlertRuleKind1 struct { - // Kind - The kind of the alert rule. Possible values include: 'Scheduled' - Kind AlertRuleKind `json:"kind,omitempty"` +// AsHostEntity is the BasicEntity implementation for AccountEntity. +func (ae AccountEntity) AsHostEntity() (*HostEntity, bool) { + return nil, false } -// AlertRuleModel ... -type AlertRuleModel struct { - autorest.Response `json:"-"` - Value BasicAlertRule `json:"value,omitempty"` +// AsFileEntity is the BasicEntity implementation for AccountEntity. +func (ae AccountEntity) AsFileEntity() (*FileEntity, bool) { + return nil, false } -// UnmarshalJSON is the custom unmarshaler for AlertRuleModel struct. -func (arm *AlertRuleModel) UnmarshalJSON(body []byte) error { - ar, err := unmarshalBasicAlertRule(body) - if err != nil { - return err - } - arm.Value = ar - - return nil +// AsEntity is the BasicEntity implementation for AccountEntity. +func (ae AccountEntity) AsEntity() (*Entity, bool) { + return nil, false } -// AlertRulesList list all the alert rules. -type AlertRulesList struct { - autorest.Response `json:"-"` - // NextLink - URL to fetch the next set of alert rules. - NextLink *string `json:"nextLink,omitempty"` - // Value - Array of alert rules. - Value *[]BasicAlertRule `json:"value,omitempty"` +// AsBasicEntity is the BasicEntity implementation for AccountEntity. +func (ae AccountEntity) AsBasicEntity() (BasicEntity, bool) { + return &ae, true } -// UnmarshalJSON is the custom unmarshaler for AlertRulesList struct. -func (arl *AlertRulesList) UnmarshalJSON(body []byte) error { +// UnmarshalJSON is the custom unmarshaler for AccountEntity struct. +func (ae *AccountEntity) UnmarshalJSON(body []byte) error { var m map[string]*json.RawMessage err := json.Unmarshal(body, &m) if err != nil { @@ -378,44 +538,1568 @@ func (arl *AlertRulesList) UnmarshalJSON(body []byte) error { } for k, v := range m { switch k { - case "nextLink": + case "properties": if v != nil { - var nextLink string - err = json.Unmarshal(*v, &nextLink) + var accountEntityProperties AccountEntityProperties + err = json.Unmarshal(*v, &accountEntityProperties) if err != nil { return err } - arl.NextLink = &nextLink + ae.AccountEntityProperties = &accountEntityProperties } - case "value": + case "id": if v != nil { - value, err := unmarshalBasicAlertRuleArray(*v) + var ID string + err = json.Unmarshal(*v, &ID) if err != nil { return err } - arl.Value = &value + ae.ID = &ID } - } - } - - return nil -} - -// AlertRulesListIterator provides access to a complete listing of AlertRule values. -type AlertRulesListIterator struct { - i int - page AlertRulesListPage -} - -// 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 *AlertRulesListIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/AlertRulesListIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ae.Type = &typeVar + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ae.Name = &name + } + case "kind": + if v != nil { + var kind KindBasicEntity + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + ae.Kind = kind + } + } + } + + return nil +} + +// AccountEntityProperties account entity property bag. +type AccountEntityProperties struct { + // AccountName - The name of the account. This field should hold only the name without any domain added to it, i.e. administrator. + AccountName *string `json:"accountName,omitempty"` + // NtDomain - The NetBIOS domain name as it appears in the alert format – domain\username. Examples: NT AUTHORITY. + NtDomain *string `json:"ntDomain,omitempty"` + // UpnSuffix - The user principal name suffix for the account, in some cases it is also the domain name. Examples: contoso.com. + UpnSuffix *string `json:"upnSuffix,omitempty"` + // Sid - The account security identifier, e.g. S-1-5-18. + Sid *string `json:"sid,omitempty"` + // AadTenantID - The Azure Active Directory tenant id. + AadTenantID *string `json:"aadTenantId,omitempty"` + // AadUserID - The Azure Active Directory user id. + AadUserID *string `json:"aadUserId,omitempty"` + // Puid - The Azure Active Directory Passport User ID. + Puid *string `json:"puid,omitempty"` + // IsDomainJoined - Determines whether this is a domain account. + IsDomainJoined *bool `json:"isDomainJoined,omitempty"` + // ObjectGUID - The objectGUID attribute is a single-value attribute that is the unique identifier for the object, assigned by active directory. + ObjectGUID *uuid.UUID `json:"objectGuid,omitempty"` +} + +// Action action for alert rule. +type Action struct { + autorest.Response `json:"-"` + // Etag - Etag of the action. + Etag *string `json:"etag,omitempty"` + // ActionProperties - Action properties + *ActionProperties `json:"properties,omitempty"` + // ID - Azure resource Id + ID *string `json:"id,omitempty"` + // Type - Azure resource type + Type *string `json:"type,omitempty"` + // Name - Azure resource name + Name *string `json:"name,omitempty"` +} + +// MarshalJSON is the custom marshaler for Action. +func (a Action) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if a.Etag != nil { + objectMap["etag"] = a.Etag + } + if a.ActionProperties != nil { + objectMap["properties"] = a.ActionProperties + } + if a.ID != nil { + objectMap["id"] = a.ID + } + if a.Type != nil { + objectMap["type"] = a.Type + } + if a.Name != nil { + objectMap["name"] = a.Name + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Action struct. +func (a *Action) 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 "etag": + if v != nil { + var etag string + err = json.Unmarshal(*v, &etag) + if err != nil { + return err + } + a.Etag = &etag + } + case "properties": + if v != nil { + var actionProperties ActionProperties + err = json.Unmarshal(*v, &actionProperties) + if err != nil { + return err + } + a.ActionProperties = &actionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + a.ID = &ID + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + a.Type = &typeVar + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + a.Name = &name + } + } + } + + return nil +} + +// ActionProperties action property bag. +type ActionProperties struct { + // TriggerURI - The uri for the action to trigger. + TriggerURI *string `json:"triggerUri,omitempty"` +} + +// ActionsList list all the actions. +type ActionsList struct { + autorest.Response `json:"-"` + // NextLink - URL to fetch the next set of actions. + NextLink *string `json:"nextLink,omitempty"` + // Value - Array of actions. + Value *[]Action `json:"value,omitempty"` +} + +// ActionsListIterator provides access to a complete listing of Action values. +type ActionsListIterator struct { + i int + page ActionsListPage +} + +// 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 *ActionsListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ActionsListIterator.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 *ActionsListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ActionsListIterator) 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 ActionsListIterator) Response() ActionsList { + 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 ActionsListIterator) Value() Action { + if !iter.page.NotDone() { + return Action{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ActionsListIterator type. +func NewActionsListIterator(page ActionsListPage) ActionsListIterator { + return ActionsListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (al ActionsList) IsEmpty() bool { + return al.Value == nil || len(*al.Value) == 0 +} + +// actionsListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (al ActionsList) actionsListPreparer(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))) +} + +// ActionsListPage contains a page of Action values. +type ActionsListPage struct { + fn func(context.Context, ActionsList) (ActionsList, error) + al ActionsList +} + +// 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 *ActionsListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ActionsListPage.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 *ActionsListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ActionsListPage) NotDone() bool { + return !page.al.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ActionsListPage) Response() ActionsList { + return page.al +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ActionsListPage) Values() []Action { + if page.al.IsEmpty() { + return nil + } + return *page.al.Value +} + +// Creates a new instance of the ActionsListPage type. +func NewActionsListPage(getNextPage func(context.Context, ActionsList) (ActionsList, error)) ActionsListPage { + return ActionsListPage{fn: getNextPage} +} + +// BasicAlertRule alert rule. +type BasicAlertRule interface { + AsScheduledAlertRule() (*ScheduledAlertRule, bool) + AsAlertRule() (*AlertRule, bool) +} + +// AlertRule alert rule. +type AlertRule struct { + autorest.Response `json:"-"` + // ID - Azure resource Id + ID *string `json:"id,omitempty"` + // Type - Azure resource type + Type *string `json:"type,omitempty"` + // Name - Azure resource name + Name *string `json:"name,omitempty"` + // Etag - Etag of the alert rule. + Etag *string `json:"etag,omitempty"` + // Kind - Possible values include: 'KindAlertRule', 'KindScheduled' + Kind Kind `json:"kind,omitempty"` +} + +func unmarshalBasicAlertRule(body []byte) (BasicAlertRule, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["kind"] { + case string(KindScheduled): + var sar ScheduledAlertRule + err := json.Unmarshal(body, &sar) + return sar, err + default: + var ar AlertRule + err := json.Unmarshal(body, &ar) + return ar, err + } +} +func unmarshalBasicAlertRuleArray(body []byte) ([]BasicAlertRule, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + arArray := make([]BasicAlertRule, len(rawMessages)) + + for index, rawMessage := range rawMessages { + ar, err := unmarshalBasicAlertRule(*rawMessage) + if err != nil { + return nil, err + } + arArray[index] = ar + } + return arArray, nil +} + +// MarshalJSON is the custom marshaler for AlertRule. +func (ar AlertRule) MarshalJSON() ([]byte, error) { + ar.Kind = KindAlertRule + objectMap := make(map[string]interface{}) + if ar.ID != nil { + objectMap["id"] = ar.ID + } + if ar.Type != nil { + objectMap["type"] = ar.Type + } + if ar.Name != nil { + objectMap["name"] = ar.Name + } + if ar.Etag != nil { + objectMap["etag"] = ar.Etag + } + if ar.Kind != "" { + objectMap["kind"] = ar.Kind + } + return json.Marshal(objectMap) +} + +// AsScheduledAlertRule is the BasicAlertRule implementation for AlertRule. +func (ar AlertRule) AsScheduledAlertRule() (*ScheduledAlertRule, bool) { + return nil, false +} + +// AsAlertRule is the BasicAlertRule implementation for AlertRule. +func (ar AlertRule) AsAlertRule() (*AlertRule, bool) { + return &ar, true +} + +// AsBasicAlertRule is the BasicAlertRule implementation for AlertRule. +func (ar AlertRule) AsBasicAlertRule() (BasicAlertRule, bool) { + return &ar, true +} + +// AlertRuleKind1 describes an Azure resource with kind. +type AlertRuleKind1 struct { + // Kind - The kind of the alert rule. Possible values include: 'Scheduled' + Kind AlertRuleKind `json:"kind,omitempty"` +} + +// AlertRuleModel ... +type AlertRuleModel struct { + autorest.Response `json:"-"` + Value BasicAlertRule `json:"value,omitempty"` +} + +// UnmarshalJSON is the custom unmarshaler for AlertRuleModel struct. +func (arm *AlertRuleModel) UnmarshalJSON(body []byte) error { + ar, err := unmarshalBasicAlertRule(body) + if err != nil { + return err + } + arm.Value = ar + + return nil +} + +// AlertRulesList list all the alert rules. +type AlertRulesList struct { + autorest.Response `json:"-"` + // NextLink - URL to fetch the next set of alert rules. + NextLink *string `json:"nextLink,omitempty"` + // Value - Array of alert rules. + Value *[]BasicAlertRule `json:"value,omitempty"` +} + +// UnmarshalJSON is the custom unmarshaler for AlertRulesList struct. +func (arl *AlertRulesList) 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 "nextLink": + if v != nil { + var nextLink string + err = json.Unmarshal(*v, &nextLink) + if err != nil { + return err + } + arl.NextLink = &nextLink + } + case "value": + if v != nil { + value, err := unmarshalBasicAlertRuleArray(*v) + if err != nil { + return err + } + arl.Value = &value + } + } + } + + return nil +} + +// AlertRulesListIterator provides access to a complete listing of AlertRule values. +type AlertRulesListIterator struct { + i int + page AlertRulesListPage +} + +// 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 *AlertRulesListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertRulesListIterator.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 *AlertRulesListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter AlertRulesListIterator) 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 AlertRulesListIterator) Response() AlertRulesList { + 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 AlertRulesListIterator) Value() BasicAlertRule { + if !iter.page.NotDone() { + return AlertRule{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the AlertRulesListIterator type. +func NewAlertRulesListIterator(page AlertRulesListPage) AlertRulesListIterator { + return AlertRulesListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (arl AlertRulesList) IsEmpty() bool { + return arl.Value == nil || len(*arl.Value) == 0 +} + +// alertRulesListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (arl AlertRulesList) alertRulesListPreparer(ctx context.Context) (*http.Request, error) { + if arl.NextLink == nil || len(to.String(arl.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(arl.NextLink))) +} + +// AlertRulesListPage contains a page of BasicAlertRule values. +type AlertRulesListPage struct { + fn func(context.Context, AlertRulesList) (AlertRulesList, error) + arl AlertRulesList +} + +// 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 *AlertRulesListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertRulesListPage.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.arl) + if err != nil { + return err + } + page.arl = 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 *AlertRulesListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page AlertRulesListPage) NotDone() bool { + return !page.arl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page AlertRulesListPage) Response() AlertRulesList { + return page.arl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page AlertRulesListPage) Values() []BasicAlertRule { + if page.arl.IsEmpty() { + return nil + } + return *page.arl.Value +} + +// Creates a new instance of the AlertRulesListPage type. +func NewAlertRulesListPage(getNextPage func(context.Context, AlertRulesList) (AlertRulesList, error)) AlertRulesListPage { + return AlertRulesListPage{fn: getNextPage} +} + +// AlertsDataTypeOfDataConnector alerts data type for data connectors. +type AlertsDataTypeOfDataConnector struct { + // Alerts - Alerts data type connection. + Alerts *AlertsDataTypeOfDataConnectorAlerts `json:"alerts,omitempty"` +} + +// AlertsDataTypeOfDataConnectorAlerts alerts data type connection. +type AlertsDataTypeOfDataConnectorAlerts struct { + // State - Describe whether this data type connection is enabled or not. Possible values include: 'Enabled', 'Disabled' + State DataTypeState `json:"state,omitempty"` +} + +// ASCDataConnector represents ASC (Azure Security Center) data connector. +type ASCDataConnector struct { + // ASCDataConnectorProperties - ASC (Azure Security Center) data connector properties. + *ASCDataConnectorProperties `json:"properties,omitempty"` + // ID - Azure resource Id + ID *string `json:"id,omitempty"` + // Type - Azure resource type + Type *string `json:"type,omitempty"` + // Name - Azure resource name + Name *string `json:"name,omitempty"` + // Etag - Etag of the data connector. + Etag *string `json:"etag,omitempty"` + // Kind - Possible values include: 'KindDataConnector', 'KindOffice365', 'KindThreatIntelligence', 'KindAzureActiveDirectory', 'KindAzureSecurityCenter', 'KindMicrosoftCloudAppSecurity' + Kind KindBasicDataConnector `json:"kind,omitempty"` +} + +// MarshalJSON is the custom marshaler for ASCDataConnector. +func (adc ASCDataConnector) MarshalJSON() ([]byte, error) { + adc.Kind = KindAzureSecurityCenter + objectMap := make(map[string]interface{}) + if adc.ASCDataConnectorProperties != nil { + objectMap["properties"] = adc.ASCDataConnectorProperties + } + if adc.ID != nil { + objectMap["id"] = adc.ID + } + if adc.Type != nil { + objectMap["type"] = adc.Type + } + if adc.Name != nil { + objectMap["name"] = adc.Name + } + if adc.Etag != nil { + objectMap["etag"] = adc.Etag + } + if adc.Kind != "" { + objectMap["kind"] = adc.Kind + } + return json.Marshal(objectMap) +} + +// AsOfficeDataConnector is the BasicDataConnector implementation for ASCDataConnector. +func (adc ASCDataConnector) AsOfficeDataConnector() (*OfficeDataConnector, bool) { + return nil, false +} + +// AsTIDataConnector is the BasicDataConnector implementation for ASCDataConnector. +func (adc ASCDataConnector) AsTIDataConnector() (*TIDataConnector, bool) { + return nil, false +} + +// AsAADDataConnector is the BasicDataConnector implementation for ASCDataConnector. +func (adc ASCDataConnector) AsAADDataConnector() (*AADDataConnector, bool) { + return nil, false +} + +// AsASCDataConnector is the BasicDataConnector implementation for ASCDataConnector. +func (adc ASCDataConnector) AsASCDataConnector() (*ASCDataConnector, bool) { + return &adc, true +} + +// AsMCASDataConnector is the BasicDataConnector implementation for ASCDataConnector. +func (adc ASCDataConnector) AsMCASDataConnector() (*MCASDataConnector, bool) { + return nil, false +} + +// AsDataConnector is the BasicDataConnector implementation for ASCDataConnector. +func (adc ASCDataConnector) AsDataConnector() (*DataConnector, bool) { + return nil, false +} + +// AsBasicDataConnector is the BasicDataConnector implementation for ASCDataConnector. +func (adc ASCDataConnector) AsBasicDataConnector() (BasicDataConnector, bool) { + return &adc, true +} + +// UnmarshalJSON is the custom unmarshaler for ASCDataConnector struct. +func (adc *ASCDataConnector) 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 aSCDataConnectorProperties ASCDataConnectorProperties + err = json.Unmarshal(*v, &aSCDataConnectorProperties) + if err != nil { + return err + } + adc.ASCDataConnectorProperties = &aSCDataConnectorProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + adc.ID = &ID + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + adc.Type = &typeVar + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + adc.Name = &name + } + case "etag": + if v != nil { + var etag string + err = json.Unmarshal(*v, &etag) + if err != nil { + return err + } + adc.Etag = &etag + } + case "kind": + if v != nil { + var kind KindBasicDataConnector + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + adc.Kind = kind + } + } + } + + return nil +} + +// ASCDataConnectorProperties MCAS (Microsoft Cloud App Security) data connector properties. +type ASCDataConnectorProperties struct { + // SubscriptionID - The subscription id to connect to, and get the data from. + SubscriptionID *string `json:"subscriptionId,omitempty"` + // DataTypes - The available data types for the connector. + DataTypes *AlertsDataTypeOfDataConnector `json:"dataTypes,omitempty"` +} + +// Bookmark represents a bookmark in Azure Security Insights. +type Bookmark struct { + autorest.Response `json:"-"` + // Etag - Etag of the bookmark. + Etag *string `json:"etag,omitempty"` + // BookmarkProperties - Bookmark properties + *BookmarkProperties `json:"properties,omitempty"` + // ID - Azure resource Id + ID *string `json:"id,omitempty"` + // Type - Azure resource type + Type *string `json:"type,omitempty"` + // Name - Azure resource name + Name *string `json:"name,omitempty"` +} + +// MarshalJSON is the custom marshaler for Bookmark. +func (b Bookmark) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if b.Etag != nil { + objectMap["etag"] = b.Etag + } + if b.BookmarkProperties != nil { + objectMap["properties"] = b.BookmarkProperties + } + if b.ID != nil { + objectMap["id"] = b.ID + } + if b.Type != nil { + objectMap["type"] = b.Type + } + if b.Name != nil { + objectMap["name"] = b.Name + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Bookmark struct. +func (b *Bookmark) 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 "etag": + if v != nil { + var etag string + err = json.Unmarshal(*v, &etag) + if err != nil { + return err + } + b.Etag = &etag + } + case "properties": + if v != nil { + var bookmarkProperties BookmarkProperties + err = json.Unmarshal(*v, &bookmarkProperties) + if err != nil { + return err + } + b.BookmarkProperties = &bookmarkProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + b.ID = &ID + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + b.Type = &typeVar + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + b.Name = &name + } + } + } + + return nil +} + +// BookmarkList list all the bookmarks. +type BookmarkList struct { + autorest.Response `json:"-"` + // NextLink - URL to fetch the next set of cases. + NextLink *string `json:"nextLink,omitempty"` + // Value - Array of bookmarks. + Value *[]Bookmark `json:"value,omitempty"` +} + +// BookmarkListIterator provides access to a complete listing of Bookmark values. +type BookmarkListIterator struct { + i int + page BookmarkListPage +} + +// 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 *BookmarkListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BookmarkListIterator.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 *BookmarkListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter BookmarkListIterator) 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 BookmarkListIterator) Response() BookmarkList { + 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 BookmarkListIterator) Value() Bookmark { + if !iter.page.NotDone() { + return Bookmark{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the BookmarkListIterator type. +func NewBookmarkListIterator(page BookmarkListPage) BookmarkListIterator { + return BookmarkListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (bl BookmarkList) IsEmpty() bool { + return bl.Value == nil || len(*bl.Value) == 0 +} + +// bookmarkListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (bl BookmarkList) bookmarkListPreparer(ctx context.Context) (*http.Request, error) { + if bl.NextLink == nil || len(to.String(bl.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(bl.NextLink))) +} + +// BookmarkListPage contains a page of Bookmark values. +type BookmarkListPage struct { + fn func(context.Context, BookmarkList) (BookmarkList, error) + bl BookmarkList +} + +// 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 *BookmarkListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BookmarkListPage.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.bl) + if err != nil { + return err + } + page.bl = 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 *BookmarkListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page BookmarkListPage) NotDone() bool { + return !page.bl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page BookmarkListPage) Response() BookmarkList { + return page.bl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page BookmarkListPage) Values() []Bookmark { + if page.bl.IsEmpty() { + return nil + } + return *page.bl.Value +} + +// Creates a new instance of the BookmarkListPage type. +func NewBookmarkListPage(getNextPage func(context.Context, BookmarkList) (BookmarkList, error)) BookmarkListPage { + return BookmarkListPage{fn: getNextPage} +} + +// BookmarkProperties describes bookmark properties +type BookmarkProperties struct { + // DisplayName - The display name of the bookmark + DisplayName *string `json:"displayName,omitempty"` + // LastUpdatedTimeUtc - The last time the bookmark was updated + LastUpdatedTimeUtc *date.Time `json:"lastUpdatedTimeUtc,omitempty"` + // CreatedTimeUtc - The time the bookmark was created + CreatedTimeUtc *date.Time `json:"createdTimeUtc,omitempty"` + // CreatedBy - Describes a user that created the bookmark + CreatedBy *UserInfo `json:"createdBy,omitempty"` + // UpdatedBy - Describes a user that updated the bookmark + UpdatedBy *UserInfo `json:"updatedBy,omitempty"` + // Notes - The notes of the bookmark + Notes *string `json:"notes,omitempty"` + // Labels - List of labels relevant to this bookmark + Labels *[]string `json:"labels,omitempty"` + // Query - The query of the bookmark. + Query *string `json:"query,omitempty"` +} + +// Case represents a case in Azure Security Insights. +type Case struct { + autorest.Response `json:"-"` + // Etag - Etag of the alert rule. + Etag *string `json:"etag,omitempty"` + // CaseProperties - Case properties + *CaseProperties `json:"properties,omitempty"` + // ID - Azure resource Id + ID *string `json:"id,omitempty"` + // Type - Azure resource type + Type *string `json:"type,omitempty"` + // Name - Azure resource name + Name *string `json:"name,omitempty"` +} + +// MarshalJSON is the custom marshaler for Case. +func (c Case) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if c.Etag != nil { + objectMap["etag"] = c.Etag + } + if c.CaseProperties != nil { + objectMap["properties"] = c.CaseProperties + } + if c.ID != nil { + objectMap["id"] = c.ID + } + if c.Type != nil { + objectMap["type"] = c.Type + } + if c.Name != nil { + objectMap["name"] = c.Name + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Case struct. +func (c *Case) 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 "etag": + if v != nil { + var etag string + err = json.Unmarshal(*v, &etag) + if err != nil { + return err + } + c.Etag = &etag + } + case "properties": + if v != nil { + var caseProperties CaseProperties + err = json.Unmarshal(*v, &caseProperties) + if err != nil { + return err + } + c.CaseProperties = &caseProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + c.ID = &ID + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + c.Type = &typeVar + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + c.Name = &name + } + } + } + + return nil +} + +// CaseList list all the cases. +type CaseList struct { + autorest.Response `json:"-"` + // NextLink - URL to fetch the next set of cases. + NextLink *string `json:"nextLink,omitempty"` + // Value - Array of cases. + Value *[]Case `json:"value,omitempty"` +} + +// CaseListIterator provides access to a complete listing of Case values. +type CaseListIterator struct { + i int + page CaseListPage +} + +// 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 *CaseListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CaseListIterator.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 *CaseListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter CaseListIterator) 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 CaseListIterator) Response() CaseList { + 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 CaseListIterator) Value() Case { + if !iter.page.NotDone() { + return Case{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the CaseListIterator type. +func NewCaseListIterator(page CaseListPage) CaseListIterator { + return CaseListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (cl CaseList) IsEmpty() bool { + return cl.Value == nil || len(*cl.Value) == 0 +} + +// caseListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (cl CaseList) caseListPreparer(ctx context.Context) (*http.Request, error) { + if cl.NextLink == nil || len(to.String(cl.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(cl.NextLink))) +} + +// CaseListPage contains a page of Case values. +type CaseListPage struct { + fn func(context.Context, CaseList) (CaseList, error) + cl CaseList +} + +// 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 *CaseListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CaseListPage.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.cl) + if err != nil { + return err + } + page.cl = 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 *CaseListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page CaseListPage) NotDone() bool { + return !page.cl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page CaseListPage) Response() CaseList { + return page.cl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page CaseListPage) Values() []Case { + if page.cl.IsEmpty() { + return nil + } + return *page.cl.Value +} + +// Creates a new instance of the CaseListPage type. +func NewCaseListPage(getNextPage func(context.Context, CaseList) (CaseList, error)) CaseListPage { + return CaseListPage{fn: getNextPage} +} + +// CaseProperties describes case properties +type CaseProperties struct { + // LastUpdatedTimeUtc - The last time the case was updated + LastUpdatedTimeUtc *date.Time `json:"lastUpdatedTimeUtc,omitempty"` + // CreatedTimeUtc - The time the case was created + CreatedTimeUtc *date.Time `json:"createdTimeUtc,omitempty"` + // EndTimeUtc - The end time of the case + EndTimeUtc *date.Time `json:"endTimeUtc,omitempty"` + // StartTimeUtc - The start time of the case + StartTimeUtc *date.Time `json:"startTimeUtc,omitempty"` + // Labels - List of labels relevant to this case + Labels *[]string `json:"labels,omitempty"` + // Description - The description of the case + Description *string `json:"description,omitempty"` + // Title - The title of the case + Title *string `json:"title,omitempty"` + // AssignedTo - Describes a user that the case is assigned to + AssignedTo *UserInfo `json:"assignedTo,omitempty"` + // Severity - The severity of the case. Possible values include: 'CaseSeverityCritical', 'CaseSeverityHigh', 'CaseSeverityMedium', 'CaseSeverityLow', 'CaseSeverityInformational' + Severity CaseSeverity `json:"severity,omitempty"` + // Status - The status of the case. Possible values include: 'Draft', 'Open', 'InProgress', 'Closed' + Status CaseStatus `json:"status,omitempty"` + // CloseReason - The reason the case was closed. Possible values include: 'Resolved', 'Dismissed', 'Other' + CloseReason CloseReason `json:"closeReason,omitempty"` +} + +// CloudError error response structure. +type CloudError struct { + // CloudErrorBody - Error data + *CloudErrorBody `json:"error,omitempty"` +} + +// MarshalJSON is the custom marshaler for CloudError. +func (ce CloudError) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ce.CloudErrorBody != nil { + objectMap["error"] = ce.CloudErrorBody + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for CloudError struct. +func (ce *CloudError) 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 "error": + if v != nil { + var cloudErrorBody CloudErrorBody + err = json.Unmarshal(*v, &cloudErrorBody) + if err != nil { + return err + } + ce.CloudErrorBody = &cloudErrorBody + } + } + } + + return nil +} + +// CloudErrorBody error details. +type CloudErrorBody struct { + // Code - An identifier for the error. Codes are invariant and are intended to be consumed programmatically. + Code *string `json:"code,omitempty"` + // Message - A message describing the error, intended to be suitable for display in a user interface. + Message *string `json:"message,omitempty"` +} + +// BasicDataConnector data connector. +type BasicDataConnector interface { + AsOfficeDataConnector() (*OfficeDataConnector, bool) + AsTIDataConnector() (*TIDataConnector, bool) + AsAADDataConnector() (*AADDataConnector, bool) + AsASCDataConnector() (*ASCDataConnector, bool) + AsMCASDataConnector() (*MCASDataConnector, bool) + AsDataConnector() (*DataConnector, bool) +} + +// DataConnector data connector. +type DataConnector struct { + autorest.Response `json:"-"` + // ID - Azure resource Id + ID *string `json:"id,omitempty"` + // Type - Azure resource type + Type *string `json:"type,omitempty"` + // Name - Azure resource name + Name *string `json:"name,omitempty"` + // Etag - Etag of the data connector. + Etag *string `json:"etag,omitempty"` + // Kind - Possible values include: 'KindDataConnector', 'KindOffice365', 'KindThreatIntelligence', 'KindAzureActiveDirectory', 'KindAzureSecurityCenter', 'KindMicrosoftCloudAppSecurity' + Kind KindBasicDataConnector `json:"kind,omitempty"` +} + +func unmarshalBasicDataConnector(body []byte) (BasicDataConnector, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["kind"] { + case string(KindOffice365): + var odc OfficeDataConnector + err := json.Unmarshal(body, &odc) + return odc, err + case string(KindThreatIntelligence): + var tdc TIDataConnector + err := json.Unmarshal(body, &tdc) + return tdc, err + case string(KindAzureActiveDirectory): + var adc AADDataConnector + err := json.Unmarshal(body, &adc) + return adc, err + case string(KindAzureSecurityCenter): + var adc ASCDataConnector + err := json.Unmarshal(body, &adc) + return adc, err + case string(KindMicrosoftCloudAppSecurity): + var mdc MCASDataConnector + err := json.Unmarshal(body, &mdc) + return mdc, err + default: + var dc DataConnector + err := json.Unmarshal(body, &dc) + return dc, err + } +} +func unmarshalBasicDataConnectorArray(body []byte) ([]BasicDataConnector, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + dcArray := make([]BasicDataConnector, len(rawMessages)) + + for index, rawMessage := range rawMessages { + dc, err := unmarshalBasicDataConnector(*rawMessage) + if err != nil { + return nil, err + } + dcArray[index] = dc + } + return dcArray, nil +} + +// MarshalJSON is the custom marshaler for DataConnector. +func (dc DataConnector) MarshalJSON() ([]byte, error) { + dc.Kind = KindDataConnector + objectMap := make(map[string]interface{}) + if dc.ID != nil { + objectMap["id"] = dc.ID + } + if dc.Type != nil { + objectMap["type"] = dc.Type + } + if dc.Name != nil { + objectMap["name"] = dc.Name + } + if dc.Etag != nil { + objectMap["etag"] = dc.Etag + } + if dc.Kind != "" { + objectMap["kind"] = dc.Kind + } + return json.Marshal(objectMap) +} + +// AsOfficeDataConnector is the BasicDataConnector implementation for DataConnector. +func (dc DataConnector) AsOfficeDataConnector() (*OfficeDataConnector, bool) { + return nil, false +} + +// AsTIDataConnector is the BasicDataConnector implementation for DataConnector. +func (dc DataConnector) AsTIDataConnector() (*TIDataConnector, bool) { + return nil, false +} + +// AsAADDataConnector is the BasicDataConnector implementation for DataConnector. +func (dc DataConnector) AsAADDataConnector() (*AADDataConnector, bool) { + return nil, false +} + +// AsASCDataConnector is the BasicDataConnector implementation for DataConnector. +func (dc DataConnector) AsASCDataConnector() (*ASCDataConnector, bool) { + return nil, false +} + +// AsMCASDataConnector is the BasicDataConnector implementation for DataConnector. +func (dc DataConnector) AsMCASDataConnector() (*MCASDataConnector, bool) { + return nil, false +} + +// AsDataConnector is the BasicDataConnector implementation for DataConnector. +func (dc DataConnector) AsDataConnector() (*DataConnector, bool) { + return &dc, true +} + +// AsBasicDataConnector is the BasicDataConnector implementation for DataConnector. +func (dc DataConnector) AsBasicDataConnector() (BasicDataConnector, bool) { + return &dc, true +} + +// DataConnectorDataTypeCommon common field for data type in data connectors. +type DataConnectorDataTypeCommon struct { + // State - Describe whether this data type connection is enabled or not. Possible values include: 'Enabled', 'Disabled' + State DataTypeState `json:"state,omitempty"` +} + +// DataConnectorKind1 describes an Azure resource with kind. +type DataConnectorKind1 struct { + // Kind - The kind of the data connector. Possible values include: 'AzureActiveDirectory', 'AzureSecurityCenter', 'MicrosoftCloudAppSecurity', 'ThreatIntelligence', 'Office365' + Kind DataConnectorKind `json:"kind,omitempty"` +} + +// DataConnectorList list all the data connectors. +type DataConnectorList struct { + autorest.Response `json:"-"` + // NextLink - URL to fetch the next set of data connectors. + NextLink *string `json:"nextLink,omitempty"` + // Value - Array of data connectors. + Value *[]BasicDataConnector `json:"value,omitempty"` +} + +// UnmarshalJSON is the custom unmarshaler for DataConnectorList struct. +func (dcl *DataConnectorList) 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 "nextLink": + if v != nil { + var nextLink string + err = json.Unmarshal(*v, &nextLink) + if err != nil { + return err + } + dcl.NextLink = &nextLink + } + case "value": + if v != nil { + value, err := unmarshalBasicDataConnectorArray(*v) + if err != nil { + return err + } + dcl.Value = &value + } + } + } + + return nil +} + +// DataConnectorListIterator provides access to a complete listing of DataConnector values. +type DataConnectorListIterator struct { + i int + page DataConnectorListPage +} + +// 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 *DataConnectorListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataConnectorListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() @@ -436,62 +2120,62 @@ func (iter *AlertRulesListIterator) NextWithContext(ctx context.Context) (err er // 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 *AlertRulesListIterator) Next() error { +func (iter *DataConnectorListIterator) Next() error { return iter.NextWithContext(context.Background()) } // NotDone returns true if the enumeration should be started or is not yet complete. -func (iter AlertRulesListIterator) NotDone() bool { +func (iter DataConnectorListIterator) 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 AlertRulesListIterator) Response() AlertRulesList { +func (iter DataConnectorListIterator) Response() DataConnectorList { 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 AlertRulesListIterator) Value() BasicAlertRule { +func (iter DataConnectorListIterator) Value() BasicDataConnector { if !iter.page.NotDone() { - return AlertRule{} + return DataConnector{} } return iter.page.Values()[iter.i] } -// Creates a new instance of the AlertRulesListIterator type. -func NewAlertRulesListIterator(page AlertRulesListPage) AlertRulesListIterator { - return AlertRulesListIterator{page: page} +// Creates a new instance of the DataConnectorListIterator type. +func NewDataConnectorListIterator(page DataConnectorListPage) DataConnectorListIterator { + return DataConnectorListIterator{page: page} } // IsEmpty returns true if the ListResult contains no values. -func (arl AlertRulesList) IsEmpty() bool { - return arl.Value == nil || len(*arl.Value) == 0 +func (dcl DataConnectorList) IsEmpty() bool { + return dcl.Value == nil || len(*dcl.Value) == 0 } -// alertRulesListPreparer prepares a request to retrieve the next set of results. +// dataConnectorListPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. -func (arl AlertRulesList) alertRulesListPreparer(ctx context.Context) (*http.Request, error) { - if arl.NextLink == nil || len(to.String(arl.NextLink)) < 1 { +func (dcl DataConnectorList) dataConnectorListPreparer(ctx context.Context) (*http.Request, error) { + if dcl.NextLink == nil || len(to.String(dcl.NextLink)) < 1 { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), autorest.AsJSON(), autorest.AsGet(), - autorest.WithBaseURL(to.String(arl.NextLink))) + autorest.WithBaseURL(to.String(dcl.NextLink))) } -// AlertRulesListPage contains a page of BasicAlertRule values. -type AlertRulesListPage struct { - fn func(context.Context, AlertRulesList) (AlertRulesList, error) - arl AlertRulesList +// DataConnectorListPage contains a page of BasicDataConnector values. +type DataConnectorListPage struct { + fn func(context.Context, DataConnectorList) (DataConnectorList, error) + dcl DataConnectorList } // 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 *AlertRulesListPage) NextWithContext(ctx context.Context) (err error) { +func (page *DataConnectorListPage) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/AlertRulesListPage.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/DataConnectorListPage.NextWithContext") defer func() { sc := -1 if page.Response().Response.Response != nil { @@ -500,203 +2184,83 @@ func (page *AlertRulesListPage) NextWithContext(ctx context.Context) (err error) tracing.EndSpan(ctx, sc, err) }() } - next, err := page.fn(ctx, page.arl) + next, err := page.fn(ctx, page.dcl) if err != nil { return err } - page.arl = next + page.dcl = 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 *AlertRulesListPage) Next() error { +func (page *DataConnectorListPage) Next() error { return page.NextWithContext(context.Background()) } // NotDone returns true if the page enumeration should be started or is not yet complete. -func (page AlertRulesListPage) NotDone() bool { - return !page.arl.IsEmpty() +func (page DataConnectorListPage) NotDone() bool { + return !page.dcl.IsEmpty() } // Response returns the raw server response from the last page request. -func (page AlertRulesListPage) Response() AlertRulesList { - return page.arl +func (page DataConnectorListPage) Response() DataConnectorList { + return page.dcl } // Values returns the slice of values for the current page or nil if there are no values. -func (page AlertRulesListPage) Values() []BasicAlertRule { - if page.arl.IsEmpty() { +func (page DataConnectorListPage) Values() []BasicDataConnector { + if page.dcl.IsEmpty() { return nil } - return *page.arl.Value -} - -// Creates a new instance of the AlertRulesListPage type. -func NewAlertRulesListPage(getNextPage func(context.Context, AlertRulesList) (AlertRulesList, error)) AlertRulesListPage { - return AlertRulesListPage{fn: getNextPage} -} - -// AlertsDataTypeOfDataConnector alerts data type for data connectors. -type AlertsDataTypeOfDataConnector struct { - // Alerts - Alerts data type connection. - Alerts *AlertsDataTypeOfDataConnectorAlerts `json:"alerts,omitempty"` -} - -// AlertsDataTypeOfDataConnectorAlerts alerts data type connection. -type AlertsDataTypeOfDataConnectorAlerts struct { - // State - Describe whether this data type connection is enabled or not. Possible values include: 'Enabled', 'Disabled' - State DataTypeState `json:"state,omitempty"` -} - -// ASCDataConnector represents ASC (Azure Security Center) data connector. -type ASCDataConnector struct { - // DataConnectorWithAlertsProperties - Data connector properties. - *DataConnectorWithAlertsProperties `json:"properties,omitempty"` - // ID - Azure resource Id - ID *string `json:"id,omitempty"` - // Type - Azure resource type - Type *string `json:"type,omitempty"` - // Name - Azure resource name - Name *string `json:"name,omitempty"` - // Etag - Etag of the data connector. - Etag *string `json:"etag,omitempty"` - // Kind - Possible values include: 'KindDataConnector', 'KindOffice365', 'KindThreatIntelligence', 'KindAzureActiveDirectory', 'KindAzureSecurityCenter', 'KindMicrosoftCloudAppSecurity', 'KindDataConnectorWithAlerts' - Kind KindBasicDataConnector `json:"kind,omitempty"` -} - -// MarshalJSON is the custom marshaler for ASCDataConnector. -func (adc ASCDataConnector) MarshalJSON() ([]byte, error) { - adc.Kind = KindAzureSecurityCenter - objectMap := make(map[string]interface{}) - if adc.DataConnectorWithAlertsProperties != nil { - objectMap["properties"] = adc.DataConnectorWithAlertsProperties - } - if adc.ID != nil { - objectMap["id"] = adc.ID - } - if adc.Type != nil { - objectMap["type"] = adc.Type - } - if adc.Name != nil { - objectMap["name"] = adc.Name - } - if adc.Etag != nil { - objectMap["etag"] = adc.Etag - } - if adc.Kind != "" { - objectMap["kind"] = adc.Kind - } - return json.Marshal(objectMap) -} - -// AsOfficeDataConnector is the BasicDataConnector implementation for ASCDataConnector. -func (adc ASCDataConnector) AsOfficeDataConnector() (*OfficeDataConnector, bool) { - return nil, false -} - -// AsTIDataConnector is the BasicDataConnector implementation for ASCDataConnector. -func (adc ASCDataConnector) AsTIDataConnector() (*TIDataConnector, bool) { - return nil, false -} - -// AsAADDataConnector is the BasicDataConnector implementation for ASCDataConnector. -func (adc ASCDataConnector) AsAADDataConnector() (*AADDataConnector, bool) { - return nil, false -} - -// AsASCDataConnector is the BasicDataConnector implementation for ASCDataConnector. -func (adc ASCDataConnector) AsASCDataConnector() (*ASCDataConnector, bool) { - return &adc, true -} - -// AsMCASDataConnector is the BasicDataConnector implementation for ASCDataConnector. -func (adc ASCDataConnector) AsMCASDataConnector() (*MCASDataConnector, bool) { - return nil, false -} - -// AsDataConnectorWithAlerts is the BasicDataConnector implementation for ASCDataConnector. -func (adc ASCDataConnector) AsDataConnectorWithAlerts() (*DataConnectorWithAlerts, bool) { - return nil, false -} - -// AsBasicDataConnectorWithAlerts is the BasicDataConnector implementation for ASCDataConnector. -func (adc ASCDataConnector) AsBasicDataConnectorWithAlerts() (BasicDataConnectorWithAlerts, bool) { - return &adc, true -} - -// AsDataConnector is the BasicDataConnector implementation for ASCDataConnector. -func (adc ASCDataConnector) AsDataConnector() (*DataConnector, bool) { - return nil, false -} - -// AsBasicDataConnector is the BasicDataConnector implementation for ASCDataConnector. -func (adc ASCDataConnector) AsBasicDataConnector() (BasicDataConnector, bool) { - return &adc, true + return *page.dcl.Value } -// CloudError error response structure. -type CloudError struct { - // CloudErrorBody - Error data - *CloudErrorBody `json:"error,omitempty"` +// Creates a new instance of the DataConnectorListPage type. +func NewDataConnectorListPage(getNextPage func(context.Context, DataConnectorList) (DataConnectorList, error)) DataConnectorListPage { + return DataConnectorListPage{fn: getNextPage} } -// MarshalJSON is the custom marshaler for CloudError. -func (ce CloudError) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if ce.CloudErrorBody != nil { - objectMap["error"] = ce.CloudErrorBody - } - return json.Marshal(objectMap) +// DataConnectorModel ... +type DataConnectorModel struct { + autorest.Response `json:"-"` + Value BasicDataConnector `json:"value,omitempty"` } -// UnmarshalJSON is the custom unmarshaler for CloudError struct. -func (ce *CloudError) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) +// UnmarshalJSON is the custom unmarshaler for DataConnectorModel struct. +func (dcm *DataConnectorModel) UnmarshalJSON(body []byte) error { + dc, err := unmarshalBasicDataConnector(body) if err != nil { return err } - for k, v := range m { - switch k { - case "error": - if v != nil { - var cloudErrorBody CloudErrorBody - err = json.Unmarshal(*v, &cloudErrorBody) - if err != nil { - return err - } - ce.CloudErrorBody = &cloudErrorBody - } - } - } + dcm.Value = dc return nil } -// CloudErrorBody error details. -type CloudErrorBody struct { - // Code - An identifier for the error. Codes are invariant and are intended to be consumed programmatically. - Code *string `json:"code,omitempty"` - // Message - A message describing the error, intended to be suitable for display in a user interface. - Message *string `json:"message,omitempty"` +// DataConnectorTenantID properties data connector on tenant level. +type DataConnectorTenantID struct { + // TenantID - The tenant id to connect to, and get the data from. + TenantID *string `json:"tenantId,omitempty"` } -// BasicDataConnector data connector. -type BasicDataConnector interface { - AsOfficeDataConnector() (*OfficeDataConnector, bool) - AsTIDataConnector() (*TIDataConnector, bool) - AsAADDataConnector() (*AADDataConnector, bool) - AsASCDataConnector() (*ASCDataConnector, bool) - AsMCASDataConnector() (*MCASDataConnector, bool) - AsDataConnectorWithAlerts() (*DataConnectorWithAlerts, bool) - AsBasicDataConnectorWithAlerts() (BasicDataConnectorWithAlerts, bool) - AsDataConnector() (*DataConnector, bool) +// DataConnectorWithAlertsProperties data connector properties. +type DataConnectorWithAlertsProperties struct { + // DataTypes - The available data types for the connector. + DataTypes *AlertsDataTypeOfDataConnector `json:"dataTypes,omitempty"` } -// DataConnector data connector. -type DataConnector struct { +// BasicEntity specific entity. +type BasicEntity interface { + AsAccountEntity() (*AccountEntity, bool) + AsHostEntity() (*HostEntity, bool) + AsFileEntity() (*FileEntity, bool) + AsEntity() (*Entity, bool) +} + +// Entity specific entity. +type Entity struct { autorest.Response `json:"-"` // ID - Azure resource Id ID *string `json:"id,omitempty"` @@ -704,165 +2268,116 @@ type DataConnector struct { Type *string `json:"type,omitempty"` // Name - Azure resource name Name *string `json:"name,omitempty"` - // Etag - Etag of the data connector. - Etag *string `json:"etag,omitempty"` - // Kind - Possible values include: 'KindDataConnector', 'KindOffice365', 'KindThreatIntelligence', 'KindAzureActiveDirectory', 'KindAzureSecurityCenter', 'KindMicrosoftCloudAppSecurity', 'KindDataConnectorWithAlerts' - Kind KindBasicDataConnector `json:"kind,omitempty"` + // Kind - Possible values include: 'KindEntity', 'KindAccount', 'KindHost', 'KindFile' + Kind KindBasicEntity `json:"kind,omitempty"` } -func unmarshalBasicDataConnector(body []byte) (BasicDataConnector, error) { +func unmarshalBasicEntity(body []byte) (BasicEntity, error) { var m map[string]interface{} err := json.Unmarshal(body, &m) if err != nil { return nil, err } - - switch m["kind"] { - case string(KindOffice365): - var odc OfficeDataConnector - err := json.Unmarshal(body, &odc) - return odc, err - case string(KindThreatIntelligence): - var tdc TIDataConnector - err := json.Unmarshal(body, &tdc) - return tdc, err - case string(KindAzureActiveDirectory): - var adc AADDataConnector - err := json.Unmarshal(body, &adc) - return adc, err - case string(KindAzureSecurityCenter): - var adc ASCDataConnector - err := json.Unmarshal(body, &adc) - return adc, err - case string(KindMicrosoftCloudAppSecurity): - var mdc MCASDataConnector - err := json.Unmarshal(body, &mdc) - return mdc, err - case string(KindDataConnectorWithAlerts): - var dcwa DataConnectorWithAlerts - err := json.Unmarshal(body, &dcwa) - return dcwa, err + + switch m["kind"] { + case string(KindAccount): + var ae AccountEntity + err := json.Unmarshal(body, &ae) + return ae, err + case string(KindHost): + var he HostEntity + err := json.Unmarshal(body, &he) + return he, err + case string(KindFile): + var fe FileEntity + err := json.Unmarshal(body, &fe) + return fe, err default: - var dc DataConnector - err := json.Unmarshal(body, &dc) - return dc, err + var e Entity + err := json.Unmarshal(body, &e) + return e, err } } -func unmarshalBasicDataConnectorArray(body []byte) ([]BasicDataConnector, error) { +func unmarshalBasicEntityArray(body []byte) ([]BasicEntity, error) { var rawMessages []*json.RawMessage err := json.Unmarshal(body, &rawMessages) if err != nil { return nil, err } - dcArray := make([]BasicDataConnector, len(rawMessages)) + eArray := make([]BasicEntity, len(rawMessages)) for index, rawMessage := range rawMessages { - dc, err := unmarshalBasicDataConnector(*rawMessage) + e, err := unmarshalBasicEntity(*rawMessage) if err != nil { return nil, err } - dcArray[index] = dc + eArray[index] = e } - return dcArray, nil + return eArray, nil } -// MarshalJSON is the custom marshaler for DataConnector. -func (dc DataConnector) MarshalJSON() ([]byte, error) { - dc.Kind = KindDataConnector +// MarshalJSON is the custom marshaler for Entity. +func (e Entity) MarshalJSON() ([]byte, error) { + e.Kind = KindEntity objectMap := make(map[string]interface{}) - if dc.ID != nil { - objectMap["id"] = dc.ID - } - if dc.Type != nil { - objectMap["type"] = dc.Type + if e.ID != nil { + objectMap["id"] = e.ID } - if dc.Name != nil { - objectMap["name"] = dc.Name + if e.Type != nil { + objectMap["type"] = e.Type } - if dc.Etag != nil { - objectMap["etag"] = dc.Etag + if e.Name != nil { + objectMap["name"] = e.Name } - if dc.Kind != "" { - objectMap["kind"] = dc.Kind + if e.Kind != "" { + objectMap["kind"] = e.Kind } return json.Marshal(objectMap) } -// AsOfficeDataConnector is the BasicDataConnector implementation for DataConnector. -func (dc DataConnector) AsOfficeDataConnector() (*OfficeDataConnector, bool) { - return nil, false -} - -// AsTIDataConnector is the BasicDataConnector implementation for DataConnector. -func (dc DataConnector) AsTIDataConnector() (*TIDataConnector, bool) { - return nil, false -} - -// AsAADDataConnector is the BasicDataConnector implementation for DataConnector. -func (dc DataConnector) AsAADDataConnector() (*AADDataConnector, bool) { - return nil, false -} - -// AsASCDataConnector is the BasicDataConnector implementation for DataConnector. -func (dc DataConnector) AsASCDataConnector() (*ASCDataConnector, bool) { - return nil, false -} - -// AsMCASDataConnector is the BasicDataConnector implementation for DataConnector. -func (dc DataConnector) AsMCASDataConnector() (*MCASDataConnector, bool) { +// AsAccountEntity is the BasicEntity implementation for Entity. +func (e Entity) AsAccountEntity() (*AccountEntity, bool) { return nil, false } -// AsDataConnectorWithAlerts is the BasicDataConnector implementation for DataConnector. -func (dc DataConnector) AsDataConnectorWithAlerts() (*DataConnectorWithAlerts, bool) { +// AsHostEntity is the BasicEntity implementation for Entity. +func (e Entity) AsHostEntity() (*HostEntity, bool) { return nil, false } -// AsBasicDataConnectorWithAlerts is the BasicDataConnector implementation for DataConnector. -func (dc DataConnector) AsBasicDataConnectorWithAlerts() (BasicDataConnectorWithAlerts, bool) { +// AsFileEntity is the BasicEntity implementation for Entity. +func (e Entity) AsFileEntity() (*FileEntity, bool) { return nil, false } -// AsDataConnector is the BasicDataConnector implementation for DataConnector. -func (dc DataConnector) AsDataConnector() (*DataConnector, bool) { - return &dc, true -} - -// AsBasicDataConnector is the BasicDataConnector implementation for DataConnector. -func (dc DataConnector) AsBasicDataConnector() (BasicDataConnector, bool) { - return &dc, true -} - -// DataConnectorContextID describes an Azure resource with kind. -type DataConnectorContextID struct { - // ContextID - The context id of the origin data source (Like tenantID, SubscriptionID etc.). - ContextID *string `json:"contextId,omitempty"` +// AsEntity is the BasicEntity implementation for Entity. +func (e Entity) AsEntity() (*Entity, bool) { + return &e, true } -// DataConnectorDataTypeCommon common field for data type in data connectors. -type DataConnectorDataTypeCommon struct { - // State - Describe whether this data type connection is enabled or not. Possible values include: 'Enabled', 'Disabled' - State DataTypeState `json:"state,omitempty"` +// AsBasicEntity is the BasicEntity implementation for Entity. +func (e Entity) AsBasicEntity() (BasicEntity, bool) { + return &e, true } -// DataConnectorKind1 describes an Azure resource with kind. -type DataConnectorKind1 struct { - // Kind - The kind of the data connector. Possible values include: 'AzureActiveDirectory', 'AzureSecurityCenter', 'MicrosoftCloudAppSecurity', 'ThreatIntelligence', 'Office365' - Kind DataConnectorKind `json:"kind,omitempty"` +// EntityKind1 describes an Azure resource with kind. +type EntityKind1 struct { + // Kind - The kind of the entity. Possible values include: 'Account', 'Host', 'File' + Kind EntityKind `json:"kind,omitempty"` } -// DataConnectorList list all the data connectors. -type DataConnectorList struct { +// EntityList list of all the entities. +type EntityList struct { autorest.Response `json:"-"` - // NextLink - URL to fetch the next set of data connectors. + // NextLink - URL to fetch the next set of entities. NextLink *string `json:"nextLink,omitempty"` - // Value - Array of data connectors. - Value *[]BasicDataConnector `json:"value,omitempty"` + // Value - Array of entities. + Value *[]BasicEntity `json:"value,omitempty"` } -// UnmarshalJSON is the custom unmarshaler for DataConnectorList struct. -func (dcl *DataConnectorList) UnmarshalJSON(body []byte) error { +// UnmarshalJSON is the custom unmarshaler for EntityList struct. +func (el *EntityList) UnmarshalJSON(body []byte) error { var m map[string]*json.RawMessage err := json.Unmarshal(body, &m) if err != nil { @@ -877,15 +2392,15 @@ func (dcl *DataConnectorList) UnmarshalJSON(body []byte) error { if err != nil { return err } - dcl.NextLink = &nextLink + el.NextLink = &nextLink } case "value": if v != nil { - value, err := unmarshalBasicDataConnectorArray(*v) + value, err := unmarshalBasicEntityArray(*v) if err != nil { return err } - dcl.Value = &value + el.Value = &value } } } @@ -893,17 +2408,17 @@ func (dcl *DataConnectorList) UnmarshalJSON(body []byte) error { return nil } -// DataConnectorListIterator provides access to a complete listing of DataConnector values. -type DataConnectorListIterator struct { +// EntityListIterator provides access to a complete listing of Entity values. +type EntityListIterator struct { i int - page DataConnectorListPage + page EntityListPage } // 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 *DataConnectorListIterator) NextWithContext(ctx context.Context) (err error) { +func (iter *EntityListIterator) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DataConnectorListIterator.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/EntityListIterator.NextWithContext") defer func() { sc := -1 if iter.Response().Response.Response != nil { @@ -928,62 +2443,62 @@ func (iter *DataConnectorListIterator) NextWithContext(ctx context.Context) (err // 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 *DataConnectorListIterator) Next() error { +func (iter *EntityListIterator) Next() error { return iter.NextWithContext(context.Background()) } // NotDone returns true if the enumeration should be started or is not yet complete. -func (iter DataConnectorListIterator) NotDone() bool { +func (iter EntityListIterator) 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 DataConnectorListIterator) Response() DataConnectorList { +func (iter EntityListIterator) Response() EntityList { 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 DataConnectorListIterator) Value() BasicDataConnector { +func (iter EntityListIterator) Value() BasicEntity { if !iter.page.NotDone() { - return DataConnector{} + return Entity{} } return iter.page.Values()[iter.i] } -// Creates a new instance of the DataConnectorListIterator type. -func NewDataConnectorListIterator(page DataConnectorListPage) DataConnectorListIterator { - return DataConnectorListIterator{page: page} +// Creates a new instance of the EntityListIterator type. +func NewEntityListIterator(page EntityListPage) EntityListIterator { + return EntityListIterator{page: page} } // IsEmpty returns true if the ListResult contains no values. -func (dcl DataConnectorList) IsEmpty() bool { - return dcl.Value == nil || len(*dcl.Value) == 0 +func (el EntityList) IsEmpty() bool { + return el.Value == nil || len(*el.Value) == 0 } -// dataConnectorListPreparer prepares a request to retrieve the next set of results. +// entityListPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. -func (dcl DataConnectorList) dataConnectorListPreparer(ctx context.Context) (*http.Request, error) { - if dcl.NextLink == nil || len(to.String(dcl.NextLink)) < 1 { +func (el EntityList) entityListPreparer(ctx context.Context) (*http.Request, error) { + if el.NextLink == nil || len(to.String(el.NextLink)) < 1 { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), autorest.AsJSON(), autorest.AsGet(), - autorest.WithBaseURL(to.String(dcl.NextLink))) + autorest.WithBaseURL(to.String(el.NextLink))) } -// DataConnectorListPage contains a page of BasicDataConnector values. -type DataConnectorListPage struct { - fn func(context.Context, DataConnectorList) (DataConnectorList, error) - dcl DataConnectorList +// EntityListPage contains a page of BasicEntity values. +type EntityListPage struct { + fn func(context.Context, EntityList) (EntityList, error) + el EntityList } // 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 *DataConnectorListPage) NextWithContext(ctx context.Context) (err error) { +func (page *EntityListPage) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DataConnectorListPage.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/EntityListPage.NextWithContext") defer func() { sc := -1 if page.Response().Response.Response != nil { @@ -992,73 +2507,337 @@ func (page *DataConnectorListPage) NextWithContext(ctx context.Context) (err err tracing.EndSpan(ctx, sc, err) }() } - next, err := page.fn(ctx, page.dcl) + next, err := page.fn(ctx, page.el) if err != nil { return err } - page.dcl = next + page.el = 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 *DataConnectorListPage) Next() error { +func (page *EntityListPage) Next() error { return page.NextWithContext(context.Background()) } // NotDone returns true if the page enumeration should be started or is not yet complete. -func (page DataConnectorListPage) NotDone() bool { - return !page.dcl.IsEmpty() +func (page EntityListPage) NotDone() bool { + return !page.el.IsEmpty() } // Response returns the raw server response from the last page request. -func (page DataConnectorListPage) Response() DataConnectorList { - return page.dcl +func (page EntityListPage) Response() EntityList { + return page.el } // Values returns the slice of values for the current page or nil if there are no values. -func (page DataConnectorListPage) Values() []BasicDataConnector { - if page.dcl.IsEmpty() { +func (page EntityListPage) Values() []BasicEntity { + if page.el.IsEmpty() { return nil } - return *page.dcl.Value + return *page.el.Value } -// Creates a new instance of the DataConnectorListPage type. -func NewDataConnectorListPage(getNextPage func(context.Context, DataConnectorList) (DataConnectorList, error)) DataConnectorListPage { - return DataConnectorListPage{fn: getNextPage} +// Creates a new instance of the EntityListPage type. +func NewEntityListPage(getNextPage func(context.Context, EntityList) (EntityList, error)) EntityListPage { + return EntityListPage{fn: getNextPage} } -// DataConnectorModel ... -type DataConnectorModel struct { +// EntityModel ... +type EntityModel struct { autorest.Response `json:"-"` - Value BasicDataConnector `json:"value,omitempty"` + Value BasicEntity `json:"value,omitempty"` } -// UnmarshalJSON is the custom unmarshaler for DataConnectorModel struct. -func (dcm *DataConnectorModel) UnmarshalJSON(body []byte) error { - dc, err := unmarshalBasicDataConnector(body) +// UnmarshalJSON is the custom unmarshaler for EntityModel struct. +func (em *EntityModel) UnmarshalJSON(body []byte) error { + e, err := unmarshalBasicEntity(body) + if err != nil { + return err + } + em.Value = e + + return nil +} + +// FileEntity represents a file entity. +type FileEntity struct { + // FileEntityProperties - File entity properties + *FileEntityProperties `json:"properties,omitempty"` + // ID - Azure resource Id + ID *string `json:"id,omitempty"` + // Type - Azure resource type + Type *string `json:"type,omitempty"` + // Name - Azure resource name + Name *string `json:"name,omitempty"` + // Kind - Possible values include: 'KindEntity', 'KindAccount', 'KindHost', 'KindFile' + Kind KindBasicEntity `json:"kind,omitempty"` +} + +// MarshalJSON is the custom marshaler for FileEntity. +func (fe FileEntity) MarshalJSON() ([]byte, error) { + fe.Kind = KindFile + objectMap := make(map[string]interface{}) + if fe.FileEntityProperties != nil { + objectMap["properties"] = fe.FileEntityProperties + } + if fe.ID != nil { + objectMap["id"] = fe.ID + } + if fe.Type != nil { + objectMap["type"] = fe.Type + } + if fe.Name != nil { + objectMap["name"] = fe.Name + } + if fe.Kind != "" { + objectMap["kind"] = fe.Kind + } + return json.Marshal(objectMap) +} + +// AsAccountEntity is the BasicEntity implementation for FileEntity. +func (fe FileEntity) AsAccountEntity() (*AccountEntity, bool) { + return nil, false +} + +// AsHostEntity is the BasicEntity implementation for FileEntity. +func (fe FileEntity) AsHostEntity() (*HostEntity, bool) { + return nil, false +} + +// AsFileEntity is the BasicEntity implementation for FileEntity. +func (fe FileEntity) AsFileEntity() (*FileEntity, bool) { + return &fe, true +} + +// AsEntity is the BasicEntity implementation for FileEntity. +func (fe FileEntity) AsEntity() (*Entity, bool) { + return nil, false +} + +// AsBasicEntity is the BasicEntity implementation for FileEntity. +func (fe FileEntity) AsBasicEntity() (BasicEntity, bool) { + return &fe, true +} + +// UnmarshalJSON is the custom unmarshaler for FileEntity struct. +func (fe *FileEntity) 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 fileEntityProperties FileEntityProperties + err = json.Unmarshal(*v, &fileEntityProperties) + if err != nil { + return err + } + fe.FileEntityProperties = &fileEntityProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + fe.ID = &ID + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + fe.Type = &typeVar + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + fe.Name = &name + } + case "kind": + if v != nil { + var kind KindBasicEntity + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + fe.Kind = kind + } + } + } + + return nil +} + +// FileEntityProperties file entity property bag. +type FileEntityProperties struct { + // Directory - The full path to the file. + Directory *string `json:"directory,omitempty"` + // FileName - The file name without path (some alerts might not include path). + FileName *string `json:"fileName,omitempty"` +} + +// HostEntity represents a host entity. +type HostEntity struct { + // HostEntityProperties - Host entity properties + *HostEntityProperties `json:"properties,omitempty"` + // ID - Azure resource Id + ID *string `json:"id,omitempty"` + // Type - Azure resource type + Type *string `json:"type,omitempty"` + // Name - Azure resource name + Name *string `json:"name,omitempty"` + // Kind - Possible values include: 'KindEntity', 'KindAccount', 'KindHost', 'KindFile' + Kind KindBasicEntity `json:"kind,omitempty"` +} + +// MarshalJSON is the custom marshaler for HostEntity. +func (he HostEntity) MarshalJSON() ([]byte, error) { + he.Kind = KindHost + objectMap := make(map[string]interface{}) + if he.HostEntityProperties != nil { + objectMap["properties"] = he.HostEntityProperties + } + if he.ID != nil { + objectMap["id"] = he.ID + } + if he.Type != nil { + objectMap["type"] = he.Type + } + if he.Name != nil { + objectMap["name"] = he.Name + } + if he.Kind != "" { + objectMap["kind"] = he.Kind + } + return json.Marshal(objectMap) +} + +// AsAccountEntity is the BasicEntity implementation for HostEntity. +func (he HostEntity) AsAccountEntity() (*AccountEntity, bool) { + return nil, false +} + +// AsHostEntity is the BasicEntity implementation for HostEntity. +func (he HostEntity) AsHostEntity() (*HostEntity, bool) { + return &he, true +} + +// AsFileEntity is the BasicEntity implementation for HostEntity. +func (he HostEntity) AsFileEntity() (*FileEntity, bool) { + return nil, false +} + +// AsEntity is the BasicEntity implementation for HostEntity. +func (he HostEntity) AsEntity() (*Entity, bool) { + return nil, false +} + +// AsBasicEntity is the BasicEntity implementation for HostEntity. +func (he HostEntity) AsBasicEntity() (BasicEntity, bool) { + return &he, true +} + +// UnmarshalJSON is the custom unmarshaler for HostEntity struct. +func (he *HostEntity) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) if err != nil { return err } - dcm.Value = dc + for k, v := range m { + switch k { + case "properties": + if v != nil { + var hostEntityProperties HostEntityProperties + err = json.Unmarshal(*v, &hostEntityProperties) + if err != nil { + return err + } + he.HostEntityProperties = &hostEntityProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + he.ID = &ID + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + he.Type = &typeVar + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + he.Name = &name + } + case "kind": + if v != nil { + var kind KindBasicEntity + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + he.Kind = kind + } + } + } return nil } -// BasicDataConnectorWithAlerts data connector with alerts data type. -type BasicDataConnectorWithAlerts interface { - AsAADDataConnector() (*AADDataConnector, bool) - AsASCDataConnector() (*ASCDataConnector, bool) - AsMCASDataConnector() (*MCASDataConnector, bool) - AsDataConnectorWithAlerts() (*DataConnectorWithAlerts, bool) +// HostEntityProperties host entity property bag. +type HostEntityProperties struct { + // DNSDomain - The DNS domain that this host belongs to. Should contain the compete DNS suffix for the domain + DNSDomain *string `json:"dnsDomain,omitempty"` + // NtDomain - The NT domain that this host belongs to. + NtDomain *string `json:"ntDomain,omitempty"` + // HostName - The hostname without the domain suffix. + HostName *string `json:"hostName,omitempty"` + // NetBiosName - The host name (pre-windows2000). + NetBiosName *string `json:"netBiosName,omitempty"` + // AzureID - The azure resource id of the VM. + AzureID *string `json:"azureID,omitempty"` + // OmsAgentID - The OMS agent id, if the host has OMS agent installed. + OmsAgentID *string `json:"omsAgentID,omitempty"` + // OsFamily - The operating system type. Possible values include: 'Linux', 'Windows', 'Android', 'IOS' + OsFamily OSFamily `json:"osFamily,omitempty"` + // OsVersion - A free text representation of the operating system. This field is meant to hold specific versions the are more fine grained than OSFamily or future values not supported by OSFamily enumeration + OsVersion *string `json:"osVersion,omitempty"` + // IsDomainJoined - Determines whether this host belongs to a domain. + IsDomainJoined *bool `json:"isDomainJoined,omitempty"` } -// DataConnectorWithAlerts data connector with alerts data type. -type DataConnectorWithAlerts struct { - // DataConnectorWithAlertsProperties - Data connector properties. - *DataConnectorWithAlertsProperties `json:"properties,omitempty"` +// MCASDataConnector represents MCAS (Microsoft Cloud App Security) data connector. +type MCASDataConnector struct { + // MCASDataConnectorProperties - MCAS (Microsoft Cloud App Security) data connector properties. + *MCASDataConnectorProperties `json:"properties,omitempty"` // ID - Azure resource Id ID *string `json:"id,omitempty"` // Type - Azure resource type @@ -1067,127 +2846,72 @@ type DataConnectorWithAlerts struct { Name *string `json:"name,omitempty"` // Etag - Etag of the data connector. Etag *string `json:"etag,omitempty"` - // Kind - Possible values include: 'KindDataConnector', 'KindOffice365', 'KindThreatIntelligence', 'KindAzureActiveDirectory', 'KindAzureSecurityCenter', 'KindMicrosoftCloudAppSecurity', 'KindDataConnectorWithAlerts' + // Kind - Possible values include: 'KindDataConnector', 'KindOffice365', 'KindThreatIntelligence', 'KindAzureActiveDirectory', 'KindAzureSecurityCenter', 'KindMicrosoftCloudAppSecurity' Kind KindBasicDataConnector `json:"kind,omitempty"` } -func unmarshalBasicDataConnectorWithAlerts(body []byte) (BasicDataConnectorWithAlerts, error) { - var m map[string]interface{} - err := json.Unmarshal(body, &m) - if err != nil { - return nil, err - } - - switch m["kind"] { - case string(KindAzureActiveDirectory): - var adc AADDataConnector - err := json.Unmarshal(body, &adc) - return adc, err - case string(KindAzureSecurityCenter): - var adc ASCDataConnector - err := json.Unmarshal(body, &adc) - return adc, err - case string(KindMicrosoftCloudAppSecurity): - var mdc MCASDataConnector - err := json.Unmarshal(body, &mdc) - return mdc, err - default: - var dcwa DataConnectorWithAlerts - err := json.Unmarshal(body, &dcwa) - return dcwa, err - } -} -func unmarshalBasicDataConnectorWithAlertsArray(body []byte) ([]BasicDataConnectorWithAlerts, error) { - var rawMessages []*json.RawMessage - err := json.Unmarshal(body, &rawMessages) - if err != nil { - return nil, err - } - - dcwaArray := make([]BasicDataConnectorWithAlerts, len(rawMessages)) - - for index, rawMessage := range rawMessages { - dcwa, err := unmarshalBasicDataConnectorWithAlerts(*rawMessage) - if err != nil { - return nil, err - } - dcwaArray[index] = dcwa - } - return dcwaArray, nil -} - -// MarshalJSON is the custom marshaler for DataConnectorWithAlerts. -func (dcwa DataConnectorWithAlerts) MarshalJSON() ([]byte, error) { - dcwa.Kind = KindDataConnectorWithAlerts +// MarshalJSON is the custom marshaler for MCASDataConnector. +func (mdc MCASDataConnector) MarshalJSON() ([]byte, error) { + mdc.Kind = KindMicrosoftCloudAppSecurity objectMap := make(map[string]interface{}) - if dcwa.DataConnectorWithAlertsProperties != nil { - objectMap["properties"] = dcwa.DataConnectorWithAlertsProperties + if mdc.MCASDataConnectorProperties != nil { + objectMap["properties"] = mdc.MCASDataConnectorProperties } - if dcwa.ID != nil { - objectMap["id"] = dcwa.ID + if mdc.ID != nil { + objectMap["id"] = mdc.ID } - if dcwa.Type != nil { - objectMap["type"] = dcwa.Type + if mdc.Type != nil { + objectMap["type"] = mdc.Type } - if dcwa.Name != nil { - objectMap["name"] = dcwa.Name + if mdc.Name != nil { + objectMap["name"] = mdc.Name } - if dcwa.Etag != nil { - objectMap["etag"] = dcwa.Etag + if mdc.Etag != nil { + objectMap["etag"] = mdc.Etag } - if dcwa.Kind != "" { - objectMap["kind"] = dcwa.Kind + if mdc.Kind != "" { + objectMap["kind"] = mdc.Kind } return json.Marshal(objectMap) } -// AsOfficeDataConnector is the BasicDataConnector implementation for DataConnectorWithAlerts. -func (dcwa DataConnectorWithAlerts) AsOfficeDataConnector() (*OfficeDataConnector, bool) { - return nil, false -} - -// AsTIDataConnector is the BasicDataConnector implementation for DataConnectorWithAlerts. -func (dcwa DataConnectorWithAlerts) AsTIDataConnector() (*TIDataConnector, bool) { +// AsOfficeDataConnector is the BasicDataConnector implementation for MCASDataConnector. +func (mdc MCASDataConnector) AsOfficeDataConnector() (*OfficeDataConnector, bool) { return nil, false } -// AsAADDataConnector is the BasicDataConnector implementation for DataConnectorWithAlerts. -func (dcwa DataConnectorWithAlerts) AsAADDataConnector() (*AADDataConnector, bool) { +// AsTIDataConnector is the BasicDataConnector implementation for MCASDataConnector. +func (mdc MCASDataConnector) AsTIDataConnector() (*TIDataConnector, bool) { return nil, false } -// AsASCDataConnector is the BasicDataConnector implementation for DataConnectorWithAlerts. -func (dcwa DataConnectorWithAlerts) AsASCDataConnector() (*ASCDataConnector, bool) { +// AsAADDataConnector is the BasicDataConnector implementation for MCASDataConnector. +func (mdc MCASDataConnector) AsAADDataConnector() (*AADDataConnector, bool) { return nil, false } -// AsMCASDataConnector is the BasicDataConnector implementation for DataConnectorWithAlerts. -func (dcwa DataConnectorWithAlerts) AsMCASDataConnector() (*MCASDataConnector, bool) { +// AsASCDataConnector is the BasicDataConnector implementation for MCASDataConnector. +func (mdc MCASDataConnector) AsASCDataConnector() (*ASCDataConnector, bool) { return nil, false } -// AsDataConnectorWithAlerts is the BasicDataConnector implementation for DataConnectorWithAlerts. -func (dcwa DataConnectorWithAlerts) AsDataConnectorWithAlerts() (*DataConnectorWithAlerts, bool) { - return &dcwa, true -} - -// AsBasicDataConnectorWithAlerts is the BasicDataConnector implementation for DataConnectorWithAlerts. -func (dcwa DataConnectorWithAlerts) AsBasicDataConnectorWithAlerts() (BasicDataConnectorWithAlerts, bool) { - return &dcwa, true +// AsMCASDataConnector is the BasicDataConnector implementation for MCASDataConnector. +func (mdc MCASDataConnector) AsMCASDataConnector() (*MCASDataConnector, bool) { + return &mdc, true } -// AsDataConnector is the BasicDataConnector implementation for DataConnectorWithAlerts. -func (dcwa DataConnectorWithAlerts) AsDataConnector() (*DataConnector, bool) { +// AsDataConnector is the BasicDataConnector implementation for MCASDataConnector. +func (mdc MCASDataConnector) AsDataConnector() (*DataConnector, bool) { return nil, false } -// AsBasicDataConnector is the BasicDataConnector implementation for DataConnectorWithAlerts. -func (dcwa DataConnectorWithAlerts) AsBasicDataConnector() (BasicDataConnector, bool) { - return &dcwa, true +// AsBasicDataConnector is the BasicDataConnector implementation for MCASDataConnector. +func (mdc MCASDataConnector) AsBasicDataConnector() (BasicDataConnector, bool) { + return &mdc, true } -// UnmarshalJSON is the custom unmarshaler for DataConnectorWithAlerts struct. -func (dcwa *DataConnectorWithAlerts) UnmarshalJSON(body []byte) error { +// UnmarshalJSON is the custom unmarshaler for MCASDataConnector struct. +func (mdc *MCASDataConnector) UnmarshalJSON(body []byte) error { var m map[string]*json.RawMessage err := json.Unmarshal(body, &m) if err != nil { @@ -1197,12 +2921,12 @@ func (dcwa *DataConnectorWithAlerts) UnmarshalJSON(body []byte) error { switch k { case "properties": if v != nil { - var dataConnectorWithAlertsProperties DataConnectorWithAlertsProperties - err = json.Unmarshal(*v, &dataConnectorWithAlertsProperties) + var mCASDataConnectorProperties MCASDataConnectorProperties + err = json.Unmarshal(*v, &mCASDataConnectorProperties) if err != nil { return err } - dcwa.DataConnectorWithAlertsProperties = &dataConnectorWithAlertsProperties + mdc.MCASDataConnectorProperties = &mCASDataConnectorProperties } case "id": if v != nil { @@ -1211,7 +2935,7 @@ func (dcwa *DataConnectorWithAlerts) UnmarshalJSON(body []byte) error { if err != nil { return err } - dcwa.ID = &ID + mdc.ID = &ID } case "type": if v != nil { @@ -1220,7 +2944,7 @@ func (dcwa *DataConnectorWithAlerts) UnmarshalJSON(body []byte) error { if err != nil { return err } - dcwa.Type = &typeVar + mdc.Type = &typeVar } case "name": if v != nil { @@ -1229,7 +2953,7 @@ func (dcwa *DataConnectorWithAlerts) UnmarshalJSON(body []byte) error { if err != nil { return err } - dcwa.Name = &name + mdc.Name = &name } case "etag": if v != nil { @@ -1238,7 +2962,7 @@ func (dcwa *DataConnectorWithAlerts) UnmarshalJSON(body []byte) error { if err != nil { return err } - dcwa.Etag = &etag + mdc.Etag = &etag } case "kind": if v != nil { @@ -1247,7 +2971,7 @@ func (dcwa *DataConnectorWithAlerts) UnmarshalJSON(body []byte) error { if err != nil { return err } - dcwa.Kind = kind + mdc.Kind = kind } } } @@ -1255,98 +2979,248 @@ func (dcwa *DataConnectorWithAlerts) UnmarshalJSON(body []byte) error { return nil } -// DataConnectorWithAlertsProperties data connector properties. -type DataConnectorWithAlertsProperties struct { +// MCASDataConnectorProperties MCAS (Microsoft Cloud App Security) data connector properties. +type MCASDataConnectorProperties struct { + // TenantID - The tenant id to connect to, and get the data from. + TenantID *string `json:"tenantId,omitempty"` // DataTypes - The available data types for the connector. DataTypes *AlertsDataTypeOfDataConnector `json:"dataTypes,omitempty"` - // ContextID - The context id of the origin data source (Like tenantID, SubscriptionID etc.). - ContextID *string `json:"contextId,omitempty"` } -// MCASDataConnector represents MCAS (Microsoft Cloud App Security) data connector. -type MCASDataConnector struct { - // DataConnectorWithAlertsProperties - Data connector properties. - *DataConnectorWithAlertsProperties `json:"properties,omitempty"` +// OfficeConsent consent for Office365 tenant that already made. +type OfficeConsent struct { + autorest.Response `json:"-"` + // OfficeConsentProperties - Office consent properties + *OfficeConsentProperties `json:"properties,omitempty"` // ID - Azure resource Id ID *string `json:"id,omitempty"` // Type - Azure resource type Type *string `json:"type,omitempty"` // Name - Azure resource name Name *string `json:"name,omitempty"` - // Etag - Etag of the data connector. - Etag *string `json:"etag,omitempty"` - // Kind - Possible values include: 'KindDataConnector', 'KindOffice365', 'KindThreatIntelligence', 'KindAzureActiveDirectory', 'KindAzureSecurityCenter', 'KindMicrosoftCloudAppSecurity', 'KindDataConnectorWithAlerts' - Kind KindBasicDataConnector `json:"kind,omitempty"` } -// MarshalJSON is the custom marshaler for MCASDataConnector. -func (mdc MCASDataConnector) MarshalJSON() ([]byte, error) { - mdc.Kind = KindMicrosoftCloudAppSecurity +// MarshalJSON is the custom marshaler for OfficeConsent. +func (oc OfficeConsent) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if mdc.DataConnectorWithAlertsProperties != nil { - objectMap["properties"] = mdc.DataConnectorWithAlertsProperties + if oc.OfficeConsentProperties != nil { + objectMap["properties"] = oc.OfficeConsentProperties } - if mdc.ID != nil { - objectMap["id"] = mdc.ID + if oc.ID != nil { + objectMap["id"] = oc.ID } - if mdc.Type != nil { - objectMap["type"] = mdc.Type + if oc.Type != nil { + objectMap["type"] = oc.Type } - if mdc.Name != nil { - objectMap["name"] = mdc.Name + if oc.Name != nil { + objectMap["name"] = oc.Name } - if mdc.Etag != nil { - objectMap["etag"] = mdc.Etag + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for OfficeConsent struct. +func (oc *OfficeConsent) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err } - if mdc.Kind != "" { - objectMap["kind"] = mdc.Kind + for k, v := range m { + switch k { + case "properties": + if v != nil { + var officeConsentProperties OfficeConsentProperties + err = json.Unmarshal(*v, &officeConsentProperties) + if err != nil { + return err + } + oc.OfficeConsentProperties = &officeConsentProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + oc.ID = &ID + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + oc.Type = &typeVar + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + oc.Name = &name + } + } } - return json.Marshal(objectMap) + + return nil } -// AsOfficeDataConnector is the BasicDataConnector implementation for MCASDataConnector. -func (mdc MCASDataConnector) AsOfficeDataConnector() (*OfficeDataConnector, bool) { - return nil, false +// OfficeConsentList list of all the office365 consents. +type OfficeConsentList struct { + autorest.Response `json:"-"` + // NextLink - URL to fetch the next set of office consents. + NextLink *string `json:"nextLink,omitempty"` + // Value - Array of the consents. + Value *[]OfficeConsent `json:"value,omitempty"` } -// AsTIDataConnector is the BasicDataConnector implementation for MCASDataConnector. -func (mdc MCASDataConnector) AsTIDataConnector() (*TIDataConnector, bool) { - return nil, false +// OfficeConsentListIterator provides access to a complete listing of OfficeConsent values. +type OfficeConsentListIterator struct { + i int + page OfficeConsentListPage } -// AsAADDataConnector is the BasicDataConnector implementation for MCASDataConnector. -func (mdc MCASDataConnector) AsAADDataConnector() (*AADDataConnector, bool) { - return nil, false +// 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 *OfficeConsentListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OfficeConsentListIterator.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 } -// AsASCDataConnector is the BasicDataConnector implementation for MCASDataConnector. -func (mdc MCASDataConnector) AsASCDataConnector() (*ASCDataConnector, bool) { - return nil, false +// 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 *OfficeConsentListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OfficeConsentListIterator) 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 OfficeConsentListIterator) Response() OfficeConsentList { + 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 OfficeConsentListIterator) Value() OfficeConsent { + if !iter.page.NotDone() { + return OfficeConsent{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OfficeConsentListIterator type. +func NewOfficeConsentListIterator(page OfficeConsentListPage) OfficeConsentListIterator { + return OfficeConsentListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ocl OfficeConsentList) IsEmpty() bool { + return ocl.Value == nil || len(*ocl.Value) == 0 +} + +// officeConsentListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ocl OfficeConsentList) officeConsentListPreparer(ctx context.Context) (*http.Request, error) { + if ocl.NextLink == nil || len(to.String(ocl.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ocl.NextLink))) +} + +// OfficeConsentListPage contains a page of OfficeConsent values. +type OfficeConsentListPage struct { + fn func(context.Context, OfficeConsentList) (OfficeConsentList, error) + ocl OfficeConsentList +} + +// 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 *OfficeConsentListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OfficeConsentListPage.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.ocl) + if err != nil { + return err + } + page.ocl = 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 *OfficeConsentListPage) Next() error { + return page.NextWithContext(context.Background()) } -// AsMCASDataConnector is the BasicDataConnector implementation for MCASDataConnector. -func (mdc MCASDataConnector) AsMCASDataConnector() (*MCASDataConnector, bool) { - return &mdc, true +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OfficeConsentListPage) NotDone() bool { + return !page.ocl.IsEmpty() } -// AsDataConnectorWithAlerts is the BasicDataConnector implementation for MCASDataConnector. -func (mdc MCASDataConnector) AsDataConnectorWithAlerts() (*DataConnectorWithAlerts, bool) { - return nil, false +// Response returns the raw server response from the last page request. +func (page OfficeConsentListPage) Response() OfficeConsentList { + return page.ocl } -// AsBasicDataConnectorWithAlerts is the BasicDataConnector implementation for MCASDataConnector. -func (mdc MCASDataConnector) AsBasicDataConnectorWithAlerts() (BasicDataConnectorWithAlerts, bool) { - return &mdc, true +// Values returns the slice of values for the current page or nil if there are no values. +func (page OfficeConsentListPage) Values() []OfficeConsent { + if page.ocl.IsEmpty() { + return nil + } + return *page.ocl.Value } -// AsDataConnector is the BasicDataConnector implementation for MCASDataConnector. -func (mdc MCASDataConnector) AsDataConnector() (*DataConnector, bool) { - return nil, false +// Creates a new instance of the OfficeConsentListPage type. +func NewOfficeConsentListPage(getNextPage func(context.Context, OfficeConsentList) (OfficeConsentList, error)) OfficeConsentListPage { + return OfficeConsentListPage{fn: getNextPage} } -// AsBasicDataConnector is the BasicDataConnector implementation for MCASDataConnector. -func (mdc MCASDataConnector) AsBasicDataConnector() (BasicDataConnector, bool) { - return &mdc, true +// OfficeConsentProperties consent property bag. +type OfficeConsentProperties struct { + // TenantID - The tenantId of the Office365 with the consent. + TenantID *string `json:"tenantId,omitempty"` + // TenantName - The tenant name of the Office365 with the consent. + TenantName *string `json:"tenantName,omitempty"` } // OfficeDataConnector represents office data connector. @@ -1361,7 +3235,7 @@ type OfficeDataConnector struct { Name *string `json:"name,omitempty"` // Etag - Etag of the data connector. Etag *string `json:"etag,omitempty"` - // Kind - Possible values include: 'KindDataConnector', 'KindOffice365', 'KindThreatIntelligence', 'KindAzureActiveDirectory', 'KindAzureSecurityCenter', 'KindMicrosoftCloudAppSecurity', 'KindDataConnectorWithAlerts' + // Kind - Possible values include: 'KindDataConnector', 'KindOffice365', 'KindThreatIntelligence', 'KindAzureActiveDirectory', 'KindAzureSecurityCenter', 'KindMicrosoftCloudAppSecurity' Kind KindBasicDataConnector `json:"kind,omitempty"` } @@ -1415,16 +3289,6 @@ func (odc OfficeDataConnector) AsMCASDataConnector() (*MCASDataConnector, bool) return nil, false } -// AsDataConnectorWithAlerts is the BasicDataConnector implementation for OfficeDataConnector. -func (odc OfficeDataConnector) AsDataConnectorWithAlerts() (*DataConnectorWithAlerts, bool) { - return nil, false -} - -// AsBasicDataConnectorWithAlerts is the BasicDataConnector implementation for OfficeDataConnector. -func (odc OfficeDataConnector) AsBasicDataConnectorWithAlerts() (BasicDataConnectorWithAlerts, bool) { - return nil, false -} - // AsDataConnector is the BasicDataConnector implementation for OfficeDataConnector. func (odc OfficeDataConnector) AsDataConnector() (*DataConnector, bool) { return nil, false @@ -1528,8 +3392,8 @@ type OfficeDataConnectorDataTypesSharePoint struct { type OfficeDataConnectorProperties struct { // DataTypes - The available data types for the connector. DataTypes *OfficeDataConnectorDataTypes `json:"dataTypes,omitempty"` - // ContextID - The context id of the origin data source (Like tenantID, SubscriptionID etc.). - ContextID *string `json:"contextId,omitempty"` + // TenantID - The tenant id to connect to, and get the data from. + TenantID *string `json:"tenantId,omitempty"` } // Operation operation provided by provider @@ -1835,12 +3699,12 @@ func (sar *ScheduledAlertRule) UnmarshalJSON(body []byte) error { // ScheduledAlertRuleProperties alert rule property bag. type ScheduledAlertRuleProperties struct { - // RuleName - The name for alerts created by this alert rule. - RuleName *string `json:"ruleName,omitempty"` + // DisplayName - The display name for alerts created by this alert rule. + DisplayName *string `json:"displayName,omitempty"` // Description - The description of the alert rule. Description *string `json:"description,omitempty"` - // Severity - The severity for alerts created by this alert rule. Possible values include: 'Low', 'Medium', 'High', 'Informational' - Severity Severity `json:"severity,omitempty"` + // Severity - The severity for alerts created by this alert rule. Possible values include: 'High', 'Medium', 'Low', 'Informational' + Severity AlertSeverity `json:"severity,omitempty"` // Enabled - Determines whether this alert rule is enabled or disabled. Enabled *bool `json:"enabled,omitempty"` // Query - The query that creates alerts for this rule. @@ -1861,9 +3725,132 @@ type ScheduledAlertRuleProperties struct { LastModifiedUtc *string `json:"lastModifiedUtc,omitempty"` } +// BasicSettings the Setting. +type BasicSettings interface { + AsUebaSettings() (*UebaSettings, bool) + AsToggleSettings() (*ToggleSettings, bool) + AsSettings() (*Settings, bool) +} + +// Settings the Setting. +type Settings struct { + autorest.Response `json:"-"` + // ID - Azure resource Id + ID *string `json:"id,omitempty"` + // Type - Azure resource type + Type *string `json:"type,omitempty"` + // Name - Azure resource name + Name *string `json:"name,omitempty"` + // Kind - Possible values include: 'KindSettings', 'KindUebaSettings', 'KindToggleSettings' + Kind KindBasicSettings `json:"kind,omitempty"` +} + +func unmarshalBasicSettings(body []byte) (BasicSettings, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["kind"] { + case string(KindUebaSettings): + var us UebaSettings + err := json.Unmarshal(body, &us) + return us, err + case string(KindToggleSettings): + var ts ToggleSettings + err := json.Unmarshal(body, &ts) + return ts, err + default: + var s Settings + err := json.Unmarshal(body, &s) + return s, err + } +} +func unmarshalBasicSettingsArray(body []byte) ([]BasicSettings, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + sArray := make([]BasicSettings, len(rawMessages)) + + for index, rawMessage := range rawMessages { + s, err := unmarshalBasicSettings(*rawMessage) + if err != nil { + return nil, err + } + sArray[index] = s + } + return sArray, nil +} + +// MarshalJSON is the custom marshaler for Settings. +func (s Settings) MarshalJSON() ([]byte, error) { + s.Kind = KindSettings + objectMap := make(map[string]interface{}) + if s.ID != nil { + objectMap["id"] = s.ID + } + if s.Type != nil { + objectMap["type"] = s.Type + } + if s.Name != nil { + objectMap["name"] = s.Name + } + if s.Kind != "" { + objectMap["kind"] = s.Kind + } + return json.Marshal(objectMap) +} + +// AsUebaSettings is the BasicSettings implementation for Settings. +func (s Settings) AsUebaSettings() (*UebaSettings, bool) { + return nil, false +} + +// AsToggleSettings is the BasicSettings implementation for Settings. +func (s Settings) AsToggleSettings() (*ToggleSettings, bool) { + return nil, false +} + +// AsSettings is the BasicSettings implementation for Settings. +func (s Settings) AsSettings() (*Settings, bool) { + return &s, true +} + +// AsBasicSettings is the BasicSettings implementation for Settings. +func (s Settings) AsBasicSettings() (BasicSettings, bool) { + return &s, true +} + +// SettingsKind describes an Azure resource with kind. +type SettingsKind struct { + // Kind - The kind of the setting. Possible values include: 'SettingKindUebaSettings', 'SettingKindToggleSettings' + Kind SettingKind `json:"kind,omitempty"` +} + +// SettingsModel ... +type SettingsModel struct { + autorest.Response `json:"-"` + Value BasicSettings `json:"value,omitempty"` +} + +// UnmarshalJSON is the custom unmarshaler for SettingsModel struct. +func (sm *SettingsModel) UnmarshalJSON(body []byte) error { + s, err := unmarshalBasicSettings(body) + if err != nil { + return err + } + sm.Value = s + + return nil +} + // TIDataConnector represents threat intelligence data connector. type TIDataConnector struct { - // TIDataConnectorProperties - TI data connector properties. + // TIDataConnectorProperties - TI (Threat Intelligence) data connector properties. *TIDataConnectorProperties `json:"properties,omitempty"` // ID - Azure resource Id ID *string `json:"id,omitempty"` @@ -1873,7 +3860,7 @@ type TIDataConnector struct { Name *string `json:"name,omitempty"` // Etag - Etag of the data connector. Etag *string `json:"etag,omitempty"` - // Kind - Possible values include: 'KindDataConnector', 'KindOffice365', 'KindThreatIntelligence', 'KindAzureActiveDirectory', 'KindAzureSecurityCenter', 'KindMicrosoftCloudAppSecurity', 'KindDataConnectorWithAlerts' + // Kind - Possible values include: 'KindDataConnector', 'KindOffice365', 'KindThreatIntelligence', 'KindAzureActiveDirectory', 'KindAzureSecurityCenter', 'KindMicrosoftCloudAppSecurity' Kind KindBasicDataConnector `json:"kind,omitempty"` } @@ -1927,16 +3914,6 @@ func (tdc TIDataConnector) AsMCASDataConnector() (*MCASDataConnector, bool) { return nil, false } -// AsDataConnectorWithAlerts is the BasicDataConnector implementation for TIDataConnector. -func (tdc TIDataConnector) AsDataConnectorWithAlerts() (*DataConnectorWithAlerts, bool) { - return nil, false -} - -// AsBasicDataConnectorWithAlerts is the BasicDataConnector implementation for TIDataConnector. -func (tdc TIDataConnector) AsBasicDataConnectorWithAlerts() (BasicDataConnectorWithAlerts, bool) { - return nil, false -} - // AsDataConnector is the BasicDataConnector implementation for TIDataConnector. func (tdc TIDataConnector) AsDataConnector() (*DataConnector, bool) { return nil, false @@ -2016,7 +3993,7 @@ func (tdc *TIDataConnector) UnmarshalJSON(body []byte) error { return nil } -// TIDataConnectorDataTypes the available data types for TI data connector. +// TIDataConnectorDataTypes the available data types for TI (Threat Intelligence) data connector. type TIDataConnectorDataTypes struct { // Indicators - Data type for indicators connection. Indicators *TIDataConnectorDataTypesIndicators `json:"indicators,omitempty"` @@ -2028,10 +4005,268 @@ type TIDataConnectorDataTypesIndicators struct { State DataTypeState `json:"state,omitempty"` } -// TIDataConnectorProperties TI data connector properties. +// TIDataConnectorProperties TI (Threat Intelligence) data connector properties. type TIDataConnectorProperties struct { // DataTypes - The available data types for the connector. DataTypes *TIDataConnectorDataTypes `json:"dataTypes,omitempty"` - // ContextID - The context id of the origin data source (Like tenantID, SubscriptionID etc.). - ContextID *string `json:"contextId,omitempty"` + // TenantID - The tenant id to connect to, and get the data from. + TenantID *string `json:"tenantId,omitempty"` +} + +// ToggleSettings settings with single toggle. +type ToggleSettings struct { + // ToggleSettingsProperties - toggle properties + *ToggleSettingsProperties `json:"properties,omitempty"` + // ID - Azure resource Id + ID *string `json:"id,omitempty"` + // Type - Azure resource type + Type *string `json:"type,omitempty"` + // Name - Azure resource name + Name *string `json:"name,omitempty"` + // Kind - Possible values include: 'KindSettings', 'KindUebaSettings', 'KindToggleSettings' + Kind KindBasicSettings `json:"kind,omitempty"` +} + +// MarshalJSON is the custom marshaler for ToggleSettings. +func (ts ToggleSettings) MarshalJSON() ([]byte, error) { + ts.Kind = KindToggleSettings + objectMap := make(map[string]interface{}) + if ts.ToggleSettingsProperties != nil { + objectMap["properties"] = ts.ToggleSettingsProperties + } + if ts.ID != nil { + objectMap["id"] = ts.ID + } + if ts.Type != nil { + objectMap["type"] = ts.Type + } + if ts.Name != nil { + objectMap["name"] = ts.Name + } + if ts.Kind != "" { + objectMap["kind"] = ts.Kind + } + return json.Marshal(objectMap) +} + +// AsUebaSettings is the BasicSettings implementation for ToggleSettings. +func (ts ToggleSettings) AsUebaSettings() (*UebaSettings, bool) { + return nil, false +} + +// AsToggleSettings is the BasicSettings implementation for ToggleSettings. +func (ts ToggleSettings) AsToggleSettings() (*ToggleSettings, bool) { + return &ts, true +} + +// AsSettings is the BasicSettings implementation for ToggleSettings. +func (ts ToggleSettings) AsSettings() (*Settings, bool) { + return nil, false +} + +// AsBasicSettings is the BasicSettings implementation for ToggleSettings. +func (ts ToggleSettings) AsBasicSettings() (BasicSettings, bool) { + return &ts, true +} + +// UnmarshalJSON is the custom unmarshaler for ToggleSettings struct. +func (ts *ToggleSettings) 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 toggleSettingsProperties ToggleSettingsProperties + err = json.Unmarshal(*v, &toggleSettingsProperties) + if err != nil { + return err + } + ts.ToggleSettingsProperties = &toggleSettingsProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ts.ID = &ID + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ts.Type = &typeVar + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ts.Name = &name + } + case "kind": + if v != nil { + var kind KindBasicSettings + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + ts.Kind = kind + } + } + } + + return nil +} + +// ToggleSettingsProperties toggle property bag. +type ToggleSettingsProperties struct { + // IsEnabled - Determines whether the setting is enable or disabled. + IsEnabled *bool `json:"isEnabled,omitempty"` +} + +// UebaSettings represents settings for User and Entity Behavior Analytics enablement. +type UebaSettings struct { + // UebaSettingsProperties - User and Entity Behavior Analytics settings properties + *UebaSettingsProperties `json:"properties,omitempty"` + // ID - Azure resource Id + ID *string `json:"id,omitempty"` + // Type - Azure resource type + Type *string `json:"type,omitempty"` + // Name - Azure resource name + Name *string `json:"name,omitempty"` + // Kind - Possible values include: 'KindSettings', 'KindUebaSettings', 'KindToggleSettings' + Kind KindBasicSettings `json:"kind,omitempty"` +} + +// MarshalJSON is the custom marshaler for UebaSettings. +func (us UebaSettings) MarshalJSON() ([]byte, error) { + us.Kind = KindUebaSettings + objectMap := make(map[string]interface{}) + if us.UebaSettingsProperties != nil { + objectMap["properties"] = us.UebaSettingsProperties + } + if us.ID != nil { + objectMap["id"] = us.ID + } + if us.Type != nil { + objectMap["type"] = us.Type + } + if us.Name != nil { + objectMap["name"] = us.Name + } + if us.Kind != "" { + objectMap["kind"] = us.Kind + } + return json.Marshal(objectMap) +} + +// AsUebaSettings is the BasicSettings implementation for UebaSettings. +func (us UebaSettings) AsUebaSettings() (*UebaSettings, bool) { + return &us, true +} + +// AsToggleSettings is the BasicSettings implementation for UebaSettings. +func (us UebaSettings) AsToggleSettings() (*ToggleSettings, bool) { + return nil, false +} + +// AsSettings is the BasicSettings implementation for UebaSettings. +func (us UebaSettings) AsSettings() (*Settings, bool) { + return nil, false +} + +// AsBasicSettings is the BasicSettings implementation for UebaSettings. +func (us UebaSettings) AsBasicSettings() (BasicSettings, bool) { + return &us, true +} + +// UnmarshalJSON is the custom unmarshaler for UebaSettings struct. +func (us *UebaSettings) 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 uebaSettingsProperties UebaSettingsProperties + err = json.Unmarshal(*v, &uebaSettingsProperties) + if err != nil { + return err + } + us.UebaSettingsProperties = &uebaSettingsProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + us.ID = &ID + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + us.Type = &typeVar + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + us.Name = &name + } + case "kind": + if v != nil { + var kind KindBasicSettings + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + us.Kind = kind + } + } + } + + return nil +} + +// UebaSettingsProperties user and Entity Behavior Analytics settings property bag. +type UebaSettingsProperties struct { + // IsEnabled - Determines whether User and Entity Behavior Analytics is enabled for this workspace. + IsEnabled *bool `json:"isEnabled,omitempty"` + // StatusInMcas - Determines whether User and Entity Behavior Analytics is enabled from MCAS (Microsoft Cloud App Security). Possible values include: 'StatusInMcasEnabled', 'StatusInMcasDisabled' + StatusInMcas StatusInMcas `json:"statusInMcas,omitempty"` + // AtpLicenseStatus - Determines whether the tenant has ATP (Advanced Threat Protection) license. + AtpLicenseStatus *bool `json:"atpLicenseStatus,omitempty"` +} + +// UserInfo user information that made some action +type UserInfo struct { + // ObjectID - The object id of the user. + ObjectID *uuid.UUID `json:"objectId,omitempty"` + // Email - The email of the user. + Email *string `json:"email,omitempty"` + // Name - The name of the user. + Name *string `json:"name,omitempty"` } diff --git a/services/preview/securityinsight/mgmt/2017-08-01-preview/securityinsight/officeconsents.go b/services/preview/securityinsight/mgmt/2017-08-01-preview/securityinsight/officeconsents.go new file mode 100644 index 000000000000..307417da98d6 --- /dev/null +++ b/services/preview/securityinsight/mgmt/2017-08-01-preview/securityinsight/officeconsents.go @@ -0,0 +1,365 @@ +package securityinsight + +// 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" +) + +// OfficeConsentsClient is the API spec for Microsoft.SecurityInsights (Azure Security Insights) resource provider +type OfficeConsentsClient struct { + BaseClient +} + +// NewOfficeConsentsClient creates an instance of the OfficeConsentsClient client. +func NewOfficeConsentsClient(subscriptionID string) OfficeConsentsClient { + return NewOfficeConsentsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOfficeConsentsClientWithBaseURI creates an instance of the OfficeConsentsClient client. +func NewOfficeConsentsClientWithBaseURI(baseURI string, subscriptionID string) OfficeConsentsClient { + return OfficeConsentsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Delete delete the office365 consent. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// operationalInsightsResourceProvider - the namespace of workspaces resource provider- +// Microsoft.OperationalInsights. +// workspaceName - the name of the workspace. +// consentID - consent ID +func (client OfficeConsentsClient) Delete(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, consentID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OfficeConsentsClient.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}}}, + {TargetValue: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("securityinsight.OfficeConsentsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, operationalInsightsResourceProvider, workspaceName, consentID) + if err != nil { + err = autorest.NewErrorWithError(err, "securityinsight.OfficeConsentsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "securityinsight.OfficeConsentsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "securityinsight.OfficeConsentsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client OfficeConsentsClient) DeletePreparer(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, consentID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "consentId": autorest.Encode("path", consentID), + "operationalInsightsResourceProvider": autorest.Encode("path", operationalInsightsResourceProvider), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2019-01-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/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/officeConsents/{consentId}", 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 OfficeConsentsClient) 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 OfficeConsentsClient) 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 gets an office365 consent. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// operationalInsightsResourceProvider - the namespace of workspaces resource provider- +// Microsoft.OperationalInsights. +// workspaceName - the name of the workspace. +// consentID - consent ID +func (client OfficeConsentsClient) Get(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, consentID string) (result OfficeConsent, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OfficeConsentsClient.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}}}, + {TargetValue: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("securityinsight.OfficeConsentsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, operationalInsightsResourceProvider, workspaceName, consentID) + if err != nil { + err = autorest.NewErrorWithError(err, "securityinsight.OfficeConsentsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "securityinsight.OfficeConsentsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "securityinsight.OfficeConsentsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client OfficeConsentsClient) GetPreparer(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, consentID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "consentId": autorest.Encode("path", consentID), + "operationalInsightsResourceProvider": autorest.Encode("path", operationalInsightsResourceProvider), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + 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}/resourceGroups/{resourceGroupName}/providers/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/officeConsents/{consentId}", 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 OfficeConsentsClient) 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 OfficeConsentsClient) GetResponder(resp *http.Response) (result OfficeConsent, 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 gets all office365 consents. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// operationalInsightsResourceProvider - the namespace of workspaces resource provider- +// Microsoft.OperationalInsights. +// workspaceName - the name of the workspace. +func (client OfficeConsentsClient) List(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string) (result OfficeConsentListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OfficeConsentsClient.List") + defer func() { + sc := -1 + if result.ocl.Response.Response != nil { + sc = result.ocl.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: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("securityinsight.OfficeConsentsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, operationalInsightsResourceProvider, workspaceName) + if err != nil { + err = autorest.NewErrorWithError(err, "securityinsight.OfficeConsentsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.ocl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "securityinsight.OfficeConsentsClient", "List", resp, "Failure sending request") + return + } + + result.ocl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "securityinsight.OfficeConsentsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client OfficeConsentsClient) ListPreparer(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "operationalInsightsResourceProvider": autorest.Encode("path", operationalInsightsResourceProvider), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + 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}/resourceGroups/{resourceGroupName}/providers/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/officeConsents", 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 OfficeConsentsClient) 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 OfficeConsentsClient) ListResponder(resp *http.Response) (result OfficeConsentList, 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 OfficeConsentsClient) listNextResults(ctx context.Context, lastResults OfficeConsentList) (result OfficeConsentList, err error) { + req, err := lastResults.officeConsentListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "securityinsight.OfficeConsentsClient", "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, "securityinsight.OfficeConsentsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "securityinsight.OfficeConsentsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OfficeConsentsClient) ListComplete(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string) (result OfficeConsentListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OfficeConsentsClient.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, operationalInsightsResourceProvider, workspaceName) + return +} diff --git a/services/preview/securityinsight/mgmt/2017-08-01-preview/securityinsight/productsettings.go b/services/preview/securityinsight/mgmt/2017-08-01-preview/securityinsight/productsettings.go new file mode 100644 index 000000000000..aab625ec53e5 --- /dev/null +++ b/services/preview/securityinsight/mgmt/2017-08-01-preview/securityinsight/productsettings.go @@ -0,0 +1,237 @@ +package securityinsight + +// 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" +) + +// ProductSettingsClient is the API spec for Microsoft.SecurityInsights (Azure Security Insights) resource provider +type ProductSettingsClient struct { + BaseClient +} + +// NewProductSettingsClient creates an instance of the ProductSettingsClient client. +func NewProductSettingsClient(subscriptionID string) ProductSettingsClient { + return NewProductSettingsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewProductSettingsClientWithBaseURI creates an instance of the ProductSettingsClient client. +func NewProductSettingsClientWithBaseURI(baseURI string, subscriptionID string) ProductSettingsClient { + return ProductSettingsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a setting. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// operationalInsightsResourceProvider - the namespace of workspaces resource provider- +// Microsoft.OperationalInsights. +// workspaceName - the name of the workspace. +// settingsName - the setting name. Supports- Fusion, UEBA +func (client ProductSettingsClient) Get(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, settingsName string) (result SettingsModel, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductSettingsClient.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}}}, + {TargetValue: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("securityinsight.ProductSettingsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, operationalInsightsResourceProvider, workspaceName, settingsName) + if err != nil { + err = autorest.NewErrorWithError(err, "securityinsight.ProductSettingsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "securityinsight.ProductSettingsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "securityinsight.ProductSettingsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ProductSettingsClient) GetPreparer(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, settingsName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "operationalInsightsResourceProvider": autorest.Encode("path", operationalInsightsResourceProvider), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "settingsName": autorest.Encode("path", settingsName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + 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}/resourceGroups/{resourceGroupName}/providers/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/settings/{settingsName}", 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 ProductSettingsClient) 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 ProductSettingsClient) GetResponder(resp *http.Response) (result SettingsModel, 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 updates the setting. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// operationalInsightsResourceProvider - the namespace of workspaces resource provider- +// Microsoft.OperationalInsights. +// workspaceName - the name of the workspace. +// settingsName - the setting name. Supports- Fusion, UEBA +// settings - the setting +func (client ProductSettingsClient) Update(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, settingsName string, settings BasicSettings) (result SettingsModel, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductSettingsClient.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}}}, + {TargetValue: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("securityinsight.ProductSettingsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, operationalInsightsResourceProvider, workspaceName, settingsName, settings) + if err != nil { + err = autorest.NewErrorWithError(err, "securityinsight.ProductSettingsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "securityinsight.ProductSettingsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "securityinsight.ProductSettingsClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ProductSettingsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, settingsName string, settings BasicSettings) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "operationalInsightsResourceProvider": autorest.Encode("path", operationalInsightsResourceProvider), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "settingsName": autorest.Encode("path", settingsName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + 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("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/settings/{settingsName}", pathParameters), + autorest.WithJSON(settings), + 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 ProductSettingsClient) 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 ProductSettingsClient) UpdateResponder(resp *http.Response) (result SettingsModel, 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/securityinsight/mgmt/2017-08-01-preview/securityinsight/securityinsightapi/interfaces.go b/services/preview/securityinsight/mgmt/2017-08-01-preview/securityinsight/securityinsightapi/interfaces.go index 5ef3fcdbfb99..6cfbd897f7e2 100644 --- a/services/preview/securityinsight/mgmt/2017-08-01-preview/securityinsight/securityinsightapi/interfaces.go +++ b/services/preview/securityinsight/mgmt/2017-08-01-preview/securityinsight/securityinsightapi/interfaces.go @@ -32,20 +32,75 @@ var _ OperationsClientAPI = (*securityinsight.OperationsClient)(nil) // AlertRulesClientAPI contains the set of methods on the AlertRulesClient type. type AlertRulesClientAPI interface { - Create(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, ruleID string, alertRule securityinsight.BasicAlertRule) (result securityinsight.AlertRuleModel, err error) + CreateOrUpdate(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, ruleID string, alertRule securityinsight.BasicAlertRule) (result securityinsight.AlertRuleModel, err error) + CreateOrUpdateAction(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, ruleID string, actionID string, action securityinsight.Action) (result securityinsight.Action, err error) Delete(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, ruleID string) (result autorest.Response, err error) + DeleteAction(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, ruleID string, actionID string) (result autorest.Response, err error) Get(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, ruleID string) (result securityinsight.AlertRuleModel, err error) + GetAction(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, ruleID string, actionID string) (result securityinsight.Action, err error) List(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string) (result securityinsight.AlertRulesListPage, err error) } var _ AlertRulesClientAPI = (*securityinsight.AlertRulesClient)(nil) +// ActionsClientAPI contains the set of methods on the ActionsClient type. +type ActionsClientAPI interface { + ListByAlertRule(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, ruleID string) (result securityinsight.ActionsListPage, err error) +} + +var _ ActionsClientAPI = (*securityinsight.ActionsClient)(nil) + +// CasesClientAPI contains the set of methods on the CasesClient type. +type CasesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, caseID string, caseParameter securityinsight.Case) (result securityinsight.Case, err error) + Delete(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, caseID string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, caseID string) (result securityinsight.Case, err error) + List(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string) (result securityinsight.CaseListPage, err error) +} + +var _ CasesClientAPI = (*securityinsight.CasesClient)(nil) + +// BookmarksClientAPI contains the set of methods on the BookmarksClient type. +type BookmarksClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, bookmarkID string, bookmark securityinsight.Bookmark) (result securityinsight.Bookmark, err error) + Delete(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, bookmarkID string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, bookmarkID string) (result securityinsight.Bookmark, err error) + List(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string) (result securityinsight.BookmarkListPage, err error) +} + +var _ BookmarksClientAPI = (*securityinsight.BookmarksClient)(nil) + // DataConnectorsClientAPI contains the set of methods on the DataConnectorsClient type. type DataConnectorsClientAPI interface { - Create(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, dataConnectorID string, dataConnector securityinsight.BasicDataConnector) (result securityinsight.DataConnectorModel, err error) + CreateOrUpdate(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, dataConnectorID string, dataConnector securityinsight.BasicDataConnector) (result securityinsight.DataConnectorModel, err error) Delete(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, dataConnectorID string) (result autorest.Response, err error) Get(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, dataConnectorID string) (result securityinsight.DataConnectorModel, err error) List(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string) (result securityinsight.DataConnectorListPage, err error) } var _ DataConnectorsClientAPI = (*securityinsight.DataConnectorsClient)(nil) + +// EntitiesClientAPI contains the set of methods on the EntitiesClient type. +type EntitiesClientAPI interface { + Get(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, entityID string) (result securityinsight.EntityModel, err error) + List(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string) (result securityinsight.EntityListPage, err error) +} + +var _ EntitiesClientAPI = (*securityinsight.EntitiesClient)(nil) + +// OfficeConsentsClientAPI contains the set of methods on the OfficeConsentsClient type. +type OfficeConsentsClientAPI interface { + Delete(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, consentID string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, consentID string) (result securityinsight.OfficeConsent, err error) + List(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string) (result securityinsight.OfficeConsentListPage, err error) +} + +var _ OfficeConsentsClientAPI = (*securityinsight.OfficeConsentsClient)(nil) + +// ProductSettingsClientAPI contains the set of methods on the ProductSettingsClient type. +type ProductSettingsClientAPI interface { + Get(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, settingsName string) (result securityinsight.SettingsModel, err error) + Update(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, settingsName string, settings securityinsight.BasicSettings) (result securityinsight.SettingsModel, err error) +} + +var _ ProductSettingsClientAPI = (*securityinsight.ProductSettingsClient)(nil)