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. |
|
Request model for re-indexing operations. |
|
A context manager for rollback object creation without interfering with InsufficientCredits. |
|
A middleware that may serve 304 not modified responses based on ETag headers. |
|
Controller for all object-related routes |
|
Controller for all external data-related routes |
|
Controller for all settings-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. |
|
Handler for timestamp skew. |
|
Setup HTTP client for connecting to 3LC Data Service |
|
Perform any required cleanup before terminating the application |
|
Root endpoint of the service |
|
Endpoint for checking if the service is running. |
|
Returns status of the service |
|
Returns status of the service |
|
Data¶
Data |
Description |
---|---|
API¶
- class LitestarStateConstants¶
Constants for the Litestar state.
- HOST_IP = HostIP¶
- OBJECT_SERVICE_RUNNING_URLS = ObjectServiceRunningsURLs¶
- NGROK_OBJECT_SERVICE_URL = NGrokObjectServiceURL¶
- insufficient_credits_handler(
- request: Request,
- exception: tlcsaas.transaction.InsufficientCredits,
Handler for insufficient credits.
- timestamp_skew_handler(
- request: Request,
- exception: TimestampSkewException,
Handler for timestamp skew.
- class 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 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 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_options: TLCPatchOptions = TLCPatchOptions(...)¶
- model_config = ConfigDict(...)¶
- class ReindexRequest(
- /,
- **data: typing.Any,
Bases:
pydantic.BaseModel
Request model for re-indexing operations.
- Parameters:
force – Whether to force re-indexing to disregard the state of the current index timestamp files.
types – The types of objects to reindex. Defaults to “all”.
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 RollbackDeleteContext(
- url: Url,
A context manager for rollback object creation without interfering with InsufficientCredits.
- async shutdown(
- app: Litestar,
Perform any required cleanup before terminating the application
- class ObjectServiceFeatures(
- /,
- **data: typing.Any,
Bases:
pydantic.BaseModel
- class ObjectServiceUserInfo(
- /,
- **data: typing.Any,
Bases:
pydantic.BaseModel
- class DashboardAnnotations(
- /,
- **data: typing.Any,
Bases:
pydantic.BaseModel
- class 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 ObjectRoutesController(
- owner: 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 list_urls() list[str] ¶
Return all the objects.
Returns: list[Any]: List of the URLs of all the objects.
- async request_reindex(
- data: ReindexRequest,
Request a reindex operation.
- Parameters:
data – The reindex request parameters.
- Returns:
Response with status message.
- async new_object(
- data: TLCObject,
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,
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: TLCPatchRequest,
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 ExternalDataRoutesController(
- owner: 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( ) 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 SettingsRoutesController(
- owner: Router,
Bases:
litestar.controller.Controller
Controller for all settings-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 = /settings¶
- 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.
- class NGrokOutputAdaptor(
- role: str,
- ngrok_helper: tlccli.subcommands.ngrok_helper.NGrokHelper,
Helper class to format output from NGrokHelper for the Object Service.
- T = TypeVar(...)¶
- 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,