Skip to content

Commit 77254e0

Browse files
author
Pooja Adhikari
committed
Updated help document, validation rules, and fixed two bugs in Set:
1. Modify the accesspolixcyObjectId 2. Enable/Disable SmartOnFhir And AllowCorsCredentials
1 parent c78e9aa commit 77254e0

File tree

6 files changed

+143
-44
lines changed

6 files changed

+143
-44
lines changed

src/HealthcareApis/HealthcareApis/HealthcareApis/NewAzureRmHealthcareApisService.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public class NewAzureRmHealthcareApisService : HealthcareApisBaseCmdlet
5454
[Parameter(
5555
Mandatory = true,
5656
ValueFromPipelineByPropertyName = true,
57-
HelpMessage = "HealthcareApis Fhir Service Location.")]
57+
HelpMessage = "HealthcareApis Service Location.")]
5858
[ValidateNotNullOrEmpty]
5959
[LocationCompleter("Microsoft.HealthcareApis/services")]
6060
public string Location { get; set; }
@@ -94,14 +94,14 @@ public class NewAzureRmHealthcareApisService : HealthcareApisBaseCmdlet
9494

9595
[Parameter(
9696
Mandatory = false,
97-
HelpMessage = "HealthcareApis Fhir Service List of Cors Header.")]
97+
HelpMessage = "HealthcareApis Fhir Service List of Cors Header. Specify HTTP headers which can be used during the request. Use \" * \" for any header.")]
9898
[ValidateNotNullOrEmpty]
9999
public string[] CorsHeader { get; set; }
100100

101101

102102
[Parameter(
103103
Mandatory = false,
104-
HelpMessage = "HealthcareApis Fhir Service Cors Max Age.")]
104+
HelpMessage = "HealthcareApis Fhir Service Cors Max Age. Specify how long a result from a request can be cached in seconds. Example: 600 means 10 minutes.")]
105105
[ValidateNotNullOrEmpty]
106106
[ValidateRange(0,99999)]
107107
public int CorsMaxAge { get; set; }
@@ -110,11 +110,12 @@ public class NewAzureRmHealthcareApisService : HealthcareApisBaseCmdlet
110110
Mandatory = false,
111111
HelpMessage = "HealthcareApis Fhir Service List of Cors Method.")]
112112
[ValidateNotNullOrEmpty]
113+
[ValidateSet("DELETE", "GET", "OPTIONS", "PATCH", "POST", "PUT")]
113114
public string[] CorsMethod { get; set; }
114115

115116
[Parameter(
116117
Mandatory = false,
117-
HelpMessage = "HealthcareApis Fhir Service List of Cors Origin.")]
118+
HelpMessage = "HealthcareApis Fhir Service List of Cors Origin. Specify URLs of origin sites that can access this API, or use \" * \" to allow access from any site.")]
118119
[ValidateNotNullOrEmpty]
119120
[ValidatePattern("^(?:(?:(?:[hH][tT][tT][pP](?:[sS]|))\\:\\/\\/(?:[a-zA-Z0-9-]+[.]?)+(?:\\:[0-9]{1,5})?|[*]))$")]
120121
public string[] CorsOrigin { get; set; }

src/HealthcareApis/HealthcareApis/HealthcareApis/SetAzureRmHealthcareApisService.cs

Lines changed: 68 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
using Microsoft.Azure.Commands.HealthcareApis.Common;
1616
using Microsoft.Azure.Commands.HealthcareApis.Models;
17+
using Microsoft.Azure.Commands.HealthcareApis.Properties;
1718
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
1819
using Microsoft.Azure.Management.HealthcareApis;
1920
using Microsoft.Azure.Management.HealthcareApis.Models;
@@ -64,24 +65,30 @@ public class SetAzureRmHealthcareApisService : HealthcareApisBaseCmdlet
6465
[ValidateNotNullOrEmpty]
6566
public SwitchParameter EnableSmartProxy { get; set; }
6667

