// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. package inspector_test import ( "context" "fmt" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/aws/awserr" "github.com/aws/aws-sdk-go-v2/aws/external" "github.com/aws/aws-sdk-go-v2/service/inspector" ) var _ aws.Config // Add attributes to findings // // Assigns attributes (key and value pairs) to the findings that are specified by the // ARNs of the findings. func ExampleClient_AddAttributesToFindingsRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := inspector.New(cfg) input := &inspector.AddAttributesToFindingsInput{ Attributes: []inspector.Attribute{ { Key: aws.String("Example"), Value: aws.String("example"), }, }, FindingArns: []string{ "arn:aws:inspector:us-west-2:123456789012:target/0-0kFIPusq/template/0-8l1VIE0D/run/0-Z02cjjug/finding/0-T8yM9mEU", }, } req := svc.AddAttributesToFindingsRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case inspector.ErrCodeInternalException: fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) case inspector.ErrCodeInvalidInputException: fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) case inspector.ErrCodeAccessDeniedException: fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) case inspector.ErrCodeNoSuchEntityException: fmt.Println(inspector.ErrCodeNoSuchEntityException, aerr.Error()) case inspector.ErrCodeServiceTemporarilyUnavailableException: fmt.Println(inspector.ErrCodeServiceTemporarilyUnavailableException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // Create assessment target // // Creates a new assessment target using the ARN of the resource group that is generated // by CreateResourceGroup. You can create up to 50 assessment targets per AWS account. // You can run up to 500 concurrent agents per AWS account. func ExampleClient_CreateAssessmentTargetRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := inspector.New(cfg) input := &inspector.CreateAssessmentTargetInput{ AssessmentTargetName: aws.String("ExampleAssessmentTarget"), ResourceGroupArn: aws.String("arn:aws:inspector:us-west-2:123456789012:resourcegroup/0-AB6DMKnv"), } req := svc.CreateAssessmentTargetRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case inspector.ErrCodeInternalException: fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) case inspector.ErrCodeInvalidInputException: fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) case inspector.ErrCodeLimitExceededException: fmt.Println(inspector.ErrCodeLimitExceededException, aerr.Error()) case inspector.ErrCodeAccessDeniedException: fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) case inspector.ErrCodeNoSuchEntityException: fmt.Println(inspector.ErrCodeNoSuchEntityException, aerr.Error()) case inspector.ErrCodeInvalidCrossAccountRoleException: fmt.Println(inspector.ErrCodeInvalidCrossAccountRoleException, aerr.Error()) case inspector.ErrCodeServiceTemporarilyUnavailableException: fmt.Println(inspector.ErrCodeServiceTemporarilyUnavailableException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // Create assessment template // // Creates an assessment template for the assessment target that is specified by the // ARN of the assessment target. func ExampleClient_CreateAssessmentTemplateRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := inspector.New(cfg) input := &inspector.CreateAssessmentTemplateInput{ AssessmentTargetArn: aws.String("arn:aws:inspector:us-west-2:123456789012:target/0-nvgVhaxX"), AssessmentTemplateName: aws.String("ExampleAssessmentTemplate"), DurationInSeconds: aws.Int64(180), RulesPackageArns: []string{ "arn:aws:inspector:us-west-2:758058086616:rulespackage/0-11B9DBXp", }, UserAttributesForFindings: []inspector.Attribute{ { Key: aws.String("Example"), Value: aws.String("example"), }, }, } req := svc.CreateAssessmentTemplateRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case inspector.ErrCodeInternalException: fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) case inspector.ErrCodeInvalidInputException: fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) case inspector.ErrCodeLimitExceededException: fmt.Println(inspector.ErrCodeLimitExceededException, aerr.Error()) case inspector.ErrCodeAccessDeniedException: fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) case inspector.ErrCodeNoSuchEntityException: fmt.Println(inspector.ErrCodeNoSuchEntityException, aerr.Error()) case inspector.ErrCodeServiceTemporarilyUnavailableException: fmt.Println(inspector.ErrCodeServiceTemporarilyUnavailableException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // Create resource group // // Creates a resource group using the specified set of tags (key and value pairs) that // are used to select the EC2 instances to be included in an Amazon Inspector assessment // target. The created resource group is then used to create an Amazon Inspector assessment // target. func ExampleClient_CreateResourceGroupRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := inspector.New(cfg) input := &inspector.CreateResourceGroupInput{ ResourceGroupTags: []inspector.ResourceGroupTag{ { Key: aws.String("Name"), Value: aws.String("example"), }, }, } req := svc.CreateResourceGroupRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case inspector.ErrCodeInternalException: fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) case inspector.ErrCodeInvalidInputException: fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) case inspector.ErrCodeLimitExceededException: fmt.Println(inspector.ErrCodeLimitExceededException, aerr.Error()) case inspector.ErrCodeAccessDeniedException: fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) case inspector.ErrCodeServiceTemporarilyUnavailableException: fmt.Println(inspector.ErrCodeServiceTemporarilyUnavailableException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // Delete assessment run // // Deletes the assessment run that is specified by the ARN of the assessment run. func ExampleClient_DeleteAssessmentRunRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := inspector.New(cfg) input := &inspector.DeleteAssessmentRunInput{ AssessmentRunArn: aws.String("arn:aws:inspector:us-west-2:123456789012:target/0-nvgVhaxX/template/0-it5r2S4T/run/0-11LMTAVe"), } req := svc.DeleteAssessmentRunRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case inspector.ErrCodeInternalException: fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) case inspector.ErrCodeInvalidInputException: fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) case inspector.ErrCodeAssessmentRunInProgressException: fmt.Println(inspector.ErrCodeAssessmentRunInProgressException, aerr.Error()) case inspector.ErrCodeAccessDeniedException: fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) case inspector.ErrCodeNoSuchEntityException: fmt.Println(inspector.ErrCodeNoSuchEntityException, aerr.Error()) case inspector.ErrCodeServiceTemporarilyUnavailableException: fmt.Println(inspector.ErrCodeServiceTemporarilyUnavailableException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // Delete assessment target // // Deletes the assessment target that is specified by the ARN of the assessment target. func ExampleClient_DeleteAssessmentTargetRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := inspector.New(cfg) input := &inspector.DeleteAssessmentTargetInput{ AssessmentTargetArn: aws.String("arn:aws:inspector:us-west-2:123456789012:target/0-0kFIPusq"), } req := svc.DeleteAssessmentTargetRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case inspector.ErrCodeInternalException: fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) case inspector.ErrCodeInvalidInputException: fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) case inspector.ErrCodeAssessmentRunInProgressException: fmt.Println(inspector.ErrCodeAssessmentRunInProgressException, aerr.Error()) case inspector.ErrCodeAccessDeniedException: fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) case inspector.ErrCodeNoSuchEntityException: fmt.Println(inspector.ErrCodeNoSuchEntityException, aerr.Error()) case inspector.ErrCodeServiceTemporarilyUnavailableException: fmt.Println(inspector.ErrCodeServiceTemporarilyUnavailableException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // Delete assessment template // // Deletes the assessment template that is specified by the ARN of the assessment template. func ExampleClient_DeleteAssessmentTemplateRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := inspector.New(cfg) input := &inspector.DeleteAssessmentTemplateInput{ AssessmentTemplateArn: aws.String("arn:aws:inspector:us-west-2:123456789012:target/0-nvgVhaxX/template/0-it5r2S4T"), } req := svc.DeleteAssessmentTemplateRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case inspector.ErrCodeInternalException: fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) case inspector.ErrCodeInvalidInputException: fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) case inspector.ErrCodeAssessmentRunInProgressException: fmt.Println(inspector.ErrCodeAssessmentRunInProgressException, aerr.Error()) case inspector.ErrCodeAccessDeniedException: fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) case inspector.ErrCodeNoSuchEntityException: fmt.Println(inspector.ErrCodeNoSuchEntityException, aerr.Error()) case inspector.ErrCodeServiceTemporarilyUnavailableException: fmt.Println(inspector.ErrCodeServiceTemporarilyUnavailableException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // Describte assessment runs // // Describes the assessment runs that are specified by the ARNs of the assessment runs. func ExampleClient_DescribeAssessmentRunsRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := inspector.New(cfg) input := &inspector.DescribeAssessmentRunsInput{ AssessmentRunArns: []string{ "arn:aws:inspector:us-west-2:123456789012:target/0-0kFIPusq/template/0-4r1V2mAw/run/0-MKkpXXPE", }, } req := svc.DescribeAssessmentRunsRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case inspector.ErrCodeInternalException: fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) case inspector.ErrCodeInvalidInputException: fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // Describte assessment targets // // Describes the assessment targets that are specified by the ARNs of the assessment // targets. func ExampleClient_DescribeAssessmentTargetsRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := inspector.New(cfg) input := &inspector.DescribeAssessmentTargetsInput{ AssessmentTargetArns: []string{ "arn:aws:inspector:us-west-2:123456789012:target/0-0kFIPusq", }, } req := svc.DescribeAssessmentTargetsRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case inspector.ErrCodeInternalException: fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) case inspector.ErrCodeInvalidInputException: fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // Describte assessment templates // // Describes the assessment templates that are specified by the ARNs of the assessment // templates. func ExampleClient_DescribeAssessmentTemplatesRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := inspector.New(cfg) input := &inspector.DescribeAssessmentTemplatesInput{ AssessmentTemplateArns: []string{ "arn:aws:inspector:us-west-2:123456789012:target/0-0kFIPusq/template/0-4r1V2mAw", }, } req := svc.DescribeAssessmentTemplatesRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case inspector.ErrCodeInternalException: fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) case inspector.ErrCodeInvalidInputException: fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // Describte cross account access role // // Describes the IAM role that enables Amazon Inspector to access your AWS account. func ExampleClient_DescribeCrossAccountAccessRoleRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := inspector.New(cfg) input := &inspector.DescribeCrossAccountAccessRoleInput{} req := svc.DescribeCrossAccountAccessRoleRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case inspector.ErrCodeInternalException: fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // Describe findings // // Describes the findings that are specified by the ARNs of the findings. func ExampleClient_DescribeFindingsRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := inspector.New(cfg) input := &inspector.DescribeFindingsInput{ FindingArns: []string{ "arn:aws:inspector:us-west-2:123456789012:target/0-0kFIPusq/template/0-4r1V2mAw/run/0-MKkpXXPE/finding/0-HwPnsDm4", }, } req := svc.DescribeFindingsRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case inspector.ErrCodeInternalException: fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) case inspector.ErrCodeInvalidInputException: fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // Describe resource groups // // Describes the resource groups that are specified by the ARNs of the resource groups. func ExampleClient_DescribeResourceGroupsRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := inspector.New(cfg) input := &inspector.DescribeResourceGroupsInput{ ResourceGroupArns: []string{ "arn:aws:inspector:us-west-2:123456789012:resourcegroup/0-PyGXopAI", }, } req := svc.DescribeResourceGroupsRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case inspector.ErrCodeInternalException: fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) case inspector.ErrCodeInvalidInputException: fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // Describe rules packages // // Describes the rules packages that are specified by the ARNs of the rules packages. func ExampleClient_DescribeRulesPackagesRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := inspector.New(cfg) input := &inspector.DescribeRulesPackagesInput{ RulesPackageArns: []string{ "arn:aws:inspector:us-west-2:758058086616:rulespackage/0-JJOtZiqQ", }, } req := svc.DescribeRulesPackagesRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case inspector.ErrCodeInternalException: fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) case inspector.ErrCodeInvalidInputException: fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // Get telemetry metadata // // Information about the data that is collected for the specified assessment run. func ExampleClient_GetTelemetryMetadataRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := inspector.New(cfg) input := &inspector.GetTelemetryMetadataInput{ AssessmentRunArn: aws.String("arn:aws:inspector:us-west-2:123456789012:target/0-0kFIPusq/template/0-4r1V2mAw/run/0-MKkpXXPE"), } req := svc.GetTelemetryMetadataRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case inspector.ErrCodeInternalException: fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) case inspector.ErrCodeInvalidInputException: fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) case inspector.ErrCodeAccessDeniedException: fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) case inspector.ErrCodeNoSuchEntityException: fmt.Println(inspector.ErrCodeNoSuchEntityException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // List assessment run agents // // Lists the agents of the assessment runs that are specified by the ARNs of the assessment // runs. func ExampleClient_ListAssessmentRunAgentsRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := inspector.New(cfg) input := &inspector.ListAssessmentRunAgentsInput{ AssessmentRunArn: aws.String("arn:aws:inspector:us-west-2:123456789012:target/0-0kFIPusq/template/0-4r1V2mAw/run/0-MKkpXXPE"), MaxResults: aws.Int64(123), } req := svc.ListAssessmentRunAgentsRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case inspector.ErrCodeInternalException: fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) case inspector.ErrCodeInvalidInputException: fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) case inspector.ErrCodeAccessDeniedException: fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) case inspector.ErrCodeNoSuchEntityException: fmt.Println(inspector.ErrCodeNoSuchEntityException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // List assessment runs // // Lists the assessment runs that correspond to the assessment templates that are specified // by the ARNs of the assessment templates. func ExampleClient_ListAssessmentRunsRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := inspector.New(cfg) input := &inspector.ListAssessmentRunsInput{ AssessmentTemplateArns: []string{ "arn:aws:inspector:us-west-2:123456789012:target/0-0kFIPusq/template/0-4r1V2mAw", }, MaxResults: aws.Int64(123), } req := svc.ListAssessmentRunsRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case inspector.ErrCodeInternalException: fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) case inspector.ErrCodeInvalidInputException: fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) case inspector.ErrCodeAccessDeniedException: fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) case inspector.ErrCodeNoSuchEntityException: fmt.Println(inspector.ErrCodeNoSuchEntityException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // List assessment targets // // Lists the ARNs of the assessment targets within this AWS account. func ExampleClient_ListAssessmentTargetsRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := inspector.New(cfg) input := &inspector.ListAssessmentTargetsInput{ MaxResults: aws.Int64(123), } req := svc.ListAssessmentTargetsRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case inspector.ErrCodeInternalException: fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) case inspector.ErrCodeInvalidInputException: fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) case inspector.ErrCodeAccessDeniedException: fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // List assessment templates // // Lists the assessment templates that correspond to the assessment targets that are // specified by the ARNs of the assessment targets. func ExampleClient_ListAssessmentTemplatesRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := inspector.New(cfg) input := &inspector.ListAssessmentTemplatesInput{ AssessmentTargetArns: []string{ "arn:aws:inspector:us-west-2:123456789012:target/0-0kFIPusq", }, MaxResults: aws.Int64(123), } req := svc.ListAssessmentTemplatesRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case inspector.ErrCodeInternalException: fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) case inspector.ErrCodeInvalidInputException: fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) case inspector.ErrCodeAccessDeniedException: fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) case inspector.ErrCodeNoSuchEntityException: fmt.Println(inspector.ErrCodeNoSuchEntityException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // List event subscriptions // // Lists all the event subscriptions for the assessment template that is specified by // the ARN of the assessment template. func ExampleClient_ListEventSubscriptionsRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := inspector.New(cfg) input := &inspector.ListEventSubscriptionsInput{ MaxResults: aws.Int64(123), ResourceArn: aws.String("arn:aws:inspector:us-west-2:123456789012:target/0-nvgVhaxX/template/0-7sbz2Kz0"), } req := svc.ListEventSubscriptionsRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case inspector.ErrCodeInternalException: fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) case inspector.ErrCodeInvalidInputException: fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) case inspector.ErrCodeAccessDeniedException: fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) case inspector.ErrCodeNoSuchEntityException: fmt.Println(inspector.ErrCodeNoSuchEntityException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // List findings // // Lists findings that are generated by the assessment runs that are specified by the // ARNs of the assessment runs. func ExampleClient_ListFindingsRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := inspector.New(cfg) input := &inspector.ListFindingsInput{ AssessmentRunArns: []string{ "arn:aws:inspector:us-west-2:123456789012:target/0-0kFIPusq/template/0-4r1V2mAw/run/0-MKkpXXPE", }, MaxResults: aws.Int64(123), } req := svc.ListFindingsRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case inspector.ErrCodeInternalException: fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) case inspector.ErrCodeInvalidInputException: fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) case inspector.ErrCodeAccessDeniedException: fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) case inspector.ErrCodeNoSuchEntityException: fmt.Println(inspector.ErrCodeNoSuchEntityException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // List rules packages // // Lists all available Amazon Inspector rules packages. func ExampleClient_ListRulesPackagesRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := inspector.New(cfg) input := &inspector.ListRulesPackagesInput{ MaxResults: aws.Int64(123), } req := svc.ListRulesPackagesRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case inspector.ErrCodeInternalException: fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) case inspector.ErrCodeInvalidInputException: fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) case inspector.ErrCodeAccessDeniedException: fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // List tags for resource // // Lists all tags associated with an assessment template. func ExampleClient_ListTagsForResourceRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := inspector.New(cfg) input := &inspector.ListTagsForResourceInput{ ResourceArn: aws.String("arn:aws:inspector:us-west-2:123456789012:target/0-0kFIPusq/template/0-gcwFliYu"), } req := svc.ListTagsForResourceRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case inspector.ErrCodeInternalException: fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) case inspector.ErrCodeInvalidInputException: fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) case inspector.ErrCodeAccessDeniedException: fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) case inspector.ErrCodeNoSuchEntityException: fmt.Println(inspector.ErrCodeNoSuchEntityException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // Preview agents // // Previews the agents installed on the EC2 instances that are part of the specified // assessment target. func ExampleClient_PreviewAgentsRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := inspector.New(cfg) input := &inspector.PreviewAgentsInput{ MaxResults: aws.Int64(123), PreviewAgentsArn: aws.String("arn:aws:inspector:us-west-2:123456789012:target/0-0kFIPusq"), } req := svc.PreviewAgentsRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case inspector.ErrCodeInternalException: fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) case inspector.ErrCodeInvalidInputException: fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) case inspector.ErrCodeAccessDeniedException: fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) case inspector.ErrCodeNoSuchEntityException: fmt.Println(inspector.ErrCodeNoSuchEntityException, aerr.Error()) case inspector.ErrCodeInvalidCrossAccountRoleException: fmt.Println(inspector.ErrCodeInvalidCrossAccountRoleException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // Register cross account access role // // Registers the IAM role that Amazon Inspector uses to list your EC2 instances at the // start of the assessment run or when you call the PreviewAgents action. func ExampleClient_RegisterCrossAccountAccessRoleRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := inspector.New(cfg) input := &inspector.RegisterCrossAccountAccessRoleInput{ RoleArn: aws.String("arn:aws:iam::123456789012:role/inspector"), } req := svc.RegisterCrossAccountAccessRoleRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case inspector.ErrCodeInternalException: fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) case inspector.ErrCodeInvalidInputException: fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) case inspector.ErrCodeAccessDeniedException: fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) case inspector.ErrCodeInvalidCrossAccountRoleException: fmt.Println(inspector.ErrCodeInvalidCrossAccountRoleException, aerr.Error()) case inspector.ErrCodeServiceTemporarilyUnavailableException: fmt.Println(inspector.ErrCodeServiceTemporarilyUnavailableException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // Remove attributes from findings // // Removes entire attributes (key and value pairs) from the findings that are specified // by the ARNs of the findings where an attribute with the specified key exists. func ExampleClient_RemoveAttributesFromFindingsRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := inspector.New(cfg) input := &inspector.RemoveAttributesFromFindingsInput{ AttributeKeys: []string{ "key=Example,value=example", }, FindingArns: []string{ "arn:aws:inspector:us-west-2:123456789012:target/0-0kFIPusq/template/0-8l1VIE0D/run/0-Z02cjjug/finding/0-T8yM9mEU", }, } req := svc.RemoveAttributesFromFindingsRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case inspector.ErrCodeInternalException: fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) case inspector.ErrCodeInvalidInputException: fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) case inspector.ErrCodeAccessDeniedException: fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) case inspector.ErrCodeNoSuchEntityException: fmt.Println(inspector.ErrCodeNoSuchEntityException, aerr.Error()) case inspector.ErrCodeServiceTemporarilyUnavailableException: fmt.Println(inspector.ErrCodeServiceTemporarilyUnavailableException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // Set tags for resource // // Sets tags (key and value pairs) to the assessment template that is specified by the // ARN of the assessment template. func ExampleClient_SetTagsForResourceRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := inspector.New(cfg) input := &inspector.SetTagsForResourceInput{ ResourceArn: aws.String("arn:aws:inspector:us-west-2:123456789012:target/0-nvgVhaxX/template/0-7sbz2Kz0"), Tags: []inspector.Tag{ { Key: aws.String("Example"), Value: aws.String("example"), }, }, } req := svc.SetTagsForResourceRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case inspector.ErrCodeInternalException: fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) case inspector.ErrCodeInvalidInputException: fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) case inspector.ErrCodeAccessDeniedException: fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) case inspector.ErrCodeNoSuchEntityException: fmt.Println(inspector.ErrCodeNoSuchEntityException, aerr.Error()) case inspector.ErrCodeServiceTemporarilyUnavailableException: fmt.Println(inspector.ErrCodeServiceTemporarilyUnavailableException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // Start assessment run // // Starts the assessment run specified by the ARN of the assessment template. For this // API to function properly, you must not exceed the limit of running up to 500 concurrent // agents per AWS account. func ExampleClient_StartAssessmentRunRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := inspector.New(cfg) input := &inspector.StartAssessmentRunInput{ AssessmentRunName: aws.String("examplerun"), AssessmentTemplateArn: aws.String("arn:aws:inspector:us-west-2:123456789012:target/0-nvgVhaxX/template/0-it5r2S4T"), } req := svc.StartAssessmentRunRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case inspector.ErrCodeInternalException: fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) case inspector.ErrCodeInvalidInputException: fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) case inspector.ErrCodeLimitExceededException: fmt.Println(inspector.ErrCodeLimitExceededException, aerr.Error()) case inspector.ErrCodeAccessDeniedException: fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) case inspector.ErrCodeNoSuchEntityException: fmt.Println(inspector.ErrCodeNoSuchEntityException, aerr.Error()) case inspector.ErrCodeInvalidCrossAccountRoleException: fmt.Println(inspector.ErrCodeInvalidCrossAccountRoleException, aerr.Error()) case inspector.ErrCodeAgentsAlreadyRunningAssessmentException: fmt.Println(inspector.ErrCodeAgentsAlreadyRunningAssessmentException, aerr.Error()) case inspector.ErrCodeServiceTemporarilyUnavailableException: fmt.Println(inspector.ErrCodeServiceTemporarilyUnavailableException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // Stop assessment run // // Stops the assessment run that is specified by the ARN of the assessment run. func ExampleClient_StopAssessmentRunRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := inspector.New(cfg) input := &inspector.StopAssessmentRunInput{ AssessmentRunArn: aws.String("arn:aws:inspector:us-west-2:123456789012:target/0-nvgVhaxX/template/0-it5r2S4T/run/0-11LMTAVe"), } req := svc.StopAssessmentRunRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case inspector.ErrCodeInternalException: fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) case inspector.ErrCodeInvalidInputException: fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) case inspector.ErrCodeAccessDeniedException: fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) case inspector.ErrCodeNoSuchEntityException: fmt.Println(inspector.ErrCodeNoSuchEntityException, aerr.Error()) case inspector.ErrCodeServiceTemporarilyUnavailableException: fmt.Println(inspector.ErrCodeServiceTemporarilyUnavailableException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // Subscribe to event // // Enables the process of sending Amazon Simple Notification Service (SNS) notifications // about a specified event to a specified SNS topic. func ExampleClient_SubscribeToEventRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := inspector.New(cfg) input := &inspector.SubscribeToEventInput{ Event: inspector.InspectorEventAssessmentRunCompleted, ResourceArn: aws.String("arn:aws:inspector:us-west-2:123456789012:target/0-nvgVhaxX/template/0-7sbz2Kz0"), TopicArn: aws.String("arn:aws:sns:us-west-2:123456789012:exampletopic"), } req := svc.SubscribeToEventRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case inspector.ErrCodeInternalException: fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) case inspector.ErrCodeInvalidInputException: fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) case inspector.ErrCodeLimitExceededException: fmt.Println(inspector.ErrCodeLimitExceededException, aerr.Error()) case inspector.ErrCodeAccessDeniedException: fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) case inspector.ErrCodeNoSuchEntityException: fmt.Println(inspector.ErrCodeNoSuchEntityException, aerr.Error()) case inspector.ErrCodeServiceTemporarilyUnavailableException: fmt.Println(inspector.ErrCodeServiceTemporarilyUnavailableException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // Unsubscribe from event // // Disables the process of sending Amazon Simple Notification Service (SNS) notifications // about a specified event to a specified SNS topic. func ExampleClient_UnsubscribeFromEventRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := inspector.New(cfg) input := &inspector.UnsubscribeFromEventInput{ Event: inspector.InspectorEventAssessmentRunCompleted, ResourceArn: aws.String("arn:aws:inspector:us-west-2:123456789012:target/0-nvgVhaxX/template/0-7sbz2Kz0"), TopicArn: aws.String("arn:aws:sns:us-west-2:123456789012:exampletopic"), } req := svc.UnsubscribeFromEventRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case inspector.ErrCodeInternalException: fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) case inspector.ErrCodeInvalidInputException: fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) case inspector.ErrCodeAccessDeniedException: fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) case inspector.ErrCodeNoSuchEntityException: fmt.Println(inspector.ErrCodeNoSuchEntityException, aerr.Error()) case inspector.ErrCodeServiceTemporarilyUnavailableException: fmt.Println(inspector.ErrCodeServiceTemporarilyUnavailableException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // Update assessment target // // Updates the assessment target that is specified by the ARN of the assessment target. func ExampleClient_UpdateAssessmentTargetRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := inspector.New(cfg) input := &inspector.UpdateAssessmentTargetInput{ AssessmentTargetArn: aws.String("arn:aws:inspector:us-west-2:123456789012:target/0-nvgVhaxX"), AssessmentTargetName: aws.String("Example"), ResourceGroupArn: aws.String("arn:aws:inspector:us-west-2:123456789012:resourcegroup/0-yNbgL5Pt"), } req := svc.UpdateAssessmentTargetRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case inspector.ErrCodeInternalException: fmt.Println(inspector.ErrCodeInternalException, aerr.Error()) case inspector.ErrCodeInvalidInputException: fmt.Println(inspector.ErrCodeInvalidInputException, aerr.Error()) case inspector.ErrCodeAccessDeniedException: fmt.Println(inspector.ErrCodeAccessDeniedException, aerr.Error()) case inspector.ErrCodeNoSuchEntityException: fmt.Println(inspector.ErrCodeNoSuchEntityException, aerr.Error()) case inspector.ErrCodeServiceTemporarilyUnavailableException: fmt.Println(inspector.ErrCodeServiceTemporarilyUnavailableException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) }