
    ['                        S 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S	KJr  \	R(                  " \	R*                  R,                  \	R*                  R.                  5       " S
 S\R0                  \R2                  5      5       r\	R(                  " \	R*                  R6                  5       " S S\5      5       rg)z2The command to view the Config Management Feature.    N)
transforms)util)
exceptions)base)	resources)utils)logc                   H    \ rS rSrSr\R                  r\R                  rSr	g)Describe   'Describe the Config Management feature. N)
__name__
__module____qualname____firstlineno____doc__r   CONFIG_MANAGEMENT_FEATURE_NAMEfeature_namemf_name__static_attributes__r       9lib/surface/container/fleet/config_management/describe.pyr   r      s     055,00'r   r   c                   |    \ rS rSrSrSS0r\S 5       r\S 5       r	\
R                  " S5      S 5       rS	 rS
 rSrg)DescribeAlpha+   r   EXAMPLESa  
To describe the entire Config Management feature, run:

  $ {command}

To describe select membership configurations, run:

  $ {command} --memberships=example-membership-1,example-membership-2

To list the membership configurations, run:

  $ {command} --view=list

MEMBERSHIP           | LOCATION    | STATUS | INSTALL_STATE             | STOP_STATE  | SYNC_STATE    | VERSION | SYNCED_TO_FLEET_DEFAULT
-------------------- | ----------- | ------ | ------------------------- | ----------- | ------------- | ------- | ----------------------------
example-membership-1 | asia-east1  | OK     | CONFIG_SYNC_NOT_INSTALLED |             | NOT_INSTALLED |         | FLEET_DEFAULT_NOT_CONFIGURED
example-membership-2 | us-central1 | OK     | CONFIG_SYNC_INSTALLED     | NOT_STOPPED | SYNCED        | 1.22.0  | FLEET_DEFAULT_NOT_CONFIGURED
example-membership-3 | us-central1 | ERROR  | CONFIG_SYNC_INSTALLED     | NOT_STOPPED | ERROR         | 1.21.3  | FLEET_DEFAULT_NOT_CONFIGURED
      c                 h   Xl         UR                  5       nUR                  SSSSS.SSS9  UR                  [        R                  S	S
9n[
        R                  " [        R                  5      nUR                  S   R                  5       S-   UR                  S'   UR                  U5        [
        R                  " [        R                  5      nUR                  S   R                  5       S-   UR                  S'   UR                  U5        UR                  SS9n[        R                  " USS9  g )Nz--viewzView of the feature.z(Default view. Prints the entire feature.a  
List of membership configurations. Default format is a table summary.

The `SYNCED_TO_FLEET_DEFAULT` column may display `UNKNOWN` for any membership
whose configuration has not been updated since the
[fleet-default membership configuration](https://cloud.google.com/kubernetes-engine/fleet-management/docs/manage-features)
enablement.

To view the underlying configurations instead of the table summary for select
memberships, run:

  $ {command} --view=list --format=yaml --memberships=example-membership-1,example-membership-2
            )fulllistr   T)helpchoicesdefaultrequiredz\List command flags. Only specify when `--view=list`. Does not include support for `--limit`.)categoryr!   r!   a>  

To filter for memberships with an overall status of `ERROR`, use the
``COLUMN~VALUE'' pattern and run:

  $ {command} --view=list --filter=STATUS~ERROR

To filter for memberships that are synced to the
fleet-default membership configuration, run:

  $ {command} --view=list --filter="spec.origin.type.synced_to_fleet_default()~YES"

`SYNCED_TO_FLEET_DEFAULT` is the only column that requires filtering on the
underlying configuration field instead of the column name. An alternative is to
`--sort-by=SYNCED_TO_FLEET_DEFAULT` and filter by eye.

To filter on a configuration field not in the table summary, in this case the
Config Sync repo, run:

  $ {command} --view=list --format=yaml --filter="spec.configmanagement.configSync.git.syncRepo~https://github.com/GoogleCloudPlatform/anthos-config-management-samples.git"
        a  

The default table summary sorts by `LOCATION` then `MEMBERSHIP`.

To sort the table by `VERSION` instead, run:

  $ {command} --view=list --sort-by=VERSION

To sort by a configuration field not in the table summary, in this case the
Config Sync repo, and print its values in a table, run:

  $ {command} --view=list --sort-by="spec.configmanagement.configSync.git.syncRepo" --format="table(MEMBERSHIP,LOCATION,spec.configmanagement.configSync.git.syncRepo:label=REPO)"
        zyMemberships to print configurations for. Errors if a specified membership does not have a configuration for this feature.)r!   )plural)parser	add_groupadd_argumentr   LIST_COMMAND_FLAGScopydeepcopyFILTER_FLAGkwargsrstripAddToParserSORT_BY_FLAGr   AddMembershipResourceArg)clsr'   
view_group
list_groupfilter_with_examplessort_by_with_examplesmemberships_groups          r   ArgsDescribeAlpha.ArgsE   sD   J!!#J#>
  )  . %%((7 & J  ==)9)9:##F+224 8 	 '. $$Z0 MM$*;*;<$$V,335 9 	   ( %%j1((! )  &&'8Fr   c                     U R                   (       d  U R                  (       a'  U R                  S:w  a  [        R                  " S5      eg g )Nr    z>--filter and --sort-by can only be specified when --view=list.)filtersort_byviewr   Errorargss    r   enforce_flag_combinations'DescribeAlpha.enforce_flag_combinations   s7    t||f)<
J  *=|r   z	{message}c                    Xl         U R                  U5        U R                  5       nUR                  (       a&  [        R
                  " USS9nU R                  X#5        UR                  S:X  a  U R                  R                  R                  [        R                  " U R                  UR                  S L5      5        U R                  R                  R                  S5        U R!                  U5      $ U$ )NT)searchr    a5  table(
          name.segment(-3):label=MEMBERSHIP:sort=2,
          name.segment(-5):label=LOCATION:sort=1,
          state.state.code:label=STATUS,
          state.configmanagement.configSyncState.state:label=INSTALL_STATE,
          state.configmanagement.configSyncState.clusterLevelStopSyncingState:label=STOP_STATE,
          state.configmanagement.configSyncState.syncState.code:label=SYNC_STATE,
          state.configmanagement.membershipSpec.version:label=VERSION,
          spec.origin.type.synced_to_fleet_default():label=SYNCED_TO_FLEET_DEFAULT
      ))rA   rB   
GetFeaturemembershipsfeatures_baseParseMembershipsPluralfilter_feature_for_membershipsr>   r'   display_infoAddTransformsr   get_transforms	hubclientfleetDefaultMemberConfig	AddFormat"construct_membership_features_list)selfrA   featurerG   s       r   RunDescribeAlpha.Run   s    I""4(ooG "88dKk
))'?yyF
kk,,Z-F-F
..'::$F. 	 kk(( 	* 	 44W==Nr   c                    UR                   (       a!  [        R                  " SUR                   5        UR                  (       d  / $ 0 nUR                  (       aO  UR                  R
                   Vs0 s H.  n[        R                  " UR                  5      UR                  _M0     nnU R                  SS9nU R                  SS9nUR                  R
                   Vs/ s H  nU R                  UR                  R                  SU S3SU S3S5      5      UR                  S.[        R                  " UR                  5      U;   a%  S	U[        R                  " UR                  5         0O0 EPM     sn$ s  snf s  snf )
NzJMembership configuration list may be incomplete. Unreachable locations: %sF)numberTz	projects//   )namespecstate)unreachabler	   warningmembershipSpecsmembershipStatesadditionalPropertiesr   MembershipPartialNamekeyvalueProjectMembershipFeatureResourceNamereplace)rR   rS   statesentry
project_idproject_numbers         r   rQ   0DescribeAlpha.construct_membership_features_list   sn   	kk /070C0CE""iF //DDDe 
$
$UYY
/
<D   U+J\\\.N: ,,AA98 BE 66		!!/q1
|1- KK	
" --eii8FB &!;!;EII!FGH%	
* B9 s   15E7BE<c                     U(       d;  U R                   R                  S:X  a   [        R                  R	                  S5        g g g )Nr    zListed 0 items.)rA   r>   r	   statusPrint)rR   resources_were_displayeds     r   EpilogDescribeAlpha.Epilog   s0    #		&(@	jj() )A#r   r@   N)r   r   r   r   r   detailed_helpclassmethodr9   staticmethodrB   gcloud_exception CatchHTTPErrorRaiseHTTPExceptionrT   rQ   rq   r   r   r   r   r   r   +   sn    /  
-, SG SGj   44[A B6+Z*r   r   )r   r+   &googlecloudsdk.api_lib.container.fleetr   r   googlecloudsdk.api_lib.utilr   rv   googlecloudsdk.callioper   *googlecloudsdk.command_lib.container.fleetr   <googlecloudsdk.command_lib.container.fleet.config_managementr   3googlecloudsdk.command_lib.container.fleet.featuresrH   =googlecloudsdk.command_lib.container.fleet.membershipfeaturesmembershipfeatures_basegooglecloudsdk.corer	   ReleaseTracksReleaseTrackBETAGAMembershipFeatureCommandDescribeCommandr   ALPHAr   r   r   r   <module>r      s    9  = 7 F ( @ N U i * # D%%**D,=,=,@,@A1 44!!	1 B1 D%%++,B*H B* -B*r   