use of com.google.cloud.kms.v1.LocationName in project java-dlp by googleapis.
the class DlpServiceClientTest method listDlpJobsTest.
@Test
public void listDlpJobsTest() throws Exception {
DlpJob responsesElement = DlpJob.newBuilder().build();
ListDlpJobsResponse expectedResponse = ListDlpJobsResponse.newBuilder().setNextPageToken("").addAllJobs(Arrays.asList(responsesElement)).build();
mockDlpService.addResponse(expectedResponse);
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ListDlpJobsPagedResponse pagedListResponse = client.listDlpJobs(parent);
List<DlpJob> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getJobsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockDlpService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListDlpJobsRequest actualRequest = ((ListDlpJobsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.kms.v1.LocationName in project java-logging by googleapis.
the class ConfigClientTest method listBucketsTest3.
@Test
public void listBucketsTest3() throws Exception {
LogBucket responsesElement = LogBucket.newBuilder().build();
ListBucketsResponse expectedResponse = ListBucketsResponse.newBuilder().setNextPageToken("").addAllBuckets(Arrays.asList(responsesElement)).build();
mockConfigServiceV2.addResponse(expectedResponse);
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ListBucketsPagedResponse pagedListResponse = client.listBuckets(parent);
List<LogBucket> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getBucketsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockConfigServiceV2.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListBucketsRequest actualRequest = ((ListBucketsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.kms.v1.LocationName in project java-servicedirectory by googleapis.
the class Quickstart method quickstart.
public static void quickstart(String projectId, String locationId) throws IOException {
// the "close" method on the client to safely clean up any remaining background resources.
try (RegistrationServiceClient client = RegistrationServiceClient.create()) {
// The project and location that hold the namespace to list.
LocationName parent = LocationName.of(projectId, locationId);
// Call the API.
ListNamespacesPagedResponse response = client.listNamespaces(parent);
// Iterate over each namespace and print its name.
System.out.println("Namespaces:");
for (Namespace namespace : response.iterateAll()) {
System.out.println(namespace.getName());
}
}
}
use of com.google.cloud.kms.v1.LocationName in project java-kms by googleapis.
the class EkmServiceClientTest method listEkmConnectionsTest.
@Test
public void listEkmConnectionsTest() throws Exception {
EkmConnection responsesElement = EkmConnection.newBuilder().build();
ListEkmConnectionsResponse expectedResponse = ListEkmConnectionsResponse.newBuilder().setNextPageToken("").addAllEkmConnections(Arrays.asList(responsesElement)).build();
mockEkmService.addResponse(expectedResponse);
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ListEkmConnectionsPagedResponse pagedListResponse = client.listEkmConnections(parent);
List<EkmConnection> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getEkmConnectionsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockEkmService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListEkmConnectionsRequest actualRequest = ((ListEkmConnectionsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.kms.v1.LocationName in project java-kms by googleapis.
the class CreateKeyRing method createKeyRing.
// Create a new key ring.
public void createKeyRing(String projectId, String locationId, String id) throws IOException {
// safely clean up any remaining background resources.
try (KeyManagementServiceClient client = KeyManagementServiceClient.create()) {
// Build the parent name from the project and location.
LocationName locationName = LocationName.of(projectId, locationId);
// Build the key ring to create.
KeyRing keyRing = KeyRing.newBuilder().build();
// Create the key ring.
KeyRing createdKeyRing = client.createKeyRing(locationName, id, keyRing);
System.out.printf("Created key ring %s%n", createdKeyRing.getName());
}
}
Aggregations