public virtual async Task <ArmOperation <WebPubSubHubResource> > CreateOrUpdateAsync(WaitUntil waitUntil, string hubName, WebPubSubHubData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(hubName, nameof(hubName));
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _webPubSubHubClientDiagnostics.CreateScope("WebPubSubHubCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _webPubSubHubRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, hubName, data, cancellationToken).ConfigureAwait(false);

                var operation = new WebPubSubArmOperation <WebPubSubHubResource>(new WebPubSubHubOperationSource(Client), _webPubSubHubClientDiagnostics, Pipeline, _webPubSubHubRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, hubName, data).Request, response, OperationFinalStateVia.Location);
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Пример #2
0
        public virtual WebPubSubHubCreateOrUpdateOperation CreateOrUpdate(string hubName, WebPubSubHubData parameters, bool waitForCompletion = true, CancellationToken cancellationToken = default)
        {
            if (hubName == null)
            {
                throw new ArgumentNullException(nameof(hubName));
            }
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            using var scope = _clientDiagnostics.CreateScope("WebPubSubHubCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _webPubSubHubsRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, hubName, parameters, cancellationToken);
                var operation = new WebPubSubHubCreateOrUpdateOperation(Parent, _clientDiagnostics, Pipeline, _webPubSubHubsRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, hubName, parameters).Request, response);
                if (waitForCompletion)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }