LifecycleRule.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. namespace OSS\Model;
  3. /**
  4. * Class LifecycleRule
  5. * @package OSS\Model
  6. *
  7. * @link http://help.aliyun.com/document_detail/oss/api-reference/bucket/PutBucketLifecycle.html
  8. */
  9. class LifecycleRule
  10. {
  11. /**
  12. * Get Id
  13. *
  14. * @return string
  15. */
  16. public function getId()
  17. {
  18. return $this->id;
  19. }
  20. /**
  21. * @param string $id Rule Id
  22. */
  23. public function setId($id)
  24. {
  25. $this->id = $id;
  26. }
  27. /**
  28. * Get a file prefix
  29. *
  30. * @return string
  31. */
  32. public function getPrefix()
  33. {
  34. return $this->prefix;
  35. }
  36. /**
  37. * Set a file prefix
  38. *
  39. * @param string $prefix The file prefix
  40. */
  41. public function setPrefix($prefix)
  42. {
  43. $this->prefix = $prefix;
  44. }
  45. /**
  46. * Get Lifecycle status
  47. *
  48. * @return string
  49. */
  50. public function getStatus()
  51. {
  52. return $this->status;
  53. }
  54. /**
  55. * Set Lifecycle status
  56. *
  57. * @param string $status
  58. */
  59. public function setStatus($status)
  60. {
  61. $this->status = $status;
  62. }
  63. /**
  64. *
  65. * @return LifecycleAction[]
  66. */
  67. public function getActions()
  68. {
  69. return $this->actions;
  70. }
  71. /**
  72. * @param LifecycleAction[] $actions
  73. */
  74. public function setActions($actions)
  75. {
  76. $this->actions = $actions;
  77. }
  78. /**
  79. * LifecycleRule constructor.
  80. *
  81. * @param string $id rule Id
  82. * @param string $prefix File prefix
  83. * @param string $status Rule status, which has the following valid values: [self::LIFECYCLE_STATUS_ENABLED, self::LIFECYCLE_STATUS_DISABLED]
  84. * @param LifecycleAction[] $actions
  85. */
  86. public function __construct($id, $prefix, $status, $actions)
  87. {
  88. $this->id = $id;
  89. $this->prefix = $prefix;
  90. $this->status = $status;
  91. $this->actions = $actions;
  92. }
  93. /**
  94. * @param \SimpleXMLElement $xmlRule
  95. */
  96. public function appendToXml(&$xmlRule)
  97. {
  98. $xmlRule->addChild('ID', $this->id);
  99. $xmlRule->addChild('Prefix', $this->prefix);
  100. $xmlRule->addChild('Status', $this->status);
  101. foreach ($this->actions as $action) {
  102. $action->appendToXml($xmlRule);
  103. }
  104. }
  105. private $id;
  106. private $prefix;
  107. private $status;
  108. private $actions = array();
  109. const LIFECYCLE_STATUS_ENABLED = 'Enabled';
  110. const LIFECYCLE_STATUS_DISABLED = 'Disabled';
  111. }