Search in sources :

Example 1 with DeleteCaPoolRequest

use of com.google.cloud.security.privateca.v1.DeleteCaPoolRequest in project java-security-private-ca by googleapis.

the class DeleteCaPool method deleteCaPool.

// Delete the CA pool as mentioned by the pool_Id.
// Before deleting the pool, all CAs in the pool MUST BE deleted.
public static void deleteCaPool(String project, String location, String pool_Id) throws InterruptedException, ExecutionException, IOException {
    // clean up any remaining background resources.
    try (CertificateAuthorityServiceClient certificateAuthorityServiceClient = CertificateAuthorityServiceClient.create()) {
        // Set the project, location and pool_Id to delete.
        CaPoolName caPool = CaPoolName.newBuilder().setProject(project).setLocation(location).setCaPool(pool_Id).build();
        // Create the Delete request.
        DeleteCaPoolRequest deleteCaPoolRequest = DeleteCaPoolRequest.newBuilder().setName(caPool.toString()).build();
        // Delete the CA Pool.
        ApiFuture<Operation> futureCall = certificateAuthorityServiceClient.deleteCaPoolCallable().futureCall(deleteCaPoolRequest);
        Operation response = futureCall.get();
        if (response.hasError()) {
            System.out.println("Error while deleting CA pool !" + response.getError());
            return;
        }
        System.out.println("Deleted CA Pool: " + pool_Id);
    }
}
Also used : DeleteCaPoolRequest(com.google.cloud.security.privateca.v1.DeleteCaPoolRequest) CertificateAuthorityServiceClient(com.google.cloud.security.privateca.v1.CertificateAuthorityServiceClient) Operation(com.google.longrunning.Operation) CaPoolName(com.google.cloud.security.privateca.v1.CaPoolName)

Aggregations

CaPoolName (com.google.cloud.security.privateca.v1.CaPoolName)1 CertificateAuthorityServiceClient (com.google.cloud.security.privateca.v1.CertificateAuthorityServiceClient)1 DeleteCaPoolRequest (com.google.cloud.security.privateca.v1.DeleteCaPoolRequest)1 Operation (com.google.longrunning.Operation)1