← All changes
|
includes/sdk/google/google/cloud-storage/src/Lifecycle.php
+74
-8
1.0.2
→
1.4.2
View file →
| @@ -14,11 +14,11 @@ | ||
| 14 | 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | 15 | * See the License for the specific language governing permissions and |
| 16 | 16 | * limitations under the License. |
| 17 | 17 | */ |
| 18 | -namespace Dudlewebs\WPMCS\Google\Cloud\Storage; | |
| 18 | +namespace Dudlewebs\WPMCS\GCP\Google\Cloud\Storage; | |
| 19 | 19 | |
| 20 | -use Dudlewebs\WPMCS\Google\Cloud\Core\Timestamp; | |
| 20 | +use Dudlewebs\WPMCS\GCP\Google\Cloud\Core\Timestamp; | |
| 21 | 21 | /** |
| 22 | 22 | * Object Lifecycle Management supports common use cases like setting a Time to |
| 23 | 23 | * Live (TTL) for objects, archiving older versions of objects, or "downgrading" |
| 24 | 24 | * storage classes of objects to help manage costs. |
| @@ -129,8 +129,74 @@ | ||
| 129 | 129 | $this->lifecycle['rule'][] = ['action' => ['type' => 'Delete'], 'condition' => $this->formatCondition($condition)]; |
| 130 | 130 | return $this; |
| 131 | 131 | } |
| 132 | 132 | /** |
| 133 | + * Adds a AbortIncompleteMultipartUpload lifecycle rule to Object Lifecycle. | |
| 134 | + * | |
| 135 | + * Example: | |
| 136 | + * ``` | |
| 137 | + * $lifecycle->addAbortIncompleteMultipartUploadRule([ | |
| 138 | + * 'age' => 50, | |
| 139 | + * 'isLive' => true | |
| 140 | + * ]); | |
| 141 | + * ``` | |
| 142 | + * | |
| 143 | + * @param array $condition { | |
| 144 | + * The condition(s) where the rule will apply. | |
| 145 | + * | |
| 146 | + * @type int $age Age of an object (in days). This condition is | |
| 147 | + * satisfied when an object reaches the specified age. | |
| 148 | + * @type \DateTimeInterface|string $createdBefore This condition is | |
| 149 | + * satisfied when an object is created before midnight of the | |
| 150 | + * specified date in UTC. If a string is given, it must be a date | |
| 151 | + * in RFC 3339 format with only the date part (for instance, | |
| 152 | + * "2013-01-15"). | |
| 153 | + * @type \DateTimeInterface|string $customTimeBefore This condition is | |
| 154 | + * satisfied when the custom time on an object is before this date | |
| 155 | + * in UTC. If a string is given, it must be a date in RFC 3339 | |
| 156 | + * format with only the date part (for instance, "2013-01-15"). | |
| 157 | + * @type int $daysSinceCustomTime Number of days elapsed since the | |
| 158 | + * user-specified timestamp set on an object. The condition is | |
| 159 | + * satisfied if the days elapsed is at least this number. If no | |
| 160 | + * custom timestamp is specified on an object, the condition does | |
| 161 | + * not apply. | |
| 162 | + * @type int $daysSinceNoncurrentTime Number of days elapsed since the | |
| 163 | + * noncurrent timestamp of an object. The condition is satisfied | |
| 164 | + * if the days elapsed is at least this number. This condition is | |
| 165 | + * relevant only for versioned objects. The value of the field | |
| 166 | + * must be a nonnegative integer. If it's zero, the object version | |
| 167 | + * will become eligible for Lifecycle action as soon as it becomes | |
| 168 | + * noncurrent. | |
| 169 | + * @type bool $isLive Relevant only for versioned objects. If the value | |
| 170 | + * is `true`, this condition matches live objects; if the value is | |
| 171 | + * `false`, it matches archived objects. | |
| 172 | + * @type string[] $matchesStorageClass Objects having any of the storage | |
| 173 | + * classes specified by this condition will be matched. Values | |
| 174 | + * include `"MULTI_REGIONAL"`, `"REGIONAL"`, `"NEARLINE"`, | |
| 175 | + * `"ARCHIVE"`, `"COLDLINE"`, `"STANDARD"`, and | |
| 176 | + * `"DURABLE_REDUCED_AVAILABILITY"`. | |
| 177 | + * @type \DateTimeInterface|string $noncurrentTimeBefore This condition | |
| 178 | + * is satisfied when the noncurrent time on an object is before | |
| 179 | + * this timestamp. This condition is relevant only for versioned | |
| 180 | + * objects. If a string is given, it must be a date in RFC 3339 | |
| 181 | + * format with only the date part (for instance, "2013-01-15"). | |
| 182 | + * @type int $numNewerVersions Relevant only for versioned objects. If | |
| 183 | + * the value is N, this condition is satisfied when there are at | |
| 184 | + * least N versions (including the live version) newer than this | |
| 185 | + * version of the object. | |
| 186 | + * @type string[] $matchesPrefix Objects having names which start with | |
| 187 | + * values specified by this condition will be matched. | |
| 188 | + * @type string[] $matchesSuffix Objects having names which end with | |
| 189 | + * values specified by this condition will be matched. | |
| 190 | + * } | |
| 191 | + * @return Lifecycle | |
| 192 | + */ | |
| 193 | + public function addAbortIncompleteMultipartUploadRule(array $condition) | |
| 194 | + { | |
| 195 | + $this->lifecycle['rule'][] = ['action' => ['type' => 'AbortIncompleteMultipartUpload'], 'condition' => $this->formatCondition($condition)]; | |
| 196 | + return $this; | |
| 197 | + } | |
| 198 | + /** | |
| 133 | 199 | * Adds an Object Lifecycle Set Storage Class Rule. |
| 134 | 200 | * |
| 135 | 201 | * Example: |
| 136 | 202 | * ``` |
| @@ -259,18 +325,18 @@ | ||
| 259 | 325 | if (!$action) { |
| 260 | 326 | $this->lifecycle = []; |
| 261 | 327 | return $this; |
| 262 | 328 | } |
| 263 | - if (!is_string($action) && !is_callable($action)) { | |
| 264 | - throw new \InvalidArgumentException(sprintf('Expected either a string or callable, instead got \'%s\'.', gettype($action))); | |
| 329 | + if (!\is_string($action) && !\is_callable($action)) { | |
| 330 | + throw new \InvalidArgumentException(\sprintf('Expected either a string or callable, instead got \'%s\'.', \gettype($action))); | |
| 265 | 331 | } |
| 266 | 332 | if (isset($this->lifecycle['rule'])) { |
| 267 | - if (is_string($action)) { | |
| 268 | - $action = function ($rule) use ($action) { | |
| 333 | + if (\is_string($action)) { | |
| 334 | + $action = function ($rule) use($action) { | |
| 269 | 335 | return $rule['action']['type'] !== $action; |
| 270 | 336 | }; |
| 271 | 337 | } |
| 272 | - $this->lifecycle['rule'] = array_filter($this->lifecycle['rule'], $action); | |
| 338 | + $this->lifecycle['rule'] = \array_filter($this->lifecycle['rule'], $action); | |
| 273 | 339 | if (!$this->lifecycle['rule']) { |
| 274 | 340 | $this->lifecycle = []; |
| 275 | 341 | } |
| 276 | 342 | } |
| @@ -286,9 +352,9 @@ | ||
| 286 | 352 | if (!isset($this->lifecycle['rule'])) { |
| 287 | 353 | return; |
| 288 | 354 | } |
| 289 | 355 | foreach ($this->lifecycle['rule'] as $rule) { |
| 290 | - yield $rule; | |
| 356 | + (yield $rule); | |
| 291 | 357 | } |
| 292 | 358 | } |
| 293 | 359 | /** |
| 294 | 360 | * @access private |