Skip to content

Commit 5b2b430

Browse files
author
Hovsep Mkrtchyan
committed
Referenced latest version of Resources and Authorization SDK packages.
1 parent 69c01d2 commit 5b2b430

File tree

12 files changed

+52
-34
lines changed

12 files changed

+52
-34
lines changed

src/CLU/Commands.ResourceManager.Cmdlets/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"System.Threading": "4.0.11-beta-23516",
4747
"System.Threading.Tasks": "4.0.11-beta-23516",
4848
"System.Threading.Thread": "4.0.0-beta-23516",
49-
"Microsoft.Azure.Management.Resources": "3.1.1-preview",
49+
"Microsoft.Azure.Management.Resources": "3.2.0-preview",
5050
"Microsoft.Extensions.Caching.Memory": "1.0.0-rc1-final"
5151
}
5252
}

src/CLU/Commands.ScenarioTests.ResourceManager.Common/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"Commands.Common": "",
2121
"Commands.Common.Authentication": "",
2222
"Commands.ResourceManager.Common": "",
23-
"Microsoft.Azure.Management.Resources": "3.1.1-preview",
23+
"Microsoft.Azure.Management.Resources": "3.2.0-preview",
2424
"Microsoft.IdentityModel.Clients.ActiveDirectory": "3.6.210231457-alpha",
2525
"Microsoft.Rest.ClientRuntime": "1.5.0",
2626
"Microsoft.Rest.ClientRuntime.Azure": "2.1.0",

src/CLU/Microsoft.Azure.Commands.Profile.Test/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"Commands.ResourceManager.Common": "",
2323
"Commands.ScenarioTests.ResourceManager.Common": "",
2424
"Microsoft.Azure.Commands.Profile": "",
25-
"Microsoft.Azure.Management.Resources": "3.1.1-preview",
25+
"Microsoft.Azure.Management.Resources": "3.2.0-preview",
2626
"Microsoft.IdentityModel.Clients.ActiveDirectory": "3.6.210231457-alpha",
2727
"Microsoft.Rest.ClientRuntime": "1.5.0",
2828
"Microsoft.Rest.ClientRuntime.Azure": "2.1.0",

src/CLU/Microsoft.Azure.Commands.Profile/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"Commands.Common": "",
2121
"Commands.Common.Authentication": "",
2222
"Commands.ResourceManager.Common": "",
23-
"Microsoft.Azure.Management.Resources": "3.1.1-preview",
23+
"Microsoft.Azure.Management.Resources": "3.2.0-preview",
2424
"Microsoft.IdentityModel.Clients.ActiveDirectory": "3.6.210231457-alpha",
2525
"Microsoft.Rest.ClientRuntime": "1.5.0",
2626
"Microsoft.Rest.ClientRuntime.Azure": "2.1.0",

src/CLU/Microsoft.Azure.Commands.Resources.Test/project.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
"Microsoft.Azure.Commands.Profile": "",
2424
"Microsoft.Azure.Commands.Resources": "",
2525
"Microsoft.Azure.Graph.RBAC": "2.0.0-preview",
26-
"Microsoft.Azure.Management.Authorization": "2.0.1-preview",
27-
"Microsoft.Azure.Management.Resources": "3.1.1-preview",
26+
"Microsoft.Azure.Management.Authorization": "2.1.0-preview",
27+
"Microsoft.Azure.Management.Resources": "3.2.0-preview",
2828
"Microsoft.IdentityModel.Clients.ActiveDirectory": "3.6.210231457-alpha",
2929
"Microsoft.Rest.ClientRuntime": "1.5.0",
3030
"Microsoft.Rest.ClientRuntime.Azure": "2.1.0",

src/CLU/Microsoft.Azure.Commands.Resources/Models.Authorization/AuthorizationClient.cs

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
using Microsoft.Azure.Commands.Common.Authentication;
2424
using Microsoft.Azure.Commands.Common.Authentication.Models;
2525
using Microsoft.Rest.Azure;
26+
using Microsoft.Rest.Azure.OData;
2627

