Skip to content

Commit

Permalink
Adding support for reject_duplicate_message flag while creating hl7v2…
Browse files Browse the repository at this point in the history
…store (#9977) (#17267)

[upstream:a81b0c649289b24114c3481128d903027fecc1d4]

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Feb 13, 2024
1 parent 9ec542c commit aae7853
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/9977.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
healthcare: added `reject_duplicate_message` field to `google_healthcare_hl7_v2_store ` resource
```
33 changes: 33 additions & 0 deletions google/services/healthcare/resource_healthcare_hl7_v2_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@ A base64-encoded string.`,
},
},
},
"reject_duplicate_message": {
Type: schema.TypeBool,
Optional: true,
Description: `Determines whether duplicate messages are allowed.`,
Default: false,
},
"effective_labels": {
Type: schema.TypeMap,
Computed: true,
Expand Down Expand Up @@ -232,6 +238,12 @@ func resourceHealthcareHl7V2StoreCreate(d *schema.ResourceData, meta interface{}
} else if v, ok := d.GetOkExists("name"); !tpgresource.IsEmptyValue(reflect.ValueOf(nameProp)) && (ok || !reflect.DeepEqual(v, nameProp)) {
obj["name"] = nameProp
}
rejectDuplicateMessageProp, err := expandHealthcareHl7V2StoreRejectDuplicateMessage(d.Get("reject_duplicate_message"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("reject_duplicate_message"); !tpgresource.IsEmptyValue(reflect.ValueOf(rejectDuplicateMessageProp)) && (ok || !reflect.DeepEqual(v, rejectDuplicateMessageProp)) {
obj["rejectDuplicateMessage"] = rejectDuplicateMessageProp
}
parserConfigProp, err := expandHealthcareHl7V2StoreParserConfig(d.Get("parser_config"), d, config)
if err != nil {
return err
Expand Down Expand Up @@ -340,6 +352,9 @@ func resourceHealthcareHl7V2StoreRead(d *schema.ResourceData, meta interface{})
if err := d.Set("name", flattenHealthcareHl7V2StoreName(res["name"], d, config)); err != nil {
return fmt.Errorf("Error reading Hl7V2Store: %s", err)
}
if err := d.Set("reject_duplicate_message", flattenHealthcareHl7V2StoreRejectDuplicateMessage(res["rejectDuplicateMessage"], d, config)); err != nil {
return fmt.Errorf("Error reading Hl7V2Store: %s", err)
}
if err := d.Set("parser_config", flattenHealthcareHl7V2StoreParserConfig(res["parserConfig"], d, config)); err != nil {
return fmt.Errorf("Error reading Hl7V2Store: %s", err)
}
Expand Down Expand Up @@ -372,6 +387,12 @@ func resourceHealthcareHl7V2StoreUpdate(d *schema.ResourceData, meta interface{}
billingProject := ""

obj := make(map[string]interface{})
rejectDuplicateMessageProp, err := expandHealthcareHl7V2StoreRejectDuplicateMessage(d.Get("reject_duplicate_message"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("reject_duplicate_message"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, rejectDuplicateMessageProp)) {
obj["rejectDuplicateMessage"] = rejectDuplicateMessageProp
}
parserConfigProp, err := expandHealthcareHl7V2StoreParserConfig(d.Get("parser_config"), d, config)
if err != nil {
return err
Expand Down Expand Up @@ -405,6 +426,10 @@ func resourceHealthcareHl7V2StoreUpdate(d *schema.ResourceData, meta interface{}
log.Printf("[DEBUG] Updating Hl7V2Store %q: %#v", d.Id(), obj)
updateMask := []string{}

if d.HasChange("reject_duplicate_message") {
updateMask = append(updateMask, "rejectDuplicateMessage")
}

if d.HasChange("parser_config") {
updateMask = append(updateMask, "parser_config.allow_null_header",
"parser_config.segment_terminator",
Expand Down Expand Up @@ -519,6 +544,10 @@ func flattenHealthcareHl7V2StoreName(v interface{}, d *schema.ResourceData, conf
return v
}

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

func flattenHealthcareHl7V2StoreParserConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
if v == nil {
return nil
Expand Down Expand Up @@ -644,6 +673,10 @@ func expandHealthcareHl7V2StoreName(v interface{}, d tpgresource.TerraformResour
return v, nil
}

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

func expandHealthcareHl7V2StoreParserConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
l := v.([]interface{})
if len(l) == 0 || l[0] == nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func testAccHealthcareHl7V2Store_healthcareHl7V2StoreBasicExample(context map[st
resource "google_healthcare_hl7_v2_store" "store" {
name = "tf-test-example-hl7-v2-store%{random_suffix}"
dataset = google_healthcare_dataset.dataset.id
reject_duplicate_message = true
notification_configs {
pubsub_topic = google_pubsub_topic.topic.id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ func testGoogleHealthcareHl7V2Store_basic(hl7_v2StoreName, datasetName string) s
resource "google_healthcare_hl7_v2_store" "default" {
name = "%s"
dataset = google_healthcare_dataset.dataset.id
reject_duplicate_message = true
}
resource "google_healthcare_dataset" "dataset" {
Expand Down
5 changes: 5 additions & 0 deletions website/docs/r/healthcare_hl7_v2_store.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ To get more information about Hl7V2Store, see:
resource "google_healthcare_hl7_v2_store" "store" {
name = "example-hl7-v2-store"
dataset = google_healthcare_dataset.dataset.id
reject_duplicate_message = true
notification_configs {
pubsub_topic = google_pubsub_topic.topic.id
Expand Down Expand Up @@ -213,6 +214,10 @@ The following arguments are supported:
- - -


* `reject_duplicate_message` -
(Optional)
Determines whether duplicate messages are allowed.

* `parser_config` -
(Optional)
A nested object resource
Expand Down

0 comments on commit aae7853

Please sign in to comment.