Skip to content

Commit

Permalink
Merge pull request #22 from artie-labs/dana/more-schema
Browse files Browse the repository at this point in the history
Schema improvements
  • Loading branch information
danafallon authored Jul 31, 2024
2 parents f9a3200 + f175939 commit 29cfd29
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 70 deletions.
2 changes: 0 additions & 2 deletions docs/resources/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ Artie Deployment resource
### Read-Only

- `company_uuid` (String)
- `has_undeployed_changes` (Boolean)
- `last_updated_at` (String)
- `uuid` (String)

<a id="nestedatt--destination_config"></a>
Expand Down
1 change: 0 additions & 1 deletion docs/resources/destination.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Artie Destination resource
### Read-Only

- `company_uuid` (String)
- `last_updated_at` (String)
- `ssh_tunnel_uuid` (String)
- `uuid` (String)

Expand Down
69 changes: 36 additions & 33 deletions internal/provider/deployment_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/boolplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/int64planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/objectplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
Expand Down Expand Up @@ -42,13 +44,11 @@ func (r *DeploymentResource) Schema(ctx context.Context, req resource.SchemaRequ
resp.Schema = schema.Schema{
MarkdownDescription: "Artie Deployment resource",
Attributes: map[string]schema.Attribute{
"uuid": schema.StringAttribute{Computed: true, PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
"company_uuid": schema.StringAttribute{Computed: true, PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
"name": schema.StringAttribute{Required: true},
"status": schema.StringAttribute{Computed: true, Optional: true, PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
"destination_uuid": schema.StringAttribute{Computed: true, Optional: true, PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
"last_updated_at": schema.StringAttribute{Computed: true},
"has_undeployed_changes": schema.BoolAttribute{Computed: true},
"uuid": schema.StringAttribute{Computed: true, PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
"company_uuid": schema.StringAttribute{Computed: true, PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
"name": schema.StringAttribute{Required: true},
"status": schema.StringAttribute{Computed: true, Optional: true, PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
"destination_uuid": schema.StringAttribute{Computed: true, Optional: true, PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
"source": schema.SingleNestedAttribute{
Required: true,
Attributes: map[string]schema.Attribute{
Expand All @@ -66,12 +66,13 @@ func (r *DeploymentResource) Schema(ctx context.Context, req resource.SchemaRequ
Optional: true,
Computed: true,
Attributes: map[string]schema.Attribute{
"region": schema.StringAttribute{Optional: true, Computed: true, Default: stringdefault.StaticString("")},
"table_name": schema.StringAttribute{Optional: true, Computed: true, Default: stringdefault.StaticString("")},
"streams_arn": schema.StringAttribute{Optional: true, Computed: true, Default: stringdefault.StaticString("")},
"aws_access_key_id": schema.StringAttribute{Optional: true, Computed: true, Default: stringdefault.StaticString("")},
"aws_secret_access_key": schema.StringAttribute{Optional: true, Computed: true, Default: stringdefault.StaticString("")},
"region": schema.StringAttribute{Optional: true, Computed: true, Default: stringdefault.StaticString(""), PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
"table_name": schema.StringAttribute{Optional: true, Computed: true, Default: stringdefault.StaticString(""), PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
"streams_arn": schema.StringAttribute{Optional: true, Computed: true, Default: stringdefault.StaticString(""), PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
"aws_access_key_id": schema.StringAttribute{Optional: true, Computed: true, Default: stringdefault.StaticString(""), PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
"aws_secret_access_key": schema.StringAttribute{Optional: true, Computed: true, Default: stringdefault.StaticString(""), PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
},
PlanModifiers: []planmodifier.Object{objectplanmodifier.UseStateForUnknown()},
},
},
},
Expand All @@ -82,15 +83,15 @@ func (r *DeploymentResource) Schema(ctx context.Context, req resource.SchemaRequ
"uuid": schema.StringAttribute{Computed: true, PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
"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)},
"enable_history_mode": schema.BoolAttribute{Optional: true, Computed: true, Default: booldefault.StaticBool(false), PlanModifiers: []planmodifier.Bool{boolplanmodifier.UseStateForUnknown()}},
"individual_deployment": schema.BoolAttribute{Optional: true, Computed: true, Default: booldefault.StaticBool(false), PlanModifiers: []planmodifier.Bool{boolplanmodifier.UseStateForUnknown()}},
"is_partitioned": schema.BoolAttribute{Optional: true, Computed: true, Default: booldefault.StaticBool(false), PlanModifiers: []planmodifier.Bool{boolplanmodifier.UseStateForUnknown()}},
"advanced_settings": schema.SingleNestedAttribute{
Optional: true,
Computed: 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)},
"alias": schema.StringAttribute{Optional: true, Computed: true, Default: stringdefault.StaticString(""), PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
"skip_delete": schema.BoolAttribute{Optional: true, Computed: true, Default: booldefault.StaticBool(false), PlanModifiers: []planmodifier.Bool{boolplanmodifier.UseStateForUnknown()}},
"flush_interval_seconds": schema.Int64Attribute{Optional: true, Computed: true, PlanModifiers: []planmodifier.Int64{int64planmodifier.UseStateForUnknown()}},
"buffer_rows": schema.Int64Attribute{Optional: true, Computed: true, PlanModifiers: []planmodifier.Int64{int64planmodifier.UseStateForUnknown()}},
"flush_size_kb": schema.Int64Attribute{Optional: true, Computed: true, PlanModifiers: []planmodifier.Int64{int64planmodifier.UseStateForUnknown()}},
Expand All @@ -100,6 +101,7 @@ func (r *DeploymentResource) Schema(ctx context.Context, req resource.SchemaRequ
"k8s_request_memory_mb": schema.Int64Attribute{Optional: true, Computed: true, PlanModifiers: []planmodifier.Int64{int64planmodifier.UseStateForUnknown()}},
// TODO BigQueryPartitionSettings, MergePredicates, ExcludeColumns
},
PlanModifiers: []planmodifier.Object{objectplanmodifier.UseStateForUnknown()},
},
},
},
Expand All @@ -110,31 +112,32 @@ func (r *DeploymentResource) Schema(ctx context.Context, req resource.SchemaRequ
Optional: true,
Computed: 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)},
"drop_deleted_columns": schema.BoolAttribute{Optional: true, Computed: true, Default: booldefault.StaticBool(false), PlanModifiers: []planmodifier.Bool{boolplanmodifier.UseStateForUnknown()}},
"include_artie_updated_at_column": schema.BoolAttribute{Optional: true, Computed: true, Default: booldefault.StaticBool(true), PlanModifiers: []planmodifier.Bool{boolplanmodifier.UseStateForUnknown()}},
"include_database_updated_at_column": schema.BoolAttribute{Optional: true, Computed: true, Default: booldefault.StaticBool(false), PlanModifiers: []planmodifier.Bool{boolplanmodifier.UseStateForUnknown()}},
"enable_heartbeats": schema.BoolAttribute{Optional: true, Computed: true, Default: booldefault.StaticBool(false), PlanModifiers: []planmodifier.Bool{boolplanmodifier.UseStateForUnknown()}},
"enable_soft_delete": schema.BoolAttribute{Optional: true, Computed: true, Default: booldefault.StaticBool(false), PlanModifiers: []planmodifier.Bool{boolplanmodifier.UseStateForUnknown()}},
"flush_interval_seconds": schema.Int64Attribute{Optional: true, Computed: true, PlanModifiers: []planmodifier.Int64{int64planmodifier.UseStateForUnknown()}},
"buffer_rows": schema.Int64Attribute{Optional: true, Computed: true, PlanModifiers: []planmodifier.Int64{int64planmodifier.UseStateForUnknown()}},
"flush_size_kb": schema.Int64Attribute{Optional: true, Computed: true, PlanModifiers: []planmodifier.Int64{int64planmodifier.UseStateForUnknown()}},
"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("")},
"publication_name_override": schema.StringAttribute{Optional: true, Computed: true, Default: stringdefault.StaticString(""), PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
"replication_slot_override": schema.StringAttribute{Optional: true, Computed: true, Default: stringdefault.StaticString(""), PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
"publication_auto_create_mode": schema.StringAttribute{Optional: true, Computed: true, Default: stringdefault.StaticString(""), PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
// TODO PartitionRegex
},
PlanModifiers: []planmodifier.Object{objectplanmodifier.UseStateForUnknown()},
},
"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("")},
"database": schema.StringAttribute{Optional: true, Computed: true, Default: stringdefault.StaticString(""), PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
"schema": schema.StringAttribute{Optional: true, Computed: true, Default: stringdefault.StaticString(""), PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
"dataset": schema.StringAttribute{Optional: true, Computed: true, Default: stringdefault.StaticString(""), PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
"use_same_schema_as_source": schema.BoolAttribute{Optional: true, Computed: true, Default: booldefault.StaticBool(false), PlanModifiers: []planmodifier.Bool{boolplanmodifier.UseStateForUnknown()}},
"schema_name_prefix": schema.StringAttribute{Optional: true, Computed: true, Default: stringdefault.StaticString(""), PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
"schema_override": schema.StringAttribute{Optional: true, Computed: true, Default: stringdefault.StaticString(""), PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
"bucket_name": schema.StringAttribute{Optional: true, Computed: true, Default: stringdefault.StaticString(""), PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
"optional_prefix": schema.StringAttribute{Optional: true, Computed: true, Default: stringdefault.StaticString(""), PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
},
},
},
Expand Down
1 change: 0 additions & 1 deletion internal/provider/destination_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ func (r *DestinationResource) Schema(ctx context.Context, req resource.SchemaReq
"ssh_tunnel_uuid": schema.StringAttribute{Computed: true, PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
"name": schema.StringAttribute{Required: true},
"label": schema.StringAttribute{Optional: true},
"last_updated_at": schema.StringAttribute{Computed: true, PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
"config": schema.SingleNestedAttribute{
Required: true,
Attributes: map[string]schema.Attribute{
Expand Down
18 changes: 8 additions & 10 deletions internal/provider/models/deployment_api_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@ type DeploymentAPIResponse struct {
}

type DeploymentAPIModel struct {
UUID string `json:"uuid"`
CompanyUUID string `json:"companyUUID"`
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"`
UUID string `json:"uuid"`
CompanyUUID string `json:"companyUUID"`
Name string `json:"name"`
Status string `json:"status"`
DestinationUUID string `json:"destinationUUID"`
Source SourceAPIModel `json:"source"`
AdvancedSettings *DeploymentAdvancedSettingsAPIModel `json:"advancedSettings"`
DestinationConfig DestinationConfigAPIModel `json:"uniqueConfig"`
}

type SourceAPIModel struct {
Expand Down
18 changes: 8 additions & 10 deletions internal/provider/models/deployment_resource_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@ package models
import "github.com/hashicorp/terraform-plugin-framework/types"

type DeploymentResourceModel struct {
UUID types.String `tfsdk:"uuid"`
CompanyUUID types.String `tfsdk:"company_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 *DeploymentDestinationConfigModel `tfsdk:"destination_config"`
UUID types.String `tfsdk:"uuid"`
CompanyUUID types.String `tfsdk:"company_uuid"`
Name types.String `tfsdk:"name"`
Status types.String `tfsdk:"status"`
DestinationUUID types.String `tfsdk:"destination_uuid"`
Source *SourceModel `tfsdk:"source"`
AdvancedSettings *DeploymentAdvancedSettingsModel `tfsdk:"advanced_settings"`
DestinationConfig *DeploymentDestinationConfigModel `tfsdk:"destination_config"`
}

type SourceModel struct {
Expand Down
1 change: 0 additions & 1 deletion internal/provider/models/destination_api_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ type DestinationAPIModel struct {
CompanyUUID string `json:"companyUUID"`
Name string `json:"name"`
Label string `json:"label"`
LastUpdatedAt string `json:"lastUpdatedAt"`
SSHTunnelUUID string `json:"sshTunnelUUID"`
Config DestinationSharedConfigAPIModel `json:"sharedConfig"`
}
Expand Down
1 change: 0 additions & 1 deletion internal/provider/models/destination_resource_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ type DestinationResourceModel struct {
SSHTunnelUUID types.String `tfsdk:"ssh_tunnel_uuid"`
Name types.String `tfsdk:"name"`
Label types.String `tfsdk:"label"`
LastUpdatedAt types.String `tfsdk:"last_updated_at"`
Config *DestinationSharedConfigModel `tfsdk:"config"`
}

Expand Down
Loading

0 comments on commit 29cfd29

Please sign in to comment.