Skip to content

Lists

albert.resources.lists

ListItemCategory

Bases: str, Enum

The category a list item belongs to, which governs its allowed list types.

Attributes:

Name Type Description
BUSINESS_DEFINED str

Predefined values managed at the business/organization level.

USER_DEFINED str

Custom values defined by users.

PROJECTS str

Values used by projects (e.g. project states).

EXTENSIONS str

Values used by extensions.

INVENTORY str

Values used by inventory (e.g. CAS categories or inventory functions).

BUSINESS_DEFINED

BUSINESS_DEFINED = 'businessDefined'

USER_DEFINED

USER_DEFINED = 'userDefined'

PROJECTS

PROJECTS = 'projects'

EXTENSIONS

EXTENSIONS = 'extensions'

INVENTORY

INVENTORY = 'inventory'

ListItem

Bases: BaseResource

A single allowed value in a configurable list of options.

List items back the choices offered by list-type custom fields (e.g. dropdown options) and other fixed option sets in Albert. A CustomField with LIST defines a list (keyed by list_type, typically the field's name); its selectable options are ListItem records with a matching list_type. Managed through ListsCollection (client.lists).

Example

from albert.resources.lists import ListItem, ListItemCategory
item = ListItem(name="In Progress", category=ListItemCategory.USER_DEFINED)
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"
    },
    "ListItemCategory": {
      "description": "The category a list item belongs to, which governs its allowed list types.\n\nAttributes\n----------\nBUSINESS_DEFINED : str\n    Predefined values managed at the business/organization level.\nUSER_DEFINED : str\n    Custom values defined by users.\nPROJECTS : str\n    Values used by projects (e.g. project states).\nEXTENSIONS : str\n    Values used by extensions.\nINVENTORY : str\n    Values used by inventory (e.g. CAS categories or inventory functions).",
      "enum": [
        "businessDefined",
        "userDefined",
        "projects",
        "extensions",
        "inventory"
      ],
      "title": "ListItemCategory",
      "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 single allowed value in a configurable list of options.\n\nList items back the choices offered by ``list``-type custom fields (e.g.\ndropdown options) and other fixed option sets in Albert. A\n[`CustomField`][albert.resources.custom_fields.CustomField] with\n[`LIST`][albert.resources.custom_fields.FieldType.LIST] defines a list (keyed\nby ``list_type``, typically the field's name); its selectable options are\n``ListItem`` records with a matching ``list_type``. Managed through\n[`ListsCollection`][albert.collections.lists.ListsCollection] (``client.lists``).\n\n!!! example\n    ```python\n    from albert.resources.lists import ListItem, ListItemCategory\n    item = ListItem(name=\"In Progress\", category=ListItemCategory.USER_DEFINED)\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."
    },
    "name": {
      "description": "The display name of the list item (the option value).",
      "title": "Name",
      "type": "string"
    },
    "albertId": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The Albert ID of the list item. Set when the item is retrieved from or created in Albert.",
      "title": "Albertid"
    },
    "category": {
      "anyOf": [
        {
          "$ref": "#/$defs/ListItemCategory"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The category of the list item. Allowed values are ``businessDefined``, ``userDefined``, ``projects``, ``extensions``, and ``inventory``."
    },
    "listType": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The list this item belongs to. For a list-type custom field this is typically the field's name (see [`CustomField`][albert.resources.custom_fields.CustomField]). For built-in categories the allowed values are ``projectState`` for ``projects``, ``extensions`` for ``extensions``, and ``casCategory`` or ``inventoryFunction`` for ``inventory``.",
      "title": "Listtype"
    }
  },
  "required": [
    "name"
  ],
  "title": "ListItem",
  "type": "object"
}

Fields:

Validators:

name

name: str

The display name of the list item (the option value).

id

id: str | None = None

The Albert ID of the list item. Set when the item is retrieved from or created in Albert.

category

category: ListItemCategory | None = None

The category of the list item. Allowed values are businessDefined, userDefined, projects, extensions, and inventory.

list_type

list_type: str | None = None

The list this item belongs to. For a list-type custom field this is typically the field's name (see CustomField). For built-in categories the allowed values are projectState for projects, extensions for extensions, and casCategory or inventoryFunction for inventory.

validate_list_type

validate_list_type() -> ListItem
Source code in src/albert/resources/lists.py
@model_validator(mode="after")
def validate_list_type(self) -> ListItem:
    allowed_by_category = {
        ListItemCategory.PROJECTS: {"projectState"},
        ListItemCategory.EXTENSIONS: {"extensions"},
        ListItemCategory.INVENTORY: {"casCategory", "inventoryFunction"},
    }
    if (
        self.list_type is not None
        and self.category in allowed_by_category
        and self.list_type not in allowed_by_category[self.category]
    ):
        raise ValueError(
            f"List type {self.list_type} is not allowed for category {self.category}"
        )
    return self