public virtual SyncGroupCreateOrUpdateOperation CreateOrUpdate(bool waitForCompletion, string syncGroupName, SyncGroupData parameters, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(syncGroupName, nameof(syncGroupName)); if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var scope = _syncGroupClientDiagnostics.CreateScope("SyncGroupCollection.CreateOrUpdate"); scope.Start(); try { var response = _syncGroupRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, syncGroupName, parameters, cancellationToken); var operation = new SyncGroupCreateOrUpdateOperation(ArmClient, _syncGroupClientDiagnostics, Pipeline, _syncGroupRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, syncGroupName, parameters).Request, response); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public async virtual Task <SyncGroupCreateOrUpdateOperation> CreateOrUpdateAsync(string syncGroupName, SyncGroupData parameters, bool waitForCompletion = true, CancellationToken cancellationToken = default) { if (syncGroupName == null) { throw new ArgumentNullException(nameof(syncGroupName)); } if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var scope = _clientDiagnostics.CreateScope("SyncGroupCollection.CreateOrUpdate"); scope.Start(); try { var response = await _syncGroupsRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, syncGroupName, parameters, cancellationToken).ConfigureAwait(false); var operation = new SyncGroupCreateOrUpdateOperation(Parent, _clientDiagnostics, Pipeline, _syncGroupsRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, syncGroupName, parameters).Request, response); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }