Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions generator/ServiceClientGeneratorLib/ServiceModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -575,8 +575,8 @@ public List<Operation> S3AllowListOperations
new Operation(this,"PutBucketRequestPayment", DocumentRoot[OperationsKey]["PutBucketRequestPayment"]),
new Operation(this, "CreateBucketMetadataConfiguration",DocumentRoot[OperationsKey]["CreateBucketMetadataConfiguration"]),
new Operation(this, "GetBucketMetadataConfiguration", DocumentRoot[OperationsKey]["GetBucketMetadataConfiguration"]),
new Operation(this, "DeleteBucketMetadataConfiguration", DocumentRoot[OperationsKey]["DeleteBucketMetadataConfiguration"])

new Operation(this, "DeleteBucketMetadataConfiguration", DocumentRoot[OperationsKey]["DeleteBucketMetadataConfiguration"]),
new Operation(this, "ListObjects", DocumentRoot[OperationsKey]["ListObjects"])
};
}
return _s3AllowListOperations.Where(operation => operation.data != null).ToList();
Expand Down
38 changes: 38 additions & 0 deletions generator/ServiceModels/s3/s3.customizations.json
Original file line number Diff line number Diff line change
Expand Up @@ -1224,6 +1224,37 @@
"ExpectedBucketOwner":{"injectXmlIsSet":["return !String.IsNullOrEmpty(this._expectedBucketOwner);"]}
}
]
},
"ListObjectsRequest":{
"modify":[
{
"EncodingType":{"emitPropertyName":"Encoding"}
},
{
"ExpectedBucketOwner":{"injectXmlIsSet":["return !String.IsNullOrEmpty(this._expectedBucketOwner);"]}
}
]
},
"ListObjectsOutput":{
"modify":[
{
"Contents":{
"emitPropertyName":"S3Objects"
}
},
{
"S3Objects":{
"injectXmlUnmarshallCode":["ContentsCustomUnmarshall(context, response);"],
"skipContextTestExpressionUnmarshallingLogic" : true
}
},
{
"NextMarker":{"injectXmlPropertyGetter":["get { return NextMarkerCustomGetter(); }"]}
},
{
"EncodingType":{"emitPropertyName":"Encoding"}
}
]
}

},
Expand Down Expand Up @@ -1521,6 +1552,13 @@
"Marshaller": "StringUtils.FromString",
"Unmarshaller": "StringUnmarshaller"
}
},
"ListObjectsOutput": {
"CommonPrefixes" : {
"Type": "List<string>",
"Marshaller": "StringUtils.FromString",
"Unmarshaller" : "CommonPrefixesItemUnmarshaller"
}
}
},
"excludeMembers":{
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,152 +12,34 @@
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
using System;
using System.Net;
using System.Collections.Generic;
using Amazon.S3.Model;
using Amazon.Runtime;
using Amazon.Runtime.Internal;
using Amazon.Runtime.Internal.Transform;
using Amazon.S3.Model;
using Amazon.S3.Util;
using System;
using System.Collections.Generic;
using System.Net;

namespace Amazon.S3.Model.Internal.MarshallTransformations
{
/// <summary>
/// Response Unmarshaller for ListObjects operation
/// </summary>
public class ListObjectsResponseUnmarshaller : S3ReponseUnmarshaller
public partial class ListObjectsResponseUnmarshaller : S3ReponseUnmarshaller
{
/// <summary>
/// Unmarshaller the response from the service to the response class.
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context)
{
ListObjectsResponse response = new ListObjectsResponse();

while (context.Read())
{
if (context.IsStartElement)
{
UnmarshallResult(context,response);
continue;
}
}

IWebResponseData responseData = context.ResponseData;
if (responseData.IsHeaderPresent(S3Constants.AmzHeaderRequestCharged))
response.RequestCharged = RequestCharged.FindValue(responseData.GetHeaderValue(S3Constants.AmzHeaderRequestCharged));

return response;
}

private static void UnmarshallResult(XmlUnmarshallerContext context,ListObjectsResponse response)
private static void ContentsCustomUnmarshall(XmlUnmarshallerContext context, ListObjectsResponse response)
{

int originalDepth = context.CurrentDepth;
int targetDepth = originalDepth + 1;

if (context.IsStartOfDocument)
targetDepth += 2;

while (context.Read())
if (response.S3Objects == null)
{
if (context.IsStartElement || context.IsAttribute)
{
if (context.TestExpression("IsTruncated", targetDepth))
{
response.IsTruncated = BoolUnmarshaller.GetInstance().Unmarshall(context);

continue;
}
if (context.TestExpression("NextMarker", targetDepth))
{
response.NextMarker = StringUnmarshaller.GetInstance().Unmarshall(context);

continue;
}
if (context.TestExpression("Contents", targetDepth))
{
if (response.S3Objects == null)
{
response.S3Objects = new List<S3Object>();
}

// adding the bucket name into the S3Object instance enables
// a better pipelining experience in PowerShell
var s3Object = ContentsItemUnmarshaller.Instance.Unmarshall(context);
s3Object.BucketName = response.Name;
response.S3Objects.Add(s3Object);
continue;
}
if (context.TestExpression("Name", targetDepth))
{
response.Name = StringUnmarshaller.GetInstance().Unmarshall(context);

continue;
}
if (context.TestExpression("Prefix", targetDepth))
{
response.Prefix = StringUnmarshaller.GetInstance().Unmarshall(context);

continue;
}
if (context.TestExpression("Delimiter", targetDepth))
{
response.Delimiter = StringUnmarshaller.GetInstance().Unmarshall(context);

continue;
}
if (context.TestExpression("MaxKeys", targetDepth))
{
response.MaxKeys = IntUnmarshaller.GetInstance().Unmarshall(context);

continue;
}
if (context.TestExpression("CommonPrefixes", targetDepth))
{
var prefix = CommonPrefixesItemUnmarshaller.Instance.Unmarshall(context);

if(prefix != null)
{
if (response.CommonPrefixes == null)
{
response.CommonPrefixes = new List<string>();
}
response.CommonPrefixes.Add(prefix);
}

continue;
}
}
else if (context.IsEndElement && context.CurrentDepth < originalDepth)
{
return;
}
response.S3Objects = new List<S3Object>();
}



return;
}

private static ListObjectsResponseUnmarshaller _instance;

/// <summary>
/// Singleton for the unmarshaller
/// </summary>
public static ListObjectsResponseUnmarshaller Instance
{
get
{
if (_instance == null)
{
_instance = new ListObjectsResponseUnmarshaller();
}
return _instance;
}
// adding the bucket name into the S3Object instance enables
// a better pipelining experience in PowerShell
var s3Object = ContentsItemUnmarshaller.Instance.Unmarshall(context);
s3Object.BucketName = response.Name;
response.S3Objects.Add(s3Object);
}
}
}
Expand Down
Loading