Skip to content

Commit

Permalink
Merge pull request #251 from JordonPhillips/ec2-query-name
Browse files Browse the repository at this point in the history
Add ec2QueryNameTrait
  • Loading branch information
JordonPhillips authored Jan 10, 2020
2 parents 387138d + efce603 commit bcaf8b6
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 2 deletions.
4 changes: 2 additions & 2 deletions config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
</module>

<!-- Files must contain a copyright header. -->
<module name="Header">
<module name="RegexpHeader">
<property name="header"
value="/*\n * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n"/>
value="/\*\n \* Copyright 20(19|20) Amazon\.com, Inc\. or its affiliates\. All Rights Reserved\.\n"/>
<property name="fileExtensions" value="java"/>
</module>

Expand Down
58 changes: 58 additions & 0 deletions docs/source/spec/aws-core.rst
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,64 @@ literal string ``UNSIGNED-PAYLOAD`` is used when constructing a
`canonical request`_, and the same value is sent in the
`x-amz-content-sha256`_ header when sending an HTTP request.

.. _aws.api#ec2QueryName-trait:

---------------------------------
``aws.api#ec2QueryName`` trait
---------------------------------

Summary
Indicates the serialized name of a structure member when that structure is
serialized for the input of an EC2 operation.
Trait selector
``member:of(structure)``
Value type
``string``

It is very important to note that the ``aws.api#ec2QueryName`` ONLY applies
when serializing an INPUT. For example, given the following Smithy model:

.. tabs::

.. code-tab:: smithy

structure MyStruct {
@ec2QueryName("foo")
bar: String
}

.. code-tabe:: json

{
"smithy": "0.5.0",
"shapes": {
"smithy.example#MyStruct": {
"type": "structure",
"members": {
"bar": {
"target": "smithy.api#String",
"traits": {
"aws.api#ec2QueryName": "foo"
}
}
}
}
}
}

The serialization of this structure as an input is:

.. code-block::
MyStruct.bar=baz
The serialization of the structure as an (XML) output is:

.. code-block:: xml
<MyStruct>
<foo>baz</foo>
</MyStruct>
.. _endpoint-discovery:

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/

package software.amazon.smithy.aws.traits;

import software.amazon.smithy.model.SourceLocation;
import software.amazon.smithy.model.shapes.ShapeId;
import software.amazon.smithy.model.traits.StringTrait;

/**
* Indicates the serialized name of a structure member when that structure is
* serialized for the input of an EC2 operation.
*/
public class Ec2QueryNameTrait extends StringTrait {
public static final ShapeId ID = ShapeId.from("aws.api#ec2QueryName");

public Ec2QueryNameTrait(String value, SourceLocation sourceLocation) {
super(ID, value, sourceLocation);
}

public Ec2QueryNameTrait(String value) {
this(value, SourceLocation.NONE);
}

public static final class Provider extends StringTrait.Provider<Ec2QueryNameTrait> {
public Provider() {
super(ID, Ec2QueryNameTrait::new);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ software.amazon.smithy.aws.traits.apigateway.MockIntegrationTrait$Provider
software.amazon.smithy.aws.traits.clientendpointdiscovery.ClientEndpointDiscoveryTrait$Provider
software.amazon.smithy.aws.traits.clientendpointdiscovery.ClientEndpointDiscoveryIdTrait$Provider
software.amazon.smithy.aws.traits.clientendpointdiscovery.ClientDiscoveredEndpointTrait$Provider
software.amazon.smithy.aws.traits.Ec2QueryNameTrait$Provider
10 changes: 10 additions & 0 deletions smithy-aws-traits/src/main/resources/META-INF/smithy/aws.api.json
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,16 @@
},
"smithy.api#documentation": "Configures endpoint discovery for the service."
}
},
"aws.api#ec2QueryName": {
"type": "string",
"traits": {
"smithy.api#trait": {
"selector": "member:of(structure)"
},
"smithy.api#documentation": "Indicates the serialized name of a structure member when that structure is serialized for the input of an EC2 operation.",
"smithy.api#pattern": "^[a-zA-Z_][a-zA-Z_0-9-]*$"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"smithy": "0.5.0",
"shapes": {
"com.example#Input": {
"type": "structure",
"members": {
"Ipv6AddressSet": {
"target": "smithy.api#String",
"traits": {
"smithy.api#xmlName": "ipv6AddressSet",
"aws.api#ec2QueryName": "Ipv6Addresses"
}
}
}
}
}
}

0 comments on commit bcaf8b6

Please sign in to comment.