1 /*
2  * Copyright 2009-2017 Alibaba Cloud All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 #include <string>
19 #include <vector>
20 #include <alibabacloud/oss/Export.h>
21 #include <alibabacloud/oss/Types.h>
22 #include <alibabacloud/oss/model/Tagging.h>
23 
24 namespace AlibabaCloud
25 {
26 namespace OSS
27 {
28     class ALIBABACLOUD_OSS_EXPORT LifeCycleExpiration
29     {
30     public:
31         LifeCycleExpiration();
32         LifeCycleExpiration(uint32_t days);
33         LifeCycleExpiration(const std::string& createdBeforeDate);
34         void setDays(uint32_t days);
35         void setCreatedBeforeDate(const std::string& date);
Days()36         uint32_t Days() const { return days_; }
CreatedBeforeDate()37         const std::string& CreatedBeforeDate() const { return createdBeforeDate_; }
38     private:
39         uint32_t days_;
40         std::string createdBeforeDate_;
41     };
42 
43     class ALIBABACLOUD_OSS_EXPORT LifeCycleTransition
44     {
45     public:
46         LifeCycleTransition() = default;
47         LifeCycleTransition(const LifeCycleExpiration& expiration, AlibabaCloud::OSS::StorageClass storageClass);
48         void setExpiration(const LifeCycleExpiration& expiration);
49         void setStorageClass(AlibabaCloud::OSS::StorageClass storageClass);
Expiration()50         const LifeCycleExpiration& Expiration() const { return expiration_; }
Expiration()51         LifeCycleExpiration& Expiration() { return expiration_; }
StorageClass()52         AlibabaCloud::OSS::StorageClass StorageClass() const { return storageClass_; }
53     private:
54         LifeCycleExpiration expiration_;
55         AlibabaCloud::OSS::StorageClass storageClass_;
56     };
57 
58     using LifeCycleTransitionList = std::vector<LifeCycleTransition>;
59 
60     class ALIBABACLOUD_OSS_EXPORT LifecycleRule
61     {
62     public:
63         LifecycleRule();
ID()64         const std::string& ID() const { return id_; }
Prefix()65         const std::string& Prefix() const { return prefix_; }
Status()66         RuleStatus Status() const {  return status_;}
Expiration()67         const LifeCycleExpiration& Expiration() const { return expiration_; }
TransitionList()68         const LifeCycleTransitionList& TransitionList() const { return transitionList_; }
AbortMultipartUpload()69         const LifeCycleExpiration& AbortMultipartUpload() const { return abortMultipartUpload_; }
Expiration()70         LifeCycleExpiration& Expiration() { return expiration_; }
TransitionList()71         LifeCycleTransitionList& TransitionList() { return transitionList_; }
AbortMultipartUpload()72         LifeCycleExpiration& AbortMultipartUpload() { return abortMultipartUpload_; }
73 
Tags()74         const TagSet& Tags() const { return tagSet_; }
Tags()75         TagSet& Tags() { return tagSet_; }
76 
setID(const std::string & id)77         void setID(const std::string& id) { id_ = id; }
setPrefix(const std::string & prefix)78         void setPrefix(const std::string& prefix) { prefix_ = prefix; }
setStatus(RuleStatus status)79         void setStatus(RuleStatus status) { status_ = status; }
setExpiration(const LifeCycleExpiration & expiration)80         void setExpiration(const LifeCycleExpiration& expiration) { expiration_ = expiration; }
addTransition(const LifeCycleTransition & transition)81         void addTransition(const LifeCycleTransition&transition) { transitionList_.push_back(transition); }
setTransitionList(const LifeCycleTransitionList & transitionList)82         void setTransitionList(const LifeCycleTransitionList& transitionList) { transitionList_ = transitionList; }
setAbortMultipartUpload(const LifeCycleExpiration & expiration)83         void setAbortMultipartUpload(const LifeCycleExpiration& expiration) { abortMultipartUpload_ = expiration; }
addTag(const Tag & tag)84         void addTag(const Tag& tag) { tagSet_.push_back(tag); }
setTags(const TagSet & tags)85         void setTags(const TagSet& tags) { tagSet_ = tags; }
86         bool hasExpiration() const;
87         bool hasTransitionList() const;
88         bool hasAbortMultipartUpload() const;
89         bool operator==(const LifecycleRule& right) const;
90 
ExpiredObjectDeleteMarker()91         bool ExpiredObjectDeleteMarker() const { return expiredObjectDeleteMarker_; };
NoncurrentVersionExpiration()92         const LifeCycleExpiration& NoncurrentVersionExpiration() const { return noncurrentVersionExpiration_; }
NoncurrentVersionTransitionList()93         const LifeCycleTransitionList& NoncurrentVersionTransitionList() const { return noncurrentVersionTransitionList_; }
NoncurrentVersionExpiration()94         LifeCycleExpiration& NoncurrentVersionExpiration() { return noncurrentVersionExpiration_; }
NoncurrentVersionTransitionList()95         LifeCycleTransitionList& NoncurrentVersionTransitionList() { return noncurrentVersionTransitionList_; }
setExpiredObjectDeleteMarker(bool value)96         void setExpiredObjectDeleteMarker(bool value) { expiredObjectDeleteMarker_ = value; };
setNoncurrentVersionExpiration(const LifeCycleExpiration & expiration)97         void setNoncurrentVersionExpiration(const LifeCycleExpiration& expiration) { noncurrentVersionExpiration_ = expiration; }
addNoncurrentVersionTransition(const LifeCycleTransition & transition)98         void addNoncurrentVersionTransition(const LifeCycleTransition&transition) { noncurrentVersionTransitionList_.push_back(transition); }
setNoncurrentVersionTransitionList(const LifeCycleTransitionList & transitionList)99         void setNoncurrentVersionTransitionList(const LifeCycleTransitionList& transitionList) { noncurrentVersionTransitionList_ = transitionList; }
100         bool hasNoncurrentVersionExpiration() const;
101         bool hasNoncurrentVersionTransitionList() const;
102 
103     private:
104         std::string id_;
105         std::string prefix_;
106         RuleStatus status_;
107         LifeCycleExpiration expiration_;
108         LifeCycleTransitionList transitionList_;
109         LifeCycleExpiration abortMultipartUpload_;
110         TagSet tagSet_;
111 
112         bool expiredObjectDeleteMarker_;
113         LifeCycleExpiration noncurrentVersionExpiration_;
114         LifeCycleTransitionList noncurrentVersionTransitionList_;
115     };
116     using LifecycleRuleList = std::vector<LifecycleRule>;
117 }
118 }
119