private Amazon.CloudWatch.Model.DeleteAlarmsResponse CallAWSServiceOperation(IAmazonCloudWatch client, Amazon.CloudWatch.Model.DeleteAlarmsRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon CloudWatch", "DeleteAlarms"); try { #if DESKTOP return(client.DeleteAlarms(request)); #elif CORECLR return(client.DeleteAlarmsAsync(request).GetAwaiter().GetResult()); #else #error "Unknown build edition" #endif } catch (AmazonServiceException exc) { var webException = exc.InnerException as System.Net.WebException; if (webException != null) { throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException); } throw; } }
/// <summary> /// Delete the alarms whose names are listed in the alarmNames parameter. /// </summary> /// <param name="client">The initialized Amazon CloudWatch client.</param> /// <param name="alarmNames">A list of names for the alarms to be /// deleted.</param> public static async Task DeleteAlarmsAsyncExample(IAmazonCloudWatch client, List <string> alarmNames) { var request = new DeleteAlarmsRequest { AlarmNames = alarmNames, }; try { var response = await client.DeleteAlarmsAsync(request); if (response.HttpStatusCode == System.Net.HttpStatusCode.OK) { Console.WriteLine("Alarms successfully deleted:"); alarmNames .ForEach(name => Console.WriteLine($"{name}")); } } catch (ResourceNotFoundException ex) { Console.WriteLine($"Error: {ex.Message}"); } }