o
    i                  	   @  s  U d Z ddlmZ ddlZddlZddlZddlmZmZ ddl	m
Z
 ddlmZmZ ddlmZ ddlmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZm Z  ddl!Z"dd	l#m$Z$m%Z%m&Z&m'Z' ddl(Z)ddl*Z)ddl+Z)ddl,Z)ddl-Z)e
G d
d dZ.G dd deZ/G dd deZ0G dd deZ1e
ddG dd dZ2eee3 ee4 ee5 ee6 ee f Z7de8d< ee3e7f Z9de8d< ee3e4e5e6eee3 f Z:de8d< ede3e4e5e6eee3 Z;G dd deZ<G dd deee; Z=e
ddG dd  d e=e; Z>G d!d" d"e$ee; Z?G d#d$ d$eee; Z@e
ddG d%d& d&e@e; ZAe
ddG d'd( d(ee? ZBeBg d)eB_C	*dudvd1d2ZDee3ee3e4e5e6f f ZEde8d3< G d4d5 d5eZFG d6d7 d7eZGG d8d9 d9eGZHG d:d; d;eGZIG d<d= d=eGZJG d>d? d?eGZKG d@dA dAeGZLG dBdC dCeGZMG dDdE dEeFZNG dFdG dGeGZOG dHdI dIeHeOZPG dJdK dKeIeOZQG dLdM dMeJeOZRG dNdO dOeKeOZSG dPdQ dQeLeOZTG dRdS dSeMeOZUeN eF_Ve
ddG dTdU dUZWeWddddVeW_XG dWdX dXeZYe
ddG dYdZ dZZZG d[d\ d\eZ[e
ddG d]d^ d^e[Z\e
ddG d_d` d`e[Z]e^ Z_dwdedfZ`dxdkdlZaebebjcebedjcebe4jedm ejffZgdydqdrZhG dsdt dteZidS )zz%Common code used in the Temporal SDK.    )annotationsN)ABCabstractmethod)	dataclass)datetime	timedelta)IntEnum)AnyCallableClassVar
CollectionGenericIteratorListMappingOptionalSequenceTextTupleTypeTypeVarUnionget_type_hintsoverload)
NamedTupleSelf	TypeAlias
get_originc                   @  s   e Zd ZU dZ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dZdddZdddZd	S )RetryPolicyz.Options for retrying workflows and activities.   )secondsr   initial_intervalg       @floatbackoff_coefficientNzOptional[timedelta]maximum_intervalr   intmaximum_attemptszOptional[Sequence[str]]non_retryable_error_typesproto$temporalio.api.common.v1.RetryPolicyreturnc                 C  s@   t | j | j| dr| j nd| j| jr| jdS ddS )z,Create a retry policy from the proto object.r$   N)r!   r#   r$   r&   r'   )r   r!   ToTimedeltar#   HasFieldr$   r&   r'   r(    r.   W/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/temporalio/common.py
from_protoD   s   	zRetryPolicy.from_protoNonec                 C  sZ   |    |j| j | j|_|j| jp| jd  | j|_| jr+|j| j dS dS )z:Apply the fields in this policy to the given proto object.d   N)	_validater!   FromTimedeltar#   r$   r&   r'   extendselfr(   r.   r.   r/   apply_to_protoS   s   zRetryPolicy.apply_to_protoc                 C  s|   | j dkrd S | j dk rtd| jdk rtd| jr3| j dk r)td| j| jk r3td| j dk r<tdd S )Nr   r   z#Initial interval cannot be negativez)Backoff coefficient cannot be less than 1z#Maximum interval cannot be negativez5Maximum interval cannot be less than initial intervalz#Maximum attempts cannot be negative)r&   r!   total_seconds
ValueErrorr#   r$   r7   r.   r.   r/   r3   a   s    


zRetryPolicy._validate)r(   r)   r*   r   )r(   r)   r*   r1   )r*   r1   )__name__
__module____qualname____doc__r   r!   __annotations__r#   r$   r&   r'   staticmethodr0   r8   r3   r.   r.   r.   r/   r   *   s    
 
r   c                   @  X   e Zd ZdZeejjjj	j
Zeejjjj	jZeejjjj	jZeejjjj	jZdS )WorkflowIDReusePolicyz~How already-in-use workflow IDs are handled on start.

    See :py:class:`temporalio.api.enums.v1.WorkflowIdReusePolicy`.
    N)r<   r=   r>   r?   r%   
temporalioapienumsv1WorkflowIdReusePolicy(WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATEALLOW_DUPLICATE4WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE_FAILED_ONLYALLOW_DUPLICATE_FAILED_ONLY)WORKFLOW_ID_REUSE_POLICY_REJECT_DUPLICATEREJECT_DUPLICATE-WORKFLOW_ID_REUSE_POLICY_TERMINATE_IF_RUNNINGTERMINATE_IF_RUNNINGr.   r.   r.   r/   rC   u       rC   c                   @  rB   )WorkflowIDConflictPolicyzHow already-running workflows of the same ID are handled on start.

    See :py:class:`temporalio.api.enums.v1.WorkflowIdConflictPolicy`.
    N)r<   r=   r>   r?   r%   rD   rE   rF   rG   WorkflowIdConflictPolicy'WORKFLOW_ID_CONFLICT_POLICY_UNSPECIFIEDUNSPECIFIED WORKFLOW_ID_CONFLICT_POLICY_FAILFAIL(WORKFLOW_ID_CONFLICT_POLICY_USE_EXISTINGUSE_EXISTING.WORKFLOW_ID_CONFLICT_POLICY_TERMINATE_EXISTINGTERMINATE_EXISTINGr.   r.   r.   r/   rR      rQ   rR   c                   @  sF   e Zd ZdZeejjjj	j
Zeejjjj	jZeejjjj	jZdS )QueryRejectConditionzWhether a query should be rejected in certain conditions.

    See :py:class:`temporalio.api.enums.v1.QueryRejectCondition`.
    N)r<   r=   r>   r?   r%   rD   rE   rF   rG   r\   QUERY_REJECT_CONDITION_NONENONEQUERY_REJECT_CONDITION_NOT_OPENNOT_OPEN,QUERY_REJECT_CONDITION_NOT_COMPLETED_CLEANLYNOT_COMPLETED_CLEANLYr.   r.   r.   r/   r\      s    r\   T)frozenc                   @  s.   e Zd ZU dZded< dddZdd
dZdS )RawValuea   Representation of an unconverted, raw payload.

    This type can be used as a parameter or return type in workflows,
    activities, signals, and queries to pass through a raw payload.
    Encoding/decoding of the payload is still done by the system.
    z temporalio.api.common.v1.Payloadpayloadr*   objectc                 C  s   d| j   S )Pickle support.   1)re   SerializeToStringr;   r.   r.   r/   __getstate__   s   zRawValue.__getstate__stater1   c              	   C  s\   t |tstdt| |dd dkstdt| dtjj	j
j|dd  dS )rg   zExpected bytes state, got Nr   rh   zBad version prefixre   )
isinstancebytes	TypeErrortyper:   rf   __setattr__rD   rE   commonrG   Payload
FromString)r7   rk   r.   r.   r/   __setstate__   s   
zRawValue.__setstate__N)r*   rf   )rk   rf   r*   r1   )r<   r=   r>   r?   r@   rj   rt   r.   r.   r.   r/   rd      s
   
 
rd   r   SearchAttributeValuesSearchAttributesSearchAttributeValueSearchAttributeValueTypec                   @  s   e Zd ZdZeejjjj	j
Zeejjjj	jZeejjjj	jZeejjjj	jZeejjjj	jZeejjjj	jZeejjjj	jZdS )SearchAttributeIndexedValueTypez(Server index type of a search attribute.N)r<   r=   r>   r?   r%   rD   rE   rF   rG   IndexedValueTypeINDEXED_VALUE_TYPE_TEXTTEXTINDEXED_VALUE_TYPE_KEYWORDKEYWORDINDEXED_VALUE_TYPE_INTINTINDEXED_VALUE_TYPE_DOUBLEDOUBLEINDEXED_VALUE_TYPE_BOOLBOOLINDEXED_VALUE_TYPE_DATETIMEDATETIMEINDEXED_VALUE_TYPE_KEYWORD_LISTKEYWORD_LISTr.   r.   r.   r/   ry      s    ry   c                   @  s   e Zd ZdZeed6ddZeed7ddZeed8d
dZed9ddZ	ed6ddZ
d:ddZd;ddZed<ddZed<ddZed=dd Zed>d"d#Zed?d%d&Zed@d(d)ZedAd+d,ZedBd/d0ZedCd3d4Zd5S )DSearchAttributeKeyzpTyped search attribute key representation.

    Use one of the ``for`` static methods here to create a key.
    r*   strc                 C     dS )zGet the name of the key.Nr.   r;   r.   r.   r/   name      zSearchAttributeKey.namery   c                 C  r   )z%Get the server index typed of the keyNr.   r;   r.   r.   r/   indexed_value_type   r   z%SearchAttributeKey.indexed_value_typeType[SearchAttributeValueType]c                 C  r   )zGet the Python type of value for the key.

        This may contain generics which cannot be used in ``isinstance``.
        :py:attr:`origin_value_type` can be used instead.
        Nr.   r;   r.   r.   r/   
value_type   s   zSearchAttributeKey.value_typer   c                 C  s   t | jp| jS )z:Get the Python type of value for the key without generics.)r   r   r;   r.   r.   r/   origin_value_type  s   z$SearchAttributeKey.origin_value_typec                 C  sv   | j }|tjkr
dS |tjkrdS |tjkrdS |tjkrdS |tjkr&dS |tjkr-dS |tjkr4dS t	d|  )	Nr   KeywordIntDoubleBoolDatetimeKeywordListzUnrecognized type: )
r   ry   r|   r~   r   r   r   r   r   r:   )r7   
index_typer.   r.   r/   _metadata_type  s    






z!SearchAttributeKey._metadata_typevaluerx   /SearchAttributeUpdate[SearchAttributeValueType]c                 C  s   t t | |S )zUCreate a search attribute update to set the given value on this
        key.
        _SearchAttributeUpdaterx   )r7   r   r.   r.   r/   	value_set  s   zSearchAttributeKey.value_setc                 C  s   t t | dS )z@Create a search attribute update to unset the value on this key.Nr   r;   r.   r.   r/   value_unset"  s   zSearchAttributeKey.value_unsetr   SearchAttributeKey[str]c                 C     t t | tjtS )z&Create a 'Text' search attribute type.)_SearchAttributeKeyr   ry   r|   r   r.   r.   r/   for_text&     zSearchAttributeKey.for_textc                 C  r   )z)Create a 'Keyword' search attribute type.)r   r   ry   r~   r   r.   r.   r/   for_keyword+     zSearchAttributeKey.for_keywordSearchAttributeKey[int]c                 C  r   )z&Create an 'Int' search attribute type.)r   r%   ry   r   r   r.   r.   r/   for_int2  r   zSearchAttributeKey.for_intSearchAttributeKey[float]c                 C  r   )z(Create a 'Double' search attribute type.)r   r"   ry   r   r   r.   r.   r/   	for_float7  r   zSearchAttributeKey.for_floatSearchAttributeKey[bool]c                 C  r   )z&Create a 'Bool' search attribute type.)r   boolry   r   r   r.   r.   r/   for_bool>  r   zSearchAttributeKey.for_boolSearchAttributeKey[datetime]c                 C  r   )z*Create a 'Datetime' search attribute type.)r   r   ry   r   r   r.   r.   r/   for_datetimeE  r   zSearchAttributeKey.for_datetime!SearchAttributeKey[Sequence[str]]c                 C  s   t tt  | tjtt S )z-Create a 'KeywordList' search attribute type.)r   r   r   ry   r   r   r.   r.   r/   for_keyword_listL  s
   
z#SearchAttributeKey.for_keyword_listmetadata_typeOptional[SearchAttributeKey]c                 C  s   |dkr	t | S |dkrt | S |dkrt | S |dkr$t | S |dkr-t | S |dkr6t | S |dkr?t | S d S )Nr   r   r   r   r   r   r   )r   r   r   r   r   r   r   r   )r   r   r.   r.   r/   _from_metadata_typeV  s   






z&SearchAttributeKey._from_metadata_typevalsru   c                 C  s   |sd S t |dkrt|d trt| S d S t|d tr$t| S t|d tr0t| S t|d tr<t	| S t|d t
rHt| S t|d trTt| S d S )Nr   r   )lenrl   r   r   r   r   r%   r   r"   r   r   r   r   r   )r   r   r.   r.   r/   _guess_from_untyped_valuesj  s"   





z-SearchAttributeKey._guess_from_untyped_valuesNr*   r   r*   ry   r*   r   )r*   r   )r   rx   r*   r   )r*   r   )r   r   r*   r   )r   r   r*   r   )r   r   r*   r   )r   r   r*   r   )r   r   r*   r   )r   r   r*   r   )r   r   r   r   r*   r   )r   r   r   ru   r*   r   )r<   r=   r>   r?   propertyr   r   r   r   r   r   r   r   rA   r   r   r   r   r   r   r   r   r   r.   r.   r.   r/   r      sF    

	r   c                   @  sP   e Zd ZU ded< ded< ded< eddd	Zedd
dZedddZdS )r   r   _namery   _indexed_value_typer   _value_typer*   c                 C     | j S Nr   r;   r.   r.   r/   r        z_SearchAttributeKey.namec                 C  r   r   )r   r;   r.   r.   r/   r     r   z&_SearchAttributeKey.indexed_value_typec                 C  r   r   )r   r;   r.   r.   r/   r     r   z_SearchAttributeKey.value_typeNr   r   r   )r<   r=   r>   r@   r   r   r   r   r.   r.   r.   r/   r     s   
 r   c                   @  s"   e Zd ZU dZded< ded< dS )SearchAttributePairz=A named tuple representing a key/value search attribute pair.,SearchAttributeKey[SearchAttributeValueType]keyrx   r   N)r<   r=   r>   r?   r@   r.   r.   r.   r/   r     s   
 r   c                   @  s4   e Zd ZdZeed
ddZeedddZd	S )SearchAttributeUpdatez,Representation of a search attribute update.r*   r   c                 C  r   )zKey that is being set.Nr.   r;   r.   r.   r/   r     r   zSearchAttributeUpdate.key"Optional[SearchAttributeValueType]c                 C  r   )z3Value that is being set or ``None`` if being unset.Nr.   r;   r.   r.   r/   r     r   zSearchAttributeUpdate.valueNr*   r   r*   r   )r<   r=   r>   r?   r   r   r   r   r.   r.   r.   r/   r     s    r   c                   @  s:   e Zd ZU ded< ded< edddZeddd	Zd
S )r   r   _keyr   _valuer*   c                 C  r   r   )r   r;   r.   r.   r/   r     r   z_SearchAttributeUpdate.keyc                 C  r   r   )r   r;   r.   r.   r/   r     r   z_SearchAttributeUpdate.valueNr   r   )r<   r=   r>   r@   r   r   r   r.   r.   r.   r/   r     s   
 r   c                   @  s   e Zd ZU dZded< 	 ded< 	 dd Zd&d
dZd'ddZd(ddZd)ddZ	e
d*ddZe
d+ddZ	d,d-d"dZd.d$d%ZdS )/TypedSearchAttributeszCollection of typed search attributes.

    This is represented as an immutable collection of
    :py:class:`SearchAttributePair`. This can be created passing a sequence of
    pairs to the constructor.
    zSequence[SearchAttributePair]search_attributeszClassVar[TypedSearchAttributes]emptyc                 C  sh   t | dt| jdd d t| jD ]\}}|dkr1| j|d  jj|jjkr1td|jj qdS )	zPost-init initialization.r   c                 S  s   | j jS r   r   r   )pairr.   r.   r/   <lambda>  s    z5TypedSearchAttributes.__post_init__.<locals>.<lambda>r   r   r   z1Duplicate search attribute entries found for key N)rf   rp   sortedr   	enumerater   r   r:   )r7   ir   r.   r.   r/   __post_init__  s   "z#TypedSearchAttributes.__post_init__r*   r%   c                 C  
   t | jS )z$Get the number of search attributes.)r   r   r;   r.   r.   r/   __len__     
zTypedSearchAttributes.__len__r   r   rx   c                   s*   t  fdd| D d}|du rt |S )zVGet a single search attribute value by key or fail with
        ``KeyError``.
        c                 3  s     | ]\}}| kr|V  qd S r   r.   .0kvr   r.   r/   	<genexpr>  s    z4TypedSearchAttributes.__getitem__.<locals>.<genexpr>N)nextKeyError)r7   r   retr.   r   r/   __getitem__  s   z!TypedSearchAttributes.__getitem__Iterator[SearchAttributePair]c                 C  r   )z6Get an iterator over search attribute key/value pairs.)iterr   r;   r.   r.   r/   __iter__  r   zTypedSearchAttributes.__iter__rf   r   c                   s   t  fdd| D S )zCheck whether this search attribute contains the given key.

        This uses key equality so the key must be the same name and type.
        c                 3  s    | ]	\}}| kV  qd S r   r.   r   r   r.   r/   r     s    z5TypedSearchAttributes.__contains__.<locals>.<genexpr>)anyr7   r   r.   r   r/   __contains__  s   z"TypedSearchAttributes.__contains__r   c                 C     d S r   r.   r   r.   r.   r/   get     zTypedSearchAttributes.getdefaulttemporalio.types.AnyType9Union[SearchAttributeValueType, temporalio.types.AnyType]c                 C  r   r   r.   r7   r   r   r.   r.   r/   r     s   NOptional[Any]r	   c                 C  s$   z|  |W S  ty   | Y S w )z\Get an attribute value for a key (or default). This is similar to
        dict.get.
        )r   r   r   r.   r.   r/   r     s
   r   c                   sT   t | j}|D ] t fddt|D d}|du r!|  q ||< qt|S )zvCopy this collection, replacing attributes with matching key names or
        adding if key name not present.
        c                 3  s(    | ]\}} j j|j jkr|V  qd S r   r   )r   r   
index_attrattrr.   r/   r     s    z0TypedSearchAttributes.updated.<locals>.<genexpr>N)listr   r   r   appendr   )r7   r   attrsexisting_indexr.   r   r/   updated  s   


zTypedSearchAttributes.updated)r*   r%   )r   r   r*   rx   )r*   r   )r   rf   r*   r   )r   r   r*   r   )r   r   r   r   r*   r   r   )r   r   r   r   r*   r	   )r   r   r*   r   )r<   r=   r>   r?   r@   r   r   r   r   r   r   r   r   r.   r.   r.   r/   r     s$   
 



	r   )r      
attributes&Optional[Union[SearchAttributes, Any]]stack_levelr%   r*   r1   c                 C  s.   | rt | trtjdtd| d d S d S d S )Nz1Dictionary-based search attributes are deprecatedr   )
stacklevel)rl   r   warningswarnDeprecationWarning)r   r   r.   r.   r/   %_warn_on_deprecated_search_attributes'  s   
r  MetricAttributesc                   @  s   e Zd ZU dZded< 	 e	d!d"ddZe	d!d#ddZe	d!d$ddZe	d!d%ddZ	e	d!d&ddZ
e	d!d'ddZed(dd ZdS ))MetricMeterz#Metric meter for recording metrics.zClassVar[MetricMeter]noopNr   r   descriptionOptional[str]unitr*   MetricCounterc                 C  r   )a  Create a counter metric for adding values.

        Args:
            name: Name for the metric.
            description: Optional description for the metric.
            unit: Optional unit for the metric.

        Returns:
            Counter metric.
        Nr.   r7   r   r  r  r.   r.   r/   create_counter<     zMetricMeter.create_counterMetricHistogramc                 C  r   a  Create a histogram metric for recording values.

        Args:
            name: Name for the metric.
            description: Optional description for the metric.
            unit: Optional unit for the metric.

        Returns:
            Histogram metric.
        Nr.   r
  r.   r.   r/   create_histogramL  r  zMetricMeter.create_histogramMetricHistogramFloatc                 C  r   r  r.   r
  r.   r.   r/   create_histogram_float\  r  z"MetricMeter.create_histogram_floatMetricHistogramTimedeltac                 C  r   )a  Create a histogram metric for recording values.

        Note, duration precision is millisecond. Also note, if "unit" is set as
        "duration", it will be converted to "ms" or "s" on the way out.

        Args:
            name: Name for the metric.
            description: Optional description for the metric.
            unit: Optional unit for the metric.

        Returns:
            Histogram metric.
        Nr.   r
  r.   r.   r/   create_histogram_timedeltal     z&MetricMeter.create_histogram_timedeltaMetricGaugec                 C  r   a  Create a gauge metric for setting values.

        Args:
            name: Name for the metric.
            description: Optional description for the metric.
            unit: Optional unit for the metric.

        Returns:
            Gauge metric.
        Nr.   r
  r.   r.   r/   create_gauge  r  zMetricMeter.create_gaugeMetricGaugeFloatc                 C  r   r  r.   r
  r.   r.   r/   create_gauge_float  r  zMetricMeter.create_gauge_floatadditional_attributesr  c                 C  r   )a[  Create a new metric meter with the given attributes appended to the
        current set.

        Args:
            additional_attributes: Additional attributes to append to the
                current set.

        Returns:
            New metric meter.

        Raises:
            TypeError: Attribute values are not the expected type.
        Nr.   r7   r  r.   r.   r/   with_additional_attributes  r  z&MetricMeter.with_additional_attributesNNr   r   r  r  r  r  r*   r	  r   r   r  r  r  r  r*   r  r   r   r  r  r  r  r*   r  r   r   r  r  r  r  r*   r  r   r   r  r  r  r  r*   r  r   r   r  r  r  r  r*   r  r  r  r*   r  )r<   r=   r>   r?   r@   r   r  r  r  r  r  r  r  r.   r.   r.   r/   r  6  s0   
 r  c                   @  sT   e Zd ZdZeedddZeedddZeedd	d
ZedddZ	dS )MetricCommonzBase for all metrics.r*   r   c                 C  r   )zName for the metric.Nr.   r;   r.   r.   r/   r     r   zMetricCommon.namer  c                 C  r   )z"Description for the metric if any.Nr.   r;   r.   r.   r/   r    r   zMetricCommon.descriptionc                 C  r   )zUnit for the metric if any.Nr.   r;   r.   r.   r/   r    r   zMetricCommon.unitr  r  r   c                 C  r   )aO  Create a new metric with the given attributes appended to the
        current set.

        Args:
            additional_attributes: Additional attributes to append to the
                current set.

        Returns:
            New metric.

        Raises:
            TypeError: Attribute values are not the expected type.
        Nr.   r  r.   r.   r/   r    r  z'MetricCommon.with_additional_attributesNr   r*   r  r  r  r*   r   )
r<   r=   r>   r?   r   r   r   r  r  r  r.   r.   r.   r/   r%    s    r%  c                   @  "   e Zd ZdZe	ddd	d
ZdS )r	  z)Counter metric created by a metric meter.Nr   r%   r  Optional[MetricAttributes]r*   r1   c                 C  r   )aK  Add a value to the counter.

        Args:
            value: A non-negative integer to add.
            additional_attributes: Additional attributes to append to the
                current set.

        Raises:
            ValueError: Value is negative.
            TypeError: Attribute values are not the expected type.
        Nr.   r7   r   r  r.   r.   r/   add     zMetricCounter.addr   r   r%   r  r)  r*   r1   )r<   r=   r>   r?   r   r+  r.   r.   r.   r/   r	    
    r	  c                   @  r(  )r  +Histogram metric created by a metric meter.Nr   r%   r  r)  r*   r1   c                 C  r   )aS  Record a value on the histogram.

        Args:
            value: A non-negative integer to record.
            additional_attributes: Additional attributes to append to the
                current set.

        Raises:
            ValueError: Value is negative.
            TypeError: Attribute values are not the expected type.
        Nr.   r*  r.   r.   r/   record  r,  zMetricHistogram.recordr   r-  r<   r=   r>   r?   r   r0  r.   r.   r.   r/   r    r.  r  c                   @  r(  )r  r/  Nr   r"   r  r)  r*   r1   c                 C  r   )aQ  Record a value on the histogram.

        Args:
            value: A non-negative float to record.
            additional_attributes: Additional attributes to append to the
                current set.

        Raises:
            ValueError: Value is negative.
            TypeError: Attribute values are not the expected type.
        Nr.   r*  r.   r.   r/   r0  	  r,  zMetricHistogramFloat.recordr   r   r"   r  r)  r*   r1   r1  r.   r.   r.   r/   r    r.  r  c                   @  r(  )r  r/  Nr   r   r  r)  r*   r1   c                 C  r   )a  Record a value on the histogram.

        Note, duration precision is millisecond.

        Args:
            value: A non-negative timedelta to record.
            additional_attributes: Additional attributes to append to the
                current set.

        Raises:
            ValueError: Value is negative.
            TypeError: Attribute values are not the expected type.
        Nr.   r*  r.   r.   r/   r0    r  zMetricHistogramTimedelta.recordr   r   r   r  r)  r*   r1   r1  r.   r.   r.   r/   r    r.  r  c                   @  r(  )r  'Gauge metric created by a metric meter.Nr   r%   r  r)  r*   r1   c                 C  r   )aI  Set a value on the gauge.

        Args:
            value: A non-negative integer to set.
            additional_attributes: Additional attributes to append to the
                current set.

        Raises:
            ValueError: Value is negative.
            TypeError: Attribute values are not the expected type.
        Nr.   r*  r.   r.   r/   set5  r,  zMetricGauge.setr   r-  r<   r=   r>   r?   r   r5  r.   r.   r.   r/   r  2  r.  r  c                   @  r(  )r  r4  Nr   r"   r  r)  r*   r1   c                 C  r   )aG  Set a value on the gauge.

        Args:
            value: A non-negative float to set.
            additional_attributes: Additional attributes to append to the
                current set.

        Raises:
            ValueError: Value is negative.
            TypeError: Attribute values are not the expected type.
        Nr.   r*  r.   r.   r/   r5  J  r,  zMetricGaugeFloat.setr   r2  r6  r.   r.   r.   r/   r  G  r.  r  c                   @  sj   e Zd Z	dd d	d
Z	dd!ddZ	dd"ddZ	dd#ddZ	dd$ddZ	dd%ddZd&ddZ	dS )'_NoopMetricMeterNr   r   r  r  r  r*   r	  c                 C     t |||S r   )_NoopMetricCounterr
  r.   r.   r/   r  ]     z_NoopMetricMeter.create_counterr  c                 C  r8  r   )_NoopMetricHistogramr
  r.   r.   r/   r  b  r:  z!_NoopMetricMeter.create_histogramr  c                 C  r8  r   )_NoopMetricHistogramFloatr
  r.   r.   r/   r  g  r:  z'_NoopMetricMeter.create_histogram_floatr  c                 C  r8  r   )_NoopMetricHistogramTimedeltar
  r.   r.   r/   r  l  r:  z+_NoopMetricMeter.create_histogram_timedeltar  c                 C  r8  r   )_NoopMetricGauger
  r.   r.   r/   r  q  r:  z_NoopMetricMeter.create_gauger  c                 C  r8  r   )_NoopMetricGaugeFloatr
  r.   r.   r/   r  v  r:  z#_NoopMetricMeter.create_gauge_floatr  r  r  c                 C     | S r   r.   r  r.   r.   r/   r  {  r   z+_NoopMetricMeter.with_additional_attributesr  r  r  r   r!  r"  r#  r$  )
r<   r=   r>   r  r  r  r  r  r  r  r.   r.   r.   r/   r7  \  s    r7  c                   @  sJ   e Zd Zddd	Zedd
dZedddZedddZdddZdS )_NoopMetricr   r   r  r  r  r*   r1   c                 C  s   || _ || _|| _d S r   )r   _description_unitr
  r.   r.   r/   __init__  s   
z_NoopMetric.__init__c                 C  r   r   r   r;   r.   r.   r/   r     r   z_NoopMetric.namec                 C  r   r   )rB  r;   r.   r.   r/   r    r   z_NoopMetric.descriptionc                 C  r   r   )rC  r;   r.   r.   r/   r    r   z_NoopMetric.unitr  r  r   c                 C  r@  r   r.   r  r.   r.   r/   r    r   z&_NoopMetric.with_additional_attributesN)r   r   r  r  r  r  r*   r1   r   r&  r'  )	r<   r=   r>   rD  r   r   r  r  r  r.   r.   r.   r/   rA    s    
rA  c                   @     e Zd Z	d
ddd	ZdS )r9  Nr   r%   r  r)  r*   r1   c                 C  r   r   r.   r*  r.   r.   r/   r+    r   z_NoopMetricCounter.addr   r-  )r<   r=   r>   r+  r.   r.   r.   r/   r9        r9  c                   @  rE  )r;  Nr   r%   r  r)  r*   r1   c                 C  r   r   r.   r*  r.   r.   r/   r0    r   z_NoopMetricHistogram.recordr   r-  r<   r=   r>   r0  r.   r.   r.   r/   r;    rF  r;  c                   @  rE  )r<  Nr   r"   r  r)  r*   r1   c                 C  r   r   r.   r*  r.   r.   r/   r0    r   z _NoopMetricHistogramFloat.recordr   r2  rG  r.   r.   r.   r/   r<    rF  r<  c                   @  rE  )r=  Nr   r   r  r)  r*   r1   c                 C  r   r   r.   r*  r.   r.   r/   r0    r   z$_NoopMetricHistogramTimedelta.recordr   r3  rG  r.   r.   r.   r/   r=    rF  r=  c                   @  rE  )r>  Nr   r%   r  r)  r*   r1   c                 C  r   r   r.   r*  r.   r.   r/   r5    r   z_NoopMetricGauge.setr   r-  r<   r=   r>   r5  r.   r.   r.   r/   r>    rF  r>  c                   @  rE  )r?  Nr   r"   r  r)  r*   r1   c                 C  r   r   r.   r*  r.   r.   r/   r5    r   z_NoopMetricGaugeFloat.setr   r2  rH  r.   r.   r.   r/   r?    rF  r?  c                   @  sf   e Zd ZU dZdZded< 	 dZded< 	 dZded< 	 d	ed
< 	 edddZ	dddZ
dd ZdS )Priorityaz  Priority contains metadata that controls relative ordering of task processing when tasks are
    backlogged in a queue. Initially, Priority will be used in activity and workflow task queues,
    which are typically where backlogs exist.

    Priority is (for now) attached to workflows and activities. Activities and child workflows
    inherit Priority from the workflow that created them, but may override fields when they are
    started or modified. For each field of a Priority on an activity/workflow, not present or equal
    to zero/empty string means to inherit the value from the calling workflow, or if there is no
    calling workflow, then use the default (documented on the field).

    The overall semantics of Priority are:
    1. First, consider "priority_key": lower number goes first.
    2. Then consider "fairness_key" and "fairness_weight" for fairness balancing.
    NzOptional[int]priority_keyr  fairness_keyzOptional[float]fairness_weightzClassVar[Priority]r   r(   !temporalio.api.common.v1.Priorityr*   c                 C  s6   t | jr| jnd| jr| jnd| jr| jdS ddS )z1Create a Priority instance from the proto object.NrJ  rK  rL  )rI  rJ  rK  rL  r-   r.   r.   r/   _from_proto  s   
zPriority._from_protoc                 C  s@   t jjjj| jp	dd}| jd ur| j|_| jd ur| j|_|S )Nr   )rJ  )rD   rE   rq   rG   rI  rJ  rK  rL  r6   r.   r.   r/   	_to_proto  s   


zPriority._to_protoc                 C  s8   | j durt| j tstd| j dk rtddS dS )zValidates priority settings.Nzpriority_key must be an integerr   z'priority_key must be a positive integer)rJ  rl   r%   rn   r:   r;   r.   r.   r/   r     s   

zPriority.__post_init__)r(   rM  r*   rI  )r*   rM  )r<   r=   r>   r?   rJ  r@   rK  rL  rA   rO  rP  r   r.   r.   r.   r/   rI    s   
 


rI  rN  c                   @  s>   e Zd ZdZejjjjj	Z
	 ejjjjjZ	 ejjjjjZdS )VersioningBehaviorzsSpecifies when a workflow might move from a worker of one Build Id to another.

    WARNING: Experimental API.
    N)r<   r=   r>   r?   rD   rE   rF   rG   rQ  VERSIONING_BEHAVIOR_UNSPECIFIEDrU   VERSIONING_BEHAVIOR_PINNEDPINNED VERSIONING_BEHAVIOR_AUTO_UPGRADEAUTO_UPGRADEr.   r.   r.   r/   rQ    s    rQ  c                   @  sD   e Zd ZU dZded< ded< dddZedd	d
ZdddZdS )WorkerDeploymentVersionz\Represents the version of a specific worker deployment.

    WARNING: Experimental API.
    r   deployment_namebuild_idr*   c                 C  s   | j  d| j S )z;Returns the canonical string representation of the version..)rX  rY  r;   r.   r.   r/   to_canonical_string<  s   z+WorkerDeploymentVersion.to_canonical_string	canonicalc                 C  s<   | j ddd}t|dkrtd|  dt|d |d S )zParse a version from a canonical string, which must be in the format
        `<deployment_name>.<build_id>`. Deployment name must not have a `.` in it.
        rZ  r   )maxsplitr   zCannot parse version string: z0, must be in format <deployment_name>.<build_id>r   )splitr   r:   rW  )r\  partsr.   r.   r/   from_canonical_string@  s   
z-WorkerDeploymentVersion.from_canonical_string4temporalio.api.deployment.v1.WorkerDeploymentVersionc                 C  s   t jjjj| j| jdS ) Convert to proto representation.)rY  rX  )rD   rE   
deploymentrG   rW  rY  rX  r;   r.   r.   r/   rP  L  s   
z!WorkerDeploymentVersion._to_protoNr   )r\  r   r*   rW  )r*   ra  )	r<   r=   r>   r?   r@   r[  rA   r`  rP  r.   r.   r.   r/   rW  2  s   
 
rW  c                   @  s   e Zd ZdZedddZdS )VersioningOverridezRepresents the override of a worker's versioning behavior for a workflow execution.

    .. warning::
        Experimental API.
    r*   -temporalio.api.workflow.v1.VersioningOverridec                 C  r   )rb  Nr.   r;   r.   r.   r/   rP  [  r   zVersioningOverride._to_protoNr*   re  )r<   r=   r>   r?   r   rP  r.   r.   r.   r/   rd  T  s    rd  c                   @  s$   e Zd ZU dZded< d	ddZdS )
