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

Dependency New Resource azurerm_healthcare_fhir_service #15913

Merged
merged 35 commits into from
May 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
912d448
add pandora sdk for healthcare api
xiaxyi Jan 28, 2022
fe68c9c
merge
xiaxyi Feb 9, 2022
b9c5400
add workspace
xiaxyi Feb 9, 2022
8ca66de
workspace
xiaxyi Feb 9, 2022
ef43a27
fhir
xiaxyi Feb 14, 2022
3e930d3
fhir
xiaxyi Feb 14, 2022
cbc8841
fhir
xiaxyi Feb 14, 2022
7e8f15e
fhir cors
xiaxyi Feb 15, 2022
67dce19
fhir
xiaxyi Feb 22, 2022
2b26b3f
update
xiaxyi Mar 18, 2022
40f0d88
fhir
xiaxyi Mar 19, 2022
0d02e16
update
xiaxyi Mar 21, 2022
b4839d2
fhir
xiaxyi Mar 21, 2022
cf0c096
fhir update
xiaxyi Mar 22, 2022
f9e1daf
update fmt
xiaxyi Mar 22, 2022
1f0d0d6
update fhir
xiaxyi Mar 23, 2022
61f2221
update docs
xiaxyi Mar 23, 2022
ca0225c
update status
xiaxyi Mar 23, 2022
a0334e4
update docs
xiaxyi Mar 29, 2022
e735aaa
update fmt
xiaxyi Mar 29, 2022
dcd3eab
Merge remote-tracking branch 'upstream/main' into hc/fhirService
xiaxyi Mar 29, 2022
2ad9dfb
Merge remote-tracking branch 'upstream/main' into hc/fhirService
xiaxyi Mar 29, 2022
9bf3285
update docs
xiaxyi Mar 29, 2022
35d837f
update
xiaxyi Mar 29, 2022
b85d3a5
â€resolve conflicts
xiaxyi Apr 18, 2022
1a563be
merge
xiaxyi May 10, 2022
35e04ae
update
xiaxyi May 10, 2022
3306563
update test case
xiaxyi May 10, 2022
15e3b19
Delete main.tf
xiaxyi May 10, 2022
d0d4ecc
update fmt
xiaxyi May 11, 2022
7a6c0ae
Merge remote-tracking branch 'origin/healthcareapi/fhir' into hc/fhir
xiaxyi May 11, 2022
5292941
Merge remote-tracking branch 'upstream/main' into hc/fhir
xiaxyi May 17, 2022
92999e1
update per review
xiaxyi May 18, 2022
11cb3c2
Merge remote-tracking branch 'upstream/main' into hc/fhir
xiaxyi May 18, 2022
6fb968f
update network
xiaxyi May 18, 2022
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
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@
<on-error>
<base />
</on-error>
</policies>
</policies>
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
-----BEGIN CERTIFICATE-----
MIICsjCCAZoCCQCMdt7DvygPtDANBgkqhkiG9w0BAQsFADAbMRkwFwYDVQQDDBBh
cGkudGVycmFmb3JtLmlvMB4XDTE4MDcwNTEwMzMzMFoXDTI4MDcwMjEwMzMzMFow
GzEZMBcGA1UEAwwQYXBpLnRlcnJhZm9ybS5pbzCCASIwDQYJKoZIhvcNAQEBBQAD
ggEPADCCAQoCggEBAKQW332Ol28CsidAheD1aL9Ul8JWnKLdaVxKZ3ssl5CXjPDO
mM7IXk0SgbQnUC8lIlPFZiDGbQ1sB6OTMun6ZZ4ipLp80dtl0roCLtCnDQOBGzCN
ArCYAoXRurjkXEY7tpD0wwtU72+37h3HQ4g0VS6VItJCqJ9QADV+HO2ZWuZTez70
MhoL6OLfZP7HGYdJDKgfEVNF5XlbVzNAGkDIJFdhjNxyGGu5Nfsm1pfQhAyunkk7
JVamjUg5IojRdo63IS9wwzMOdeGSAbBcsJfYeCfVg2kupR8q0TmZ+x93RmmOlbSi
66kEYxRzZ9YCQeHJmn1YfJ92BpCUiy9A6Z1iaKUCAwEAATANBgkqhkiG9w0BAQsF
AAOCAQEAJ7JhlecP7J48wI2QHTMbAMkkWBv/iWq1/Q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
AHPAZt9j5LqeHX+enR6RbINAf3jn+YU3MdVe0MsADdFASVDfjmQP2R7o9aJb/QqO
g3bZBWsiBDEISfyaH2+pgUM7wtwEoFWmEMlgjLK1MRBs1cDZXqnHaCd/rs+NmWV9
naEu7x5fyQOk4HozkpweR+Jx1sBlTRsa49/qSHt/6ULKfO01/cTs4iF71ykXPbh3
Kj9cI2uo9aYtXkxkhKrGyUpA7FJqWw==
-----END CERTIFICATE-----
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified internal/services/apimanagement/testdata/keyvaultcert.pfx
Binary file not shown.
2 changes: 1 addition & 1 deletion internal/services/appservice/testdata/host.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[2.*, 3.0.0)"
}
}
}
46 changes: 23 additions & 23 deletions internal/services/appservice/testdata/run.csx
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
#r "Newtonsoft.Json"
using System.Net;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
using Newtonsoft.Json;
public static async Task<IActionResult> Run(HttpRequest req, ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");
string name = req.Query["name"];
string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
dynamic data = JsonConvert.DeserializeObject(requestBody);
name = name ?? data?.name;
string responseMessage = string.IsNullOrEmpty(name)
? "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response."
: $"Hello, {name}. This HTTP triggered function executed successfully.";
return new OkObjectResult(responseMessage);
}
#r "Newtonsoft.Json"

using System.Net;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
using Newtonsoft.Json;

public static async Task<IActionResult> Run(HttpRequest req, ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");

string name = req.Query["name"];

string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
dynamic data = JsonConvert.DeserializeObject(requestBody);
name = name ?? data?.name;

string responseMessage = string.IsNullOrEmpty(name)
? "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response."
: $"Hello, {name}. This HTTP triggered function executed successfully.";

return new OkObjectResult(responseMessage);
}
5 changes: 5 additions & 0 deletions internal/services/healthcare/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ type Client struct {
HealthcareServiceClient *healthcareapis.ServicesClient
HealthcareWorkspaceClient *healthcareapis.WorkspacesClient
HealthcareWorkspaceDicomServiceClient *healthcareapis.DicomServicesClient
HealthcareWorkspaceFhirServiceClient *healthcareapis.FhirServicesClient
}

func NewClient(o *common.ClientOptions) *Client {
Expand All @@ -21,9 +22,13 @@ func NewClient(o *common.ClientOptions) *Client {
HealthcareWorkspaceDicomServiceClient := healthcareapis.NewDicomServicesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&HealthcareWorkspaceDicomServiceClient.Client, o.ResourceManagerAuthorizer)

HealthcareWorkspaceFhirServiceClient := healthcareapis.NewFhirServicesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&HealthcareWorkspaceFhirServiceClient.Client, o.ResourceManagerAuthorizer)

