Orion Client Links¶
Orion Type Link¶
Record Type Link¶
- class orionclient.links.RecordLink(resource, record_id, field_name=None)¶
A link to a specific OEMolRecord within a Dataset. Optional to associate an OEField with the link. Inherits from OrionLink.
- get_field(include_meta=True)¶
Retrieves the OEField associated with the link
- Returns
OEField
- Raises
OrionLinkError – If link does not contain a field name
- get_orion_resource()¶
Retrieves the Orion Resource that indicates the base Orion resource that the linked resource is stored in.
- get_record()¶
Retrieves the record that the link is associated with
- Returns
Record
- Return type
- Raises
OrionLinkError – If unable to find the specified record
Shard Type Link¶
- class orionclient.links.ShardLink(resource, shard_id)¶
A link to a specific Shard within a Collection. Inherits from OrionLink.
- get_orion_resource()¶
Retrieves the Orion Resource that indicates the base Orion resource that the linked resource is stored in.
- get_shard()¶
Retrieve the shard associated with the link.
- Returns
Shard
- Raises
OrionLinkError – Unable to find specified shard
Note
To store an OrionLink
on an `OEMolRecord`
:
from datarecord import OEMolRecord, OEField, Types
from orionclient.session import APISession
from orionclient.types import Dataset
record = OEMolRecord()
field = OEField("Orion Link", Types.Link)
# Storing an OrionLink to an arbitrary Orion Resource in a record (substitute any class in orionclient/types and modify method of creation)
orion_resource = Dataset.upload(APISession, "Test Dataset", "test_file.oedb")
record.set_value(field, APISession.create_link(orion_resource))
# Retreiving an OrionLink from an existing record
orion_link = APISession.get_link(record.get_value(field))