
    ^)                         S r SSKJr  SSKJr  SSKJr  SSKrSSKJr  SSKJr	  SSK
Jr  SS	 jrS
 rSS jrS rS rS rS rS r    SS jrS rS rS rS rg)z+Library for retrieving declarative parsers.    )absolute_import)division)unicode_literalsN)arg_parsers)base)filesc                 F    U R                  SU[        R                  SSS9  g )Nz--path-zqPath of the directory or file to output configuration(s). To output configurations to stdout, specify "--path=-".)requiredtypedefaulthelp)add_argumentr   ExpandHomeAndVars)parserr   s     8lib/googlecloudsdk/command_lib/util/declarative/flags.pyAddPathFlagr      s.    ""C  E    c                 *    U R                  SSS/SS9  g )Nz--resource-formatkrm	terraformzFormat of the configuration to export. Available configuration formats are Kubernetes Resource Model YAML (krm) or Terraform HCL (terraform). Command defaults to "krm".)choicesr   r   r   s    r   AddFormatFlagr   '   s%    k":  <r   c                 D    U R                  SSSR                  U5      S9  g )Nz--all
store_truezRetrieve all resources within the {}. If `--path` is specified and is a valid directory, resources will be output as individual files based on resource name and scope. If `--path` is not specified, resources will be streamed to stdout.)actionr   )r   format)r   
collections     r   
AddAllFlagr!   0   s-    = >DVJ=O  	r   c                 ,    U R                  S/ SQSSS9  g )Nz
--on-error)continuehaltignorer%   a,  Determines behavior when a recoverable error is encountered while exporting a resource. To stop execution when encountering an error, specify "halt". To log errors when encountered and continue the export, specify "continue". To continue when errors are encountered without logging, specify "ignore".)r   r   r   r   r   s    r   AddOnErrorFlagr&   <   s%    ,A	  Cr   c                     [        U SSSS9  g )Nz+Project ID to list supported resources for.z0Organization ID to list supported resources for.z*Folder ID to list supported resources for.)project_helporg_helpfolder_help)_GetBulkExportParentGroupr   s    r   AddListResourcesFlagsr,   H   s    %!$&r   c                     U R                  SSSS9nUR                  S[        R                  " 5       SSS9  UR                  S	[        R                  " 5       S
SS9  g)z!Add resource-type flag to parser.TFz;`RESOURCE TYPE FILTERS` - specify resource types to export.mutexr   r   z--resource-typesRESOURCE_TYPEzList of Config Connector KRM Kinds to export.
  For a full list of supported resource types for a given parent scope run:

  $ {parent_command} list-resource-types --[project|organization|folder]=<PARENT>
  )r   metavarr   z--resource-types-fileRESOURCE_TYPE_FILEa  A comma (',') or newline ('\n') separated file containing the list of
      Config Connector KRM Kinds to export.
  For a full list of supported resource types for a given parent scope run:

  $ {parent_command} list-resource-types --[project|organization|folder]=<PARENT>
  N)	add_groupr   r   ArgListFileContents)r   groups     r   AddResourceTypeFlagsr7   S   sx    


H  %
  	   ##%"	  	r   c                     [        U 5        [        U 5        [        U 5        U R                  SSS9n[	        U5        UR                  SSSS9  [        U 5        g)	z'Adds flags for the bulk-export command.Ta  Select `storage-path` if you want to specify the Google Cloud Storage bucket bulk-export should use for Cloud Asset Inventory Export. Alternatively, you can provide a `RESOURCE TYPE FILTER` to filter resources. Filtering resources _does not_ use Google Cloud Storage to export resources.)r/   r   z--storage-pathFzGoogle Cloud Storage path where a Cloud Asset Inventory export will be stored, example: `gs://your-bucket-name/your/prefix/path`r   r   N)r&   r   r   r3   r7   r   r+   )r   resource_storage_mutexs     r   AddBulkExportArgsr;   o   sk    f!++* , 	 -.%%7 & 9 F#r   c                    SSK Jn  U R                  S5      (       ap  U R                  S5      (       aY  [        R                  R                  U R                  5      (       d*  UR                  SR                  U R                  5      5      eg g g )Nr   )declarative_client_baseallpathzIError executing export: "{}" must be a directory when --all is specified.)3googlecloudsdk.command_lib.util.declarative.clientsr=   IsSpecifiedosr?   isdirClientExceptionr   )argsr=   s     r   ValidateAllPathArgsrF      sq    Y	edii(@(@#33tyy)  )A r   c                     U R                  SUSS9nUR                  S[        US9  UR                  SUS9  UR                  S[        US9  U$ )	zCreates parent flags for resource export.

