use of com.google.api.services.storagetransfer.v1.model.GcsData 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.GcsData 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