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.

fetch_extracted_items(query_string: str | None, stable_target_id: str | None, entity_type: list[str] | None, skip: int, limit: int) ExtractedItemsResponse

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, skip: int, limit: int) MergedItemsResponse

Fetch merged items that match the given set of filters.

Parameters:
  • query_string – Full-text search query

  • 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 merged 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

post_extracted_items(extracted_items: list[ExtractedAccessPlatform | ExtractedActivity | ExtractedBibliographicResource | ExtractedConsent | ExtractedContactPoint | ExtractedDistribution | ExtractedOrganization | ExtractedOrganizationalUnit | ExtractedPerson | ExtractedPrimarySource | ExtractedResource | ExtractedVariable | ExtractedVariableGroup]) IdentifiersResponse

Post extracted items to the backend in bulk.

Parameters:

extracted_items – Extracted items to post

Raises:

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

Returns:

Response model 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

mex.common.backend_api.models.BulkInsertResponse

alias of IdentifiersResponse

class mex.common.backend_api.models.ExtractedItemsRequest(*, items: list[ExtractedAccessPlatform | ExtractedActivity | ExtractedBibliographicResource | ExtractedConsent | ExtractedContactPoint | ExtractedDistribution | ExtractedOrganization | ExtractedOrganizationalUnit | ExtractedPerson | ExtractedPrimarySource | ExtractedResource | ExtractedVariable | ExtractedVariableGroup])

Bases: BaseModel

Request model for a list of extracted items.

items: list[ExtractedAccessPlatform | ExtractedActivity | ExtractedBibliographicResource | ExtractedConsent | ExtractedContactPoint | ExtractedDistribution | ExtractedOrganization | ExtractedOrganizationalUnit | ExtractedPerson | ExtractedPrimarySource | ExtractedResource | ExtractedVariable | ExtractedVariableGroup]
model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {'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_default': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[Dict[str, FieldInfo]] = {'items': FieldInfo(annotation=list[Union[ExtractedAccessPlatform, ExtractedActivity, ExtractedBibliographicResource, ExtractedConsent, ExtractedContactPoint, ExtractedDistribution, ExtractedOrganization, ExtractedOrganizationalUnit, ExtractedPerson, ExtractedPrimarySource, ExtractedResource, ExtractedVariable, ExtractedVariableGroup]], required=True)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

class mex.common.backend_api.models.ExtractedItemsResponse(*, items: list[ExtractedAccessPlatform | ExtractedActivity | ExtractedBibliographicResource | ExtractedConsent | ExtractedContactPoint | ExtractedDistribution | ExtractedOrganization | ExtractedOrganizationalUnit | ExtractedPerson | ExtractedPrimarySource | ExtractedResource | ExtractedVariable | ExtractedVariableGroup], total: int)

Bases: BaseModel

Response model for a list of extracted items including a total count.

items: list[ExtractedAccessPlatform | ExtractedActivity | ExtractedBibliographicResource | ExtractedConsent | ExtractedContactPoint | ExtractedDistribution | ExtractedOrganization | ExtractedOrganizationalUnit | ExtractedPerson | ExtractedPrimarySource | ExtractedResource | ExtractedVariable | ExtractedVariableGroup]
model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {'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_default': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[Dict[str, FieldInfo]] = {'items': FieldInfo(annotation=list[Union[ExtractedAccessPlatform, ExtractedActivity, ExtractedBibliographicResource, ExtractedConsent, ExtractedContactPoint, ExtractedDistribution, ExtractedOrganization, ExtractedOrganizationalUnit, ExtractedPerson, ExtractedPrimarySource, ExtractedResource, ExtractedVariable, ExtractedVariableGroup]], required=True), 'total': FieldInfo(annotation=int, required=True)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

total: int
class mex.common.backend_api.models.IdentifiersResponse(*, identifiers: list[Identifier])

Bases: BaseModel

Response models for a list of identifiers.

identifiers: list[Identifier]
model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {'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_default': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[Dict[str, FieldInfo]] = {'identifiers': FieldInfo(annotation=list[Identifier], required=True)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

class mex.common.backend_api.models.MergedItemsResponse(*, items: list[MergedAccessPlatform | MergedActivity | MergedBibliographicResource | MergedConsent | MergedContactPoint | MergedDistribution | MergedOrganization | MergedOrganizationalUnit | MergedPerson | MergedPrimarySource | MergedResource | MergedVariable | MergedVariableGroup], total: int)

Bases: BaseModel

Response model for a list of merged items including a total count.

items: list[MergedAccessPlatform | MergedActivity | MergedBibliographicResource | MergedConsent | MergedContactPoint | MergedDistribution | MergedOrganization | MergedOrganizationalUnit | MergedPerson | MergedPrimarySource | MergedResource | MergedVariable | MergedVariableGroup]
model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {'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_default': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[Dict[str, FieldInfo]] = {'items': FieldInfo(annotation=list[Union[MergedAccessPlatform, MergedActivity, MergedBibliographicResource, MergedConsent, MergedContactPoint, MergedDistribution, MergedOrganization, MergedOrganizationalUnit, MergedPerson, MergedPrimarySource, MergedResource, MergedVariable, MergedVariableGroup]], required=True), 'total': FieldInfo(annotation=int, required=True)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

total: int

Module contents