|
| 1 | +/* |
| 2 | + * Copyright (C) Alibaba Cloud Computing |
| 3 | + * All rights reserved. |
| 4 | + * |
| 5 | + */ |
| 6 | + |
| 7 | +using System; |
| 8 | +using System.IO; |
| 9 | +using System.Collections.Generic; |
| 10 | + |
| 11 | +using Aliyun.OSS.Common.Communication; |
| 12 | +using Aliyun.OSS.Util; |
| 13 | +using Aliyun.OSS.Transform; |
| 14 | + |
| 15 | +namespace Aliyun.OSS.Commands |
| 16 | +{ |
| 17 | + internal class SetBucketStorageCapacityCommand : OssCommand |
| 18 | + { |
| 19 | + private readonly string _bucketName; |
| 20 | + private readonly SetBucketStorageCapacityRequest _setBucketStorageCapacityRequest; |
| 21 | + |
| 22 | + protected override HttpMethod Method |
| 23 | + { |
| 24 | + get { return HttpMethod.Put; } |
| 25 | + } |
| 26 | + |
| 27 | + protected override string Bucket |
| 28 | + { |
| 29 | + get { return _bucketName; } |
| 30 | + } |
| 31 | + |
| 32 | + private SetBucketStorageCapacityCommand(IServiceClient client, Uri endpoint, ExecutionContext context, |
| 33 | + string bucketName, SetBucketStorageCapacityRequest setBucketStorageCapacityRequest) |
| 34 | + : base(client, endpoint, context) |
| 35 | + { |
| 36 | + OssUtils.CheckBucketName(bucketName); |
| 37 | + if (setBucketStorageCapacityRequest.StorageCapacity < -1) |
| 38 | + throw new ArgumentException("storage capacity must greater than -1"); |
| 39 | + |
| 40 | + _bucketName = bucketName; |
| 41 | + _setBucketStorageCapacityRequest = setBucketStorageCapacityRequest; |
| 42 | + } |
| 43 | + |
| 44 | + public static SetBucketStorageCapacityCommand Create(IServiceClient client, Uri endpoint, |
| 45 | + ExecutionContext context, |
| 46 | + string bucketName, SetBucketStorageCapacityRequest setBucketStorageCapacityRequest) |
| 47 | + { |
| 48 | + return new SetBucketStorageCapacityCommand(client, endpoint, context, bucketName, setBucketStorageCapacityRequest); |
| 49 | + } |
| 50 | + |
| 51 | + |
| 52 | + protected override IDictionary<string, string> Parameters |
| 53 | + { |
| 54 | + get |
| 55 | + { |
| 56 | + return new Dictionary<string, string>() |
| 57 | + { |
| 58 | + { RequestParameters.SUBRESOURCE_QOS, null } |
| 59 | + }; |
| 60 | + } |
| 61 | + } |
| 62 | + protected override Stream Content |
| 63 | + { |
| 64 | + get |
| 65 | + { |
| 66 | + return SerializerFactory.GetFactory().CreateSetBucketStorageCapacityRequestSerializer() |
| 67 | + .Serialize(_setBucketStorageCapacityRequest); |
| 68 | + } |
| 69 | + } |
| 70 | + } |
| 71 | +} |
0 commit comments