return &Client{
HealthcareServiceClient: &HealthcareServiceClient,
HealthcareWorkspaceClient: &HealthcareWorkspaceClient,
HealthcareWorkspaceDicomServiceClient: &HealthcareWorkspaceDicomServiceClient,
HealthcareWorkspaceFhirServiceClient: &HealthcareWorkspaceFhirServiceClient,
}
}
189 changes: 189 additions & 0 deletions internal/services/healthcare/healthcare_fhir_data_source.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
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 dataSourceHealthcareApisFhirService() *pluginsdk.Resource {
return &pluginsdk.Resource{
Read: dataSourceHealthcareApisFhirServiceRead,

Timeouts: &pluginsdk.ResourceTimeout{
Read: pluginsdk.DefaultTimeout(5 * time.Minute),
},

Schema: map[string]*pluginsdk.Schema{
"name": {
Type: pluginsdk.TypeString,
Required: true,
ValidateFunc: validate.FhirServiceName(),
},

"workspace_id": {
Type: pluginsdk.TypeString,
Required: true,
ValidateFunc: validate.WorkspaceID,
},

"location": commonschema.LocationComputed(),

"kind": {
Type: pluginsdk.TypeString,
Computed: true,
},

"access_policy_object_ids": {
Type: pluginsdk.TypeList,
Computed: true,
Elem: &pluginsdk.Schema{
Type: pluginsdk.TypeString,
},
},

"authentication": {
Type: pluginsdk.TypeList,
Computed: true,
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
"authority": {
Type: pluginsdk.TypeString,
Computed: true,
},

"audience": {
Type: pluginsdk.TypeString,
Computed: true,
},

"smart_proxy_enabled": {
Type: pluginsdk.TypeBool,
Computed: true,
},
},
},
},

"identity": commonschema.SystemAssignedIdentityComputed(),

"container_registry_login_server_url": {
Type: pluginsdk.TypeList,
Computed: true,
Elem: &pluginsdk.Schema{
Type: pluginsdk.TypeString,
},
},

"cors": {
Type: pluginsdk.TypeList,
Computed: true,
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
"allowed_origins": {
Type: pluginsdk.TypeList,
Computed: true,
Elem: &pluginsdk.Schema{
Type: pluginsdk.TypeString,
},
},

"allowed_headers": {
Type: pluginsdk.TypeList,
Computed: true,
Elem: &pluginsdk.Schema{
Type: pluginsdk.TypeString,
},
},

"allowed_methods": {
Type: pluginsdk.TypeList,
Computed: true,
Elem: &pluginsdk.Schema{
Type: pluginsdk.TypeString,
},
},

"max_age_in_seconds": {
Type: pluginsdk.TypeInt,
Computed: true,
},

"credentials_allowed": {
Type: pluginsdk.TypeBool,
Computed: true,
},
},
},
},

"configuration_export_storage_account_name": {
Type: pluginsdk.TypeString,
Computed: true,
},

"tags": commonschema.Tags(),
},
}
}

func dataSourceHealthcareApisFhirServiceRead(d *pluginsdk.ResourceData, meta interface{}) error {
client := meta.(*clients.Client).HealthCare.HealthcareWorkspaceFhirServiceClient
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.NewFhirServiceID(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.NormalizeNilable(resp.Location))
}
if err := d.Set("identity", flattenFhirManagedIdentity(resp.Identity)); err != nil {
return fmt.Errorf("setting `identity`: %+v", err)
}
if err := d.Set("kind", resp.Kind); err != nil {
return fmt.Errorf("setting `kind`: %+v", err)
}

if props := resp.FhirServiceProperties; props != nil {
d.Set("access_policy_object_ids", flattenFhirAccessPolicy(props.AccessPolicies))
d.Set("authentication", flattenFhirAuthentication(props.AuthenticationConfiguration))
d.Set("cors", flattenFhirCorsConfiguration(props.CorsConfiguration))
d.Set("container_registry_login_server_url", flattenFhirAcrLoginServer(props.AcrConfiguration))
if props.ExportConfiguration != nil && props.ExportConfiguration.StorageAccountName != nil {
d.Set("configuration_export_storage_account_name", props.ExportConfiguration.StorageAccountName)
}
}
if err := tags.FlattenAndSet(d, resp.Tags); err != nil {
return err
}

return nil
}
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 HealthCareFhirServiceDataSource struct{}

func TestAccHealthCareFhirServiceDataSource_basic(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_healthcare_fhir_service", "test")
r := HealthCareFhirServiceDataSource{}

data.DataSourceTest(t, []acceptance.TestStep{
{
Config: r.basic(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).Key("name").Exists()),
},
})
}

func (HealthCareFhirServiceDataSource) basic(data acceptance.TestData) string {
return fmt.Sprintf(`
%s

data "azurerm_healthcare_fhir_service" "test" {
name = azurerm_healthcare_fhir_service.test.name
workspace_id = azurerm_healthcare_fhir_service.test.workspace_id
}
`, HealthcareApiFhirServiceResource{}.basic(data))
}
Loading