serializers.go 15 KB

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