
    UٵgT                        d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZ d dlmZmZmZmZ  G d d	ee      Zd
efdZde	d
efdZ edded      Zdddeej*                  dfej,                  dfej.                  dfgdddZy)    )secret_manager)
exceptions)APIEndpoint)AdditionalInfo)UAConfig)UAContractClient)
DataObjectFieldIntDataValueStringDataValuec                   x    e Zd Z eded       eded       eded       eded	      gZdedededefd
Z	y)MagicAttachInitiateResult	user_codezACode the user will see in the UI when confirming the Magic Attach)doctokenzgMagic Token that can be used in either `u.pro.attach.magic.revoke.v1`_ or `u.pro.attach.magic.wait.v1`_expiresz0Timestamp of the Magic Attach process expiration
expires_inz/Seconds before the Magic Attach process expiresc                 <    || _         || _        || _        || _        y Nr   r   r   r   )selfr   r   r   r   s        M/usr/lib/python3/dist-packages/uaclient/api/u/pro/attach/magic/initiate/v1.py__init__z"MagicAttachInitiateResult.__init__.   s      #
$    N)
__name__
__module____qualname__r
   r   r   fieldsstrintr    r   r   r   r      s    		
 	1		
 	B	

 	A	
/F<
%
% 
% 	
%
 
%r   r   returnc                  (    t        t                     S r   )	_initiater   r!   r   r   initiater%   ;   s    XZ  r   cfgc           	         t        |       }|j                         }t        j                  j	                  |d          t        j                  j	                  |d          t        |d   |d   |d   t        |d               S )z
    This endpoint initiates the Magic Attach flow, retrieving the User Code to
    confirm the operation and the Token used to proceed.
    r   userCoder   	expiresInr   )r   new_magic_attach_tokenr   secrets
add_secretr   r    )r&   contractinitiate_resps      r   r$   r$   ?   s    
  $H335M%%mG&<=%%mJ&?@$
+G$i(}[12	 r   v1MagicAttachInitiateN)versionnamefnoptions_clsz27.11TzW
from uaclient.api.u.pro.attach.magic.initiate.v1 import initiate

result = initiate()
zARaised if it is not possible to connect to the contracts service.zLRaised if there is an unexpected error in the contracts service interaction.zHRaised if the Magic Attach service is busy or unavailable at the moment.z&pro api u.pro.attach.magic.initiate.v1z
{
    "user_code":"<UI_code>",
    "token":"<magic_token>",
    "expires": "<yyyy-MM-dd>T<HH:mm:ss>.<TZ>",
    "expires_in": 600
}
)introduced_inrequires_networkexample_pythonresult_classr   example_cliexample_json)uaclientr   uaclient.apir   uaclient.api.apir   uaclient.api.data_typesr   uaclient.configr   uaclient.contractr   uaclient.data_typesr	   r
   r   r   r   r%   r$   endpointConnectivityErrorContractAPIErrorMagicAttachUnavailable_docr!   r   r   <module>rG      s    # # ( 2 $ . )%
N )%X!+ !8  9 " 		 
 . ((	
 ''(	
 --	
. <C)r   