diff --git a/src/Authentication.Abstractions/AuthTelemetryRecord.cs b/src/Authentication.Abstractions/AuthTelemetryRecord.cs index 34d56c3a3c..582372981e 100644 --- a/src/Authentication.Abstractions/AuthTelemetryRecord.cs +++ b/src/Authentication.Abstractions/AuthTelemetryRecord.cs @@ -21,33 +21,44 @@ namespace Microsoft.Azure.Commands.Common.Authentication.Abstractions { /// - /// A model class for authenction telemetry record. + /// Represents a telemetry record for authentication. /// public class AuthTelemetryRecord : IAuthTelemetryRecord { /// - /// Class name of the TokenCredential, stands for the authentication method + /// Gets or sets the class name of the TokenCredential, which stands for the authentication method. /// public string TokenCredentialName { get; set; } /// - /// Authentication process succeed or not. + /// Gets or sets a value indicating whether the authentication process succeeded or not. /// public bool AuthenticationSuccess { get; set; } = false; - public bool correlationId { get; set; } + /// + /// Gets or sets the correlation ID for the authentication. + /// + public string CorrelationId { get; set; } /// - /// Additional properties for AuthenticationInfo + /// Gets the additional properties for AuthenticationInfo. /// [JsonIgnore] public IDictionary ExtendedProperties { get; } = new ConcurrentDictionary(StringComparer.OrdinalIgnoreCase); + /// + /// Initializes a new instance of the class. + /// public AuthTelemetryRecord() { TokenCredentialName = null; } + /// + /// Initializes a new instance of the class based on another instance of . + /// + /// The other instance of . + /// A value indicating whether the authentication was successful or not. public AuthTelemetryRecord(IAuthTelemetryRecord other, bool? isSuccess = null) { this.TokenCredentialName = other.TokenCredentialName; @@ -59,17 +70,17 @@ public AuthTelemetryRecord(IAuthTelemetryRecord other, bool? isSuccess = null) } /// - /// Key to show whether token cache is enabled or not. + /// Represents the key to indicate whether the token cache is enabled or not. /// public const string TokenCacheEnabled = "TokenCacheEnabled"; /// - /// Prefix of properties of the first record of authentication telemetry record. + /// Represents the prefix of properties of the first record of authentication telemetry record. /// public const string AuthTelemetryPropertyHeadPrefix = "auth-info-head"; /// - /// Key of the left records of authentication telemetry. + /// Represents the key of the left records of authentication telemetry. /// public const string AuthTelemetryPropertyTailKey = "auth-info-tail"; } diff --git a/src/Authentication.Abstractions/AuthenticationTelemetryData.cs b/src/Authentication.Abstractions/AuthenticationTelemetryData.cs index fd256055e4..ff75300e6e 100644 --- a/src/Authentication.Abstractions/AuthenticationTelemetryData.cs +++ b/src/Authentication.Abstractions/AuthenticationTelemetryData.cs @@ -17,20 +17,24 @@ namespace Microsoft.Azure.Commands.Common.Authentication.Abstractions { /// - /// A model class for a list of authenction telemetry records. + /// Represents the telemetry data for authentication. /// public class AuthenticationTelemetryData { /// - /// The first record of authentication telemetry data, usually describes the main method of this authentication process. + /// Gets the first record of authentication telemetry data, usually describing the main method of the authentication process. /// public IAuthTelemetryRecord Head { get; } = null; /// - /// The left part of authentication telemetry records. + /// Gets the remaining authentication telemetry records. /// public IList Tail { get; } = new List(); + /// + /// Initializes a new instance of the class with the specified authentication telemetry records. + /// + /// The authentication telemetry records. public AuthenticationTelemetryData(IEnumerable records) { var enumerator = records.GetEnumerator(); diff --git a/src/Authentication.Abstractions/AzureCmdletContext.cs b/src/Authentication.Abstractions/AzureCmdletContext.cs index e5147c9dd2..80a5f86a49 100644 --- a/src/Authentication.Abstractions/AzureCmdletContext.cs +++ b/src/Authentication.Abstractions/AzureCmdletContext.cs @@ -1,4 +1,17 @@ -using Microsoft.Azure.Commands.Common.Authentication.Abstractions.Interfaces; +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- +using Microsoft.Azure.Commands.Common.Authentication.Abstractions.Interfaces; using System; using System.Collections.Generic; @@ -6,22 +19,34 @@ namespace Microsoft.Azure.Commands.Common.Authentication.Abstractions { + /// + /// Represents the context for an Azure cmdlet. + /// public class AzureCmdletContext : ICmdletContext { private string cmdletId; - public const ICmdletContext CmdletNone = null; - + /// + /// Initializes a new instance of the class with the specified ID. + /// + /// The ID of the cmdlet. public AzureCmdletContext(string id) { cmdletId = id; } + + /// + /// Gets or sets the ID of the cmdlet. + /// public string CmdletId { get => cmdletId; set => cmdletId = value; } + /// + /// Gets a value indicating whether the cmdlet context is valid. + /// public bool IsValid { get => !string.IsNullOrEmpty(cmdletId); diff --git a/src/Authentication.Abstractions/Extensions/CmdletContextExtension.cs b/src/Authentication.Abstractions/Extensions/CmdletContextExtension.cs index 8d9c3e70c3..a97c9c3f59 100644 --- a/src/Authentication.Abstractions/Extensions/CmdletContextExtension.cs +++ b/src/Authentication.Abstractions/Extensions/CmdletContextExtension.cs @@ -18,8 +18,16 @@ namespace Microsoft.Azure.Commands.Common.Authentication.Abstractions.Extensions { + /// + /// Provides extension methods for the interface. + /// public static class CmdletContextExtension { + /// + /// Converts the object to a dictionary of extensible parameters. + /// + /// The object to convert. + /// A dictionary of extensible parameters. public static IDictionary ToExtensibleParameters(this ICmdletContext cmdletContext) { if (cmdletContext != null) diff --git a/src/Authentication.Abstractions/Interfaces/IAuthTelemetryRecord.cs b/src/Authentication.Abstractions/Interfaces/IAuthTelemetryRecord.cs index d9f75692e9..ee3676c9c2 100644 --- a/src/Authentication.Abstractions/Interfaces/IAuthTelemetryRecord.cs +++ b/src/Authentication.Abstractions/Interfaces/IAuthTelemetryRecord.cs @@ -15,20 +15,23 @@ namespace Microsoft.Azure.Commands.Common.Authentication.Abstractions { /// - /// Representation of an authentication telemetry record + /// Represents a telemetry record for authentication. /// public interface IAuthTelemetryRecord : IExtensibleModel { /// - /// Class name of the TokenCredential, stands for the authentication method + /// Gets or sets the class name of the TokenCredential, which stands for the authentication method. /// string TokenCredentialName { get; set; } /// - /// Authentication process succeed or not. + /// Gets or sets a value indicating whether the authentication process succeeded or not. /// bool AuthenticationSuccess { get; set; } - bool correlationId { get; set; } + /// + /// Gets or sets the correlation ID for the authentication process. + /// + string CorrelationId { get; set; } } } diff --git a/src/Authentication.Abstractions/Interfaces/IAzureTelemetry.cs b/src/Authentication.Abstractions/Interfaces/IAzureTelemetry.cs index 853b346cf4..fe561019fa 100644 --- a/src/Authentication.Abstractions/Interfaces/IAzureTelemetry.cs +++ b/src/Authentication.Abstractions/Interfaces/IAzureTelemetry.cs @@ -5,22 +5,44 @@ namespace Microsoft.Azure.Commands.Common.Authentication.Abstractions.Interfaces { - public abstract class IAzureTelemetry + /// + /// Represents an abstract class for Azure telemetry. + /// + /// The type of telemetry record. + public abstract class IAzureTelemetry { private ConcurrentDictionary> telemetryDataAccquirer = new ConcurrentDictionary>(); protected int historyKeyCount = 0; + /// + /// Gets the total count of all keys in the telemetry data. + /// public int KeysAllCount { get => historyKeyCount; } + /// + /// Gets the current count of keys in the telemetry data. + /// protected int currentKeyCount = 0; + /// + /// Gets the count of empty commandlet contexts in the telemetry data. + /// public int KeysCurrentCount { get => currentKeyCount; } protected int nullCmdletContextCount = 0; public int EmptyCmdletContextCount { get => nullCmdletContextCount; } protected int keyNotFoundCount = 0; + /// + /// Gets the count of key not found occurrences in the telemetry data. + /// public int KeyNotFoundCount { get => keyNotFoundCount; } + /// + /// Pushes a telemetry record to the telemetry data. + /// + /// The commandlet context. + /// The telemetry record. + /// true if the telemetry record was successfully pushed; otherwise, false. public bool PushTelemetryRecord(ICmdletContext cmdletContext, T record) { if (cmdletContext != null && cmdletContext.IsValid && record != null) @@ -38,6 +60,11 @@ public bool PushTelemetryRecord(ICmdletContext cmdletContext, T record) return false; } + /// + /// Pops a telemetry record from the telemetry data. + /// + /// The commandlet context. + /// The telemetry records associated with the commandlet context, or null if not found. public IList PopTelemetryRecord(ICmdletContext cmdletContext) { if (cmdletContext != null && cmdletContext.IsValid) diff --git a/src/Authentication.Abstractions/Interfaces/ICmdletContext.cs b/src/Authentication.Abstractions/Interfaces/ICmdletContext.cs index 600afbf4fb..118f92cea7 100644 --- a/src/Authentication.Abstractions/Interfaces/ICmdletContext.cs +++ b/src/Authentication.Abstractions/Interfaces/ICmdletContext.cs @@ -13,10 +13,19 @@ // ---------------------------------------------------------------------------------- namespace Microsoft.Azure.Commands.Common.Authentication.Abstractions.Interfaces { + /// + /// Represents the context of a cmdlet. + /// public interface ICmdletContext { + /// + /// Gets the ID of the cmdlet. + /// string CmdletId { get; } + /// + /// Gets a value indicating whether the cmdlet context is valid. + /// bool IsValid { get; } } } diff --git a/src/Graph.Rbac/Version1_6.20190326/ActiveDirectory/ActiveDirectoryClient.cs b/src/Graph.Rbac/Version1_6.20190326/ActiveDirectory/ActiveDirectoryClient.cs index f4d32f39b7..d27adf20b6 100644 --- a/src/Graph.Rbac/Version1_6.20190326/ActiveDirectory/ActiveDirectoryClient.cs +++ b/src/Graph.Rbac/Version1_6.20190326/ActiveDirectory/ActiveDirectoryClient.cs @@ -36,9 +36,9 @@ public class ActiveDirectoryClient public GraphRbacManagementClient GraphClient { get; private set; } /// - /// Creates new ActiveDirectoryClient using WindowsAzureSubscription. + /// Creates new ActiveDirectoryClient using Azure Subscription. /// - /// + /// The Azure context /// The cmdlet context public ActiveDirectoryClient(IAzureContext context, ICmdletContext cmdletContext) { @@ -49,9 +49,9 @@ public ActiveDirectoryClient(IAzureContext context, ICmdletContext cmdletContext } /// - /// Creates new ActiveDirectoryClient using WindowsAzureSubscription. + /// Creates new ActiveDirectoryClient using Azure Subscription. /// - /// + /// The Azure context public ActiveDirectoryClient(IAzureContext context) { GraphClient = AzureSession.Instance.ClientFactory.CreateArmClient( diff --git a/src/Graph.Rbac/Version1_6/ActiveDirectory/ActiveDirectoryClient.cs b/src/Graph.Rbac/Version1_6/ActiveDirectory/ActiveDirectoryClient.cs index d939a21da5..de5dcc5729 100644 --- a/src/Graph.Rbac/Version1_6/ActiveDirectory/ActiveDirectoryClient.cs +++ b/src/Graph.Rbac/Version1_6/ActiveDirectory/ActiveDirectoryClient.cs @@ -36,9 +36,9 @@ public class ActiveDirectoryClient public GraphRbacManagementClient GraphClient { get; private set; } /// - /// Creates new ActiveDirectoryClient using WindowsAzureSubscription. + /// Creates new ActiveDirectoryClient using Azure Subscription. /// - /// + /// The Azure context /// The cmdlet context public ActiveDirectoryClient(IAzureContext context, ICmdletContext cmdletContext) { @@ -48,6 +48,18 @@ public ActiveDirectoryClient(IAzureContext context, ICmdletContext cmdletContext GraphClient.TenantID = context.Tenant.Id.ToString(); } + /// + /// Creates new ActiveDirectoryClient using Azure Subscription. + /// + /// The Azure context + public ActiveDirectoryClient(IAzureContext context) + { + GraphClient = AzureSession.Instance.ClientFactory.CreateArmClient( + context, AzureEnvironment.Endpoint.Graph); + + GraphClient.TenantID = context.Tenant.Id.ToString(); + } + public PSADObject GetADObject(ADObjectFilterOptions options) { PSADObject result = null; diff --git a/src/ResourceManager/Version2016_09_01/ArgumentCompleters/LocationCompleter.cs b/src/ResourceManager/Version2016_09_01/ArgumentCompleters/LocationCompleter.cs index 842d5225a6..3cdbb1db78 100644 --- a/src/ResourceManager/Version2016_09_01/ArgumentCompleters/LocationCompleter.cs +++ b/src/ResourceManager/Version2016_09_01/ArgumentCompleters/LocationCompleter.cs @@ -25,7 +25,6 @@ namespace Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters using System.Linq; using System.Management.Automation; using System.Collections.Concurrent; - using Microsoft.Azure.Commands.Common.Authentication.Abstractions.Interfaces; ///