Search in sources :

Example 1 with TransferJob

use of com.google.api.services.storagetransfer.v1.model.TransferJob in project java-docs-samples by GoogleCloudPlatform.

the class AwsRequester method createAwsTransferJob.

/**
 * Creates and executes a request for a TransferJob from Amazon S3 to Cloud Storage.
 *
 * <p>The {@code startDate} and {@code startTime} parameters should be set according to the UTC
 * Time Zone. See:
 * https://developers.google.com/resources/api-libraries/documentation/storagetransfer/v1/java/latest/com/google/api/services/storagetransfer/v1/model/Schedule.html#getStartTimeOfDay()
 *
 * @return the response TransferJob if the request is successful
 * @throws InstantiationException
 *           if instantiation fails when building the TransferJob
 * @throws IllegalAccessException
 *           if an illegal access occurs when building the TransferJob
 * @throws IOException
 *           if the client failed to complete the request
 */
public static TransferJob createAwsTransferJob(String projectId, String jobDescription, String awsSourceBucket, String gcsSinkBucket, String startDate, String startTime, String awsAccessKeyId, String awsSecretAccessKey) throws InstantiationException, IllegalAccessException, IOException {
    Date date = TransferJobUtils.createDate(startDate);
    TimeOfDay time = TransferJobUtils.createTimeOfDay(startTime);
    TransferJob transferJob = new TransferJob().setDescription(jobDescription).setProjectId(projectId).setTransferSpec(new TransferSpec().setAwsS3DataSource(new AwsS3Data().setBucketName(awsSourceBucket).setAwsAccessKey(new AwsAccessKey().setAccessKeyId(awsAccessKeyId).setSecretAccessKey(awsSecretAccessKey))).setGcsDataSink(new GcsData().setBucketName(gcsSinkBucket))).setSchedule(new Schedule().setScheduleStartDate(date).setScheduleEndDate(date).setStartTimeOfDay(time)).setStatus("ENABLED");
    Storagetransfer client = TransferClientCreator.createStorageTransferClient();
    return client.transferJobs().create(transferJob).execute();
}
Also used : TimeOfDay(com.google.api.services.storagetransfer.v1.model.TimeOfDay) TransferSpec(com.google.api.services.storagetransfer.v1.model.TransferSpec) AwsAccessKey(com.google.api.services.storagetransfer.v1.model.AwsAccessKey) Schedule(com.google.api.services.storagetransfer.v1.model.Schedule) Storagetransfer(com.google.api.services.storagetransfer.v1.Storagetransfer) Date(com.google.api.services.storagetransfer.v1.model.Date) AwsS3Data(com.google.api.services.storagetransfer.v1.model.AwsS3Data) GcsData(com.google.api.services.storagetransfer.v1.model.GcsData) TransferJob(com.google.api.services.storagetransfer.v1.model.TransferJob)

Example 2 with TransferJob

use of com.google.api.services.storagetransfer.v1.model.TransferJob in project java-docs-samples by GoogleCloudPlatform.

the class AwsRequester method run.

public static void run(PrintStream out) throws InstantiationException, IllegalAccessException, IOException {
    String projectId = TransferJobUtils.getPropertyOrFail("projectId");
    String jobDescription = TransferJobUtils.getPropertyOrFail("jobDescription");
    String awsSourceBucket = TransferJobUtils.getPropertyOrFail("awsSourceBucket");
    String gcsSinkBucket = TransferJobUtils.getPropertyOrFail("gcsSinkBucket");
    String startDate = TransferJobUtils.getPropertyOrFail("startDate");
    String startTime = TransferJobUtils.getPropertyOrFail("startTime");
    String awsAccessKeyId = TransferJobUtils.getEnvOrFail("AWS_ACCESS_KEY_ID");
    String awsSecretAccessKey = TransferJobUtils.getEnvOrFail("AWS_SECRET_ACCESS_KEY");
    TransferJob responseT = createAwsTransferJob(projectId, jobDescription, awsSourceBucket, gcsSinkBucket, startDate, startTime, awsAccessKeyId, awsSecretAccessKey);
    out.println("Return transferJob: " + responseT.toPrettyString());
}
Also used : TransferJob(com.google.api.services.storagetransfer.v1.model.TransferJob)

Example 3 with TransferJob

use of com.google.api.services.storagetransfer.v1.model.TransferJob in project java-docs-samples by GoogleCloudPlatform.

the class NearlineRequester method run.

