2019-12-15 16:06:08 +01:00
|
|
|
import json
|
|
|
|
|
|
|
|
from moto.core.responses import BaseResponse
|
2023-11-30 07:55:51 -08:00
|
|
|
|
|
|
|
from .models import CodePipelineBackend, codepipeline_backends
|
2019-12-15 16:06:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
class CodePipelineResponse(BaseResponse):
|
2022-10-31 17:34:03 -01:00
|
|
|
def __init__(self) -> None:
|
2022-08-13 09:49:43 +00:00
|
|
|
super().__init__(service_name="codepipeline")
|
|
|
|
|
2019-12-15 16:06:08 +01:00
|
|
|
@property
|
2022-10-31 17:34:03 -01:00
|
|
|
def codepipeline_backend(self) -> CodePipelineBackend:
|
2022-08-13 09:49:43 +00:00
|
|
|
return codepipeline_backends[self.current_account][self.region]
|
2019-12-15 16:06:08 +01:00
|
|
|
|
2022-10-31 17:34:03 -01:00
|
|
|
def create_pipeline(self) -> str:
|
2019-12-15 16:06:08 +01:00
|
|
|
pipeline, tags = self.codepipeline_backend.create_pipeline(
|
2022-03-11 20:28:45 -01:00
|
|
|
self._get_param("pipeline"), self._get_param("tags")
|
2019-12-15 16:06:08 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
return json.dumps({"pipeline": pipeline, "tags": tags})
|
2019-12-15 16:54:58 +01:00
|
|
|
|
2022-10-31 17:34:03 -01:00
|
|
|
def get_pipeline(self) -> str:
|
2019-12-15 16:54:58 +01:00
|
|
|
pipeline, metadata = self.codepipeline_backend.get_pipeline(
|
|
|
|
self._get_param("name")
|
|
|
|
)
|
|
|
|
|
|
|
|
return json.dumps({"pipeline": pipeline, "metadata": metadata})
|
2019-12-15 17:28:59 +01:00
|
|
|
|
2022-10-31 17:34:03 -01:00
|
|
|
def update_pipeline(self) -> str:
|
2019-12-15 17:28:59 +01:00
|
|
|
pipeline = self.codepipeline_backend.update_pipeline(
|
|
|
|
self._get_param("pipeline")
|
|
|
|
)
|
|
|
|
|
|
|
|
return json.dumps({"pipeline": pipeline})
|
2019-12-15 17:44:54 +01:00
|
|
|
|
2022-10-31 17:34:03 -01:00
|
|
|
def list_pipelines(self) -> str:
|
2019-12-15 17:44:54 +01:00
|
|
|
pipelines = self.codepipeline_backend.list_pipelines()
|
|
|
|
|
|
|
|
return json.dumps({"pipelines": pipelines})
|
2019-12-15 17:58:38 +01:00
|
|
|
|
2022-10-31 17:34:03 -01:00
|
|
|
def delete_pipeline(self) -> str:
|
2019-12-15 17:58:38 +01:00
|
|
|
self.codepipeline_backend.delete_pipeline(self._get_param("name"))
|
|
|
|
|
|
|
|
return ""
|
2019-12-22 11:42:15 +01:00
|
|
|
|
2022-10-31 17:34:03 -01:00
|
|
|
def list_tags_for_resource(self) -> str:
|
2019-12-22 11:42:15 +01:00
|
|
|
tags = self.codepipeline_backend.list_tags_for_resource(
|
|
|
|
self._get_param("resourceArn")
|
|
|
|
)
|
|
|
|
|
|
|
|
return json.dumps({"tags": tags})
|
2019-12-23 19:33:37 +01:00
|
|
|
|
2022-10-31 17:34:03 -01:00
|
|
|
def tag_resource(self) -> str:
|
2019-12-23 19:33:37 +01:00
|
|
|
self.codepipeline_backend.tag_resource(
|
|
|
|
self._get_param("resourceArn"), self._get_param("tags")
|
|
|
|
)
|
|
|
|
|
|
|
|
return ""
|
2019-12-23 19:50:16 +01:00
|
|
|
|
2022-10-31 17:34:03 -01:00
|
|
|
def untag_resource(self) -> str:
|
2019-12-23 19:50:16 +01:00
|
|
|
self.codepipeline_backend.untag_resource(
|
|
|
|
self._get_param("resourceArn"), self._get_param("tagKeys")
|
|
|
|
)
|
|
|
|
|
|
|
|
return ""
|