
                         b   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 ddl	m
Z
 dd	lmZ dd
lmZ ddlmZ ej"                   ej$                  ej&                  j(                  ej&                  j*                        ej,                   G d dej.                                             Zy)Create a Workflow.    )absolute_import)division)unicode_literals)client_util)
input_util)workflow_input_util)waiter)base)	run_flags)	resourcesc                   &    e Zd ZdZed        Zd Zy)Creater   c                 V    | j                  ddd       t        j                  |        y)zRegister flags for this command.

    Args:
      parser: An argparse.ArgumentParser-like object. It is mocked out in order
        to capture some information, but behaves like an ArgumentParser.
    z--fileTz8The YAML file to use as the Workflow configuration file.)requiredhelpN)add_argumentr   AddsRegionResourceArg)parsers    %lib/surface/builds/workflows/apply.pyArgszCreate.Args$   s1     G  I ##F+    c                    t        j                         }t        j                         }t        j                  |j
                        }t        j                  |      }|j                  j                  j                         }|j                         }|d   }|d|}	|	|_        |j                  j                  |j                  |	|d            }
t         j"                  j%                  |
j                  d      }t'        j(                  t'        j*                  |j                  |j,                        |dj/                  |j
                  |	            }|S )	z9This is what gets called when the user runs this command.namez/workflows/T)r   workflowallowMissingz(cloudbuild.projects.locations.operations)
collectionz"Applying {file} as workflow {name})filer   )r   GetClientInstanceGetMessagesModuler   LoadYamlFromPathr   r	   CloudBuildYamlDataToWorkflowCONCEPTSregionParseRelativeNamer   projects_locations_workflowsPatch0CloudbuildProjectsLocationsWorkflowsPatchRequestr   REGISTRYParseRelativeNamer
   WaitForCloudOperationPollerprojects_locations_operationsformat)selfargsclientmessages	yaml_datar   
region_refparentworkflow_idr   update_operationupdate_operation_refupdated_workflows                r   Runz
Create.Run2   s6   **,F,,.H++DII6I"??	JH%%++-J$$&FF#K &4D HM::@@AAt 	B 	=> %--??= @ ? ~~##F$G$G$*$H$H	J,333N	P r   N)__name__
__module____qualname____doc__staticmethodr   r;    r   r   r   r      s     , ,r   r   N)r?   
__future__r   r   r   $googlecloudsdk.api_lib.cloudbuild.v2r   r   r	   googlecloudsdk.api_lib.utilr
   googlecloudsdk.callioper   %googlecloudsdk.command_lib.cloudbuildr   googlecloudsdk.corer   HiddenReleaseTracksReleaseTrackALPHABETAUniverseCompatibleCreateCommandr   rA   r   r   <module>rO      s     &  ' < ; D . ( ; ) D%%++T->->-C-CD.T .  E .r   