文件範例儲存庫中有更多 AWS SDK可用的範例。 AWS SDK
本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
DeleteOrganizationalUnit
搭配 AWS SDK或 使用 CLI
下列程式碼範例示範如何使用 DeleteOrganizationalUnit
。
- .NET
-
- AWS SDK for .NET
-
注意
還有更多 。 GitHub尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 using System; using System.Threading.Tasks; using Amazon.Organizations; using Amazon.Organizations.Model; /// <summary> /// Shows how to delete an existing AWS Organizations organizational unit. /// </summary> public class DeleteOrganizationalUnit { /// <summary> /// Initializes the Organizations client object and calls /// DeleteOrganizationalUnitAsync to delete the organizational unit /// with the selected ID. /// </summary> public static async Task Main() { // Create the client object using the default account. IAmazonOrganizations client = new AmazonOrganizationsClient(); var orgUnitId = "ou-0000-00000000"; var request = new DeleteOrganizationalUnitRequest { OrganizationalUnitId = orgUnitId, }; var response = await client.DeleteOrganizationalUnitAsync(request); if (response.HttpStatusCode == System.Net.HttpStatusCode.OK) { Console.WriteLine($"Successfully deleted the organizational unit with ID: {orgUnitId}."); } else { Console.WriteLine($"Could not delete the organizational unit with ID: {orgUnitId}."); } } }
-
如需API詳細資訊,請參閱 參考 DeleteOrganizationalUnit中的 。 AWS SDK for .NET API
-
- CLI
-
- AWS CLI
-
若要刪除 OU
下列範例顯示如何刪除 OU。此範例假設您先前OUs已從 OU 移除所有帳戶和其他帳戶:
aws organizations delete-organizational-unit --organizational-unit-id
ou-examplerootid111-exampleouid111
-
如需API詳細資訊,請參閱 命令參考 DeleteOrganizationalUnit
中的 。 AWS CLI
-
DeleteOrganization
DeletePolicy