< Summary

Class:Microsoft.Azure.Batch.ComputeNodeUser
Assembly:Microsoft.Azure.Batch
File(s):C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\ComputeNodeUser.cs
C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\Generated\ComputeNodeUser.cs
Covered lines:20
Uncovered lines:73
Coverable lines:93
Total lines:318
Line coverage:21.5% (20 of 93)
Covered branches:0
Total branches:2
Branch coverage:0% (0 of 2)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
get_IsAdmin()-100%100%
set_IsAdmin(...)-100%100%
get_Name()-100%100%
set_Name(...)-100%100%
get_Password()-100%100%
set_Password(...)-100%100%
get_SshPublicKey()-100%100%
set_SshPublicKey(...)-100%100%
Microsoft.Azure.Batch.IModifiable.get_HasBeenModified()-100%100%
Microsoft.Azure.Batch.IReadOnly.get_IsReadOnly()-100%100%
Microsoft.Azure.Batch.IReadOnly.set_IsReadOnly(...)-100%100%
Microsoft.Azure.Batch.ITransportObjectProvider<Microsoft.Azure.Batch.Protocol.Models.ComputeNodeUser>.GetTransportObject()-100%100%
.ctor()-100%100%
CommitAsync(...)-12.5%0%
get_ParentPoolId()-0%100%
get_ParentNodeId()-0%100%
.ctor(...)-100%100%
Commit(...)-0%100%
DeleteAsync(...)-0%100%
get_CustomBehaviors()-0%100%
get_ExpiryTime()-100%100%
Delete(...)-33.33%100%
set_ExpiryTime(...)-100%100%
.ctor()-0%100%
get_ParentPoolId()-0%100%
get_ParentNodeId()-0%100%
.ctor(...)-0%100%
get_CustomBehaviors()-0%100%
get_ExpiryTime()-0%100%
set_ExpiryTime(...)-0%100%
get_IsAdmin()-0%100%
set_IsAdmin(...)-0%100%
get_Name()-0%100%
set_Name(...)-0%100%
get_Password()-0%100%
set_Password(...)-0%100%
get_SshPublicKey()-0%100%
set_SshPublicKey(...)-0%100%
Microsoft.Azure.Batch.IModifiable.get_HasBeenModified()-0%100%
Microsoft.Azure.Batch.IReadOnly.get_IsReadOnly()-0%100%
Microsoft.Azure.Batch.IReadOnly.set_IsReadOnly(...)-0%100%
Microsoft.Azure.Batch.ITransportObjectProvider<Microsoft.Azure.Batch.Protocol.Models.ComputeNodeUser>.GetTransportObject()-0%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\ComputeNodeUser.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License. See License.txt in the project root for license information.
 3
 4namespace Microsoft.Azure.Batch
 5{
 6    using System.Collections.Generic;
 7    using System.Threading;
 8    using System.Threading.Tasks;
 9    using Models = Microsoft.Azure.Batch.Protocol.Models;
 10
 11    /// <summary>
 12    /// Informs the Commit() call that the state transfer between the client and server is
 13    /// either a create-user or update-user operation.
 14    /// </summary>
 15    public enum ComputeNodeUserCommitSemantics
 16    {
 17        /// <summary>
 18        /// The Commit operation is adding a new user.
 19        /// </summary>
 20        AddUser,
 21
 22        /// <summary>
 23        /// The Commit operation is updating an existing user.
 24        /// </summary>
 25        UpdateUser
 26    };
 27
 28    /// <summary>
 29    /// A user for a specific Azure Batch compute node.
 30    /// </summary>
 31    public partial class ComputeNodeUser
 32    {
 10133        /// <summary>
 34        /// Begins an asynchronous call to create or update a user account on the compute node.
 10135        /// </summary>
 10136        /// <param name="addOrUpdate">Selects the type of commit operation to perform.</param>
 10137        /// <param name="additionalBehaviors">A collection of BatchClientBehavior instances that are applied after the C
 10138        /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch
 10139        /// <returns>A <see cref="System.Threading.Tasks.Task"/> object that represents the asynchronous operation.</ret
 10140        public Task CommitAsync(
 41            ComputeNodeUserCommitSemantics addOrUpdate = ComputeNodeUserCommitSemantics.AddUser,
 42            IEnumerable<BatchClientBehavior> additionalBehaviors = null,
 43            CancellationToken cancellationToken = default(CancellationToken))
 44        {
 45            // create the behavior managaer
 046            BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors);
 47            Task asyncTask;
 48
 049            if (ComputeNodeUserCommitSemantics.AddUser == addOrUpdate)
 50            {
 051                Models.ComputeNodeUser protoUser = new Models.ComputeNodeUser()
 052                        {
 053                            Name = this.Name,
 054                            Password = this.Password,
 055                        };
 056                protoUser.ExpiryTime = this.ExpiryTime;
 057                protoUser.IsAdmin = this.IsAdmin;
 058                protoUser.SshPublicKey = this.SshPublicKey;
 59
 60                // begin the adduser call
 061                asyncTask = this.parentBatchClient.ProtocolLayer.AddComputeNodeUser(this.parentPoolId, this.parentNodeId
 062            }
 63            else
 64            {
 65                // begin the update call
 066                asyncTask = this.parentBatchClient.ProtocolLayer.UpdateComputeNodeUser(
 067                    this.parentPoolId,
 068                    this.parentNodeId,
 069                    this.Name,
 070                    this.Password,
 071                    this.ExpiryTime,
 072                    this.SshPublicKey,
 073                    bhMgr,
 074                    cancellationToken);
 10175            }
 10176
 10177            return asyncTask;
 10178        }
 10179
 80        /// <summary>
 10181        /// Blocking call to create or update a user account on the compute node.
 10182        /// </summary>
 10183        /// <param name="addOrUpdate">Selects the type of commit operation to perform.</param>
 10184        /// <param name="additionalBehaviors">A collection of BatchClientBehavior instances that are applied after the C
 10185        public void Commit(ComputeNodeUserCommitSemantics addOrUpdate = ComputeNodeUserCommitSemantics.AddUser, IEnumera
 10186        {
 087            Task asyncTask = CommitAsync(addOrUpdate, additionalBehaviors);
 088            asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors);
 089        }
 90
 91        /// <summary>
 92        /// Begins an asyncrhonous call to delete the current user from the compute node.
 93        /// </summary>
 94        /// <param name="additionalBehaviors">A collection of BatchClientBehavior instances that are applied after the C
 95        /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch
 96        /// <returns>A <see cref="System.Threading.Tasks.Task"/> object that represents the asynchronous operation.</ret
 97        public Task DeleteAsync(IEnumerable<BatchClientBehavior> additionalBehaviors = null, CancellationToken cancellat
 98        {
 99            // create the behavior managaer
 0100            BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors);
 0101
 0102            Task asyncTask = this.parentBatchClient.ProtocolLayer.DeleteComputeNodeUser(this.parentPoolId, this.parentNo
 103
 0104            return asyncTask;
 105        }
 106
 107        /// <summary>
 108        /// call to delete the current user from the compute node.
 109        /// </summary>
 110        /// <param name="additionalBehaviors">A collection of BatchClientBehavior instances that are applied after the C
 111        public void Delete(IEnumerable<BatchClientBehavior> additionalBehaviors = null)
 201112        {
 107113            Task asyncTask = DeleteAsync(additionalBehaviors);
 0114            asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors);
 0115        }
 116    }
 117}

