Skip to content
This repository has been archived by the owner on Nov 9, 2022. It is now read-only.

Commit

Permalink
remove dynamo table from tested resources
Browse files Browse the repository at this point in the history
  • Loading branch information
BryanCrotaz committed Jan 20, 2016
1 parent 20292de commit 37e6575
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 91 deletions.
23 changes: 5 additions & 18 deletions lib/commands/ApiMethod.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,11 @@ pub.createResource = function createResource(event, context, eventParams, callba
};

pub.deleteResource = function deleteResource(event, context, eventParams, callback) {
CloudFormationResourceTracker.get(event, context, function (getError, data) {
if (getError) {
return callback(getError);
}
if (data) {
ApiMethodService.deleteMethod(eventParams.params.restApiId, eventParams.params.resourceId, event.PhysicalResourceId, function (deleteError) {
if (deleteError) {
return callback(deleteError);
}
CloudFormationResourceTracker.delete(event, context, function (error) {
return callback(error);
});
});
} else {
return callback();
ApiMethodService.deleteMethod(eventParams.params.restApiId, eventParams.params.resourceId, event.PhysicalResourceId, function (deleteError) {
if (deleteError) {
return callback(deleteError);
}
return callback(error);
});
};

Expand All @@ -57,8 +46,6 @@ function getForResponse(event, context, restApiId, resourceId, httpMethod, callb
return callback(getError);
}
apiMethod.physicalResourceId = resourceId + '/' + httpMethod;
CloudFormationResourceTracker.put(event, context, httpMethod, function (error) {
return callback(error, apiMethod);
});
return callback(error, apiMethod);
});
}
60 changes: 18 additions & 42 deletions lib/commands/ApiResource.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
var ApiResourceService = require('../service/ApiResource/ApiResourceService');
var ApiResourceEvent = require('../service/ApiResource/ApiResourceEvent');
var CorsService = require('../service/Cors/CorsService');
var CloudFormationResourceTracker = require('../service/CloudFormationResourceTracker');
var logger = require('../service/util/logger');

var pub = {};
Expand All @@ -23,53 +22,32 @@ pub.createResource = function createResource(event, context, eventParams, callba
};

pub.deleteResource = function deleteResource(event, context, eventParams, callback) {
CloudFormationResourceTracker.get(event, context, function (getError, apiResourceEntry) {
if (getError) {
return callback(getError);
}
if (apiResourceEntry) {
ApiResourceService.deleteResource(event.PhysicalResourceId, eventParams.params.restApiId, function (deleteError) {
if (deleteError) {
return callback(deleteError);
}
CloudFormationResourceTracker.delete(event, context, function (error) {
return callback(error);
});
});
} else {
logger.log('API Resource not found, returning');
return callback();
ApiResourceService.deleteResource(event.PhysicalResourceId, eventParams.params.restApiId, function (deleteError) {
if (deleteError) {
return callback(deleteError);
}
return callback(error);
});
};

/* eslint max-nested-callbacks: 0 */
pub.updateResource = function updateResource(event, context, eventParams, callback) {
CloudFormationResourceTracker.get(event, context, function (getError, apiResourceEntry) {
if (getError) {
return callback(getError);
ApiResourceService.patchResource(event.PhysicalResourceId, eventParams.params.restApiId, eventParams, function (patchError) {
if (patchError) {
return callback(patchError);
}
if (apiResourceEntry) {
ApiResourceService.patchResource(event.PhysicalResourceId, eventParams.params.restApiId, eventParams, function (patchError) {
if (patchError) {
return callback(patchError);
}

ApiResourceService.getForResponse(eventParams.params.restApiId, apiResourceEntry.resourceIdentifier, function (getForResponseError) {
if (getForResponseError) {
return callback(getForResponseError);
}
CorsService.updateCorsConfiguration(eventParams, apiResourceEntry.resourceIdentifier, function (corsError) {
if (corsError) {
return callback(corsError);
}
getForResponse(event, context, eventParams.params.restApiId, apiResourceEntry.resourceIdentifier, callback);
});
});
ApiResourceService.getForResponse(eventParams.params.restApiId, apiResourceEntry.resourceIdentifier, function (getForResponseError) {
if (getForResponseError) {
return callback(getForResponseError);
}
CorsService.updateCorsConfiguration(eventParams, apiResourceEntry.resourceIdentifier, function (corsError) {
if (corsError) {
return callback(corsError);
}
getForResponse(event, context, eventParams.params.restApiId, apiResourceEntry.resourceIdentifier, callback);
});
} else {
return callback('API Resource not found');
}
});
});
};

Expand All @@ -82,8 +60,6 @@ function getForResponse(event, context, restApiId, resourceId, callback) {
return callback(getError);
}
apiResource.physicalResourceId = apiResource.id;
CloudFormationResourceTracker.put(event, context, apiResource.id, function (error) {
return callback(error, apiResource);
});
return callback(error, apiResource);
});
}
40 changes: 9 additions & 31 deletions lib/commands/RestApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,40 +20,20 @@ pub.createResource = function createResource(event, context, eventParams, callba
};

pub.deleteResource = function deleteResource(event, context, _eventParams, callback) {
CloudFormationResourceTracker.get(event, context, function (getError, restApiEntry) {
if (getError) {
return callback(getError);
}
if (restApiEntry) {
RestApiService.deleteApi(event.PhysicalResourceId, function (deleteError) {
if (deleteError) {
return callback(deleteError);
}
CloudFormationResourceTracker.delete(event, context, function (error) {
return callback(error);
});
});
} else {
return callback();
RestApiService.deleteApi(event.PhysicalResourceId, function (deleteError) {
if (deleteError) {
return callback(deleteError);
}
return callback(error);
});
};

pub.updateResource = function updateResource(event, context, eventParams, callback) {
CloudFormationResourceTracker.get(event, context, function (error, restApiEntry) {
if (error) {
return callback(error);
}
if (restApiEntry) {
RestApiService.patchApi(event.PhysicalResourceId, eventParams, function (patchError, restApi) {
if (patchError) {
return callback(patchError);
}
getForResponse(event, context, restApi.id, callback);
});
} else {
return callback('Rest API not found');
RestApiService.patchApi(event.PhysicalResourceId, eventParams, function (patchError, restApi) {
if (patchError) {
return callback(patchError);
}
getForResponse(event, context, restApi.id, callback);
});
};

Expand All @@ -65,8 +45,6 @@ function getForResponse(event, context, restApiId, callback) {
return callback(getError);
}
restApi.physicalResourceId = restApi.id;
CloudFormationResourceTracker.put(event, context, restApi.id, function (error) {
return callback(error, restApi);
});
return callback(error, restApi);
});
}

0 comments on commit 37e6575

Please sign in to comment.