use of com.google.privacy.dlp.v2.LocationName in project java-docs-samples by GoogleCloudPlatform.
the class WorkflowsQuickstartTest method deployWorkflow.
private static void deployWorkflow(String projectId, String location, String workflowId) throws IOException, InterruptedException, ExecutionException {
if (workflowsClient == null) {
workflowsClient = WorkflowsClient.create();
}
LocationName parent = LocationName.of(projectId, location);
String source = new String(Files.readAllBytes(Paths.get("src/test/java/com/example/workflows/resources/source.yaml")));
Workflow workflow = Workflow.newBuilder().setSourceContents(source).build();
// Deploy workflow
workflowsClient.createWorkflowAsync(parent, workflow, workflowId).get();
}
use of com.google.privacy.dlp.v2.LocationName in project java-kms by googleapis.
the class GenerateRandomBytes method generateRandomBytes.
// Create a new key for use with MacSign.
public void generateRandomBytes(String projectId, String locationId, int numBytes) throws IOException {
// safely clean up any remaining background resources.
try (KeyManagementServiceClient client = KeyManagementServiceClient.create()) {
// Build the parent name for the location.
LocationName locationName = LocationName.of(projectId, locationId);
// Generate the bytes.
GenerateRandomBytesResponse response = client.generateRandomBytes(locationName.toString(), numBytes, ProtectionLevel.HSM);
// The data comes back as raw bytes, which may include non-printable
// characters. This base64-encodes the result so it can be printed below.
String encodedData = Base64.getEncoder().encodeToString(response.getData().toByteArray());
System.out.printf("Random bytes: %s", encodedData);
}
}
use of com.google.privacy.dlp.v2.LocationName in project java-kms by googleapis.
the class Quickstart method quickstart.
public void quickstart(String projectId, String locationId) throws IOException {
// safely clean up any remaining background resources.
try (KeyManagementServiceClient client = KeyManagementServiceClient.create()) {
// Build the parent from the project and location.
LocationName parent = LocationName.of(projectId, locationId);
// Call the API.
ListKeyRingsPagedResponse response = client.listKeyRings(parent);
// Iterate over each key ring and print its name.
System.out.println("key rings:");
for (KeyRing keyRing : response.iterateAll()) {
System.out.printf("%s%n", keyRing.getName());
}
}
}
use of com.google.privacy.dlp.v2.LocationName in project java-dlp by googleapis.
the class DlpServiceClientTest method listDeidentifyTemplatesExceptionTest.
@Test
public void listDeidentifyTemplatesExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockDlpService.addException(exception);
try {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
client.listDeidentifyTemplates(parent);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.privacy.dlp.v2.LocationName in project java-dlp by googleapis.
the class DlpServiceClientTest method listStoredInfoTypesExceptionTest.
@Test
public void listStoredInfoTypesExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockDlpService.addException(exception);
try {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
client.listStoredInfoTypes(parent);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
Aggregations