
    59                        S r SSKrSSKJr  SSKJr  SSKJr  SSKJr  SSKJ	r
  SSKJr  SS	KJr  \R                  4S
 jr\R"                  \R$                  " \R&                  R(                  5       " S S\R*                  5      5       5       r\R$                  " \R&                  R.                  5       " S S\5      5       r\R$                  " \R&                  R2                  5       " S S\5      5       rg)Update a Filestore instance.    N)filestore_client)base)
exceptions)dp_util)flags)labels_util)logc                 0    [         R                  " X5        g N)instances_flagsAddInstanceUpdateArgs)parserapi_versions     )lib/surface/filestore/instances/update.py_CommonArgsr      s    ''<    c                   p    \ rS rSrSr\R                  rS\R                  " S5      S.r
\S 5       rS rSrg)	Update    r   Y      The following command updates the Filestore instance NAME to change the
    description to "A new description."

      $ {command} NAME --description="A new description."

    The following command updates a Filestore instance named NAME to add the label
    "key1=value1" and remove any metadata with the label "key2".

      $ {command} NAME --update-labels=key1=value1 --remove-labels=key2

      $ {command} NAME --zone=ZONE --flags-file=FILE_PATH

    Example json configuration file:
      {
      "--file-share":
      {
        "capacity": "102400",
        "name": "my_vol",
        "nfs-export-options": [
          {
            "access-mode": "READ_WRITE",
            "ip-ranges": [
              "10.0.0.0/29",
              "10.2.0.0/29"
            ],
            "squash-mode": "ROOT_SQUASH",
            "anon_uid": 1003,
            "anon_gid": 1003
          }
        ]
      }
      }


    The following command updates a Filestore instance named NAME to change the
    capacity to CAPACITY.

      $ {command} NAME --project=PROJECT_ID --zone=ZONE        --file-share=name=VOLUME_NAME,capacity=CAPACITY

    The following command updates a Filestore instance named NAME to configure the
    max-iops-per-tb to MAX-IOPS-PER-TB.

      $ {command} NAME --project=PROJECT_ID --zone=ZONE        --performance=max-iops-per-tb=MAX-IOPS-PER-TB
    DESCRIPTIONEXAMPLESc                 8    [        U [        R                  5        g r   )r   r   _API_VERSIONr   s    r   ArgsUpdate.Args\   s    ++,r   c                    UR                   R                  R                  5       n[        R                  " U R
                  5      n[        R                  R                  U5      n[        R                  " U5        UR                  U5      n UR                  (       a4  UR                  UR                  UR                  R                  S/ 5      S9  UR)                  5       (       aI  UR+                  UR                  R,                  R.                  UR0                  5      R3                  5       nOSn UR5                  UUR6                  UUR                  UR8                  UR:                  UR<                  UR>                  UR@                  URB                  S9
n/ n
URK                  S5      (       a  U
RM                  S5        URK                  S	5      (       d,  URK                  S
5      (       d  URK                  S5      (       a  U
RM                  S5        URK                  S5      (       a  U
RM                  S5        URK                  S5      (       a  U
RM                  S5        U
[        RN                  " U5      -  n
URK                  S5      (       d  URK                  S5      (       a  U
RM                  S5        SRQ                  U
5      nURS                  X(XRT                  5      nURT                  (       a8  [V        RX                  R[                  SR]                  UR^                  5      5        U$ ! [          a%  n["        R$                  " S['        U5      5      eSnAff = f! [        RD                   a%  n	["        R$                  " S['        U	5      5      eSn	A	f[        RF                   a%  n	["        R$                  " S['        U	5      5      eSn	A	f[        RH                   a%  n	["        R$                  " S['        U	5      5      eSn	A	ff = f)Runs command line arguments.

Args:
  args: Command line arguments.

Returns:
   The client instance.

Raises:
   InvalidArgumentException: For invalid JSON formatted --file-args.
nfs-export-optionsmessagesnfs_export_options--file-shareN)	descriptionlabels
file_shareperformanceldapdisconnect_ldapclear_nfs_export_optionsdeletion_protection_enableddeletion_protection_reason--disconnect-ldap--disconnect-managed-adr'   update_labelsremove_labelsclear_labelsr(   r)   
fileSharesr*   performanceConfigr+   r,   directoryServices,zSTo check the status of the operation, run `gcloud filestore operations describe {}`)0CONCEPTSinstanceParser   FilestoreClientr   r	   DiffFromUpdateArgsr   $ValidateDeletionProtectionUpdateArgsGetInstancer)   MakeNFSExportOptionsMsgr$   getKeyErrorr   InvalidArgumentExceptionstrMayHaveUpdatesApplyInstanceLabelsValuer(   	GetOrNoneParseUpdatedInstanceConfigr'   r*   r+   r,   r-   deletion_protectionr/   InvalidDisconnectLdapErrorInvalidDisconnectManagedADErrorErrorIsSpecifiedappendGetDeletionProtectionUpdateMaskjoinUpdateInstanceasync_r
   statusPrintformatnameselfargsinstance_refclientlabels_difforig_instanceerrr(   r:   eupdated_fieldsupdate_maskresults                r   Run
Update.Run`   sV    ==))//1L--d.?.?@F""11$7K006&&|4M		&&__#223GL 	' 	
 !!##  
//
"
"
.
.0D0D	  f22
&&__&&yy..#'#@#@&*&>&>%)%D%D 3 h2 N&&M*))O,,N++H%%%L)&&/0g==dCCN4#3#34E#F#F/0((>*K""[[F {{	jj$$*F6;;$7 MA  //
#c( 2 66 //
s1v  ;; //
#SV  !! //
#a& sJ   AL2 2A(M$ 2
M!< MM!$P8 NP/ OP& PP N)__name__
__module____qualname____firstlineno____doc__r   V1_API_VERSIONr   textwrapdedentdetailed_helpstaticmethodr   rf   __static_attributes__rh   r   r   r   r       sJ     %!00, )
// . .		3-j - -Yr   r   c                   p    \ rS rSrSr\R                  rS\R                  " S5      S.r
\S 5       rS rSrg)	UpdateAlpha   r   ao      The following command updates the Filestore instance NAME to change the
    description to "A new description."

      $ {command} NAME --description="A new description."

    The following command updates a Filestore instance named NAME to add the label
    "key1=value1" and remove any metadata with the label "key2".

      $ {command} NAME --update-labels=key1=value1 --remove-labels=key2

      $ {command} NAME --zone=ZONE --flags-file=FILE_PATH

    Example json configuration file:
      {
      "--file-share":
      {
        "capacity": "102400",
        "name": "my_vol",
        "nfs-export-options": [
          {
            "access-mode": "READ_WRITE",
            "ip-ranges": [
              "10.0.0.0/29",
              "10.2.0.0/29"
            ],
            "squash-mode": "ROOT_SQUASH",
            "anon_uid": 1003,
            "anon_gid": 1003
          }
        ]
      }
      }


    The following command updates a Filestore instance named NAME to change the
    capacity to CAPACITY.

      $ {command} NAME --project=PROJECT_ID --zone=ZONE        --file-share=name=VOLUME_NAME,capacity=CAPACITY
    r   c                 8    [        U [        R                  5        g r   )r   ru   r   r   s    r   r   UpdateAlpha.Args   s    001r   c                    UR                   R                  R                  5       n[        R                  " U R
                  5      n[        R                  R                  U5      nUR                  U5      n UR                  (       a4  UR                  UR                  UR                  R                  S/ 5      S9  UR%                  5       (       aI  UR'                  UR                  R(                  R*                  UR,                  5      R/                  5       nOSn UR1                  UUR2                  UUR                  UR4                  S9n/ n
UR9                  S5      (       a  U
R;                  S5        UR9                  S5      (       d,  UR9                  S5      (       d  UR9                  S	5      (       a  U
R;                  S
5        UR9                  S5      (       a  U
R;                  S5        SR=                  U
5      nUR?                  X(XR@                  5      nUR@                  (       a8  [B        RD                  RG                  SRI                  URJ                  5      5        U$ ! [         a%  n[        R                   " S[#        U5      5      eSnAff = f! [        R6                   a%  n	[        R                   " S[#        U	5      5      eSn	A	ff = f)r!   r"   r#   r&   N)r'   r(   r)   r-   r'   r2   r3   r4   r(   r)   r5   r8   zYTo check the status of the operation, run `gcloud alpha filestore operations describe {}`)&r9   r:   r;   r   r<   r   r	   r=   r>   r@   r)   rA   r$   rB   rC   r   rD   rE   rF   rG   rH   rI   r(   rJ   rK   r'   r-   rO   rP   rQ   rS   rT   rU   r
   rV   rW   rX   rY   rZ   s                r   rf   UpdateAlpha.Run   s]    ==))//1L--d.?.?@F""11$7K&&|4M		&&__#223GL 	' 	
 !!##  
//
"
"
.
.0D0D	  f22
&&__#'#@#@ 3 h N&&M*))O,,N++H%%%L)((>*K""[[F {{	jj$$*F6;;$7 M]  //
#c( ( !! //
#a& s1   6AI( 1J (
J2 JJK. KKrh   N)ri   rj   rk   rl   rm   r   ALPHA_API_VERSIONr   ro   rp   rq   rr   r   rf   rs   rh   r   r   ru   ru      sH    $!33, )
// ( (		--^ 2 2Fr   ru   c                   p    \ rS rSrSr\R                  rS\R                  " S5      S.r
\S 5       rS rSrg)	
UpdateBetai=  r   r   r   c                 8    [        U [        R                  5        g r   )r   r}   r   r   s    r   r   UpdateBeta.Argsx  s     
//0r   c                    UR                   R                  R                  5       n[        R                  " U R
                  5      n[        R                  R                  U5      n[        R                  " U5        UR                  U5      n UR                  (       a4  UR                  UR                  UR                  R                  S/ 5      S9  UR)                  5       (       aI  UR+                  UR                  R,                  R.                  UR0                  5      R3                  5       nOSn UR5                  UUR6                  UUR                  UR8                  UR:                  UR<                  UR>                  UR@                  URB                  URD                  URF                  S9n/ n	URO                  S5      (       a  U	RQ                  S5        URO                  S	5      (       d,  URO                  S
5      (       d  URO                  S5      (       a  U	RQ                  S5        URO                  S5      (       a  U	RQ                  S5        URO                  S5      (       a  U	RQ                  S5        URO                  S5      (       dB  URO                  S5      (       d,  URO                  S5      (       d  URO                  S5      (       a  U	RQ                  S5        U	[        RR                  " U5      -  n	SRU                  U	5      n
URW                  X(XRX                  5      nURX                  (       a8  [Z        R\                  R_                  SRa                  URb                  5      5        U$ ! [          a%  n["        R$                  " S['        U5      5      eSnAff = f! [        RH                   a%  n["        R$                  " S['        U5      5      eSnAf[        RJ                   a%  n["        R$                  " S['        U5      5      eSnAf[        RL                   a%  n["        R$                  " S['        U5      5      eSnAff = f)zRuns a command line string arguments.

Args:
  args: cmd line string arguments.

Returns:
   client: A FilestoreClient instance.

Raises:
   InvalidArgumentException: for invalid JSON formatted --file-args.
   KeyError: for key errors in JSON values.
r"   r#   r&   N)r'   r(   r)   r*   
managed_addisconnect_managed_adr+   r,   r-   r.   r/   r0   r1   r'   r2   r3   r4   r(   r)   r5   r*   r6   r   r   r+   r,   r7   r8   zXTo check the status of the operation, run `gcloud beta filestore operations describe {}`)2r9   r:   r;   r   r<   r   r	   r=   r>   r   r?   r@   r)   MakeNFSExportOptionsMsgBetar$   rB   rC   r   rD   rE   rF   rG   rH   rI   r(   rJ   rK   r'   r*   r   r   r+   r,   r-   rL   r/   rM   rN   rO   rP   rQ   rR   rS   rT   rU   r
   rV   rW   rX   rY   )r[   r\   r]   r^   r_   r`   rb   r(   r:   rc   rd   re   s               r   rf   UpdateBeta.Run}  s    ==))//1L--d.?.?@F""11$7K006&&|4M		**__#223GL 	+ 	
 !!##  
//
"
"
.
.0D0D	  f22
&&__&&__ $ : :yy..#'#@#@&*&>&>%)%D%D 3 h6 N&&M*))O,,N++H%%%L)&&/0%%)9)9* *			&	!	!T%5%56G%H%H/0g==dCCN((>*K""[[F {{	jj$$*F6;;$7 MI  //
#a& 4 66 //
s1v  ;; //
#SV  !! //
#a& sJ   AM4 2A>N& 4
N#> NN#&Q: OQ1 PQ( QQrh   N)ri   rj   rk   rl   rm   r   BETA_API_VERSIONr   ro   rp   rq   rr   r   rf   rs   rh   r   r   r}   r}   =  sH    $!22, )
// . .		3-j 1 1^r   r}   )rm   ro    googlecloudsdk.api_lib.filestorer   googlecloudsdk.callioper   r   .googlecloudsdk.command_lib.filestore.instancesr   r   r   $googlecloudsdk.command_lib.util.argsr	   googlecloudsdk.corer
   rn   r   UniverseCompatibleReleaseTracksReleaseTrackGACreateCommandr   ALPHAru   BETAr}   rh   r   r   <module>r      s    #  = ( . B S < # %5$C$C = D%%(()WT W * Wt D%%++,}& } -}@ D%%**+] ] ,]r   