
    K.hq                      d Z ddlmZ ddlZddlZddlZddlZddlZddlZ	ddl
Z
ddlZddlZddlZddlZddlZddlZddlZddlmZ ddlmZmZ ddlmZmZ ddl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& dd
l'm(Z(m)Z)m*Z* ddl+Z+ddl,m-Z. ddl+m/Z/ ddl0m1Z1 ddl2m3Z3 ddl4m5Z5 ddl6m7Z7 ddl8m9Z9 ddl:m;Z;m<Z< ddl=m>Z>m?Z? ddl@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZPmQZQmRZRmSZSmTZTmUZUmVZVmWZWmXZXmYZYmZZZm[Z[m\Z\m]Z]m^Z^m_Z_m`Z`maZambZbmcZcmdZdmeZemfZfmgZgmhZhmiZimjZjmkZk ddllmmZmmnZnmoZo 	 ddlpmqZq n# er$ r Y nw xY w e	js        d          Ztetu                     e	jv                               d2dZwd2dZxd3dZy	 d4d5d$Zz e$d%d&e_'          Z{ G d( d)e|e!e{                   Z} G d* d+          Z~ G d, d-e1          Z G d. d/e1          Z G d0 d1          ZdS )6aA  Jira Client module.

This module implements a friendly (well, friendlier) interface between the raw JSON
responses from Jira and the Resource/dict abstractions provided by this library. Users
will construct a JIRA object as described below. Full API documentation can be found
at: https://jira.readthedocs.io/en/latest/.
    )annotationsN)OrderedDict)IterableIterator)cachewraps)BufferedReader)Number)AnyCallableGenericLiteralSupportsIndexTypeVarno_type_checkoverload)parse_qsquoteurlparse)parse)Response)AuthBase)CaseInsensitiveDict)get_netrc_auth)MultipartEncoder)__version__)	JIRAErrorNotJIRAInstanceError)PrepareRequestForRetryResilientSession)+AgileResource
AttachmentBoardComment	ComponentCustomerCustomFieldOption	DashboardDashboardGadgetDashboardItemPropertyDashboardItemPropertyKeyFieldFilterGroupIssue	IssueLinkIssueLinkTypeIssuePropertyIssueSecurityLevelScheme	IssueTypeIssueTypeSchemeNotificationSchemePermissionSchemePinnedCommentPriorityPrioritySchemeProject
RemoteLinkRequestType
ResolutionResourceRoleSecurityLevelServiceDeskSprintStatusStatusCategoryUserVersionVotesWatchersWorkflowSchemeWorklog)
json_loadsremove_empty_attributesthreaded_requests)JWTAuthjiraclient_methodr   returnc                0     t                       fd}|S )aS  A convenience decorator to check if the Jira instance is cloud.

    Checks if the client instance is talking to Cloud Jira. If it is, return
    the result of the called client method. If not, return None and log a
    warning.

    Args:
      client_method: The method that is being called by the client.

    Returns:
      Either the result of the wrapped function or None.

    Raises:
      JIRAError: In the case the error is not an HTTP error with a status code.
      NotJIRAInstanceError: In the case that the first argument to this method
       is not a `client.JIRA` instance.
    c                     t          d | D                       }t          |t                    st          |          |j        r | i |S |j                            d           d S )Nc              3     K   | ]}|V  d S N .0args     ]/Users/user/workspace/sujinbaek/cqa-test-app/venv/lib/python3.11/site-packages/jira/client.py	<genexpr>z4cloud_api.<locals>.check_if_cloud.<locals>.<genexpr>   "      ,,,,,,,,    zIThis functionality is not available on Jira Data Center (Server) version.)next
isinstanceJIRAr   	_is_cloudlogwarning)argskwargsinstancerQ   s      r[   check_if_cloudz!cloud_api.<locals>.check_if_cloud   s     ,,t,,,,,(D)) 	1&x000 	2 =$1&111W	
 	
 	
 tr^   r   )rQ   rh   s   ` r[   	cloud_apirj   n   s4    $ 
-     r^   c                0     t                       fd}|S )aK  A convenience decorator to inform if a client method is experimental.

    Indicates the path covered by the client method is experimental. If the path
    disappears or the method becomes disallowed, this logs an error and returns
    None. If another kind of exception is raised, this reraises.

    Raises:
      JIRAError: In the case the error is not an HTTP error with a status code.
      NotJIRAInstanceError: In the case that the first argument to this method is
       is not a `client.JIRA` instance.

    Returns:
      Either the result of the wrapped function or None.
    c                 N   t          d | D                       }t          |t                    st          |          	  | i |S # t          $ rR}t          |dd           }|9|j        dv r0|j                            d|j	         d|j                    Y d }~d S  d }~ww xY w)Nc              3     K   | ]}|V  d S rV   rW   rX   s     r[   r\   zFexperimental_atlassian_api.<locals>.is_experimental.<locals>.<genexpr>   r]   r^   response)i    zFunctionality at path z# is/was experimental. Status Code: )
r_   r`   ra   r   r   getattrstatus_coderc   rd   url)re   rf   rg   ern   rQ   s        r[   is_experimentalz3experimental_atlassian_api.<locals>.is_experimental   s    ,,t,,,,,(D)) 	1&x000	 =$1&111 		 		 		q*d33H#(<
(J(J$$;X\ ; ;$,$8; ;   ttttt		s    A 
B$ABBB$ri   )rQ   rt   s   ` r[   experimental_atlassian_apiru      s4     
-    $ r^   funcc                >     t                     d fd            }|S )zDecorator that converts Issue and Project resources to their keys when used as arguments.

    Args:
        func (Callable): the function to decorate
    re   r   rf   rR   c                     g }| D ]}t          |t          t          z            r|                    |j                   :t          |t
                    r|                    |j                   j|                    |            |i |}|S rV   )r`   r/   r;   appendkeyr1   name)re   rf   arg_listrZ   resultrv   s        r[   wrapperz(translate_resource_args.<locals>.wrapper   s     	% 	%C#uw// %((((C// %))))$$$$x*6**r^   )re   r   rf   r   rR   r   ri   )rv   r~   s   ` r[   translate_resource_argsr      s:     4[[
 
 
 
 
 [
 Nr^   fieldsdict[str, Any] | None	fieldargsr   5dict[str, dict[str, Any]] | dict[str, dict[str, str]]c                    | d| iS d|iS )Nr   rW   )r   r   s     r[   _field_workerr      s      &!!i  r^   ResourceTypeT)contravariantboundc                  t     e Zd Z	 	 	 	 	 	 dddZddZd  fdZed!d            Zed"d            Zd Z xZS )#
ResultListNr   iterableIterable | None_startAtint_maxResults_total
int | None_isLastbool | None_nextPageToken
str | NonerR   Nonec                &   |t                               | |           nt                               |            || _        || _        || _        ||nt          |           | _        |rt          |          ng | _        | j        | _        || _	        dS )a  Results List.

        Args:
            iterable (Iterable): [description]. Defaults to None.
            _startAt (int): Start page. Defaults to 0.
            _maxResults (int): Max results per page. Defaults to 0.
            _total (Optional[int]): Total results from query. Defaults to 0.
            _isLast (Optional[bool]): True to mark this page is the last page? (Default: ``None``).
            _nextPageToken (Optional[str]): Token for fetching the next page of results. Defaults to None.
             see `The official API docs <https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/#expansion:~:text=for%20all%20operations.-,isLast,-indicates%20whether%20the>`_
        N)
list__init__startAt
maxResultsisLastlentotalr   currentnextPageToken)selfr   r   r   r   r   r   s          r[   r   zResultList.__init__   s    ( MM$))))MM$%%1VVs4yy
>F,NDNNNB|+r^   r   c                z    | xj         dz  c_         | j         | j        k    rt          | j        | j         dz
           S N   )r   r   StopIterationr   r   s    r[   __next__zResultList.__next__   s;    <$*$$=!122r^   Iterator[ResourceType]c                D    t                                                      S rV   )super__iter__)r   	__class__s    r[   r   zResultList.__iter__  s    ww!!!r^   ir   c                    d S rV   rW   )r   r   s     r[   __getitem__zResultList.__getitem__  s    =@Sr^   sslicelist[ResourceType]c                    d S rV   rW   )r   r   s     r[   r   zResultList.__getitem__  s    ;>3r^   c                8    t                               | |          S rV   )r   r   )r   slice_or_indexs     r[   r   zResultList.__getitem__  s    n555r^   )Nr   r   NNN)r   r   r   r   r   r   r   r   r   r   r   r   rR   r   )rR   r   )rR   r   )r   r   rR   r   )r   r   rR   r   )	__name__
__module____qualname__r   r   r   r   r   __classcell__)r   s   @r[   r   r      s         %)!#%)!, !, !, !, !,F3 3 3 3" " " " " " @@@ X@>>> X>6 6 6 6 6 6 6r^   r   c                  &    e Zd Zd Zd Zd Zd ZdS )QshGeneratorc                    || _         d S rV   )context_path)r   r   s     r[   r   zQshGenerator.__init__  s    (r^   c                    |                      |          }t          j        |                    d                                                    S )Nzutf-8)_generate_qshhashlibsha256encode	hexdigest)r   reqqshs      r[   __call__zQshGenerator.__call__  s=      %%~cjj1122<<>>>r^   c                    t          |j                  }t           j                  dk    r!|j        t           j                  d          n|j        }t          |j        d           fdD             d                    fdt          	                                          D                       }|j
                                         d| d| }|S )Nr   T)keep_blank_valuesc           	     n    i | ]1}|d                                          |                             2S ),)join_sort_and_quote_values)rY   rz   paramsr   s     r[   
<dictcomp>z.QshGenerator._generate_qsh.<locals>.<dictcomp>,  sF     
 
 
HKC$55fSkBBCC
 
 
r^   &c              3  2   K   | ]}| d |          V  dS )=NrW   )rY   rz   joineds     r[   r\   z-QshGenerator._generate_qsh.<locals>.<genexpr>/  s5      QQCC//&+//QQQQQQr^   )r   rr   r   r   pathr   queryr   sortedkeysmethodupper)r   r   parse_resultr   r   r   r   r   s   `     @@r[   r   zQshGenerator._generate_qsh   s   (( 4$%%)) c$"3446677" 	 ,,EEE
 
 
 
 
OU
 
 
 QQQQ6&++--;P;PQQQQQ!!##44d44U44
r^   c                8    t          |          }d |D             S )Nc                0    g | ]}t          |d           S )~safe)r   )rY   values     r[   
<listcomp>z7QshGenerator._sort_and_quote_values.<locals>.<listcomp>6  s%    CCC5e#&&&CCCr^   )r   )r   valuesordered_valuess      r[   r   z#QshGenerator._sort_and_quote_values4  s!    CCNCCCCr^   N)r   r   r   r   r   r   r   rW   r^   r[   r   r     sU        ) ) )? ? ?  (D D D D Dr^   r   c                  j    e Zd ZdZddZed	             Zd
 Zd ZddZ	d Z
ddZddZddZddZdS )JiraCookieAuthzJira Cookie Authentication.

    Allows using cookie authentication as described by `jira api docs <https://developer.atlassian.com/server/jira/platform/cookie-based-authentication/>`_
    sessionr    session_api_urlstrauthtuple[str, str]c                L    || _         || _        || _        d| _        d| _        dS )a  Cookie Based Authentication.

        Args:
            session (ResilientSession): The Session object to communicate with the API.
            session_api_url (str): The session api url to use.
            auth (Tuple[str, str]): The username, password tuple.
        r   r   N)_session_session_api_url_JiraCookieAuth__auth_retry_counter_401_max_allowed_401_retries)r   r   r   r   s       r[   r   zJiraCookieAuth.__init__?  s0       /"#()%%%r^   c                    | j         j        S rV   )r   cookiesr   s    r[   r   zJiraCookieAuth.cookiesO  s    }$$r^   c                &    | xj         dz  c_         d S r   r   r   s    r[   _increment_401_retry_counterz+JiraCookieAuth._increment_401_retry_counterS  s    1$r^   c                    d| _         d S Nr   r   r   s    r[   _reset_401_retry_counterz'JiraCookieAuth._reset_401_retry_counterV  s    "#r^   requestrequests.PreparedRequestc                <    |                     d| j                   |S )Nrn   )register_hook
handle_401r   r   s     r[   r   zJiraCookieAuth.__call__Y  s    j$/:::r^   c                    | j         \  }}||d}| j                            | j        t	          j        |                    }|                                 dS )zInitialise the Session object's cookies, so we can use the session cookie.

        Raises HTTPError if the post returns an erroring http response
        )usernamepassworddataN)r   r   postr   jsondumpsraise_for_status)r   r   r   authentication_datars        r[   init_sessionzJiraCookieAuth.init_session]  sg    
 "[(+3JJM!
3F(G(G  
 
 	
r^   rn   requests.ResponserR   c                @   |j         dk    r~| j        | j        k     rnt                              d           |                                  |                                  |                     |j        	                                          }| 
                                 |S )zRefresh cookies if the session cookie has expired. Then retry the request.

        Args:
            response (requests.Response): the response with the possible 401 to handle

        Returns:
            requests.Response
        i  z,Trying to refresh the cookie auth session...)rq   r   r   LOGinfor   r	  process_original_requestr   copyr   )r   rn   rf   s      r[   r   zJiraCookieAuth.handle_401i  s      C'''$*GGGHHCDDD--///44X5E5J5J5L5LMMH%%'''r^   original_requestc                V    |                      |           |                     |          S rV   )update_cookiessend_requestr   r  s     r[   r  z'JiraCookieAuth.process_original_request}  s,    ,---  !1222r^   c                \    d|j         v r|j         d= |                    | j                   d S )NCookie)headersprepare_cookiesr   r  s     r[   r  zJiraCookieAuth.update_cookies  s:     '/// (2((66666r^   c                6    | j                             |          S rV   )r   sendr   s     r[   r  zJiraCookieAuth.send_request  s    }!!'***r^   N)r   r    r   r   r   r   )r   r   )rn   r
  rR   r
  )r  r   )r   r   r   __doc__r   propertyr   r   r   r   r	  r   r  r  r  rW   r^   r[   r   r   9  s         
* * * *  % % X%% % %$ $ $   
 
 
   (3 3 3 37 7 7 7+ + + + + +r^   r   c                  "    e Zd ZdZd	dZd
dZdS )	TokenAuthzBearer Token Authentication.tokenr   c                    || _         d S rV   )_token)r   r  s     r[   r   zTokenAuth.__init__  s    r^   r  r   c                *    d| j          |j        d<   |S )NzBearer authorization)r!  r  )r   r  s     r[   r   zTokenAuth.__call__  s    %<t{%<%<	/"r^   N)r  r   )r  r   )r   r   r   r  r   r   rW   r^   r[   r  r    sB        &&        r^   r  c                     e Zd ZdZi dddddddd	d
ddej        dddddddddddddddddddddd ed!iZdZej	        Z	ej
        Z
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d?d@d:ZedAd=            Zd> ZedBd@            ZedCdA            ZdDdCZdD ZdE ZdF ZdEdHZdI ZddJde	dfdFdUZedJde	dfdGdV            ZdHdZZdId\ZdBd]Z	 dJdKdcZedLdMdf            Z	 dNdOdiZ dPdkZ!dQdRdnZ"dSdqZ#dTdsZ$e%	 dNdUdy            Z&dVd{Z'dWd|Z(e%	 	 	 	 dXdYd            Z)dWdZ*dVdZ+dZdZ,	 d[d\dZ-d]dZ.ee/	 	 	 d^d_d                        Z0ee/	 	 	 d^d`d                        Z1ee/dad                        Z2dbdZ3dcdZ4dddZ5ee/ded                        Z6ee/dfd                        Z7ee/	 	 	 	 	 	 dgdhd                        Z8didZ9djdZ:dkdZ;	 	 	 	 dldmdZ<	 	 	 	 dldndZ=dNdodZ>	 	 	 dpdqdZ?drdZ@dsdZAdsdZB	 	 	 d^dtdńZC	 	 dudvdǄZD	 dQdwdɄZEdʄ ZFdxd΄ZGdydЄZHdzd҄ZIe	 	 dudvdӄ            ZJd{dՄZK	 	 d|d}dׄZL	 	 d|d~dلZMdg dddfddZNddZOddZPe%dd            ZQe%	 	 	 	 dldd            ZRe%	 dNdd            ZSe%	 	 ddd            ZTe%dd            ZUe%dd            ZVe%dd            ZW	 	 	 d^ddZXddZYe%ddd            ZZddZ[e%	 	 	 d^dd	            Z\e%dd            Z]e%dd            Z^e%dd            Z_e%dd            Z`e%dd            Zae%dd            Zbe%dd            Zce%dd            Zde%dd            Zee%dd            Zfe%dd            Zge%dd            Zhe%dd             Zie%	 	 	 	 	 	 	 	 	 ddd(            Zje%dd*            Zke%dd,            Zle%dd-            Zme%	 dNdd2            ZndWd3Zodd5Zpddd8Zqdd:Zrdd<Zs	 	 d|dd>Zt	 	 d|ddAZuddCZvdNddDZwddGZxddHZy	 	 	 	 	 dddOZzddQZ{ddSZ|dNddUZ}dNddWZ~e%ddX            Ze%	 	 ddd]            Ze%dd_            Ze%dda            Ze%ddb            Ze%ddd            Ze%ddf            Ze%ddi            Ze%ddl            Ze%ddn            Ze%ddp            ZddrZddtZe	 	 	 	 	 	 ddddvdd}            Ze	 	 	 	 	 	 ddd~dd            Z	 	 	 	 	 	 ddddvddZe	 	 	 	 	 	 ddddvdĐd            ZedddŐd            ZdƐdZdǐdZdǐdZdȐdZdɐdZdʐdZdːdZd̐dZdNd͐dZ	 	 d|dΐdZ	 	 	 	 	 	 	 dϐdАdZdѐdZ	 	 ddҐdZdӐdZdԐdZdԐdZe%ddddՐd            Z	 	 	 	 	 	 d֐dאdZ	 	 	 	 dؐdِdZe%	 	 	 	 	 dڐdېd            Z	 ddܐdZdNdݐdZdWdZdWdZdސdZdߐdZddZddZddZ	 dNddZd Zd ZedNdd            ZddÄZddĄZdń Ze	fddǄZe	fddȄZe	fddɄZde	dfddʄZ	 dNdd΄Zdτ ZddфZddԄZddՄZddքZddd؄Z	 ddd܄Zdd݄ZddބZdNdd߄ZÐdNddZ	 dQddZŐd Zeǐdd            Zeǐd             Zeǐdd            Zeǐd             Zeǐd             Zeǐdd            Zeǐd             Zeǐd             Zeǐd             Zeǐd             ZѐdWdZҐdWdZӐddZ	 	 	 	 	 	 	 	 	 	 	 dddZ	 	 	 	 	 	 	 ddd
Z֐ddZאd dZؐdidZِddZ	 e%	 	 	 	 	 ddd            Ze%	 	 	 	 ddd            Z	 dddZ	 	 	 	 	 dddZސd	d Zߐd	d!Zd	d"Zd
d#Zdd%Zd& Z	 	 	 	 ddd/Z	 	 	 d^dd0Zdd2Z	 dNdd6Z	 	 ddd9Zdd:Ze%dd<            Ze%dd>            ZdS (  ra   a  User interface to Jira.

    Clients interact with Jira by constructing an instance of this object and calling its methods.
    For addressable resources in Jira -- those with "self" links -- an appropriate subclass of
    :py:class:`jira.resources.Resource` will be returned with customized ``update()`` and ``delete()`` methods,
    along with attribute access to fields. This means that calls of the form ``issue.fields.summary`` will be resolved into the proper lookups to return
    the JSON value at that mapping. Methods that do not return resources will return a dict constructed from the JSON response or a scalar value;
    see each method's documentation for details on what that method returns.

    Without any arguments, this client will connect anonymously to the Jira instance started by the Atlassian Plugin SDK from one of the
    'atlas-run', ``atlas-debug`` or ``atlas-run-standalone`` commands. By default, this instance runs at ``http://localhost:2990/jira``.
    The ``options`` argument can be used to set the Jira instance to use.

    Authentication is handled with the ``basic_auth`` argument. If authentication is supplied (and is accepted by Jira), the client will remember it for subsequent requests.

    For quick command line access to a server, see the ``jirashell`` script included with this distribution.

    The easiest way to instantiate is using ``j = JIRA("https://jira.atlassian.com")``
    serverzhttp://localhost:2990/jiraauth_urlz/rest/auth/1/sessionr   /	rest_pathapirest_api_version2agile_rest_pathagile_rest_api_versionz1.0verifyT	resilientasyncFasync_workers   client_certNcheck_updatedelay_reloadr   r  zno-cacheapplication/jsonno-check)zCache-ControlContent-TypeX-Atlassian-Tokendefault_batch_sized      r   options"dict[str, str | bool | Any] | None
basic_authtuple[str, str] | None
token_authoauthr   jwtkerberos_optionsget_server_infoboolasync_r   loggingmax_retriesproxies
Any | Nonetimeout>None | float | tuple[float, float] | tuple[float, None] | Noner   default_batch_sizes'dict[type[Resource], int | None] | Nonec                   t          t          j                  | _        |7i }|r3t	          |t
                    rt          j        dt                     |}d}|r||d<   |r
||d<   ||d<   t          
                    |rt          j        nt          j                   t          | _        t          j        t"          j                  | _        |r | j        d                             |           d|v rt          j        |d                   }|d= ni }| j                            |           | j        d                             |           d| _        t	          | j        d         t,                    sJ | j        d                             d	          r| j        d         dd
         | j        d<   t1          | j                  j        }t7          |          dk    r
|| j        d<   |                                  t	          | j        d         t
                    sJ t;          |          | _        |                                  |                                   | j        j!                            | j        d                    d| j        v r*| j        j"                            | j        d                    || j        _#        |r|| j        _$        |r| %                    |           no|r | j&        |  nb|r| '                    |           nJ|r| (                    |           n2|r| )                    |           n|r| *                    |           d}	|| _+        |	r9| ,                                }|j-        |p	|p|p|p|pd}t]          d|           d| _/        |
rz| 0                                }	 t          |d                   | _1        n/# td          $ r"}| j        3                    d|           |d}~ww xY w|4                    d          | _/        nd| _1        | j        d         r,t"          j5        s | 6                                 dt"          _5        i | _7        dS )a4  Construct a Jira client instance.

        Without any arguments, this client will connect anonymously to the Jira instance started by the Atlassian Plugin SDK from one
        of the 'atlas-run', ``atlas-debug`` or ``atlas-run-standalone`` commands.
        By default, this instance runs at ``http://localhost:2990/jira``. The ``options`` argument can be used to set the Jira instance to use.

        Authentication is handled with the ``basic_auth``  or ``token_auth`` argument.
        If authentication is supplied (and is accepted by Jira), the client will remember it for subsequent requests.

        For quick command line access to a server, see the ``jirashell`` script included with this distribution.

        The easiest way to instantiate is using ``j = JIRA("https://jira.atlasian.com")``

        Args:
            server (Optional[str]): The server address and context path to use. Defaults to ``http://localhost:2990/jira``.
            options (Optional[Dict[str, bool, Any]]): Specify the server and properties this client will use.
              Use a dict with any of the following properties:

                * server -- the server address and context path to use. Defaults to ``http://localhost:2990/jira``.
                * rest_path -- the root REST path to use. Defaults to ``api``, where the Jira REST resources live.
                * rest_api_version -- the version of the REST resources under rest_path to use. Defaults to ``2``.
                * agile_rest_path - the REST path to use for Jira Agile requests. Defaults to ``agile``.
                * verify (Union[bool, str]) -- Verify SSL certs. (Default: ``True``).
                  Or path to a CA_BUNDLE file or directory with certificates of trusted CAs, for the `requests` library to use.
                * client_cert (Union[str, Tuple[str,str]]) -- Path to file with both cert and key or a tuple of (cert,key), for the `requests` library to use for client side SSL.
                * check_update -- Check whether using the newest python-jira library version.
                * headers -- a dict to update the default headers the session uses for all API requests.

            basic_auth (Optional[Tuple[str, str]]): A tuple of username and password to use when establishing a session via HTTP BASIC authentication.

            token_auth (Optional[str]): A string containing the token necessary for (PAT) bearer token authorization.

            oauth (Optional[Any]): A dict of properties for OAuth authentication. The following properties are required:

                * access_token -- OAuth access token for the user
                * access_token_secret -- OAuth access token secret to sign with the key
                * consumer_key -- key of the OAuth application link defined in Jira
                * key_cert -- private key file to sign requests with (should be the pair of the public key supplied to Jira in the OAuth application link)
                * signature_method (Optional) -- The signature method to use with OAuth. Defaults to oauthlib.oauth1.SIGNATURE_HMAC_SHA1

            kerberos (bool): True to enable Kerberos authentication. (Default: ``False``)
            kerberos_options (Optional[Dict[str,str]]): A dict of properties for Kerberos authentication.
              The following properties are possible:

                * mutual_authentication -- string DISABLED or OPTIONAL.

                Example kerberos_options structure: ``{'mutual_authentication': 'DISABLED'}``

            jwt (Optional[Any]): A dict of properties for JWT authentication supported by Atlassian Connect.
              The following properties are required:

                * secret -- shared secret as delivered during 'installed' lifecycle event
                  (see https://developer.atlassian.com/static/connect/docs/latest/modules/lifecycle.html for details)
                * payload -- dict of fields to be inserted in the JWT payload, e.g. 'iss'

                Example jwt structure: ``{'secret': SHARED_SECRET, 'payload': {'iss': PLUGIN_KEY}}``

            validate (bool): True makes your credentials first to be validated. Remember that if you are accessing Jira as anonymous it will fail. (Default: ``False``).
            get_server_info (bool): True fetches server version info first to determine if some API calls are available. (Default: ``True``).
            async_ (bool): True enables async requests for those actions where we implemented it, like issue update() or delete(). (Default: ``False``).
            async_workers (int): Set the number of worker threads for async operations.
            timeout (Optional[Union[Union[float, int], Tuple[float, float]]]): Set a connect/read timeout for the underlying calls to Jira.
              Obviously this means that you cannot rely on the return code when this is enabled.
            max_retries (int): Sets the amount Retries for the HTTP sessions initiated by the client. (Default: ``3``)
            proxies (Optional[Any]): Sets the proxies for the HTTP session.
            auth (Optional[Tuple[str,str]]): Set a cookie auth token if this is required.
            logging (bool): True enables loglevel to info => else critical. (Default: ``True``)
            default_batch_sizes (Optional[Dict[Type[Resource], Optional[int]]]): Manually specify the batch-sizes for
              the paginated retrieval of different item types. `Resource` is used as a fallback for every item type not
              specified. If an item type is mapped to `None` no fallback occurs, instead the JIRA-backend will use its
              default batch-size. By default all Resources will be queried in batches of 100. E.g., setting this to
              ``{Issue: 500, Resource: None}`` will make :py:meth:`search_issues` query Issues in batches of 500, while
              every other item type's batch-size will be controlled by the backend. (Default: None)
        NzpOld API usage, use JIRA(url) or JIRA(options={'server': url}, when using dictionary always use named parameters. r%  r0  r1  r:  r  r'  r   r   rL  r   )rD  T	anonymouszCan not log in with versionNumberszinvalid server_info: %sdeploymentType)r   r   r   r4  )8tuplesysversion_infosys_version_infor`   dictwarningswarnDeprecationWarningr  setLevel_loggingINFOCRITICALrc   r  deepcopyra   DEFAULT_OPTIONS_optionsupdate_rankr   endswithr   
server_urlr   r   
_try_magicr    r   _add_client_cert_to_session'_add_ssl_cert_verif_strategy_to_sessionr  r   rI  rJ  _create_oauth_session_create_http_basic_session_create_jwt_session_create_token_session_create_kerberos_session_create_cookie_authr   r   rawr   rV  server_info_version	Exceptionerrorgetchecked_version_check_update__fields_cache_value)r   r%  r=  r?  rA  rB  rC  kerberosrD  validaterE  rG  r1  rH  rI  rJ  rL  r   rN  r  r   userauth_methodsirs   s                            r[   r   zJIRA.__init__  s   B !&c&6 7 7?G *VT22  G&   ! 	' &GH 	5%GG'4GO$gDX]]83DEEE(,d6J(K(K 	LM./667JKKKi	 233G	""GW%%%i ''000
 $-1377777="++C00 	C&*mH&=crc&BDM(#005|q  ,8DM.)$-	2D99999 )999((***44666$$T]9%=>>>%%M!((y)ABBB$/! 	,$+DM!  	&&u---- 	+D+Z888 		$$S)))) 	&&z2222 	));K)LLLL 	$$T***H	 	F <<>>DxQZQ3Q(QdQk    D{ D DEEE" 
	&!!##B %b)9&: ; ;   8"=== #%&&)9":":D%DM=( 	(1E 	(!!!#'D 35   s   9O 
P O;;P rR   dict[str, str]c                F    | j         s|                                  | j         S )z9Cached dictionary of {Field Name: Field ID}. Lazy loaded.)r{  _update_fields_cacher   s    r[   _fields_cachezJIRA._fields_cache  s*     ' 	(%%'''''r^   c                    i | _         |                                 D ]!}d|v r|d         D ]}|d         | j         |<   "dS )z/Update the cache used for `self._fields_cache`.clauseNamesidN)r{  r   )r   fr{   s      r[   r  zJIRA._update_fields_cache  s_    #%  	= 	=A!!m, = =D56tWD,T22	= 	=r^   r   c                6    t          | j        d                   S )zAReturn the server url.

        Returns:
            str
        r%  )r   re  r   s    r[   ri  zJIRA.server_url  s     4=*+++r^   c                    | j         dv S )z5Return whether we are on a Cloud based Jira instance.)Cloud)rV  r   s    r[   rb   zJIRA._is_cloud  s     "j00r^   r   c                    t          j        dt                     t          | j         dj        di | j        |          | j        _        d S )NzOUse OAuth or Token based authentication instead of Cookie based Authentication.{server}{auth_url})r   r   r   rW   )r\  r]  r^  r   r   formatre  r   )r   r   s     r[   rr  zJIRA._create_cookie_auth  s`    8	
 	
 	

 ,M707HH$-HH
 
 
r^   c                   	 t          j        dd                                          }|d         d         }t          |          t          t                    k    r"t          j        dt           d| d           d	S d	S # t           j        $ r Y d	S t          $ r%}| j	        
                    |           Y d	}~d	S d	}~ww xY w)
z8Check if the current version of the library is outdated.z&https://pypi.python.org/pypi/jira/jsong5^I @rS  r  versionz3You are running an outdated version of Jira Python z. Current version is z.. Do not file any bugs against older versions.N)requestsrx  r  parse_versionr   r\  r]  RequestExceptionrv  rc   rd   )r   r  released_versionrs   s       r[   rz  zJIRA._check_update_  s   	 <8%  dff   $F|I6-..{1K1KKK m+  m  ml|  m  m  m     LK ( 	 	 	DD 	  	  	 HQ	 s   A;B C	CB<<Cc                .    |                                   dS )zDestructor for JIRA instance.Ncloser   s    r[   __del__zJIRA.__del__  s    

r^   c                    t          | dd           }|/	 |                                 n# t          $ r Y nw xY wd | _        d S d S )Nr   )rp   r  	TypeErrorr   )r   r   s     r[   r  z
JIRA.close  sd    $
D11    	 !DMMM s   * 
77contentc                f    d|v r,| j                             d           t          d|           dS )Nz<!-- SecurityTokenMissing -->zGot SecurityTokenMissingzSecurityTokenMissing: T)rc   rd   r   )r   r  s     r[   _check_for_html_errorzJIRA._check_for_html_error  sB     +g55H7888>W>>???tr^   c                X    dfd|                                  D             d         }|S )NrC   c                D    g | ]}|d          k    |d         d         S )r{   schemacustomIdrW   )rY   r  sprint_field_names     r[   r   z-JIRA._get_sprint_field_id.<locals>.<listcomp>  s<     
 
 
y--- hK
#---r^   r   r   )r   sprint_field_idr  s     @r[   _get_sprint_field_idzJIRA._get_sprint_field_id  sK    $
 
 
 
[[]]
 
 
 	
 r^   2   	item_typetype[ResourceType]	items_keyrequest_pathr   r   r   baseuse_postResultList[ResourceType]c	                   d}	d}
| j         d         r4	 ddlm} |}
n# t          $ r Y nw xY w| j                             d          }	dfd} |            }|r||d	<   |r||d
<   n|                     |          x}r||d
<   |                     ||||          }|                     |||          }|}	 t          |t                    rk|                    d          }|t          |          n|}|                    dd          }|                    d	d          }|                    d
d          }nd}d}d}d}|s|pt          |          }|#||k     r| j                            d|||           |p|pd|z   }|
|s|t          |          |k     rg } |
| j        |	          }t          |||          D ]} |            }||d	<   ||d
<   |                     |          }|r)|                    |t%          j        |                    n|                    ||          }|                    |           |D ]S}|                                }t-          |          }|r,|                     |||          }|                    |           T|
|s|||k     rt          |          |k    r |            }||d	<   ||d
<   |                     ||||          }|r2|                     |||          }|                    |           ||z  }nn|
|s|||k     rt          |          |k    t1          |||||          S )a  Fetch from a paginated end point.

        Args:
            item_type (Type[Resource]): Type of single item. ResultList of such items will be returned.
            items_key (Optional[str]): Path to the items in JSON returned from server. Set it to None, if response is an array, and not a JSON object.
            request_path (str): path in request URL
            startAt (int): index of the first record to be fetched. (Default: ``0``)
            maxResults (int): Maximum number of items to return. If maxResults evaluates as False, it will try to get all items in batches. (Default:50)
            params (Dict[str, Any]): Params to be used in all requests. Should not contain startAt and maxResults, as they will be added for each request created from this function.
            base (str): base URL to use for the requests.
            use_post (bool): Use POST endpoint instead of GET endpoint.

        Returns:
            ResultList
        Nr0  r   )FuturesSessionr1  rR   dict[str, Any]c                 |     r8t          j        t          j                                                             ni S rV   )r  loadsr  r  r   s   r[   json_paramsz&JIRA._fetch_pages.<locals>.json_params&  s/    <BJ4:dj77888Jr^   r   r   r   r  r  Tr   r   Fr   zP'batch_size' set to %s, but only received %s items in batch. Falling back to %s.)r   max_workersr  r  rR   r  )re  requests_futures.sessionsr  ImportErrorrx  _get_batch_size	_get_json_get_items_from_pager`   r[  r   r   rc   rd   r   range_get_urlr  r  r  ry   r}   rL   extendr   )r   r  r  r  r   r   r   r  r  r1  async_classr  r  page_params
batch_sizeresourcenext_items_pageitemsr   is_laststart_at_from_responsemax_results_from_response	page_size
page_startasync_fetchesfuture_sessionstart_indexrr   r  futurern   s         `                        r[   _fetch_pageszJIRA._fetch_pages  s   4 =! 	?DDDDDD,    M--o>>M	K 	K 	K 	K 	K 	K "kmm 	-%,K	" 	3(2K%%//	:::Z 	3(2K%>>4( " 
 
 33Iy(SSW	(D)) . W--&+&7E


U #,,x77)1i)C)C&,4LLq,I,I)) )*&,-)  =5CU	)i*.D.DH$$j"!!	   &D)?D1	Q
+# ,*s5zzE/A/A$&M%0[ $=& & &N (-Z	'J'J 
0 
0&1kmm1<I.4=L1"mmL99  (MN//$*[:Q:Q/RRR!/!3!3C!3!L!L 
 &,,Q////"/ : :#)==??#-h#7#7# :.2.G.G )9h/ /O "LL999'# (*u*<*<O,,	99 $   .8K	*09K-#~~$[th  .    H   *.*C*C%y(+ + _555"i/

 -  '# (*u*<*<O,,	99* -/H%QX  s    
**c                   d}|dv }	|pi                                  }
|	r|n||
d<   |
                    d          }g }	 |r||
d<   n|
                    dd           |                     ||
||          }|                    |                     |||                     |                    d          }|	r|sn|t          ||          S )	a  Fetch from a paginated API endpoint using `nextPageToken`.

        Args:
            item_type (Type[Resource]): Type of single item. Returns a `ResultList` of such items.
            items_key (Optional[str]): Path to the items in JSON returned from the server.
            request_path (str): Path in the request URL.
            maxResults (int): Maximum number of items to return per page. (Default: 50)
            params (Dict[str, Any]): Parameters to be sent with the request.
            base (str): Base URL for the requests.
            use_post (bool): Whether to use POST instead of GET.

        Returns:
            ResultList: List of fetched items.
        r;  )r   Fr   r   TNr  )r   )r  rx  popr  r  r  r   )r   r  r  r  r   r   r  r  DEFAULT_BATCH	fetch_allr  r   r  rn   s                 r[   _fetch_pages_searchTokenzJIRA._fetch_pages_searchToken  s   2 *,	|))++5>$NMMJL! %0OOO$D$D$&	 7/<O,,666~~[th &  H LL229iRRSSS$LL99M M 	 %>>>>r^   r  r  r   c                     	  fd|r||         n|D             S # t           $ r9}t          t          |          dz   t          j        |          z             d }~ww xY w)Nc                >    g | ]} j         j        |          S rW   )re  r   )rY   raw_issue_jsonr  r   s     r[   r   z-JIRA._get_items_from_page.<locals>.<listcomp>  s=        # 	$-GG  r^   z : )KeyErrorr   r  r  )r   r  r  r  rs   s   ``   r[   r  zJIRA._get_items_from_page  s    	B     ?H'Ux	':':X   
  	B 	B 	B3q66E>DJx,@,@@AAA	Bs    
A 4AA r   c                    | j         d         }	 ||         }n+# t          $ r |                    t          d          }Y nw xY w|S )a  Return the batch size for the given resource type from the options.

        Check if specified item-type has a mapped batch-size, else try to fallback to batch-size assigned to `Resource`, else fallback to Backend-determined batch-size.

        Returns:
           Optional[int]: The batch size to use. When the configured batch size is None, the batch size should be determined by the JIRA-Backend.
        r:  N)re  r  rx  r?   )r   r  batch_sizesitem_type_batch_sizes       r[   r  zJIRA._get_batch_size  sh     9= 9
	C#.y#9   	C 	C 	C#.??8T#B#B   	C $#s    %A A c                    | j         S )z+Get the server this client is connected to.)ri  r   s    r[   client_infozJIRA.client_info  s
    r^   rQ  resource_formatidstuple[str, str] | int | strr?   c                f    t          || j        | j                  }|                    |           |S )a  Find Resource object for any addressable resource on the server.

        This method is a universal resource locator for any REST-ful resource in Jira. The argument ``resource_format`` is a string of
        the form ``resource``, ``resource/{0}``, ``resource/{0}/sub``, ``resource/{0}/sub/{1}``, etc.
        The format placeholders will be populated from the ``ids`` argument if present. The existing authentication session will be used.

        The return value is an untyped Resource object, which will not support specialized :py:meth:`.Resource.update` or :py:meth:`.Resource.delete` behavior.
        Moreover, it will not know to return an issue Resource if the client uses the resource issue path.
        For this reason, it is intended to support resources that are not included in the standard Atlassian REST API.

        Args:
            resource_format (str): the subpath to the resource string
            ids (Optional[Tuple]): values to substitute in the ``resource_format`` string
        Returns:
            Resource
        )r?   re  r   find)r   r  r  r  s       r[   r  z	JIRA.find  s0    & OT]DMJJcr^   
   sizec                    t          | j        d          rZ| j                            dt	          | j        j                   d| d           t          j        | j        j        |           dS dS )zExecute all asynchronous jobs and wait for them to finish. By default it will run on 10 threads.

        Args:
            size (int): number of threads to run on.
        _async_jobszExecuting asynchronous z jobs found in queue by using z threads...)r  N)hasattrr   rc   r  r   r  rN   map)r   r  s     r[   async_dozJIRA.async_do  s     4=-00 	HHMMy#dm.G*H*Hyyhlyyy   !$-";$GGGGGG		H 	Hr^   rz   %dict[str, str] | list[dict[str, str]]c                B    i }|||d<   |                      d|          S )zReturn the mutable server application properties.

        Args:
            key (Optional[str]): the single property to return a value for
        Returns:
            Union[Dict[str, str], List[Dict[str, str]]]
        Nrz   zapplication-propertiesr  r  )r   rz   r   s      r[   application_propertieszJIRA.application_properties  s.     ?F5M~~6v~FFFr^   r   c                    |                      d|z             }||d}| j                            |t          j        |                    S )zSet the application property.

        Args:
            key (str): key of the property to set
            value (str): value to assign to the property
        zapplication-properties/)r  r   r  )_get_latest_urlr   putr  r  )r   rz   r   rr   payloads        r[   set_application_propertyzJIRA.set_application_property'  sO     ""#<s#BCCu--}  4:g+>+> ???r^   cachedr   c                   |  |rt          | d          r| j        S | j        dz   }| j                            |          }t          |          }d|v r#t          |t                    r|d         | _        ng | _        | j        S )zaList of application links.

        Returns:
            List[Dict]: json, or empty list
        _applicationlinksz*/rest/applinks/latest/listApplicationlinksr   )r  r  ri  r   rx  rL   r`   r[  )r   r  rr   r  os        r[   applicationlinkszJIRA.applicationlinks2  s     	* 	*gd$788 	*)) o LLMc""qMMQ;;:a..;%&vYD""%'D"%%r^   r  r"   c                8    |                      t          |          S )zGet an attachment Resource from the server for the specified ID.

        Args:
            id (str): The Attachment ID

        Returns:
            Attachment
        )_find_for_resourcer"   r   r  s     r[   
attachmentzJIRA.attachmentJ       &&z2666r^   dict[str, int]c                ,    |                      d          S )zQGet the attachment metadata.

        Return:
            Dict[str, int]
        zattachment/metar  r   s    r[   attachment_metazJIRA.attachment_metaV  s     ~~/000r^   issue	str | intr  str | BufferedReaderfilenamec                   d}t          |t                    rt          |d          d}nD|t          |t                    r-|j        dk    r"| j                            |j         d           |s9t          t                    r$t          j	        
                    j                  dfd G fdd	t                    }|                     d
| d          }	              \  }}| j                            ||| |                      }	|r                                 n# |r                                 w w xY wt!          |	          }
|
rt          |
t"                    st%          d|
 d          t'          | j        | j        t          |
t*                    r|
d         n|
          }|j        dk    rt%          dd|	 d| z             |S )aQ  Attach an attachment to an issue and returns a Resource for it.

        The client will *not* attempt to open or validate the attachment; it expects a file-like object to be ready for its use.
        The user is still responsible for tidying up (e.g., closing the file, killing the socket, etc.)

        Args:
            issue (Union[str, int]): the issue to attach the attachment to
            attachment (Union[str,BufferedReader]): file-like object to attach to the issue, also works if it is a string with the filename.
            filename (str): optional name for the attached file. If omitted, the file object's ``name`` attribute is used.
              If you acquired the file-like object by any other method than ``open()``, make sure that a name is specified in one way or the other.

        Returns:
            Attachment
        FrbTz6 was not opened in 'rb' mode, attaching file may fail.rR   ,tuple[MultipartEncoder, CaseInsensitiveDict]c                                          d           t          ddfi          } t          | j        dd          }| |fS )z>Returns MultipartEncoder stream of attachment, and the header.r   filezapplication/octet-streamr  r7  )content-typer9  )seekr   r   content_type)encoded_datarequest_headersattachment_iofnames     r[   &generate_multipartencoded_request_argszCJIRA.add_attachment.<locals>.generate_multipartencoded_request_args  sn     q!!!+7Q RS  L 2$0$=)3  O  00r^   c                  $     e Zd Zd fdZ xZS )6JIRA.add_attachment.<locals>.RetryableMultipartEncoderoriginal_request_kwargsr   rR   c                t                 \  }}||d<   ||d<   t                                          |          S )Nr  r  )r   prepare)r   r  r  r  r   r  s       r[   r  z>JIRA.add_attachment.<locals>.RetryableMultipartEncoder.prepare  sF     1W0V0X0X-o2>'/5D'	2ww'>???r^   )r  r   rR   r   )r   r   r   r  r   )r   r  s   @r[   RetryableMultipartEncoderr    sN        @ @ @ @ @ @ @ @ @ @ @r^   r  issue/z/attachments)r  r  _prepare_retry_classzUnable to parse JSON: z. Failed to add attachment?r   zAdded empty attachment?!: z
Response: z
Attachment: )rR   r  )r`   r   openr	   moderc   rd   r{   osr   basenamer   r  r   r  r  rL   r   r   r"   re  r   r  )r   r   r  r  close_attachmentr  rr   r  r  r  jsjira_attachmentr  r  r  s               @@@r[   add_attachmentzJIRA.add_attachment^  s   * !j#&& 	 T22M#&M*n55 */T:Q:Q  !^^^    	9M>BB 	9G$$]%788E	1 	1 	1 	1 	1 	1 	1 	@ 	@ 	@ 	@ 	@ 	@ 	@(> 	@ 	@ 	@ mm8U88899
	&,R,R,T,T)L/""!'%>%>%@%@	 #  A   &##%%%   &##%%%%& 5?qMM 	VB11 	VTRTTTUUU$M4=:b$3G3G*O"Q%%R
 
 1$$,AqAAAAB   s   %3D/ /Er   c                    |                      dt          |          z             }| j                            |          S )zDelete attachment by id.

        Args:
            id (str): ID of the attachment to delete

        Returns:
            Response
        zattachment/r  r   r   deleter   r  rr   s      r[   delete_attachmentzJIRA.delete_attachment  s6     mmMCGG344}##C(((r^   c                8    |                      t          |          S )zrGet a component Resource from the server.

        Args:
            id (str): ID of the component to get
        )r  r%   r  s     r[   	componentzJIRA.component  s     &&y"555r^   r{   projectr%   c                   |||d}|||d<   |||d<   |||d<   |                      d          }| j                            |t          j        |                    }	t          | j        | j        t          |	                    }
|
S )	ap  Create a component inside a project and return a Resource for it.

        Args:
            name (str): name of the component
            project (str): key of the project to create the component in
            description (str): a description of the component
            leadUserName (Optional[str]): the username of the user responsible for this component
            assigneeType (Optional[str]): see the ComponentBean.AssigneeType class for valid values
            isAssigneeTypeValid (bool): True specifies whether the assignee type is acceptable (Default: ``False``)

        Returns:
            Component
        )r{   r(  isAssigneeTypeValidNdescriptionleadUserNameassigneeTyper'  r  rs  )r  r   r  r  r  r%   re  rL   )r   r{   r(  r+  r,  r-  r*  r  rr   r  r'  s              r[   create_componentzJIRA.create_component  s    0 #6
 

 ""-D##/D ##/D mmK((MsD)9)9::dmT]
1NNN	r^   c                b    |                      dt          |          z   dz             }|d         S )zyGet the count of related issues for a component.

        Args:
            id (str): ID of the component to use
        
component//relatedIssueCounts
issueCountr  r   )r   r  r  s      r[   component_count_related_issuesz#JIRA.component_count_related_issues  s8      $~~3r77"%:: 
  
 L!!r^   c                    |                      dt          |          z             }| j                            |          S )zDelete component by id.

        Args:
            id (str): ID of the component to use

        Returns:
            Response
        r1  r"  r$  s      r[   delete_componentzJIRA.delete_component  s6     mmL3r77233}##C(((r^   r'   c                8    |                      t          |          S )zGet a custom field option Resource from the server.

        Args:
            id (str): ID of the custom field to use

        Returns:
            CustomFieldOption
        )r  r'   r  s     r[   custom_field_optionzJIRA.custom_field_option  s     &&'8"===r^      ResultList[Dashboard]c                R    i }|||d<   |                      t          dd|||          S )a  Return a ResultList of Dashboard resources and a ``total`` count.

        Args:
            filter (Optional[str]): either "favourite" or "my", the type of dashboards to return
            startAt (int): index of the first dashboard to return (Default: ``0``)
            maxResults (int): maximum number of dashboards to return. If maxResults set to False, it will try to get all items in batches. (Default: ``20``)

        Returns:
            ResultList[Dashboard]
        Nfilter
dashboards	dashboard)r  r(   )r   r=  r   r   r   s        r[   r>  zJIRA.dashboards  sC     %F8  
 
 	
r^   r(   c                    |                      t          |          }|j                            |                     |          pg            |S )zGet a dashboard Resource from the server.

        Args:
            id (str): ID of the dashboard to get.

        Returns:
            Dashboard
        )r  r(   gadgetsr  dashboard_gadgets)r   r  r?  s      r[   r?  zJIRA.dashboard3  sI     ++Ir::	  !7!7!;!;!ArBBBr^   r+  edit_permissionslist[dict] | list | Noneshare_permissionsc                   t          ||pg |pg |d          }|                     d          }| j                            |t	          j        |                    }t          |          }t          | j        | j        |          S )a*  Create a new dashboard and return a dashboard resource for it.

        Args:
            name (str): Name of the new dashboard `required`.
            description (Optional[str]): Useful human-readable description of the new dashboard.
            edit_permissions (list | list[dict]): A list of permissions dicts `required`
                though can be an empty list.
            share_permissions (list | list[dict]): A list of permissions dicts `required`
                though can be an empty list.

        Returns:
            Dashboard
        r{   editPermissionssharePermissionsr+  r?  r  r.  )	rM   r  r   r  r  r  rL   r(   re  )	r   r{   r+  rC  rE  r  rr   r  raw_dashboard_jsons	            r[   create_dashboardzJIRA.create_dashboard@  s    ,  7#3#9r$5$;*	  
  
 mmK((MsD)9)9::-7]];MNNNNr^   c                    t          ||pg |pg |d          }|                     d          }| d| d}| j                            ||          }t	          |          }	t          | j        | j        |	          S )a2  Copy an existing dashboard.

        Args:
          id (str): The ``id`` of the ``Dashboard`` to copy.
          name (str): Name of the new dashboard `required`.
          description (Optional[str]): Useful human-readable description of the new dashboard.
          edit_permissions (list | list[dict]): A list of permissions dicts `required`
            though can be an empty list.
          share_permissions (list | list[dict]): A list of permissions dicts `required`
            though can be an empty list.

        Returns:
          Dashboard
        rG  r?  r'  z/copyr  r.  )rM   r  r   r  rL   r(   re  )
r   r  r{   r+  rC  rE  r  rr   r  rJ  s
             r[   copy_dashboardzJIRA.copy_dashboardd  s    0  7#3#9r$5$;*	  
  
 mmK((  r   Ms..-7]];MNNNNr^   minutesc                    |r|dz  nd}d|i}|                      d| d          }| j                            ||          S )a  Update the automatic refresh interval of a dashboard.

        Args:
          id (str): The ``id`` of the ``Dashboard`` to copy.
          minutes (int): The frequency of the dashboard automatic refresh in minutes.

        Returns:
          Response
        i`  NautomaticRefreshMszdashboards/z/automatic-refresh-msrM  )_get_internal_urlr   r  )r   r  rO  r   r  rr   s         r[   *update_dashboard_automatic_refresh_minutesz/JIRA.update_dashboard_automatic_refresh_minutes  sZ    & $+4%$e,$$%L2%L%L%LMM}  4 000r^   dashboard_iditem_id$ResultList[DashboardItemPropertyKey]c           	     H    |                      t          dd| d| d          S )a	  Return a ResultList of a Dashboard gadget's property keys.

        Args:
          dashboard_id (str): ID of dashboard.
          item_id (str): ID of dashboard item (``DashboardGadget``).

        Returns:
            ResultList[DashboardItemPropertyKey]
        r   
dashboard//items//properties)r  r+   )r   rT  rU  s      r[   dashboard_item_property_keysz!JIRA.dashboard_item_property_keys  s8       $BBBgBBB
 
 	
r^   property_keyr*   c                B    |                      t          |||f          }|S )aM  Get the item property for a specific dashboard item (DashboardGadget).

        Args:
          dashboard_id (str):  of the dashboard.
          item_id (str): ID of the item (``DashboardGadget``) on the dashboard.
          property_key (str): KEY of the gadget property.

        Returns:
            DashboardItemProperty
        )r  r*   )r   rT  rU  r\  dashboard_item_propertys        r[   r^  zJIRA.dashboard_item_property  s.     #'"9"9!L'<#H#
 #
 '&r^   c                    |                      d| d| d|           }| j                            ||          }|j        st	          |j        |          |                     |||          S )a  Set a dashboard item property.

        Args:
          dashboard_id (str): Dashboard id.
          item_id (str): ID of dashboard item (``DashboardGadget``) to add property_key to.
          property_key (str): The key of the property to set.
          value (dict[str, Any]): The dictionary containing the value of the property key.

        Returns:
          DashboardItemProperty
        rX  rY  /properties/rM  rq   r   )r  r   r  okr   rq   r^  )r   rT  rU  r\  r   rr   r  s          r[   set_dashboard_item_propertyz JIRA.set_dashboard_item_property  s     mmQQQgQQ<QQ
 
 Mc..t 	BqAAAA++L'<PPPr^   list[DashboardGadget]c           	        g }|                      t          dd| d          }|D ]Y}|                     ||j                  D ];}|j                            |                     ||j        |j                             <Z|S )zReturn a list of DashboardGadget resources for the specified dashboard.

        Args:
          dashboard_id (str): the ``dashboard_id`` of the dashboard to get gadgets for

        Returns:
          list[DashboardGadget]
        rA  rX  /gadget)r  r)   r[  r  item_propertiesry   r^  rz   )r   rT  rA  gadgetdashboard_item_keys        r[   rB  zJIRA.dashboard_gadgets  s     *,##Y(J\(J(J(J
 
  	 	F&*&G&Gfi' '  " &--00$fi1C1G     r^   ResultList[DashboardGadget]c                :    |                      t          dd          S )zReturn a ResultList of available DashboardGadget resources and a ``total`` count.

        Returns:
            ResultList[DashboardGadget]
        rA  zdashboard/gadgets)r  r)   r   s    r[   all_dashboard_gadgetszJIRA.all_dashboard_gadgets  s       )=PQQQr^   str | Dashboardcolor$ignore_uri_and_module_key_validationr   
module_keypositiondict[str, int] | Nonetitleurir)   c           	         t          ||||||d          }|                     d| d          }	| j                            |	|          }
t	          |
          }t          | j        | j        |          S )a  Add a gadget to a dashboard and return a ``DashboardGadget`` resource.

        Args:
          dashboard_id (str): The ``dashboard_id`` of the dashboard to add the gadget to `required`.
          color (str): The color of the gadget, should be one of: blue, red, yellow,
              green, cyan, purple, gray, or white.
          ignore_uri_and_module_key_validation (bool): Whether to ignore the
              validation of the module key and URI. For example, when a gadget is created
              that is part of an application that is not installed.
          module_key (str): The module to use in the gadget. Mutually exclusive with
              `uri`.
          position (dict[str, int]): A dictionary containing position information like -
              `{"column": 0, "row", 1}`.
          title (str): The title of the gadget.
          uri (str): The uri to the module to use in the gadget. Mutually exclusive
              with `module_key`.

        Returns:
          DashboardGadget
        )rn  ignoreUriAndModuleKeyValidationrp  rq  rs  rt  rX  rf  rM  r.  )rM   r  r   r  rL   r)   re  )r   rT  rn  ro  rp  rq  rs  rt  r  rr   r  raw_gadget_jsons               r[   add_gadget_to_dashboardzJIRA.add_gadget_to_dashboard  s    @ '3W($ 	
 	
 mm>>>>??Ms..*4Q--t}dmQQQQr^   list[dict[str, Any]]c                ,    |                      d          S )z^Return a list of all issue fields.

        Returns:
            List[Dict[str, Any]]
        fieldr  r   s    r[   r   zJIRA.fields7  s     ~~g&&&r^   r-   c                8    |                      t          |          S )zGet a filter Resource from the server.

        Args:
            id (str): ID of the filter to get.

        Returns:
            Filter
        )r  r-   r  s     r[   r=  zJIRA.filterA       &&vr222r^   list[Filter]c                N                           d          } fd|D             }|S )zGet a list of filter Resources which are the favourites of the currently authenticated user.

        Returns:
            List[Filter]
        zfilter/favouritec                F    g | ]}t          j        j        |          S rW   )r-   re  r   )rY   raw_filter_jsonr   s     r[   r   z*JIRA.favourite_filters.<locals>.<listcomp>S  s9     
 
 
 4=$-AA
 
 
r^   r  )r   r_jsonfilterss   `  r[   favourite_filterszJIRA.favourite_filtersL  sF     (,~~6H'I'I
 
 
 
#)
 
 
 r^   jql	favouritec                   i }|||d<   |||d<   |||d<   |||d<   |                      d          }| j                            |t          j        |                    }t          |          }t          | j        | j        |          S )	a  Create a new filter and return a filter Resource for it.

        Args:
            name (str): name of the new filter
            description (str): Useful human-readable description of the new filter
            jql (str): query string that defines the filter
            favourite (Optional[bool]): True adds this filter to the current user's favorites (Default: ``None``)

        Returns:
            Filter
        Nr{   r+  r  r  r=  r  r.  )r  r   r  r  r  rL   r-   re  )	r   r{   r+  r  r  r  rr   r  r  s	            r[   create_filterzJIRA.create_filterY  s    $  "DL""-D?DK  )DmmH%%MsD)9)9::*4Q--dmT]HHHHr^   c                   |                      |          }i }|p|j        |d<   |st          |d          r|p|j        |d<   |p|j        |d<   |p|j        |d<   |                     d|           }| j                            |ddit          j
        |                    }	t          j        |	j                  }
t          | j        | j        |
	          S )
a  Update a filter and return a filter Resource for it.

        Args:
            name (Optional[str]): name of the new filter
            description (Optional[str]): Useful human-readable description of the new filter
            jql (Optional[str]): query string that defines the filter
            favourite (Optional[bool]): True to add this filter to the current user's favorites (Default: ``None``)

        r{   r+  r  r  zfilter/r	  r6  r  r  r.  )r=  r{   r  r+  r  r  r  r   r  r  r  r  textr-   re  )r   	filter_idr{   r+  r  r  r=  r  rr   r  r  s              r[   update_filterzJIRA.update_filterz  s    " Y''*v{V 	D'&-88 	D"-"C1CD'VZU%9)9[mm1i1122M.*<=DJtDTDT  
 
 *QV,,dmT]HHHHr^   expandr.   c                z    t          | j        | j                  }i }|||d<   |                    ||           |S )zGet a group Resource from the server.

        Args:
            id (str): ID of the group to get
            expand (Optional[Any]): Extra information to fetch inside each resource

        Returns:
            Group
        Nr  r  )r.   re  r   r  )r   r  r  groupr   s        r[   r  z
JIRA.group  sG     dmT]33%F8

2f
%%%r^   '  r   exclude	list[str]c                    i }g }|||d<   |||d<   |||d<   |                      d|          d         D ]}|                    |d                    t          |          S )	a_  Return a list of groups matching the specified criteria.

        Args:
            query (Optional[str]): filter groups by name with this string
            exclude (Optional[Any]): filter out groups by name with this string
            maxResults (int): maximum results to return. (Default: ``9999``)

        Returns:
            List[str]
        Nr   r  r   zgroups/pickerr  groupsr{   )r  ry   r   )r   r   r  r   r   r  r  s          r[   r  zJIRA.groups  s      "$#F7O 'F9!#-F< ^^OF^CCHM 	) 	)EMM%-((((f~~r^   r  r   c           
        | j         dk     rt          d          |dd}|                     d|          }|d         d         }|d         d         }||d	z
  k     r|d
|d	z    d|dz    dd}|                     d|          }|d         d         D ]#}|d         d                             |           $|d         d         }|d         d         }||d	z
  k     i }|d         d         D ]*}|                    d          duo|                    d          dk    }	|                    d          duo|                    d          dk    }
|                    d          |                    d          |                    d          |                    d          |                    dd          |                    d          |                    d          d||	r|d         n+|
r|                    d          n|                    d          <   ,t          t          |                                d                     S )zReturn a hash or users with their information. Requires Jira 6.0 or will raise NotImplemented.

        Args:
            group (str): Name of the group.
           r   r   z_Group members is not implemented in Jira before version 6.0, upgrade the instance, if possible.users)	groupnamer  r  r  r  z	end-indexr   zusers[:r  ]r  r  NrQ  r{   	accountIddisplayNameemailAddresshiddenactivetimezone)r{   r  r  fullnameemailr  r  c                    | d         S r   rW   )ts    r[   <lambda>z$JIRA.group_members.<locals>.<lambda>  s
    ! r^   rz   )ru  NotImplementedErrorr  ry   rx  r   r   r  )r   r  r   r  r  	end_indexr2r~  r}   hasIdhasNames              r[   group_memberszJIRA.group_members  sz    =9$$%q    %88NN76N22z&!gJ{+	$("""D9q=DD9r>DDD F 77B7G, 1 1'
7#**400007K0IW:f%D $("" gJw' 	 	D HHTNN$.G488D>>R3GEhhv&&d2Mtxx7G7G27MG ((hhtnn!XXk22 HH]33.(;;((8,, HHZ00   /DJJ /&)))+.. " 6&,,..nnEEEFFFr^   r  c                    |                      d          }t                      }||d<   t          j        |          }| j                            ||           dS )zCreate a new group in Jira.

        Args:
            groupname (str): The name of the group you wish to create.

        Returns:
            bool: True if successful.
        r  r{   r  T)r  r   r  r  r   r  )r   r  rr   xr  s        r[   	add_groupzJIRA.add_group  sX     ""7++ MM&	*Q--3W---tr^   c                p    |                      d          }d|i}| j                            ||           dS )zDelete a group from the Jira instance.

        Args:
            groupname (str): The group to be deleted from the Jira instance.

        Returns:
            bool: Returns True on success.
        r  r  r  Tr  r   r#  )r   r  rr   r  s       r[   remove_groupzJIRA.remove_group  sA     ""7++)$S+++tr^   Issue | strr   
propertiesr/   c                    t          |t                    r|S t          | j        | j                  }i }|||d<   |||d<   |||d<   |                    ||           |S )a  Get an issue Resource from the server.

        Args:
            id (Union[Issue, str]): ID or key of the issue to get
            fields (Optional[str]): comma-separated string of issue fields to include in the results
            expand (Optional[str]): extra information to fetch inside each resource
            properties (Optional[str]): extra properties to fetch inside each result

        Returns:
            Issue
        Nr   r  r  r  )r`   r/   re  r   r  )r   r  r   r  r  r   r   s          r[   r   z
JIRA.issue)  s~    & b%   	IdmT]33%F8%F8!#-F< 

2f
%%%r^   prefetchc                f   t          |fi |}|d         d         }d}t          |t          t          z            r4|                     t          |                    j        }d|i|d         d<   |d         d         }t          |t                    rd|i|d         d<   nZt          |t                    rEd|                     t          |          |rt          |          nd          j        i|d         d<   |                     d          }| j        	                    |t          j        |                    }t          |          }	d	|	vr*t          |j        ||t          j        |          
          |r|                     |	d	                   S t!          | j        | j        |	          S )a  Create a new issue and return an issue Resource for it.

        Each keyword argument (other than the predefined ones) is treated as a field name and the argument's value is treated as the
        intended value for that field -- if the fields argument is used, all other keyword arguments will be ignored.

        By default, the client will immediately reload the issue Resource created by this method in order to return a complete Issue object to the caller;
        this behavior can be controlled through the 'prefetch' argument.

        Jira projects may contain many different issue types. Some issue screens have different requirements for fields in a new issue.
        This information is available through the 'createmeta' set of methods.
        Further examples are available here: https://developer.atlassian.com/display/JIRADEV/JIRA+REST+API+Example+-+Create+Issue

        Args:
            fields (Optional[Dict[str, Any]]): a dict containing field names and the values to use. If present, all other keyword arguments will be ignored
            prefetch (bool): True reloads the created issue Resource so all of its data is present in the value returned (Default: ``True``)

        Returns:
            Issue
        r   r(  Nr  	issuetyper(  r   r  rz   )rq   rn   rr   r  r.  )r   r`   r   r   r(  r  issue_type_by_namer  r   r  r  r  rL   r   rq   r   r/   re  )
r   r   r  r   r  p
project_idrr   r  r  s
             r[   create_issuezJIRA.create_issueK  s   2  -VAAyAAN9%
as## 	;c!ff--0J)-z(:DN9%N;'a 	+/)DN;''3 	d--FFz$KC
OOOt .  +DN;' mmG$$MsD)9)9::#A&&MA3TZPTEUEU     	K::nU3444>JJJJr^   
field_listc                    dg i}|D ]}t          |          }|d         d         }d}t          |t          t          z            r4|                     t          |                    j        }d|i|d         d<   |d         d         }t          |t                    rd|i|d         d<   nZt          |t                    rEd|                     t          |          |rt          |          nd          j        i|d         d<   |d                             |           |                     d          }	 | j	        
                    |t          j        |          	          }	t          |	          }
nI# t          $ r<}|j        d
k    r&|j        t          j        |j        j                  }
n Y d}~nd}~ww xY wg }i }|
d         D ]}|d         d         ||d         <   t'          |          D ]\  }}||v r!|                    d||         d|d           *|
d                             d          }|r|                     |d                   }nt-          | j        | j	        |          }|                    d|d|d           |S )a:  Bulk create new issues and return an issue Resource for each successfully created issue.

        See `create_issue` documentation for field information.

        Args:
            field_list (List[Dict[str, Any]]): a list of dicts each containing field names and the values to use. Each dict is an individual issue to create and is subject to its minimum requirements.
            prefetch (bool): True reloads the created issue Resource so all of its data is present in the value returned (Default: ``True``)

        Returns:
            List[Dict[str, Any]]
        issueUpdatesr   r(  Nr  r  r  z
issue/bulkr  i  errorselementErrorsfailedElementNumberError)statusrw  r   input_fieldsissuesr   rz   r.  Success)r  r   rw  r  )r   r`   r   r   r(  r  r  ry   r  r   r  r  r  rL   r   rq   rn   r  r  	enumerater  r   r/   re  )r   r  r  r  
field_dict
issue_datar  r  rr   r  r  je
issue_listr  rw  indexr   r   s                     r[   create_issueszJIRA.create_issues  s    "0 4$ 	4 	4J)6z)B)BJ8$Y/AJ!S3Y'' E!\\#a&&114
372D
8$Y/8$[1A!S!! 591I
8$[11As## $11A:(OJ4 2  5
8$[1  ''
3333mmL))		""3TZ-=-=">>A']]NN  	 	 	~$$)@!%BK,<!=!= 	
 
#H- 	T 	TE383I(3SF5./00&z22 	 	ME6!!")!'!%(.	     'x044Q77 K JJuU|44EE!$-EJJJE!!"+!&!%(.	     s   8=E6 6
F< 2F77F<c                    | j         dz   }ddi}	 | j                            ||          }|j        dk    S # t          $ r Y dS w xY w)z_Returns if the Jira instance supports service desk.

        Returns:
            bool
        z/rest/servicedeskapi/infoX-ExperimentalApiopt-inr     F)ri  r   rx  rq   r   )r   rr   r  r  s       r[   supports_service_deskzJIRA.supports_service_desk  si     o ;;&1	!!#w!77A=C'' 	 	 	55	s   &7 
AAr  r  r&   c           	        | j         dz   }ddi}| j                            ||t          j        ||d                    }t          |          }|j        dk    rt          |j        |          t          | j	        | j        |          S )	zCreate a new customer and return an issue Resource for it.

        Args:
            email (str): Customer Email
            displayName (str): Customer display name

        Returns:
            Customer
        z/rest/servicedeskapi/customerr  r  )r  r  r     ra  r.  )
ri  r   r  r  r  rL   rq   r   r&   re  )r   r  r  rr   r  r  raw_customer_jsons          r[   create_customerzJIRA.create_customer  s     o ??&1MeKHHII  
 
 'qMM=CqAAAAt}:KLLLLr^   list[ServiceDesk]c                      j         dz   }ddi}t           j                            ||                    } fd|d         D             }|S )zGet a list of ServiceDesk Resources from the server visible to the current authenticated user.

        Returns:
            List[ServiceDesk]
        z /rest/servicedeskapi/servicedeskr  r  r  c                F    g | ]}t          j        j        |          S rW   )rB   re  r   rY   raw_project_jsonr   s     r[   r   z&JIRA.service_desks.<locals>.<listcomp>   s:     
 
 
  t}6FGG
 
 
r^   r   )ri  rL   r   rx  )r   rr   r  r  projectss   `    r[   service_deskszJIRA.service_desks  sr     o BB&1DM--c7-CCDD
 
 
 
$*8$4
 
 
 r^   rB   c                8    |                      t          |          S )zGet a Service Desk Resource from the server.

        Args:
            id (str): ID or key of the Service Desk to get

        Returns:
            ServiceDesk
        )r  rB   r  s     r[   service_deskzJIRA.service_desk  s     &&{B777r^   c                   |}|d         }d}t          |t          t          z            r|                     |          }nt          |t                    r|}|j        |d<   |d         }t          |t                    r||d<   n3t          |t                    r|                     ||          j        |d<   | j        dz   }ddi}| j        	                    ||t          j        |                    }	t          |	          }
d|
vrt          |	j        |		          |r|                     |
d                   S t!          | j        | j        |

          S )a  Create a new customer request and return an issue Resource for it.

        Each keyword argument (other than the predefined ones) is treated as a field name and the argument's value is treated as the
        intended value for that field -- if the fields argument is used, all other keyword arguments will be ignored.

        By default, the client will immediately reload the issue Resource created by this method in order to return a complete Issue object to the caller;
        this behavior can be controlled through the 'prefetch' argument.

        Jira projects may contain many issue types. Some issue screens have different requirements for fields in a new issue.
        This information is available through the 'createmeta' set of methods.
        Further examples are available here: https://developer.atlassian.com/display/JIRADEV/JIRA+REST+API+Example+-+Create+Issue

        Args:
            fields (Dict[str, Any]): a dict containing field names and the values to use. If present, all other keyword arguments will be ignored
            prefetch (bool): True reloads the created issue Resource so all of its data is present in the value returned (Default: ``True``)

        Returns:
            Issue
        serviceDeskIdNrequestTypeIdz/rest/servicedeskapi/requestr  r  r  issueKeyra  r.  )r`   r   r   r  rB   r  request_type_by_nameri  r   r  r  r  rL   r   rq   r   r/   re  )r   r   r  r   r  r  r  rr   r  r  r  s              r[   create_customer_requestzJIRA.create_customer_request  sa   4 !as## 	,,Q//LL;'' 	L ,_!a 	R$%D!!3 	R$($=$=lA$N$N$QD!o >>&1MsG$*T:J:JKK#A^++qAAAA 	K::nZ8999>JJJJr^   r   c                j    | j         s| j        dk     r t          d| j         d| j         d          dS )zCheck whether Jira deployment supports the createmeta issuetypes endpoint.

        Raises:
            JIRAError: If the deployment does not support the API endpoint.

        Returns:
            None
              r   z"Unsupported JIRA deployment type: z or version: z. Use 'createmeta' instead.N)rb   ru  r   rV  r   s    r[   _check_createmeta_issuetypesz!JIRA._check_createmeta_issuetypesI  s]     > 	T]Y66,T5H , ,W[Wd , , ,   76r^   projectIdOrKeyc                    t          j        dt          d           |                                  |                     d| d||d          S )a  Get the issue types metadata for a given project, required to create issues.

        .. deprecated:: 3.6.0
            Use :func:`project_issue_types` instead.

        This API was introduced in JIRA Server / DC 8.4 as a replacement for the more general purpose API 'createmeta'.
        For details see: https://confluence.atlassian.com/jiracore/createmeta-rest-endpoint-to-be-removed-975040986.html

        Args:
            projectIdOrKey (Union[str, int]): id or key of the project for which to get the metadata.
            startAt (int): Index of the first issue to return. (Default: ``0``)
            maxResults (int): Maximum number of issues to return.
              Total number of results is available in the ``total`` attribute of the returned :class:`ResultList`.
              If maxResults evaluates to False, it will try to get all issues in batches. (Default: ``50``)

        Returns:
            Dict[str, Any]
        zo'createmeta_issuetypes' is deprecated and will be removed in future releases.Use 'project_issue_types' instead.   
stacklevelissue/createmeta//issuetypesr   r   r  r\  r]  r^  r  r  )r   r  r   r   s       r[   createmeta_issuetypeszJIRA.createmeta_issuetypesX  su    0 	1		
 	
 	
 	
 	))+++~~;;;;"(   
 
 	
r^   issueTypeIdc                    t          j        dt          d           |                                  |                     d| d| ||d          S )a  Get the field metadata for a given project and issue type, required to create issues.

        .. deprecated:: 3.6.0
            Use :func:`project_issue_fields` instead.

        This API was introduced in JIRA Server / DC 8.4 as a replacement for the more general purpose API 'createmeta'.
        For details see: https://confluence.atlassian.com/jiracore/createmeta-rest-endpoint-to-be-removed-975040986.html

        Args:
            projectIdOrKey (Union[str, int]): id or key of the project for which to get the metadata.
            issueTypeId (Union[str, int]): id of the issue type for which to get the metadata.
            startAt (int): Index of the first issue to return. (Default: ``0``)
            maxResults (int): Maximum number of issues to return.
              Total number of results is available in the ``total`` attribute of the returned :class:`ResultList`.
              If maxResults evaluates to False, it will try to get all issues in batches. (Default: ``50``)

        Returns:
            Dict[str, Any]
        zp'createmeta_fieldtypes' is deprecated and will be removed in future releases.Use 'project_issue_fields' instead.r  r  r  /issuetypes/r  r  r  )r   r  r  r   r   s        r[   createmeta_fieldtypeszJIRA.createmeta_fieldtypes  sz    4 	2		
 	
 	
 	
 	))+++~~IIIKII"(   
 
 	
r^   projectKeystuple[str, str] | str | None
projectIdslist | tuple[str, str]issuetypeIdslist[str] | NoneissuetypeNamesc                n   | j         sJ| j        dk    rt          d| j         d          | j        dk    rt          j        dt
          d           i }|||d	<   |/t          |t                    r|                    d
          }||d<   |||d<   |||d<   |||d<   | 	                    d|          S )a"  Get the metadata required to create issues, optionally filtered by projects and issue types.

        Args:
            projectKeys (Optional[Union[Tuple[str, str], str]]): keys of the projects to filter the results with.
              Can be a single value or a comma-delimited string. May be combined with projectIds.
            projectIds (Union[List, Tuple[str, str]]): IDs of the projects to filter the results with.
              Can be a single value or a comma-delimited string. May be combined with projectKeys.
            issuetypeIds (Optional[List[str]]): IDs of the issue types to filter the results with.
              Can be a single value or a comma-delimited string. May be combined with issuetypeNames.
            issuetypeNames (Optional[str]): Names of the issue types to filter the results with.
              Can be a single value or a comma-delimited string. May be combined with issuetypeIds.
            expand (Optional[str]): extra information to fetch inside each resource.

        Returns:
            Dict[str, Any]
        )	   r   r   zUnsupported JIRA version: z?. Use 'project_issue_types' and 'project_issue_fields' instead.r  zThis API have been deprecated in JIRA 8.4 and is removed in JIRA 9.0. Use 'project_issue_types' and 'project_issue_fields' instead.r  r  Nr  r   r   r  r  r  zissue/createmeta)
rb   ru  r   r\  r]  r^  r`   r   splitr  )r   r  r   r  r  r  r   s          r[   
createmetazJIRA.createmeta  s   0 ~ 	}	))T T T T   )++T& 	    "$"$/F=!!*c** 3'--c22
#-F< #%1F>"%'5F#$%F8~~0&999r^   r~  rF   c                ,    | j         r|j        n|j        S )a  Get the unique identifier depending on the deployment type.

        - Cloud: 'accountId'
        - Self Hosted: 'name' (equivalent to username).

        Args:
            user (User): a User object

        Returns:
            str: the User's unique identifier.
        )rb   r  r{   )r   r~  s     r[   _get_user_identifierzJIRA._get_user_identifier  s     "&>t~~TY>r^   c                    dv rS 	  j         r                     d          }n                     d          }t          |          dk     rt          d d          g }t          |          dk    r fd|D             }|r|d	         n|d	         }n.# t          $ r!}t          t          |                    d
}~ww xY w                     |          S )a  Internal method for translating a user search (str) to an id.

        Return None and -1 unchanged.

        This function uses :py:meth:`JIRA.search_users` to find the user and then using :py:meth:`JIRA._get_user_identifier` extracts
        the relevant identifier property depending on whether the instance is a Cloud or self-hosted Instance.

        Args:
            user (Optional[str]): The search term used for finding a user. None, '-1' and -1 are equivalent to 'Unassigned'.

        Raises:
            JIRAError: If any error occurs.

        Returns:
            Optional[str]: The Jira user's identifier. Or "-1" and None unchanged.
        )NrR  z-1r:  )r   r   )r~  r   r   zNo matching user found for: ''c                F    g | ]}                     |          k    |S rW   )r
  )rY   ur   r~  s     r[   r   z%JIRA._get_user_id.<locals>.<listcomp>
	  s1    TTTt/H/H/K/Kt/S/S1/S/S/Sr^   r   N)rb   search_usersr   r   rv  r   r
  )r   r~  r  matchesuser_objrs   s   ``    r[   _get_user_idzJIRA._get_user_id  s   " ###K	$~ D)))DD))t)CC5zzA~~ G G G GHHHG5zzA~~TTTTTeTTT%,:wqzz%(HH 	$ 	$ 	$CFF###	$((222s   BB 
C'CC	int | strassigneec                    |                      d| d          }|                     |          }| j        rd|ind|i}| j                            |t          j        |                     dS )a  Assign an issue to a user.

        Args:
            issue (Union[int, str]): the issue ID or key to assign
            assignee (str): the user to assign the issue to. None will set it to unassigned. -1 will set it to Automatic.

        Returns:
            bool
        r  z	/assigneer  r{   r  T)r  r  rb   r   r  r  r  )r   r   r  rr   user_idr  s         r[   assign_issuezJIRA.assign_issue	  s{     ""#<E#<#<#<==##H--,0NQ;((@Q#DJw$7$7888tr^   start_atmax_resultsorder_bylist[Comment]c                     i }|||d<   |t          |          |d<   |t          |          |d<   |||d<                        d| d|          } fd	|d
         D             }|S )a^  Get a list of comment Resources of the issue provided.

        Args:
            issue (Union[int, str]): the issue ID or key to get the comments from
            expand (Optional[str]): extra information to fetch for each comment such as renderedBody and properties.
            start_at (Optional[int]): index of the first comment to return (page offset)
            max_results (Optional[int]): maximum number of comments to return
            order_by (Optional[str]): order of the comments to return; should be 'created', '+created' or '-created'.

        Returns:
            List[Comment]
        Nr  r   r   orderByr  /commentr  c                F    g | ]}t          j        j        |          S rW   )r$   re  r   rY   raw_comment_jsonr   s     r[   r   z!JIRA.comments.<locals>.<listcomp>C	  :     
 
 
  DM4=2BCC
 
 
r^   comments)r   r  )	r   r   r  r  r  r  r   r  r#  s	   `        r[   r#  zJIRA.comments#	  s    * %F8 #HF9"#&{#3#3F<  (F9 8 8 8 8HH
 
 
 
$*:$6
 
 
 r^   commentr$   c                @    |                      t          ||f|          S )at  Get a comment Resource from the server for the specified ID.

        Args:
            issue (Union[int, str]): the issue ID or key to get the comment from
            comment (str): ID of the comment to get
            expand (Optional[str]): extra information to fetch for each comment such as renderedBody and properties.

        Returns:
            Comment
        r  )r  r$   )r   r   r$  r  s       r[   r$  zJIRA.commentI	  s$     &&w0@&PPPr^   str | int | Issuebody
visibilitydict[str, str] | Noneis_internalc                0   d|i}|rdd|idg|d<   |||d<   |                      dt          |          z   d	z             }| j                            |t	          j        |          
          }t          | j        | j        t          |                    S )a  Add a comment from the current authenticated user on the specified issue and return a Resource for it.

        Args:
            issue (Union[str, int, jira.resources.Issue]): ID or key of the issue to add the comment to
            body (str): Text of the comment to add
            visibility (Optional[Dict[str, str]]): a dict containing two entries: "type" and "value".
              "type" is 'role' (or 'group' if the Jira server has configured comment visibility for groups)
              "value" is the name of the role (or group) to which viewing of this comment will be restricted.
            is_internal (bool): True marks the comment as 'Internal' in Jira Service Desk (Default: ``False``)

        Returns:
            Comment: the created comment
        r(  zsd.public.commentinternal)rz   r   r  Nr)  r  r  r  r.  )	r  r   r   r  r  r  r$   re  rL   )r   r   r(  r)  r+  r  rr   r  s           r[   add_commentzJIRA.add_commentY	  s    * !'~ 	+z;6OPP"D !!+DmmHs5zz1J>??MsD)9)9::t}dmAGGGGr^   c                R    |                      dt          |          z   dz             S )zGet the edit metadata for an issue.

        Args:
            issue (Union[str, int]): the issue to get metadata for

        Returns:
            Dict[str, Dict[str, Dict[str, Any]]]
        r  z	/editmetar4  r   r   s     r[   editmetazJIRA.editmeta}	  s&     ~~hU3kABBBr^   list[RemoteLink]c                t                           dt          |          z   dz             } fd|D             }|S )zGet a list of remote link Resources from an issue.

        Args:
            issue (Union[str, int]): the issue to get remote links from

        Returns:
            List[RemoteLink]
        r  /remotelinkc                F    g | ]}t          j        j        |          S rW   )r<   re  r   )rY   raw_remotelink_jsonr   s     r[   r   z%JIRA.remote_links.<locals>.<listcomp>	  s:     
 
 
# t}dm5HII
 
 
r^   r4  )r   r   r  remote_linkss   `   r[   r7  zJIRA.remote_links	  sV     3u:: 5 EFF
 
 
 
'-
 
 
 r^   r<   c                <    |                      t          ||f          S )zGet a remote link Resource from the server.

        Args:
            issue (Union[str, int]): the issue holding the remote link
            id (str): ID of the remote link

        Returns:
            RemoteLink
        )r  r<   r   r   r  s      r[   remote_linkzJIRA.remote_link	  s     &&zE2;???r^   destinationIssue | dict[str, Any]globalIdapplicationrelationshipc                h   	 |                                  }nC# t          $ r6}g }t          j        d|j         d|j         t                     Y d}~nd}~ww xY wi }t          |t                    r|j	        rt          |          |                                d|d<   |D ]e}	|	d         d         |j        d         k    rFd	                    |	d         d
         |j	        d
                   |d<   |	d         d         dd|d<    nfd|vrt          d          n|||d<   |||d<   ||d<   |||d<   t          |t                    ri|j	        rb|D ]_}	|	d         d         | j        k    rFd	                    |	d         d
         |j	        d
                   |d<   |	d         d         dd|d<    n`|                     dt          |          z   dz             }
| j                            |
t'          j        |                    }t+          | j        | j        t-          |                    }|S )a<  Add a remote link from an issue to an external application and returns a remote link Resource for it.

        ``destination`` should be a dict containing at least ``url`` to the linked external URL and ``title`` to display for the link inside Jira.

        For definitions of the allowable fields for ``destination`` and the keyword arguments ``globalId``, ``application`` and ``relationship``,
        see https://developer.atlassian.com/display/JIRADEV/JIRA+REST+API+for+Remote+Issue+Links.

        Args:
            issue (str): the issue to add the remote link to
            destination (Union[Issue, Dict[str, Any]]): the link details to add (see the above link for details)
            globalId (Optional[str]): unique ID for the link (see the above link for details)
            application (Optional[Dict[str,Any]]): application information for the link (see the above link for details)
            relationship (Optional[str]): relationship description for the link (see the above link for details)

        Returns:
            RemoteLink: the added remote link
        zXUnable to gather applicationlinks; you will not be able to add links to remote issues: (z) N)rs  rr   objectr>  
displayUrlr%  zappId={}&issueId={}r  r=  r{   zcom.atlassian.jira)r{   typez(Unable to identify the issue to link to.r?  r  r4  r  r.  )r  r   r\  r]  rq   r  Warningr`   r/   rs  r   	permalinkre  r  r  ri  r  r   r  r  r  r<   rL   )r   r   r;  r=  r>  r?  r  rs   r  r  rr   r  r:  s                r[   add_remote_linkzJIRA.add_remote_link	  s   2	+/+@+@+B+B 
	 
	 
	!
 MM34=M MDEFM M       
	  "k5)) 	)ko 	)'*;'7'7@U@U@W@WXXDN% 
 
]#L1[5I(5SSS'<'C'C-(.#-( (D$
 !"- 0 8 4+ +D' E T %%)*TUUU & ##+Z &&1]#(DN##/D  k5)) 	ko 	% 
 
]#L1T_DD'<'C'C-(.#-( (D$
 !"- 0 8 4+ +D' E E mmHs5zz1MABBMsD)9)9:: :a==QQQs    
A,AArA  c                   d|i}|                      dt          |          z   dz             }| j                            |t	          j        |                    }t          | j        | j        t          |                    }|S )a  Add a simple remote link from an issue to web resource.

        This avoids the admin access problems from add_remote_link by just using a simple object and presuming all fields are correct
        and not requiring more complex ``application`` data.

        ``object`` should be a dict containing at least ``url`` to the linked external URL and ``title`` to display for the link inside Jira

        For definitions of the allowable fields for ``object`` ,
        see https://developer.atlassian.com/display/JIRADEV/JIRA+REST+API+for+Remote+Issue+Links.

        Args:
            issue (str): the issue to add the remote link to
            object (Dict[str,Any]): the dictionary used to create remotelink data

        Returns:
            RemoteLink
        rA  r  r4  r  r.  )	r  r   r   r  r  r  r<   re  rL   )r   r   rA  r  rr   r  simple_links          r[   add_simple_linkzJIRA.add_simple_link	  sw    $ &!mmHs5zz1MABBMsD)9)9:: :a==QQQr^   c                    i }|||d<   |||d<   |                      dt          |          z   dz   |          d         S )a  Get a list of the transitions available on the specified issue to the current user.

        Args:
            issue (Union[str, int, jira.resources.Issue]): ID or key of the issue to get the transitions from
            id (Optional[str]): if present, get only the transition matching this ID
            expand (Optional): extra information to fetch inside each transition

        Returns:
            Any: json of response
        NtransitionIdr  r  /transitionsr  transitionsr4  )r   r   r  r  r   s        r[   rM  zJIRA.transitions
  sX     >%'F>"%F8~~hU3nDV~TT
 	
r^   transition_namec                    |                      |          }d}|D ]<}|d                                         |                                k    r
|d         } n=|S )a  Get a transitionid available on the specified issue to the current user.

        Look at https://developer.atlassian.com/static/rest/jira/6.1.html#d2e1074 for json reference

        Args:
            issue (Union[str, int, jira.resources.Issue]): ID or key of the issue to get the transitions from
            transition_name (str): name of transition we are looking for

        Returns:
            Optional[int]: returns the id is found None when it's not
        Nr{   r  )rM  lower)r   r   rN  transitions_jsonr  
transitions         r[   find_transitionid_by_namezJIRA.find_transitionid_by_name-
  sp      ++E22* 	 	J&!''))_-B-B-D-DDD% E 	r^   rR  worklogc                n   d}	 t          |          }n:# t          $ r- |                     ||          }|t          d|           Y nw xY wdd|ii}i }	|r
dd|iig|	d<   |r
dd|iig|	d	<   |s|r|	|d
<   |||d<   ni }
|D ]}||         |
|<   |
|d<   |                     dt          |          z   dz             }| j                            |t          j	        |                    }	 t          |          }n8# t          $ r+}| j                            | d|j                    |d}~ww xY w|S )a  Perform a transition on an issue.

        Each keyword argument (other than the predefined ones) is treated as a field name and the argument's value is treated as the intended value for that field -- if the fields argument is used,
        all other keyword arguments will be ignored. Field values will be set on the issue as part of the transition process.

        Args:
            issue (Union[str, int, jira.resources.Issue]): ID or key of the issue to perform the transition on
            transition (str): ID or name of the transition to perform
            fields (Optional[Dict[str,Any]]): a dict containing field names and the values to use.
            comment (Optional[str]): String to add as comment to the issue when performing the transition.
            worklog (Optional[str]): String to add as time spent on the issue when performing the transition.
            **fieldargs: If present, all other keyword arguments will be ignored
        NzInvalid transition name. rR  r  addr(  r$  	timeSpentrT  rf  r   r  rL  r  
)r   rv  rS  r   r  r   r   r  r  r  rL   
ValueErrorrc   rw  r  )r   r   rR  r   r$  rT  r   rK  r  update_dictfields_dictr{  rr   r  r  rs   s                   r[   transition_issuezJIRA.transition_issueD
  s   . $(	Jz??LL 	J 	J 	J99%LLL# HJ H HIII $#	J !-t\.BC&( 	B',vw.?&@%AK	" 	G',{G.D&E%FK	" 	)g 	)(DN#DNNK" 6 6%.u%5E""(DNmmHs5zz1NBCCMsD)9)9::	]]FF 	 	 	HNNa++16++,,,G	 s'    4A
A-C= =
D2&D--D2rH   c                8    |                      t          |          S )zGet a votes Resource from the server.

        Args:
            issue (Union[str, int]): ID or key of the issue to get the votes for
        Returns:
            Votes
        )r  rH   r0  s     r[   votesz
JIRA.votes~
  s     &&ue444r^   r3   c                8    |                      t          |          S )a  Get a IssueSecurityLevelScheme Resource from the server.

        Args:
            project (str): ID or key of the project to get the IssueSecurityLevelScheme for

        Returns:
            IssueSecurityLevelScheme: The issue security level scheme
        )r  r3   r   r(  s     r[   #project_issue_security_level_schemez(JIRA.project_issue_security_level_scheme
  s     &&'?IIIr^   r6   c                8    |                      t          |          S )zGet a NotificationScheme Resource from the server.

        Args:
            project (str): ID or key of the project to get the NotificationScheme for

        Returns:
            NotificationScheme: The notification scheme
        )r  r6   r`  s     r[   project_notification_schemez JIRA.project_notification_scheme
  s     &&'97CCCr^   r7   c                8    |                      t          |          S )zGet a PermissionScheme Resource from the server.

        Args:
            project (str): ID or key of the project to get the permissionscheme for

        Returns:
            PermissionScheme: The permission scheme
        )r  r7   r`  s     r[   project_permissionschemezJIRA.project_permissionscheme
  s     &&'7AAAr^   r:   c                8    |                      t          |          S )zGet a PriorityScheme Resource from the server.

        Args:
            project (str): ID or key of the project to get the PriorityScheme for

        Returns:
            PriorityScheme: The priority scheme
        )r  r:   r`  s     r[   project_priority_schemezJIRA.project_priority_scheme
       &&~w???r^   rJ   c                8    |                      t          |          S )zGet a WorkflowScheme Resource from the server.

        Args:
            project (str): ID or key of the project to get the WorkflowScheme for

        Returns:
            WorkflowScheme: The workflow scheme
        )r  rJ   r`  s     r[   project_workflow_schemezJIRA.project_workflow_scheme
  rh  r^   c                    |                      dt          |          z   dz             }| j                            |          S )zRegister a vote for the current authenticated user on an issue.

        Args:
            issue (Union[str, int]): ID or key of the issue to vote on

        Returns:
            Response
        r  /votes)r  r   r   r  r   r   rr   s      r[   add_votezJIRA.add_vote
  s;     mmHs5zz1H<==}!!#&&&r^   c                    |                      dt          |          z   dz             }| j                            |           dS )zRemove the current authenticated user's vote from an issue.

        Args:
            issue (Union[str, int]): ID or key of the issue to remove vote on
        r  rl  Nr"  rm  s      r[   remove_votezJIRA.remove_vote
  sA     mmHs5zz1H<==S!!!!!r^   rI   c                8    |                      t          |          S )zGet a watchers Resource from the server for an issue.

        Args:
            issue (Union[str, int]): ID or key of the issue to get the watchers for

        Returns:
            Watchers
        )r  rI   r0  s     r[   watcherszJIRA.watchers
  s     &&x777r^   watcherc                    |                      dt          |          z   dz             }|                     |          }| j                            |t          j        |                    S )zAdd a user to an issue's watchers list.

        Args:
            issue (Union[str, int]): ID or key of the issue affected
            watcher (str): name of the user to add to the watchers list

        Returns:
            Response
        r  	/watchersr  )r  r   r  r   r  r  r  )r   r   rs  rr   
watcher_ids        r[   add_watcherzJIRA.add_watcher
  s]     mmHs5zz1K?@@&&w//
}!!#DJz,B,B!CCCr^   c                    |                      dt          |          z   dz             }|                     |          }| j        rd|ind|i}| j                            ||          }|S )zRemove a user from an issue's watch list.

        Args:
            issue (Union[str, int]): ID or key of the issue affected
            watcher (str): name of the user to remove from the watchers list

        Returns:
            Response
        r  ru  r  r   r  )r  r   r  rb   r   r#  )r   r   rs  rr   r  r  r}   s          r[   remove_watcherzJIRA.remove_watcher
  sr     mmHs5zz1K?@@##G,,,0NU;((W@U%%c'%::r^   list[Worklog]c                                           dt          |          z   dz             } fd|d         D             }|S )zGet a list of worklog Resources from the server for an issue.

        Args:
            issue (Union[str, int]): ID or key of the issue to get worklogs from
        Returns:
            List[Worklog]
        r  /worklogc                F    g | ]}t          j        j        |          S rW   )rK   re  r   )rY   raw_worklog_jsonr   s     r[   r   z!JIRA.worklogs.<locals>.<listcomp>  r"  r^   worklogsr4  )r   r   r  r  s   `   r[   r  zJIRA.worklogs  sZ     3u:: 5
 BCC
 
 
 
$*:$6
 
 
 r^   rK   c                <    |                      t          ||f          S )zGet a specific worklog Resource from the server.

        Args:
            issue (Union[str, int]): ID or key of the issue to get the worklog from
            id (str): ID of the worklog to get

        Returns:
            Worklog
        )r  rK   r9  s      r[   rT  zJIRA.worklog  s     &&w<<<r^   rW  timeSpentSecondsadjustEstimatenewEstimatereduceBystarteddatetime.datetime | Nonec                   i }|||d<   |||d<   |||d<   i }|||d<   |||d<   |||d<   n|	r|	|d<   |
|
|d<   |8|j         |                    d	          |d
<   n|                    d          |d
<   |	 |	| j        dz   |	z   |	dd|d<   |d         |d<   |                     d| d          }| j                            ||t          j        |                    }t          | j	        | j        t          |                    S )a]  Add a new worklog entry on an issue and return a Resource for it.

        Args:
            issue (Union[str, int]): the issue to add the worklog to
            timeSpent (Optional[str]): a worklog entry with this amount of time spent, e.g. "2d"
            timeSpentSeconds (Optional[str]): a worklog entry with this amount of time spent in seconds
            adjustEstimate (Optional[str]):  allows the user to provide specific instructions to update the remaining time estimate of the issue.
              The value can either be ``new``, ``leave``, ``manual`` or ``auto`` (default).
            newEstimate (Optional[str]): the new value for the remaining estimate field. e.g. "2d"
            reduceBy (Optional[str]): the amount to reduce the remaining estimate by e.g. "2d"
            comment (Optional[str]): optional worklog comment
            started (Optional[datetime.datetime]): Moment when the work is logged, if not specified will default to now
            user (Optional[str]): the user ID or name to use for this worklog
            visibility (Optional[Dict[str,Any]]): Details about any restrictions in the visibility of the worklog.
                Example of visibility options when creating or updating a worklog.
                ``{ "type": "group", "value": "<string>", "identifier": "<string>"}``

        Returns:
            Worklog
        Nr  r  r  rW  r  r$  r)  z%Y-%m-%dT%H:%M:%S.000+0000r  z%Y-%m-%dT%H:%M:%S.000%zz/rest/api/latest/user?username=F)r{   r   r  r  authorupdateAuthorr  r|  r   r  )tzinfostrftimeJIRA_BASE_URLr  r   r  r  r  rK   re  rL   )r   r   rW  r  r  r  r  r$  r  r~  r)  r   r  rr   r  s                  r[   add_worklogzJIRA.add_worklog)  ss   D %'5F#$"$/F=!!)F:!  )D''7D#$%DOO 	#"DO!!+D~%")"2"23O"P"PY")"2"23L"M"MY*-NNQUU#	 DN $(>D mm4U44455Ms6
48H8HIIt}dmZ]]CCCr^   list[IssueProperty]c                f                           d d          } fd|d         D             }|S )zGet a list of issue property Resource from the server for an issue.

        Args:
            issue (str): ID or key of the issue to get properties from

        Returns:
            List[IssueProperty]
        r  rZ  c                H    g | ]}                     |d                    S r  )issue_property)rY   rz   r   r   s     r[   r   z)JIRA.issue_properties.<locals>.<listcomp>  s-    WWWd))%U<<WWWr^   r   r  )r   r   r  r  s   ``  r[   issue_propertieszJIRA.issue_propertiesv  sI      ; ; ; ;<<WWWWWvWWW
r^   r2   c                <    |                      t          ||f          S )zGet a specific issue property Resource from the server.

        Args:
            issue (str): ID or key of the issue to get the property from
            key (str): Key of the property to get
        Returns:
            IssueProperty
        )r  r2   )r   r   rz   s      r[   r  zJIRA.issue_property  s     &&}uclCCCr^   c                    |                      d| d|           }| j                            |t          j        |                    S )a  Add or update a specific issue property Resource.

        Args:
            issue (str): ID or key of the issue to set the property to
            key (str): Key of the property to set
            data: The data to set for the property
        Returns:
            Response
        r  r`  r  )r  r   r  r  r  )r   r   rz   r  rr   s        r[   add_issue_propertyzJIRA.add_issue_property  sK     mm=U====>>}  4:d+;+; <<<r^   rC  str | IssueLinkTypeinwardIssueoutwardIssuec                h   |                                  }||vrK| j                            d           |D ].}|j        |k    r	|j        } n|j        |k    r|j        }||}} n/d|id|id|i|d}|                     d          }| j                            |t          j
        |                    S )a  Create a link between two issues.

        Args:
            type (Union[str,IssueLinkType]): the type of link to create
            inwardIssue: the issue to link from
            outwardIssue: the issue to link to
            comment (Optional[Dict[str, Any]]):  a comment to add to the issues with the link. Should be a dict containing ``body`` and
              ``visibility`` fields: ``body`` being the text of the comment and ``visibility`` being a dict containing two entries:
              ``type`` and ``value``. ``type`` is ``role`` (or ``group`` if the Jira server has configured comment visibility for groups)
              and ``value`` is the name of the role (or group) to which viewing of this comment will be restricted.

        Returns:
            Response
        zKWarning: Specified issue link type is not present in the list of link typesr{   rz   )rC  r  r  r$  	issueLinkr  )issue_link_typesrc   rd   outwardr{   inwardr  r   r  r  r  )	r   rC  r  r  r$  r  ltr  rr   s	            r[   create_issue_linkzJIRA.create_issue_link  s    .  0022'''H]   ' 	 	:%%7DEY$&&7D0<kKE	 ' TN!;/"L1	
 
 mmK((}!!#DJt,<,<!===r^   c                l    |                      d          dz   |z   }| j                            |          S )znDelete a link between two issues.

        Args:
            id (str): ID of the issue link to delete
        r  r'  r  r   r#  r$  s      r[   delete_issue_linkzJIRA.delete_issue_link  s5     mmK((3.3}##C(((r^   r0   c                8    |                      t          |          S )zGet an issue link Resource from the server.

        Args:
            id (str): ID of the issue link to get

        Returns:
            IssueLink
        )r  r0   r  s     r[   
issue_linkzJIRA.issue_link       &&y"555r^   forcelist[IssueLinkType]c                     t           d          r|r.                     d          } fd|d         D              _         j        S )zGet a list of issue link type Resources from the server.

        Args:
            force (bool): True forces an update of the cached IssueLinkTypes. (Default: ``False``)

        Returns:
            List[IssueLinkType]
        zself._cached_issue_link_typesissueLinkTypec                F    g | ]}t          j        j        |          S rW   )r1   re  r   )rY   raw_link_jsonr   s     r[   r   z)JIRA.issue_link_types.<locals>.<listcomp>  s9     - - -! dmT]MJJ- - -r^   issueLinkTypes)r  r  _cached_issue_link_types)r   r  r  s   `  r[   r  zJIRA.issue_link_types  sl     t<== 	 	^^O44F- - - -%+,<%=- - -D) ,,r^   r1   c                8    |                      t          |          S )zGet an issue link type Resource from the server.

        Args:
            id (str): ID of the issue link type to get

        Returns:
            IssueLinkType
        )r  r1   r  s     r[   issue_link_typezJIRA.issue_link_type       &&}b999r^   list[IssueType]c                N                           d          } fd|D             }|S )zjGet a list of issue type Resources from the server.

        Returns:
            List[IssueType]
        r  c                F    g | ]}t          j        j        |          S rW   r4   re  r   rY   raw_type_jsonr   s     r[   r   z$JIRA.issue_types.<locals>.<listcomp>  9     
 
 
 dmT]MBB
 
 
r^   r  )r   r  issue_typess   `  r[   r  zJIRA.issue_types  sF     ,,
 
 
 
!'
 
 
 r^   ResultList[IssueType]c                t    |                                   |                     t          dd| d||          }|S )a  Get a list of issue type Resources available in a given project from the server.

        This API was introduced in JIRA Server / DC 8.4 as a replacement for the more general purpose API 'createmeta'.
        For details see: https://confluence.atlassian.com/jiracore/createmeta-rest-endpoint-to-be-removed-975040986.html

        Args:
            project (str): ID or key of the project to query issue types from.
            startAt (int): Index of first issue type to return. (Default: ``0``)
            maxResults (int): Maximum number of issue types to return. (Default: ``50``)

        Returns:
            ResultList[IssueType]
        r   r  r  r  )r  r  r4   )r   r(  r   r   r  s        r[   project_issue_typeszJIRA.project_issue_types  sR    & 	))+++''4444! ( 
 
 r^   
issue_typeResultList[Field]c                x    |                                   |                     t          dd| d| ||          }|S )a  Get a list of field type Resources available for a project and issue type from the server.

        This API was introduced in JIRA Server / DC 8.4 as a replacement for the more general purpose API 'createmeta'.
        For details see: https://confluence.atlassian.com/jiracore/createmeta-rest-endpoint-to-be-removed-975040986.html

        Args:
            project (str): ID or key of the project to query field types from.
            issue_type (str): ID of the issue type to query field types from.
            startAt (int): Index of first issue type to return. (Default: ``0``)
            maxResults (int): Maximum number of issue types to return. (Default: ``50``)

        Returns:
            ResultList[Field]
        r   r  r  r  )r  r  r,   )r   r(  r  r   r   r   s         r[   project_issue_fieldszJIRA.project_issue_fields/  sV    * 	))+++""AAAZAA! # 
 
 r^   r4   c                8    |                      t          |          S )zGet an issue type Resource from the server.

        Args:
            id (str): ID of the issue type to get

        Returns:
            IssueType
        )r  r4   r  s     r[   r  zJIRA.issue_typeN  r  r^   c                .   |r|                      |d          j        }n|                                 }fd|D             }t          |          dk    r|d         S t          |          dk    rt	          d d          t	          d d          )	a  Get issue type by name.

        Args:
            name (str): Name of the issue type
            project (str): Key or ID of the project. If set, only issue types available for that project will be looked up.

        Returns:
            IssueType
        
