
                         J   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Z e
j                   e
j"                  j$                  e
j"                  j&                         G d
 dej(                  ej*                  ej,                               Zy)z0The command to enable Config Management feature.    )absolute_import)division)unicode_literalsN)api_lib)core)base)commandc                   0    e Zd ZdZdZed        Zd Zd Zy)Enablead  Enable Config Management feature.

  Enables the Config Management feature in a fleet.
  Without any flags, this command no-ops if the feature is already enabled.
  This command can also enable the feature with a [fleet-default membership
  configuration](https://cloud.google.com/kubernetes-engine/fleet-management/docs/manage-features)
  for Config Sync.

  ## EXAMPLES

  To enable the Config Management feature, run:

    $ {command}

  To enable the Config Management feature with a fleet-default membership
  configuration for Config Sync, run:

    $ {command} --fleet-default-member-config=config.yaml
  configmanagementc                 *    |j                  dd       y )Nz--fleet-default-member-configa  Path to YAML file that contains the [fleet-default membership configuration](https://cloud.google.com/kubernetes-engine/fleet-management/docs/manage-features) to enable with a new feature. This file shares the syntax of the `--config` flag on the `apply` command: see recognized fields [here](https://cloud.google.com/kubernetes-engine/enterprise/config-sync/docs/reference/gcloud-apply-fields). Errors if the Policy Controller or Hierarchy Controller field is set. This flag will also enable or update the fleet-default membership configuration on an existing feature. See the `apply` command for how to sync a membership to the fleet-default membership configuration.)help)add_argument)clsparsers     7lib/surface/container/fleet/config_management/enable.pyArgszEnable.Args8   s    
'9      c                     	 | j                  |      }y # t        j                  j                  j                  j
                  $ r0}t        j                  j                  j                  |d      d }~ww xY w)Nz	{message})error_format)	enable_feature_with_fdcapitoolsr   py
exceptions	HttpErrorr   utilHttpException)selfargs_es       r   Runz
Enable.RunK   s`    O

&
&t
,a==&&00 OLL##11!+1NNOs    1A5+A00A5c                    | j                   j                         }|j                  rP| j                  |j                        }| j                   j	                  |      |_        	 | j                  dg|      S | j                  |      S # t        j                  j                  $ rD}t        j                  |      t        j                  | j                               k7  r Y d}~md}~ww xY w)zEnable feature and fleet-default membership configuration, if specified.

    Args:
      args: Command arguments.
    Returns:
      Enabled or updated GKE Hub Feature.
    )r   fleet_default_member_configN)messagesFeaturer$   parse_config_management"CommonFleetDefaultMemberConfigSpecfleetDefaultMemberConfigUpdater   r   Errorsix	text_typeFeatureNotEnabledErrorr   )r   r   featurespecr!   s        r   r   zEnable.enable_feature_with_fdcR   s     mm##%G''))$*J*JKd
--
:
:# ;  &
{{9:GDD ;;w __"" ==s}}T-H-H-JKK
 Ls   $B C)%:C$$C)N)	__name__
__module____qualname____doc__feature_nameclassmethodr   r"   r    r   r   r   r      s+    ( $, $O r   r   )r4   
__future__r   r   r   r   googlecloudsdkr   r   googlecloudsdk.callioper   <googlecloudsdk.command_lib.container.fleet.config_managementr	   3googlecloudsdk.command_lib.container.fleet.featuresfeatures_baser,   ReleaseTracksReleaseTrackALPHABETAEnableCommandUpdateCommandCommonr   r7   r   r   <module>rE      s    7 &  '  "  ( P U 
 D%%++T->->-C-CDH ]((((^^H  EH r   