Skip to content

Instantly share code, notes, and snippets.

@ruseel
Created August 1, 2018 09:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruseel/df5f8cf1adb1ff928bbc839a8d057db6 to your computer and use it in GitHub Desktop.
Save ruseel/df5f8cf1adb1ff928bbc839a8d057db6 to your computer and use it in GitHub Desktop.
scala - google storage transfer job create
#
# service-account can call Google StorageTransfer API.
#
import scala.collection.JavaConversions._
val c = createStorageTransferClient
val j = new TransferJob()
.setProjectId("projec-id-a")
.setDescription("dsec ...")
.setSchedule(new Schedule()
.setScheduleStartDate(
new Date().setYear(2018).setMonth(8).setDay(1)
)
.setScheduleEndDate(
new Date().setYear(2018).setMonth(8).setDay(1)
))
.setStatus("ENABLED")
.setTransferSpec(
new TransferSpec()
.setAwsS3DataSource(
new AwsS3Data()
.setBucketName("aws-bucket-name")
.setAwsAccessKey(
new AwsAccessKey()
.setAccessKeyId("ACCESS_KEY_ID__SHOUD_BE_REPLACED")
.setSecretAccessKey("SECRET_ACCESS_KEY_ID__SHOUD_BE_REPLACED")))
.setObjectConditions(
new ObjectConditions()
.setIncludePrefixes(List("test-r1/"))
)
.setGcsDataSink(
new GcsData()
.setBucketName("gcs-bucket-name")
))
val res = c.transferJobs().create(j).execute()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment