SIGN IN SIGN UP

Welcome to the AWS Code Examples Repository. This repo contains code examples used in the AWS documentation, AWS SDK Developer Guides, and more. For more information, see the Readme.md file below.

0 0 1 Java
2021-11-15 13:31:25 +00:00
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
2021-11-15 13:15:43 +00:00
/*
*/
2021-12-17 14:41:43 +00:00
/* ////////////////////////////////////////////////////////////////////////////
* Purpose: disable_alarm_actions.cpp demonstrates how to disable actions on an Amazon CloudWatch alarm.
*
* Prerequisites:
2021-12-21 13:36:46 +00:00
* An Amazon CloudWatch metric alarm with at least one action.
2021-12-17 14:41:43 +00:00
*
* Inputs:
2021-12-17 17:57:59 +00:00
* - alarm_name (entered as second argument in command line)
2021-12-17 14:41:43 +00:00
*
* Outputs:
2021-12-17 17:57:59 +00:00
* The alarm is disabled.
2021-12-17 14:41:43 +00:00
* ///////////////////////////////////////////////////////////////////////// */
2021-11-15 13:15:43 +00:00
// snippet-start:[cw.cpp.disable_alarm_actions.inc]
#include <aws/core/Aws.h>
#include <aws/monitoring/CloudWatchClient.h>
#include <aws/monitoring/model/DisableAlarmActionsRequest.h>
#include <iostream>
// snippet-end:[cw.cpp.disable_alarm_actions.inc]
/**
* Disable actions on a CloudWatch alarm based on command-line input
*/
int main(int argc, char** argv)
{
if (argc != 2)
{
std::cout << "Usage: disable_alarm_actions <alarm_name>" <<
std::endl;
return 1;
}
Aws::SDKOptions options;
Aws::InitAPI(options);
{
Aws::String alarm_name(argv[1]);
// snippet-start:[cw.cpp.disable_alarm_actions.code]
Aws::CloudWatch::CloudWatchClient cw;
Aws::CloudWatch::Model::DisableAlarmActionsRequest disableAlarmActionsRequest;
disableAlarmActionsRequest.AddAlarmNames(alarm_name);
auto disableAlarmActionsOutcome = cw.DisableAlarmActions(disableAlarmActionsRequest);
if (!disableAlarmActionsOutcome.IsSuccess())
{
std::cout << "Failed to disable actions for alarm " << alarm_name <<
": " << disableAlarmActionsOutcome.GetError().GetMessage() <<
std::endl;
}
else
{
std::cout << "Successfully disabled actions for alarm " <<
alarm_name << std::endl;
}
// snippet-end:[cw.cpp.disable_alarm_actions.code]
}
Aws::ShutdownAPI(options);
return 0;
}