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/aws-sdk-go-v2/service/iam/types" 10 "github.com/aws/smithy-go/middleware" 11 smithyhttp "github.com/aws/smithy-go/transport/http" 12) 13 14// Creates a new IAM user for your account. For information about quotas for the 15// number of IAM users you can create, see IAM and STS quotas 16// (https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_iam-quotas.html) in 17// the IAM User Guide. 18func (c *Client) CreateUser(ctx context.Context, params *CreateUserInput, optFns ...func(*Options)) (*CreateUserOutput, error) { 19 if params == nil { 20 params = &CreateUserInput{} 21 } 22 23 result, metadata, err := c.invokeOperation(ctx, "CreateUser", params, optFns, c.addOperationCreateUserMiddlewares) 24 if err != nil { 25 return nil, err 26 } 27 28 out := result.(*CreateUserOutput) 29 out.ResultMetadata = metadata 30 return out, nil 31} 32 33type CreateUserInput struct { 34 35 // The name of the user to create. IAM user, group, role, and policy names must be 36 // unique within the account. Names are not distinguished by case. For example, you 37 // cannot create resources named both "MyResource" and "myresource". 38 // 39 // This member is required. 40 UserName *string 41 42 // The path for the user name. For more information about paths, see IAM 43 // identifiers 44 // (https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html) in the 45 // IAM User Guide. This parameter is optional. If it is not included, it defaults 46 // to a slash (/). This parameter allows (through its regex pattern 47 // (http://wikipedia.org/wiki/regex)) a string of characters consisting of either a 48 // forward slash (/) by itself or a string that must begin and end with forward 49 // slashes. In addition, it can contain any ASCII character from the ! (\u0021) 50 // through the DEL character (\u007F), including most punctuation characters, 51 // digits, and upper and lowercased letters. 52 Path *string 53 54 // The ARN of the policy that is used to set the permissions boundary for the user. 55 PermissionsBoundary *string 56 57 // A list of tags that you want to attach to the new user. Each tag consists of a 58 // key name and an associated value. For more information about tagging, see 59 // Tagging IAM resources 60 // (https://docs.aws.amazon.com/IAM/latest/UserGuide/id_tags.html) in the IAM User 61 // Guide. If any one of the tags is invalid or if you exceed the allowed maximum 62 // number of tags, then the entire request fails and the resource is not created. 63 Tags []types.Tag 64 65 noSmithyDocumentSerde 66} 67 68// Contains the response to a successful CreateUser request. 69type CreateUserOutput struct { 70 71 // A structure with details about the new IAM user. 72 User *types.User 73 74 // Metadata pertaining to the operation's result. 75 ResultMetadata middleware.Metadata 76 77 noSmithyDocumentSerde 78} 79 80func (c *Client) addOperationCreateUserMiddlewares(stack *middleware.Stack, options Options) (err error) { 81 err = stack.Serialize.Add(&awsAwsquery_serializeOpCreateUser{}, middleware.After) 82 if err != nil { 83 return err 84 } 85 err = stack.Deserialize.Add(&awsAwsquery_deserializeOpCreateUser{}, 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 = addOpCreateUserValidationMiddleware(stack); err != nil { 126 return err 127 } 128 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateUser(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_opCreateUser(region string) *awsmiddleware.RegisterServiceMetadata { 144 return &awsmiddleware.RegisterServiceMetadata{ 145 Region: region, 146 ServiceID: ServiceID, 147 SigningName: "iam", 148 OperationName: "CreateUser", 149 } 150} 151