@@ -96,6 +96,46 @@ final class DeleteObjectRequest extends Input
9696 */
9797 private $ expectedBucketOwner ;
9898
99+ /**
100+ * The `If-Match` header field makes the request method conditional on ETags. If the ETag value does not match, the
101+ * operation returns a `412 Precondition Failed` error. If the ETag matches or if the object doesn't exist, the
102+ * operation will return a `204 Success (No Content) response`.
103+ *
104+ * For more information about conditional requests, see RFC 7232 [^1].
105+ *
106+ * > This functionality is only supported for directory buckets.
107+ *
108+ * [^1]: https://docs.aws.amazon.com/https:/tools.ietf.org/html/rfc7232
109+ *
110+ * @var string|null
111+ */
112+ private $ ifMatch ;
113+
114+ /**
115+ * If present, the object is deleted only if its modification times matches the provided `Timestamp`. If the `Timestamp`
116+ * values do not match, the operation returns a `412 Precondition Failed` error. If the `Timestamp` matches or if the
117+ * object doesn’t exist, the operation returns a `204 Success (No Content)` response.
118+ *
119+ * > This functionality is only supported for directory buckets.
120+ *
121+ * @var \DateTimeImmutable|null
122+ */
123+ private $ ifMatchLastModifiedTime ;
124+
125+ /**
126+ * If present, the object is deleted only if its size matches the provided size in bytes. If the `Size` value does not
127+ * match, the operation returns a `412 Precondition Failed` error. If the `Size` matches or if the object doesn’t
128+ * exist, the operation returns a `204 Success (No Content)` response.
129+ *
130+ * > This functionality is only supported for directory buckets.
131+ *
132+ * ! You can use the `If-Match`, `x-amz-if-match-last-modified-time` and `x-amz-if-match-size` conditional headers in
133+ * ! conjunction with each-other or individually.
134+ *
135+ * @var int|null
136+ */
137+ private $ ifMatchSize ;
138+
99139 /**
100140 * @param array{
101141 * Bucket?: string,
@@ -105,6 +145,9 @@ final class DeleteObjectRequest extends Input
105145 * RequestPayer?: null|RequestPayer::*,
106146 * BypassGovernanceRetention?: null|bool,
107147 * ExpectedBucketOwner?: null|string,
148+ * IfMatch?: null|string,
149+ * IfMatchLastModifiedTime?: null|\DateTimeImmutable|string,
150+ * IfMatchSize?: null|int,
108151 * '@region'?: string|null,
109152 * } $input
110153 */
@@ -117,6 +160,9 @@ public function __construct(array $input = [])
117160 $ this ->requestPayer = $ input ['RequestPayer ' ] ?? null ;
118161 $ this ->bypassGovernanceRetention = $ input ['BypassGovernanceRetention ' ] ?? null ;
119162 $ this ->expectedBucketOwner = $ input ['ExpectedBucketOwner ' ] ?? null ;
163+ $ this ->ifMatch = $ input ['IfMatch ' ] ?? null ;
164+ $ this ->ifMatchLastModifiedTime = !isset ($ input ['IfMatchLastModifiedTime ' ]) ? null : ($ input ['IfMatchLastModifiedTime ' ] instanceof \DateTimeImmutable ? $ input ['IfMatchLastModifiedTime ' ] : new \DateTimeImmutable ($ input ['IfMatchLastModifiedTime ' ]));
165+ $ this ->ifMatchSize = $ input ['IfMatchSize ' ] ?? null ;
120166 parent ::__construct ($ input );
121167 }
122168
@@ -129,6 +175,9 @@ public function __construct(array $input = [])
129175 * RequestPayer?: null|RequestPayer::*,
130176 * BypassGovernanceRetention?: null|bool,
131177 * ExpectedBucketOwner?: null|string,
178+ * IfMatch?: null|string,
179+ * IfMatchLastModifiedTime?: null|\DateTimeImmutable|string,
180+ * IfMatchSize?: null|int,
132181 * '@region'?: string|null,
133182 * }|DeleteObjectRequest $input
134183 */
@@ -152,6 +201,21 @@ public function getExpectedBucketOwner(): ?string
152201 return $ this ->expectedBucketOwner ;
153202 }
154203
204+ public function getIfMatch (): ?string
205+ {
206+ return $ this ->ifMatch ;
207+ }
208+
209+ public function getIfMatchLastModifiedTime (): ?\DateTimeImmutable
210+ {
211+ return $ this ->ifMatchLastModifiedTime ;
212+ }
213+
214+ public function getIfMatchSize (): ?int
215+ {
216+ return $ this ->ifMatchSize ;
217+ }
218+
155219 public function getKey (): ?string
156220 {
157221 return $ this ->key ;
@@ -197,6 +261,15 @@ public function request(): Request
197261 if (null !== $ this ->expectedBucketOwner ) {
198262 $ headers ['x-amz-expected-bucket-owner ' ] = $ this ->expectedBucketOwner ;
199263 }
264+ if (null !== $ this ->ifMatch ) {
265+ $ headers ['If-Match ' ] = $ this ->ifMatch ;
266+ }
267+ if (null !== $ this ->ifMatchLastModifiedTime ) {
268+ $ headers ['x-amz-if-match-last-modified-time ' ] = $ this ->ifMatchLastModifiedTime ->setTimezone (new \DateTimeZone ('GMT ' ))->format (\DateTimeInterface::RFC7231 );
269+ }
270+ if (null !== $ this ->ifMatchSize ) {
271+ $ headers ['x-amz-if-match-size ' ] = (string ) $ this ->ifMatchSize ;
272+ }
200273
201274 // Prepare query
202275 $ query = [];
@@ -244,6 +317,27 @@ public function setExpectedBucketOwner(?string $value): self
244317 return $ this ;
245318 }
246319
320+ public function setIfMatch (?string $ value ): self
321+ {
322+ $ this ->ifMatch = $ value ;
323+
324+ return $ this ;
325+ }
326+
327+ public function setIfMatchLastModifiedTime (?\DateTimeImmutable $ value ): self
328+ {
329+ $ this ->ifMatchLastModifiedTime = $ value ;
330+
331+ return $ this ;
332+ }
333+
334+ public function setIfMatchSize (?int $ value ): self
335+ {
336+ $ this ->ifMatchSize = $ value ;
337+
338+ return $ this ;
339+ }
340+
247341 public function setKey (?string $ value ): self
248342 {
249343 $ this ->key = $ value ;
0 commit comments