
                         .   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ZdZdZdZdZ ej,                  ej.                  j0                        ej2                   G d dej4                                      Zy)zQImplementation of gcloud managed kafka schema registries subjects update command.    )absolute_import)division)unicode_literals)apis)base)	arguments)util)log)	resources)managedkafka_v1_messagesz	projects/z
locations/zschemaRegistries/z	subjects/z
/contexts/c                   &    e Zd ZdZed        Zd Zy)Updatea  Update the mode and compatibility of a subject.

  ## EXAMPLES

  Modify the mode of the subject to READONLY:

    $ {command} --registry=SCHEMA_REGISTRY --context=CONTEXT
    --project=PROJECT_ID --location=LOCATION_ID --mode=READONLY

  Modify the compatibility of the subject to BACKWARDS:

    $ {command} --registry=SCHEMA_REGISTRY --context=CONTEXT
    --project=PROJECT_ID --location=LOCATION_ID --compatibility=BACKWARDS
  c                 2   t        j                  |        | j                  dt        d       | j	                  d      }|j                  dt        d       |j                  dt        d	       |j                  d
dd       |j                  ddd       y)z Register flags for this command.z	--contextzThe context of the subject.)typehelpT)requiredz--modez"The mode of the subject to update.z--compatibilityz+The compatibility of the subject to update.z--delete-mode
store_truezDelete the mode of the subject.)actionr   z--delete-configz!Delete the config of the subject.N)r   AddSubjectArgToParseradd_argumentstradd_mutually_exclusive_group)parsergroups     >lib/surface/managed_kafka/schema_registries/subjects/update.pyArgszUpdate.Args6   s     ##F+
*   ///>E	1  
 
:  
 
.  
 
0      c           	      v   t        j                  dd      }|j                  }t        j                  |j
                        }|j                  }|j                  }|j                  j                  j                         j                  }t        j                  j                  |j                  d||||d      }|j                         j                         }	|j                   r|	 t"         |j                    }	|j$                  r!t        j&                  ||	|j                          |j(                  r!t        j*                  ||	|j                          |j,                  r|j,                  j/                         }
|	 d|j                  j                  j                         j                   }|j1                         }t2        j0                  j5                  |
      |_        |j                   r0|j7                  ||      }|j8                  j;                  |      }n/|j=                  ||      }|j>                  j;                  |      }tA        jB                  |d	|j,                  z  
       |jD                  r=|jD                  j/                         }|	 d|j                  j                  j                         j                   }|jG                         }t2        jF                  jI                  |      |_"        |j                   r0|jK                  ||      }|jL                  j;                  |      }n/|jO                  ||      }|jP                  j;                  |      }tA        jB                  |d|jD                  z  
       t@        jR                  jU                  d|jD                  z         yy)zCalled when the user runs gcloud managed-kafka schema-registries subjects update ...

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

    Returns:
      The updated subject.
    managedkafkav1z9managedkafka.projects.locations.schemaRegistries.subjects)
projectsIdlocationsIdschemaRegistriesId
subjectsId)
collectionparamsz/mode/)nameupdateSchemaModeRequest)requestz
mode to %s)detailsz/config/)r'   updateSchemaConfigRequestzcompatibility to %sz-Current subject config: 
 - compatibility: %sN)+r   GetClientInstanceMESSAGES_MODULEr	   ParseProjectprojectlocationregistryCONCEPTSsubjectParser$   r   REGISTRYParentRelativeNamecontextCONTEXTS_RESOURCE_PATHdelete_configDeleteSubjectConfigdelete_modeDeleteSubjectModemodeupperUpdateSchemaModeRequestr   ModeValueValuesEnumFManagedkafkaProjectsLocationsSchemaRegistriesContextsModeUpdateRequest1projects_locations_schemaRegistries_contexts_moder   >ManagedkafkaProjectsLocationsSchemaRegistriesModeUpdateRequest(projects_locations_schemaRegistries_moder
   UpdatedResourcecompatibilityUpdateSchemaConfigRequestCompatibilityValueValuesEnumHManagedkafkaProjectsLocationsSchemaRegistriesContextsConfigUpdateRequest3projects_locations_schemaRegistries_contexts_config@ManagedkafkaProjectsLocationsSchemaRegistriesConfigUpdateRequest*projects_locations_schemaRegistries_configstatusPrint)selfargsclientmessage
project_idr0   schema_registry_idr3   subject_run_resourceschema_registry_resourcer>   r'   updatemoderequestr)   responserG   updateconfigrequests                    r   Runz
Update.RunY   sv    ##ND9F$$G""4<<0J}}Hmm##))+66G$--33N$#"4!	
 4 	  4::<IIK||%&'=&>t||n
M  
w(@$,,O
W&>MyyYY__d()0E0E0K0K0M0X0X/YZd!99;
"
:
:
N
N  
``/@ a 
 DDKK L  	 XX/@ Y 
 BBII J 
 
'<(--+GH((..0m()$--2G2G2M2M2O2Z2Z1[\d#==?*B*\*\*y*y
+' 
bb1D c 
 FFMM N  	 ZZ1D [ 
 DDKK L 
 

083I3II 
jj
:##%? r   N)__name__
__module____qualname____doc__staticmethodr   r[    r   r   r   r   $   s"        Dfr   r   N)r_   
__future__r   r   r   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper   (googlecloudsdk.command_lib.managed_kafkar   r	   googlecloudsdk.corer
   r   5googlecloudsdk.generated_clients.apis.managedkafka.v1r   PROJECTS_RESOURCE_PATHLOCATIONS_RESOURCE_PATHSCHEMA_REGISTRIES_RESOURCE_PATHSUBJECTS_RESOURCE_PATHr9   ReleaseTracksReleaseTrackALPHADefaultUniverseOnlyUpdateCommandr   ra   r   r   <module>rq      s    X &  ' , ( > 9 # ) Z$ & "5 $ %  D%%++,YT Y  -Yr   