-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dependency
New Resource/Data Source azurerm_healthcare_dicom_service (
#15887) Co-authored-by: kt <[email protected]>adding new resource: healthcare dicom service. Dependency of #15759 DICOM (Digital Imaging and Communications in Medicine) is the international standard to transmit, store, retrieve, print, process, and display medical imaging information, and is the primary medical imaging standard accepted across healthcare. The DICOM service is a managed service within Azure Health Data Services that ingests and persists DICOM objects at multiple thousands of images per second.
- Loading branch information
Showing
14 changed files
with
1,312 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
135 changes: 135 additions & 0 deletions
135
internal/services/healthcare/healthcare_dicom_data_source.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
package healthcare | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
|
||
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" | ||
"github.com/hashicorp/go-azure-helpers/resourcemanager/location" | ||
"github.com/hashicorp/terraform-provider-azurerm/internal/clients" | ||
"github.com/hashicorp/terraform-provider-azurerm/internal/services/healthcare/parse" | ||
"github.com/hashicorp/terraform-provider-azurerm/internal/services/healthcare/validate" | ||
"github.com/hashicorp/terraform-provider-azurerm/internal/tags" | ||
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" | ||
"github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" | ||
"github.com/hashicorp/terraform-provider-azurerm/utils" | ||
) | ||
|
||
func dataSourceHealthcareDicomService() *pluginsdk.Resource { | ||
return &pluginsdk.Resource{ | ||
Read: dataSourceHealthcareApisDicomServiceRead, | ||
|
||
Timeouts: &pluginsdk.ResourceTimeout{ | ||
Read: pluginsdk.DefaultTimeout(5 * time.Minute), | ||
}, | ||
|
||
Schema: map[string]*pluginsdk.Schema{ | ||
"name": { | ||
Type: pluginsdk.TypeString, | ||
Required: true, | ||
ValidateFunc: validate.DicomServiceName(), | ||
}, | ||
|
||
"workspace_id": { | ||
Type: pluginsdk.TypeString, | ||
Required: true, | ||
ValidateFunc: validate.WorkspaceID, | ||
}, | ||
|
||
"location": commonschema.LocationComputed(), | ||
|
||
"identity": commonschema.SystemAssignedUserAssignedIdentityComputed(), | ||
|
||
"authentication": { | ||
Type: pluginsdk.TypeList, | ||
Computed: true, | ||
Elem: &pluginsdk.Resource{ | ||
Schema: map[string]*pluginsdk.Schema{ | ||
"authority": { | ||
Type: pluginsdk.TypeString, | ||
Computed: true, | ||
}, | ||
"audience": { | ||
Type: pluginsdk.TypeList, | ||
Computed: true, | ||
Elem: &pluginsdk.Schema{Type: pluginsdk.TypeString}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
|
||
"private_endpoint": { | ||
Type: pluginsdk.TypeList, | ||
Computed: true, | ||
Elem: &pluginsdk.Resource{ | ||
Schema: map[string]*pluginsdk.Schema{ | ||
"name": { | ||
Type: pluginsdk.TypeString, | ||
Computed: true, | ||
}, | ||
|
||
"id": { | ||
Type: pluginsdk.TypeString, | ||
Computed: true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
|
||
"service_url": { | ||
Type: pluginsdk.TypeString, | ||
Computed: true, | ||
}, | ||
|
||
"tags": tags.SchemaDataSource(), | ||
}, | ||
} | ||
} | ||
|
||
func dataSourceHealthcareApisDicomServiceRead(d *pluginsdk.ResourceData, meta interface{}) error { | ||
client := meta.(*clients.Client).HealthCare.HealthcareWorkspaceDicomServiceClient | ||
subscriptionId := meta.(*clients.Client).Account.SubscriptionId | ||
ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) | ||
defer cancel() | ||
|
||
workspaceId, err := parse.WorkspaceID(d.Get("workspace_id").(string)) | ||
if err != nil { | ||
return fmt.Errorf("parsing workspace id error: %+v", err) | ||
} | ||
|
||
id := parse.NewDicomServiceID(subscriptionId, workspaceId.ResourceGroup, workspaceId.Name, d.Get("name").(string)) | ||
resp, err := client.Get(ctx, id.ResourceGroup, id.WorkspaceName, id.Name) | ||
if err != nil { | ||
if utils.ResponseWasNotFound(resp.Response) { | ||
d.SetId("") | ||
return nil | ||
} | ||
return fmt.Errorf("retrieving %s: %+v", id, err) | ||
} | ||
|
||
d.SetId(id.ID()) | ||
|
||
d.Set("name", id.Name) | ||
d.Set("workspace_id", workspaceId.ID()) | ||
|
||
if resp.Location != nil { | ||
d.Set("location", location.Normalize(*resp.Location)) | ||
} | ||
|
||
if props := resp.DicomServiceProperties; props != nil { | ||
d.Set("authentication", flattenDicomAuthentication(props.AuthenticationConfiguration)) | ||
d.Set("private_endpoint", flattenDicomServicePrivateEndpoint(props.PrivateEndpointConnections)) | ||
d.Set("service_url", props.ServiceURL) | ||
} | ||
|
||
identity, _ := flattenDicomManagedIdentity(resp.Identity) | ||
if err := d.Set("identity", identity); err != nil { | ||
return fmt.Errorf("setting `identity`: %+v", err) | ||
} | ||
|
||
if err := tags.FlattenAndSet(d, resp.Tags); err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |
35 changes: 35 additions & 0 deletions
35
internal/services/healthcare/healthcare_dicom_data_source_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package healthcare_test | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" | ||
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" | ||
) | ||
|
||
type HealthCareDicomServiceDataSource struct{} | ||
|
||
func TestAccHealthCareDicomDataSource_basic(t *testing.T) { | ||
data := acceptance.BuildTestData(t, "data.azurerm_healthcare_dicom_service", "test") | ||
r := HealthCareDicomServiceDataSource{} | ||
|
||
data.DataSourceTest(t, []acceptance.TestStep{ | ||
{ | ||
Config: r.basic(data), | ||
Check: acceptance.ComposeTestCheckFunc( | ||
check.That(data.ResourceName).Key("name").Exists()), | ||
}, | ||
}) | ||
} | ||
|
||
func (r HealthCareDicomServiceDataSource) basic(data acceptance.TestData) string { | ||
return fmt.Sprintf(` | ||
%s | ||
data "azurerm_healthcare_dicom_service" "test" { | ||
name = azurerm_healthcare_dicom_service.test.name | ||
workspace_id = azurerm_healthcare_dicom_service.test.workspace_id | ||
} | ||
`, HealthCareDicomResource{}.basic(data)) | ||
} |
Oops, something went wrong.