o >f @s4ddlZddlmZddlmZmZmZmZmZm Z ddl m Z m Z ddl mZmZmZddlmZddlmZddlmZmZdd lmZgd Zd eed eed e eeefeeffddZded eed e eeefeeffddZ dded eedededee d ef ddZGdddZdS)N) import_module)AnyCallableDictListOptionalTuple)AbstractProgresserrors)APIData APIResponseErrorWarningObject)UAConfig)IncorrectFieldTypeError)API_UNKNOWN_ARGWARN_NEW_VERSION_AVAILABLE)check_for_new_version)z,u.pro.attach.auto.configure_retry_service.v1z%u.pro.attach.auto.full_auto_attach.v1z'u.pro.attach.auto.should_auto_attach.v1zu.pro.attach.magic.initiate.v1zu.pro.attach.magic.revoke.v1zu.pro.attach.magic.wait.v1z'u.pro.attach.token.full_token_attach.v1zu.pro.detach.v1zu.pro.packages.summary.v1zu.pro.packages.updates.v1z!u.pro.security.fix.cve.execute.v1zu.pro.security.fix.cve.plan.v1z!u.pro.security.fix.usn.execute.v1zu.pro.security.fix.usn.plan.v1z'u.pro.security.status.livepatch_cves.v1z(u.pro.security.status.reboot_required.v1zu.pro.services.dependencies.v1zu.pro.services.disable.v1zu.pro.services.enable.v1z u.pro.status.enabled_services.v1zu.pro.status.is_attached.v1zu.pro.version.v1zu.security.package_manifest.v1zu.unattended_upgrades.status.v1zu.apt_news.current_news.v1optionsfieldsreturnc Csi}g}|D];}z |d\}}Wn tytj|dw|r#|s)tj|d||vr=|ttj|djtj id|||<q||fS)N=argtitlecodemeta) split ValueErrorr APIBadArgsFormatappendr rformatmsgname)rrkwargswarningsoptionkvr)2/usr/lib/python3/dist-packages/uaclient/api/api.py_process_options)s(     r+datacCsi}g}zt|}Wntjjytj|dw|D]\}}||vr7|tt j |dj t j id|||<q||fS)N)r,rr) jsonloadsdecoderJSONDecodeErrorr APIJSONDataFormatErroritemsr r rr!r"r#)r,rr$r% json_datar'r(r)r)r* _process_dataFs$   r4 endpoint_pathcfgprogress_objectc Cs|tvr ttj|dStd|}|j}g}|jrdd|jjD}z |r/t||\} } n|r9t ||\} } nig} } | | Wntj y\} z t| WYd} ~ Sd} ~ wwz|j | }Wnt y} zttj| j|dWYd} ~ Sd} ~ wwz|jr|j|||d} n|||} WnNty} z t| WYd} ~ Sd} ~ ww|s|rttj|dSz|jr|j||d} n||} Wnty} z t| WYd} ~ Sd} ~ wwt} | r|ttj| djtjidt|j| j|t|j| | jd d S) N)endpointz uaclient.api.cSsg|]}|jqSr))key).0fr)r)r* sszcall_api..)rr8)r7)versionr)type attributesr)_schema_versionr%r,) VALID_ENDPOINTSr error_outAPIInvalidEndpointrr8 options_clsrr+r4extendAPIError from_dictr APIMissingArgr9supports_progressfn ExceptionAPINoArgsForEndpointrr r rr!r"r#r r=r%r r)r5rr,r6r7moduler8option_warningsrr$r%eresult new_versionr)r)r*call_api`s       rRc @s*eZdZ d dedededefddZdS) APIEndpointFr=r#rJrIcCs"||_||_||_||_||_dSN)r=r#rJrDrI)selfr=r#rJrDrIr)r)r*__init__s  zAPIEndpoint.__init__N)F)__name__ __module__ __qualname__strrboolrVr)r)r)r*rSsrSrT) r- importlibrtypingrrrrrr uaclient.apir r uaclient.api.data_typesr r r uaclient.configruaclient.data_typesruaclient.messagesrruaclient.versionrrArZr+r4rRrSr)r)r)r*sN        T