%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python3/dist-packages/uaclient/__pycache__/
Upload File :
Create Path :
Current File : //usr/lib/python3/dist-packages/uaclient/__pycache__/contract.cpython-312.pyc

�

�(�f�w��~�ddlZddlZddlZddlmZddlmZmZmZm	Z	m
Z
ddlmcm
ZddlmZmZmZmZmZmZmZmZmZddlmZddlmZddlmZddlm Z dd	l!m"Z"m#Z#dd
l$m%Z%ddl&m'Z'dZ(d
Z)d
Z*dZ+dZ,dZ-dZ.dZ/dZ0dZ1dZ2ddddd�Z3ejh�Z5ejlejne8��Z9edddg�Z:Gd�de%jv�Z<de=fd�Z>	d;d ed!ee?efd"ee?efd#e@d$e@d%dfd&�ZA		d<d ed'ee?efd(ee?efd#e@d$e@d%e
ee@ffd)�ZBd*ej�d%ej�fd+�ZEd efd,�ZFd ed%eefd-�ZGd ed.e?d%ee?effd/�ZHd0ee?e?fd1ee?e?fd%eIfd2�ZJ	d=d3ee?efd4e?d5e?de	e?d%eeIee?efff
d6�ZK		d>d'ee?efd7e	e?de	e?d%dfd8�ZLd ed9ee?efd%ee:fd:�ZMy)?�N)�
namedtuple)�Any�Dict�List�Optional�Tuple)	�clouds�event_logger�
exceptions�http�messages�secret_manager�system�util�version)�_enabled_services)�_is_attached)�UAConfig)�ATTACH_FAIL_DATE_FORMAT)�attachment_data_file�machine_id_file)�
serviceclient)�get_user_or_root_log_file_pathz/v1/context/machines/tokenz3/v1/contracts/{contract}/context/machines/{machine}z
/v1/resourcesz3/v1/resources/{resource}/context/machines/{machine}z/v1/clouds/{cloud_type}/tokenz3/v1/contracts/{contract}/machine-activity/{machine}z/v1/contractz/v1/magic-attach����)�series_overrides�series�cloud�variant�EnableByDefaultService�namer!c����eZdZdZ	ddeeddf�fd�
Zeje	jgd���	dd��Zdee
effd	�Zd
e
dee
effd�Zeje	jgd���dej$fd
��Z	dde
de
dee
dee
effd�Zd�Zde
dee
effd�Zdee
effd�Zde
fd�Z	dde
de
dee
dee
effd�Z	dde
de
dee
defd�Zd�Z�xZS)�UAContractClient�contract_urlN�cfg�returnc�X��t�|�|��tj�|_y)N�r')�super�__init__�mtf�get_machine_token_file�machine_token_file)�selfr'�	__class__s  ��3/usr/lib/python3/dist-packages/uaclient/contract.pyr,zUAContractClient.__init__Es&���	���S��!�"%�"<�"<�">���)rrr)�retry_sleepsc�<�|stj|j�}|j�}|j	ddj|�i�|j
�}|j�|d<||d�}t|�}|jt||��}|jdk(rtj��|jdk(rt|�|jdk7r0tjt|j|j �	��|j"}	t$j&j)|	j+d
d��|	j+dg�D]1}
t$j&j)|
j+d
d���3|	S)a}Requests machine attach to the provided machine_id.

        @param contract_token: Token string providing authentication to
            ContractBearer service endpoint.
        @param machine_id: Optional unique system machine id. When absent,
            contents of /etc/machine-id will be used.

        @return: Dict of the JSON response containing the machine-token.
        �
Authorization�	Bearer {}�lastAttachment��	machineId�activityInfo)�data�headers�i�����url�code�body�machineToken��resourceTokens�token)r�get_machine_idr'r=�update�format�_get_activity_info�	isoformat�_support_old_machine_info�request_url�API_V1_ADD_CONTRACT_MACHINErBr�AttachInvalidTokenError�_raise_attach_forbidden_message�ContractAPIErrorrC�	json_dictr�secrets�
add_secret�get)r0�contract_token�
attachment_dt�
machine_idr=�
activity_infor<�backcompat_data�response�
response_jsonrGs           r2�add_contract_machinez%UAContractClient.add_contract_machineLsl����.�.�t�x�x�8�J��,�,�.�������);�);�N�)K�L�M��/�/�1�
�*7�*A�*A�*C�
�&�'�'��G��3�D�9���#�#�'�o�w�$�
���=�=�C���4�4�6�6�
�]�]�c�
!�+�H�5��=�=�C���-�-�/��]�]��]�]��
�
!�*�*�
����)�)����n�b�1�	
�#�&�&�'7��<�	F�E��"�"�-�-�e�i�i���.D�E�	F��r3c��|j�}|jt|d|d|d|dd���}|jdk7r0t	j
t|j|j���|jS)	z=Requests list of entitlements available to this machine type.�architecturer�kernel�virt�r`rrarb)�query_paramsr?r@)rKrN�API_V1_AVAILABLE_RESOURCESrBrrRrCrS)r0rZr\s   r2�available_resourcesz$UAContractClient.available_resourcesws����/�/�1�
��#�#�&� -�n� =�'��1�'��1�%�f�-�	�$�
���=�=�C���-�-�.��]�]��]�]��
�
�!�!�!r3rWc�*�|j�}|jddj|�i�|jt|��}|j
dk7r0t
jt|j
|j���|jS)Nr6r7�r=r?r@)
r=rIrJrN�API_V1_GET_CONTRACT_USING_TOKENrBrrRrCrS)r0rWr=r\s    r2�get_contract_using_tokenz)UAContractClient.get_contract_using_token�s����,�,�.�������);�);�N�)K�L�M��#�#�+�W�$�
���=�=�C���-�-�3��]�]��]�]��
�
�!�!�!r3�instancec��|jtj|j��|j��}|j
dk7ry|jjdd�}|r+tj|�tj|���tjt|j
|j���|j}tjj!|jdd��|S)	z�Requests contract token for auto-attach images for Pro clouds.

        @param instance: AutoAttachCloudInstance for the cloud.

        @return: Dict of the JSON response containing the contract-token.
        )�
cloud_type)r<r?�messagerE)�	error_msgr@�
contractToken)rN�,API_V1_GET_CONTRACT_TOKEN_FOR_CLOUD_INSTANCErJrm�identity_docrBrSrV�LOG�debugr�InvalidProImagerRrCrrTrU)r0rkr\�msgr]s     r2�%get_contract_token_for_cloud_instancez6UAContractClient.get_contract_token_for_cloud_instance�s����#�#�8�?�?�#�.�.�
@�
��&�&�	$�
���=�=�C���$�$�(�(��B�7�C���	�	�#�� �0�0�3�?�?��-�-�@��]�]��]�]��
�!�*�*�
����)�)����o�r�2�	
��r3�
machine_token�resourcerYc��|stj|j�}|j�}|j	ddj|�i�tj||��}|j||��}|jdk7r0tjt|j|j���|jjd�r|jd|jd<|j}|jdg�D]1}tjj!|jd	d
���3|S)a�Requests machine access context for a given resource

        @param machine_token: The authentication token needed to talk to
            this contract service endpoint.
        @param resource: Entitlement name.
        @param machine_id: Optional unique system machine id. When absent,
            contents of /etc/machine-id will be used.

        @return: Dict of the JSON response containing entitlement accessInfo.
        r6r7)ry�machinerhr?r@�expiresrFrGrE)rrHr'r=rIrJ�"API_V1_GET_RESOURCE_MACHINE_ACCESSrNrBrrRrCrVrSrrTrU)	r0rxryrYr=rAr\r]rGs	         r2�get_resource_machine_accessz,UAContractClient.get_resource_machine_access�s#�� ��.�.�t�x�x�8�J��,�,�.�������);�);�M�)J�K�L�0�7�7��z�8�
���#�#�C��#�9���=�=�C���-�-�6��]�]��]�]��
�
�����	�*�,4�,<�,<�Y�,G�H���y�)� �*�*�
�"�&�&�'7��<�	F�E��"�"�-�-�e�i�i���.D�E�	F��r3c��|jj}|jjjd�}t	j
|j�}|j�}tj||��}|j�}|jddj|�i�|j|||��}|jdk7r,tj||j|j ���|j"rA|jj}|j"|d<|jj%|�y	y	)
z�Report current activity token and enabled services.

        This will report to the contracts backend all the current
        enabled services in the system.
        rD��contractr{r6r7)r=r<r?r@r;N)r/�contract_idrxrVrrHr'rK�API_V1_UPDATE_ACTIVITY_TOKENrJr=rIrNrBrrRrCrS�write)r0r�rxrY�request_datarAr=r\s        r2�update_activity_tokenz&UAContractClient.update_activity_token�s'���-�-�9�9���/�/�=�=�A�A��
�
��*�*�4�8�8�4�
��.�.�0��*�1�1� �*�2�
���,�,�.�������);�);�M�)J�K�L��#�#�C��|�#�L���=�=�C���-�-��h�m�m�(�-�-��
���� �3�3�A�A�M�-5�,>�,>�M�.�)��#�#�)�)�-�8�r3�magic_tokenc�.�|j�}|jddj|�i�|jt|��}|j
dk(rt
j��|j
dk(rt
j��|j
dk7r0t
jt|j
|j���|j}gd�}|D]1}tjj|j|d	���3|S)
z�Request magic attach token info.

        When the magic token is registered, it will contain new fields
        that will allow us to know that the attach process can proceed
        r6r7rhr>�r?r@�rG�userCoderprE)r=rIrJrN�"API_V1_GET_MAGIC_ATTACH_TOKEN_INFOrBr�MagicAttachTokenError�MagicAttachUnavailablerRrCrSrrTrUrV)r0r�r=r\r]�
secret_fields�fields       r2�get_magic_attach_token_infoz,UAContractClient.get_magic_attach_token_infos����,�,�.�������);�);�K�)H�I�J��#�#�.��$�
���=�=�C���2�2�4�4��=�=�C���3�3�5�5��=�=�C���-�-�6��]�]��]�]��
�
!�*�*�
�>�
�"�	L�E��"�"�-�-�m�.?�.?��r�.J�K�	L��r3c��|j�}|jt|d��}|jdk(rt	j
��|jdk7r0t	jt|j|j���|j}gd�}|D]1}tjj|j|d���3|S)z)Create a magic attach token for the user.�POST�r=�methodr�r?r@r�rE)
r=rN�API_V1_NEW_MAGIC_ATTACHrBrr�rRrCrSrrTrUrV)r0r=r\r]r�r�s      r2�new_magic_attach_tokenz'UAContractClient.new_magic_attach_token$s����,�,�.���#�#�#���$�
���=�=�C���3�3�5�5��=�=�C���-�-�+��]�]��]�]��
�
!�*�*�
�>�
�"�	L�E��"�"�-�-�m�.?�.?��r�.J�K�	L��r3c���|j�}|jddj|�i�|jt|d��}|j
dk(rt
j��|j
dk(rt
j��|j
dk(rt
j��|j
dk7r0t
jt|j
|j�	��y
)z)Revoke a magic attach token for the user.r6r7�DELETEr�i�r>r�r?r@N)r=rIrJrN�API_V1_REVOKE_MAGIC_ATTACHrBr� MagicAttachTokenAlreadyActivatedr�r�rRrC)r0r�r=r\s    r2�revoke_magic_attach_tokenz*UAContractClient.revoke_magic_attach_token;s����,�,�.�������);�);�K�)H�I�J��#�#�&���$�
���=�=�C���=�=�?�?��=�=�C���2�2�4�4��=�=�C���3�3�5�5��=�=�C���-�-�.��]�]��]�]��
� r3r�c
�>�|stj|j�}|j�}|j	ddj|�i�tj||��}|j�}|j|d||d|d|d|dd	��
�}|jdk7r,tj||j|j���|jjd
�r|jd
|jd
<|jS)a|Get the updated machine token from the contract server.

        @param machine_token: The machine token needed to talk to
            this contract service endpoint.
        @param contract_id: Unique contract id provided by contract service
        @param machine_id: Optional unique system machine id. When absent,
            contents of /etc/machine-id will be used.
        r6r7r��GETr`rrarbrc)r�r=rdr?r@r|)rrHr'r=rIrJ�API_V1_GET_CONTRACT_MACHINErKrNrBrrRrCrVrS)r0rxr�rYr=rArZr\s        r2�get_contract_machinez%UAContractClient.get_contract_machineRs����.�.�t�x�x�8�J��,�,�.�������);�);�M�)J�K�L�)�0�0� ��1�
