diff --git a/generator/ServiceClientGeneratorLib/ServiceModel.cs b/generator/ServiceClientGeneratorLib/ServiceModel.cs index 563eab474e26..1a060ed21fa4 100644 --- a/generator/ServiceClientGeneratorLib/ServiceModel.cs +++ b/generator/ServiceClientGeneratorLib/ServiceModel.cs @@ -575,8 +575,8 @@ public List 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(); diff --git a/generator/ServiceModels/s3/s3.customizations.json b/generator/ServiceModels/s3/s3.customizations.json index 93ccd709a143..673798271d6f 100644 --- a/generator/ServiceModels/s3/s3.customizations.json +++ b/generator/ServiceModels/s3/s3.customizations.json @@ -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"} + } + ] } }, @@ -1521,6 +1552,13 @@ "Marshaller": "StringUtils.FromString", "Unmarshaller": "StringUnmarshaller" } + }, + "ListObjectsOutput": { + "CommonPrefixes" : { + "Type": "List", + "Marshaller": "StringUtils.FromString", + "Unmarshaller" : "CommonPrefixesItemUnmarshaller" + } } }, "excludeMembers":{ diff --git a/sdk/src/Services/S3/Custom/Model/Internal/MarshallTransformations/ListObjectsRequestMarshaller.cs b/sdk/src/Services/S3/Custom/Model/Internal/MarshallTransformations/ListObjectsRequestMarshaller.cs deleted file mode 100644 index f7e3802f076d..000000000000 --- a/sdk/src/Services/S3/Custom/Model/Internal/MarshallTransformations/ListObjectsRequestMarshaller.cs +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 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. - */ - -using Amazon.S3.Util; -using Amazon.Runtime.Internal; -using Amazon.Runtime.Internal.Transform; -using Amazon.Util; - -#pragma warning disable 1591 - -namespace Amazon.S3.Model.Internal.MarshallTransformations -{ - /// - /// List Objects Request Marshaller - /// - public class ListObjectsRequestMarshaller : IMarshaller ,IMarshaller - { - public IRequest Marshall(Amazon.Runtime.AmazonWebServiceRequest input) - { - return this.Marshall((ListObjectsRequest)input); - } - - public IRequest Marshall(ListObjectsRequest listObjectsRequest) - { - IRequest request = new DefaultRequest(listObjectsRequest, "Amazon.S3"); - - request.HttpMethod = "GET"; - - if (listObjectsRequest.IsSetRequestPayer()) - request.Headers.Add(S3Constants.AmzHeaderRequestPayer, S3Transforms.ToStringValue(listObjectsRequest.RequestPayer.ToString())); - - if (listObjectsRequest.IsSetExpectedBucketOwner()) - request.Headers.Add(S3Constants.AmzHeaderExpectedBucketOwner, S3Transforms.ToStringValue(listObjectsRequest.ExpectedBucketOwner)); - - if (listObjectsRequest.IsSetOptionalObjectAttributes()) - request.Headers.Add(S3Constants.AmzOptionalObjectAttributes, AWSSDKUtils.Join(listObjectsRequest.OptionalObjectAttributes)); - - if (string.IsNullOrEmpty(listObjectsRequest.BucketName)) - throw new System.ArgumentException("BucketName is a required property and must be set before making this call.", "ListObjectsRequest.BucketName"); - - request.ResourcePath = "/"; - - if (listObjectsRequest.IsSetDelimiter()) - request.Parameters.Add("delimiter", S3Transforms.ToStringValue(listObjectsRequest.Delimiter)); - if (listObjectsRequest.IsSetMarker()) - request.Parameters.Add("marker", S3Transforms.ToStringValue(listObjectsRequest.Marker)); - if (listObjectsRequest.IsSetMaxKeys()) - request.Parameters.Add("max-keys", S3Transforms.ToStringValue(listObjectsRequest.MaxKeys.Value)); - if (listObjectsRequest.IsSetPrefix()) - request.Parameters.Add("prefix", S3Transforms.ToStringValue(listObjectsRequest.Prefix)); - if (listObjectsRequest.IsSetEncoding()) - request.Parameters.Add("encoding-type", S3Transforms.ToStringValue(listObjectsRequest.Encoding)); - - request.UseQueryString = true; - - return request; - } - - private static ListObjectsRequestMarshaller _instance; - - /// - /// Singleton for marshaller - /// - public static ListObjectsRequestMarshaller Instance - { - get - { - if (_instance == null) - { - _instance = new ListObjectsRequestMarshaller(); - } - return _instance; - } - } - } -} - diff --git a/sdk/src/Services/S3/Custom/Model/Internal/MarshallTransformations/ListObjectsResponseUnmarshaller.cs b/sdk/src/Services/S3/Custom/Model/Internal/MarshallTransformations/ListObjectsResponseUnmarshaller.cs index d0b9f1faa9ae..3391a86848e5 100644 --- a/sdk/src/Services/S3/Custom/Model/Internal/MarshallTransformations/ListObjectsResponseUnmarshaller.cs +++ b/sdk/src/Services/S3/Custom/Model/Internal/MarshallTransformations/ListObjectsResponseUnmarshaller.cs @@ -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 { /// /// Response Unmarshaller for ListObjects operation /// - public class ListObjectsResponseUnmarshaller : S3ReponseUnmarshaller + public partial class ListObjectsResponseUnmarshaller : S3ReponseUnmarshaller { - /// - /// Unmarshaller the response from the service to the response class. - /// - /// - /// - 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(); - } - - // 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(); - } - response.CommonPrefixes.Add(prefix); - } - - continue; - } - } - else if (context.IsEndElement && context.CurrentDepth < originalDepth) - { - return; - } + response.S3Objects = new List(); } - - - return; - } - - private static ListObjectsResponseUnmarshaller _instance; - - /// - /// Singleton for the unmarshaller - /// - 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); } } } diff --git a/sdk/src/Services/S3/Custom/Model/ListObjectsResponse.cs b/sdk/src/Services/S3/Custom/Model/ListObjectsResponse.cs index 702764d5f260..74f30425806d 100644 --- a/sdk/src/Services/S3/Custom/Model/ListObjectsResponse.cs +++ b/sdk/src/Services/S3/Custom/Model/ListObjectsResponse.cs @@ -24,178 +24,23 @@ namespace Amazon.S3.Model /// /// Returns information about the ListObjects response and response metadata. /// - public class ListObjectsResponse : AmazonWebServiceResponse + public partial class ListObjectsResponse : AmazonWebServiceResponse { - private bool? isTruncated; - private string nextMarker; - private List contents = AWSConfigs.InitializeCollections ? new List() : null; - private string name; - private string prefix; - private int? maxKeys; - private List commonPrefixes = AWSConfigs.InitializeCollections ? new List() : null; - private string delimiter; - private RequestCharged _requestCharged; - - /// - /// A flag that indicates whether or not Amazon S3 returned all of the results that satisfied - /// the search criteria. - /// - public bool? IsTruncated - { - get { return this.isTruncated; } - set { this.isTruncated = value; } - } - - // Check to see if IsTruncated property is set - internal bool IsSetIsTruncated() - { - return this.isTruncated.HasValue; - } - - /// - /// Gets and sets the NextMarker property. - /// NextMarker is set by S3 only if a Delimiter was specified - /// in the original ListObjects request. If a delimiter was - /// not specified, the AWS SDK for .NET returns the last Key - /// of the List of Objects retrieved from S3 as the NextMarker. - /// - public string NextMarker - { - get + private string NextMarkerCustomGetter() + { + // If the list is truncated and there is at least + // one object in the list returned and nextMarker + // has not been populated with a value, use the + // last returned Key as the default value. + if (String.IsNullOrEmpty(_nextMarker) && + _isTruncated.GetValueOrDefault() && + (this.S3Objects?.Count > 0)) { - // If the list is truncated and there is at least - // one object in the list returned and nextMarker - // has not been populated with a value, use the - // last returned Key as the default value. - if (System.String.IsNullOrEmpty(nextMarker) && - isTruncated.GetValueOrDefault() && - (this.S3Objects?.Count > 0)) - { - int lastObjIdx = this.S3Objects.Count - 1; - nextMarker = this.S3Objects[lastObjIdx].Key; - } - - return this.nextMarker; + int lastObjIdx = this.S3Objects.Count - 1; + _nextMarker = this.S3Objects[lastObjIdx].Key; } - set { this.nextMarker = value; } - } - - // Check to see if NextMarker property is set - internal bool IsSetNextMarker() - { - return this.nextMarker != null; - } - - /// - /// Gets the S3Objects property. This is a list of - /// objects in the bucket that match your search criteria. - /// - public List S3Objects - { - get { return this.contents; } - set { this.contents = value; } - } - - // Check to see if Contents property is set - internal bool IsSetContents() - { - return this.contents != null && (this.contents.Count > 0 || !AWSConfigs.InitializeCollections); - } - - /// - /// The bucket name. - /// - public string Name - { - get { return this.name; } - set { this.name = value; } - } - - // Check to see if Name property is set - internal bool IsSetName() - { - return this.name != null; - } - /// - /// Gets and sets the Prefix property. - /// - public string Prefix - { - get { return this.prefix; } - set { this.prefix = value; } - } - - // Check to see if Prefix property is set - internal bool IsSetPrefix() - { - return this.prefix != null; - } - - /// - /// Gets and sets the property RequestCharged. - /// - public RequestCharged RequestCharged - { - get { return this._requestCharged; } - set { this._requestCharged = value; } - } - - // Check to see if RequestCharged property is set - internal bool IsSetRequestCharged() - { - return this._requestCharged != null; - } - - /// - /// Gets and sets the MaxKeys property. This is max number of object keys returned by the list operation. - /// - public int? MaxKeys - { - get { return this.maxKeys; } - set { this.maxKeys = value; } - } - - // Check to see if MaxKeys property is set - internal bool IsSetMaxKeys() - { - return this.maxKeys.HasValue; - } - - /// - /// Gets the CommonPrefixes property. - /// A response can contain CommonPrefixes only if you specify a delimiter. - /// When you do, CommonPrefixes contains all (if there are any) keys between - /// Prefix and the next occurrence of the string specified by delimiter. In effect, - /// CommonPrefixes lists keys that act like subdirectories in the directory specified - /// by Prefix. For example, if prefix is notes/ and delimiter is a slash (/), in - /// notes/summer/july, the common prefix is notes/summer/. - /// - public List CommonPrefixes - { - get { return this.commonPrefixes; } - set { this.commonPrefixes = value; } - } - - // Check to see if CommonPrefixes property is set - internal bool IsSetCommonPrefixes() - { - return this.commonPrefixes != null && (this.commonPrefixes.Count > 0 || !AWSConfigs.InitializeCollections); - } - - /// - /// Gets and sets the Delimiter property. - /// Causes keys that contain the same string between the prefix and the - /// first occurrence of the delimiter to be rolled up into a single result - /// element in the CommonPrefixes collection. - /// - /// - /// These rolled-up keys are not returned elsewhere in the response. - /// - public string Delimiter - { - get { return this.delimiter; } - set { this.delimiter = value; } + return this._nextMarker; } } } diff --git a/sdk/src/Services/S3/Generated/Model/Internal/MarshallTransformations/ListObjectsRequestMarshaller.cs b/sdk/src/Services/S3/Generated/Model/Internal/MarshallTransformations/ListObjectsRequestMarshaller.cs new file mode 100644 index 000000000000..bc889dcb9da7 --- /dev/null +++ b/sdk/src/Services/S3/Generated/Model/Internal/MarshallTransformations/ListObjectsRequestMarshaller.cs @@ -0,0 +1,120 @@ +/* + * Copyright 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. + */ + +/* + * Do not modify this file. This file is generated from the s3-2006-03-01.normal.json service model. + */ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Text; +using System.Xml.Serialization; + +using Amazon.S3.Model; +using Amazon.Runtime; +using Amazon.Runtime.Internal; +using Amazon.Runtime.Internal.Transform; +using Amazon.Runtime.Internal.Util; +using System.Xml; + +#pragma warning disable CS0612,CS0618 +namespace Amazon.S3.Model.Internal.MarshallTransformations +{ + /// + /// ListObjects Request Marshaller + /// + public partial class ListObjectsRequestMarshaller : IMarshaller , IMarshaller + { + /// + /// Marshaller the request object to the HTTP request. + /// + /// + /// + public IRequest Marshall(AmazonWebServiceRequest input) + { + return this.Marshall((ListObjectsRequest)input); + } + + /// + /// Marshaller the request object to the HTTP request. + /// + /// + /// + public IRequest Marshall(ListObjectsRequest publicRequest) + { + var request = new DefaultRequest(publicRequest, "Amazon.S3"); + PreMarshallCustomization(request, publicRequest); + request.HttpMethod = "GET"; + + if (publicRequest.IsSetExpectedBucketOwner()) + { + request.Headers["x-amz-expected-bucket-owner"] = publicRequest.ExpectedBucketOwner; + } + + if (publicRequest.IsSetOptionalObjectAttributes()) + { + request.Headers["x-amz-optional-object-attributes"] = StringUtils.FromList(publicRequest.OptionalObjectAttributes); + } + + if (publicRequest.IsSetRequestPayer()) + { + request.Headers["x-amz-request-payer"] = publicRequest.RequestPayer; + } + if (string.IsNullOrEmpty(publicRequest.BucketName)) + throw new System.ArgumentException("BucketName is a required property and must be set before making this call.", "ListObjectsRequest.BucketName"); + + if (publicRequest.IsSetDelimiter()) + request.Parameters.Add("delimiter", StringUtils.FromString(publicRequest.Delimiter)); + + if (publicRequest.IsSetEncoding()) + request.Parameters.Add("encoding-type", StringUtils.FromString(publicRequest.Encoding)); + + if (publicRequest.IsSetMarker()) + request.Parameters.Add("marker", StringUtils.FromString(publicRequest.Marker)); + + if (publicRequest.IsSetMaxKeys()) + request.Parameters.Add("max-keys", StringUtils.FromInt(publicRequest.MaxKeys)); + + if (publicRequest.IsSetPrefix()) + request.Parameters.Add("prefix", StringUtils.FromString(publicRequest.Prefix)); + request.ResourcePath = "/"; + + PostMarshallCustomization(request, publicRequest); + request.UseQueryString = true; + return request; + } + private static ListObjectsRequestMarshaller _instance = new ListObjectsRequestMarshaller(); + + internal static ListObjectsRequestMarshaller GetInstance() + { + return _instance; + } + + /// + /// Gets the singleton. + /// + public static ListObjectsRequestMarshaller Instance + { + get + { + return _instance; + } + } + + partial void PostMarshallCustomization(DefaultRequest defaultRequest, ListObjectsRequest publicRequest); + partial void PreMarshallCustomization(DefaultRequest defaultRequest, ListObjectsRequest publicRequest); + } +} \ No newline at end of file diff --git a/sdk/src/Services/S3/Generated/Model/Internal/MarshallTransformations/ListObjectsResponseUnmarshaller.cs b/sdk/src/Services/S3/Generated/Model/Internal/MarshallTransformations/ListObjectsResponseUnmarshaller.cs new file mode 100644 index 000000000000..fbd089d6102a --- /dev/null +++ b/sdk/src/Services/S3/Generated/Model/Internal/MarshallTransformations/ListObjectsResponseUnmarshaller.cs @@ -0,0 +1,191 @@ +/* + * Copyright 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. + */ + +/* + * Do not modify this file. This file is generated from the s3-2006-03-01.normal.json service model. + */ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Net; +using System.Text; +using System.Xml.Serialization; + +using Amazon.S3.Model; +using Amazon.Runtime; +using Amazon.Runtime.Internal; +using Amazon.Runtime.Internal.Transform; +using Amazon.Runtime.Internal.Util; + +#pragma warning disable CS0612,CS0618 +namespace Amazon.S3.Model.Internal.MarshallTransformations +{ + /// + /// Response Unmarshaller for ListObjects operation + /// + public partial class ListObjectsResponseUnmarshaller : S3ReponseUnmarshaller + { + /// + /// Unmarshaller the response from the service to the response class. + /// + /// + /// + public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context) + { + ListObjectsResponse response = new ListObjectsResponse(); + UnmarshallResult(context,response); + if (context.ResponseData.IsHeaderPresent("x-amz-request-charged")) + response.RequestCharged = context.ResponseData.GetHeaderValue("x-amz-request-charged"); + + PostUnmarshallCustomization(context, response); + return response; + } + + private static void UnmarshallResult(XmlUnmarshallerContext context, ListObjectsResponse response) + { + int originalDepth = context.CurrentDepth; + int targetDepth = originalDepth + 1; + if (context.IsStartOfDocument) + targetDepth += 1; + if (context.IsEmptyResponse) + { + return; + } + while (context.Read()) + { + if (context.IsStartElement || context.IsAttribute) + { + if (context.TestExpression("CommonPrefixes", targetDepth)) + { + if (response.CommonPrefixes == null) + { + response.CommonPrefixes = new List(); + } + var unmarshaller = CommonPrefixesItemUnmarshaller.Instance; + response.CommonPrefixes.Add(unmarshaller.Unmarshall(context)); + continue; + } + if (context.TestExpression("Delimiter", targetDepth)) + { + var unmarshaller = StringUnmarshaller.Instance; + response.Delimiter = unmarshaller.Unmarshall(context); + continue; + } + if (context.TestExpression("EncodingType", targetDepth)) + { + var unmarshaller = StringUnmarshaller.Instance; + response.Encoding = unmarshaller.Unmarshall(context); + continue; + } + if (context.TestExpression("IsTruncated", targetDepth)) + { + var unmarshaller = NullableBoolUnmarshaller.Instance; + response.IsTruncated = unmarshaller.Unmarshall(context); + continue; + } + if (context.TestExpression("Marker", targetDepth)) + { + var unmarshaller = StringUnmarshaller.Instance; + response.Marker = unmarshaller.Unmarshall(context); + continue; + } + if (context.TestExpression("MaxKeys", targetDepth)) + { + var unmarshaller = NullableIntUnmarshaller.Instance; + response.MaxKeys = unmarshaller.Unmarshall(context); + continue; + } + if (context.TestExpression("Name", targetDepth)) + { + var unmarshaller = StringUnmarshaller.Instance; + response.Name = unmarshaller.Unmarshall(context); + continue; + } + if (context.TestExpression("NextMarker", targetDepth)) + { + var unmarshaller = StringUnmarshaller.Instance; + response.NextMarker = unmarshaller.Unmarshall(context); + continue; + } + if (context.TestExpression("Prefix", targetDepth)) + { + var unmarshaller = StringUnmarshaller.Instance; + response.Prefix = unmarshaller.Unmarshall(context); + continue; + } + if (context.TestExpression("Contents", targetDepth)) + { + ContentsCustomUnmarshall(context, response); + continue; + } + } + else if (context.IsEndElement && context.CurrentDepth < originalDepth) + { + return; + } + } + return; + } + + + /// + /// Unmarshaller error response to exception. + /// + /// + /// + /// + /// + public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode) + { + S3ErrorResponse errorResponse = S3ErrorResponseUnmarshaller.Instance.Unmarshall(context); + errorResponse.InnerException = innerException; + errorResponse.StatusCode = statusCode; + + var responseBodyBytes = context.GetResponseBodyBytes(); + + using (var streamCopy = new MemoryStream(responseBodyBytes)) + using (var contextCopy = new XmlUnmarshallerContext(streamCopy, false, null)) + { + if (errorResponse.Code != null && errorResponse.Code.Equals("NoSuchBucket")) + { + return NoSuchBucketExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse); + } + } + return base.ConstructS3Exception(context, errorResponse, innerException, statusCode); + } + + partial void PostUnmarshallCustomization(XmlUnmarshallerContext context, ListObjectsResponse response); + + private static ListObjectsResponseUnmarshaller _instance = new ListObjectsResponseUnmarshaller(); + + internal static ListObjectsResponseUnmarshaller GetInstance() + { + return _instance; + } + + /// + /// Gets the singleton. + /// + public static ListObjectsResponseUnmarshaller Instance + { + get + { + return _instance; + } + } + + } +} \ No newline at end of file diff --git a/sdk/src/Services/S3/Custom/Model/ListObjectsRequest.cs b/sdk/src/Services/S3/Generated/Model/ListObjectsRequest.cs similarity index 54% rename from sdk/src/Services/S3/Custom/Model/ListObjectsRequest.cs rename to sdk/src/Services/S3/Generated/Model/ListObjectsRequest.cs index 2f5cdd3c8510..a90c11b1939b 100644 --- a/sdk/src/Services/S3/Custom/Model/ListObjectsRequest.cs +++ b/sdk/src/Services/S3/Generated/Model/ListObjectsRequest.cs @@ -12,22 +12,28 @@ * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ + +/* + * Do not modify this file. This file is generated from the s3-2006-03-01.normal.json service model. + */ using System; using System.Collections.Generic; using System.Xml.Serialization; using System.Text; using System.IO; +using System.Net; using Amazon.Runtime; using Amazon.Runtime.Internal; +#pragma warning disable CS0612,CS0618,CS1570 namespace Amazon.S3.Model { /// /// Container for the parameters to the ListObjects operation. /// /// - /// This operation is not supported by directory buckets. + /// This operation is not supported for directory buckets. /// /// /// @@ -71,108 +77,118 @@ namespace Amazon.S3.Model /// ListBuckets /// /// - /// + /// + /// + /// You must URL encode any signed header values that contain spaces. For example, if + /// your header value is my file.txt, containing two spaces after my, you + /// must URL encode this value to my%20%20file.txt. + /// + /// /// public partial class ListObjectsRequest : AmazonWebServiceRequest { - private string bucketName; - private string delimiter; - private EncodingType encoding; - private string expectedBucketOwner; - private string marker; - private int? maxKeys; + private string _bucketName; + private string _delimiter; + private EncodingType _encoding; + private string _expectedBucketOwner; + private string _marker; + private int? _maxKeys; private List _optionalObjectAttributes = AWSConfigs.InitializeCollections ? new List() : null; - private string prefix; - private RequestPayer requestPayer; + private string _prefix; + private RequestPayer _requestPayer; /// /// Gets and sets the property BucketName. /// /// The name of the bucket containing the objects. - /// - /// - /// Directory buckets - When you use this operation with a directory bucket, you must use virtual-hosted-style requests in the - /// format Bucket-name.s3express-zone-id.region-code.amazonaws.com. Path-style requests are not - /// supported. Directory bucket names must be unique in the chosen Zone (Availability Zone or Local Zone). Bucket names must follow - /// the format bucket-base-name--zone-id--x-s3 (for example, amzn-s3-demo-bucket--usw2-az1--x-s3). For - /// information about bucket naming restrictions, see - /// Directory bucket naming rules in - /// the Amazon S3 User Guide. - /// - /// - /// Access points - When you use this action with an access point for general purpose buckets, you must provide the alias of the access - /// point in place of the bucket name or specify the access point ARN. When you use this action with an access point for directory buckets, you - /// must provide the access point name in place of the bucket name. When using the access point ARN, you must direct requests to the access point - /// hostname. The access point hostname takes the form AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com. When - /// using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For - /// more information about access point ARNs, see - /// Using access points in the Amazon S3 User Guide. - /// - /// + /// + /// + /// + /// Directory buckets - When you use this operation with a directory bucket, you + /// must use virtual-hosted-style requests in the format Bucket-name.s3express-zone-id.region-code.amazonaws.com. + /// Path-style requests are not supported. Directory bucket names must be unique in the + /// chosen Zone (Availability Zone or Local Zone). Bucket names must follow the format + /// bucket-base-name--zone-id--x-s3 (for example, amzn-s3-demo-bucket--usw2-az1--x-s3). + /// For information about bucket naming restrictions, see Directory + /// bucket naming rules in the Amazon S3 User Guide. + /// + /// + /// + /// Access points - When you use this action with an access point for general + /// purpose buckets, you must provide the alias of the access point in place of the bucket + /// name or specify the access point ARN. When you use this action with an access point + /// for directory buckets, you must provide the access point name in place of the bucket + /// name. When using the access point ARN, you must direct requests to the access point + /// hostname. The access point hostname takes the form AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com. + /// When using this action with an access point through the Amazon Web Services SDKs, + /// you provide the access point ARN in place of the bucket name. For more information + /// about access point ARNs, see Using + /// access points in the Amazon S3 User Guide. + /// + /// /// /// Object Lambda access points are not supported by directory buckets. - /// - /// - /// - /// S3 on Outposts - When you use this action with S3 on Outposts, you must direct requests to the S3 on Outposts hostname. The S3 on Outposts - /// hostname takes the form AccessPointName-AccountId.outpostID.s3-outposts.Region.amazonaws.com. When you use - /// this action with S3 on Outposts, the destination bucket must be the Outposts access point ARN or the access point alias. For more information - /// about S3 on Outposts, see - /// What is S3 on Outposts? in the Amazon S3 User Guide. + /// + /// + /// + /// S3 on Outposts - When you use this action with S3 on Outposts, you must direct + /// requests to the S3 on Outposts hostname. The S3 on Outposts hostname takes the form + /// AccessPointName-AccountId.outpostID.s3-outposts.Region.amazonaws.com. + /// When you use this action with S3 on Outposts, the destination bucket must be the Outposts + /// access point ARN or the access point alias. For more information about S3 on Outposts, + /// see What + /// is S3 on Outposts? in the Amazon S3 User Guide. /// /// + [AWSProperty(Required=true)] public string BucketName { - get { return this.bucketName; } - set { this.bucketName = value; } + get { return this._bucketName; } + set { this._bucketName = value; } } // Check to see if BucketName property is set internal bool IsSetBucketName() { - return this.bucketName != null; + return this._bucketName != null; } /// + /// Gets and sets the property Delimiter. + /// /// A delimiter is a character that you use to group keys. - /// - /// CommonPrefixes is filtered out from results if it is not lexicographically greater than the key-marker. + /// + /// + /// + /// CommonPrefixes is filtered out from results if it is not lexicographically + /// greater than the key-marker. /// /// public string Delimiter { - get { return this.delimiter; } - set { this.delimiter = value; } + get { return this._delimiter; } + set { this._delimiter = value; } } // Check to see if Delimiter property is set internal bool IsSetDelimiter() { - return this.delimiter != null; + return this._delimiter != null; } /// - /// Encoding type used by Amazon S3 to encode the - /// object keys - /// in the response. Responses are encoded only in UTF-8. An object key can contain any Unicode - /// character. However, the XML 1.0 parser can't parse certain characters, such as characters with an - /// ASCII value from 0 to 10. For characters that aren't supported in XML 1.0, you can add this parameter - /// to request that Amazon S3 encode the keys in the response. For more information about characters to avoid - /// in object key names, see Object key naming guidelines. - /// When using the URL encoding type, non-ASCII characters that are used in an object's - /// key name will be percent-encoded according to UTF-8 code values. For example, the object - /// test_file(3).png will appear as test_file%283%29.png. + /// Gets and sets the property Encoding. /// public EncodingType Encoding { - get { return this.encoding; } - set { this.encoding = value; } + get { return this._encoding; } + set { this._encoding = value; } } - // Check to see if DeleteMarker property is set + // Check to see if Encoding property is set internal bool IsSetEncoding() { - return this.encoding != null; + return this._encoding != null; } /// @@ -180,22 +196,19 @@ internal bool IsSetEncoding() /// /// The account ID of the expected bucket owner. If the account ID that you provide does /// not match the actual owner of the bucket, the request fails with the HTTP status code - /// 403 Forbidden (access denied). + /// 403 Forbidden (access denied). /// /// public string ExpectedBucketOwner { - get { return this.expectedBucketOwner; } - set { this.expectedBucketOwner = value; } + get { return this._expectedBucketOwner; } + set { this._expectedBucketOwner = value; } } - /// - /// Checks to see if ExpectedBucketOwner is set. - /// - /// true, if ExpectedBucketOwner property is set. + // Check to see if ExpectedBucketOwner property is set internal bool IsSetExpectedBucketOwner() { - return !String.IsNullOrEmpty(this.expectedBucketOwner); + return !String.IsNullOrEmpty(this._expectedBucketOwner); } /// @@ -207,34 +220,34 @@ internal bool IsSetExpectedBucketOwner() /// public string Marker { - get { return this.marker; } - set { this.marker = value; } + get { return this._marker; } + set { this._marker = value; } } // Check to see if Marker property is set internal bool IsSetMarker() { - return this.marker != null; + return this._marker != null; } /// /// Gets and sets the property MaxKeys. /// - /// Sets the maximum number of keys returned in the response. By default the action returns + /// Sets the maximum number of keys returned in the response. By default, the action returns /// up to 1,000 key names. The response might contain fewer keys but will never contain /// more. /// /// public int? MaxKeys { - get { return this.maxKeys; } - set { this.maxKeys = value; } + get { return this._maxKeys; } + set { this._maxKeys = value; } } // Check to see if MaxKeys property is set internal bool IsSetMaxKeys() { - return this.maxKeys.HasValue; + return this._maxKeys.HasValue; } /// @@ -243,6 +256,11 @@ internal bool IsSetMaxKeys() /// Specifies the optional fields that you want returned in the response. Fields that /// you do not specify are not returned. /// + /// + /// Starting with version 4 of the SDK this property will default to null. If no data for this property is returned + /// from the service the property will also be null. This was changed to improve performance and allow the SDK and caller + /// to distinguish between a property not set or a property being empty to clear out a value. To retain the previous + /// SDK behavior set the AWSConfigs.InitializeCollections static property to true. /// public List OptionalObjectAttributes { @@ -257,18 +275,21 @@ internal bool IsSetOptionalObjectAttributes() } /// + /// Gets and sets the property Prefix. + /// /// Limits the response to keys that begin with the specified prefix. + /// /// public string Prefix { - get { return this.prefix; } - set { this.prefix = value; } + get { return this._prefix; } + set { this._prefix = value; } } // Check to see if Prefix property is set internal bool IsSetPrefix() { - return this.prefix != null; + return this._prefix != null; } /// @@ -280,19 +301,15 @@ internal bool IsSetPrefix() /// public RequestPayer RequestPayer { - get { return this.requestPayer; } - set { this.requestPayer = value; } + get { return this._requestPayer; } + set { this._requestPayer = value; } } - /// - /// Checks to see if RequetsPayer is set. - /// - /// true, if RequestPayer property is set. + // Check to see if RequestPayer property is set internal bool IsSetRequestPayer() { - return requestPayer != null; + return this._requestPayer != null; } } -} - +} \ No newline at end of file diff --git a/sdk/src/Services/S3/Generated/Model/ListObjectsResponse.cs b/sdk/src/Services/S3/Generated/Model/ListObjectsResponse.cs new file mode 100644 index 000000000000..78877bd1e7ce --- /dev/null +++ b/sdk/src/Services/S3/Generated/Model/ListObjectsResponse.cs @@ -0,0 +1,307 @@ +/* + * Copyright 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. + */ + +/* + * Do not modify this file. This file is generated from the s3-2006-03-01.normal.json service model. + */ +using System; +using System.Collections.Generic; +using System.Xml.Serialization; +using System.Text; +using System.IO; +using System.Net; + +using Amazon.Runtime; +using Amazon.Runtime.Internal; + +#pragma warning disable CS0612,CS0618,CS1570 +namespace Amazon.S3.Model +{ + /// + /// This is the response object from the ListObjects operation. + /// + public partial class ListObjectsResponse : AmazonWebServiceResponse + { + private List _commonPrefixes = AWSConfigs.InitializeCollections ? new List() : null; + private string _delimiter; + private EncodingType _encoding; + private bool? _isTruncated; + private string _marker; + private int? _maxKeys; + private string _name; + private string _nextMarker; + private string _prefix; + private RequestCharged _requestCharged; + private List _s3Objects = AWSConfigs.InitializeCollections ? new List() : null; + + /// + /// Gets and sets the property CommonPrefixes. + /// + /// All of the keys (up to 1,000) rolled up in a common prefix count as a single return + /// when calculating the number of returns. + /// + /// + /// + /// A response can contain CommonPrefixes only if you specify a delimiter. + /// + /// + /// + /// CommonPrefixes contains all (if there are any) keys between Prefix + /// and the next occurrence of the string specified by the delimiter. + /// + /// + /// + /// CommonPrefixes lists keys that act like subdirectories in the directory specified + /// by Prefix. + /// + /// + /// + /// For example, if the prefix is notes/ and the delimiter is a slash (/), + /// as in notes/summer/july, the common prefix is notes/summer/. All of + /// the keys that roll up into a common prefix count as a single return when calculating + /// the number of returns. + /// + /// + /// Starting with version 4 of the SDK this property will default to null. If no data for this property is returned + /// from the service the property will also be null. This was changed to improve performance and allow the SDK and caller + /// to distinguish between a property not set or a property being empty to clear out a value. To retain the previous + /// SDK behavior set the AWSConfigs.InitializeCollections static property to true. + /// + public List CommonPrefixes + { + get { return this._commonPrefixes; } + set { this._commonPrefixes = value; } + } + + // Check to see if CommonPrefixes property is set + internal bool IsSetCommonPrefixes() + { + return this._commonPrefixes != null && (this._commonPrefixes.Count > 0 || !AWSConfigs.InitializeCollections); + } + + /// + /// Gets and sets the property Delimiter. + /// + /// Causes keys that contain the same string between the prefix and the first occurrence + /// of the delimiter to be rolled up into a single result element in the CommonPrefixes + /// collection. These rolled-up keys are not returned elsewhere in the response. Each + /// rolled-up result counts as only one return against the MaxKeys value. + /// + /// + public string Delimiter + { + get { return this._delimiter; } + set { this._delimiter = value; } + } + + // Check to see if Delimiter property is set + internal bool IsSetDelimiter() + { + return this._delimiter != null; + } + + /// + /// Gets and sets the property Encoding. + /// + /// Encoding type used by Amazon S3 to encode the object + /// keys in the response. Responses are encoded only in UTF-8. An object key can contain + /// any Unicode character. However, the XML 1.0 parser can't parse certain characters, + /// such as characters with an ASCII value from 0 to 10. For characters that aren't supported + /// in XML 1.0, you can add this parameter to request that Amazon S3 encode the keys in + /// the response. For more information about characters to avoid in object key names, + /// see Object + /// key naming guidelines. + /// + /// + /// + /// When using the URL encoding type, non-ASCII characters that are used in an object's + /// key name will be percent-encoded according to UTF-8 code values. For example, the + /// object test_file(3).png will appear as test_file%283%29.png. + /// + /// + /// + public EncodingType Encoding + { + get { return this._encoding; } + set { this._encoding = value; } + } + + // Check to see if Encoding property is set + internal bool IsSetEncoding() + { + return this._encoding != null; + } + + /// + /// Gets and sets the property IsTruncated. + /// + /// A flag that indicates whether Amazon S3 returned all of the results that satisfied + /// the search criteria. + /// + /// + public bool? IsTruncated + { + get { return this._isTruncated; } + set { this._isTruncated = value; } + } + + // Check to see if IsTruncated property is set + internal bool IsSetIsTruncated() + { + return this._isTruncated.HasValue; + } + + /// + /// Gets and sets the property Marker. + /// + /// Indicates where in the bucket listing begins. Marker is included in the response if + /// it was sent with the request. + /// + /// + public string Marker + { + get { return this._marker; } + set { this._marker = value; } + } + + // Check to see if Marker property is set + internal bool IsSetMarker() + { + return this._marker != null; + } + + /// + /// Gets and sets the property MaxKeys. + /// + /// The maximum number of keys returned in the response body. + /// + /// + public int? MaxKeys + { + get { return this._maxKeys; } + set { this._maxKeys = value; } + } + + // Check to see if MaxKeys property is set + internal bool IsSetMaxKeys() + { + return this._maxKeys.HasValue; + } + + /// + /// Gets and sets the property Name. + /// + /// The bucket name. + /// + /// + public string Name + { + get { return this._name; } + set { this._name = value; } + } + + // Check to see if Name property is set + internal bool IsSetName() + { + return this._name != null; + } + + /// + /// Gets and sets the property NextMarker. + /// + /// When the response is truncated (the IsTruncated element value in the response + /// is true), you can use the key name in this field as the marker parameter + /// in the subsequent request to get the next set of objects. Amazon S3 lists objects + /// in alphabetical order. + /// + /// + /// + /// This element is returned only if you have the delimiter request parameter specified. + /// If the response does not include the NextMarker element and it is truncated, + /// you can use the value of the last Key element in the response as the marker + /// parameter in the subsequent request to get the next set of object keys. + /// + /// + /// + public string NextMarker + { + get { return NextMarkerCustomGetter(); } + set { this._nextMarker = value; } + } + + // Check to see if NextMarker property is set + internal bool IsSetNextMarker() + { + return this._nextMarker != null; + } + + /// + /// Gets and sets the property Prefix. + /// + /// Keys that begin with the indicated prefix. + /// + /// + public string Prefix + { + get { return this._prefix; } + set { this._prefix = value; } + } + + // Check to see if Prefix property is set + internal bool IsSetPrefix() + { + return this._prefix != null; + } + + /// + /// Gets and sets the property RequestCharged. + /// + public RequestCharged RequestCharged + { + get { return this._requestCharged; } + set { this._requestCharged = value; } + } + + // Check to see if RequestCharged property is set + internal bool IsSetRequestCharged() + { + return this._requestCharged != null; + } + + /// + /// Gets and sets the property S3Objects. + /// + /// Metadata about each object returned. + /// + /// + /// Starting with version 4 of the SDK this property will default to null. If no data for this property is returned + /// from the service the property will also be null. This was changed to improve performance and allow the SDK and caller + /// to distinguish between a property not set or a property being empty to clear out a value. To retain the previous + /// SDK behavior set the AWSConfigs.InitializeCollections static property to true. + /// + public List S3Objects + { + get { return this._s3Objects; } + set { this._s3Objects = value; } + } + + // Check to see if S3Objects property is set + internal bool IsSetS3Objects() + { + return this._s3Objects != null && (this._s3Objects.Count > 0 || !AWSConfigs.InitializeCollections); + } + + } +} \ No newline at end of file