
    E                     ,   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 dd	lmZ e	j                   e	j                   e	j"                  j$                  e	j"                  j&                         G d
 de	j(                                      Zy)z*Create command for Backup for GKE restore.    )absolute_import)division)unicode_literals)util)base)hooks)resource_args)labels_utilc                   &    e Zd ZdZed        Zd Zy)Createa  Creates a restore.

  Creates a Backup for GKE restore.

  ## EXAMPLES

  To create a restore ``my-restore'' in location ``us-central1'' under restore
  plan ``my-restore-plan'', run:

    $ {command} my-restore --project=my-project --location=us-central1
    --restore-plan=my-restore-plan
    --backup=projects/my-project/locations/us-east1/backupPlans/my-backup-plan/backups/my-backup
  c                    t        j                  |        | j                  d      }|j                  ddddd       |j                  ddddd	       | j                  d
t        dd       | j                  dt        dd d       | j                  ddd d       | j                  ddd d       t        j                  |        y )NT)mutexz--asyncF
store_truezh
        Return immediately, without waiting for the operation in progress to
        complete.
        )requiredactiondefaulthelpz--wait-for-completionz)Wait for the created restore to complete.z--backupz
        Name of the backup from which to restore under the backup plan specified
        in restore plan.
        Format: projects/<project>/locations/<location>/backupPlans/<backupPlan>/backups/<backup>.
        )typer   r   z--descriptionz*Optional text description for the restore.)r   r   r   r   z+--volume-data-restore-policy-overrides-filez
        If provided, defines an array of volume data restore policy overrides
        from the given config file in yaml.
        )r   r   r   z--filter-filea  
        JSON/YAML file containing the configuration of the fine-grained
        restore filter which can be used to further refine the resource
        selection of the Restore beyond the coarse-grained scope defined
        in the RestorePlan.

        For more information about examples and how to use this filter,
        please refer to the Backup for GKE documentation:
        https://cloud.google.com/kubernetes-engine/docs/add-on/backup-for-gke/how-to/fine-grained-restore.
        )r	   AddRestoreArg	add_groupadd_argumentstrr
   AddCreateLabelsFlags)parsergroups     7lib/surface/container/backup_restore/restores/create.pyArgszCreate.Args-   s   '4(E	  	 
8   	  	 9   5	   		   $$V,    c                 :   t        j                  |      }t        j                  |j                        }|j
                  j                  j                         }t        j                  |j                        }|j                  d      r/t        j                  ||j                  |j                  |||      S t        j                  ||j                  |j                  |||       |j                  d      sg S t        j                   |j#                               S )Nasync)backupdescriptionlabels$volume_data_restore_policy_overridesrestore_filter)restore_refr!   r"   r#   r$   r%   wait_for_completion)r
   GetUpdateLabelsDictFromArgsr   (ReadVolumeDataRestorePolicyOverridesFile)volume_data_restore_policy_overrides_fileCONCEPTSrestoreParseReadRestoreFilterFilefilter_fileIsSpecifiedapi_utilCreateRestorer!   r"   CreateRestoreAndWaitForLROWaitForRestoreToFinishRelativeName)selfargsr#   vdrpor&   r%   s         r   Runz
Create.Runq   s    44T:F::66E --''--/K001A1ABN ##
&&/4'  ''{{$$-2% 12i**;+C+C+EFFr   N)__name__
__module____qualname____doc__staticmethodr   r9    r   r   r   r      s$     A- A-FGr   r   N)r=   
__future__r   r   r   /googlecloudsdk.api_lib.container.backup_restorer   r1   googlecloudsdk.callioper   3googlecloudsdk.command_lib.container.backup_restorer   r	   $googlecloudsdk.command_lib.util.argsr
   DefaultUniverseOnlyReleaseTracksReleaseTrackALPHABETACreateCommandr   r?   r   r   <module>rK      s    1 &  ' L ( E M < D%%++T->->-C-CDmGT mG E mGr   