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// CasesClient is the API spec for Microsoft.SecurityInsights (Azure Security Insights) resource provider 19type CasesClient struct { 20 BaseClient 21} 22 23// NewCasesClient creates an instance of the CasesClient client. 24func NewCasesClient(subscriptionID string) CasesClient { 25 return NewCasesClientWithBaseURI(DefaultBaseURI, subscriptionID) 26} 27 28// NewCasesClientWithBaseURI creates an instance of the CasesClient client using a custom endpoint. Use this when 29// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 30func NewCasesClientWithBaseURI(baseURI string, subscriptionID string) CasesClient { 31 return CasesClient{NewWithBaseURI(baseURI, subscriptionID)} 32} 33 34// CreateOrUpdate creates or updates the case. 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// caseID - case ID 42// caseParameter - the case 43func (client CasesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, caseID string, caseParameter Case) (result Case, err error) { 44 if tracing.IsEnabled() { 45 ctx = tracing.StartSpan(ctx, fqdn+"/CasesClient.CreateOrUpdate") 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}}}, 64 {TargetValue: caseParameter, 65 Constraints: []validation.Constraint{{Target: "caseParameter.CaseProperties", Name: validation.Null, Rule: false, 66 Chain: []validation.Constraint{{Target: "caseParameter.CaseProperties.Title", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { 67 return result, validation.NewError("securityinsight.CasesClient", "CreateOrUpdate", err.Error()) 68 } 69 70 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, operationalInsightsResourceProvider, workspaceName, caseID, caseParameter) 71 if err != nil { 72 err = autorest.NewErrorWithError(err, "securityinsight.CasesClient", "CreateOrUpdate", nil, "Failure preparing request") 73 return 74 } 75 76 resp, err := client.CreateOrUpdateSender(req) 77 if err != nil { 78 result.Response = autorest.Response{Response: resp} 79 err = autorest.NewErrorWithError(err, "securityinsight.CasesClient", "CreateOrUpdate", resp, "Failure sending request") 80 return 81 } 82 83 result, err = client.CreateOrUpdateResponder(resp) 84 if err != nil { 85 err = autorest.NewErrorWithError(err, "securityinsight.CasesClient", "CreateOrUpdate", resp, "Failure responding to request") 86 return 87 } 88 89 return 90} 91 92// CreateOrUpdatePreparer prepares the CreateOrUpdate request. 93func (client CasesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, caseID string, caseParameter Case) (*http.Request, error) { 94 pathParameters := map[string]interface{}{ 95 "caseId": autorest.Encode("path", caseID), 96 "operationalInsightsResourceProvider": autorest.Encode("path", operationalInsightsResourceProvider), 97 "resourceGroupName": autorest.Encode("path", resourceGroupName), 98 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 99 "workspaceName": autorest.Encode("path", workspaceName), 100 } 101 102 const APIVersion = "2019-01-01-preview" 103 queryParameters := map[string]interface{}{ 104 "api-version": APIVersion, 105 } 106 107 preparer := autorest.CreatePreparer( 108 autorest.AsContentType("application/json; charset=utf-8"), 109 autorest.AsPut(), 110 autorest.WithBaseURL(client.BaseURI), 111 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/cases/{caseId}", pathParameters), 112 autorest.WithJSON(caseParameter), 113 autorest.WithQueryParameters(queryParameters)) 114 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 115} 116 117// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the 118// http.Response Body if it receives an error. 119func (client CasesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { 120 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 121} 122 123// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always 124// closes the http.Response Body. 125func (client CasesClient) CreateOrUpdateResponder(resp *http.Response) (result Case, err error) { 126 err = autorest.Respond( 127 resp, 128 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 129 autorest.ByUnmarshallingJSON(&result), 130 autorest.ByClosing()) 131 result.Response = autorest.Response{Response: resp} 132 return 133} 134 135// Delete delete the case. 136// Parameters: 137// resourceGroupName - the name of the resource group within the user's subscription. The name is case 138// insensitive. 139// operationalInsightsResourceProvider - the namespace of workspaces resource provider- 140// Microsoft.OperationalInsights. 141// workspaceName - the name of the workspace. 142// caseID - case ID 143func (client CasesClient) Delete(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, caseID string) (result autorest.Response, err error) { 144 if tracing.IsEnabled() { 145 ctx = tracing.StartSpan(ctx, fqdn+"/CasesClient.Delete") 146 defer func() { 147 sc := -1 148 if result.Response != nil { 149 sc = result.Response.StatusCode 150 } 151 tracing.EndSpan(ctx, sc, err) 152 }() 153 } 154 if err := validation.Validate([]validation.Validation{ 155 {TargetValue: client.SubscriptionID, 156 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}}}, 157 {TargetValue: resourceGroupName, 158 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 159 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 160 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 161 {TargetValue: workspaceName, 162 Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 163 {Target: "workspaceName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { 164 return result, validation.NewError("securityinsight.CasesClient", "Delete", err.Error()) 165 } 166 167 req, err := client.DeletePreparer(ctx, resourceGroupName, operationalInsightsResourceProvider, workspaceName, caseID) 168 if err != nil { 169 err = autorest.NewErrorWithError(err, "securityinsight.CasesClient", "Delete", nil, "Failure preparing request") 170 return 171 } 172 173 resp, err := client.DeleteSender(req) 174 if err != nil { 175 result.Response = resp 176 err = autorest.NewErrorWithError(err, "securityinsight.CasesClient", "Delete", resp, "Failure sending request") 177 return 178 } 179 180 result, err = client.DeleteResponder(resp) 181 if err != nil { 182 err = autorest.NewErrorWithError(err, "securityinsight.CasesClient", "Delete", resp, "Failure responding to request") 183 return 184 } 185 186 return 187} 188 189// DeletePreparer prepares the Delete request. 190func (client CasesClient) DeletePreparer(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, caseID string) (*http.Request, error) { 191 pathParameters := map[string]interface{}{ 192 "caseId": autorest.Encode("path", caseID), 193 "operationalInsightsResourceProvider": autorest.Encode("path", operationalInsightsResourceProvider), 194 "resourceGroupName": autorest.Encode("path", resourceGroupName), 195 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 196 "workspaceName": autorest.Encode("path", workspaceName), 197 } 198 199 const APIVersion = "2019-01-01-preview" 200 queryParameters := map[string]interface{}{ 201 "api-version": APIVersion, 202 } 203 204 preparer := autorest.CreatePreparer( 205 autorest.AsDelete(), 206 autorest.WithBaseURL(client.BaseURI), 207 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/cases/{caseId}", pathParameters), 208 autorest.WithQueryParameters(queryParameters)) 209 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 210} 211 212// DeleteSender sends the Delete request. The method will close the 213// http.Response Body if it receives an error. 214func (client CasesClient) DeleteSender(req *http.Request) (*http.Response, error) { 215 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 216} 217 218// DeleteResponder handles the response to the Delete request. The method always 219// closes the http.Response Body. 220func (client CasesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 221 err = autorest.Respond( 222 resp, 223 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), 224 autorest.ByClosing()) 225 result.Response = resp 226 return 227} 228 229// Get gets a case. 230// Parameters: 231// resourceGroupName - the name of the resource group within the user's subscription. The name is case 232// insensitive. 233// operationalInsightsResourceProvider - the namespace of workspaces resource provider- 234// Microsoft.OperationalInsights. 235// workspaceName - the name of the workspace. 236// caseID - case ID 237func (client CasesClient) Get(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, caseID string) (result Case, err error) { 238 if tracing.IsEnabled() { 239 ctx = tracing.StartSpan(ctx, fqdn+"/CasesClient.Get") 240 defer func() { 241 sc := -1 242 if result.Response.Response != nil { 243 sc = result.Response.Response.StatusCode 244 } 245 tracing.EndSpan(ctx, sc, err) 246 }() 247 } 248 if err := validation.Validate([]validation.Validation{ 249 {TargetValue: client.SubscriptionID, 250 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}}}, 251 {TargetValue: resourceGroupName, 252 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 253 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 254 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 255 {TargetValue: workspaceName, 256 Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 257 {Target: "workspaceName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { 258 return result, validation.NewError("securityinsight.CasesClient", "Get", err.Error()) 259 } 260 261 req, err := client.GetPreparer(ctx, resourceGroupName, operationalInsightsResourceProvider, workspaceName, caseID) 262 if err != nil { 263 err = autorest.NewErrorWithError(err, "securityinsight.CasesClient", "Get", nil, "Failure preparing request") 264 return 265 } 266 267 resp, err := client.GetSender(req) 268 if err != nil { 269 result.Response = autorest.Response{Response: resp} 270 err = autorest.NewErrorWithError(err, "securityinsight.CasesClient", "Get", resp, "Failure sending request") 271 return 272 } 273 274 result, err = client.GetResponder(resp) 275 if err != nil { 276 err = autorest.NewErrorWithError(err, "securityinsight.CasesClient", "Get", resp, "Failure responding to request") 277 return 278 } 279 280 return 281} 282 283// GetPreparer prepares the Get request. 284func (client CasesClient) GetPreparer(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, caseID string) (*http.Request, error) { 285 pathParameters := map[string]interface{}{ 286 "caseId": autorest.Encode("path", caseID), 287 "operationalInsightsResourceProvider": autorest.Encode("path", operationalInsightsResourceProvider), 288 "resourceGroupName": autorest.Encode("path", resourceGroupName), 289 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 290 "workspaceName": autorest.Encode("path", workspaceName), 291 } 292 293 const APIVersion = "2019-01-01-preview" 294 queryParameters := map[string]interface{}{ 295 "api-version": APIVersion, 296 } 297 298 preparer := autorest.CreatePreparer( 299 autorest.AsGet(), 300 autorest.WithBaseURL(client.BaseURI), 301 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/cases/{caseId}", pathParameters), 302 autorest.WithQueryParameters(queryParameters)) 303 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 304} 305 306// GetSender sends the Get request. The method will close the 307// http.Response Body if it receives an error. 308func (client CasesClient) GetSender(req *http.Request) (*http.Response, error) { 309 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 310} 311 312// GetResponder handles the response to the Get request. The method always 313// closes the http.Response Body. 314func (client CasesClient) GetResponder(resp *http.Response) (result Case, err error) { 315 err = autorest.Respond( 316 resp, 317 azure.WithErrorUnlessStatusCode(http.StatusOK), 318 autorest.ByUnmarshallingJSON(&result), 319 autorest.ByClosing()) 320 result.Response = autorest.Response{Response: resp} 321 return 322} 323 324// GetComment gets a case comment. 325// Parameters: 326// resourceGroupName - the name of the resource group within the user's subscription. The name is case 327// insensitive. 328// operationalInsightsResourceProvider - the namespace of workspaces resource provider- 329// Microsoft.OperationalInsights. 330// workspaceName - the name of the workspace. 331// caseID - case ID 332// caseCommentID - case comment ID 333func (client CasesClient) GetComment(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, caseID string, caseCommentID string) (result CaseComment, err error) { 334 if tracing.IsEnabled() { 335 ctx = tracing.StartSpan(ctx, fqdn+"/CasesClient.GetComment") 336 defer func() { 337 sc := -1 338 if result.Response.Response != nil { 339 sc = result.Response.Response.StatusCode 340 } 341 tracing.EndSpan(ctx, sc, err) 342 }() 343 } 344 if err := validation.Validate([]validation.Validation{ 345 {TargetValue: client.SubscriptionID, 346 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}}}, 347 {TargetValue: resourceGroupName, 348 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 349 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 350 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 351 {TargetValue: workspaceName, 352 Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 353 {Target: "workspaceName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { 354 return result, validation.NewError("securityinsight.CasesClient", "GetComment", err.Error()) 355 } 356 357 req, err := client.GetCommentPreparer(ctx, resourceGroupName, operationalInsightsResourceProvider, workspaceName, caseID, caseCommentID) 358 if err != nil { 359 err = autorest.NewErrorWithError(err, "securityinsight.CasesClient", "GetComment", nil, "Failure preparing request") 360 return 361 } 362 363 resp, err := client.GetCommentSender(req) 364 if err != nil { 365 result.Response = autorest.Response{Response: resp} 366 err = autorest.NewErrorWithError(err, "securityinsight.CasesClient", "GetComment", resp, "Failure sending request") 367 return 368 } 369 370 result, err = client.GetCommentResponder(resp) 371 if err != nil { 372 err = autorest.NewErrorWithError(err, "securityinsight.CasesClient", "GetComment", resp, "Failure responding to request") 373 return 374 } 375 376 return 377} 378 379// GetCommentPreparer prepares the GetComment request. 380func (client CasesClient) GetCommentPreparer(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, caseID string, caseCommentID string) (*http.Request, error) { 381 pathParameters := map[string]interface{}{ 382 "caseCommentId": autorest.Encode("path", caseCommentID), 383 "caseId": autorest.Encode("path", caseID), 384 "operationalInsightsResourceProvider": autorest.Encode("path", operationalInsightsResourceProvider), 385 "resourceGroupName": autorest.Encode("path", resourceGroupName), 386 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 387 "workspaceName": autorest.Encode("path", workspaceName), 388 } 389 390 const APIVersion = "2019-01-01-preview" 391 queryParameters := map[string]interface{}{ 392 "api-version": APIVersion, 393 } 394 395 preparer := autorest.CreatePreparer( 396 autorest.AsGet(), 397 autorest.WithBaseURL(client.BaseURI), 398 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/cases/{caseId}/comments/{caseCommentId}", pathParameters), 399 autorest.WithQueryParameters(queryParameters)) 400 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 401} 402 403// GetCommentSender sends the GetComment request. The method will close the 404// http.Response Body if it receives an error. 405func (client CasesClient) GetCommentSender(req *http.Request) (*http.Response, error) { 406 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 407} 408 409// GetCommentResponder handles the response to the GetComment request. The method always 410// closes the http.Response Body. 411func (client CasesClient) GetCommentResponder(resp *http.Response) (result CaseComment, err error) { 412 err = autorest.Respond( 413 resp, 414 azure.WithErrorUnlessStatusCode(http.StatusOK), 415 autorest.ByUnmarshallingJSON(&result), 416 autorest.ByClosing()) 417 result.Response = autorest.Response{Response: resp} 418 return 419} 420 421// List gets all cases. 422// Parameters: 423// resourceGroupName - the name of the resource group within the user's subscription. The name is case 424// insensitive. 425// operationalInsightsResourceProvider - the namespace of workspaces resource provider- 426// Microsoft.OperationalInsights. 427// workspaceName - the name of the workspace. 428// filter - filters the results, based on a Boolean condition. Optional. 429// orderby - sorts the results. Optional. 430// top - returns only the first n results. Optional. 431// skipToken - skiptoken is only used if a previous operation returned a partial result. If a previous response 432// contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that 433// specifies a starting point to use for subsequent calls. Optional. 434func (client CasesClient) List(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, filter string, orderby string, top *int32, skipToken string) (result CaseListPage, err error) { 435 if tracing.IsEnabled() { 436 ctx = tracing.StartSpan(ctx, fqdn+"/CasesClient.List") 437 defer func() { 438 sc := -1 439 if result.cl.Response.Response != nil { 440 sc = result.cl.Response.Response.StatusCode 441 } 442 tracing.EndSpan(ctx, sc, err) 443 }() 444 } 445 if err := validation.Validate([]validation.Validation{ 446 {TargetValue: client.SubscriptionID, 447 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}}}, 448 {TargetValue: resourceGroupName, 449 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 450 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 451 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 452 {TargetValue: workspaceName, 453 Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 454 {Target: "workspaceName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { 455 return result, validation.NewError("securityinsight.CasesClient", "List", err.Error()) 456 } 457 458 result.fn = client.listNextResults 459 req, err := client.ListPreparer(ctx, resourceGroupName, operationalInsightsResourceProvider, workspaceName, filter, orderby, top, skipToken) 460 if err != nil { 461 err = autorest.NewErrorWithError(err, "securityinsight.CasesClient", "List", nil, "Failure preparing request") 462 return 463 } 464 465 resp, err := client.ListSender(req) 466 if err != nil { 467 result.cl.Response = autorest.Response{Response: resp} 468 err = autorest.NewErrorWithError(err, "securityinsight.CasesClient", "List", resp, "Failure sending request") 469 return 470 } 471 472 result.cl, err = client.ListResponder(resp) 473 if err != nil { 474 err = autorest.NewErrorWithError(err, "securityinsight.CasesClient", "List", resp, "Failure responding to request") 475 return 476 } 477 if result.cl.hasNextLink() && result.cl.IsEmpty() { 478 err = result.NextWithContext(ctx) 479 return 480 } 481 482 return 483} 484 485// ListPreparer prepares the List request. 486func (client CasesClient) ListPreparer(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, filter string, orderby string, top *int32, skipToken string) (*http.Request, error) { 487 pathParameters := map[string]interface{}{ 488 "operationalInsightsResourceProvider": autorest.Encode("path", operationalInsightsResourceProvider), 489 "resourceGroupName": autorest.Encode("path", resourceGroupName), 490 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 491 "workspaceName": autorest.Encode("path", workspaceName), 492 } 493 494 const APIVersion = "2019-01-01-preview" 495 queryParameters := map[string]interface{}{ 496 "api-version": APIVersion, 497 } 498 if len(filter) > 0 { 499 queryParameters["$filter"] = autorest.Encode("query", filter) 500 } 501 if len(orderby) > 0 { 502 queryParameters["$orderby"] = autorest.Encode("query", orderby) 503 } 504 if top != nil { 505 queryParameters["$top"] = autorest.Encode("query", *top) 506 } 507 if len(skipToken) > 0 { 508 queryParameters["$skipToken"] = autorest.Encode("query", skipToken) 509 } 510 511 preparer := autorest.CreatePreparer( 512 autorest.AsGet(), 513 autorest.WithBaseURL(client.BaseURI), 514 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/cases", pathParameters), 515 autorest.WithQueryParameters(queryParameters)) 516 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 517} 518 519// ListSender sends the List request. The method will close the 520// http.Response Body if it receives an error. 521func (client CasesClient) ListSender(req *http.Request) (*http.Response, error) { 522 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 523} 524 525// ListResponder handles the response to the List request. The method always 526// closes the http.Response Body. 527func (client CasesClient) ListResponder(resp *http.Response) (result CaseList, err error) { 528 err = autorest.Respond( 529 resp, 530 azure.WithErrorUnlessStatusCode(http.StatusOK), 531 autorest.ByUnmarshallingJSON(&result), 532 autorest.ByClosing()) 533 result.Response = autorest.Response{Response: resp} 534 return 535} 536 537// listNextResults retrieves the next set of results, if any. 538func (client CasesClient) listNextResults(ctx context.Context, lastResults CaseList) (result CaseList, err error) { 539 req, err := lastResults.caseListPreparer(ctx) 540 if err != nil { 541 return result, autorest.NewErrorWithError(err, "securityinsight.CasesClient", "listNextResults", nil, "Failure preparing next results request") 542 } 543 if req == nil { 544 return 545 } 546 resp, err := client.ListSender(req) 547 if err != nil { 548 result.Response = autorest.Response{Response: resp} 549 return result, autorest.NewErrorWithError(err, "securityinsight.CasesClient", "listNextResults", resp, "Failure sending next results request") 550 } 551 result, err = client.ListResponder(resp) 552 if err != nil { 553 err = autorest.NewErrorWithError(err, "securityinsight.CasesClient", "listNextResults", resp, "Failure responding to next results request") 554 } 555 return 556} 557 558// ListComplete enumerates all values, automatically crossing page boundaries as required. 559func (client CasesClient) ListComplete(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, filter string, orderby string, top *int32, skipToken string) (result CaseListIterator, err error) { 560 if tracing.IsEnabled() { 561 ctx = tracing.StartSpan(ctx, fqdn+"/CasesClient.List") 562 defer func() { 563 sc := -1 564 if result.Response().Response.Response != nil { 565 sc = result.page.Response().Response.Response.StatusCode 566 } 567 tracing.EndSpan(ctx, sc, err) 568 }() 569 } 570 result.page, err = client.List(ctx, resourceGroupName, operationalInsightsResourceProvider, workspaceName, filter, orderby, top, skipToken) 571 return 572} 573