
                             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 ddlmZ dd
lmZ  G d dej(                        Zy)z"Import autoscaling policy command.    )absolute_import)division)unicode_literals)
exceptions)dataproc)util)base)flags)
console_ioc                   &    e Zd ZdZed        Zd Zy)Importa  Import an autoscaling policy.

  If the specified autoscaling policy already exists, it will be overwritten.
  Otherwise, a new autoscaling policy will be created.
  To edit an existing autoscaling policy, you can export the autoscaling policy
  to a file, edit its configuration, and then import the new configuration.

  This command does not allow output only fields, such as policy id and resource
  name. It populates the id field based on the resource name specified as the
  first command line argument.

  ## EXAMPLES

  The following command creates or updates the contents of autoscaling policy
  `example-autoscaling-policy` based on a yaml file:

    $ {command} example-autoscaling-policy --source=saved-policy.yaml
  c                     t        j                  | j                               }t        j                  |d|j
                         t        j                  |       y )Nimport)dpDataprocReleaseTrackr
   AddAutoscalingPolicyResourceArgapi_versionexport_utilAddImportFlags)clsparserr   s      3lib/surface/dataproc/autoscaling_policies/import.pyArgszImport.Args2   sC    {{3++-.H	))&(*2*>*>@v&    c                 H   t        j                  | j                               }|j                  j                  j                         }t        j                  ||j                         |j                        }	 t        j                  ||j                         |      S # t        j                  $ rp}|j                  dk7  r|t        j                   dj#                  |j$                        d       t        j&                  ||j                         |      cY d }~S d }~ww xY w)N)r   	policy_idpolicy_file_namei  z-Autoscaling policy [{0}] will be overwritten.T)messagecancel_on_no)r   r   r   CONCEPTSautoscaling_policyParser   ReadAutoscalingPolicyNamesourceCreateAutoscalingPolicyRelativeNameapitools_exceptions	HttpErrorstatus_coder   PromptContinueformatidUpdateAutoscalingPolicy)selfargsr   
policy_refpolicyerrors         r   Runz
Import.Run:   s    {{4,,./H11779J''//#&F
2))(J4K4K4M*02 2(( 
2			c	!BJJii ))(J4K4K4M*02 2
2s   9$B D!1A%DD!D!N)__name__
__module____qualname____doc__classmethodr   r5    r   r   r   r      s     & ' '2r   r   N)r9   
__future__r   r   r   apitools.base.pyr   r)   googlecloudsdk.api_lib.dataprocr   r   r   googlecloudsdk.callioper	   #googlecloudsdk.command_lib.dataprocr
   !googlecloudsdk.command_lib.exportr   googlecloudsdk.core.consoler   Commandr   r;   r   r   <module>rD      s8    ) &  ' > : 0 ( 5 A 212T\\ 12r   