Skip to content

Commit 6ac155b

Browse files
committed
Merge pull request Azure#91 from rakashya/RevertChanges
Revert changes made for Set-AzureRoleDefinition and New-AzureRoleDefinition command let
2 parents 782922e + 4d135b5 commit 6ac155b

File tree

9 files changed

+23
-240
lines changed

9 files changed

+23
-240
lines changed

src/ResourceManager/Resources/Commands.Resources.Test/Commands.Resources.Test.csproj

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,9 @@
247247
<Content Include="ScenarioTests\AuthorizationTests.ps1">
248248
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
249249
</Content>
250-
<None Include="Resources\NewRoleDefinition.json" />
251-
<None Include="Resources\RoleDefinition.json" />
250+
<None Include="Resources\NewRoleDefinition.json">
251+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
252+
</None>
252253
<None Include="ScenarioTests\ActiveDirectoryTests.ps1">
253254
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
254255
</None>
@@ -270,7 +271,9 @@
270271
<None Include="ScenarioTests\RoleAssignmentTests.ps1">
271272
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
272273
</None>
273-
<None Include="ScenarioTests\RoleDefinitionTests.ps1" />
274+
<None Include="ScenarioTests\RoleDefinitionTests.ps1">
275+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
276+
</None>
274277
<None Include="SessionRecords\Microsoft.Azure.Commands.Resources.Test.ScenarioTests.ActiveDirectoryTests\TestGetADUserWithMail.json">
275278
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
276279
</None>

src/ResourceManager/Resources/Commands.Resources.Test/Resources/RoleDefinition.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/ResourceManager/Resources/Commands.Resources/Commands.Resources.csproj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@
192192
<Compile Include="Models.Authorization\AuthorizationClient.cs" />
193193
<Compile Include="ProviderFeatures\RegisterAzureProviderFeatureCmdlet.cs" />
194194
<Compile Include="Providers\GetAzureProviderCmdlet.cs" />
195-
<Compile Include="Providers\GetAzureProviderOperationCmdlet.cs" />
195+
<Compile Include="Providers\GetAzureProviderOperationCmdlet.cs" />
196196
<Compile Include="Providers\RegisterAzureProviderCmdlet.cs" />
197197
<Compile Include="Providers\UnregisterAzureProviderCmdlet.cs" />
198198
<Compile Include="ResourceGroups\GetAzureResourceGroupLogCommand.cs" />
@@ -205,8 +205,6 @@
205205
<Compile Include="RoleAssignments\NewAzureRoleAssignmentCommand.cs" />
206206
<Compile Include="RoleDefinitions\GetAzureRoleDefinitionCommand.cs" />
207207
<Compile Include="RoleDefinitions\NewAzureRoleDefinitionCommand.cs" />
208-
<Compile Include="RoleDefinitions\RemoveAzureRoleDefinitionCommand.cs" />
209-
<Compile Include="RoleDefinitions\SetAzureRoleDefinitionCommand.cs" />
210208
<Compile Include="Templates\TestAzureResourceGroupTemplateCommand.cs" />
211209
<Compile Include="Templates\SaveAzureResourceGroupGalleryTemplateCommand.cs" />
212210
<Compile Include="Templates\GetAzureResourceGroupGalleryTemplateCommand.cs" />

src/ResourceManager/Resources/Commands.Resources/Models.Authorization/AuthorizationClient.cs

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

15-
using System;
16-
using System.Collections.Generic;
17-
using System.Linq;
1815
using Microsoft.Azure.Commands.Resources.Models.ActiveDirectory;
19-
using Microsoft.Azure.Common.Authentication;
20-
using Microsoft.Azure.Common.Authentication.Models;
2116
using Microsoft.Azure.Management.Authorization;
2217
using Microsoft.Azure.Management.Authorization.Models;
18+
using Microsoft.Azure.Common.Authentication.Models;
19+
using System;
20+
using System.Collections.Generic;
21+
using System.Linq;
2322
using ProjectResources = Microsoft.Azure.Commands.Resources.Properties.Resources;
23+
using Microsoft.Azure.Common.Authentication;
2424

