CA Service への認証を行うには、アプリケーションのデフォルト認証情報を設定します。
詳細については、ローカル開発環境の認証の設定をご覧ください。
import("context""fmt""io"privateca"cloud.google.com/go/security/privateca/apiv1""cloud.google.com/go/security/privateca/apiv1/privatecapb")// Delete the CA pool as mentioned by the ca_pool_name.// Before deleting the pool, all CAs in the pool MUST BE deleted.funcdeleteCaPool(wio.Writer,projectIdstring,locationstring,caPoolIdstring)error{// projectId := "your_project_id"// location := "us-central1" // For a list of locations, see: https://cloud.google.com/certificate-authority-service/docs/locations.// caPoolId := "ca-pool-id" // A unique id/name for the ca pool.ctx:=context.Background()caClient,err:=privateca.NewCertificateAuthorityClient(ctx)iferr!=nil{returnfmt.Errorf("NewCertificateAuthorityClient creation failed: %w",err)}defercaClient.Close()fullCaPoolName:=fmt.Sprintf("projects/%s/locations/%s/caPools/%s",projectId,location,caPoolId)// See https://pkg.go.dev/cloud.google.com/go/security/privateca/apiv1/privatecapb#DeleteCaPoolRequest.req:=&privatecapb.DeleteCaPoolRequest{Name:fullCaPoolName,}op,err:=caClient.DeleteCaPool(ctx,req)iferr!=nil{returnfmt.Errorf("DeleteCaPool failed: %w",err)}iferr=op.Wait(ctx);err!=nil{returnfmt.Errorf("DeleteCaPool failed during wait: %w",err)}fmt.Fprintf(w,"CA Pool deleted")returnnil}
Java
CA Service への認証を行うには、アプリケーションのデフォルト認証情報を設定します。
詳細については、ローカル開発環境の認証の設定をご覧ください。
importcom.google.api.core.ApiFuture;importcom.google.cloud.security.privateca.v1.CaPoolName;importcom.google.cloud.security.privateca.v1.CertificateAuthorityServiceClient;importcom.google.cloud.security.privateca.v1.DeleteCaPoolRequest;importcom.google.longrunning.Operation;importjava.io.IOException;importjava.util.concurrent.ExecutionException;importjava.util.concurrent.TimeoutException;publicclassDeleteCaPool{publicstaticvoidmain(String[]args)throwsInterruptedException,ExecutionException,IOException,TimeoutException{// TODO(developer): Replace these variables before running the sample.// location: For a list of locations, see:// https://cloud.google.com/certificate-authority-service/docs/locations// poolId: The id of the CA pool to be deleted.Stringproject="your-project-id";Stringlocation="ca-location";StringpoolId="ca-pool-id";deleteCaPool(project,location,poolId);}// Delete the CA pool as mentioned by the poolId.// Before deleting the pool, all CAs in the pool MUST BE deleted.publicstaticvoiddeleteCaPool(Stringproject,Stringlocation,StringpoolId)throwsInterruptedException,ExecutionException,IOException{// Initialize client that will be used to send requests. This client only needs to be created// once, and can be reused for multiple requests. After completing all of your requests, call// the `certificateAuthorityServiceClient.close()` method on the client to safely// clean up any remaining background resources.try(CertificateAuthorityServiceClientcertificateAuthorityServiceClient=CertificateAuthorityServiceClient.create()){// Set the project, location and poolId to delete.CaPoolNamecaPool=CaPoolName.newBuilder().setProject(project).setLocation(location).setCaPool(poolId).build();// Create the Delete request.DeleteCaPoolRequestdeleteCaPoolRequest=DeleteCaPoolRequest.newBuilder().setName(caPool.toString()).build();// Delete the CA Pool.ApiFuture<Operation>futureCall=certificateAuthorityServiceClient.deleteCaPoolCallable().futureCall(deleteCaPoolRequest);Operationresponse=futureCall.get();if(response.hasError()){System.out.println("Error while deleting CA pool !"+response.getError());return;}System.out.println("Deleted CA Pool: "+poolId);}}}
Python
CA Service への認証を行うには、アプリケーションのデフォルト認証情報を設定します。
詳細については、ローカル開発環境の認証の設定をご覧ください。
importgoogle.cloud.security.privateca_v1asprivateca_v1defdelete_ca_pool(project_id:str,location:str,ca_pool_name:str)-> None:""" Delete the CA pool as mentioned by the ca_pool_name. Before deleting the pool, all CAs in the pool MUST BE deleted. Args: project_id: project ID or project number of the Cloud project you want to use. location: location you want to use. For a list of locations, see: https://cloud.google.com/certificate-authority-service/docs/locations. ca_pool_name: the name of the CA pool to be deleted. """caServiceClient=privateca_v1.CertificateAuthorityServiceClient()ca_pool_path=caServiceClient.ca_pool_path(project_id,location,ca_pool_name)# Create the Delete request.request=privateca_v1.DeleteCaPoolRequest(name=ca_pool_path)# Delete the CA Pool.caServiceClient.delete_ca_pool(request=request)print("Deleted CA Pool:",ca_pool_name)
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-02-18 UTC。"],[[["A CA pool can only be deleted after all Certificate Authorities (CAs) within it have been permanently deleted, which occurs after a 30-day grace period following the initiation of deletion."],["Deleting a CA pool is irreversible, and the name of the deleted CA pool cannot be used again for another CA pool."],["The process for deleting a CA pool is demonstrated using the Google Cloud console, the `gcloud` command-line tool, as well as Go, Java, and Python code examples."],["To delete a CA pool, users must specify the pool's ID and its location, which are required for both the `gcloud` command and the code examples provided."],["Before attempting to delete the CA pool, you need to authenticate to the CA service by setting up Application Default Credentials."]]],[]]