Search in sources :

Example 6 with ImportJob

use of com.google.cloud.kms.v1.ImportJob in project gapic-generator-java by googleapis.

the class SyncCreateImportJobStringStringImportjob method syncCreateImportJobStringStringImportjob.

public static void syncCreateImportJobStringStringImportjob() throws Exception {
    // It may require modifications to work in your environment.
    try (KeyManagementServiceClient keyManagementServiceClient = KeyManagementServiceClient.create()) {
        String parent = KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]").toString();
        String importJobId = "importJobId1449444627";
        ImportJob importJob = ImportJob.newBuilder().build();
        ImportJob response = keyManagementServiceClient.createImportJob(parent, importJobId, importJob);
    }
}
Also used : ImportJob(com.google.cloud.kms.v1.ImportJob) KeyManagementServiceClient(com.google.cloud.kms.v1.KeyManagementServiceClient)

Example 7 with ImportJob

use of com.google.cloud.kms.v1.ImportJob in project gapic-generator-java by googleapis.

the class SyncGetImportJobString method syncGetImportJobString.

public static void syncGetImportJobString() throws Exception {
    // It may require modifications to work in your environment.
    try (KeyManagementServiceClient keyManagementServiceClient = KeyManagementServiceClient.create()) {
        String name = ImportJobName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[IMPORT_JOB]").toString();
        ImportJob response = keyManagementServiceClient.getImportJob(name);
    }
}
Also used : ImportJob(com.google.cloud.kms.v1.ImportJob) KeyManagementServiceClient(com.google.cloud.kms.v1.KeyManagementServiceClient)

Example 8 with ImportJob

use of com.google.cloud.kms.v1.ImportJob in project java-kms by googleapis.

the class KeyManagementServiceClientTest method listImportJobsTest.

@Test
public void listImportJobsTest() throws Exception {
    ImportJob responsesElement = ImportJob.newBuilder().build();
    ListImportJobsResponse expectedResponse = ListImportJobsResponse.newBuilder().setNextPageToken("").addAllImportJobs(Arrays.asList(responsesElement)).build();
    mockKeyManagementService.addResponse(expectedResponse);
    KeyRingName parent = KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]");
    ListImportJobsPagedResponse pagedListResponse = client.listImportJobs(parent);
    List<ImportJob> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getImportJobsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockKeyManagementService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListImportJobsRequest actualRequest = ((ListImportJobsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListImportJobsPagedResponse(com.google.cloud.kms.v1.KeyManagementServiceClient.ListImportJobsPagedResponse) Test(org.junit.Test)

Example 9 with ImportJob

use of com.google.cloud.kms.v1.ImportJob in project java-kms by googleapis.

the class KeyManagementServiceClientTest method listImportJobsTest2.

@Test
public void listImportJobsTest2() throws Exception {
    ImportJob responsesElement = ImportJob.newBuilder().build();
    ListImportJobsResponse expectedResponse = ListImportJobsResponse.newBuilder().setNextPageToken("").addAllImportJobs(Arrays.asList(responsesElement)).build();
    mockKeyManagementService.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListImportJobsPagedResponse pagedListResponse = client.listImportJobs(parent);
    List<ImportJob> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getImportJobsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockKeyManagementService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListImportJobsRequest actualRequest = ((ListImportJobsRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListImportJobsPagedResponse(com.google.cloud.kms.v1.KeyManagementServiceClient.ListImportJobsPagedResponse) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 10 with ImportJob

use of com.google.cloud.kms.v1.ImportJob in project gapic-generator-java by googleapis.

the class AsyncImportCryptoKeyVersion method asyncImportCryptoKeyVersion.

public static void asyncImportCryptoKeyVersion() throws Exception {
    // It may require modifications to work in your environment.
    try (KeyManagementServiceClient keyManagementServiceClient = KeyManagementServiceClient.create()) {
        ImportCryptoKeyVersionRequest request = ImportCryptoKeyVersionRequest.newBuilder().setParent(CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]").toString()).setImportJob("importJob-208547368").build();
        ApiFuture<CryptoKeyVersion> future = keyManagementServiceClient.importCryptoKeyVersionCallable().futureCall(request);
        // Do something.
        CryptoKeyVersion response = future.get();
    }
}
Also used : CryptoKeyVersion(com.google.cloud.kms.v1.CryptoKeyVersion) ImportCryptoKeyVersionRequest(com.google.cloud.kms.v1.ImportCryptoKeyVersionRequest) KeyManagementServiceClient(com.google.cloud.kms.v1.KeyManagementServiceClient)

Aggregations

KeyManagementServiceClient (com.google.cloud.kms.v1.KeyManagementServiceClient)12 ImportJob (com.google.cloud.kms.v1.ImportJob)10 ListImportJobsPagedResponse (com.google.cloud.kms.v1.KeyManagementServiceClient.ListImportJobsPagedResponse)4 AbstractMessage (com.google.protobuf.AbstractMessage)4 Test (org.junit.Test)4 CreateImportJobRequest (com.google.cloud.kms.v1.CreateImportJobRequest)2 CryptoKeyVersion (com.google.cloud.kms.v1.CryptoKeyVersion)2 GetImportJobRequest (com.google.cloud.kms.v1.GetImportJobRequest)2 ImportCryptoKeyVersionRequest (com.google.cloud.kms.v1.ImportCryptoKeyVersionRequest)2 ListImportJobsRequest (com.google.cloud.kms.v1.ListImportJobsRequest)2 ByteString (com.google.protobuf.ByteString)2 ImportJobName (com.google.cloud.kms.v1.ImportJobName)1 KeyRingName (com.google.cloud.kms.v1.KeyRingName)1 ListImportJobsResponse (com.google.cloud.kms.v1.ListImportJobsResponse)1