PinnedVersioningOverridezjWorkflow will be pinned to a specific deployment version.

    .. warning::
        Experimental API.
    rW  versionr*   re  c                 C  sJ   t jjjjt jjjjj| j	 t jjjjj
| j t jjjjjjddS )rb  )rh  behavior)ri  pinned_versionpinned)rD   rE   workflowrG   rd  rF   rQ  rS  rh  r[  PinnedOverriderP  PinnedOverrideBehaviorPINNED_OVERRIDE_BEHAVIOR_PINNEDr;   r.   r.   r/   rP  k  s   
z"PinnedVersioningOverride._to_protoNrf  )r<   r=   r>   r?   r@   rP  r.   r.   r.   r/   rg  a  s   
 rg  c                   @  s   e Zd ZdZdddZdS )AutoUpgradeVersioningOverridezThe workflow will auto-upgrade to the current deployment version on the next workflow task.

    .. warning::
        Experimental API.
    r*   re  c                 C  s   t jjjjt jjjjjddS )rb  T)ri  auto_upgrade)rD   rE   rl  rG   rd  rF   rQ  rU  r;   r.   r.   r/   rP    s   
z'AutoUpgradeVersioningOverride._to_protoNrf  )r<   r=   r>   r?   rP  r.   r.   r.   r/   rp  x  s    rp  argr	   argsSequence[Any]c                 C  s   | t ur|r
td| g}|S )NzCannot have arg and args)
_arg_unsetr:   )rr  rs  r.   r.   r/   _arg_or_args  s
   rv  source8Optional[Mapping[str, temporalio.api.common.v1.Payload]]destVgoogle.protobuf.internal.containers.MessageMap[Text, temporalio.api.common.v1.Payload]c                 C  s0   | d u rd S |   D ]\}}|| | q
