Skip to content

Commit e27c041

Browse files
committed
Resolve the review comments
1 parent afb643f commit e27c041

19 files changed

+388
-492
lines changed

src/Attestation/Attestation.Test/ScenarioTests/AttestationController.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1-
using Microsoft.Azure.Commands.Common.Authentication;
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.Azure.Commands.Common.Authentication;
216
using Microsoft.Azure.Graph.RBAC.Version1_6;
317
using Microsoft.Azure.Management.Attestation;
418
using Microsoft.Azure.ServiceManagement.Common.Models;

src/Attestation/Attestation.Test/ScenarioTests/AttstationTests.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1-
using Microsoft.Azure.Commands.ScenarioTest;
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.Azure.Commands.ScenarioTest;
216
using Microsoft.Azure.ServiceManagement.Common.Models;
317
using Microsoft.WindowsAzure.Commands.ScenarioTest;
418
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;

src/Attestation/Attestation.Test/ScenarioTests/AttstationTests.ps1

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# ----------------------------------------------------------------------------------
2+
#
3+
# Copyright Microsoft Corporation
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
# ----------------------------------------------------------------------------------
14+
115
<#
216
.SYNOPSIS
317
Test New-AzAttestation
@@ -71,9 +85,9 @@ function Test-DeleteAttestationByName
7185
{
7286
$rgName = Create-ResourceGroup
7387
New-AzAttestation -Name $attestationName -ResourceGroupName $rgName.ResourceGroupName -AttestationPolicy $attestationPolicy
74-
Remove-AzAttestation -Name $attestationName -ResourceGroupName $rgName.ResourceGroupName -Force
75-
$deletedAttestation= Get-AzAttestation -Name $attestationName -ResourceGroupName $rgName.ResourceGroupName
76-
Assert-Null $deletedAttestation
88+
Remove-AzAttestation -Name $attestationName -ResourceGroupName $rgName.ResourceGroupName
89+
90+
Assert-Throws {Get-AzAttestation -Name $attestationName -ResourceGroupName $rgName.ResourceGroupName}
7791
}
7892

7993
finally

src/Attestation/Attestation.Test/SessionRecords/Microsoft.Azure.Commands.Attestation.Test.ScenarioTests.AttstationTests/TestCreateAttestation.json

Lines changed: 71 additions & 71 deletions
Large diffs are not rendered by default.

src/Attestation/Attestation.Test/SessionRecords/Microsoft.Azure.Commands.Attestation.Test.ScenarioTests.AttstationTests/TestDeleteAttestationByName.json

Lines changed: 73 additions & 73 deletions
Large diffs are not rendered by default.

src/Attestation/Attestation.Test/SessionRecords/Microsoft.Azure.Commands.Attestation.Test.ScenarioTests.AttstationTests/TestGetAttestation.json

Lines changed: 61 additions & 61 deletions
Large diffs are not rendered by default.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!--
2+
Please leave this section at the top of the change log.
3+
4+
Changes for the upcoming release should go under the section titled "Upcoming Release", and should adhere to the following format:
5+
6+
## Upcoming Release
7+
* Overview of change #1
8+
- Additional information about change #1
9+
* Overview of change #2
10+
- Additional information about change #2
11+
- Additional information about change #2
12+
* Overview of change #3
13+
* Overview of change #4
14+
- Additional information about change #4
15+
16+
## YYYY.MM.DD - Version X.Y.Z (Previous Release)
17+
* Overview of change #1
18+
- Additional information about change #1
19+
-->
20+
## Upcoming Release
21+
22+
## Version 0.1.1
23+
24+
* General availability of `Az.Attestation` module

src/Attestation/Attestation/Commands/GetAzureAttestation.cs

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1-
using Microsoft.Azure.Commands.Attestation.Models;
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.Azure.Commands.Attestation.Models;
216
using Microsoft.Azure.Commands.Attestation.Properties;
317
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
418
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;
@@ -12,16 +26,14 @@
1226