67-
[Parameter(Mandatory = false, ParameterSetName = ServiceNameParameterSet, HelpMessage = "HealthcareApis FhirService List of Cors Origins.")]
68-
[Parameter(Mandatory = false, ParameterSetName = ResourceIdParameterSet, HelpMessage = "HealthcareApis FhirService List of Cors Origins.")]
68+
[Parameter(Mandatory = false, ParameterSetName = ServiceNameParameterSet, HelpMessage = "HealthcareApis FhirService DisableSmartProxy.")]
69+
[Parameter(Mandatory = false, ParameterSetName = ResourceIdParameterSet, HelpMessage = "HealthcareApis FhirService DisableSmartProxy.")]
70+
[ValidateNotNullOrEmpty]
71+
public SwitchParameter DisableSmartProxy { get; set; }
72+
73+
[Parameter(Mandatory = false, ParameterSetName = ServiceNameParameterSet, HelpMessage = "HealthcareApis FhirService List of Cors Origins. Specify URLs of origin sites that can access this API, or use \" * \" to allow access from any site.")]
74+
[Parameter(Mandatory = false, ParameterSetName = ResourceIdParameterSet, HelpMessage = "HealthcareApis FhirService List of Cors Origins. Specify URLs of origin sites that can access this API, or use \" * \" to allow access from any site.")]
6975
[ValidateNotNullOrEmpty]
7076
[ValidatePattern("^(?:(?:(?:[hH][tT][tT][pP](?:[sS]|))\\:\\/\\/(?:[a-zA-Z0-9-]+[.]?)+(?:\\:[0-9]{1,5})?|[*]))$")]
7177
public string[] CorsOrigin { get; set; }
7278

73-
[Parameter(Mandatory = false,ParameterSetName = ServiceNameParameterSet, HelpMessage = "HealthcareApis FhirService List of Cors Headers.")]
74-
[Parameter(Mandatory = false,ParameterSetName = ResourceIdParameterSet, HelpMessage = "HealthcareApis FhirService List of Cors Headers.")]
79+
[Parameter(Mandatory = false,ParameterSetName = ServiceNameParameterSet, HelpMessage = "HealthcareApis FhirService List of Cors Headers. Specify HTTP headers which can be used during the request. Use \" * \" for any header.")]
80+
[Parameter(Mandatory = false,ParameterSetName = ResourceIdParameterSet, HelpMessage = "HealthcareApis FhirService List of Cors Headers. Specify HTTP headers which can be used during the request. Use \" * \" for any header.")]
7581
[ValidateNotNullOrEmpty]
7682
public string[] CorsHeader { get; set; }
7783

7884
[Parameter(Mandatory = false, ParameterSetName = ServiceNameParameterSet,HelpMessage = "HealthcareApis FhirService List of Cors Methods.")]
7985
[Parameter(Mandatory = false,ParameterSetName = ResourceIdParameterSet,HelpMessage = "HealthcareApis FhirService List of Cors Methods.")]
8086
[ValidateNotNullOrEmpty]
87+
[ValidateSet("DELETE", "GET", "OPTIONS", "PATCH", "POST", "PUT")]
8188
public string[] CorsMethod { get; set; }
8289

83-
[Parameter(Mandatory = false,ParameterSetName = ServiceNameParameterSet,HelpMessage = "HealthcareApis FhirService Cors Max Age.")]
84-
[Parameter(Mandatory = false,ParameterSetName = ResourceIdParameterSet,HelpMessage = "HealthcareApis FhirService Cors Max Age.")]
90+
[Parameter(Mandatory = false,ParameterSetName = ServiceNameParameterSet,HelpMessage = "HealthcareApis FhirService Cors Max Age. Specify how long a result from a request can be cached in seconds. Example: 600 means 10 minutes.")]
91+
[Parameter(Mandatory = false,ParameterSetName = ResourceIdParameterSet,HelpMessage = "HealthcareApis FhirService Cors Max Age. Specify how long a result from a request can be cached in seconds. Example: 600 means 10 minutes.")]
8592
[ValidateNotNullOrEmpty]
8693
[ValidateRange(0, 99999)]
8794
public int? CorsMaxAge { get; set; }
@@ -91,6 +98,11 @@ public class SetAzureRmHealthcareApisService : HealthcareApisBaseCmdlet
9198
[ValidateNotNullOrEmpty]
9299
public SwitchParameter AllowCorsCredential { get; set; }
93100

