|
| 1 | +package adapters |
| 2 | + |
| 3 | +import ( |
| 4 | + "fmt" |
| 5 | + |
| 6 | + "github.com/overmindtech/cli/sdp-go" |
| 7 | + gcpshared "github.com/overmindtech/cli/sources/gcp/shared" |
| 8 | +) |
| 9 | + |
| 10 | +// Storage Transfer Transfer Job facilitates data transfers between cloud storage systems and on-premises data |
| 11 | +// GCP Ref (GET): https://cloud.google.com/storage-transfer/docs/reference/rest/v1/transferJobs/get |
| 12 | +// GCP Ref (Schema): https://cloud.google.com/storage-transfer/docs/reference/rest/v1/transferJobs#TransferJob |
| 13 | +// GET https://storagetransfer.googleapis.com/v1/transferJobs/{jobName} |
| 14 | +// LIST https://storagetransfer.googleapis.com/v1/transferJobs |
| 15 | +var _ = registerableAdapter{ |
| 16 | + sdpType: gcpshared.StorageTransferTransferJob, |
| 17 | + meta: gcpshared.AdapterMeta{ |
| 18 | + SDPAdapterCategory: sdp.AdapterCategory_ADAPTER_CATEGORY_STORAGE, |
| 19 | + Scope: gcpshared.ScopeProject, |
| 20 | + GetEndpointBaseURLFunc: func(adapterInitParams ...string) (gcpshared.EndpointFunc, error) { |
| 21 | + if len(adapterInitParams) == 1 && adapterInitParams[0] != "" { |
| 22 | + return func(query string) string { |
| 23 | + if query != "" { |
| 24 | + // query is the job name, adapterInitParams[0] is the project ID |
| 25 | + return fmt.Sprintf("https://storagetransfer.googleapis.com/v1/transferJobs/%s?projectId=%s", query, adapterInitParams[0]) |
| 26 | + } |
| 27 | + return "" |
| 28 | + }, nil |
| 29 | + } |
| 30 | + return nil, fmt.Errorf("projectID cannot be empty: %v", adapterInitParams) |
| 31 | + }, |
| 32 | + ListEndpointFunc: gcpshared.ProjectLevelListFunc("https://storagetransfer.googleapis.com/v1/transferJobs?filter={\"projectId\":\"%s\"}"), |
| 33 | + UniqueAttributeKeys: []string{"transferJobs"}, |
| 34 | + IAMPermissions: []string{ |
| 35 | + "storagetransfer.jobs.get", |
| 36 | + "storagetransfer.jobs.list", |
| 37 | + }, |
| 38 | + // TODO: https://linear.app/overmind/issue/ENG-631 status |
| 39 | + // https://cloud.google.com/storage-transfer/docs/reference/rest/v1/transferJobs#TransferJob.status |
| 40 | + }, |
| 41 | + blastPropagation: map[string]*gcpshared.Impact{ |
| 42 | + // Transfer spec references to source and destination storage |
| 43 | + "transferSpec.gcsDataSource.bucketName": { |
| 44 | + ToSDPItemType: gcpshared.StorageBucket, |
| 45 | + Description: "If the source GCS bucket is deleted or inaccessible: The transfer job will fail. If the transfer job is updated: The source bucket remains unaffected.", |
| 46 | + BlastPropagation: &sdp.BlastPropagation{ |
| 47 | + In: true, |
| 48 | + }, |
| 49 | + }, |
| 50 | + "transferSpec.gcsDataSink.bucketName": { |
| 51 | + ToSDPItemType: gcpshared.StorageBucket, |
| 52 | + Description: "If the destination GCS bucket is deleted or inaccessible: The transfer job will fail. If the transfer job is updated: The destination bucket remains unaffected.", |
| 53 | + BlastPropagation: &sdp.BlastPropagation{ |
| 54 | + In: true, |
| 55 | + }, |
| 56 | + }, |
| 57 | + // TODO: Investigate how we can link to AWS and Azure source when the account id (scope) is not available |
| 58 | + // https://cloud.google.com/storage-transfer/docs/reference/rest/v1/TransferSpec#AwsS3Data |
| 59 | + // https://cloud.google.com/storage-transfer/docs/reference/rest/v1/TransferSpec#AzureBlobStorageData |
| 60 | + "transferSpec.httpDataSource.listUrl": { |
| 61 | + ToSDPItemType: gcpshared.StorageBucket, |
| 62 | + Description: "HTTP data source URL for transfer operations. If the HTTP endpoint is unreachable: The transfer job will fail to access the source data.", |
| 63 | + BlastPropagation: &sdp.BlastPropagation{ |
| 64 | + In: true, |
| 65 | + }, |
| 66 | + }, |
| 67 | + "transferSpec.gcsIntermediateDataLocation.bucketName": { |
| 68 | + ToSDPItemType: gcpshared.StorageBucket, |
| 69 | + Description: "If the destination GCS bucket is deleted or inaccessible: The transfer job will fail. If the transfer job is updated: The destination bucket remains unaffected.", |
| 70 | + BlastPropagation: &sdp.BlastPropagation{ |
| 71 | + In: true, |
| 72 | + }, |
| 73 | + }, |
| 74 | + "serviceAccount": { |
| 75 | + ToSDPItemType: gcpshared.IAMServiceAccount, |
| 76 | + Description: "If the Service Account is deleted or permissions are revoked: The transfer job may fail to execute. If the transfer job is updated: The service account remains unaffected.", |
| 77 | + BlastPropagation: &sdp.BlastPropagation{ |
| 78 | + In: true, |
| 79 | + }, |
| 80 | + }, |
| 81 | + // Notification configuration |
| 82 | + "notificationConfig.pubsubTopic": { |
| 83 | + ToSDPItemType: gcpshared.PubSubTopic, |
| 84 | + Description: "If the Pub/Sub Topic is deleted: Transfer job notifications will fail. If the transfer job is updated: The Pub/Sub topic remains unaffected.", |
| 85 | + BlastPropagation: &sdp.BlastPropagation{ |
| 86 | + In: true, |
| 87 | + }, |
| 88 | + }, |
| 89 | + // TODO: Investigate whether we can/should support multiple items for a given key. |
| 90 | + // In this case, the eventStream can be an AWS SQS ARN in the form 'arn:aws:sqs:region:account_id:queue_name' |
| 91 | + // https://linear.app/overmind/issue/ENG-1348/investigate-supporting-multiple-items-in-blast-propagations |
| 92 | + "eventStream.name": { |
| 93 | + ToSDPItemType: gcpshared.PubSubTopic, |
| 94 | + Description: "If the Pub/Sub Topic for event streaming is deleted: Transfer job events will not be published. If the transfer job is updated: The Pub/Sub topic remains unaffected.", |
| 95 | + BlastPropagation: &sdp.BlastPropagation{ |
| 96 | + In: true, |
| 97 | + }, |
| 98 | + }, |
| 99 | + }, |
| 100 | + terraformMapping: gcpshared.TerraformMapping{ |
| 101 | + Reference: "https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/storage_transfer_job", |
| 102 | + Description: "name => transferJobs/{jobName}", |
| 103 | + Mappings: []*sdp.TerraformMapping{ |
| 104 | + { |
| 105 | + TerraformMethod: sdp.QueryMethod_GET, |
| 106 | + TerraformQueryMap: "google_storage_transfer_job.name", |
| 107 | + }, |
| 108 | + }, |
| 109 | + }, |
| 110 | +}.Register() |
0 commit comments