
                            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 ddlmZ  ej&                  ej(                  j*                        ej,                   G d dej.                                      Z ej&                  ej(                  j2                         G d de             Z ej&                  ej(                  j6                         G d de             Zd Zd Zy)zDelete worker pool command.    )absolute_import)division)unicode_literals)cloudbuild_util)client_util)waiter)base)
exceptions)log)
properties)	resourcesc                   0    e Zd ZdZdddZed        Zd Zy)Deletez&Delete a worker pool from Cloud Build.z{description}z          To delete 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 delete.N)add_argumentparsers    )lib/surface/builds/worker_pools/delete.pyArgszDelete.Args/   s9     9  ; B  D    c                 8    t        || j                                y)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.
    N)_DeleteWorkerPoolFirstGenReleaseTrackselfargss     r   Runz
Delete.Run=   s     dD$5$5$78r   N)__name__
__module____qualname____doc__detailed_helpstaticmethodr   r'    r   r   r   r      s3     / 		- D D9r   r   c                   &    e Zd ZdZed        Zd Zy)
DeleteBetaz-Delete a worker pool from Google Cloud Build.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DeleteBeta.ArgsO   Z     9  ; .	  1
 B  Dr   c                     |j                   dk(  rt        || j                                y|j                   dk(  rt        |       yt	        j
                  dd      r!   r4      r3   z=please use one of the following valid generation values: 1, 2N
generationr"   r#   _DeleteWorkerPoolSecondGenr
   InvalidArgumentExceptionr$   s     r   r'   zDeleteBeta.Runb   P     !d&7&7&9:	A	 &//

I r   Nr(   r)   r*   r+   r-   r   r'   r.   r   r   r0   r0   K   s    5D D$r   r0   c                   &    e Zd ZdZed        Zd Zy)DeleteAlphaz5Delete a private worker pool from Google Cloud Build.c                     | j                  dd       | j                  ddt        d       | j                  dd	       y
r2   r7   r   s    r   r   zDeleteAlpha.Args|   r9   r   c                     |j                   dk(  rt        || j                                y|j                   dk(  rt        |       yt	        j
                  dd      r;   r=   r$   s     r   r'   zDeleteAlpha.Run   rA   r   NrB   r.   r   r   rD   rD   x   s    =D D$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)                  |j*                  d	      }t-        j.                  t-        j0                  |j2                        |d
d       t5        j6                  |       y)zDeletes a Worker Pool Second Generation.

  Args:
    args: an argparse namespace. All the arguments that were provided to the
        delete command invocation.
  Nz1cloudbuild.projects.locations.workerPoolSecondGenTrequired)
projectsIdlocationsIdworkerPoolSecondGenId
collectionapi_versionparamsname(cloudbuild.projects.locations.operationsrN   zDeleting worker pool second gen6 max_wait_ms)cloudbuild_v2_utilGetClientInstanceMESSAGES_MODULEregionr   VALUESbuilds	GetOrFailr   REGISTRYParseGA_API_VERSIONcoreprojectGetr   &projects_locations_workerPoolSecondGenr   ;CloudbuildProjectsLocationsWorkerPoolSecondGenDeleteRequestRelativeNameParseRelativeNamerR   r   WaitForCloudOperationPollerNoResourcesprojects_locations_operationsr   DeletedResource)r&   clientmessages	wp_regionwp_resource
deleted_opop_resources          r   r?   r?      sE    //1&##(kk)	!!((//99;I ""((
D$33"))..66::D:I"#'#3#3	 ) 	+ <<CCJJ'') K +,* ""44oo"L 5 N+..,,

.
.01<'	 k"r   c           	         | j                   }|s2t        j                  j                  j                   j	                         }t        j                  |      }|j                  }t        j                  j                  j                  j                  d      }| j                  }t        j                  j                  ddt
        j                  |   |||d      }|j                   j#                  |j%                  |j'                                     }t        j                  j)                  |j*                  d	      }	t-        j.                  t-        j0                  |j2                        |	d
d       t5        j6                  |       y)a  Deletes a Worker Pool First Generation.

  Args:
    args: an argparse namespace. All the arguments that were provided to the
        delete command invocation.
    release_track: The desired value of the enum
      googlecloudsdk.calliope.base.ReleaseTrack.
  TrH   Nz)cloudbuild.projects.locations.workerPools)rJ   rK   workerPoolsIdrM   rQ   rS   rT   zDeleting worker poolrU   rV   )r[   r   r\   r]   r^   r   rY   rZ   rb   rc   rd   r   r   r_   r`   RELEASE_TRACK_TO_API_VERSIONprojects_locations_workerPoolsr   3CloudbuildProjectsLocationsWorkerPoolsDeleteRequestrg   rh   rR   r   ri   rj   rk   r   rl   )
r&   release_trackro   rm   rn   parentwp_namerp   rq   rr   s
             r   r"   r"      sV    kk)	!!((//99;I,,];&##(!!))--t-<&' ""((
<!>>}M""	 ) 	+ 44;;BB'') C +,* ""44oo"L 5 N+..,,

.
.01<	 k"r   N)r+   
__future__r   r   r   !googlecloudsdk.api_lib.cloudbuildr   $googlecloudsdk.api_lib.cloudbuild.v2r   rX   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper	   r
   googlecloudsdk.corer   r   r   ReleaseTracksr#   GAUniverseCompatibleDeleteCommandr   BETAr0   ALPHArD   r?   r"   r.   r   r   <module>r      s    " &  ' = R . ( . # * ) D%%(()'9T '9  *'9T D%%**+) ) ,)X D%%++,)& ) -)X&#R,#r   