%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/uaclient/api/u/pro/status/is_attached/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/uaclient/api/u/pro/status/is_attached/__pycache__/v1.cpython-312.pyc

�

�(�f<�
�J�ddlZddlmZmZddlmZddlmZddlm	Z	ddl
mZmZm
Z
mZmZddlmZmZddlmZGd	�d
ee�Zej,Gd�dej.��Zd
e	dedeedeeeffd�Zdefd�Zd
e	defd�Zedded��Zdddegdddd�Zy)�N)�Optional�Tuple)�APIEndpoint)�AdditionalInfo)�UAConfig)�
BoolDataValue�
DataObject�Field�IntDataValue�StringDataValue)�!CONTRACT_EXPIRY_GRACE_PERIOD_DAYS�CONTRACT_EXPIRY_PENDING_DAYS)�
machine_tokenc��eZdZeded��ededd��eded��ed	ed
��gZdede	e
ded	efd�Zy)
�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 expiredc�<�||_||_||_||_y�N�rrrr)�selfrrrrs     �J/usr/lib/python3/dist-packages/uaclient/api/u/pro/status/is_attached/v1.py�__init__zIsAttachedResult.__init__3s$��'���.���'>��$�.L��+�N)
�__name__�
__module__�__qualname__r
rrr�fields�boolr�str�intr�rrrrs���
���O�		
�	����7�		
�	�%��D�	
�
	�,��8�		
�'�F�:M��M�"�#��	M�
"%�M�)-�
Mrrc� �eZdZdZdZdZdZdZy)�ContractExpiryStatusN�activezactive-soon-to-expirezgrace-period�expired)rrr �NONE�ACTIVE�ACTIVE_EXPIRED_SOON�EXPIRED_GRACE_PERIOD�EXPIREDr%rrr'r'As���D�
�F�1��)���Grr'�cfg�is_machine_attached�remaining_days�returnc�B�|stjdfSt}t}|�tj|fSd|cxkr|krnntj
|fS||cxkrdkrnntj|fS||krtj|fStj|fS)z/Return a tuple [ContractExpiryStatus, num_days]r)r'r*r
rr.r,r-r+)r/r0r1�grace_period�pending_expirys     r�_get_contract_expiry_statusr6Js����#�(�(�!�+�+�4�L�1�N���#�+�+�l�]�:�:��N�,�n�,�#�7�7��G�G�
��.�	,�1�	,�#�8�8�.�H�H�	�<�-�	'�#�+�+�^�;�;��&�&��6�6rc�(�tt��Sr)�_is_attachedrr%rrrrcs����
�#�#rc���tj|�}t|j�}t|||j�\}}d}|r|t
jk(rd}t||j||��S)zO
    This endpoint shows if the machine is attached to a Pro subscription.
    TFr)	r�get_machine_token_filer"r6rr'r.r�value)r/�machine_token_filer0rr1rs      rr8r8gs���'�=�=�c�B���1�?�?�@��&A��
 �"4�"L�"L�'�#�O�^�&*�"���2�:�:�:�).�&��'�'�-�-� .�'E�	�r�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_typesrr	r
rr�uaclient.defaultsr
r�uaclient.filesrr�unique�Enumr'r"r$r6rr8�endpoint�_docr%rr�<module>rXs����"�(�2�$����)�)M�z�>�)M�X����4�9�9��
��7�	�7��7��S�M�7����$�%�	7�2$�%�$��h��#3��4��	���	�����
%��8��
�'!�r

Zerion Mini Shell 1.0