|
| 1 | +/* |
| 2 | + * Copyright (C) Alibaba Cloud Computing |
| 3 | + * All rights reserved. |
| 4 | + * |
| 5 | + */ |
| 6 | + |
| 7 | +using System; |
| 8 | +using System.Collections.Generic; |
| 9 | +using Aliyun.OSS.Common.Communication; |
| 10 | +using Aliyun.OSS.Util; |
| 11 | +using Aliyun.OSS.Transform; |
| 12 | +using Aliyun.OSS.Properties; |
| 13 | +using Aliyun.OSS.Model; |
| 14 | + |
| 15 | +namespace Aliyun.OSS.Commands |
| 16 | +{ |
| 17 | + internal class RestoreObjectCommand : OssCommand<RestoreObjectResult> |
| 18 | + { |
| 19 | + private string bucketName; |
| 20 | + private string key; |
| 21 | + |
| 22 | + protected override string Bucket |
| 23 | + { |
| 24 | + get { |
| 25 | + return bucketName; |
| 26 | + } |
| 27 | + } |
| 28 | + |
| 29 | + protected override string Key |
| 30 | + { |
| 31 | + get { |
| 32 | + return key; |
| 33 | + } |
| 34 | + } |
| 35 | + |
| 36 | + protected override HttpMethod Method |
| 37 | + { |
| 38 | + get { return HttpMethod.Post; } |
| 39 | + } |
| 40 | + |
| 41 | + protected override IDictionary<string, string> Parameters |
| 42 | + { |
| 43 | + get |
| 44 | + { |
| 45 | + var parameters = new Dictionary<string, string>(); |
| 46 | + parameters[RequestParameters.SUBRESOURCE_RESTORE] = null; |
| 47 | + return parameters; |
| 48 | + } |
| 49 | + } |
| 50 | + |
| 51 | + private RestoreObjectCommand(IServiceClient client, Uri endpoint, ExecutionContext context, |
| 52 | + string bucketName, string key, IDeserializer<ServiceResponse, RestoreObjectResult> deserializer) |
| 53 | + : base(client, endpoint, context, deserializer) |
| 54 | + { |
| 55 | + OssUtils.CheckBucketName(bucketName); |
| 56 | + OssUtils.CheckObjectKey(key); |
| 57 | + |
| 58 | + this.bucketName = bucketName; |
| 59 | + this.key = key; |
| 60 | + this.ParametersInUri = true; // in restore request, the parameter restore needs to be in uri |
| 61 | + } |
| 62 | + |
| 63 | + public static RestoreObjectCommand Create(IServiceClient client, Uri endpoint, |
| 64 | + ExecutionContext context, |
| 65 | + string bucketName, string key) |
| 66 | + { |
| 67 | + return new RestoreObjectCommand(client, endpoint, context, bucketName, key, DeserializerFactory.GetFactory().CreateRestoreObjectResultDeserializer()); |
| 68 | + } |
| 69 | + } |
| 70 | +} |
0 commit comments