文件範例儲存庫中有更多 AWS SDK可用的範例。 AWS SDK
本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
DeletePolicy
搭配 AWS SDK或 使用 CLI
下列程式碼範例示範如何使用 DeletePolicy
。
- .NET
-
- AWS SDK for .NET
-
注意
還有更多 。 GitHub尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 using System; using System.Threading.Tasks; using Amazon.Organizations; using Amazon.Organizations.Model; /// <summary> /// Deletes an existing AWS Organizations policy. /// </summary> public class DeletePolicy { /// <summary> /// Initializes the Organizations client object and then uses it to /// delete the policy with the specified policyId. /// </summary> public static async Task Main() { // Create the client object using the default account. IAmazonOrganizations client = new AmazonOrganizationsClient(); var policyId = "p-00000000"; var request = new DeletePolicyRequest { PolicyId = policyId, }; var response = await client.DeletePolicyAsync(request); if (response.HttpStatusCode == System.Net.HttpStatusCode.OK) { Console.WriteLine($"Successfully deleted Policy: {policyId}."); } else { Console.WriteLine($"Could not delete Policy: {policyId}."); } } }
-
如需API詳細資訊,請參閱 參考 DeletePolicy中的 。 AWS SDK for .NET API
-
- CLI
-
- AWS CLI
-
若要刪除政策
下列範例示範如何從組織刪除政策。此範例假設您先前已從所有實體分離政策:
aws organizations delete-policy --policy-id
p-examplepolicyid111
-
如需API詳細資訊,請參閱 命令參考 DeletePolicy
中的 。 AWS CLI
-
- Python
-
- SDK for Python (Boto3)
-
注意
還有更多 。 GitHub尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 def delete_policy(policy_id, orgs_client): """ Deletes a policy. :param policy_id: The ID of the policy to delete. :param orgs_client: The Boto3 Organizations client. """ try: orgs_client.delete_policy(PolicyId=policy_id) logger.info("Deleted policy %s.", policy_id) except ClientError: logger.exception("Couldn't delete policy %s.", policy_id) raise
-
如需API詳細資訊,請參閱 DeletePolicy 中的 AWS SDK for Python (Boto3) API參考 。
-
DeleteOrganizationalUnit
DescribePolicy