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// ProductSettingsClient is the API spec for Microsoft.SecurityInsights (Azure Security Insights) resource provider 19type ProductSettingsClient struct { 20 BaseClient 21} 22 23// NewProductSettingsClient creates an instance of the ProductSettingsClient client. 24func NewProductSettingsClient(subscriptionID string) ProductSettingsClient { 25 return NewProductSettingsClientWithBaseURI(DefaultBaseURI, subscriptionID) 26} 27 28// NewProductSettingsClientWithBaseURI creates an instance of the ProductSettingsClient client using a custom endpoint. 29// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 30func NewProductSettingsClientWithBaseURI(baseURI string, subscriptionID string) ProductSettingsClient { 31 return ProductSettingsClient{NewWithBaseURI(baseURI, subscriptionID)} 32} 33 34// Delete delete setting of the product. 35// Parameters: 36// resourceGroupName - the name of the resource group within the user's subscription. The name is case 37// insensitive. 38// operationalInsightsResourceProvider - the namespace of workspaces resource provider- 39// Microsoft.OperationalInsights. 40// workspaceName - the name of the workspace. 41// settingsName - the setting name. Supports - EyesOn, EntityAnalytics, Ueba 42func (client ProductSettingsClient) Delete(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, settingsName string) (result autorest.Response, err error) { 43 if tracing.IsEnabled() { 44 ctx = tracing.StartSpan(ctx, fqdn+"/ProductSettingsClient.Delete") 45 defer func() { 46 sc := -1 47 if result.Response != nil { 48 sc = result.Response.StatusCode 49 } 50 tracing.EndSpan(ctx, sc, err) 51 }() 52 } 53 if err := validation.Validate([]validation.Validation{ 54 {TargetValue: client.SubscriptionID, 55 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}}}, 56 {TargetValue: resourceGroupName, 57 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 58 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 59 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 60 {TargetValue: workspaceName, 61 Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 62 {Target: "workspaceName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { 63 return result, validation.NewError("securityinsight.ProductSettingsClient", "Delete", err.Error()) 64 } 65 66 req, err := client.DeletePreparer(ctx, resourceGroupName, operationalInsightsResourceProvider, workspaceName, settingsName) 67 if err != nil { 68 err = autorest.NewErrorWithError(err, "securityinsight.ProductSettingsClient", "Delete", nil, "Failure preparing request") 69 return 70 } 71 72 resp, err := client.DeleteSender(req) 73 if err != nil { 74 result.Response = resp 75 err = autorest.NewErrorWithError(err, "securityinsight.ProductSettingsClient", "Delete", resp, "Failure sending request") 76 return 77 } 78 79 result, err = client.DeleteResponder(resp) 80 if err != nil { 81 err = autorest.NewErrorWithError(err, "securityinsight.ProductSettingsClient", "Delete", resp, "Failure responding to request") 82 return 83 } 84 85 return 86} 87 88// DeletePreparer prepares the Delete request. 89func (client ProductSettingsClient) DeletePreparer(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, settingsName string) (*http.Request, error) { 90 pathParameters := map[string]interface{}{ 91 "operationalInsightsResourceProvider": autorest.Encode("path", operationalInsightsResourceProvider), 92 "resourceGroupName": autorest.Encode("path", resourceGroupName), 93 "settingsName": autorest.Encode("path", settingsName), 94 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 95 "workspaceName": autorest.Encode("path", workspaceName), 96 } 97 98 const APIVersion = "2019-01-01-preview" 99 queryParameters := map[string]interface{}{ 100 "api-version": APIVersion, 101 } 102 103 preparer := autorest.CreatePreparer( 104 autorest.AsDelete(), 105 autorest.WithBaseURL(client.BaseURI), 106 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/settings/{settingsName}", pathParameters), 107 autorest.WithQueryParameters(queryParameters)) 108 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 109} 110 111// DeleteSender sends the Delete request. The method will close the 112// http.Response Body if it receives an error. 113func (client ProductSettingsClient) DeleteSender(req *http.Request) (*http.Response, error) { 114 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 115} 116 117// DeleteResponder handles the response to the Delete request. The method always 118// closes the http.Response Body. 119func (client ProductSettingsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 120 err = autorest.Respond( 121 resp, 122 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), 123 autorest.ByClosing()) 124 result.Response = resp 125 return 126} 127 128// Get gets a setting. 129// Parameters: 130// resourceGroupName - the name of the resource group within the user's subscription. The name is case 131// insensitive. 132// operationalInsightsResourceProvider - the namespace of workspaces resource provider- 133// Microsoft.OperationalInsights. 134// workspaceName - the name of the workspace. 135// settingsName - the setting name. Supports - EyesOn, EntityAnalytics, Ueba 136func (client ProductSettingsClient) Get(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, settingsName string) (result SettingsModel, err error) { 137 if tracing.IsEnabled() { 138 ctx = tracing.StartSpan(ctx, fqdn+"/ProductSettingsClient.Get") 139 defer func() { 140 sc := -1 141 if result.Response.Response != nil { 142 sc = result.Response.Response.StatusCode 143 } 144 tracing.EndSpan(ctx, sc, err) 145 }() 146 } 147 if err := validation.Validate([]validation.Validation{ 148 {TargetValue: client.SubscriptionID, 149 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}}}, 150 {TargetValue: resourceGroupName, 151 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 152 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 153 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 154 {TargetValue: workspaceName, 155 Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 156 {Target: "workspaceName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { 157 return result, validation.NewError("securityinsight.ProductSettingsClient", "Get", err.Error()) 158 } 159 160 req, err := client.GetPreparer(ctx, resourceGroupName, operationalInsightsResourceProvider, workspaceName, settingsName) 161 if err != nil { 162 err = autorest.NewErrorWithError(err, "securityinsight.ProductSettingsClient", "Get", nil, "Failure preparing request") 163 return 164 } 165 166 resp, err := client.GetSender(req) 167 if err != nil { 168 result.Response = autorest.Response{Response: resp} 169 err = autorest.NewErrorWithError(err, "securityinsight.ProductSettingsClient", "Get", resp, "Failure sending request") 170 return 171 } 172 173 result, err = client.GetResponder(resp) 174 if err != nil { 175 err = autorest.NewErrorWithError(err, "securityinsight.ProductSettingsClient", "Get", resp, "Failure responding to request") 176 return 177 } 178 179 return 180} 181 182// GetPreparer prepares the Get request. 183func (client ProductSettingsClient) GetPreparer(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, settingsName string) (*http.Request, error) { 184 pathParameters := map[string]interface{}{ 185 "operationalInsightsResourceProvider": autorest.Encode("path", operationalInsightsResourceProvider), 186 "resourceGroupName": autorest.Encode("path", resourceGroupName), 187 "settingsName": autorest.Encode("path", settingsName), 188 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 189 "workspaceName": autorest.Encode("path", workspaceName), 190 } 191 192 const APIVersion = "2019-01-01-preview" 193 queryParameters := map[string]interface{}{ 194 "api-version": APIVersion, 195 } 196 197 preparer := autorest.CreatePreparer( 198 autorest.AsGet(), 199 autorest.WithBaseURL(client.BaseURI), 200 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/settings/{settingsName}", pathParameters), 201 autorest.WithQueryParameters(queryParameters)) 202 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 203} 204 205// GetSender sends the Get request. The method will close the 206// http.Response Body if it receives an error. 207func (client ProductSettingsClient) GetSender(req *http.Request) (*http.Response, error) { 208 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 209} 210 211// GetResponder handles the response to the Get request. The method always 212// closes the http.Response Body. 213func (client ProductSettingsClient) GetResponder(resp *http.Response) (result SettingsModel, err error) { 214 err = autorest.Respond( 215 resp, 216 azure.WithErrorUnlessStatusCode(http.StatusOK), 217 autorest.ByUnmarshallingJSON(&result), 218 autorest.ByClosing()) 219 result.Response = autorest.Response{Response: resp} 220 return 221} 222 223// GetAll list of all the settings 224// Parameters: 225// resourceGroupName - the name of the resource group within the user's subscription. The name is case 226// insensitive. 227// operationalInsightsResourceProvider - the namespace of workspaces resource provider- 228// Microsoft.OperationalInsights. 229// workspaceName - the name of the workspace. 230func (client ProductSettingsClient) GetAll(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string) (result SettingList, err error) { 231 if tracing.IsEnabled() { 232 ctx = tracing.StartSpan(ctx, fqdn+"/ProductSettingsClient.GetAll") 233 defer func() { 234 sc := -1 235 if result.Response.Response != nil { 236 sc = result.Response.Response.StatusCode 237 } 238 tracing.EndSpan(ctx, sc, err) 239 }() 240 } 241 if err := validation.Validate([]validation.Validation{ 242 {TargetValue: client.SubscriptionID, 243 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}}}, 244 {TargetValue: resourceGroupName, 245 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 246 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 247 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 248 {TargetValue: workspaceName, 249 Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 250 {Target: "workspaceName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { 251 return result, validation.NewError("securityinsight.ProductSettingsClient", "GetAll", err.Error()) 252 } 253 254 req, err := client.GetAllPreparer(ctx, resourceGroupName, operationalInsightsResourceProvider, workspaceName) 255 if err != nil { 256 err = autorest.NewErrorWithError(err, "securityinsight.ProductSettingsClient", "GetAll", nil, "Failure preparing request") 257 return 258 } 259 260 resp, err := client.GetAllSender(req) 261 if err != nil { 262 result.Response = autorest.Response{Response: resp} 263 err = autorest.NewErrorWithError(err, "securityinsight.ProductSettingsClient", "GetAll", resp, "Failure sending request") 264 return 265 } 266 267 result, err = client.GetAllResponder(resp) 268 if err != nil { 269 err = autorest.NewErrorWithError(err, "securityinsight.ProductSettingsClient", "GetAll", resp, "Failure responding to request") 270 return 271 } 272 273 return 274} 275 276// GetAllPreparer prepares the GetAll request. 277func (client ProductSettingsClient) GetAllPreparer(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string) (*http.Request, error) { 278 pathParameters := map[string]interface{}{ 279 "operationalInsightsResourceProvider": autorest.Encode("path", operationalInsightsResourceProvider), 280 "resourceGroupName": autorest.Encode("path", resourceGroupName), 281 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 282 "workspaceName": autorest.Encode("path", workspaceName), 283 } 284 285 const APIVersion = "2019-01-01-preview" 286 queryParameters := map[string]interface{}{ 287 "api-version": APIVersion, 288 } 289 290 preparer := autorest.CreatePreparer( 291 autorest.AsGet(), 292 autorest.WithBaseURL(client.BaseURI), 293 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/settings", pathParameters), 294 autorest.WithQueryParameters(queryParameters)) 295 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 296} 297 298// GetAllSender sends the GetAll request. The method will close the 299// http.Response Body if it receives an error. 300func (client ProductSettingsClient) GetAllSender(req *http.Request) (*http.Response, error) { 301 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 302} 303 304// GetAllResponder handles the response to the GetAll request. The method always 305// closes the http.Response Body. 306func (client ProductSettingsClient) GetAllResponder(resp *http.Response) (result SettingList, err error) { 307 err = autorest.Respond( 308 resp, 309 azure.WithErrorUnlessStatusCode(http.StatusOK), 310 autorest.ByUnmarshallingJSON(&result), 311 autorest.ByClosing()) 312 result.Response = autorest.Response{Response: resp} 313 return 314} 315 316// Update updates setting. 317// Parameters: 318// resourceGroupName - the name of the resource group within the user's subscription. The name is case 319// insensitive. 320// operationalInsightsResourceProvider - the namespace of workspaces resource provider- 321// Microsoft.OperationalInsights. 322// workspaceName - the name of the workspace. 323// settingsName - the setting name. Supports - EyesOn, EntityAnalytics, Ueba 324// settings - the setting 325func (client ProductSettingsClient) Update(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, settingsName string, settings BasicSettings) (result SettingsModel, err error) { 326 if tracing.IsEnabled() { 327 ctx = tracing.StartSpan(ctx, fqdn+"/ProductSettingsClient.Update") 328 defer func() { 329 sc := -1 330 if result.Response.Response != nil { 331 sc = result.Response.Response.StatusCode 332 } 333 tracing.EndSpan(ctx, sc, err) 334 }() 335 } 336 if err := validation.Validate([]validation.Validation{ 337 {TargetValue: client.SubscriptionID, 338 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}}}, 339 {TargetValue: resourceGroupName, 340 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 341 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 342 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 343 {TargetValue: workspaceName, 344 Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 345 {Target: "workspaceName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { 346 return result, validation.NewError("securityinsight.ProductSettingsClient", "Update", err.Error()) 347 } 348 349 req, err := client.UpdatePreparer(ctx, resourceGroupName, operationalInsightsResourceProvider, workspaceName, settingsName, settings) 350 if err != nil { 351 err = autorest.NewErrorWithError(err, "securityinsight.ProductSettingsClient", "Update", nil, "Failure preparing request") 352 return 353 } 354 355 resp, err := client.UpdateSender(req) 356 if err != nil { 357 result.Response = autorest.Response{Response: resp} 358 err = autorest.NewErrorWithError(err, "securityinsight.ProductSettingsClient", "Update", resp, "Failure sending request") 359 return 360 } 361 362 result, err = client.UpdateResponder(resp) 363 if err != nil { 364 err = autorest.NewErrorWithError(err, "securityinsight.ProductSettingsClient", "Update", resp, "Failure responding to request") 365 return 366 } 367 368 return 369} 370 371// UpdatePreparer prepares the Update request. 372func (client ProductSettingsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, settingsName string, settings BasicSettings) (*http.Request, error) { 373 pathParameters := map[string]interface{}{ 374 "operationalInsightsResourceProvider": autorest.Encode("path", operationalInsightsResourceProvider), 375 "resourceGroupName": autorest.Encode("path", resourceGroupName), 376 "settingsName": autorest.Encode("path", settingsName), 377 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 378 "workspaceName": autorest.Encode("path", workspaceName), 379 } 380 381 const APIVersion = "2019-01-01-preview" 382 queryParameters := map[string]interface{}{ 383 "api-version": APIVersion, 384 } 385 386 preparer := autorest.CreatePreparer( 387 autorest.AsContentType("application/json; charset=utf-8"), 388 autorest.AsPut(), 389 autorest.WithBaseURL(client.BaseURI), 390 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/settings/{settingsName}", pathParameters), 391 autorest.WithJSON(settings), 392 autorest.WithQueryParameters(queryParameters)) 393 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 394} 395 396// UpdateSender sends the Update request. The method will close the 397// http.Response Body if it receives an error. 398func (client ProductSettingsClient) UpdateSender(req *http.Request) (*http.Response, error) { 399 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 400} 401 402// UpdateResponder handles the response to the Update request. The method always 403// closes the http.Response Body. 404func (client ProductSettingsClient) UpdateResponder(resp *http.Response) (result SettingsModel, err error) { 405 err = autorest.Respond( 406 resp, 407 azure.WithErrorUnlessStatusCode(http.StatusOK), 408 autorest.ByUnmarshallingJSON(&result), 409 autorest.ByClosing()) 410 result.Response = autorest.Response{Response: resp} 411 return 412} 413