public virtual async Task <ArmOperation <ServiceBusNamespace> > CreateOrUpdateAsync(WaitUntil waitUntil, string namespaceName, ServiceBusNamespaceData parameters, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); Argument.AssertNotNull(parameters, nameof(parameters)); using var scope = _serviceBusNamespaceNamespacesClientDiagnostics.CreateScope("ServiceBusNamespaceCollection.CreateOrUpdate"); scope.Start(); try { var response = await _serviceBusNamespaceNamespacesRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, namespaceName, parameters, cancellationToken).ConfigureAwait(false); var operation = new ServiceBusArmOperation <ServiceBusNamespace>(new ServiceBusNamespaceOperationSource(Client), _serviceBusNamespaceNamespacesClientDiagnostics, Pipeline, _serviceBusNamespaceNamespacesRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, namespaceName, parameters).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual NamespaceCreateOrUpdateOperation CreateOrUpdate(string namespaceName, ServiceBusNamespaceData parameters, bool waitForCompletion = true, CancellationToken cancellationToken = default) { if (namespaceName == null) { throw new ArgumentNullException(nameof(namespaceName)); } if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var scope = _clientDiagnostics.CreateScope("ServiceBusNamespaceCollection.CreateOrUpdate"); scope.Start(); try { var response = _namespacesRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, namespaceName, parameters, cancellationToken); var operation = new NamespaceCreateOrUpdateOperation(Parent, _clientDiagnostics, Pipeline, _namespacesRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, namespaceName, parameters).Request, response); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }