Skip to content

Commit

Permalink
Promote healthcare consent API to GA support (hashicorp#4393) (hashic…
Browse files Browse the repository at this point in the history
…orp#3050)

Co-authored-by: Scott Suarez <[email protected]>
Signed-off-by: Modular Magician <[email protected]>

Co-authored-by: Scott Suarez <[email protected]>
  • Loading branch information
modular-magician and ScottSuarez authored Mar 12, 2021
1 parent 41e3cff commit 5d548a3
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 78 deletions.
3 changes: 3 additions & 0 deletions .changelog/4393.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
Promote `google_healthcare_consent_store*` to GA support
```
64 changes: 34 additions & 30 deletions google-beta/iam_healthcare_consent_store_generated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package google

import (
"fmt"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
Expand All @@ -30,15 +31,27 @@ func TestAccHealthcareConsentStoreIamBindingGenerated(t *testing.T) {

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProvidersOiCS,
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccHealthcareConsentStoreIamBinding_basicGenerated(context),
},
{
ResourceName: "google_healthcare_consent_store_iam_binding.foo",
ImportStateId: fmt.Sprintf("%s/consentStores/%s roles/viewer", fmt.Sprintf("projects/%s/locations/%s/datasets/tf-test-my-dataset%s", getTestProjectFromEnv(), getTestRegionFromEnv(), context["random_suffix"]), fmt.Sprintf("tf-test-my-consent-store%s", context["random_suffix"])),
ImportState: true,
ImportStateVerify: true,
},
{
// Test Iam Binding update
Config: testAccHealthcareConsentStoreIamBinding_updateGenerated(context),
},
{
ResourceName: "google_healthcare_consent_store_iam_binding.foo",
ImportStateId: fmt.Sprintf("%s/consentStores/%s roles/viewer", fmt.Sprintf("projects/%s/locations/%s/datasets/tf-test-my-dataset%s", getTestProjectFromEnv(), getTestRegionFromEnv(), context["random_suffix"]), fmt.Sprintf("tf-test-my-consent-store%s", context["random_suffix"])),
ImportState: true,
ImportStateVerify: true,
},
},
})
}
Expand All @@ -53,12 +66,18 @@ func TestAccHealthcareConsentStoreIamMemberGenerated(t *testing.T) {

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProvidersOiCS,
Providers: testAccProviders,
Steps: []resource.TestStep{
{
// Test Iam Member creation (no update for member, no need to test)
Config: testAccHealthcareConsentStoreIamMember_basicGenerated(context),
},
{
ResourceName: "google_healthcare_consent_store_iam_member.foo",
ImportStateId: fmt.Sprintf("%s/consentStores/%s roles/viewer user:[email protected]", fmt.Sprintf("projects/%s/locations/%s/datasets/tf-test-my-dataset%s", getTestProjectFromEnv(), getTestRegionFromEnv(), context["random_suffix"]), fmt.Sprintf("tf-test-my-consent-store%s", context["random_suffix"])),
ImportState: true,
ImportStateVerify: true,
},
},
})
}
Expand All @@ -73,36 +92,43 @@ func TestAccHealthcareConsentStoreIamPolicyGenerated(t *testing.T) {

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProvidersOiCS,
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccHealthcareConsentStoreIamPolicy_basicGenerated(context),
},
{
ResourceName: "google_healthcare_consent_store_iam_policy.foo",
ImportStateId: fmt.Sprintf("%s/consentStores/%s", fmt.Sprintf("projects/%s/locations/%s/datasets/tf-test-my-dataset%s", getTestProjectFromEnv(), getTestRegionFromEnv(), context["random_suffix"]), fmt.Sprintf("tf-test-my-consent-store%s", context["random_suffix"])),
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccHealthcareConsentStoreIamPolicy_emptyBinding(context),
},
{
ResourceName: "google_healthcare_consent_store_iam_policy.foo",
ImportStateId: fmt.Sprintf("%s/consentStores/%s", fmt.Sprintf("projects/%s/locations/%s/datasets/tf-test-my-dataset%s", getTestProjectFromEnv(), getTestRegionFromEnv(), context["random_suffix"]), fmt.Sprintf("tf-test-my-consent-store%s", context["random_suffix"])),
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func testAccHealthcareConsentStoreIamMember_basicGenerated(context map[string]interface{}) string {
return Nprintf(`
resource "google_healthcare_dataset" "dataset" {
provider = google-beta
location = "us-central1"
name = "tf-test-my-dataset%{random_suffix}"
}
resource "google_healthcare_consent_store" "my-consent" {
provider = google-beta
dataset = google_healthcare_dataset.dataset.id
name = "tf-test-my-consent-store%{random_suffix}"
}
resource "google_healthcare_consent_store_iam_member" "foo" {
provider = google-beta
dataset = google_healthcare_consent_store.my-consent.dataset
consent_store_id = google_healthcare_consent_store.my-consent.name
role = "%{role}"
Expand All @@ -114,29 +140,23 @@ resource "google_healthcare_consent_store_iam_member" "foo" {
func testAccHealthcareConsentStoreIamPolicy_basicGenerated(context map[string]interface{}) string {
return Nprintf(`
resource "google_healthcare_dataset" "dataset" {
provider = google-beta
location = "us-central1"
name = "tf-test-my-dataset%{random_suffix}"
}
resource "google_healthcare_consent_store" "my-consent" {
provider = google-beta
dataset = google_healthcare_dataset.dataset.id
name = "tf-test-my-consent-store%{random_suffix}"
}
data "google_iam_policy" "foo" {
provider = google-beta
binding {
role = "%{role}"
members = ["user:[email protected]"]
}
}
resource "google_healthcare_consent_store_iam_policy" "foo" {
provider = google-beta
dataset = google_healthcare_consent_store.my-consent.dataset
consent_store_id = google_healthcare_consent_store.my-consent.name
policy_data = data.google_iam_policy.foo.policy_data
Expand All @@ -147,25 +167,19 @@ resource "google_healthcare_consent_store_iam_policy" "foo" {
func testAccHealthcareConsentStoreIamPolicy_emptyBinding(context map[string]interface{}) string {
return Nprintf(`
resource "google_healthcare_dataset" "dataset" {
provider = google-beta
location = "us-central1"
name = "tf-test-my-dataset%{random_suffix}"
}
resource "google_healthcare_consent_store" "my-consent" {
provider = google-beta
dataset = google_healthcare_dataset.dataset.id
name = "tf-test-my-consent-store%{random_suffix}"
}
data "google_iam_policy" "foo" {
provider = google-beta
}
resource "google_healthcare_consent_store_iam_policy" "foo" {
provider = google-beta
dataset = google_healthcare_consent_store.my-consent.dataset
consent_store_id = google_healthcare_consent_store.my-consent.name
policy_data = data.google_iam_policy.foo.policy_data
Expand All @@ -176,21 +190,16 @@ resource "google_healthcare_consent_store_iam_policy" "foo" {
func testAccHealthcareConsentStoreIamBinding_basicGenerated(context map[string]interface{}) string {
return Nprintf(`
resource "google_healthcare_dataset" "dataset" {
provider = google-beta
location = "us-central1"
name = "tf-test-my-dataset%{random_suffix}"
}
resource "google_healthcare_consent_store" "my-consent" {
provider = google-beta
dataset = google_healthcare_dataset.dataset.id
name = "tf-test-my-consent-store%{random_suffix}"
}
resource "google_healthcare_consent_store_iam_binding" "foo" {
provider = google-beta
dataset = google_healthcare_consent_store.my-consent.dataset
consent_store_id = google_healthcare_consent_store.my-consent.name
role = "%{role}"
Expand All @@ -202,21 +211,16 @@ resource "google_healthcare_consent_store_iam_binding" "foo" {
func testAccHealthcareConsentStoreIamBinding_updateGenerated(context map[string]interface{}) string {
return Nprintf(`
resource "google_healthcare_dataset" "dataset" {
provider = google-beta
location = "us-central1"
name = "tf-test-my-dataset%{random_suffix}"
}
resource "google_healthcare_consent_store" "my-consent" {
provider = google-beta
dataset = google_healthcare_dataset.dataset.id
name = "tf-test-my-consent-store%{random_suffix}"
}
resource "google_healthcare_consent_store_iam_binding" "foo" {
provider = google-beta
dataset = google_healthcare_consent_store.my-consent.dataset
consent_store_id = google_healthcare_consent_store.my-consent.name
role = "%{role}"
Expand Down
6 changes: 2 additions & 4 deletions google-beta/resource_healthcare_consent_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ A duration in seconds with up to nine fractional digits, terminated by 's'. Exam
"enable_consent_create_on_update": {
Type: schema.TypeBool,
Optional: true,
Description: `If true, [consents.patch] [google.cloud.healthcare.v1beta1.consent.UpdateConsent] creates the consent if it does not already exist.`,
Description: `If true, [consents.patch] [google.cloud.healthcare.v1.consent.UpdateConsent] creates the consent if it does not already exist.`,
},
"labels": {
Type: schema.TypeMap,
Expand Down Expand Up @@ -290,9 +290,7 @@ func resourceHealthcareConsentStoreDelete(d *schema.ResourceData, meta interface
func resourceHealthcareConsentStoreImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
config := meta.(*Config)
if err := parseImportId([]string{
"(?P<dataset>[^/]+)/consentStores/(?P<name>[^/]+)",
"(?P<dataset>[^/]+)/(?P<name>[^/]+)",
"(?P<name>[^/]+)",
"(?P<dataset>.+)/consentStores/(?P<name>[^/]+)",
}, d, config); err != nil {
return nil, err
}
Expand Down
40 changes: 21 additions & 19 deletions google-beta/resource_healthcare_consent_store_generated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestAccHealthcareConsentStore_healthcareConsentStoreBasicExample(t *testing

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProvidersOiCS,
Providers: testAccProviders,
ExternalProviders: map[string]resource.ExternalProvider{
"random": {},
},
Expand All @@ -41,22 +41,24 @@ func TestAccHealthcareConsentStore_healthcareConsentStoreBasicExample(t *testing
{
Config: testAccHealthcareConsentStore_healthcareConsentStoreBasicExample(context),
},
{
ResourceName: "google_healthcare_consent_store.my-consent",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"name", "dataset"},
},
},
})
}

func testAccHealthcareConsentStore_healthcareConsentStoreBasicExample(context map[string]interface{}) string {
return Nprintf(`
resource "google_healthcare_dataset" "dataset" {
provider = google-beta
location = "us-central1"
name = "tf-test-my-dataset%{random_suffix}"
}
resource "google_healthcare_consent_store" "my-consent" {
provider = google-beta
dataset = google_healthcare_dataset.dataset.id
name = "tf-test-my-consent-store%{random_suffix}"
}
Expand All @@ -72,7 +74,7 @@ func TestAccHealthcareConsentStore_healthcareConsentStoreFullExample(t *testing.

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProvidersOiCS,
Providers: testAccProviders,
ExternalProviders: map[string]resource.ExternalProvider{
"random": {},
},
Expand All @@ -81,6 +83,12 @@ func TestAccHealthcareConsentStore_healthcareConsentStoreFullExample(t *testing.
{
Config: testAccHealthcareConsentStore_healthcareConsentStoreFullExample(context),
},
{
ResourceName: "google_healthcare_consent_store.my-consent",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"name", "dataset"},
},
},
})
}
Expand All @@ -89,15 +97,11 @@ func testAccHealthcareConsentStore_healthcareConsentStoreFullExample(context map
return Nprintf(`
resource "google_healthcare_dataset" "dataset" {
provider = google-beta
location = "us-central1"
name = "tf-test-my-dataset%{random_suffix}"
}
resource "google_healthcare_consent_store" "my-consent" {
provider = google-beta
dataset = google_healthcare_dataset.dataset.id
name = "tf-test-my-consent-store%{random_suffix}"
Expand All @@ -120,7 +124,7 @@ func TestAccHealthcareConsentStore_healthcareConsentStoreIamExample(t *testing.T

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProvidersOiCS,
Providers: testAccProviders,
ExternalProviders: map[string]resource.ExternalProvider{
"random": {},
},
Expand All @@ -129,36 +133,34 @@ func TestAccHealthcareConsentStore_healthcareConsentStoreIamExample(t *testing.T
{
Config: testAccHealthcareConsentStore_healthcareConsentStoreIamExample(context),
},
{
ResourceName: "google_healthcare_consent_store.my-consent",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"name", "dataset"},
},
},
})
}

func testAccHealthcareConsentStore_healthcareConsentStoreIamExample(context map[string]interface{}) string {
return Nprintf(`
resource "google_healthcare_dataset" "dataset" {
provider = google-beta
location = "us-central1"
name = "tf-test-my-dataset%{random_suffix}"
}
resource "google_healthcare_consent_store" "my-consent" {
provider = google-beta
dataset = google_healthcare_dataset.dataset.id
name = "tf-test-my-consent-store%{random_suffix}"
}
resource "google_service_account" "test-account" {
provider = google-beta
account_id = "tf-test-my-account%{random_suffix}"
display_name = "Test Service Account"
}
resource "google_healthcare_consent_store_iam_member" "test-iam" {
provider = google-beta
dataset = google_healthcare_dataset.dataset.id
consent_store_id = google_healthcare_consent_store.my-consent.name
role = "roles/editor"
Expand Down
Loading

0 comments on commit 5d548a3

Please sign in to comment.