public static void run(PrintStream out) throws InstantiationException, IllegalAccessException, IOException {
    String projectId = TransferJobUtils.getPropertyOrFail("projectId");
    String jobDescription = TransferJobUtils.getPropertyOrFail("jobDescription");
    String gcsSourceBucket = TransferJobUtils.getPropertyOrFail("gcsSourceBucket");
    String gcsNearlineSinkBucket = TransferJobUtils.getPropertyOrFail("gcsNearlineSinkBucket");
    String startDate = TransferJobUtils.getPropertyOrFail("startDate");
    String startTime = TransferJobUtils.getPropertyOrFail("startTime");
    TransferJob responseT = createNearlineTransferJob(projectId, jobDescription, gcsSourceBucket, gcsNearlineSinkBucket, startDate, startTime);
    out.println("Return transferJob: " + responseT.toPrettyString());
}
Also used : TransferJob(com.google.api.services.storagetransfer.v1.model.TransferJob)

Example 4 with TransferJob

use of com.google.api.services.storagetransfer.v1.model.TransferJob in project java-docs-samples by GoogleCloudPlatform.

the class NearlineRequester method createNearlineTransferJob.

/**
 * Creates and executes a request for a TransferJob to Cloud Storage Nearline.
 *
 * <p>The {@code startDate} and {@code startTime} parameters should be set according to the UTC
 * Time Zone. See:
 * https://developers.google.com/resources/api-libraries/documentation/storagetransfer/v1/java/latest/com/google/api/services/storagetransfer/v1/model/Schedule.html#getStartTimeOfDay()
 *
 * @return the response TransferJob if the request is successful
 * @throws InstantiationException
 *           if instantiation fails when building the TransferJob
 * @throws IllegalAccessException
 *           if an illegal access occurs when building the TransferJob
 * @throws IOException
 *           if the client failed to complete the request
 */
public static TransferJob createNearlineTransferJob(String projectId, String jobDescription, String gcsSourceBucket, String gcsNearlineSinkBucket, String startDate, String startTime) throws InstantiationException, IllegalAccessException, IOException {
    Date date = TransferJobUtils.createDate(startDate);
    TimeOfDay time = TransferJobUtils.createTimeOfDay(startTime);
    TransferJob transferJob = new TransferJob().setDescription(jobDescription).setProjectId(projectId).setTransferSpec(new TransferSpec().setGcsDataSource(new GcsData().setBucketName(gcsSourceBucket)).setGcsDataSink(new GcsData().setBucketName(gcsNearlineSinkBucket)).setObjectConditions(new ObjectConditions().setMinTimeElapsedSinceLastModification("2592000s")).setTransferOptions(new TransferOptions().setDeleteObjectsFromSourceAfterTransfer(true))).setSchedule(new Schedule().setScheduleStartDate(date).setStartTimeOfDay(time)).setStatus("ENABLED");
    Storagetransfer client = TransferClientCreator.createStorageTransferClient();
    return client.transferJobs().create(transferJob).execute();
}
Also used : TimeOfDay(com.google.api.services.storagetransfer.v1.model.TimeOfDay) TransferSpec(com.google.api.services.storagetransfer.v1.model.TransferSpec) TransferOptions(com.google.api.services.storagetransfer.v1.model.TransferOptions) ObjectConditions(com.google.api.services.storagetransfer.v1.model.ObjectConditions) Schedule(com.google.api.services.storagetransfer.v1.model.Schedule) Storagetransfer(com.google.api.services.storagetransfer.v1.Storagetransfer) Date(com.google.api.services.storagetransfer.v1.model.Date) GcsData(com.google.api.services.storagetransfer.v1.model.GcsData) TransferJob(com.google.api.services.storagetransfer.v1.model.TransferJob)

Aggregations

TransferJob (com.google.api.services.storagetransfer.v1.model.TransferJob)4 Storagetransfer (com.google.api.services.storagetransfer.v1.Storagetransfer)2 Date (com.google.api.services.storagetransfer.v1.model.Date)2 GcsData (com.google.api.services.storagetransfer.v1.model.GcsData)2 Schedule (com.google.api.services.storagetransfer.v1.model.Schedule)2 TimeOfDay (com.google.api.services.storagetransfer.v1.model.TimeOfDay)2 TransferSpec (com.google.api.services.storagetransfer.v1.model.TransferSpec)2 AwsAccessKey (com.google.api.services.storagetransfer.v1.model.AwsAccessKey)1 AwsS3Data (com.google.api.services.storagetransfer.v1.model.AwsS3Data)1 ObjectConditions (com.google.api.services.storagetransfer.v1.model.ObjectConditions)1 TransferOptions (com.google.api.services.storagetransfer.v1.model.TransferOptions)1