Skip to content

Base Models

albert.core.shared.models.base

AuditFields

The audit fields for a resource

Show JSON schema:
{
  "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"
}

Fields:

by

by: str = None

by_name

by_name: str | None = None

at

at: datetime | None = None
Show JSON schema:
{
  "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"
}

Fields:

id

id: str

name

name: str | None = None

category

category: str | None = None
to_entity_link() -> EntityLink
Source code in src/albert/core/shared/models/base.py
def to_entity_link(self) -> EntityLink:
    # Convience method to return self, so you can call this method on objects that are already entity links
    return self

EntityLinkWithName

EntityLink that includes the name field in serialization.

Show JSON schema:
{
  "description": "EntityLink that includes the name field in serialization.",
  "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": "EntityLinkWithName",
  "type": "object"
}

Fields:

name

name: str | None = None

LocalizedNames

Show JSON schema:
{
  "properties": {
    "de": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "De"
    },
    "ja": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Ja"
    },
    "zh": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Zh"
    },
    "es": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Es"
    }
  },
  "title": "LocalizedNames",
  "type": "object"
}

Fields:

de

de: str | None = None

ja

ja: str | None = None

zh

zh: str | None = None

es

es: str | None = None

BaseResource

The base resource for all Albert resources.

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": "The base resource for all Albert resources.",
  "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."
    }
  },
  "title": "BaseResource",
  "type": "object"
}

Fields:

status

status: Status | None = None

The status of the resource, optional.

created

created: AuditFields | None = None

Audit fields for the creation of the resource, optional.

updated

updated: AuditFields | None = None

Audit fields for the update of the resource, optional.

to_entity_link() -> EntityLink
Source code in src/albert/core/shared/models/base.py
def to_entity_link(self) -> EntityLink:
    if id := getattr(self, "id", None):
        return EntityLink(id=id)
    raise AlbertException(
        "A non-null 'id' is required to create an entity link. "
        "Ensure the linked object is registered and has a valid 'id'."
    )
to_entity_link_with_name() -> EntityLinkWithName
Source code in src/albert/core/shared/models/base.py
def to_entity_link_with_name(self) -> EntityLinkWithName:
    if id := getattr(self, "id", None):
        return EntityLinkWithName(id=id, name=getattr(self, "name", None))
    raise AlbertException(
        "A non-null 'id' is required to create an entity link. "
        "Ensure the linked object is registered and has a valid 'id'."
    )

BaseSessionResource

BaseSessionResource(**data)
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"
    }
  },
  "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."
    }
  },
  "title": "BaseSessionResource",
  "type": "object"
}

Fields:

Source code in src/albert/core/shared/models/base.py
def __init__(self, **data):
    super().__init__(**data)
    self._session = data.get("session")

session

session: AlbertSession | None