Skip to content

Commit 64b822b

Browse files
committed
Generate ListObjects
stack-info: PR: #4205, branch: peterrsongg/petesong/phase-3-pr5-rebased-2/2
1 parent 241693e commit 64b822b

File tree

9 files changed

+801
-477
lines changed

9 files changed

+801
-477
lines changed

generator/ServiceClientGeneratorLib/ServiceModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,8 +575,8 @@ public List<Operation> S3AllowListOperations
575575
new Operation(this,"PutBucketRequestPayment", DocumentRoot[OperationsKey]["PutBucketRequestPayment"]),
576576
new Operation(this, "CreateBucketMetadataConfiguration",DocumentRoot[OperationsKey]["CreateBucketMetadataConfiguration"]),
577577
new Operation(this, "GetBucketMetadataConfiguration", DocumentRoot[OperationsKey]["GetBucketMetadataConfiguration"]),
578-
new Operation(this, "DeleteBucketMetadataConfiguration", DocumentRoot[OperationsKey]["DeleteBucketMetadataConfiguration"])
579-
578+
new Operation(this, "DeleteBucketMetadataConfiguration", DocumentRoot[OperationsKey]["DeleteBucketMetadataConfiguration"]),
579+
new Operation(this, "ListObjects", DocumentRoot[OperationsKey]["ListObjects"])
580580
};
581581
}
582582
return _s3AllowListOperations.Where(operation => operation.data != null).ToList();

generator/ServiceModels/s3/s3.customizations.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,6 +1224,34 @@
12241224
"ExpectedBucketOwner":{"injectXmlIsSet":["return !String.IsNullOrEmpty(this._expectedBucketOwner);"]}
12251225
}
12261226
]
1227+
},
1228+
"ListObjectsRequest":{
1229+
"modify":[
1230+
{
1231+
"EncodingType":{"emitPropertyName":"Encoding"}
1232+
},
1233+
{
1234+
"ExpectedBucketOwner":{"injectXmlIsSet":["return !String.IsNullOrEmpty(this._expectedBucketOwner);"]}
1235+
}
1236+
]
1237+
},
1238+
"ListObjectsOutput":{
1239+
"modify":[
1240+
{
1241+
"Contents":{
1242+
"emitPropertyName":"S3Objects"
1243+
}
1244+
},
1245+
{
1246+
"S3Objects":{
1247+
"injectXmlUnmarshallCode":["ContentsCustomUnmarshall(context, response);"],
1248+
"skipContextTestExpressionUnmarshallingLogic" : true
1249+
}
1250+
},
1251+
{
1252+
"NextMarker":{"injectXmlPropertyGetter":["get { return NextMarkerCustomGetter(); }"]}
1253+
}
1254+
]
12271255
}
12281256

