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// Configures an event selector or advanced event selectors for your trail. Use 15// event selectors or advanced event selectors to specify management and data event 16// settings for your trail. By default, trails created without specific event 17// selectors are configured to log all read and write management events, and no 18// data events. When an event occurs in your account, CloudTrail evaluates the 19// event selectors or advanced event selectors in all trails. For each trail, if 20// the event matches any event selector, the trail processes and logs the event. If 21// the event doesn't match any event selector, the trail doesn't log the event. 22// Example 23// 24// * You create an event selector for a trail and specify that you want 25// write-only events. 26// 27// * The EC2 GetConsoleOutput and RunInstances API operations 28// occur in your account. 29// 30// * CloudTrail evaluates whether the events match your 31// event selectors. 32// 33// * The RunInstances is a write-only event and it matches your 34// event selector. The trail logs the event. 35// 36// * The GetConsoleOutput is a read-only 37// event that doesn't match your event selector. The trail doesn't log the 38// event. 39// 40// The PutEventSelectors operation must be called from the region in which 41// the trail was created; otherwise, an InvalidHomeRegionException exception is 42// thrown. You can configure up to five event selectors for each trail. For more 43// information, see Logging data and management events for trails 44// (https://docs.aws.amazon.com/awscloudtrail/latest/userguide/logging-management-and-data-events-with-cloudtrail.html) 45// and Quotas in CloudTrail 46// (https://docs.aws.amazon.com/awscloudtrail/latest/userguide/WhatIsCloudTrail-Limits.html) 47// in the CloudTrail User Guide. You can add advanced event selectors, and 48// conditions for your advanced event selectors, up to a maximum of 500 values for 49// all conditions and selectors on a trail. You can use either 50// AdvancedEventSelectors or EventSelectors, but not both. If you apply 51// AdvancedEventSelectors to a trail, any existing EventSelectors are overwritten. 52// For more information about advanced event selectors, see Logging data events for 53// trails 54// (https://docs.aws.amazon.com/awscloudtrail/latest/userguide/logging-data-events-with-cloudtrail.html) 55// in the CloudTrail User Guide. 56func (c *Client) PutEventSelectors(ctx context.Context, params *PutEventSelectorsInput, optFns ...func(*Options)) (*PutEventSelectorsOutput, error) { 57 if params == nil { 58 params = &PutEventSelectorsInput{} 59 } 60 61 result, metadata, err := c.invokeOperation(ctx, "PutEventSelectors", params, optFns, c.addOperationPutEventSelectorsMiddlewares) 62 if err != nil { 63 return nil, err 64 } 65 66 out := result.(*PutEventSelectorsOutput) 67 out.ResultMetadata = metadata 68 return out, nil 69} 70 71type PutEventSelectorsInput struct { 72 73 // Specifies the name of the trail or trail ARN. If you specify a trail name, the 74 // string must meet the following requirements: 75 // 76 // * Contain only ASCII letters (a-z, 77 // A-Z), numbers (0-9), periods (.), underscores (_), or dashes (-) 78 // 79 // * Start with a 80 // letter or number, and end with a letter or number 81 // 82 // * Be between 3 and 128 83 // characters 84 // 85 // * Have no adjacent periods, underscores or dashes. Names like 86 // my-_namespace and my--namespace are not valid. 87 // 88 // * Not be in IP address format 89 // (for example, 192.168.5.4) 90 // 91 // If you specify a trail ARN, it must be in the 92 // following format. arn:aws:cloudtrail:us-east-2:123456789012:trail/MyTrail 93 // 94 // This member is required. 95 TrailName *string 96 97 // Specifies the settings for advanced event selectors. You can add advanced event 98 // selectors, and conditions for your advanced event selectors, up to a maximum of 99 // 500 values for all conditions and selectors on a trail. You can use either 100 // AdvancedEventSelectors or EventSelectors, but not both. If you apply 101 // AdvancedEventSelectors to a trail, any existing EventSelectors are overwritten. 102 // For more information about advanced event selectors, see Logging data events for 103 // trails 104 // (https://docs.aws.amazon.com/awscloudtrail/latest/userguide/logging-data-events-with-cloudtrail.html) 105 // in the CloudTrail User Guide. 106 AdvancedEventSelectors []types.AdvancedEventSelector 107 108 // Specifies the settings for your event selectors. You can configure up to five 109 // event selectors for a trail. You can use either EventSelectors or 110 // AdvancedEventSelectors in a PutEventSelectors request, but not both. If you 111 // apply EventSelectors to a trail, any existing AdvancedEventSelectors are 112 // overwritten. 113 EventSelectors []types.EventSelector 114 115 noSmithyDocumentSerde 116} 117 118type PutEventSelectorsOutput struct { 119 120 // Specifies the advanced event selectors configured for your trail. 121 AdvancedEventSelectors []types.AdvancedEventSelector 122 123 // Specifies the event selectors configured for your trail. 124 EventSelectors []types.EventSelector 125 126 // Specifies the ARN of the trail that was updated with event selectors. The 127 // following is the format of a trail ARN. 128 // arn:aws:cloudtrail:us-east-2:123456789012:trail/MyTrail 129 TrailARN *string 130 131 // Metadata pertaining to the operation's result. 132 ResultMetadata middleware.Metadata 133 134 noSmithyDocumentSerde 135} 136 137func (c *Client) addOperationPutEventSelectorsMiddlewares(stack *middleware.Stack, options Options) (err error) { 138 err = stack.Serialize.Add(&awsAwsjson11_serializeOpPutEventSelectors{}, middleware.After) 139 if err != nil { 140 return err 141 } 142 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpPutEventSelectors{}, middleware.After) 143 if err != nil { 144 return err 145 } 146 if err = addSetLoggerMiddleware(stack, options); err != nil { 147 return err 148 } 149 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 150 return err 151 } 152 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 153 return err 154 } 155 if err = addResolveEndpointMiddleware(stack, options); err != nil { 156 return err 157 } 158 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 159 return err 160 } 161 if err = addRetryMiddlewares(stack, options); err != nil { 162 return err 163 } 164 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 165 return err 166 } 167 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 168 return err 169 } 170 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 171 return err 172 } 173 if err = addClientUserAgent(stack); err != nil { 174 return err 175 } 176 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 177 return err 178 } 179 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 180 return err 181 } 182 if err = addOpPutEventSelectorsValidationMiddleware(stack); err != nil { 183 return err 184 } 185 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opPutEventSelectors(options.Region), middleware.Before); err != nil { 186 return err 187 } 188 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 189 return err 190 } 191 if err = addResponseErrorMiddleware(stack); err != nil { 192 return err 193 } 194 if err = addRequestResponseLogging(stack, options); err != nil { 195 return err 196 } 197 return nil 198} 199 200func newServiceMetadataMiddleware_opPutEventSelectors(region string) *awsmiddleware.RegisterServiceMetadata { 201 return &awsmiddleware.RegisterServiceMetadata{ 202 Region: region, 203 ServiceID: ServiceID, 204 SigningName: "cloudtrail", 205 OperationName: "PutEventSelectors", 206 } 207} 208