
    AL                     n   d Z ddlmZ ddlmZ ddlmZ ddl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(                  ddde
j*                  d      Z e
j(                  d e	j.                  dej0                  d      de
j*                  d      Z ej4                  d ej6                  dd      j8                  j:                  dddd dd!"      Z e
j(                  d#d$d%dd&'      Ze e e d(Z!e e d)Z"d*Z#d+ Z$e e e e$ e	jJ                          e	jJ                          e	jJ                         d,Z&g d-Z'd.Z(e e e d/Z)d0d1gZ*dJd2Z+dJd3Z,dKd4Z-	 	 	 	 dLd5Z.dMd6Z/dJd7Z0d8 Z1dJd9Z2d: Z3dJd;Z4dJd<Z5dKd=Z6	 dNd>Z7	 dNd?Z8d@ Z9dA Z:dB Z;dC Z<dD Z=dE Z>dF Z?dG Z@dH ZAdI ZBy)Oz Flags for data-catalog commands.    )absolute_import)division)unicode_literalsN)apis)arg_parsers)base)
exceptions)concepts)	arg_utils)	yaml_data)concept_parsers)presentation_specsz--filter
EXPRESSIONFaS      Apply a Boolean filter _EXPRESSION_ to each resource item to be listed.
    If the expression evaluates `True`, then that item is listed. For more
    details and examples of filter expressions, run $ gcloud topic filters. This
    flag interacts with other flags that are applied in this order: *--flatten*,
    *--filter*, *--limit*.)metavarrequire_coverage_in_testscategoryhelpz--limit   T)	unlimitedz    Maximum number of resources to list. The default is *unlimited*.
    This flag interacts with other flags that are applied in this order:
    *--flatten*, *--filter*, *--limit*.
    )typer   r   r   z--snapshot-auto-deletebaremetalsolutionv2)znewest-firstz!Delete the newest snapshot first.)zoldest-firstz!Delete the oldest snapshot first.)disabledzoDon't delete any snapshots. This disables new snapshot creation as long as the snapshot reserved space is full.)NEWEST_FIRSTOLDEST_FIRSTDISABLEDz:Behavior of the disk when snapshot reserved space is full.)arg_namemessage_enumcustom_mappingsrequiredhelp_strz--async
store_trueasync_zV    Return immediately, without waiting for the operation in progress to
    complete.)actiondestdefaultr   )start-addressend-addressnote)r'   r(   a  
Adds an allowed client to the NFS share. This flag can be repeated to specify multiple allowed clients.

*network*::: The name of the network to allow.

*network-project-id*::: The project ID of the allowed client network.
If not present, the project ID of the NFS share will be used.

*cidr*::: The subnet of IP addresses permitted to access the NFS
share.

*mount-permissions*::: The mount permissions for the allowed client.
``MOUNT_PERMISSIONS'' must be one of: `READ_ONLY`, `READ_WRITE`.

*allow-dev*::: If ``yes'', allows creation of devices.

*allow-suid*::: If ``yes'', allows SUID.

*enable-root-squash*::: If ``yes'', enables root squashing which
is a special mapping of the remote superuser (root) identity when
using identity authentication .
c                     | j                         }|t        vr%t        j                  ddj	                  |             |S )zCValidates NFS mount permissions field, throws exception if invalid.--allowed-clientz&Invalid value {} for mount-permissions)upperNFS_MOUNT_PERMISSIONS_CHOICESr	   InvalidArgumentExceptionformat)mount_permissions_inputmount_permissionss     +lib/googlecloudsdk/command_lib/bms/flags.py_ValidateNFSMountPermissionsr3   v   sI    -335;;

-
-077#	%& & 
    )networknetwork-project-idcidrmount-permissions	allow-dev
allow-suidenable-root-squash)r5   r7   r8   r9   r:   r;   )	READ_ONLY
READ_WRITE)r5   r6   r7   r5   r7   c                 $   |rd}nd}t         j                  j                  d      }t        j                  j                  |j                               }t        j                  ||dd      }t        j                  |g      j                  |       S ).Sets up an argument for the instance resource.instancez
--instancezbms.instanceTz	instance.nameconcept_specr    
group_helpr   ResourceYAMLDataFromPathr
   ResourceSpecFromYamlGetDatar   ResourcePresentationSpecr   ConceptParserAddToParser)parser
