PutBucketIntelligentTieringRequest.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System;
  2. using System.Text;
  3. using COSXML.Common;
  4. using COSXML.Model.Tag;
  5. using COSXML.Network;
  6. using COSXML.CosException;
  7. namespace COSXML.Model.Bucket
  8. {
  9. /// <summary>
  10. /// 设置 Bucket 生命周期
  11. /// <see href="https://cloud.tencent.com/document/product/436/8280"/>
  12. /// </summary>
  13. public sealed class PutBucketIntelligentTieringRequest : BucketRequest
  14. {
  15. private IntelligentTieringConfiguration configuration;
  16. public PutBucketIntelligentTieringRequest(string bucket, IntelligentTieringConfiguration configuration)
  17. : base(bucket)
  18. {
  19. if (String.IsNullOrEmpty(configuration.Status))
  20. {
  21. configuration.Status = "Enabled";
  22. }
  23. if (configuration.Transition == null)
  24. {
  25. configuration.Transition = new IntelligentTieringConfiguration.IntelligentTieringTransition();
  26. }
  27. if (configuration.Transition.Days < 1)
  28. {
  29. configuration.Transition.Days = 30;
  30. }
  31. if (configuration.Transition.RequestFrequent < 1)
  32. {
  33. configuration.Transition.RequestFrequent = 1;
  34. }
  35. this.method = CosRequestMethod.PUT;
  36. this.queryParameters.Add("intelligenttiering", null);
  37. this.configuration = configuration;
  38. }
  39. public override Network.RequestBody GetRequestBody()
  40. {
  41. return GetXmlRequestBody(configuration);
  42. }
  43. public override void CheckParameters()
  44. {
  45. base.CheckParameters();
  46. if (String.IsNullOrEmpty(configuration.Status))
  47. {
  48. throw new CosClientException((int)CosClientError.InvalidArgument, "Status 不能为空");
  49. }
  50. }
  51. }
  52. }