
                            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  ej                   ej"                  j$                        ej&                   G d dej(                                      Z ej                   ej"                  j,                         G d de             Z ej                   ej"                  j0                         G d de             Zd Zd Zy)zDescribe worker pool command.    )absolute_import)division)unicode_literals)cloudbuild_util)client_util)base)
exceptions)
properties)	resourcesc                   0    e Zd ZdZdddZed        Zd Zy)Describe+Describe a worker pool used by Cloud Build.z{description}z          To get information about a worker pool named `wp1` in region `us-central1`, run:

            $ {command} wp1 --region=us-central1
          )DESCRIPTIONEXAMPLESc                 P    | j                  dd       | j                  dd       y)Register 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.
    --region*The Cloud region where the worker pool is.helpWORKER_POOL&The ID of the worker pool to describe.N)add_argumentparsers    +lib/surface/builds/worker_pools/describe.pyArgszDescribe.Args-   s9     9  ; D  F    c                 6    t        || j                               S )This is what gets called when the user runs this command.

    Args:
      args: an argparse namespace. All the arguments that were provided to this
        command invocation.

    Returns:
      Some value that we want to have printed later.
    )_DescribeWorkerPoolFirstGenReleaseTrackselfargss     r   RunzDescribe.Run;   s     'tT->->-@AAr   N)__name__
__module____qualname____doc__detailed_helpstaticmethodr   r&    r   r   r   r      s4     4 		- F FBr   r   c                   &    e Zd ZdZed        Zd Zy)DescribeBetar   c                     | j                  dd       | j                  ddt        d       | j                  dd	       y
r   r   r   r   --generation   zGeneration of the worker pool.)defaulttyper   r   r   Nr   intr   s    r   r   zDescribeBeta.ArgsM   Z     9  ; .	  1
 D  Fr   c                     |j                   dk(  rt        || j                               S |j                   dk(  rt        |      S t	        j
                  dd      r    r3      r2   z=please use one of the following valid generation values: 1, 2
generationr!   r"   _DescribeWorkerPoolSecondGenr	   InvalidArgumentExceptionr#   s     r   r&   zDescribeBeta.Run`   V     !(t/@/@/BCC!)$//

-
-G r   Nr'   r(   r)   r*   r,   r   r&   r-   r   r   r/   r/   I       3F F$r   r/   c                   &    e Zd ZdZed        Zd Zy)DescribeAlphar   c                     | j                  dd       | j                  ddt        d       | j                  dd	       y
r1   r6   r   s    r   r   zDescribeAlpha.Argsz   r8   r   c                     |j                   dk(  rt        || j                               S |j                   dk(  rt        |      S t	        j
                  dd      r:   r<   r#   s     r   r&   zDescribeAlpha.Run   r@   r   NrA   r-   r   r   rD   rD   v   rB   r   rD   c           	         t        j                         }|j                  }| j                  }|s2t        j
                  j                  j                  j                         }t        j                  j                  ddt         j                  t        j
                  j                  j                  j                  d      || j                  d      }|j                   j                  |j#                  |j%                                     }	 t        j&                  |j(                        |_        |S # t*        $ r Y |S w xY w)zDescribes a Worker Pool Second Generation.

  Args:
    args: an argparse namespace. All the arguments that were provided to the
        create command invocation.

  Returns:
    A Worker Pool Second Generation resource.
  Nz1cloudbuild.projects.locations.workerPoolSecondGenTrequired)
projectsIdlocationsIdworkerPoolSecondGenId
collectionapi_versionparamsname)cloudbuild_v2_utilGetClientInstanceMESSAGES_MODULEregionr
   VALUESbuilds	GetOrFailr   REGISTRYParseGA_API_VERSIONcoreprojectGetr   &projects_locations_workerPoolSecondGen8CloudbuildProjectsLocationsWorkerPoolSecondGenGetRequestRelativeNameWorkerPoolSecondGenShortNamerR   
ValueError)r%   clientmessages	wp_regionwp_resourcewps         r   r>   r>      s    //1&##(kk)	!!((//99;I ""((
D$33"))..66::D:I"#'#3#3	 ) 	+ 4488GG'') H +,"
	 ==bggFBG 
) 
 		)	s   $D2 2	D?>D?c           	         | j                   }|s2t        j                  j                  j                   j	                         }t        j                  |      }t        j                  |      }t        j                  j                  j                  j                  d      }| j                  }t        j                  j                  ddt
        j                  |   |||d      }|j                   j                  |j#                  |j%                                     }	 t        j&                  |j(                        |_        |S # t*        $ r Y |S w xY w)a@  Describes a Worker Pool First Generation.

  Args:
    args: an argparse namespace. All the arguments that were provided to the
        create command invocation.
    release_track: The desired value of the enum
      googlecloudsdk.calliope.base.ReleaseTrack.

  Returns:
    A Worker Pool First Generation resource.
  TrH   Nz)cloudbuild.projects.locations.workerPools)rJ   rK   workerPoolsIdrM   rQ   )rV   r
   rW   rX   rY   r   rT   GetMessagesModuler]   r^   r_   r   r   rZ   r[   RELEASE_TRACK_TO_API_VERSIONprojects_locations_workerPools0CloudbuildProjectsLocationsWorkerPoolsGetRequestrb   WorkerPoolShortNamerR   rd   )	r%   release_trackrg   re   rf   parentwp_namerh   ri   s	            r   r!   r!      s2    kk)	!!((//99;I,,];&..}=(!!))--t-<&' ""((
<!>>}M""	 ) 	+ ,,00??'') @ +,"
	11"'':BG 
) 
 		)	s   $E 	EEN)r*   
__future__r   r   r   !googlecloudsdk.api_lib.cloudbuildr   $googlecloudsdk.api_lib.cloudbuild.v2r   rS   googlecloudsdk.callioper   r	   googlecloudsdk.corer
   r   ReleaseTracksr"   GAUniverseCompatibleDescribeCommandr   BETAr/   ALPHArD   r>   r!   r-   r   r   <module>r      s    $ &  ' = R ( . * ) D%%(()'Bt## 'B  *'BT D%%**+)8 ) ,)X D%%++,)H ) -)X'T-r   