sdk/Commands/GetObjectAclCommand.cs (64 lines of code) (raw):
/*
* Copyright (C) Alibaba Cloud Computing
* All rights reserved.
*
*/
using System;
using System.Collections.Generic;
using Aliyun.OSS.Common.Communication;
using Aliyun.OSS.Util;
using Aliyun.OSS.Transform;
namespace Aliyun.OSS.Commands
{
internal class GetObjectAclCommand : OssCommand<AccessControlList>
{
private readonly GetObjectAclRequest _request;
protected override string Bucket
{
get { return _request.BucketName; }
}
protected override string Key
{
get { return _request.Key; }
}
protected override IDictionary<string, string> Parameters
{
get
{
var parameters = new Dictionary<string, string>()
{
{ RequestParameters.SUBRESOURCE_ACL, null }
};
if (!string.IsNullOrEmpty(_request.VersionId))
{
parameters.Add(RequestParameters.SUBRESOURCE_VERSIONID, _request.VersionId);
}
return parameters;
}
}
protected override IDictionary<string, string> Headers
{
get
{
var headers = base.Headers;
if (_request.RequestPayer == RequestPayer.Requester)
{
headers.Add(OssHeaders.OssRequestPayer, RequestPayer.Requester.ToString().ToLowerInvariant());
}
return headers;
}
}
private GetObjectAclCommand(IServiceClient client, Uri endpoint, ExecutionContext context,
GetObjectAclRequest request,
IDeserializer<ServiceResponse, AccessControlList> deserializer)
: base(client, endpoint, context, deserializer)
{
OssUtils.CheckBucketName(request.BucketName);
OssUtils.CheckObjectKey(request.Key);
_request = request;
}
public static GetObjectAclCommand Create(IServiceClient client, Uri endpoint,
ExecutionContext context,
GetObjectAclRequest request)
{
return new GetObjectAclCommand(client, endpoint, context, request,
DeserializerFactory.GetFactory().CreateGetAclResultDeserializer());
}
}
}