Skip to content

Commit 6387bef

Browse files
authored
Generate 7 more S3 Operations (#3953)
1 parent a57c43c commit 6387bef

File tree

125 files changed

+6848
-4231
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+6848
-4231
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"core": {
3+
"updateMinimum": true,
4+
"type": "patch",
5+
"changeLogMessages": [
6+
"Remove extra Content MD5 setting in BaseMarshaller. Minor Xml namespace logic updates. Update all rest-xml service response unmarshallers to generate partial method PostUnmarshallCustomization. Generator updates."
7+
]
8+
},
9+
"services": [
10+
{
11+
"serviceName": "S3",
12+
"type": "patch",
13+
"changeLogMessages": [
14+
"Generate PutBucketAcl PutBucketCors,PutObjectAcl, GetObjectAcl, ListObjectsV2, ListVersions, HeadObject.",
15+
"As part of generating S3, all response unmarshallers will implement UnmarshallException. GetObjectACL will now throw NoSuchKeyException if no such key exists. This is not a breaking change."
16+
]
17+
}
18+
]
19+
}

generator/ServiceClientGeneratorLib/Customizations.cs

Lines changed: 96 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,20 @@ public PropertyModifier GetPropertyModifier(string shapeName, string propertyNam
809809
return null;
810810
}
811811

812+
/// <summary>
813+
/// Gets the property modifier for a property if it exists. Otherwise returns false.
814+
/// </summary>
815+
/// <param name="shapeName"></param>
816+
/// <param name="propertyName"></param>
817+
/// <param name="propertyModifier"></param>
818+
/// <returns></returns>
819+
public bool TryGetPropertyModifier(string shapeName, string propertyName, out PropertyModifier propertyModifier)
820+
{
821+
propertyModifier = null;
822+
propertyModifier = GetPropertyModifier(shapeName, propertyName) ?? null;
823+
return propertyModifier != null ? true : false;
824+
}
825+
812826
/// <summary>
813827
/// Determines if the property has a customization to be set to nullable
814828
/// </summary>
@@ -1020,6 +1034,7 @@ public class ShapeModifier
10201034
public const string ShapeModifierXmlNamespaceKey = "xmlNamespace";
10211035
public const string OriginalMemberIsOutsideContainingShapeKey = "originalMemberIsOutsideContainingShape";
10221036
public const string PredicateListUnmarshallersKey = "predicateListUnmarshallers";
1037+
public const string ExcludeFromUnmarshallingKey = "excludeFromUnmarshalling";
10231038

10241039
private readonly HashSet<string> _excludedProperties;
10251040
private readonly Dictionary<string, JsonData> _modifiedProperties;
@@ -1030,6 +1045,7 @@ public class ShapeModifier
10301045
private readonly HashSet<string> _shapeDocumentation;
10311046
private readonly string _shapeModifierXmlNamespace;
10321047
private readonly Dictionary<string, JsonData> _predicateListUnmarshallers;
1048+
private readonly HashSet<string> _excludedUnmarshallingProperties;
10331049

10341050
public string DeprecationMessage { get; private set; }
10351051

@@ -1049,6 +1065,7 @@ public ShapeModifier(JsonData data)
10491065
_shapeDocumentation = ParseShapeDocumentation(data);
10501066
_shapeModifierXmlNamespace = ParseXmlNamespace(data);
10511067
_predicateListUnmarshallers = ParsePredicateListUnmarshallers(data);
1068+
_excludedUnmarshallingProperties = ParseExcludedUnmarshallingProperties(data);
10521069
Validate(data);
10531070
}
10541071

@@ -1317,6 +1334,7 @@ private static Dictionary<string, JsonData> ParsePredicateListUnmarshallers(Json
13171334
?? new Dictionary<string, JsonData>();
13181335

13191336
}
1337+
13201338
/// <summary>
13211339
/// This customization tells the generator that the member's shape is a filter type that has predicates
13221340
/// and operators and that it should be unmarshalled with the PredicateListUnmarshaller type that each
@@ -1327,6 +1345,35 @@ private static Dictionary<string, JsonData> ParsePredicateListUnmarshallers(Json
13271345
public Dictionary<string, JsonData> PredicateListUnmarshallers { get { return _predicateListUnmarshallers; } }
13281346

13291347
#endregion
1348+
1349+
#region ExcludedUnmarshallingProperties
1350+
1351+
private static HashSet<string> ParseExcludedUnmarshallingProperties(JsonData data)
1352+
{
1353+
var excludedUnmarshallingProperties = data[ShapeModifier.ExcludeFromUnmarshallingKey]?.Cast<object>()
1354+
.Select(x => x.ToString());
1355+
1356+
return new HashSet<string>(excludedUnmarshallingProperties ?? new string[0]);
1357+
}
1358+
1359+
/// <summary>
1360+
/// Properties that should be excluded from unmarshalling. Example usage:
1361+
///
1362+
/// The members that should be excluded are in the array.
1363+
/// "S3Grantee":{
1364+
/// "modify": [
1365+
/// {
1366+
/// "ID": {"emitPropertyName": "CanonicalUser"}
1367+
/// }
1368+
/// ],
1369+
/// "excludeFromUnmarshalling":
1370+
/// [
1371+
/// "Type"
1372+
/// ]
1373+
/// },
1374+
/// </summary>
1375+
public HashSet<string> ExcludedUnmarshallingProperties { get { return _excludedUnmarshallingProperties; } }
1376+
#endregion
13301377
}
13311378