2728
namespace Microsoft.Azure.Commands.Resources.Models.Authorization
2829
{
@@ -78,7 +79,9 @@ public PSRoleDefinition GetRoleDefinition(string roleId)
7879
/// <param name="roleId">RoleId guid</param>
7980
public PSRoleDefinition GetRoleDefinition(Guid roleId)
8081
{
81-
return AuthorizationManagementClient.RoleDefinitions.Get(roleId.ToString()).ToPSRoleDefinition();
82+
return AuthorizationManagementClient.RoleDefinitions.Get(
83+
"subscription/" + AuthorizationManagementClient.SubscriptionId,
84+
roleId.ToString()).ToPSRoleDefinition();
8285
}
8386

8487
/// <summary>
@@ -90,7 +93,10 @@ public PSRoleDefinition GetRoleDefinition(Guid roleId)
9093
public List<PSRoleDefinition> FilterRoleDefinitions(string name)
9194
{
9295
List<PSRoleDefinition> result = new List<PSRoleDefinition>();
93-
result.AddRange(AuthorizationManagementClient.RoleDefinitions.List(item => item.Name == name).Select(r => r.ToPSRoleDefinition()));
96+
result.AddRange(AuthorizationManagementClient.RoleDefinitions.List(
97+
"subscription/" + AuthorizationManagementClient.SubscriptionId,
98+
new ODataQuery<RoleDefinition>( item => item.Name == name))
99+
.Select(r => r.ToPSRoleDefinition()));
94100

95101
return result;
96102
}
@@ -102,7 +108,8 @@ public List<PSRoleDefinition> FilterRoleDefinitions(string name)
102108
public List<PSRoleDefinition> GetRoleDefinitions()
103109
{
104110
List<PSRoleDefinition> result = new List<PSRoleDefinition>();
105-
result.AddRange(AuthorizationManagementClient.RoleDefinitions.List()
111+
result.AddRange(AuthorizationManagementClient.RoleDefinitions.List(
112+
"subscription/" + AuthorizationManagementClient.SubscriptionId)
106113
.Select(r => r.ToPSRoleDefinition()));
107114
return result;
108115
}
@@ -114,7 +121,8 @@ public List<PSRoleDefinition> GetRoleDefinitions()
114121
public List<PSRoleDefinition> FilterRoleDefinitionsByCustom()
115122
{
116123
List<PSRoleDefinition> result = new List<PSRoleDefinition>();
117-
result.AddRange(AuthorizationManagementClient.RoleDefinitions.List()
124+
result.AddRange(AuthorizationManagementClient.RoleDefinitions.List(
125+
"subscription/" + AuthorizationManagementClient.SubscriptionId)
118126
.Where(r => r.Properties.Type == AuthorizationClientExtensions.CustomRole)
119127
.Select(r => r.ToPSRoleDefinition()));
120128
return result;
@@ -182,7 +190,8 @@ public List<PSRoleAssignment> FilterRoleAssignments(FilterRoleAssignmentsOptions
182190
principalId = string.IsNullOrEmpty(options.ADObjectFilter.Id.ToString()) ? adObject.Id.ToString() : options.ADObjectFilter.Id;
183191
}
184192

185-
var tempResult = AuthorizationManagementClient.RoleAssignments.List(false, principalId, assignedToPrincipalId);
193+
var tempResult = AuthorizationManagementClient.RoleAssignments.List(
194+
new ODataQuery<RoleAssignmentFilter>( f => f.PrincipalId == principalId && f.AssignedTo(assignedToPrincipalId)));
186195
result.AddRange(tempResult.FilterRoleAssignmentsOnRoleId(AuthorizationHelper.GetRoleDefinitionFullyQualifiedId(currentSubscription, options.RoleDefinitionId))
187196
.ToPSRoleAssignments(this, ActiveDirectoryClient, options.ExcludeAssignmentsForDeletedPrincipals));
188197

@@ -202,7 +211,11 @@ public List<PSRoleAssignment> FilterRoleAssignments(FilterRoleAssignmentsOptions
202211
else if (!string.IsNullOrEmpty(options.Scope))
203212
{
204213
// Filter by scope and above directly
205-
var tempResult = AuthorizationManagementClient.RoleAssignments.ListForScope(options.Scope, true, principalId, assignedToPrincipalId);
214+
var tempResult = AuthorizationManagementClient.RoleAssignments.ListForScope(
215+
options.Scope,
216+
new ODataQuery<RoleAssignmentFilter>(
217+
f => f.AtScope() && f.PrincipalId == principalId && f.AssignedTo(assignedToPrincipalId)));
218+
206219
result.AddRange(tempResult.FilterRoleAssignmentsOnRoleId(AuthorizationHelper.GetRoleDefinitionFullyQualifiedId(currentSubscription, options.RoleDefinitionId))
207220
.ToPSRoleAssignments(this, ActiveDirectoryClient, options.ExcludeAssignmentsForDeletedPrincipals));
208221

@@ -215,7 +228,8 @@ public List<PSRoleAssignment> FilterRoleAssignments(FilterRoleAssignmentsOptions
215228
}
216229
else
217230
{
218-
var tempResult = AuthorizationManagementClient.RoleAssignments.List(false, principalId, assignedToPrincipalId);
231+
var tempResult = AuthorizationManagementClient.RoleAssignments.List(
232+
new ODataQuery<RoleAssignmentFilter>(f=> f.PrincipalId == principalId && f.AssignedTo(assignedToPrincipalId)));
219233
result.AddRange(tempResult
220234
.FilterRoleAssignmentsOnRoleId(AuthorizationHelper.GetRoleDefinitionFullyQualifiedId(currentSubscription, options.RoleDefinitionId))
221235
.ToPSRoleAssignments(this, ActiveDirectoryClient, options.ExcludeAssignmentsForDeletedPrincipals));
@@ -270,7 +284,7 @@ public List<PSRoleAssignment> FilterRoleAssignments(FilterRoleAssignmentsOptions
270284
/// <returns>The deleted role assignments</returns>
271285
public IEnumerable<PSRoleAssignment> RemoveRoleAssignment(FilterRoleAssignmentsOptions options, string subscriptionId)
272286
{
273-
// Match role assignments at exact scope. Ideally, atmost 1 roleAssignment should match the criteria
287+
// Match role assignments at exact scope. Ideally, at most 1 roleAssignment should match the criteria
274288
// but an edge case can have multiple role assignments to the same role or multiple role assignments to different roles, with same name.
275289
// The FilterRoleAssignments takes care of paging internally
276290
IEnumerable<PSRoleAssignment> roleAssignments = FilterRoleAssignments(options, currentSubscription: subscriptionId)
@@ -355,7 +369,7 @@ public PSRoleDefinition RemoveRoleDefinition(string roleDefinitionName, string s
355369
}
356370

357371
/// <summary>
358-
/// Updates a role definiton.
372+
/// Updates a role definition.
359373
/// </summary>
360374
/// <param name="role">The role definition to update.</param>
361375
/// <returns>The updated role definition.</returns>

src/CLU/Microsoft.Azure.Commands.Resources/Models.ResourceGroups/ResourceClient.ResourceManager.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using Microsoft.Azure.Management.Resources;
1616
using Microsoft.Azure.Management.Resources.Models;
1717
using Microsoft.Rest.Azure;
18+
using Microsoft.Rest.Azure.OData;
1819
using System;
1920
using System.Collections;
2021
using System.Collections.Generic;
@@ -228,10 +229,11 @@ public virtual List<PSResource> FilterPSResources(BasePSResourceParameters param
228229
throw new ArgumentException(ProjectResources.InvalidTagFormat);
229230
}
230231
}
231-
var listResult = ResourceManagementClient.Resources.List( item =>
232-
item.ResourceType == parameters.ResourceType &&
233-
item.Tagname == tagValuePair.Name &&
234-
item.Tagvalue == tagValuePair.Value);
232+
var listResult = ResourceManagementClient.Resources.List(
233+
new ODataQuery<GenericResourceFilter>( f =>
234+
f.ResourceType == parameters.ResourceType &&
235+
f.Tagname == tagValuePair.Name &&
236+
f.Tagvalue == tagValuePair.Value));
235237

236238
if (listResult != null)
237239
{
@@ -317,11 +319,11 @@ public virtual List<GenericResource> FilterResources(FilterResourcesOptions opti
317319
}
318320
else
319321
{
320-
321322
IPage<GenericResource> result;
322323
if (options != null && options.ResourceType != null)
323324
{
324-
result = ResourceManagementClient.Resources.List(item => item.ResourceType == options.ResourceType);
325+
result = ResourceManagementClient.Resources.List(
326+
new ODataQuery<GenericResourceFilter>( f => f.ResourceType == options.ResourceType));
325327
}
326328
else
327329
{

src/CLU/Microsoft.Azure.Commands.Resources/Models.ResourceGroups/ResourceClient.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Components;
1919
using Microsoft.Azure.Commands.Resources.Models.Authorization;
2020
using Microsoft.Azure.Management.Authorization;
21+
using Microsoft.Azure.Management.Authorization.Models;
2122
using Microsoft.Azure.Management.Resources;
2223
using Microsoft.Azure.Management.Resources.Models;
2324
using Microsoft.Rest.Azure;
@@ -64,7 +65,7 @@ public partial class ResourcesClient
6465
/// <summary>
6566
/// Creates new ResourceManagementClient
6667
/// </summary>
67-
/// <param name="clientFactory">Factory for management cleints</param>
68+
/// <param name="clientFactory">Factory for management clients</param>
6869
/// <param name="context">Profile containing resources to manipulate</param>
6970
public ResourcesClient(IClientFactory clientFactory, AzureContext context, IDataStore dataStore)
7071
: this(
@@ -542,14 +543,14 @@ public Dictionary<string, string> GetResourceProvidersWithOperationsSupport()
542543
return providersSupportingOperations;
543544
}
544545

545-
public Management.Resources.Models.ProviderOperationsMetadata GetProviderOperationsMetadata(string providerNamespace)
546+
public ProviderOperationsMetadata GetProviderOperationsMetadata(string providerNamespace)
546547
{
547-
return this.ResourceManagementClient.ProviderOperationsMetadata.Get(providerNamespace, this.ResourceManagementClient.ApiVersion);
548+
return this.AuthorizationManagementClient.ProviderOperationsMetadata.Get(providerNamespace, this.ResourceManagementClient.ApiVersion);
548549
}
549550

550-
public IEnumerable<Management.Resources.Models.ProviderOperationsMetadata> ListProviderOperationsMetadata()
551+
public IEnumerable<ProviderOperationsMetadata> ListProviderOperationsMetadata()
551552
{
552-
return this.ResourceManagementClient.ProviderOperationsMetadata.List(this.ResourceManagementClient.ApiVersion).Value;
553+
return this.AuthorizationManagementClient.ProviderOperationsMetadata.List(this.ResourceManagementClient.ApiVersion);
553554
}
554555
}
555556
}

src/CLU/Microsoft.Azure.Commands.Resources/Providers/GetAzureProviderOperationCmdlet.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ namespace Microsoft.Azure.Commands.Resources
2222
using Microsoft.Azure.Commands.Resources.Models;
2323
using Microsoft.Azure.Management.Resources.Models;
2424
using ProjectResources = Microsoft.Azure.Commands.Resources.Properties.Resources;
25+
using Management.Authorization.Models;
2526

2627
/// <summary>
2728
/// Get an existing resource.
@@ -132,12 +133,12 @@ private static IEnumerable<PSResourceProviderOperation> GetPSOperationsFromProvi
132133
return operations;
133134
}
134135

135-
private static bool IsUserOperation(Operation operation)
136+
private static bool IsUserOperation(ProviderOperation operation)
136137
{
137138
return operation.Origin == null || operation.Origin.Contains("user");
138139
}
139140

140-
private static PSResourceProviderOperation ToPSResourceProviderOperation(Operation operation, string provider, string resource = null)
141+
private static PSResourceProviderOperation ToPSResourceProviderOperation(ProviderOperation operation, string provider, string resource = null)
141142
{
142143
PSResourceProviderOperation psOperation = new PSResourceProviderOperation();
143144
psOperation.Operation = operation.Name;

src/CLU/Microsoft.Azure.Commands.Resources/project.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
"Commands.ResourceManager.Common": "",
2323
"Commands.ResourceManager.Cmdlets": "",
2424
"Microsoft.Azure.Graph.RBAC": "2.0.0-preview",
25-
"Microsoft.Azure.Management.Authorization": "2.0.1-preview",
26-
"Microsoft.Azure.Management.Resources": "3.1.1-preview",
25+
"Microsoft.Azure.Management.Authorization": "2.1.0-preview",
26+
"Microsoft.Azure.Management.Resources": "3.2.0-preview",
2727
"Microsoft.IdentityModel.Clients.ActiveDirectory": "3.6.210231457-alpha",
2828
"Microsoft.Rest.ClientRuntime": "1.5.0",
2929
"Microsoft.Rest.ClientRuntime.Azure": "2.1.0",

src/CLU/Microsoft.Azure.Commands.Websites.Test/project.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
"Commands.ScenarioTests.ResourceManager.Common": "",
2222
"Microsoft.Azure.Commands.Profile": "",
2323
"Microsoft.Azure.Commands.Websites": "",
24-
"Microsoft.Azure.Management.Authorization": "2.0.1-preview",
25-
"Microsoft.Azure.Management.Resources": "3.1.1-preview",
24+
"Microsoft.Azure.Management.Authorization": "2.1.0-preview",
25+
"Microsoft.Azure.Management.Resources": "3.2.0-preview",
2626
"Microsoft.Azure.Management.Websites": "1.0.0-preview",
2727
"Microsoft.IdentityModel.Clients.ActiveDirectory": "3.6.210231457-alpha",
2828
"Microsoft.Rest.ClientRuntime": "1.5.0",

src/CLU/Microsoft.Azure.Commands.Websites/project.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
"Microsoft.Azure.Commands.Resources": "",
2525
"Microsoft.Azure.Commands.Profile": "",
2626
"Microsoft.Azure.Graph.RBAC": "2.0.0-preview",
27-
"Microsoft.Azure.Management.Authorization": "2.0.1-preview",
28-
"Microsoft.Azure.Management.Resources": "3.1.1-preview",
27+
"Microsoft.Azure.Management.Authorization": "2.1.0-preview",
28+
"Microsoft.Azure.Management.Resources": "3.2.0-preview",
2929
"Microsoft.Azure.Management.Websites": "1.0.0-preview",
3030
"Microsoft.IdentityModel.Clients.ActiveDirectory": "3.6.210231457-alpha",
3131
"Microsoft.Rest.ClientRuntime": "1.5.0",

0 commit comments

Comments
 (0)