tlc.service.object_service

The 3LC Object Service.

Module Contents

Classes

Class

Description

DashboardAnnotations

LitestarStateConstants

Constants for the Litestar state.

NGrokOutputAdaptor

Helper class to format output from NGrokHelper for the Object Service.

ObjectServiceFeatures

ObjectServiceUserInfo

TLCCustomLoggingMiddleware

Custom middleware to log object service requests and responses.

Functions

Function

Description

create_litestar_app

format_yaml_for_logging

get_ip_addresses

get_last_lru_stats

get_running_urls

get_status

Returns status of the service

insufficient_credits_handler

Handler for insufficient credits.

internal_server_error_handler

Catch-all for application errors.

live

Endpoint for checking if the service is running.

open_dashboard_in_web_browser

open_in_web_browser

root

Root endpoint of the service

shutdown

Perform any required cleanup before terminating the application

startup

Setup HTTP client for connecting to 3LC Data Service

status

Returns status of the service

timestamp_skew_handler

Handler for timestamp skew.

Data

Data

Description

T

last_lru_stats

API

class DashboardAnnotations(
/,
**data: typing.Any,
)

Bases: pydantic.BaseModel

banner_background_color: str = <Multiline-String>
banner_icon_url: str = <Multiline-String>
banner_message: str = <Multiline-String>
title_message: str = <Multiline-String>
class LitestarStateConstants

Constants for the Litestar state.

HOST_IP = HostIP
NGROK_OBJECT_SERVICE_URL = NGrokObjectServiceURL
OBJECT_SERVICE_RUNNING_URLS = ObjectServiceRunningsURLs
class NGrokOutputAdaptor(
role: str,
ngrok_helper: tlccli.subcommands.ngrok_helper.NGrokHelper,
)

Helper class to format output from NGrokHelper for the Object Service.

async output_public_url(
app: Litestar,
) None
class ObjectServiceFeatures(
/,
**data: typing.Any,
)

Bases: pydantic.BaseModel

post_external_data: bool = True
post_objects_multi_part: bool = True
class ObjectServiceUserInfo(
/,
**data: typing.Any,
)

Bases: pydantic.BaseModel

tenant_id: str = None
tenant_name: str = None
user_email: str = None
user_full_name: str = None
user_id: str = None
T = TypeVar(...)
class TLCCustomLoggingMiddleware(
app: litestar.types.ASGIApp,
config: LoggingMiddlewareConfig,
)

Bases: litestar.middleware.logging.LoggingMiddleware

Custom middleware to log object service requests and responses.

Logs request and response data to loglevel.INFO, together with the time it takes to complete the request.

Initialize LoggingMiddleware.

Args: app: The next ASGI app to call. config: An instance of LoggingMiddlewareConfig.

log_message(
values: dict[str, Any],
) None

Log a message.

This is a copy of the superclass’ method, with special case handling of the /status endpoint, and url decoding of the path.

Parameters:

values – Extract values to log.

Returns:

None

async log_request(
scope: litestar.types.Scope,
receive: litestar.types.Receive,
) None

Record the start time and log the request data.

log_response(
scope: litestar.types.Scope,
) None

Measure elapsed time and log the response data.

create_litestar_app(
host: str,
port: int,
use_ngrok: bool,
dashboard: bool = False,
after_startup_handler: list[litestar.types.callable_types.LifespanHook] | litestar.types.callable_types.LifespanHook | None = None,
after_shutdown_handler: list[litestar.types.callable_types.LifespanHook] | litestar.types.callable_types.LifespanHook | None = None,
) Litestar
format_yaml_for_logging(
data: dict | list,
indent: int = 4,
) str
get_ip_addresses() list[str]
get_last_lru_stats() dict[str, Any] | None
get_running_urls() list[str]
get_status() dict[str, Any]

Returns status of the service

insufficient_credits_handler(
request: Request,
exception: tlcsaas.transaction.InsufficientCredits,
) Response

Handler for insufficient credits.

internal_server_error_handler(
request: Request,
exception: Exception,
) Response

Catch-all for application errors.

last_lru_stats: dict[str, Any] | None = None
async live() Response

Endpoint for checking if the service is running.

open_dashboard_in_web_browser(
app: Litestar,
) None
open_in_web_browser(
url: str,
) None
async root() Response

Root endpoint of the service

async shutdown(
app: Litestar,
) None

Perform any required cleanup before terminating the application

async startup(
app: Litestar,
) None

Setup HTTP client for connecting to 3LC Data Service

async status(
request: Request,
) dict[str, Any]

Returns status of the service

timestamp_skew_handler(
request: Request,
exception: TimestampSkewException,
) Response

Handler for timestamp skew.