>f JddlZddlmZddlmZmZmZmZmZm Z ddl m Z m Z ddl mZmZmZddlmZddlmZddlmZmZdd lmZgd Zd eed eed e eeefeeffdZded eed e eeefeeffdZ dded eedededee d ef dZGddZy)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.v1optionsfieldsreturnchi}g}|D]} |jd\}}|r|stj|||vrI|j t t j|jt ji|||<||fS#t$rtj|wxYw)N=argtitlecodemeta) split ValueErrorr APIBadArgsFormatappendrrformatmsgname)rrkwargswarningsoptionkvs 2/usr/lib/python3/dist-packages/uaclient/api/api.py_process_optionsr,)sFH 6<<$DAq))f5 5 F? OO")00Q7;;(-- q %( 8 # 6))f5 5 6s B B1dataci}g} tj|}|j D]W\}}||vrI|jttj|jtji|||<Y||fS#tjj$rt j |wxYw)N)r-rr) jsonloadsdecoderJSONDecodeErrorr APIJSONDataFormatErroritemsr"rrr#r$r%)r-rr&r' json_datar)r*s r+ _process_datar6FsFH7JJt$ ! 1 F? OO")00Q7;;(-- q   8  << ' '7++667s B 4B= endpoint_pathcfgprogress_objectc |tvr)tjtj|St d|z}|j }g}|j r|j jDcgc]}|j} } |rt|| \} } n|rt|| \} } nig} } |j|  |j j| } |j r|j#|||} n|j#||} n_|s|r)tjtj&|S |j r|j#||} n|j#|} t)}|rI|j+t-t/j0|j2t.j4it7|j8| j:|zt=|j4| | j>Scc}w#tj$r} tj| cYd} ~ Sd} ~ wwxYw#t$r>} tjtj| j|cYd} ~ Sd} ~ wwxYw#t$$r} tj| cYd} ~ Sd} ~ wwxYw#t$$r} tj| cYd} ~ Sd} ~ wwxYw) N)endpointz uaclient.api.)rr;)r9)versionr)type attributesr)_schema_versionr'r-) VALID_ENDPOINTSr error_outAPIInvalidEndpointrr; options_clsrkeyr,r6extendAPIError from_dictr APIMissingArgsupports_progressfn ExceptionAPINoArgsForEndpointrr"rrr#r$r%r r<r'r r)r7rr-r8r9moduler;option_warningsfrr&r'eresult new_versions r+call_apirS`sO+  % %} =  ?]: ;FHO!)!5!5! #%r  " "8 , **44V '##A& & ' ' ##$$G   '##A& & ' '##A& & 's~2H 9HI3J1J:I#H=7I=I J 3JJ J  J7J2,J72J7: K"KK"K"c (eZdZ ddedededefdZy) APIEndpointr<r%rJrIcJ||_||_||_||_||_yN)r<r%rJrCrI)selfr<r%rJrCrIs r+__init__zAPIEndpoint.__init__s)  &!2N)F)__name__ __module__ __qualname__strrboolrYrZr+rUrUs2#( 3 3 3  3  3rZrUrW) r/ importlibrtypingrrrrrr uaclient.apir r uaclient.api.data_typesr r ruaclient.configruaclient.data_typesruaclient.messagesrruaclient.versionrr@r^r,r6rSrUr`rZr+ris #==1LL$7I2: #Y $S  4S>4 23 34: Cy 4S>4 23 34>37 QQ #YQ Q  Q ./ Q  Qh 3 3rZ