positionalrB   instance_dataresource_specpresentation_specs         r2   AddInstanceArgToParserrS          DD,,55-''001F1F1HI-(AA 	
 
	&	&(9':	;	G	G	OOr4   c                 $   t         j                  j                  d      }t        j                  j                  |j                               }|rd}nd}t        j                  ||dd      }t        j                  |g      j                  |       S )zParses region flag.z
bms.regionregionz--regionFzregion.rA   rE   )rN   rO   region_datarQ   rB   rR   s         r2   AddRegionArgToParserrX      s    **33LA+''001D1D1FG-DD(AA 	
 
	&	&(9':	;	G	G	OOr4   c                 ,   |rd}nd}t         j                  j                  d      }t        j                  j                  |j                               }t        j                  ||d|xs d      }t        j                  |g      j                  |       S )r?   volumez--volumez
bms.volumeTzvolume.rA   rE   )rN   rO   group_help_textrB   volume_datarQ   rR   s          r2   AddVolumeArgToParserr]      s    DD**33+''001D1D1FG-(AA  -I	/
 
	&	&(9':	;	G	G	OOr4   c                 0   |s|rd}nd}t         j                  j                  d      }t        j                  j                  |j                               }t        j                  ||||ddid      }t        j                  |g      j                  |       S )z>Sets up an argument for the snapshot schedule policy resource.snapshot_schedule_policyz--snapshot-schedule-policyzbms.snapshot_schedule_policyrV    zsnapshot_schedule_policy.)rB   grouprC   r    flag_name_overridesrD   rE   )rN   rO   r    rB   ra   policy_datarQ   rR   s           r2   $AddSnapshotSchedulePolicyArgToParserrd      s     
'd)d**33$&+''001D1D1FG-(AA #R.,. 
	&	&(9':	;	G	G	OOr4   c           
          t         t        t         d}| j                  d|t        j                  |t        |      |j                               ddd       y)	z,Sets up an argument for a snapshot schedule.)crontab_specretention_countprefixz
--schedule)spec
max_lengthrequired_keysappendz#CRONTAB_SPEC,RETENTION_COUNT,PREFIXaE  
              Adds a schedule for taking snapshots of volumes under this policy.
              This flag may be repeated to specify up to 5 schedules.

              *crontab_spec*::: Specification of the times at which snapshots
              will be taken. This should be in Crontab format:
              http://en.wikipedia.org/wiki/Cron#Overview

              *retention_count*::: The maximum number of snapshots to retain in
              this schedule.

              *prefix*::: Value to append to the name of snapshots created by
              this schedule.

           )r    r   r$   r   r   N)strintadd_argumentr   ArgDictlenkeys)rN   r    ri   s      r2   "AddSnapshotScheduleArgListToParserrs      s\     
