public virtual ManagementLockCreateOrUpdateOperation CreateOrUpdate(bool waitForCompletion, string lockName, ManagementLockData parameters, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(lockName, nameof(lockName));
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            using var scope = _managementLockClientDiagnostics.CreateScope("ManagementLockCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _managementLockRestClient.CreateOrUpdateByScope(Id, lockName, parameters, cancellationToken);
                var operation = new ManagementLockCreateOrUpdateOperation(ArmClient, response);
                if (waitForCompletion)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
        public virtual ArmOperation <ManagementLockResource> Update(WaitUntil waitUntil, ManagementLockData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _managementLockClientDiagnostics.CreateScope("ManagementLockResource.Update");
            scope.Start();
            try
            {
                var response  = _managementLockRestClient.CreateOrUpdateByScope(Id.Parent, Id.Name, data, cancellationToken);
                var operation = new ResourcesArmOperation <ManagementLockResource>(Response.FromValue(new ManagementLockResource(Client, response), response.GetRawResponse()));
                if (waitUntil == WaitUntil.Completed)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
예제 #3
0
        public virtual ArmOperation <ManagementLock> CreateOrUpdate(WaitUntil waitUntil, string lockName, ManagementLockData parameters, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(lockName, nameof(lockName));
            Argument.AssertNotNull(parameters, nameof(parameters));

            using var scope = _managementLockClientDiagnostics.CreateScope("ManagementLockCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _managementLockRestClient.CreateOrUpdateByScope(Id, lockName, parameters, cancellationToken);
                var operation = new ResourcesArmOperation <ManagementLock>(Response.FromValue(new ManagementLock(Client, response), response.GetRawResponse()));
                if (waitUntil == WaitUntil.Completed)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }