SetBucketLifecycleCommand.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Copyright (C) Alibaba Cloud Computing
  3. * All rights reserved.
  4. *
  5. * 版权所有 (C)阿里云计算有限公司
  6. */
  7. using System;
  8. using System.Collections.Generic;
  9. using System.IO;
  10. using Aliyun.OSS.Common.Communication;
  11. using Aliyun.OSS.Util;
  12. using Aliyun.OSS.Transform;
  13. namespace Aliyun.OSS.Commands
  14. {
  15. internal class SetBucketLifecycleCommand : OssCommand
  16. {
  17. private readonly string _bucketName;
  18. private readonly SetBucketLifecycleRequest _setBucketLifecycleRequest;
  19. protected override HttpMethod Method
  20. {
  21. get { return HttpMethod.Put; }
  22. }
  23. protected override string Bucket
  24. {
  25. get { return _bucketName; }
  26. }
  27. protected override Stream Content
  28. {
  29. get
  30. {
  31. return SerializerFactory.GetFactory().CreateSetBucketLifecycleRequestSerializer()
  32. .Serialize(_setBucketLifecycleRequest);
  33. }
  34. }
  35. private SetBucketLifecycleCommand(IServiceClient client, Uri endpoint, ExecutionContext context,
  36. string bucketName, SetBucketLifecycleRequest setBucketLifecycleRequest)
  37. : base(client, endpoint, context)
  38. {
  39. OssUtils.CheckBucketName(bucketName);
  40. _bucketName = bucketName;
  41. _setBucketLifecycleRequest = setBucketLifecycleRequest;
  42. }
  43. public static SetBucketLifecycleCommand Create(IServiceClient client, Uri endpoint,
  44. ExecutionContext context,
  45. string bucketName, SetBucketLifecycleRequest setBucketLifecycleRequest)
  46. {
  47. return new SetBucketLifecycleCommand(client, endpoint, context, bucketName, setBucketLifecycleRequest);
  48. }
  49. protected override IDictionary<string, string> Parameters
  50. {
  51. get
  52. {
  53. return new Dictionary<string, string>()
  54. {
  55. { RequestParameters.SUBRESOURCE_LIFECYCLE, null }
  56. };
  57. }
  58. }
  59. }
  60. }