2525
namespace Microsoft.Azure.Commands.Resources.Models.Authorization
2626
{
@@ -92,13 +92,14 @@ public PSRoleAssignment CreateRoleAssignment(FilterRoleAssignmentsOptions parame
9292

9393
RoleAssignmentCreateParameters createParameters = new RoleAssignmentCreateParameters
9494
{
95-
Properties = new RoleAssignmentProperties() { PrincipalId = principalId, RoleDefinitionId = roleDefinitionId }
95+
Properties = new RoleAssignmentProperties {
96+
PrincipalId = principalId,
97+
RoleDefinitionId = roleDefinitionId
98+
}
9699
};
97100

98101
AuthorizationManagementClient.RoleAssignments.Create(parameters.Scope, roleAssignmentId, createParameters);
99-
return
100-
AuthorizationManagementClient.RoleAssignments.Get(parameters.Scope, roleAssignmentId)
101-
.RoleAssignment.ToPSRoleAssignment(this, ActiveDirectoryClient);
102+
return AuthorizationManagementClient.RoleAssignments.Get(parameters.Scope, roleAssignmentId).RoleAssignment.ToPSRoleAssignment(this, ActiveDirectoryClient);
102103
}
103104

104105
/// <summary>
@@ -166,26 +167,6 @@ public PSRoleAssignment RemoveRoleAssignment(FilterRoleAssignmentsOptions option
166167
return roleAssignment;
167168
}
168169

169-
/// <summary>
170-
/// Deletes a role definition based on the id.
171-
/// </summary>
172-
/// <param name="id">The role definition id.</param>
173-
/// <returns>The deleted role definition.</returns>
174-
public PSRoleDefinition RemoveRoleDefinition(string id)
175-
{
176-
PSRoleDefinition roleDefinition = this.GetRoleDefinition(id);
177-
if (roleDefinition != null)
178-
{
179-
AuthorizationManagementClient.RoleDefinitions.Delete(roleDefinition.Id);
180-
}
181-
else
182-
{
183-
throw new KeyNotFoundException(string.Format(ProjectResources.RoleDefinitionWithIdNotFound, id));
184-
}
185-
186-
return roleDefinition;
187-
}
188-
189170
public PSRoleDefinition GetRoleRoleDefinition(string name)
190171
{
191172
PSRoleDefinition role = FilterRoleDefinitions(name).FirstOrDefault();
@@ -246,59 +227,5 @@ private static void ValidateRoleDefinition(PSRoleDefinition roleDefinition)
246227
throw new ArgumentException(ProjectResources.InvalidActions);
247228
}
248229
}
249-
250-
/// <summary>
251-
/// Updates a role definiton.
252-
/// </summary>
253-
/// <param name="role">The role definition to update.</param>
254-
/// <returns>The updated role definition.</returns>
255-
public PSRoleDefinition UpdateRoleDefinition(PSRoleDefinition role)
256-
{
257-
PSRoleDefinition roleDefinition = this.GetRoleDefinition(role.Id);
258-
if (roleDefinition == null)
259-
{
260-
throw new KeyNotFoundException(string.Format(ProjectResources.RoleDefinitionWithIdNotFound, role.Id));
261-
}
262-
263-
roleDefinition.Name = role.Name ?? roleDefinition.Name;
264-
roleDefinition.Actions = role.Actions ?? roleDefinition.Actions;
265-
roleDefinition.NotActions = role.NotActions ?? roleDefinition.NotActions;
266-
roleDefinition.AssignableScopes = role.AssignableScopes ?? roleDefinition.AssignableScopes;
267-
roleDefinition.Description = role.Description ?? roleDefinition.Description;
268-
269-
// TODO: confirm with ARM on what exception will be thrown when the last segment of the roleDefinition's ID is not a GUID.
270-
// This will be done after their API is designed.
271-
string[] scopes = roleDefinition.Id.Split('/');
272-
Guid roleDefinitionId = Guid.Parse(scopes.Last());
273-
274-
// TODO: update to include assignable scopes.
275-
return
276-
AuthorizationManagementClient.RoleDefinitions.CreateOrUpdate(
277-
roleDefinitionId,
278-
new RoleDefinitionCreateOrUpdateParameters()
279-
{
280-
RoleDefinition = new RoleDefinition()
281-
{
282-
Id = roleDefinition.Id,
283-
Name = roleDefinitionId,
284-
Properties =
285-
new RoleDefinitionProperties()
286-
{
287-
RoleName = roleDefinition.Name,
288-
Permissions =
289-
new List<Permission>()
290-
{
291-
new Permission()
292-
{
293-
Actions = roleDefinition.Actions,
294-
NotActions = roleDefinition.NotActions
295-
}
296-
},
297-
AssignableScopes = roleDefinition.AssignableScopes,
298-
Description = roleDefinition.Description
299-
}
300-
}
301-
}).RoleDefinition.ToPSRoleDefinition();
302-
}
303230
}
304231
}

src/ResourceManager/Resources/Commands.Resources/Properties/Resources.Designer.cs

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

src/ResourceManager/Resources/Commands.Resources/Properties/Resources.resx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@
208208
<value>Invalid tag format. Ensure that each tag has a unique name. Example: @{Name = "tagName1"; Value = "tagValue1"}, @{Name = "tagName2"; Value = "tagValue2"}</value>
209209
</data>
210210
<data name="RoleDefinitionNotFound" xml:space="preserve">
211-
<value>Cannot find role definition with name '{0}'.</value>
211+
<value>Can not find role definition with name '{0}'.</value>
212212
</data>
213213
<data name="RemoveApplication" xml:space="preserve">
214214
<value>Removing application ...</value>
@@ -297,4 +297,4 @@
297297
<data name="InvalidAssignableScopes" xml:space="preserve">
298298
<value>Invalid value for AssignableScopes</value>
299299
</data>
300-
</root>
300+
</root>

src/ResourceManager/Resources/Commands.Resources/RoleDefinitions/RemoveAzureRoleDefinitionCommand.cs

Lines changed: 0 additions & 55 deletions
This file was deleted.

src/ResourceManager/Resources/Commands.Resources/RoleDefinitions/SetAzureRoleDefinitionCommand.cs

Lines changed: 0 additions & 65 deletions
This file was deleted.
Binary file not shown.

0 commit comments

Comments
 (0)