
                         T   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 dZdZdZdZdZdZ G d de      Z ej4                  ej6                  j8                        ej:                   G d dej<                                      Zy)zSImplementation of gcloud managed kafka schema registries subjects describe command.    )absolute_import)division)unicode_literals)
exceptions)apis)base)	arguments)util)log)	resourcesz	projects/z
locations/zschemaRegistries/z
/subjects/z
/contexts/z|
    table(
      subject:format='yaml(compatibility, subject.compatibility, mode, subject.mode, name, subject.name)'
    )
c                       e Zd ZdZd Zy)_Resultsz@Encapsulate results into a single object to fit the Run() model.c                     || _         y )N)subject)selfr   s     @lib/surface/managed_kafka/schema_registries/subjects/describe.py__init__z_Results.__init__.   s	    DL    N)__name__
__module____qualname____doc__r    r   r   r   r   +   s
    Hr   r   c                   &    e Zd ZdZed        Zd Zy)DescribezDescribe a subject in a schema registry with all of its fields.

  ## EXAMPLES

   Describe the subject in a schema registry with all of its fields:

    $ {command} --project=PROJECT_ID --location=LOCATION_ID
    --registry=SCHEMA_REGISTRY_ID
  c                     | j                   j                  t               | j                  dt        d       t        j                  |        y)z Register flags for this command.z	--contextzThe context of the subject.)typehelpN)display_info	AddFormatSUBJECT_FORMATadd_argumentstrr	   AddSubjectArgToParser)parsers    r   ArgszDescribe.Args?   sD     !!.1
*   ##F+r   c           	      h   t        j                  dd      }|j                  }t        j                  |j
                        }|j                  }|j                  }|j                  j                  j                         j                  }t        j                  j                  |j                  d||||d      }|j                         j                         }	|j                         }
|j                   r4|	 t"         |j                    t$         | }
|	 t"         |j                    }	t&        j(                  j+                  dj-                  |      dz          |j/                  |	 d| 	      }|j1                  |	 d
| 	      }d}d}	 |j2                  j5                  |      }t        j6                  |j8                        }	 |jF                  j5                  |      }t        jH                  |jJ                        }|
||d}tM        |      S # t:        j<                  $ r}t?        j@                  |t        jB                        }d|jD                  v r&t?        j@                  |dj-                  |            	 |j/                  |	 d	      }|j2                  j5                  |      }t        j6                  |j8                        }| d}n0# t:        j<                  $ r}t?        j@                  |      d}~ww xY wY d}~Ed}~ww xY w# t:        j<                  $ r 	 |j1                  |	 d	      }|jF                  j5                  |      }t        jH                  |jJ                        }| d}n0# t:        j<                  $ r}t?        j@                  |      d}~ww xY wY w xY w)zCalled when the user runs gcloud managed-kafka schema-registries subjects describe ...

    Args:
      args: all the arguments that were provided to this command invocation.

    Returns:
      The subject.
    managedkafkav1z9managedkafka.projects.locations.schemaRegistries.subjects)
projectsIdlocationsIdschemaRegistriesId
subjectsId)
collectionparamszDescribing subject [{}].
z/mode/)namez/config/None)requestzResource not foundzSubject {} not found.)error_formatz/modez (from registry)Nz/config)r1   modecompatibility)'r   GetClientInstanceMESSAGES_MODULEr
   ParseProjectprojectlocationregistryCONCEPTSr   Parser-   r   REGISTRYParentRelativeNamecontextCONTEXTS_RESOURCE_PATHSUBJECTS_RESOURCE_PATHr   statusPrintformat;ManagedkafkaProjectsLocationsSchemaRegistriesModeGetRequest=ManagedkafkaProjectsLocationsSchemaRegistriesConfigGetRequest(projects_locations_schemaRegistries_modeGet	ParseModer5   apitools_exceptionsHttpNotFoundErrorr   HttpExceptionHTTP_ERROR_FORMATmessage*projects_locations_schemaRegistries_configParseCompatibilityr6   r   )r   argsclientrQ   
project_idr;   schema_registry_idr   subject_run_resourceschema_registry_resourcesubject_resource_pathsubject_mode_requestsubject_config_requestr5   r6   subject_modee	api_errorschema_registry_mode_requestschema_registry_modeinner_esubject_configschema_registry_config_requestschema_registry_configverbose_subjects                            r   RunzDescribe.RunM   s    ##ND9F$$G""4<<0J}}Hmm##))+66G$--33N$#"4!	
 4 	  4::<IIK0==?||!9 :;Q:RSWS_S_R`aw`x  zA  yB  C%&'=&>t||n
M  JJ/66w?$FG 	KK,-VG9= 	L 	
  	MM,-XgY? 	N 	
  DM0DDHH& I l ^^L--.d00HHLL( M n --n.J.JKm( &&O O$$i 00 0**1d.D.DEi	!2!2	2&&3::7C
 	
0OO017 P  	% ;;??4 @  	
 ~~2778'( 22 0&&w//0 	%08 00 00)0)n)n,-W5 *o *
& ==AA6 B  	
 //"00
 )/)9: 22 0&&w//0 	0su   ;H ;L L&AL?AKLL(K==LLLN1'AM=<N1=N*N%%N**N10N1N)r   r   r   r   staticmethodr&   rg   r   r   r   r   r   2   s!     , ,j%r   r   N) r   
__future__r   r   r   apitools.base.pyr   rM   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper   (googlecloudsdk.command_lib.managed_kafkar	   r
   googlecloudsdk.corer   r   PROJECTS_RESOURCE_PATHLOCATIONS_RESOURCE_PATHSCHEMA_REGISTRIES_RESOURCE_PATHrD   rC   r!   objectr   ReleaseTracksReleaseTrackALPHADefaultUniverseOnlyDescribeCommandr   r   r   r   <module>rx      s    Z &  ' > , ( . > 9 # )$ & "5 % % v  D%%++,C%t## C%  -C%r   