Add codepipeline.untag_resource

This commit is contained in:
gruebel 2019-12-23 19:50:16 +01:00
parent b96a46b98f
commit 8331d480ba
4 changed files with 71 additions and 4 deletions

View File

@ -1374,7 +1374,7 @@
- [ ] update_profiling_group
## codepipeline
13% implemented
22% implemented
- [ ] acknowledge_job
- [ ] acknowledge_third_party_job
- [ ] create_custom_action_type
@ -1394,7 +1394,7 @@
- [ ] list_action_types
- [ ] list_pipeline_executions
- [X] list_pipelines
- [ ] list_tags_for_resource
- [X] list_tags_for_resource
- [ ] list_webhooks
- [ ] poll_for_jobs
- [ ] poll_for_third_party_jobs
@ -1408,8 +1408,8 @@
- [ ] register_webhook_with_third_party
- [ ] retry_stage_execution
- [ ] start_pipeline_execution
- [ ] tag_resource
- [ ] untag_resource
- [X] tag_resource
- [X] untag_resource
- [X] update_pipeline
## codestar

View File

@ -192,6 +192,20 @@ class CodePipelineBackend(BaseBackend):
for tag in tags:
pipeline.tags.update({tag["key"]: tag["value"]})
def untag_resource(self, arn, tag_keys):
name = arn.split(":")[-1]
pipeline = self.pipelines.get(name)
if not pipeline:
raise ResourceNotFoundException(
"The account with id '{0}' does not include a pipeline with the name '{1}'".format(
ACCOUNT_ID, name
)
)
for key in tag_keys:
pipeline.tags.pop(key, None)
codepipeline_backends = {}
for region in Session().get_available_regions("codepipeline"):

View File

@ -53,3 +53,10 @@ class CodePipelineResponse(BaseResponse):
)
return ""
def untag_resource(self):
self.codepipeline_backend.untag_resource(
self._get_param("resourceArn"), self._get_param("tagKeys")
)
return ""

View File

@ -602,6 +602,52 @@ def test_tag_resource_errors():
)
@mock_codepipeline
def test_untag_resource():
client = boto3.client("codepipeline", region_name="us-east-1")
name = "test-pipeline"
create_basic_codepipeline(client, name)
response = client.list_tags_for_resource(
resourceArn="arn:aws:codepipeline:us-east-1:123456789012:{}".format(name)
)
response["tags"].should.equal([{"key": "key", "value": "value"}])
client.untag_resource(
resourceArn="arn:aws:codepipeline:us-east-1:123456789012:{}".format(name),
tagKeys=["key"],
)
response = client.list_tags_for_resource(
resourceArn="arn:aws:codepipeline:us-east-1:123456789012:{}".format(name)
)
response["tags"].should.have.length_of(0)
# removing a not existing tag should raise no exception
client.untag_resource(
resourceArn="arn:aws:codepipeline:us-east-1:123456789012:{}".format(name),
tagKeys=["key"],
)
@mock_codepipeline
def test_untag_resource_errors():
client = boto3.client("codepipeline", region_name="us-east-1")
with assert_raises(ClientError) as e:
client.untag_resource(
resourceArn="arn:aws:codepipeline:us-east-1:123456789012:not-existing",
tagKeys=["key"],
)
ex = e.exception
ex.operation_name.should.equal("UntagResource")
ex.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
ex.response["Error"]["Code"].should.contain("ResourceNotFoundException")
ex.response["Error"]["Message"].should.equal(
"The account with id '123456789012' does not include a pipeline with the name 'not-existing'"
)
@mock_iam
def get_role_arn():
client = boto3.client("iam", region_name="us-east-1")