imednet.core.endpoint package
Subpackages
- imednet.core.endpoint.mixins package
- Submodules
- imednet.core.endpoint.mixins.caching module
- imednet.core.endpoint.mixins.get module
- imednet.core.endpoint.mixins.list module
- imednet.core.endpoint.mixins.params module
- imednet.core.endpoint.mixins.parsing module
- Module contents
- imednet.core.endpoint.operations package
Submodules
imednet.core.endpoint.abc module
Abstract base class for all API endpoints.
- class imednet.core.endpoint.abc.EndpointABC(*args, **kwargs)[source]
Bases:
ABC,ClientProvider,Generic[T]Abstract base class defining the contract for all API endpoints.
This ensures that all endpoint implementations provide necessary properties like PATH and MODEL, and implement core path building logic.
- abstract property MODEL: Type[T]
The model class associated with this endpoint.
- abstract property PATH: str
The relative path for the endpoint.
- property requires_study_key: bool
Whether this endpoint requires a study key. Defaults to True. Override in subclasses if needed.
imednet.core.endpoint.base module
Base endpoint mix-in for all API resource endpoints.
- class imednet.core.endpoint.base.GenericEndpoint(client, ctx, async_client=None)[source]
Bases:
EndpointABC[T]Generic base for endpoint wrappers.
Handles context injection and basic path building. Does NOT include EDC-specific logic.
- Parameters:
client (RequestorProtocol) –
ctx (Context) –
async_client (Optional[AsyncRequestorProtocol]) –
- BASE_PATH = ''
- class imednet.core.endpoint.base.GenericListGetEndpoint(client, ctx, async_client=None)[source]
Bases:
GenericEndpoint[T],ListEndpointMixin[T],FilterGetEndpointMixin[T]Generic base for endpoints that provide list and get-by-filter functionality.
Combines GenericEndpoint with ListEndpointMixin and FilterGetEndpointMixin to provide standard CRUD read operations.
- Parameters:
client (RequestorProtocol) –
ctx (Context) –
async_client (Optional[AsyncRequestorProtocol]) –
imednet.core.endpoint.edc_mixin module
Mixin for EDC-specific endpoint logic.
imednet.core.endpoint.protocols module
imednet.core.endpoint.strategies module
Parameter processing strategies for endpoints.
This module implements the ParamProcessor strategy pattern, allowing endpoints to customize how filters are processed and special parameters are extracted.
- class imednet.core.endpoint.strategies.DefaultParamProcessor(*args, **kwargs)[source]
Bases:
ParamProcessorDefault parameter processor.
Simply passes filters through without modification.
- class imednet.core.endpoint.strategies.KeepStudyKeyStrategy(exception_cls=<class 'imednet.errors.client.ClientError'>)[source]
Bases:
objectStrategy that requires a study key and keeps it in the filters.
Used when the API expects ‘studyKey’ as a query parameter.
- Parameters:
exception_cls (Type[Exception]) –
- process(filters)[source]
Extract study key, validate presence, and keep in filters.
- Parameters:
filters (
Dict[str,Any]) – The filters dictionary.- Return type:
Tuple[Optional[str],Dict[str,Any]]- Returns:
Tuple of (study_key, filters).
- Raises:
Exception – If study key is missing (type determined by exception_cls).
- class imednet.core.endpoint.strategies.MappingParamProcessor(mapping, defaults=None)[source]
Bases:
ParamProcessorParamProcessor that maps specific filter keys to API parameters.
Extracts keys defined in the mapping and returns them as special parameters, optionally renaming them according to the mapping values.
- Parameters:
mapping (Dict[str, str]) –
defaults (Dict[str, Any] | None) –
- class imednet.core.endpoint.strategies.OptionalStudyKeyStrategy[source]
Bases:
objectStrategy that allows the study key to be optional.
If present, it is kept in the filters.
- class imednet.core.endpoint.strategies.PopStudyKeyStrategy(exception_cls=<class 'imednet.errors.client.ClientError'>)[source]
Bases:
objectStrategy that requires a study key but removes it from the filters.
Used when the study key is part of the path or handled separately, not sent as a query parameter.
- Parameters:
exception_cls (Type[Exception]) –
- process(filters)[source]
Extract study key, validate presence, and remove from filters.
- Parameters:
filters (
Dict[str,Any]) – The filters dictionary.- Return type:
Tuple[Optional[str],Dict[str,Any]]- Returns:
Tuple of (study_key, modified_filters).
- Raises:
Exception – If study key is missing (type determined by exception_cls).
imednet.core.endpoint.structs module
- class imednet.core.endpoint.structs.ListRequestState(path, params, study, has_filters, cache, cached_result=None)[source]
Bases:
Generic[T]Encapsulates the state required to execute a list request.
- Parameters:
path (str) –
params (Dict[str, Any]) –
study (str | None) –
has_filters (bool) –
cache (Any) –
cached_result (List[T] | None) –
- cached_result
The result from cache, if any.
- path
The API path for the request.
- params
The query parameters.
- study
The study key.
- has_filters
Whether filters other than study key are present.
- cache
The cache object used for this request.
-
cache:
Any
-
cached_result:
Optional[List[TypeVar(T, bound=JsonModel)]] = None
-
has_filters:
bool
-
params:
Dict[str,Any]
-
path:
str
-
study:
Optional[str]
- class imednet.core.endpoint.structs.ParamState(study, params, other_filters)[source]
Bases:
objectEncapsulates the state of resolved parameters for an endpoint request.
- Parameters:
study (str | None) –
params (Dict[str, Any]) –
other_filters (Dict[str, Any]) –
- study
The study key, if applicable.
- params
The dictionary of query parameters.
- other_filters
Remaining filters after study key extraction.
-
other_filters:
Dict[str,Any]
-
params:
Dict[str,Any]
-
study:
Optional[str]
Module contents
Core endpoint abstractions and mixins.
- class imednet.core.endpoint.FilterGetEndpointMixin(*args, **kwargs)[source]
Bases:
EndpointABC[T]Mixin implementing
getvia filtering.- ASYNC_PAGINATOR_CLS
alias of
AsyncPaginator
- class imednet.core.endpoint.ListEndpointMixin(*args, **kwargs)[source]
Bases:
ParamMixin,CacheMixin,ParsingMixin[T],EndpointABC[T]Mixin implementing
listhelpers.- ASYNC_PAGINATOR_CLS
alias of
AsyncPaginator
- PAGE_SIZE: int = 100
- async async_list(study_key=None, **filters)[source]
List items asynchronously.
- Return type:
List[TypeVar(T, bound=JsonModel)]- Parameters:
study_key (str | None) –
filters (Any) –
- async async_list_by_attribute(attr_name, target_value, study_key=None, **filters)[source]
Asynchronously list items filtered by a specific attribute.
- Return type:
List[TypeVar(T, bound=JsonModel)]- Parameters:
attr_name (str) –
target_value (Any) –
study_key (str | None) –
filters (Any) –
- class imednet.core.endpoint.ParsingMixin[source]
Bases:
Generic[T]Mixin implementing model parsing helpers.
-
MODEL:
Type[TypeVar(T, bound=JsonModel)]
-
MODEL:
- class imednet.core.endpoint.PathGetEndpointMixin(*args, **kwargs)[source]
Bases:
ParsingMixin[T],EndpointABC[T]Mixin implementing
getvia direct path.