Exemplo n.º 1
0
def lambda_handler(event, context):
    api = LambdaAPI("Saving chirp", "https://my-server/api-errors", event, context)
    api.set_root_logging_level(10)
    api.log_initial_status()
    chirp_service = ChirpService()

    try:
        api.except_on_missing_value([["body-json", "chirp-text"]])

        text = api.fetch_value(["body-json", "chirp-text"])
        key = chirp_service.save(text)

        return api.api_success(key)

    except Exception as exception:
        api.convert_exception_to_error_response(exception)
Exemplo n.º 2
0
def lambda_handler(event, context):
    api = LambdaAPI("Creating image location", "https://my-server/api-errors",
                    event, context)
    api.set_root_logging_level(10)
    api.log_initial_status()
    chirp_service = ChirpService()

    try:
        api.except_on_missing_value([])

        location = chirp_service.create_image_location()

        return api.api_success(location)

    except Exception as exception:
        api.convert_exception_to_error_response(exception)
Exemplo n.º 3
0
def lambda_handler(event, context):
    api = LambdaAPI("Creating image location", "https://my-server/api-errors", event, context)
    api.set_root_logging_level(10)
    api.log_initial_status()
    chirp_service = ChirpService()


    try:
        api.except_on_missing_value([
        ])

        location = chirp_service.create_image_location()

        return api.api_success(location)

    except Exception as exception:
        api.convert_exception_to_error_response(exception)
Exemplo n.º 4
0
def lambda_handler(event, context):
    api = LambdaAPI("Saving chirp", "https://my-server/api-errors", event,
                    context)
    api.set_root_logging_level(10)
    api.log_initial_status()
    chirp_service = ChirpService()

    try:
        api.except_on_missing_value([['body-json', 'chirp-text']])

        text = api.fetch_value(['body-json', 'chirp-text'])
        key = chirp_service.save(text)

        return api.api_success(key)

    except Exception as exception:
        api.convert_exception_to_error_response(exception)
Exemplo n.º 5
0
def lambda_handler(event, context):
    api = LambdaAPI("Fetching chirps", "https://my-server/api-errors", event,
                    context)
    api.set_root_logging_level(10)
    api.log_initial_status()
    chirp_service = ChirpService()

    try:
        api.except_on_missing_value([])

        chirps = chirp_service.fetch_list()

        # Always get the last ten at most
        chirps = chirps[-10:]

        return api.api_success(chirps)

    except Exception as exception:
        api.convert_exception_to_error_response(exception)
Exemplo n.º 6
0
def lambda_handler(event, context):
    api = LambdaAPI("Fetching chirps", "https://my-server/api-errors", event, context)
    api.set_root_logging_level(10)
    api.log_initial_status()
    chirp_service = ChirpService()


    try:
        api.except_on_missing_value([
        ])

        chirps = chirp_service.fetch_list()

        # Always get the last ten at most
        chirps = chirps[-10:]

        return api.api_success(chirps)

    except Exception as exception:
        api.convert_exception_to_error_response(exception)