imednet.core.endpoint package

Core endpoint abstractions and protocols.

class imednet.core.endpoint.AsyncListGetEndpoint[source]

Bases: _ListGetEndpointBase[T]

__init__(async_client, ctx=None)[source]
Parameters:
Return type:

None

async async_get(study_key, item_id)[source]
Return type:

TypeVar(T, bound= JsonModel)

Parameters:
  • study_key (str | None) –

  • item_id (str | int) –

async async_list(study_key=None, **filters)[source]
Return type:

List[TypeVar(T, bound= JsonModel)]

Parameters:
  • study_key (str | None) –

  • filters (str | int | float | bool | None | Tuple[str, str | int | float | bool | None] | List[str | int | float | bool | None]) –

class imednet.core.endpoint.EdcAsyncListGetEndpoint[source]

Bases: _EdcEndpointBase, AsyncListGetEndpoint[T]

Async EDC list/get endpoint base.

BASE_PATH = '/api/v1/edc/studies'
imednet.core.endpoint.EdcGenericListGetEndpoint

alias of EdcSyncListGetEndpoint

class imednet.core.endpoint.EdcSyncListGetEndpoint[source]

Bases: _EdcEndpointBase, SyncListGetEndpoint[T]

Sync EDC list/get endpoint base.

BASE_PATH = '/api/v1/edc/studies'
class imednet.core.endpoint.GenericEndpoint[source]

Bases: EndpointABC[T]

Generic base for endpoint wrappers.

Handles context injection and basic path building. Does NOT include EDC-specific logic.

BASE_PATH = ''
__init__(client=None, ctx=None, async_client=None)[source]
Parameters:
Return type:

None

imednet.core.endpoint.GenericListGetEndpoint

alias of SyncListGetEndpoint

class imednet.core.endpoint.SupportsCreate[source]

Bases: Protocol[T_co]

Protocol for resources that support create operations.

__init__(*args, **kwargs)
async async_create(*args, **kwargs)[source]

Create an item asynchronously.

Return type:

TypeVar(T_co, covariant=True)

Parameters:
  • args (Any) –

  • kwargs (Any) –

create(*args, **kwargs)[source]

Create an item synchronously.

Return type:

TypeVar(T_co, covariant=True)

Parameters:
  • args (Any) –

  • kwargs (Any) –

class imednet.core.endpoint.SupportsGet[source]

Bases: Protocol[T_co]

Protocol for resources that support get operations.

__init__(*args, **kwargs)
async async_get(study_key, item_id)[source]

Get a single item asynchronously.

Return type:

TypeVar(T_co, covariant=True)

Parameters:
  • study_key (str | None) –

  • item_id (str | int) –

get(study_key, item_id)[source]

Get a single item synchronously.

Return type:

TypeVar(T_co, covariant=True)

Parameters:
  • study_key (str | None) –

  • item_id (str | int) –

class imednet.core.endpoint.SupportsList[source]

Bases: Protocol[T_co]

Protocol for resources that support list operations.

__init__(*args, **kwargs)
async async_list(study_key=None, **filters)[source]

List items asynchronously.

Return type:

Sequence[TypeVar(T_co, covariant=True)]

Parameters:
  • study_key (str | None) –

  • filters (str | int | float | bool | None | Tuple[str, str | int | float | bool | None] | List[str | int | float | bool | None]) –

list(study_key=None, **filters)[source]

List items synchronously.

Return type:

Sequence[TypeVar(T_co, covariant=True)]

Parameters:
  • study_key (str | None) –

  • filters (str | int | float | bool | None | Tuple[str, str | int | float | bool | None] | List[str | int | float | bool | None]) –

class imednet.core.endpoint.SyncListGetEndpoint[source]

Bases: _ListGetEndpointBase[T]

__init__(client, ctx=None)[source]
Parameters:
Return type:

None

get(study_key, item_id)[source]
Return type:

TypeVar(T, bound= JsonModel)

Parameters:
  • study_key (str | None) –

  • item_id (str | int) –

list(study_key=None, **filters)[source]
Return type:

List[TypeVar(T, bound= JsonModel)]

Parameters:
  • study_key (str | None) –

  • filters (str | int | float | bool | None | Tuple[str, str | int | float | bool | None] | List[str | int | float | bool | None]) –

Subpackages

Submodules

imednet.core.endpoint.abc module

Abstract base class for all API endpoints.

