Source code for ace.centralize.models.entitylink

"""
    Entity Link models for Centralize graphql mutations

    Based on the GraphQL schema:
        - EntityLinkCreateParamsInput (for adding links)
        - EntityLinkUpdateParamsInput (for updating existing links)
        - EntityLinksUpdateParamsInput (for batch add/update/delete)
"""

from ace.centralize.models.base import ModelBase
from typing import List, Optional
from datetime import date


[docs] class EntityLinkCreateParamsInput(ModelBase): """Maps to EntityLinkCreateParamsInput in GraphQL schema. Schema fields: relatedEntityId: Int! (required) relatedEntityTypeId: UUID! (required) relationRoleId: Int! (required) effectiveDate: LocalDate expirationDate: LocalDate sharedPercent: BigDecimal """
[docs] def __init__( self, related_entity_type_id: str, related_entity_id: int, relation_role_id: int = 1, shared_percent: Optional[float] = None, effective_date: Optional[date] = None, expiration_date: Optional[date] = None, ): self.relatedEntityTypeId = related_entity_type_id self.relatedEntityId = related_entity_id self.relationRoleId = relation_role_id if shared_percent is not None: self.sharedPercent = shared_percent if effective_date is not None: self.effectiveDate = effective_date if expiration_date is not None: self.expirationDate = expiration_date
[docs] class EntityLinkUpdateParamsInput(ModelBase): """Maps to EntityLinkUpdateParamsInput in GraphQL schema. The update type does NOT allow re-pointing the link (no relatedEntityId/relatedEntityTypeId). Schema fields: id: Int! (required) effectiveDate: LocalDate expirationDate: LocalDate relationRoleId: Int sharedPercent: BigDecimal """
[docs] def __init__( self, entity_link_id: int, effective_date: Optional[date] = None, expiration_date: Optional[date] = None, relation_role_id: Optional[int] = None, shared_percent: Optional[float] = None, ): self.id = entity_link_id if effective_date is not None: self.effectiveDate = effective_date if expiration_date is not None: self.expirationDate = expiration_date if relation_role_id is not None: self.relationRoleId = relation_role_id if shared_percent is not None: self.sharedPercent = shared_percent
[docs] class EntityLinksUpdateParamsInput(ModelBase): """Maps to EntityLinksUpdateParamsInput in GraphQL schema. Schema fields: entityLinksToAdd: [EntityLinkCreateParamsInput!] entityLinksToDelete: [Int!] entityLinksToUpdate: [EntityLinkUpdateParamsInput!] """
[docs] def __init__( self, entity_links_to_add: Optional[List[EntityLinkCreateParamsInput]] = None, entity_links_to_delete: Optional[List[int]] = None, entity_links_to_update: Optional[List[EntityLinkUpdateParamsInput]] = None, ): if entity_links_to_add is not None: self.entityLinksToAdd = entity_links_to_add if entity_links_to_delete is not None: self.entityLinksToDelete = entity_links_to_delete if entity_links_to_update is not None: self.entityLinksToUpdate = entity_links_to_update