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/detach/__pycache__/v1.cpython-38.pyc
U

��Jh�@s(ddlmZddlmZmZmZmZmZmZm	Z	ddl
mZddlm
Z
ddlmZmZddlmZddlmZddlmZdd	lmZmZmZmZmZdd
lmZmZm Z ddl!m"Z"Gdd
�d
ee�Z#e#d�dd�Z$ee#d�dd�Z%ee#d�dd�Z&e
dde%dd�Z'ddde#ej(dfgddd �Z)dS)!�)�List)�daemon�entitlements�
exceptions�lock�messages�timer�util)�ProgressWrapper)�APIEndpoint)�AdditionalInfo�ErrorWarningObject)�_reboot_required)�_is_attached)�UAConfig)�
BoolDataValue�
DataObject�Field�StringDataValue�	data_list)�
machine_token�notices�state_files)�update_motd_messagesc@s@eZdZedee�dd�ededd�gZee	e
d�dd�Zd	S)
�DetachResult�disabledz1The services disabled during the detach operation)�doc�reboot_requiredz?True if the system requires a reboot after the detach operation�rrcCs||_||_dS�Nr)�selfrr�r!�>/usr/lib/python3/dist-packages/uaclient/api/u/pro/detach/v1.py�__init__0szDetachResult.__init__N)�__name__�
__module__�__qualname__rrrrZfieldsr�str�boolr#r!r!r!r"rs���r)�returncCs
tt��Sr)�_detachrr!r!r!r"�detach5sr+)�cfgr)c
Csft��stj�z$tjdd��t|�}W5QRXWn.tk
r`}zt��|�W5d}~XYnX|S)zZ
    This endpoint allows the user to detach the machine from a Pro
    subscription.
    zpro.api.u.pro.detach.v1)Zlock_holderN)	r	Zwe_are_currently_rootr�NonRootUserErrorrZ	RetryLock�_detach_in_lock�	ExceptionZclear_lock_file_if_present)r,�ret�er!r!r"r*9s�r*c
	Cs8t|�jstgdd�Sg}g}t�|�D]�}ztj||d�}Wntjk
rXYq(YnX|jdd�\}}|r(|�	t
��\}}|s�|r�|jr�|jj}	|jj
}
ntjj|d�}	d}
|�t|	|
d|id	��q(|�|�q(t�tjj�t��t����t|�t��t� �t!|�}tt"|�|j#d
kd�}||_$|S)NFr)r,�nameT)Zignore_dependent_services)�title��service)r3�code�metaZyes)%rZis_attachedrrZentitlements_disable_orderZentitlement_factoryrZEntitlementNotFoundError�can_disable�disabler
�message�msgr2rZDISABLE_FAILED_TMPL�format�appendr
r�removeZNoticeZLIMITED_TO_RELEASErZdelete_state_filesrZget_machine_token_file�deleterr�startr�stopr�sortedr�warnings)
r,rrCZent_nameZentr8�_r0�reasonr;r6Zreboot_required_result�resultr!r!r"r.LsT
�


���r.Zv1ZDetachN)�versionr2�fnZoptions_clsZ32TzD
from uaclient.api.u.pro.detach.v1 import detach

result = detach()
z1Raised if a non-root user executes this endpoint.zpro api u.pro.detach.v1zL
{
    "disabled": ["service1", "service2"],
    "reboot_required": false
}
)Z
introduced_inZrequires_networkZexample_pythonZresult_classrZexample_cliZexample_json)*�typingrZuaclientrrrrrrr	Zuaclient.apir
Zuaclient.api.apirZuaclient.api.data_typesrr
Z5uaclient.api.u.pro.security.status.reboot_required.v1rZ(uaclient.api.u.pro.status.is_attached.v1rZuaclient.configrZuaclient.data_typesrrrrrZuaclient.filesrrrZuaclient.timer.update_messagingrrr+r*r.Zendpointr-Z_docr!r!r!r"�<module>s>$	9����