heyuntao
2023-06-09 3b7af15b742ab218d0f18809f292270881747b94
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?php
 
namespace OSS\Model;
 
 
/**
 * Class LifecycleRule
 * @package OSS\Model
 *
 * @link http://help.aliyun.com/document_detail/oss/api-reference/bucket/PutBucketLifecycle.html
 */
class LifecycleRule
{
    /**
     * 得到规则ID
     *
     * @return string
     */
    public function getId()
    {
        return $this->id;
    }
 
    /**
     * @param string $id 规则ID
     */
    public function setId($id)
    {
        $this->id = $id;
    }
 
    /**
     * 得到文件前缀
     *
     * @return string
     */
    public function getPrefix()
    {
        return $this->prefix;
    }
 
    /**
     * 设置文件前缀
     *
     * @param string $prefix 文件前缀
     */
    public function setPrefix($prefix)
    {
        $this->prefix = $prefix;
    }
 
    /**
     * Lifecycle规则的状态
     *
     * @return string
     */
    public function getStatus()
    {
        return $this->status;
    }
 
    /**
     * 设置Lifecycle规则状态
     *
     * @param string $status
     */
    public function setStatus($status)
    {
        $this->status = $status;
    }
 
    /**
     *
     * @return LifecycleAction[]
     */
    public function getActions()
    {
        return $this->actions;
    }
 
    /**
     * @param LifecycleAction[] $actions
     */
    public function setActions($actions)
    {
        $this->actions = $actions;
    }
 
 
    /**
     * LifecycleRule constructor.
     *
     * @param string $id 规则ID
     * @param string $prefix 文件前缀
     * @param string $status 规则状态,可选[self::LIFECYCLE_STATUS_ENABLED, self::LIFECYCLE_STATUS_DISABLED]
     * @param LifecycleAction[] $actions
     */
    public function __construct($id, $prefix, $status, $actions)
    {
        $this->id = $id;
        $this->prefix = $prefix;
        $this->status = $status;
        $this->actions = $actions;
    }
 
    /**
     * @param \SimpleXMLElement $xmlRule
     */
    public function appendToXml(&$xmlRule)
    {
        $xmlRule->addChild('ID', $this->id);
        $xmlRule->addChild('Prefix', $this->prefix);
        $xmlRule->addChild('Status', $this->status);
        foreach ($this->actions as $action) {
            $action->appendToXml($xmlRule);
        }
    }
 
    private $id;
    private $prefix;
    private $status;
    private $actions = array();
 
    const LIFECYCLE_STATUS_ENABLED = 'Enabled';
    const LIFECYCLE_STATUS_DISABLED = 'Disabled';
}