1package securityinsight 2 3// Copyright (c) Microsoft Corporation. All rights reserved. 4// Licensed under the MIT License. See License.txt in the project root for license information. 5// 6// Code generated by Microsoft (R) AutoRest Code Generator. 7// Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 9import ( 10 "context" 11 "github.com/Azure/go-autorest/autorest" 12 "github.com/Azure/go-autorest/autorest/azure" 13 "github.com/Azure/go-autorest/autorest/validation" 14 "github.com/Azure/go-autorest/tracing" 15 "net/http" 16) 17 18// CasesAggregationsClient is the API spec for Microsoft.SecurityInsights (Azure Security Insights) resource provider 19type CasesAggregationsClient struct { 20 BaseClient 21} 22 23// NewCasesAggregationsClient creates an instance of the CasesAggregationsClient client. 24func NewCasesAggregationsClient(subscriptionID string) CasesAggregationsClient { 25 return NewCasesAggregationsClientWithBaseURI(DefaultBaseURI, subscriptionID) 26} 27 28// NewCasesAggregationsClientWithBaseURI creates an instance of the CasesAggregationsClient client using a custom 29// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure 30// stack). 31func NewCasesAggregationsClientWithBaseURI(baseURI string, subscriptionID string) CasesAggregationsClient { 32 return CasesAggregationsClient{NewWithBaseURI(baseURI, subscriptionID)} 33} 34 35// Get get aggregative result for the given resources under the defined workspace 36// Parameters: 37// resourceGroupName - the name of the resource group within the user's subscription. The name is case 38// insensitive. 39// operationalInsightsResourceProvider - the namespace of workspaces resource provider- 40// Microsoft.OperationalInsights. 41// workspaceName - the name of the workspace. 42// aggregationsName - the aggregation name. Supports - Cases 43func (client CasesAggregationsClient) Get(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, aggregationsName string) (result AggregationsModel, err error) { 44 if tracing.IsEnabled() { 45 ctx = tracing.StartSpan(ctx, fqdn+"/CasesAggregationsClient.Get") 46 defer func() { 47 sc := -1 48 if result.Response.Response != nil { 49 sc = result.Response.Response.StatusCode 50 } 51 tracing.EndSpan(ctx, sc, err) 52 }() 53 } 54 if err := validation.Validate([]validation.Validation{ 55 {TargetValue: client.SubscriptionID, 56 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}}}, 57 {TargetValue: resourceGroupName, 58 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 59 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 60 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 61 {TargetValue: workspaceName, 62 Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 63 {Target: "workspaceName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { 64 return result, validation.NewError("securityinsight.CasesAggregationsClient", "Get", err.Error()) 65 } 66 67 req, err := client.GetPreparer(ctx, resourceGroupName, operationalInsightsResourceProvider, workspaceName, aggregationsName) 68 if err != nil { 69 err = autorest.NewErrorWithError(err, "securityinsight.CasesAggregationsClient", "Get", nil, "Failure preparing request") 70 return 71 } 72 73 resp, err := client.GetSender(req) 74 if err != nil { 75 result.Response = autorest.Response{Response: resp} 76 err = autorest.NewErrorWithError(err, "securityinsight.CasesAggregationsClient", "Get", resp, "Failure sending request") 77 return 78 } 79 80 result, err = client.GetResponder(resp) 81 if err != nil { 82 err = autorest.NewErrorWithError(err, "securityinsight.CasesAggregationsClient", "Get", resp, "Failure responding to request") 83 return 84 } 85 86 return 87} 88 89// GetPreparer prepares the Get request. 90func (client CasesAggregationsClient) GetPreparer(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, aggregationsName string) (*http.Request, error) { 91 pathParameters := map[string]interface{}{ 92 "aggregationsName": autorest.Encode("path", aggregationsName), 93 "operationalInsightsResourceProvider": autorest.Encode("path", operationalInsightsResourceProvider), 94 "resourceGroupName": autorest.Encode("path", resourceGroupName), 95 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 96 "workspaceName": autorest.Encode("path", workspaceName), 97 } 98 99 const APIVersion = "2019-01-01-preview" 100 queryParameters := map[string]interface{}{ 101 "api-version": APIVersion, 102 } 103 104 preparer := autorest.CreatePreparer( 105 autorest.AsGet(), 106 autorest.WithBaseURL(client.BaseURI), 107 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/aggregations/{aggregationsName}", pathParameters), 108 autorest.WithQueryParameters(queryParameters)) 109 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 110} 111 112// GetSender sends the Get request. The method will close the 113// http.Response Body if it receives an error. 114func (client CasesAggregationsClient) GetSender(req *http.Request) (*http.Response, error) { 115 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 116} 117 118// GetResponder handles the response to the Get request. The method always 119// closes the http.Response Body. 120func (client CasesAggregationsClient) GetResponder(resp *http.Response) (result AggregationsModel, err error) { 121 err = autorest.Respond( 122 resp, 123 azure.WithErrorUnlessStatusCode(http.StatusOK), 124 autorest.ByUnmarshallingJSON(&result), 125 autorest.ByClosing()) 126 result.Response = autorest.Response{Response: resp} 127 return 128} 129