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

Promote healthcare resources to GA #6164

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
12 changes: 12 additions & 0 deletions .changelog/3377.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
```release-note:new-resource
`google_healthcare_dataset` is now GA
```
```release-note:new-resource
`google_healthcare_dicom_store` is now GA
```
```release-note:new-resource
`google_healthcare_fhir_store` is now GA
```
```release-note:new-resource
`google_healthcare_hl7_v2_store` is now GA
```
16 changes: 16 additions & 0 deletions google/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
"google.golang.org/api/dns/v1"
dnsBeta "google.golang.org/api/dns/v1beta2"
file "google.golang.org/api/file/v1beta1"
healthcare "google.golang.org/api/healthcare/v1beta1"
"google.golang.org/api/iam/v1"
iamcredentials "google.golang.org/api/iamcredentials/v1"
cloudlogging "google.golang.org/api/logging/v2"
Expand Down Expand Up @@ -97,6 +98,7 @@ type Config struct {
DNSBasePath string
FilestoreBasePath string
FirestoreBasePath string
HealthcareBasePath string
IapBasePath string
IdentityPlatformBasePath string
KMSBasePath string
Expand Down Expand Up @@ -179,6 +181,8 @@ type Config struct {
IAMBasePath string
clientIAM *iam.Service

clientHealthcare *healthcare.Service

clientServiceMan *servicemanagement.APIService

clientServiceUsage *serviceusage.Service
Expand Down Expand Up @@ -232,6 +236,7 @@ var DialogflowDefaultBasePath = "https://dialogflow.googleapis.com/v2/"
var DNSDefaultBasePath = "https://www.googleapis.com/dns/v1/"
var FilestoreDefaultBasePath = "https://file.googleapis.com/v1/"
var FirestoreDefaultBasePath = "https://firestore.googleapis.com/v1/"
var HealthcareDefaultBasePath = "https://healthcare.googleapis.com/v1/"
var IapDefaultBasePath = "https://iap.googleapis.com/v1/"
var IdentityPlatformDefaultBasePath = "https://identitytoolkit.googleapis.com/v2/"
var KMSDefaultBasePath = "https://cloudkms.googleapis.com/v1/"
Expand Down Expand Up @@ -621,6 +626,16 @@ func (c *Config) LoadAndValidate(ctx context.Context) error {
c.clientStorageTransfer.UserAgent = userAgent
c.clientStorageTransfer.BasePath = storageTransferClientBasePath

healthcareClientBasePath := removeBasePathVersion(c.HealthcareBasePath)
log.Printf("[INFO] Instantiating Google Cloud Healthcare client for path %s", healthcareClientBasePath)

c.clientHealthcare, err = healthcare.NewService(ctx, option.WithHTTPClient(client))
if err != nil {
return err
}
c.clientHealthcare.UserAgent = userAgent
c.clientHealthcare.BasePath = healthcareClientBasePath

c.Region = GetRegionFromRegionSelfLink(c.Region)

c.requestBatcherServiceUsage = NewRequestBatcher("Service Usage", ctx, c.BatchingConfig)
Expand Down Expand Up @@ -733,6 +748,7 @@ func ConfigureBasePaths(c *Config) {
c.DNSBasePath = DNSDefaultBasePath
c.FilestoreBasePath = FilestoreDefaultBasePath
c.FirestoreBasePath = FirestoreDefaultBasePath
c.HealthcareBasePath = HealthcareDefaultBasePath
c.IapBasePath = IapDefaultBasePath
c.IdentityPlatformBasePath = IdentityPlatformDefaultBasePath
c.KMSBasePath = KMSDefaultBasePath
Expand Down
234 changes: 233 additions & 1 deletion google/healthcare_utils.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,235 @@
package google

// Magic Modules doesn't let us remove files - blank out beta-only common-compile files for now.
import (
"fmt"
"regexp"
"strings"
)

type healthcareDatasetId struct {
Project string
Location string
Name string
}

func (s *healthcareDatasetId) datasetId() string {
return fmt.Sprintf("projects/%s/locations/%s/datasets/%s", s.Project, s.Location, s.Name)
}

func (s *healthcareDatasetId) terraformId() string {
return fmt.Sprintf("%s/%s/%s", s.Project, s.Location, s.Name)
}

func parseHealthcareDatasetId(id string, config *Config) (*healthcareDatasetId, error) {
parts := strings.Split(id, "/")

datasetIdRegex := regexp.MustCompile("^(" + ProjectRegex + ")/([a-z0-9-])+/([a-zA-Z0-9_-]{1,256})$")
datasetIdWithoutProjectRegex := regexp.MustCompile("^([a-z0-9-])+/([a-zA-Z0-9_-]{1,256})$")
datasetRelativeLinkRegex := regexp.MustCompile("^projects/(" + ProjectRegex + ")/locations/([a-z0-9-]+)/datasets/([a-zA-Z0-9_-]{1,256})$")

if datasetIdRegex.MatchString(id) {
return &healthcareDatasetId{
Project: parts[0],
Location: parts[1],
Name: parts[2],
}, nil
}

if datasetIdWithoutProjectRegex.MatchString(id) {
if config.Project == "" {
return nil, fmt.Errorf("The default project for the provider must be set when using the `{location}/{datasetName}` id format.")
}

return &healthcareDatasetId{
Project: config.Project,
Location: parts[0],
Name: parts[1],
}, nil
}

if parts := datasetRelativeLinkRegex.FindStringSubmatch(id); parts != nil {
return &healthcareDatasetId{
Project: parts[1],
Location: parts[2],
Name: parts[3],
}, nil
}
return nil, fmt.Errorf("Invalid Dataset id format, expecting `{projectId}/{locationId}/{datasetName}` or `{locationId}/{datasetName}.`")
}

type healthcareFhirStoreId struct {
DatasetId healthcareDatasetId
Name string
}

func (s *healthcareFhirStoreId) fhirStoreId() string {
return fmt.Sprintf("%s/fhirStores/%s", s.DatasetId.datasetId(), s.Name)
}

func (s *healthcareFhirStoreId) terraformId() string {
return fmt.Sprintf("%s/%s", s.DatasetId.terraformId(), s.Name)
}

func parseHealthcareFhirStoreId(id string, config *Config) (*healthcareFhirStoreId, error) {
parts := strings.Split(id, "/")

fhirStoreIdRegex := regexp.MustCompile("^(" + ProjectRegex + ")/([a-z0-9-])+/([a-zA-Z0-9_-]{1,256})/([a-zA-Z0-9_-]{1,256})$")
fhirStoreIdWithoutProjectRegex := regexp.MustCompile("^([a-z0-9-])+/([a-zA-Z0-9_-]{1,256})/([a-zA-Z0-9_-]{1,256})$")
fhirStoreRelativeLinkRegex := regexp.MustCompile("^projects/(" + ProjectRegex + ")/locations/([a-z0-9-]+)/datasets/([a-zA-Z0-9_-]{1,256})/fhirStores/([a-zA-Z0-9_-]{1,256})$")

if fhirStoreIdRegex.MatchString(id) {
return &healthcareFhirStoreId{
DatasetId: healthcareDatasetId{
Project: parts[0],
Location: parts[1],
Name: parts[2],
},
Name: parts[3],
}, nil
}

if fhirStoreIdWithoutProjectRegex.MatchString(id) {
if config.Project == "" {
return nil, fmt.Errorf("The default project for the provider must be set when using the `{location}/{datasetName}/{fhirStoreName}` id format.")
}

return &healthcareFhirStoreId{
DatasetId: healthcareDatasetId{
Project: config.Project,
Location: parts[0],
Name: parts[1],
},
Name: parts[2],
}, nil
}

if parts := fhirStoreRelativeLinkRegex.FindStringSubmatch(id); parts != nil {
return &healthcareFhirStoreId{
DatasetId: healthcareDatasetId{
Project: parts[1],
Location: parts[2],
Name: parts[3],
},
Name: parts[4],
}, nil
}
return nil, fmt.Errorf("Invalid FhirStore id format, expecting `{projectId}/{locationId}/{datasetName}/{fhirStoreName}` or `{locationId}/{datasetName}/{fhirStoreName}.`")
}

type healthcareHl7V2StoreId struct {
DatasetId healthcareDatasetId
Name string
}

func (s *healthcareHl7V2StoreId) hl7V2StoreId() string {
return fmt.Sprintf("%s/hl7V2Stores/%s", s.DatasetId.datasetId(), s.Name)
}

func (s *healthcareHl7V2StoreId) terraformId() string {
return fmt.Sprintf("%s/%s", s.DatasetId.terraformId(), s.Name)
}

func parseHealthcareHl7V2StoreId(id string, config *Config) (*healthcareHl7V2StoreId, error) {
parts := strings.Split(id, "/")

hl7V2StoreIdRegex := regexp.MustCompile("^(" + ProjectRegex + ")/([a-z0-9-])+/([a-zA-Z0-9_-]{1,256})/([a-zA-Z0-9_-]{1,256})$")
hl7V2StoreIdWithoutProjectRegex := regexp.MustCompile("^([a-z0-9-])+/([a-zA-Z0-9_-]{1,256})/([a-zA-Z0-9_-]{1,256})$")
hl7V2StoreRelativeLinkRegex := regexp.MustCompile("^projects/(" + ProjectRegex + ")/locations/([a-z0-9-]+)/datasets/([a-zA-Z0-9_-]{1,256})/hl7V2Stores/([a-zA-Z0-9_-]{1,256})$")

if hl7V2StoreIdRegex.MatchString(id) {
return &healthcareHl7V2StoreId{
DatasetId: healthcareDatasetId{
Project: parts[0],
Location: parts[1],
Name: parts[2],
},
Name: parts[3],
}, nil
}

if hl7V2StoreIdWithoutProjectRegex.MatchString(id) {
if config.Project == "" {
return nil, fmt.Errorf("The default project for the provider must be set when using the `{location}/{datasetName}/{hl7V2StoreName}` id format.")
}

return &healthcareHl7V2StoreId{
DatasetId: healthcareDatasetId{
Project: config.Project,
Location: parts[0],
Name: parts[1],
},
Name: parts[2],
}, nil
}

if parts := hl7V2StoreRelativeLinkRegex.FindStringSubmatch(id); parts != nil {
return &healthcareHl7V2StoreId{
DatasetId: healthcareDatasetId{
Project: parts[1],
Location: parts[2],
Name: parts[3],
},
Name: parts[4],
}, nil
}
return nil, fmt.Errorf("Invalid Hl7V2Store id format, expecting `{projectId}/{locationId}/{datasetName}/{hl7V2StoreName}` or `{locationId}/{datasetName}/{hl7V2StoreName}.`")
}

type healthcareDicomStoreId struct {
DatasetId healthcareDatasetId
Name string
}

func (s *healthcareDicomStoreId) dicomStoreId() string {
return fmt.Sprintf("%s/dicomStores/%s", s.DatasetId.datasetId(), s.Name)
}

func (s *healthcareDicomStoreId) terraformId() string {
return fmt.Sprintf("%s/%s", s.DatasetId.terraformId(), s.Name)
}

func parseHealthcareDicomStoreId(id string, config *Config) (*healthcareDicomStoreId, error) {
parts := strings.Split(id, "/")

dicomStoreIdRegex := regexp.MustCompile("^(" + ProjectRegex + ")/([a-z0-9-])+/([a-zA-Z0-9_-]{1,256})/([a-zA-Z0-9_-]{1,256})$")
dicomStoreIdWithoutProjectRegex := regexp.MustCompile("^([a-z0-9-])+/([a-zA-Z0-9_-]{1,256})/([a-zA-Z0-9_-]{1,256})$")
dicomStoreRelativeLinkRegex := regexp.MustCompile("^projects/(" + ProjectRegex + ")/locations/([a-z0-9-]+)/datasets/([a-zA-Z0-9_-]{1,256})/dicomStores/([a-zA-Z0-9_-]{1,256})$")

if dicomStoreIdRegex.MatchString(id) {
return &healthcareDicomStoreId{
DatasetId: healthcareDatasetId{
Project: parts[0],
Location: parts[1],
Name: parts[2],
},
Name: parts[3],
}, nil
}

if dicomStoreIdWithoutProjectRegex.MatchString(id) {
if config.Project == "" {
return nil, fmt.Errorf("The default project for the provider must be set when using the `{location}/{datasetName}/{dicomStoreName}` id format.")
}

return &healthcareDicomStoreId{
DatasetId: healthcareDatasetId{
Project: config.Project,
Location: parts[0],
Name: parts[1],
},
Name: parts[2],
}, nil
}

if parts := dicomStoreRelativeLinkRegex.FindStringSubmatch(id); parts != nil {
return &healthcareDicomStoreId{
DatasetId: healthcareDatasetId{
Project: parts[1],
Location: parts[2],
Name: parts[3],
},
Name: parts[4],
}, nil
}
return nil, fmt.Errorf("Invalid DicomStore id format, expecting `{projectId}/{locationId}/{datasetName}/{dicomStoreName}` or `{locationId}/{datasetName}/{dicomStoreName}.`")
}
17 changes: 15 additions & 2 deletions google/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,14 @@ func Provider() terraform.ResourceProvider {
"GOOGLE_FIRESTORE_CUSTOM_ENDPOINT",
}, FirestoreDefaultBasePath),
},
"healthcare_custom_endpoint": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validateCustomEndpoint,
DefaultFunc: schema.MultiEnvDefaultFunc([]string{
"GOOGLE_HEALTHCARE_CUSTOM_ENDPOINT",
}, HealthcareDefaultBasePath),
},
"iap_custom_endpoint": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -530,9 +538,9 @@ func Provider() terraform.ResourceProvider {
return provider
}

// Generated resources: 118
// Generated resources: 122
// Generated IAM resources: 51
// Total generated resources: 169
// Total generated resources: 173
func ResourceMap() map[string]*schema.Resource {
resourceMap, _ := ResourceMapWithErrors()
return resourceMap
Expand Down Expand Up @@ -637,6 +645,10 @@ func ResourceMapWithErrors() (map[string]*schema.Resource, error) {
"google_dns_managed_zone": resourceDNSManagedZone(),
"google_filestore_instance": resourceFilestoreInstance(),
"google_firestore_index": resourceFirestoreIndex(),
"google_healthcare_dataset": resourceHealthcareDataset(),
"google_healthcare_dicom_store": resourceHealthcareDicomStore(),
"google_healthcare_fhir_store": resourceHealthcareFhirStore(),
"google_healthcare_hl7_v2_store": resourceHealthcareHl7V2Store(),
"google_iap_web_iam_binding": ResourceIamBinding(IapWebIamSchema, IapWebIamUpdaterProducer, IapWebIdParseFunc),
"google_iap_web_iam_member": ResourceIamMember(IapWebIamSchema, IapWebIamUpdaterProducer, IapWebIdParseFunc),
"google_iap_web_iam_policy": ResourceIamPolicy(IapWebIamSchema, IapWebIamUpdaterProducer, IapWebIdParseFunc),
Expand Down Expand Up @@ -879,6 +891,7 @@ func providerConfigure(d *schema.ResourceData, p *schema.Provider, terraformVers
config.DNSBasePath = d.Get("dns_custom_endpoint").(string)
config.FilestoreBasePath = d.Get("filestore_custom_endpoint").(string)
config.FirestoreBasePath = d.Get("firestore_custom_endpoint").(string)
config.HealthcareBasePath = d.Get("healthcare_custom_endpoint").(string)
config.IapBasePath = d.Get("iap_custom_endpoint").(string)
config.IdentityPlatformBasePath = d.Get("identity_platform_custom_endpoint").(string)
config.KMSBasePath = d.Get("kms_custom_endpoint").(string)
Expand Down
Loading