public GetRetentionResponse(HttpStatusCode statusCode, string responseContent) : base(statusCode, responseContent) { if (string.IsNullOrEmpty(responseContent) && !HttpStatusCode.OK.Equals(statusCode)) { this.CurrentRetentionConfiguration = null; return; } using (var stream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(responseContent))) { CurrentRetentionConfiguration = (ObjectRetentionConfiguration) new XmlSerializer(typeof(ObjectRetentionConfiguration)).Deserialize(stream); } }
public override RestRequest BuildRequest(RestRequest request) { request.AddQueryParameter("retention", ""); if (!string.IsNullOrEmpty(this.VersionId)) { request.AddQueryParameter("versionId", this.VersionId); } if (this.BypassGovernanceMode) { request.AddOrUpdateParameter("x-amz-bypass-governance-retention", "true", ParameterType.HttpHeader); } ObjectRetentionConfiguration config = new ObjectRetentionConfiguration(this.RetentionUntilDate, this.Mode); string body = utils.MarshalXML(config, "http://s3.amazonaws.com/doc/2006-03-01/"); request.AddParameter("text/xml", body, ParameterType.RequestBody); request.AddOrUpdateParameter("Content-MD5", utils.getMD5SumStr(System.Text.Encoding.UTF8.GetBytes(body)), ParameterType.HttpHeader); return(request); }
public T WithRetentionConfiguration(ObjectRetentionConfiguration retentionConfiguration) { this.Retention = retentionConfiguration; return((T)this); }