Skip to content

Emulator id

EmulationID dataclass

Value Object representing an emulation's unique identifier.

Source code in libs/ddd/value-objects/value_objects/emulator_id.py
@dataclass(frozen=True)
class EmulationID:
    """Value Object representing an emulation's unique identifier."""

    value: str

    def __post_init__(self):
        """Ensure the ID is a valid UUID."""
        try:
            uuid.UUID(self.value)  # Validate UUID format
        except ValueError:
            raise ValueError(f"Invalid EmulationID: {self.value}") from None

    @classmethod
    def generate(cls) -> "EmulationID":
        """Generate a new AgentID."""
        return cls(value=str(uuid.uuid4()))

__post_init__()

Ensure the ID is a valid UUID.

Source code in libs/ddd/value-objects/value_objects/emulator_id.py
def __post_init__(self):
    """Ensure the ID is a valid UUID."""
    try:
        uuid.UUID(self.value)  # Validate UUID format
    except ValueError:
        raise ValueError(f"Invalid EmulationID: {self.value}") from None

generate() classmethod

Generate a new AgentID.

Source code in libs/ddd/value-objects/value_objects/emulator_id.py
@classmethod
def generate(cls) -> "EmulationID":
    """Generate a new AgentID."""
    return cls(value=str(uuid.uuid4()))