use of com.google.cloud.tasks.v2.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.tasks.v2.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.tasks.v2.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.tasks.v2.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());
}
}
use of com.google.cloud.tasks.v2.LocationName in project java-security-private-ca by googleapis.
the class ListCaPools method listCaPools.
// List all CA pools present in the given project and location.
public static void listCaPools(String project, String location) throws IOException {
// clean up any remaining background resources.
try (CertificateAuthorityServiceClient certificateAuthorityServiceClient = CertificateAuthorityServiceClient.create()) {
// Set the Location Name which contains project and location of the pool.
LocationName locationName = LocationName.newBuilder().setProject(project).setLocation(location).build();
String caPoolName = "";
System.out.println("Available CA pools: ");
// List the CA pools.
for (CaPool caPool : certificateAuthorityServiceClient.listCaPools(locationName).iterateAll()) {
caPoolName = caPool.getName();
// caPoolName represents the full resource name of the
// format 'projects/{project-id}/locations/{location}/ca-pools/{ca-pool-id}'.
// Hence stripping it down to just CA pool id.
System.out.println(caPoolName.substring(caPoolName.lastIndexOf("/") + 1) + " " + caPool.isInitialized());
}
}
}
Aggregations