d S r   )itemsCopyFrom)rw  ry  r   r   r.   r.   r/   _apply_headers  s
   r}  
from_bytesfuncr
   +Tuple[Optional[List[Type]], Optional[Type]]c                 C  s2  t | s,t| ts,t| tjs,t| tr| nt| }t|dd}|dur,t|ts,|} t | }t	| }|
d}|t jjurB|nd}g }t|j D ]G\}}	|dkri|	jdkri|	jt jju sht|	jdkriqM|	jt jjur}|	jt jjur}d|f  S |
|	j}
|
t jju rd|f  S ||
 qM||fS )a  Extracts the type hints from the function.

    Args:
        func: Function to extract hints from.

    Returns:
        Tuple containing parameter types and return type. The parameter types
        will be None if there are any non-positional parameters or if any of the
        parameters to not have an annotation that represents a class. If the
        first parameter is "self" with no attribute, it is not included.
    __call__Nr*   r   r7   ztyping.Self)inspect
isfunctionrl   _non_user_defined_callablestypes
MethodTypero   getattr	signaturer   r   	Signaturer   r   
parametersvaluesr   
annotation	Parameterr   kindPOSITIONAL_ONLYPOSITIONAL_OR_KEYWORDr   )r  tmp_func	call_funcsighintsret_hintr   rs  indexr   arg_hintr.   r.   r/   _type_hints_from_func  s>   




