Search in sources :

Example 1 with ListTransferConfigsRequest

use of com.google.cloud.bigquery.datatransfer.v1.ListTransferConfigsRequest in project java-bigquerydatatransfer by googleapis.

the class ListTransferConfigs method listTransferConfigs.

public static void listTransferConfigs(String projectId) throws IOException {
    try (DataTransferServiceClient dataTransferServiceClient = DataTransferServiceClient.create()) {
        ProjectName parent = ProjectName.of(projectId);
        ListTransferConfigsRequest request = ListTransferConfigsRequest.newBuilder().setParent(parent.toString()).build();
        dataTransferServiceClient.listTransferConfigs(request).iterateAll().forEach(config -> System.out.print("Success! Config ID :" + config.getName() + "\n"));
    } catch (ApiException ex) {
        System.out.println("Config list not found due to error." + ex.toString());
    }
}
Also used : ListTransferConfigsRequest(com.google.cloud.bigquery.datatransfer.v1.ListTransferConfigsRequest) DataTransferServiceClient(com.google.cloud.bigquery.datatransfer.v1.DataTransferServiceClient) ProjectName(com.google.cloud.bigquery.datatransfer.v1.ProjectName) ApiException(com.google.api.gax.rpc.ApiException)

Example 2 with ListTransferConfigsRequest

use of com.google.cloud.bigquery.datatransfer.v1.ListTransferConfigsRequest in project java-bigquerydatatransfer by googleapis.

the class DataTransferServiceClientTest method listTransferConfigsTest3.

@Test
public void listTransferConfigsTest3() throws Exception {
    TransferConfig responsesElement = TransferConfig.newBuilder().build();
    ListTransferConfigsResponse expectedResponse = ListTransferConfigsResponse.newBuilder().setNextPageToken("").addAllTransferConfigs(Arrays.asList(responsesElement)).build();
    mockDataTransferService.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListTransferConfigsPagedResponse pagedListResponse = client.listTransferConfigs(parent);
    List<TransferConfig> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getTransferConfigsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockDataTransferService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListTransferConfigsRequest actualRequest = ((ListTransferConfigsRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListTransferConfigsPagedResponse(com.google.cloud.bigquery.datatransfer.v1.DataTransferServiceClient.ListTransferConfigsPagedResponse) Test(org.junit.Test)

Example 3 with ListTransferConfigsRequest

use of com.google.cloud.bigquery.datatransfer.v1.ListTransferConfigsRequest in project java-bigquerydatatransfer by googleapis.

the class DataTransferServiceClientTest method listTransferConfigsTest2.

@Test
public void listTransferConfigsTest2() throws Exception {
    TransferConfig responsesElement = TransferConfig.newBuilder().build();
    ListTransferConfigsResponse expectedResponse = ListTransferConfigsResponse.newBuilder().setNextPageToken("").addAllTransferConfigs(Arrays.asList(responsesElement)).build();
    mockDataTransferService.addResponse(expectedResponse);
    ProjectName parent = ProjectName.of("[PROJECT]");
    ListTransferConfigsPagedResponse pagedListResponse = client.listTransferConfigs(parent);
    List<TransferConfig> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getTransferConfigsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockDataTransferService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListTransferConfigsRequest actualRequest = ((ListTransferConfigsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListTransferConfigsPagedResponse(com.google.cloud.bigquery.datatransfer.v1.DataTransferServiceClient.ListTransferConfigsPagedResponse) Test(org.junit.Test)

Example 4 with ListTransferConfigsRequest

use of com.google.cloud.bigquery.datatransfer.v1.ListTransferConfigsRequest in project java-bigquerydatatransfer by googleapis.

the class DataTransferServiceClientTest method listTransferConfigsTest.

@Test
public void listTransferConfigsTest() throws Exception {
    TransferConfig responsesElement = TransferConfig.newBuilder().build();
    ListTransferConfigsResponse expectedResponse = ListTransferConfigsResponse.newBuilder().setNextPageToken("").addAllTransferConfigs(Arrays.asList(responsesElement)).build();
    mockDataTransferService.addResponse(expectedResponse);
    LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
    ListTransferConfigsPagedResponse pagedListResponse = client.listTransferConfigs(parent);
    List<TransferConfig> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getTransferConfigsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockDataTransferService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListTransferConfigsRequest actualRequest = ((ListTransferConfigsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListTransferConfigsPagedResponse(com.google.cloud.bigquery.datatransfer.v1.DataTransferServiceClient.ListTransferConfigsPagedResponse) Test(org.junit.Test)

Aggregations

ListTransferConfigsPagedResponse (com.google.cloud.bigquery.datatransfer.v1.DataTransferServiceClient.ListTransferConfigsPagedResponse)3 AbstractMessage (com.google.protobuf.AbstractMessage)3 Test (org.junit.Test)3 ApiException (com.google.api.gax.rpc.ApiException)1 DataTransferServiceClient (com.google.cloud.bigquery.datatransfer.v1.DataTransferServiceClient)1 ListTransferConfigsRequest (com.google.cloud.bigquery.datatransfer.v1.ListTransferConfigsRequest)1 ProjectName (com.google.cloud.bigquery.datatransfer.v1.ProjectName)1