将 CancelExportTask 和 AWS SDK 结合使用 - AWS SDK 代码示例

AWS 文档 SDK 示例 GitHub 存储库中还有更多 AWS SDK 示例。

CancelExportTask 和 AWS SDK 结合使用

以下代码示例演示了如何使用 CancelExportTask

.NET
SDK for .NET
注意

查看 GitHub,了解更多信息。查找完整示例,了解如何在 AWS 代码示例存储库中进行设置和运行。

using System; using System.Threading.Tasks; using Amazon.CloudWatchLogs; using Amazon.CloudWatchLogs.Model; /// <summary> /// Shows how to cancel an Amazon CloudWatch Logs export task. /// </summary> public class CancelExportTask { public static async Task Main() { // This client object will be associated with the same AWS Region // as the default user on this system. If you need to use a // different AWS Region, pass it as a parameter to the client // constructor. var client = new AmazonCloudWatchLogsClient(); string taskId = "exampleTaskId"; var request = new CancelExportTaskRequest { TaskId = taskId, }; var response = await client.CancelExportTaskAsync(request); if (response.HttpStatusCode == System.Net.HttpStatusCode.OK) { Console.WriteLine($"{taskId} successfully canceled."); } else { Console.WriteLine($"{taskId} could not be canceled."); } } }
  • 有关 API 详细信息,请参阅《AWS SDK for .NET API Reference》中的 CancelExportTask