Search in sources :

Example 1 with AwsS3Data

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

Aggregations

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