
                  	          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	KJr  SS
KJr  SSKJr  SSKJ
r  SSKJ
r  SSKJr  Sr\
R,                  " \
R.                  R0                  \
R.                  R2                  5      \
R4                   " S S\R6                  \R6                  \R8                  5      5       5       rg)z0The command to update Config Management Feature.    )absolute_import)division)unicode_literalsN)api_lib)core)base)	resources)command)utils)converta  
    To apply the [fleet-default membership configuration](https://cloud.google.com/kubernetes-engine/fleet-management/docs/manage-features)
    to `MEMBERSHIP_NAME`, run:

    $ {command} --membership=MEMBERSHIP_NAME --origin=FLEET

    To apply a membership configuration as a YAML file, prepare
    [apply-spec.yaml](https://cloud.google.com/anthos-config-management/docs/reference/gcloud-apply-fields#example_gcloud_apply_spec) then run:

      $ {command} --membership=MEMBERSHIP_NAME --config=APPLY-SPEC.YAML --version=VERSION
c                   x    \ rS rSrSrS\0r\R                  r	\R                  r
\S 5       rS rS rS rS rS	rg
)Apply/   zUpdate a Config Management feature spec.

Update a membership configuration for the Config Management feature in a
fleet. This command errors if the Config Management feature is not enabled on
the fleet.
EXAMPLESc                     [         R                  " U5        UR                  SSSS9nUR                  SS/SS9  UR                  SS	9nUR                  S
SSS9  UR                  SSS	9  g )NTa  Update the membership configuration either to the [fleet-default membership configuration](https://cloud.google.com/kubernetes-engine/fleet-management/docs/manage-features) with `--origin` or to a user-provided configuration with `--config` and `--version`.)requiredmutexhelpz--originFLEETa)  Updates the configuration of the target membership to the current [fleet-default membership configuration](https://cloud.google.com/kubernetes-engine/fleet-management/docs/manage-features). Errors if fleet-default membership configuration is not enabled; see the `enable` command for more details.)choicesr   zVProvide the entire membership configuration to update with `--config` and `--version`.)r   z--configzPath to YAML file that contains the configuration to update the target membership to. The file accepts the [following fields](https://cloud.google.com/anthos-config-management/docs/reference/gcloud-apply-fields).)r   r   z	--versiona  Version of Config Management. Equivalent to the [`spec.version`](https://cloud.google.com/anthos-config-management/docs/reference/gcloud-apply-fields#common) field in the `--config` file. Provides `--config` with a version in the absence of `spec.version`. Cannot specify this flag without `--config`; cannot set both this flag and `spec.version`. See [`spec.version`](https://cloud.google.com/anthos-config-management/docs/reference/gcloud-apply-fields#common) for more details.)r	   AddMembershipResourceArg	add_groupadd_argument)clsparser
spec_groupconfig_groups       6lib/surface/container/fleet/config_management/apply.pyArgs
Apply.Args>   s    &&v.!!- " J 	E   ''- ( L '   #      c                 t   S U l         [        R                  " USSSS9U l        U R                  R                  5       nUR                  (       aH  U R                  R                  U R                  R                  R                  R                  S9Ul        GOU R                  UR                  5      nUR                  (       aT  UR                  (       aC  [        R                  R                  SR!                  UR                  UR                  5      5      eUR                  (       a  UR                  Ul        UR                  (       dX  UR"                  U R                  R$                  R&                  R(                  :w  a   U R+                  U R                  5      Ul        X2l        U R/                  U5        g )NT)prompt
autoselectsearch)typezaCannot set version in multiple flags: --version={} and the version field in --config has value {})_Apply__feature_cache
fleet_baseParseMembership
membershipmessagesMembershipFeatureSpecoriginOriginTypeValueValuesEnumr   parse_config_managementconfigversionr   
exceptionsErrorformat
managementConfigManagementMembershipSpecManagementValueValuesEnumMANAGEMENT_AUTOMATIC_get_backfill_versionconfigmanagement_update_membership)selfargsfeature_speccms       r   Run	Apply.Runq   s3   D 00Td4DO ==668L{{ MM00}}##77== 1 l ''4b	oo##..4fT\\2::.N
 	
 
\\
jj
--
--
6
6
P
P
e
ef//@
&(#L)r!   c                 ^    U R                   c  U R                  5       U l         U R                   $ )zuGets the Config Management feature at most once per command execution.

Returns:
  Cached Config Management feature.
)r'   
GetFeature)r=   s    r   _get_feature_cacheApply._get_feature_cache   s+     #!__.dr!   c                 N    U R                  5       n[        R                  " X!5      $ )a  Get the value the version field in FeatureSpec should be set to.

Args:
  membership: The full membership  name whose Spec will be backfilled.

Returns:
  version: A string denoting the version field in MembershipConfig
Raises: Error, if retrieving FeatureSpec of FeatureState fails
)rE   r   !get_backfill_version_from_feature)r=   r*   fs      r   r:   Apply._get_backfill_version   s#     	!A221AAr!   c           	           UR                   (       dJ  [        R                  " X R                  U R                  U5      nU R                  U R                  S/U5      $ U R                  S/U R                  R                  U R                  R                  U R                  U05      S95      $ ! [        R                  R                  R                  R                   a/  n[         R"                  R                  R%                  US5      eSnAff = f)zUpdate the spec of the target membership to feature_spec.

Args:
  feature_spec: gkehub API MembershipFeatureSpec to update to.

Returns:
  Updated feature or membership feature, for projects migrated to v2 by Hub.
specmembership_specs)membershipSpecsz	{message}N)r-   r   ToV2MembershipFeaturer*   mf_nameUpdateV2Updater+   Feature	hubclientToMembershipSpecsapitoolsr   pyr3   	HttpErrorr   utilHttpException)r=   r?   membershipfeaturees       r   r<   Apply._update_membership   s    B  #99//4<<
 }}T__vh8IJJ{{./1F1F NN<<>  2G 2
  	
 ==&&00 BLL##11![AABs   AB, AB, ,2D*DD)__feature_cacher*   N)__name__
__module____qualname____firstlineno____doc__r   detailed_helpr   CONFIG_MANAGEMENT_FEATURE_NAMEfeature_namerP   classmethodr   rA   rE   r:   r<   __static_attributes__ r!   r   r   r   /   sR     x(-55,00'0 0d*<	 BBr!   r   )rc   
__future__r   r   r   rV   googlecloudsdkr   r   googlecloudsdk.callioper   *googlecloudsdk.command_lib.container.fleetr	   <googlecloudsdk.command_lib.container.fleet.config_managementr
   r   3googlecloudsdk.command_lib.container.fleet.featuresr(   =googlecloudsdk.command_lib.container.fleet.membershipfeaturesmf_baser   r   ReleaseTracksReleaseTrackALPHABETADefaultUniverseOnlyUpdateCommandCommonr   ri   r!   r   <module>ry      s    7 &  '  "  ( @ P N R Y Q
 D%%++T->->-C-CDLBJ$$g&;&;W^^ LB  ELBr!   