# Path: e2e-test-server/e2e_test_server/constants.py
# PROJECT_ID = os.environ["PROJECT_ID"]
# 
# PUSH_PORT = (
#     os.environ["PUSH_PORT"]
#     if SUBSCRIPTION_MODE is SubscriptionMode.PUSH
#     else None
# )
# 
# REQUEST_SUBSCRIPTION_NAME = os.environ["REQUEST_SUBSCRIPTION_NAME"]
# 
# RESPONSE_TOPIC_NAME = os.environ["RESPONSE_TOPIC_NAME"]
# 
# SCENARIO = "scenario"
# 
# STATUS_CODE = "status_code"
# 
# TEST_ID = "test_id"


import base64
import logging
from typing import Literal
from google.cloud import pubsub_v1
from google.cloud.pubsub_v1.subscriber.message import Message
from google.rpc import code_pb2
from . import scenarios, types
from .constants import (
    PROJECT_ID,
    PUSH_PORT,
    REQUEST_SUBSCRIPTION_NAME,
    RESPONSE_TOPIC_NAME,
    SCENARIO,
    STATUS_CODE,
    TEST_ID,
)
    from flask import Flask, Response, request
    from waitress import serve
        return "ack"


def pubsub_pull() -> None:
    """Pull incoming pub/sub push messages on REQUEST_SUBSCRIPTION_NAME"""
    responder = _Responder()
    subscriber = pubsub_v1.SubscriberClient()
    subscription_path = subscriber.subscription_path(
        PROJECT_ID,
        REQUEST_SUBSCRIPTION_NAME,
    )

    def pubsub_callback(message: Message) -> None:
        ack_or_nack = handle_message(
            types.PubsubMessage(
                attributes=message.attributes, data=message.data
            ),
            responder,
        )
        if ack_or_nack == "ack":
            message.ack()
        else:
            message.nack()

    streaming_pull_future = subscriber.subscribe(
        subscription_path, callback=pubsub_callback
    )

    logger.info(
        "Listening on subscription {} for pub/sub messages".format(

# Path: e2e-test-server/e2e_test_server/constants.py
# PROJECT_ID = os.environ["PROJECT_ID"]
# 
# PUSH_PORT = (
#     os.environ["PUSH_PORT"]
#     if SUBSCRIPTION_MODE is SubscriptionMode.PUSH
#     else None
# )
# 
# REQUEST_SUBSCRIPTION_NAME = os.environ["REQUEST_SUBSCRIPTION_NAME"]
# 
# RESPONSE_TOPIC_NAME = os.environ["RESPONSE_TOPIC_NAME"]
# 
# SCENARIO = "scenario"
# 
# STATUS_CODE = "status_code"
# 
# TEST_ID = "test_id"


# Path: e2e-test-server/e2e_test_server/server.py
import base64
import logging
from typing import Literal
from google.cloud import pubsub_v1
from google.cloud.pubsub_v1.subscriber.message import Message
from google.rpc import code_pb2
from . import scenarios, types
from .constants import (
    PROJECT_ID,
    PUSH_PORT,
    REQUEST_SUBSCRIPTION_NAME,
    RESPONSE_TOPIC_NAME,
    SCENARIO,
    STATUS_CODE,
    TEST_ID,
)
    from flask import Flask, Response, request
    from waitress import serve

        return "ack"


def pubsub_pull() -> None:
    """Pull incoming pub/sub push messages on REQUEST_SUBSCRIPTION_NAME"""
    responder = _Responder()
    subscriber = pubsub_v1.SubscriberClient()
    subscription_path = subscriber.subscription_path(
        PROJECT_ID,
        REQUEST_SUBSCRIPTION_NAME,
    )

    def pubsub_callback(message: Message) -> None:
        ack_or_nack = handle_message(
            types.PubsubMessage(
                attributes=message.attributes, data=message.data
            ),
            responder,
        )
        if ack_or_nack == "ack":
            message.ack()
        else:
            message.nack()

    streaming_pull_future = subscriber.subscribe(
        subscription_path, callback=pubsub_callback
    )

    logger.info(
        "Listening on subscription {} for pub/sub messages".format(

            REQUEST_SUBSCRIPTION_NAME