���/�/�1�
��#�#���� -�n� =�'��1�'��1�%�f�-�	�	$�

���=�=�C���-�-��h�m�m�(�-�-��
������	�*�,4�,<�,<�Y�,G�H���y�)��!�!�!r3c�8�|stj|j�}|j�}|j	ddj|�i�||j
�d�}t|�}tj||��}|j||d|��}|jdk7r,tj||j|j���|jjd	�r|jd	|jd	<|jS)
a�Request machine token refresh from contract server.

        @param machine_token: The machine token needed to talk to
            this contract service endpoint.
        @param contract_id: Unique contract id provided by contract service.
        @param machine_id: Optional unique system machine id. When absent,
            contents of /etc/machine-id will be used.

        @return: Dict of the JSON response containing refreshed machine-token
        r6r7r9r�r�)r=r�r<r?r@r|)rrHr'r=rIrJrKrM�API_V1_UPDATE_CONTRACT_MACHINErNrBrrRrCrVrS)	r0rxr�rYr=r<r[rAr\s	         r2�update_contract_machinez(UAContractClient.update_contract_machine}s�� ��.�.�t�x�x�8�J��,�,�.�������);�);�M�)J�K�L�#� �3�3�5�
��4�D�9��,�3�3� �*�4�
���#�#����o�$�
���=�=�C���-�-��h�m�m�(�-�-��
������	�*�,4�,<�,<�Y�,G�H���y�)��!�!�!r3c��tj�jtj�jtj�j
tj�tj�tj�tj�d�}t|j�jr�t|j�j}t!j"�}|j$j&xstj(|j�|j$j*|D�cgc]}|j,��c}|D�cic]%}|j.r|j,|j0��'c}|r|j2j5�ndd�}ni}i|�|�Scc}wcc}w)z9Return a dict of activity info data for contract requests)�distributionrarr`�desktoprb�
clientVersionN)�
activityID�
activityToken�	resources�resourceVariantsr8)r�get_release_infor��get_kernel_info�
uname_releaser�
get_dpkg_arch�
is_desktop�
get_virt_typer�get_versionrr'�is_attachedr�enabled_servicesr�readr/�activity_idrH�activity_tokenr#�variant_enabled�variant_name�attached_atrL)r0�machine_infor��attachment_data�servicerZs      r2rKz#UAContractClient._get_activity_info�sn��#�3�3�5�B�B��,�,�.�<�<��-�-�/�6�6�"�0�0�2��(�(�*��(�(�*�$�0�0�2�
������!�-�-�0����:�K�K��2�7�7�9�O�"�5�5�A�A�3��(�(����2�!%�!8�!8�!G�!G�:J�K�w�g�l�l�K�$4�%���.�.��L�L�'�"6�"6�6�%�'�$�/�/�9�9�;���M�"�M�
��
��
�	
��L��%s�F6�!*F;
�N)�__name__�
__module__�__qualname__�cfg_url_base_attrrrr,r�retry�socket�timeoutr^r�strrrfrjr	�AutoAttachCloudInstancerwr~r�r�r�r�r�r�rK�
__classcell__)r1s@r2r%r%Bs����&��#'�?�
�h�
�?�
�?��T�Z�Z����Y�7�8<�(�8�(�T"�T�#�s�(�^�"�("�s�"�t�C��H�~�"��T�Z�Z����Y�7��!�9�9��8��H%)�	$��$��$��S�M�	$�

�c�3�h��$�L&9�P�s��t�C��H�~��8��S�#�X���.�S��6%)�	)"��)"��)"��S�M�	)"�

�c�3�h��)"�^%)�	&"��&"��&"��S�M�	&"�

�&"�P&
r3r%�request_bodyc	��|jdi�}|jd�||jd�|jd�|jd�|jd�dtj�jd�d	�S)
a?
    Transforms a request_body that has the new activity_info into a body that
    includes both old and new forms of machineInfo/activityInfo

    This is necessary because there may be old ua-airgapped contract
    servers deployed that we need to support.
    This function is used for attach and refresh calls.
    r;r:r`r�rar�Linux)r�rar�type�release)r:r;r`�os)rVrr�r�)r�rZs  r2rMrM�s���!�$�$�^�R�8�M�"�%�%�k�2�%�%�)�)�.�9�)�-�-�n�=�#�'�'��1�#�'�'��1���.�.�0�8�8�
�	
�
r3r'�past_entitlements�new_entitlements�allow_enablerr(c��ddlm}d}g}g}||�D]I}		||	}
g}	t||j	|	i�|
||��\}}|s�2|s�5t
j
|	��Kt
j|�t|�dkDretj t#||�D�	�cgc]9\}	}|	t$j&j)t+|�t-��	�f��;c}}	�
��|r4tj.|D�	cgc]}	|	t$j0f��c}	�
��y#t$rY��wxYw#tj$rJ}
tj|
�d}|j|	�tjd|	|
�Yd}
~
��sd}
~
wt$rY}
tj|
�|j|
�|j|	�tjd|	|
�Yd}
~
���d}
~
wwxYwcc}}	wcc}	w)a�Iterate over all entitlements in new_entitlement and apply any delta
    found according to past_entitlements.

    :param cfg: UAConfig instance
    :param past_entitlements: dict containing the last valid information
        regarding service entitlements.
    :param new_entitlements: dict containing the current information regarding
        service entitlements.
    :param allow_enable: Boolean set True if allowed to perform the enable
        operation. When False, a message will be logged to inform the user
        about the recommended enabled service.
    :param series_overrides: Boolean set True if series overrides should be
        applied to the new_access dict.
    r)�entitlements_enable_orderF)r'�orig_access�
new_accessr�rTz+Failed to process contract delta for %s: %rNz5Unexpected error processing contract delta for %s: %r)ro�log_path)�failed_services)�uaclient.entitlementsr��KeyError�process_entitlement_deltarV�event�service_processedr�UbuntuProErrorrs�	exception�append�error�	Exception�services_failed�len�AttachFailureUnknownError�zipr
�UNEXPECTED_ERRORrJr�r�AttachFailureDefaultServices�!E_ATTACH_FAILURE_DEFAULT_SERVICES)r'r�r�r�rr��delta_error�unexpected_errorsr�r#�new_entitlement�deltas�service_enabled�er�s               r2�process_entitlements_deltar��s��*@��K����O�)�#�.�%.��	�.�t�4�O���	.�&?��-�1�1�$��;�*�)�!1�'�#�F�O�8�6��'�'��-�K%.�L
���/�*�
����!��2�2�(+�?�<M�'N�	�$�D�)�
��-�-�4�4�"%�i�.�!?�!A�5���	�
�	
�
��5�5�,����x�A�A�B��
�	
�
��c�	��	���(�(�	��M�M�!���K��"�"�4�(��I�I�=���
�
��
�	��M�M�!���$�$�Q�'��"�"�4�(��M�M�G���
�
��		��"	��sA�D �#D0�">G0
�>G6� 	D-�,D-�0G-�?F�G-�AG(�(G-r�r�c�(�ddlm}|rt|�tj||�}d}|r�|jdi�jd�}|s!|jdi�jd�}|st
j||���|jdi�jdi�jd	d
�}		||||	��}
|
j|||��}||fS#tj$r}tjd|�|�d
}~wwxYw)a,Process a entitlement access dictionary deltas if they exist.

    :param cfg: UAConfig instance
    :param orig_access: Dict with original entitlement access details before
        contract refresh deltas
    :param new_access: Dict with updated entitlement access details after
        contract refresh
    :param allow_enable: Boolean set True if allowed to perform the enable
        operation. When False, a message will be logged to inform the user
        about the recommended enabled service.
    :param series_overrides: Boolean set True if series overrides should be
        applied to the new_access dict.

    :raise UbuntuProError: on failure to process deltas.
    :return: A tuple containing a dict of processed deltas and a
             boolean indicating if the service was fully processed
    r��entitlement_factoryF�entitlementr�)�orig�new�entitlements�obligations�use_selectorrE�r'r#r!z3Skipping entitlement deltas for "%s". No such classN�r�)r�r��apply_contract_overridesr�get_dict_deltasrVr� InvalidContractDeltasServiceType�EntitlementNotFoundErrorrsrt�process_contract_deltas)r'r�r�r�rr�r��retr#r!r��excs            r2r�r�Cs��0:�� ��,�
