예제 #1
0
 def test_execute(self, mock_hook):
     operator = StackdriverDisableAlertPoliciesOperator(
         task_id=TEST_TASK_ID, filter_=TEST_FILTER)
     operator.execute(None)
     mock_hook.return_value.disable_alert_policies.assert_called_once_with(
         project_id=None,
         filter_=TEST_FILTER,
         retry=DEFAULT,
         timeout=DEFAULT,
         metadata=None)
예제 #2
0
        task_id='create-alert-policies',
        alerts=json.dumps(
            {"policies": [TEST_ALERT_POLICY_1, TEST_ALERT_POLICY_2]}),
    )
    # [END howto_operator_gcp_stackdriver_upsert_alert_policy]

    # [START howto_operator_gcp_stackdriver_enable_alert_policy]
    enable_alert_policy = StackdriverEnableAlertPoliciesOperator(
        task_id='enable-alert-policies',
        filter_='(displayName="test alert 1" OR displayName="test alert 2")',
    )
    # [END howto_operator_gcp_stackdriver_enable_alert_policy]

    # [START howto_operator_gcp_stackdriver_disable_alert_policy]
    disable_alert_policy = StackdriverDisableAlertPoliciesOperator(
        task_id='disable-alert-policies',
        filter_='displayName="test alert 1"',
    )
    # [END howto_operator_gcp_stackdriver_disable_alert_policy]

    # [START howto_operator_gcp_stackdriver_list_alert_policy]
    list_alert_policies = StackdriverListAlertPoliciesOperator(
        task_id='list-alert-policies', )
    # [END howto_operator_gcp_stackdriver_list_alert_policy]

    # [START howto_operator_gcp_stackdriver_delete_notification_channel]
    delete_notification_channel = StackdriverDeleteNotificationChannelOperator(
        task_id='delete-notification-channel',
        name=
        "{{ task_instance.xcom_pull('list-notification-channel')[0]['name'] }}",
    )
    # [END howto_operator_gcp_stackdriver_delete_notification_channel]