12291257
},
@@ -1521,6 +1549,13 @@
15211549
"Marshaller": "StringUtils.FromString",
15221550
"Unmarshaller": "StringUnmarshaller"
15231551
}
1552+
},
1553+
"ListObjectsOutput": {
1554+
"CommonPrefixes" : {
1555+
"Type": "List<string>",
1556+
"Marshaller": "StringUtils.FromString",
1557+
"Unmarshaller" : "CommonPrefixesItemUnmarshaller"
1558+
}
15241559
}
15251560
},
15261561
"excludeMembers":{

sdk/src/Services/S3/Custom/Model/Internal/MarshallTransformations/ListObjectsRequestMarshaller.cs

Lines changed: 0 additions & 89 deletions
This file was deleted.

sdk/src/Services/S3/Custom/Model/Internal/MarshallTransformations/ListObjectsResponseUnmarshaller.cs

Lines changed: 13 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -12,153 +12,36 @@
1212
* express or implied. See the License for the specific language governing
1313
* permissions and limitations under the License.
1414
*/
15-
using System;
16-
using System.Net;
17-
using System.Collections.Generic;
18-
using Amazon.S3.Model;
1915
using Amazon.Runtime;
2016
using Amazon.Runtime.Internal;
2117
using Amazon.Runtime.Internal.Transform;
18+
using Amazon.S3.Model;
2219
using Amazon.S3.Util;
20+
using System;
21+
using System.Collections.Generic;
22+
using System.Net;
2323

2424
namespace Amazon.S3.Model.Internal.MarshallTransformations
2525
{
2626
/// <summary>
2727
/// Response Unmarshaller for ListObjects operation
2828
/// </summary>
29-
public class ListObjectsResponseUnmarshaller : S3ReponseUnmarshaller
29+
public partial class ListObjectsResponseUnmarshaller : S3ReponseUnmarshaller
3030
{
31-
/// <summary>
32-
/// Unmarshaller the response from the service to the response class.
33-
/// </summary>
34-
/// <param name="context"></param>
35-
/// <returns></returns>
36-
public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context)
37-
{
38-
ListObjectsResponse response = new ListObjectsResponse();
39-
40-
while (context.Read())
41-
{
42-
if (context.IsStartElement)
43-
{
44-
UnmarshallResult(context,response);
45-
continue;
46-
}
47-
}
48-
49-
IWebResponseData responseData = context.ResponseData;
50-
if (responseData.IsHeaderPresent(S3Constants.AmzHeaderRequestCharged))
51-
response.RequestCharged = RequestCharged.FindValue(responseData.GetHeaderValue(S3Constants.AmzHeaderRequestCharged));
52-
53-
return response;
54-
}
55-
56-
private static void UnmarshallResult(XmlUnmarshallerContext context,ListObjectsResponse response)
31+
private static void ContentsCustomUnmarshall(XmlUnmarshallerContext context, ListObjectsResponse response)
5732
{
58-
59-
int originalDepth = context.CurrentDepth;
60-
int targetDepth = originalDepth + 1;
61-
62-
if (context.IsStartOfDocument)
63-
targetDepth += 2;
64-
65-
while (context.Read())
33+
if (response.S3Objects == null)
6634
{
67-
if (context.IsStartElement || context.IsAttribute)
68-
{
69-
if (context.TestExpression("IsTruncated", targetDepth))
70-
{
71-
response.IsTruncated = BoolUnmarshaller.GetInstance().Unmarshall(context);
72-
73-
continue;
74-
}
75-
if (context.TestExpression("NextMarker", targetDepth))
76-
{
77-
response.NextMarker = StringUnmarshaller.GetInstance().Unmarshall(context);
78-
79-
continue;
80-
}
81-
if (context.TestExpression("Contents", targetDepth))
82-
{
83-
if (response.S3Objects == null)
84-
{
85-
response.S3Objects = new List<S3Object>();
86-
}
87-
88-
// adding the bucket name into the S3Object instance enables
89-
// a better pipelining experience in PowerShell
90-
var s3Object = ContentsItemUnmarshaller.Instance.Unmarshall(context);
91-
s3Object.BucketName = response.Name;
92-
response.S3Objects.Add(s3Object);
93-
continue;
94-
}
95-
if (context.TestExpression("Name", targetDepth))
96-
{
97-
response.Name = StringUnmarshaller.GetInstance().Unmarshall(context);
98-
99-
continue;
100-
}
101-
if (context.TestExpression("Prefix", targetDepth))
102-
{
103-
response.Prefix = StringUnmarshaller.GetInstance().Unmarshall(context);
104-
105-
continue;
106-
}
107-
if (context.TestExpression("Delimiter", targetDepth))
108-
{
109-
response.Delimiter = StringUnmarshaller.GetInstance().Unmarshall(context);
110-
111-
continue;
112-
}
113-
if (context.TestExpression("MaxKeys", targetDepth))
114-
{
115-
response.MaxKeys = IntUnmarshaller.GetInstance().Unmarshall(context);
116-
117-
continue;
118-
}
119-
if (context.TestExpression("CommonPrefixes", targetDepth))
120-
{
121-
var prefix = CommonPrefixesItemUnmarshaller.Instance.Unmarshall(context);
122-
123-
if(prefix != null)
124-
{
125-
if (response.CommonPrefixes == null)
126-
{
127-
response.CommonPrefixes = new List<string>();
128-
}
129-
response.CommonPrefixes.Add(prefix);
130-
}
131-
132-
continue;
133-
}
134-
}
135-
else if (context.IsEndElement && context.CurrentDepth < originalDepth)
136-
{
137-
return;
138-
}
35+
response.S3Objects = new List<S3Object>();
13936
}
140-
141-
14237

38+
// adding the bucket name into the S3Object instance enables
39+
// a better pipelining experience in PowerShell
40+
var s3Object = ContentsItemUnmarshaller.Instance.Unmarshall(context);
41+
s3Object.BucketName = response.Name;
42+
response.S3Objects.Add(s3Object);
14343
return;
14444
}
145-
146-
private static ListObjectsResponseUnmarshaller _instance;
147-
148-
/// <summary>
149-
/// Singleton for the unmarshaller
150-
/// </summary>
151-
public static ListObjectsResponseUnmarshaller Instance
152-
{
153-
get
154-
{
155-
if (_instance == null)
156-
{
157-
_instance = new ListObjectsResponseUnmarshaller();
158-
}
159-
return _instance;
160-
}
161-
}
16245
}
16346
}
16447

0 commit comments

Comments
 (0)