diff --git a/docs/resources/deployment.md b/docs/resources/deployment.md index e27b9a4..f8dce28 100644 --- a/docs/resources/deployment.md +++ b/docs/resources/deployment.md @@ -17,14 +17,124 @@ Artie Deployment resource ### Required +- `destination_config` (Attributes) (see [below for nested schema](#nestedatt--destination_config)) - `name` (String) +- `source` (Attributes) (see [below for nested schema](#nestedatt--source)) ### Optional +- `advanced_settings` (Attributes) (see [below for nested schema](#nestedatt--advanced_settings)) - `status` (String) ### Read-Only +- `destination_uuid` (String) - `has_undeployed_changes` (Boolean) - `last_updated_at` (String) - `uuid` (String) + + +### Nested Schema for `destination_config` + +Optional: + +- `bucket_name` (String) +- `database` (String) +- `dataset` (String) +- `optional_prefix` (String) +- `schema` (String) +- `schema_name_prefix` (String) +- `schema_override` (String) +- `use_same_schema_as_source` (Boolean) + + + +### Nested Schema for `source` + +Required: + +- `config` (Attributes) (see [below for nested schema](#nestedatt--source--config)) +- `name` (String) +- `tables` (Attributes List) (see [below for nested schema](#nestedatt--source--tables)) + + +### Nested Schema for `source.config` + +Required: + +- `database` (String) +- `host` (String) +- `port` (Number) +- `user` (String) + +Optional: + +- `dynamodb` (Attributes) (see [below for nested schema](#nestedatt--source--config--dynamodb)) +- `snapshot_host` (String) + + +### Nested Schema for `source.config.dynamodb` + +Optional: + +- `aws_access_key_id` (String) +- `aws_secret_access_key` (String) +- `region` (String) +- `streams_arn` (String) +- `table_name` (String) + + + + +### Nested Schema for `source.tables` + +Required: + +- `name` (String) +- `schema` (String) + +Optional: + +- `advanced_settings` (Attributes) (see [below for nested schema](#nestedatt--source--tables--advanced_settings)) +- `enable_history_mode` (Boolean) +- `individual_deployment` (Boolean) +- `is_partitioned` (Boolean) + +Read-Only: + +- `uuid` (String) + + +### Nested Schema for `source.tables.advanced_settings` + +Optional: + +- `alias` (String) +- `autoscale_max_replicas` (Number) +- `autoscale_target_value` (Number) +- `buffer_rows` (Number) +- `flush_interval_seconds` (Number) +- `flush_size_kb` (Number) +- `k8s_request_cpu` (Number) +- `k8s_request_memory_mb` (Number) +- `skip_delete` (Boolean) + + + + + +### Nested Schema for `advanced_settings` + +Optional: + +- `buffer_rows` (Number) +- `drop_deleted_columns` (Boolean) +- `enable_heartbeats` (Boolean) +- `enable_soft_delete` (Boolean) +- `flush_interval_seconds` (Number) +- `flush_size_kb` (Number) +- `include_artie_updated_at_column` (Boolean) +- `include_database_updated_at_column` (Boolean) +- `publication_auto_create_mode` (String) +- `publication_name_override` (String) +- `replication_slot_override` (String) diff --git a/examples/deployments/main.tf b/examples/deployments/main.tf index f4388fe..e3cd1b1 100644 --- a/examples/deployments/main.tf +++ b/examples/deployments/main.tf @@ -17,6 +17,35 @@ import { resource "artie_deployment" "example" { name = "MongoDB ➡️ BigQuery" + source = { + name = "MongoDB" + config = { + database = "myFirstDatabase" + host = "mongodb+srv://cluster0.szddg49.mongodb.net/" + port = 0 + user = "artie" + } + tables = [ + { + name = "customers" + schema = "" + advanced_settings = { + skip_delete = false + } + }, + { + name = "stock" + schema = "" + } + ] + } + destination_config = { + dataset = "customers" + } + advanced_settings = { + enable_soft_delete = true + flush_interval_seconds = 60 + } } # data "artie_deployments" "example" {} diff --git a/internal/provider/deployment_resource.go b/internal/provider/deployment_resource.go index 66b347f..44561a3 100644 --- a/internal/provider/deployment_resource.go +++ b/internal/provider/deployment_resource.go @@ -6,11 +6,13 @@ import ( "fmt" "io" "net/http" + "terraform-provider-artie/internal/provider/models" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/resource/schema" - "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault" "github.com/hashicorp/terraform-plugin-log/tflog" ) @@ -28,26 +30,6 @@ type DeploymentResource struct { apiKey string } -type DeploymentResourceModel struct { - UUID types.String `tfsdk:"uuid"` - Name types.String `tfsdk:"name"` - Status types.String `tfsdk:"status"` - LastUpdatedAt types.String `tfsdk:"last_updated_at"` - HasUndeployedChanges types.Bool `tfsdk:"has_undeployed_changes"` -} - -type DeploymentResponse struct { - Deployment DeploymentResourceAPIModel `json:"deploy"` -} - -type DeploymentResourceAPIModel struct { - UUID string `json:"uuid"` - Name string `json:"name"` - Status string `json:"status"` - LastUpdatedAt string `json:"lastUpdatedAt"` - HasUndeployedChanges bool `json:"hasUndeployedChanges"` -} - func (r *DeploymentResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = req.ProviderTypeName + "_deployment" } @@ -60,7 +42,94 @@ func (r *DeploymentResource) Schema(ctx context.Context, req resource.SchemaRequ "name": schema.StringAttribute{Required: true}, "status": schema.StringAttribute{Computed: true, Optional: true}, "last_updated_at": schema.StringAttribute{Computed: true}, + "destination_uuid": schema.StringAttribute{Computed: true}, "has_undeployed_changes": schema.BoolAttribute{Computed: true}, + "source": schema.SingleNestedAttribute{ + Required: true, + Attributes: map[string]schema.Attribute{ + "name": schema.StringAttribute{Required: true}, + "config": schema.SingleNestedAttribute{ + Required: true, + Attributes: map[string]schema.Attribute{ + "host": schema.StringAttribute{Required: true}, + "snapshot_host": schema.StringAttribute{Optional: true}, + "port": schema.Int64Attribute{Required: true}, + "user": schema.StringAttribute{Required: true}, + "database": schema.StringAttribute{Required: true}, + "dynamodb": schema.SingleNestedAttribute{ + Optional: true, + Attributes: map[string]schema.Attribute{ + "region": schema.StringAttribute{Optional: true}, + "table_name": schema.StringAttribute{Optional: true}, + "streams_arn": schema.StringAttribute{Optional: true}, + "aws_access_key_id": schema.StringAttribute{Optional: true}, + "aws_secret_access_key": schema.StringAttribute{Optional: true}, + }, + }, + // TODO Password + }, + }, + "tables": schema.ListNestedAttribute{ + Required: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "uuid": schema.StringAttribute{Computed: true}, + "name": schema.StringAttribute{Required: true}, + "schema": schema.StringAttribute{Required: true}, + "enable_history_mode": schema.BoolAttribute{Optional: true, Computed: true, Default: booldefault.StaticBool(false)}, + "individual_deployment": schema.BoolAttribute{Optional: true, Computed: true, Default: booldefault.StaticBool(false)}, + "is_partitioned": schema.BoolAttribute{Optional: true, Computed: true, Default: booldefault.StaticBool(false)}, + "advanced_settings": schema.SingleNestedAttribute{ + Optional: true, + Attributes: map[string]schema.Attribute{ + "alias": schema.StringAttribute{Optional: true, Computed: true, Default: stringdefault.StaticString("")}, + "skip_delete": schema.BoolAttribute{Optional: true, Computed: true, Default: booldefault.StaticBool(false)}, + "flush_interval_seconds": schema.Int64Attribute{Optional: true, Computed: true}, + "buffer_rows": schema.Int64Attribute{Optional: true, Computed: true}, + "flush_size_kb": schema.Int64Attribute{Optional: true, Computed: true}, + "autoscale_max_replicas": schema.Int64Attribute{Optional: true, Computed: true}, + "autoscale_target_value": schema.Int64Attribute{Optional: true, Computed: true}, + "k8s_request_cpu": schema.Int64Attribute{Optional: true, Computed: true}, + "k8s_request_memory_mb": schema.Int64Attribute{Optional: true, Computed: true}, + // TODO BigQueryPartitionSettings, MergePredicates, ExcludeColumns + }, + Computed: true, + }, + }, + }, + }, + }, + }, + "advanced_settings": schema.SingleNestedAttribute{ + Optional: true, + Attributes: map[string]schema.Attribute{ + "drop_deleted_columns": schema.BoolAttribute{Optional: true, Computed: true, Default: booldefault.StaticBool(false)}, + "include_artie_updated_at_column": schema.BoolAttribute{Optional: true, Computed: true, Default: booldefault.StaticBool(true)}, + "include_database_updated_at_column": schema.BoolAttribute{Optional: true, Computed: true, Default: booldefault.StaticBool(false)}, + "enable_heartbeats": schema.BoolAttribute{Optional: true, Computed: true, Default: booldefault.StaticBool(false)}, + "enable_soft_delete": schema.BoolAttribute{Optional: true, Computed: true, Default: booldefault.StaticBool(false)}, + "flush_interval_seconds": schema.Int64Attribute{Optional: true, Computed: true}, + "buffer_rows": schema.Int64Attribute{Optional: true, Computed: true}, + "flush_size_kb": schema.Int64Attribute{Optional: true, Computed: true}, + "publication_name_override": schema.StringAttribute{Optional: true, Computed: true, Default: stringdefault.StaticString("")}, + "replication_slot_override": schema.StringAttribute{Optional: true, Computed: true, Default: stringdefault.StaticString("")}, + "publication_auto_create_mode": schema.StringAttribute{Optional: true, Computed: true, Default: stringdefault.StaticString("")}, + // TODO PartitionRegex + }, + }, + "destination_config": schema.SingleNestedAttribute{ + Required: true, + Attributes: map[string]schema.Attribute{ + "database": schema.StringAttribute{Optional: true, Computed: true, Default: stringdefault.StaticString("")}, + "schema": schema.StringAttribute{Optional: true, Computed: true, Default: stringdefault.StaticString("")}, + "dataset": schema.StringAttribute{Optional: true, Computed: true, Default: stringdefault.StaticString("")}, + "use_same_schema_as_source": schema.BoolAttribute{Optional: true, Computed: true, Default: booldefault.StaticBool(false)}, + "schema_name_prefix": schema.StringAttribute{Optional: true, Computed: true, Default: stringdefault.StaticString("")}, + "schema_override": schema.StringAttribute{Optional: true, Computed: true, Default: stringdefault.StaticString("")}, + "bucket_name": schema.StringAttribute{Optional: true, Computed: true, Default: stringdefault.StaticString("")}, + "optional_prefix": schema.StringAttribute{Optional: true, Computed: true, Default: stringdefault.StaticString("")}, + }, + }, }, } } @@ -86,7 +155,7 @@ func (r *DeploymentResource) Configure(ctx context.Context, req resource.Configu } func (r *DeploymentResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var data DeploymentResourceModel + var data models.DeploymentResourceModel // Read Terraform plan data into the model resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...) @@ -116,7 +185,7 @@ func (r *DeploymentResource) Create(ctx context.Context, req resource.CreateRequ } func (r *DeploymentResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { - var data DeploymentResourceModel + var data models.DeploymentResourceModel // Read Terraform prior state data into the model resp.Diagnostics.Append(req.State.Get(ctx, &data)...) @@ -149,24 +218,22 @@ func (r *DeploymentResource) Read(ctx context.Context, req resource.ReadRequest, return } - var deploymentResp DeploymentResponse + var deploymentResp models.DeploymentAPIResponse err = json.Unmarshal(bodyBytes, &deploymentResp) if err != nil { resp.Diagnostics.AddError("Unable to Read Deployment", err.Error()) return } - data.Name = types.StringValue(deploymentResp.Deployment.Name) - data.Status = types.StringValue(deploymentResp.Deployment.Status) - data.LastUpdatedAt = types.StringValue(deploymentResp.Deployment.LastUpdatedAt) - data.HasUndeployedChanges = types.BoolValue(deploymentResp.Deployment.HasUndeployedChanges) + // Translate API response into Terraform state + models.DeploymentAPIToResourceModel(deploymentResp.Deployment, &data) // Save updated data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) } func (r *DeploymentResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { - var data DeploymentResourceModel + var data models.DeploymentResourceModel // Read Terraform plan data into the model resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...) @@ -188,7 +255,7 @@ func (r *DeploymentResource) Update(ctx context.Context, req resource.UpdateRequ } func (r *DeploymentResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { - var data DeploymentResourceModel + var data models.DeploymentResourceModel // Read Terraform prior state data into the model resp.Diagnostics.Append(req.State.Get(ctx, &data)...) diff --git a/internal/provider/models/deployment_api_model.go b/internal/provider/models/deployment_api_model.go new file mode 100644 index 0000000..f9d3324 --- /dev/null +++ b/internal/provider/models/deployment_api_model.go @@ -0,0 +1,90 @@ +package models + +type DeploymentAPIResponse struct { + Deployment DeploymentAPIModel `json:"deploy"` +} + +type DeploymentAPIModel struct { + UUID string `json:"uuid"` + Name string `json:"name"` + Status string `json:"status"` + LastUpdatedAt string `json:"lastUpdatedAt"` + DestinationUUID string `json:"destinationUUID"` + HasUndeployedChanges bool `json:"hasUndeployedChanges"` + Source SourceAPIModel `json:"source"` + AdvancedSettings DeploymentAdvancedSettingsAPIModel `json:"advancedSettings"` + DestinationConfig DestinationConfigAPIModel `json:"uniqueConfig"` +} + +type SourceAPIModel struct { + Name string `json:"name"` + Config SourceConfigAPIModel `json:"config"` + Tables []TableAPIModel `json:"tables"` +} + +type SourceConfigAPIModel struct { + Host string `json:"host"` + SnapshotHost string `json:"snapshotHost"` + Port int64 `json:"port"` + User string `json:"user"` + Database string `json:"database"` + DynamoDB DynamoDBConfigAPIModel `json:"dynamodb"` + // TODO Password +} + +type DynamoDBConfigAPIModel struct { + Region string `json:"region"` + TableName string `json:"tableName"` + StreamsArn string `json:"streamsArn"` + AwsAccessKeyID string `json:"awsAccessKeyId"` + AwsSecretAccessKey string `json:"awsSecretAccessKey"` +} + +type TableAPIModel struct { + UUID string `json:"uuid"` + Name string `json:"name"` + Schema string `json:"schema"` + EnableHistoryMode bool `json:"enableHistoryMode"` + IndividualDeployment bool `json:"individualDeployment"` + IsPartitioned bool `json:"isPartitioned"` + AdvancedSettings TableAdvancedSettingsAPIModel `json:"advancedSettings"` +} + +type TableAdvancedSettingsAPIModel struct { + Alias string `json:"alias"` + SkipDelete bool `json:"skipDelete"` + FlushIntervalSeconds int64 `json:"flushIntervalSeconds"` + BufferRows int64 `json:"bufferRows"` + FlushSizeKB int64 `json:"flushSizeKb"` + AutoscaleMaxReplicas int64 `json:"autoscaleMaxReplicas"` + AutoscaleTargetValue int64 `json:"autoscaleTargetValue"` + K8sRequestCPU int64 `json:"k8sRequestCPU"` + K8sRequestMemoryMB int64 `json:"k8sRequestMemoryMB"` + // TODO BigQueryPartitionSettings, MergePredicates, ExcludeColumns +} + +type DeploymentAdvancedSettingsAPIModel struct { + DropDeletedColumns bool `json:"dropDeletedColumns"` + IncludeArtieUpdatedAtColumn bool `json:"includeArtieUpdatedAtColumn"` + IncludeDatabaseUpdatedAtColumn bool `json:"includeDatabaseUpdatedAtColumn"` + EnableHeartbeats bool `json:"enableHeartbeats"` + EnableSoftDelete bool `json:"enableSoftDelete"` + FlushIntervalSeconds int64 `json:"flushIntervalSeconds"` + BufferRows int64 `json:"bufferRows"` + FlushSizeKB int64 `json:"flushSizeKb"` + PublicationNameOverride string `json:"publicationNameOverride"` + ReplicationSlotOverride string `json:"replicationSlotOverride"` + PublicationAutoCreateMode string `json:"publicationAutoCreateMode"` + // TODO PartitionRegex +} + +type DestinationConfigAPIModel struct { + Dataset string `json:"dataset"` + Database string `json:"database"` + Schema string `json:"schema"` + SchemaOverride string `json:"schemaOverride"` + UseSameSchemaAsSource bool `json:"useSameSchemaAsSource"` + SchemaNamePrefix string `json:"schemaNamePrefix"` + BucketName string `json:"bucketName"` + OptionalPrefix string `json:"optionalPrefix"` +} diff --git a/internal/provider/models/deployment_resource_model.go b/internal/provider/models/deployment_resource_model.go new file mode 100644 index 0000000..9b1c49c --- /dev/null +++ b/internal/provider/models/deployment_resource_model.go @@ -0,0 +1,88 @@ +package models + +import "github.com/hashicorp/terraform-plugin-framework/types" + +type DeploymentResourceModel struct { + UUID types.String `tfsdk:"uuid"` + Name types.String `tfsdk:"name"` + Status types.String `tfsdk:"status"` + LastUpdatedAt types.String `tfsdk:"last_updated_at"` + DestinationUUID types.String `tfsdk:"destination_uuid"` + HasUndeployedChanges types.Bool `tfsdk:"has_undeployed_changes"` + Source *SourceModel `tfsdk:"source"` + AdvancedSettings *DeploymentAdvancedSettingsModel `tfsdk:"advanced_settings"` + DestinationConfig *DestinationConfigModel `tfsdk:"destination_config"` +} + +type SourceModel struct { + Name types.String `tfsdk:"name"` + Config SourceConfigModel `tfsdk:"config"` + Tables []TableModel `tfsdk:"tables"` +} + +type SourceConfigModel struct { + Host types.String `tfsdk:"host"` + SnapshotHost types.String `tfsdk:"snapshot_host"` + Port types.Int64 `tfsdk:"port"` + User types.String `tfsdk:"user"` + Database types.String `tfsdk:"database"` + DynamoDB *DynamoDBConfigModel `tfsdk:"dynamodb"` + // TODO Password +} + +type DynamoDBConfigModel struct { + Region types.String `tfsdk:"region"` + TableName types.String `tfsdk:"table_name"` + StreamsArn types.String `tfsdk:"streams_arn"` + AwsAccessKeyID types.String `tfsdk:"aws_access_key_id"` + AwsSecretAccessKey types.String `tfsdk:"aws_secret_access_key"` +} + +type TableModel struct { + UUID types.String `tfsdk:"uuid"` + Name types.String `tfsdk:"name"` + Schema types.String `tfsdk:"schema"` + EnableHistoryMode types.Bool `tfsdk:"enable_history_mode"` + IndividualDeployment types.Bool `tfsdk:"individual_deployment"` + IsPartitioned types.Bool `tfsdk:"is_partitioned"` + AdvancedSettings TableAdvancedSettingsModel `tfsdk:"advanced_settings"` +} + +type TableAdvancedSettingsModel struct { + Alias types.String `tfsdk:"alias"` + SkipDelete types.Bool `tfsdk:"skip_delete"` + FlushIntervalSeconds types.Int64 `tfsdk:"flush_interval_seconds"` + BufferRows types.Int64 `tfsdk:"buffer_rows"` + FlushSizeKB types.Int64 `tfsdk:"flush_size_kb"` + AutoscaleMaxReplicas types.Int64 `tfsdk:"autoscale_max_replicas"` + AutoscaleTargetValue types.Int64 `tfsdk:"autoscale_target_value"` + K8sRequestCPU types.Int64 `tfsdk:"k8s_request_cpu"` + K8sRequestMemoryMB types.Int64 `tfsdk:"k8s_request_memory_mb"` + // TODO BigQueryPartitionSettings, MergePredicates, ExcludeColumns +} + +type DeploymentAdvancedSettingsModel struct { + DropDeletedColumns types.Bool `tfsdk:"drop_deleted_columns"` + IncludeArtieUpdatedAtColumn types.Bool `tfsdk:"include_artie_updated_at_column"` + IncludeDatabaseUpdatedAtColumn types.Bool `tfsdk:"include_database_updated_at_column"` + EnableHeartbeats types.Bool `tfsdk:"enable_heartbeats"` + EnableSoftDelete types.Bool `tfsdk:"enable_soft_delete"` + FlushIntervalSeconds types.Int64 `tfsdk:"flush_interval_seconds"` + BufferRows types.Int64 `tfsdk:"buffer_rows"` + FlushSizeKB types.Int64 `tfsdk:"flush_size_kb"` + PublicationNameOverride types.String `tfsdk:"publication_name_override"` + ReplicationSlotOverride types.String `tfsdk:"replication_slot_override"` + PublicationAutoCreateMode types.String `tfsdk:"publication_auto_create_mode"` + // TODO PartitionRegex +} + +type DestinationConfigModel struct { + Dataset types.String `tfsdk:"dataset"` + Database types.String `tfsdk:"database"` + Schema types.String `tfsdk:"schema"` + SchemaOverride types.String `tfsdk:"schema_override"` + UseSameSchemaAsSource types.Bool `tfsdk:"use_same_schema_as_source"` + SchemaNamePrefix types.String `tfsdk:"schema_name_prefix"` + BucketName types.String `tfsdk:"bucket_name"` + OptionalPrefix types.String `tfsdk:"optional_prefix"` +} diff --git a/internal/provider/models/translate.go b/internal/provider/models/translate.go new file mode 100644 index 0000000..e6ba9de --- /dev/null +++ b/internal/provider/models/translate.go @@ -0,0 +1,78 @@ +package models + +import "github.com/hashicorp/terraform-plugin-framework/types" + +func DeploymentAPIToResourceModel(apiModel DeploymentAPIModel, resourceModel *DeploymentResourceModel) { + resourceModel.Name = types.StringValue(apiModel.Name) + resourceModel.Status = types.StringValue(apiModel.Status) + resourceModel.LastUpdatedAt = types.StringValue(apiModel.LastUpdatedAt) + resourceModel.HasUndeployedChanges = types.BoolValue(apiModel.HasUndeployedChanges) + resourceModel.DestinationUUID = types.StringValue(apiModel.DestinationUUID) + + tables := []TableModel{} + for _, apiTable := range apiModel.Source.Tables { + tables = append(tables, TableModel{ + UUID: types.StringValue(apiTable.UUID), + Name: types.StringValue(apiTable.Name), + Schema: types.StringValue(apiTable.Schema), + EnableHistoryMode: types.BoolValue(apiTable.EnableHistoryMode), + IndividualDeployment: types.BoolValue(apiTable.IndividualDeployment), + IsPartitioned: types.BoolValue(apiTable.IsPartitioned), + AdvancedSettings: TableAdvancedSettingsModel{ + Alias: types.StringValue(apiTable.AdvancedSettings.Alias), + SkipDelete: types.BoolValue(apiTable.AdvancedSettings.SkipDelete), + FlushIntervalSeconds: types.Int64Value(apiTable.AdvancedSettings.FlushIntervalSeconds), + BufferRows: types.Int64Value(apiTable.AdvancedSettings.BufferRows), + FlushSizeKB: types.Int64Value(apiTable.AdvancedSettings.FlushSizeKB), + AutoscaleMaxReplicas: types.Int64Value(apiTable.AdvancedSettings.AutoscaleMaxReplicas), + AutoscaleTargetValue: types.Int64Value(apiTable.AdvancedSettings.AutoscaleTargetValue), + K8sRequestCPU: types.Int64Value(apiTable.AdvancedSettings.K8sRequestCPU), + K8sRequestMemoryMB: types.Int64Value(apiTable.AdvancedSettings.K8sRequestMemoryMB), + // TODO BigQueryPartitionSettings, MergePredicates, ExcludeColumns + }, + }) + } + resourceModel.Source = &SourceModel{ + Name: types.StringValue(apiModel.Source.Name), + Config: SourceConfigModel{ + Host: types.StringValue(apiModel.Source.Config.Host), + SnapshotHost: types.StringValue(apiModel.Source.Config.SnapshotHost), + Port: types.Int64Value(apiModel.Source.Config.Port), + User: types.StringValue(apiModel.Source.Config.User), + Database: types.StringValue(apiModel.Source.Config.Database), + DynamoDB: &DynamoDBConfigModel{ + Region: types.StringValue(apiModel.Source.Config.DynamoDB.Region), + TableName: types.StringValue(apiModel.Source.Config.DynamoDB.TableName), + StreamsArn: types.StringValue(apiModel.Source.Config.DynamoDB.StreamsArn), + AwsAccessKeyID: types.StringValue(apiModel.Source.Config.DynamoDB.AwsAccessKeyID), + AwsSecretAccessKey: types.StringValue(apiModel.Source.Config.DynamoDB.AwsSecretAccessKey), + }, + // TODO Password + }, + Tables: tables, + } + resourceModel.DestinationConfig = &DestinationConfigModel{ + Dataset: types.StringValue(apiModel.DestinationConfig.Dataset), + Database: types.StringValue(apiModel.DestinationConfig.Database), + Schema: types.StringValue(apiModel.DestinationConfig.Schema), + SchemaOverride: types.StringValue(apiModel.DestinationConfig.SchemaOverride), + UseSameSchemaAsSource: types.BoolValue(apiModel.DestinationConfig.UseSameSchemaAsSource), + SchemaNamePrefix: types.StringValue(apiModel.DestinationConfig.SchemaNamePrefix), + BucketName: types.StringValue(apiModel.DestinationConfig.BucketName), + OptionalPrefix: types.StringValue(apiModel.DestinationConfig.OptionalPrefix), + } + resourceModel.AdvancedSettings = &DeploymentAdvancedSettingsModel{ + DropDeletedColumns: types.BoolValue(apiModel.AdvancedSettings.DropDeletedColumns), + IncludeArtieUpdatedAtColumn: types.BoolValue(apiModel.AdvancedSettings.IncludeArtieUpdatedAtColumn), + IncludeDatabaseUpdatedAtColumn: types.BoolValue(apiModel.AdvancedSettings.IncludeDatabaseUpdatedAtColumn), + EnableHeartbeats: types.BoolValue(apiModel.AdvancedSettings.EnableHeartbeats), + EnableSoftDelete: types.BoolValue(apiModel.AdvancedSettings.EnableSoftDelete), + FlushIntervalSeconds: types.Int64Value(apiModel.AdvancedSettings.FlushIntervalSeconds), + BufferRows: types.Int64Value(apiModel.AdvancedSettings.BufferRows), + FlushSizeKB: types.Int64Value(apiModel.AdvancedSettings.FlushSizeKB), + PublicationNameOverride: types.StringValue(apiModel.AdvancedSettings.PublicationNameOverride), + ReplicationSlotOverride: types.StringValue(apiModel.AdvancedSettings.ReplicationSlotOverride), + PublicationAutoCreateMode: types.StringValue(apiModel.AdvancedSettings.PublicationAutoCreateMode), + // TODO PartitionRegex + } +}