13321379
/// <summary>
@@ -1393,14 +1440,17 @@ public class PropertyModifier
13931440
public const string EmitPropertyNameKey = "emitPropertyName";
13941441
public const string LocationNameKey = "locationName";
13951442
public const string AccessModifierKey = "accessModifier";
1443+
public const string InjectXmlUnmarshallCodeKey = "injectXmlUnmarshallCode";
1444+
public const string SkipContextTestExpressionUnmarshallingLogicKey = "skipContextTestExpressionUnmarshallingLogic";
13961445

13971446
private readonly string _modelPropertyName; // for debug inspection assist
13981447
private readonly JsonData _modifierData;
1399-
1448+
private readonly HashSet<string> _injectXmlUnmarshallCode;
14001449
internal PropertyModifier(string modelPropertyName, JsonData modifierData)
14011450
{
14021451
this._modelPropertyName = modelPropertyName;
14031452
this._modifierData = modifierData;
1453+
_injectXmlUnmarshallCode = ParseInjectXmlUnmarshallCode();
14041454
}
14051455

14061456
// The access modifier for the property. Defaults to public if not set in the customization.
@@ -1473,14 +1523,56 @@ public bool UseCustomMarshall
14731523
}
14741524

14751525
public string DeprecationMessage
1476-
{
1477-
get
14781526
{
1527+
get
1528+
{
14791529
return _modifierData[ShapeModifier.DeprecatedMessageKey].CastToString();
1530+
}
14801531
}
1481-
}
1532+
1533+
private HashSet<string> ParseInjectXmlUnmarshallCode()
1534+
{
1535+
var data = _modifierData[InjectXmlUnmarshallCodeKey]?.Cast<object>()
1536+
.Select(x => x.ToString());
1537+
1538+
return new HashSet<string>(data ?? new string[0]);
14821539
}
14831540

1541+
/// <summary>
1542+
/// Use this customization for rest-xml services when you want to inject some code into the "Context.TestExpression" portion
1543+
/// of the member.
1544+
///
1545+
/// A prime example of this is here https://github.com/aws/aws-sdk-net/blob/79cbc392fc3f1c74fcdf34efd77ad681da8af328/sdk/src/Services/S3/Custom/Model/Internal/MarshallTransformations/ListObjectsV2ResponseUnmarshaller.cs#L85
1546+
/// How to use this customization (within the modify array of a property) :
1547+
/// Within the "Contents" member while this member is being unmarshalled the code in the "injectXmlUnmarshallCode" will be added line by line
1548+
/// right before the "continue" statement within each "context.TestExpression" call.
1549+
/// {
1550+
/// "Contents" : {
1551+
/// "emitPropertyName" : "S3Objects",
1552+
/// "injectXmlUnmarshallCode":[
1553+
/// "response.S3Objects[response.S3Objects.Count - 1].BucketName = response.Name;"
1554+
/// ]
1555+
/// }
1556+
/// },
1557+
/// </summary>
1558+
public HashSet<string> InjectXmlUnmarshallCode
1559+
{
1560+
get { return _injectXmlUnmarshallCode; }
1561+
}
1562+
1563+
/// <summary>
1564+
/// If this is set, all the logic inside of the "context.testExpression" code block for that member won't be generated. this is meant
1565+
/// to be used in conjunction with InjectXmlUnmarshallCode, but can be used separately as well. For example:
1566+
/// "Versions":{
1567+
/// "skipContextTestExpressionUnmarshallingLogic" : true,
1568+
/// "injectXmlUnmarshallCode" :[
1569+
/// "VersionsItemCustomUnmarshall(context, response);"
1570+
/// ]
1571+
/// }
1572+
/// </summary>
1573+
public bool SkipContextTestExpressionUnmarshallingLogic { get { return _modifierData[SkipContextTestExpressionUnmarshallingLogicKey] != null; } }
1574+
}
1575+
14841576
#endregion
14851577
// Injection modifier is an array of objects, each object being the
14861578
private Dictionary<string, ShapeModifier> _shapeModifiers = null;

0 commit comments

Comments
 (0)