Search in sources :

Example 76 with LocationName

use of com.google.cloud.servicedirectory.v1.LocationName in project java-docs-samples by GoogleCloudPlatform.

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());
    }
}
Also used : KeyRing(com.google.cloud.kms.v1.KeyRing) KeyManagementServiceClient(com.google.cloud.kms.v1.KeyManagementServiceClient) LocationName(com.google.cloud.kms.v1.LocationName)

Example 77 with LocationName

use of com.google.cloud.servicedirectory.v1.LocationName in project java-docs-samples by GoogleCloudPlatform.

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());
        }
    }
}
Also used : ListKeyRingsPagedResponse(com.google.cloud.kms.v1.KeyManagementServiceClient.ListKeyRingsPagedResponse) KeyRing(com.google.cloud.kms.v1.KeyRing) KeyManagementServiceClient(com.google.cloud.kms.v1.KeyManagementServiceClient) LocationName(com.google.cloud.kms.v1.LocationName)

Example 78 with LocationName

use of com.google.cloud.servicedirectory.v1.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();
}
Also used : Workflow(com.google.cloud.workflows.v1.Workflow) LocationName(com.google.cloud.workflows.v1.LocationName)

Example 79 with LocationName

use of com.google.cloud.servicedirectory.v1.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);
    }
}
Also used : GenerateRandomBytesResponse(com.google.cloud.kms.v1.GenerateRandomBytesResponse) KeyManagementServiceClient(com.google.cloud.kms.v1.KeyManagementServiceClient) LocationName(com.google.cloud.kms.v1.LocationName)

Example 80 with LocationName

use of com.google.cloud.servicedirectory.v1.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());
        }
    }
}
Also used : ListKeyRingsPagedResponse(com.google.cloud.kms.v1.KeyManagementServiceClient.ListKeyRingsPagedResponse) KeyRing(com.google.cloud.kms.v1.KeyRing) KeyManagementServiceClient(com.google.cloud.kms.v1.KeyManagementServiceClient) LocationName(com.google.cloud.kms.v1.LocationName)

Aggregations

LocationName (com.google.cloud.aiplatform.v1.LocationName)36 Test (org.junit.Test)35 LocationName (com.google.privacy.dlp.v2.LocationName)22 OrganizationLocationName (com.google.privacy.dlp.v2.OrganizationLocationName)22 LocationName (com.google.cloud.translate.v3beta1.LocationName)18 TranslationServiceClient (com.google.cloud.translate.v3beta1.TranslationServiceClient)18 AbstractMessage (com.google.protobuf.AbstractMessage)18 AutoMlClient (com.google.cloud.automl.v1.AutoMlClient)17 LocationName (com.google.cloud.automl.v1.LocationName)17 JobServiceClient (com.google.cloud.aiplatform.v1.JobServiceClient)15 JobServiceSettings (com.google.cloud.aiplatform.v1.JobServiceSettings)15 Value (com.google.protobuf.Value)15 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)14 Model (com.google.cloud.aiplatform.v1.Model)14 StatusRuntimeException (io.grpc.StatusRuntimeException)14 PipelineServiceClient (com.google.cloud.aiplatform.v1.PipelineServiceClient)13 PipelineServiceSettings (com.google.cloud.aiplatform.v1.PipelineServiceSettings)13 TrainingPipeline (com.google.cloud.aiplatform.v1.TrainingPipeline)13 LocationName (com.google.cloud.translate.v3.LocationName)13 TranslationServiceClient (com.google.cloud.translate.v3.TranslationServiceClient)13