
    "                         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  G d	 d
e      Z G d de      Z G d de      Zy)zNCommands for interacting with the Cloud NetApp Files Host Groups API resource.    )
list_pager)	constants)util)waiter)base)log)	resourcesc                       e Zd ZdZej
                  j                  fdZed        Z	ed        Z
d Zd Z	 	 	 	 	 	 ddZd	 Zd
 Zd Z	 	 	 ddZd Zy)HostGroupsClientzJWrapper for working with Host Groups in the Cloud NetApp Files API Client.c                 B   || _         | j                   t        j                  j                  k(  rt	               | _        y | j                   t        j                  j                  k(  rt               | _        y t        dj                  t        j                  |               )Nz [{}] is not a valid API version.)release_trackr   ReleaseTrackALPHAAlphaHostGroupsAdapter_adapterBETABetaHostGroupsAdapter
ValueErrorformatnetapp_api_utilVERSION_MAP)selfr   s     7lib/googlecloudsdk/api_lib/netapp/host_groups/client.py__init__zHostGroupsClient.__init__   s{    &DT..444,.dm			t0055	5+-dm
,
3
3))-8     c                 .    | j                   j                  S N)r   clientr   s    r   r   zHostGroupsClient.client+   s    ==r   c                 .    | j                   j                  S r   )r   messagesr   s    r   r!   zHostGroupsClient.messages/   s    ==!!!r   c                     t        j                  t        j                  | j                  j                        |dj                  |j                                     S )a  Waits on the long-running operation until the done field is True.

    Args:
      operation_ref: the operation reference.

    Raises:
      waiter.OperationError: if the operation contains an error.

    Returns:
      the 'response' field of the Operation.
    zWaiting for [{0}] to finish)r   WaitForCloudOperationPollerNoResourcesr   projects_locations_operationsr   Name)r   operation_refs     r   WaitForOperationz!HostGroupsClient.WaitForOperation3   sL     >>..KK55	
 	%,,]-?-?-AB r   c                 x   | j                   j                  |j                         j                         |j	                         |      }| j
                  j                  j                  |      }|r|S t        j                  j                  |j                  t        j                        }| j                  |      S )z!Create a Cloud NetApp Host Group.)parenthostGroupId	hostGroup
collection)r!   .NetappProjectsLocationsHostGroupsCreateRequestParentRelativeNamer&   r   projects_locations_hostGroupsCreater	   REGISTRYParseRelativeNamenamer   OPERATIONS_COLLECTIONr(   )r   host_group_refasync_configrequest	create_opr'   s          r   CreateHostGroupz HostGroupsClient.CreateHostGroupG   s    mmJJ$$&335"'') K G
 99@@II&&889#B#B 9 M   //r   Nc                     | j                   j                         }||_        ||_        ||_        ||_        ||_        ||_        |S )zFParses the command line arguments for Create Host Group into a config.)r!   	HostGroupr6   typehostsosTypedescriptionlabels)r   r6   host_group_typerA   os_typerC   rD   
