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();
}
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());
}
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());
}
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();
}
Aggregations