Skip to content

Tags

albert.resources.tags

TagEntity

Bases: str, Enum

The kind of entity a tag can be attached to.

Attributes:

Name Type Description
INVENTORY str

Inventory items.

COMPANY str

Companies.

INVENTORY

INVENTORY = 'Inventory'

COMPANY

COMPANY = 'Company'

Tag

Bases: BaseResource

A freeform text label used to categorize and connect entities.

Tags are shared by name across the platform and can be applied to inventory items, companies, tasks, and other records to group and filter them. Managed through TagCollection (client.tags); the usual entry point is get_or_create.

Example

from albert.resources.tags import Tag
tag = Tag(tag="high-priority")

Methods:

Name Description
from_string

Build a Tag from its name string.

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"
    },
    "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 freeform text label used to categorize and connect entities.\n\nTags are shared by name across the platform and can be applied to inventory\nitems, companies, tasks, and other records to group and filter them. Managed\nthrough [`TagCollection`][albert.collections.tags.TagCollection] (``client.tags``);\nthe usual entry point is [`get_or_create`][albert.collections.tags.TagCollection.get_or_create].\n\n!!! example\n    ```python\n    from albert.resources.tags import Tag\n    tag = Tag(tag=\"high-priority\")\n    ```\nMethods\n-------\nfrom_string(tag) -> Tag\n    Build a Tag from its name string.",
  "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."
    },
    "name": {
      "description": "The name of the tag (its text label).",
      "title": "Name",
      "type": "string"
    },
    "albertId": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The Albert ID of the tag (format ``TAG...``). Set when the tag is retrieved from or created in Albert. Methods ------- from_string(tag) -> Tag Build a Tag from its name string.",
      "title": "Albertid"
    }
  },
  "required": [
    "name"
  ],
  "title": "Tag",
  "type": "object"
}

Fields:

tag

tag: str

The name of the tag (its text label).

id

id: str | None = None

The Albert ID of the tag (format TAG...). Set when the tag is retrieved from or created in Albert. Methods ------- from_string(tag) -> Tag Build a Tag from its name string.

from_string

from_string(tag: str) -> Tag

Build a Tag from its name string.

Example

from albert.resources.tags import Tag
tag = Tag.from_string("experimental")

Parameters:

Name Type Description Default
tag str

The name of the tag.

required

Returns:

Type Description
Tag

A Tag with the given name.

Source code in src/albert/resources/tags.py
@classmethod
def from_string(cls, tag: str) -> Tag:
    """Build a Tag from its name string.

    !!! example
        ```python
        from albert.resources.tags import Tag
        tag = Tag.from_string("experimental")
        ```

    Parameters
    ----------
    tag : str
        The name of the tag.

    Returns
    -------
    Tag
        A Tag with the given name.
    """
    return cls(tag=tag)