Args:
  parser:
  required:
  project_help:
  org_help:
  folder_help:

Returns:
  Mutext group for resource export parent.
Tzc`RESOURCE PARENT FLAG` - specify one of the following to determine the scope of exported resources.r.   z--organizationr   r   z	--projectr   z--folder)r3   r   str)r   r   r(   r)   r*   r6   s         r   r+   r+      si    & 

.	  % %Ch?[|4Zc<	,r   c           	      B   Sn[         R                  " S[        R                  US9n[         R                  " SSSS9n[         R                  " SS	9nUR                  [         R                  " S
S[        R                  SS95        UR                  [         R                  " SS[        R                  SS95        UR                  U5        UR                  [         R                  " SS[        R                  SS95        UR                  U 5        UR                  U 5        g)z@Arguments for resource-config terraform generate-import command.zPath to a Terrafrom formatted (.tf) resource file or directory of files exported via. `gcloud alpha resource-config bulk-export` or resource surface specific `config export` command.
INPUT_PATHrH   zOUTPUT DESTINATIONTz0Specify the destination of the generated script.)categoryr/   r   zJSpecify the exact filenames for the output import script and module files.rI   z--output-script-fileFzSpecify the full path path for generated import script. If not set, a default filename of the form `terraform_import_YYYYMMDD-HH-MM-SS.sh|cmd` will be generated.)r   r   r   z--output-module-filezSpecify the full path path for generated terraform module file. If not set, a default filename of `gcloud-export-modules.tf` will be generated.z--output-dirzSpecify the output directory only for the generated import script. If specified directory does not exists it will be created. Generated script will have a default name of the form `terraform_import_YYYYMMDD-HH-MM-SS.sh|cmd`N)calliope_baseArgumentr   r   ArgumentGroupAddArgumentAddToParser)r   input_path_help
input_pathoutput_argsfile_spec_groups        r   AddTerraformGenerateImportArgsrW      s    ;  %%00H* ++#=?+
 "/// 
 &&O	 
 &&$	 /*-00"":	< =  &!r   c                 N   [         R                  " SSSS9n[         R                  " SSSS9nU R                  SSSS	9nUR                  S
SSSSS9  UR                  SS9nUR                  SSSSSS9  UR                  SSSS9  UR	                  U 5        UR	                  U 5        g)zAdd args for init provider.z--zoneFzyDefault Google Cloud Zone for Zonal Resources.
        If not specified the current `compute/zone` property will be used.r9   z--regionz~Default Google Cloud Region for Regional Resources.
      If not specified the current `compute/region` property will be used.aT  The below flags specify how the optional `user_project_override` and `billing_project` settings are configured for the Google Terraform Provider.
      See the [Google Terraform Provider Config Reference](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#user_project_override) for more details.T)r   r   r/   z--use-gcloud-billing-projectr   zIf specified, will set `user_project_override` value in the Terrafom provider config to `true` and
      set `billing_project` to the current gcloud `billing/quota_project` property.)r   r   r   r   zAccount Override Flags.rI   z--tf-user-project-overridez`If specified, sets the `user_project_override` value in the Terraform provider config to `true`.z--tf-billing-projectzPIf specified, sets the `billing_project` value in the Terraform provider config.)r   r   N)rN   rO   r3   r   rR   )r   zoneregionbilling_groupbilling_account_groups        r   AddInitProviderArgsr]      s   			N
O$ !!NO& ""F	 # - $W   (11$ 2 &$$"q %  $$a % 
 6Vr   c                 $    U R                  SSS9  g )NPATHz9File or directory path containing the resources to apply.rI   r   r   s    r   AddApplyPathArgr`      s    G  Jr   c                 *    U R                  SSSSSS9  g )Nz--resolve-referencesr   FTzIf True, any resource references in the target file PATH will be resolved, and those external resources will be applied as well.)r   r   hiddenr   r   r   s    r   AddResolveResourcesArgrc   &  s(    N  Pr   )F)r    )Fz
Project IDzOrganization IDz	Folder ID)__doc__
__future__r   r   r   rB   googlecloudsdk.callioper   r   rN   googlecloudsdk.core.utilr   r   r   r!   r&   r,   r7   r;   rF   r+   rW   r]   r`   rc    r   r   <module>ri      sw    2 &  ' 	 0 9 *E<			C&8$6	 B7"t+^JPr   