コード例 #1
0
        public virtual async Task <ArmOperation <IscsiTargetResource> > UpdateAsync(WaitUntil waitUntil, IscsiTargetPatch patch, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(patch, nameof(patch));

            using var scope = _iscsiTargetClientDiagnostics.CreateScope("IscsiTargetResource.Update");
            scope.Start();
            try
            {
                var response = await _iscsiTargetRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch, cancellationToken).ConfigureAwait(false);

                var operation = new StoragePoolArmOperation <IscsiTargetResource>(new IscsiTargetOperationSource(Client), _iscsiTargetClientDiagnostics, Pipeline, _iscsiTargetRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch).Request, response, OperationFinalStateVia.AzureAsyncOperation);
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
コード例 #2
0
        public async virtual Task<IscsiTargetUpdateOperation> UpdateAsync(bool waitForCompletion, IscsiTargetUpdate iscsiTargetUpdatePayload, CancellationToken cancellationToken = default)
        {
            if (iscsiTargetUpdatePayload == null)
            {
                throw new ArgumentNullException(nameof(iscsiTargetUpdatePayload));
            }

            using var scope = _iscsiTargetClientDiagnostics.CreateScope("IscsiTarget.Update");
            scope.Start();
            try
            {
                var response = await _iscsiTargetRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, iscsiTargetUpdatePayload, cancellationToken).ConfigureAwait(false);
                var operation = new IscsiTargetUpdateOperation(ArmClient, _iscsiTargetClientDiagnostics, Pipeline, _iscsiTargetRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, iscsiTargetUpdatePayload).Request, response);
                if (waitForCompletion)
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                return operation;
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }