Search in sources :

Example 1 with CreateCaPoolRequest

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

the class CreateCaPool method createCaPool.

// Create a Certificate Authority Pool. All certificates created under this CA pool will
// follow the same issuance policy, IAM policies,etc.,
public static void createCaPool(String project, String location, String pool_Id) throws InterruptedException, ExecutionException, IOException {
    // clean up any remaining background resources.
    try (CertificateAuthorityServiceClient certificateAuthorityServiceClient = CertificateAuthorityServiceClient.create()) {
        /* Create the pool request
        Set Parent which denotes the project id and location.
        Set the Tier (see: https://cloud.google.com/certificate-authority-service/docs/tiers).
      */
        CreateCaPoolRequest caPoolRequest = CreateCaPoolRequest.newBuilder().setParent(LocationName.of(project, location).toString()).setCaPoolId(pool_Id).setCaPool(CaPool.newBuilder().setTier(Tier.ENTERPRISE).build()).build();
        // Create the CA pool.
        ApiFuture<Operation> futureCall = certificateAuthorityServiceClient.createCaPoolCallable().futureCall(caPoolRequest);
        Operation response = futureCall.get();
        if (response.hasError()) {
            System.out.println("Error while creating CA pool !" + response.getError());
            return;
        }
        System.out.println("CA pool created successfully: " + pool_Id);
    }
}
Also used : CertificateAuthorityServiceClient(com.google.cloud.security.privateca.v1.CertificateAuthorityServiceClient) CreateCaPoolRequest(com.google.cloud.security.privateca.v1.CreateCaPoolRequest) Operation(com.google.longrunning.Operation)

Aggregations

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