/usr/lib/python3/dist-packages/uaclient/api/u/pro/attach/magic/wait/__pycache__
Edit: /usr/lib/python3/dist-packages/uaclient/api/u/pro/attach/magic/wait/__pycache__/v1.cpython-310.pyc (4173B)
o
Ki[ @ s d dl Z d dlmZmZ d dlmZ d dlmZ d dlm Z d dl
mZ d dlm
Z
mZmZmZ dZG d d
d
e
ZG dd de
eZd
edefddZd
ede defddZeddeedZdddeejdfejdfejdfejdfgddd ZdS )! N)
exceptionssecret_manager)APIEndpoint)AdditionalInfo)UAConfig)UAContractClient)
DataObjectFieldIntDataValueStringDataValueF c @ s* e Zd ZededdgZdefddZdS )MagicAttachWaitOptionsmagic_tokenz,The Token provided by the initiate endpoint.docc C s
|| _ d S Nr )selfr r I/usr/lib/python3/dist-packages/uaclient/api/u/pro/attach/magic/wait/v1.py__init__ s
zMagicAttachWaitOptions.__init__N)__name__
__module____qualname__r r fieldsstrr r r r r r
s r
c @ sz e Zd Zededdededdededdeded ded
eddeded
dgZdedededed
edefddZ 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 argumentexpiresz0Timestamp of the Magic Attach process expiration
expires_inz/Seconds before the Magic Attach process expirescontract_idz2ID of the contract the machine will be attached tocontract_tokenz(The contract Token to attach the machinec C s( || _ || _|| _|| _|| _|| _d S r r r r r r! r" )r r r r r r! r" r r r r D s
zMagicAttachWaitResult.__init__N)
r r r r r r
r r intr r r r r r sZ $r optionsreturnc C s t | t S r )_waitr )r% r r r waitU s r( cfgc
C s t |}d}d}d}tj| j |tk rd}z|j| jd}d}W n5 tjy/ Y t tj y: d}Y n tj
yW } z|dk rK|d7 }n|W Y d}~nd}~ww |ry|dduryt|d |d
|d t
|d |d
|d dS |r}d}t| |d7 }|tk st )zi
This endpoint polls the contracts service waiting for the user to confirm
the Magic Attach.
r
Nr
contractTokenuserCoder r expiresIn
contractIDr# )r r secrets
add_secretr MAXIMUM_ATTEMPTSget_magic_attach_token_infor MagicAttachTokenErrorMagicAttachUnavailableConnectivityErrorgetr r$ timesleep)r% r) contractnum_attemptsnum_connection_errors wait_time wait_resper r r r' [ sN
)r' v1MagicAttachWait)versionnamefnoptions_clsz27.11Tz
from uaclient.api.u.pro.attach.magic.wait.v1 import MagicAttachWaitOptions, wait
options = MagicAttachWaitOptions(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=z
{
"user_code":"",
"token":"",
"expires": "T.",
"expires_in": 500,
"contract_id": "",
"contract_token": "",
}
)
introduced_inrequires_networkexample_pythonresult_classr example_cliexample_json)r: uaclientr r uaclient.api.apir uaclient.api.data_typesr uaclient.configr uaclient.contractr uaclient.data_typesr r r
r r4 r
r r( r' endpointr8 ContractAPIErrorr6 r7 _docr r r r s`
6
: