
    d                         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Jr  \R                    " S S\R"                  5      5       rg)zGImplementation of create command for creating Anywhere Cache Instances.    )arg_parsers)base)errors_util)flags)plurality_checkable_iterator)progress_callbacks)storage_url)task_executor)task_graph_executor)task_status)create_anywhere_cache_taskc                   >    \ rS rSrSrSSS.r\S 5       rS rS r	S	r
g
)Create   z-Create Anywhere Cache instances for a bucket.zv

      Create Anywhere Cache instances.
      Only one cache instance per zone can be created for each bucket.
      a  

      The following command creates an anywhere cache instance for bucket
      in ``asia-south2-b'' zone:

        $ {command} gs://my-bucket asia-south2-b

      The following command creates anywhere cache instances for bucket
      in ``asia-south2-b'', and ``asia-east1-a'' zone:

        $ {command} gs://my-bucket asia-south2-b asia-east1-a

      The following command creates an anywhere cache instance for bucket
      in ``asia-south2-b'' zone, with ttl for cache entry as 6 hours, and
      admission policy as ``ADMIT_ON_SECOND_MISS'':

        $ {command} gs://my-bucket asia-south2-b --ttl=6h --admission-policy='ADMIT_ON_SECOND_MISS'
      )DESCRIPTIONEXAMPLESc                     UR                  S[        SS9  UR                  S[        SSS9  UR                  S[        R                  " 5       S	S9  [        R
                  " U5        g )
NurlzKSpecifies the URL of the bucket where the Anywhere Cache should be created.)typehelpzone+zUSpecifies the name of the zonal locations where the Anywhere Cache should be created.)r   nargsr   z--ttlz9Cache entry time-to-live. Default to 24h if not provided.)add_argumentstrr   Durationr   add_admission_policy_flag)clsparsers     5lib/surface/storage/buckets/anywhere_caches/create.pyArgsCreate.Args<   sz    
	   "   !!#H   
##F+    c              #     #    [         R                  " UR                  5      n[        R                  " UR
                  U5        [        R                  " U[        UR                  5      5        UR                  b  [        UR                  5      S-   Ul
        UR                   H/  n[        R                  " X4UR                  UR                  S9v   M1     g 7f)Ns)admission_policyttl)r	   storage_url_from_stringr   r   raise_error_if_not_gcs_bucketcommand_pathr   workload_estimator_callbacklenr   r'   r   r   CreateAnywhereCacheTaskr&   )selfargstask_status_queuer   r   s        r    get_task_iteratorCreate.get_task_iteratorY   s     

-
-dhh
7C--d.?.?E223tyy> xxTXXs"dh		&>>
d&;&;  s   CCc           
         [         R                  R                  5       nU R                  X5      n[        R
                  " U5      n[        R                  " USU[        R                  " [        R                  R                  S S9S9U l        g )NT)increment_typemanifest_path)parallelizabler0   progress_manager_args)r   multiprocessing_contextQueuer1   r   PluralityCheckableIteratorr
   execute_tasksr   ProgressManagerArgsIncrementTypeINTEGER	exit_code)r.   r/   r0   task_iterator!plurality_checkable_task_iterators        r    Run
Create.Runi   sv    +CCIIK**4CM$??N & #00)+)==&44<<D
	DNr#   )r?   N)__name__
__module____qualname____firstlineno____doc__detailed_helpclassmethodr!   r1   rB   __static_attributes__ r#   r    r   r      s4    5


-4 , ,8 r#   r   N)rH   googlecloudsdk.callioper   r   "googlecloudsdk.command_lib.storager   r   r   r   r	   (googlecloudsdk.command_lib.storage.tasksr
   r   r   @googlecloudsdk.command_lib.storage.tasks.buckets.anywhere_cachesr   DefaultUniverseOnlyCreateCommandr   rL   r#   r    <module>rS      sV    N / ( : 4 K A : B H @ g WT W Wr#   