101+
[Parameter(Mandatory = false, ParameterSetName = ServiceNameParameterSet, HelpMessage = "HealthcareApis FhirService CorsCredentials Not Allowed.")]
102+
[Parameter(Mandatory = false, ParameterSetName = ResourceIdParameterSet, HelpMessage = "HealthcareApis FhirService CorsCredentials Not Allowed.")]
103+
[ValidateNotNullOrEmpty]
104+
public SwitchParameter DisableCorsCredential { get; set; }
105+
94106
[Parameter(Mandatory = false, ParameterSetName = ServiceNameParameterSet, HelpMessage = "List of Access Policy Object IDs.")]
95107
[Parameter(Mandatory = false, ParameterSetName = ResourceIdParameterSet, HelpMessage = "List of Access Policy Object IDs.")]
96108
[ValidateNotNullOrEmpty]
@@ -135,19 +147,21 @@ public override void ExecuteCmdlet()
135147
case ServiceNameParameterSet:
136148
{
137149
List<ServiceAccessPolicyEntry> accessPolicies = new List<ServiceAccessPolicyEntry>();
150+
var healthcareApisAccount = this.HealthcareApisClient.Services.Get(this.ResourceGroupName, this.Name);
151+
138152
if (AccessPolicyObjectId != null && AccessPolicyObjectId.Length > 0)
139153
{
140154
foreach (string objectId in AccessPolicyObjectId)
141155
{
142156
accessPolicies.Add(new ServiceAccessPolicyEntry(objectId));
143157
}
144158
}
145-
146-
var healthcareApisAccount = this.HealthcareApisClient.Services.Get(this.ResourceGroupName, this.Name);
147-
148-
foreach (ServiceAccessPolicyEntry objectId in healthcareApisAccount.Properties.AccessPolicies)
159+
else
149160
{
150-
accessPolicies.Add(objectId);
161+
foreach (ServiceAccessPolicyEntry objectId in healthcareApisAccount.Properties.AccessPolicies)
162+
{
163+
accessPolicies.Add(objectId);
164+
}
151165
}
152166

153167
ServicesDescription servicesDescription = GenerateServiceDescription(healthcareApisAccount, accessPolicies);
@@ -161,6 +175,7 @@ public override void ExecuteCmdlet()
161175
string rgName = null;
162176
string name = null;
163177
ValidateAndExtractName(this.ResourceId, out rgName, out name);
178+
var healthcareApisAccount = this.HealthcareApisClient.Services.Get(rgName, name);
164179

165180
List<ServiceAccessPolicyEntry> accessPolicies = new List<ServiceAccessPolicyEntry>();
166181
if (AccessPolicyObjectId != null && AccessPolicyObjectId.Length > 0)
@@ -170,12 +185,12 @@ public override void ExecuteCmdlet()
170185
accessPolicies.Add(new ServiceAccessPolicyEntry(objectId));
171186
}
172187
}
173-
174-
var healthcareApisAccount = this.HealthcareApisClient.Services.Get(rgName, name);
175-
176-
foreach (ServiceAccessPolicyEntry objectId in healthcareApisAccount.Properties.AccessPolicies)
188+
else
177189
{
178-
accessPolicies.Add(objectId);
190+
foreach (ServiceAccessPolicyEntry objectId in healthcareApisAccount.Properties.AccessPolicies)
191+
{
192+
accessPolicies.Add(objectId);
193+
}
179194
}
180195

181196
ServicesDescription servicesDescription = GenerateServiceDescription(healthcareApisAccount, accessPolicies);
@@ -201,12 +216,6 @@ public override void ExecuteCmdlet()
201216
var healthcareApisAccount = this.HealthcareApisClient.Services.Get(InputObject.ResourceGroupName,
202217
InputObject.Name);
203218