class imednet.core.endpoint.abc.EndpointABC[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.

requires_study_key: bool = True

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.AsyncListGetEndpoint[source]

Bases: _ListGetEndpointBase[T]

__init__(async_client, ctx=None)[source]
Parameters:
Return type:

None

async async_get(study_key, item_id)[source]
Return type:

TypeVar(T, bound= JsonModel)

Parameters:
  • study_key (str | None) –

  • item_id (str | int) –

async async_list(study_key=None, **filters)[source]
Return type:

List[TypeVar(T, bound= JsonModel)]

Parameters:
  • study_key (str | None) –

  • filters (str | int | float | bool | None | Tuple[str, str | int | float | bool | None] | List[str | int | float | bool | None]) –

class imednet.core.endpoint.base.GenericEndpoint[source]

Bases: EndpointABC[T]

Generic base for endpoint wrappers.

Handles context injection and basic path building. Does NOT include EDC-specific logic.

BASE_PATH = ''
__init__(client=None, ctx=None, async_client=None)[source]
Parameters:
Return type:

None

imednet.core.endpoint.base.GenericListGetEndpoint

alias of SyncListGetEndpoint

class imednet.core.endpoint.base.SyncListGetEndpoint[source]

Bases: _ListGetEndpointBase[T]

__init__(client, ctx=None)[source]
Parameters:
Return type:

None

get(study_key, item_id)[source]
Return type:

TypeVar(T, bound= JsonModel)

Parameters:
  • study_key (str | None) –

  • item_id (str | int) –

list(study_key=None, **filters)[source]
Return type:

List[TypeVar(T, bound= JsonModel)]

Parameters:
  • study_key (str | None) –

  • filters (str | int | float | bool | None | Tuple[str, str | int | float | bool | None] | List[str | int | float | bool | None]) –

imednet.core.endpoint.edc_mixin module

EDC-specific endpoint base class and mixin.

class imednet.core.endpoint.edc_mixin.EdcAsyncListGetEndpoint[source]

Bases: _EdcEndpointBase, AsyncListGetEndpoint[T]

Async EDC list/get endpoint base.

BASE_PATH = '/api/v1/edc/studies'
class imednet.core.endpoint.edc_mixin.EdcEndpointMixin[source]

Bases: object

Mixin providing EDC-specific logic for endpoints.

This includes the base path for EDC resources and automatic injection of the default study key into filters.

BASE_PATH = '/api/v1/edc/studies'
imednet.core.endpoint.edc_mixin.EdcGenericListGetEndpoint

alias of EdcSyncListGetEndpoint

class imednet.core.endpoint.edc_mixin.EdcSyncListGetEndpoint[source]

Bases: _EdcEndpointBase, SyncListGetEndpoint[T]

Sync EDC list/get endpoint base.

BASE_PATH = '/api/v1/edc/studies'

imednet.core.endpoint.protocols module

class imednet.core.endpoint.protocols.AsyncOperationProtocol[source]

Bases: Protocol, Generic[T_co]

Protocol for async operation executors requiring explicit transport injection.

Note

These operation protocols are intentionally generic extension points for future endpoint operation bindings.

__init__(*args, **kwargs)
async execute()[source]

Execute asynchronously.

Return type:

TypeVar(T_co, covariant=True)

class imednet.core.endpoint.protocols.EndpointProtocol[source]

Bases: Protocol

Protocol defining the interface for endpoint classes.

MODEL: Type[JsonModel]
PAGE_SIZE: int
PATH: str
__init__(*args, **kwargs)
requires_study_key: bool
class imednet.core.endpoint.protocols.ListEndpointProtocol[source]

Bases: Protocol[T]

Protocol defining the interface for listing endpoint classes.

__init__(*args, **kwargs)
class imednet.core.endpoint.protocols.SupportsCreate[source]

Bases: Protocol[T_co]

Protocol for resources that support create operations.

__init__(*args, **kwargs)
async async_create(*args, **kwargs)[source]

Create an item asynchronously.

Return type:

TypeVar(T_co, covariant=True)

Parameters:
  • args (Any) –

  • kwargs (Any) –

create(*args, **kwargs)[source]

Create an item synchronously.

Return type:

TypeVar(T_co, covariant=True)

Parameters:
  • args (Any) –

  • kwargs (Any) –

class imednet.core.endpoint.protocols.SupportsGet[source]

Bases: Protocol[T_co]

Protocol for resources that support get operations.

__init__(*args, **kwargs)
async async_get(study_key, item_id)[source]

Get a single item asynchronously.

Return type:

TypeVar(T_co, covariant=True)

Parameters:
  • study_key (str | None) –

  • item_id (str | int) –

get(study_key, item_id)[source]

Get a single item synchronously.

Return type:

TypeVar(T_co, covariant=True)

Parameters:
  • study_key (str | None) –

  • item_id (str | int) –

class imednet.core.endpoint.protocols.SupportsList[source]

Bases: Protocol[T_co]

Protocol for resources that support list operations.

__init__(*args, **kwargs)
async async_list(study_key=None, **filters)[source]

List items asynchronously.

Return type:

Sequence[TypeVar(T_co, covariant=True)]

Parameters:
  • study_key (str | None) –

  • filters (str | int | float | bool | None | Tuple[str, str | int | float | bool | None] | List[str | int | float | bool | None]) –

list(study_key=None, **filters)[source]

List items synchronously.

Return type:

Sequence[TypeVar(T_co, covariant=True)]

Parameters:
  • study_key (str | None) –

  • filters (str | int | float | bool | None | Tuple[str, str | int | float | bool | None] | List[str | int | float | bool | None]) –

class imednet.core.endpoint.protocols.SyncOperationProtocol[source]

Bases: Protocol, Generic[T_co]

Protocol for sync operation executors requiring explicit transport injection.

Note

These operation protocols are intentionally generic extension points for future endpoint operation bindings.

__init__(*args, **kwargs)
execute()[source]

Execute synchronously.

Return type:

TypeVar(T_co, covariant=True)

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[source]

Bases: ParamProcessor

Default parameter processor.

Simply passes filters through without modification.

process_filters(filters)[source]

Return filters as-is and no special parameters.

Parameters:

filters (Dict[str, Any]) – The input filters dictionary.

Return type:

Tuple[Dict[str, Any], Dict[str, Any]]

Returns:

A tuple of (copy of filters, empty dict).

class imednet.core.endpoint.strategies.KeepStudyKeyStrategy[source]

Bases: object

Strategy that requires a study key and keeps it in the filters.

Used when the API expects ‘studyKey’ as a query parameter.

process(filters)[source]

Extract study key 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).

