mex.common.backend_api package¶
Submodules¶
mex.common.backend_api.connector module¶
- class mex.common.backend_api.connector.BackendApiConnector¶
Bases:
HTTPConnectorConnector class to handle interaction with the Backend API.
- API_VERSION = 'v0'¶
- _check_availability() None¶
Send a GET request to verify the API is available.
- static _fetch_all_items(fetch_page: Callable[[int, int], PaginatedItemsContainer[TypeVar]]) Generator[_ContainerItemT, None, None]¶
Yield all items across all pages using the given page-fetching callable.
- Parameters:
fetch_page – Callable that returns one page given a skip and a limit
- Returns:
Generator for all items across all matching pages
- static _search_request(endpoint: str, filters: dict[str, Any], reference_filters: list[ReferenceFilter] | None, skip: int, limit: int) dict[str, Any]¶
Build request kwargs for a simple GET or an advanced POST _search.
When reference_filters are given, an advanced POST search request against the _search endpoint is built, otherwise a simple GET request with the filters passed as query params.
- Parameters:
endpoint – Base endpoint of the resource, e.g. merged-item
filters – Simple filters shared by the GET params and the POST body
reference_filters – Advanced reference filters to search for
skip – How many items to skip for pagination
limit – How many items to return in one page
- Returns:
Keyword arguments to pass to self.request
- _set_authentication() None¶
Set the backend API key to all session headers.
- _set_url() None¶
Set the backend api url with the version path.
- assign_identity(had_primary_source: MergedPrimarySourceIdentifier, identifier_in_primary_source: str) Identity¶
Find an Identity in a database or assign a new one.
- create_rule_set(rule_set: AccessPlatformRuleSetRequest | ActivityRuleSetRequest | BibliographicResourceRuleSetRequest | ConsentRuleSetRequest | ContactPointRuleSetRequest | DistributionRuleSetRequest | OrganizationRuleSetRequest | OrganizationalUnitRuleSetRequest | PersonRuleSetRequest | PrimarySourceRuleSetRequest | ResourceRuleSetRequest | ResourceSeriesRuleSetRequest | VariableRuleSetRequest | VariableGroupRuleSetRequest) AccessPlatformRuleSetResponse | ActivityRuleSetResponse | BibliographicResourceRuleSetResponse | ConsentRuleSetResponse | ContactPointRuleSetResponse | DistributionRuleSetResponse | OrganizationRuleSetResponse | OrganizationalUnitRuleSetResponse | PersonRuleSetResponse | PrimarySourceRuleSetResponse | ResourceRuleSetResponse | ResourceSeriesRuleSetResponse | VariableRuleSetResponse | VariableGroupRuleSetResponse¶
Create a new rule set.
- Parameters:
rule_set – New rule-set to create
- Raises:
HTTPError – If the rule-set did not validate
- Returns:
The newly created rule-set
- delete_merged_item(identifier: str, *, include_rule_set: bool = False) None¶
Delete a merged item.
- Parameters:
identifier – The merged item’s identifier
include_rule_set – Whether to also delete the associated rule set
- Raises:
HTTPError – If no merged item was found
- delete_rule_set(stable_target_id: str) None¶
Delete a rule set.
- Parameters:
stable_target_id – The merged item’s identifier
- Raises:
HTTPError – If no rule-set was found
- fetch_all_extracted_items(*, query_string: str | None = None, entity_type: list[str] | None = None, reference_filters: list[ReferenceFilter] | None = None) Generator[ExtractedAccessPlatform | ExtractedActivity | ExtractedBibliographicResource | ExtractedConsent | ExtractedContactPoint | ExtractedDistribution | ExtractedOrganization | ExtractedOrganizationalUnit | ExtractedPerson | ExtractedPrimarySource | ExtractedResource | ExtractedResourceSeries | ExtractedVariable | ExtractedVariableGroup, None, None]¶
Fetch all extracted items that match the given set of filters.
- Parameters:
query_string – Full-text search query
entity_type – The item’s entityType
reference_filters – Advanced reference filters to search for
- Raises:
HTTPError – If search was not accepted, crashes or times out
- Returns:
Generator for all extracted items that match the filters
- fetch_all_merged_items(*, query_string: str | None = None, identifier: str | None = None, entity_type: list[str] | None = None, reference_filters: list[ReferenceFilter] | None = None) Generator[MergedAccessPlatform | MergedActivity | MergedBibliographicResource | MergedConsent | MergedContactPoint | MergedDistribution | MergedOrganization | MergedOrganizationalUnit | MergedPerson | MergedPrimarySource | MergedResource | MergedResourceSeries | MergedVariable | MergedVariableGroup, None, None]¶
Fetch all merged items that match the given set of filters.
- Parameters:
query_string – Full-text search query
identifier – Merged item identifier filter
entity_type – The items’ entityType
reference_filters – Advanced reference filters to search for
- Raises:
HTTPError – If search was not accepted, crashes or times out
- Returns:
Generator for all merged items that match the filters
- fetch_all_publishable_merged_items(*, publishing_target: str, query_string: str | None = None, identifier: str | None = None, entity_type: list[str] | None = None, reference_filters: list[ReferenceFilter] | None = None) Generator[MergedAccessPlatform | MergedActivity | MergedBibliographicResource | MergedConsent | MergedContactPoint | MergedDistribution | MergedOrganization | MergedOrganizationalUnit | MergedPerson | MergedPrimarySource | MergedResource | MergedResourceSeries | MergedVariable | MergedVariableGroup, None, None]¶
Fetch all publishable merged items that match the given set of filters.
- Parameters:
publishing_target – The target to publish the items to
query_string – Full-text search query
identifier – Merged item identifier filter
entity_type – The items’ entityType
reference_filters – Advanced reference filters to search for
- Raises:
HTTPError – If search was not accepted, crashes or times out
- Returns:
Generator for all publishable merged items that match the filters
- fetch_extracted_items(*, query_string: str | None = None, entity_type: list[str] | None = None, reference_filters: list[ReferenceFilter] | None = None, skip: int = 0, limit: int = 100) PaginatedItemsContainer[ExtractedAccessPlatform | ExtractedActivity | ExtractedBibliographicResource | ExtractedConsent | ExtractedContactPoint | ExtractedDistribution | ExtractedOrganization | ExtractedOrganizationalUnit | ExtractedPerson | ExtractedPrimarySource | ExtractedResource | ExtractedResourceSeries | ExtractedVariable | ExtractedVariableGroup]¶
Fetch extracted items that match the given set of filters.
When reference_filters are given, the advanced POST search endpoint is used, otherwise the simple GET endpoint is queried.
- Parameters:
query_string – Full-text search query
entity_type – The item’s entityType
reference_filters – Advanced reference filters to search for
skip – How many items to skip for pagination
limit – How many items to return in one page
- Raises:
HTTPError – If search was not accepted, crashes or times out
- Returns:
One page of extracted items and the total count that was matched
- fetch_identities(had_primary_source: Identifier | None = None, identifier_in_primary_source: str | None = None, stable_target_id: Identifier | None = None) PaginatedItemsContainer[Identity]¶
Find Identity instances matching the given filters.
Either provide stableTargetId or hadPrimarySource and identifierInPrimarySource together to get a unique result.
- fetch_merged_items(*, query_string: str | None = None, identifier: str | None = None, entity_type: list[str] | None = None, reference_filters: list[ReferenceFilter] | None = None, skip: int = 0, limit: int = 100) PaginatedItemsContainer[MergedAccessPlatform | MergedActivity | MergedBibliographicResource | MergedConsent | MergedContactPoint | MergedDistribution | MergedOrganization | MergedOrganizationalUnit | MergedPerson | MergedPrimarySource | MergedResource | MergedResourceSeries | MergedVariable | MergedVariableGroup]¶
Fetch merged items that match the given set of filters.
When reference_filters are given, the advanced POST search endpoint is used, otherwise the simple GET endpoint is queried.
- Parameters:
query_string – Full-text search query
identifier – Merged item identifier filter
entity_type – The items’ entityType
reference_filters – Advanced reference filters to search for
skip – How many items to skip for pagination
limit – How many items to return in one page
- Raises:
HTTPError – If search was not accepted, crashes or times out
- Returns:
One page of merged items and the total count that was matched
- fetch_preview_items(*, query_string: str | None = None, identifier: str | None = None, entity_type: list[str] | None = None, reference_filters: list[ReferenceFilter] | None = None, skip: int = 0, limit: int = 100) PaginatedItemsContainer[PreviewAccessPlatform | PreviewActivity | PreviewBibliographicResource | PreviewConsent | PreviewContactPoint | PreviewDistribution | PreviewOrganization | PreviewOrganizationalUnit | PreviewPerson | PreviewPrimarySource | PreviewResource | PreviewResourceSeries | PreviewVariable | PreviewVariableGroup]¶
Fetch merged item previews that match the given set of filters.
When reference_filters are given, the advanced POST search endpoint is used, otherwise the simple GET endpoint is queried.
- Parameters:
query_string – Full-text search query
identifier – Merged item identifier filter
entity_type – The items’ entityType
reference_filters – Advanced reference filters to search for
skip – How many items to skip for pagination
limit – How many items to return in one page
- Raises:
HTTPError – If search was not accepted, crashes or times out
- Returns:
One page of preview items and the total count that was matched
- fetch_publishable_merged_items(*, publishing_target: str, query_string: str | None = None, identifier: str | None = None, entity_type: list[str] | None = None, reference_filters: list[ReferenceFilter] | None = None, skip: int = 0, limit: int = 100) PaginatedItemsContainer[MergedAccessPlatform | MergedActivity | MergedBibliographicResource | MergedConsent | MergedContactPoint | MergedDistribution | MergedOrganization | MergedOrganizationalUnit | MergedPerson | MergedPrimarySource | MergedResource | MergedResourceSeries | MergedVariable | MergedVariableGroup]¶
Fetch publishable merged items that match the given set of filters.
When reference_filters are given, the advanced POST search endpoint is used, otherwise the simple GET endpoint is queried.
- Parameters:
publishing_target – The target to publish the items to
query_string – Full-text search query
identifier – Merged item identifier filter
entity_type – The items’ entityType
reference_filters – Advanced reference filters to search for
skip – How many items to skip for pagination
limit – How many items to return in one page
- Raises:
HTTPError – If search was not accepted, crashes or times out
- Returns:
One page of publishable merged items and the total count that was matched
- get_extracted_item(identifier: str) ExtractedAccessPlatform | ExtractedActivity | ExtractedBibliographicResource | ExtractedConsent | ExtractedContactPoint | ExtractedDistribution | ExtractedOrganization | ExtractedOrganizationalUnit | ExtractedPerson | ExtractedPrimarySource | ExtractedResource | ExtractedResourceSeries | ExtractedVariable | ExtractedVariableGroup¶
Return one extracted item for the given identifier.
- Parameters:
identifier – The extracted item’s identifier
- Raises:
HTTPError – If no extracted item was found
- Returns:
A single extracted item
- get_merged_item(identifier: str) MergedAccessPlatform | MergedActivity | MergedBibliographicResource | MergedConsent | MergedContactPoint | MergedDistribution | MergedOrganization | MergedOrganizationalUnit | MergedPerson | MergedPrimarySource | MergedResource | MergedResourceSeries | MergedVariable | MergedVariableGroup¶
Return one merged item for the given identifier.
- Parameters:
identifier – The merged item’s identifier
- Raises:
HTTPError – If no merged item was found
- Returns:
A single merged item
- get_preview_item(identifier: str) PreviewAccessPlatform | PreviewActivity | PreviewBibliographicResource | PreviewConsent | PreviewContactPoint | PreviewDistribution | PreviewOrganization | PreviewOrganizationalUnit | PreviewPerson | PreviewPrimarySource | PreviewResource | PreviewResourceSeries | PreviewVariable | PreviewVariableGroup¶
Return one preview item for the given identifier.
- Parameters:
identifier – The preview item’s identifier
- Raises:
HTTPError – If no preview item was found
- Returns:
A single preview item
- get_rule_set(stable_target_id: str) AccessPlatformRuleSetResponse | ActivityRuleSetResponse | BibliographicResourceRuleSetResponse | ConsentRuleSetResponse | ContactPointRuleSetResponse | DistributionRuleSetResponse | OrganizationRuleSetResponse | OrganizationalUnitRuleSetResponse | PersonRuleSetResponse | PrimarySourceRuleSetResponse | ResourceRuleSetResponse | ResourceSeriesRuleSetResponse | VariableRuleSetResponse | VariableGroupRuleSetResponse¶
Return the rules for the given stableTargetId.
- Parameters:
stable_target_id – The merged item’s identifier
- Raises:
HTTPError – If no rule-set was found
- Returns:
A set of four rules
- ingest(ingestible_models: list[_IngestibleModelT], **kwargs: Any) None¶
Post extracted models or rule-sets to the backend in bulk.
- Parameters:
ingestible_models – Extracted models or rule-sets to ingest
kwargs – Further keyword arguments passed to requests
- Raises:
HTTPError – If post was not accepted, crashes or times out
- merge_items(goner_identifier: MergedAccessPlatformIdentifier | MergedActivityIdentifier | MergedBibliographicResourceIdentifier | MergedConsentIdentifier | MergedContactPointIdentifier | MergedDistributionIdentifier | MergedOrganizationalUnitIdentifier | MergedOrganizationIdentifier | MergedPersonIdentifier | MergedPrimarySourceIdentifier | MergedResourceIdentifier | MergedResourceSeriesIdentifier | MergedVariableGroupIdentifier | MergedVariableIdentifier, keeper_identifier: MergedAccessPlatformIdentifier | MergedActivityIdentifier | MergedBibliographicResourceIdentifier | MergedConsentIdentifier | MergedContactPointIdentifier | MergedDistributionIdentifier | MergedOrganizationalUnitIdentifier | MergedOrganizationIdentifier | MergedPersonIdentifier | MergedPrimarySourceIdentifier | MergedResourceIdentifier | MergedResourceSeriesIdentifier | MergedVariableGroupIdentifier | MergedVariableIdentifier) None¶
Merge a goner merged item into a keeper merged item.
- Parameters:
goner_identifier – Identifier of the merged item to be merged away
keeper_identifier – Identifier of the merged item to keep
- Raises:
HTTPError – If merging was not accepted
- search_organization_in_wikidata(q: str, offset: int = 0, limit: int = 10) PaginatedItemsContainer[ExtractedOrganization]¶
Search for organizations in wikidata.
- Parameters:
q – Wikidata item ID or full URL
offset – The starting index for pagination
limit – The maximum number of results to return
- Returns:
Paginated list of ExtractedOrganizations
- search_person_in_orcid(q: str, offset: int = 0, limit: int = 10) PaginatedItemsContainer[ExtractedPerson]¶
Search for persons in orcid.
- Parameters:
q – The name of the person to be searched
offset – The starting index for pagination
limit – The maximum number of results to return
- Returns:
Paginated list of ExtractedPersons
- search_person_or_contact_point_in_ldap(q: str, offset: int = 0, limit: int = 10) PaginatedItemsContainer[ExtractedPerson | ExtractedContactPoint]¶
Search for persons or contact points in LDAP.
- Parameters:
q – The name of the person or contact point
offset – The starting index for pagination
limit – The maximum number of results to return
- Returns:
Paginated list of ExtractedPersons and ExtractedContactPoints
- system_status() VersionStatus¶
Return the status and version of the backend.
- update_rule_set(stable_target_id: str, rule_set: AccessPlatformRuleSetRequest | ActivityRuleSetRequest | BibliographicResourceRuleSetRequest | ConsentRuleSetRequest | ContactPointRuleSetRequest | DistributionRuleSetRequest | OrganizationRuleSetRequest | OrganizationalUnitRuleSetRequest | PersonRuleSetRequest | PrimarySourceRuleSetRequest | ResourceRuleSetRequest | ResourceSeriesRuleSetRequest | VariableRuleSetRequest | VariableGroupRuleSetRequest) AccessPlatformRuleSetResponse | ActivityRuleSetResponse | BibliographicResourceRuleSetResponse | ConsentRuleSetResponse | ContactPointRuleSetResponse | DistributionRuleSetResponse | OrganizationRuleSetResponse | OrganizationalUnitRuleSetResponse | PersonRuleSetResponse | PrimarySourceRuleSetResponse | ResourceRuleSetResponse | ResourceSeriesRuleSetResponse | VariableRuleSetResponse | VariableGroupRuleSetResponse¶
Update an existing rule set.
- Parameters:
stable_target_id – The merged item’s identifier
rule_set – The new rule-set contents
- Raises:
HTTPError – If no rule-set was found
- Returns:
A set of four rules
- class mex.common.backend_api.connector.LDAPBackendApiConnector¶
Bases:
HTTPConnectorConnector class to handle interaction with the Backend API without an API key.
- API_VERSION = 'v0'¶
- _check_availability() None¶
Send a GET request to verify the API is available.
- _set_url() None¶
Set the backend api url with the version path.
- merged_person_from_login(username: str, password: str) MergedPerson¶
Fetch a MergedPerson by their login username.
- Raises:
HTTPError – If authentication fails or user is not authorized
- Returns:
The merged person corresponding to the authenticated user
- Return type:
- class mex.common.backend_api.connector.ReferenceFilter(*, field: str, identifiers: Annotated[list[Identifier | None], MinLen(min_length=1), MaxLen(max_length=100)])¶
Bases:
BaseModelReference filter definition with a field and list of identifiers.
- field: str¶
- identifiers: Annotated[list[Identifier | None], FieldInfo(annotation=NoneType, required=True, metadata=[MinLen(min_length=1), MaxLen(max_length=100)])]¶
- model_config = {'extra': 'ignore', 'populate_by_name': True, 'str_max_length': 100000, 'str_min_length': 1, 'str_strip_whitespace': True, 'use_enum_values': True, 'validate_assignment': True, 'validate_by_alias': True, 'validate_by_name': True, 'validate_default': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
Module contents¶
- class mex.common.backend_api.BackendApiConnector¶
Bases:
HTTPConnectorConnector class to handle interaction with the Backend API.
- API_VERSION = 'v0'¶
- _check_availability() None¶
Send a GET request to verify the API is available.
- static _fetch_all_items(fetch_page: Callable[[int, int], PaginatedItemsContainer[TypeVar]]) Generator[_ContainerItemT, None, None]¶
Yield all items across all pages using the given page-fetching callable.
- Parameters:
fetch_page – Callable that returns one page given a skip and a limit
- Returns:
Generator for all items across all matching pages
- static _search_request(endpoint: str, filters: dict[str, Any], reference_filters: list[ReferenceFilter] | None, skip: int, limit: int) dict[str, Any]¶
Build request kwargs for a simple GET or an advanced POST _search.
When reference_filters are given, an advanced POST search request against the _search endpoint is built, otherwise a simple GET request with the filters passed as query params.
- Parameters:
endpoint – Base endpoint of the resource, e.g. merged-item
filters – Simple filters shared by the GET params and the POST body
reference_filters – Advanced reference filters to search for
skip – How many items to skip for pagination
limit – How many items to return in one page
- Returns:
Keyword arguments to pass to self.request
- _set_authentication() None¶
Set the backend API key to all session headers.
- _set_url() None¶
Set the backend api url with the version path.
- assign_identity(had_primary_source: MergedPrimarySourceIdentifier, identifier_in_primary_source: str) Identity¶
Find an Identity in a database or assign a new one.
- create_rule_set(rule_set: AccessPlatformRuleSetRequest | ActivityRuleSetRequest | BibliographicResourceRuleSetRequest | ConsentRuleSetRequest | ContactPointRuleSetRequest | DistributionRuleSetRequest | OrganizationRuleSetRequest | OrganizationalUnitRuleSetRequest | PersonRuleSetRequest | PrimarySourceRuleSetRequest | ResourceRuleSetRequest | ResourceSeriesRuleSetRequest | VariableRuleSetRequest | VariableGroupRuleSetRequest) AccessPlatformRuleSetResponse | ActivityRuleSetResponse | BibliographicResourceRuleSetResponse | ConsentRuleSetResponse | ContactPointRuleSetResponse | DistributionRuleSetResponse | OrganizationRuleSetResponse | OrganizationalUnitRuleSetResponse | PersonRuleSetResponse | PrimarySourceRuleSetResponse | ResourceRuleSetResponse | ResourceSeriesRuleSetResponse | VariableRuleSetResponse | VariableGroupRuleSetResponse¶
Create a new rule set.
- Parameters:
rule_set – New rule-set to create
- Raises:
HTTPError – If the rule-set did not validate
- Returns:
The newly created rule-set
- delete_merged_item(identifier: str, *, include_rule_set: bool = False) None¶
Delete a merged item.
- Parameters:
identifier – The merged item’s identifier
include_rule_set – Whether to also delete the associated rule set
- Raises:
HTTPError – If no merged item was found
- delete_rule_set(stable_target_id: str) None¶
Delete a rule set.
- Parameters:
stable_target_id – The merged item’s identifier
- Raises:
HTTPError – If no rule-set was found
- fetch_all_extracted_items(*, query_string: str | None = None, entity_type: list[str] | None = None, reference_filters: list[ReferenceFilter] | None = None) Generator[ExtractedAccessPlatform | ExtractedActivity | ExtractedBibliographicResource | ExtractedConsent | ExtractedContactPoint | ExtractedDistribution | ExtractedOrganization | ExtractedOrganizationalUnit | ExtractedPerson | ExtractedPrimarySource | ExtractedResource | ExtractedResourceSeries | ExtractedVariable | ExtractedVariableGroup, None, None]¶
Fetch all extracted items that match the given set of filters.
- Parameters:
query_string – Full-text search query
entity_type – The item’s entityType
reference_filters – Advanced reference filters to search for
- Raises:
HTTPError – If search was not accepted, crashes or times out
- Returns:
Generator for all extracted items that match the filters
- fetch_all_merged_items(*, query_string: str | None = None, identifier: str | None = None, entity_type: list[str] | None = None, reference_filters: list[ReferenceFilter] | None = None) Generator[MergedAccessPlatform | MergedActivity | MergedBibliographicResource | MergedConsent | MergedContactPoint | MergedDistribution | MergedOrganization | MergedOrganizationalUnit | MergedPerson | MergedPrimarySource | MergedResource | MergedResourceSeries | MergedVariable | MergedVariableGroup, None, None]¶
Fetch all merged items that match the given set of filters.
- Parameters:
query_string – Full-text search query
identifier – Merged item identifier filter
entity_type – The items’ entityType
reference_filters – Advanced reference filters to search for
- Raises:
HTTPError – If search was not accepted, crashes or times out
- Returns:
Generator for all merged items that match the filters
- fetch_all_publishable_merged_items(*, publishing_target: str, query_string: str | None = None, identifier: str | None = None, entity_type: list[str] | None = None, reference_filters: list[ReferenceFilter] | None = None) Generator[MergedAccessPlatform | MergedActivity | MergedBibliographicResource | MergedConsent | MergedContactPoint | MergedDistribution | MergedOrganization | MergedOrganizationalUnit | MergedPerson | MergedPrimarySource | MergedResource | MergedResourceSeries | MergedVariable | MergedVariableGroup, None, None]¶
Fetch all publishable merged items that match the given set of filters.
- Parameters:
publishing_target – The target to publish the items to
query_string – Full-text search query
identifier – Merged item identifier filter
entity_type – The items’ entityType
reference_filters – Advanced reference filters to search for
- Raises:
HTTPError – If search was not accepted, crashes or times out
- Returns:
Generator for all publishable merged items that match the filters
- fetch_extracted_items(*, query_string: str | None = None, entity_type: list[str] | None = None, reference_filters: list[ReferenceFilter] | None = None, skip: int = 0, limit: int = 100) PaginatedItemsContainer[ExtractedAccessPlatform | ExtractedActivity | ExtractedBibliographicResource | ExtractedConsent | ExtractedContactPoint | ExtractedDistribution | ExtractedOrganization | ExtractedOrganizationalUnit | ExtractedPerson | ExtractedPrimarySource | ExtractedResource | ExtractedResourceSeries | ExtractedVariable | ExtractedVariableGroup]¶
Fetch extracted items that match the given set of filters.
When reference_filters are given, the advanced POST search endpoint is used, otherwise the simple GET endpoint is queried.
- Parameters:
query_string – Full-text search query
entity_type – The item’s entityType
reference_filters – Advanced reference filters to search for
skip – How many items to skip for pagination
limit – How many items to return in one page
- Raises:
HTTPError – If search was not accepted, crashes or times out
- Returns:
One page of extracted items and the total count that was matched
- fetch_identities(had_primary_source: Identifier | None = None, identifier_in_primary_source: str | None = None, stable_target_id: Identifier | None = None) PaginatedItemsContainer[Identity]¶
Find Identity instances matching the given filters.
Either provide stableTargetId or hadPrimarySource and identifierInPrimarySource together to get a unique result.
- fetch_merged_items(*, query_string: str | None = None, identifier: str | None = None, entity_type: list[str] | None = None, reference_filters: list[ReferenceFilter] | None = None, skip: int = 0, limit: int = 100) PaginatedItemsContainer[MergedAccessPlatform | MergedActivity | MergedBibliographicResource | MergedConsent | MergedContactPoint | MergedDistribution | MergedOrganization | MergedOrganizationalUnit | MergedPerson | MergedPrimarySource | MergedResource | MergedResourceSeries | MergedVariable | MergedVariableGroup]¶
Fetch merged items that match the given set of filters.
When reference_filters are given, the advanced POST search endpoint is used, otherwise the simple GET endpoint is queried.
- Parameters:
query_string – Full-text search query
identifier – Merged item identifier filter
entity_type – The items’ entityType
reference_filters – Advanced reference filters to search for
skip – How many items to skip for pagination
limit – How many items to return in one page
- Raises:
HTTPError – If search was not accepted, crashes or times out
- Returns:
One page of merged items and the total count that was matched
- fetch_preview_items(*, query_string: str | None = None, identifier: str | None = None, entity_type: list[str] | None = None, reference_filters: list[ReferenceFilter] | None = None, skip: int = 0, limit: int = 100) PaginatedItemsContainer[PreviewAccessPlatform | PreviewActivity | PreviewBibliographicResource | PreviewConsent | PreviewContactPoint | PreviewDistribution | PreviewOrganization | PreviewOrganizationalUnit | PreviewPerson | PreviewPrimarySource | PreviewResource | PreviewResourceSeries | PreviewVariable | PreviewVariableGroup]¶
Fetch merged item previews that match the given set of filters.
When reference_filters are given, the advanced POST search endpoint is used, otherwise the simple GET endpoint is queried.
- Parameters:
query_string – Full-text search query
identifier – Merged item identifier filter
entity_type – The items’ entityType
reference_filters – Advanced reference filters to search for
skip – How many items to skip for pagination
limit – How many items to return in one page
- Raises:
HTTPError – If search was not accepted, crashes or times out
- Returns:
One page of preview items and the total count that was matched
- fetch_publishable_merged_items(*, publishing_target: str, query_string: str | None = None, identifier: str | None = None, entity_type: list[str] | None = None, reference_filters: list[ReferenceFilter] | None = None, skip: int = 0, limit: int = 100) PaginatedItemsContainer[MergedAccessPlatform | MergedActivity | MergedBibliographicResource | MergedConsent | MergedContactPoint | MergedDistribution | MergedOrganization | MergedOrganizationalUnit | MergedPerson | MergedPrimarySource | MergedResource | MergedResourceSeries | MergedVariable | MergedVariableGroup]¶
Fetch publishable merged items that match the given set of filters.
When reference_filters are given, the advanced POST search endpoint is used, otherwise the simple GET endpoint is queried.
- Parameters:
publishing_target – The target to publish the items to
query_string – Full-text search query
identifier – Merged item identifier filter
entity_type – The items’ entityType
reference_filters – Advanced reference filters to search for
skip – How many items to skip for pagination
limit – How many items to return in one page
- Raises:
HTTPError – If search was not accepted, crashes or times out
- Returns:
One page of publishable merged items and the total count that was matched
- get_extracted_item(identifier: str) ExtractedAccessPlatform | ExtractedActivity | ExtractedBibliographicResource | ExtractedConsent | ExtractedContactPoint | ExtractedDistribution | ExtractedOrganization | ExtractedOrganizationalUnit | ExtractedPerson | ExtractedPrimarySource | ExtractedResource | ExtractedResourceSeries | ExtractedVariable | ExtractedVariableGroup¶
Return one extracted item for the given identifier.
- Parameters:
identifier – The extracted item’s identifier
- Raises:
HTTPError – If no extracted item was found
- Returns:
A single extracted item
- get_merged_item(identifier: str) MergedAccessPlatform | MergedActivity | MergedBibliographicResource | MergedConsent | MergedContactPoint | MergedDistribution | MergedOrganization | MergedOrganizationalUnit | MergedPerson | MergedPrimarySource | MergedResource | MergedResourceSeries | MergedVariable | MergedVariableGroup¶
Return one merged item for the given identifier.
- Parameters:
identifier – The merged item’s identifier
- Raises:
HTTPError – If no merged item was found
- Returns:
A single merged item
- get_preview_item(identifier: str) PreviewAccessPlatform | PreviewActivity | PreviewBibliographicResource | PreviewConsent | PreviewContactPoint | PreviewDistribution | PreviewOrganization | PreviewOrganizationalUnit | PreviewPerson | PreviewPrimarySource | PreviewResource | PreviewResourceSeries | PreviewVariable | PreviewVariableGroup¶
Return one preview item for the given identifier.
- Parameters:
identifier – The preview item’s identifier
- Raises:
HTTPError – If no preview item was found
- Returns:
A single preview item
- get_rule_set(stable_target_id: str) AccessPlatformRuleSetResponse | ActivityRuleSetResponse | BibliographicResourceRuleSetResponse | ConsentRuleSetResponse | ContactPointRuleSetResponse | DistributionRuleSetResponse | OrganizationRuleSetResponse | OrganizationalUnitRuleSetResponse | PersonRuleSetResponse | PrimarySourceRuleSetResponse | ResourceRuleSetResponse | ResourceSeriesRuleSetResponse | VariableRuleSetResponse | VariableGroupRuleSetResponse¶
Return the rules for the given stableTargetId.
- Parameters:
stable_target_id – The merged item’s identifier
- Raises:
HTTPError – If no rule-set was found
- Returns:
A set of four rules
- ingest(ingestible_models: list[_IngestibleModelT], **kwargs: Any) None¶
Post extracted models or rule-sets to the backend in bulk.
- Parameters:
ingestible_models – Extracted models or rule-sets to ingest
kwargs – Further keyword arguments passed to requests
- Raises:
HTTPError – If post was not accepted, crashes or times out
- merge_items(goner_identifier: MergedAccessPlatformIdentifier | MergedActivityIdentifier | MergedBibliographicResourceIdentifier | MergedConsentIdentifier | MergedContactPointIdentifier | MergedDistributionIdentifier | MergedOrganizationalUnitIdentifier | MergedOrganizationIdentifier | MergedPersonIdentifier | MergedPrimarySourceIdentifier | MergedResourceIdentifier | MergedResourceSeriesIdentifier | MergedVariableGroupIdentifier | MergedVariableIdentifier, keeper_identifier: MergedAccessPlatformIdentifier | MergedActivityIdentifier | MergedBibliographicResourceIdentifier | MergedConsentIdentifier | MergedContactPointIdentifier | MergedDistributionIdentifier | MergedOrganizationalUnitIdentifier | MergedOrganizationIdentifier | MergedPersonIdentifier | MergedPrimarySourceIdentifier | MergedResourceIdentifier | MergedResourceSeriesIdentifier | MergedVariableGroupIdentifier | MergedVariableIdentifier) None¶
Merge a goner merged item into a keeper merged item.
- Parameters:
goner_identifier – Identifier of the merged item to be merged away
keeper_identifier – Identifier of the merged item to keep
- Raises:
HTTPError – If merging was not accepted
- search_organization_in_wikidata(q: str, offset: int = 0, limit: int = 10) PaginatedItemsContainer[ExtractedOrganization]¶
Search for organizations in wikidata.
- Parameters:
q – Wikidata item ID or full URL
offset – The starting index for pagination
limit – The maximum number of results to return
- Returns:
Paginated list of ExtractedOrganizations
- search_person_in_orcid(q: str, offset: int = 0, limit: int = 10) PaginatedItemsContainer[ExtractedPerson]¶
Search for persons in orcid.
- Parameters:
q – The name of the person to be searched
offset – The starting index for pagination
limit – The maximum number of results to return
- Returns:
Paginated list of ExtractedPersons
- search_person_or_contact_point_in_ldap(q: str, offset: int = 0, limit: int = 10) PaginatedItemsContainer[ExtractedPerson | ExtractedContactPoint]¶
Search for persons or contact points in LDAP.
- Parameters:
q – The name of the person or contact point
offset – The starting index for pagination
limit – The maximum number of results to return
- Returns:
Paginated list of ExtractedPersons and ExtractedContactPoints
- system_status() VersionStatus¶
Return the status and version of the backend.
- update_rule_set(stable_target_id: str, rule_set: AccessPlatformRuleSetRequest | ActivityRuleSetRequest | BibliographicResourceRuleSetRequest | ConsentRuleSetRequest | ContactPointRuleSetRequest | DistributionRuleSetRequest | OrganizationRuleSetRequest | OrganizationalUnitRuleSetRequest | PersonRuleSetRequest | PrimarySourceRuleSetRequest | ResourceRuleSetRequest | ResourceSeriesRuleSetRequest | VariableRuleSetRequest | VariableGroupRuleSetRequest) AccessPlatformRuleSetResponse | ActivityRuleSetResponse | BibliographicResourceRuleSetResponse | ConsentRuleSetResponse | ContactPointRuleSetResponse | DistributionRuleSetResponse | OrganizationRuleSetResponse | OrganizationalUnitRuleSetResponse | PersonRuleSetResponse | PrimarySourceRuleSetResponse | ResourceRuleSetResponse | ResourceSeriesRuleSetResponse | VariableRuleSetResponse | VariableGroupRuleSetResponse¶
Update an existing rule set.
- Parameters:
stable_target_id – The merged item’s identifier
rule_set – The new rule-set contents
- Raises:
HTTPError – If no rule-set was found
- Returns:
A set of four rules
- class mex.common.backend_api.LDAPBackendApiConnector¶
Bases:
HTTPConnectorConnector class to handle interaction with the Backend API without an API key.
- API_VERSION = 'v0'¶
- _check_availability() None¶
Send a GET request to verify the API is available.
- _set_url() None¶
Set the backend api url with the version path.
- merged_person_from_login(username: str, password: str) MergedPerson¶
Fetch a MergedPerson by their login username.
- Raises:
HTTPError – If authentication fails or user is not authorized
- Returns:
The merged person corresponding to the authenticated user
- Return type: