o
    q)                     @   s  d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z G dd	 d	eZG d
d deZejdejdejdejdejdejdejdejdejdejdejdejdejdejdiZG dd deZG dd deZG dd deZ G dd deZ!G dd deZ"G dd  d eZ#G d!d" d"eZ$G d#d$ d$eZ%G d%d& d&eZ&G d'd( d(eZ'G d)d* d*eZ(G d+d, d,eZ)dS )-z0Data objects to support the yaml command schema.    )absolute_import)division)unicode_literals)Enum)base)yaml_command_schema_utilc                   @      e Zd ZdZdd ZdS )CommandDataz0A general holder object for yaml command schema.c           
      C   s  ddl m} |dd| _|dd| _|dd | _dd |d	g D | _t|d
|| _	|d | _
d | _d | _d }t| j	rY|d}t| j	|| _t|di | _|d}|d}|d}|d}|d}	| j	tjkr|std|rt|nd | _|rt|nd | _||d || _t| j	|di | _t|di | _|rt|nd | _|rt|nd | _ |	rt!|	||nd | _"|d| _#d S )Nr   )yaml_arg_schemahiddenFauto_generateduniverse_compatiblec                 S      g | ]}t j|qS  )r   ReleaseTrackFromId).0ir   r   U/tmp/google-cloud-sdk/lib/googlecloudsdk/command_lib/util/apis/yaml_command_schema.py
<listcomp>&       z(CommandData.__init__.<locals>.<listcomp>release_trackscommand_type	help_textrequestresponseasynciamupdategenericimportz,Wait commands must include an async section.	argumentsinputoutput	deprecate)$$googlecloudsdk.command_lib.util.apisr
   getr   r   r   r   CommandTypeForNamer   r   r   r   HasRequestMethodRequestResponseWAITutilInvalidSchemaErrorAsyncasync_IamDatar   	Argumentsr!   Inputr"   Outputr#   
UpdateDatar   GenericDatar   
ImportDataimport_deprecated_data)
selfnamedatar
   request_data
async_dataiam_dataupdate_datageneric_dataimport_datar   r   r   __init__   sN   







zCommandData.__init__N__name__
__module____qualname____doc__rC   r   r   r   r   r	          r	   c                   @   sl   e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZdZdZdZdZedd Zedd Zedd ZdS )r'   z9An enum for the types of commands the generator supports.                        	   
               c                 C   s
   t | S )z=Returns the default API method name for this type of command.) _DEFAULT_METHODS_BY_COMMAND_TYPEr&   )r:   r   r   r   default_methodW   s   
zCommandType.default_methodc                 C   s(   zt |  W S  ty   t j Y S w N)r'   upperKeyErrorGENERIC)clsr;   r   r   r   r(   \   s
   
zCommandType.ForNamec                 C   s   | j h}||vS rZ   )CONFIG_EXPORT)r^   r;   methodless_commandsr   r   r   r)   c   s   zCommandType.HasRequestMethodN)rE   rF   rG   rH   DESCRIBELISTDELETEIMPORTEXPORTr_   CREATEr,   UPDATEGET_IAM_POLICYSET_IAM_POLICYADD_IAM_POLICY_BINDINGREMOVE_IAM_POLICY_BINDINGr]   propertyrY   classmethodr(   r)   r   r   r   r   r'   F   s,    

r'   r&   listdeletepatchconfig_exportcreategetIamPolicysetIamPolicyNc                   @   r   )r*   zFA holder object for api request information specified in yaml command.c                 C   s   | d}t|tr|| _n|g| _| d| _| d| _| d| _| d|j| _| js4t	
d| dd| _| d	i | _d
d | dg D | _t	j|d| _t	j|d| _t	j|d| _d S )N
collectiondisable_resource_checkdisplay_resource_typeapi_versionmethodzOrequest.method was not specified and there is no default for this command type.disable_paginationFstatic_fieldsc                 S   r   r   r-   HookFromPathr   pr   r   r   r      r   z$Request.__init__.<locals>.<listcomp>modify_request_hookscreate_request_hookmodify_method_hookissue_request_hook)r&   
isinstancern   collectionsrv   rw   rx   rY   ry   r-   r.   rz   r{   r   r}   FromDatar   r   r   )r:   r   r<   ru   r   r   r   rC      s(   


zRequest.__init__NrD   r   r   r   r   r*      rI   r*   c                   @   r   )r+   zGA holder object for api response information specified in yaml command.c                 C   sN   | d| _| d| _d|v rt|d nd | _dd | dg D | _d S )Nid_fieldresult_attributeerrorc                 S   r   r   r|   r   r   r   r   r      r   z%Response.__init__.<locals>.<listcomp>modify_response_hooks)r&   r   r   ResponseErrorr   r   r:   r<   r   r   r   rC      s   
zResponse.__init__NrD   r   r   r   r   r+      rI   r+   c                   @      e Zd Zdd ZdS )r   c                 C   s*   | dd| _| d| _| d| _d S )Nfieldr   codemessage)r&   r   r   r   r   r   r   r   rC      s   zResponseError.__init__NrE   rF   rG   rC   r   r   r   r   r          r   c                   @   r   )r/   zDA holder object for api async information specified in yaml command.c                 C   s   | d}t|tr|| _n|g| _| d| _| dd| _| d| _| dd| _| dd	| _| d
i | _	| d| _
t| di | _t| di | _dd | dg D | _d S )Nru   rx   ry   r&   request_issued_messageresponse_name_fieldr;   extract_resource_resultToperation_get_method_paramsr   stater   c                 S   r   r   r|   r   r   r   r   r      r   z"Async.__init__.<locals>.<listcomp>r   )r&   r   rn   r   rx   ry   r   r   r   r   r   AsyncStateFieldr   AsyncErrorFieldr   r   )r:   r<   ru   r   r   r   rC      s$   


zAsync.__init__NrD   r   r   r   r   r/      rI   r/   c                   @   r   )r1   zFA holder object for IAM related information specified in yaml command.c                 C   sV   | di | _| d| _| dd| _| dd| _| dd | _| dd| _d S )	Nmessage_type_overridesset_iam_policy_request_pathenable_conditionFhide_special_member_typespolicy_versionget_iam_policy_version_pathzoptions.requestedPolicyVersion)r&   r   r   r   r   r   r   r   r   r   r   rC      s   
zIamData.__init__NrD   r   r   r   r   r1      rI   r1   c                   @   r   )r   c                 C   s0   | dd| _| ddg| _| dg | _d S )Nr   donesuccess_valuesTerror_values)r&   r   r   r   r   r   r   r   rC      s   zAsyncStateField.__init__Nr   r   r   r   r   r      r   r   c                   @   r   )r   c                 C      | dd| _d S )Nr   r   )r&   r   r   r   r   r   rC         zAsyncErrorField.__init__Nr   r   r   r   r   r      r   r   c                   @   r   )r3   c                 C   sH   | d| _| dd| _| js |tju r"dtjtj| _d S d S d S )Nconfirmation_promptdefault_continueTz'You are about to delete {{{}}} [{{{}}}])	r&   r   r   r'   rc   formatr-   RESOURCE_TYPE_FORMAT_KEYNAME_FORMAT_KEY)r:   r   r<   r   r   r   rC      s   zInput.__init__Nr   r   r   r   r   r3      r   r3   c                   @   r   )r4   c                 C   s   | d| _| d| _d S )Nr   flatten)r&   r   r   r   r   r   r   rC      s   zOutput.__init__Nr   r   r   r   r   r4      r   r4   c                   @   r   )r5   z(A holder object for yaml update command.c                 C   s.   | dd | _| dd| _| dd| _d S )N
mask_fieldread_modify_updateFdisable_auto_field_mask)r&   r   r   r   r   r   r   r   rC      s   zUpdateData.__init__NrD   r   r   r   r   r5      rI   r5   c                   @   r   )r6   z%A holder object for generic commands.c                 C   r   )Ndisable_paging_flagsF)r&   r   r   r   r   r   rC      r   zGenericData.__init__NrD   r   r   r   r   r6      rI   r6   c                   @   s    e Zd ZdZdd Zdd ZdS )r7   z(A holder object for yaml import command.c                 C   s   | dd| _| dd| _| dd| _| dd }|r+| ||}ttj|| _nd | _| dd }|rC| ||}t	|| _
d S d | _
d S )Nabort_if_equivalentFcreate_if_not_existsno_create_asynccreate_requestcreate_async)r&   r   r   r   _OverlayDatar*   r'   rf   r   r/   r   )r:   r<   orig_request
orig_asyncr   overlayed_create_requestr   overlayed_create_asyncr   r   r   rC     s   
zImportData.__init__c                 C   s(   |  D ]\}}||p|||< q|S )zDUses data from the original configuration unless explicitly defined.)itemsr&   )r:   create_data	orig_datakvr   r   r   r     s   zImportData._OverlayDataN)rE   rF   rG   rH   rC   r   r   r   r   r   r7     s    r7   )*rH   
__future__r   r   r   enumr   googlecloudsdk.callioper   r%   r   r-   objectr	   r'   ra   rb   rc   rd   re   r_   rf   r,   rg   rh   ri   rj   rk   r]   rX   r*   r+   r   r/   r1   r   r   r3   r4   r5   r6   r7   r   r   r   r   <module>   sH   *$	