AWS 文档 SDK 示例
将 DeleteTrail 与 AWS SDK 或 CLI 配合使用
以下代码示例演示如何使用 DeleteTrail。
- C++
-
- SDK for C++
-
注意
查看 GitHub,了解更多信息。在 AWS 代码示例存储库
中查找完整示例,了解如何进行设置和运行。 // Routine which deletes an AWS CloudTrail trail. /*! \param trailName: The name of the CloudTrail trail. \param clientConfig: Aws client configuration. \return bool: Function succeeded. */ bool AwsDoc::CloudTrail::deleteTrail(const Aws::String trailName, const Aws::Client::ClientConfiguration &clientConfig) { Aws::CloudTrail::CloudTrailClient trailClient(clientConfig); Aws::CloudTrail::Model::DeleteTrailRequest request; request.SetName(trailName); auto outcome = trailClient.DeleteTrail(request); if (outcome.IsSuccess()) { std::cout << "Successfully deleted trail " << trailName << std::endl; } else { std::cerr << "Error deleting trail " << trailName << " " << outcome.GetError().GetMessage() << std::endl; } return outcome.IsSuccess(); }-
有关 API 详细信息,请参阅《适用于 C++ 的 AWS SDK API Reference》中的 DeleteTrail。
-
- CLI
-
- AWS CLI
-
删除跟踪
以下
delete-trail命令删除名为Trail1的跟踪:aws cloudtrail delete-trail --nameTrail1-
有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 DeleteTrail
。
-
- PowerShell
-
- Tools for PowerShell V4
-
示例 1:删除指定的跟踪。在运行此命令之前,系统会提示您进行确认。要禁止确认,请添加 -Force 开关参数。
Remove-CTTrail -Name "awscloudtrail-example"-
有关 API 详细信息,请参阅《AWS Tools for PowerShell Cmdlet Reference (V4)》中的 DeleteTrail。
-
- Tools for PowerShell V5
-
示例 1:删除指定的跟踪。在运行此命令之前,系统会提示您进行确认。要禁止确认,请添加 -Force 开关参数。
Remove-CTTrail -Name "awscloudtrail-example"-
有关 API 详细信息,请参阅《AWS Tools for PowerShell Cmdlet Reference (V5)》中的 DeleteTrail。
-
- Ruby
-
- 适用于 Ruby 的 SDK
-
注意
查看 GitHub,了解更多信息。在 AWS 代码示例存储库
中查找完整示例,了解如何进行设置和运行。 client.delete_trail({ name: trail_name # required }) puts "Successfully deleted trail: #{trail_name}" rescue StandardError => e puts "Got error trying to delete trail: #{trail_name}:" puts e exit 1 end-
有关 API 详细信息,请参阅《适用于 Ruby 的 AWS SDK API Reference》中的 DeleteTrail。
-
CreateTrail
DescribeTrail