1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package macie2 4 5import ( 6 "context" 7 "fmt" 8 awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" 9 "github.com/aws/aws-sdk-go-v2/aws/signer/v4" 10 "github.com/aws/smithy-go/middleware" 11 smithyhttp "github.com/aws/smithy-go/transport/http" 12) 13 14// Creates and defines the criteria and other settings for a custom data 15// identifier. 16func (c *Client) CreateCustomDataIdentifier(ctx context.Context, params *CreateCustomDataIdentifierInput, optFns ...func(*Options)) (*CreateCustomDataIdentifierOutput, error) { 17 if params == nil { 18 params = &CreateCustomDataIdentifierInput{} 19 } 20 21 result, metadata, err := c.invokeOperation(ctx, "CreateCustomDataIdentifier", params, optFns, addOperationCreateCustomDataIdentifierMiddlewares) 22 if err != nil { 23 return nil, err 24 } 25 26 out := result.(*CreateCustomDataIdentifierOutput) 27 out.ResultMetadata = metadata 28 return out, nil 29} 30 31type CreateCustomDataIdentifierInput struct { 32 33 // A unique, case-sensitive token that you provide to ensure the idempotency of the 34 // request. 35 ClientToken *string 36 37 // A custom description of the custom data identifier. The description can contain 38 // as many as 512 characters. We strongly recommend that you avoid including any 39 // sensitive data in the description of a custom data identifier. Other users of 40 // your account might be able to see the identifier's description, depending on the 41 // actions that they're allowed to perform in Amazon Macie. 42 Description *string 43 44 // An array that lists specific character sequences (ignore words) to exclude from 45 // the results. If the text matched by the regular expression is the same as any 46 // string in this array, Amazon Macie ignores it. The array can contain as many as 47 // 10 ignore words. Each ignore word can contain 4 - 90 characters. Ignore words 48 // are case sensitive. 49 IgnoreWords []string 50 51 // An array that lists specific character sequences (keywords), one of which must 52 // be within proximity (maximumMatchDistance) of the regular expression to match. 53 // The array can contain as many as 50 keywords. Each keyword can contain 4 - 90 54 // characters. Keywords aren't case sensitive. 55 Keywords []string 56 57 // The maximum number of characters that can exist between text that matches the 58 // regex pattern and the character sequences specified by the keywords array. Macie 59 // includes or excludes a result based on the proximity of a keyword to text that 60 // matches the regex pattern. The distance can be 1 - 300 characters. The default 61 // value is 50. 62 MaximumMatchDistance int32 63 64 // A custom name for the custom data identifier. The name can contain as many as 65 // 128 characters. We strongly recommend that you avoid including any sensitive 66 // data in the name of a custom data identifier. Other users of your account might 67 // be able to see the identifier's name, depending on the actions that they're 68 // allowed to perform in Amazon Macie. 69 Name *string 70 71 // The regular expression (regex) that defines the pattern to match. The expression 72 // can contain as many as 512 characters. 73 Regex *string 74 75 // A map of key-value pairs that specifies the tags to associate with the custom 76 // data identifier. A custom data identifier can have a maximum of 50 tags. Each 77 // tag consists of a tag key and an associated tag value. The maximum length of a 78 // tag key is 128 characters. The maximum length of a tag value is 256 characters. 79 Tags map[string]string 80} 81 82type CreateCustomDataIdentifierOutput struct { 83 84 // The unique identifier for the custom data identifier that was created. 85 CustomDataIdentifierId *string 86 87 // Metadata pertaining to the operation's result. 88 ResultMetadata middleware.Metadata 89} 90 91func addOperationCreateCustomDataIdentifierMiddlewares(stack *middleware.Stack, options Options) (err error) { 92 err = stack.Serialize.Add(&awsRestjson1_serializeOpCreateCustomDataIdentifier{}, middleware.After) 93 if err != nil { 94 return err 95 } 96 err = stack.Deserialize.Add(&awsRestjson1_deserializeOpCreateCustomDataIdentifier{}, middleware.After) 97 if err != nil { 98 return err 99 } 100 if err = addSetLoggerMiddleware(stack, options); err != nil { 101 return err 102 } 103 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 104 return err 105 } 106 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 107 return err 108 } 109 if err = addResolveEndpointMiddleware(stack, options); err != nil { 110 return err 111 } 112 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 113 return err 114 } 115 if err = addRetryMiddlewares(stack, options); err != nil { 116 return err 117 } 118 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 119 return err 120 } 121 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 122 return err 123 } 124 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 125 return err 126 } 127 if err = addClientUserAgent(stack); err != nil { 128 return err 129 } 130 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 131 return err 132 } 133 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 134 return err 135 } 136 if err = addIdempotencyToken_opCreateCustomDataIdentifierMiddleware(stack, options); err != nil { 137 return err 138 } 139 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateCustomDataIdentifier(options.Region), middleware.Before); err != nil { 140 return err 141 } 142 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 143 return err 144 } 145 if err = addResponseErrorMiddleware(stack); err != nil { 146 return err 147 } 148 if err = addRequestResponseLogging(stack, options); err != nil { 149 return err 150 } 151 return nil 152} 153 154type idempotencyToken_initializeOpCreateCustomDataIdentifier struct { 155 tokenProvider IdempotencyTokenProvider 156} 157 158func (*idempotencyToken_initializeOpCreateCustomDataIdentifier) ID() string { 159 return "OperationIdempotencyTokenAutoFill" 160} 161 162func (m *idempotencyToken_initializeOpCreateCustomDataIdentifier) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) ( 163 out middleware.InitializeOutput, metadata middleware.Metadata, err error, 164) { 165 if m.tokenProvider == nil { 166 return next.HandleInitialize(ctx, in) 167 } 168 169 input, ok := in.Parameters.(*CreateCustomDataIdentifierInput) 170 if !ok { 171 return out, metadata, fmt.Errorf("expected middleware input to be of type *CreateCustomDataIdentifierInput ") 172 } 173 174 if input.ClientToken == nil { 175 t, err := m.tokenProvider.GetIdempotencyToken() 176 if err != nil { 177 return out, metadata, err 178 } 179 input.ClientToken = &t 180 } 181 return next.HandleInitialize(ctx, in) 182} 183func addIdempotencyToken_opCreateCustomDataIdentifierMiddleware(stack *middleware.Stack, cfg Options) error { 184 return stack.Initialize.Add(&idempotencyToken_initializeOpCreateCustomDataIdentifier{tokenProvider: cfg.IdempotencyTokenProvider}, middleware.Before) 185} 186 187func newServiceMetadataMiddleware_opCreateCustomDataIdentifier(region string) *awsmiddleware.RegisterServiceMetadata { 188 return &awsmiddleware.RegisterServiceMetadata{ 189 Region: region, 190 ServiceID: ServiceID, 191 SigningName: "macie2", 192 OperationName: "CreateCustomDataIdentifier", 193 } 194} 195