tlc.service.object_service
¶
The 3LC Object Service.
Module Contents¶
Classes¶
Class |
Description |
---|---|
Constants for the Litestar state. |
|
In-flight representation of a TLCObject. |
|
TLC patch request. |
|
In-flight representation of a patch request for a TLCObject. |
|
A context manager for rollback object creation without interfering with InsufficientCredits. |
|
A middleware that may serve 304 not modified responses based on ETag headers. |
|
Middleware to activate JWT on API key |
|
Controller for all object-related routes |
|
Controller for all external data-related routes |
|
Custom middleware to log object service requests and responses. |
|
Helper class to format output from NGrokHelper for the Object Service. |
Functions¶
Function |
Description |
---|---|
Catch-all for application errors. |
|
Handler for insufficient credits. |
|
Setup HTTP client for connecting to 3LC Data Service |
|
Perform any required cleanup before terminating the application |
|
Root endpoint of the service |
|
Returns status of the service |
|
Returns status of the service |
|
Data¶
Data |
Description |
---|---|
API¶
- class tlc.service.object_service.LitestarStateConstants¶
Constants for the Litestar state.
- HOST_IP = HostIP¶
- OBJECT_SERVICE_RUNNING_URLS = ObjectServiceRunningsURLs¶
- NGROK_OBJECT_SERVICE_URL = NGrokObjectServiceURL¶
- tlc.service.object_service.internal_server_error_handler(request: litestar.Request, exception: Exception) litestar.Response ¶
Catch-all for application errors.
- tlc.service.object_service.insufficient_credits_handler(request: litestar.Request, exception: tlcsaas.transaction.InsufficientCredits) litestar.Response ¶
Handler for insufficient credits.
- class tlc.service.object_service.TLCObject(/, **data: typing.Any)¶
Bases:
pydantic.BaseModel
In-flight representation of a TLCObject.
Create a new model by parsing and validating input data from keyword arguments.
Raises [
ValidationError
][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.self
is explicitly positional-only to allowself
as a field name.- model_config = ConfigDict(...)¶
- class tlc.service.object_service.TLCPatchOptions(/, **data: typing.Any)¶
Bases:
pydantic.BaseModel
TLC patch request.
Create a new model by parsing and validating input data from keyword arguments.
Raises [
ValidationError
][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.self
is explicitly positional-only to allowself
as a field name.- model_config = ConfigDict(...)¶
- class tlc.service.object_service.TLCPatchRequest(/, **data: typing.Any)¶
Bases:
pydantic.BaseModel
In-flight representation of a patch request for a TLCObject.
Create a new model by parsing and validating input data from keyword arguments.
Raises [
ValidationError
][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.self
is explicitly positional-only to allowself
as a field name.- patch_object: tlc.service.object_service.TLCObject = None¶
- patch_options: tlc.service.object_service.TLCPatchOptions = TLCPatchOptions(...)¶
- model_config = ConfigDict(...)¶
- class tlc.service.object_service.RollbackDeleteContext(url: tlc.core.url.Url)¶
A context manager for rollback object creation without interfering with InsufficientCredits.
- async tlc.service.object_service.startup(app: litestar.Litestar) None ¶
Setup HTTP client for connecting to 3LC Data Service
- async tlc.service.object_service.shutdown(app: litestar.Litestar) None ¶
Perform any required cleanup before terminating the application
- async tlc.service.object_service.root() litestar.Response ¶
Root endpoint of the service
- class tlc.service.object_service.ObjectServiceFeatures(/, **data: typing.Any)¶
Bases:
pydantic.BaseModel
- class tlc.service.object_service.ObjectServiceUserInfo(/, **data: typing.Any)¶
Bases:
pydantic.BaseModel
- class tlc.service.object_service.DashboardAnnotations(/, **data: typing.Any)¶
Bases:
pydantic.BaseModel
- async tlc.service.object_service.status(request: litestar.Request) dict[str, Any] ¶
Returns status of the service
- class tlc.service.object_service.ETagMiddleware(app: litestar.types.ASGIApp, **kwargs: Any)¶
Bases:
litestar.middleware.MiddlewareProtocol
A middleware that may serve 304 not modified responses based on ETag headers.
Only affects endpoints/responses that have previously been served with ETag. Other requests are passed through.
If the request contains an If-None-Match header with the same ETag as the previous response, a 304 Not Modified response is returned.
- class tlc.service.object_service.JwtAuthenticationMiddleware(app: litestar.types.ASGIApp, exclude: str | list[str] | None = None, exclude_from_auth_key: str = 'exclude_from_auth', exclude_http_methods: Sequence[litestar.types.Method] | None = None, scopes: litestar.types.Scopes | None = None)¶
Bases:
litestar.middleware.authentication.AbstractAuthenticationMiddleware
- async authenticate_request(connection: litestar.connection.ASGIConnection) litestar.middleware.authentication.AuthenticationResult ¶
- class tlc.service.object_service.ActivateJwtOnApiKeyMiddleware(app: litestar.types.asgi_types.ASGIApp, exclude: str | list[str] | None = None, exclude_opt_key: str | None = None, scopes: litestar.types.Scopes | None = None)¶
Bases:
litestar.middleware.base.AbstractMiddleware
Middleware to activate JWT on API key
Initialize the middleware.
Args: app: The
next
ASGI app to call. exclude: A pattern or list of patterns to match against a request’s path. If a match is found, the middleware will be skipped. exclude_opt_key: An identifier that is set in the route handleropt
key which allows skipping the middleware. scopes: ASGI scope types, should be a set including either or both ‘ScopeType.HTTP’ and ‘ScopeType.WEBSOCKET’.
- class tlc.service.object_service.ObjectRoutesController(owner: litestar.router.Router)¶
Bases:
litestar.controller.Controller
Controller for all object-related routes
Initialize a controller.
Should only be called by routers as part of controller registration.
Args: owner: An instance of :class:
Router <.router.Router>
- path = /objects¶
- cache_time_out = resolve_cache_timeout(...)¶
- async get_encoded_url(encoded_url: str, request: litestar.Request) litestar.Response[tlc.service.object_service.TLCObject] ¶
- async get_encoded_url_rows(encoded_url: str, attribute: str, request: litestar.Request) litestar.Response[bytes] ¶
- async list_urls() list[str] ¶
Return all the objects.
Returns: list[Any]: List of the URLs of all the objects.
- async new_object(data: tlc.service.object_service.TLCObject) litestar.Response ¶
Create a new object.
- Parameters:
data – Object to be created
- Returns:
Empty response. URL of the created object will be in the ‘Location’ field of the response headers.
- async delete_object(encoded_url: str) None ¶
Delete an object.
- Parameters:
encoded_url – URL of the object to be deleted.
- Raises:
HTTPException if no object can be found at the URL.
- async update_object(encoded_url: str, data: tlc.service.object_service.TLCPatchRequest) litestar.Response ¶
Update the attributes of an object.
Raises: HTTPException: If the object type of
obj_in
does not match the type of the object atobject_url
.
- class tlc.service.object_service.ExternalDataRoutesController(owner: litestar.router.Router)¶
Bases:
litestar.controller.Controller
Controller for all external data-related routes
Initialize a controller.
Should only be called by routers as part of controller registration.
Args: owner: An instance of :class:
Router <.router.Router>
- path = /external_data¶
- cache_time_out = resolve_cache_timeout(...)¶
- async post_encoded_url(request: litestar.Request, owner_url: str, base_name: str, extension: str) litestar.Response ¶
Write a new file with given binary contents.
- Parameters:
request – The request object.
owner_url – The URL of the tlc Object that owns the file. Currently only support Table owners, data will be written in the table’s bulk data folder.
base_name – The base name of the file or folder to be created. Used to provide more context to the filename.
extension – The extension of the file.
- Returns:
A response with a 201 status code and a Location header pointing to the newly created file.
- class tlc.service.object_service.TLCCustomLoggingMiddleware(app: litestar.types.ASGIApp, config: litestar.middleware.logging.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.
- class tlc.service.object_service.NGrokOutputAdaptor(role: str, ngrok_helper: tlccli.subcommands.ngrok_helper.NGrokHelper)¶
Helper class to format output from NGrokHelper for the Object Service.
- tlc.service.object_service.T = TypeVar(...)¶
- tlc.service.object_service.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.Litestar ¶