
    ZThO                        d dl mZ d dlmZmZmZ d dlmZmZm	Z	m
Z
 d dlmZmZ d dlmZmZmZ  G d de      Z G d d	e      Zy
)    )annotations)ListOptionalUnion)	BaseModel
ConfigDictfield_validatormodel_validator)NotRequired	TypedDict)ExpressionChannelReference'ExpressionChannelReferenceChannelConfig_channel_references_from_dictsc                      e Zd ZU dZ ed      Zded<   dZded<   ded<   d	ed
<   dZded<   dZ	ded<   dZ
ded<   dZded<   dZded<   dZded<    edd      ed               Z ed
d      e	 	 	 	 dd              Z ed      d        Zy)CalculatedChannelConfiga  
    Configuration for a calculated channel.

    - `name`: Name of the calculated channel.
    - `description`: Description of the calculated channel.
    - `expression`: The expression to calculate the value of the calculated channel.
    - `channel_references`: A list of channel references that are used in the expression. Each reference can either
      be an `ExpressionChannelReference` or `ExpressionChannelReferenceChannelConfig`.
    - `units`: Units of the calculated channel.
    - `client_key`: A user defined string that uniquely identifies the calculated channel. Name is unique, but may be changed.
    - `asset_names`: A list of asset names to make the calculation available for.
    - `tags`: A list of tags on assets to make the calculation available for. NOTE: Not yet supported.
    - `all_assets`: A flag that, when set to `True`, associates the calculated channel with all assets.
    T)arbitrary_types_allowedstrname description
expressionPList[Union[ExpressionChannelReference, ExpressionChannelReferenceChannelConfig]]channel_referencesNzOptional[str]unitscalculated_channel_id
client_keyzOptional[List[str]]asset_names	tag_namesFbool
all_assetsbefore)modec                     |rt        d      |S )Nz!`tag_names` is not yet supported.)
ValueError)clsvs     g/home/www/backend.miabetepe.com/venv/lib/python3.12/site-packages/sift_py/calculated_channels/config.pycheck_for_unsupported_tagsz2CalculatedChannelConfig.check_for_unsupported_tags.   s     @AA    c                    t        |t              st        d      |D ]&  }t        |t              r
d|vsd|vst        d       t	        |      S )Nz$`channel_references` must be a list.channel_identifierchannel_configzq`channel_references` must be a list of `ExpressionChannelReference` or `ExpressionChannelReferenceChannelConfig`.)
isinstancelistr$   dictr   )r%   rawrefs      r'   convert_channel_referencesz2CalculatedChannelConfig.convert_channel_references5   sc    
 #t$CDD 	Cc4($C/4DC4O  H 		 .c22r)   afterc                    | j                   s#| j                  s| j                  st        d      | j                  r#| j                   s| j                  rt        d      | S )NzcAt least one of `asset_names`, `tag_names` must be specified or `all_assets` must be set to `True`.zL`all_assets` cannot be `True` if `asset_names` or `tag_names` are specified.)r   r   r    r$   )selfs    r'   validate_assetsz'CalculatedChannelConfig.validate_assetsG   sU    tu  ?? 0 0DNN^  r)   )r0   r   returnz List[ExpressionChannelReference])__name__
__module____qualname____doc__r   model_config__annotations__r   r   r   r   r   r   r    r	   classmethodr(   r2   r
   r6    r)   r'   r   r      s     d;L
IKO   E=+/=/ $J$'+K$+%)I")J[x0  1
 )93b3	)3  :3  '"	 #	r)   r   c                  l    e Zd ZU dZded<   ded<   ded<   ded<   ded<   d	ed
<   d	ed<   ded<   ded<   y)CalculatedChannelUpdatea  
    Represents a dictionary for updating properties of a calculated channel. All fields are optional
    and only the provided fields will be updated.

    - `name`: Updated name of the calculated channel.
    - `description`: Updated description of the calculated channel.
    - `units`: String representing the units for the calculated channel.
    - `expression`: Updated expression used to calculate channel values.
    - `channel_references`: A list of channel references which can either be `ExpressionChannelReference`
       or `ExpressionChannelReferenceChannelConfig` used in the expression.
    - `asset_names`: List of assets associated with the calculation.
    - `tags`: List of tags for associating the calculated channel to assets.
    - `all_assets`: Boolean flag indicating if the calculated channel applies to all assets.
    - `archived`: Boolean flag indicating if the calculated channel is archived.
    zNotRequired[str]r   r   r   r   z]NotRequired[List[Union[ExpressionChannelReference, ExpressionChannelReferenceChannelConfig]]]r   zNotRequired[List[str]]r   r   zNotRequired[bool]r    archivedN)r8   r9   r:   r;   r=   r?   r)   r'   rA   rA   T   sE      !!    ('%%!!r)   rA   N)
__future__r   typingr   r   r   pydanticr   r   r	   r
   typing_extensionsr   r   sift_py.rule.configr   r   r   r   rA   r?   r)   r'   <module>rH      s<    " ( ( L L 4 Bi BJ i  r)   