Ë
    €Ï¥  ã                   óÂ   — 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dlmZ  G d„ de	j(                  «      Zy)z-`gcloud monitoring policies migrate` command.é    )Úabsolute_import)Údivision)Úunicode_literals)Úchannels)Úpolicies)Úbase)Úflags)Úutil)Úlog)Ú
properties)Ú
console_ioc                   ó.   — e Zd ZdZddiZed„ «       Zd„ Zy)ÚMigratez<Migrate a Prometheus configuration file to Cloud Monitoring.ÚDESCRIPTIONa            Creates new alerting policies and/or notification channels based on
          provided Prometheus files. The rules YAML file, which holds the alert
          rules, must be specified as a file through the
          `--policies-from-prometheus-alert-rules-yaml` flag.
       c                 ó.   — t        j                  | «       y )N)r	   ÚAddMigrateFlags)Úparsers    ú*lib/surface/monitoring/policies/migrate.pyÚArgszMigrate.Args*   s   € ä	×Ñ˜&Õ!ó    c                 ó
  — t        j                  «       }t        j                  «       }ddg}t	        j
                  ||«       t        j                  t        j                  j                  j                  j                  «       «      }t        j                  dd¬«      sy t	        j                  ||j                   «      }g }|D ]O  }|j#                  ||«      }	t%        j&                  |	j(                  d«       |j+                  |	j(                  «       ŒQ t	        j,                  ||j                   |«      }
g }|
D ]E  }|j#                  ||«      }	t%        j&                  |	j(                  d«       |j+                  |	«       ŒG |S )Nz+--policies-from-prometheus-alert-rules-yamlz,--channels-from-prometheus-alertmanager-yamlzÑEach call of the migration tool will create a new set of alert policies and/or notification channels. Thus, the migration tool should not be used to update existing alert policies and/or notification channels.F)ÚmessageÚdefaultznotification channelzalert policy)r   ÚNotificationChannelsClientr   ÚAlertPolicyClientr
   ÚValidateAtleastOneSpecifiedÚprojects_utilÚParseProjectr   ÚVALUESÚcoreÚprojectÚGetr   ÚPromptContinueÚ"CreateNotificationChannelsFromArgsÚmessagesÚCreater   ÚCreatedResourceÚnameÚappendÚCreatePromQLPoliciesFromArgs)ÚselfÚargsÚnotification_channel_clientÚalert_policy_clientÚpromql_flagsÚproject_refÚnotification_channelsÚcreated_channel_namesÚchannelÚresultÚpromql_policiesÚpolicies_resultsÚpolicys                r   ÚRunzMigrate.Run.   se  € Ü"*×"EÑ"EÓ"GÐÜ"×4Ñ4Ó6Ðà5Ø6ð€Lô 	×$Ñ$ T¨<Ô8Ü×,Ñ,Ü×Ñ×Ñ×&Ñ&×*Ñ*Ó,ó€Kô ×$Ñ$ð&ð
 õð ä ×CÑCØÐ!×*Ñ*óÐð ÐÛ(ˆØ*×1Ñ1°+¸wÓG€fÜ	×Ñ˜&Ÿ+™+Ð'=Ô>Ø×"Ñ" 6§;¡;Õ/ð )ô
 ×7Ñ7ØÐ!×*Ñ*Ð,Aó€Oð Ðó "ˆØ"×)Ñ)¨+°vÓ>€fÜ	×Ñ˜&Ÿ+™+ ~Ô6Ø×Ñ˜fÕ%ð "ð Ðr   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Údetailed_helpÚstaticmethodr   r8   © r   r   r   r       s-   „ ÙDà ð #ð €-ð ñ"ó ð"ó-r   r   N)r<   Ú
__future__r   r   r   Ú!googlecloudsdk.api_lib.monitoringr   r   Úgooglecloudsdk.callioper   Ú%googlecloudsdk.command_lib.monitoringr	   r
   Ú#googlecloudsdk.command_lib.projectsr   Úgooglecloudsdk.corer   r   Úgooglecloudsdk.core.consoler   ÚCreateCommandr   r?   r   r   Ú<module>rH      s@   ðñ 4å &Ý Ý 'å 6Ý 6Ý (Ý 7Ý 6Ý EÝ #Ý *Ý 2ô;ˆd× Ñ õ ;r   