Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for AWS rest-xml protocol #727

Merged
merged 1 commit into from
Jan 14, 2020
Merged

Conversation

kstich
Copy link
Contributor

@kstich kstich commented Jan 13, 2020

Add support for AWS rest-xml protocol

This commit adds support for the aws.rest-xml protocol, building
on top of the HttpBindingProtocolGenerator for document and
payload serde.

Implementations of the DocumentMember[Deser|Ser]Visitor and the
DocumentShape[Deser|Ser]Visitor have been created that handle
Smithy's XML traits and their influence on protocol serde.

A minor update has been made to the XmlNode to allow for nodes to
be renamed, as the same structure may change XML node names when it
is bound to different locations.


Handles namespaces on payloads/services/structures:

Payload:

  if (input.Tagging !== undefined) {
    contents = serializeAws_restXmlTagging(input.Tagging, context);
    body = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
    contents.addAttribute("xmlns", "http://s3.amazonaws.com/doc/2006-03-01/");
    body += contents.toString();
  }

Service for document:

  body = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
  const bodyNode = new __XmlNode("SelectObjectContent");
  bodyNode.addAttribute("xmlns", "http://s3.amazonaws.com/doc/2006-03-01/");

Structure specific:

  const bodyNode = new __XmlNode("Grantee");
  bodyNode.addAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");

Handles flattened and unflattened aggregate shapes:

Unflattened:

  if (input.TopicConfigurations !== undefined) {
    const nodes = serializeAws_restXmlTopicConfigurationList(input.TopicConfigurations, context);
    nodes.map((node: any) => {
      node = node.withName("TopicConfiguration");
      bodyNode.addChildNode(node);
    });
  }

Flattened:

  if (input.TagSet !== undefined) {
    const nodes = serializeAws_restXmlTagSet(input.TagSet, context);
    const containerNode = new __XmlNode("TagSet");
    nodes.map((node: any) => {
      containerNode.addChildNode(node);
    });
    bodyNode.addChildNode(containerNode);
  }

Handles attributes and names:

  if (input.Type !== undefined) {
    bodyNode.addAttribute("xsi:type", input.Type);
  }

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@kstich kstich requested a review from mtdowling January 13, 2020 21:43
@AllanZhengYP AllanZhengYP changed the title Add support for AWS rest-xml protocol feat: add support for AWS rest-xml protocol Jan 13, 2020
@aws-sdk-js-automation

This comment has been minimized.

This commit adds support for the `aws.rest-xml` protocol, building
on top of the `HttpBindingProtocolGenerator` for document and
payload serde.

Implementations of the `DocumentMember[Deser|Ser]Visitor` and the
`DocumentShape[Deser|Ser]Visitor` have been created that handle
Smithy's XML traits and their influence on protocol serde.

A minor update has been made to the `XmlNode` to allow for nodes to
be renamed, as the same structure may change XML node names when it
is bound to different locations.
@aws-sdk-js-automation
Copy link

AWS CodeBuild CI Report

  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Copy link
Contributor

@AllanZhengYP AllanZhengYP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ship it! 🎉🎉

@kstich kstich merged commit d418410 into smithy-codegen Jan 14, 2020
@trivikr trivikr deleted the add_rest_xml branch January 14, 2020 04:05
@lock
Copy link

lock bot commented Jan 24, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants