Search in sources :

Example 6 with TransferConfig

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

the class CreateYoutubeContentOwnerTransfer method createYoutubeContentOwnerTransfer.

public static void createYoutubeContentOwnerTransfer(String projectId, TransferConfig transferConfig) throws IOException {
    try (DataTransferServiceClient client = DataTransferServiceClient.create()) {
        ProjectName parent = ProjectName.of(projectId);
        CreateTransferConfigRequest request = CreateTransferConfigRequest.newBuilder().setParent(parent.toString()).setTransferConfig(transferConfig).build();
        TransferConfig config = client.createTransferConfig(request);
        System.out.println("Youtube content owner channel transfer created successfully :" + config.getName());
    } catch (ApiException ex) {
        System.out.print("Youtube content owner channel transfer was not created." + ex.toString());
    }
}
Also used : DataTransferServiceClient(com.google.cloud.bigquery.datatransfer.v1.DataTransferServiceClient) ProjectName(com.google.cloud.bigquery.datatransfer.v1.ProjectName) TransferConfig(com.google.cloud.bigquery.datatransfer.v1.TransferConfig) CreateTransferConfigRequest(com.google.cloud.bigquery.datatransfer.v1.CreateTransferConfigRequest) ApiException(com.google.api.gax.rpc.ApiException)

Example 7 with TransferConfig

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

the class ReEnableTransferConfig method main.

public static void main(String[] args) throws IOException {
    // TODO(developer): Replace these variables before running the sample.
    String configId = "MY_CONFIG_ID";
    TransferConfig transferConfig = TransferConfig.newBuilder().setName(configId).setDisabled(false).build();
    FieldMask updateMask = FieldMaskUtil.fromString("disabled");
    reEnableTransferConfig(transferConfig, updateMask);
}
Also used : TransferConfig(com.google.cloud.bigquery.datatransfer.v1.TransferConfig) FieldMask(com.google.protobuf.FieldMask)

Example 8 with TransferConfig

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

the class ReEnableTransferConfig method reEnableTransferConfig.

public static void reEnableTransferConfig(TransferConfig transferConfig, FieldMask updateMask) throws IOException {
    try (DataTransferServiceClient dataTransferServiceClient = DataTransferServiceClient.create()) {
        UpdateTransferConfigRequest request = UpdateTransferConfigRequest.newBuilder().setTransferConfig(transferConfig).setUpdateMask(updateMask).build();
        TransferConfig updateConfig = dataTransferServiceClient.updateTransferConfig(request);
        System.out.println("Transfer config reenable successfully :" + updateConfig.getDisplayName());
    } catch (ApiException ex) {
        System.out.print("Transfer config was not reenable." + ex.toString());
    }
}
Also used : DataTransferServiceClient(com.google.cloud.bigquery.datatransfer.v1.DataTransferServiceClient) UpdateTransferConfigRequest(com.google.cloud.bigquery.datatransfer.v1.UpdateTransferConfigRequest) TransferConfig(com.google.cloud.bigquery.datatransfer.v1.TransferConfig) ApiException(com.google.api.gax.rpc.ApiException)

Example 9 with TransferConfig

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

the class CreateAdManagerTransfer method main.

public static void main(String[] args) throws IOException {
    // TODO(developer): Replace these variables before running the sample.
    final String projectId = "MY_PROJECT_ID";
    String datasetId = "MY_DATASET_ID";
    String bucket = "gs://cloud-sample-data";
    // the network_code can only be digits with length 1 to 15
    String networkCode = "12345678";
    Map<String, Value> params = new HashMap<>();
    params.put("bucket", Value.newBuilder().setStringValue(bucket).build());
    params.put("network_code", Value.newBuilder().setStringValue(networkCode).build());
    TransferConfig transferConfig = TransferConfig.newBuilder().setDestinationDatasetId(datasetId).setDisplayName("Your Ad Manager Config Name").setDataSourceId("dfp_dt").setParams(Struct.newBuilder().putAllFields(params).build()).build();
    createAdManagerTransfer(projectId, transferConfig);
}
Also used : HashMap(java.util.HashMap) Value(com.google.protobuf.Value) TransferConfig(com.google.cloud.bigquery.datatransfer.v1.TransferConfig)

Example 10 with TransferConfig

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

the class CreateAdManagerTransfer method createAdManagerTransfer.

public static void createAdManagerTransfer(String projectId, TransferConfig transferConfig) throws IOException {
    try (DataTransferServiceClient client = DataTransferServiceClient.create()) {
        ProjectName parent = ProjectName.of(projectId);
        CreateTransferConfigRequest request = CreateTransferConfigRequest.newBuilder().setParent(parent.toString()).setTransferConfig(transferConfig).build();
        TransferConfig config = client.createTransferConfig(request);
        System.out.println("Ad manager transfer created successfully :" + config.getName());
    } catch (ApiException ex) {
        System.out.print("Ad manager transfer was not created." + ex.toString());
    }
}
Also used : DataTransferServiceClient(com.google.cloud.bigquery.datatransfer.v1.DataTransferServiceClient) ProjectName(com.google.cloud.bigquery.datatransfer.v1.ProjectName) TransferConfig(com.google.cloud.bigquery.datatransfer.v1.TransferConfig) CreateTransferConfigRequest(com.google.cloud.bigquery.datatransfer.v1.CreateTransferConfigRequest) ApiException(com.google.api.gax.rpc.ApiException)

Aggregations

TransferConfig (com.google.cloud.bigquery.datatransfer.v1.TransferConfig)49 Value (com.google.protobuf.Value)22 HashMap (java.util.HashMap)22 DataTransferServiceClient (com.google.cloud.bigquery.datatransfer.v1.DataTransferServiceClient)21 ApiException (com.google.api.gax.rpc.ApiException)19 CreateTransferConfigRequest (com.google.cloud.bigquery.datatransfer.v1.CreateTransferConfigRequest)16 ProjectName (com.google.cloud.bigquery.datatransfer.v1.ProjectName)16 Test (org.junit.Test)13 FieldMask (com.google.protobuf.FieldMask)9 UpdateTransferConfigRequest (com.google.cloud.bigquery.datatransfer.v1.UpdateTransferConfigRequest)4 ListTransferConfigsPagedResponse (com.google.cloud.bigquery.datatransfer.v1.DataTransferServiceClient.ListTransferConfigsPagedResponse)3 AbstractMessage (com.google.protobuf.AbstractMessage)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 PrintStream (java.io.PrintStream)3 Before (org.junit.Before)3 ServiceAccountCredentials (com.google.auth.oauth2.ServiceAccountCredentials)1 GetTransferConfigRequest (com.google.cloud.bigquery.datatransfer.v1.GetTransferConfigRequest)1