
                         p    S 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	\	5      r
 " S
 S\	5      rg)zHA module container a helper class for generating config report requests.    )absolute_import)division)unicode_literals   )services_util)encodingc                   T    \ rS rSrSrSrSrSrS rS r	S r
S	 rS
 rS rS rS rSrg)ConfigReporterValue   zAA container class to hold config report value fields and methods.z&type.googleapis.com/google.api.Servicez=type.googleapis.com/google.api.servicemanagement.v1.ConfigRefz@type.googleapis.com/google.api.servicemanagement.v1.ConfigSourcec                     [         R                  " 5       U l        Xl        S U l        S U l        S U l        S U l        SU l        g NT)	r   GetMessagesModulemessagesserviceconfigswagger_pathswagger_contents	config_idconfig_use_active_idselfr   s     7lib/googlecloudsdk/api_lib/endpoints/config_reporter.py__init__ConfigReporterValue.__init__#   s=    !335DMLDKD DDN $D    c                 H    Xl         S U l        S U l        S U l        SU l        g NFr   r   r   r   r   )r   r   s     r   	SetConfigConfigReporterValue.SetConfig.   s&    KD DDN %Dr   c                 F    S U l         Xl        X l        S U l        SU l        g r   r   )r   pathcontentss      r   
SetSwaggerConfigReporterValue.SetSwagger5   s$    DK$DN %Dr   c                 H    S U l         S U l        S U l        Xl        SU l        g r   r   )r   r   s     r   SetConfigIdConfigReporterValue.SetConfigId<   s&    DKD DN %Dr   c                 J    S U l         S U l        S U l        S U l        SU l        g r   r   r   s    r   SetConfigUseDefaultId)ConfigReporterValue.SetConfigUseDefaultIdC   s(    DKD DDN $Dr   c                    U R                   (       a  [        R                  $ U R                  (       a!  U R                  (       a  [        R
                  $ U R                  (       d  U R                  (       a  [        R                  $ g N)	r   r
   SERVICE_CONFIG_TYPE_URLr   r   CONFIG_SOURCE_TYPE_URLr   r   CONFIG_REF_TYPE_URLr*   s    r   
GetTypeUrlConfigReporterValue.GetTypeUrlJ   sR    {{ 888			t44 777	444 444 5r   c                     U R                   S L=(       d6    U R                  S L=(       d!    U R                  S L=(       d    U R                  $ r.   )r   r   r   r   r*   s    r   IsReadyForReport$ConfigReporterValue.IsReadyForReportR   sG    KKt# &T)&NN$&& %%'r   c                    0 nU R                  5       (       d  gU R                  (       a  UR                  U R                  5        GOUU R                  (       a  U R                  R                  U R                  U R                  U R                  R
                  R                  R                  S9nU R                  R                  U/S9nUR                  [        R                  " U5      5        OU R                  (       a'  SR                  U R                  U R                  5      nOb[        R                   " U R                  5      nU(       a   SR                  U R                  US   5      nOSR                  U R                  5      nUR                  SU05        UR                  SU R#                  5       05        [        R$                  " X!5      $ )	zMake a value to insert into the GenerateConfigReport request.

Args:
  value_type: The type to encode the message into. Generally, either
    OldConfigValue or NewConfigValue.

Returns:
  The encoded config value object of type value_type.
N)filePathfileContentsfileType)fileszservices/{0}/configs/{1}r   zservices/{0}namez@type)r5   r   updater   r   
ConfigFiler   FileTypeValueValuesEnumOPEN_API_YAMLConfigSourcer   MessageToDictr   formatr   r   #GetActiveServiceConfigIdsForServicer2   DictToMessage)r   
value_typeresultconfig_fileconfig_source_messageresourceactive_config_idss          r   ConstructConfigValue(ConfigReporterValue.ConstructConfigValueX   sc    F  ""	mmDKK 			MM,,$$,,MM,,++MM - <k #mm88}8MmmH**+@AB	-44LL$..*
 *MMLL
 /66ll-a02( $**4<<8(mmVX&'
MM7DOO-./!!&55r   )r   r   r   r   r   r   r   N)__name__
__module____qualname____firstlineno____doc__r/   r1   r0   r   r   r$   r'   r+   r2   r5   rL   __static_attributes__ r   r   r
   r
      sE    IDEK	%&&&%5'06r   r
   c                   *    \ rS rSrSrS rS rS rSrg)ConfigReporter   z;A container class to hold config report fields and methods.c                     [         R                  " 5       U l        [         R                  " 5       U l        Xl        [        U5      U l        [        U5      U l        g r.   )	r   GetClientInstanceclientr   r   r   r
   
old_config
new_configr   s     r   r   ConfigReporter.__init__   s?    113DK!335DML)'2DO)'2DOr   c                    U R                   R                  U R                  R                  R                  5      nU R
                  R                  U R                  R                  R                  5      nU R                  R                  UUS9$ )N)	oldConfig	newConfig)r[   rL   r   GenerateConfigReportRequestOldConfigValuer\   NewConfigValue)r   old_config_valuenew_config_values      r   ConstructRequestMessage&ConfigReporter.ConstructRequestMessage   sz    ;;11@@B;;11@@B ==44?O?O 5 Q Qr   c                     U R                   R                  R                  U R                  5       5      nU(       d  g UR                  (       d  / $ UR                  S   $ )Nr   )rZ   servicesGenerateConfigReportrf   changeReports)r   rG   s     r   	RunReportConfigReporter.RunReport   sM    [[!!66$$&(Fi""r   )rZ   r   r\   r[   r   N)	rN   rO   rP   rQ   rR   r   rf   rl   rS   rT   r   r   rV   rV      s    C3Q#r   rV   N)rR   
__future__r   r   r    r   apitools.base.pyr   objectr
   rV   rT   r   r   <module>rr      s5     O &  '  %m6& m6`#V #r   