1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package jsonrpc10 4 5import ( 6 "bytes" 7 "context" 8 "fmt" 9 "github.com/aws/aws-sdk-go-v2/internal/protocoltest/jsonrpc10/types" 10 smithy "github.com/aws/smithy-go" 11 "github.com/aws/smithy-go/encoding/httpbinding" 12 smithyjson "github.com/aws/smithy-go/encoding/json" 13 "github.com/aws/smithy-go/middleware" 14 smithytime "github.com/aws/smithy-go/time" 15 smithyhttp "github.com/aws/smithy-go/transport/http" 16 "strings" 17) 18 19type awsAwsjson10_serializeOpEmptyInputAndEmptyOutput struct { 20} 21 22func (*awsAwsjson10_serializeOpEmptyInputAndEmptyOutput) ID() string { 23 return "OperationSerializer" 24} 25 26func (m *awsAwsjson10_serializeOpEmptyInputAndEmptyOutput) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) ( 27 out middleware.SerializeOutput, metadata middleware.Metadata, err error, 28) { 29 request, ok := in.Request.(*smithyhttp.Request) 30 if !ok { 31 return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown transport type %T", in.Request)} 32 } 33 34 input, ok := in.Parameters.(*EmptyInputAndEmptyOutputInput) 35 _ = input 36 if !ok { 37 return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown input parameters type %T", in.Parameters)} 38 } 39 40 request.Request.URL.Path = "/" 41 request.Request.Method = "POST" 42 httpBindingEncoder, err := httpbinding.NewEncoder(request.URL.Path, request.URL.RawQuery, request.Header) 43 if err != nil { 44 return out, metadata, &smithy.SerializationError{Err: err} 45 } 46 httpBindingEncoder.SetHeader("Content-Type").String("application/x-amz-json-1.0") 47 httpBindingEncoder.SetHeader("X-Amz-Target").String("JsonRpc10.EmptyInputAndEmptyOutput") 48 49 jsonEncoder := smithyjson.NewEncoder() 50 if err := awsAwsjson10_serializeOpDocumentEmptyInputAndEmptyOutputInput(input, jsonEncoder.Value); err != nil { 51 return out, metadata, &smithy.SerializationError{Err: err} 52 } 53 54 if request, err = request.SetStream(bytes.NewReader(jsonEncoder.Bytes())); err != nil { 55 return out, metadata, &smithy.SerializationError{Err: err} 56 } 57 58 if request.Request, err = httpBindingEncoder.Encode(request.Request); err != nil { 59 return out, metadata, &smithy.SerializationError{Err: err} 60 } 61 in.Request = request 62 63 return next.HandleSerialize(ctx, in) 64} 65 66type awsAwsjson10_serializeOpEndpointOperation struct { 67} 68 69func (*awsAwsjson10_serializeOpEndpointOperation) ID() string { 70 return "OperationSerializer" 71} 72 73func (m *awsAwsjson10_serializeOpEndpointOperation) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) ( 74 out middleware.SerializeOutput, metadata middleware.Metadata, err error, 75) { 76 request, ok := in.Request.(*smithyhttp.Request) 77 if !ok { 78 return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown transport type %T", in.Request)} 79 } 80 81 input, ok := in.Parameters.(*EndpointOperationInput) 82 _ = input 83 if !ok { 84 return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown input parameters type %T", in.Parameters)} 85 } 86 87 request.Request.URL.Path = "/" 88 request.Request.Method = "POST" 89 httpBindingEncoder, err := httpbinding.NewEncoder(request.URL.Path, request.URL.RawQuery, request.Header) 90 if err != nil { 91 return out, metadata, &smithy.SerializationError{Err: err} 92 } 93 httpBindingEncoder.SetHeader("Content-Type").String("application/x-amz-json-1.0") 94 httpBindingEncoder.SetHeader("X-Amz-Target").String("JsonRpc10.EndpointOperation") 95 96 if request, err = request.SetStream(strings.NewReader(`{}`)); err != nil { 97 return out, metadata, &smithy.SerializationError{Err: err} 98 } 99 100 if request.Request, err = httpBindingEncoder.Encode(request.Request); err != nil { 101 return out, metadata, &smithy.SerializationError{Err: err} 102 } 103 in.Request = request 104 105 return next.HandleSerialize(ctx, in) 106} 107 108type awsAwsjson10_serializeOpEndpointWithHostLabelOperation struct { 109} 110 111func (*awsAwsjson10_serializeOpEndpointWithHostLabelOperation) ID() string { 112 return "OperationSerializer" 113} 114 115func (m *awsAwsjson10_serializeOpEndpointWithHostLabelOperation) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) ( 116 out middleware.SerializeOutput, metadata middleware.Metadata, err error, 117) { 118 request, ok := in.Request.(*smithyhttp.Request) 119 if !ok { 120 return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown transport type %T", in.Request)} 121 } 122 123 input, ok := in.Parameters.(*EndpointWithHostLabelOperationInput) 124 _ = input 125 if !ok { 126 return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown input parameters type %T", in.Parameters)} 127 } 128 129 request.Request.URL.Path = "/" 130 request.Request.Method = "POST" 131 httpBindingEncoder, err := httpbinding.NewEncoder(request.URL.Path, request.URL.RawQuery, request.Header) 132 if err != nil { 133 return out, metadata, &smithy.SerializationError{Err: err} 134 } 135 httpBindingEncoder.SetHeader("Content-Type").String("application/x-amz-json-1.0") 136 httpBindingEncoder.SetHeader("X-Amz-Target").String("JsonRpc10.EndpointWithHostLabelOperation") 137 138 jsonEncoder := smithyjson.NewEncoder() 139 if err := awsAwsjson10_serializeOpDocumentEndpointWithHostLabelOperationInput(input, jsonEncoder.Value); err != nil { 140 return out, metadata, &smithy.SerializationError{Err: err} 141 } 142 143 if request, err = request.SetStream(bytes.NewReader(jsonEncoder.Bytes())); err != nil { 144 return out, metadata, &smithy.SerializationError{Err: err} 145 } 146 147 if request.Request, err = httpBindingEncoder.Encode(request.Request); err != nil { 148 return out, metadata, &smithy.SerializationError{Err: err} 149 } 150 in.Request = request 151 152 return next.HandleSerialize(ctx, in) 153} 154 155type awsAwsjson10_serializeOpGreetingWithErrors struct { 156} 157 158func (*awsAwsjson10_serializeOpGreetingWithErrors) ID() string { 159 return "OperationSerializer" 160} 161 162func (m *awsAwsjson10_serializeOpGreetingWithErrors) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) ( 163 out middleware.SerializeOutput, metadata middleware.Metadata, err error, 164) { 165 request, ok := in.Request.(*smithyhttp.Request) 166 if !ok { 167 return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown transport type %T", in.Request)} 168 } 169 170 input, ok := in.Parameters.(*GreetingWithErrorsInput) 171 _ = input 172 if !ok { 173 return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown input parameters type %T", in.Parameters)} 174 } 175 176 request.Request.URL.Path = "/" 177 request.Request.Method = "POST" 178 httpBindingEncoder, err := httpbinding.NewEncoder(request.URL.Path, request.URL.RawQuery, request.Header) 179 if err != nil { 180 return out, metadata, &smithy.SerializationError{Err: err} 181 } 182 httpBindingEncoder.SetHeader("Content-Type").String("application/x-amz-json-1.0") 183 httpBindingEncoder.SetHeader("X-Amz-Target").String("JsonRpc10.GreetingWithErrors") 184 185 if request, err = request.SetStream(strings.NewReader(`{}`)); err != nil { 186 return out, metadata, &smithy.SerializationError{Err: err} 187 } 188 189 if request.Request, err = httpBindingEncoder.Encode(request.Request); err != nil { 190 return out, metadata, &smithy.SerializationError{Err: err} 191 } 192 in.Request = request 193 194 return next.HandleSerialize(ctx, in) 195} 196 197type awsAwsjson10_serializeOpJsonUnions struct { 198} 199 200func (*awsAwsjson10_serializeOpJsonUnions) ID() string { 201 return "OperationSerializer" 202} 203 204func (m *awsAwsjson10_serializeOpJsonUnions) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) ( 205 out middleware.SerializeOutput, metadata middleware.Metadata, err error, 206) { 207 request, ok := in.Request.(*smithyhttp.Request) 208 if !ok { 209 return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown transport type %T", in.Request)} 210 } 211 212 input, ok := in.Parameters.(*JsonUnionsInput) 213 _ = input 214 if !ok { 215 return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown input parameters type %T", in.Parameters)} 216 } 217 218 request.Request.URL.Path = "/" 219 request.Request.Method = "POST" 220 httpBindingEncoder, err := httpbinding.NewEncoder(request.URL.Path, request.URL.RawQuery, request.Header) 221 if err != nil { 222 return out, metadata, &smithy.SerializationError{Err: err} 223 } 224 httpBindingEncoder.SetHeader("Content-Type").String("application/x-amz-json-1.0") 225 httpBindingEncoder.SetHeader("X-Amz-Target").String("JsonRpc10.JsonUnions") 226 227 jsonEncoder := smithyjson.NewEncoder() 228 if err := awsAwsjson10_serializeOpDocumentJsonUnionsInput(input, jsonEncoder.Value); err != nil { 229 return out, metadata, &smithy.SerializationError{Err: err} 230 } 231 232 if request, err = request.SetStream(bytes.NewReader(jsonEncoder.Bytes())); err != nil { 233 return out, metadata, &smithy.SerializationError{Err: err} 234 } 235 236 if request.Request, err = httpBindingEncoder.Encode(request.Request); err != nil { 237 return out, metadata, &smithy.SerializationError{Err: err} 238 } 239 in.Request = request 240 241 return next.HandleSerialize(ctx, in) 242} 243 244type awsAwsjson10_serializeOpNoInputAndNoOutput struct { 245} 246 247func (*awsAwsjson10_serializeOpNoInputAndNoOutput) ID() string { 248 return "OperationSerializer" 249} 250 251func (m *awsAwsjson10_serializeOpNoInputAndNoOutput) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) ( 252 out middleware.SerializeOutput, metadata middleware.Metadata, err error, 253) { 254 request, ok := in.Request.(*smithyhttp.Request) 255 if !ok { 256 return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown transport type %T", in.Request)} 257 } 258 259 input, ok := in.Parameters.(*NoInputAndNoOutputInput) 260 _ = input 261 if !ok { 262 return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown input parameters type %T", in.Parameters)} 263 } 264 265 request.Request.URL.Path = "/" 266 request.Request.Method = "POST" 267 httpBindingEncoder, err := httpbinding.NewEncoder(request.URL.Path, request.URL.RawQuery, request.Header) 268 if err != nil { 269 return out, metadata, &smithy.SerializationError{Err: err} 270 } 271 httpBindingEncoder.SetHeader("Content-Type").String("application/x-amz-json-1.0") 272 httpBindingEncoder.SetHeader("X-Amz-Target").String("JsonRpc10.NoInputAndNoOutput") 273 274 if request, err = request.SetStream(strings.NewReader(`{}`)); err != nil { 275 return out, metadata, &smithy.SerializationError{Err: err} 276 } 277 278 if request.Request, err = httpBindingEncoder.Encode(request.Request); err != nil { 279 return out, metadata, &smithy.SerializationError{Err: err} 280 } 281 in.Request = request 282 283 return next.HandleSerialize(ctx, in) 284} 285 286type awsAwsjson10_serializeOpNoInputAndOutput struct { 287} 288 289func (*awsAwsjson10_serializeOpNoInputAndOutput) ID() string { 290 return "OperationSerializer" 291} 292 293func (m *awsAwsjson10_serializeOpNoInputAndOutput) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) ( 294 out middleware.SerializeOutput, metadata middleware.Metadata, err error, 295) { 296 request, ok := in.Request.(*smithyhttp.Request) 297 if !ok { 298 return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown transport type %T", in.Request)} 299 } 300 301 input, ok := in.Parameters.(*NoInputAndOutputInput) 302 _ = input 303 if !ok { 304 return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown input parameters type %T", in.Parameters)} 305 } 306 307 request.Request.URL.Path = "/" 308 request.Request.Method = "POST" 309 httpBindingEncoder, err := httpbinding.NewEncoder(request.URL.Path, request.URL.RawQuery, request.Header) 310 if err != nil { 311 return out, metadata, &smithy.SerializationError{Err: err} 312 } 313 httpBindingEncoder.SetHeader("Content-Type").String("application/x-amz-json-1.0") 314 httpBindingEncoder.SetHeader("X-Amz-Target").String("JsonRpc10.NoInputAndOutput") 315 316 if request, err = request.SetStream(strings.NewReader(`{}`)); err != nil { 317 return out, metadata, &smithy.SerializationError{Err: err} 318 } 319 320 if request.Request, err = httpBindingEncoder.Encode(request.Request); err != nil { 321 return out, metadata, &smithy.SerializationError{Err: err} 322 } 323 in.Request = request 324 325 return next.HandleSerialize(ctx, in) 326} 327func awsAwsjson10_serializeDocumentMyUnion(v types.MyUnion, value smithyjson.Value) error { 328 object := value.Object() 329 defer object.Close() 330 331 switch uv := v.(type) { 332 case *types.MyUnionMemberBlobValue: 333 av := object.Key("blobValue") 334 av.Base64EncodeBytes(uv.Value) 335 336 case *types.MyUnionMemberBooleanValue: 337 av := object.Key("booleanValue") 338 av.Boolean(uv.Value) 339 340 case *types.MyUnionMemberEnumValue: 341 av := object.Key("enumValue") 342 av.String(string(uv.Value)) 343 344 case *types.MyUnionMemberListValue: 345 av := object.Key("listValue") 346 if err := awsAwsjson10_serializeDocumentStringList(uv.Value, av); err != nil { 347 return err 348 } 349 350 case *types.MyUnionMemberMapValue: 351 av := object.Key("mapValue") 352 if err := awsAwsjson10_serializeDocumentStringMap(uv.Value, av); err != nil { 353 return err 354 } 355 356 case *types.MyUnionMemberNumberValue: 357 av := object.Key("numberValue") 358 av.Integer(uv.Value) 359 360 case *types.MyUnionMemberStringValue: 361 av := object.Key("stringValue") 362 av.String(uv.Value) 363 364 case *types.MyUnionMemberStructureValue: 365 av := object.Key("structureValue") 366 if err := awsAwsjson10_serializeDocumentGreetingStruct(&uv.Value, av); err != nil { 367 return err 368 } 369 370 case *types.MyUnionMemberTimestampValue: 371 av := object.Key("timestampValue") 372 av.Double(smithytime.FormatEpochSeconds(uv.Value)) 373 374 default: 375 return fmt.Errorf("attempted to serialize unknown member type %T for union %T", uv, v) 376 377 } 378 return nil 379} 380 381func awsAwsjson10_serializeDocumentGreetingStruct(v *types.GreetingStruct, value smithyjson.Value) error { 382 object := value.Object() 383 defer object.Close() 384 385 if v.Hi != nil { 386 ok := object.Key("hi") 387 ok.String(*v.Hi) 388 } 389 390 return nil 391} 392 393func awsAwsjson10_serializeDocumentStringList(v []string, value smithyjson.Value) error { 394 array := value.Array() 395 defer array.Close() 396 397 for i := range v { 398 av := array.Value() 399 av.String(v[i]) 400 } 401 return nil 402} 403 404func awsAwsjson10_serializeDocumentStringMap(v map[string]string, value smithyjson.Value) error { 405 object := value.Object() 406 defer object.Close() 407 408 for key := range v { 409 om := object.Key(key) 410 om.String(v[key]) 411 } 412 return nil 413} 414 415func awsAwsjson10_serializeOpDocumentEmptyInputAndEmptyOutputInput(v *EmptyInputAndEmptyOutputInput, value smithyjson.Value) error { 416 object := value.Object() 417 defer object.Close() 418 419 return nil 420} 421 422func awsAwsjson10_serializeOpDocumentEndpointWithHostLabelOperationInput(v *EndpointWithHostLabelOperationInput, value smithyjson.Value) error { 423 object := value.Object() 424 defer object.Close() 425 426 if v.Label != nil { 427 ok := object.Key("label") 428 ok.String(*v.Label) 429 } 430 431 return nil 432} 433 434func awsAwsjson10_serializeOpDocumentJsonUnionsInput(v *JsonUnionsInput, value smithyjson.Value) error { 435 object := value.Object() 436 defer object.Close() 437 438 if v.Contents != nil { 439 ok := object.Key("contents") 440 if err := awsAwsjson10_serializeDocumentMyUnion(v.Contents, ok); err != nil { 441 return err 442 } 443 } 444 445 return nil 446} 447