Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for lastUpdatedPartitionConfig in Terraform #15271

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/8363.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
healthcare: added `last_updated_partition_config` field to `google_healthcare_fhir_store` resource
```
4 changes: 4 additions & 0 deletions google/resource_healthcare_fhir_store_generated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ resource "google_healthcare_fhir_store" "default" {
dataset_uri = "bq://${google_bigquery_dataset.bq_dataset.project}.${google_bigquery_dataset.bq_dataset.dataset_id}"
schema_config {
recursive_structure_depth = 3
last_updated_partition_config {
type = "HOUR"
expiration_ms = 1000000
}
}
}
}
Expand Down
87 changes: 87 additions & 0 deletions google/services/healthcare/resource_healthcare_fhir_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,27 @@ resource is a recursive structure; when the depth is 2, the CodeSystem table wil
concept.concept but not concept.concept.concept. If not specified or set to 0, the server will use the default
value 2. The maximum depth allowed is 5.`,
},
"last_updated_partition_config": {
Type: schema.TypeList,
Optional: true,
Description: `The configuration for exported BigQuery tables to be partitioned by FHIR resource's last updated time column.`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"type": {
Type: schema.TypeString,
Required: true,
ValidateFunc: verify.ValidateEnum([]string{"PARTITION_TYPE_UNSPECIFIED", "HOUR", "DAY", "MONTH", "YEAR"}),
Description: `Type of partitioning. Possible values: ["PARTITION_TYPE_UNSPECIFIED", "HOUR", "DAY", "MONTH", "YEAR"]`,
},
"expiration_ms": {
Type: schema.TypeString,
Optional: true,
Description: `Number of milliseconds for which to keep the storage for a partition.`,
},
},
},
},
"schema_type": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -689,6 +710,8 @@ func flattenHealthcareFhirStoreStreamConfigsBigqueryDestinationSchemaConfig(v in
flattenHealthcareFhirStoreStreamConfigsBigqueryDestinationSchemaConfigSchemaType(original["schemaType"], d, config)
transformed["recursive_structure_depth"] =
flattenHealthcareFhirStoreStreamConfigsBigqueryDestinationSchemaConfigRecursiveStructureDepth(original["recursiveStructureDepth"], d, config)
transformed["last_updated_partition_config"] =
flattenHealthcareFhirStoreStreamConfigsBigqueryDestinationSchemaConfigLastUpdatedPartitionConfig(original["lastUpdatedPartitionConfig"], d, config)
return []interface{}{transformed}
}
func flattenHealthcareFhirStoreStreamConfigsBigqueryDestinationSchemaConfigSchemaType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
Expand All @@ -712,6 +735,29 @@ func flattenHealthcareFhirStoreStreamConfigsBigqueryDestinationSchemaConfigRecur
return v // let terraform core handle it otherwise
}

func flattenHealthcareFhirStoreStreamConfigsBigqueryDestinationSchemaConfigLastUpdatedPartitionConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
if v == nil {
return nil
}
original := v.(map[string]interface{})
if len(original) == 0 {
return nil
}
transformed := make(map[string]interface{})
transformed["type"] =
flattenHealthcareFhirStoreStreamConfigsBigqueryDestinationSchemaConfigLastUpdatedPartitionConfigType(original["type"], d, config)
transformed["expiration_ms"] =
flattenHealthcareFhirStoreStreamConfigsBigqueryDestinationSchemaConfigLastUpdatedPartitionConfigExpirationMs(original["expirationMs"], d, config)
return []interface{}{transformed}
}
func flattenHealthcareFhirStoreStreamConfigsBigqueryDestinationSchemaConfigLastUpdatedPartitionConfigType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}

func flattenHealthcareFhirStoreStreamConfigsBigqueryDestinationSchemaConfigLastUpdatedPartitionConfigExpirationMs(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}

func expandHealthcareFhirStoreName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
Expand Down Expand Up @@ -860,6 +906,13 @@ func expandHealthcareFhirStoreStreamConfigsBigqueryDestinationSchemaConfig(v int
transformed["recursiveStructureDepth"] = transformedRecursiveStructureDepth
}

transformedLastUpdatedPartitionConfig, err := expandHealthcareFhirStoreStreamConfigsBigqueryDestinationSchemaConfigLastUpdatedPartitionConfig(original["last_updated_partition_config"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedLastUpdatedPartitionConfig); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["lastUpdatedPartitionConfig"] = transformedLastUpdatedPartitionConfig
}

return transformed, nil
}

Expand All @@ -871,6 +924,40 @@ func expandHealthcareFhirStoreStreamConfigsBigqueryDestinationSchemaConfigRecurs
return v, nil
}

func expandHealthcareFhirStoreStreamConfigsBigqueryDestinationSchemaConfigLastUpdatedPartitionConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
l := v.([]interface{})
if len(l) == 0 || l[0] == nil {
return nil, nil
}
raw := l[0]
original := raw.(map[string]interface{})
transformed := make(map[string]interface{})

transformedType, err := expandHealthcareFhirStoreStreamConfigsBigqueryDestinationSchemaConfigLastUpdatedPartitionConfigType(original["type"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedType); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["type"] = transformedType
}

transformedExpirationMs, err := expandHealthcareFhirStoreStreamConfigsBigqueryDestinationSchemaConfigLastUpdatedPartitionConfigExpirationMs(original["expiration_ms"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedExpirationMs); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["expirationMs"] = transformedExpirationMs
}

return transformed, nil
}

func expandHealthcareFhirStoreStreamConfigsBigqueryDestinationSchemaConfigLastUpdatedPartitionConfigType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}

func expandHealthcareFhirStoreStreamConfigsBigqueryDestinationSchemaConfigLastUpdatedPartitionConfigExpirationMs(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}

func resourceHealthcareFhirStoreDecoder(d *schema.ResourceData, meta interface{}, res map[string]interface{}) (map[string]interface{}, error) {
// Take the returned long form of the name and use it as `self_link`.
// Then modify the name to be the user specified form.
Expand Down
21 changes: 21 additions & 0 deletions website/docs/r/healthcare_fhir_store.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ resource "google_healthcare_fhir_store" "default" {
dataset_uri = "bq://${google_bigquery_dataset.bq_dataset.project}.${google_bigquery_dataset.bq_dataset.dataset_id}"
schema_config {
recursive_structure_depth = 3
last_updated_partition_config {
type = "HOUR"
expiration_ms = 1000000
}
}
}
}
Expand Down Expand Up @@ -355,6 +359,23 @@ The following arguments are supported:
concept.concept but not concept.concept.concept. If not specified or set to 0, the server will use the default
value 2. The maximum depth allowed is 5.

* `last_updated_partition_config` -
(Optional)
The configuration for exported BigQuery tables to be partitioned by FHIR resource's last updated time column.
Structure is [documented below](#nested_last_updated_partition_config).


<a name="nested_last_updated_partition_config"></a>The `last_updated_partition_config` block supports:

* `type` -
(Required)
Type of partitioning.
Possible values are: `PARTITION_TYPE_UNSPECIFIED`, `HOUR`, `DAY`, `MONTH`, `YEAR`.

* `expiration_ms` -
(Optional)
Number of milliseconds for which to keep the storage for a partition.

<a name="nested_notification_configs"></a>The `notification_configs` block supports:

* `pubsub_topic` -
Expand Down