Exemple #1
0
        public async virtual Task <Response <WebPubSubHub> > GetAsync(string hubName, CancellationToken cancellationToken = default)
        {
            if (hubName == null)
            {
                throw new ArgumentNullException(nameof(hubName));
            }

            using var scope = _clientDiagnostics.CreateScope("WebPubSubHubCollection.Get");
            scope.Start();
            try
            {
                var response = await _webPubSubHubsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, hubName, cancellationToken).ConfigureAwait(false);

                if (response.Value == null)
                {
                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
                }
                return(Response.FromValue(new WebPubSubHub(Parent, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Exemple #2
0
        public virtual async Task <Response <WebPubSubHubResource> > GetAsync(CancellationToken cancellationToken = default)
        {
            using var scope = _webPubSubHubClientDiagnostics.CreateScope("WebPubSubHubResource.Get");
            scope.Start();
            try
            {
                var response = await _webPubSubHubRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false);

                if (response.Value == null)
                {
                    throw new RequestFailedException(response.GetRawResponse());
                }
                return(Response.FromValue(new WebPubSubHubResource(Client, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }