Exemplo n.º 1
0
        public async virtual Task <DiskUpdateOperation> UpdateAsync(DiskUpdate disk, bool waitForCompletion = true, CancellationToken cancellationToken = default)
        {
            if (disk == null)
            {
                throw new ArgumentNullException(nameof(disk));
            }

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

                var operation = new DiskUpdateOperation(this, _clientDiagnostics, Pipeline, _restClient.CreateUpdateRequest(Id.ResourceGroupName, Id.Name, disk).Request, response);
                if (waitForCompletion)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Exemplo n.º 2
0
        public virtual async Task <ArmOperation <ManagedDiskResource> > UpdateAsync(WaitUntil waitUntil, ManagedDiskPatch patch, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(patch, nameof(patch));

            using var scope = _managedDiskDisksClientDiagnostics.CreateScope("ManagedDiskResource.Update");
            scope.Start();
            try
            {
                var response = await _managedDiskDisksRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken).ConfigureAwait(false);

                var operation = new ComputeArmOperation <ManagedDiskResource>(new ManagedDiskOperationSource(Client), _managedDiskDisksClientDiagnostics, Pipeline, _managedDiskDisksRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch).Request, response, OperationFinalStateVia.Location);
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Exemplo n.º 3
0
        public async virtual Task <ArmOperation <Disk> > UpdateAsync(bool waitForCompletion, DiskUpdateOptions options, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(options, nameof(options));

            using var scope = _diskClientDiagnostics.CreateScope("Disk.Update");
            scope.Start();
            try
            {
                var response = await _diskRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, options, cancellationToken).ConfigureAwait(false);

                var operation = new ComputeArmOperation <Disk>(new DiskOperationSource(Client), _diskClientDiagnostics, Pipeline, _diskRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, options).Request, response, OperationFinalStateVia.Location);
                if (waitForCompletion)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }