Search in sources :

Example 46 with LocationName

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()));
}
Also used : ListDlpJobsPagedResponse(com.google.cloud.dlp.v2.DlpServiceClient.ListDlpJobsPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) ListDlpJobsRequest(com.google.privacy.dlp.v2.ListDlpJobsRequest) DlpJob(com.google.privacy.dlp.v2.DlpJob) ListDlpJobsResponse(com.google.privacy.dlp.v2.ListDlpJobsResponse) OrganizationLocationName(com.google.privacy.dlp.v2.OrganizationLocationName) LocationName(com.google.privacy.dlp.v2.LocationName) Test(org.junit.Test)

Example 47 with LocationName

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()));
}
Also used : ListBucketsResponse(com.google.logging.v2.ListBucketsResponse) ListBucketsPagedResponse(com.google.cloud.logging.v2.ConfigClient.ListBucketsPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) ListBucketsRequest(com.google.logging.v2.ListBucketsRequest) LogBucket(com.google.logging.v2.LogBucket) BillingAccountLocationName(com.google.logging.v2.BillingAccountLocationName) OrganizationLocationName(com.google.logging.v2.OrganizationLocationName) FolderLocationName(com.google.logging.v2.FolderLocationName) LocationName(com.google.logging.v2.LocationName) Test(org.junit.Test)

Example 48 with LocationName

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());
        }
    }
}
Also used : Namespace(com.google.cloud.servicedirectory.v1.Namespace) RegistrationServiceClient(com.google.cloud.servicedirectory.v1.RegistrationServiceClient) LocationName(com.google.cloud.servicedirectory.v1.LocationName) ListNamespacesPagedResponse(com.google.cloud.servicedirectory.v1.RegistrationServiceClient.ListNamespacesPagedResponse)

Example 49 with LocationName

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()));
}
Also used : ListEkmConnectionsPagedResponse(com.google.cloud.kms.v1.EkmServiceClient.ListEkmConnectionsPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Test(org.junit.Test)

Example 50 with LocationName

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

Aggregations

Test (org.junit.Test)34 LocationName (com.google.privacy.dlp.v2.LocationName)22 OrganizationLocationName (com.google.privacy.dlp.v2.OrganizationLocationName)22 AbstractMessage (com.google.protobuf.AbstractMessage)18 AutoMlClient (com.google.cloud.automl.v1.AutoMlClient)17 LocationName (com.google.cloud.automl.v1.LocationName)17 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)16 StatusRuntimeException (io.grpc.StatusRuntimeException)14 LocationName (com.google.cloud.translate.v3.LocationName)13 TranslationServiceClient (com.google.cloud.translate.v3.TranslationServiceClient)13 OperationMetadata (com.google.cloud.automl.v1.OperationMetadata)12 AutoMlClient (com.google.cloud.automl.v1beta1.AutoMlClient)12 LocationName (com.google.cloud.automl.v1beta1.LocationName)12 LocationName (com.google.cloud.translate.v3beta1.LocationName)10 TranslationServiceClient (com.google.cloud.translate.v3beta1.TranslationServiceClient)10 Model (com.google.cloud.automl.v1.Model)8 LocationName (com.google.cloud.bigquery.connection.v1.LocationName)8 Dataset (com.google.cloud.automl.v1.Dataset)7 Dataset (com.google.cloud.automl.v1beta1.Dataset)6 CloudTasksClient (com.google.cloud.tasks.v2.CloudTasksClient)5