$
 	D*-d)-1YY[: 3  r4   c                 $   |rd}nd}t         j                  j                  d      }t        j                  j                  |j                               }t        j                  ||dd      }t        j                  |g      j                  |       S )z-Sets up an argument for the network resource.r5   z	--networkzbms.networkTznetwork.rA   rE   )rN   rO   rB   rc   rQ   rR   s         r2   AddNetworkArgToParserru   	  s    DD**33+''001D1D1FG-(AA 	 
	&	&(9':	;	G	G	OOr4   c                    d}t         j                  j                  d      }t        j                  j                  |j                               }t        j                  ||dd      }t        j                  |g      j                  |       S )1Sets up an argument for a volume snapshot policy.lunzbms.lunTzlun.rA   rE   )rN   rB   snapshot_datarQ   rR   s        r2   AddLunArgToParserrz     s{    	$,,55i@-''001F1F1HI-(AA 	
 
	&	&(9':	;	G	G	OOr4   c                 $   |rd}nd}t         j                  j                  d      }t        j                  j                  |j                               }t        j                  ||dd      }t        j                  |g      j                  |       S )rw   snapshotz
--snapshotzbms.snapshotTz	snapshot.rA   rE   )rN   rO   rB   ry   rQ   rR   s         r2   AddVolumeSnapshotArgToParserr}   (  s    DD,,55nE-''001F1F1HI-(AA 	
 
	&	&(9':	;	G	G	OOr4   c                 B    t         j                  j                  |        y)zDSets up an argument for a volume snapshot auto-delete-behavior enum.N)+VOLUME_SNAPSHOT_AUTO_DELETE_BEHAVIOR_MAPPER
choice_argrM   rN   s    r2   .AddVolumeSnapshotAutoDeleteBehaviorArgToParserr   8  s    -88DDVLr4   c                 $   |rd}nd}t         j                  j                  d      }t        j                  j                  |j                               }t        j                  ||dd      }t        j                  |g      j                  |       S )z.Sets up an argument for an nfs-share resource.	nfs_sharez--nfs_sharezbms.nfs_shareTz
nfs_share.rA   rE   )rN   rO   rB   nfs_datarQ   rR   s         r2   AddNfsShareArgToParserr   =  s    DD''00(''001A1A1CD-(AA 	
 
	&	&(9':	;	G	G	OOr4   c                 $   |rd}nd}t         j                  j                  d      }t        j                  j                  |j                               }t        j                  ||dd      }t        j                  |g      j                  |       S )z-Sets up an argument for an os-image resource.os_image
--os-imagezbms.os_imageTz	os_image.rA   rE   )rN   rO   rB   os_image_datarQ   rR   s         r2   AddOsImageArgToParserr   N  rT   r4   c                 (   |rdnd}t         j                  j                  d      }t        j                  j                  |j                               }t        j                  ||dddid      }t        j                  |g      j                  |       S )	z<Sets up an argument for the serial-console-ssh-key resource.serial_console_ssh_keyz--serial-console-ssh-keyzbms.serial_console_ssh_keyTrV   r`   zserial_console_ssh_key.)rB   rC   r    rb   rD   rE   )rN   rO   rB   ssh_key_datarQ   rR   s         r2   !AddSerialConsoleSshKeyArgToParserr   _  s    %/	!5O$++44", ''001E1E1GH-(AA #R.* 
	&	&(9':	;	G	G	OOr4   c                 ^    | j                  |      }t        |||||       t        |       y )Nr    )rO   rB   pluralr    )add_mutually_exclusive_groupAddSshKeyArgToParserAddClearSshKeyToParser)rN   rO   rB   r    r   group_parsers         r2    AddProvisioningSshKeyArgToParserr   p  s8     44h4G, &r4   c                 8   |rdnd}t         j                  j                  d      }t        j                  j                  |j                               }t        j                  |s|n| d||ddid|      }t        j                  |g      j                  |       S )	z-Sets up an argument for the ssh-key resource.ssh_keyz	--ssh-keyzbms.ssh_keysrV   r`   zssh_key.)rB   rC   r    rb   rD   r   rE   )rN   rO   rB   r    r   r   rQ   rR   s           r2   r   r   ~  s     !k$++44]C,''001E1E1GH-(AA4dV1: #R. 
	&	&(9':	;	G	G	OOr4   c                 .    | j                  dddd       y )Nz--clear-ssh-keysr"   z-Provisions the instance without any SSH keys.F)r$   r   r    )ro   r   s    r2   r   r     s!    >	  r4   c                 V    | j                  dt        dj                  |      d       y )Nz
--new-namez8New {name} name for renaming an already existing {name}.)rB   T)r   r   r    )ro   rm   r/   )rN   obj_names     r2   AddNewNameArgToParserr     s5    IPP Q   r4   c                 8    | j                  dt        d||       y )Nr   z
              OS image to install on the server.

              To list all OS image codes supported by BMS, run:

                  $ gcloud bms os-images list
        )r   r   hiddenr    ro   rm   )rN   r   r    s      r2   AddInstanceOsImageToParserr     s(       r4   c                 J    | j                  dt        j                  d|       y )Nz--enable-hyperthreadingz%Enable hyperthreading for the server.r$   r   r   )ro   r   StoreTrueFalseActionrN   r   s     r2   'AddInstanceEnableHyperthreadingToParserr     s'    --6	  r4   c                 
   | j                  d      }|j                  dt        j                  t              dd|       |j                  dt        j                  t
              dd	|       |j                  d
dd|       y)z:Adds the flags for network IP range reservation to parser.Fr   z--add-ip-range-reservation)ri   PROPERTY=VALUEau  
              Add a reservation of a range of IP addresses in the network.

              *start_address*::: The first address of this reservation block.
              Must be specified as a single IPv4 address, e.g. `10.1.2.2`.

              *end_address*::: The last address of this reservation block,
              inclusive. I.e., for cases when reservations are only single
              addresses, end_address and start_address will be the same.
              Must be specified as a single IPv4 address, e.g. `10.1.2.2`.

              *note*::: A note about this reservation, intended for human consumption.
            )r   r   r   r   z--remove-ip-range-reservationa  
              Remove a reservation of a range of IP addresses in the network.

              *start_address*::: The first address of the reservation block to remove.

              *end_address*::: The last address of the reservation block to remove.
            z--clear-ip-range-reservationsr"   1Removes all IP range reservations in the network.r   N)r   ro   r   rp   IP_RESERVATION_SPECIP_RESERVATION_KEY_SPECrN   r   	group_args      r2   AddNetworkIpReservationToParserr     s    1151A)"$78 #  $ %$;<    %B	  r4   c                 6    | j                  ddt        d       y)zAdds size GiB argument for NFS.z
--size-gibz*The requested size of the NFS share in GiBT)r   r   r    N)ro   rn   r   s    r2   AddNfsSizeGibArgr     s!    7	  r4   c                 R    | j                  dddddt        j                  d       y)	z#Adds storage type argument for NFS.z--storage-typez5The storage type of the underlying volume will be SSDz5The storage type of the underlying volume will be HDD)SSDHDDTz\Specifies the storage type of the underlying volume which will be created for the NFS share.)choicesr    r   r   N)ro   r   ChoiceToEnumNamer   s    r2   AddNfsStorageTypeArgr     s9     FE	 %%*  ,r4   c                 t    | j                  dt        j                  t        t              dddt
               y )Nr+   ri   rk   Trl   r   )r   r    r$   r   r   )ro   r   rp   NFS_ALLOWED_CLIENT_SPEC REQUIRED_NFS_ALLOWED_CLIENT_KEYSNFS_ALLOWED_CLIENTS_HELP_TEXTr   s    r2   AddNfsAllowedClientArgr     s:    $;-M! (  	r4   c                 &   | j                  d|      }|j                  dt        j                  t        t
              ddt               |j                  dt        j                  t        t              ddd	       |j                  d
dd       y)z0Adds NFS update allowed clients arguments group.F)r    r   z--add-allowed-clientr   rl   r   )r   r$   r   r   z--remove-allowed-clienta  
              Removes an allowed client for the NFS share given its network name and cidr. This flag can be repeated to remove multiple allowed clients.

              *network*::: The name of the network of the allowed client to remove.

              *network-project-id*::: The project ID of the allowed client network.
              If not present, the project ID of the NFS share will be used.

              *cidr*::: The subnet of permitted IP addresses of the allowed client to remove.
            z--clear-allowed-clientsr"   r   )r$   r   N)	r   ro   r   rp   r   r   r   REMOVE_NFS_ALLOWED_CLIENT_SPEC'REQUIRED_REMOVE_NFS_ALLOWED_CLIENT_KEYSr   s      r2   AddNfsUpdateAllowedClientArgsr     s    1151P)&8 (  	 -? 	  $ B  Dr4   c                 6    | j                  dt        d|       y )Nz--kms-crypto-key-versionz
      Resource ID of a KMS CryptoKeyVersion used to encrypt the initial password.

      https://cloud.google.com/kms/docs/resource-hierarchy#key_versions
      )r   r   r   r   r   s     r2   AddKMSCryptoKeyVersionToParserr   -  s%     

   	r4   )F)FN)FTNN)T)FNTF)C__doc__
__future__r   r   r   sysgooglecloudsdk.api_lib.utilr   googlecloudsdk.callioper   r   r	    googlecloudsdk.calliope.conceptsr
   $googlecloudsdk.command_lib.util.apisr   r   (googlecloudsdk.command_lib.util.conceptsr   r   ArgumentLIST_COMMAND_FLAGSFILTER_FLAG_NO_SORTBY_DOC
BoundedIntmaxsizeLIMIT_FLAG_NO_SORTBY_DOCChoiceEnumMapperGetMessagesModuleVolume)SnapshotAutoDeleteBehaviorValueValuesEnumr   ASYNC_FLAG_DEFAULT_TRUErm   r   r   r   r3   
ArgBooleanr   r   r-   r   r   rS   rX   r]   rd   rs   ru   rz   r}   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r4   r2   <module>r      sU   ' &  ' 
 , / ( . 5 : : D G)DMM#$$

  )4==			3;;$	?#$$
		  /Ii.H.H%'''f>>MMG I/K +  ($--	
     
! 0 5''')(+((*0+002 $   !< "  
+ 'P"P P$ 5:26.2/3	P0BP$
PP M
P"P"P$ @E' @EP$ %P, 
"DJ
r4   