# Path: aiobotocore/eventstream.py
# class AioEventStream(EventStream):
#     async def _create_raw_event_generator(self):
#         event_stream_buffer = EventStreamBuffer()
#         async for chunk, _ in self._raw_stream.iter_chunks():
#             event_stream_buffer.add_data(chunk)
#             for event in event_stream_buffer:
#                 yield event
# 
#     def __iter__(self):
#         raise NotImplementedError('Use async-for instead')
# 
#     def __aiter__(self):
#         return self.__anext__()
# 
#     async def __anext__(self):
#         async for event in self._event_generator:
#             parsed_event = self._parse_event(event)
#             if parsed_event:
#                 yield parsed_event
# 
#     async def get_initial_response(self):
#         try:
#             async for event in self._event_generator:
#                 event_type = event.headers.get(':event-type')
#                 if event_type == 'initial-response':
#                     return event
# 
#                 break
#         except StopIteration:
#             pass
#         raise NoInitialResponseError()


from botocore.parsers import ResponseParserFactory, RestXMLParser, \
    RestJSONParser, JSONParser, QueryParser, EC2QueryParser, \
    NoInitialResponseError, ResponseParserError, LOG, lowercase_dict
from .eventstream import AioEventStream
                parsed = self._do_modeled_error_parse(response, shape)
                # We don't want to decorate the modeled fields with metadata
                return parsed
            else:
                parsed = self._do_error_parse(response, shape)
        else:
            parsed = await self._do_parse(response, shape)

        # We don't want to decorate event stream responses with metadata
        if shape and shape.serialization.get('eventstream'):
            return parsed

        # Add ResponseMetadata if it doesn't exist and inject the HTTP
        # status code and headers from the response.
        if isinstance(parsed, dict):
            response_metadata = parsed.get('ResponseMetadata', {})
            response_metadata['HTTPStatusCode'] = response['status_code']
            # Ensure that the http header keys are all lower cased. Older
            # versions of urllib3 (< 1.11) would unintentionally do this for us
            # (see urllib3#633). We need to do this conversion manually now.
            headers = response['headers']
            response_metadata['HTTPHeaders'] = lowercase_dict(headers)
            parsed['ResponseMetadata'] = response_metadata
        return parsed


class AioRestJSONParser(RestJSONParser):
    def _create_event_stream(self, response, shape):
        parser = self._event_stream_parser
        name = response['context'].get('operation_name')

# Path: aiobotocore/eventstream.py
# class AioEventStream(EventStream):
#     async def _create_raw_event_generator(self):
#         event_stream_buffer = EventStreamBuffer()
#         async for chunk, _ in self._raw_stream.iter_chunks():
#             event_stream_buffer.add_data(chunk)
#             for event in event_stream_buffer:
#                 yield event
# 
#     def __iter__(self):
#         raise NotImplementedError('Use async-for instead')
# 
#     def __aiter__(self):
#         return self.__anext__()
# 
#     async def __anext__(self):
#         async for event in self._event_generator:
#             parsed_event = self._parse_event(event)
#             if parsed_event:
#                 yield parsed_event
# 
#     async def get_initial_response(self):
#         try:
#             async for event in self._event_generator:
#                 event_type = event.headers.get(':event-type')
#                 if event_type == 'initial-response':
#                     return event
# 
#                 break
#         except StopIteration:
#             pass
#         raise NoInitialResponseError()


# Path: aiobotocore/parsers.py
from botocore.parsers import ResponseParserFactory, RestXMLParser, \
    RestJSONParser, JSONParser, QueryParser, EC2QueryParser, \
    NoInitialResponseError, ResponseParserError, LOG, lowercase_dict
from .eventstream import AioEventStream

                parsed = self._do_modeled_error_parse(response, shape)
                # We don't want to decorate the modeled fields with metadata
                return parsed
            else:
                parsed = self._do_error_parse(response, shape)
        else:
            parsed = await self._do_parse(response, shape)

        # We don't want to decorate event stream responses with metadata
        if shape and shape.serialization.get('eventstream'):
            return parsed

        # Add ResponseMetadata if it doesn't exist and inject the HTTP
        # status code and headers from the response.
        if isinstance(parsed, dict):
            response_metadata = parsed.get('ResponseMetadata', {})
            response_metadata['HTTPStatusCode'] = response['status_code']
            # Ensure that the http header keys are all lower cased. Older
            # versions of urllib3 (< 1.11) would unintentionally do this for us
            # (see urllib3#633). We need to do this conversion manually now.
            headers = response['headers']
            response_metadata['HTTPHeaders'] = lowercase_dict(headers)
            parsed['ResponseMetadata'] = response_metadata
        return parsed


class AioRestJSONParser(RestJSONParser):
    def _create_event_stream(self, response, shape):
        parser = self._event_stream_parser
        name = response['context'].get('operation_name')

        return AioEventStream(response['body'], shape, parser, name)