PHP WebShell

Текущая директория: /usr/lib/python3/dist-packages/uaclient/api/u/pro/status/is_attached/__pycache__

Просмотр файла: v1.cpython-310.pyc

o

Uٵg<�
@sddlZddlmZmZddlmZddlmZddlm	Z	ddl
mZmZm
Z
mZmZddlmZmZddlmZGd	d
�d
ee�ZejGdd�dej��Zd
e	dedeedeeeffdd�Zdefdd�Zd
e	defdd�Zeddedd�Zdddegdddd �ZdS)!�N)�Optional�Tuple)�APIEndpoint)�AdditionalInfo)�UAConfig)�
BoolDataValue�
DataObject�Field�IntDataValue�StringDataValue)�!CONTRACT_EXPIRY_GRACE_PERIOD_DAYS�CONTRACT_EXPIRY_PENDING_DAYS)�
machine_tokenc@s`eZdZededd�ededdd�ededd�ed	ed
d�gZdede	e
ded	efdd�Zd
S)�IsAttachedResult�is_attachedz=True if the machine is attached to an Ubuntu Pro subscription)�doc�contract_statusFz%Status of the Ubuntu Pro subscription�contract_remaining_daysz2Number of days left in the Ubuntu Pro subscription�is_attached_and_contract_validzbTrue if the machine is attached to an Ubuntu Pro subscription and that subscription is not expiredcCs||_||_||_||_dS�N�rrrr)�selfrrrr�r�J/usr/lib/python3/dist-packages/uaclient/api/u/pro/status/is_attached/v1.py�__init__3s
zIsAttachedResult.__init__N)
�__name__�
__module__�__qualname__r	rrr
�fields�boolr�str�intrrrrrrs@���������rc@s eZdZdZdZdZdZdZdS)�ContractExpiryStatusN�activezactive-soon-to-expirezgrace-period�expired)rrr�NONE�ACTIVE�ACTIVE_EXPIRED_SOON�EXPIRED_GRACE_PERIOD�EXPIREDrrrrr"Asr"�cfg�is_machine_attached�remaining_days�returncCs�|stjdfSt}t}|durtj|fSd|kr|kr&nntj|fS||kr1dkr8nntj|fS||krBtj|fStj|fS)z/Return a tuple [ContractExpiryStatus, num_days]rN)r"r%rr
r)r'r(r&)r*r+r,�grace_period�pending_expiryrrr�_get_contract_expiry_statusJs





r0cCs
tt��Sr)�_is_attachedrrrrrrcs
rcCsNt�|�}t|j�}t|||j�\}}d}|r|tjkrd}t||j||d�S)zO
    This endpoint shows if the machine is attached to a Pro subscription.
    TFr)	r�get_machine_token_filerr0rr"r)r�value)r*�machine_token_filer+rr,rrrrr1gs 

��
�r1�v1�
IsAttached)�version�name�fn�options_cls�28FzZ
from uaclient.api.u.pro.status.is_attached.v1 import is_attached

result = is_attached()
z#pro api u.pro.status.is_attached.v1z�
{
    "contract_remaining_days": 360,
    "contract_status": "active",
    "is_attached": true,
    "is_attached_and_contract_valid": true
}
a�
.. tab-item:: Explanation
    :sync: explanation

    The ``contract_status`` field can return 4 different states, they are:

    * **active**: The contract is currently valid.
    * **grace-period**: The contract is in the grace period. This means that
      it is expired, but there are still some days where the contract will be
      valid.
    * **active-soon-to-expire**: The contract is almost expired, but still
      valid.
    * **expired**: The contract is expired and no longer valid.
)�
introduced_in�requires_network�example_python�result_class�
exceptions�example_cli�example_json�extra) �enum�typingrr�uaclient.api.apir�uaclient.api.data_typesr�uaclient.configr�uaclient.data_typesrrr	r
r�uaclient.defaultsrr
�uaclient.filesrr�unique�Enumr"rr!r0rr1�endpoint�_docrrrr�<module>sJ,���

��
�

Выполнить команду


Для локальной разработки. Не используйте в интернете!