204-
foreach (ServiceAccessPolicyEntry objectId in healthcareApisAccount.Properties.AccessPolicies)
205-
{
206-
accessPolicies.Add(objectId);
207-
}
208-
209-
210219

211220
ServicesDescription servicesDescription = InputObjectToServiceDescription(healthcareApisAccount,accessPolicies);
212221
var healthcareApisFhirServiceUpdateAccount = this.HealthcareApisClient.Services.CreateOrUpdate(
@@ -232,7 +241,7 @@ private ServicesDescription GenerateServiceDescription(ServicesDescription healt
232241
{
233242
Authority = Authority ?? healthcareApisAccount.Properties.AuthenticationConfiguration.Authority,
234243
Audience = Audience ?? healthcareApisAccount.Properties.AuthenticationConfiguration.Audience,
235-
SmartProxyEnabled = EnableSmartProxy.ToBool() != healthcareApisAccount.Properties.AuthenticationConfiguration.SmartProxyEnabled ? healthcareApisAccount.Properties.AuthenticationConfiguration.SmartProxyEnabled : this.EnableSmartProxy.ToBool()
244+
SmartProxyEnabled = IsSmartOnFhirEnabled(healthcareApisAccount.Properties.AuthenticationConfiguration.SmartProxyEnabled)
236245
},
237246
CosmosDbConfiguration = new ServiceCosmosDbConfigurationInfo()
238247
{
@@ -244,14 +253,48 @@ private ServicesDescription GenerateServiceDescription(ServicesDescription healt
244253
Headers = CorsHeader ?? healthcareApisAccount.Properties.CorsConfiguration.Headers,
245254
Methods = CorsMethod ?? healthcareApisAccount.Properties.CorsConfiguration.Methods,
246255
MaxAge = CorsMaxAge ?? healthcareApisAccount.Properties.CorsConfiguration.MaxAge,
247-
AllowCredentials = AllowCorsCredential != healthcareApisAccount.Properties.CorsConfiguration.AllowCredentials ? healthcareApisAccount.Properties.CorsConfiguration.AllowCredentials : this.AllowCorsCredential.ToBool()
256+
AllowCredentials = IsCorsCredentialsAllowed(healthcareApisAccount.Properties.CorsConfiguration.AllowCredentials)
248257
},
249258
AccessPolicies = accessPolicies
250259
},
251260
Kind = healthcareApisAccount.Kind
252261
};
253262
}
254263

264+
private bool? IsSmartOnFhirEnabled(bool? currentSmartOnFhirValue)
265+
{
266+
if (EnableSmartProxy.IsPresent && DisableSmartProxy.IsPresent)
267+
{
268+
throw new PSArgumentException(Resources.updatedService_InvalidSmartOnProxyInput);
269+
}
270+
else if (EnableSmartProxy.IsPresent)
271+
{
272+
return true;
273+
}
274+
else if (DisableSmartProxy.IsPresent)
275+
{
276+
return false;
277+
}
278+
return currentSmartOnFhirValue;
279+
}
280+
281+
private bool? IsCorsCredentialsAllowed(bool? currentAllowCorsCrendentialsValue)
282+
{
283+
if (AllowCorsCredential.IsPresent && DisableCorsCredential.IsPresent)
284+
{
285+
throw new PSArgumentException(Resources.updatedService_InvalidAllowCorsCredentialsInput);
286+
}
287+
else if (AllowCorsCredential.IsPresent)
288+
{
289+
return true;
290+
}
291+
else if (DisableCorsCredential.IsPresent)
292+
{
293+
return false;
294+
}
295+
return currentAllowCorsCrendentialsValue;
296+
}
297+
255298
private ServicesDescription InputObjectToServiceDescription(ServicesDescription healthcareApisAccount, List<ServiceAccessPolicyEntry> accessPolicies)
256299
{
257300
return new ServicesDescription()
@@ -263,7 +306,7 @@ private ServicesDescription InputObjectToServiceDescription(ServicesDescription
263306
{
264307
Authority = InputObject.Properties.AuthenticationConfiguration.Authority?? healthcareApisAccount.Properties.AuthenticationConfiguration.Authority,
265308
Audience = InputObject.Properties.AuthenticationConfiguration.Audience ?? healthcareApisAccount.Properties.AuthenticationConfiguration.Audience,
266-
SmartProxyEnabled = InputObject.Properties.AuthenticationConfiguration.SmartProxyEnabled != healthcareApisAccount.Properties.AuthenticationConfiguration.SmartProxyEnabled ? InputObject.Properties.AuthenticationConfiguration.SmartProxyEnabled : healthcareApisAccount.Properties.AuthenticationConfiguration.SmartProxyEnabled
309+
SmartProxyEnabled = InputObject.Properties.AuthenticationConfiguration.SmartProxyEnabled !=healthcareApisAccount.Properties.AuthenticationConfiguration.SmartProxyEnabled ? InputObject.Properties.AuthenticationConfiguration.SmartProxyEnabled : healthcareApisAccount.Properties.AuthenticationConfiguration.SmartProxyEnabled
267310
},
268311
CosmosDbConfiguration = new ServiceCosmosDbConfigurationInfo()
269312
{

src/HealthcareApis/HealthcareApis/Properties/Resources.Designer.cs

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/HealthcareApis/HealthcareApis/Properties/Resources.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,10 @@
132132
<data name="RemoveService_ProcessMessage" xml:space="preserve">
133133
<value>Removing service</value>
134134
</data>
135+
<data name="updatedService_InvalidAllowCorsCredentialsInput" xml:space="preserve">
136+
<value>AllowCorsCredentials and DisableCorsCredentials are mutually exclusive parameters. Please specify only one parameter.</value>
137+
</data>
138+
<data name="updatedService_InvalidSmartOnProxyInput" xml:space="preserve">
139+
<value>EnableSmartProxy and DisableSmartProxy are mutually exclusive parameters. Please specify only one</value>
140+
</data>
135141
</root>

src/HealthcareApis/HealthcareApis/help/New-AzHealthcareApisService.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ Accept wildcard characters: False
122122
```
123123
124124
### -CorsHeader
125-
HealthcareApis Fhir Service List of Cors Header.
125+
HealthcareApis Fhir Service List of Cors Header. Specify HTTP headers which can be used during the request. Use * for any header.
126126
127127
```yaml
128128
Type: System.String[]
@@ -137,7 +137,7 @@ Accept wildcard characters: False
137137
```
138138
139139
### -CorsMaxAge
140-
HealthcareApis Fhir Service Cors Max Age.
140+
HealthcareApis Fhir Service Cors Max Age. Specify how long a result from a request can be cached in seconds. Example: 600 means 10 minutes.
141141
142142
```yaml
143143
Type: System.Int32
@@ -158,6 +158,7 @@ HealthcareApis Fhir Service List of Cors Method.
158158
Type: System.String[]
159159
Parameter Sets: (All)
160160
Aliases:
161+
Accepted values: DELETE, GET, OPTIONS, PATCH, POST, PUT
161162

162163
Required: False
163164
Position: Named
@@ -167,7 +168,7 @@ Accept wildcard characters: False
167168
```
168169
169170
### -CorsOrigin
170-
HealthcareApis Fhir Service List of Cors Origin.
171+
HealthcareApis Fhir Service List of Cors Origin. Specify URLs of origin sites that can access this API, or use * to allow access from any site.
171172
172173
```yaml
173174
Type: System.String[]
@@ -258,7 +259,7 @@ Accept wildcard characters: False
258259
```
259260
260261
### -Location
261-
HealthcareApis Fhir Service Location.
262+
HealthcareApis Service Location.
262263
263264
```yaml
264265
Type: System.String

0 commit comments

Comments
 (0)