
    /                     0   S 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  SS	KJr  SS
KJr  SSKJr  SSKr\R&                  4S jr\R*                  \R,                  " \R.                  R0                  5       " S S\R2                  5      5       5       r\R*                  \R,                  " \R.                  R6                  5       " S S\5      5       5       r\R,                  " \R.                  R:                  5       " S S\5      5       rg)zCreates a Filestore instance.    )absolute_import)division)unicode_literals)filestore_client)base)
exceptions)flags)labels_util)log)
propertiesNc                 0    [         R                  " X5        g N)instances_flagsAddInstanceCreateArgs)parserapi_versions     )lib/surface/filestore/instances/create.py_CommonArgsr       s    ''<    c                   P    \ rS rSrSr\R                  rSSS.r\	S 5       r
S rSrg)	Create$   Create a Filestore instance.a      To create a Basic HDD instance named `my-instance` in zone `us-central1-c` with a 1TB volume named `my_vol` on the default network, run:

      $ {command} my-instance --zone=us-central1-c --tier=BASIC_HDD --file-share=name=my_vol,capacity=1TB --network=name=default

    To create an Enterprise instance named `my-ent-instance` in region `us-central1` with a 2TB volume named `my_vol` on network `my-network`, run:

      $ {command} my-ent-instance --zone=us-central1 --tier=ENTERPRISE --file-share=name=my_vol,capacity=2TB --network=name=my-network

    To create an instance with specific NFS export options, you can use a JSON configuration file with `--flags-file`. For example, create a file named `config.json` with the following content:
  {
  "--file-share":
  {
    "capacity": "1024",
    "name": "my_vol",
    "nfs-export-options": [
      {
        "access-mode": "READ_WRITE",
        "ip-ranges": [
          "10.0.0.0/8"
        ],
        "squash-mode": "NO_ROOT_SQUASH"
      },
       {
        "access-mode": "READ_ONLY",
        "ip-ranges": [
          "192.168.0.0/24"
        ],
        "squash-mode": "ROOT_SQUASH",
        "anon_uid": 1003,
        "anon_gid": 1003
      }
    ]
  }
  }

    To create a Basic SSD instance named `my-nfs-instance` using the above configuration file, run:
      $ {command} my-nfs-instance --zone=us-central1-c --tier=BASIC_SSD --network=name=default --flags-file=config.json
    DESCRIPTIONEXAMPLESc                 8    [        U [        R                  5        g r   )r   r   _API_VERSIONr   s    r   ArgsCreate.ArgsV   s    ++,r   c                    UR                   R                  R                  5       n[        R                  " U R
                  5      n[        R                  " UR                  5      R                  UR                  5      nSnUR                  b9  [        R                  " UR                  5      R                  UR                  5      nUR                  =(       d    Sn[        R                  " UUR                  R                   R"                  5      n[        R$                  " UUR                  R                   R&                  5      n UR)                  UR                  UR*                  R-                  S/ 5      S9n	UR9                  UUUR:                  UR*                  UR<                  UR>                  UUUR@                  U	[        RB                  " U5      UURD                  URF                  URH                  S9nURK                  X!RL                  U5      nURL                  (       a  [N        RP                  RR                  RT                  RW                  5       RY                  S5      nU(       a  SUS'   [Z        R\                  R_                  S	Ra                  S
Rc                  U5      5      5        U$ ! [.         a0  n
[0        R2                  " S[4        R6                  " U
5      5      eSn
A
ff = f)3Create a Filestore instance in the current project.Nnfs-export-optionsmessagesnfs_export_options--file-share)tierprotocoldescription
file_sharenetworkperformancelabelstagszoner'   kms_key_nameldapsource_instancedeletion_protection_enableddeletion_protection_reason.listFCheck the status of the new instance by listing all instances:
  $ {}  )2CONCEPTSinstanceParser   FilestoreClientr   r   
GetTierArgr&   GetEnumForChoicer)   r*   GetProtocolArgr3   r
   ParseCreateArgsInstanceLabelsValueGetTagsFromArgs	TagsValueMakeNFSExportOptionsMsgr,   getKeyErrorr   InvalidArgumentExceptionsix	text_typeParseFilestoreConfigr+   r-   r.   locationsIdGetAndValidateKmsKeyNamer4   deletion_protectionr6   CreateInstanceasync_r   VALUESmetricscommand_nameGetsplitr   statusPrintformatjoin)selfargsinstance_refclientr)   r*   r3   r/   r0   r'   errr=   resultcommands                 r   Run
Create.RunZ   s_   ==))//1L--d.?.?@F%%foo6GG		D H}}  //
//'  99D(()/)A)A)M)MOF**4+1??+C+C+M+MODD!99??!__001ErJ : L **$$??$$%%-$==dC,,$($<$<#'#B#B + DH  ""<hGF{{!!))66::<BB3Gg		jj&'*+- M9  D//03c0BD DDs   4J4 4
K.>+K))K. N)__name__
__module____qualname____firstlineno____doc__r   V1_API_VERSIONr   detailed_helpstaticmethodr    rd   __static_attributes__rf   r   r   r   r   $   s=     %!00, 4&)-V - -1r   r   c                   P    \ rS rSrSr\R                  rSSS.r\	S 5       r
S rSrg)	
CreateBeta   r   a      To create a Basic HDD instance named `my-instance` in zone `us-central1-c` with a 1TB volume named `my_vol` on the default network, run:

      $ {command} my-instance --zone=us-central1-c --tier=BASIC_HDD --file-share=name=my_vol,capacity=1TB --network=name=default

    To create an Enterprise instance named `my-ent-instance` in region `us-central1` with a 2TB volume named `my_vol` on network `my-network`, run:

      $ {command} my-ent-instance --zone=us-central1 --tier=ENTERPRISE --file-share=name=my_vol,capacity=2TB --network=name=my-network

    To create an instance with specific NFS export options, you can use a JSON configuration file with `--flags-file`. For example, create a file named `config.json` with the following content:
  {
  "--file-share":
  {
    "capacity": "1024",
    "name": "my_vol",
    "nfs-export-options": [
      {
        "access-mode": "READ_WRITE",
        "ip-ranges": [
          "10.0.0.0/8"
        ],
        "squash-mode": "NO_ROOT_SQUASH"
      },
       {
        "access-mode": "READ_ONLY",
        "ip-ranges": [
          "192.168.0.0/24"
        ],
        "squash-mode": "ROOT_SQUASH",
        "anon_uid": 1003,
        "anon_gid": 1003
      }
    ]
  }
  }

    To create a Basic SSD instance named `my-nfs-instance` using the above configuration file, run:
      $ {command} my-nfs-instance --zone=us-central1-c --tier=BASIC_SSD --network=name=default --flags-file=config.json

    r   c                 8    [        U [        R                  5        g r   )r   rq   r   r   s    r   r    CreateBeta.Args   s    
//0r   c                    UR                   R                  R                  5       n[        R                  " U R
                  5      n[        R                  " UR                  5      R                  UR                  5      nSnUR                  b9  [        R                  " UR                  5      R                  UR                  5      nSnUR                  b9  [        R                  " UR                  5      R                  UR                  5      nUR                  =(       d    SnUR                   =(       d    SnUR"                  =(       d    Sn	[$        R&                  " XR                  R(                  R*                  5      n
[        R,                  " UUR                  R(                  R.                  5      n UR1                  UR                  UR2                  R5                  S/ 5      S9nURA                  UUURB                  UR2                  URD                  URF                  U
UURH                  U[        RJ                  " U5      UUU	URL                  URN                  US9nURQ                  X!RR                  U5      nURR                  (       a  [T        RV                  RX                  RZ                  R]                  5       R_                  S5      nU(       a  SUS'   [`        Rb                  Re                  S	Rg                  S
Ri                  U5      5      5        U$ ! [6         a0  n[8        R:                  " S[<        R>                  " U5      5      eSnAff = f)zCreates a Filestore instance in the current project.

Note: This is a copied code from Run() of base.ReleaseTrack.GA.
Args:
  args: A list of fields.
Returns:
  A filestore instance.
Nr$   r%   r(   )r)   r*   r+   r,   r-   r.   r/   r0   r1   r'   r2   
managed_adr3   r4   r5   r6   backend_typer7   r8   r9   r:   r;   )5r<   r=   r>   r   r?   r   r   r@   r&   rA   r)   r*   rB   rw   GetBackendTypeArgrv   r3   r4   r
   rC   rD   rE   rF   rG   MakeNFSExportOptionsMsgBetar,   rI   rJ   r   rK   rL   rM   rN   r+   r-   r.   rO   rP   rQ   r6   rR   rS   r   rT   rU   rV   rW   rX   r   rY   rZ   r[   r\   )r]   r^   r_   r`   r)   r*   rw   rv   r3   r4   r/   r0   r'   ra   r=   rb   rc   s                    r   rd   CreateBeta.Run   s    ==))//1L--d.?.?@F%%foo6GG		D H}}  //
//'  L$$66
//**+  (DJ99D**2dO((oo&&224F**4+1??+C+C+M+MODD!==??!__001ErJ > L **$$??$$%%-$==dC'$($<$<#'#B#B!# + H( ""<hGF{{!!))66::<BB3Gg		jj&'*+- MA  D//03c0BD DDs   74L 
M'+MMrf   N)rg   rh   ri   rj   rk   r   BETA_API_VERSIONr   rm   rn   r    rd   ro   rf   r   r   rq   rq      s>     %!22, 4'*-X 1 1Cr   rq   c                   P    \ rS rSrSr\R                  rSSS.r\	S 5       r
S rSrg)	CreateAlphai  r   ad      The following command creates a Filestore instance named NAME with a single volume.

      $ {command} NAME       --description=DESCRIPTION --tier=TIER       --file-share=name=VOLUME_NAME,capacity=CAPACITY       --network=name=NETWORK_NAME,reserved-ip-range=RESERVED_IP_RANGE,connect-mode=CONNECT_MODE       --zone=ZONE       --flags-file=FLAGS_FILE

    Example json configuration file:
  {
  "--file-share":
  {
    "capacity": "61440",
    "name": "my_vol",
    "nfs-export-options": [
      {
        "access-mode": "READ_WRITE",
        "ip-ranges": [
          "10.0.0.0/8",
        ],
        "squash-mode": "NO_ROOT_SQUASH",
      },
       {
        "access-mode": "READ_ONLY",
        "ip-ranges": [
          "192.168.0.0/24"
        ],
        "squash-mode": "ROOT_SQUASH"
        "anon_uid": 1003,
        "anon_gid": 1003
      }
    ],
  }
  }

    r   c                 8    [        U [        R                  5        g r   )r   r}   r   r   s    r   r    CreateAlpha.Args=  s    001r   c           
      6   UR                   R                  R                  5       n[        R                  " U R
                  5      n[        R                  " UR                  5      R                  UR                  5      n[        R                  " UUR                  R                  R                  5      n UR                  UR                  UR                   R#                  S/ 5      S9nUR/                  UUR0                  UR                   UR2                  UUR4                  US9nUR7                  X!R8                  U5      n	UR8                  (       a  [:        R<                  R>                  R@                  RC                  5       RE                  S5      n
U
(       a  SU
S'   [F        RH                  RK                  S	RM                  S
RO                  U
5      5      5        U	$ ! [$         a0  n[&        R(                  " S[*        R,                  " U5      5      eSnAff = f)r#   r$   r%   r(   N)r)   r+   r,   r-   r/   r1   r'   r7   r8   r9   r:   r;   )(r<   r=   r>   r   r?   r   r   r@   r&   rA   r)   r
   rC   rD   rE   rH   r,   rI   rJ   r   rK   rL   rM   rN   r+   r-   rO   rR   rS   r   rT   rU   rV   rW   rX   r   rY   rZ   r[   r\   )r]   r^   r_   r`   r)   r/   r'   ra   r=   rb   rc   s              r   rd   CreateAlpha.RunA  s   ==))//1L--d.?.?@F%%foo6GG		D (()/)A)A)M)MOFD!99??!__001ErJ : L **$$??%%- + /H ""<hGF{{!!))66::<BB3Gg		jj&'*+- M'  D//03c0BD DDs   44G 
H(+HHrf   N)rg   rh   ri   rj   rk   r   ALPHA_API_VERSIONr   rm   rn   r    rd   ro   rf   r   r   r}   r}     s;    $!33, )%	*-X 2 2 r   r}   )rk   
__future__r   r   r    googlecloudsdk.api_lib.filestorer   googlecloudsdk.callioper   r   .googlecloudsdk.command_lib.filestore.instancesr	   r   $googlecloudsdk.command_lib.util.argsr
   googlecloudsdk.corer   r   rL   rl   r   UniverseCompatibleReleaseTracksReleaseTrackGACreateCommandr   BETArq   ALPHAr}   rf   r   r   <module>r      s    $ &  ' = ( . S < # * 
 %5$C$C = D%%(()eT e * eP D%%**+x x , xv D%%++,U& U -Ur   