Repository: localstack/localstack

Issue:
ses delete template feature is not implemented
# Type of request: This is a ...

[x] feature request

# Detailed description

Whenever we try to do delete template operation through AWS java SDK it is throwing 500 error with null message
AWS SDK version: version: 1.11.327

## Expected behavior

delete template operation should work properly deleting given template

## Actual behavior

Delete template operation is throwing 500 exception with null message
com.amazonaws.services.simpleemail.model.AmazonSimpleEmailServiceException: null (Service: AmazonSimpleEmailService; Status Code: 500; Error Code: 500 ; Request ID: null)

or through command line it is giving

Unable to parse response (syntax error: line 1, column 54), invalid XML received. Further retries may succeed:
b'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">\n<title xmlns="http://ses.amazonaws.com/doc/2010-01-31/">500 Internal Server Error</title>\n<h1>Internal Server Error</h1>\n<p>The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.</p>\n'

# Steps to reproduce

1. use AWS java SDK in java project
2. make localstack up using docker latest image
3. perform delete template operation on already created template

## Command used to start LocalStack

docker run --env SERVICES=ses -p 4566:4566 localstack/localstack

## Client code 

val client: AmazonSimpleEmailService = AmazonSimpleEmailServiceClientBuilder.standard()
            .withEndpointConfiguration(endpoint).build()
val deleteTemplateResult = client.deleteTemplate(deleteTemplatesRequest)

 OR through the command line

 aws ses delete-template --template-name on_demand_template --region=us-east-1 --endpoint-url=http://localhost:4566



Discussion:

Resolving patch:
diff --git a/localstack/services/ses/ses_starter.py b/localstack/services/ses/ses_starter.py
--- a/localstack/services/ses/ses_starter.py
+++ b/localstack/services/ses/ses_starter.py
@@ -81,6 +81,23 @@ def list_templates(self):
 
     email_responses.list_templates = list_templates
 
+    def delete_template(self):
+        template_name = self._get_param('TemplateName')
+        templates = ses_backend.templates
+        if template_name in templates:
+            del templates[template_name]
+        ses_backend.templates = templates
+        DELETE_IDENTITY_RESPONSE = """<DeleteTemplateResponse xmlns="http://ses.amazonaws.com/doc/2010-12-01/">
+            <DeleteTemplateResult/>
+            <ResponseMetadata>
+              <RequestId>d96bd875-9bf2-11e1-8ee7-c98a0037a2b6</RequestId>
+            </ResponseMetadata>
+        </DeleteTemplateResponse>"""
+        template = self.response_template(DELETE_IDENTITY_RESPONSE)
+        return template.render()
+
+    email_responses.delete_template = delete_template
+
 
 def start_ses(port=None, backend_port=None, asynchronous=None, update_listener=None):
     port = port or config.PORT_SES


Test patch:
diff --git a/tests/integration/test_ses.py b/tests/integration/test_ses.py
--- a/tests/integration/test_ses.py
+++ b/tests/integration/test_ses.py
@@ -28,3 +28,12 @@ def test_list_templates(self):
         created_template = templ_list[0]
         self.assertEqual(created_template['Name'], TEST_TEMPLATE_ATTRIBUTES['TemplateName'])
         self.assertIn(type(created_template['CreatedTimestamp']), (date, datetime))
+
+    def test_delete_template(self):
+        client = aws_stack.connect_to_service('ses')
+        client.create_template(Template=TEST_TEMPLATE_ATTRIBUTES)
+        templ_list = client.list_templates()['TemplatesMetadata']
+        self.assertEqual(1, len(templ_list))
+        client.delete_template(TemplateName=TEST_TEMPLATE_ATTRIBUTES['TemplateName'])
+        templ_list = client.list_templates()['TemplatesMetadata']
+        self.assertEqual(0, len(templ_list))