
Ke                 @   s   d  d l  m Z d  d l m Z m Z d  d l m Z d  d l m Z d  d l	 m
 Z
 e e d d d    Z Gd	 d
   d
 e  Z Gd d   d e  Z Gd d   d e  Z Gd d   d e  Z Gd d   d e  Z Gd d   d e  Z d S)    )messages)APIResponseErrorWarningObject)UbuntuProError)get_pro_environment)check_for_new_version)	exceptionreturnc             C   s  t  |  t t f  rR t d |  j d |  j p: d |  j j d |  j pI i   } n+ t d t	 |   d d |  j j d i   } g  } t
   } | r | j t d t j j d |  j d t j j d i    t d d d d	 d
 d d d d   t t   j    D i i d | g d |  S)Ntitlecodezgeneric-metaversionZ_schema_versionZv1resultZfailuredataZenvironment_varsc             S   s(   g  |  ] \ } } d  | d | i  q S)namevalue ).0r   r   r   r   5/usr/lib/python3/dist-packages/uaclient/api/errors.py
<listcomp>*   s   	zerror_out.<locals>.<listcomp>errorswarnings)
isinstancer   APIErrorr   msgZmsg_code	__class____name__Zadditional_infostrr   appendr   ZWARN_NEW_VERSION_AVAILABLEformatr   r   sortedr   items)r   errorr   Znew_versionr   r   r   	error_out   s8    				
		r#   c               @   s   e  Z d  Z d S)r   N)r   
__module____qualname__r   r   r   r   r   4   s   r   c               @   s   e  Z d  Z e j Z d S)APIInvalidEndpointN)r   r$   r%   r   ZE_API_INVALID_ENDPOINT_formatted_msgr   r   r   r   r&   8   s   r&   c               @   s   e  Z d  Z e j Z d S)APIMissingArgN)r   r$   r%   r   ZE_API_MISSING_ARGr'   r   r   r   r   r(   <   s   r(   c               @   s   e  Z d  Z e j Z d S)APINoArgsForEndpointN)r   r$   r%   r   ZE_API_NO_ARG_FOR_ENDPOINTr'   r   r   r   r   r)   @   s   r)   c               @   s   e  Z d  Z e j Z d S)APIJSONDataFormatErrorN)r   r$   r%   r   ZE_API_JSON_DATA_FORMAT_ERRORr'   r   r   r   r   r*   D   s   r*   c               @   s   e  Z d  Z e j Z d S)APIBadArgsFormatN)r   r$   r%   r   ZE_API_BAD_ARGS_FORMATr'   r   r   r   r   r+   H   s   r+   N)Zuaclientr   Zuaclient.api.data_typesr   r   Zuaclient.exceptionsr   Zuaclient.utilr   Zuaclient.versionr   	Exceptionr#   r   r&   r(   r)   r*   r+   r   r   r   r   <module>   s   ,