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'¶
- _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.
- 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 | VariableRuleSetRequest | VariableGroupRuleSetRequest) AccessPlatformRuleSetResponse | ActivityRuleSetResponse | BibliographicResourceRuleSetResponse | ConsentRuleSetResponse | ContactPointRuleSetResponse | DistributionRuleSetResponse | OrganizationRuleSetResponse | OrganizationalUnitRuleSetResponse | PersonRuleSetResponse | PrimarySourceRuleSetResponse | ResourceRuleSetResponse | 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
- 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_identities(had_primary_source: Identifier | None = None, identifier_in_primary_source: str | None = None, stable_target_id: Identifier | None = None) ItemsContainer[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, 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(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
- preview_merged_item(stable_target_id: str, rule_set: AccessPlatformRuleSetRequest | ActivityRuleSetRequest | BibliographicResourceRuleSetRequest | ConsentRuleSetRequest | ContactPointRuleSetRequest | DistributionRuleSetRequest | OrganizationRuleSetRequest | OrganizationalUnitRuleSetRequest | PersonRuleSetRequest | PrimarySourceRuleSetRequest | ResourceRuleSetRequest | VariableRuleSetRequest | VariableGroupRuleSetRequest) PreviewAccessPlatform | PreviewActivity | PreviewBibliographicResource | PreviewConsent | PreviewContactPoint | PreviewDistribution | PreviewOrganization | PreviewOrganizationalUnit | PreviewPerson | PreviewPrimarySource | PreviewResource | PreviewVariable | PreviewVariableGroup ¶
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
- 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_ldap(q: str, offset: int = 0, limit: int = 10) PaginatedItemsContainer[ExtractedPerson] ¶
Search for persons in LDAP.
- 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_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
- update_rule_set(stable_target_id: str, rule_set: AccessPlatformRuleSetRequest | ActivityRuleSetRequest | BibliographicResourceRuleSetRequest | ConsentRuleSetRequest | ContactPointRuleSetRequest | DistributionRuleSetRequest | OrganizationRuleSetRequest | OrganizationalUnitRuleSetRequest | PersonRuleSetRequest | PrimarySourceRuleSetRequest | ResourceRuleSetRequest | VariableRuleSetRequest | VariableGroupRuleSetRequest) AccessPlatformRuleSetResponse | ActivityRuleSetResponse | BibliographicResourceRuleSetResponse | ConsentRuleSetResponse | ContactPointRuleSetResponse | DistributionRuleSetResponse | OrganizationRuleSetResponse | OrganizationalUnitRuleSetResponse | PersonRuleSetResponse | PrimarySourceRuleSetResponse | ResourceRuleSetResponse | 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 three rules