1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package cloudtrail
4
5import (
6	"context"
7	awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
8	"github.com/aws/aws-sdk-go-v2/aws/signer/v4"
9	"github.com/aws/aws-sdk-go-v2/service/cloudtrail/types"
10	"github.com/aws/smithy-go/middleware"
11	smithyhttp "github.com/aws/smithy-go/transport/http"
12)
13
14// Describes the settings for the Insights event selectors that you configured for
15// your trail. GetInsightSelectors shows if CloudTrail Insights event logging is
16// enabled on the trail, and if it is, which insight types are enabled. If you run
17// GetInsightSelectors on a trail that does not have Insights events enabled, the
18// operation throws the exception InsightNotEnabledException For more information,
19// see Logging CloudTrail Insights Events for Trails
20// (https://docs.aws.amazon.com/awscloudtrail/latest/userguide/logging-insights-events-with-cloudtrail.html)
21// in the CloudTrail User Guide.
22func (c *Client) GetInsightSelectors(ctx context.Context, params *GetInsightSelectorsInput, optFns ...func(*Options)) (*GetInsightSelectorsOutput, error) {
23	if params == nil {
24		params = &GetInsightSelectorsInput{}
25	}
26
27	result, metadata, err := c.invokeOperation(ctx, "GetInsightSelectors", params, optFns, c.addOperationGetInsightSelectorsMiddlewares)
28	if err != nil {
29		return nil, err
30	}
31
32	out := result.(*GetInsightSelectorsOutput)
33	out.ResultMetadata = metadata
34	return out, nil
35}
36
37type GetInsightSelectorsInput struct {
38
39	// Specifies the name of the trail or trail ARN. If you specify a trail name, the
40	// string must meet the following requirements:
41	//
42	// * Contain only ASCII letters (a-z,
43	// A-Z), numbers (0-9), periods (.), underscores (_), or dashes (-)
44	//
45	// * Start with a
46	// letter or number, and end with a letter or number
47	//
48	// * Be between 3 and 128
49	// characters
50	//
51	// * Have no adjacent periods, underscores or dashes. Names like
52	// my-_namespace and my--namespace are not valid.
53	//
54	// * Not be in IP address format
55	// (for example, 192.168.5.4)
56	//
57	// If you specify a trail ARN, it must be in the
58	// format: arn:aws:cloudtrail:us-east-2:123456789012:trail/MyTrail
59	//
60	// This member is required.
61	TrailName *string
62
63	noSmithyDocumentSerde
64}
65
66type GetInsightSelectorsOutput struct {
67
68	// A JSON string that contains the insight types you want to log on a trail. In
69	// this release, only ApiCallRateInsight is supported as an insight type.
70	InsightSelectors []types.InsightSelector
71
72	// The Amazon Resource Name (ARN) of a trail for which you want to get Insights
73	// selectors.
74	TrailARN *string
75
76	// Metadata pertaining to the operation's result.
77	ResultMetadata middleware.Metadata
78
79	noSmithyDocumentSerde
80}
81
82func (c *Client) addOperationGetInsightSelectorsMiddlewares(stack *middleware.Stack, options Options) (err error) {
83	err = stack.Serialize.Add(&awsAwsjson11_serializeOpGetInsightSelectors{}, middleware.After)
84	if err != nil {
85		return err
86	}
87	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpGetInsightSelectors{}, middleware.After)
88	if err != nil {
89		return err
90	}
91	if err = addSetLoggerMiddleware(stack, options); err != nil {
92		return err
93	}
94	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
95		return err
96	}
97	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
98		return err
99	}
100	if err = addResolveEndpointMiddleware(stack, options); err != nil {
101		return err
102	}
103	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
104		return err
105	}
106	if err = addRetryMiddlewares(stack, options); err != nil {
107		return err
108	}
109	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
110		return err
111	}
112	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
113		return err
114	}
115	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
116		return err
117	}
118	if err = addClientUserAgent(stack); err != nil {
119		return err
120	}
121	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
122		return err
123	}
124	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
125		return err
126	}
127	if err = addOpGetInsightSelectorsValidationMiddleware(stack); err != nil {
128		return err
129	}
130	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetInsightSelectors(options.Region), middleware.Before); err != nil {
131		return err
132	}
133	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
134		return err
135	}
136	if err = addResponseErrorMiddleware(stack); err != nil {
137		return err
138	}
139	if err = addRequestResponseLogging(stack, options); err != nil {
140		return err
141	}
142	return nil
143}
144
145func newServiceMetadataMiddleware_opGetInsightSelectors(region string) *awsmiddleware.RegisterServiceMetadata {
146	return &awsmiddleware.RegisterServiceMetadata{
147		Region:        region,
148		ServiceID:     ServiceID,
149		SigningName:   "cloudtrail",
150		OperationName: "GetInsightSelectors",
151	}
152}
153