
    S                     X    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Z
d	 Zd
 Zy)zJConvenience utilities for building python calliope config export commands.    )absolute_import)division)unicode_literals)flags)
kcc_clientNc                 X   |xs dj                  |       }| }|rdj                  ||       }d}|rd}dj                  | j                         j                               }dj                  ||      dj                  | j	                         |||	      d
j                  | |||      d}|S )z=Builds and returns help text for declarative export commands.z{}sz{} {}aan-z?Export the configuration for {a_or_an} {singular_with_service}.)a_or_ansingular_with_servicea               *{{command}}* exports the configuration for {a_or_an} {singular_with_service}.

            {singular_capitalized} configurations can be exported in
            Kubernetes Resource Model (krm) or Terraform HCL formats. The
            default format is `krm`.

            Specifying `--all` allows you to export the configurations for all
            {plural} within the project.

            Specifying `--path` allows you to export the configuration(s) to
            a local directory.
          )singular_capitalizedr   pluralr   aQ              To export the configuration for {a_or_an} {singular}, run:

              $ {{command}} my-{resource_name}

            To export the configuration for {a_or_an} {singular} to a file, run:

              $ {{command}} my-{resource_name} --path=/path/to/dir/

            To export the configuration for {a_or_an} {singular} in Terraform
            HCL format, run:

              $ {{command}} my-{resource_name} --resource-format=terraform

            To export the configurations for all {plural} within a
            project, run:

              $ {{command}} --all
          )singularr   resource_namer   )briefDESCRIPTIONEXAMPLES)formatjoinlowersplit
capitalize)r   r   servicebegins_with_vowelr   r   r   detailed_helps           Flib/googlecloudsdk/command_lib/util/declarative/python_command_util.pyBuildHelpTextr      s     +U\\(+& ##NN7H= 'G((8>>+1134- L6'9N6O f#+#6#6#8$9	  $ f)	  S.-^ 
    c                     | j                  dd      }|j                         } ||fi | t        j                  |d       t        j                  |        t        j                  |        y )NT)mutexrequiredproject)
collection)	add_groupdeclarative_config_flags
AddAllFlagAddPathFlagAddFormatFlag)parseradd_to_parserkwargsmutex_groupresource_groups        r   RegisterArgsr/   ]   s^      td ;+((*.)&)%%kiH&&v.((0r   c                     t        j                         }t        | dd       r|j                  | |      S |j	                  | |      S )Nall)argsr$   )resource_uri)r   	KccClientgetattr	ExportAllExport)r2   r$   resource_refclients       r   	RunExportr:   f   sE    !&T5$*==	t,	77r   )NNF)__doc__
__future__r   r   r   +googlecloudsdk.command_lib.util.declarativer   r&   3googlecloudsdk.command_lib.util.declarative.clientsr   r   r/   r:    r   r   <module>r@      s+    Q &  ' Y JAH18r   