| Server IP : 35.236.43.222 / Your IP : 216.73.216.143 Web Server : Apache System : Linux order-form-vm-001 5.10.0-37-cloud-amd64 #1 SMP Debian 5.10.247-1 (2025-12-11) x86_64 User : deploy ( 1002) PHP Version : 8.1.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /usr/lib/google-cloud-sdk/lib/surface/monitoring/channels/__pycache__/ |
Upload File : |
�
��� � � � d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddl m
Z
ddl mZ ddlmZ
dd lmZ dd
lmZ ej ej j ej j � � G d� dej � � � � Zd
S )z,`gcloud monitoring channels create` command.� )�absolute_import)�division)�unicode_literals)�channels)�base)�flags)�util)�log)�
propertiesc �6 � e Zd ZdZddiZed� � � Zd� ZdS )�Createz"Create a new notification channel.�DESCRIPTIONa Creates a new notification channel. A channel can be specified as
JSON/YAML passed in as a string through the `--channel-content` flag
or as a file through the `--channel-content-from-file` flag.
A basic channel can also be specified through command line flags. If
a channel is specified through `--channel-content` or
`--channel-content-from-file`, and additional flags are supplied, the
flags will override the given channel's settings.
For information about the JSON/YAML format of a notification channel:
https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.notificationChannels
Additional documentation can for this operation can be found at:
https://cloud.google.com/monitoring/alerts/using-channels-api
## EXAMPLES
The following commands setup both email and SMS notification channels for the team lead. Note
that the display name and description focus on the purpose/semantics of the channel rather
than its destination. This is a best-practice that facilitates swapping/updating notification
channels in-place (such as when users change teams, projects, roles, companies, etc.) with
minimal impact to the alerting policies that reference the existing channels. It is also
a best practice to supply at least two channels of different types for a given person.
$ {command} --display-name="Foo Team Lead (Primary)" --description="Primary contact method for the Foo team lead" --type=email --user-labels=team=foo,role=lead,ord=1 --channel-labels=email_address=user@somedomain.tld
$ {command} --display-name="Foo Team Lead (Secondary)" --description="Secondary contact method for the Foo team lead" --type=sms --user-labels=team=foo,role=lead,ord=2 --channel-labels=number=123-456-7890
c �X � t j | d� � t j | � � d S )Nzchannel-content)r �AddMessageFlags�"AddNotificationChannelSettingFlags)�parsers �)lib/surface/monitoring/channels/create.py�ArgszCreate.ArgsK s- � � ��&�"3�4�4�4� �,�V�4�4�4�4�4� c � � t j � � }|j }t j ||� � }|j r)t j |j |j j � � |_ |j
r)t j |j
|j j � � |_ t j t j j j � � � � � }|� ||� � }t+ j |j d� � |S )Nznotification channel)r �NotificationChannelsClient�messagesr �GetNotificationChannelFromArgs�user_labels�ParseCreateLabels�NotificationChannel�UserLabelsValue�
userLabels�channel_labels�LabelsValue�labels�
projects_util�ParseProjectr �VALUES�core�project�Getr
r
�CreatedResource�name)�self�args�clientr �channel�project_ref�results r �Runz
Create.RunP s� � �
�
0�
2�
2�F���H��1�$��A�A�G��� J��1�
�
�H�8�H�J� J�g���� I��-�
�
�x�;�G�I� I�g�n� �"�:�#4�#9�#A�#E�#E�#G�#G�H�H� � �]�]�;��
0�
0�F�����%;�<�<�<��Mr N)�__name__�
__module__�__qualname__�__doc__�
detailed_help�staticmethodr r0 � r r r
r
sV � � � � � �*�*� �$�'�-�R �5� 5� �<�5�� � � � r r
N)r4 �
__future__r r r �!googlecloudsdk.api_lib.monitoringr �googlecloudsdk.callioper �%googlecloudsdk.command_lib.monitoringr r �#googlecloudsdk.command_lib.projectsr"