
                         f    S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSK	J
r
   " S S	\5      rg
)z7Common stateful utilities for the gcloud dataproc tool.    )absolute_import)division)unicode_literals)apis)base)	resourcesc                      ^  \ rS rSrSr\R                  R                  4U 4S jjr\	S 5       r
\	S 5       r\	S 5       r\	S 5       r SS jrSS	 jrS
rU =r$ )Dataproc   zStateful utility for calling Dataproc APIs.

While this currently could all be static. It is encapsulated in a class to
support API version switching in future.
c                 `   > [         [        U ]  5         Xl        SU l        S U l        S U l        g )Nv1)superr
   __init__release_trackapi_version_client
_resources)selfr   	__class__s     /lib/googlecloudsdk/api_lib/dataproc/dataproc.pyr   Dataproc.__init__"   s,    	(D"$&DDLDO    c                     U R                   c&  [        R                  " SU R                  5      U l         U R                   $ Ndataproc)r   r   GetClientInstancer   r   s    r   clientDataproc.client)   s0    ||++J8H8HIdl<<r   c                 D    [         R                  " SU R                  5      $ r   )r   GetMessagesModuler   r   s    r   messagesDataproc.messages/   s    !!*d.>.>??r   c                     U R                   cI  [        R                  R                  5       U l         U R                   R	                  SU R
                  5        U R                   $ r   )r   r   REGISTRYCloneRegisterApiByNamer   r   s    r   r   Dataproc.resources3   sF    !**002do
oo''
D4D4DE??r   c                     U R                   R                  R                  R                  U R                   R                  R                  R                  U R                   R                  R                  R
                  /$ N)r"   	JobStatusStateValueValuesEnum	CANCELLEDDONEERRORr   s    r   terminal_job_statesDataproc.terminal_job_states:   sY     	44>>449944:: r   c                     Uc  U R                   R                  UUUUS9$ U R                  S:X  a  [        S5      eU R                   R                  UUUUUS9$ )a!  Gets the CreateClusterRequest for the appropriate api version.

Args :
  cluster : Dataproc cluster to be created.
  project_id: The ID of the Google Cloud Platform project that the cluster
  belongs to.
  region : The Dataproc region in which to handle the request.
  request_id : A unique ID used to identify the request.
  action_on_failed_primary_workers : Supported only for v1 api.

Raises :
  ValueError : if non-None action_on_failed_primary_workers is passed for
  v1beta2 api.

Returns :
  DataprocProjectsRegionsClustersCreateRequest
)cluster	projectIdregion	requestIdv1beta2zAaction_on_failed_primary_workers is not supported for v1beta2 api)r3   r4   r5   r6   actionOnFailedPrimaryWorkers)r"   ,DataprocProjectsRegionsClustersCreateRequestr   
ValueError)r   r3   
project_idr5   
request_id action_on_failed_primary_workerss         r   GetCreateClusterRequest Dataproc.GetCreateClusterRequestB   s    . (/]]GG	 H     9$
MO O ==EE%E F G Gr   c                     U R                   nUR                  UR                  5       S9nU(       a  [        U5      Ul        U R
                  R                  R                  U5      $ )aD  Gets workflow template from dataproc.

Args:
  template: workflow template resource that contains template name and id.
  version: version of the workflow template to get.

Returns:
  WorkflowTemplate object that contains the workflow template info.

Raises:
  ValueError: if version cannot be converted to a valid integer.
)name)r"   2DataprocProjectsRegionsWorkflowTemplatesGetRequestRelativeNameintversionr   "projects_regions_workflowTemplatesGet)r   templaterE   r"   get_requests        r   GetRegionsWorkflowTemplate#Dataproc.GetRegionsWorkflowTemplatek   sY     }}HMM""$ N &KLk;;99==kJJr   )r   r   r   r   r*   )__name__
__module____qualname____firstlineno____doc__r   ReleaseTrackGAr   propertyr   r"   r   r0   r>   rJ   __static_attributes____classcell__)r   s   @r   r
   r
      s     $(#4#4#7#7   
 @ @     @D'GRK Kr   r
   N)rP   
__future__r   r   r   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper   googlecloudsdk.corer   objectr
    r   r   <module>r\      s,     > &  ' , ( )bKv bKr   