
    c                         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 dd
lmZ e	j*                   G d dej,                  ej.                  ej0                               Zy)z1The command to disable Config Management Feature.    )absolute_import)division)unicode_literals)
exceptions)base)flags)	resources)utils)
console_ioc                       e Zd ZdZej
                  Zej
                  ZdZe	d        Z
 ej                  d      d        Zy)Disablea  Disable the Config Management feature.

  Disable the Config Management feature entirely, or disable specific
  configuration on the feature.

  `{command}` without flags deletes the Config Management feature,
  which unmanages and leaves existing Config Sync installations on membership
  clusters. Running the command without flags exits silently if the feature
  does not exist. Specify flags to disable configuration on parts of the feature
  without deleting it.

  ## EXAMPLES

  To disable the Config Management feature entirely, run:

    $ {command}

  To unmanage Config Sync only on select memberships, run:

    $ {command} --memberships=example-membership-1,example-membership-2
  Tc                 j   | j                   j                  |       |j                         }| j                  j                  |       |j	                  d      }|j                  dddd       |j                         }t        j                  |d       t        j                  j                  |       y	)
zAdds flags to the command.

    Args:
      parser: googlecloudsdk.calliope.parser_arguments.ArgumentInterceptor,
        Argument parser to add flags to.
    aA  Membership-specific flags. In the absence of `--uninstall`, using either `--memberships` or `--all-memberships` removes the entire configuration for the specified memberships, which unmanages and leaves existing Config Sync installations on the membership clusters. Unmanagement does not error if the feature is disabled.)helpz--uninstallstore_constTa.  Uninstall any previously-installed and managed Config Sync on the specified
memberships by setting the `enabled`
[field](https://cloud.google.com/kubernetes-engine/enterprise/config-sync/docs/reference/gcloud-apply-fields)
to false. Clears all other configuration for each membership. Does not wait for
the uninstallation to complete. To bypass the confirmation prompt, use
`--force`. Requires the feature to be enabled.

To uninstall Config Sync on select memberships, run:

  $ {command} --uninstall --memberships=example-membership-1,example-membership-2
)actionconstr   )pluralN)

FORCE_FLAGAddToParseradd_mutually_exclusive_group FLEET_DEFAULT_MEMBER_CONFIG_FLAG	add_groupadd_argumentr	   AddMembershipResourceArgr   ALL_MEMBERSHIPS_FLAG)clsparserpartial_disable_flag_groupmembership_disable_groupmemberships_groups        8lib/surface/container/fleet/config_management/disable.pyArgszDisable.Args?   s     NNv&!'!D!D!F((445OP9CCG  D    ))	 * " 1MMO&&'8F	**+<=    z	{message}c                    |j                   r| j                          yg }|j                  s|j                  s|j                  rt        j                  |dd      }|j                  r3| j                          |j                  st        j                  dd       |D ]  }|j                  r}| j                  |dg| j                  j                  | j                  j                  | j                  j                  | j                  j!                  d      	      
                   | j#                  |        |s| j%                  |j                         yy)a  Executes command logic.

    Disables parts of or the entire feature specified by args.

    Args:
      args: Flags specified in the call. The value associated with each flag
        is stored on an args field that is named after the flag with dashes
        replaced by underscores.
    Returns:
      None. In other words, completes without outputting the disabled or
        partially disabled Feature.
    Raises:
      api_lib.util.exceptions.HttpException: On HTTP errors from API calls,
        raises the exception without details to remove the stack trace.
        `gcloud info --show-log` shows the entire error to users who care.
    NT)promptsearchzaAbout to uninstall any previously-installed and managed Config Sync on the specified memberships.)messagecancel_on_nospecF)enabled)
configSync)configmanagement)r)   )fleet_default_member_configclear_fleet_default	uninstallmembershipsall_membershipsfeatures_baseParseMembershipsPlural
GetFeatureforcer   PromptContinueUpdateV2messages_v2MembershipFeatureFeatureSpecConfigManagementSpecConfigManagementConfigSyncDeleteV2r   )selfargsr0   
memberships       r!   RunzDisable.Runo   s=   $ ''
 K~~))T-A-A "88@D@DFk ~~ ooZZ!!= 	
 "
	j6(D,<,<,N,N!!--!%!1!1!F!F#//JJ %  K   "G " .  -O -
 	 	j! " 
ll4:: r#   N)__name__
__module____qualname____doc__r
   CONFIG_MANAGEMENT_FEATURE_NAMEfeature_namemf_namesupport_fleet_defaultclassmethodr"   gcloud_exception CatchHTTPErrorRaiseHTTPExceptionrA    r#   r!   r   r      s[    , 55,00'-> ->^ 544[A5 B5r#   r   N)rE   
__future__r   r   r   googlecloudsdk.api_lib.utilr   rK   googlecloudsdk.callioper   *googlecloudsdk.command_lib.container.fleetr   r	   <googlecloudsdk.command_lib.container.fleet.config_managementr
   3googlecloudsdk.command_lib.container.fleet.featuresr2   =googlecloudsdk.command_lib.container.fleet.membershipfeaturesmembershipfeatures_basegooglecloudsdk.core.consoler   DefaultUniverseOnlyDisableCommandDeleteCommandMixinUpdateCommandMixinr   rM   r#   r!   <module>r[      sh    8 &  ' F ( < @ N U i 2 E  ....E Er#   