class imednet.core.endpoint.strategies.MappingParamProcessor[source]

Bases: ParamProcessor

ParamProcessor 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.

__init__(mapping, defaults=None)[source]

Initialize the processor with a mapping.

Parameters:
  • mapping (Dict[str, str]) – A dictionary where keys are the filter keys to look for, and values are the API parameter names to map them to.

  • defaults (Optional[Dict[str, Any]]) – A dictionary of default values for keys not found in filters.

Return type:

None

process_filters(filters)[source]

Process filters using the configured mapping.

Parameters:

filters (Dict[str, Any]) – The input filters dictionary.

Return type:

Tuple[Dict[str, Any], Dict[str, Any]]

Returns:

A tuple of (cleaned filters, special parameters).

class imednet.core.endpoint.strategies.OptionalStudyKeyStrategy[source]

Bases: object

Strategy that allows the study key to be optional.

If present, it is kept in the filters.

process(filters)[source]

Extract study key if present.

Parameters:

filters (Dict[str, Any]) – The filters dictionary.

Return type:

Tuple[Optional[str], Dict[str, Any]]

Returns:

Tuple of (study_key_or_none, filters).

class imednet.core.endpoint.strategies.PopStudyKeyStrategy[source]

Bases: object

Strategy 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.

process(filters)[source]

Extract study key 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).

class imednet.core.endpoint.strategies.StudyKeyStrategy[source]

Bases: Protocol

Protocol for study key handling strategies.

__init__(*args, **kwargs)
process(filters)[source]

Process the study key from filters.

Parameters:

filters (Dict[str, Any]) – The current filters dictionary.

Return type:

Tuple[Optional[str], Dict[str, Any]]

Returns:

A tuple containing the extracted study key (if any) and the modified filters.

imednet.core.endpoint.structs module

class imednet.core.endpoint.structs.ListRequestState[source]

Bases: Generic[T]

Encapsulates the state required to execute a list request.

path

The API path for the request.

params

The query parameters.

study

The study key.

__init__(path, params, study)
Parameters:
  • path (str) –

  • params (Dict[str, Any]) –

  • study (str | None) –

Return type:

None

params: Dict[str, Any]
path: str
study: Optional[str]
class imednet.core.endpoint.structs.ParamState[source]

Bases: object

Encapsulates the state of resolved parameters for an endpoint request.

study

The study key, if applicable.

params

The dictionary of query parameters.

other_filters

Remaining filters after study key extraction.

__init__(study, params, other_filters)
Parameters:
  • study (str | None) –

  • params (Dict[str, Any]) –

  • other_filters (Dict[str, Any]) –

Return type:

None

other_filters: Dict[str, Any]
params: Dict[str, Any]
study: Optional[str]