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// ThreatIntelligenceIndicatorMetricsClient is the API spec for Microsoft.SecurityInsights (Azure Security Insights) 19// resource provider 20type ThreatIntelligenceIndicatorMetricsClient struct { 21 BaseClient 22} 23 24// NewThreatIntelligenceIndicatorMetricsClient creates an instance of the ThreatIntelligenceIndicatorMetricsClient 25// client. 26func NewThreatIntelligenceIndicatorMetricsClient(subscriptionID string) ThreatIntelligenceIndicatorMetricsClient { 27 return NewThreatIntelligenceIndicatorMetricsClientWithBaseURI(DefaultBaseURI, subscriptionID) 28} 29 30// NewThreatIntelligenceIndicatorMetricsClientWithBaseURI creates an instance of the 31// ThreatIntelligenceIndicatorMetricsClient client using a custom endpoint. Use this when interacting with an Azure 32// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 33func NewThreatIntelligenceIndicatorMetricsClientWithBaseURI(baseURI string, subscriptionID string) ThreatIntelligenceIndicatorMetricsClient { 34 return ThreatIntelligenceIndicatorMetricsClient{NewWithBaseURI(baseURI, subscriptionID)} 35} 36 37// List get threat intelligence indicators metrics (Indicators counts by Type, Threat Type, Source). 38// Parameters: 39// resourceGroupName - the name of the resource group within the user's subscription. The name is case 40// insensitive. 41// operationalInsightsResourceProvider - the namespace of workspaces resource provider- 42// Microsoft.OperationalInsights. 43// workspaceName - the name of the workspace. 44func (client ThreatIntelligenceIndicatorMetricsClient) List(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string) (result ThreatIntelligenceMetricsList, err error) { 45 if tracing.IsEnabled() { 46 ctx = tracing.StartSpan(ctx, fqdn+"/ThreatIntelligenceIndicatorMetricsClient.List") 47 defer func() { 48 sc := -1 49 if result.Response.Response != nil { 50 sc = result.Response.Response.StatusCode 51 } 52 tracing.EndSpan(ctx, sc, err) 53 }() 54 } 55 if err := validation.Validate([]validation.Validation{ 56 {TargetValue: client.SubscriptionID, 57 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}}}, 58 {TargetValue: resourceGroupName, 59 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 60 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 61 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 62 {TargetValue: workspaceName, 63 Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 64 {Target: "workspaceName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { 65 return result, validation.NewError("securityinsight.ThreatIntelligenceIndicatorMetricsClient", "List", err.Error()) 66 } 67 68 req, err := client.ListPreparer(ctx, resourceGroupName, operationalInsightsResourceProvider, workspaceName) 69 if err != nil { 70 err = autorest.NewErrorWithError(err, "securityinsight.ThreatIntelligenceIndicatorMetricsClient", "List", nil, "Failure preparing request") 71 return 72 } 73 74 resp, err := client.ListSender(req) 75 if err != nil { 76 result.Response = autorest.Response{Response: resp} 77 err = autorest.NewErrorWithError(err, "securityinsight.ThreatIntelligenceIndicatorMetricsClient", "List", resp, "Failure sending request") 78 return 79 } 80 81 result, err = client.ListResponder(resp) 82 if err != nil { 83 err = autorest.NewErrorWithError(err, "securityinsight.ThreatIntelligenceIndicatorMetricsClient", "List", resp, "Failure responding to request") 84 return 85 } 86 87 return 88} 89 90// ListPreparer prepares the List request. 91func (client ThreatIntelligenceIndicatorMetricsClient) ListPreparer(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string) (*http.Request, error) { 92 pathParameters := map[string]interface{}{ 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/threatIntelligence/main/metrics", pathParameters), 108 autorest.WithQueryParameters(queryParameters)) 109 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 110} 111 112// ListSender sends the List request. The method will close the 113// http.Response Body if it receives an error. 114func (client ThreatIntelligenceIndicatorMetricsClient) ListSender(req *http.Request) (*http.Response, error) { 115 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 116} 117 118// ListResponder handles the response to the List request. The method always 119// closes the http.Response Body. 120func (client ThreatIntelligenceIndicatorMetricsClient) ListResponder(resp *http.Response) (result ThreatIntelligenceMetricsList, 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