Add events.delete_event_bus
This commit is contained in:
parent
831577350d
commit
1d615e25b6
@ -2713,12 +2713,12 @@
|
||||
- [ ] upgrade_elasticsearch_domain
|
||||
|
||||
## events
|
||||
54% implemented
|
||||
58% implemented
|
||||
- [ ] activate_event_source
|
||||
- [X] create_event_bus
|
||||
- [ ] create_partner_event_source
|
||||
- [ ] deactivate_event_source
|
||||
- [ ] delete_event_bus
|
||||
- [X] delete_event_bus
|
||||
- [ ] delete_partner_event_source
|
||||
- [X] delete_rule
|
||||
- [X] describe_event_bus
|
||||
|
@ -354,6 +354,14 @@ class EventsBackend(BaseBackend):
|
||||
|
||||
return list(self.event_buses.values())
|
||||
|
||||
def delete_event_bus(self, name):
|
||||
if name == "default":
|
||||
raise JsonRESTError(
|
||||
"ValidationException", "Cannot delete event bus default."
|
||||
)
|
||||
|
||||
self.event_buses.pop(name, None)
|
||||
|
||||
|
||||
available_regions = boto3.session.Session().get_available_regions("events")
|
||||
events_backends = {region: EventsBackend(region) for region in available_regions}
|
||||
|
@ -296,3 +296,10 @@ class EventsHandler(BaseResponse):
|
||||
response.append(event_bus_response)
|
||||
|
||||
return json.dumps({"EventBuses": response}), self.response_headers
|
||||
|
||||
def delete_event_bus(self):
|
||||
name = self._get_param("Name")
|
||||
|
||||
self.events_backend.delete_event_bus(name)
|
||||
|
||||
return "", self.response_headers
|
||||
|
@ -283,7 +283,7 @@ def test_create_event_bus():
|
||||
@mock_events
|
||||
def test_create_event_bus_errors():
|
||||
client = boto3.client("events", "us-east-1")
|
||||
response = client.create_event_bus(Name="test-bus")
|
||||
client.create_event_bus(Name="test-bus")
|
||||
|
||||
client.create_event_bus.when.called_with(Name="test-bus").should.throw(
|
||||
ClientError, "Event bus test-bus already exists."
|
||||
@ -415,3 +415,37 @@ def test_list_event_buses():
|
||||
},
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
@mock_events
|
||||
def test_delete_event_bus():
|
||||
client = boto3.client("events", "us-east-1")
|
||||
client.create_event_bus(Name="test-bus")
|
||||
|
||||
response = client.list_event_buses()
|
||||
response["EventBuses"].should.have.length_of(2)
|
||||
|
||||
client.delete_event_bus(Name="test-bus")
|
||||
|
||||
response = client.list_event_buses()
|
||||
response["EventBuses"].should.have.length_of(1)
|
||||
response["EventBuses"].should.equal(
|
||||
[
|
||||
{
|
||||
"Name": "default",
|
||||
"Arn": "arn:aws:events:us-east-1:123456789012:event-bus/default",
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
# deleting non existing event bus should be successful
|
||||
client.delete_event_bus(Name="non-existing")
|
||||
|
||||
|
||||
@mock_events
|
||||
def test_delete_event_bus_errors():
|
||||
client = boto3.client("events", "us-east-1")
|
||||
|
||||
client.delete_event_bus.when.called_with(Name="default").should.throw(
|
||||
ClientError, "Cannot delete event bus default."
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user