public async virtual Task <ManagementLockCreateOrUpdateOperation> CreateOrUpdateAsync(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 = await _managementLockRestClient.CreateOrUpdateByScopeAsync(Id, lockName, parameters, cancellationToken).ConfigureAwait(false); var operation = new ManagementLockCreateOrUpdateOperation(ArmClient, response); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual async Task <ArmOperation <ManagementLockResource> > UpdateAsync(WaitUntil waitUntil, ManagementLockData data, CancellationToken cancellationToken = default) { Argument.AssertNotNull(data, nameof(data)); using var scope = _managementLockClientDiagnostics.CreateScope("ManagementLockResource.Update"); scope.Start(); try { var response = await _managementLockRestClient.CreateOrUpdateByScopeAsync(Id.Parent, Id.Name, data, cancellationToken).ConfigureAwait(false); var operation = new ResourcesArmOperation <ManagementLockResource>(Response.FromValue(new ManagementLockResource(Client, response), response.GetRawResponse())); if (waitUntil == WaitUntil.Completed) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual async Task <ArmOperation <ManagementLock> > CreateOrUpdateAsync(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 = await _managementLockRestClient.CreateOrUpdateByScopeAsync(Id, lockName, parameters, cancellationToken).ConfigureAwait(false); var operation = new ResourcesArmOperation <ManagementLock>(Response.FromValue(new ManagementLock(Client, response), response.GetRawResponse())); if (waitUntil == WaitUntil.Completed) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }