
    Q                     P   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&                  ej(                  j*                         G d dej,                                      Zdddde_         ej&                  ej(                  j2                         G d de             Zej0                  e_         ej&                  ej(                  j6                         G d de             Zej0                  e_        y)zomanaged-instance-groups list-instances command.

It's an alias for the instance-groups list-instances command.
    )absolute_import)division)unicode_literals)base_classes)instance_groups_utils)request_helper)utils)base)flags)scopec                   &    e Zd ZdZed        Zd Zy)ListInstances@List Compute Engine instances present in managed instance group.c                     t        j                  |        | j                  j                  t        j
                         t         j                  j                  |        y )N)instance_groups_flagsAddListInstancesOutputFormatdisplay_info
AddUriFuncr   $UriFuncForListInstanceRelatedObjects%MULTISCOPE_INSTANCE_GROUP_MANAGER_ARGAddArgumentparsers    =lib/surface/compute/instance_groups/managed/list_instances.pyArgszListInstances.Args'   sE    66v>
""BBD??KK    c                 X   t        j                  | j                               }|j                  }t        j
                  j                  ||j                  t        j                  j                  t        j                  |            }t        |d      rW|j                  j                  }|j                   j#                  |j%                         |j&                  |j(                        }nbt        |d      rV|j                  j*                  }|j                   j-                  |j%                         |j.                  |j(                        }g }t1        t3        j4                  dfg|j                  j6                  |j8                  |            }|rt;        j<                  |       |S )z7Retrieves response with instance in the instance group.)default_scopescope_listerzone)instanceGroupManagerr    projectregion)r!   r#   r"   ListManagedInstances)requestshttp	batch_urlerrors)r   ComputeApiHolderReleaseTrackclientr   r   ResolveAsResource	resourcescompute_scope	ScopeEnumZONEr   GetDefaultScopeListerhasattrapitools_clientinstanceGroupManagersmessages7ComputeInstanceGroupManagersListManagedInstancesRequestNamer    r"   regionInstanceGroupManagers=ComputeRegionInstanceGroupManagersListManagedInstancesRequestr#   listr   MakeRequestsr&   r'   r	   RaiseToolException)	selfargsholderr+   	group_refservicerequestr(   resultss	            r   RunzListInstances.Run/   su   **4+<+<+>?F]]F&LL""%%#0#:#:#?#?"'"="=f"E	 # G  y&!&&<<gHH*3..*:#..&.. I 0 
 
H	%&&BBgNN*3..*:%,,&.. O 0  F>..2G<=##((""	 G v&Nr   N)__name__
__module____qualname____doc__staticmethodr   rD    r   r   r   r   "   s     I $r   r   z4List instances present in the managed instance groupa[            *{command}* lists instances in a managed instance group.

          The required permission to execute this command is
          `compute.instanceGroupManagers.list`. If needed, you can include this
          permission, or choose any of the following preexisting IAM roles
          that contain this particular permission:

          *   Compute Admin
          *   Compute Viewer
          *   Compute Instance Admin (v1)
          *   Compute Instance Admin (beta)
          *   Compute Network Admin
          *   Editor
          *   Owner
          *   Security Reviewer
          *   Viewer

          For more information regarding permissions required by managed
          instance groups, refer to Compute Engine's access control guide :
          https://cloud.google.com/compute/docs/access/iam#managed-instance-groups-and-iam.
        z        To see additional details about the instances in a managed instance
        group `my-group`, including per-instance overrides, run:

            $ {command} \
                  my-group --format=yaml
        )briefDESCRIPTIONEXAMPLESc                        e Zd ZdZed        Zy)ListInstancesBetar   c                     t        j                  | t        j                  j                         | j
                  j                  t        j                         t         j                  j                  |        y N)release_track)r   r   r
   r*   BETAr   r   r   r   r   r   r   s    r   r   zListInstancesBeta.Args   sV    66d//446
""BBD??KKr   N)rE   rF   rG   rH   rI   r   rJ   r   r   rO   rO   {   s    H r   rO   c                   2     e Zd ZdZ fdZed        Z xZS )ListInstancesAlphar   c                     t         |   |      }|j                  sD|j                  d      s3t	        j
                  |t        j                  j                        |_	        |S )Nformat)
superrD   uriIsSpecifiedr   'GetListInstancesOutputWithDynamicFieldsr
   r*   ALPHArW   )r=   r>   managed_instances	__class__s      r   rD   zListInstancesAlpha.Run   sV    D) 88D,,X6

G
G!2!2!8!8 k
 r   c                     t        j                  | t        j                  j                         | j
                  j                  t        j                         t         j                  j                  |        y rQ   )r   r   r
   r*   r\   r   r   r   r   r   r   r   s    r   r   zListInstancesAlpha.Args   sV    66d//557
""BBD??KKr   )rE   rF   rG   rH   rD   rI   r   __classcell__)r^   s   @r   rU   rU      s    H
  r   rU   N)rH   
__future__r   r   r   googlecloudsdk.api_lib.computer   r   r   r	   googlecloudsdk.callioper
   "googlecloudsdk.command_lib.computer   r   r.   2googlecloudsdk.command_lib.compute.instance_groupsr   UniverseCompatibleReleaseTracksr*   GAListCommandr   detailed_helprS   rO   r\   rU   rJ   r   r   <module>rk      s  
 '  ' 7 @ 9 0 ( 4 E ] D%%(()/D$$ / * /h 	?	.	7" J D%%**+
 
 ,
 #0"="=   D%%++,  -2 $5#B#B   r   