Added support for SSM delete_parameters

Signed-off-by: Ali Rizwan <ari@hellofresh.com>
This commit is contained in:
Ali Rizwan 2017-08-11 15:19:36 +02:00
parent 9ebcaf561e
commit d8b0df2bef
3 changed files with 45 additions and 0 deletions

View File

@ -52,6 +52,16 @@ class SimpleSystemManagerBackend(BaseBackend):
except KeyError: except KeyError:
pass pass
def delete_parameters(self, names):
result = []
for name in names:
try:
del self._parameters[name]
result.append(name)
except KeyError:
pass
return result
def get_all_parameters(self): def get_all_parameters(self):
result = [] result = []
for k, _ in self._parameters.items(): for k, _ in self._parameters.items():

View File

@ -26,6 +26,22 @@ class SimpleSystemManagerResponse(BaseResponse):
self.ssm_backend.delete_parameter(name) self.ssm_backend.delete_parameter(name)
return json.dumps({}) return json.dumps({})
def delete_parameters(self):
names = self._get_param('Names')
result = self.ssm_backend.delete_parameters(names)
response = {
'DeletedParameters': [],
'InvalidParameters': []
}
for name in names:
if name in result:
response['DeletedParameters'].append(name)
else:
response['InvalidParameters'].append(name)
return json.dumps(response)
def get_parameters(self): def get_parameters(self):
names = self._get_param('Names') names = self._get_param('Names')
with_decryption = self._get_param('WithDecryption') with_decryption = self._get_param('WithDecryption')

View File

@ -24,6 +24,25 @@ def test_delete_parameter():
response = client.get_parameters(Names=['test']) response = client.get_parameters(Names=['test'])
len(response['Parameters']).should.equal(0) len(response['Parameters']).should.equal(0)
@mock_ssm
def test_delete_parameters():
client = boto3.client('ssm', region_name='us-east-1')
client.put_parameter(
Name='test',
Description='A test parameter',
Value='value',
Type='String')
response = client.get_parameters(Names=['test'])
len(response['Parameters']).should.equal(1)
result = client.delete_parameters(Names=['test', 'invalid'])
len(result['DeletedParameters']).should.equal(1)
len(result['InvalidParameters']).should.equal(1)
response = client.get_parameters(Names=['test'])
len(response['Parameters']).should.equal(0)
@mock_ssm @mock_ssm
def test_put_parameter(): def test_put_parameter():