public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();
            ExecuteClientAction(() =>
            {
                string resourceGroupName;
                string sshKeyName;
                string publicKey = this.PublicKey;

                switch (this.ParameterSetName)
                {
                case ResourceIDParameterSet:
                    resourceGroupName = GetResourceGroupName(this.ResourceId);
                    sshKeyName        = GetResourceName(this.ResourceId, "Microsoft.Compute/SshPublicKeys");
                    break;

                case InputObjectParameterSet:
                    resourceGroupName = GetResourceGroupName(this.InputObject.Id);
                    sshKeyName        = GetResourceName(this.InputObject.Id, "Microsoft.Compute/SshPublicKeys");
                    break;

                default:
                    resourceGroupName = this.ResourceGroupName;
                    sshKeyName        = this.Name;
                    break;
                }

                SshPublicKeyUpdateResource sshkeyUpdateResource = new SshPublicKeyUpdateResource();
                sshkeyUpdateResource.PublicKey = publicKey;
                var result   = SshPublicKeyClient.Update(resourceGroupName, sshKeyName, sshkeyUpdateResource);
                var psObject = new PSSshPublicKeyResource();
                ComputeAutomationAutoMapperProfile.Mapper.Map <SshPublicKeyResource, PSSshPublicKeyResource>(result, psObject);
                WriteObject(psObject);
            });
        }
        public virtual Response <SshPublicKey> Update(SshPublicKeyUpdateResource parameters, CancellationToken cancellationToken = default)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            using var scope = _sshPublicKeyClientDiagnostics.CreateScope("SshPublicKey.Update");
            scope.Start();
            try
            {
                var response = _sshPublicKeyRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, parameters, cancellationToken);
                return(Response.FromValue(new SshPublicKey(Client, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Esempio n. 3
0
        public virtual async Task <Response <SshPublicKey> > UpdateAsync(SshPublicKeyUpdateResource parameters, CancellationToken cancellationToken = default)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            using var scope = _clientDiagnostics.CreateScope("SshPublicKey.Update");
            scope.Start();
            try
            {
                var response = await _restClient.UpdateAsync(Id.ResourceGroupName, Id.Name, parameters, cancellationToken).ConfigureAwait(false);

                return(Response.FromValue(new SshPublicKey(this, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Esempio n. 4
0
 public virtual async Task <Response <SshPublicKeyResource> > UpdateAsync(string resourceGroupName, string sshPublicKeyName, SshPublicKeyUpdateResource parameters, CancellationToken cancellationToken = default)
 {
     using var scope = _clientDiagnostics.CreateScope("SshPublicKeysOperations.Update");
     scope.Start();
     try
     {
         return(await RestClient.UpdateAsync(resourceGroupName, sshPublicKeyName, parameters, cancellationToken).ConfigureAwait(false));
     }
     catch (Exception e)
     {
         scope.Failed(e);
         throw;
     }
 }
 /// <summary>
 /// Updates a new SSH public key resource.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group.
 /// </param>
 /// <param name='sshPublicKeyName'>
 /// The name of the SSH public key.
 /// </param>
 /// <param name='parameters'>
 /// Parameters supplied to update the SSH public key.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <SshPublicKeyResourceInner> UpdateAsync(this ISshPublicKeysOperations operations, string resourceGroupName, string sshPublicKeyName, SshPublicKeyUpdateResource parameters, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, sshPublicKeyName, parameters, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 public virtual Response <SshPublicKeyResource> Update(string resourceGroupName, string sshPublicKeyName, SshPublicKeyUpdateResource parameters, CancellationToken cancellationToken = default)
 {
     using var scope = _clientDiagnostics.CreateScope("SshPublicKeysClient.Update");
     scope.Start();
     try
     {
         return(RestClient.Update(resourceGroupName, sshPublicKeyName, parameters, cancellationToken));
     }
     catch (Exception e)
     {
         scope.Failed(e);
         throw;
     }
 }
 /// <summary>
 /// Updates a new SSH public key resource.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group.
 /// </param>
 /// <param name='sshPublicKeyName'>
 /// The name of the SSH public key.
 /// </param>
 /// <param name='parameters'>
 /// Parameters supplied to update the SSH public key.
 /// </param>
 public static SshPublicKeyResource Update(this ISshPublicKeysOperations operations, string resourceGroupName, string sshPublicKeyName, SshPublicKeyUpdateResource parameters)
 {
     return(operations.UpdateAsync(resourceGroupName, sshPublicKeyName, parameters).GetAwaiter().GetResult());
 }