serializers.go (12897B)
1 // Code generated by smithy-go-codegen DO NOT EDIT. 2 3 package ssooidc 4 5 import ( 6 "bytes" 7 "context" 8 "fmt" 9 smithy "github.com/aws/smithy-go" 10 "github.com/aws/smithy-go/encoding/httpbinding" 11 smithyjson "github.com/aws/smithy-go/encoding/json" 12 "github.com/aws/smithy-go/middleware" 13 smithyhttp "github.com/aws/smithy-go/transport/http" 14 ) 15 16 type awsRestjson1_serializeOpCreateToken struct { 17 } 18 19 func (*awsRestjson1_serializeOpCreateToken) ID() string { 20 return "OperationSerializer" 21 } 22 23 func (m *awsRestjson1_serializeOpCreateToken) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) ( 24 out middleware.SerializeOutput, metadata middleware.Metadata, err error, 25 ) { 26 request, ok := in.Request.(*smithyhttp.Request) 27 if !ok { 28 return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown transport type %T", in.Request)} 29 } 30 31 input, ok := in.Parameters.(*CreateTokenInput) 32 _ = input 33 if !ok { 34 return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown input parameters type %T", in.Parameters)} 35 } 36 37 opPath, opQuery := httpbinding.SplitURI("/token") 38 request.URL.Path = smithyhttp.JoinPath(request.URL.Path, opPath) 39 request.URL.RawQuery = smithyhttp.JoinRawQuery(request.URL.RawQuery, opQuery) 40 request.Method = "POST" 41 var restEncoder *httpbinding.Encoder 42 if request.URL.RawPath == "" { 43 restEncoder, err = httpbinding.NewEncoder(request.URL.Path, request.URL.RawQuery, request.Header) 44 } else { 45 request.URL.RawPath = smithyhttp.JoinPath(request.URL.RawPath, opPath) 46 restEncoder, err = httpbinding.NewEncoderWithRawPath(request.URL.Path, request.URL.RawPath, request.URL.RawQuery, request.Header) 47 } 48 49 if err != nil { 50 return out, metadata, &smithy.SerializationError{Err: err} 51 } 52 53 restEncoder.SetHeader("Content-Type").String("application/json") 54 55 jsonEncoder := smithyjson.NewEncoder() 56 if err := awsRestjson1_serializeOpDocumentCreateTokenInput(input, jsonEncoder.Value); err != nil { 57 return out, metadata, &smithy.SerializationError{Err: err} 58 } 59 60 if request, err = request.SetStream(bytes.NewReader(jsonEncoder.Bytes())); err != nil { 61 return out, metadata, &smithy.SerializationError{Err: err} 62 } 63 64 if request.Request, err = restEncoder.Encode(request.Request); err != nil { 65 return out, metadata, &smithy.SerializationError{Err: err} 66 } 67 in.Request = request 68 69 return next.HandleSerialize(ctx, in) 70 } 71 func awsRestjson1_serializeOpHttpBindingsCreateTokenInput(v *CreateTokenInput, encoder *httpbinding.Encoder) error { 72 if v == nil { 73 return fmt.Errorf("unsupported serialization of nil %T", v) 74 } 75 76 return nil 77 } 78 79 func awsRestjson1_serializeOpDocumentCreateTokenInput(v *CreateTokenInput, value smithyjson.Value) error { 80 object := value.Object() 81 defer object.Close() 82 83 if v.ClientId != nil { 84 ok := object.Key("clientId") 85 ok.String(*v.ClientId) 86 } 87 88 if v.ClientSecret != nil { 89 ok := object.Key("clientSecret") 90 ok.String(*v.ClientSecret) 91 } 92 93 if v.Code != nil { 94 ok := object.Key("code") 95 ok.String(*v.Code) 96 } 97 98 if v.DeviceCode != nil { 99 ok := object.Key("deviceCode") 100 ok.String(*v.DeviceCode) 101 } 102 103 if v.GrantType != nil { 104 ok := object.Key("grantType") 105 ok.String(*v.GrantType) 106 } 107 108 if v.RedirectUri != nil { 109 ok := object.Key("redirectUri") 110 ok.String(*v.RedirectUri) 111 } 112 113 if v.RefreshToken != nil { 114 ok := object.Key("refreshToken") 115 ok.String(*v.RefreshToken) 116 } 117 118 if v.Scope != nil { 119 ok := object.Key("scope") 120 if err := awsRestjson1_serializeDocumentScopes(v.Scope, ok); err != nil { 121 return err 122 } 123 } 124 125 return nil 126 } 127 128 type awsRestjson1_serializeOpCreateTokenWithIAM struct { 129 } 130 131 func (*awsRestjson1_serializeOpCreateTokenWithIAM) ID() string { 132 return "OperationSerializer" 133 } 134 135 func (m *awsRestjson1_serializeOpCreateTokenWithIAM) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) ( 136 out middleware.SerializeOutput, metadata middleware.Metadata, err error, 137 ) { 138 request, ok := in.Request.(*smithyhttp.Request) 139 if !ok { 140 return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown transport type %T", in.Request)} 141 } 142 143 input, ok := in.Parameters.(*CreateTokenWithIAMInput) 144 _ = input 145 if !ok { 146 return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown input parameters type %T", in.Parameters)} 147 } 148 149 opPath, opQuery := httpbinding.SplitURI("/token?aws_iam=t") 150 request.URL.Path = smithyhttp.JoinPath(request.URL.Path, opPath) 151 request.URL.RawQuery = smithyhttp.JoinRawQuery(request.URL.RawQuery, opQuery) 152 request.Method = "POST" 153 var restEncoder *httpbinding.Encoder 154 if request.URL.RawPath == "" { 155 restEncoder, err = httpbinding.NewEncoder(request.URL.Path, request.URL.RawQuery, request.Header) 156 } else { 157 request.URL.RawPath = smithyhttp.JoinPath(request.URL.RawPath, opPath) 158 restEncoder, err = httpbinding.NewEncoderWithRawPath(request.URL.Path, request.URL.RawPath, request.URL.RawQuery, request.Header) 159 } 160 161 if err != nil { 162 return out, metadata, &smithy.SerializationError{Err: err} 163 } 164 165 restEncoder.SetHeader("Content-Type").String("application/json") 166 167 jsonEncoder := smithyjson.NewEncoder() 168 if err := awsRestjson1_serializeOpDocumentCreateTokenWithIAMInput(input, jsonEncoder.Value); err != nil { 169 return out, metadata, &smithy.SerializationError{Err: err} 170 } 171 172 if request, err = request.SetStream(bytes.NewReader(jsonEncoder.Bytes())); err != nil { 173 return out, metadata, &smithy.SerializationError{Err: err} 174 } 175 176 if request.Request, err = restEncoder.Encode(request.Request); err != nil { 177 return out, metadata, &smithy.SerializationError{Err: err} 178 } 179 in.Request = request 180 181 return next.HandleSerialize(ctx, in) 182 } 183 func awsRestjson1_serializeOpHttpBindingsCreateTokenWithIAMInput(v *CreateTokenWithIAMInput, encoder *httpbinding.Encoder) error { 184 if v == nil { 185 return fmt.Errorf("unsupported serialization of nil %T", v) 186 } 187 188 return nil 189 } 190 191 func awsRestjson1_serializeOpDocumentCreateTokenWithIAMInput(v *CreateTokenWithIAMInput, value smithyjson.Value) error { 192 object := value.Object() 193 defer object.Close() 194 195 if v.Assertion != nil { 196 ok := object.Key("assertion") 197 ok.String(*v.Assertion) 198 } 199 200 if v.ClientId != nil { 201 ok := object.Key("clientId") 202 ok.String(*v.ClientId) 203 } 204 205 if v.Code != nil { 206 ok := object.Key("code") 207 ok.String(*v.Code) 208 } 209 210 if v.GrantType != nil { 211 ok := object.Key("grantType") 212 ok.String(*v.GrantType) 213 } 214 215 if v.RedirectUri != nil { 216 ok := object.Key("redirectUri") 217 ok.String(*v.RedirectUri) 218 } 219 220 if v.RefreshToken != nil { 221 ok := object.Key("refreshToken") 222 ok.String(*v.RefreshToken) 223 } 224 225 if v.RequestedTokenType != nil { 226 ok := object.Key("requestedTokenType") 227 ok.String(*v.RequestedTokenType) 228 } 229 230 if v.Scope != nil { 231 ok := object.Key("scope") 232 if err := awsRestjson1_serializeDocumentScopes(v.Scope, ok); err != nil { 233 return err 234 } 235 } 236 237 if v.SubjectToken != nil { 238 ok := object.Key("subjectToken") 239 ok.String(*v.SubjectToken) 240 } 241 242 if v.SubjectTokenType != nil { 243 ok := object.Key("subjectTokenType") 244 ok.String(*v.SubjectTokenType) 245 } 246 247 return nil 248 } 249 250 type awsRestjson1_serializeOpRegisterClient struct { 251 } 252 253 func (*awsRestjson1_serializeOpRegisterClient) ID() string { 254 return "OperationSerializer" 255 } 256 257 func (m *awsRestjson1_serializeOpRegisterClient) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) ( 258 out middleware.SerializeOutput, metadata middleware.Metadata, err error, 259 ) { 260 request, ok := in.Request.(*smithyhttp.Request) 261 if !ok { 262 return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown transport type %T", in.Request)} 263 } 264 265 input, ok := in.Parameters.(*RegisterClientInput) 266 _ = input 267 if !ok { 268 return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown input parameters type %T", in.Parameters)} 269 } 270 271 opPath, opQuery := httpbinding.SplitURI("/client/register") 272 request.URL.Path = smithyhttp.JoinPath(request.URL.Path, opPath) 273 request.URL.RawQuery = smithyhttp.JoinRawQuery(request.URL.RawQuery, opQuery) 274 request.Method = "POST" 275 var restEncoder *httpbinding.Encoder 276 if request.URL.RawPath == "" { 277 restEncoder, err = httpbinding.NewEncoder(request.URL.Path, request.URL.RawQuery, request.Header) 278 } else { 279 request.URL.RawPath = smithyhttp.JoinPath(request.URL.RawPath, opPath) 280 restEncoder, err = httpbinding.NewEncoderWithRawPath(request.URL.Path, request.URL.RawPath, request.URL.RawQuery, request.Header) 281 } 282 283 if err != nil { 284 return out, metadata, &smithy.SerializationError{Err: err} 285 } 286 287 restEncoder.SetHeader("Content-Type").String("application/json") 288 289 jsonEncoder := smithyjson.NewEncoder() 290 if err := awsRestjson1_serializeOpDocumentRegisterClientInput(input, jsonEncoder.Value); err != nil { 291 return out, metadata, &smithy.SerializationError{Err: err} 292 } 293 294 if request, err = request.SetStream(bytes.NewReader(jsonEncoder.Bytes())); err != nil { 295 return out, metadata, &smithy.SerializationError{Err: err} 296 } 297 298 if request.Request, err = restEncoder.Encode(request.Request); err != nil { 299 return out, metadata, &smithy.SerializationError{Err: err} 300 } 301 in.Request = request 302 303 return next.HandleSerialize(ctx, in) 304 } 305 func awsRestjson1_serializeOpHttpBindingsRegisterClientInput(v *RegisterClientInput, encoder *httpbinding.Encoder) error { 306 if v == nil { 307 return fmt.Errorf("unsupported serialization of nil %T", v) 308 } 309 310 return nil 311 } 312 313 func awsRestjson1_serializeOpDocumentRegisterClientInput(v *RegisterClientInput, value smithyjson.Value) error { 314 object := value.Object() 315 defer object.Close() 316 317 if v.ClientName != nil { 318 ok := object.Key("clientName") 319 ok.String(*v.ClientName) 320 } 321 322 if v.ClientType != nil { 323 ok := object.Key("clientType") 324 ok.String(*v.ClientType) 325 } 326 327 if v.Scopes != nil { 328 ok := object.Key("scopes") 329 if err := awsRestjson1_serializeDocumentScopes(v.Scopes, ok); err != nil { 330 return err 331 } 332 } 333 334 return nil 335 } 336 337 type awsRestjson1_serializeOpStartDeviceAuthorization struct { 338 } 339 340 func (*awsRestjson1_serializeOpStartDeviceAuthorization) ID() string { 341 return "OperationSerializer" 342 } 343 344 func (m *awsRestjson1_serializeOpStartDeviceAuthorization) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) ( 345 out middleware.SerializeOutput, metadata middleware.Metadata, err error, 346 ) { 347 request, ok := in.Request.(*smithyhttp.Request) 348 if !ok { 349 return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown transport type %T", in.Request)} 350 } 351 352 input, ok := in.Parameters.(*StartDeviceAuthorizationInput) 353 _ = input 354 if !ok { 355 return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown input parameters type %T", in.Parameters)} 356 } 357 358 opPath, opQuery := httpbinding.SplitURI("/device_authorization") 359 request.URL.Path = smithyhttp.JoinPath(request.URL.Path, opPath) 360 request.URL.RawQuery = smithyhttp.JoinRawQuery(request.URL.RawQuery, opQuery) 361 request.Method = "POST" 362 var restEncoder *httpbinding.Encoder 363 if request.URL.RawPath == "" { 364 restEncoder, err = httpbinding.NewEncoder(request.URL.Path, request.URL.RawQuery, request.Header) 365 } else { 366 request.URL.RawPath = smithyhttp.JoinPath(request.URL.RawPath, opPath) 367 restEncoder, err = httpbinding.NewEncoderWithRawPath(request.URL.Path, request.URL.RawPath, request.URL.RawQuery, request.Header) 368 } 369 370 if err != nil { 371 return out, metadata, &smithy.SerializationError{Err: err} 372 } 373 374 restEncoder.SetHeader("Content-Type").String("application/json") 375 376 jsonEncoder := smithyjson.NewEncoder() 377 if err := awsRestjson1_serializeOpDocumentStartDeviceAuthorizationInput(input, jsonEncoder.Value); err != nil { 378 return out, metadata, &smithy.SerializationError{Err: err} 379 } 380 381 if request, err = request.SetStream(bytes.NewReader(jsonEncoder.Bytes())); err != nil { 382 return out, metadata, &smithy.SerializationError{Err: err} 383 } 384 385 if request.Request, err = restEncoder.Encode(request.Request); err != nil { 386 return out, metadata, &smithy.SerializationError{Err: err} 387 } 388 in.Request = request 389 390 return next.HandleSerialize(ctx, in) 391 } 392 func awsRestjson1_serializeOpHttpBindingsStartDeviceAuthorizationInput(v *StartDeviceAuthorizationInput, encoder *httpbinding.Encoder) error { 393 if v == nil { 394 return fmt.Errorf("unsupported serialization of nil %T", v) 395 } 396 397 return nil 398 } 399 400 func awsRestjson1_serializeOpDocumentStartDeviceAuthorizationInput(v *StartDeviceAuthorizationInput, value smithyjson.Value) error { 401 object := value.Object() 402 defer object.Close() 403 404 if v.ClientId != nil { 405 ok := object.Key("clientId") 406 ok.String(*v.ClientId) 407 } 408 409 if v.ClientSecret != nil { 410 ok := object.Key("clientSecret") 411 ok.String(*v.ClientSecret) 412 } 413 414 if v.StartUrl != nil { 415 ok := object.Key("startUrl") 416 ok.String(*v.StartUrl) 417 } 418 419 return nil 420 } 421 422 func awsRestjson1_serializeDocumentScopes(v []string, value smithyjson.Value) error { 423 array := value.Array() 424 defer array.Close() 425 426 for i := range v { 427 av := array.Value() 428 av.String(v[i]) 429 } 430 return nil 431 }