
    d                        d Z ddlmZ ddlmZ ddlmZ ddl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ZdZdj/                  ee      Zdez   ddZej4                  j7                  ej4                  j9                  e      dd      Z ej>                  e      Z  ejB                  ejD                  jF                         G d dejH                               Z%y)zDCommand for generating main.tf file to configure Terraform Provider.    )absolute_import)division)unicode_literalsN)base)flags)log)
properties)
console_io)progress_tracker)files)runtime)templatez0.2zv3.90.0z\This command supports Google Terraform Provider version {}+ and Terraform Provider Schema {}z{description}

        a  
    To generate a `main.tf` file in the current directory using the gcloud default values for `zone`, `region` and `project` run:

      $ {command}

    To generate a `main.tf` file in the current directory using the user suppplied values for `zone`, `region` and `project` run:

      $ {command}  --project="my-project-id" --region="us-central1" --zone="us-central1-c

    To generate a `main.tf` file in the current directory using the gcloud default `billing_project` run:

      $ {command} --use-gcloud-billing-project

    To generate a `main.tf` file in the current directory using user specified `billing_project` value run:

      $ {command} --tf-user-project-override --tf-billing-project="my-other-project-id"
   )DESCRIPTIONEXAMPLES	templateszmain_tf.tpl)filenamec                   0    e Zd ZdZeZd Zed        Zd Z	y)InitProviderzCGenerate main.tf file to configure Google Cloud Terraform Provider.c                     |j                   }dx}}|r8t        j                  j                  j                  j                         }d}||fS |j                  r|j                  }d}||fS )zDProcess billing project flags in args and return Terraform settings.Ntrue)use_gcloud_billing_projectr	   VALUESbillingquota_projectGettf_user_project_overridetf_billing_project)selfargs_namspaceuse_gcloud_billinguser_project_overridebilling_projects        6lib/surface/resource_config/terraform/init_provider.py_GetBillingParamszInitProvider._GetBillingParamsN   sv    &AA.22O"))11??CCEo$ !/11 
	/	/%88o$ /11    c                 .    t        j                  |       y )N)r   AddInitProviderArgs)clsparsers     r#   ArgszInitProvider.ArgsZ   s    	f%r%   c                    | j                  |      \  }}|j                  xs2 t        j                  j                  j                  j                         }|j                  xs2 t        j                  j                  j                  j                         }|j                  xs2 t        j                  j                  j                  j                         }|||||d}t        j                  j                  t        j                         d      }t        j                  j                  |      r(t        j                   dj#                  |      ddd       t%        j&                  d      5  t        j(                  |d	      5 }	t+        j,                  |	fi |}
t.        j1                  |
       d d d        d d d        t2        j4                  j7                  d
j#                  |             y # 1 sw Y   AxY w# 1 sw Y   ExY w)N)projectregionzoneuser_overrider"   zmain.tfz
{} Exists.z
Overwrite?TzInit Provider cancelled.)prompt_stringcancel_on_nocancel_stringzCreating Terraform init module)create_pathz%Created Terraform module file {path}.)path)r$   r,   r	   r   corer   r-   computer.   osr4   joinr   GetCWDisfiler
   PromptContinueformatr   ProgressTracker
FileWriterr   ContextINIT_FILE_TEMPLATErender_contextr   statusPrint)r   argsdo_overrider"   r,   r-   r.   template_contextr4   fctxs              r#   RunzInitProvider.Run^   s   #'#9#9$#? KllBj//44<<@@BG[[BJ--55<<@@BF99<
))1166::<D$* 77<<	2D	ww~~d 3 3D 9.:-1.HJ 
	)	)*J	KDd3qooa4#34))#. 4 
L JJ<CCCNO 43 
L	Ks$   +G;,G//G;/G8	4G;;HN)
__name__
__module____qualname____doc___DETAILED_HELPdetailed_helpr$   classmethodr*   rI    r%   r#   r   r   H   s)    K -
2 & &Pr%   r   )&rM   
__future__r   r   r   r7   googlecloudsdk.callioper   +googlecloudsdk.command_lib.util.declarativer   googlecloudsdk.corer   r	   googlecloudsdk.core.consoler
   r   googlecloudsdk.core.utilr   makor   r   _SCHEMA_VERSION_MIN_PROVIDER_VERSIONr<   _SUPPORTED_MSGrN   r4   r8   dirname__file___INIT_TEMPLATE_NAMETemplater@   ReleaseTracksReleaseTrackALPHADeclarativeCommandr   rQ   r%   r#   <module>rd      s    K &  ' 	 ( = # * 2 8 *   ! ::@&+_;> 			2 ggllGGOOH{M;  'X&&0CD  D%%++,+P4** +P -+Pr%   