r  c                   @  s    e Zd ZdZdZ	 dZ	 dZdS )HeaderCodecBehaviorz(Different ways to handle header encodingr   r      N)r<   r=   r>   r?   NO_CODECCODECWORKFLOW_ONLY_CODECr.   r.   r.   r/   r    s    r  )r   )r   r   r   r%   r*   r1   )rr  r	   rs  rt  r*   rt  )rw  rx  ry  rz  r*   r1   )r  r
   r*   r  )jr?   
__future__r   r  r  r   abcr   r   dataclassesr   r   r   enumr   typingr	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   #google.protobuf.internal.containersgoogletyping_extensionsr   r   r   r   temporalio.api.common.v1rD   temporalio.api.deployment.v1temporalio.api.enums.v1temporalio.api.workflow.v1temporalio.typesr   rC   rR   r\   rd   r   r%   r"   r   ru   r@   rv   rw   rx   ry   r   r   r   r   r   r   r   r  r  r  r%  r	  r  r  r  r  r  r7  rA  r9  r;  r<  r=  r>  r?  r  rI  r   rQ  rW  rd  rg  rp  rf   ru  rv  r}  ro   r  all__dict__BuiltinFunctionTyper  r  r  r.   r.   r.   r/   <module>   s    LJ   j })%R!


B