Search in sources :

Example 1 with TransferOptions

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

Storagetransfer (com.google.api.services.storagetransfer.v1.Storagetransfer)1 Date (com.google.api.services.storagetransfer.v1.model.Date)1 GcsData (com.google.api.services.storagetransfer.v1.model.GcsData)1 ObjectConditions (com.google.api.services.storagetransfer.v1.model.ObjectConditions)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 TransferOptions (com.google.api.services.storagetransfer.v1.model.TransferOptions)1 TransferSpec (com.google.api.services.storagetransfer.v1.model.TransferSpec)1