HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python3/dist-packages/uaclient/api/u/pro/attach/magic/wait/__pycache__/v1.cpython-38.pyc
U

��Jh[�	@s�ddlZddlmZmZddlmZddlmZddlm	Z	ddl
mZddlm
Z
mZmZmZdZGd	d
�d
e
�ZGdd�de
e�Zeed
�dd�Zee	ed�dd�Zeddeed�Zdddeejdfejdfejdfejdfgddd�ZdS) �N)�
exceptions�secret_manager)�APIEndpoint)�AdditionalInfo)�UAConfig)�UAContractClient)�
DataObject�Field�IntDataValue�StringDataValue�Fc@s*eZdZededd�gZed�dd�ZdS)�MagicAttachWaitOptions�magic_tokenz,The Token provided by the initiate endpoint.��doc�rcCs
||_dS�Nr)�selfr�r�I/usr/lib/python3/dist-packages/uaclient/api/u/pro/attach/magic/wait/v1.py�__init__szMagicAttachWaitOptions.__init__N)�__name__�
__module__�__qualname__r	r�fields�strrrrrrr
s��r
c
@speZdZededd�ededd�ededd�eded	d�ed
edd�eded
d�gZeeeeeed�dd�Z	dS)�MagicAttachWaitResult�	user_codezACode the user will see in the UI when confirming the Magic Attachr�tokenz1The same Magic Token that was sent as an argument�expiresz0Timestamp of the Magic Attach process expiration�
expires_inz/Seconds before the Magic Attach process expires�contract_idz2ID of the contract the machine will be attached to�contract_tokenz(The contract Token to attach the machine�rrrr r!r"cCs(||_||_||_||_||_||_dSrr#)rrrrr r!r"rrrrDs	zMagicAttachWaitResult.__init__N)
rrrr	rr
rr�intrrrrrrsL�������&�r)�options�returncCst|t��Sr)�_waitr)r%rrr�waitUsr()r%�cfgr&c
Cs t|�}d}d}d}tj�|j�|tk�rd}z|j|jd�}d}Wnltjk
rbY�qYnRtj	k
rzd}Yn:tj
k
r�}z|dkr�|d7}n|�W5d}~XYnX|r�|�d�dk	r�t|d	|d
|dt
|d�|d
|dd�S|�rd}t�|�|d7}q"t���dS)zi
    This endpoint polls the contracts service waiting for the user to confirm
    the Magic Attach.
    r�
Nr���Z
contractTokenZuserCoderrZ	expiresInZ
contractIDr#)rrZsecretsZ
add_secretr�MAXIMUM_ATTEMPTSZget_magic_attach_token_infor�MagicAttachTokenError�MagicAttachUnavailable�ConnectivityError�getrr$�time�sleep)r%r)ZcontractZnum_attemptsZnum_connection_errorsZ	wait_timeZ	wait_resp�errrr'[sD
�


�

r'Zv1ZMagicAttachWait)�version�name�fnZoptions_clsz27.11Tz�
from uaclient.api.u.pro.attach.magic.wait.v1 import MagicAttachWaitOptions, wait

options = MagicAttachWaitOptions(magic_token="<magic_token>")
result = wait(options)
zARaised if it is not possible to connect to the contracts service.zLRaised if there is an unexpected error in the contracts service interaction.z-Raised when an invalid/expired Token is sent.zHRaised if the Magic Attach service is busy or unavailable at the moment.zCpro api u.pro.attach.magic.wait.v1 --args magic_token=<magic_token>z�
{
    "user_code":"<UI_code>",
    "token":"<magic_token>",
    "expires": "<yyyy-MM-dd>T<HH:mm:ss>.<TZ>",
    "expires_in": 500,
    "contract_id": "<Contract-ID>",
    "contract_token": "<attach_token>",
}
)Z
introduced_inZrequires_networkZexample_pythonZresult_classrZexample_cliZexample_json)r3ZuaclientrrZuaclient.api.apirZuaclient.api.data_typesrZuaclient.configrZuaclient.contractrZuaclient.data_typesrr	r
rr.r
rr(r'Zendpointr1ZContractAPIErrorr/r0Z_docrrrr�<module>sT
7��:�������