�
!�
!�+�z�
:�F�
�C�
����}�b�1�5�5�f�=����:�:�m�R�0�4�4�V�<�D���=�=� �j��
�

�N�N�>�2�.�
�S���
#�
�S���
$�	�

	�-�����K��1�1���l�2�
���3�;����2�2�	��I�I�E�t�
��I��		�s�>C!�!D�4D�Dr\c���|jjd�}|r�|d}|d}|dk(rB|djt�}t	j
|||djd����|dk(rB|djt�}t	j|||djd��	��|d
k(rt	j|���t	j��)N�info�
contractId�reasonzno-longer-effective�timez%m-%d-%Y)r��date�contract_expiry_dateznot-effective-yet)r�r�contract_effective_dateznever-effective)r�)	rSrV�strftimerr�AttachForbiddenExpired�AttachForbiddenNotYet�AttachForbiddenNever�AttachExpiredToken)r\rr�rrs     r2rQrQ�s������!�!�&�)�D���<�(���h����*�*���<�(�(�)@�A�D��3�3�'��%)�&�\�%:�%:�:�%F�	�
��*�
*���<�(�(�)@�A�D��2�2�'��(,�V��(=�(=�j�(I�	�
��(�
(��1�1�k�J�J�
�
'�
'�
)�)r3c���tj|�}|j�}|j}|d}|ddd}t	|��}|j||��}|j
|�tjj�|jdi�jdtj|��}tj|�t|||j�d�	�y
)z�Request contract refresh from ua-contracts service.

    :raise UbuntuProError: on failure to update contract or error processing
        contract deltas
    :raise ConnectivityError: On failure during a connection
    rD�machineTokenInfo�contractInfo�idr*)rxr�r:Fr�N)
r-r.r�rxr%r�r�rrH�cache_clearrVrr�)	r'r/�orig_entitlements�
orig_tokenrxr��contract_client�resprYs	         r2�refreshr�s����3�3�C�8��*�7�7�9��#�1�1�J��~�.�M��/�0��@��F�K�&�3�/�O��2�2�#��3��D����T�"�
���%�%�'����,�b�1�5�5��V�*�*�3�/��J����*�%�����'�'�)��	r3c�\�t|�}|j�}|jdg�S)zDQuery available resources from the contract server for this machine.r�)r%rfrV)r'�clientr�s   r2�get_available_resourcesr�s+��
�c�
"�F��*�*�,�I��=�=��b�)�)r3rGc�:�t|�}|j|�S)z/Query contract information for a specific token)r%rj)r'rGrs   r2�get_contract_informationr�s��
�c�
"�F��*�*�5�1�1r3�override_selector�selector_valuesc�~�d}|j�D]'\}}||f|j�vry|t|z
}�)|S)Nr)�items�OVERRIDE_SELECTOR_WEIGHTS)rr�override_weight�selector�values     r2�_get_override_weightr&�sV���O�,�2�2�4�?���%��e��O�$9�$9�$;�;���4�X�>�>��?�
�r3r��series_namermc� �i}||d�}|r||d<|jdi�j|i�}|r||td<tj|j	dg��}|D]%}t|jd�|�}	|	s�!|||	<�'|S)N)rr r!rr�	overridesr$)�popr"�copy�deepcopyrVr&)
r�r'rmr!r)rr�general_overrides�override�weights
          r2�_select_overridesr0�s����I�!,�z�B�O��%,��	�"�"���x��4�8�8��b�I����	�+�,>�?�@��
�
�k�o�o�k�2�&F�G��%�)��%��L�L��$�o�
��� (�I�f��)��r3rc��ddlm}tt|t�d|vg�stdj
|���|�tj�jn|}|�\}}|jdi�}t||||�}t|j��D][\}	}
|
j�D]C\}}|dj|�}
t|
t�r|
j|��<||d|<�E�]y)a�Apply series-specific overrides to an entitlement dict.

    This function mutates orig_access dict by applying any series-overrides to
    the top-level keys under 'entitlement'. The series-overrides are sparse
    and intended to supplement existing top-level dict values. So, sub-keys
    under the top-level directives, obligations and affordance sub-key values
    will be preserved if unspecified in series-overrides.

    To more clearly indicate that orig_access in memory has already had
    the overrides applied, the 'series' key is also removed from the
    orig_access dict.

    :param orig_access: Dict with original entitlement access details
    r)�get_cloud_typer�z?Expected entitlement access dict. Missing "entitlement" key: {}N)�uaclient.clouds.identityr2�all�
isinstance�dict�RuntimeErrorrJrr�rrVr0�sortedr!rI)r�rr!r2r'rm�_�orig_entitlementr)�_weight�overrides_to_apply�keyr%�currents              r2r�r��s
��&8��
�;��-�}��/K�L�M��
��&��%�
�	
�-3�N����!�(�(���#�$�M�J��"���}�b�9��!��+�z�7��I�(.�i�o�o�.?�'@�	8�#��#�,�2�2�4�	8�J�C��!�-�0�4�4�S�9�G��'�4�(����u�%�38��M�*�3�/�	8�	8r3r�c���ddlm}g}|j�D]�\}}|jdi�jdd�}	||||��}|jdi�jdi�}|jd�}	|j
||	�s�z|j�\}
}|
s��|jt||�	����|S#tj
$rY��wxYw)
Nrr�r�r�rEr�r��
resourceToken)r#r!)
r�r�r!rVrr��_should_enable_by_default�
can_enabler�r")r'r�r��enable_by_default_services�ent_name�	ent_valuer!�entr�r@rBr9s            r2�get_enabled_by_default_servicesrG's���:�!#��+�1�1�3����)��-�-�
�r�2�6�6�~�r�J��	�%�#�H�g�N�C� �m�m�M�2�6�:�:�=�"�M��!�
�
�o�6�
��(�(��m�D��N�N�,�M�J���*�1�1�*�%� '����*&�%��!�2�2�	��	�s�C	�	C�C)T)FTr�)NN)Nr+�loggingr��collectionsr�typingrrrrr�uaclient.files.machine_token�filesrxr-�uaclientr	r
rrr
rrrr�-uaclient.api.u.pro.status.enabled_services.v1r�(uaclient.api.u.pro.status.is_attached.v1r�uaclient.configr�uaclient.defaultsr�uaclient.files.state_filesrr�
uaclient.httpr�uaclient.logrrOr�r�rer}rqr�rir�r�r�r"�get_event_loggerr��	getLogger�replace_top_level_logger_namer�rsr"�UAServiceClientr%r6rMr��boolr�r��HTTPResponse�NamedMessagerQrrr�intr&r0r�rG�r3r2�<module>r^s*����
�"�3�3�*�*�
�
�
�L�A�$�5�L�'�7�;��9��:��-��9�#�0O�,�9��#1��%7�"�,��/����
��	��	&��%�%�'���g���:��:�:�8�D�E��$��v�y�1���
I
�}�4�4�I
�X�D��@"�W
�	�W
��C��H�~�W
��3��8�n�W
��	W
�
�W
�
�
W
�|�!�<�	�<��c�3�h��<��S�#�X��<��	<�
�<��4��:��
<�~*����*�
���*�:���B*��*�d�4�j�*�2�(�2�3�2�4��S��>�2�	��C��H�~�	�8<�S�#�X��	��	� "�	��c�3�h��������c�]�	�

�#�t�C��H�~�
���>!�!�.8��c�3�h��.8��S�M�.8��c�]�.8�
�	.8�b&�	�&�!%�c�3�h��&�	�
 �!�&r3

Zerion Mini Shell 1.0