Address
Address class to store address of object
amsdal_utils.models.data_models.address.Address ¶
Bases: BaseModel
Represents a resource address with flexible identification.
Attributes: resource (str): The resource/connection name. class_name (str): The class name. class_version (Versions | str): The class specific version or LATEST/ALL. object_id (ObjectIDType): The object id. Can be either a single value or list of values in case of compound PK object_version (Versions | str): The object specific version or LATEST/ALL.
object_id_segments ¶
object_id_segments()
Return object_id as a flat list of PK segments.
Composite PK stored as a list/tuple → list(object_id).
Simple PK stored as a scalar → [object_id].
Inverse of :meth:normalize_object_id_to_scalar: where the validator
collapses a 1-element list into a scalar, this method always lifts
scalars into a 1-element list. Use this when you need to iterate
over PK segments uniformly regardless of storage form.
normalize_object_id_to_scalar
staticmethod
¶
normalize_object_id_to_scalar(object_id)
Collapse a 1-element list/tuple to its scalar element.
Used by :class:Reference to keep a single canonical form: a
simple-PK reference always stores object_id as a scalar, never as
[scalar], even when the value arrived from JSON as a 1-element
list. Multi-element lists (composite PKs) and bare scalars are
returned unchanged.
from_string
classmethod
¶
from_string(address)
Creates an Address instance from a string representation.
Args: cls (type[AddressType]): The class type. address (str): The string representation of the address.
Returns: AddressType: The Address instance created from the string.
Raises: ValueError: If the resource name is not specified in the address.
to_string ¶
to_string()
Convert Address instance to string representation.
Returns: String representation of the address
validate_version
classmethod
¶
validate_version(version)
Validate and convert version to Versions enum if possible.
Args: version: Version to validate
Returns: Validated version
is_complete
property
¶
is_complete
Check if the address is fully specified.
Returns: Whether all address components are specified
to_query ¶
to_query(prefix='')
Converts the Address instance to a query. Args: prefix (str, optional): The prefix for the query fields. Defaults to ''. Returns: Q: The query object.