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

Add @s3UnwrappedXmlOutput trait to support S3's GetBucketLocation #839

Merged
merged 3 commits into from
Jun 23, 2021
Merged

Add @s3UnwrappedXmlOutput trait to support S3's GetBucketLocation #839

merged 3 commits into from
Jun 23, 2021

Conversation

jdisanti
Copy link
Contributor

This PR adds a new @s3UnwrappedXmlOutput trait so that the response shape for S3's GetBucketLocation call can be expressed in the Smithy model, and also adds an S3 protocol test to exercise the new trait.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@kggilmer
Copy link
Contributor

imho It seems a little weird to create a trait to fix a specific problem on a specific operation, as one would expect traits to be more general purpose. I'm guessing that this is the approach because, due to the structure of the response, Smithy is unable to describe it. Would a more general-purpose approach be a trait which would collapse the wrapper of any XML structure/shape, similar to how maps and lists can be flattened?

}
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

minor: Should have a newline at EOF.

import software.amazon.smithy.model.traits.AnnotationTrait;

public final class S3UnwrappedXmlOutputTrait extends AnnotationTrait {
public static final ShapeId ID = ShapeId.from("smithy.api#s3UnwrappedXmlOutput");
Copy link
Contributor

Choose a reason for hiding this comment

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

The namespace should be aws.customizations and not smithy.api here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch! Fixed.

@@ -130,3 +130,22 @@ resolved to "virtual" to enable this setting.
.. _path-style requests: https://docs.aws.amazon.com/AmazonS3/latest/dev/VirtualHosting.html#path-style-access
.. _dual-stack endpoints: https://docs.aws.amazon.com/AmazonS3/latest/dev/dual-stack-endpoints.html
.. _transfer acceleration: https://docs.aws.amazon.com/AmazonS3/latest/dev/transfer-acceleration.html

S3 Unwrapped XML Responses
--------------------------
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't a component of the bucket addressing customizations, so should probably be at a higher header level using === to declare it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I didn't notice that. Revised the documentation to match the other trait docs and gave it its own top-level section. Thanks!

S3 Unwrapped XML Responses
--------------------------

Clients code generated from Smithy for Amazon S3 MUST understand the `@s3UnwrappedXmlOutput` trait.
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is a trait, can the documentation instead look like our traditional XML trait documentation?

You can see the .rst layout here (sadly raw link because GH auto-renders).

@jdisanti
Copy link
Contributor Author

@kggilmer - The intent is to be able to express S3 in Smithy while avoiding a more generic mechanism that would allow future services to have unwrapped responses like this.

Indicates the response output is not wrapped in an operation-level XML tag.

Trait selector
.. code-block:: none
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the selector is so simple, this can be reduced to

Trait selector
    ``operation``

without the follow-up text.

S3 Traits
=========

``s3UnwrappedXmlOutput`` trait
Copy link
Contributor

Choose a reason for hiding this comment

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

This should include the namespace.

------------------------------

Summary
Indicates the response output is not wrapped in an operation-level XML tag.
Copy link
Contributor

@kstich kstich Jun 22, 2021

Choose a reason for hiding this comment

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

Given the S3 context, this should probably be more specific:

Indicates that the response body from S3 is not wrapped in the :ref:`aws-restxml-protocol` operation-level XML node.

This should replace the opening sentence in the trait's documentation in aws.customizations.json as well.

Annotation trait

This trait indicates the response output is not wrapped in an operation-level tag.
For example, rather than having some data wrapped in `SomeOperationResult` as shown below,
Copy link
Contributor

Choose a reason for hiding this comment

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

Simple code components in RST syntax are wrapped in double back-ticks, so:

``SomeOperationResult``

This should also be done in a couple places below.


You can make sure the rendered RST is correct by following the steps in the docs readme.


.. code-block:: xml

<SomeOperationResult>
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be better to have this example be the direct S3 one only, with the expected behavior listed first and the counter-example after it. This will be more straightforward for those reading the spec to implement.


<LocationConstraint>us-west-2</LocationConstraint>

Client code generated from Smithy for Amazon S3 MUST understand the `@s3UnwrappedXmlOutput` trait
Copy link
Contributor

Choose a reason for hiding this comment

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

Can the opening of this be made to match the other customization fields?

A client for Amazon S3 MUST...

params: {
"LocationConstraint": "us-west-2"
},
protocol: "aws.protocols#restXml"
Copy link
Contributor

Choose a reason for hiding this comment

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

This can just be an unquoted restXml as it's a reference to the protocol trait.

}

@httpResponseTests([{
id: "GetBucketLocation",
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this have "UnwrappedOutput" appended to the id for clarity of what this is testing? Can you also add a description?

}])
@http(uri: "/GetBucketLocation", method: "GET")
@s3UnwrappedXmlOutput
operation GetBucketLocation {
Copy link
Contributor

Choose a reason for hiding this comment

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

For ease of finding the tests themselves, can you move this operation and its traits up to where the others are?

@JordonPhillips JordonPhillips merged commit 91014fc into smithy-lang:main Jun 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants