1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package iam 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/smithy-go/middleware" 10 smithyhttp "github.com/aws/smithy-go/transport/http" 11) 12 13// Enables the specified MFA device and associates it with the specified IAM user. 14// When enabled, the MFA device is required for every subsequent login by the IAM 15// user associated with the device. 16func (c *Client) EnableMFADevice(ctx context.Context, params *EnableMFADeviceInput, optFns ...func(*Options)) (*EnableMFADeviceOutput, error) { 17 if params == nil { 18 params = &EnableMFADeviceInput{} 19 } 20 21 result, metadata, err := c.invokeOperation(ctx, "EnableMFADevice", params, optFns, addOperationEnableMFADeviceMiddlewares) 22 if err != nil { 23 return nil, err 24 } 25 26 out := result.(*EnableMFADeviceOutput) 27 out.ResultMetadata = metadata 28 return out, nil 29} 30 31type EnableMFADeviceInput struct { 32 33 // An authentication code emitted by the device. The format for this parameter is a 34 // string of six digits. Submit your request immediately after generating the 35 // authentication codes. If you generate the codes and then wait too long to submit 36 // the request, the MFA device successfully associates with the user but the MFA 37 // device becomes out of sync. This happens because time-based one-time passwords 38 // (TOTP) expire after a short period of time. If this happens, you can resync the 39 // device 40 // (https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_mfa_sync.html). 41 // 42 // This member is required. 43 AuthenticationCode1 *string 44 45 // A subsequent authentication code emitted by the device. The format for this 46 // parameter is a string of six digits. Submit your request immediately after 47 // generating the authentication codes. If you generate the codes and then wait too 48 // long to submit the request, the MFA device successfully associates with the user 49 // but the MFA device becomes out of sync. This happens because time-based one-time 50 // passwords (TOTP) expire after a short period of time. If this happens, you can 51 // resync the device 52 // (https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_mfa_sync.html). 53 // 54 // This member is required. 55 AuthenticationCode2 *string 56 57 // The serial number that uniquely identifies the MFA device. For virtual MFA 58 // devices, the serial number is the device ARN. This parameter allows (through its 59 // regex pattern (http://wikipedia.org/wiki/regex)) a string of characters 60 // consisting of upper and lowercase alphanumeric characters with no spaces. You 61 // can also include any of the following characters: =,.@:/- 62 // 63 // This member is required. 64 SerialNumber *string 65 66 // The name of the IAM user for whom you want to enable the MFA device. This 67 // parameter allows (through its regex pattern (http://wikipedia.org/wiki/regex)) a 68 // string of characters consisting of upper and lowercase alphanumeric characters 69 // with no spaces. You can also include any of the following characters: _+=,.@- 70 // 71 // This member is required. 72 UserName *string 73} 74 75type EnableMFADeviceOutput struct { 76 // Metadata pertaining to the operation's result. 77 ResultMetadata middleware.Metadata 78} 79 80func addOperationEnableMFADeviceMiddlewares(stack *middleware.Stack, options Options) (err error) { 81 err = stack.Serialize.Add(&awsAwsquery_serializeOpEnableMFADevice{}, middleware.After) 82 if err != nil { 83 return err 84 } 85 err = stack.Deserialize.Add(&awsAwsquery_deserializeOpEnableMFADevice{}, middleware.After) 86 if err != nil { 87 return err 88 } 89 if err = addSetLoggerMiddleware(stack, options); err != nil { 90 return err 91 } 92 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 93 return err 94 } 95 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 96 return err 97 } 98 if err = addResolveEndpointMiddleware(stack, options); err != nil { 99 return err 100 } 101 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 102 return err 103 } 104 if err = addRetryMiddlewares(stack, options); err != nil { 105 return err 106 } 107 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 108 return err 109 } 110 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 111 return err 112 } 113 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 114 return err 115 } 116 if err = addClientUserAgent(stack); err != nil { 117 return err 118 } 119 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 120 return err 121 } 122 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 123 return err 124 } 125 if err = addOpEnableMFADeviceValidationMiddleware(stack); err != nil { 126 return err 127 } 128 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opEnableMFADevice(options.Region), middleware.Before); err != nil { 129 return err 130 } 131 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 132 return err 133 } 134 if err = addResponseErrorMiddleware(stack); err != nil { 135 return err 136 } 137 if err = addRequestResponseLogging(stack, options); err != nil { 138 return err 139 } 140 return nil 141} 142 143func newServiceMetadataMiddleware_opEnableMFADevice(region string) *awsmiddleware.RegisterServiceMetadata { 144 return &awsmiddleware.RegisterServiceMetadata{ 145 Region: region, 146 ServiceID: ServiceID, 147 SigningName: "iam", 148 OperationName: "EnableMFADevice", 149 } 150} 151