Merge pull request #909 from dataxu/BT-1753
Implementation of delete_pipeline
This commit is contained in:
commit
d5e73e11fc
@ -23,14 +23,15 @@ class PipelineObject(BaseModel):
|
||||
|
||||
class Pipeline(BaseModel):
|
||||
|
||||
def __init__(self, name, unique_id):
|
||||
def __init__(self, name, unique_id, **kwargs):
|
||||
self.name = name
|
||||
self.unique_id = unique_id
|
||||
self.description = ""
|
||||
self.description = kwargs.get('description', '')
|
||||
self.pipeline_id = get_random_pipeline_id()
|
||||
self.creation_time = datetime.datetime.utcnow()
|
||||
self.objects = []
|
||||
self.status = "PENDING"
|
||||
self.tags = kwargs.get('tags', [])
|
||||
|
||||
@property
|
||||
def physical_resource_id(self):
|
||||
@ -78,8 +79,7 @@ class Pipeline(BaseModel):
|
||||
}],
|
||||
"name": self.name,
|
||||
"pipelineId": self.pipeline_id,
|
||||
"tags": [
|
||||
]
|
||||
"tags": self.tags
|
||||
}
|
||||
|
||||
def set_pipeline_objects(self, pipeline_objects):
|
||||
@ -113,8 +113,8 @@ class DataPipelineBackend(BaseBackend):
|
||||
def __init__(self):
|
||||
self.pipelines = {}
|
||||
|
||||
def create_pipeline(self, name, unique_id):
|
||||
pipeline = Pipeline(name, unique_id)
|
||||
def create_pipeline(self, name, unique_id, **kwargs):
|
||||
pipeline = Pipeline(name, unique_id, **kwargs)
|
||||
self.pipelines[pipeline.pipeline_id] = pipeline
|
||||
return pipeline
|
||||
|
||||
@ -129,6 +129,9 @@ class DataPipelineBackend(BaseBackend):
|
||||
def get_pipeline(self, pipeline_id):
|
||||
return self.pipelines[pipeline_id]
|
||||
|
||||
def delete_pipeline(self, pipeline_id):
|
||||
self.pipelines.pop(pipeline_id, None)
|
||||
|
||||
def put_pipeline_definition(self, pipeline_id, pipeline_objects):
|
||||
pipeline = self.get_pipeline(pipeline_id)
|
||||
pipeline.set_pipeline_objects(pipeline_objects)
|
||||
|
@ -21,9 +21,11 @@ class DataPipelineResponse(BaseResponse):
|
||||
return datapipeline_backends[self.region]
|
||||
|
||||
def create_pipeline(self):
|
||||
name = self.parameters['name']
|
||||
unique_id = self.parameters['uniqueId']
|
||||
pipeline = self.datapipeline_backend.create_pipeline(name, unique_id)
|
||||
name = self.parameters.get('name')
|
||||
unique_id = self.parameters.get('uniqueId')
|
||||
description = self.parameters.get('description', '')
|
||||
tags = self.parameters.get('tags', [])
|
||||
pipeline = self.datapipeline_backend.create_pipeline(name, unique_id, description=description, tags=tags)
|
||||
return json.dumps({
|
||||
"pipelineId": pipeline.pipeline_id,
|
||||
})
|
||||
@ -48,6 +50,11 @@ class DataPipelineResponse(BaseResponse):
|
||||
]
|
||||
})
|
||||
|
||||
def delete_pipeline(self):
|
||||
pipeline_id = self.parameters["pipelineId"]
|
||||
self.datapipeline_backend.delete_pipeline(pipeline_id)
|
||||
return json.dumps({})
|
||||
|
||||
def put_pipeline_definition(self):
|
||||
pipeline_id = self.parameters["pipelineId"]
|
||||
pipeline_objects = self.parameters["pipelineObjects"]
|
||||
|
@ -136,6 +136,19 @@ def test_activate_pipeline():
|
||||
get_value_from_fields('@pipelineState', fields).should.equal("SCHEDULED")
|
||||
|
||||
|
||||
@mock_datapipeline_deprecated
|
||||
def test_delete_pipeline():
|
||||
conn = boto.datapipeline.connect_to_region("us-west-2")
|
||||
res = conn.create_pipeline("mypipeline", "some-unique-id")
|
||||
pipeline_id = res["pipelineId"]
|
||||
|
||||
conn.delete_pipeline(pipeline_id)
|
||||
|
||||
response = conn.list_pipelines()
|
||||
|
||||
response["pipelineIdList"].should.have.length_of(0)
|
||||
|
||||
|
||||
@mock_datapipeline_deprecated
|
||||
def test_listing_pipelines():
|
||||
conn = boto.datapipeline.connect_to_region("us-west-2")
|
||||
|
Loading…
Reference in New Issue
Block a user