mex.common.backend_api package

Submodules

mex.common.backend_api.connector module

class mex.common.backend_api.connector.BackendApiConnector

Bases: HTTPConnector

Connector class to handle interaction with the Backend API.

API_VERSION = 'v0'
INGEST_TIMEOUT = 30
_check_availability() None

Send a GET request to verify the API is available.

_set_authentication() None

Set the backend API key to all session headers.

_set_url() None

Set the backend api url with the version path.

fetch_extracted_items(query_string: str | None, stable_target_id: str | None, entity_type: list[str] | None, skip: int, limit: int) PaginatedItemsContainer[ExtractedAccessPlatform | ExtractedActivity | ExtractedBibliographicResource | ExtractedConsent | ExtractedContactPoint | ExtractedDistribution | ExtractedOrganization | ExtractedOrganizationalUnit | ExtractedPerson | ExtractedPrimarySource | ExtractedResource | ExtractedVariable | ExtractedVariableGroup]

Fetch extracted items that match the given set of filters.

Parameters:
  • query_string – Full-text search query

  • stable_target_id – The item’s stableTargetId

  • entity_type – The item’s entityType

  • 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_merged_items(query_string: str | None, entity_type: list[str] | None, had_primary_source: list[str] | None, skip: int, limit: int) PaginatedItemsContainer[MergedAccessPlatform | MergedActivity | MergedBibliographicResource | MergedConsent | MergedContactPoint | MergedDistribution | MergedOrganization | MergedOrganizationalUnit | MergedPerson | MergedPrimarySource | MergedResource | MergedVariable | MergedVariableGroup]

Fetch merged items that match the given set of filters.

Parameters:
  • query_string – Full-text search query

  • entity_type – The items’ entityType

  • had_primary_source – The items’ hadPrimarySource

  • 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, entity_type: list[str] | None, had_primary_source: list[str] | None, skip: int, limit: int) PaginatedItemsContainer[PreviewAccessPlatform | PreviewActivity | PreviewBibliographicResource | PreviewConsent | PreviewContactPoint | PreviewDistribution | PreviewOrganization | PreviewOrganizationalUnit | PreviewPerson | PreviewPrimarySource | PreviewResource | PreviewVariable | PreviewVariableGroup]

Fetch merged item previews that match the given set of filters.

Parameters:
  • query_string – Full-text search query

  • entity_type – The items’ entityType

  • had_primary_source – The items’ hadPrimarySource

  • 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

get_merged_item(identifier: str) MergedAccessPlatform | MergedActivity | MergedBibliographicResource | MergedConsent | MergedContactPoint | MergedDistribution | MergedOrganization | MergedOrganizationalUnit | MergedPerson | MergedPrimarySource | MergedResource | 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_rule_set(stable_target_id: str) AccessPlatformRuleSetResponse | ActivityRuleSetResponse | BibliographicResourceRuleSetResponse | ConsentRuleSetResponse | ContactPointRuleSetResponse | DistributionRuleSetResponse | OrganizationRuleSetResponse | OrganizationalUnitRuleSetResponse | PersonRuleSetResponse | PrimarySourceRuleSetResponse | ResourceRuleSetResponse | VariableRuleSetResponse | VariableGroupRuleSetResponse

Return a triple of 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 three rules

ingest(models_or_rule_sets: list[ExtractedAccessPlatform | ExtractedActivity | ExtractedBibliographicResource | ExtractedConsent | ExtractedContactPoint | ExtractedDistribution | ExtractedOrganization | ExtractedOrganizationalUnit | ExtractedPerson | ExtractedPrimarySource | ExtractedResource | ExtractedVariable | ExtractedVariableGroup | AccessPlatformRuleSetResponse | ActivityRuleSetResponse | BibliographicResourceRuleSetResponse | ConsentRuleSetResponse | ContactPointRuleSetResponse | DistributionRuleSetResponse | OrganizationRuleSetResponse | OrganizationalUnitRuleSetResponse | PersonRuleSetResponse | PrimarySourceRuleSetResponse | ResourceRuleSetResponse | VariableRuleSetResponse | VariableGroupRuleSetResponse]) list[ExtractedAccessPlatform | ExtractedActivity | ExtractedBibliographicResource | ExtractedConsent | ExtractedContactPoint | ExtractedDistribution | ExtractedOrganization | ExtractedOrganizationalUnit | ExtractedPerson | ExtractedPrimarySource | ExtractedResource | ExtractedVariable | ExtractedVariableGroup | AccessPlatformRuleSetResponse | ActivityRuleSetResponse | BibliographicResourceRuleSetResponse | ConsentRuleSetResponse | ContactPointRuleSetResponse | DistributionRuleSetResponse | OrganizationRuleSetResponse | OrganizationalUnitRuleSetResponse | PersonRuleSetResponse | PrimarySourceRuleSetResponse | ResourceRuleSetResponse | VariableRuleSetResponse | VariableGroupRuleSetResponse]

Post extracted models or rule-sets to the backend in bulk.

Parameters:

models_or_rule_sets – Extracted models or rule-sets to ingest

Raises:

HTTPError – If post was not accepted, crashes or times out

Returns:

List of extracted models or rule-sets from the endpoint

preview_merged_item(stable_target_id: str, rule_set: AccessPlatformRuleSetRequest | ActivityRuleSetRequest | BibliographicResourceRuleSetRequest | ConsentRuleSetRequest | ContactPointRuleSetRequest | DistributionRuleSetRequest | OrganizationRuleSetRequest | OrganizationalUnitRuleSetRequest | PersonRuleSetRequest | PrimarySourceRuleSetRequest | ResourceRuleSetRequest | VariableRuleSetRequest | VariableGroupRuleSetRequest) MergedAccessPlatform | MergedActivity | MergedBibliographicResource | MergedConsent | MergedContactPoint | MergedDistribution | MergedOrganization | MergedOrganizationalUnit | MergedPerson | MergedPrimarySource | MergedResource | MergedVariable | MergedVariableGroup

Return a preview for merging the given rule-set with stored extracted items.

Parameters:
  • stable_target_id – The extracted items’ stableTargetId

  • rule_set – A rule-set to use for previewing

Raises:

HTTPError – If preview produces errors, crashes or times out

Returns:

A single merged item

mex.common.backend_api.models module

Module contents