public async virtual Task <Response <VirtualCluster> > GetAsync(string virtualClusterName, CancellationToken cancellationToken = default)
        {
            if (virtualClusterName == null)
            {
                throw new ArgumentNullException(nameof(virtualClusterName));
            }

            using var scope = _clientDiagnostics.CreateScope("VirtualClusterCollection.Get");
            scope.Start();
            try
            {
                var response = await _virtualClustersRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, virtualClusterName, cancellationToken).ConfigureAwait(false);

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

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