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