Skip to content

Commit 6568986

Browse files
committed
Merge branch 'clu' of https://github.com/Azure/azure-powershell into clu
2 parents b1a729c + a3d1ee9 commit 6568986

File tree

54 files changed

+336
-154
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+336
-154
lines changed

src/CLU/Commands.Common.Authentication/Authentication/AdalTokenProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Commands.Common.Authentication.Properties;
1516
using Microsoft.Azure.Commands.Common.Authentication.Models;
1617
using System;
17-
using Commands.Common.Authentication.Properties;
1818

1919
namespace Microsoft.Azure.Commands.Common.Authentication
2020
{

src/CLU/Commands.Common.Authentication/Authentication/ServicePrincipalTokenProvider.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,11 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Commands.Common.Authentication.Properties;
1516
using Microsoft.Azure.Commands.Common.Authentication.Models;
1617
using Microsoft.IdentityModel.Clients.ActiveDirectory;
1718
using Microsoft.Rest;
1819
using System;
19-
using System.Collections.Generic;
20-
using System.Security;
21-
using System.Security.Cryptography.X509Certificates;
22-
using Commands.Common.Authentication.Properties;
2320

2421
namespace Microsoft.Azure.Commands.Common.Authentication
2522
{

src/CLU/Commands.Common.Authentication/Authentication/UserTokenProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
using Microsoft.Rest;
1818
using System;
1919
using System.Runtime.InteropServices;
20-
using Commands.Common.Authentication.Properties;
2120
using Microsoft.Rest.Azure.Authentication;
2221
using System.Management.Automation;
22+
using Commands.Common.Authentication.Properties;
2323

2424
namespace Microsoft.Azure.Commands.Common.Authentication
2525
{

src/CLU/Commands.Common.Authentication/AuthenticationFactory.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// ----------------------------------------------------------------------------------
1+
// ----------------------------------------------------------------------------------
22
//
33
// Copyright Microsoft Corporation
44
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,11 +16,10 @@
1616
using System;
1717
using System.Linq;
1818
using System.Management.Automation;
19-
using System.Security;
20-
using Commands.Common.Authentication.Properties;
2119
using Microsoft.IdentityModel.Clients.ActiveDirectory;
2220
using Microsoft.Rest;
2321
using Microsoft.Rest.Azure.Authentication;
22+
using Commands.Common.Authentication.Properties;
2423

2524
namespace Microsoft.Azure.Commands.Common.Authentication.Factories
2625
{

src/CLU/Commands.Common.Authentication/ClientFactory.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,17 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Commands.Common.Authentication.Properties;
1516
using Microsoft.Azure.Commands.Common.Authentication.Models;
1617
using Microsoft.Rest;
1718
using System;
1819
using System.Collections.Generic;
1920
using System.Collections.Specialized;
20-
using System.Linq;
2121
using System.Management.Automation;
2222
using System.Net;
2323
using System.Net.Http;
2424
using System.Net.Http.Headers;
2525
using System.Reflection;
26-
using Commands.Common.Authentication.Properties;
2726

2827
namespace Microsoft.Azure.Commands.Common.Authentication.Factories
2928
{

src/CLU/Commands.Common.Authentication/JsonUtilities.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Commands.Common.Authentication.Properties;
1516
using Newtonsoft.Json;
1617
using Newtonsoft.Json.Linq;
1718
using System;
1819
using System.Collections.Generic;
1920
using System.Diagnostics.CodeAnalysis;
20-
using Commands.Common.Authentication.Properties;
2121

2222
namespace Microsoft.Azure.Commands.Common.Authentication
2323
{

src/CLU/Commands.Common.Authentication/Models/AzureEnvironment.Methods.cs

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

15+
using Commands.Common.Authentication.Properties;
1516
using System;
1617
using System.Collections.Generic;
17-
using Commands.Common.Authentication.Properties;
1818

1919
namespace Microsoft.Azure.Commands.Common.Authentication.Models
2020
{
@@ -372,7 +372,7 @@ public static class AzureEnvironmentConstants
372372

373373
public const string USGovernmentSqlDatabaseDnsSuffix = ".database.usgovcloudapi.net";
374374

375-
public const string AzureActiveDirectoryEndpoint = "https://login.windows.net/";
375+
public const string AzureActiveDirectoryEndpoint = "https://login.microsoftonline.com/";
376376

377377
public const string ChinaActiveDirectoryEndpoint = "https://login.chinacloudapi.cn/";
378378

src/CLU/Commands.Common.Authentication/Models/AzureSMProfile.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Commands.Common.Authentication.Properties;
1516
using Microsoft.Rest;
1617
using Newtonsoft.Json;
1718
using System;
1819
using System.Collections.Generic;
1920
using System.Linq;
20-
using Commands.Common.Authentication.Properties;
2121

2222
namespace Microsoft.Azure.Commands.Common.Authentication.Models
2323
{

src/CLU/Commands.Common.Authentication/Models/DiskDataStore.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Commands.Common.Authentication.Properties;
1516
using System;
1617
using System.IO;
1718
using System.Security.Cryptography.X509Certificates;
1819
using System.Text;
19-
using Commands.Common.Authentication.Properties;
2020

2121
namespace Microsoft.Azure.Commands.Common.Authentication.Models
2222
{

src/CLU/Commands.Common.Authentication/Properties/Resources.Designer.cs

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

src/CLU/Commands.Common.Authentication/Properties/Resources.resx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,6 @@
120120
<data name="AccountNeedsToBeSpecified" xml:space="preserve">
121121
<value>Account needs to be specified</value>
122122
</data>
123-
<data name="AzureDirectoryName" xml:space="preserve">
124-
<value>Windows Azure Powershell</value>
125-
</data>
126123
<data name="CertificateNotFoundInStore" xml:space="preserve">
127124
<value>No certificate was found in the certificate store with thumbprint {0}</value>
128125
</data>

src/CLU/Commands.Common.Authentication/Validate.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Commands.Common.Authentication.Properties;
1516
using System;
1617
using System.IO;
1718
using System.Linq;
18-
using Commands.Common.Authentication.Properties;
1919

2020
namespace Microsoft.Azure.Commands.Common.Authentication
2121
{

src/CLU/Commands.Common/AzurePSCmdlet.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -436,17 +436,11 @@ protected virtual void WriteExceptionError(Exception ex)
436436
WriteError(new ErrorRecord(ex, string.Empty, ErrorCategory.CloseError, null));
437437
}
438438

439-
protected PSObject ConstructPSObject(string typeName, params object[] args)
439+
protected PSObject ConstructPSObject(params object[] args)
440440
{
441-
return PowerShellUtilities.ConstructPSObject(typeName, args);
441+
return PowerShellUtilities.ConstructPSObject(args);
442442
}
443-
444-
protected void SafeWriteOutputPSObject(string typeName, params object[] args)
445-
{
446-
PSObject customObject = this.ConstructPSObject(typeName, args);
447-
WriteObject(customObject);
448-
}
449-
443+
450444
private void FlushDebugMessages(bool record = false)
451445
{
452446
if (record)

src/CLU/Commands.Common/Models/PSAzureContext.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,14 @@ public static implicit operator AzureContext(PSAzureContext context)
8686
public PSAzureTenant Tenant { get; set; }
8787

8888
public byte[] TokenCache { get; set; }
89+
90+
public override string ToString()
91+
{
92+
var account = Account != null ? Account.Id : string.Empty;
93+
var subscription = Subscription != null ? Subscription.SubscriptionId : string.Empty;
94+
var tenant = Tenant != null ? Tenant.TenantId : string.Empty;
95+
var environment = Environment != null ? Environment.Name : EnvironmentName.AzureCloud;
96+
return $"{{Account: {account}, Subscription: {subscription}, Tenant: {tenant}, Environment: {environment}}}";
97+
}
8998
}
9099
}

src/CLU/Commands.Common/Models/PSAzureProfile.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ public IDictionary<string, PSAzureEnvironment> Environments
6464
get { return _env; }
6565
}
6666

67+
public string EnvironmentNames
68+
{
69+
get { return _env == null? null : $"{string.Join(", ", _env.Keys.ToArray())}"; }
70+
}
71+
6772
/// <summary>
6873
/// The current credentials and metadata for connecting with the current Azure cloud instance.
6974
/// </summary>

src/CLU/Commands.Common/PowerShellUtilities.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,12 @@ private static void ChangeForTargetEnvironment(Func<IEnumerable<string>, IEnumer
5050
}
5151
}
5252

53-
public static PSObject ConstructPSObject(string typeName, params object[] args)
53+
public static PSObject ConstructPSObject(params object[] args)
5454
{
5555
Debug.Assert(args.Length % 2 == 0, "The parameter args length must be even number");
5656

5757
PSObject outputObject = new PSObject();
58-
59-
if (!string.IsNullOrEmpty(typeName))
60-
{
61-
outputObject.TypeNames.Add(typeName);
62-
}
63-
58+
6459
for (int i = 0, j = 0; i < args.Length / 2; i++, j += 2)
6560
{
6661
outputObject.Properties.Add(new PSNoteProperty(args[j].ToString(), args[j + 1]));
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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 Newtonsoft.Json;
16+
17+
namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Entities.Resources
18+
{
19+
public class ResourceLock<TProperties> : Resource<TProperties>
20+
{
21+
public ResourceLock(Resource<TProperties> r)
22+
: base(r)
23+
{
24+
}
25+
26+
/// <summary>
27+
/// Gets or sets the lock id for the resource.
28+
/// </summary>
29+
[JsonProperty(Required = Required.Default)]
30+
public string LockId { get; set; }
31+
}
32+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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.ResourceManager.Cmdlets.Entities.Resources;
16+
using Newtonsoft.Json;
17+
18+
namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Entities.Policy
19+
{
20+
public class ResourcePolicyAssignment<TProperties> : Resource<TProperties>
21+
{
22+
public ResourcePolicyAssignment(Resource<TProperties> r)
23+
: base(r)
24+
{
25+
}
26+
27+
/// <summary>
28+
/// Gets or sets the policy assignment id for the resource.
29+
/// </summary>
30+
[JsonProperty(Required = Required.Default)]
31+
public string PolicyAssignmentId { get; set; }
32+
}
33+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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.ResourceManager.Cmdlets.Entities.Resources;
16+
using Newtonsoft.Json;
17+
18+
namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Entities.Policy
19+
{
20+
public class ResourcePolicyDefinition<TProperties> : Resource<TProperties>
21+
{
22+
public ResourcePolicyDefinition(Resource<TProperties> r)
23+
: base(r)
24+
{
25+
}
26+
27+
/// <summary>
28+
/// Gets or sets the policy definition id for the resource.
29+
/// </summary>
30+
[JsonProperty(Required = Required.Default)]
31+
public string PolicyDefinitionId { get; set; }
32+
}
33+
}

src/CLU/Commands.ResourceManager.Cmdlets/Entities/Resources/Resource.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,27 @@ namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Entities.Resources
2323
/// </summary>
2424
public class Resource<TProperties>
2525
{
26+
public Resource()
27+
{
28+
29+
}
30+
31+
public Resource(Resource<TProperties> r)
32+
{
33+
this.ChangedTime = r.ChangedTime;
34+
this.CreatedTime = r.CreatedTime;
35+
this.ETag = r.ETag;
36+
this.Id = r.Id;
37+
this.Kind = r.Kind;
38+
this.Location = r.Location;
39+
this.Name = r.Name;
40+
this.Plan = r.Plan;
41+
this.Properties = r.Properties;
42+
this.Sku = r.Sku;
43+
this.Tags = r.Tags;
44+
this.Type = r.Type;
45+
}
46+
2647
/// <summary>
2748
/// Gets or sets the properties.
2849
/// </summary>

src/CLU/Commands.ResourceManager.Cmdlets/Extensions/JTokenExtensions.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ internal static class JTokenExtensions
4848
/// </summary>
4949
/// <param name="jtoken">The <see cref="JObject"/></param>
5050
/// <param name="objectType">The type of the object.</param>
51-
internal static PSObject ToPsObject(this JToken jtoken, string objectType = null)
51+
internal static PSObject ToPsObject(this JToken jtoken)
5252
{
5353
if (jtoken == null)
5454
{
@@ -63,12 +63,7 @@ internal static PSObject ToPsObject(this JToken jtoken, string objectType = null
6363

6464
var jobject = (JObject)jtoken;
6565
var psObject = new PSObject();
66-
67-
if (!string.IsNullOrWhiteSpace(objectType))
68-
{
69-
psObject.TypeNames.Add(objectType);
70-
}
71-
66+
7267
foreach (var property in jobject.Properties())
7368
{
7469
psObject.Properties.Add(new PSNoteProperty(

0 commit comments

Comments
 (0)