host_groups           r   ParseHostGroupConfigz%HostGroupsClient.ParseHostGroupConfigV   sJ     ((*JJO%JOJJ(JJr   c                 d   | j                   j                  |      }| j                  j                  j	                  |      }|j
                  D ]&  }t        j                  dj                  |             ( t        j                  | j                  j                  |t        j                  d      S )zList Cloud NetApp Host Groups.

    Args:
      location_ref: The parent location to list Cloud Netapp Host Groups.

    Returns:
      Generator that yields the Cloud Netapp Host Groups.
    )r*   zLocation {} may be unreachable.pageSize)fieldbatch_size_attribute)r!   ,NetappProjectsLocationsHostGroupsListRequestr   r2   Listunreachabler   warningr   r   YieldFromListr   HOST_GROUP_RESOURCE)r   location_refr;   responselocations        r   ListHostGroupszHostGroupsClient.ListHostGroupsi   s     mmHH I G {{88==gFH((	kk3::8DE )##11++'	 r   c                     | j                   j                  |j                               }| j                  j                  j                  |      S )zGet a Cloud NetApp Host Group.r6   )r!   +NetappProjectsLocationsHostGroupsGetRequestr1   r   r2   Get)r   r8   r;   s      r   GetHostGroupzHostGroupsClient.GetHostGroup   sE    mmGG((* H G ;;4488AAr   c                 <   | j                   j                  |j                               }| j                  j                  j                  |      }|r|S t        j                  j                  |j                  t        j                        }| j                  |      S )z!Delete a Cloud NetApp Host Group.rX   r-   )r!   .NetappProjectsLocationsHostGroupsDeleteRequestr1   r   r2   Deleter	   r4   r5   r6   r   r7   r(   )r   r8   r9   r;   	delete_opr'   s         r   DeleteHostGroupz HostGroupsClient.DeleteHostGroup   s    mmJJ((* K G 99@@II&&889#B#B 9 M   //r   c                 <    |||_         |||_        |||_        |S )aG  Parses updates into a host group config.

    Args:
      host_group_config: The host group config to update.
      hosts: list of str, new list of hosts, if any.
      description: str, a new description, if any.
      labels: LabelsValue message, the new labels value, if any.

    Returns:
      The host group message.
    )rA   rC   rD   )r   host_group_configrA   rC   rD   s        r   ParseUpdatedHostGroupConfigz,HostGroupsClient.ParseUpdatedHostGroupConfig   s7    $  %&1#!'r   c                 @   | j                   j                  |j                         ||      }| j                  j                  j                  |      }|r|S t        j                  j                  |j                  t        j                        }| j                  |      S )aa  Updates a Cloud NetApp Host Group.

    Args:
      host_group_ref: the reference to the Host Group.
      host_group: Host group config, the updated host group.
      update_mask: str, a comma-separated list of updated fields.
      async_: bool, if False, wait for the operation to complete.

    Returns:
      an Operation or HostGroup message.
    )r6   
updateMaskr,   r-   )r!   -NetappProjectsLocationsHostGroupsPatchRequestr1   r   r2   Patchr	   r4   r5   r6   r   r7   r(   )r   r8   rG   update_maskr9   r;   	update_opr'   s           r   UpdateHostGroupz HostGroupsClient.UpdateHostGroup   s     mmII((* J G
 99??HI&&889#B#B 9 M   //r   )NNNNNN)NNN)__name__
__module____qualname____doc__r   r   r   r   propertyr   r!   r(   r=   rH   rV   r[   r`   rc   rj    r   r   r   r      s    R#'#4#4#:#:      " "(0" &.B0  40r   r   c                       e Zd ZdZd Zy)r   z;Adapter for the Cloud NetApp Files API Host Group resource.c                     t         j                  j                  | _        t	        j
                  | j                        | _        t	        j                  | j                        | _        y N)r   )	r   r   r   r   r   GetClientInstancer   GetMessagesModuler!   r   s    r   r   zAlphaHostGroupsAdapter.__init__   sN    **00D!33((DK $55((DMr   N)rk   rl   rm   rn   r   rp   r   r   r   r      s
    Cr   r   c                   "     e Zd ZdZ fdZ xZS )r   z@Adapter for the Beta Cloud NetApp Files API Host Group resource.c                     t         t        |           t        j                  j
                  | _        t        j                  | j                        | _	        t        j                  | j                        | _        y rs   )superr   r   r   r   r   r   r   rt   r   ru   r!   )r   	__class__s    r   r   zBetaHostGroupsAdapter.__init__   s]    	
/1**//D!33((DK $55((DMr   )rk   rl   rm   rn   r   __classcell__)ry   s   @r   r   r      s    H r   r   N)rn   apitools.base.pyr   googlecloudsdk.api_lib.netappr   r   r   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper   googlecloudsdk.corer   r	   objectr   r   r   rp   r   r   <module>r      sH     U ' 3 A . ( # )j0v j0Z
V 
2 r   