文档 AWS SDK 示例 GitHub 存储库中还有更多 S AWS DK 示例
本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
与 AWS SDK DeleteDBSubnetGroup
配合使用
以下代码示例演示如何使用 DeleteDBSubnetGroup
。
- Java
-
- 适用于 Java 的 SDK 2.x
-
注意
还有更多相关信息 GitHub。在 AWS 代码示例存储库
中查找完整示例,了解如何进行设置和运行。 /** * Deletes a subnet group. * * @param subnetGroupName the identifier of the subnet group to delete * @return a {@link CompletableFuture} that completes when the cluster has been deleted */ public CompletableFuture<Void> deleteDBSubnetGroupAsync(String subnetGroupName) { DeleteDbSubnetGroupRequest request = DeleteDbSubnetGroupRequest.builder() .dbSubnetGroupName(subnetGroupName) .build(); return getAsyncClient().deleteDBSubnetGroup(request) .thenAccept(response -> logger.info("🗑️ Deleting Subnet Group: " + subnetGroupName)); }
-
有关 API 的详细信息,请参阅《AWS SDK for Java 2.x API 参考》中的 “删除DBSubnet群组”。
-
- Python
-
- 适用于 Python 的 SDK(Boto3)
-
注意
还有更多相关信息 GitHub。在 AWS 代码示例存储库
中查找完整示例,了解如何进行设置和运行。 def delete_db_subnet_group(neptune_client, subnet_group_name): """ Deletes a Neptune DB subnet group synchronously using Boto3. Args: neptune_client (boto3.client): The Neptune client. subnet_group_name (str): The name of the DB subnet group to delete. Raises: ClientError: If the delete operation fails. """ delete_group_request = { 'DBSubnetGroupName': subnet_group_name } try: neptune_client.delete_db_subnet_group(**delete_group_request) print(f"️ Deleting Subnet Group: {subnet_group_name}") except ClientError as err: code = err.response["Error"]["Code"] message = err.response["Error"]["Message"] if code == "DBSubnetGroupNotFoundFault": print(f"Subnet group '{subnet_group_name}' not found or already deleted.") elif code == "AccessDeniedException": print("Access denied. Please ensure you have the necessary permissions.") else: print(f"Couldn't delete subnet group. {code}: {message}") raise
-
有关 API 的详细信息,请参阅 Python AWS SDK 中的删除DBSubnet群组 (Boto3) API 参考。
-
DeleteDBInstance
DescribeDBClusters