Esempio n. 1
0
    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)
Esempio n. 2
0
    def tag_resource(self, arn, tags):
        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))

        pipeline.validate_tags(tags)

        for tag in tags:
            pipeline.tags.update({tag["key"]: tag["value"]})
Esempio n. 3
0
    def update_pipeline(self, pipeline):
        codepipeline = self.pipelines.get(pipeline["name"])

        if not codepipeline:
            raise ResourceNotFoundException(
                "The account with id '{0}' does not include a pipeline with the name '{1}'"
                .format(ACCOUNT_ID, pipeline["name"]))

        # version number is auto incremented
        pipeline["version"] = codepipeline.pipeline["version"] + 1
        codepipeline._updated = datetime.utcnow()
        codepipeline.pipeline = codepipeline.add_default_values(pipeline)

        return codepipeline.pipeline
Esempio n. 4
0
    def list_tags_for_resource(self, arn):
        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
                )
            )

        tags = [{"key": key, "value": value} for key, value in pipeline.tags.items()]

        return sorted(tags, key=lambda i: i["key"])