diff --git a/connect/eaas/core/proto.py b/connect/eaas/core/proto.py index 472c75d..5d253b7 100644 --- a/connect/eaas/core/proto.py +++ b/connect/eaas/core/proto.py @@ -56,11 +56,19 @@ class Logging(BaseModel): meta: Optional[LogMeta] +class EventDefinition(BaseModel): + event_type: str + api_resource_endpoint: str + api_collection_endpoint: str + api_collection_filter: str + + class SetupResponse(BaseModel): variables: Optional[dict] # delete after stop using version 1 environment_type: Optional[str] logging: Optional[Logging] + event_definitions: Optional[List[EventDefinition]] class Schedulable(BaseModel): diff --git a/tests/connect/eaas/core/test_proto.py b/tests/connect/eaas/core/test_proto.py index f8fe298..253eb3c 100644 --- a/tests/connect/eaas/core/test_proto.py +++ b/tests/connect/eaas/core/test_proto.py @@ -3,6 +3,7 @@ import pytest from connect.eaas.core.proto import ( + EventDefinition, Logging, LogMeta, Message, @@ -133,6 +134,7 @@ 'hub_id': None, }, }, + 'event_definitions': None, } SETUP_RESPONSE_DATA_V1 = { 'configuration': {'conf1': 'val1'}, @@ -396,3 +398,28 @@ def test_serialize_v2(msg_type, data): assert serialized['version'] == 2 assert serialized['message_type'] == msg_type assert serialized['data'] == data + + +def test_serialize_setup_response_with_events_definitions(): + data = copy.deepcopy(SETUP_RESPONSE_DATA) + data['event_definitions'] = [ + { + 'event_type': 'event_type', + 'api_resource_endpoint': 'api_resource_endpoint', + 'api_collection_endpoint': 'api_collection_endpoint', + 'api_collection_filter': 'api_collection_filter', + }, + ] + msg = Message( + version=2, + message_type=MessageType.SETUP_RESPONSE, + data=data, + ) + + assert isinstance(msg.data.event_definitions[0], EventDefinition) + + serialized = msg.serialize() + + assert serialized['version'] == 2 + assert serialized['message_type'] == MessageType.SETUP_RESPONSE + assert serialized['data'] == data