S3 - Implement delete_object_tagging
This commit is contained in:
parent
c5f8fa4e1f
commit
9ed7ba58df
@ -7093,7 +7093,7 @@
|
||||
- [X] delete_bucket_tagging
|
||||
- [ ] delete_bucket_website
|
||||
- [X] delete_object
|
||||
- [ ] delete_object_tagging
|
||||
- [x] delete_object_tagging
|
||||
- [ ] delete_objects
|
||||
- [ ] delete_public_access_block
|
||||
- [ ] get_bucket_accelerate_configuration
|
||||
|
@ -1566,6 +1566,10 @@ class S3Backend(BaseBackend):
|
||||
bucket = self.get_bucket(bucket_name)
|
||||
bucket.keys[key_name] = FakeDeleteMarker(key=bucket.keys[key_name])
|
||||
|
||||
def delete_object_tagging(self, bucket_name, key_name, version_id=None):
|
||||
key = self.get_object(bucket_name, key_name, version_id=version_id)
|
||||
self.tagger.delete_all_tags_for_resource(key.arn)
|
||||
|
||||
def delete_object(self, bucket_name, key_name, version_id=None):
|
||||
key_name = clean_key_name(key_name)
|
||||
bucket = self.get_bucket(bucket_name)
|
||||
|
@ -1618,6 +1618,12 @@ class ResponseObject(_TemplateEnvironmentMixin, ActionAuthenticatorMixin):
|
||||
self.backend.cancel_multipart(bucket_name, upload_id)
|
||||
return 204, {}, ""
|
||||
version_id = query.get("versionId", [None])[0]
|
||||
if "tagging" in query:
|
||||
self.backend.delete_object_tagging(
|
||||
bucket_name, key_name, version_id=version_id
|
||||
)
|
||||
template = self.response_template(S3_DELETE_KEY_TAGGING_RESPONSE)
|
||||
return 204, {}, template.render(version_id=version_id)
|
||||
self.backend.delete_object(bucket_name, key_name, version_id=version_id)
|
||||
return 204, {}, ""
|
||||
|
||||
@ -1935,6 +1941,12 @@ S3_DELETE_KEYS_RESPONSE = """<?xml version="1.0" encoding="UTF-8"?>
|
||||
{% endfor %}
|
||||
</DeleteResult>"""
|
||||
|
||||
S3_DELETE_KEY_TAGGING_RESPONSE = """<?xml version="1.0" encoding="UTF-8"?>
|
||||
<DeleteObjectTaggingResult xmlns="http://s3.amazonaws.com/doc/2006-03-01">
|
||||
<VersionId>{{version_id}}</VersionId>
|
||||
</DeleteObjectTaggingResult>
|
||||
"""
|
||||
|
||||
S3_OBJECT_ACL_RESPONSE = """<?xml version="1.0" encoding="UTF-8"?>
|
||||
<AccessControlPolicy xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
||||
<Owner>
|
||||
|
@ -2424,9 +2424,13 @@ def test_boto3_put_object_with_tagging():
|
||||
|
||||
s3.put_object(Bucket=bucket_name, Key=key, Body="test", Tagging="foo=bar")
|
||||
|
||||
resp = s3.get_object_tagging(Bucket=bucket_name, Key=key)
|
||||
s3.get_object_tagging(Bucket=bucket_name, Key=key)["TagSet"].should.contain(
|
||||
{"Key": "foo", "Value": "bar"}
|
||||
)
|
||||
|
||||
resp["TagSet"].should.contain({"Key": "foo", "Value": "bar"})
|
||||
s3.delete_object_tagging(Bucket=bucket_name, Key=key)
|
||||
|
||||
s3.get_object_tagging(Bucket=bucket_name, Key=key)["TagSet"].should.equal([])
|
||||
|
||||
|
||||
@mock_s3
|
||||
|
Loading…
Reference in New Issue
Block a user