Skip to content

Links

LinkCategory

Bases: str, Enum

The kind of relationship a link represents.

Attributes:

Name Type Description
MENTION

One entity mentions another (e.g. a user or entity referenced in a note).

LINKED_TASK

A task linked to another entity.

SYNTHESIS

A synthesis relationship between entities.

LINKED_INVENTORY

An inventory item linked to another entity.

MENTION

MENTION = 'mention'

One entity mentions another (e.g. a user or entity referenced in a note).

LINKED_TASK

LINKED_TASK = 'linkedTask'

A task linked to another entity.

SYNTHESIS

SYNTHESIS = 'synthesis'

A synthesis relationship between entities.

LINKED_INVENTORY

LINKED_INVENTORY = 'linkedInventory'

An inventory item linked to another entity.

Bases: BaseResource

A directional relationship between two entities in Albert.

A link connects a parent entity to a child entity under a given LinkCategory. Links are managed through the LinksCollection.

Example

from albert.resources.links import Link, LinkCategory
from albert.core.shared.models.base import EntityLink
link = Link(
    parent=EntityLink(id="INVA9999999"),
    child=EntityLink(id="INVA9999998"),
    category=LinkCategory.LINKED_INVENTORY,
)
Show JSON schema:
{
  "$defs": {
    "AuditFields": {
      "description": "The audit fields for a resource",
      "properties": {
        "by": {
          "default": null,
          "title": "By",
          "type": "string"
        },
        "byName": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Byname"
        },
        "at": {
          "anyOf": [
            {
              "format": "date-time",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "At"
        }
      },
      "title": "AuditFields",
      "type": "object"
    },
    "EntityLink": {
      "properties": {
        "id": {
          "title": "Id",
          "type": "string"
        },
        "name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Name"
        },
        "category": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Category"
        }
      },
      "required": [
        "id"
      ],
      "title": "EntityLink",
      "type": "object"
    },
    "LinkCategory": {
      "description": "The kind of relationship a link represents.",
      "enum": [
        "mention",
        "linkedTask",
        "synthesis",
        "linkedInventory"
      ],
      "title": "LinkCategory",
      "type": "string"
    },
    "Status": {
      "description": "The status of a resource.\n\nAttributes\n----------\nACTIVE : str\n    The resource is fully operational and visible in normal operations.\nINACTIVE : str\n    The resource is hidden from normal operations and disabled from use.",
      "enum": [
        "active",
        "inactive"
      ],
      "title": "Status",
      "type": "string"
    }
  },
  "description": "A directional relationship between two entities in Albert.\n\nA link connects a ``parent`` entity to a ``child`` entity under a given\n[`LinkCategory`][albert.resources.links.LinkCategory]. Links are managed through the\n[`LinksCollection`][albert.collections.links.LinksCollection].\n\n!!! example\n    ```python\n    from albert.resources.links import Link, LinkCategory\n    from albert.core.shared.models.base import EntityLink\n    link = Link(\n        parent=EntityLink(id=\"INVA9999999\"),\n        child=EntityLink(id=\"INVA9999998\"),\n        category=LinkCategory.LINKED_INVENTORY,\n    )\n    ```",
  "properties": {
    "status": {
      "anyOf": [
        {
          "$ref": "#/$defs/Status"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The status of the resource, optional."
    },
    "Created": {
      "anyOf": [
        {
          "$ref": "#/$defs/AuditFields"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Audit fields for the creation of the resource, optional."
    },
    "Updated": {
      "anyOf": [
        {
          "$ref": "#/$defs/AuditFields"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Audit fields for the update of the resource, optional."
    },
    "Parent": {
      "$ref": "#/$defs/EntityLink",
      "description": "The parent (source) entity of the link."
    },
    "Child": {
      "$ref": "#/$defs/EntityLink",
      "description": "The child (target) entity of the link."
    },
    "category": {
      "$ref": "#/$defs/LinkCategory",
      "description": "The category of the link (e.g. ``mention``, ``linkedTask``, ``synthesis``, ``linkedInventory``)."
    },
    "counter": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "An optional counter associated with the link.",
      "title": "Counter"
    },
    "albertId": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The Albert ID of the link (format ``LNK...``). Assigned by Albert when the link is created.",
      "title": "Albertid"
    }
  },
  "required": [
    "Parent",
    "Child",
    "category"
  ],
  "title": "Link",
  "type": "object"
}

Fields:

parent

parent: EntityLink

The parent (source) entity of the link.

child

child: EntityLink

The child (target) entity of the link.

category

category: LinkCategory

The category of the link (e.g. mention, linkedTask, synthesis, linkedInventory).

counter

counter: int | None = None

An optional counter associated with the link.

id

id: str | None = None

The Albert ID of the link (format LNK...). Assigned by Albert when the link is created.