plexus.dashboard.api.models.identifier module
Identifier Model - API interface for identifier management and exact-match searching.
This model provides the Python API interface for the new Identifier table, enabling efficient exact-match searches by identifier value within account boundaries.
Key Features: - O(1) exact-match lookups using GSI byAccountAndValue - Account-scoped searches for security and performance - Batch operations for efficient bulk lookups - Integration with existing Item model via itemId relationship
- Usage Examples:
# Find item by exact identifier value identifier = Identifier.find_by_value(“CUST-123456”, account_id, client) if identifier:
item = Item.get_by_id(identifier.itemId, client)
# Create identifier for an item identifier = Identifier.create(
client=client, itemId=”item123”, name=”Customer ID”, value=”CUST-123456”, accountId=”account123”, url=”https://crm.example.com/customers/123456”
)
# Batch exact-match lookup identifiers = Identifier.batch_find_by_values(
[“CUST-123456”, “ORD-789012”], account_id, client
)
- GSI Usage:
This model leverages the following Global Secondary Indexes: - byAccountAndValue: Primary exact-match search (accountId + value) - byAccountNameAndValue: Search within identifier type (accountId + name + value) - byItemId: Get all identifiers for a specific item
- class plexus.dashboard.api.models.identifier.Identifier(itemId: str, name: str, value: str, accountId: str, createdAt: datetime.datetime, updatedAt: datetime.datetime, url: str | None = None, position: int | None = None, client: ForwardRef('PlexusDashboardClient') | None = None)
Bases:
BaseModel- __init__(itemId: str, name: str, value: str, accountId: str, createdAt: datetime, updatedAt: datetime, url: str | None = None, position: int | None = None, client: PlexusDashboardClient | None = None)
- accountId: str
- classmethod batch_create_for_item(client: PlexusDashboardClient, item_id: str, account_id: str, identifiers_data: List[Dict[str, Any]]) List[Identifier]
Create multiple identifiers for an item in a single operation.
- Args:
client: API client item_id: ID of the item these identifiers belong to account_id: Account ID for data isolation identifiers_data: List of identifier data dicts with ‘name’, ‘value’, and optional ‘url’
- Returns:
List of created Identifier objects
- classmethod batch_find_by_values(values: List[str], account_id: str, client: PlexusDashboardClient) Dict[str, Identifier]
Batch exact-match lookup for multiple identifier values.
Returns a dictionary mapping value -> Identifier for found identifiers. Missing values will not appear in the result dictionary.
- Args:
values: List of identifier values to search for account_id: Account to search within client: API client
- Returns:
Dict mapping found values to their Identifier objects
- classmethod create(client: PlexusDashboardClient, itemId: str, name: str, value: str, accountId: str, url: str | None = None, position: int | None = None) Identifier
Create a new identifier record.
- createdAt: datetime
- delete() bool
Delete this identifier.
- classmethod fields() str
Return the GraphQL fields to query for this model
- classmethod find_by_name_and_value(name: str, value: str, account_id: str, client: PlexusDashboardClient) Identifier | None
Find an identifier by name and exact value within an account.
Uses regular listIdentifiers with compound filter for compatibility.
- classmethod find_by_value(value: str, account_id: str, client: PlexusDashboardClient) Identifier | None
Find an identifier by exact value within an account.
Uses the byAccountAndValue GSI for O(1) performance. Returns the first matching identifier or None if not found.
- classmethod from_dict(data: Dict[str, Any], client: PlexusDashboardClient) Identifier
Create an Identifier instance from API response data.
- itemId: str
- classmethod list_by_item_id(item_id: str, client: PlexusDashboardClient) List[Identifier]
Get all identifiers for a specific item.
Uses the byItemId GSI for efficient lookup.
- name: str
- position: int | None = None
- update(**kwargs) Identifier
Update this identifier with new values.
- updatedAt: datetime
- url: str | None = None
- value: str