
                         D   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 ej&                   ej(                  ej*                  j,                  ej*                  j.                         G d dej0                                      Zy)z*Initialize a Backup and DR Service Config.    )absolute_import)division)unicode_literals)
exceptions)util)ServiceConfigClient)base)flags)logc                   4    e Zd ZdZdddddZed        Zd Zy	)
Initz1Initialize a Backup and DR Service configuration.z2Initializes a Backup and DR Service configuration.z{description}zThis command uses the backupdr/v1 API. The full documentation for this API can be found at: https://cloud.google.com/backup-disaster-recoverya           To initialize a new service configuration in location ``MY_LOCATION''
        and project ``MY_PROJECT'' for resource type ``MY_RESOURCE_TYPE'', run:

        $ {command} --project=MY_PROJECT             --location=MY_LOCATION             --resource-type=MY_RESOURCE_TYPE
        )BRIEFDESCRIPTIONzAPI REFERENCEEXAMPLESc                     t        j                  |        t        j                  | d       t        j                  | d       y)zySpecifies additional command flags.

    Args:
      parser: argparse.Parser: Parser object for command line inputs.
    zCThe location for which the service configuration should be created.zThe resource type to which the default service configuration
           will be applied. Examples include, "compute.<UNIVERSE_DOMAIN>.com/Instance"
N)r
   AddNoAsyncFlagAddLocationResourceArgAddResourceType)parsers    ,lib/surface/backup_dr/service_config/init.pyArgsz	Init.Args5   s>     
 	  Q 
	    c           	      |   t               }|j                  j                  j                         j	                         }|j
                  }|j                  }	 |j                  ||      }|rQ|j                  |j                  |      dj!                  ||      d      }t#        j$                  d|ddddd       |S t#        j$                  d|dd	t        j&                  j!                  |j(                        d
       |S # t        j                  $ r)}t        j                  |t        j                        d}~ww xY w)zConstructs and sends request.

    Args:
      args: argparse.Namespace, An object that contains the values for the
        arguments specified in the .Args() method.

    Returns:
      ProcessHttpResponse of the request made.
    NzxInitializing service configuration for resource type [{}] in location [{}]. (This operation could take up to 2 minutes.)F)operation_refmessage
has_resultz'Initialization of service configurationlocationz%Service configuration initialized for)kindis_asyncdetailsfailedoperation_past_tenseT)r   r   r    r!   )r   CONCEPTSr   ParseRelativeNameresource_typeno_asyncr   apitools_exceptions	HttpErrorr   HttpExceptionr   HTTP_ERROR_FORMATWaitForOperationGetOperationRefformatr   _PrintResourceChangeASYNC_OPERATION_MESSAGEname)	selfargsclientr   r&   r'   	operationeresources	            r   RunzInit.RunH   s7    !"F}}%%++-::<H&&M}}H@++

i ((..y9MvmX. ) h 

3
F o 1,,33INNC K (( @$$Q(>(>??@s   C? ?D;$D66D;N)__name__
__module____qualname____doc__detailed_helpstaticmethodr   r8    r   r   r   r      s:     : D$?-$  $9r   r   N)r<   
__future__r   r   r   apitools.base.pyr   r(   googlecloudsdk.api_lib.backupdrr   .googlecloudsdk.api_lib.backupdr.service_configr   googlecloudsdk.api_lib.utilgooglecloudsdk.callioper	   #googlecloudsdk.command_lib.backupdrr
   googlecloudsdk.corer   DefaultUniverseOnlyReleaseTracksReleaseTrackALPHAGACommandr   r?   r   r   <module>rN      s    1 &  ' > 0 N 2 ( 5 # D%%++T->->-A-ABa4<< a C ar   