validators.go (8855B)
1 // Code generated by smithy-go-codegen DO NOT EDIT. 2 3 package sts 4 5 import ( 6 "context" 7 "fmt" 8 "github.com/aws/aws-sdk-go-v2/service/sts/types" 9 smithy "github.com/aws/smithy-go" 10 "github.com/aws/smithy-go/middleware" 11 ) 12 13 type validateOpAssumeRole struct { 14 } 15 16 func (*validateOpAssumeRole) ID() string { 17 return "OperationInputValidation" 18 } 19 20 func (m *validateOpAssumeRole) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) ( 21 out middleware.InitializeOutput, metadata middleware.Metadata, err error, 22 ) { 23 input, ok := in.Parameters.(*AssumeRoleInput) 24 if !ok { 25 return out, metadata, fmt.Errorf("unknown input parameters type %T", in.Parameters) 26 } 27 if err := validateOpAssumeRoleInput(input); err != nil { 28 return out, metadata, err 29 } 30 return next.HandleInitialize(ctx, in) 31 } 32 33 type validateOpAssumeRoleWithSAML struct { 34 } 35 36 func (*validateOpAssumeRoleWithSAML) ID() string { 37 return "OperationInputValidation" 38 } 39 40 func (m *validateOpAssumeRoleWithSAML) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) ( 41 out middleware.InitializeOutput, metadata middleware.Metadata, err error, 42 ) { 43 input, ok := in.Parameters.(*AssumeRoleWithSAMLInput) 44 if !ok { 45 return out, metadata, fmt.Errorf("unknown input parameters type %T", in.Parameters) 46 } 47 if err := validateOpAssumeRoleWithSAMLInput(input); err != nil { 48 return out, metadata, err 49 } 50 return next.HandleInitialize(ctx, in) 51 } 52 53 type validateOpAssumeRoleWithWebIdentity struct { 54 } 55 56 func (*validateOpAssumeRoleWithWebIdentity) ID() string { 57 return "OperationInputValidation" 58 } 59 60 func (m *validateOpAssumeRoleWithWebIdentity) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) ( 61 out middleware.InitializeOutput, metadata middleware.Metadata, err error, 62 ) { 63 input, ok := in.Parameters.(*AssumeRoleWithWebIdentityInput) 64 if !ok { 65 return out, metadata, fmt.Errorf("unknown input parameters type %T", in.Parameters) 66 } 67 if err := validateOpAssumeRoleWithWebIdentityInput(input); err != nil { 68 return out, metadata, err 69 } 70 return next.HandleInitialize(ctx, in) 71 } 72 73 type validateOpDecodeAuthorizationMessage struct { 74 } 75 76 func (*validateOpDecodeAuthorizationMessage) ID() string { 77 return "OperationInputValidation" 78 } 79 80 func (m *validateOpDecodeAuthorizationMessage) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) ( 81 out middleware.InitializeOutput, metadata middleware.Metadata, err error, 82 ) { 83 input, ok := in.Parameters.(*DecodeAuthorizationMessageInput) 84 if !ok { 85 return out, metadata, fmt.Errorf("unknown input parameters type %T", in.Parameters) 86 } 87 if err := validateOpDecodeAuthorizationMessageInput(input); err != nil { 88 return out, metadata, err 89 } 90 return next.HandleInitialize(ctx, in) 91 } 92 93 type validateOpGetAccessKeyInfo struct { 94 } 95 96 func (*validateOpGetAccessKeyInfo) ID() string { 97 return "OperationInputValidation" 98 } 99 100 func (m *validateOpGetAccessKeyInfo) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) ( 101 out middleware.InitializeOutput, metadata middleware.Metadata, err error, 102 ) { 103 input, ok := in.Parameters.(*GetAccessKeyInfoInput) 104 if !ok { 105 return out, metadata, fmt.Errorf("unknown input parameters type %T", in.Parameters) 106 } 107 if err := validateOpGetAccessKeyInfoInput(input); err != nil { 108 return out, metadata, err 109 } 110 return next.HandleInitialize(ctx, in) 111 } 112 113 type validateOpGetFederationToken struct { 114 } 115 116 func (*validateOpGetFederationToken) ID() string { 117 return "OperationInputValidation" 118 } 119 120 func (m *validateOpGetFederationToken) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) ( 121 out middleware.InitializeOutput, metadata middleware.Metadata, err error, 122 ) { 123 input, ok := in.Parameters.(*GetFederationTokenInput) 124 if !ok { 125 return out, metadata, fmt.Errorf("unknown input parameters type %T", in.Parameters) 126 } 127 if err := validateOpGetFederationTokenInput(input); err != nil { 128 return out, metadata, err 129 } 130 return next.HandleInitialize(ctx, in) 131 } 132 133 func addOpAssumeRoleValidationMiddleware(stack *middleware.Stack) error { 134 return stack.Initialize.Add(&validateOpAssumeRole{}, middleware.After) 135 } 136 137 func addOpAssumeRoleWithSAMLValidationMiddleware(stack *middleware.Stack) error { 138 return stack.Initialize.Add(&validateOpAssumeRoleWithSAML{}, middleware.After) 139 } 140 141 func addOpAssumeRoleWithWebIdentityValidationMiddleware(stack *middleware.Stack) error { 142 return stack.Initialize.Add(&validateOpAssumeRoleWithWebIdentity{}, middleware.After) 143 } 144 145 func addOpDecodeAuthorizationMessageValidationMiddleware(stack *middleware.Stack) error { 146 return stack.Initialize.Add(&validateOpDecodeAuthorizationMessage{}, middleware.After) 147 } 148 149 func addOpGetAccessKeyInfoValidationMiddleware(stack *middleware.Stack) error { 150 return stack.Initialize.Add(&validateOpGetAccessKeyInfo{}, middleware.After) 151 } 152 153 func addOpGetFederationTokenValidationMiddleware(stack *middleware.Stack) error { 154 return stack.Initialize.Add(&validateOpGetFederationToken{}, middleware.After) 155 } 156 157 func validateTag(v *types.Tag) error { 158 if v == nil { 159 return nil 160 } 161 invalidParams := smithy.InvalidParamsError{Context: "Tag"} 162 if v.Key == nil { 163 invalidParams.Add(smithy.NewErrParamRequired("Key")) 164 } 165 if v.Value == nil { 166 invalidParams.Add(smithy.NewErrParamRequired("Value")) 167 } 168 if invalidParams.Len() > 0 { 169 return invalidParams 170 } else { 171 return nil 172 } 173 } 174 175 func validateTagListType(v []types.Tag) error { 176 if v == nil { 177 return nil 178 } 179 invalidParams := smithy.InvalidParamsError{Context: "TagListType"} 180 for i := range v { 181 if err := validateTag(&v[i]); err != nil { 182 invalidParams.AddNested(fmt.Sprintf("[%d]", i), err.(smithy.InvalidParamsError)) 183 } 184 } 185 if invalidParams.Len() > 0 { 186 return invalidParams 187 } else { 188 return nil 189 } 190 } 191 192 func validateOpAssumeRoleInput(v *AssumeRoleInput) error { 193 if v == nil { 194 return nil 195 } 196 invalidParams := smithy.InvalidParamsError{Context: "AssumeRoleInput"} 197 if v.RoleArn == nil { 198 invalidParams.Add(smithy.NewErrParamRequired("RoleArn")) 199 } 200 if v.RoleSessionName == nil { 201 invalidParams.Add(smithy.NewErrParamRequired("RoleSessionName")) 202 } 203 if v.Tags != nil { 204 if err := validateTagListType(v.Tags); err != nil { 205 invalidParams.AddNested("Tags", err.(smithy.InvalidParamsError)) 206 } 207 } 208 if invalidParams.Len() > 0 { 209 return invalidParams 210 } else { 211 return nil 212 } 213 } 214 215 func validateOpAssumeRoleWithSAMLInput(v *AssumeRoleWithSAMLInput) error { 216 if v == nil { 217 return nil 218 } 219 invalidParams := smithy.InvalidParamsError{Context: "AssumeRoleWithSAMLInput"} 220 if v.RoleArn == nil { 221 invalidParams.Add(smithy.NewErrParamRequired("RoleArn")) 222 } 223 if v.PrincipalArn == nil { 224 invalidParams.Add(smithy.NewErrParamRequired("PrincipalArn")) 225 } 226 if v.SAMLAssertion == nil { 227 invalidParams.Add(smithy.NewErrParamRequired("SAMLAssertion")) 228 } 229 if invalidParams.Len() > 0 { 230 return invalidParams 231 } else { 232 return nil 233 } 234 } 235 236 func validateOpAssumeRoleWithWebIdentityInput(v *AssumeRoleWithWebIdentityInput) error { 237 if v == nil { 238 return nil 239 } 240 invalidParams := smithy.InvalidParamsError{Context: "AssumeRoleWithWebIdentityInput"} 241 if v.RoleArn == nil { 242 invalidParams.Add(smithy.NewErrParamRequired("RoleArn")) 243 } 244 if v.RoleSessionName == nil { 245 invalidParams.Add(smithy.NewErrParamRequired("RoleSessionName")) 246 } 247 if v.WebIdentityToken == nil { 248 invalidParams.Add(smithy.NewErrParamRequired("WebIdentityToken")) 249 } 250 if invalidParams.Len() > 0 { 251 return invalidParams 252 } else { 253 return nil 254 } 255 } 256 257 func validateOpDecodeAuthorizationMessageInput(v *DecodeAuthorizationMessageInput) error { 258 if v == nil { 259 return nil 260 } 261 invalidParams := smithy.InvalidParamsError{Context: "DecodeAuthorizationMessageInput"} 262 if v.EncodedMessage == nil { 263 invalidParams.Add(smithy.NewErrParamRequired("EncodedMessage")) 264 } 265 if invalidParams.Len() > 0 { 266 return invalidParams 267 } else { 268 return nil 269 } 270 } 271 272 func validateOpGetAccessKeyInfoInput(v *GetAccessKeyInfoInput) error { 273 if v == nil { 274 return nil 275 } 276 invalidParams := smithy.InvalidParamsError{Context: "GetAccessKeyInfoInput"} 277 if v.AccessKeyId == nil { 278 invalidParams.Add(smithy.NewErrParamRequired("AccessKeyId")) 279 } 280 if invalidParams.Len() > 0 { 281 return invalidParams 282 } else { 283 return nil 284 } 285 } 286 287 func validateOpGetFederationTokenInput(v *GetFederationTokenInput) error { 288 if v == nil { 289 return nil 290 } 291 invalidParams := smithy.InvalidParamsError{Context: "GetFederationTokenInput"} 292 if v.Name == nil { 293 invalidParams.Add(smithy.NewErrParamRequired("Name")) 294 } 295 if v.Tags != nil { 296 if err := validateTagListType(v.Tags); err != nil { 297 invalidParams.AddNested("Tags", err.(smithy.InvalidParamsError)) 298 } 299 } 300 if invalidParams.Len() > 0 { 301 return invalidParams 302 } else { 303 return nil 304 } 305 }