From 13b23b67fb1bfb170136877ba8f8bcfaef5a2d05 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Mon, 1 Apr 2019 13:00:33 +0000 Subject: [PATCH 1/2] Generated from f20f1d94a584bf55c225139c0991138b1c90420f Add cases aggregation endpoint to SecurityInsights RP swagger spec --- .../mgmt/securityinsight/models.go | 29 ++++ .../securityinsightapi/models.go | 1 + .../securityinsight/casesaggregations.go | 138 ++++++++++++++++++ .../securityinsight/models.go | 129 ++++++++++++++++ .../securityinsightapi/interfaces.go | 7 + 5 files changed, 304 insertions(+) create mode 100644 services/preview/securityinsight/mgmt/2017-08-01-preview/securityinsight/casesaggregations.go diff --git a/profiles/preview/preview/securityinsight/mgmt/securityinsight/models.go b/profiles/preview/preview/securityinsight/mgmt/securityinsight/models.go index f5fcaaf299ef..76762b15a8bc 100644 --- a/profiles/preview/preview/securityinsight/mgmt/securityinsight/models.go +++ b/profiles/preview/preview/securityinsight/mgmt/securityinsight/models.go @@ -29,6 +29,12 @@ const ( DefaultBaseURI = original.DefaultBaseURI ) +type AggregationsKind = original.AggregationsKind + +const ( + CasesAggregation AggregationsKind = original.CasesAggregation +) + type AlertRuleKind = original.AlertRuleKind const ( @@ -103,6 +109,12 @@ const ( KindScheduled Kind = original.KindScheduled ) +type KindBasicAggregations = original.KindBasicAggregations + +const ( + KindAggregations KindBasicAggregations = original.KindAggregations +) + type KindBasicDataConnector = original.KindBasicDataConnector const ( @@ -175,6 +187,9 @@ type ActionsClient = original.ActionsClient type ActionsList = original.ActionsList type ActionsListIterator = original.ActionsListIterator type ActionsListPage = original.ActionsListPage +type Aggregations = original.Aggregations +type AggregationsKind1 = original.AggregationsKind1 +type AggregationsModel = original.AggregationsModel type AlertRule = original.AlertRule type AlertRuleKind1 = original.AlertRuleKind1 type AlertRuleModel = original.AlertRuleModel @@ -185,6 +200,7 @@ type AlertRulesListPage = original.AlertRulesListPage type AlertsDataTypeOfDataConnector = original.AlertsDataTypeOfDataConnector type AlertsDataTypeOfDataConnectorAlerts = original.AlertsDataTypeOfDataConnectorAlerts type BaseClient = original.BaseClient +type BasicAggregations = original.BasicAggregations type BasicAlertRule = original.BasicAlertRule type BasicDataConnector = original.BasicDataConnector type BasicEntity = original.BasicEntity @@ -200,6 +216,7 @@ type CaseList = original.CaseList type CaseListIterator = original.CaseListIterator type CaseListPage = original.CaseListPage type CaseProperties = original.CaseProperties +type CasesAggregationsClient = original.CasesAggregationsClient type CasesClient = original.CasesClient type CloudError = original.CloudError type CloudErrorBody = original.CloudErrorBody @@ -305,6 +322,12 @@ func NewCaseListIterator(page CaseListPage) CaseListIterator { func NewCaseListPage(getNextPage func(context.Context, CaseList) (CaseList, error)) CaseListPage { return original.NewCaseListPage(getNextPage) } +func NewCasesAggregationsClient(subscriptionID string) CasesAggregationsClient { + return original.NewCasesAggregationsClient(subscriptionID) +} +func NewCasesAggregationsClientWithBaseURI(baseURI string, subscriptionID string) CasesAggregationsClient { + return original.NewCasesAggregationsClientWithBaseURI(baseURI, subscriptionID) +} func NewCasesClient(subscriptionID string) CasesClient { return original.NewCasesClient(subscriptionID) } @@ -368,6 +391,9 @@ func NewProductSettingsClientWithBaseURI(baseURI string, subscriptionID string) func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { return original.NewWithBaseURI(baseURI, subscriptionID) } +func PossibleAggregationsKindValues() []AggregationsKind { + return original.PossibleAggregationsKindValues() +} func PossibleAlertRuleKindValues() []AlertRuleKind { return original.PossibleAlertRuleKindValues() } @@ -392,6 +418,9 @@ func PossibleDataTypeStateValues() []DataTypeState { func PossibleEntityKindValues() []EntityKind { return original.PossibleEntityKindValues() } +func PossibleKindBasicAggregationsValues() []KindBasicAggregations { + return original.PossibleKindBasicAggregationsValues() +} func PossibleKindBasicDataConnectorValues() []KindBasicDataConnector { return original.PossibleKindBasicDataConnectorValues() } diff --git a/profiles/preview/preview/securityinsight/mgmt/securityinsight/securityinsightapi/models.go b/profiles/preview/preview/securityinsight/mgmt/securityinsight/securityinsightapi/models.go index 4108e71b917d..91ee04b3b4cf 100644 --- a/profiles/preview/preview/securityinsight/mgmt/securityinsight/securityinsightapi/models.go +++ b/profiles/preview/preview/securityinsight/mgmt/securityinsight/securityinsightapi/models.go @@ -24,6 +24,7 @@ import original "github.com/Azure/azure-sdk-for-go/services/preview/securityinsi type ActionsClientAPI = original.ActionsClientAPI type AlertRulesClientAPI = original.AlertRulesClientAPI type BookmarksClientAPI = original.BookmarksClientAPI +type CasesAggregationsClientAPI = original.CasesAggregationsClientAPI type CasesClientAPI = original.CasesClientAPI type DataConnectorsClientAPI = original.DataConnectorsClientAPI type EntitiesClientAPI = original.EntitiesClientAPI diff --git a/services/preview/securityinsight/mgmt/2017-08-01-preview/securityinsight/casesaggregations.go b/services/preview/securityinsight/mgmt/2017-08-01-preview/securityinsight/casesaggregations.go new file mode 100644 index 000000000000..d7d28e46f4d5 --- /dev/null +++ b/services/preview/securityinsight/mgmt/2017-08-01-preview/securityinsight/casesaggregations.go @@ -0,0 +1,138 @@ +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" +) + +// CasesAggregationsClient is the API spec for Microsoft.SecurityInsights (Azure Security Insights) resource provider +type CasesAggregationsClient struct { + BaseClient +} + +// NewCasesAggregationsClient creates an instance of the CasesAggregationsClient client. +func NewCasesAggregationsClient(subscriptionID string) CasesAggregationsClient { + return NewCasesAggregationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewCasesAggregationsClientWithBaseURI creates an instance of the CasesAggregationsClient client. +func NewCasesAggregationsClientWithBaseURI(baseURI string, subscriptionID string) CasesAggregationsClient { + return CasesAggregationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get get aggregative result for the given resources under the defined workspace +// 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. +// aggregationsName - the aggregation name. Supports - Cases +func (client CasesAggregationsClient) Get(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, aggregationsName string) (result AggregationsModel, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CasesAggregationsClient.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.CasesAggregationsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, operationalInsightsResourceProvider, workspaceName, aggregationsName) + if err != nil { + err = autorest.NewErrorWithError(err, "securityinsight.CasesAggregationsClient", "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.CasesAggregationsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "securityinsight.CasesAggregationsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client CasesAggregationsClient) GetPreparer(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, aggregationsName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "aggregationsName": autorest.Encode("path", aggregationsName), + "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/aggregations/{AggregationsName}", 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 CasesAggregationsClient) 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 CasesAggregationsClient) GetResponder(resp *http.Response) (result AggregationsModel, 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/models.go b/services/preview/securityinsight/mgmt/2017-08-01-preview/securityinsight/models.go index 26c8459d263a..dac49f34e0b1 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 @@ -31,6 +31,19 @@ import ( // The package's fully qualified name. const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/securityinsight/mgmt/2017-08-01-preview/securityinsight" +// AggregationsKind enumerates the values for aggregations kind. +type AggregationsKind string + +const ( + // CasesAggregation ... + CasesAggregation AggregationsKind = "CasesAggregation" +) + +// PossibleAggregationsKindValues returns an array of possible values for the AggregationsKind const type. +func PossibleAggregationsKindValues() []AggregationsKind { + return []AggregationsKind{CasesAggregation} +} + // AlertRuleKind enumerates the values for alert rule kind. type AlertRuleKind string @@ -188,6 +201,19 @@ func PossibleKindValues() []Kind { return []Kind{KindAlertRule, KindScheduled} } +// KindBasicAggregations enumerates the values for kind basic aggregations. +type KindBasicAggregations string + +const ( + // KindAggregations ... + KindAggregations KindBasicAggregations = "Aggregations" +) + +// PossibleKindBasicAggregationsValues returns an array of possible values for the KindBasicAggregations const type. +func PossibleKindBasicAggregationsValues() []KindBasicAggregations { + return []KindBasicAggregations{KindAggregations} +} + // KindBasicDataConnector enumerates the values for kind basic data connector. type KindBasicDataConnector string @@ -859,6 +885,109 @@ func NewActionsListPage(getNextPage func(context.Context, ActionsList) (ActionsL return ActionsListPage{fn: getNextPage} } +// BasicAggregations the aggregation. +type BasicAggregations interface { + AsAggregations() (*Aggregations, bool) +} + +// Aggregations the aggregation. +type Aggregations 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: 'KindAggregations' + Kind KindBasicAggregations `json:"kind,omitempty"` +} + +func unmarshalBasicAggregations(body []byte) (BasicAggregations, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["kind"] { + default: + var a Aggregations + err := json.Unmarshal(body, &a) + return a, err + } +} +func unmarshalBasicAggregationsArray(body []byte) ([]BasicAggregations, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + aArray := make([]BasicAggregations, len(rawMessages)) + + for index, rawMessage := range rawMessages { + a, err := unmarshalBasicAggregations(*rawMessage) + if err != nil { + return nil, err + } + aArray[index] = a + } + return aArray, nil +} + +// MarshalJSON is the custom marshaler for Aggregations. +func (a Aggregations) MarshalJSON() ([]byte, error) { + a.Kind = KindAggregations + objectMap := make(map[string]interface{}) + if a.ID != nil { + objectMap["id"] = a.ID + } + if a.Type != nil { + objectMap["type"] = a.Type + } + if a.Name != nil { + objectMap["name"] = a.Name + } + if a.Kind != "" { + objectMap["kind"] = a.Kind + } + return json.Marshal(objectMap) +} + +// AsAggregations is the BasicAggregations implementation for Aggregations. +func (a Aggregations) AsAggregations() (*Aggregations, bool) { + return &a, true +} + +// AsBasicAggregations is the BasicAggregations implementation for Aggregations. +func (a Aggregations) AsBasicAggregations() (BasicAggregations, bool) { + return &a, true +} + +// AggregationsKind1 describes an Azure resource with kind. +type AggregationsKind1 struct { + // Kind - The kind of the setting. Possible values include: 'CasesAggregation' + Kind AggregationsKind `json:"kind,omitempty"` +} + +// AggregationsModel ... +type AggregationsModel struct { + autorest.Response `json:"-"` + Value BasicAggregations `json:"value,omitempty"` +} + +// UnmarshalJSON is the custom unmarshaler for AggregationsModel struct. +func (am *AggregationsModel) UnmarshalJSON(body []byte) error { + a, err := unmarshalBasicAggregations(body) + if err != nil { + return err + } + am.Value = a + + return nil +} + // BasicAlertRule alert rule. type BasicAlertRule interface { AsScheduledAlertRule() (*ScheduledAlertRule, bool) 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 6cfbd897f7e2..db0717a1bd3d 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 @@ -104,3 +104,10 @@ type ProductSettingsClientAPI interface { } var _ ProductSettingsClientAPI = (*securityinsight.ProductSettingsClient)(nil) + +// CasesAggregationsClientAPI contains the set of methods on the CasesAggregationsClient type. +type CasesAggregationsClientAPI interface { + Get(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, aggregationsName string) (result securityinsight.AggregationsModel, err error) +} + +var _ CasesAggregationsClientAPI = (*securityinsight.CasesAggregationsClient)(nil) From 4f39196272bd6b823b70a4519adb6f9999f8970b Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Tue, 2 Apr 2019 07:23:20 +0000 Subject: [PATCH 2/2] Generated from 2e84b343d46947d2cc6d9f79a64ced02e82027c6 Fix pathParam and add Tag --- .../2017-08-01-preview/securityinsight/casesaggregations.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/preview/securityinsight/mgmt/2017-08-01-preview/securityinsight/casesaggregations.go b/services/preview/securityinsight/mgmt/2017-08-01-preview/securityinsight/casesaggregations.go index d7d28e46f4d5..5579afca115e 100644 --- a/services/preview/securityinsight/mgmt/2017-08-01-preview/securityinsight/casesaggregations.go +++ b/services/preview/securityinsight/mgmt/2017-08-01-preview/securityinsight/casesaggregations.go @@ -112,7 +112,7 @@ func (client CasesAggregationsClient) GetPreparer(ctx context.Context, resourceG preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/aggregations/{AggregationsName}", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/aggregations/{aggregationsName}", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) }