Esempio n. 1
0
        public async virtual Task <GalleryImageUpdateOperation> UpdateAsync(GalleryImageUpdate galleryImage, bool waitForCompletion = true, CancellationToken cancellationToken = default)
        {
            if (galleryImage == null)
            {
                throw new ArgumentNullException(nameof(galleryImage));
            }

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

                var operation = new GalleryImageUpdateOperation(this, _clientDiagnostics, Pipeline, _restClient.CreateUpdateRequest(Id.ResourceGroupName, Id.Parent.Name, Id.Name, galleryImage).Request, response);
                if (waitForCompletion)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Esempio n. 2
0
        public async virtual Task <ArmOperation <GalleryImage> > UpdateAsync(bool waitForCompletion, GalleryImageUpdate galleryImage, CancellationToken cancellationToken = default)
        {
            if (galleryImage == null)
            {
                throw new ArgumentNullException(nameof(galleryImage));
            }

            using var scope = _galleryImageClientDiagnostics.CreateScope("GalleryImage.Update");
            scope.Start();
            try
            {
                var response = await _galleryImageRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, galleryImage, cancellationToken).ConfigureAwait(false);

                var operation = new ComputeArmOperation <GalleryImage>(new GalleryImageOperationSource(Client), _galleryImageClientDiagnostics, Pipeline, _galleryImageRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, galleryImage).Request, response, OperationFinalStateVia.Location);
                if (waitForCompletion)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
        public virtual async Task <ArmOperation <GalleryImageResource> > UpdateAsync(WaitUntil waitUntil, PatchableGalleryImageData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _galleryImageClientDiagnostics.CreateScope("GalleryImageResource.Update");
            scope.Start();
            try
            {
                var response = await _galleryImageRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false);

                var operation = new ComputeArmOperation <GalleryImageResource>(new GalleryImageOperationSource(Client), _galleryImageClientDiagnostics, Pipeline, _galleryImageRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data).Request, response, OperationFinalStateVia.Location);
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }