github.com/aavshr/aws-sdk-go@v1.41.3/service/inspector/examples_test.go (about) 1 // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. 2 3 package inspector_test 4 5 import ( 6 "fmt" 7 "strings" 8 "time" 9 10 "github.com/aavshr/aws-sdk-go/aws" 11 "github.com/aavshr/aws-sdk-go/aws/awserr" 12 "github.com/aavshr/aws-sdk-go/aws/session" 13 "github.com/aavshr/aws-sdk-go/service/inspector" 14 ) 15 16 var _ time.Duration 17 var _ strings.Reader 18 var _ aws.Config 19 20 func parseTime(layout, value string) *time.Time { 21 t, err := time.Parse(layout, value) 22 if err != nil { 23 panic(err) 24 } 25 return &t 26 } 27 28 // Add attributes to findings 29 // 30 // Assigns attributes (key and value pairs) to the findings that are specified by the 31 // ARNs of the findings. 32 func ExampleInspector_AddAttributesToFindings_shared00() { 33 svc := inspector.New(session.New()) 34 input := &inspector.AddAttributesToFindingsInput{ 35 Attributes: []*inspector.Attribute{ 36 { 37 Key: aws.String("Example"), 38 Value: aws.String("example"), 39 }, 40 }, 41 FindingArns: []*string{ 42 aws.String("arn:aws:inspector:us-west-2:123456789012:target/0-0kFIPusq/template/0-8l1VIE0D/run/0-Z02cjjug/finding/0-T8yM9mEU"), 43 }, 44 } 45 46 result, err := svc.AddAttributesToFindings(input) 47 if err != nil { 48 if aerr, ok := err.(awserr.Error); ok { 49 switch aerr.Code() { 50 case inspector.ErrCodeInternalException: 51 fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) 52 case inspector.ErrCodeInvalidInputException: 53 fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) 54 case inspector.ErrCodeAccessDeniedException: 55 fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) 56 case inspector.ErrCodeNoSuchEntityException: 57 fmt.Println(inspector.ErrCodeNoSuchEntityException, aerr.Error()) 58 case inspector.ErrCodeServiceTemporarilyUnavailableException: 59 fmt.Println(inspector.ErrCodeServiceTemporarilyUnavailableException, aerr.Error()) 60 default: 61 fmt.Println(aerr.Error()) 62 } 63 } else { 64 // Print the error, cast err to awserr.Error to get the Code and 65 // Message from an error. 66 fmt.Println(err.Error()) 67 } 68 return 69 } 70 71 fmt.Println(result) 72 } 73 74 // Create assessment target 75 // 76 // Creates a new assessment target using the ARN of the resource group that is generated 77 // by CreateResourceGroup. You can create up to 50 assessment targets per AWS account. 78 // You can run up to 500 concurrent agents per AWS account. 79 func ExampleInspector_CreateAssessmentTarget_shared00() { 80 svc := inspector.New(session.New()) 81 input := &inspector.CreateAssessmentTargetInput{ 82 AssessmentTargetName: aws.String("ExampleAssessmentTarget"), 83 ResourceGroupArn: aws.String("arn:aws:inspector:us-west-2:123456789012:resourcegroup/0-AB6DMKnv"), 84 } 85 86 result, err := svc.CreateAssessmentTarget(input) 87 if err != nil { 88 if aerr, ok := err.(awserr.Error); ok { 89 switch aerr.Code() { 90 case inspector.ErrCodeInternalException: 91 fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) 92 case inspector.ErrCodeInvalidInputException: 93 fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) 94 case inspector.ErrCodeLimitExceededException: 95 fmt.Println(inspector.ErrCodeLimitExceededException, aerr.Error()) 96 case inspector.ErrCodeAccessDeniedException: 97 fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) 98 case inspector.ErrCodeNoSuchEntityException: 99 fmt.Println(inspector.ErrCodeNoSuchEntityException, aerr.Error()) 100 case inspector.ErrCodeInvalidCrossAccountRoleException: 101 fmt.Println(inspector.ErrCodeInvalidCrossAccountRoleException, aerr.Error()) 102 case inspector.ErrCodeServiceTemporarilyUnavailableException: 103 fmt.Println(inspector.ErrCodeServiceTemporarilyUnavailableException, aerr.Error()) 104 default: 105 fmt.Println(aerr.Error()) 106 } 107 } else { 108 // Print the error, cast err to awserr.Error to get the Code and 109 // Message from an error. 110 fmt.Println(err.Error()) 111 } 112 return 113 } 114 115 fmt.Println(result) 116 } 117 118 // Create assessment template 119 // 120 // Creates an assessment template for the assessment target that is specified by the 121 // ARN of the assessment target. 122 func ExampleInspector_CreateAssessmentTemplate_shared00() { 123 svc := inspector.New(session.New()) 124 input := &inspector.CreateAssessmentTemplateInput{ 125 AssessmentTargetArn: aws.String("arn:aws:inspector:us-west-2:123456789012:target/0-nvgVhaxX"), 126 AssessmentTemplateName: aws.String("ExampleAssessmentTemplate"), 127 DurationInSeconds: aws.Int64(180), 128 RulesPackageArns: []*string{ 129 aws.String("arn:aws:inspector:us-west-2:758058086616:rulespackage/0-11B9DBXp"), 130 }, 131 UserAttributesForFindings: []*inspector.Attribute{ 132 { 133 Key: aws.String("Example"), 134 Value: aws.String("example"), 135 }, 136 }, 137 } 138 139 result, err := svc.CreateAssessmentTemplate(input) 140 if err != nil { 141 if aerr, ok := err.(awserr.Error); ok { 142 switch aerr.Code() { 143 case inspector.ErrCodeInternalException: 144 fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) 145 case inspector.ErrCodeInvalidInputException: 146 fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) 147 case inspector.ErrCodeLimitExceededException: 148 fmt.Println(inspector.ErrCodeLimitExceededException, aerr.Error()) 149 case inspector.ErrCodeAccessDeniedException: 150 fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) 151 case inspector.ErrCodeNoSuchEntityException: 152 fmt.Println(inspector.ErrCodeNoSuchEntityException, aerr.Error()) 153 case inspector.ErrCodeServiceTemporarilyUnavailableException: 154 fmt.Println(inspector.ErrCodeServiceTemporarilyUnavailableException, aerr.Error()) 155 default: 156 fmt.Println(aerr.Error()) 157 } 158 } else { 159 // Print the error, cast err to awserr.Error to get the Code and 160 // Message from an error. 161 fmt.Println(err.Error()) 162 } 163 return 164 } 165 166 fmt.Println(result) 167 } 168 169 // Create resource group 170 // 171 // Creates a resource group using the specified set of tags (key and value pairs) that 172 // are used to select the EC2 instances to be included in an Amazon Inspector assessment 173 // target. The created resource group is then used to create an Amazon Inspector assessment 174 // target. 175 func ExampleInspector_CreateResourceGroup_shared00() { 176 svc := inspector.New(session.New()) 177 input := &inspector.CreateResourceGroupInput{ 178 ResourceGroupTags: []*inspector.ResourceGroupTag{ 179 { 180 Key: aws.String("Name"), 181 Value: aws.String("example"), 182 }, 183 }, 184 } 185 186 result, err := svc.CreateResourceGroup(input) 187 if err != nil { 188 if aerr, ok := err.(awserr.Error); ok { 189 switch aerr.Code() { 190 case inspector.ErrCodeInternalException: 191 fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) 192 case inspector.ErrCodeInvalidInputException: 193 fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) 194 case inspector.ErrCodeLimitExceededException: 195 fmt.Println(inspector.ErrCodeLimitExceededException, aerr.Error()) 196 case inspector.ErrCodeAccessDeniedException: 197 fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) 198 case inspector.ErrCodeServiceTemporarilyUnavailableException: 199 fmt.Println(inspector.ErrCodeServiceTemporarilyUnavailableException, aerr.Error()) 200 default: 201 fmt.Println(aerr.Error()) 202 } 203 } else { 204 // Print the error, cast err to awserr.Error to get the Code and 205 // Message from an error. 206 fmt.Println(err.Error()) 207 } 208 return 209 } 210 211 fmt.Println(result) 212 } 213 214 // Delete assessment run 215 // 216 // Deletes the assessment run that is specified by the ARN of the assessment run. 217 func ExampleInspector_DeleteAssessmentRun_shared00() { 218 svc := inspector.New(session.New()) 219 input := &inspector.DeleteAssessmentRunInput{ 220 AssessmentRunArn: aws.String("arn:aws:inspector:us-west-2:123456789012:target/0-nvgVhaxX/template/0-it5r2S4T/run/0-11LMTAVe"), 221 } 222 223 result, err := svc.DeleteAssessmentRun(input) 224 if err != nil { 225 if aerr, ok := err.(awserr.Error); ok { 226 switch aerr.Code() { 227 case inspector.ErrCodeInternalException: 228 fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) 229 case inspector.ErrCodeInvalidInputException: 230 fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) 231 case inspector.ErrCodeAssessmentRunInProgressException: 232 fmt.Println(inspector.ErrCodeAssessmentRunInProgressException, aerr.Error()) 233 case inspector.ErrCodeAccessDeniedException: 234 fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) 235 case inspector.ErrCodeNoSuchEntityException: 236 fmt.Println(inspector.ErrCodeNoSuchEntityException, aerr.Error()) 237 case inspector.ErrCodeServiceTemporarilyUnavailableException: 238 fmt.Println(inspector.ErrCodeServiceTemporarilyUnavailableException, aerr.Error()) 239 default: 240 fmt.Println(aerr.Error()) 241 } 242 } else { 243 // Print the error, cast err to awserr.Error to get the Code and 244 // Message from an error. 245 fmt.Println(err.Error()) 246 } 247 return 248 } 249 250 fmt.Println(result) 251 } 252 253 // Delete assessment target 254 // 255 // Deletes the assessment target that is specified by the ARN of the assessment target. 256 func ExampleInspector_DeleteAssessmentTarget_shared00() { 257 svc := inspector.New(session.New()) 258 input := &inspector.DeleteAssessmentTargetInput{ 259 AssessmentTargetArn: aws.String("arn:aws:inspector:us-west-2:123456789012:target/0-0kFIPusq"), 260 } 261 262 result, err := svc.DeleteAssessmentTarget(input) 263 if err != nil { 264 if aerr, ok := err.(awserr.Error); ok { 265 switch aerr.Code() { 266 case inspector.ErrCodeInternalException: 267 fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) 268 case inspector.ErrCodeInvalidInputException: 269 fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) 270 case inspector.ErrCodeAssessmentRunInProgressException: 271 fmt.Println(inspector.ErrCodeAssessmentRunInProgressException, aerr.Error()) 272 case inspector.ErrCodeAccessDeniedException: 273 fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) 274 case inspector.ErrCodeNoSuchEntityException: 275 fmt.Println(inspector.ErrCodeNoSuchEntityException, aerr.Error()) 276 case inspector.ErrCodeServiceTemporarilyUnavailableException: 277 fmt.Println(inspector.ErrCodeServiceTemporarilyUnavailableException, aerr.Error()) 278 default: 279 fmt.Println(aerr.Error()) 280 } 281 } else { 282 // Print the error, cast err to awserr.Error to get the Code and 283 // Message from an error. 284 fmt.Println(err.Error()) 285 } 286 return 287 } 288 289 fmt.Println(result) 290 } 291 292 // Delete assessment template 293 // 294 // Deletes the assessment template that is specified by the ARN of the assessment template. 295 func ExampleInspector_DeleteAssessmentTemplate_shared00() { 296 svc := inspector.New(session.New()) 297 input := &inspector.DeleteAssessmentTemplateInput{ 298 AssessmentTemplateArn: aws.String("arn:aws:inspector:us-west-2:123456789012:target/0-nvgVhaxX/template/0-it5r2S4T"), 299 } 300 301 result, err := svc.DeleteAssessmentTemplate(input) 302 if err != nil { 303 if aerr, ok := err.(awserr.Error); ok { 304 switch aerr.Code() { 305 case inspector.ErrCodeInternalException: 306 fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) 307 case inspector.ErrCodeInvalidInputException: 308 fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) 309 case inspector.ErrCodeAssessmentRunInProgressException: 310 fmt.Println(inspector.ErrCodeAssessmentRunInProgressException, aerr.Error()) 311 case inspector.ErrCodeAccessDeniedException: 312 fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) 313 case inspector.ErrCodeNoSuchEntityException: 314 fmt.Println(inspector.ErrCodeNoSuchEntityException, aerr.Error()) 315 case inspector.ErrCodeServiceTemporarilyUnavailableException: 316 fmt.Println(inspector.ErrCodeServiceTemporarilyUnavailableException, aerr.Error()) 317 default: 318 fmt.Println(aerr.Error()) 319 } 320 } else { 321 // Print the error, cast err to awserr.Error to get the Code and 322 // Message from an error. 323 fmt.Println(err.Error()) 324 } 325 return 326 } 327 328 fmt.Println(result) 329 } 330 331 // Describte assessment runs 332 // 333 // Describes the assessment runs that are specified by the ARNs of the assessment runs. 334 func ExampleInspector_DescribeAssessmentRuns_shared00() { 335 svc := inspector.New(session.New()) 336 input := &inspector.DescribeAssessmentRunsInput{ 337 AssessmentRunArns: []*string{ 338 aws.String("arn:aws:inspector:us-west-2:123456789012:target/0-0kFIPusq/template/0-4r1V2mAw/run/0-MKkpXXPE"), 339 }, 340 } 341 342 result, err := svc.DescribeAssessmentRuns(input) 343 if err != nil { 344 if aerr, ok := err.(awserr.Error); ok { 345 switch aerr.Code() { 346 case inspector.ErrCodeInternalException: 347 fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) 348 case inspector.ErrCodeInvalidInputException: 349 fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) 350 default: 351 fmt.Println(aerr.Error()) 352 } 353 } else { 354 // Print the error, cast err to awserr.Error to get the Code and 355 // Message from an error. 356 fmt.Println(err.Error()) 357 } 358 return 359 } 360 361 fmt.Println(result) 362 } 363 364 // Describte assessment targets 365 // 366 // Describes the assessment targets that are specified by the ARNs of the assessment 367 // targets. 368 func ExampleInspector_DescribeAssessmentTargets_shared00() { 369 svc := inspector.New(session.New()) 370 input := &inspector.DescribeAssessmentTargetsInput{ 371 AssessmentTargetArns: []*string{ 372 aws.String("arn:aws:inspector:us-west-2:123456789012:target/0-0kFIPusq"), 373 }, 374 } 375 376 result, err := svc.DescribeAssessmentTargets(input) 377 if err != nil { 378 if aerr, ok := err.(awserr.Error); ok { 379 switch aerr.Code() { 380 case inspector.ErrCodeInternalException: 381 fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) 382 case inspector.ErrCodeInvalidInputException: 383 fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) 384 default: 385 fmt.Println(aerr.Error()) 386 } 387 } else { 388 // Print the error, cast err to awserr.Error to get the Code and 389 // Message from an error. 390 fmt.Println(err.Error()) 391 } 392 return 393 } 394 395 fmt.Println(result) 396 } 397 398 // Describte assessment templates 399 // 400 // Describes the assessment templates that are specified by the ARNs of the assessment 401 // templates. 402 func ExampleInspector_DescribeAssessmentTemplates_shared00() { 403 svc := inspector.New(session.New()) 404 input := &inspector.DescribeAssessmentTemplatesInput{ 405 AssessmentTemplateArns: []*string{ 406 aws.String("arn:aws:inspector:us-west-2:123456789012:target/0-0kFIPusq/template/0-4r1V2mAw"), 407 }, 408 } 409 410 result, err := svc.DescribeAssessmentTemplates(input) 411 if err != nil { 412 if aerr, ok := err.(awserr.Error); ok { 413 switch aerr.Code() { 414 case inspector.ErrCodeInternalException: 415 fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) 416 case inspector.ErrCodeInvalidInputException: 417 fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) 418 default: 419 fmt.Println(aerr.Error()) 420 } 421 } else { 422 // Print the error, cast err to awserr.Error to get the Code and 423 // Message from an error. 424 fmt.Println(err.Error()) 425 } 426 return 427 } 428 429 fmt.Println(result) 430 } 431 432 // Describte cross account access role 433 // 434 // Describes the IAM role that enables Amazon Inspector to access your AWS account. 435 func ExampleInspector_DescribeCrossAccountAccessRole_shared00() { 436 svc := inspector.New(session.New()) 437 input := &inspector.DescribeCrossAccountAccessRoleInput{} 438 439 result, err := svc.DescribeCrossAccountAccessRole(input) 440 if err != nil { 441 if aerr, ok := err.(awserr.Error); ok { 442 switch aerr.Code() { 443 case inspector.ErrCodeInternalException: 444 fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) 445 default: 446 fmt.Println(aerr.Error()) 447 } 448 } else { 449 // Print the error, cast err to awserr.Error to get the Code and 450 // Message from an error. 451 fmt.Println(err.Error()) 452 } 453 return 454 } 455 456 fmt.Println(result) 457 } 458 459 // Describe findings 460 // 461 // Describes the findings that are specified by the ARNs of the findings. 462 func ExampleInspector_DescribeFindings_shared00() { 463 svc := inspector.New(session.New()) 464 input := &inspector.DescribeFindingsInput{ 465 FindingArns: []*string{ 466 aws.String("arn:aws:inspector:us-west-2:123456789012:target/0-0kFIPusq/template/0-4r1V2mAw/run/0-MKkpXXPE/finding/0-HwPnsDm4"), 467 }, 468 } 469 470 result, err := svc.DescribeFindings(input) 471 if err != nil { 472 if aerr, ok := err.(awserr.Error); ok { 473 switch aerr.Code() { 474 case inspector.ErrCodeInternalException: 475 fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) 476 case inspector.ErrCodeInvalidInputException: 477 fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) 478 default: 479 fmt.Println(aerr.Error()) 480 } 481 } else { 482 // Print the error, cast err to awserr.Error to get the Code and 483 // Message from an error. 484 fmt.Println(err.Error()) 485 } 486 return 487 } 488 489 fmt.Println(result) 490 } 491 492 // Describe resource groups 493 // 494 // Describes the resource groups that are specified by the ARNs of the resource groups. 495 func ExampleInspector_DescribeResourceGroups_shared00() { 496 svc := inspector.New(session.New()) 497 input := &inspector.DescribeResourceGroupsInput{ 498 ResourceGroupArns: []*string{ 499 aws.String("arn:aws:inspector:us-west-2:123456789012:resourcegroup/0-PyGXopAI"), 500 }, 501 } 502 503 result, err := svc.DescribeResourceGroups(input) 504 if err != nil { 505 if aerr, ok := err.(awserr.Error); ok { 506 switch aerr.Code() { 507 case inspector.ErrCodeInternalException: 508 fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) 509 case inspector.ErrCodeInvalidInputException: 510 fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) 511 default: 512 fmt.Println(aerr.Error()) 513 } 514 } else { 515 // Print the error, cast err to awserr.Error to get the Code and 516 // Message from an error. 517 fmt.Println(err.Error()) 518 } 519 return 520 } 521 522 fmt.Println(result) 523 } 524 525 // Describe rules packages 526 // 527 // Describes the rules packages that are specified by the ARNs of the rules packages. 528 func ExampleInspector_DescribeRulesPackages_shared00() { 529 svc := inspector.New(session.New()) 530 input := &inspector.DescribeRulesPackagesInput{ 531 RulesPackageArns: []*string{ 532 aws.String("arn:aws:inspector:us-west-2:758058086616:rulespackage/0-JJOtZiqQ"), 533 }, 534 } 535 536 result, err := svc.DescribeRulesPackages(input) 537 if err != nil { 538 if aerr, ok := err.(awserr.Error); ok { 539 switch aerr.Code() { 540 case inspector.ErrCodeInternalException: 541 fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) 542 case inspector.ErrCodeInvalidInputException: 543 fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) 544 default: 545 fmt.Println(aerr.Error()) 546 } 547 } else { 548 // Print the error, cast err to awserr.Error to get the Code and 549 // Message from an error. 550 fmt.Println(err.Error()) 551 } 552 return 553 } 554 555 fmt.Println(result) 556 } 557 558 // Get telemetry metadata 559 // 560 // Information about the data that is collected for the specified assessment run. 561 func ExampleInspector_GetTelemetryMetadata_shared00() { 562 svc := inspector.New(session.New()) 563 input := &inspector.GetTelemetryMetadataInput{ 564 AssessmentRunArn: aws.String("arn:aws:inspector:us-west-2:123456789012:target/0-0kFIPusq/template/0-4r1V2mAw/run/0-MKkpXXPE"), 565 } 566 567 result, err := svc.GetTelemetryMetadata(input) 568 if err != nil { 569 if aerr, ok := err.(awserr.Error); ok { 570 switch aerr.Code() { 571 case inspector.ErrCodeInternalException: 572 fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) 573 case inspector.ErrCodeInvalidInputException: 574 fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) 575 case inspector.ErrCodeAccessDeniedException: 576 fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) 577 case inspector.ErrCodeNoSuchEntityException: 578 fmt.Println(inspector.ErrCodeNoSuchEntityException, aerr.Error()) 579 default: 580 fmt.Println(aerr.Error()) 581 } 582 } else { 583 // Print the error, cast err to awserr.Error to get the Code and 584 // Message from an error. 585 fmt.Println(err.Error()) 586 } 587 return 588 } 589 590 fmt.Println(result) 591 } 592 593 // List assessment run agents 594 // 595 // Lists the agents of the assessment runs that are specified by the ARNs of the assessment 596 // runs. 597 func ExampleInspector_ListAssessmentRunAgents_shared00() { 598 svc := inspector.New(session.New()) 599 input := &inspector.ListAssessmentRunAgentsInput{ 600 AssessmentRunArn: aws.String("arn:aws:inspector:us-west-2:123456789012:target/0-0kFIPusq/template/0-4r1V2mAw/run/0-MKkpXXPE"), 601 MaxResults: aws.Int64(123), 602 } 603 604 result, err := svc.ListAssessmentRunAgents(input) 605 if err != nil { 606 if aerr, ok := err.(awserr.Error); ok { 607 switch aerr.Code() { 608 case inspector.ErrCodeInternalException: 609 fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) 610 case inspector.ErrCodeInvalidInputException: 611 fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) 612 case inspector.ErrCodeAccessDeniedException: 613 fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) 614 case inspector.ErrCodeNoSuchEntityException: 615 fmt.Println(inspector.ErrCodeNoSuchEntityException, aerr.Error()) 616 default: 617 fmt.Println(aerr.Error()) 618 } 619 } else { 620 // Print the error, cast err to awserr.Error to get the Code and 621 // Message from an error. 622 fmt.Println(err.Error()) 623 } 624 return 625 } 626 627 fmt.Println(result) 628 } 629 630 // List assessment runs 631 // 632 // Lists the assessment runs that correspond to the assessment templates that are specified 633 // by the ARNs of the assessment templates. 634 func ExampleInspector_ListAssessmentRuns_shared00() { 635 svc := inspector.New(session.New()) 636 input := &inspector.ListAssessmentRunsInput{ 637 AssessmentTemplateArns: []*string{ 638 aws.String("arn:aws:inspector:us-west-2:123456789012:target/0-0kFIPusq/template/0-4r1V2mAw"), 639 }, 640 MaxResults: aws.Int64(123), 641 } 642 643 result, err := svc.ListAssessmentRuns(input) 644 if err != nil { 645 if aerr, ok := err.(awserr.Error); ok { 646 switch aerr.Code() { 647 case inspector.ErrCodeInternalException: 648 fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) 649 case inspector.ErrCodeInvalidInputException: 650 fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) 651 case inspector.ErrCodeAccessDeniedException: 652 fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) 653 case inspector.ErrCodeNoSuchEntityException: 654 fmt.Println(inspector.ErrCodeNoSuchEntityException, aerr.Error()) 655 default: 656 fmt.Println(aerr.Error()) 657 } 658 } else { 659 // Print the error, cast err to awserr.Error to get the Code and 660 // Message from an error. 661 fmt.Println(err.Error()) 662 } 663 return 664 } 665 666 fmt.Println(result) 667 } 668 669 // List assessment targets 670 // 671 // Lists the ARNs of the assessment targets within this AWS account. 672 func ExampleInspector_ListAssessmentTargets_shared00() { 673 svc := inspector.New(session.New()) 674 input := &inspector.ListAssessmentTargetsInput{ 675 MaxResults: aws.Int64(123), 676 } 677 678 result, err := svc.ListAssessmentTargets(input) 679 if err != nil { 680 if aerr, ok := err.(awserr.Error); ok { 681 switch aerr.Code() { 682 case inspector.ErrCodeInternalException: 683 fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) 684 case inspector.ErrCodeInvalidInputException: 685 fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) 686 case inspector.ErrCodeAccessDeniedException: 687 fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) 688 default: 689 fmt.Println(aerr.Error()) 690 } 691 } else { 692 // Print the error, cast err to awserr.Error to get the Code and 693 // Message from an error. 694 fmt.Println(err.Error()) 695 } 696 return 697 } 698 699 fmt.Println(result) 700 } 701 702 // List assessment templates 703 // 704 // Lists the assessment templates that correspond to the assessment targets that are 705 // specified by the ARNs of the assessment targets. 706 func ExampleInspector_ListAssessmentTemplates_shared00() { 707 svc := inspector.New(session.New()) 708 input := &inspector.ListAssessmentTemplatesInput{ 709 AssessmentTargetArns: []*string{ 710 aws.String("arn:aws:inspector:us-west-2:123456789012:target/0-0kFIPusq"), 711 }, 712 MaxResults: aws.Int64(123), 713 } 714 715 result, err := svc.ListAssessmentTemplates(input) 716 if err != nil { 717 if aerr, ok := err.(awserr.Error); ok { 718 switch aerr.Code() { 719 case inspector.ErrCodeInternalException: 720 fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) 721 case inspector.ErrCodeInvalidInputException: 722 fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) 723 case inspector.ErrCodeAccessDeniedException: 724 fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) 725 case inspector.ErrCodeNoSuchEntityException: 726 fmt.Println(inspector.ErrCodeNoSuchEntityException, aerr.Error()) 727 default: 728 fmt.Println(aerr.Error()) 729 } 730 } else { 731 // Print the error, cast err to awserr.Error to get the Code and 732 // Message from an error. 733 fmt.Println(err.Error()) 734 } 735 return 736 } 737 738 fmt.Println(result) 739 } 740 741 // List event subscriptions 742 // 743 // Lists all the event subscriptions for the assessment template that is specified by 744 // the ARN of the assessment template. 745 func ExampleInspector_ListEventSubscriptions_shared00() { 746 svc := inspector.New(session.New()) 747 input := &inspector.ListEventSubscriptionsInput{ 748 MaxResults: aws.Int64(123), 749 ResourceArn: aws.String("arn:aws:inspector:us-west-2:123456789012:target/0-nvgVhaxX/template/0-7sbz2Kz0"), 750 } 751 752 result, err := svc.ListEventSubscriptions(input) 753 if err != nil { 754 if aerr, ok := err.(awserr.Error); ok { 755 switch aerr.Code() { 756 case inspector.ErrCodeInternalException: 757 fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) 758 case inspector.ErrCodeInvalidInputException: 759 fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) 760 case inspector.ErrCodeAccessDeniedException: 761 fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) 762 case inspector.ErrCodeNoSuchEntityException: 763 fmt.Println(inspector.ErrCodeNoSuchEntityException, aerr.Error()) 764 default: 765 fmt.Println(aerr.Error()) 766 } 767 } else { 768 // Print the error, cast err to awserr.Error to get the Code and 769 // Message from an error. 770 fmt.Println(err.Error()) 771 } 772 return 773 } 774 775 fmt.Println(result) 776 } 777 778 // List findings 779 // 780 // Lists findings that are generated by the assessment runs that are specified by the 781 // ARNs of the assessment runs. 782 func ExampleInspector_ListFindings_shared00() { 783 svc := inspector.New(session.New()) 784 input := &inspector.ListFindingsInput{ 785 AssessmentRunArns: []*string{ 786 aws.String("arn:aws:inspector:us-west-2:123456789012:target/0-0kFIPusq/template/0-4r1V2mAw/run/0-MKkpXXPE"), 787 }, 788 MaxResults: aws.Int64(123), 789 } 790 791 result, err := svc.ListFindings(input) 792 if err != nil { 793 if aerr, ok := err.(awserr.Error); ok { 794 switch aerr.Code() { 795 case inspector.ErrCodeInternalException: 796 fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) 797 case inspector.ErrCodeInvalidInputException: 798 fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) 799 case inspector.ErrCodeAccessDeniedException: 800 fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) 801 case inspector.ErrCodeNoSuchEntityException: 802 fmt.Println(inspector.ErrCodeNoSuchEntityException, aerr.Error()) 803 default: 804 fmt.Println(aerr.Error()) 805 } 806 } else { 807 // Print the error, cast err to awserr.Error to get the Code and 808 // Message from an error. 809 fmt.Println(err.Error()) 810 } 811 return 812 } 813 814 fmt.Println(result) 815 } 816 817 // List rules packages 818 // 819 // Lists all available Amazon Inspector rules packages. 820 func ExampleInspector_ListRulesPackages_shared00() { 821 svc := inspector.New(session.New()) 822 input := &inspector.ListRulesPackagesInput{ 823 MaxResults: aws.Int64(123), 824 } 825 826 result, err := svc.ListRulesPackages(input) 827 if err != nil { 828 if aerr, ok := err.(awserr.Error); ok { 829 switch aerr.Code() { 830 case inspector.ErrCodeInternalException: 831 fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) 832 case inspector.ErrCodeInvalidInputException: 833 fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) 834 case inspector.ErrCodeAccessDeniedException: 835 fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) 836 default: 837 fmt.Println(aerr.Error()) 838 } 839 } else { 840 // Print the error, cast err to awserr.Error to get the Code and 841 // Message from an error. 842 fmt.Println(err.Error()) 843 } 844 return 845 } 846 847 fmt.Println(result) 848 } 849 850 // List tags for resource 851 // 852 // Lists all tags associated with an assessment template. 853 func ExampleInspector_ListTagsForResource_shared00() { 854 svc := inspector.New(session.New()) 855 input := &inspector.ListTagsForResourceInput{ 856 ResourceArn: aws.String("arn:aws:inspector:us-west-2:123456789012:target/0-0kFIPusq/template/0-gcwFliYu"), 857 } 858 859 result, err := svc.ListTagsForResource(input) 860 if err != nil { 861 if aerr, ok := err.(awserr.Error); ok { 862 switch aerr.Code() { 863 case inspector.ErrCodeInternalException: 864 fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) 865 case inspector.ErrCodeInvalidInputException: 866 fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) 867 case inspector.ErrCodeAccessDeniedException: 868 fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) 869 case inspector.ErrCodeNoSuchEntityException: 870 fmt.Println(inspector.ErrCodeNoSuchEntityException, aerr.Error()) 871 default: 872 fmt.Println(aerr.Error()) 873 } 874 } else { 875 // Print the error, cast err to awserr.Error to get the Code and 876 // Message from an error. 877 fmt.Println(err.Error()) 878 } 879 return 880 } 881 882 fmt.Println(result) 883 } 884 885 // Preview agents 886 // 887 // Previews the agents installed on the EC2 instances that are part of the specified 888 // assessment target. 889 func ExampleInspector_PreviewAgents_shared00() { 890 svc := inspector.New(session.New()) 891 input := &inspector.PreviewAgentsInput{ 892 MaxResults: aws.Int64(123), 893 PreviewAgentsArn: aws.String("arn:aws:inspector:us-west-2:123456789012:target/0-0kFIPusq"), 894 } 895 896 result, err := svc.PreviewAgents(input) 897 if err != nil { 898 if aerr, ok := err.(awserr.Error); ok { 899 switch aerr.Code() { 900 case inspector.ErrCodeInternalException: 901 fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) 902 case inspector.ErrCodeInvalidInputException: 903 fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) 904 case inspector.ErrCodeAccessDeniedException: 905 fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) 906 case inspector.ErrCodeNoSuchEntityException: 907 fmt.Println(inspector.ErrCodeNoSuchEntityException, aerr.Error()) 908 case inspector.ErrCodeInvalidCrossAccountRoleException: 909 fmt.Println(inspector.ErrCodeInvalidCrossAccountRoleException, aerr.Error()) 910 default: 911 fmt.Println(aerr.Error()) 912 } 913 } else { 914 // Print the error, cast err to awserr.Error to get the Code and 915 // Message from an error. 916 fmt.Println(err.Error()) 917 } 918 return 919 } 920 921 fmt.Println(result) 922 } 923 924 // Register cross account access role 925 // 926 // Registers the IAM role that Amazon Inspector uses to list your EC2 instances at the 927 // start of the assessment run or when you call the PreviewAgents action. 928 func ExampleInspector_RegisterCrossAccountAccessRole_shared00() { 929 svc := inspector.New(session.New()) 930 input := &inspector.RegisterCrossAccountAccessRoleInput{ 931 RoleArn: aws.String("arn:aws:iam::123456789012:role/inspector"), 932 } 933 934 result, err := svc.RegisterCrossAccountAccessRole(input) 935 if err != nil { 936 if aerr, ok := err.(awserr.Error); ok { 937 switch aerr.Code() { 938 case inspector.ErrCodeInternalException: 939 fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) 940 case inspector.ErrCodeInvalidInputException: 941 fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) 942 case inspector.ErrCodeAccessDeniedException: 943 fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) 944 case inspector.ErrCodeInvalidCrossAccountRoleException: 945 fmt.Println(inspector.ErrCodeInvalidCrossAccountRoleException, aerr.Error()) 946 case inspector.ErrCodeServiceTemporarilyUnavailableException: 947 fmt.Println(inspector.ErrCodeServiceTemporarilyUnavailableException, aerr.Error()) 948 default: 949 fmt.Println(aerr.Error()) 950 } 951 } else { 952 // Print the error, cast err to awserr.Error to get the Code and 953 // Message from an error. 954 fmt.Println(err.Error()) 955 } 956 return 957 } 958 959 fmt.Println(result) 960 } 961 962 // Remove attributes from findings 963 // 964 // Removes entire attributes (key and value pairs) from the findings that are specified 965 // by the ARNs of the findings where an attribute with the specified key exists. 966 func ExampleInspector_RemoveAttributesFromFindings_shared00() { 967 svc := inspector.New(session.New()) 968 input := &inspector.RemoveAttributesFromFindingsInput{ 969 AttributeKeys: []*string{ 970 aws.String("key=Example,value=example"), 971 }, 972 FindingArns: []*string{ 973 aws.String("arn:aws:inspector:us-west-2:123456789012:target/0-0kFIPusq/template/0-8l1VIE0D/run/0-Z02cjjug/finding/0-T8yM9mEU"), 974 }, 975 } 976 977 result, err := svc.RemoveAttributesFromFindings(input) 978 if err != nil { 979 if aerr, ok := err.(awserr.Error); ok { 980 switch aerr.Code() { 981 case inspector.ErrCodeInternalException: 982 fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) 983 case inspector.ErrCodeInvalidInputException: 984 fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) 985 case inspector.ErrCodeAccessDeniedException: 986 fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) 987 case inspector.ErrCodeNoSuchEntityException: 988 fmt.Println(inspector.ErrCodeNoSuchEntityException, aerr.Error()) 989 case inspector.ErrCodeServiceTemporarilyUnavailableException: 990 fmt.Println(inspector.ErrCodeServiceTemporarilyUnavailableException, aerr.Error()) 991 default: 992 fmt.Println(aerr.Error()) 993 } 994 } else { 995 // Print the error, cast err to awserr.Error to get the Code and 996 // Message from an error. 997 fmt.Println(err.Error()) 998 } 999 return 1000 } 1001 1002 fmt.Println(result) 1003 } 1004 1005 // Set tags for resource 1006 // 1007 // Sets tags (key and value pairs) to the assessment template that is specified by the 1008 // ARN of the assessment template. 1009 func ExampleInspector_SetTagsForResource_shared00() { 1010 svc := inspector.New(session.New()) 1011 input := &inspector.SetTagsForResourceInput{ 1012 ResourceArn: aws.String("arn:aws:inspector:us-west-2:123456789012:target/0-nvgVhaxX/template/0-7sbz2Kz0"), 1013 Tags: []*inspector.Tag{ 1014 { 1015 Key: aws.String("Example"), 1016 Value: aws.String("example"), 1017 }, 1018 }, 1019 } 1020 1021 result, err := svc.SetTagsForResource(input) 1022 if err != nil { 1023 if aerr, ok := err.(awserr.Error); ok { 1024 switch aerr.Code() { 1025 case inspector.ErrCodeInternalException: 1026 fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) 1027 case inspector.ErrCodeInvalidInputException: 1028 fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) 1029 case inspector.ErrCodeAccessDeniedException: 1030 fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) 1031 case inspector.ErrCodeNoSuchEntityException: 1032 fmt.Println(inspector.ErrCodeNoSuchEntityException, aerr.Error()) 1033 case inspector.ErrCodeServiceTemporarilyUnavailableException: 1034 fmt.Println(inspector.ErrCodeServiceTemporarilyUnavailableException, aerr.Error()) 1035 default: 1036 fmt.Println(aerr.Error()) 1037 } 1038 } else { 1039 // Print the error, cast err to awserr.Error to get the Code and 1040 // Message from an error. 1041 fmt.Println(err.Error()) 1042 } 1043 return 1044 } 1045 1046 fmt.Println(result) 1047 } 1048 1049 // Start assessment run 1050 // 1051 // Starts the assessment run specified by the ARN of the assessment template. For this 1052 // API to function properly, you must not exceed the limit of running up to 500 concurrent 1053 // agents per AWS account. 1054 func ExampleInspector_StartAssessmentRun_shared00() { 1055 svc := inspector.New(session.New()) 1056 input := &inspector.StartAssessmentRunInput{ 1057 AssessmentRunName: aws.String("examplerun"), 1058 AssessmentTemplateArn: aws.String("arn:aws:inspector:us-west-2:123456789012:target/0-nvgVhaxX/template/0-it5r2S4T"), 1059 } 1060 1061 result, err := svc.StartAssessmentRun(input) 1062 if err != nil { 1063 if aerr, ok := err.(awserr.Error); ok { 1064 switch aerr.Code() { 1065 case inspector.ErrCodeInternalException: 1066 fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) 1067 case inspector.ErrCodeInvalidInputException: 1068 fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) 1069 case inspector.ErrCodeLimitExceededException: 1070 fmt.Println(inspector.ErrCodeLimitExceededException, aerr.Error()) 1071 case inspector.ErrCodeAccessDeniedException: 1072 fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) 1073 case inspector.ErrCodeNoSuchEntityException: 1074 fmt.Println(inspector.ErrCodeNoSuchEntityException, aerr.Error()) 1075 case inspector.ErrCodeInvalidCrossAccountRoleException: 1076 fmt.Println(inspector.ErrCodeInvalidCrossAccountRoleException, aerr.Error()) 1077 case inspector.ErrCodeAgentsAlreadyRunningAssessmentException: 1078 fmt.Println(inspector.ErrCodeAgentsAlreadyRunningAssessmentException, aerr.Error()) 1079 case inspector.ErrCodeServiceTemporarilyUnavailableException: 1080 fmt.Println(inspector.ErrCodeServiceTemporarilyUnavailableException, aerr.Error()) 1081 default: 1082 fmt.Println(aerr.Error()) 1083 } 1084 } else { 1085 // Print the error, cast err to awserr.Error to get the Code and 1086 // Message from an error. 1087 fmt.Println(err.Error()) 1088 } 1089 return 1090 } 1091 1092 fmt.Println(result) 1093 } 1094 1095 // Stop assessment run 1096 // 1097 // Stops the assessment run that is specified by the ARN of the assessment run. 1098 func ExampleInspector_StopAssessmentRun_shared00() { 1099 svc := inspector.New(session.New()) 1100 input := &inspector.StopAssessmentRunInput{ 1101 AssessmentRunArn: aws.String("arn:aws:inspector:us-west-2:123456789012:target/0-nvgVhaxX/template/0-it5r2S4T/run/0-11LMTAVe"), 1102 } 1103 1104 result, err := svc.StopAssessmentRun(input) 1105 if err != nil { 1106 if aerr, ok := err.(awserr.Error); ok { 1107 switch aerr.Code() { 1108 case inspector.ErrCodeInternalException: 1109 fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) 1110 case inspector.ErrCodeInvalidInputException: 1111 fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) 1112 case inspector.ErrCodeAccessDeniedException: 1113 fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) 1114 case inspector.ErrCodeNoSuchEntityException: 1115 fmt.Println(inspector.ErrCodeNoSuchEntityException, aerr.Error()) 1116 case inspector.ErrCodeServiceTemporarilyUnavailableException: 1117 fmt.Println(inspector.ErrCodeServiceTemporarilyUnavailableException, aerr.Error()) 1118 default: 1119 fmt.Println(aerr.Error()) 1120 } 1121 } else { 1122 // Print the error, cast err to awserr.Error to get the Code and 1123 // Message from an error. 1124 fmt.Println(err.Error()) 1125 } 1126 return 1127 } 1128 1129 fmt.Println(result) 1130 } 1131 1132 // Subscribe to event 1133 // 1134 // Enables the process of sending Amazon Simple Notification Service (SNS) notifications 1135 // about a specified event to a specified SNS topic. 1136 func ExampleInspector_SubscribeToEvent_shared00() { 1137 svc := inspector.New(session.New()) 1138 input := &inspector.SubscribeToEventInput{ 1139 Event: aws.String("ASSESSMENT_RUN_COMPLETED"), 1140 ResourceArn: aws.String("arn:aws:inspector:us-west-2:123456789012:target/0-nvgVhaxX/template/0-7sbz2Kz0"), 1141 TopicArn: aws.String("arn:aws:sns:us-west-2:123456789012:exampletopic"), 1142 } 1143 1144 result, err := svc.SubscribeToEvent(input) 1145 if err != nil { 1146 if aerr, ok := err.(awserr.Error); ok { 1147 switch aerr.Code() { 1148 case inspector.ErrCodeInternalException: 1149 fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) 1150 case inspector.ErrCodeInvalidInputException: 1151 fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) 1152 case inspector.ErrCodeLimitExceededException: 1153 fmt.Println(inspector.ErrCodeLimitExceededException, aerr.Error()) 1154 case inspector.ErrCodeAccessDeniedException: 1155 fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) 1156 case inspector.ErrCodeNoSuchEntityException: 1157 fmt.Println(inspector.ErrCodeNoSuchEntityException, aerr.Error()) 1158 case inspector.ErrCodeServiceTemporarilyUnavailableException: 1159 fmt.Println(inspector.ErrCodeServiceTemporarilyUnavailableException, aerr.Error()) 1160 default: 1161 fmt.Println(aerr.Error()) 1162 } 1163 } else { 1164 // Print the error, cast err to awserr.Error to get the Code and 1165 // Message from an error. 1166 fmt.Println(err.Error()) 1167 } 1168 return 1169 } 1170 1171 fmt.Println(result) 1172 } 1173 1174 // Unsubscribe from event 1175 // 1176 // Disables the process of sending Amazon Simple Notification Service (SNS) notifications 1177 // about a specified event to a specified SNS topic. 1178 func ExampleInspector_UnsubscribeFromEvent_shared00() { 1179 svc := inspector.New(session.New()) 1180 input := &inspector.UnsubscribeFromEventInput{ 1181 Event: aws.String("ASSESSMENT_RUN_COMPLETED"), 1182 ResourceArn: aws.String("arn:aws:inspector:us-west-2:123456789012:target/0-nvgVhaxX/template/0-7sbz2Kz0"), 1183 TopicArn: aws.String("arn:aws:sns:us-west-2:123456789012:exampletopic"), 1184 } 1185 1186 result, err := svc.UnsubscribeFromEvent(input) 1187 if err != nil { 1188 if aerr, ok := err.(awserr.Error); ok { 1189 switch aerr.Code() { 1190 case inspector.ErrCodeInternalException: 1191 fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) 1192 case inspector.ErrCodeInvalidInputException: 1193 fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) 1194 case inspector.ErrCodeAccessDeniedException: 1195 fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) 1196 case inspector.ErrCodeNoSuchEntityException: 1197 fmt.Println(inspector.ErrCodeNoSuchEntityException, aerr.Error()) 1198 case inspector.ErrCodeServiceTemporarilyUnavailableException: 1199 fmt.Println(inspector.ErrCodeServiceTemporarilyUnavailableException, aerr.Error()) 1200 default: 1201 fmt.Println(aerr.Error()) 1202 } 1203 } else { 1204 // Print the error, cast err to awserr.Error to get the Code and 1205 // Message from an error. 1206 fmt.Println(err.Error()) 1207 } 1208 return 1209 } 1210 1211 fmt.Println(result) 1212 } 1213 1214 // Update assessment target 1215 // 1216 // Updates the assessment target that is specified by the ARN of the assessment target. 1217 func ExampleInspector_UpdateAssessmentTarget_shared00() { 1218 svc := inspector.New(session.New()) 1219 input := &inspector.UpdateAssessmentTargetInput{ 1220 AssessmentTargetArn: aws.String("arn:aws:inspector:us-west-2:123456789012:target/0-nvgVhaxX"), 1221 AssessmentTargetName: aws.String("Example"), 1222 ResourceGroupArn: aws.String("arn:aws:inspector:us-west-2:123456789012:resourcegroup/0-yNbgL5Pt"), 1223 } 1224 1225 result, err := svc.UpdateAssessmentTarget(input) 1226 if err != nil { 1227 if aerr, ok := err.(awserr.Error); ok { 1228 switch aerr.Code() { 1229 case inspector.ErrCodeInternalException: 1230 fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) 1231 case inspector.ErrCodeInvalidInputException: 1232 fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) 1233 case inspector.ErrCodeAccessDeniedException: 1234 fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) 1235 case inspector.ErrCodeNoSuchEntityException: 1236 fmt.Println(inspector.ErrCodeNoSuchEntityException, aerr.Error()) 1237 case inspector.ErrCodeServiceTemporarilyUnavailableException: 1238 fmt.Println(inspector.ErrCodeServiceTemporarilyUnavailableException, aerr.Error()) 1239 default: 1240 fmt.Println(aerr.Error()) 1241 } 1242 } else { 1243 // Print the error, cast err to awserr.Error to get the Code and 1244 // Message from an error. 1245 fmt.Println(err.Error()) 1246 } 1247 return 1248 } 1249 1250 fmt.Println(result) 1251 }