1327
namespace Microsoft.Azure.Commands.Attestation
1428
{
15-
[Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "Attestation", SupportsShouldProcess = true, DefaultParameterSetName = NameParameterSet)]
29+
[Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "Attestation", DefaultParameterSetName = NameParameterSet)]
1630
[OutputType(typeof(PSAttestation))]
1731
public class GetAzureAttestation : AttestationManagementCmdletBase
1832
{
1933
#region Parameter Set Names
2034

2135
private const string NameParameterSet = "NameParameterSet";
22-
private const string InputObjectParameterSet = "IdParameterSet";
23-
24-
36+
private const string ResourceGroupParameterSet = "ResourceGroupParameterSet";
2537
#endregion
2638

2739
#region Input Parameter Definitions
@@ -37,15 +49,17 @@ public class GetAzureAttestation : AttestationManagementCmdletBase
3749
public string Name { get; set; }
3850

3951
/// <summary>
40-
/// Attestation object
52+
/// ResourceId to which the attestation belongs.
4153
/// </summary>
42-
[Parameter(Mandatory = true,
54+
[Parameter(
4355
Position = 0,
44-
ParameterSetName = InputObjectParameterSet,
45-
ValueFromPipeline = true,
46-
HelpMessage = "Attestation object to be queried.")]
56+
Mandatory = true,
57+
ParameterSetName = ResourceGroupParameterSet,
58+
HelpMessage = "Specifies the name of the ResourceID associated with the attestation being queried")]
59+
[ResourceGroupCompleter()]
4760
[ValidateNotNullOrEmpty]
48-
public PSAttestation InputObject { get; set; }
61+
public string ResourceId { get; set; }
62+
4963

5064
/// <summary>
5165
/// Resource group to which the attestation belongs.
@@ -61,11 +75,13 @@ public class GetAzureAttestation : AttestationManagementCmdletBase
6175

6276
public override void ExecuteCmdlet()
6377
{
64-
if (InputObject != null)
78+
if (ResourceId != null)
6579
{
66-
Name = InputObject.Name;
67-
ResourceGroupName = InputObject.ResourceGroupName;
80+
var resourceIdentifier = new ResourceIdentifier(ResourceId);
81+
Name = resourceIdentifier.ResourceName;
82+
ResourceGroupName = resourceIdentifier.ResourceGroupName;
6883
}
84+
6985
if (string.IsNullOrEmpty(Name))
7086
{
7187
throw new CloudException(string.Format("ResourceNotSpecified", Name));

src/Attestation/Attestation/Commands/NewAzureAttestation.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
using System.Management.Automation;
2222
using System.Runtime.InteropServices.ComTypes;
2323
using Newtonsoft.Json;
24-
//using Microsoft.Azure.KeyVault.WebKey;
2524

2625
namespace Microsoft.Azure.Commands.Attestation
2726
{
@@ -38,7 +37,6 @@ public class NewAzureAttestation : AttestationManagementCmdletBase
3837
/// Instance name
3938
/// </summary>
4039
[Parameter(Mandatory = true,
41-
Position = 0,
4240
ValueFromPipelineByPropertyName = true,
4341
HelpMessage =
4442
"Specifies a name of the Instance to create. The name can be any combination of letters, digits, or hyphens. The name must start and end with a letter or digit. The name must be universally unique."
@@ -50,7 +48,6 @@ public class NewAzureAttestation : AttestationManagementCmdletBase
5048
/// Resource group name
5149
/// </summary>
5250
[Parameter(Mandatory = true,
53-
Position = 1,
5451
ValueFromPipelineByPropertyName = true,
5552
HelpMessage = "Specifies the name of an existing resource group in which to create the attestation.")]
5653
[ResourceGroupCompleter]
@@ -59,7 +56,6 @@ public class NewAzureAttestation : AttestationManagementCmdletBase
5956

6057

6158
[Parameter(Mandatory = false,
62-
Position = 2,
6359
ValueFromPipelineByPropertyName = true,
6460
HelpMessage =
6561
"Specifies the attestation policy passed in which to create the attestation."

src/Attestation/Attestation/Commands/RemoveAzureAttestation.cs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,6 @@ public class RemoveAzureAttestation : AttestationManagementCmdletBase
8484
[ValidateNotNullOrEmpty()]
8585
public string ResourceGroupName { get; set; }
8686

87-
88-
/// <summary>
89-
/// If present, do not ask for confirmation
90-
/// </summary>
91-
[Parameter(Mandatory = false,
92-
HelpMessage = "Indicates that the cmdlet does not prompt you for confirmation. By default, this cmdlet prompts you to confirm that you want to delete the attestation.")]
93-
public SwitchParameter Force { get; set; }
94-
9587
[Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")]
9688
public SwitchParameter AsJob { get; set; }
9789

@@ -114,11 +106,14 @@ public override void ExecuteCmdlet()
114106
ResourceGroupName = resourceIdentifier.ResourceGroupName;
115107
}
116108

117-
AttestationClient.DeleteAttestation(Name,ResourceGroupName);
118-
119-
if (PassThru)
109+
if (ShouldProcess(Name))
120110
{
121-
WriteObject(true);
111+
AttestationClient.DeleteAttestation(Name, ResourceGroupName);
112+
113+
if (PassThru)
114+
{
115+
WriteObject(true);
116+
}
122117
}
123118
}
124119
}

src/Attestation/Attestation/Models/AttestationClient.cs

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
// TODO: Remove IfDef
16-
#if NETSTANDARD
17-
using Microsoft.Azure.Graph.RBAC.Version1_6.ActiveDirectory;
18-
#else
19-
using Microsoft.Azure.ActiveDirectory.GraphClient;
20-
#endif
2115
using System;
2216
using System.Collections.Generic;
2317
using System.Linq;
@@ -53,11 +47,18 @@ public AttestationClient()
5347
public PSAttestation CreateNewAttestation(AttestationCreationParameters parameters)
5448
{
5549
if (parameters == null)
50+
{
5651
throw new ArgumentNullException("parameters");
52+
}
5753
if (string.IsNullOrWhiteSpace(parameters.ProviderName))
54+
{
5855
throw new ArgumentNullException("parameters.ProviderName");
56+
}
5957
if (string.IsNullOrWhiteSpace(parameters.ResourceGroupName))
58+
{
6059
throw new ArgumentNullException("parameters.ResourceGroupName");
60+
}
61+
6162
try
6263
{
6364
AttestationServiceCreationParams _creationParams = new AttestationServiceCreationParams();
@@ -71,50 +72,66 @@ public PSAttestation CreateNewAttestation(AttestationCreationParameters paramete
7172
providerName: parameters.ProviderName,
7273
creationParams: _creationParams);
7374

74-
if (response.Status == "Ready" || response.Status == "NotReady")
75+
if ((response.Status == "Ready") || (response.Status == "NotReady"))
76+
{
7577
return new PSAttestation(response);
76-
else return null;
78+
}
79+
else
80+
{
81+
return null;
82+
}
7783
}
7884
catch
7985
{
80-
throw;
86+
throw new ArgumentException(string.Format("FailToCreateAttestation", parameters.ProviderName, parameters.ResourceGroupName));
8187
}
8288
}
8389

8490
public PSAttestation GetAttestation(string attestationName, string resourceGroupName)
8591
{
8692
if (string.IsNullOrWhiteSpace(attestationName))
93+
{
8794
throw new ArgumentNullException("attestationName");
95+
}
8896
if (string.IsNullOrWhiteSpace(resourceGroupName))
97+
{
8998
throw new ArgumentNullException("resourceGroupName");
99+
}
90100
try
91101
{
92102
var response = attestationClient.AttestationProviders.Get(resourceGroupName, attestationName);
93103

94-
if (response.Status == "Ready" || response.Status == "NotReady")
104+
if ((response.Status == "Ready") || (response.Status == "NotReady"))
105+
{
95106
return new PSAttestation(response);
96-
else return null;
97-
107+
}
108+
else
109+
{
110+
return null;
111+
}
98112
}
99113
catch
100114
{
101-
return null;
115+
throw new ArgumentException(string.Format("AttestationNotFound", attestationName, resourceGroupName));
102116
}
103117
}
104118
public void DeleteAttestation(string attestationName, string resourceGroupName)
105119
{
106120
if (string.IsNullOrWhiteSpace(attestationName))
121+
{
107122
throw new ArgumentNullException("attestationName");
123+
}
124+
108125
if (string.IsNullOrWhiteSpace(resourceGroupName))
126+
{
109127
throw new ArgumentNullException("resourceGroupName");
128+
}
110129
try
111130
{
112131
attestationClient.AttestationProviders.Delete(resourceGroupName, attestationName);
113132
}
114-
catch (CloudException ce)
133+
catch
115134
{
116-
if (ce.Response.StatusCode == HttpStatusCode.NotFound)
117-
throw new ArgumentException(string.Format("AttestationNotFound", attestationName, resourceGroupName));
118135
throw;
119136
}
120137
}

src/Attestation/Attestation/Models/AttestationCmdletBase.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
// TODO: Remove IfDef
16-
#if NETSTANDARD
17-
using Microsoft.Azure.Graph.RBAC.Version1_6.ActiveDirectory;
18-
#else
19-
using Microsoft.Azure.ActiveDirectory.GraphClient;
20-
#endif
2115
using System;
2216
using System.Collections;
2317
using System.Collections.Generic;

src/Attestation/Attestation/Models/AttestationCreationParameters.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1-
using System;
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System;
216
using System.Collections.Generic;
317
using System.Text;
418

src/Attestation/Attestation/Models/PSAttestation.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
// TODO: Remove IfDef
16-
#if NETSTANDARD
17-
using Microsoft.Azure.Graph.RBAC.Version1_6.ActiveDirectory;
18-
#else
19-
using Microsoft.Azure.ActiveDirectory.GraphClient;
20-
#endif
2115
using Microsoft.Azure.Commands.ResourceManager.Common.Tags;
2216
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;
2317
using Microsoft.Azure.Management.Attestation.Models;

0 commit comments

Comments
 (0)