C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\Generated\ComputeNodeUser.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License. See License.txt in the project root for license information.
 3//
 4// Code generated by Microsoft (R) AutoRest Code Generator.
 5// Changes may cause incorrect behavior and will be lost if the code is
 6// regenerated.
 7
 8//
 9// This file was autogenerated by a tool.
 10// Do not modify it.
 11//
 12
 13namespace Microsoft.Azure.Batch
 14{
 15    using Models = Microsoft.Azure.Batch.Protocol.Models;
 16    using System;
 17    using System.Collections.Generic;
 18    using System.Linq;
 19
 20    /// <summary>
 21    /// A user account for remote access to a compute node.
 22    /// </summary>
 23    public partial class ComputeNodeUser : ITransportObjectProvider<Models.ComputeNodeUser>, IInheritedBehaviors, IPrope
 24    {
 25        private class PropertyContainer : PropertyCollection
 26        {
 27            public readonly PropertyAccessor<DateTime> ExpiryTimeProperty;
 28            public readonly PropertyAccessor<bool?> IsAdminProperty;
 29            public readonly PropertyAccessor<string> NameProperty;
 30            public readonly PropertyAccessor<string> PasswordProperty;
 31            public readonly PropertyAccessor<string> SshPublicKeyProperty;
 32
 033            public PropertyContainer() : base(BindingState.Unbound)
 34            {
 035                this.ExpiryTimeProperty = this.CreatePropertyAccessor<DateTime>(nameof(ExpiryTime), BindingAccess.Read |
 036                this.IsAdminProperty = this.CreatePropertyAccessor<bool?>(nameof(IsAdmin), BindingAccess.Read | BindingA
 037                this.NameProperty = this.CreatePropertyAccessor<string>(nameof(Name), BindingAccess.Read | BindingAccess
 038                this.PasswordProperty = this.CreatePropertyAccessor<string>(nameof(Password), BindingAccess.Read | Bindi
 039                this.SshPublicKeyProperty = this.CreatePropertyAccessor<string>(nameof(SshPublicKey), BindingAccess.Read
 040            }
 41
 42        }
 43
 44        private PropertyContainer propertyContainer;
 45
 46        private readonly BatchClient parentBatchClient;
 47        private readonly string parentPoolId;
 48
 49        internal string ParentPoolId
 50        {
 51            get
 52            {
 053                return this.parentPoolId;
 54            }
 55        }
 56        private readonly string parentNodeId;
 57
 58        internal string ParentNodeId
 59        {
 60            get
 61            {
 062                return this.parentNodeId;
 63            }
 64        }
 65
 66        #region Constructors
 67
 68        /// <summary>
 69        /// Initializes a new instance of the <see cref="ComputeNodeUser"/> class.
 70        /// </summary>
 71        /// <param name='parentBatchClient'>The parent <see cref="BatchClient"/> to use.</param>
 72        /// <param name='baseBehaviors'>The base behaviors to use.</param>
 73        /// <param name='parentPoolId'>The parentPoolId.</param>
 74        /// <param name='parentNodeId'>The parentNodeId.</param>
 075        internal ComputeNodeUser(
 076            BatchClient parentBatchClient,
 077            IEnumerable<BatchClientBehavior> baseBehaviors,
 078            string parentPoolId,
 079            string parentNodeId)
 80        {
 081            this.propertyContainer = new PropertyContainer();
 082            this.parentBatchClient = parentBatchClient;
 083            this.parentPoolId = parentPoolId;
 084            this.parentNodeId = parentNodeId;
 085            InheritUtil.InheritClientBehaviorsAndSetPublicProperty(this, baseBehaviors);
 086        }
 87
 88
 89        #endregion Constructors
 90
 91        #region IInheritedBehaviors
 92
 93        /// <summary>
 94        /// Gets or sets a list of behaviors that modify or customize requests to the Batch service
 95        /// made via this <see cref="ComputeNodeUser"/>.
 96        /// </summary>
 97        /// <remarks>
 98        /// <para>These behaviors are inherited by child objects.</para>
 99        /// <para>Modifications are applied in the order of the collection. The last write wins.</para>
 100        /// </remarks>
 0101        public IList<BatchClientBehavior> CustomBehaviors { get; set; }
 102
 103        #endregion IInheritedBehaviors
 104
 105        #region ComputeNodeUser
 106
 107        /// <summary>
 108        /// Gets or sets the expiry time.
 109        /// </summary>
 110        public DateTime ExpiryTime
 111        {
 0112            get { return this.propertyContainer.ExpiryTimeProperty.Value; }
 0113            set { this.propertyContainer.ExpiryTimeProperty.Value = value; }
 114        }
 115
 116        /// <summary>
 117        /// Gets or sets the administrative privilege level of the user account. The value of this property is ignored w
 118        /// UpdateUser is specified for the commit operation.
 119        /// </summary>
 120        public bool? IsAdmin
 121        {
 0122            get { return this.propertyContainer.IsAdminProperty.Value; }
 0123            set { this.propertyContainer.IsAdminProperty.Value = value; }
 124        }
 125
 126        /// <summary>
 127        /// Gets or sets the name. If AddUser is specified for the commit operation, the value of this property is the n
 128        /// of the local Windows account created. If UpdateUser is specified for the commit operation, the value of this
 129        /// property selects the local Windows account to modify. Changing this property does not rename the local Windo
 130        /// account on the compute node.
 131        /// </summary>
 132        public string Name
 133        {
 0134            get { return this.propertyContainer.NameProperty.Value; }
 0135            set { this.propertyContainer.NameProperty.Value = value; }
 136        }
 137
 138        /// <summary>
 139        /// Gets or sets the password.
 140        /// </summary>
 141        public string Password
 142        {
 0143            get { return this.propertyContainer.PasswordProperty.Value; }
 0144            set { this.propertyContainer.PasswordProperty.Value = value; }
 145        }
 146
 147        /// <summary>
 148        /// Gets or sets the SSH public key that can be used for remote login to the compute node.
 149        /// </summary>
 150        /// <remarks>
 151        /// <para>The public key should be compatible with Open SSH encoding and should be base 64 encoded. This propert
 152        /// can be specified only for Linux nodes. The Batch service will return an error if this property is set for po
 153        /// created with <see cref="Microsoft.Azure.Batch.CloudServiceConfiguration"/> or <see cref="Microsoft.Azure.Bat
 154        /// with Windows compute nodes.</para>
 155        /// </remarks>
 156        public string SshPublicKey
 157        {
 0158            get { return this.propertyContainer.SshPublicKeyProperty.Value; }
 0159            set { this.propertyContainer.SshPublicKeyProperty.Value = value; }
 160        }
 161
 162        #endregion // ComputeNodeUser
 163
 164        #region IPropertyMetadata
 165
 166        bool IModifiable.HasBeenModified
 167        {
 0168            get { return this.propertyContainer.HasBeenModified; }
 169        }
 170
 171        bool IReadOnly.IsReadOnly
 172        {
 0173            get { return this.propertyContainer.IsReadOnly; }
 0174            set { this.propertyContainer.IsReadOnly = value; }
 175        }
 176
 177        #endregion //IPropertyMetadata
 178
 179        #region Internal/private methods
 180        /// <summary>
 181        /// Return a protocol object of the requested type.
 182        /// </summary>
 183        /// <returns>The protocol object of the requested type.</returns>
 184        Models.ComputeNodeUser ITransportObjectProvider<Models.ComputeNodeUser>.GetTransportObject()
 185        {
 0186            Models.ComputeNodeUser result = new Models.ComputeNodeUser()
 0187            {
 0188                ExpiryTime = this.ExpiryTime,
 0189                IsAdmin = this.IsAdmin,
 0190                Name = this.Name,
 0191                Password = this.Password,
 0192                SshPublicKey = this.SshPublicKey,
 0193            };
 194
 0195            return result;
 196        }
 197
 198
 199        #endregion // Internal/private methods
 200    }
 201}