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

��Jh��
@sjddlZddlmZmZddlmZmZmZmZm	Z	ddl
mZmZm
Z
ddlmZddlmZddlmZddlmZdd	lmZdd
lmZmZmZmZmZe�e	�e ��Z!Gdd�de�Z"Gd
d�dee�Z#eee$d�dd�Z%d&e"eee#d�dd�Z&d'e"eeee#d�dd�Z'edde'e"dd�Z(ddde#e
j)dfe
j*dfe
j+d fe
j,d!fe
j-d"fgd#d$d%�Z.dS)(�N)�List�Optional)�entitlements�lock�messages�status�util)�AbstractProgress�ProgressWrapper�
exceptions)�APIEndpoint)�AdditionalInfo)�_enabled_services)�_is_attached)�UAConfig)�
BoolDataValue�
DataObject�Field�StringDataValue�	data_listc@s@eZdZededd�ededdd�gZdd�eed�d	d
�Z	dS)�DisableOptions�servicezPro service to disable��doc�purgeFzqAlso remove all packages that were installed from this service. Only supported by some services. (default: false))r�rrcCs||_||_dS�Nr)�selfrr�r�H/usr/lib/python3/dist-packages/uaclient/api/u/pro/services/disable/v1.py�__init__$szDisableOptions.__init__N)
�__name__�
__module__�__qualname__rrr�fields�str�boolr rrrrrs��
rc@s2eZdZedee�dd�gZeed�dd�Z	dS)�
DisableResult�disabledzList of services disabledr�r(cCs
||_dSrr))rr(rrrr 2szDisableResult.__init__N)
r!r"r#rrrr$rr%r rrrrr')s��r')�cfg�returncCsdd�t|�jD�S)NcSsg|]
}|j�qSr)�name)�.0�srrr�
<listcomp>7sz+_enabled_services_names.<locals>.<listcomp>)rZenabled_services�r*rrr�_enabled_services_names6sr1)�options�progress_objectr+cCst|t�|d�S)N)r3)�_disabler)r2r3rrr�disable:sr5)r2r*r3r+c
CsJt|�}t��st���t|�js*t���tj	||j
|jd�}t|�}|j
|krZt
gd�S|j}|dk	rl|}|��|_d}d}z*tjdd��|�|�\}}W5QRXWn.tk
r�}	zt��|	�W5d}	~	XYnX|�s|dk	r�|jdk	r�|j}
ntj}
tj|j
|
d��t|�}tj|d�|��t
ttt|��t|����d�S)	zt
    Disable a Pro service. This will automatically disable any services that
    depend on the target service.
    )r*r,rr)NFzu.pro.services.disable.v1)Zlock_holder)r�reasonr0) r
rZwe_are_currently_rootr�NonRootUserErrorrZis_attached�UnattachedErrorrZentitlement_factoryrrr1r'Zenabled_variantZcalculate_total_disable_stepsZtotal_stepsrZ	RetryLockr5�	ExceptionZclear_lock_file_if_present�messagerZGENERIC_UNKNOWN_ISSUE�EntitlementNotDisabledErrorrZfinish�sorted�list�set�
difference)r2r*r3ZprogressZentitlementZenabled_services_beforeZvariantZsuccessZfail_reason�er6Zenabled_services_afterrrrr4@sb	
�
�
������r4Zv1ZDisableServiceT)�versionr,�fnZoptions_clsZsupports_progressZ32z|
from uaclient.api.u.pro.services.disable.v1 import disable, DisableOptions
result = disable(DisableOptions(service="usg"))
zWhen called as non-root userzCWhen called on a machine that is not attached to a Pro subscriptionz9When the service argument is not a valid Pro service namez8When another Ubuntu Pro related operation is in progressz!When the service fails to disablez4pro api u.pro.services.disable.v1 --args service=usgz+
{
    "disabled": [
        "usg"
    ]
}
)Z
introduced_inZrequires_networkZexample_pythonZresult_classrZexample_cliZexample_json)N)N)/Zlogging�typingrrZuaclientrrrrrZuaclient.apir	r
rZuaclient.api.apirZuaclient.api.data_typesr
Z-uaclient.api.u.pro.status.enabled_services.v1rZ(uaclient.api.u.pro.status.is_attached.v1rZuaclient.configrZuaclient.data_typesrrrrrZ	getLoggerZreplace_top_level_logger_namer!ZLOGrr'r%r1r5r4Zendpointr7r8ZEntitlementNotFoundErrorZ
LockHeldErrorr;Z_docrrrr�<module>sl
��	��L�	������