issueTypesr&  c                *    g | ]}|j         k    |S rW   r{   )rY   itr{   s     r[   r   z+JIRA.issue_type_by_name.<locals>.<listcomp>h  s     LLLrBGtOOOOOr^   r   r   zIssue type '' is unknown.z' appears more than once.)r(  r  r  r   r  )r   r{   r(  r  matching_issue_typess    `   r[   r  zJIRA.issue_type_by_nameY  s      	-,,w|,DDOKK**,,KLLLL[LLL#$$))'**%&&!++=$===>>>I$IIIJJJr^   r  list[RequestType]c                     t          |d          r|j        } j        d| dz   }ddi}t           j                            ||                    } fd|d         D             }|S )	zReturns request types supported by a service desk instance.

        Args:
            service_desk (ServiceDesk): The service desk instance.

        Returns:
            List[RequestType]
        r  z!/rest/servicedeskapi/servicedesk/z/requesttyper  r  r  c                F    g | ]}t          j        j        |          S rW   )r=   re  r   r  s     r[   r   z&JIRA.request_types.<locals>.<listcomp>  s9     
 
 
 t}mDD
 
 
r^   r   )r  r  ri  rL   r   rx  )r   r  rr   r  r  request_typess   `     r[   r  zJIRA.request_typesp  s     <&& 	+'?LOL,LLLM 	 '1DM--c7-CCDD
 
 
 
!'!1
 
 
 r^   c                    |                      |          }	 fd|D             d         }n!# t          $ r t          d d          w xY w|S )Nc                *    g | ]}|j         k    |S rW   r  )rY   rtr{   s     r[   r   z-JIRA.request_type_by_name.<locals>.<listcomp>  s     JJJ2"'T//B///r^   r   zRequest type 'r  )r  
IndexErrorr  )r   r  r{   r  request_types     `  r[   r  zJIRA.request_type_by_name  s{    **<88	AJJJJJJJ1MLL 	A 	A 	A?D???@@@	As	   - A
projectKey	projectIdr  issueIdpermissions$dict[str, dict[str, dict[str, str]]]c                z    i }|||d<   |||d<   |||d<   |||d<   |||d<   |                      d|          S )	a  Get a dict of all available permissions on the server.

        ``permissions`` is a comma-separated value list of permission keys that is
        required in Jira Cloud. For possible and allowable permission values, see
        https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-permission-schemes/#built-in-permissions

        Args:
            projectKey (Optional[str]): limit returned permissions to the specified project
            projectId (Optional[str]): limit returned permissions to the specified project
            issueKey (Optional[str]): limit returned permissions to the specified issue
            issueId (Optional[str]): limit returned permissions to the specified issue
            permissions (Optional[str]): limit returned permissions to the specified csv permission keys (cloud required field)

        Returns:
            Dict[str, Dict[str, Dict[str, str]]]
        Nr  r  r  r  r  mypermissionsr  r  )r   r  r  r  r  r  r   s          r[   my_permissionszJIRA.my_permissions  so    0 !#-F<  "+F;!)F: 'F9"$/F=!~~of~===r^   list[Priority]c                N                           d          } fd|D             }|S )zgGet a list of priority Resources from the server.

        Returns:
            List[Priority]
        priorityc                F    g | ]}t          j        j        |          S rW   )r9   re  r   )rY   raw_priority_jsonr   s     r[   r   z#JIRA.priorities.<locals>.<listcomp>  s:     
 
 
! T]DM3DEE
 
 
r^   r  )r   r  
prioritiess   `  r[   r  zJIRA.priorities  sF     
++
 
 
 
%+
 
 

 r^   r9   c                8    |                      t          |          S )zGet a priority Resource from the server.

        Args:
            id (str): ID of the priority to get

        Returns:
            Priority
        )r  r9   r  s     r[   r  zJIRA.priority  s     &&x444r^   list[Project]c                d     i }|||d<                         d|          } fd|D             }|S )a  Get a list of project Resources from the server visible to the current authenticated user.

        Args:
            expand (Optional[str]): extra information to fetch for each project such as projectKeys and description.

        Returns:
            List[Project]
        Nr  r(  r  c                F    g | ]}t          j        j        |          S rW   )r;   re  r   r  s     r[   r   z!JIRA.projects.<locals>.<listcomp>  r"  r^   r  )r   r  r   r  r  s   `    r[   r  zJIRA.projects  s^     %F8	&99
 
 
 
$*
 
 
 r^   r;   c                <    |                      t          ||          S )a  Get a project Resource from the server.

        Args:
            id (str): ID or key of the project to get
            expand (Optional[str]): extra information to fetch for the project such as projectKeys and description.

        Returns:
            Project
        r&  )r  r;   )r   r  r  s      r[   r(  zJIRA.project  s     &&w6&BBBr^   c                8    |                      d|z   dz             S )zGet a dict of all avatars for a project visible to the current authenticated user.

        Args:
            project (str): ID or key of the project to get avatars for
        project/z/avatarsr  r`  s     r[   project_avatarszJIRA.project_avatars  s      ~~j72Z?@@@r^   
avatar_imgbytescontentTypeauto_confirmc                f   t           j                            |          }||k    r|}||d}ddi}	|||	d<   n|                     |          |	d<   |                     d|z   dz             }
| j                            |
||	|          }t          |          }|r|                     ||          S |S )	a  Register an image file as a project avatar.

        The avatar created is temporary and must be confirmed before it can be used.

        Avatar images are specified by a filename, size, and file object. By default, the client will attempt to autodetect the picture's content type
        this mechanism relies on libmagic and will not work out of the box on Windows systems
        (see `Their Documentation <https://filemagic.readthedocs.io/en/latest/guide.html>`_ for details on how to install support).

        The ``contentType`` argument can be used to explicitly set the value (note that Jira will reject any type other than the well-known ones for images, e.g. ``image/jpg``, ``image/png``, etc.)

        This method returns a dict of properties that can be used to crop a subarea of a larger image for use.
        This dict should be saved and passed to :py:meth:`confirm_project_avatar` to finish the avatar creation process.
        If you want to confirm the avatar with Jira's default cropping,
        pass the 'auto_confirm' argument with a truthy value and :py:meth:`confirm_project_avatar` will be called for you before this method returns.

        Args:
            project (str): ID or key of the project to create the avatar in
            filename (str): name of the avatar file
            size (int): size of the avatar file
            avatar_img (bytes): file-like object holding the avatar
            contentType (str): explicit specification for the avatar image's content-type
            auto_confirm (bool): True to automatically confirm the temporary avatar by calling :py:meth:`confirm_project_avatar` with the return value of this method. (Default: ``False``)

        )r  r  r9  r7  Nr	  r  z/avatar/temporaryr   r  r  )	r  r   getsize_get_mime_typer  r   r  rL   confirm_project_avatar)r   r(  r  r  r  r  r  size_from_filer   r  rr   r  cropping_propertiess                r[   create_temp_project_avatarzJIRA.create_temp_project_avatar  s    D 22>!!!D4<d'K'K#6
"C"&1GN## '+&9&9*&E&EGN#mmJ03FFGGMs67TT.8mm 	'..w8KLLL&&r^   r  c                    |}|                      d|z   dz             }| j                            |t          j        |                    }t          |          S )a  Confirm the temporary avatar image previously uploaded with the specified cropping.

        After a successful registry with :py:meth:`create_temp_project_avatar`, use this method to confirm the avatar for use.
        The final avatar can be a subarea of the uploaded image, which is customized with the ``cropping_properties``:
        the return value of :py:meth:`create_temp_project_avatar` should be used for this argument.

        Args:
            project (str): ID or key of the project to confirm the avatar in
            cropping_properties (Dict[str,Any]): a dict of cropping properties from :py:meth:`create_temp_project_avatar`
        r  /avatarr  r  r   r  r  r  rL   )r   r(  r  r  rr   r  s         r[   r  zJIRA.confirm_project_avatar5  sT     #mmJ09<==MsD)9)9::!}}r^   avatarc                f    |                      d|                     d|z   dz             |           dS )zSet a project's avatar.

        Args:
            project (str): ID or key of the project to set the avatar on
            avatar (str): ID of the avatar to set
        Nr  r  _set_avatarr  )r   r(  r  s      r[   set_project_avatarzJIRA.set_project_avatarG  s9     	t}}Z'-AI-MNNPVWWWWWr^   c                r    |                      d|z   dz   |z             }| j                            |          S )zDelete a project's avatar.

        Args:
            project (str): ID or key of the project to delete the avatar from
            avatar (str): ID of the avatar to delete

        Returns:
            Response
        r  z/avatar/r  )r   r(  r  rr   s       r[   delete_project_avatarzJIRA.delete_project_avatarQ  s:     mmJ0:=FGG}##C(((r^   list[Component]c                Z                           d|z   dz             } fd|D             }|S )zGet a list of component Resources present on a project.

        Args:
            project (str): ID or key of the project to get components from

        Returns:
            List[Component]
        r  z/componentsc                F    g | ]}t          j        j        |          S rW   )r%   re  r   )rY   raw_comp_jsonr   s     r[   r   z+JIRA.project_components.<locals>.<listcomp>j  s9     
 
 
 dmT]MBB
 
 
r^   r  )r   r(  r  
componentss   `   r[   project_componentszJIRA.project_components_  sP     
W 4} DEE
 
 
 
!'
 
 

 r^   list[Version]c                Z                           d|z   dz             } fd|D             }|S )zGet a list of version Resources present on a project.

        Args:
            project (str): ID or key of the project to get versions from

        Returns:
            List[Version]
        r  z	/versionsc                F    g | ]}t          j        j        |          S rW   )rG   re  r   )rY   raw_ver_jsonr   s     r[   r   z)JIRA.project_versions.<locals>.<listcomp>{  s9     
 
 
 DM4=,??
 
 
r^   r  )r   r(  r  versionss   `   r[   project_versionszJIRA.project_versionsp  sO     
W 4{ BCC
 
 
 
 &
 
 
 r^   version_nameVersion | Nonec                X    |                      |          }|D ]}|j        |k    r|c S dS )a  Get a version Resource by its name present on a project.

        Args:
            project (str): ID or key of the project to get versions from
            version_name (str): name of the version to search for

        Returns:
            Optional[Version]
        N)r	  r{   )r   r(  r
  r  r  s        r[   get_project_version_by_namez JIRA.get_project_version_by_name  sF     #'"7"7"@"@ 	 	G||++ ,tr^   old_namenew_namec                f    |                      ||          }|r|                    |           dS dS )a  Rename a version Resource on a project.

        Args:
            project (str): ID or key of the project to get versions from
            old_name (str): old name of the version to rename
            new_name (str): new name of the version to rename
        r  N)r  rf  )r   r(  r  r  r  s        r[   rename_versionzJIRA.rename_version  sE     227HEE 	*NNN)))))	* 	*r^   dict[str, dict[str, str]]c                    d|z   dz   }|                      |          }i }|                                D ]/\  }}i }|                    d          d         |d<   ||d<   |||<   0|S )zGet a dict of role names to resource locations for a project.

        Args:
            project (str): ID or key of the project to get roles from

        Returns:
            Dict[str, Dict[str, str]]
        r  z/roler'  rR  r  rr   )r  r  r  )r   r(  r   
_rolesdict	rolesdictkvtmps           r[   project_roleszJIRA.project_roles  s     G#g-%)^^D%9%9
/1	$$&& 	 	DAq"$CR(CICJIaLLr^   r@   c                l    t          |t                    r| }|                     t          ||f          S )zGet a role Resource.

        Args:
            project (str): ID or key of the project to get the role from
            id (str): ID of the role to get

        Returns:
            Role
        )r`   r
   r  r@   )r   r(  r  s      r[   project_rolezJIRA.project_role  s7     b&!! 	B&&tgr];;;r^   list[Resolution]c                N                           d          } fd|D             }|S )zkGet a list of resolution Resources from the server.

        Returns:
            List[Resolution]
        
resolutionc                F    g | ]}t          j        j        |          S rW   )r>   re  r   )rY   raw_res_jsonr   s     r[   r   z$JIRA.resolutions.<locals>.<listcomp>  s9     
 
 
 t}dm\BB
 
 
r^   r  )r   r  resolutionss   `  r[   r!  zJIRA.resolutions  sF     --
 
 
 
 &
 
 
 r^   r>   c                8    |                      t          |          S )zGet a resolution Resource from the server.

        Args:
            id (str): ID of the resolution to get

        Returns:
            Resolution
        )r  r>   r  s     r[   r  zJIRA.resolution  r  r^   *all)json_resultr  jql_strvalidate_querystr | list[str] | Noner$  Literal[False]ResultList[Issue]c                   d S rV   rW   
r   r%  r   r   r&  r   r  r  r$  r  s
             r[   search_issueszJIRA.search_issues  s	      Cr^   r  Literal[True]c                   d S rV   rW   r+  s
             r[   r,  zJIRA.search_issues  s	     r^   "dict[str, Any] | ResultList[Issue]c          	     8   t          |t                    r|                    d          }n|dg}| j        r1|dk    r|                     |||||||	          S t          d          i }
| j        rDt          |          D ]4\  }}|| j        v r&||         |
| j        |         <   | j        |         ||<   5||||||d}|	r|                    d           |r;||d	<   |st          j
        d
t                     |                     d||	          }|S |                     t          dd||||	          }|
rd|D ]a}|
                                D ]J\  }}|j        r>||j                            di           v r!|j        d         |         |j        d         |<   Kb|S )a  Get a :class:`~jira.client.ResultList` of issue Resources matching a JQL search string.

        Args:
            jql_str (str): The JQL search string.
            startAt (int): Index of the first issue to return. (Default: ``0``)
            maxResults (int): Maximum number of issues to return.
              Total number of results is available in the ``total`` attribute of the returned :class:`ResultList`.
              If maxResults evaluates to False, it will try to get all issues in batches. (Default: ``50``)
            validate_query (bool): True to validate the query. (Default: ``True``)
            fields (Optional[Union[str, List[str]]]): comma-separated string or list of issue fields to include in the results.
              Default is to include all fields.
            expand (Optional[str]): extra information to fetch inside each resource
            properties (Optional[str]): extra properties to fetch inside each result
            json_result (bool): True to return a JSON response. When set to False a :class:`ResultList` will be returned. (Default: ``False``)
            use_post (bool): True to use POST endpoint to fetch issues.

        Returns:
            Union[Dict,ResultList]: Dict if ``json_result=True``
        r   Nr#  r   )r%  r   r   r  r  r$  r  zZThe `search` API is deprecated in Jira Cloud. Use `enhanced_search_issues` method instead.)r  r   validateQueryr   r  r  r  r   GAll issues cannot be fetched at once, when json_result parameter is setsearchr   r  r  r-  r   )r`   r   r  rb   enhanced_search_issuesr   r  r  r  r\  r]  rD  r  r  r/   r  rs  rx  )r   r%  r   r   r&  r   r  r  r$  r  untranslater   r{  search_paramsr  r  issr  r  s                      r[   r,  zJIRA.search_issues  sL   @ fc"" 	\\#&&FF^XF> 	!||22#)!!) +% 3     p    	:%f-- : :5D...=CAYK 25 9: $ 25 9F1I +$
 
  	,l+++ 
	*4M,' ]   &*^^ &4 & &F M"" # 
 
  	H H H'--// H HDAqw HHb 9 99936783DQ3GCGH-a0H
 r^   r   reconcileIssueslist[int] | Nonec                  t          |t                    r|                    d          }n|dg}i }
|rK| j        rDt	          |          D ]4\  }}|| j        v r&||         |
| j        |         <   | j        |         ||<   5|||||pg d}|r||d<   |r<|st          j        dt                     n||d<   |                     d||		          }|S | 	                    t          d
d|||	          }|
rd|D ]a}|
                                D ]J\  }}|j        r>||j                            di           v r!|j        d         |         |j        d         |<   Kb|S )a=  Get a :class:`~jira.client.ResultList` of issue Resources matching a JQL search string.

        Args:
            jql_str (str): The JQL search string.
            nextPageToken (Optional[str]): Token for paginated results.
            maxResults (int): Maximum number of issues to return.
              Total number of results is available in the ``total`` attribute of the returned :class:`ResultList`.
              If maxResults evaluates to False, it will try to get all issues in batches. (Default: ``50``)
            fields (Optional[Union[str, List[str]]]): comma-separated string or list of issue fields to include in the results.
              Default is to include all fields If you don't require fields, set it to empty string ``''``.
            expand (Optional[str]): extra information to fetch inside each resource.
            reconcileIssues (Optional[List[int]]): List of issue IDs to reconcile.
            properties (Optional[str]): extra properties to fetch inside each result
            json_result (bool): True to return a JSON response. When set to False a :class:`ResultList` will be returned. (Default: ``False``)
            use_post (bool): True to use POST endpoint to fetch issues.

        Returns:
            Union[Dict, ResultList]: JSON Dict if ``json_result=True``, otherwise a `ResultList`.
        r   Nr#  )r  r   r  r  r:  r   r3  r   z
search/jqlr5  r  )r  r  r  r   r   r  r   )r`   r   r  r  r  r\  r]  rD  r  r  r/   r  rs  rx  )r   r%  r   r   r   r  r:  r  r$  r  r7  r   r{  r8  r  r  r9  r  r  s                      r[   r6  zJIRA.enhanced_search_issuesk  s   B fc"" 	\\#&&FF^XF 	> ! > )& 1 1 > >HAu 222AGD$6u$=>$($6u$=q	 $.4")
 )
  	;-:M/* 	 9]   
 /9l+%)^^]X &4 & &F M..%!  / 
 
  	H H H'--// H HDAqw HHb 9 99936783DQ3GCGH-a0H
 r^   )r$  int | dict[str, Any]c                   | j         st          d          d|i}|                     d|d          }|r|S |                    dd          S )a_  Get an approximate count of issues matching a JQL search string.

        Args:
            jql_str (str): The JQL search string.
            json_result (bool): If True, returns the full JSON response. Defaults to False.

        Returns:
            int | dict[str, Any]: The issue count if json_result is False, else the raw JSON response.
        z=The 'approximate-count' API is only available for Jira Cloud.r  zsearch/approximate-countTr5  countr   )rb   rY  r  rx  )r   r%  r$  r8  response_jsons        r[   approximate_issue_countzJIRA.approximate_issue_count  st      ~ 	O   ((,&}t )7 )
 )
  	!    !,,,r^   rA   c                8    |                      t          |          S )zGet a security level Resource.

        Args:
            id (str): ID of the security level to get

        Returns:
            SecurityLevel
        )r  rA   r  s     r[   security_levelzJIRA.security_level  r  r^   c                    d}|                      d          }|sB|dk     r<| j                            d           |dz  }|                      d          }|s|dk     <|S )znGet a dict of server information for this Jira instance.

        Returns:
            Dict[str, Any]
        r   
serverInfor<  z?Bug https://jira.atlassian.com/browse/JRA-59676 trying again...r   )r  rc   rd   )r   retryjs      r[   rt  zJIRA.server_info  s|     NN<(( 	-		HQ   QJE|,,A  	-		 r^   c                ,    |                      d          S )znGet a dict of client information for this Jira instance.

        Returns:
            Dict[str, Any]
        myselfr  r   s    r[   rI  zJIRA.myself  s     ~~h'''r^   list[Status]c                N                           d          } fd|D             }|S )zGet a list of all status Resources from the server.

        Refer to :py:meth:`JIRA.issue_types_for_project` for getting statuses
        for a specific issue type within a specific project.

        Returns:
            List[Status]
        r  c                F    g | ]}t          j        j        |          S rW   )rD   re  r   rY   raw_stat_jsonr   s     r[   r   z!JIRA.statuses.<locals>.<listcomp>  s9     
 
 
 4=$-??
 
 
r^   r  )r   r  statusess   `  r[   rO  zJIRA.statuses  sE     ))
 
 
 
!'
 
 
 r^   c                V                           d| d          } fd|D             }|S )a4  Get a list of issue types available within the project.

        Each project has a set of valid issue types and each issue type has a set of valid statuses.
        The valid statuses for a given issue type can be extracted via: `issue_type_x.statuses`

        Returns:
            List[IssueType]
        r  z	/statusesc                F    g | ]}t          j        j        |          S rW   r  rM  s     r[   r   z0JIRA.issue_types_for_project.<locals>.<listcomp>(  r  r^   r  )r   r  r  r  s   `   r[   issue_types_for_projectzJIRA.issue_types_for_project  sR      D> D D DEE
 
 
 
!'
 
 
 r^   rD   c                8    |                      t          |          S )zGet a status Resource from the server.

        Args:
            id (str): ID of the status resource to get

        Returns:
            Status
        )r  rD   r  s     r[   r  zJIRA.status.  r}  r^   list[StatusCategory]c                N                           d          } fd|D             }|S )ztGet a list of status category Resources from the server.

        Returns:
            List[StatusCategory]
        statuscategoryc                F    g | ]}t          j        j        |          S rW   )rE   re  r   rM  s     r[   r   z)JIRA.statuscategories.<locals>.<listcomp>B  s9     
 
 
 4=$-GG
 
 
r^   r  )r   r  statuscategoriess   `  r[   rX  zJIRA.statuscategories;  sH      011
 
 
 
!'
 
 
  r^   rE   c                8    |                      t          |          S )zGet a status category Resource from the server.

        Args:
            id (int): ID of the status category resource to get

        Returns:
            StatusCategory
        )r  rE   r  s     r[   rV  zJIRA.statuscategoryH  s     &&~r:::r^   c                    t          | j        | j        | j        rdnd          }i }|||d<   |                    ||           |S )zGet a user Resource from the server.

        Args:
            id (str): ID of the user to get
            expand (Optional[Any]): Extra information to fetch inside each resource

        Returns:
            User
        r  r   )_query_paramNr  r  )rF   re  r   rb   r  )r   r  r  r~  r   s        r[   r~  z	JIRA.userU  sb     MM(,FJ
 
 

 %F8		"V	$$$r^   r   r   c                J    ||d}|                      t          dd|||          S )a=  Get a list of user Resources that match the search string and can be assigned issues for projects.

        Args:
            username (str): A string to match usernames against
            projectKeys (str): Comma-separated list of project keys to check for issue assignment permissions
            startAt (int): Index of the first user to return (Default: ``0``)
            maxResults (int): Maximum number of users to return. If maxResults evaluates as False, it will try to get all users in batches. (Default: ``50``)

        Returns:
            ResultList
        )r   r  Nz"user/assignable/multiProjectSearch)r  rF   )r   r   r  r   r   r   s         r[   $search_assignable_users_for_projectsz)JIRA.search_assignable_users_for_projectsj  s;    $ '{CC  0
 
 	
r^   c                    |s|st          d          |d|i}|d|i}|||d<   |||d<   |||d<   |                     t          dd|||          S )	aw  Get a list of user Resources that match the search string for assigning or creating issues.

        "username" query parameter is deprecated in Jira Cloud; the expected parameter now is "query", which can just be the full email again.
        But the "user" parameter is kept for backwards compatibility, i.e. Jira Server/Data Center.

        This method is intended to find users that are eligible to create issues in a project or be assigned to an existing issue.
        When searching for eligible creators, specify a project. When searching for eligible assignees, specify an issue key.

        Args:
            username (Optional[str]): A string to match usernames against
            project (Optional[str]): Filter returned users by permission in this project (expected if a result will be used to create an issue)
            issueKey (Optional[str]): Filter returned users by this issue (expected if a result will be used to edit this issue)
            expand (Optional[Any]): Extra information to fetch inside each resource
            startAt (int): Index of the first user to return (Default: ``0``)
            maxResults (int): maximum number of users to return. If maxResults evaluates as False, it will try to get all items in batches. (Default: ``50``)
            query (Optional[str]): Search term. It can just be the email.

        Returns:
            ResultList
        z9Either 'username' or 'query' arguments must be specified.Nr   r   r(  r  r  zuser/assignable/searchrY  r  rF   )	r   r   r(  r  r  r   r   r   r   s	            r[   "search_assignable_users_for_issuesz'JIRA.search_assignable_users_for_issues  s    <  	 	K    (+Fu%F 'F9!)F:%F8  $
 
 	
r^   c                4    |                      dd|i          S )zGet a dict of avatars for the specified user.

        Args:
            username (str): the username to get avatars for

        Returns:
            Dict[str, Any]
        zuser/avatarsr   r  r  )r   r   s     r[   user_avatarszJIRA.user_avatars  s     ~~nj(5K~LLLr^   c                   t           j                            |          }||k    r|}t           j                            |          d         }|||d}ddi}	|||	d<   n|                     |          |	d<   |                     d          }
| j                            |
||	|          }t          |          }|r| 	                    ||          S |S )	a  Register an image file as a user avatar.

        The avatar created is temporary and must be confirmed before it can be used.

        Avatar images are specified by a filename, size, and file object. By default, the client will attempt to autodetect the picture's content type:
        this mechanism relies on ``libmagic`` and will not work out of the box on Windows systems
        (see `Their Documentation <https://filemagic.readthedocs.io/en/latest/guide.html>`_ for details on how to install support).
        The ``contentType`` argument can be used to explicitly set the value
        (note that Jira will reject any type other than the well-known ones for images, e.g. ``image/jpg``, ``image/png``, etc.)

        This method returns a dict of properties that can be used to crop a subarea of a larger image for use.
        This dict should be saved and passed to :py:meth:`confirm_user_avatar` to finish the avatar creation process.
        If you want to confirm the avatar with Jira's default cropping, pass the ``auto_confirm`` argument with a truthy value and
        :py:meth:`confirm_user_avatar` will be called for you before this method returns.

        Args:
            user (str): User to register the avatar for
            filename (str): name of the avatar file
            size (int): size of the avatar file
            avatar_img (bytes): file-like object containing the avatar
            contentType (Optional[Any]): explicit specification for the avatar image's content-type
            auto_confirm (bool): True to automatically confirm the temporary avatar by calling
              :py:meth:`confirm_user_avatar` with the return value of this method. (Default: ``False``)

        r   )r   r  r  r9  r7  Nr	  zuser/avatar/temporaryr  )
r  r   r  r  r  r  r   r  rL   confirm_user_avatar)r   r~  r  r  r  r  r  r  r   r  rr   r  r  s                r[   create_temp_user_avatarzJIRA.create_temp_user_avatar  s    D 22>!!!D 7==**1-  (
 (
 '
3"&1GN## '+&9&9*&E&EGN#mm344Ms67TT.8mm 	'++D2EFFF&&r^   c                    |}|                      d          }| j                            |d|it          j        |                    }t          |          S )ar  Confirm the temporary avatar image previously uploaded with the specified cropping.

        After a successful registry with :py:meth:`create_temp_user_avatar`, use this method to confirm the avatar for use.
        The final avatar can be a subarea of the uploaded image, which is customized with the ``cropping_properties``:
        the return value of :py:meth:`create_temp_user_avatar` should be used for this argument.

        Args:
            user (str): the user to confirm the avatar for
            cropping_properties (Dict[str,Any]): a dict of cropping properties from :py:meth:`create_temp_user_avatar`
        user/avatarr   r  r  )r   r~  r  r  rr   r  s         r[   rd  zJIRA.confirm_user_avatar	  sQ     #mmM**MsJ+=DJtDTDTUU!}}r^   c                Z    |                      d|i|                     d          |          S )zSet a user's avatar.

        Args:
            username (str): the user to set the avatar for
            avatar (str): ID of the avatar to set

        Returns:
            Response
        r   rg  r  )r   r   r  s      r[   set_user_avatarzJIRA.set_user_avatar  s4     "DMM-$@$@&
 
 	
r^   c                r    d|i}|                      d|z             }| j                            ||          S )zDelete a user's avatar.

        Args:
            username (str): the user to delete the avatar from
            avatar (str): ID of the avatar to remove

        Returns:
            Response
        r   zuser/avatar/r  r  )r   r   r  r   rr   s        r[   delete_user_avatarzJIRA.delete_user_avatar(  s?     h'mmNV344}##C#777r^   )internal_id	global_idstr | Issuerl  rm  c                  |du |du z  st          d          ||                     d| d|           }n>|<t          j                            |d          }|                     d| d|           }| j                            |          S )aF  Delete remote link from issue by internalId or globalId.

        Args:
            issue (str): Key (or Issue) of Issue
            internal_id (Optional[str]): InternalID of the remote link to delete
            global_id (Optional[str]): GlobalID of the remote link to delete

        Returns:
            Response
        Nz1Must supply either 'internal_id' XOR 'global_id'.r  z/remotelink/rQ  r   z/remotelink?globalId=)rY  r  urllibr   r   r   r#  )r   r   rl  rm  rr   s        r[   delete_remote_linkzJIRA.delete_remote_link6  s    $ $d):; 	RPQQQ"-- I I IK I IJJCC"**92*>>I-- P P PY P PQQC}##C(((r^   includeActiveincludeInactiveResultList[User]c                t    |s|st          d          ||||d}|                     t          dd|||          S )a  Get a list of user Resources that match the specified search string.

        "username" query parameter is deprecated in Jira Cloud; the expected parameter now is "query", which can just be the full email again.
        But the "user" parameter is kept for backwards compatibility, i.e. Jira Server/Data Center.

        Args:
            user (Optional[str]): a string to match usernames, name or email against.
            startAt (int): index of the first user to return.
            maxResults (int): maximum number of users to return. If maxResults evaluates as False, it will try to get all items in batches.
            includeActive (bool): True to include active users in the results. (Default: ``True``)
            includeInactive (bool): True to include inactive users in the results. (Default: ``False``)
            query (Optional[str]): Search term. It can just be the email.

        Returns:
            ResultList[User]
        z5Either 'user' or 'query' arguments must be specified.)r   r   rr  rs  Nzuser/searchr_  )r   r~  r   r   rr  rs  r   r   s           r[   r  zJIRA.search_usersT  s_    2  	VE 	VTUUU *.	
 
   t]GZQWXXXr^   c                v    | j         rdnd|i}|||d<   |||d<   |                     t          dd|||          S )a  Get a list of user Resources that match a username string and have browse permission for the issue or project.

        Args:
            user (str): a string to match usernames against.
            issueKey (Optional[str]): find users with browse permission for this issue.
            projectKey (Optional[str]): find users with browse permission for this project.
            startAt (int): index of the first user to return. (Default: ``0``)
            maxResults (int): maximum number of users to return. If maxResults evaluates as False, it will try to get all items in batches. (Default: ``50``)

        Returns:
            ResultList
        r   r   Nr  r  zuser/viewissue/search)rb   r  rF   )r   r~  r  r  r   r   r   s          r[   search_allowed_users_for_issuez#JIRA.search_allowed_users_for_issuey  s_    ( "^;''TB!)F:!#-F<   $/*f
 
 	
r^   releaseDate	startDatearchivedreleasedrG   c                >   ||||d}|||d<   |||d<   |||d<   |                      d          }	| j                            |	t          j        |                    }
t          j        d           t          | j        | j        t          |
          	          }|S )
au  Create a version in a project and return a Resource for it.

        Args:
            name (str): name of the version to create
            project (str): key of the project to create the version in
            description (str): a description of the version
            releaseDate (Optional[Any]): the release date assigned to the version
            startDate (Optional[Any]): The start date for the version
            archived (bool): True to create an archived version. (Default: ``False``)
            released (bool): True to create a released version. (Default: ``False``)

        Returns:
            Version
        )r{   r(  rz  r{  Nr+  rx  ry  r  r  r   r.  )
r  r   r  r  r  timesleeprG   re  rL   )r   r{   r(  r+  rx  ry  rz  r{  r  rr   r  r  s               r[   create_versionzJIRA.create_version  s    4   	
 
 ""-D""-D  )DmmI&&MsD)9)9::
1$-JqMMJJJr^   afterc                   i }|||d<   n|||d<   |                      d|z   dz             }| j                            |t          j        |                    }t          | j        | j        t          |                    }|S )a*  Move a version within a project's ordered version list and return a new version Resource for it.

        One, but not both, of ``after`` and ``position`` must be specified.

        Args:
            id (str): ID of the version to move
            after (str): the self attribute of a version to place the specified version after (that is, higher in the list)
            position (Optional[str]): the absolute position to move this version to: must be one of ``First``, ``Last``, ``Earlier``, or ``Later``

        Returns:
            Version
        Nr  rq  version/z/mover  r.  )r  r   r  r  r  rG   re  rL   )r   r  r  rq  r  rr   r  r  s           r[   move_versionzJIRA.move_version  s     !DMM!'DmmJOg566MsD)9)9::$-JqMMJJJr^   c                z    t          | j        | j                  }i }|||d<   |                    ||           |S )zGet a version Resource.

        Args:
            id (str): ID of the version to get
            expand (Optional[Any]): extra information to fetch inside each resource

        Returns:
            Version
        Nr  r  )rG   re  r   r  )r   r  r  r  r   s        r[   r  zJIRA.version  sG     $-77%F8R'''r^   c                B    |                      d|z   dz             }|d= |S )zGet a dict of the counts of issues fixed and affected by a version.

        Args:
            id (str): the version to count issues for
        r  r2  r   r  r   r  r  s      r[   version_count_related_issuesz!JIRA.version_count_related_issues  s+     "&
RBW0W!X!X6Nr^   c                H    |                      d|z   dz             }|d         S )zGet the number of unresolved issues for a version.

        Args:
            id (str): ID of the version to count issues for
        r  z/unresolvedIssueCountissuesUnresolvedCountr  r  s      r[   version_count_unresolved_issuesz$JIRA.version_count_unresolved_issues  s2     "&O55"
 "
 -..r^   c                     dj         di | j        }| j                            |          }t	          | j        | j        t          |                    }|S )zoGet a dict of the current authenticated user's session information.

        Returns:
            User
        r  rW   )r  re  r   rx  rF   rL   )r   rr   r  r~  s       r[   r   zJIRA.session  sT     *")::DM::Mc""DM4=*Q--@@r^   c                J    | j         dz   }| j                            |          S )zfDestroy the session of the current authenticated user.

        Returns:
            Response
        z/rest/auth/latest/session)ri  r   r#  r   rr   s     r[   kill_sessionzJIRA.kill_session  s'     o ;;}##C(((r^   Response | Nonec                \    | j         s$| j        dz   }| j                            |          S dS )zDestroy the user's current WebSudo session.

        Works only for non-cloud deployments, for others does nothing.

        Returns:
            Optional[Response]
        z/rest/auth/1/websudoN)rb   ri  r   r#  r  s     r[   kill_websudozJIRA.kill_websudo  s6     ~ 	-/$::C='',,,tr^   r   c                "    ||f| j         _        dS )zCreates a basic http session.

        Args:
            username (str): Username for the session
            password (str): Password for the username

        Returns:
            ResilientSession
        N)r   r   )r   r   r   s      r[   rn  zJIRA._create_http_basic_session,  s     '1r^   c           	        ddl m} ddlm} 	 ddl m} n,# t
          $ r |}| j                            d           Y nw xY w|                    d          ||fD ]}| ||d         |d         ||d	         |d
                   }|| j	        _
        	 |                                  | j                            d|             d S # t          $ r, | j                            d| ddz   dz              ||u r Y w xY wd S )Nr   )SIGNATURE_HMAC_SHA1)OAuth1)SIGNATURE_RSAz8Fallback SHA 'SIGNATURE_RSA_SHA1' could not be imported.signature_methodconsumer_keykey_certaccess_tokenaccess_token_secret)rsa_keyr  resource_owner_keyresource_owner_secretz'OAuth1 succeeded with signature_method=z5Failed to create OAuth session with signature_method=z.
zAttempting fallback method(s).z@Consider specifying the signature via oauth['signature_method'].)oauthlib.oauth1r  requests_oauthlibr  r  r  rc   debugrx  r   r   rI  r   	exception)r   rB  DEFAULT_SHAr  FALLBACK_SHAsha_typeoauth_instances          r[   rm  zJIRA._create_oauth_session8  s   FFFFFF,,,,,,	WEEEEEEE 	W 	W 	W&LHNNUVVVVV	W #566\R 	 	H#Vn%j)!)#(#8&+,A&B  N "0DMSSSTTT   ""YHYYY67XY  
 |++ ,+	 	s    &>>1C3C=<C=c                   |i }ddl m}m}m} |                    dd          dk    r|}nD|                    d          dk    r|}n(t          d                    |d                              ||          | j        _        d S )Nr   )DISABLEDOPTIONALHTTPKerberosAuthmutual_authenticationr  r  z+Unknown value for mutual_authentication: {})r  )	requests_kerberosr  r  r  rx  rY  r  r   r   )r   rD  r  r  r  r  s         r[   rq  zJIRA._create_kerberos_sessionZ  s     #!JJJJJJJJJJ 7DD
RR$,!!!!"9::jHH$,!!=DD$%<=    .-"7
 
 
r^   c                8    | j         d         }|| j        _        dS )uF  Adds the client certificate to the session.

        If configured through the constructor.

        https://docs.python-requests.org/en/latest/user/advanced/#client-side-certificates
        - str: a single file (containing the private key and the certificate)
        - Tuple[str,str] a tuple of both files’ paths
        r3  N)re  r   cert)r   r3  s     r[   rk  z JIRA._add_client_cert_to_sessionr  s      .2]=-I(r^   c                8    | j         d         }|| j        _        dS )a;  Adds verification strategy for host SSL certificates.

        If configured through the constructor.

        https://docs.python-requests.org/en/latest/user/advanced/#ssl-cert-verification
        - str: Path to a `CA_BUNDLE` file or directory with certificates of trusted CAs.
        - bool: True/False
        r.  N)re  r   r.  )r   ssl_certs     r[   rl  z,JIRA._add_ssl_cert_verif_strategy_to_session~  s       $}X6'r^   dtdatetime.timedelta | Nonec                    t           j                                         }| || z  }t          j        |                                          S rV   )datetimeutcnowcalendartimegm	timetuple)r  r  s     r[   
_timestampzJIRA._timestamp  s<    $$&&>GAq{{}}---r^   c                   	 t          |d         d          }n.# t          $ r!}| j                            d           |d }~ww xY w|                    d           |                    dd            |                    dd	            |                    d
t          | j        d                              |d                                         D ]$}|                    |d         |d                    %|| j	        _
        d S )NsecretHS256)algz(JWT authentication requires requests_jwtzJWT %siatc                4    t                                           S rV   )ra   r  r   s    r[   r  z*JIRA._create_jwt_session.<locals>.<lambda>  s    doo.?.? r^   expc                \    t                               t          j        d                    S )Nr<  )rO  )ra   r  r  	timedeltar  s    r[   r  z*JIRA._create_jwt_session.<locals>.<lambda>  s     tx/A!/L/L/LMM r^   r   r   r  r   r   )rO   	NameErrorrc   rw  set_header_format	add_fieldr   re  r  r   r   )r   rC  jwt_authrs   r  s        r[   ro  zJIRA._create_jwt_session  s    	s8}':::HH 	 	 	HNNEFFFG	 	""8,,,5"?"?@@@MM	
 	
 	
 	5,t}^/L"M"MNNNY%%'' 	+ 	+AqtQqT****%s    
AA  Ac                8    t          |          | j        _        dS )zhCreates token-based session.

        Header structure: "authorization": "Bearer <token_auth>".
        N)r  r   r   )r   rA  s     r[   rp  zJIRA._create_token_session  s    
 'z22r^   c                h    d|i}| j                             ||t          j        |                    S )Nr  r  )r   r  r  r  )r   r   rr   r  r  s        r[   r  zJIRA._set_avatar  s2    f~}  V$*T:J:J KKKr^   r   c                    | j                                         }|                    |ddd            |j        di |S )aX  Returns the full internal api url based on Jira base url and the path provided.

        Using the API version specified during the __init__.

        Args:
          path (str): The subpath desired.
          base (Optional[str]): The base url which should be prepended to the path

        Returns:
          str: Fully qualified URL
        latestr-  )r   r*  r(  rW   re  r  rf  r  r   r   r  r=  s       r[   rR  zJIRA._get_internal_url  sT     -$$&&xjQQ	
 	
 	
 t{%%W%%%r^   c                |    | j                                         }|                    d|i            |j        di |S )aQ  Returns the full url based on Jira base url and the path provided.

        Using the API version specified during the __init__.

        Args:
            path (str): The subpath desired.
            base (Optional[str]): The base url which should be prepended to the path

        Returns:
            str: Fully qualified URL
        r   rW   r  r  s       r[   r  zJIRA._get_url  sE     -$$&&~&&&t{%%W%%%r^   c                ~    | j                                         }|                    |dd            |j        di |S )a;  Returns the full url based on Jira base url and the path provided.

        Using the latest API endpoint.

        Args:
            path (str): The subpath desired.
            base (Optional[str]): The base url which should be prepended to the path

        Returns:
            str: Fully qualified URL
        r  )r   r*  rW   r  r  s       r[   r  zJIRA._get_latest_url  sI     -$$&&(CCDDDt{%%W%%%r^   c                d   |                      ||          }|r.| j                            |t          j        |                    n| j                            ||          }	 t          |          }n<# t          $ r/}| j        	                    | d|r|j
        n|            |d}~ww xY w|S )a  Get the json for a given path and params.

        Args:
            path (str): The subpath required
            params (Optional[Dict[str, Any]]): Parameters to filter the json query.
            base (Optional[str]): The Base Jira URL, defaults to the instance base.
            use_post (bool): Use POST endpoint instead of GET endpoint.

        Returns:
            Union[Dict[str, Any], List[Dict[str, str]]]
        r  r  rX  N)r  r   r  r  r  rx  rL   rY  rc   rw  r  )	r   r   r   r  r  rr   r  r  rs   s	            r[   r  zJIRA._get_json  s    $ mmD$'' 7DMsF););<<<""3v"66 	

	]]FF 	 	 	HNNa77Q#5166A77888G	 s   $A4 4
B->*B((B-resource_clsr   3tuple[str, ...] | tuple[str | int, str] | int | strc                     || j         | j                  }i }|||d<   |                    ||           |st          d|t	          |                    |S )a  Uses the find method of the provided Resource class.

        Args:
            resource_cls (Any): Any instance of :py:class`Resource`
            ids (Union[Tuple[str, str], int, str]): The arguments to the Resource's ``find()``
            expand ([type], optional): The value for the expand property in the Resource's ``find()`` params. Defaults to None.

        Raises:
            JIRAError: If the Resource cannot be found

        Returns:
            Any: A class of the same type as ``resource_cls``
        Nr  )r  r   zUnable to find resource %s(%s))re  r   r  r   r   )r   r  r  r  r  r   s         r[   r  zJIRA._find_for_resource  sl    &  <t}==%F8V,,, 	V<lCPSHHUUUr^   c                &   	 dd l }dd l}	 |                    |j                  fd}|                    | |          | _        | _        d S # t          $ r d | _        Y d S t          $ r d | _        Y d S w xY w# t          $ r d | _        Y d S w xY w)Nr   )flagsc                0                                      d S rV   r  )r  _magics    r[   cleanupz JIRA._try_magic.<locals>.cleanup%  s    LLNNNNNr^   )
weakrefmagicMagicMAGIC_MIME_TYPEref_magic_weakrefr  r  AttributeErrorr  )r   r  r  r  r  s       @r[   rj  zJIRA._try_magic  s    	#NNNLLL#5+@AA# # # # # '.kk$&@&@#$ # # #"! # # #"#  	 	 	DKKKK	s)   A; AA A8$A87A8;BBbuffc                   | j         | j                             |          S 	 t          j                    5 }|                    |           t          j        |j                  d         cddd           S # 1 swxY w Y   t          j        |j                  d         S # t          t          f$ r | j
                            d           Y dS w xY w)zGet the MIME type for a given stream of bytes.

        Args:
            buff (bytes): Stream of bytes

        Returns:
            Optional[str]: the MIME type
        Nr   z]Couldn't detect content type of avatar image. Specify the 'contentType' parameter explicitly.)r  	id_buffertempfileTemporaryFilewrite	mimetypes
guess_typer{   OSErrorr  rc   rd   )r   r  r  s      r[   r  zJIRA._get_mime_type/  s    ;";((...
	')) 7Q +AF33A67 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 '//22# 	 	 	HD   44	s4   B! 4A7*B! 7A;;B! >A;?!B! !+CCold_usernew_userc                <   | j         dk    r|                     d          }d|i}d|i}| j                            d|                     |          j                    | j                            ||t          j	        |                     dS t          d          )	zRename a Jira user.

        Args:
            old_user (str): Old username login
            new_user (str): New username login
        r  r~  r{   r   z	renaming r  z<Support for renaming users in Jira < 6.0.0 has been removed.N)ru  r  rc   r  r~  r  r   r  r  r  r  )r   r  r  rr   r  r   s         r[   rename_userzJIRA.rename_userF  s     =9$$&&v..Cx(G (+F HNNItyy':':'GIIJJJMc&tz'7J7JKKKKK%N  r^   c                    |                      d|           }| j                            |          }d|j        cxk    rdk    rn ndS | j                            |j                   dS )zDeletes a Jira User.

        Args:
            username (str): Username to delete

        Returns:
            bool: Success of user deletion
        zuser/?username=r  i+  TF)r  r   r#  rq   rc   rw  )r   r   rr   r  s       r[   delete_userzJIRA.delete_user[  sy     ""#?X#?#?@@M  %%!-&&&&3&&&&&4q}%%%ur^   c                h   | j         r6dt          |           vrg|                                 }|j        t	          d          d                    |j        d         d         |j        d         d                   | _        | j        d         d	| z   }	 t          j	        || j        d
d| j
        j        i           }|j        dk    rdS | j                            d| d|j                    |j        S # t          $ r:}| j                            d| d|            t	          d| d|           d}~ww xY w| j        dz   }d| j        d         d<   |                     |          }dd|j        |j        |j        |j        d}	 | j
        	                    || j        d         |          }|j        dk    rdS | j                            d| d|j                    |j        S # t          $ r:}| j                            d| d|            t	          d| d|           d}~ww xY w)zDisable/deactivate the user.

        Args:
            username (str): User to be deactivated.

        Returns:
            Union[str, int]
        
authCookieNzCan not log in!z{}={}r   r{   r   r%  z*/admin/rest/um/1/user/deactivate?username=r6  )r  r8  )r  rJ  r  r  TzGot response from deactivating z: zError Deactivating z /secure/admin/user/EditUser.jspaz0application/x-www-form-urlencoded; charset=UTF-8r  r8  truedialog)inline	decoratorr   fullNamer  editNamer  )rb   varsr   rs  r   r  r  re  r  r  r   rJ  rq   rc   rd   rv  rw  ri  r~  r{   r  r  )r   r   r~  rr   r  rs   userInfos          r[   deactivate_userzJIRA.deactivate_userl  s    > >	G 4::--||~~8##$5666")..HY'/HY'0# #
 h'IxIIJ GM"&/(:  !M1   =C''4  QhQQ!-QQ   }$ G G GDXDDDDEEE Eh E E! E EFFFG /$FFCB M)$^4 99X&&D % I ,* I HGM&&y!9 '   =C''4  QhQQ!-QQ   }$ G G GDXDDDDEEE Eh E E! E EFFFGs<   5C8 +C8 8
D<5D77D<3G- +G- -
H175H,,H1
backgroundc                8   |rdnd}| j         dz   }| j                            || j        d                   }|j        dk    rdS |j                            d          s|sdS |j                            d	          r| j                            d
           dS |j                            d          s|rK| j        	                    || j        d         |dd          }|j                            d	          dk    rdS | j        
                    d           dS )a&  Start jira re-indexing. Returns True if reindexing is in progress or not needed, or False.

        If you call reindex() without any parameters it will perform a background reindex only if Jira thinks it should do it.

        Args:
            force (bool): True to reindex even if Jira doesn't say this is needed. (Default: ``False``)
            background (bool): True to reindex in background, slower but does not impact the users. (Default: ``True``)

        Returns:
            bool: True if reindexing is in progress or not needed
        r  stoptheworldz$/secure/admin/jira/IndexReIndex.jspar  r  i  z-To perform the re-index now, please go to theTzAll issues are being re-indexedz$Jira re-indexing is already running.zRe-Index)indexingStrategyreindexr  r   rR  z'Failed to reindex jira, probably a bug.F)ri  r   rx  re  rq   r  r  rc   rd   r  rw  )r   r  r  r  rr   r  s         r[   r  zJIRA.reindex  s;    ,6I<<>o FFMc4=+CDD=C3 KLL		 46;;899 	HCDDD46;;FGG 	5 	""i0,<TT #  A
 v{{<==CCt@AAAur^   
backup.zipattachmentsbool | int | Nonec                   | j         r1| j        dz   }t          j        d|i          }d| j        d         d<   n| j        dz   }d|i}	 | j                            || j        d         |          }|j        d	k    rd
S | j        	                    d|j         d           |j        S # t          $ r%}| j                            d|           Y d}~nd}~ww xY wdS )a  Will call jira export to backup as zipped xml. Returning with success does not mean that the backup process finished.

        Args:
            filename (str): the filename for the backup (Default: "backup.zip")
            attachments (bool): True to also backup attachments (Default: ``False``)

        Returns:
            Union[bool, int]: Returns True if successful else it returns the statuscode of the Response or False
        z/rest/backup/1/export/runbackupcbAttachmentsXMLHttpRequestr  zX-Requested-Withz/secure/admin/XmlBackup.jspar  r  r  TzGot z response from calling backup.zI see %sNF)rb   ri  r  r  re  r   r  rq   rc   rd   rv  rw  )r   r  r  rr   r  r  rs   s          r[   backupzJIRA.backup  s
    > 	-/$EECj/;!?@@G;KDM)$%788/$BBC!8,G	*""3i0Hw"WWA}##tHQAMQQQRRR=  	* 	* 	*HNN:q))))))))	*us   3B' =)B' '
C1CCc                d   t          t          j                    dz            }| j        r| j        d|dz   }n| j                            d           dS | j                            || j        d                   }	 t          j
        |j                  S # t          $ r ddlm} i }	 |                    |j                  }n6# |j        $ r)}| j                            d	|            Y d}~Y dS d}~ww xY w|                                D ]}|                    |          ||<   |cY S w xY w)
zReturn status of cloud backup as a dict.

        Is there a way to get progress for Server version?

        Returns:
            Optional[Dict[str, Any]]
        i  z/rest/obm/1.0/getprogress?_=r   5This functionality is not available in Server versionNr  r  r   zHUnable to find backup info. You probably need to initiate a new backup. )r   r}  rb   ri  rc   rd   r   rx  re  r  r  r  rv  defusedxml.ElementTreeElementTree
fromstring
ParseErrorr   )	r   
epoch_timerr   r  etreeprogressrootper  s	            r[   backup_progresszJIRA.backup_progress  sr    t+,,
> 	/$Q:$Q$Q$QQCCHTUUU4Mc4=+CDD	:af%%% 	 	 	222222H''//#     c_acc   tttttt	
 YY[[ * *"hhqkkOOO	s<   >B D/*CD/
C8C3,D/3C884D/.D/c                N   | j         s| j                            d           dS |                                 }|st	          d          t          j        d|d                   }t          |                    d                    }t          |d                   }|dk    o|d	k    S )
zfReturn boolean based on 'alternativePercentage' and 'size' returned from backup_progress (cloud only).r  Nz#Failed to retrieve backup progress.z\s([0-9]*)\salternativePercentager   r  r;  r   )	rb   rc   rd   r  RuntimeErrorrer4  r   r  )r   r  perc_searchperc_complete	file_sizes        r[   backup_completezJIRA.backup_complete   s    ~ 	HTUUU4%%'' 	FDEEEi8O1PQQa  
 
 v''	#5	A5r^   c                x   | j         s| j                            d           dS |                                 }|st	          d          |d         }|p|}| j        dz   |z   }	 | j                            d|            t          |d          5 }	 | j        	                    || j
        d         d	
          }n# t          $ r t                      w xY w|j        s6| j                            d|j                    t          |j                  |                    d          D ]}|                    |           	 ddd           n# 1 swxY w Y   n`# t          $ r'}	| j                            d|	            Y d}	~	n4d}	~	wt$          $ r$}
| j                            |
           Y d}
~
nd}
~
ww xY wdS )z.Download backup file from WebDAV (cloud only).r  Nz#Unable to retrieve backup progress.fileNamez/webdav/backupmanager/zWriting file to wbr  T)r  streamz$Something went wrong with download: i   z%Unable to access remote backup file: )rb   rc   rd   r  r  ri  r  r  r   rx  re  rv  r   rb  rw  r  iter_contentr  r  )r   r  r  remote_file
local_filerr   r  respblockr  ioes              r[   backup_downloadzJIRA.backup_download/  sR   ~ 	HTUUU4'')) 	FDEEEz*,
o 88;F	 HNN:j::;;;j$'' &4&=,,T]9%=d -  DD ! & & &#++%&w /HNN#U$)#U#UVVV#DI...!..t44 & &EJJu%%%%&& & & & & & & & & & & & & & &  	I 	I 	IHNNG2GGHHHHHHHH 	  	  	 HNN3	 tsa   #-E E(B;:E;CA-EE EE EE 
F7$FF7F22F7r{  c                    t          | d          sR|                     d          }| j                            || j        d                   }t          |          }|| _        || j        rdnd}| j        |         S )a  Return the `accountId` (Cloud) else `username` of the current user.

        For anonymous users it will return a value that evaluates as False.

        Args:
            field (Optional[str]): the name of the identifier field.
              Defaults to "accountId" for Jira Cloud, else "username"

        Returns:
            str: User's `accountId` (Cloud) else `username`.
        _myselfrI  r  r  Nr  r{   )r  r  r   rx  re  rL   r'  rb   )r   r{  rr   r  r  s        r[   current_userzJIRA.current_userN  s~     tY'' 	"--))C!!#t}Y/G!HHA%/]]F!DL= $(>=KKvE|E""r^   pidstr | Projectenable_undoc                V   t          |t                    r$t          |d          rt          |j                  }|                     d|           }| j                            |d|i          }|j        dk    rt          d          |j        dk    rt          d          |j
        S )	a  Delete project from Jira.

        Args:
            pid (Union[str, Project]): Jira projectID or Project or slug.
            enable_undo (bool): Jira Cloud only. True moves to 'Trash'. False permanently deletes.

        Raises:
            JIRAError:  If project not found or not enough permissions
            ValueError: If pid parameter is not Project, slug or ProjectID

        Returns:
            bool: True if project was deleted
        r  r  
enableUndor  i  z(Not enough permissions to delete projectro   zProject not found in Jira)r`   r;   r  r   r  r  r   r#  rq   r   rb  )r   r)  r+  rr   r  s        r[   delete_projectzJIRA.delete_projecth  s    " c7## 	T(:(: 	cf++Cmm,s,,--M  lK-H II=CFGGG=C7888tr^   c                   | j         dz   }| j        j        st          |          | j        _        | j        j        d         |dd}|                    |           | j                            |t          ddi          |          S )Nz&/secure/admin/WebSudoAuthenticate.jspar   r  )webSudoPasswordwebSudoDestinationwebSudoIsPostr	  z!application/x-www-form-urlencodedr  )ri  r   r   r   rf  r  r   )r   r=  r;  rr   r  s        r[   _gain_sudo_sessionzJIRA._gain_sudo_session  s    o HH}! 	5!/!4!4DM  $}1!4"-#
 
 	w}!!'!DE   " 
 
 	
r^   r[  c                    | j         dz   }| j                            |          }t          |          }i }d|v r!|d         D ]}|d         D ]}|||d         <   |S )Nz(/rest/project-templates/latest/templatesprojectTemplatesGroupedByTypeprojectTemplatesr{   )ri  r   rx  rL   )r   rr   r  r  	templatesr  r  s          r[   r7  zJIRA.templates  s    o JJMc"")!}}	*d22=> - -12 - -A+,Iai((- r^   c                    |                      d          }| j                            |          }t          |          }|d         S )NpermissionschemepermissionSchemesr  r   rx  rL   r   rr   r  r  s       r[   permissionschemeszJIRA.permissionschemes  s@    mm.//Mc"")!}}'((r^   list[IssueTypeScheme]c                    |                      d          }| j                            |          }t          |          }|d         S )zGet all issue type schemes defined (Admin required).

        Returns:
            List[IssueTypeScheme]: All the Issue Type Schemes available to the currently logged in user.
        issuetypeschemeschemesr;  r<  s       r[   issue_type_schemeszJIRA.issue_type_schemes  s@     mm-..Mc"")!}}Ir^   c                    |                      d          }| j                            |          }t          |          }|d         S )NissuesecurityschemesissueSecuritySchemesr;  r<  s       r[   rD  zJIRA.issuesecurityschemes  s@    mm233Mc"")!}}*++r^   c                    |                      d          }| j                            |          }t          |          }|S )NprojectCategoryr;  r<  s       r[   projectcategorieszJIRA.projectcategories  s9    mm-..Mc""!}}r^   c                    |                      d| d          }| j                            |          }t          |          }|d         S )Nzavatar/z/systemsystemr;  )r   entityrr   r  r  s        r[   avatarszJIRA.avatars  sI    mm5f55566Mc"")!}}H~r^   c                    |                      d          }| j                            |          }t          |          }|d         S )Nnotificationschemer   r;  r<  s       r[   notificationschemeszJIRA.notificationschemes  s@     mm011Mc"")!}}H~r^   c                    |                      d          }| j                            |          }t          |          }|d         S )Nscreensr   r;  r<  s       r[   rQ  zJIRA.screens  s?     mmI&&Mc"")!}}H~r^   c                    |                      d          }| j                            |          }t          |          }|S )Nworkflowschemesr;  r<  s       r[   workflowschemezJIRA.workflowscheme  s;     mm-..Mc""!}}r^   c                    |                      d          }| j                            |          }t          |          }|S )Nworkflowr;  r<  s       r[   	workflowszJIRA.workflows  s:     mmJ''Mc""!}}r^   c                    |                      d|           }| j                            |          }t          |          }| j                                         |S )Nzscreens/)r  r   r#  rL   rQ  cache_clearr   r  rr   r  r  s        r[   delete_screenzJIRA.delete_screen  sR    mmOrOO,,M  %%!}}  """r^   c                    |                      d|           }| j                            |          }t          |          }| j                                         |S )Nzpermissionscheme/)r  r   r#  rL   r=  rY  rZ  s        r[   delete_permissionschemezJIRA.delete_permissionscheme  sV    mm44455M  %%!}}**,,,r^   c                    |                      d| d          }| j                            |          }t          |          }|S )a  For the specified issue type scheme, returns all of the associated projects. (Admin required).

        Args:
            id (str): The issue type scheme id.

        Returns:
            List[Project]: Associated Projects for the Issue Type Scheme.
        zissuetypescheme/z/associationsr;  rZ  s        r[   "get_issue_type_scheme_associationsz'JIRA.get_issue_type_scheme_associations  sF     mm@r@@@AAMc""!}}r^   software'  ptypetemplate_nameavatarIdissueSecuritySchemepermissionSchemerG  notificationScheme
categoryIdrr   c                   d}||                                  }||}|A|                                 }|D ]}|d         dk    r
|d         } n||r|d         d         }|t          d          |A|                                 }|D ]}|d         dk    r
|d         } n||r|d         d         }|t          d          |r|	s|n|	}	|	A|                                 }|D ]}|d         dk    r
|d         }	 n|	|r|d         d         }	|s| j        rd	nd
}n|}d|d|d|d|| j        rdnd|dddddt          |          d|
d|i
}|rt          |          |d<   |	rt          |	          |d<   |                     d          }| j        	                    |t          j        |                    }|                                 t          |          }|S )a  Create a project with the specified parameters.

        Args:
            key (str): Mandatory. Must match Jira project key requirements, usually only 2-10 uppercase characters.
            name (Optional[str]): If not specified it will use the key value.
            assignee (Optional[str]): Key of the lead, if not specified it will use current user.
            ptype (Optional[str]): Determines the type of project that should be created. Defaults to 'software'.
            template_name (Optional[str]): Is used to create a project based on one of the existing project templates.
              If `template_name` is not specified, then it should use one of the default values.
            avatarId (Optional[int]): ID of the avatar to use for the project.
            issueSecurityScheme (Optional[int]): Determines the security scheme to use. If none provided, will fetch the
              scheme named 'Default' or the first scheme returned.
            permissionScheme (Optional[int]): Determines the permission scheme to use. If none provided, will fetch the
              scheme named 'Default Permission Scheme' or the first scheme returned.
            projectCategory (Optional[int]): Determines the category the project belongs to. If none provided,
              will fetch the one named 'Default' or the first category returned.
            notificationScheme (Optional[int]): Determines the notification scheme to use.
            categoryId (Optional[int]): Same as projectCategory. Can be used interchangeably.
            url (Optional[str]): A link to information about the project, such as documentation.

        Returns:
            Union[bool,int]: Should evaluate to False if it fails otherwise it will be the new project id.
        Nr{   zDefault Permission Schemer  r   z)Unable to identify valid permissionSchemeDefaultz,Unable to identify valid issueSecuritySchemez.com.pyxis.greenhopper.jira:gh-simplified-basicz>com.pyxis.greenhopper.jira:basic-software-development-templaterz   projectTypeKeyprojectTemplateKeyleadAccountIdleadr-  PROJECT_LEADr+  rQ  rf  rg  rr   re  rh  r(  r  )r(  r=  r  rD  rH  rb   r   r  r   r  r  r  r  rL   )r   rz   r{   r  rb  rc  rd  re  rf  rG  rg  rh  rr   template_keyps_listsecr  r  r  s                      r[   create_projectzJIRA.create_project  s   L ((**H<D #,,..G  v;"==='*4y$E >  'G'#*1:d#3 #JKKK&//11G  v;)++*-d)'E , #*w*&-aj&6#&MNNN
 %Q_QJJ/ 	 ",,..G  v;)++&)$iOE , &7&")!*T"2  	) >V@@U L )Lt D3e ,#~9OO68N2$4 5 5 "43
  	F-01D-E-EG)* 	9$'$8$8GL!mmI&&MsG)<)<==	Ar^   r   directoryIdr  notifyr  ignore_existingapplication_keyslist | Nonec
                   |s|}|                      d          }
t                      }||d<   ||d<   ||d<   |r||d<   |rd|d<   |	|	|d	<   t          j        |          }	 | j                            |
|
           nR# t          $ rE}|j        7|j                                        d         }d|v r|d         dk    r|rY d}~dS |d}~ww xY wdS )a  Create a new Jira user.

        Args:
            username (str): the username of the new user
            email (str): email address of the new user
            directoryId (int): The directory ID the new user should be a part of (Default: ``1``)
            password (Optional[str]): Optional, the password for the new user
            fullname (Optional[str]): Optional, the full name of the new user
            notify (bool): True to send a notification to the new user. (Default: ``False``)
            active (bool): True to make the new user active upon creation. (Default: ``True``)
            ignore_existing (bool): True to ignore existing users. (Default: ``False``)
            application_keys (Optional[list]): Keys of products user should have access to

        Raises:
            JIRAError:  If username already exists and `ignore_existing` has not been set to `True`.

        Returns:
            bool: Whether the user creation was successful.
        r~  r  r  r{   r   TruenotificationNapplicationKeysr  r  r   z)A user with that username already exists.T)r  r   r  r  r   r  r   rn   )r   r   r  rt  r   r  ru  r  rv  rw  rr   r  r  rs   errs                  r[   add_userzJIRA.add_user  s.   >  	 H ""6** (MM#-!.&	 	%$AjM 	' &An'#3A *Q--	Ms1111 		 		 		z%joo''1#%%J+VVV' W  44444G		 ts   !A> >
C8CCCbool | dict[str, Any]c                    |                      d          }d|i}d|i}t          j        |          }t          | j                            |||                    }d|vs|d         |k    rdS |S )a^  Add a user to an existing group.

        Args:
            username (str): Username that will be added to specified group.
            group (str): Group that the user will be added to.

        Returns:
            Union[bool,Dict[str,Any]]: json response from Jira server for success or a value that evaluates as False in case of failure.
        
group/userr  r{   r  F)r  r  r  rL   r   r  )r   r   r  rr   r  yr  r  s           r[   add_user_to_groupzJIRA.add_user_to_group  s}     ""<00% X*Q--&t}'9'9#ag'9'V'VWW??ai5005Hr^   c                r    |                      d          }||d}| j                            ||           dS )zRemove a user from a group.

        Args:
            username (str): The user to remove from the group.
            groupname (str): The group that the user will be removed from.

        Returns:
            bool
        r  )r  r   r  Tr  )r   r   r  rr   r  s        r[   remove_user_from_groupzJIRA.remove_user_from_group)  sD     ""<00#::S+++tr^   c                    |                      d          }| j                            |          }t          |          }|S )ztReturn Jira role information.

        Returns:
            List[Dict[str,Any]]: List of current user roles
        role)r  r   rx  rL   r<  s       r[   r  z	JIRA.role:  s<     ""6**Mc""%/]]r^   issueidcustomfieldschemeidc                    | j         dz   }t          |                                          rd| }|||d}| j                            || j        d         |          }t          |          S )Nz$/rest/idalko-igrid/1.0/datagrid/datacustomfield_)_issueId_fieldId_confSchemeIdr  r  )ri  r   isdigitr   rx  re  rL   )r   r  r  r  rr   r   r  s          r[   	get_igridzJIRA.get_igridJ  s~    o FF{##%% 	7666K#%
 

 Mc4=+CFSS!}}r^   ResultList[Board]c           	     |    i }|r||d<   |r||d<   |r||d<   |                      t          dd|||| j                  S )a*  Get a list of board resources.

        Args:
            startAt: The starting index of the returned boards. Base index: 0.
            maxResults: The maximum number of boards to return per page. Default: 50
            type: Filters results to boards of the specified type. Valid values: scrum, kanban.
            name: Filters results to boards that match or partially match the specified name.
            projectKeyOrID: Filters results to boards that match the specified project key or ID.

        Returns:
            ResultList[Board]
        rC  r{   projectKeyOrIdr   boardr  )r  r#   AGILE_BASE_URL)r   r   r   rC  r{   projectKeyOrIDr   s          r[   boardszJIRA.boardsZ  ss    *  	"!F6N 	"!F6N 	6'5F#$  $ ! 
 
 	
r^   board_idextendedstateResultList[Sprint]c           	         i }|r||d<   |t          d           |                     t          dd| d|||| j                  S )a&  Get a list of sprint Resources.

        Args:
            board_id (int): the board to get sprints from
            extended (bool): Deprecated.
            startAt (int): the index of the first sprint to return (0 based)
            maxResults (int): the maximum number of sprints to return
            state (str): Filters results to sprints in specified states. Valid values: `future`, `active`, `closed`.
              You can define multiple states separated by commas

        Returns:
            ResultList[Sprint]: List of sprints.
        r  Nz%The `extended` argument is deprecatedr   zboard/z/sprint)r^  r  rC   r  )r   r  r  r   r   r  r   s          r[   sprintszJIRA.sprints  sj    ,  	$#F7OFGGG  &X&&&
 
 	
r^   dict[str, dict[str, Any]]c                    i }|                      |||          D ]5}|j        |vr|j        ||j        <   t          d|j         d| d          |S )a  Get a dictionary of sprint Resources where the name of the sprint is the key.

        Args:
            board_id (int): the board to get sprints from
            extended (bool): Deprecated.
            state (str): Filters results to sprints in specified states. Valid values: `future`, `active`, `closed`.
              You can define multiple states separated by commas

        Returns:
            Dict[str, Dict[str, Any]]: dictionary of sprints with the sprint name as key
        )r  r  z1There are multiple sprints defined with the name z on board id zS,
returning a dict with sprint names as a key, assumes unique names for each sprint)r  r{   rs  r   )r   r  r  r  r  r   s         r[   sprints_by_namezJIRA.sprints_by_name  s     b85AA 	 	AvW$$"#%i i i]_ i i i   r^   endDategoalc                   i }|r||d<   |r||d<   |r||d<   |r||d<   |r||d<   |                      d| | j                  }| j                            |t	          j        |                    }	t          |	          S )	a  Updates the sprint with the given values.

        Args:
            id (Union[str, int]): The id of the sprint to update
            name (Optional[str]): The name to update your sprint to
            startDate (Optional[Any]): The start date for the sprint
            endDate (Optional[Any]): The start date for the sprint
            state: (Optional[str]): The state of the sprint
            goal: (Optional[str]): The goal of the sprint

        Returns:
            Dict[str, Any]
        r{   ry  r  r  r  sprint/r  r  )r  r  r   r  r  r  rL   )
r   r  r{   ry  r  r  r  r  rr   r  s
             r[   update_sprintzJIRA.update_sprint  s    ,  	#"GFO 	-#,GK  	)!(GI 	%$GG 	#"GFOmmNbNN1DmEEMc
7(;(;<<!}}r^   	sprint_idc                n    |                      d| d| | j                  }|d         d         d         S )0Return the total incompleted points this sprint.&rapid/charts/sprintreport?rapidViewId=
&sprintId=r  contentsincompletedIssuesEstimateSumr   r  r  r   r  r  r  s       r[   r  z!JIRA.incompletedIssuesEstimateSum  sK    #~~TXTTTT$  .  
  
 J >?HHr^   c                                           d| d|  j                  } fd|d         d         D             }|S )z^Return the completed issues for the sprint.

        Returns:
            List[Issue]
        r  r  r  c                F    g | ]}t          j        j        |          S rW   )r/   re  r   )rY   raw_issues_jsonr   s     r[   r   z'JIRA.removed_issues.<locals>.<listcomp>  s9     
 
 
 $-@@
 
 
r^   r  puntedIssuesr  )r   r  r  r  r  s   `    r[   removed_issueszJIRA.removed_issues  so     "&TXTTTT$ "0 "
 "

 
 
 
#)*#5n#E
 
 

 r^   c                n    |                      d| d| | j                  }|d         d         d         S )r  r  r  r  r  puntedIssuesEstimateSumr   r  r  s       r[   removedIssuesEstimateSumzJIRA.removedIssuesEstimateSum  sK    #~~TXTTTT$  .  
  
 J 9:7CCr^   c                n    t          | j        | j                  }|                    |           |j        S )a   Return the information about a sprint.

        Args:
            board_id (str): the board retrieving issues from. Deprecated and ignored.
            sprint_id (str): the sprint retrieving issues from

        Returns:
            Dict[str, Any]
        )rC   re  r   r  rs  )r   r  r  sprints       r[   sprint_infozJIRA.sprint_info
  s1     t}55Izr^   rC   c                d    t          | j        | j                  }|                    |           |S )zReturn the information about a sprint.

        Args:
            sprint_id (int): the sprint retrieving issues from

        Returns:
            Sprint
        )rC   re  r   r  )r   r  r  s      r[   r  zJIRA.sprint  s+     t}55Br^   c                j    t          | j        | j        d|i          }|                                 dS )zDelete an agile board.r  r.  N)r#   re  r   r#  )r   r  r  s      r[   delete_boardzJIRA.delete_board&  s/    dmT]r
CCCr^   scrumr  project_idspresetlocation_typeLiteral['user', 'project']location_idr#   c                   i }|t          d           ||                     |          j        }||d<   ||d<   ||d<   | j        r(d|i|d<   |dvr|d                             d|i           |                     d	| j        
          }| j                            |t          j
        |                    }	t          |	          }
t          | j        | j        |
          S )a  Create a new board for the ``project_ids``.

        Args:
            name (str): name of the Board (<255 characters).
            filter_id (str): the Filter to use to create the Board.
              Note: if the user does not have the 'Create shared objects' permission and tries to create a shared board,
              a private board will be created instead (remember that board sharing depends on the filter sharing).
            project_ids (str): Deprecated. See location_id.
            preset (str): What preset/type to use for this Board, options: kanban, scrum, agility. (Default: "scrum")
            location_type (str): the location type. Available in Cloud. (Default: "user")
            location_id (Optional[str]):  aka ``projectKeyOrId``. The id of Project that the Board should be located under.
              Omit this for a 'user' location_type. Available in Cloud.

        Returns:
            Board: The newly created board
        Nzcproject_ids is deprecated and ignored. Use filter_id and location_id with `location_type='project'`r{   filterIdrC  location)r~  r  r  r  r  r.  )r^  r(  r  rb   rf  r  r  r   r  r  r  rL   r#   re  )r   r{   r  r  r  r  r  r  rr   r  r  s              r[   create_boardzJIRA.create_board+  s   2 #%"Q  
 ",,{336K'
 > 	L#)="9GJI--
#**,<k+JKKKmmG$*=m>>MsG)<)<==#AT]DM~FFFFr^   c                (   d|i}|r||d<   |r||d<   |r||d<   |                      d| j                  }||d<   | j                            |t	          j        |                    }t          |          }	t          | j        | j        |		          S )
a  Create a new sprint for the ``board_id``.

        Args:
            name (str): Name of the sprint
            board_id (int): Which board the sprint should be assigned.
            startDate (Optional[Any]): Start date for the sprint.
            endDate (Optional[Any]): End date for the sprint.
            goal (Optional[str]): Goal for the sprint.

        Returns:
            Sprint: The newly created Sprint
        r{   ry  r  r  r  r  originBoardIdr  r.  )	r  r  r   r  r  r  rL   rC   re  )
r   r{   r  ry  r  r  r  rr   r  raw_sprint_jsons
             r[   create_sprintzJIRA.create_sprint]  s    ( $*4. 	-#,GK  	)!(GI 	#"GFO mmH4+>m??#+ MsG)<)<==$Q--dmT]HHHHr^   
issue_keysc                    |                      d| d| j                  }d|i}| j                            |t	          j        |                    S )a  Add the issues in ``issue_keys`` to the ``sprint_id``.

        The sprint must be started but not completed.

        If a sprint was completed, then have to also edit the history of the issue so that it was added to the sprint before it was
        completed, preferably before it started. A completed sprint's issues also all have a resolution set before the completion date.

        If a sprint was not started, then have to edit the marker and copy the rank of each issue too.

        Args:
            sprint_id (int): the sprint to add issues to
            issue_keys (List[str]): the issues to add to the sprint

        Returns:
            Response
        r  /issuer  r  r  r  r  r   r  r  r  )r   r  r  rr   r  s        r[   add_issues_to_sprintzJIRA.add_issues_to_sprint  sW    " mm7i777d>QmRRZ(}!!#DJw,?,?!@@@r^   epic_idstr | list[str]ignore_epicsc                <   i }t          |t                    r|                    d          nt          |          |d<   |t	          d           |                     d| d| j                  }| j                            |t          j
        |                    S )	a  Add the issues in ``issue_keys`` to the ``epic_id``.

        Issues can only exist in one Epic!

        Args:
            epic_id (str): The ID for the epic where issues should be added.
            issue_keys (Union[str, List[str]]): The list (or comma separated str) of issues
              to add to the epic
            ignore_epics (bool): Deprecated.

        Returns:
            Response
        r   r  Nz`ignore_epics` is Deprecatedzepic/r  r  r  )r`   r   r  r   r^  r  r  r   r  r  r  )r   r  r  r  r  rr   s         r[   add_issues_to_epiczJIRA.add_issues_to_epic  s    &  "%/
C%@%@VJS!!!d:FVFV 	X #=>>>mm3G333$:MmNN}!!#DJt,<,<!===r^   
next_issue
prev_issuec                   ||t          d          ||t          d          |d}|}n|d}|}| j        so|                                 D ]Z}|d         dk    rL|d         d	         d
k    r|d         d         | _         n&|d         d	         dk    r|d         d         | _        [|                     d| j                  }d|gd| d|d| j        i}| j                            |t          j        |                    S )a  Rank an issue before/after another using the default Ranking field, the one named 'Rank'.

        Pass only ONE of `next_issue` or `prev_issue`.

        Args:
            issue (str): issue key of the issue to be ranked before/after the second one.
            next_issue (str): issue key that the first issue is to be ranked before.
            prev_issue (str): issue key that the first issue is to be ranked after.

        Returns:
            Response
        Nz5One of 'next_issue' or 'prev_issue' must be specifiedz9Only one of 'next_issue' or 'prev_issue' may be specifiedBeforeAfterr{   Rankr  customz'com.pyxis.greenhopper.jira:gh-lexo-rankr  z)com.pyxis.greenhopper.jira:gh-global-rankz
issue/rankr  r  rankr/   rankCustomFieldIdr  )	rY  rg  r   r  r  r   r  r  r  )	r   r   r  r  before_or_afterother_issuer{  rr   r  s	            r[   r  z	JIRA.rank  sY   ( *"4TUUU#
(>K   !&O$KK#%O$Kz 	A A A=F**h1DE E &+8_Z%@
h1FG G &+8_Z%@
mmLt/BmCCug)?)));

 }  4:g+>+> ???r^   c                    |                      d| j                  }d|i}| j                            |t	          j        |                    S )a9  Move issues in ``issue_keys`` to the backlog, removing them from all sprints that have not been completed.

        Args:
            issue_keys (List[str]): the issues to move to the backlog

        Raises:
            JIRAError: If moving issues to backlog fails

        Returns:
            Response
        zbacklog/issuer  r  r  r  )r   r  rr   r  s       r[   move_to_backlogzJIRA.move_to_backlog  sK     mmO$2EmFFZ(}!!#DJw,?,?!@@@r^   list[PinnedComment]c                Z                           d| di           } fd|D             }|S )zGet a list of pinned comment Resources of the issue provided.

        Args:
            issue (Union[int, str]): the issue ID or key to get the comments from

        Returns:
            List[PinnedComment]
        r  z/pinned-commentsr  c                F    g | ]}t          j        j        |          S rW   )r8   re  r   r   s     r[   r   z(JIRA.pinned_comments.<locals>.<listcomp>  s:     
 
 
  $-8HII
 
 
r^   r  )r   r   r  pinned_commentss   `   r[   r  zJIRA.pinned_comments  sV      @ @ @ @LL
 
 
 
$*
 
 
 r^   pinc                    |                      dt          |          z   dz   t          |          z   dz             }| j                            |t          |                                                    S )a  Pin/Unpin a comment on the issue.

        Args:
          issue (Union[int, str]): the issue ID or key to get the comments from
          comment (Union[int, str]): the comment ID
          pin (bool): Pin (True) or Unpin (False)

        Returns:
          Response
        r  z	/comment/z/pinr  )r  r   r   r  rP  )r   r   r$  r  rr   s        r[   pin_commentzJIRA.pin_comment  sa     mmHs5zz1K?#g,,NQWWXX}  3s88>>+;+; <<<r^   )NNNNNNFNFTFr2  Tr<  NNNN) r%  r   r=  r>  r?  r@  rA  r   rB  r   rC  r   rD  r   rE  rF  rG  rF  r1  r   rH  rF  rI  r   rJ  rK  rL  rM  r   r@  rN  rO  )rR   r  )rR   r   )rR   rF  )r   r   )r  r   )r  r  r  r   r  r   r   r   r   r   r   r   r  r   r  rF  rR   r  )r  r  r  r   r  r   r   r   r   r   r  r   r  rF  rR   r  )r  r  r  r   r  r  rR   r   )r  r  rR   r   )rQ  )r  r   r  r  rR   r?   )r  )r  r   rV   )rz   r   rR   r  )rz   r   r   r   )T)r  rF  rR   r   )r  r   rR   r"   )rR   r  )r   r  r  r  r  r   rR   r"   )r  r   rR   r   )r  r   )NNNF)r{   r   r(  r   rR   r%   )r  r   rR   r'   )Nr   r:  )rR   r;  )r  r   rR   r(   )NNN)
r{   r   r+  r   rC  rD  rE  rD  rR   r(   )r  r   r{   r   r+  r   rC  rD  rE  rD  rR   r(   )r  r   rO  r   rR   r   )rT  r   rU  r   rR   rV  )rT  r   rU  r   r\  r   rR   r*   )
rT  r   rU  r   r\  r   r   r  rR   r*   )rT  r   rR   rd  )rR   rj  )NNNNNN)rT  rm  rn  r   ro  r   rp  r   rq  rr  rs  r   rt  r   rR   r)   )rR   ry  )r  r   rR   r-   )rR   r~  )NNNN)
r{   r   r+  r   r  r   r  r   rR   r-   )r{   r   r+  r   r  r   r  r   )r  r   r  rK  rR   r.   )NNr  )r   r   r  rK  r   r   rR   r  )r  r   rR   r   )r  r   rR   rF  )
r  r  r   r   r  r   r  r   rR   r/   )NT)r   r   r  rF  rR   r/   )r  ry  r  rF  rR   ry  )r  r   r  r   rR   r&   )rR   r  )r  r   rR   rB   )rR   r   )r   r  )r  r  r   r   r   r   rR   r  )
r  r  r  r  r   r   r   r   rR   r  )r  r  r   r  r  r  r  r   r  r   rR   r  )r~  rF   rR   r   )r~  r   rR   r   )r   r  r  r   rR   rF  )r   r  r  r   r  r   r  r   r  r   rR   r  )r   r  r$  r   r  r   rR   r$   )NF)
r   r'  r(  r   r)  r*  r+  rF  rR   r$   )r   r  )r   r  rR   r2  )r   r  r  r   rR   r<   )r   r   r;  r<  r=  r   r>  r   r?  r   rR   r<   )r   r   rA  r  )NN)r   r'  r  r   )r   r'  rN  r   rR   r   )
r   r'  rR  r   r   r   r$  r   rT  r   )r   r  rR   rH   )r(  r   rR   r3   )r(  r   rR   r6   )r(  r   rR   r7   )r(  r   rR   r:   )r(  r   rR   rJ   )r   r  rR   r   )r   r  rR   rI   )r   r  rs  r   rR   r   )r   r  rR   rz  )r   r  r  r   rR   rK   )	NNNNNNNNN)r   r  rW  r   r  r   r  r   r  r   r  r   r$  r   r  r  r~  r   r)  r   rR   rK   )r   r   rR   r  )r   r   rz   r   rR   r2   )r   r   rz   r   rR   r   )
rC  r  r  r   r  r   r$  r   rR   r   )r  r   rR   r0   )F)r  rF  rR   r  )r  r   rR   r1   )rR   r  )r(  r   r   r   r   r   rR   r  )
r(  r   r  r   r   r   r   r   rR   r  )r  r   rR   r4   )r{   r   r(  r   rR   r4   )r  rB   rR   r  )r  rB   r{   r   )NNNNN)r  r   r  r   r  r   r  r   r  r   rR   r  )rR   r  )r  r   rR   r9   )r  r   rR   r  )r  r   r  r   rR   r;   )r(  r   )r(  r   r  r   r  r   r  r  r  r   r  rF  )r(  r   r  r  )r(  r   r  r   )r(  r   r  r   rR   r   )r(  r   rR   r  )r(  r   rR   r  )r(  r   r
  r   rR   r  )r(  r   r  r   r  r   rR   r   )r(  r   rR   r  )r(  r   r  r   rR   r@   )rR   r  )r  r   rR   r>   )r   r  Tr#  NN)r%  r   r   r   r   r   r&  rF  r   r'  r  r   r  r   r$  r(  r  rF  rR   r)  )r%  r   r   r   r   r   r&  rF  r   r'  r  r   r  r   r$  r.  r  rF  rR   r  )r%  r   r   r   r   r   r&  rF  r   r'  r  r   r  r   r$  rF  r  rF  rR   r0  )Nr  r#  NNN)r%  r   r   r   r   r   r   r'  r  r   r:  r;  r  r   r$  rF  r  rF  rR   r0  )r%  r   r$  rF  rR   r=  )r  r   rR   rA   r  )rR   rJ  )r  r   rR   r  )r  r   rR   rD   )rR   rT  )r  r   rR   rE   )r  r   r  rK  rR   rF   )
r   r   r  r   r   r   r   r   rR   r   )NNNNr   r  N)r   r   r(  r   r  r   r  rK  r   r   r   r   r   r   )r   r   rR   r  )r~  r   r  r   r  r   r  r  r  rK  r  rF  )r~  r   r  r  )r   r   r  r   rR   r   )r   rn  rl  r   rm  r   rR   r   )Nr   r  TFN)r~  r   r   r   r   r   rr  rF  rs  rF  r   r   rR   rt  )NNr   r  )r~  r   r  r   r  r   r   r   r   r   rR   r   )NNNFF)r{   r   r(  r   r+  r   rx  rK  ry  rK  rz  rF  r{  rF  rR   rG   )r  r   r  r   rq  r   rR   rG   )r  r   r  rK  rR   rG   )rR   rF   )rR   r   )rR   r  )r   r   r   r   )rB  r  )rD  r   )r  r  )rC  r  )rA  r   )r   r   r  r   rR   r   )r   r   r   r   r  r   r  rF  )r  r   r  r  rR   r   )r  r  rR   r   )r  r   r  r   )r   r   rR   rF  )r   r   rR   r  )FT)r  rF  r  rF  rR   rF  )r   F)r  r   r  rF  rR   r  )rR   r   )rR   r   )r  r   )r{  r   rR   r   )r)  r*  r+  rF  rR   r   )rR   r[  )rR   r>  r  )r  r   rR   r  )NNr`  NNNNNra  NrQ  )rz   r   r{   r   r  r   rb  r   rc  r   rd  r   re  r   rf  r   rG  r   rg  r   rh  r   rr   r   )r   NNFTFN)r   r   r  r   rt  r   r   r   r  r   ru  rF  r  rF  rv  rF  rw  rx  )r   r   r  r   rR   r  )r   r   r  r   rR   rF  )r  r   r  r   r  r   )r   r  NNN)
r   r   r   r   rC  r   r{   r   rR   r  )Nr   r  N)r  r   r  r   r   r   r   r   r  r   rR   r  )FN)r  r  r  rF  r  r   rR   r  )r  r  r{   r   ry  rK  r  rK  r  r   r  r   rR   r  )r  r   r  r   )r  r   r  r   rR   r  )r  r   rR   rC   )Nr  r~  N)r{   r   r  r   r  r   r  r   r  r  r  r   rR   r#   )r{   r   r  r   ry  rK  r  rK  r  r   rR   rC   )r  r   r  r  rR   r   )r  r   r  r  r  r   rR   r   )r   r   r  r   r  r   rR   r   )r  r  rR   r   )r   r  rR   r  )r   r  r$  r  r  rF  rR   r   )r   r   r   r  r!   AGILE_BASE_REST_PATHr?   rd  ry  r  r  r   r  r  r  ri  rb   rr  rz  r  r  r  r  r  rj   r  r  r  r  r  r   r  r  r  r  r  r  r   r   r%  r'  r/  r5  r7  r9  r>  r?  ru   rK  rN  rS  r[  r^  rc  rB  rl  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.  r1  r7  r:  rF  rI  rM  rS  r\  r^  ra  rc  re  rg  rj  rn  rp  rr  rw  ry  r  rT  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,  r6  rA  rC  rt  rI  rO  rR  r  rX  rV  r~  r]  r`  rb  re  rd  ri  rk  rq  r  rw  r  r  r  r  r  r   r  r  rn  rm  rq  rk  rl  staticmethodr  ro  rp  r  rR  r  r  r  r  rj  r  r  r  r  r  r  r  r  r%  r(  r.  r3  r   r7  r=  rB  rD  rH  rL  rO  rQ  rT  rW  r[  r]  r_  rs  r~  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rW   r^   r[   ra   ra     s        (.* 	 	U	
 	C 	== 	!% 	$ 	T 	 	 	t 	  	!" 	'. ",
 
#4 	c
5O> O *M"1N "6:-1!%'+%)26 $"RV'+GK'P6 P6 P6 P6 P6d ( ( ( X(= = = , , , X, 1 1 1 X1

 

 

 

     "  ! ! !      (,!P P P P Pd  (,!1? 1? 1? 1? Y1?fB B B B $ $ $ $(    HJ    . 
H 
H 
H 
H ]
H  !%G G G G G	@ 	@ 	@ 	@& & & & &0	7 	7 	7 	71 1 1 1 
  $	T T T T Tl
) 
) 
) 
)6 6 6 6 
 !& & & & &P	" 	" 	" 	"
) 
) 
) 
)	> 	> 	> 	> 24
 
 
 
 
2     #'596: O  O  O  O   Y OD 
 #'596:#O #O #O #O   Y#OJ 1 1 1   Y1.
 
 
 
$' ' ' '$Q Q Q Q.      Y2 R R R   YR  !<@!%*. ,R ,R ,R ,R   Y,Rb' ' ' '	3 	3 	3 	3     "&!%I I I I IH  "&!% I  I  I  I  IH    ( !"	    83G 3G 3G 3Gj   .   ( "!!%         H )-7K 7K 7K 7K 7Kt BFK K K K KZ  M M M M0   	8 	8 	8 	8  )-5K 5K 5K 5K ]5Kn   $ 	%
 %
 %
 %
 %
V '
 '
 '
 '
 '
V 59-/)-%)!3: 3: 3: 3: 3:j? ? ? ?$3 $3 $3 $3N       "#"&## # # # #J CGQ Q Q Q Q 
 -1! H  H  H  H  HF 	C 	C 	C 	C      
@ 
@ 
@ 
@$  $-1#'S S S S Sj   4 
 
 
 
 
(   . 
 )-""7 7 7 7 7r 5 5 5 5 J J J J 	D 	D 	D 	D 	B 	B 	B 	B 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 
' 
' 
' 
' " " " " 	8 	8 	8 	8 D D D D    "     
= 
= 
= 
=  !%'+%)"&#",0,0HD HD HD HD HDX     	D 	D 	D 	D = = = =  *..> .> .> .> .>`) ) ) )	6 	6 	6 	6- - - - -"	: 	: 	: 	:     	    B     >	6 	6 	6 	6K K K K K.   .    "& $#""&$> $> $> $> $>P   	5 	5 	5 	5    &
C 
C 
C 
C 
C A A A A  #'"5' 5' 5' 5' 5'n    " X X X X ) ) ) )              $ 
* 
* 
* 
*    * < < < <    	7 	7 	7 	7  #)/!!%  ',          X   #)/!!%      X" #)/!!%h "h h h h h hT  %))/!,0!%W "W W W W W YWr 
 "	- - - - - Y-@	: 	: 	: 	:    ( ( ( (        	3 	3 	3 	3       	; 	; 	; 	;    2 
 
 
 
 
<  $"#! 5
 5
 5
 5
 5
p	M 	M 	M 	M" #'">' >' >' >' >'@   "
 
 
 
8 8 8 8 
 #' $) ) ) ) ) )>  " % #Y #Y #Y #Y #YP  $!%
 
 
 
 
> 
 #'"& $* * * * *Z IM    6    "   	/ 	/ 	/ 	/
 
 
 
) ) ) )   
2 
2 
2 
2       H 37
 
 
 
 
0
) 
) 
)
( 
( 
( . . . . \.& & & &"3 3 3 3L L L 8E & & & & &$ /< & & & & &  6C & & & & && )-!    F 	    8# # #*   .   *   "GG GG GG GGR* * * * *Z AF    <   B6 6 6 6    ># # # # #6 7;    8
 
 
,    U ) ) U)    U , , U,   U    U   U   U   U   U         "  #$(#*.'+&*"'!%p p p p pl ## %(,@ @ @ @ @D   ,   "    
 
 
 
  $
 $
 $
 $
 $
L  !% $
 $
 $
 $
 $
N JN    8   $" % % % % %NI I I I   "D D D D         #'4:"&0G 0G 0G 0G 0Gl !%""I "I "I "I "IHA A A A2 %)	> > > > >> "&!%	7@ 7@ 7@ 7@ 7@rA A A A     " = = = = = =r^   ra   )rQ   r   rR   r   )rv   r   rV   )r   r   r   r   rR   r   )r  
__future__r   r  r  r  r   r  rH  r`  r  r  r  rX  r  r}  rp  r\  collectionsr   collections.abcr   r   	functoolsr   r   ior	   numbersr
   typingr   r   r   r   r   r   r   r   urllib.parser   r   r   r  packaging.versionr   r  r   requests.authr   requests.structuresr   requests.utilsr   requests_toolbeltr   rP   r   jira.exceptionsr   r   jira.resilientsessionr   r    jira.resourcesr!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   
jira.utilsrL   rM   rN   requests_jwtrO   r  	getLoggerr  
addHandlerNullHandlerrj   ru   r   r   r   r   r   r   r   r  ra   rW   r^   r[   <module>r     s    # " " " " "              				 				 



     # # # # # # . . . . . . . . " " " " " " " "            	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 3 2 2 2 2 2 2 2 2 2  4 4 4 4 4 4       " " " " " " 3 3 3 3 3 3 ) ) ) ) ) ) . . . . . .       ; ; ; ; ; ; ; ; J J J J J J J J, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,Z N M M M M M M M M M	$$$$$$$ 	 	 	D	 h   #x#%% & & &# # # #L# # # #L   0 %)! ! ! ! ! w~TJJJ86 86 86 86 86w|, 86 86 86xD D D D D D D DBP+ P+ P+ P+ P+X P+ P+ P+f
 
 
 
 
 
 
 
AV= AV= AV= AV= AV= AV= AV= AV= AV= AV=s   $D+ +D32D3